PageFour.vue 30 KB

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