PageFour.vue 38 KB

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