PageFour.vue 38 KB

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