taskForm.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. <template>
  2. <view class="task-form-container">
  3. <u-sticky offset-top="50">
  4. <view class="subsection-bar">
  5. <view
  6. v-for="(item, index) in list"
  7. :key="index"
  8. class="subsection-item"
  9. :class="{ 'subsection-item-active': curNow === index }"
  10. @click="sectionChange(index)"
  11. >
  12. <text class="subsection-text">{{ item }}</text>
  13. </view>
  14. </view>
  15. </u-sticky>
  16. <view v-show='curNow===0'>
  17. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
  18. <u-form-item label="发货单据编码" prop="docNo" borderBottom>
  19. <u--input style="width: 100%;" disabled v-model="form.docNo"></u--input>
  20. </u-form-item>
  21. <u-form-item label="订单编码" prop="orderNo" borderBottom>
  22. <u--input style="width: 100%;" disabled v-model="form.orderNo"></u--input>
  23. </u-form-item>
  24. <u-form-item label="客户名称" prop="contactName" borderBottom>
  25. <u--input style="width: 100%;" disabled v-model="form.contactName"></u--input>
  26. </u-form-item>
  27. <u-form-item label="客户联系人" prop="linkName" borderBottom>
  28. <u--input style="width: 100%;" disabled v-model="form.linkName"></u--input>
  29. </u-form-item>
  30. <u-form-item label="客户电话" prop="linkPhone" borderBottom>
  31. <u--input style="width: 100%;" disabled v-model="form.linkPhone"></u--input>
  32. </u-form-item>
  33. <u-form-item label="客户地址" prop="receiveAddress" borderBottom>
  34. <u--input style="width: 100%;" disabled v-model="form.receiveAddress"></u--input>
  35. </u-form-item>
  36. <u-form-item label="车牌号" prop="carNo" borderBottom>
  37. <u--input style="width: 100%;" disabled v-model="form.carNo"></u--input>
  38. </u-form-item>
  39. <u-form-item label="是否回执" prop="replied" borderBottom>
  40. <u--input style="width: 100%;" disabled v-model="form.repliedStr"></u--input>
  41. </u-form-item>
  42. <u-form-item label="制单人" prop="makerName" borderBottom>
  43. <u--input style="width: 100%;" disabled v-model="form.makerName"></u--input>
  44. </u-form-item>
  45. </u--form>
  46. </view>
  47. <view v-show='curNow===1'>
  48. <view v-for="(item,index) in form['productList']" :key="index">
  49. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" labelWidth='140rpx'>
  50. <u-row v-for="(key,index1) in tableField" :key="index1">
  51. <u-col :span="12">
  52. <u-form-item :label="key.label" prop="categoryName" borderBottom>
  53. <!-- <u--input style="width: 100%;" :title='item[key.field]' disabled
  54. v-model="item[key.field]"></u--input> -->
  55. {{ key.formatter ? key.formatter(item) : item[key.field] }}
  56. </u-form-item>
  57. </u-col>
  58. </u-row>
  59. </u--form>
  60. <u-gap height="40" bgColor="#f0f0f0"></u-gap>
  61. </view>
  62. </view>
  63. <view v-show="curNow===2">
  64. <u--form style="margin: 0 20px;" labelPosition="left" :model="formData" ref="outForm" :rules="outRules" labelWidth='140rpx'>
  65. <u-form-item label="出库场景" prop="bizType" borderBottom>
  66. <u--input style="width: 100%;" disabled v-model="formData.bizTypeStr"></u--input>
  67. </u-form-item>
  68. <u-form-item label="单据来源" prop="sourceBizNo" borderBottom>
  69. <u--input style="width: 100%;" disabled v-model="formData.sourceBizNo"></u--input>
  70. </u-form-item>
  71. <u-form-item label="出库物品类型" prop="extInfo.assetType" borderBottom>
  72. <u--input style="width: 100%;" disabled v-model="formData.extInfo.assetTypeName"></u--input>
  73. </u-form-item>
  74. <u-form-item label="出库时间" prop="storageTime" borderBottom>
  75. <!-- <u--input style="width: 100%;" disabled v-model="formData.storageTime"></u--input> -->
  76. <!-- <uni-datetime-picker :end="finishTime" type="datetime" slot="value" v-model="formData.storageTime"
  77. @change="starTimeChange"> -->
  78. <uni-datetime-picker type="datetime" v-model="formData.storageTime" @change="changeStorageTime" />
  79. <!-- </uni-datetime-picker> -->
  80. </u-form-item>
  81. <u-form-item label="出库登记人" prop="extInfo.createUserName" borderBottom>
  82. <u--input style="width: 100%;" disabled v-model="formData.extInfo.createUserName"></u--input>
  83. </u-form-item>
  84. <u-form-item label="领料人部门" prop="extInfo.verifyDeptName" borderBottom required>
  85. <u--input style="width: 100%;" v-model="formData.extInfo.verifyDeptName" @click.native="openDepartmentPicker"></u--input>
  86. <!-- <view :style="{ color: formData.extInfo.verifyDeptName ? 'black' : '#c0c4cc' }" class="assetType_box"
  87. @click="openDepartmentPicker">
  88. {{ formData.extInfo.verifyDeptName ? formData.extInfo.verifyDeptName : '请选择领料部门' }}
  89. </view> -->
  90. </u-form-item>
  91. <u-form-item label="领料人" prop="fromUser" borderBottom required>
  92. <u--input style="width: 100%;" v-model="formData.fromUser" @click.native="openUserPicker"></u--input>
  93. <!-- <view :style="{ color: formData.fromUser ? 'black' : '#c0c4cc' }" class="assetType_box"
  94. @click="openUserPicker">
  95. {{ formData.fromUser ? formData.fromUser : '请选择领料人' }}
  96. </view> -->
  97. </u-form-item>
  98. <u-form-item label="客户名称" prop="clientName" borderBottom>
  99. <u--input style="width: 100%;" disabled v-model="formData.clientName"></u--input>
  100. </u-form-item>
  101. <u-form-item label="备注" prop="remark" borderBottom>
  102. <u--input style="width: 100%;" v-model="formData.remark"></u--input>
  103. </u-form-item>
  104. </u--form>
  105. <ba-tree-picker ref="departmentPicker" :multiple="false" @select-change="departmentConfirm" title="选择领料部门"
  106. :localdata="departmentOption" valueKey="id" textKey="name" childrenKey="children" />
  107. <!-- 选择领料人 -->
  108. <ba-tree-picker ref="userPicker" :multiple="false" @select-change="userConfirm" title="选择领料人"
  109. :localdata="userOption" valueKey="id" textKey="name" childrenKey="children" />
  110. </view>
  111. <view class="tab-content" v-show="curNow===3">
  112. <!-- <u-row v-if="isEdit">
  113. <u-col :span="3" offset="9">
  114. <u-button type="primary" size="small" text="添加" @click="addStock(item, index)"></u-button>
  115. </u-col>
  116. </u-row> -->
  117. <view v-if="productList.length === 0" class="empty-tip" style="text-align: center; color: #999; font-size: 28rpx; padding: 100rpx 0;">
  118. 暂无出库清单数据
  119. </view>
  120. <view v-else>
  121. <view v-for="(item, index) in productList" :key="index">
  122. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" labelWidth='140rpx'>
  123. <u-row v-for="(key,index1) in tableField2" :key="index1">
  124. <u-col :span="12">
  125. <u-form-item :label="key.label" borderBottom>
  126. <text>{{ key.formatter ? key.formatter(item) : item[key.field] }}</text>
  127. </u-form-item>
  128. </u-col>
  129. </u-row>
  130. <u-row v-if="isEdit">
  131. <u-col :span="3" offset="9">
  132. <u-button type="error" size="small" text="删除" @click="deleteProductList(item, index)"></u-button>
  133. </u-col>
  134. </u-row>
  135. </u--form>
  136. <u-gap height="40" bgColor="#f0f0f0"></u-gap>
  137. </view>
  138. </view>
  139. <view v-if="isEdit" class="add" @click="addStock">
  140. <u-icon name="plus" color="#fff"></u-icon>
  141. </view>
  142. </view>
  143. <view v-show="curNow===4">
  144. <view v-if="packingList.length === 0" class="empty-tip" style="text-align: center; color: #999; font-size: 28rpx; padding: 100rpx 0;">
  145. 暂无包装清单数据
  146. </view>
  147. <view v-else>
  148. <view v-for="(item, index) in packingList" :key="index">
  149. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" labelWidth='140rpx'>
  150. <u-row v-for="(key,index1) in tableField3" :key="index1">
  151. <u-col :span="12">
  152. <u-form-item :label="key.label" borderBottom>
  153. <text>{{ key.formatter ? key.formatter(item) : (item[key.field] || '-') }}</text>
  154. </u-form-item>
  155. </u-col>
  156. </u-row>
  157. </u--form>
  158. <u-gap height="40" bgColor="#f0f0f0"></u-gap>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. </template>
  164. <script>
  165. import { getByIdOnlyReplaceAPI, getUserById } from '@/api/wt/index.js'
  166. import { outputSceneState } from '@/enum/dict.js'
  167. import { parameterGetByCode } from '@/api/mainData/index.js'
  168. import { toTreeData } from '@/utils/utils.js'
  169. import { listOrganizations, getUserPage } from '@/api/common'
  170. import { getHierarchyFifo, getProduceTreeByPid } from '@/api/warehouseManagement/index.js'
  171. export default {
  172. props: {
  173. businessId: {
  174. default: ''
  175. },
  176. taskDefinitionKey: {
  177. default: ''
  178. },
  179. bizType: {
  180. default: 3
  181. },
  182. type: {
  183. default: '销售发货出库'
  184. },
  185. isEdit: {
  186. default: true
  187. }
  188. },
  189. data() {
  190. return {
  191. outRules: {
  192. verifyDeptName: {
  193. required: true,
  194. message: '请选择领料部门',
  195. trigger: ['blur', 'change']
  196. },
  197. fromUser: {
  198. required: true,
  199. message: '请选择领料人',
  200. trigger: ['blur', 'change']
  201. }
  202. },
  203. outputSceneState,
  204. clientEnvironmentId:
  205. uni.getStorageSync("userInfo") &&
  206. uni.getStorageSync("userInfo").clientEnvironmentId,
  207. pricingWayList: [
  208. { id: 1, name: '按数量计价' },
  209. { id: 2, name: '按重量计价' },
  210. { id: 3, name: '按增重计价' }
  211. ],
  212. form: {},
  213. tableField: [{
  214. label: '名称',
  215. field: 'productName',
  216. },
  217. {
  218. label: '计价方式',
  219. field: 'pricingWay',
  220. formatter: (row) => {
  221. return this.pricingWayList.find(item => item.id === row.pricingWay)?.name || '';
  222. }
  223. },
  224. {
  225. label: '编码',
  226. field: 'productCode',
  227. },
  228. {
  229. label: '类型',
  230. field: 'productCategoryName',
  231. },
  232. {
  233. label: '客户代号',
  234. field: 'customerMark',
  235. },
  236. {
  237. label: '单价',
  238. field: 'singlePrice',
  239. },
  240. {
  241. label: '数量',
  242. field: 'totalCount',
  243. },
  244. {
  245. label: '合计',
  246. field: 'totalPrice',
  247. },
  248. ],
  249. tableField2: [{
  250. label: '名称',
  251. field: 'categoryName',
  252. },
  253. {
  254. label: '编码',
  255. field: 'categoryCode',
  256. },
  257. {
  258. label: '型号',
  259. field: 'categoryModel',
  260. },
  261. {
  262. label: '规格',
  263. field: 'specification',
  264. },
  265. {
  266. label: '牌号',
  267. field: 'brandNum',
  268. },
  269. {
  270. label: '批次号',
  271. field: 'batchNo',
  272. },
  273. {
  274. label: '颜色',
  275. field: 'colorKey',
  276. },
  277. {
  278. label: '计量数量',
  279. field: 'measureQuantity',
  280. },
  281. {
  282. label: '计量单位',
  283. field: 'measureUnit',
  284. },
  285. {
  286. label: '重量',
  287. field: 'weight',
  288. },
  289. {
  290. label: '重量单位',
  291. field: 'weightUnit',
  292. },
  293. {
  294. label: '单价',
  295. field: 'price',
  296. },
  297. {
  298. label: '金额',
  299. field: 'totalMoney',
  300. },
  301. {
  302. label: '仓库',
  303. field: 'warehouseName',
  304. },
  305. {
  306. label: '机型',
  307. field: 'modelKey',
  308. },
  309. {
  310. label: '供应商',
  311. field: 'supplierName',
  312. },
  313. {
  314. label: '供应商代号',
  315. field: 'supplierCode',
  316. },
  317. ],
  318. tableField3: [{
  319. label: '编码',
  320. field: 'categoryCode',
  321. },
  322. {
  323. label: '名称',
  324. field: 'categoryName',
  325. },
  326. {
  327. label: '批次号',
  328. field: 'batchNo',
  329. },
  330. {
  331. label: '发货条码',
  332. field: 'barcodes',
  333. },
  334. {
  335. label: '包装编码',
  336. field: 'packageNo',
  337. },
  338. {
  339. label: '包装数量',
  340. field: 'packingQuantity',
  341. },
  342. {
  343. label: '包装单位',
  344. field: 'packingUnit',
  345. },
  346. {
  347. label: '计量数量',
  348. field: 'measureQuantity',
  349. },
  350. {
  351. label: '计量单位',
  352. field: 'measureUnit',
  353. },
  354. {
  355. label: '物料代号',
  356. field: 'materielDesignation',
  357. },
  358. {
  359. label: '客户代号',
  360. field: 'clientCode',
  361. },
  362. {
  363. label: '刻码',
  364. field: 'engrave',
  365. },
  366. {
  367. label: '重量',
  368. field: 'weight',
  369. },
  370. {
  371. label: '重量单位',
  372. field: 'weightUnit',
  373. },
  374. {
  375. label: '机型',
  376. field: 'modelKey',
  377. },
  378. {
  379. label: '颜色',
  380. field: 'colorKey',
  381. },
  382. {
  383. label: '质检结果',
  384. field: 'result',
  385. formatter: (row) => {
  386. return this.qualityResults[row.result] || '-';
  387. }
  388. },
  389. {
  390. label: '质检状态',
  391. field: 'status',
  392. formatter: (row) => {
  393. return this.qualityStatus[row.status] || '-';
  394. }
  395. },
  396. {
  397. label: '生产日期',
  398. field: 'productionDate',
  399. },
  400. {
  401. label: '采购日期',
  402. field: 'purchaseDate',
  403. },
  404. {
  405. label: '供应商',
  406. field: 'supplierName',
  407. },
  408. {
  409. label: '供应商代号',
  410. field: 'supplierCode',
  411. },
  412. ],
  413. qualityResults: { 1: '合格', 2: '不合格' },
  414. qualityStatus: { 1: '未质检', 2: '已质检' },
  415. dimension: '3',
  416. curNow: 0,
  417. isPrice: 1,
  418. departmentOption: [],
  419. userOption: [],
  420. userInfo: {},
  421. formData: {
  422. storageTime: '',
  423. extInfo: {
  424. assetType: [], //物品类型id
  425. assetTypeName: '', //物品类型名称
  426. deptCode: '', //部门code
  427. deptName: '', //部门名称
  428. verifyDeptCode: '', //审核部门编码
  429. verifyDeptName: '', //审核部门名称
  430. deliveryName: '', //送货人名称
  431. fromUserPhone: '', //送货人电话
  432. sourceBizNo: '', //销售订单
  433. urgent: '', //紧急状态
  434. supplierId: '', //供应商ID
  435. supplierName: '', //供应商名称
  436. createUserName: '', //创建人名字
  437. contentImage: [] //图片数组
  438. },
  439. fromId: '', //领料人
  440. fromUser: '', //送货人
  441. bizType: '', //物品类型
  442. verifyId: '', //审核人Id
  443. verifyName: '', //审核人名称
  444. createUserId: '',
  445. remark: '',
  446. type: 2
  447. },
  448. productList: [],
  449. packingList: [],
  450. showPackingList: [],
  451. newColumns: [],
  452. goodsLists: [],
  453. }
  454. },
  455. computed: {
  456. list() {
  457. if(this.taskDefinitionKey == 'storemanApprove') {
  458. return ['发货信息', '物品清单', '出库信息', '出库清单', '包装清单']
  459. } else {
  460. return ['发货信息', '物品清单']
  461. }
  462. },
  463. columns() {
  464. const columns = [
  465. {
  466. columnKey: 'index',
  467. label: '序号',
  468. type: 'index',
  469. width: 55,
  470. align: 'center',
  471. showOverflowTooltip: true,
  472. fixed: 'left'
  473. },
  474. {
  475. label: '编码',
  476. prop: 'categoryCode',
  477. align: 'center',
  478. width: 150,
  479. showOverflowTooltip: true
  480. },
  481. {
  482. label: '名称',
  483. prop: 'categoryName',
  484. align: 'center',
  485. width: 150,
  486. showOverflowTooltip: true
  487. }
  488. ];
  489. // 级别 - 仅 clientEnvironmentId == 4 时显示
  490. if (this.clientEnvironmentId == 4) {
  491. columns.push({
  492. label: '级别',
  493. prop: 'level',
  494. align: 'center'
  495. });
  496. }
  497. // 型号、规格、牌号
  498. columns.push(
  499. {
  500. label: '型号',
  501. prop: 'categoryModel',
  502. align: 'center',
  503. showOverflowTooltip: true
  504. },
  505. {
  506. label: '规格',
  507. prop: 'specification',
  508. align: 'center',
  509. showOverflowTooltip: true
  510. },
  511. {
  512. label: '牌号',
  513. prop: 'brandNum',
  514. align: 'center',
  515. showOverflowTooltip: true
  516. }
  517. );
  518. // 动态列
  519. this.newColumns.forEach(item => {
  520. columns.push({
  521. label: item.label,
  522. prop: item.prop,
  523. width: 120,
  524. align: item.align,
  525. showOverflowTooltip: item.showOverflowTooltip
  526. });
  527. });
  528. // 批次号
  529. columns.push({
  530. label: '批次号',
  531. prop: 'batchNo',
  532. align: 'center',
  533. showOverflowTooltip: true
  534. });
  535. // 包装数量、单位
  536. columns.push(
  537. {
  538. label: '包装数量',
  539. prop: 'packingQuantity',
  540. width: 80
  541. },
  542. {
  543. label: '单位',
  544. prop: 'packingUnit'
  545. }
  546. );
  547. // 计量数量、计量单位
  548. columns.push(
  549. {
  550. label: '计量数量',
  551. prop: 'measureQuantity',
  552. showOverflowTooltip: true
  553. },
  554. {
  555. label: '计量单位',
  556. prop: 'measureUnit'
  557. }
  558. );
  559. // 重量、重量单位
  560. columns.push(
  561. {
  562. label: '重量',
  563. prop: 'weight',
  564. align: 'center',
  565. showOverflowTooltip: true
  566. },
  567. {
  568. label: '重量单位',
  569. prop: 'weightUnit',
  570. align: 'center',
  571. showOverflowTooltip: true
  572. }
  573. );
  574. // 机型、颜色、锁定数量、库存
  575. columns.push(
  576. {
  577. label: '机型',
  578. prop: 'modelKey',
  579. width: 150
  580. },
  581. {
  582. label: '颜色',
  583. prop: 'colorKey',
  584. width: 150
  585. },
  586. {
  587. label: '锁定数量',
  588. prop: 'lockQuantity',
  589. width: 100
  590. },
  591. {
  592. label: '库存',
  593. prop: 'stockNum',
  594. align: 'center',
  595. showOverflowTooltip: true
  596. }
  597. );
  598. // 单价 - 条件显示
  599. if (this.isPrice == 1) {
  600. columns.push({
  601. label: '单价',
  602. prop: 'price',
  603. align: 'center',
  604. slot: 'price'
  605. });
  606. }
  607. // 金额 - 条件显示
  608. if (this.isPrice == 1) {
  609. columns.push({
  610. label: '金额',
  611. prop: 'totalMoney',
  612. align: 'center',
  613. showOverflowTooltip: true,
  614. slot: 'totalMoney'
  615. });
  616. }
  617. // 采购原因 - 仅 clientEnvironmentId == 4 时显示
  618. if (this.clientEnvironmentId == 4) {
  619. columns.push({
  620. label: '采购原因',
  621. prop: 'purpose',
  622. align: 'center',
  623. showOverflowTooltip: true
  624. });
  625. }
  626. // 仓库、供应商、供应商代号
  627. columns.push(
  628. {
  629. label: '仓库',
  630. prop: 'warehouseName',
  631. width: 150,
  632. showOverflowTooltip: true
  633. },
  634. {
  635. label: '供应商',
  636. prop: 'supplierName',
  637. minWidth: 150,
  638. showOverflowTooltip: true
  639. },
  640. {
  641. label: '供应商代号',
  642. prop: 'supplierCode',
  643. minWidth: 150,
  644. showOverflowTooltip: true
  645. }
  646. );
  647. // 操作列 - 仅在可编辑时显示
  648. if (this.isEdit) {
  649. columns.push({
  650. label: '操作',
  651. width: 120,
  652. align: 'center',
  653. slot: 'action',
  654. fixed: 'right'
  655. });
  656. }
  657. return columns;
  658. }
  659. },
  660. beforeDestroy() {
  661. uni.$off('setSelectList')
  662. uni.removeStorageSync('productList')
  663. },
  664. created() {
  665. uni.$on('setSelectList', async (data, dimension) => {
  666. uni.removeStorageSync('productList')
  667. console.log('setSelectList~~~', data, dimension)
  668. if (data?.length) {
  669. this.detailData(data, dimension)
  670. }
  671. })
  672. },
  673. async mounted() {
  674. this.userInfo = uni.getStorageSync('userInfo')
  675. this.$nextTick(() => {
  676. this.$refs.outForm?.setRules(this.outRules)
  677. })
  678. await this.getListItems()
  679. //仓库出入库是否显示金额(0:不显示 1:显示)
  680. parameterGetByCode({
  681. code: 'wms_price'
  682. }).then((res) => {
  683. this.isPrice = res.value;
  684. });
  685. await this.initDeptData();
  686. await this.getDetailData(this.businessId);
  687. },
  688. methods: {
  689. // 打开领料部门选择器
  690. openDepartmentPicker() {
  691. this.$refs.departmentPicker._show()
  692. },
  693. departmentConfirm(data, name, allList) {
  694. this.formData.extInfo.verifyDeptCode = data[0]
  695. this.formData.extInfo.verifyDeptName = name
  696. this.formData.fromId = ''
  697. this.formData.fromUser = ''
  698. this.getStaffList(data[0])
  699. },
  700. // 打开领料人选择器
  701. openUserPicker() {
  702. this.$refs.userPicker._show()
  703. },
  704. userConfirm(data, name) {
  705. this.formData.fromId = data[0]
  706. this.formData.fromUser = name
  707. },
  708. changeStorageTime(e) {
  709. console.log(e, 'changeStorageTime');
  710. },
  711. // 获取物品列表
  712. async getListItems() {
  713. const res = await getProduceTreeByPid({});
  714. this.goodsLists = res;
  715. },
  716. getFieldModel() {
  717. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  718. let newRes = res.map((m) => {
  719. return {
  720. prop: 'extField.' + m.prop,
  721. label: m.label,
  722. align: 'center',
  723. showOverflowTooltip: true
  724. };
  725. });
  726. this.newColumns = [...newRes];
  727. });
  728. },
  729. // 获取当前时间 YYYY-MM-DD HH:mm:ss
  730. getCurrentTime() {
  731. const now = new Date();
  732. const year = now.getFullYear();
  733. const month = String(now.getMonth() + 1).padStart(2, '0');
  734. const day = String(now.getDate()).padStart(2, '0');
  735. const hours = String(now.getHours()).padStart(2, '0');
  736. const minutes = String(now.getMinutes()).padStart(2, '0');
  737. const seconds = String(now.getSeconds()).padStart(2, '0');
  738. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  739. },
  740. initFormData() {
  741. console.log('initFormData~~~', this.outputSceneState)
  742. // 出库类型
  743. this.formData.bizType = this.bizType;
  744. this.formData.storageTime = this.getCurrentTime();
  745. this.formData.bizTypeStr = this.outputSceneState.find(item => item.code == this.bizType)?.label || ''
  746. this.formData.extInfo.assetType = Array.from(
  747. new Set(this.form.topCategoryIds?.split(','))
  748. );
  749. this.formData.extInfo.assetTypeName = this.formData.extInfo.assetType.map(id => {
  750. const item = this.goodsLists.find(g => g.id == id);
  751. return item?.name || id;
  752. }).join(',');
  753. console.log('formData.extInfo.assetTypeName:', this.formData.extInfo.assetTypeName);
  754. // 添加单据来源
  755. this.formData.sourceBizNo = this.form?.docNo;
  756. // 入库登记人
  757. this.formData.extInfo.createUserId = this.userInfo.userId;
  758. this.formData.extInfo.createUserName = this.userInfo.name;
  759. this.formData.createUserId = this.userInfo.userId;
  760. if (this.form.makerId) {
  761. getUserById(this.form.makerId).then((res) => {
  762. console.log(res, 'makerId');
  763. this.$set(this.formData.extInfo, 'verifyDeptCode', res.groupId);
  764. this.$set(this.formData.extInfo, 'verifyDeptName', res.groupName);
  765. });
  766. }
  767. // 销售相关逻辑
  768. if (this.form.productList?.length > 0) {
  769. this.formData.clientName = this.form.contactName;
  770. this.formData.clientCode = this.form.contactCode;
  771. // 获取领料人列表
  772. this.getStaffList(this.form.deptId).then(() => {
  773. // 获取领料人和领料部门
  774. this.formData.fromId = this.form.makerId;
  775. this.formData.fromUser = this.form.makerName;
  776. this.formData.extInfo.verifyDeptCode = this.form.deptId;
  777. this.formData.extInfo.verifyDeptName = this.form.deptName;
  778. });
  779. console.log(this.form.productList, 'this.saleProductList11111');
  780. let pData = {
  781. type: '1',
  782. deliveryNo: this.formData.sourceBizNo,
  783. builders: this.form.productList.map((item) => {
  784. return {
  785. categoryId: item.productId || item.categoryId,
  786. num: item.totalCount,
  787. // warehouseId: this.bizType == 3 ? item.warehouseId : ''
  788. batchNo: item.batchNo || '',
  789. };
  790. })
  791. };
  792. console.log('111~~~~~~~~', pData)
  793. getHierarchyFifo(pData)
  794. .then((data) => {
  795. this.detailData(data, this.dimension);
  796. })
  797. .catch((err) => {
  798. console.log(err);
  799. });
  800. }
  801. console.log('formData~~~', this.formData)
  802. },
  803. detailData(data, dimension) {
  804. console.log('detailData~~~', data, dimension)
  805. this.dimension = dimension;
  806. const mergedData = [...(this.formData.outInDetailList || []), ...data];
  807. this.formData.outInDetailList = mergedData;
  808. this.productList = data.map((productItem) => {
  809. return {
  810. ...productItem,
  811. suspendBatchNo: productItem.batchNo || '',
  812. outInDetailRecordRequestList:
  813. productItem.outInDetailRecordRequestList.map((packingItem) => {
  814. return {
  815. ...packingItem,
  816. workOrderId:
  817. this.type === '自选领用出库'
  818. ? this.form.detailList[0].workOrderId
  819. : '',
  820. pickOrderId:
  821. this.type === '自选领用出库'
  822. ? this.form.detailList[0].pickOrderId
  823. : '',
  824. taskId:
  825. this.type === '自选领用出库'
  826. ? this.form.detailList[0].taskId
  827. : '',
  828. categoryName: productItem.categoryName,
  829. categoryCode: productItem.categoryCode,
  830. supplierCode: productItem.supplierCode,
  831. supplierName: productItem.supplierName,
  832. materialDetailList: packingItem.materialDetailList.map(
  833. (materialItem) => {
  834. return {
  835. ...materialItem,
  836. categoryName: productItem.categoryName,
  837. categoryCode: productItem.categoryCode,
  838. supplierCode: productItem.supplierCode,
  839. supplierName: productItem.supplierName
  840. };
  841. }
  842. )
  843. };
  844. })
  845. };
  846. });
  847. const newProducts = mergedData.map((productItem) => ({
  848. ...productItem,
  849. suspendBatchNo: productItem.batchNo || '',
  850. outInDetailRecordRequestList:
  851. productItem.outInDetailRecordRequestList.map((packingItem) => ({
  852. ...packingItem,
  853. categoryName: productItem.categoryName,
  854. categoryCode: productItem.categoryCode,
  855. supplierCode: productItem.supplierCode,
  856. supplierName: productItem.supplierName,
  857. workOrderId:
  858. this.type === '自选领用出库'
  859. ? this.form.detailList[0].workOrderId
  860. : '',
  861. pickOrderId:
  862. this.type === '自选领用出库'
  863. ? this.form.detailList[0].pickOrderId
  864. : '',
  865. taskId:
  866. this.type === '自选领用出库'
  867. ? this.form.detailList[0].taskId
  868. : '',
  869. materialDetailList: packingItem.materialDetailList.map(
  870. (materialItem) => ({
  871. ...materialItem,
  872. categoryName: productItem.categoryName,
  873. categoryCode: productItem.categoryCode,
  874. supplierCode: productItem.supplierCode,
  875. supplierName: productItem.supplierName
  876. })
  877. )
  878. }))
  879. }));
  880. // 去重合并产品列表和新产品列表
  881. const uniqueProducts = [
  882. ...new Map(
  883. [...this.productList, ...newProducts].map((item) => [item.id, item])
  884. ).values()
  885. ];
  886. this.productList = uniqueProducts;
  887. console.log('111111111111111');
  888. console.log(this.productList);
  889. // 排序
  890. this.productList.sort((a, b) => a.categoryCode - b.categoryCode);
  891. // 获取包装维度数据
  892. const arr = [];
  893. for (const key in this.productList) {
  894. for (const k in this.productList[key].outInDetailRecordRequestList) {
  895. arr.push({
  896. ...this.productList[key].outInDetailRecordRequestList[k]
  897. });
  898. }
  899. }
  900. this.packingList = arr;
  901. const newPacking = [];
  902. newProducts.forEach((item) => {
  903. newPacking.push(...item.outInDetailRecordRequestList);
  904. });
  905. //去重
  906. const newPackingList = [
  907. ...new Map(
  908. [...this.packingList, ...newPacking].map((item) => [item.id, item])
  909. ).values()
  910. ];
  911. this.packingList = newPackingList;
  912. this.packingList.sort((a, b) => a.categoryCode - b.categoryCode);
  913. // 获取物料维度数据
  914. // let iArr = [];
  915. // arr.forEach((item) => {
  916. // item.materialDetailList.forEach((ele) => {
  917. // iArr.push({ ...ele });
  918. // });
  919. // });
  920. // this.materialList = iArr;
  921. // const newMaterial = [];
  922. // newPacking.forEach((item) => {
  923. // newMaterial.push(...item.materialDetailList);
  924. // });
  925. // this.materialList = [...this.materialList, ...newMaterial];
  926. // 触发分页更新
  927. // this.pickingPageNum = 1;
  928. // this.materielPageNum = 1;
  929. // this.pickingFetchData();
  930. // this.materielFetchData();
  931. this.formData.outInDetailList = this.productList;
  932. console.log(this.productList, 'this.productList');
  933. console.log(this.packingList, 'this.packingList');
  934. },
  935. // 部门列表
  936. async initDeptData() {
  937. let deptTreeList = await listOrganizations()
  938. this.departmentOption = toTreeData({
  939. data: deptTreeList,
  940. idField: 'id',
  941. parentIdField: 'parentId'
  942. })
  943. },
  944. async getStaffList(id) {
  945. uni.showLoading({
  946. title: '加载中',
  947. mask: true
  948. })
  949. let res = await getUserPage({
  950. groupId: id,
  951. size: 9999,
  952. page: 1
  953. })
  954. uni.hideLoading()
  955. this.userOption = res.list
  956. },
  957. sectionChange(index) {
  958. this.curNow = index;
  959. },
  960. addStock() {
  961. console.log(this.formData.extInfo.assetType);
  962. if (
  963. !(
  964. this.formData.extInfo.assetType &&
  965. this.formData.extInfo.assetType.length > 0
  966. )
  967. )
  968. return uni.$u.toast('请选择出库产品类型')
  969. if (!this.formData.bizType && this.formData.bizType !== 0)
  970. return uni.$u.toast('请选择出库场景');
  971. uni.setStorageSync('productList', this.productList)
  972. uni.navigateTo({
  973. url: '/pages/warehouse/outHouse/selectOutType?assetType=' + this.formData.extInfo.assetType
  974. })
  975. },
  976. // 删除产品
  977. deleteProductList(row, index) {
  978. uni.showModal({
  979. title: '提示',
  980. content: '确定删除该产品吗?',
  981. success: (res) => {
  982. if (res.confirm) {
  983. this.productList.splice(index, 1);
  984. }
  985. }
  986. });
  987. },
  988. async getDetailData(id) {
  989. const data = await getByIdOnlyReplaceAPI(id);
  990. data.repliedStr = data.replied === 1 ? '是' : '否';
  991. this.form = data;
  992. console.log('form~~~', this.form)
  993. this.initFormData();
  994. },
  995. async getReturnStorage() {
  996. try {
  997. const valid = await this.$refs.outForm.validate();
  998. console.log('valid~~~', valid);
  999. if (!this.productList?.length) {
  1000. return uni.$u.toast('请添加出库明细!');
  1001. }
  1002. let obj = JSON.parse(JSON.stringify({ ...this.formData, type: 2 }));
  1003. obj.extInfo.sourceBizNo = obj.sourceBizNo;
  1004. obj.fromType = obj.type;
  1005. // 处理物品类型assetType
  1006. obj.extInfo.assetType = obj.extInfo?.assetType.join(',');
  1007. // 处理仓库id
  1008. let warehouseId = [];
  1009. let warehouseName = [];
  1010. let warehouseIds = this.productList
  1011. .map((item) => item.warehouseId)
  1012. .flat();
  1013. let warehouseNames = this.productList
  1014. .map((item) => item.warehouseName)
  1015. .flat();
  1016. warehouseIds.forEach((item, index) => {
  1017. if (!warehouseId.includes(item)) {
  1018. warehouseId.push(item);
  1019. warehouseName.push(warehouseNames[index]);
  1020. }
  1021. });
  1022. obj.warehouseIds = warehouseId;
  1023. obj.warehouseNames = warehouseName;
  1024. console.log('2222', obj);
  1025. let isPass = false;
  1026. // 1按数量计费 2按重量计费
  1027. if (this.form.pricingWay == 2) {
  1028. // 判断包装重量是否全部大于0
  1029. isPass = this.packingList.every((item) => item.weight > 0);
  1030. } else {
  1031. isPass = true;
  1032. }
  1033. if (isPass) {
  1034. return obj;
  1035. } else {
  1036. uni.$u.toast('委外发货重量不能为空');
  1037. }
  1038. } catch (e) {
  1039. console.log('验证失败', e);
  1040. return null;
  1041. }
  1042. },
  1043. //
  1044. getTableValue() {
  1045. return new Promise(async (resolve, reject) => {
  1046. try {
  1047. // await this.$refs.uForm[0].validate()
  1048. // await this.$refs.outForm[0].validate()
  1049. resolve({
  1050. form: this.form,
  1051. returnStorageData: await this.getReturnStorage()
  1052. })
  1053. } catch {
  1054. reject(null)
  1055. }
  1056. })
  1057. },
  1058. }
  1059. }
  1060. </script>
  1061. <style scoped>
  1062. /* .task-form-container { */
  1063. /* padding-top: 20rpx; */
  1064. /* } */
  1065. .tab-content {
  1066. padding-top: 20rpx;
  1067. }
  1068. .subsection-bar {
  1069. display: flex;
  1070. background-color: #fff;
  1071. /* padding: 0 16rpx; */
  1072. margin: 16rpx;
  1073. border: 1px solid #ebedf0;
  1074. border-radius: 8rpx;
  1075. overflow: hidden;
  1076. }
  1077. .subsection-item {
  1078. flex: 1;
  1079. text-align: center;
  1080. padding: 12rpx 0;
  1081. margin: 0 4rpx;
  1082. border-bottom: 4rpx solid transparent;
  1083. transition: all 0.3s;
  1084. }
  1085. .subsection-item-active {
  1086. color: #fff;
  1087. background-color: #157A2C;
  1088. }
  1089. .subsection-text {
  1090. font-size: 25rpx;
  1091. color: #323233;
  1092. }
  1093. .subsection-item-active .subsection-text {
  1094. color: #fff;
  1095. }
  1096. .assetType_box {
  1097. padding: 12rpx 18rpx;
  1098. width: 100%;
  1099. overflow: hidden;
  1100. white-space: nowrap;
  1101. text-overflow: ellipsis;
  1102. font-size: 30rpx;
  1103. }
  1104. .add {
  1105. width: 96rpx;
  1106. height: 96rpx;
  1107. border-radius: 48rpx;
  1108. background: #3c9cff;
  1109. position: fixed;
  1110. bottom: 100rpx;
  1111. right: 24rpx;
  1112. display: flex;
  1113. align-items: center;
  1114. justify-content: center;
  1115. z-index: 99;
  1116. }
  1117. </style>