PageFour.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. <template>
  2. <view class="page-four-container">
  3. <!-- 入库信息卡片 -->
  4. <view class="card-wrap">
  5. <u--form labelPosition="top" :model="warehouseInfo" ref="form" :rules="rules" class="address-section">
  6. <view class="address-header">
  7. <u-icon name="car-fill" size="36rpx" color="#108cff" class="location-icon" />
  8. <text class="address-title">入库信息</text>
  9. </view>
  10. <!-- 编码、快递单号、物流图片 -->
  11. <!-- 收单物品、收单类型 -->
  12. <u-row class="info-row" justify="space-between">
  13. <u-col span="5.8">
  14. <u-form-item label="收单物品" prop="item">
  15. <u--input v-model="warehouseInfo.item" placeholder="请输入收单物品" class="info-input"
  16. @blur="saveWarehouseInfoOnBlur" />
  17. </u-form-item>
  18. </u-col>
  19. <u-col span="5.8">
  20. <view @tap="selectCustomerServiceName">
  21. <u-form-item label="收单类型" prop="customerServiceNameLabel">
  22. <view class="click-wrapper info-input">
  23. {{ warehouseInfo.customerServiceNameLabel || '点击选择收单类型' }}
  24. </view>
  25. </u-form-item>
  26. <u-picker :show="showCustomerServicePicker" :columns="customerServiceColumns" confirm keyName="label"
  27. @confirm="handleConfirmCustomerService" @cancel="showCustomerServicePicker = false" />
  28. </view>
  29. </u-col>
  30. </u-row>
  31. <!-- 类别、是否需要查码 -->
  32. <u-row class="info-row" justify="space-between">
  33. <u-col span="5.8">
  34. <view @tap="selectCategory">
  35. <u-form-item label="类别" prop="category">
  36. <view class="click-wrapper info-input">
  37. {{ warehouseInfo.categoryLabel || '点击选择类别' }}
  38. </view>
  39. </u-form-item>
  40. <u-picker :show="showCategoryPicker" :columns="categoryColumns" confirm keyName="label"
  41. @confirm="handleConfirmCategory" @cancel="showCategoryPicker = false" />
  42. </view>
  43. </u-col>
  44. <u-col span="5.8">
  45. <view @tap="selectNeedCheckCode">
  46. <u-form-item label="是否需要查码" prop="needCheckCode">
  47. <view class="click-wrapper info-input">
  48. {{ warehouseInfo.needCheckCodeLabel || '点击选择是否需要查码' }}
  49. </view>
  50. </u-form-item>
  51. <u-picker :show="showNeedCheckCodePicker" :columns="needCheckCodeColumns" confirm keyName="label"
  52. @confirm="handleConfirmNeedCheckCode" @cancel="showNeedCheckCodePicker = false" />
  53. </view>
  54. </u-col>
  55. </u-row>
  56. <u-row class="info-row" justify="space-between">
  57. <u-col span="4.5">
  58. <u-form-item label="编码" prop="codeStorage">
  59. <u--input v-model="warehouseInfo.codeStorage" placeholder="请输入编码" class="info-input"
  60. :disabled="warehouseInfo.needCheckCode === '2'" @blur="saveWarehouseInfoOnBlur" />
  61. </u-form-item>
  62. </u-col>
  63. <u-col span="4.5">
  64. <u-form-item label="快递单号" prop="expressOrderNo">
  65. <u--input v-model="warehouseInfo.expressOrderNo" placeholder="请输入快递单号" class="info-input"
  66. @blur="saveWarehouseInfoOnBlur" />
  67. </u-form-item>
  68. </u-col>
  69. <u-col span="2">
  70. <u-form-item label="物流图片" prop="uploadedImage">
  71. <view class="image-uploader" @click="selectImage">
  72. <u-icon v-if="!warehouseInfo.uploadedImage" name="camera-fill" size="48rpx" color="#909399"
  73. class="camera-icon" />
  74. <image v-else :src="warehouseInfo.uploadedImage" mode="aspectFill" class="image-preview" />
  75. </view>
  76. </u-form-item>
  77. </u-col>
  78. </u-row>
  79. <!-- 表款、查码费 -->
  80. <u-row class="info-row" justify="space-between">
  81. <u-col span="5.8">
  82. <u-form-item label="表款">
  83. <u--input v-model="warehouseInfo.watchPrice" placeholder="请输入表款" class="info-input" type="number"
  84. @blur="saveWarehouseInfoOnBlur" />
  85. </u-form-item>
  86. </u-col>
  87. <u-col span="5.8">
  88. <u-form-item label="查码费">
  89. <u--input v-model="warehouseInfo.checkCodeFee" placeholder="请输入查码费" class="info-input" type="number"
  90. :disabled="warehouseInfo.needCheckCode === '2'" @blur="saveWarehouseInfoOnBlur" />
  91. </u-form-item>
  92. </u-col>
  93. </u-row>
  94. <!-- 好处费、运费 -->
  95. <u-row class="info-row" justify="space-between">
  96. <u-col span="5.8">
  97. <u-form-item label="好处费">
  98. <u--input v-model="warehouseInfo.benefitFee" placeholder="请输入好处费" class="info-input" type="number" />
  99. </u-form-item>
  100. </u-col>
  101. <u-col span="5.8">
  102. <u-form-item label="运费">
  103. <u--input v-model="warehouseInfo.freight" placeholder="请输入运费" class="info-input" type="number" />
  104. </u-form-item>
  105. </u-col>
  106. </u-row>
  107. <!-- 维修金额、分单比例 -->
  108. <u-row class="info-row" justify="space-between">
  109. <u-col span="5.8">
  110. <u-form-item label="维修金额">
  111. <u--input v-model="warehouseInfo.repairAmount" placeholder="请输入维修金额" class="info-input" type="number"
  112. @blur="saveWarehouseInfoOnBlur" />
  113. </u-form-item>
  114. </u-col>
  115. <u-col span="5.8">
  116. <u-form-item label="分单比例(0~100)">
  117. <u--input v-model="warehouseInfo.splitRatio" placeholder="请输入分单比例(0~100)" class="info-input"
  118. type="number" @blur="saveWarehouseInfoOnBlur" />
  119. </u-form-item>
  120. </u-col>
  121. </u-row>
  122. <u-row class="info-row" justify="space-between">
  123. <u-col span="5.8">
  124. <u-form-item label="型号" required prop="model">
  125. <u--input v-model="warehouseInfo.model" placeholder="请输入型号" class="info-input"
  126. @blur="saveWarehouseInfoOnBlur" />
  127. </u-form-item>
  128. </u-col>
  129. </u-row>
  130. <!-- 成本合计、业绩、毛业绩 -->
  131. <u-row class="info-row" justify="space-between">
  132. <u-col span="3.8">
  133. <u-form-item label="成本合计">
  134. <u--input :disabled="true" :value="computedTotalCost" placeholder="成本合计自动计算" class="info-input"
  135. type="number" />
  136. </u-form-item>
  137. </u-col>
  138. <u-col span="3.8">
  139. <u-form-item label="业绩">
  140. <u--input :disabled="true" :value="computedPerformance" placeholder="业绩自动计算" class="info-input"
  141. type="number" />
  142. </u-form-item>
  143. </u-col>
  144. <u-col span="3.8">
  145. <u-form-item label="毛业绩">
  146. <u--input :disabled="true" :value="computedGrossPerformance" placeholder="毛业绩自动计算" class="info-input"
  147. type="number" />
  148. </u-form-item>
  149. </u-col>
  150. </u-row>
  151. <!-- 是否入库 -->
  152. <!-- <u-row class="info-row">
  153. <u-col span="12">
  154. <view @tap="selectIsWarehouse">
  155. <u-form-item label="是否入库" prop="isWarehouse">
  156. <view class="click-wrapper info-input">
  157. {{ isWarehouseLabel || '点击选择是否入库' }}
  158. </view>
  159. </u-form-item>
  160. <u-picker :show="showIsWarehousePicker" :columns="isWarehouseColumns" confirm keyName="label"
  161. @confirm="handleConfirmIsWarehouse" @cancel="showIsWarehousePicker = false" />
  162. </view>
  163. </u-col>
  164. </u-row> -->
  165. <!-- 收单备注 -->
  166. <u-row class="info-row">
  167. <u-col span="12">
  168. <u-form-item label="收单备注">
  169. <u--textarea v-model="warehouseInfo.remarks" placeholder="请输入收单备注" class="info-textarea"
  170. confirmType="done" rows="4" @blur="saveWarehouseInfoOnBlur" />
  171. </u-form-item>
  172. </u-col>
  173. </u-row>
  174. </u--form>
  175. </view>
  176. <!-- 分成信息卡片 -->
  177. <view class="card-wrap">
  178. <view class="address-section">
  179. <view class="address-header add-button-container">
  180. <text class="address-title">分成信息</text>
  181. <view class="add-button" @click="addSplit">
  182. <u-icon name="plus" size="24rpx" color="#108cff" />
  183. <text>添加</text>
  184. </view>
  185. </view>
  186. <!-- 分成信息表格 -->
  187. <view class="split-table">
  188. <u-row class="split-table-header">
  189. <u-col span="4"><text class="header-text">关联</text></u-col>
  190. <u-col span="2"><text class="header-text">分成人</text></u-col>
  191. <u-col span="2"><text class="header-text">比例</text></u-col>
  192. <u-col span="1"><text class="header-text">类型</text></u-col>
  193. <u-col span="1"><text class="header-text">公司</text></u-col>
  194. <u-col span="2" class="action-column"><text class="header-text">操作</text></u-col>
  195. </u-row>
  196. <u-row v-for="(item, index) in profitSharingList" :key="item.uuid" class="split-table-row">
  197. <u-col span="4">
  198. <view class="table-cell">
  199. <u-button @click="handleSelectOrg(item)" :text="item.orgName || '选择组织'" plain />
  200. </view>
  201. </u-col>
  202. <u-col span="2">
  203. <view class="table-cell">
  204. <u-button @click="handleSelectPerson(item)" :text="item.userName || '选择人员'" plain />
  205. </view>
  206. </u-col>
  207. <u-col span="2">
  208. <view class="table-cell">
  209. <u--input v-model="item.commissionRate" type="number" class="percentage-input"
  210. @input="handlePercentageInput(item)" min="0" max="100" precision="0" />
  211. </view>
  212. </u-col>
  213. <u-col span="1">
  214. <view class="table-cell">
  215. <view :class="['account-type', item.accountType == '1' ? 'frontend' : 'backend']"
  216. @click="toggleAccountType(item)">
  217. {{ item.accountType == '1' ? '前' : '后' }}
  218. </view>
  219. </view>
  220. </u-col>
  221. <u-col span="1">
  222. <view class="table-cell">
  223. <view class="radio-wrapper" @click="toggleBelongToCompany(item)">
  224. <view :class="['radio-circle', item.isCompanyPerformance == '1' ? 'active' : '']">
  225. <u-icon v-if="item.isCompanyPerformance == '1'" name="checkmark" size="20rpx" color="#fff" />
  226. </view>
  227. </view>
  228. </view>
  229. </u-col>
  230. <u-col span="2" class="action-column">
  231. <view class="table-cell">
  232. <u-button type="error" plain shape="circle" size="mini" @click="deleteRow(item.id, item.uuid)"
  233. class="delete-btn">
  234. <u-icon name="trash" size="20rpx" color="#ff6b6b" />
  235. </u-button>
  236. </view>
  237. </u-col>
  238. </u-row>
  239. </view>
  240. </view>
  241. </view>
  242. <!-- 确认收单、确认入库按钮 -->
  243. <view class="confirm-button-container">
  244. <u-row gutter="24">
  245. <u-col span="6">
  246. <u-button class="next-btn" type="success" @click="confirmReceiveOrder">
  247. <u-icon name="checkmark-circle-fill" size="28rpx" color="#fff" />
  248. <text style="margin-left: 8rpx;">确认收单</text>
  249. </u-button>
  250. </u-col>
  251. <u-col span="6">
  252. <u-button class="next-btn" type="success" @click="confirmWarehouseEntry">
  253. <u-icon name="checkmark-circle-fill" size="28rpx" color="#fff" />
  254. <text style="margin-left: 8rpx;">确认入库</text>
  255. </u-button>
  256. </u-col>
  257. </u-row>
  258. </view>
  259. <!-- 组织选择器 -->
  260. <u-picker :show="showOrgPicker" title="请选择组织" :columns="columnsOrgList" keyName="label" @confirm="handleOrgConfirm"
  261. @cancel="showOrgPicker = false" />
  262. <!-- 人员选择器 -->
  263. <u-picker :show="showPersonPicker" title="请选择分成人" :columns="columnsPersonList" keyName="label"
  264. @confirm="handleConfirmPerson" @cancel="handleCancelPerson" />
  265. <u-toast ref="uToast" />
  266. </view>
  267. </template>
  268. <script>
  269. import imageUpload from '../utils/imageUpload.js'
  270. import dayjs from 'dayjs'
  271. export default {
  272. name: 'PageFour',
  273. props: {
  274. orderDetail: {
  275. type: Object,
  276. default: () => ({})
  277. },
  278. currentReceipt: {
  279. type: Object,
  280. default: () => ({})
  281. }
  282. },
  283. data() {
  284. return {
  285. warehouseInfo: {
  286. codeStorage: '',
  287. expressOrderNo: '',
  288. uploadedImage: '',
  289. item: '',
  290. checkCodeFee: '',
  291. watchPrice: '',
  292. benefitFee: '',
  293. freight: '',
  294. repairAmount: '',
  295. grossPerformance: '',
  296. performance: '',
  297. splitRatio: '',
  298. remarks: '',
  299. customerServiceNameLabel: '',
  300. customerServiceName: '',
  301. categoryLabel: '',
  302. category: '',
  303. needCheckCodeLabel: '',
  304. needCheckCode: ''
  305. },
  306. profitSharingList: [],
  307. showOrgPicker: false,
  308. showPersonPicker: false,
  309. columnsOrgList: [],
  310. columnsPersonList: [],
  311. showCustomerServicePicker: false,
  312. customerServiceColumns: [[
  313. { label: '收单类', value: '1' },
  314. { label: '维修类', value: '2' },
  315. { label: '销售类', value: '3' }
  316. ]],
  317. showCategoryPicker: false,
  318. categoryColumns: [[
  319. { label: '腕表', value: '1' },
  320. { label: '包包', value: '2' },
  321. { label: '首饰', value: '4' },
  322. { label: '其他', value: '3' }
  323. ]],
  324. showNeedCheckCodePicker: false,
  325. needCheckCodeColumns: [[
  326. { label: '是', value: '1' },
  327. { label: '否', value: '2' }
  328. ]],
  329. currentEditItem: '',
  330. isWarehouse: '2',
  331. isWarehouseLabel: '不入库',
  332. showIsWarehousePicker: false,
  333. isWarehouseColumns: [[
  334. { label: '确认入库', value: '1' },
  335. { label: '不入库', value: '2' }
  336. ]],
  337. brandList: [],
  338. rules: {
  339. model: [
  340. { required: true, message: '请输入型号', trigger: 'blur' }
  341. ]
  342. }
  343. }
  344. },
  345. computed: {
  346. computedTotalCost() {
  347. const freight = Number(this.warehouseInfo.freight) || 0
  348. const benefitFee = Number(this.warehouseInfo.benefitFee) || 0
  349. const checkCodeFee = Number(this.warehouseInfo.checkCodeFee) || 0
  350. const watchPrice = Number(this.warehouseInfo.watchPrice) || 0
  351. const repairAmount = Number(this.warehouseInfo.repairAmount) || 0
  352. return freight + benefitFee + checkCodeFee + watchPrice + repairAmount
  353. },
  354. computedPerformance() {
  355. const sellingPrice = Number(this.currentReceipt.sellingPrice) || 0
  356. return sellingPrice - this.computedTotalCost
  357. },
  358. computedGrossPerformance() {
  359. const performance = this.computedPerformance || 0
  360. const splitRatio = Number(this.warehouseInfo.splitRatio) / 100 || 0
  361. return (performance * splitRatio).toFixed(2)
  362. }
  363. },
  364. watch: {
  365. currentReceipt: {
  366. handler(newVal) {
  367. if (newVal) {
  368. this.initWarehouseInfo(newVal)
  369. this.loadShareList()
  370. }
  371. },
  372. immediate: true,
  373. deep: true
  374. }
  375. },
  376. mounted() {
  377. this.loadCommissionUserList()
  378. this.loadBrandList()
  379. },
  380. methods: {
  381. /**
  382. * 加载品牌列表
  383. */
  384. async loadBrandList() {
  385. try {
  386. const res = await this.$getDicts('crm_form_brand')
  387. this.brandList = res
  388. } catch (error) {
  389. console.error('加载品牌列表失败:', error)
  390. }
  391. },
  392. /**
  393. * 初始化入库信息
  394. */
  395. initWarehouseInfo(data) {
  396. const receiptRemark = data.receiptRemark || ''
  397. const remarkParts = receiptRemark.split(';')
  398. // 设置默认值:收单类型默认为"收单类",类别默认为"腕表",是否需要查码默认为"是"
  399. const defaultCustomerServiceName = data.customerServiceName || '1'
  400. const defaultCategory = data.category || '1'
  401. const defaultNeedCheckCode = data.needCheckCode || '1'
  402. this.warehouseInfo = {
  403. codeStorage: data.code || '',
  404. expressOrderNo: data.expressOrderNo || '',
  405. uploadedImage: remarkParts[1] || '',
  406. item: data.item || '',
  407. checkCodeFee: data.checkCodeFee || '',
  408. watchPrice: data.tableFee || '',
  409. benefitFee: data.benefitFee || '',
  410. freight: data.freight || '',
  411. repairAmount: data.repairAmount || '',
  412. grossPerformance: data.grossPerformance || '',
  413. performance: data.performance || '',
  414. splitRatio: data.splitRatio || '',
  415. remarks: remarkParts[0] || '',
  416. model: data.model || '',
  417. customerServiceName: defaultCustomerServiceName,
  418. customerServiceNameLabel: this.getLabelByValue(
  419. this.customerServiceColumns[0],
  420. defaultCustomerServiceName
  421. ),
  422. category: defaultCategory,
  423. categoryLabel: this.getLabelByValue(
  424. this.categoryColumns[0],
  425. defaultCategory
  426. ),
  427. needCheckCode: defaultNeedCheckCode,
  428. needCheckCodeLabel: this.getLabelByValue(
  429. this.needCheckCodeColumns[0],
  430. defaultNeedCheckCode
  431. )
  432. }
  433. },
  434. /**
  435. * 根据值获取标签
  436. */
  437. getLabelByValue(columns, value) {
  438. const item = columns.find(col => col.value == value)
  439. return item ? item.label : ''
  440. },
  441. /**
  442. * 入库信息失焦 / 物流图片变更后保存
  443. */
  444. async saveWarehouseInfoOnBlur() {
  445. if (!this.currentReceipt || !this.currentReceipt.id) return
  446. try {
  447. await uni.$u.api.updateReceiptForm({
  448. id: this.currentReceipt.id,
  449. code: this.warehouseInfo.codeStorage || '',
  450. expressOrderNo: this.warehouseInfo.expressOrderNo || '',
  451. item: this.warehouseInfo.item || '',
  452. checkCodeFee: this.warehouseInfo.checkCodeFee || '',
  453. tableFee: this.warehouseInfo.watchPrice || '',
  454. benefitFee: this.warehouseInfo.benefitFee || '',
  455. freight: this.warehouseInfo.freight || '',
  456. repairAmount: this.warehouseInfo.repairAmount || '',
  457. grossPerformance: this.computedGrossPerformance || '',
  458. performance: this.computedPerformance || '',
  459. splitRatio: this.warehouseInfo.splitRatio || '',
  460. receiptRemark: `${this.warehouseInfo.remarks || ''};${this.warehouseInfo.uploadedImage || ''}`,
  461. customerServiceName: this.warehouseInfo.customerServiceName || '',
  462. category: this.warehouseInfo.category || '',
  463. needCheckCode: this.warehouseInfo.needCheckCode || '',
  464. totalCost: this.computedTotalCost || '',
  465. model: this.warehouseInfo.model || ''
  466. })
  467. } catch (e) {
  468. console.error('保存入库信息失败:', e)
  469. }
  470. },
  471. /**
  472. * 选择物流图片(选完后即保存)
  473. */
  474. async selectImage() {
  475. try {
  476. const tempFilePaths = await imageUpload.chooseImage(1)
  477. if (!tempFilePaths || tempFilePaths.length === 0) {
  478. uni.$u.toast('未获取到图片路径,请重试')
  479. return
  480. }
  481. const tempFilePath = tempFilePaths[0]
  482. const rep = await uni.$u.api.uploadFile(tempFilePath)
  483. if (rep.code == 200) {
  484. this.warehouseInfo.uploadedImage = rep.data.url
  485. await this.saveWarehouseInfoOnBlur()
  486. }
  487. } catch (error) {
  488. console.error('上传图片失败:', error)
  489. }
  490. },
  491. /**
  492. * 加载分成人名单
  493. */
  494. async loadCommissionUserList() {
  495. try {
  496. const res = await uni.$u.api.getCustomerManagerAllList()
  497. this.columnsOrgList = [res.data[0].children]
  498. } catch (error) {
  499. console.error('加载分成人名单失败:', error)
  500. }
  501. },
  502. /**
  503. * 加载分成列表
  504. */
  505. async loadShareList() {
  506. if (!this.currentReceipt.sendFormId) return
  507. try {
  508. const { rows } = await uni.$u.api.selectCommissionList({
  509. pageSize: 9999,
  510. pageNum: 1
  511. }, { sendFormId: this.currentReceipt.sendFormId })
  512. const newRows = rows
  513. .filter(item => item.receiptFormId == this.currentReceipt.id)
  514. .map(item => ({
  515. ...item,
  516. uuid: Math.random()
  517. }))
  518. this.profitSharingList = newRows
  519. } catch (error) {
  520. console.error('加载分成列表失败:', error)
  521. }
  522. },
  523. /**
  524. * 添加分成行
  525. */
  526. addSplit() {
  527. this.profitSharingList.push({
  528. deptId: '',
  529. accountType: '1',
  530. userId: '',
  531. commissionRate: 0,
  532. isCompanyPerformance: '2',
  533. orgName: '',
  534. userName: '',
  535. id: '',
  536. uuid: Math.random()
  537. })
  538. this.calculateTotalPercentage()
  539. },
  540. /**
  541. * 重新计算分成比例
  542. */
  543. calculateTotalPercentage() {
  544. const frontItems = this.profitSharingList.filter(item => item.accountType == '1')
  545. const backItems = this.profitSharingList.filter(item => item.accountType == '2')
  546. const totalFrontItems = frontItems.length || 1
  547. const totalBackItems = backItems.length || 1
  548. this.profitSharingList.forEach(item => {
  549. if (item.accountType == '1') {
  550. item.commissionRate = Math.floor(100 / totalFrontItems)
  551. }
  552. if (item.accountType == '2') {
  553. item.commissionRate = Math.floor(100 / totalBackItems)
  554. }
  555. })
  556. },
  557. /**
  558. * 切换账户类型
  559. */
  560. toggleAccountType(item) {
  561. item.accountType = item.accountType == '1' ? '2' : '1'
  562. this.calculateTotalPercentage()
  563. },
  564. /**
  565. * 处理百分比输入
  566. */
  567. handlePercentageInput(item) {
  568. let value = Number(item.commissionRate)
  569. if (isNaN(value)) value = 0
  570. if (value < 0) value = 0
  571. if (value > 100) value = 100
  572. item.commissionRate = Math.floor(value)
  573. },
  574. /**
  575. * 切换归属公司
  576. */
  577. toggleBelongToCompany(item) {
  578. item.isCompanyPerformance = item.isCompanyPerformance == '1' ? '2' : '1'
  579. },
  580. /**
  581. * 选择组织
  582. */
  583. handleSelectOrg(item) {
  584. this.currentEditItem = item.uuid
  585. this.showPersonPicker = true
  586. this.columnsPersonList = this.columnsOrgList
  587. },
  588. /**
  589. * 选择人员
  590. */
  591. handleSelectPerson(item) {
  592. this.currentEditItem = item.uuid
  593. const deptId = item.deptId
  594. const org = this.findOrg(this.columnsOrgList[0], deptId)
  595. if (org) {
  596. this.columnsPersonList = [org.children]
  597. }
  598. this.showPersonPicker = true
  599. },
  600. /**
  601. * 递归查找组织
  602. */
  603. findOrg(orgList, deptId) {
  604. for (const org of orgList) {
  605. if (org.id == deptId) {
  606. return org
  607. }
  608. if (org.children && org.children.length > 0) {
  609. const found = this.findOrg(org.children, deptId)
  610. if (found) return found
  611. }
  612. }
  613. return null
  614. },
  615. /**
  616. * 确认选择组织
  617. */
  618. handleOrgConfirm({ value }) {
  619. this.profitSharingList.forEach(item => {
  620. if (item.uuid == this.currentEditItem) {
  621. item.orgName = value[0].label
  622. item.deptId = value[0].id
  623. item.userId = ''
  624. item.userName = ''
  625. }
  626. })
  627. this.showOrgPicker = false
  628. },
  629. /**
  630. * 确认选择人员
  631. */
  632. handleConfirmPerson({ value }) {
  633. if (value[0].isUser) {
  634. this.profitSharingList.forEach(item => {
  635. if (item.uuid == this.currentEditItem) {
  636. item.userName = value[0].label
  637. item.userId = value[0].id
  638. }
  639. })
  640. this.columnsPersonList = []
  641. this.showPersonPicker = false
  642. } else {
  643. this.profitSharingList.forEach(item => {
  644. if (item.uuid == this.currentEditItem) {
  645. item.orgName = value[0].label
  646. item.deptId = value[0].id
  647. }
  648. })
  649. this.columnsPersonList = [value[0].children]
  650. }
  651. },
  652. /**
  653. * 取消选择人员
  654. */
  655. handleCancelPerson() {
  656. this.columnsPersonList = []
  657. this.showPersonPicker = false
  658. },
  659. /**
  660. * 删除分成行
  661. */
  662. async deleteRow(id, uuid) {
  663. uni.showModal({
  664. title: '确认删除',
  665. content: '是否确认删除当前行分成比例?',
  666. success: async (res) => {
  667. if (res.confirm) {
  668. if (!id) {
  669. this.profitSharingList = this.profitSharingList.filter(item => item.uuid != uuid)
  670. this.calculateTotalPercentage()
  671. return
  672. }
  673. try {
  674. await uni.$u.api.deleteClueCommissionForm(id)
  675. uni.$u.toast('删除成功')
  676. this.loadShareList()
  677. } catch (error) {
  678. uni.$u.toast('删除失败')
  679. }
  680. }
  681. }
  682. })
  683. },
  684. /**
  685. * 选择收单类型
  686. */
  687. selectCustomerServiceName() {
  688. this.showCustomerServicePicker = true
  689. },
  690. /**
  691. * 确认收单类型
  692. */
  693. handleConfirmCustomerService({ value }) {
  694. this.warehouseInfo.customerServiceNameLabel = value[0].label
  695. this.warehouseInfo.customerServiceName = value[0].value
  696. this.showCustomerServicePicker = false
  697. this.saveWarehouseInfoOnBlur()
  698. },
  699. /**
  700. * 选择类别
  701. */
  702. selectCategory() {
  703. this.showCategoryPicker = true
  704. },
  705. /**
  706. * 确认类别
  707. */
  708. handleConfirmCategory({ value }) {
  709. this.warehouseInfo.categoryLabel = value[0].label
  710. this.warehouseInfo.category = value[0].value
  711. this.showCategoryPicker = false
  712. this.saveWarehouseInfoOnBlur()
  713. },
  714. /**
  715. * 选择是否需要查码
  716. */
  717. selectNeedCheckCode() {
  718. this.showNeedCheckCodePicker = true
  719. },
  720. /**
  721. * 确认是否需要查码
  722. */
  723. handleConfirmNeedCheckCode({ value }) {
  724. this.warehouseInfo.needCheckCodeLabel = value[0].label
  725. this.warehouseInfo.needCheckCode = value[0].value
  726. // 如果选择"否",清空编码和查码费
  727. if (value[0].value === '2') {
  728. this.warehouseInfo.codeStorage = ''
  729. this.warehouseInfo.checkCodeFee = ''
  730. }
  731. this.showNeedCheckCodePicker = false
  732. this.saveWarehouseInfoOnBlur()
  733. },
  734. /**
  735. * 确认收单
  736. */
  737. async confirmReceiveOrder() {
  738. // 校验表单
  739. await this.$refs.form.validate().then(() => {
  740. uni.showModal({
  741. title: '确认收单',
  742. content: `是否确认收单该订单:${this.orderDetail.item}?`,
  743. success: async (res) => {
  744. if (res.confirm) {
  745. try {
  746. // 先判断当前的状态是不是3(收单),如果是3的话就不调这个接口,修改订单状态
  747. if (this.orderDetail.status != '3') {
  748. // 当前的收单状态不是收单状态,则修改订单状态
  749. await uni.$u.api.oderForm({
  750. status: '3',
  751. id: this.orderDetail.id
  752. })
  753. }
  754. // 更新收单表单
  755. await uni.$u.api.updateReceiptForm({
  756. id: this.currentReceipt.id,
  757. code: this.warehouseInfo.codeStorage || '',
  758. expressOrderNo: this.warehouseInfo.expressOrderNo || '',
  759. item: this.warehouseInfo.item || '',
  760. checkCodeFee: this.warehouseInfo.checkCodeFee || '',
  761. tableFee: this.warehouseInfo.watchPrice || '',
  762. benefitFee: this.warehouseInfo.benefitFee || '',
  763. freight: this.warehouseInfo.freight || '',
  764. repairAmount: this.warehouseInfo.repairAmount || '',
  765. grossPerformance: this.computedGrossPerformance || '',
  766. performance: this.computedPerformance || '',
  767. splitRatio: this.warehouseInfo.splitRatio || '',
  768. receiptRemark: `${this.warehouseInfo.remarks || ''};${this.warehouseInfo.uploadedImage || ''}`,
  769. customerServiceName: this.warehouseInfo.customerServiceName || '',
  770. category: this.warehouseInfo.category || '',
  771. needCheckCode: this.warehouseInfo.needCheckCode || '',
  772. totalCost: this.computedTotalCost || '',
  773. model: this.warehouseInfo.model || '',
  774. })
  775. // 上传分成数据
  776. await this.addShare()
  777. // //新增仓库或者编辑仓库
  778. // //等于1的时候放入仓库表
  779. // if (this.isWarehouse == '1') {
  780. // // 获取品牌ID
  781. // const brandObj = this.brandList.find(item => item.dictLabel === this.currentReceipt.brand)
  782. // const brandId = brandObj ? brandObj.dictValue : ''
  783. // //建立入库data
  784. // // 获取 PageThree 的高清实物图的 fileUrl 数组
  785. // // 直接使用 imageUpload 获取图片列表,与 PageThree 保持一致
  786. // let goodPicFileUrls = []
  787. // if (this.currentReceipt.id && this.orderDetail.itemBrand) {
  788. // try {
  789. // const list = await imageUpload.getFileList(
  790. // '2',
  791. // '3',
  792. // this.currentReceipt.id,
  793. // this.orderDetail.itemBrand,
  794. // this.currentReceipt.clueId
  795. // )
  796. // // 获取前6个图片的 fileUrl(与 PageThree 的 displayImages 保持一致)
  797. // // goodPicFileUrls = (list || []).slice(0, 6).map(item => item.fileUrl).filter(url => url)
  798. // goodPicFileUrls = (list || []).map(item => item.fileUrl).filter(url => url)
  799. // } catch (error) {
  800. // console.error('获取高清实物图失败:', error)
  801. // }
  802. // }
  803. // const warehouseData = {
  804. // goodPicFileList: goodPicFileUrls,//商品图片 page3的高清实物图的url数组
  805. // type: this.warehouseInfo.category || '',//商品分类
  806. // dictLabel: this.currentReceipt.brand || '',//品牌名称
  807. // dictValue: brandId || '',//品牌id
  808. // indentifyCode:this.warehouseInfo.codeStorage|| '',//独立编码
  809. // costPrice: this.computedTotalCost || '',//总成本价
  810. // recycleTime: dayjs().format('YYYY-MM-DD'),//回收时间 必填
  811. // stockStatus:0,//库存状态,0待入库,1已入库,因为是我们是预入库,所以是0
  812. // origin:this.orderDetail.website//来源
  813. // }
  814. // if (!this.currentReceipt.warehouseId) {
  815. // //当没有仓库id的时候调用新增仓库接口
  816. // await uni.$u.api.wareHouseAdd(warehouseData)
  817. // } else {
  818. // //当有仓库id的时候调用编辑仓库接口
  819. // warehouseData.id = this.currentReceipt.warehouseId
  820. // await uni.$u.api.wareHouseUpdate(warehouseData)
  821. // }
  822. // } else if (this.isWarehouse == '2') {
  823. // //等于2的时候不放入仓库表
  824. // }
  825. this.$refs.uToast.show({
  826. type: 'success',
  827. message: '收单成功',
  828. complete: () => {
  829. // uni.navigateBack({
  830. // delta: 1
  831. // })
  832. }
  833. })
  834. } catch (error) {
  835. console.error('收单失败:', error)
  836. uni.$u.toast('收单失败')
  837. }
  838. }
  839. }
  840. })
  841. }).catch(() => {
  842. uni.$u.toast('请输入正确的信息')
  843. })
  844. },
  845. //确认入库
  846. confirmWarehouseEntry() {
  847. // 校验表单
  848. this.$refs.form.validate().then(() => {
  849. //点击了入库按钮
  850. //首先判断该大单的status是否为3,3代表已收单,如果为3,则提示已收单,不能入库
  851. console.log('xxxxx', this.orderDetail)
  852. if (this.orderDetail.status != '3') {
  853. uni.$u.toast('该订单未收单,不能入库')
  854. return
  855. }
  856. uni.showModal({
  857. title: '确认入库',
  858. content: `是否确认入库该订单:${this.orderDetail.item}-${this.currentReceipt.brand}?`,
  859. success: async (res) => {
  860. if (res.confirm) {
  861. //点击了确认入库,执行入库方法
  862. try {
  863. // 获取品牌ID
  864. const brandObj = this.brandList.find(item => item.dictLabel === this.currentReceipt.brand)
  865. const brandId = brandObj ? brandObj.dictValue : ''
  866. //建立入库data
  867. // 获取 PageThree 的高清实物图的 fileUrl 数组,顺序与 PageThree 的 displayImages 一致(按 fileIds 排序)
  868. let goodPicFileUrls = []
  869. if (this.currentReceipt.id && this.orderDetail.itemBrand) {
  870. try {
  871. const list = await imageUpload.getFileList(
  872. '2',
  873. '3',
  874. this.currentReceipt.id,
  875. this.orderDetail.itemBrand,
  876. this.currentReceipt.clueId
  877. )
  878. // 按 currentReceipt.fileIds 排序,与 PageThree 的 loadDetailImages 逻辑一致
  879. let sortedList = list || []
  880. if (this.currentReceipt.fileIds && sortedList.length > 0) {
  881. const sortedIds = this.currentReceipt.fileIds.split(',')
  882. sortedList = [...sortedList].sort((a, b) => {
  883. const indexA = sortedIds.indexOf(a.id)
  884. const indexB = sortedIds.indexOf(b.id)
  885. if (indexA === -1 && indexB === -1) return 0
  886. if (indexA === -1) return 1
  887. if (indexB === -1) return -1
  888. return indexA - indexB
  889. })
  890. }
  891. goodPicFileUrls = sortedList.map(item => item.fileUrl).filter(url => url)
  892. } catch (error) {
  893. console.error('获取高清实物图失败:', error)
  894. }
  895. }
  896. const warehouseData = {
  897. goodPicFileList: goodPicFileUrls,//商品图片 page3的高清实物图的url数组
  898. type: this.warehouseInfo.category || '',//商品分类
  899. dictLabel: this.currentReceipt.brand || '',//品牌名称
  900. dictValue: brandId || '',//品牌id
  901. indentifyCode: this.warehouseInfo.codeStorage || '',//独立编码
  902. costPrice: this.computedTotalCost || '',//总成本价
  903. recycleTime: dayjs().format('YYYY-MM-DD'),//回收时间 必填
  904. stockStatus: 0,//库存状态,0待入库,1已入库,因为是我们是预入库,所以是0
  905. origin: this.orderDetail.website,//来源
  906. actualPrice: this.currentReceipt.sellingPrice || '',//实价,也就是顶部的第三个价格sellingPrice
  907. price: this.currentReceipt.sellingPrice || '',//官方指导价,也就是顶部的第三个价格sellingPrice
  908. model: this.warehouseInfo.model || '',//型号
  909. }
  910. if (!this.currentReceipt.warehouseId) {
  911. //当没有仓库id的时候调用新增仓库接口
  912. await uni.$u.api.wareHouseAdd(warehouseData)
  913. } else {
  914. // //当有仓库id的时候调用编辑仓库接口
  915. // warehouseData.id = this.currentReceipt.warehouseId
  916. // await uni.$u.api.wareHouseUpdate(warehouseData)
  917. }
  918. this.$refs.uToast.show({
  919. type: 'success',
  920. message: '入库成功',
  921. complete: () => {
  922. // uni.navigateBack({
  923. // delta: 1
  924. // })
  925. }
  926. })
  927. } catch (error) {
  928. console.error('入库失败:', error)
  929. uni.$u.toast('入库失败')
  930. }
  931. }
  932. }
  933. })
  934. }).catch(() => {
  935. uni.$u.toast('请输入正确的信息')
  936. })
  937. },
  938. /**
  939. * 上传分成
  940. */
  941. async addShare() {
  942. for (const item of this.profitSharingList) {
  943. const data = {
  944. id: item.id || '',
  945. accountType: item.accountType == '1' ? 1 : 2,
  946. clueId: this.currentReceipt.clueId,
  947. commissionRate: item.commissionRate,
  948. isCompanyPerformance: item.isCompanyPerformance == '1' ? 1 : 2,
  949. sendFormId: this.currentReceipt.sendFormId,
  950. userId: item.userId,
  951. userName: item.userName,
  952. receiptFormId: this.currentReceipt.id
  953. }
  954. if (item.id) {
  955. await uni.$u.api.clueCommissionUpdate(data)
  956. } else {
  957. await uni.$u.api.clueCommissionAdd(data)
  958. }
  959. }
  960. },
  961. selectIsWarehouse() {
  962. this.showIsWarehousePicker = true
  963. },
  964. handleConfirmIsWarehouse({ value }) {
  965. this.isWarehouse = value[0].value
  966. this.isWarehouseLabel = value[0].label
  967. this.showIsWarehousePicker = false
  968. },
  969. }
  970. }
  971. </script>
  972. <style scoped lang="scss">
  973. @import '../styles/common.scss';
  974. .page-four-container {
  975. @extend .page-container;
  976. padding-bottom: 100rpx;
  977. }
  978. .address-section {
  979. padding: 20rpx;
  980. // 防止 label 换行
  981. ::v-deep .u-form-item__body__left__content__label {
  982. white-space: nowrap !important;
  983. overflow: visible;
  984. }
  985. }
  986. .info-row {
  987. margin-bottom: 20rpx;
  988. }
  989. .info-input {
  990. height: 65rpx;
  991. border-radius: 8rpx;
  992. border: 1rpx solid #e5e7eb;
  993. padding: 20rpx 16rpx;
  994. width: 100%;
  995. box-sizing: border-box;
  996. }
  997. .info-textarea {
  998. width: 100%;
  999. box-sizing: border-box;
  1000. ::v-deep .u-textarea {
  1001. min-height: 200rpx;
  1002. border-radius: 8rpx;
  1003. border: 1rpx solid #e5e7eb;
  1004. padding: 20rpx 16rpx;
  1005. line-height: 1.5;
  1006. }
  1007. ::v-deep textarea {
  1008. min-height: 200rpx;
  1009. border-radius: 8rpx;
  1010. width: 100%;
  1011. box-sizing: border-box;
  1012. line-height: 1.5;
  1013. font-size: 28rpx;
  1014. }
  1015. }
  1016. .click-wrapper {
  1017. width: 100%;
  1018. cursor: pointer;
  1019. display: flex;
  1020. align-items: center;
  1021. }
  1022. .image-uploader {
  1023. width: 100%;
  1024. height: 65rpx;
  1025. border: 2rpx dashed #409eff;
  1026. border-radius: 8rpx;
  1027. display: flex;
  1028. align-items: center;
  1029. justify-content: center;
  1030. cursor: pointer;
  1031. background-color: #ecf5ff;
  1032. }
  1033. .image-preview {
  1034. width: 100%;
  1035. height: 100%;
  1036. object-fit: cover;
  1037. border-radius: 10rpx;
  1038. }
  1039. .split-table {
  1040. width: 100%;
  1041. margin-top: 20rpx;
  1042. }
  1043. .split-table-header {
  1044. background-color: #f5f7fa;
  1045. padding: 15rpx 0;
  1046. border-bottom: 1rpx solid #e4e7ed;
  1047. }
  1048. .split-table-row {
  1049. padding: 15rpx 0;
  1050. border-bottom: 1rpx solid #e4e7ed;
  1051. align-items: center;
  1052. }
  1053. .header-text {
  1054. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  1055. text-align: center;
  1056. display: block;
  1057. }
  1058. .table-cell {
  1059. display: flex;
  1060. align-items: center;
  1061. justify-content: center;
  1062. padding: 0 10rpx;
  1063. }
  1064. .percentage-input {
  1065. text-align: center;
  1066. background-color: #f9f9f9;
  1067. padding: 0rpx !important;
  1068. }
  1069. .account-type {
  1070. padding: 4rpx 16rpx;
  1071. border-radius: 12rpx;
  1072. font-size: 24rpx;
  1073. font-weight: 500;
  1074. color: #fff;
  1075. text-align: center;
  1076. cursor: pointer;
  1077. &.frontend {
  1078. background-color: #409eff;
  1079. }
  1080. &.backend {
  1081. background-color: #909399;
  1082. }
  1083. }
  1084. .radio-wrapper {
  1085. cursor: pointer;
  1086. display: flex;
  1087. align-items: center;
  1088. justify-content: center;
  1089. }
  1090. .radio-circle {
  1091. width: 32rpx;
  1092. height: 32rpx;
  1093. border-radius: 50%;
  1094. border: 2rpx solid #dcdfe6;
  1095. display: flex;
  1096. align-items: center;
  1097. justify-content: center;
  1098. transition: all 0.3s ease;
  1099. &.active {
  1100. border-color: #67c23a;
  1101. background-color: #67c23a;
  1102. }
  1103. }
  1104. .confirm-button-container {
  1105. padding: 40rpx 0;
  1106. margin-top: 20rpx;
  1107. }
  1108. .confirm-button-container .next-btn {
  1109. width: 100%;
  1110. height: 80rpx;
  1111. line-height: 80rpx;
  1112. text-align: center;
  1113. border-radius: 11px;
  1114. }
  1115. .add-button-container {
  1116. justify-content: space-between;
  1117. }
  1118. </style>