taskForm.vue 31 KB

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