PageFour.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  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-row gutter="24">
  233. <u-col span="6">
  234. <u-button class="next-btn" type="success" @click="confirmReceiveOrder">
  235. <u-icon name="checkmark-circle-fill" size="28rpx" color="#fff" />
  236. <text style="margin-left: 8rpx;">确认收单</text>
  237. </u-button>
  238. </u-col>
  239. <u-col span="6">
  240. <u-button class="next-btn" type="success" @click="confirmWarehouseEntry">
  241. <u-icon name="checkmark-circle-fill" size="28rpx" color="#fff" />
  242. <text style="margin-left: 8rpx;">确认入库</text>
  243. </u-button>
  244. </u-col>
  245. </u-row>
  246. </view>
  247. <!-- 组织选择器 -->
  248. <u-picker :show="showOrgPicker" title="请选择组织" :columns="columnsOrgList" keyName="label" @confirm="handleOrgConfirm"
  249. @cancel="showOrgPicker = false" />
  250. <!-- 人员选择器 -->
  251. <u-picker :show="showPersonPicker" title="请选择分成人" :columns="columnsPersonList" keyName="label"
  252. @confirm="handleConfirmPerson" @cancel="handleCancelPerson" />
  253. <u-toast ref="uToast" />
  254. </view>
  255. </template>
  256. <script>
  257. import imageUpload from '../utils/imageUpload.js'
  258. import dayjs from 'dayjs'
  259. export default {
  260. name: 'PageFour',
  261. props: {
  262. orderDetail: {
  263. type: Object,
  264. default: () => ({})
  265. },
  266. currentReceipt: {
  267. type: Object,
  268. default: () => ({})
  269. }
  270. },
  271. data() {
  272. return {
  273. warehouseInfo: {
  274. codeStorage: '',
  275. expressOrderNo: '',
  276. uploadedImage: '',
  277. item: '',
  278. checkCodeFee: '',
  279. watchPrice: '',
  280. benefitFee: '',
  281. freight: '',
  282. repairAmount: '',
  283. grossPerformance: '',
  284. performance: '',
  285. splitRatio: '',
  286. remarks: '',
  287. customerServiceNameLabel: '',
  288. customerServiceName: '',
  289. categoryLabel: '',
  290. category: '',
  291. needCheckCodeLabel: '',
  292. needCheckCode: ''
  293. },
  294. profitSharingList: [],
  295. showOrgPicker: false,
  296. showPersonPicker: false,
  297. columnsOrgList: [],
  298. columnsPersonList: [],
  299. showCustomerServicePicker: false,
  300. customerServiceColumns: [[
  301. { label: '收单类', value: '1' },
  302. { label: '维修类', value: '2' },
  303. { label: '销售类', value: '3' }
  304. ]],
  305. showCategoryPicker: false,
  306. categoryColumns: [[
  307. { label: '腕表', value: '1' },
  308. { label: '包包', value: '2' },
  309. { label: '首饰', value: '4' },
  310. { label: '其他', value: '3' }
  311. ]],
  312. showNeedCheckCodePicker: false,
  313. needCheckCodeColumns: [[
  314. { label: '是', value: '1' },
  315. { label: '否', value: '2' }
  316. ]],
  317. currentEditItem: '',
  318. isWarehouse: '2',
  319. isWarehouseLabel: '不入库',
  320. showIsWarehousePicker: false,
  321. isWarehouseColumns: [[
  322. { label: '确认入库', value: '1' },
  323. { label: '不入库', value: '2' }
  324. ]],
  325. brandList: []
  326. }
  327. },
  328. computed: {
  329. computedTotalCost() {
  330. const freight = Number(this.warehouseInfo.freight) || 0
  331. const benefitFee = Number(this.warehouseInfo.benefitFee) || 0
  332. const checkCodeFee = Number(this.warehouseInfo.checkCodeFee) || 0
  333. const watchPrice = Number(this.warehouseInfo.watchPrice) || 0
  334. const repairAmount = Number(this.warehouseInfo.repairAmount) || 0
  335. return freight + benefitFee + checkCodeFee + watchPrice + repairAmount
  336. },
  337. computedPerformance() {
  338. const sellingPrice = Number(this.currentReceipt.sellingPrice) || 0
  339. return sellingPrice - this.computedTotalCost
  340. },
  341. computedGrossPerformance() {
  342. const performance = this.computedPerformance || 0
  343. const splitRatio = Number(this.warehouseInfo.splitRatio) / 100 || 0
  344. return (performance * splitRatio).toFixed(2)
  345. }
  346. },
  347. watch: {
  348. currentReceipt: {
  349. handler(newVal) {
  350. if (newVal) {
  351. this.initWarehouseInfo(newVal)
  352. this.loadShareList()
  353. }
  354. },
  355. immediate: true,
  356. deep: true
  357. }
  358. },
  359. mounted() {
  360. this.loadCommissionUserList()
  361. this.loadBrandList()
  362. },
  363. methods: {
  364. /**
  365. * 加载品牌列表
  366. */
  367. async loadBrandList() {
  368. try {
  369. const res = await this.$getDicts('crm_form_brand')
  370. this.brandList = res
  371. } catch (error) {
  372. console.error('加载品牌列表失败:', error)
  373. }
  374. },
  375. /**
  376. * 初始化入库信息
  377. */
  378. initWarehouseInfo(data) {
  379. const receiptRemark = data.receiptRemark || ''
  380. const remarkParts = receiptRemark.split(';')
  381. // 设置默认值:收单类型默认为"收单类",类别默认为"腕表",是否需要查码默认为"是"
  382. const defaultCustomerServiceName = data.customerServiceName || '1'
  383. const defaultCategory = data.category || '1'
  384. const defaultNeedCheckCode = data.needCheckCode || '1'
  385. this.warehouseInfo = {
  386. codeStorage: data.code || '',
  387. expressOrderNo: data.expressOrderNo || '',
  388. uploadedImage: remarkParts[1] || '',
  389. item: data.item || '',
  390. checkCodeFee: data.checkCodeFee || '',
  391. watchPrice: data.tableFee || '',
  392. benefitFee: data.benefitFee || '',
  393. freight: data.freight || '',
  394. repairAmount: data.repairAmount || '',
  395. grossPerformance: data.grossPerformance || '',
  396. performance: data.performance || '',
  397. splitRatio: data.splitRatio || '',
  398. remarks: remarkParts[0] || '',
  399. customerServiceName: defaultCustomerServiceName,
  400. customerServiceNameLabel: this.getLabelByValue(
  401. this.customerServiceColumns[0],
  402. defaultCustomerServiceName
  403. ),
  404. category: defaultCategory,
  405. categoryLabel: this.getLabelByValue(
  406. this.categoryColumns[0],
  407. defaultCategory
  408. ),
  409. needCheckCode: defaultNeedCheckCode,
  410. needCheckCodeLabel: this.getLabelByValue(
  411. this.needCheckCodeColumns[0],
  412. defaultNeedCheckCode
  413. )
  414. }
  415. },
  416. /**
  417. * 根据值获取标签
  418. */
  419. getLabelByValue(columns, value) {
  420. const item = columns.find(col => col.value == value)
  421. return item ? item.label : ''
  422. },
  423. /**
  424. * 选择物流图片
  425. */
  426. async selectImage() {
  427. try {
  428. const tempFilePaths = await imageUpload.chooseImage(1)
  429. if (!tempFilePaths || tempFilePaths.length === 0) {
  430. uni.$u.toast('未获取到图片路径,请重试')
  431. return
  432. }
  433. const tempFilePath = tempFilePaths[0]
  434. const rep = await uni.$u.api.uploadFile(tempFilePath)
  435. if (rep.code == 200) {
  436. this.warehouseInfo.uploadedImage = rep.data.url
  437. }
  438. } catch (error) {
  439. console.error('上传图片失败:', error)
  440. }
  441. },
  442. /**
  443. * 加载分成人名单
  444. */
  445. async loadCommissionUserList() {
  446. try {
  447. const res = await uni.$u.api.getCustomerManagerAllList()
  448. this.columnsOrgList = [res.data[0].children]
  449. } catch (error) {
  450. console.error('加载分成人名单失败:', error)
  451. }
  452. },
  453. /**
  454. * 加载分成列表
  455. */
  456. async loadShareList() {
  457. if (!this.currentReceipt.sendFormId) return
  458. try {
  459. const { rows } = await uni.$u.api.selectCommissionList({
  460. pageSize: 9999,
  461. pageNum: 1
  462. }, { sendFormId: this.currentReceipt.sendFormId })
  463. const newRows = rows
  464. .filter(item => item.receiptFormId == this.currentReceipt.id)
  465. .map(item => ({
  466. ...item,
  467. uuid: Math.random()
  468. }))
  469. this.profitSharingList = newRows
  470. } catch (error) {
  471. console.error('加载分成列表失败:', error)
  472. }
  473. },
  474. /**
  475. * 添加分成行
  476. */
  477. addSplit() {
  478. this.profitSharingList.push({
  479. deptId: '',
  480. accountType: '1',
  481. userId: '',
  482. commissionRate: 0,
  483. isCompanyPerformance: '2',
  484. orgName: '',
  485. userName: '',
  486. id: '',
  487. uuid: Math.random()
  488. })
  489. this.calculateTotalPercentage()
  490. },
  491. /**
  492. * 重新计算分成比例
  493. */
  494. calculateTotalPercentage() {
  495. const frontItems = this.profitSharingList.filter(item => item.accountType == '1')
  496. const backItems = this.profitSharingList.filter(item => item.accountType == '2')
  497. const totalFrontItems = frontItems.length || 1
  498. const totalBackItems = backItems.length || 1
  499. this.profitSharingList.forEach(item => {
  500. if (item.accountType == '1') {
  501. item.commissionRate = Math.floor(100 / totalFrontItems)
  502. }
  503. if (item.accountType == '2') {
  504. item.commissionRate = Math.floor(100 / totalBackItems)
  505. }
  506. })
  507. },
  508. /**
  509. * 切换账户类型
  510. */
  511. toggleAccountType(item) {
  512. item.accountType = item.accountType == '1' ? '2' : '1'
  513. this.calculateTotalPercentage()
  514. },
  515. /**
  516. * 处理百分比输入
  517. */
  518. handlePercentageInput(item) {
  519. let value = Number(item.commissionRate)
  520. if (isNaN(value)) value = 0
  521. if (value < 0) value = 0
  522. if (value > 100) value = 100
  523. item.commissionRate = Math.floor(value)
  524. },
  525. /**
  526. * 切换归属公司
  527. */
  528. toggleBelongToCompany(item) {
  529. item.isCompanyPerformance = item.isCompanyPerformance == '1' ? '2' : '1'
  530. },
  531. /**
  532. * 选择组织
  533. */
  534. handleSelectOrg(item) {
  535. this.currentEditItem = item.uuid
  536. this.showPersonPicker = true
  537. this.columnsPersonList = this.columnsOrgList
  538. },
  539. /**
  540. * 选择人员
  541. */
  542. handleSelectPerson(item) {
  543. this.currentEditItem = item.uuid
  544. const deptId = item.deptId
  545. const org = this.findOrg(this.columnsOrgList[0], deptId)
  546. if (org) {
  547. this.columnsPersonList = [org.children]
  548. }
  549. this.showPersonPicker = true
  550. },
  551. /**
  552. * 递归查找组织
  553. */
  554. findOrg(orgList, deptId) {
  555. for (const org of orgList) {
  556. if (org.id == deptId) {
  557. return org
  558. }
  559. if (org.children && org.children.length > 0) {
  560. const found = this.findOrg(org.children, deptId)
  561. if (found) return found
  562. }
  563. }
  564. return null
  565. },
  566. /**
  567. * 确认选择组织
  568. */
  569. handleOrgConfirm({ value }) {
  570. this.profitSharingList.forEach(item => {
  571. if (item.uuid == this.currentEditItem) {
  572. item.orgName = value[0].label
  573. item.deptId = value[0].id
  574. item.userId = ''
  575. item.userName = ''
  576. }
  577. })
  578. this.showOrgPicker = false
  579. },
  580. /**
  581. * 确认选择人员
  582. */
  583. handleConfirmPerson({ value }) {
  584. if (value[0].isUser) {
  585. this.profitSharingList.forEach(item => {
  586. if (item.uuid == this.currentEditItem) {
  587. item.userName = value[0].label
  588. item.userId = value[0].id
  589. }
  590. })
  591. this.columnsPersonList = []
  592. this.showPersonPicker = false
  593. } else {
  594. this.profitSharingList.forEach(item => {
  595. if (item.uuid == this.currentEditItem) {
  596. item.orgName = value[0].label
  597. item.deptId = value[0].id
  598. }
  599. })
  600. this.columnsPersonList = [value[0].children]
  601. }
  602. },
  603. /**
  604. * 取消选择人员
  605. */
  606. handleCancelPerson() {
  607. this.columnsPersonList = []
  608. this.showPersonPicker = false
  609. },
  610. /**
  611. * 删除分成行
  612. */
  613. async deleteRow(id, uuid) {
  614. uni.showModal({
  615. title: '确认删除',
  616. content: '是否确认删除当前行分成比例?',
  617. success: async (res) => {
  618. if (res.confirm) {
  619. if (!id) {
  620. this.profitSharingList = this.profitSharingList.filter(item => item.uuid != uuid)
  621. this.calculateTotalPercentage()
  622. return
  623. }
  624. try {
  625. await uni.$u.api.deleteClueCommissionForm(id)
  626. uni.$u.toast('删除成功')
  627. this.loadShareList()
  628. } catch (error) {
  629. uni.$u.toast('删除失败')
  630. }
  631. }
  632. }
  633. })
  634. },
  635. /**
  636. * 选择收单类型
  637. */
  638. selectCustomerServiceName() {
  639. this.showCustomerServicePicker = true
  640. },
  641. /**
  642. * 确认收单类型
  643. */
  644. handleConfirmCustomerService({ value }) {
  645. this.warehouseInfo.customerServiceNameLabel = value[0].label
  646. this.warehouseInfo.customerServiceName = value[0].value
  647. this.showCustomerServicePicker = false
  648. },
  649. /**
  650. * 选择类别
  651. */
  652. selectCategory() {
  653. this.showCategoryPicker = true
  654. },
  655. /**
  656. * 确认类别
  657. */
  658. handleConfirmCategory({ value }) {
  659. this.warehouseInfo.categoryLabel = value[0].label
  660. this.warehouseInfo.category = value[0].value
  661. this.showCategoryPicker = false
  662. },
  663. /**
  664. * 选择是否需要查码
  665. */
  666. selectNeedCheckCode() {
  667. this.showNeedCheckCodePicker = true
  668. },
  669. /**
  670. * 确认是否需要查码
  671. */
  672. handleConfirmNeedCheckCode({ value }) {
  673. this.warehouseInfo.needCheckCodeLabel = value[0].label
  674. this.warehouseInfo.needCheckCode = value[0].value
  675. // 如果选择"否",清空编码和查码费
  676. if (value[0].value === '2') {
  677. this.warehouseInfo.codeStorage = ''
  678. this.warehouseInfo.checkCodeFee = ''
  679. }
  680. this.showNeedCheckCodePicker = false
  681. },
  682. /**
  683. * 确认收单
  684. */
  685. async confirmReceiveOrder() {
  686. uni.showModal({
  687. title: '确认收单',
  688. content: `是否确认收单该订单:${this.orderDetail.item}?`,
  689. success: async (res) => {
  690. if (res.confirm) {
  691. try {
  692. // 修改订单状态
  693. await uni.$u.api.oderForm({
  694. status: '3',
  695. id: this.orderDetail.id
  696. })
  697. // 更新收单表单
  698. await uni.$u.api.updateReceiptForm({
  699. id: this.currentReceipt.id,
  700. code: this.warehouseInfo.codeStorage || '',
  701. expressOrderNo: this.warehouseInfo.expressOrderNo || '',
  702. item: this.warehouseInfo.item || '',
  703. checkCodeFee: this.warehouseInfo.checkCodeFee || '',
  704. tableFee: this.warehouseInfo.watchPrice || '',
  705. benefitFee: this.warehouseInfo.benefitFee || '',
  706. freight: this.warehouseInfo.freight || '',
  707. repairAmount: this.warehouseInfo.repairAmount || '',
  708. grossPerformance: this.computedGrossPerformance || '',
  709. performance: this.computedPerformance || '',
  710. splitRatio: this.warehouseInfo.splitRatio || '',
  711. receiptRemark: `${this.warehouseInfo.remarks || ''};${this.warehouseInfo.uploadedImage || ''}`,
  712. customerServiceName: this.warehouseInfo.customerServiceName || '',
  713. category: this.warehouseInfo.category || '',
  714. needCheckCode: this.warehouseInfo.needCheckCode || '',
  715. totalCost: this.computedTotalCost || ''
  716. })
  717. // 上传分成数据
  718. await this.addShare()
  719. // //新增仓库或者编辑仓库
  720. // //等于1的时候放入仓库表
  721. // if (this.isWarehouse == '1') {
  722. // // 获取品牌ID
  723. // const brandObj = this.brandList.find(item => item.dictLabel === this.currentReceipt.brand)
  724. // const brandId = brandObj ? brandObj.dictValue : ''
  725. // //建立入库data
  726. // // 获取 PageThree 的高清实物图的 fileUrl 数组
  727. // // 直接使用 imageUpload 获取图片列表,与 PageThree 保持一致
  728. // let goodPicFileUrls = []
  729. // if (this.currentReceipt.id && this.orderDetail.itemBrand) {
  730. // try {
  731. // const list = await imageUpload.getFileList(
  732. // '2',
  733. // '3',
  734. // this.currentReceipt.id,
  735. // this.orderDetail.itemBrand,
  736. // this.currentReceipt.clueId
  737. // )
  738. // // 获取前6个图片的 fileUrl(与 PageThree 的 displayImages 保持一致)
  739. // // goodPicFileUrls = (list || []).slice(0, 6).map(item => item.fileUrl).filter(url => url)
  740. // goodPicFileUrls = (list || []).map(item => item.fileUrl).filter(url => url)
  741. // } catch (error) {
  742. // console.error('获取高清实物图失败:', error)
  743. // }
  744. // }
  745. // const warehouseData = {
  746. // goodPicFileList: goodPicFileUrls,//商品图片 page3的高清实物图的url数组
  747. // type: this.warehouseInfo.category || '',//商品分类
  748. // dictLabel: this.currentReceipt.brand || '',//品牌名称
  749. // dictValue: brandId || '',//品牌id
  750. // indentifyCode:this.warehouseInfo.codeStorage|| '',//独立编码
  751. // costPrice: this.computedTotalCost || '',//总成本价
  752. // recycleTime: dayjs().format('YYYY-MM-DD'),//回收时间 必填
  753. // stockStatus:0,//库存状态,0待入库,1已入库,因为是我们是预入库,所以是0
  754. // origin:this.orderDetail.website//来源
  755. // }
  756. // if (!this.currentReceipt.warehouseId) {
  757. // //当没有仓库id的时候调用新增仓库接口
  758. // await uni.$u.api.wareHouseAdd(warehouseData)
  759. // } else {
  760. // //当有仓库id的时候调用编辑仓库接口
  761. // warehouseData.id = this.currentReceipt.warehouseId
  762. // await uni.$u.api.wareHouseUpdate(warehouseData)
  763. // }
  764. // } else if (this.isWarehouse == '2') {
  765. // //等于2的时候不放入仓库表
  766. // }
  767. this.$refs.uToast.show({
  768. type: 'success',
  769. message: '收单成功',
  770. complete: () => {
  771. uni.navigateBack({
  772. delta: 1
  773. })
  774. }
  775. })
  776. } catch (error) {
  777. console.error('收单失败:', error)
  778. uni.$u.toast('收单失败')
  779. }
  780. }
  781. }
  782. })
  783. },
  784. //确认入库
  785. confirmWarehouseEntry() {
  786. //点击了入库按钮
  787. //首先判断该大单的status是否为3,3代表已收单,如果为3,则提示已收单,不能入库
  788. console.log('xxxxx',this.orderDetail)
  789. if (this.orderDetail.status != '3') {
  790. uni.$u.toast('该订单未收单,不能入库')
  791. return
  792. }
  793. uni.showModal({
  794. title: '确认入库',
  795. content: `是否确认入库该订单:${this.orderDetail.item}-${this.currentReceipt.brand}?`,
  796. success: async (res) => {
  797. if (res.confirm) {
  798. //点击了确认入库,执行入库方法
  799. try {
  800. // 获取品牌ID
  801. const brandObj = this.brandList.find(item => item.dictLabel === this.currentReceipt.brand)
  802. const brandId = brandObj ? brandObj.dictValue : ''
  803. //建立入库data
  804. // 获取 PageThree 的高清实物图的 fileUrl 数组
  805. // 直接使用 imageUpload 获取图片列表,与 PageThree 保持一致
  806. let goodPicFileUrls = []
  807. if (this.currentReceipt.id && this.orderDetail.itemBrand) {
  808. try {
  809. const list = await imageUpload.getFileList(
  810. '2',
  811. '3',
  812. this.currentReceipt.id,
  813. this.orderDetail.itemBrand,
  814. this.currentReceipt.clueId
  815. )
  816. // 获取前6个图片的 fileUrl(与 PageThree 的 displayImages 保持一致)
  817. // goodPicFileUrls = (list || []).slice(0, 6).map(item => item.fileUrl).filter(url => url)
  818. goodPicFileUrls = (list || []).map(item => item.fileUrl).filter(url => url)
  819. } catch (error) {
  820. console.error('获取高清实物图失败:', error)
  821. }
  822. }
  823. const warehouseData = {
  824. goodPicFileList: goodPicFileUrls,//商品图片 page3的高清实物图的url数组
  825. type: this.warehouseInfo.category || '',//商品分类
  826. dictLabel: this.currentReceipt.brand || '',//品牌名称
  827. dictValue: brandId || '',//品牌id
  828. indentifyCode:this.warehouseInfo.codeStorage|| '',//独立编码
  829. costPrice: this.computedTotalCost || '',//总成本价
  830. recycleTime: dayjs().format('YYYY-MM-DD'),//回收时间 必填
  831. stockStatus:0,//库存状态,0待入库,1已入库,因为是我们是预入库,所以是0
  832. origin:this.orderDetail.website//来源
  833. }
  834. if (!this.currentReceipt.warehouseId) {
  835. //当没有仓库id的时候调用新增仓库接口
  836. await uni.$u.api.wareHouseAdd(warehouseData)
  837. } else {
  838. // //当有仓库id的时候调用编辑仓库接口
  839. // warehouseData.id = this.currentReceipt.warehouseId
  840. // await uni.$u.api.wareHouseUpdate(warehouseData)
  841. }
  842. this.$refs.uToast.show({
  843. type: 'success',
  844. message: '入库成功',
  845. complete: () => {
  846. uni.navigateBack({
  847. delta: 1
  848. })
  849. }
  850. })
  851. } catch (error) {
  852. console.error('入库失败:', error)
  853. uni.$u.toast('入库失败')
  854. }
  855. }
  856. }
  857. })
  858. },
  859. /**
  860. * 上传分成
  861. */
  862. async addShare() {
  863. for (const item of this.profitSharingList) {
  864. const data = {
  865. id: item.id || '',
  866. accountType: item.accountType == '1' ? 1 : 2,
  867. clueId: this.currentReceipt.clueId,
  868. commissionRate: item.commissionRate,
  869. isCompanyPerformance: item.isCompanyPerformance == '1' ? 1 : 2,
  870. sendFormId: this.currentReceipt.sendFormId,
  871. userId: item.userId,
  872. userName: item.userName,
  873. receiptFormId: this.currentReceipt.id
  874. }
  875. if (item.id) {
  876. await uni.$u.api.clueCommissionUpdate(data)
  877. } else {
  878. await uni.$u.api.clueCommissionAdd(data)
  879. }
  880. }
  881. },
  882. selectIsWarehouse() {
  883. this.showIsWarehousePicker = true
  884. },
  885. handleConfirmIsWarehouse({ value }) {
  886. this.isWarehouse = value[0].value
  887. this.isWarehouseLabel = value[0].label
  888. this.showIsWarehousePicker = false
  889. },
  890. }
  891. }
  892. </script>
  893. <style scoped lang="scss">
  894. @import '../styles/common.scss';
  895. .page-four-container {
  896. @extend .page-container;
  897. padding-bottom: 100rpx;
  898. }
  899. .address-section {
  900. padding: 20rpx;
  901. // 防止 label 换行
  902. ::v-deep .u-form-item__body__left__content__label {
  903. white-space: nowrap !important;
  904. overflow: visible;
  905. }
  906. }
  907. .info-row {
  908. margin-bottom: 20rpx;
  909. }
  910. .info-input {
  911. height: 65rpx;
  912. border-radius: 8rpx;
  913. border: 1rpx solid #e5e7eb;
  914. padding: 20rpx 16rpx;
  915. width: 100%;
  916. box-sizing: border-box;
  917. }
  918. .info-textarea {
  919. width: 100%;
  920. box-sizing: border-box;
  921. ::v-deep .u-textarea {
  922. min-height: 200rpx;
  923. border-radius: 8rpx;
  924. border: 1rpx solid #e5e7eb;
  925. padding: 20rpx 16rpx;
  926. line-height: 1.5;
  927. }
  928. ::v-deep textarea {
  929. min-height: 200rpx;
  930. border-radius: 8rpx;
  931. width: 100%;
  932. box-sizing: border-box;
  933. line-height: 1.5;
  934. font-size: 28rpx;
  935. }
  936. }
  937. .click-wrapper {
  938. width: 100%;
  939. cursor: pointer;
  940. display: flex;
  941. align-items: center;
  942. }
  943. .image-uploader {
  944. width: 100%;
  945. height: 65rpx;
  946. border: 2rpx dashed #409eff;
  947. border-radius: 8rpx;
  948. display: flex;
  949. align-items: center;
  950. justify-content: center;
  951. cursor: pointer;
  952. background-color: #ecf5ff;
  953. }
  954. .image-preview {
  955. width: 100%;
  956. height: 100%;
  957. object-fit: cover;
  958. border-radius: 10rpx;
  959. }
  960. .split-table {
  961. width: 100%;
  962. margin-top: 20rpx;
  963. }
  964. .split-table-header {
  965. background-color: #f5f7fa;
  966. padding: 15rpx 0;
  967. border-bottom: 1rpx solid #e4e7ed;
  968. }
  969. .split-table-row {
  970. padding: 15rpx 0;
  971. border-bottom: 1rpx solid #e4e7ed;
  972. align-items: center;
  973. }
  974. .header-text {
  975. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  976. text-align: center;
  977. display: block;
  978. }
  979. .table-cell {
  980. display: flex;
  981. align-items: center;
  982. justify-content: center;
  983. padding: 0 10rpx;
  984. }
  985. .percentage-input {
  986. text-align: center;
  987. background-color: #f9f9f9;
  988. padding: 0rpx !important;
  989. }
  990. .account-type {
  991. padding: 4rpx 16rpx;
  992. border-radius: 12rpx;
  993. font-size: 24rpx;
  994. font-weight: 500;
  995. color: #fff;
  996. text-align: center;
  997. cursor: pointer;
  998. &.frontend {
  999. background-color: #409eff;
  1000. }
  1001. &.backend {
  1002. background-color: #909399;
  1003. }
  1004. }
  1005. .radio-wrapper {
  1006. cursor: pointer;
  1007. display: flex;
  1008. align-items: center;
  1009. justify-content: center;
  1010. }
  1011. .radio-circle {
  1012. width: 32rpx;
  1013. height: 32rpx;
  1014. border-radius: 50%;
  1015. border: 2rpx solid #dcdfe6;
  1016. display: flex;
  1017. align-items: center;
  1018. justify-content: center;
  1019. transition: all 0.3s ease;
  1020. &.active {
  1021. border-color: #67c23a;
  1022. background-color: #67c23a;
  1023. }
  1024. }
  1025. .confirm-button-container {
  1026. padding: 40rpx 0;
  1027. margin-top: 20rpx;
  1028. }
  1029. .confirm-button-container .next-btn {
  1030. width: 100%;
  1031. height: 80rpx;
  1032. line-height: 80rpx;
  1033. text-align: center;
  1034. border-radius: 11px;
  1035. }
  1036. .add-button-container {
  1037. justify-content: space-between;
  1038. }
  1039. </style>