PageFour.vue 34 KB

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