PageFour.vue 30 KB

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