PageFour.vue 30 KB

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