taskForm.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  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. initFormData() {
  721. console.log('initFormData~~~', this.outputSceneState)
  722. // this.getNowFormatDate();
  723. // 出库类型
  724. this.formData.bizType = this.bizType;
  725. this.formData.storageTime = Date.now() - 2*24*3600*1000;
  726. this.formData.bizTypeStr = this.outputSceneState.find(item => item.code == this.bizType)?.label || ''
  727. this.formData.extInfo.assetType = Array.from(
  728. new Set(this.form.topCategoryIds?.split(','))
  729. );
  730. this.formData.extInfo.assetTypeName = this.formData.extInfo.assetType.map(id => {
  731. const item = this.goodsLists.find(g => g.id == id);
  732. return item?.name || id;
  733. }).join(',');
  734. console.log('formData.extInfo.assetTypeName:', this.formData.extInfo.assetTypeName);
  735. // 添加单据来源
  736. this.formData.sourceBizNo = this.form?.docNo;
  737. // 入库登记人
  738. this.formData.extInfo.createUserId = this.userInfo.userId;
  739. this.formData.extInfo.createUserName = this.userInfo.name;
  740. this.formData.createUserId = this.userInfo.userId;
  741. if (this.form.makerId) {
  742. getUserById(this.form.makerId).then((res) => {
  743. console.log(res, 'makerId');
  744. this.$set(this.formData.extInfo, 'verifyDeptCode', res.groupId);
  745. this.$set(this.formData.extInfo, 'verifyDeptName', res.groupName);
  746. });
  747. }
  748. // 销售相关逻辑
  749. if (this.form.productList?.length > 0) {
  750. this.formData.clientName = this.form.contactName;
  751. this.formData.clientCode = this.form.contactCode;
  752. // 获取领料人列表
  753. this.getStaffList(this.form.deptId).then(() => {
  754. // 获取领料人和领料部门
  755. this.formData.fromId = this.form.makerId;
  756. this.formData.fromUser = this.form.makerName;
  757. this.formData.extInfo.verifyDeptCode = this.form.deptId;
  758. this.formData.extInfo.verifyDeptName = this.form.deptName;
  759. });
  760. console.log(this.form.productList, 'this.saleProductList11111');
  761. let pData = {
  762. type: '1',
  763. deliveryNo: this.formData.sourceBizNo,
  764. builders: this.form.productList.map((item) => {
  765. return {
  766. categoryId: item.productId || item.categoryId,
  767. num: item.totalCount,
  768. // warehouseId: this.bizType == 3 ? item.warehouseId : ''
  769. batchNo: item.batchNo || '',
  770. };
  771. })
  772. };
  773. console.log('111~~~~~~~~', pData)
  774. getHierarchyFifo(pData)
  775. .then((data) => {
  776. this.detailData(data, this.dimension);
  777. })
  778. .catch((err) => {
  779. console.log(err);
  780. });
  781. }
  782. console.log('formData~~~', this.formData)
  783. },
  784. detailData(data, dimension) {
  785. console.log('detailData~~~', data, dimension)
  786. this.dimension = dimension;
  787. const mergedData = [...(this.formData.outInDetailList || []), ...data];
  788. this.formData.outInDetailList = mergedData;
  789. this.productList = data.map((productItem) => {
  790. return {
  791. ...productItem,
  792. suspendBatchNo: productItem.batchNo || '',
  793. outInDetailRecordRequestList:
  794. productItem.outInDetailRecordRequestList.map((packingItem) => {
  795. return {
  796. ...packingItem,
  797. workOrderId:
  798. this.type === '自选领用出库'
  799. ? this.form.detailList[0].workOrderId
  800. : '',
  801. pickOrderId:
  802. this.type === '自选领用出库'
  803. ? this.form.detailList[0].pickOrderId
  804. : '',
  805. taskId:
  806. this.type === '自选领用出库'
  807. ? this.form.detailList[0].taskId
  808. : '',
  809. categoryName: productItem.categoryName,
  810. categoryCode: productItem.categoryCode,
  811. supplierCode: productItem.supplierCode,
  812. supplierName: productItem.supplierName,
  813. materialDetailList: packingItem.materialDetailList.map(
  814. (materialItem) => {
  815. return {
  816. ...materialItem,
  817. categoryName: productItem.categoryName,
  818. categoryCode: productItem.categoryCode,
  819. supplierCode: productItem.supplierCode,
  820. supplierName: productItem.supplierName
  821. };
  822. }
  823. )
  824. };
  825. })
  826. };
  827. });
  828. const newProducts = mergedData.map((productItem) => ({
  829. ...productItem,
  830. suspendBatchNo: productItem.batchNo || '',
  831. outInDetailRecordRequestList:
  832. productItem.outInDetailRecordRequestList.map((packingItem) => ({
  833. ...packingItem,
  834. categoryName: productItem.categoryName,
  835. categoryCode: productItem.categoryCode,
  836. supplierCode: productItem.supplierCode,
  837. supplierName: productItem.supplierName,
  838. workOrderId:
  839. this.type === '自选领用出库'
  840. ? this.form.detailList[0].workOrderId
  841. : '',
  842. pickOrderId:
  843. this.type === '自选领用出库'
  844. ? this.form.detailList[0].pickOrderId
  845. : '',
  846. taskId:
  847. this.type === '自选领用出库'
  848. ? this.form.detailList[0].taskId
  849. : '',
  850. materialDetailList: packingItem.materialDetailList.map(
  851. (materialItem) => ({
  852. ...materialItem,
  853. categoryName: productItem.categoryName,
  854. categoryCode: productItem.categoryCode,
  855. supplierCode: productItem.supplierCode,
  856. supplierName: productItem.supplierName
  857. })
  858. )
  859. }))
  860. }));
  861. // 去重合并产品列表和新产品列表
  862. const uniqueProducts = [
  863. ...new Map(
  864. [...this.productList, ...newProducts].map((item) => [item.id, item])
  865. ).values()
  866. ];
  867. this.productList = uniqueProducts;
  868. console.log('111111111111111');
  869. console.log(this.productList);
  870. // 排序
  871. this.productList.sort((a, b) => a.categoryCode - b.categoryCode);
  872. // 获取包装维度数据
  873. const arr = [];
  874. for (const key in this.productList) {
  875. for (const k in this.productList[key].outInDetailRecordRequestList) {
  876. arr.push({
  877. ...this.productList[key].outInDetailRecordRequestList[k]
  878. });
  879. }
  880. }
  881. this.packingList = arr;
  882. const newPacking = [];
  883. newProducts.forEach((item) => {
  884. newPacking.push(...item.outInDetailRecordRequestList);
  885. });
  886. //去重
  887. const newPackingList = [
  888. ...new Map(
  889. [...this.packingList, ...newPacking].map((item) => [item.id, item])
  890. ).values()
  891. ];
  892. this.packingList = newPackingList;
  893. this.packingList.sort((a, b) => a.categoryCode - b.categoryCode);
  894. // 获取物料维度数据
  895. // let iArr = [];
  896. // arr.forEach((item) => {
  897. // item.materialDetailList.forEach((ele) => {
  898. // iArr.push({ ...ele });
  899. // });
  900. // });
  901. // this.materialList = iArr;
  902. // const newMaterial = [];
  903. // newPacking.forEach((item) => {
  904. // newMaterial.push(...item.materialDetailList);
  905. // });
  906. // this.materialList = [...this.materialList, ...newMaterial];
  907. // 触发分页更新
  908. // this.pickingPageNum = 1;
  909. // this.materielPageNum = 1;
  910. // this.pickingFetchData();
  911. // this.materielFetchData();
  912. this.formData.outInDetailList = this.productList;
  913. console.log(this.productList, 'this.productList');
  914. console.log(this.packingList, 'this.packingList');
  915. },
  916. // 部门列表
  917. async initDeptData() {
  918. let deptTreeList = await listOrganizations()
  919. this.departmentOption = toTreeData({
  920. data: deptTreeList,
  921. idField: 'id',
  922. parentIdField: 'parentId'
  923. })
  924. },
  925. async getStaffList(id) {
  926. uni.showLoading({
  927. title: '加载中',
  928. mask: true
  929. })
  930. let res = await getUserPage({
  931. groupId: id,
  932. size: 9999,
  933. page: 1
  934. })
  935. uni.hideLoading()
  936. this.userOption = res.list
  937. },
  938. sectionChange(index) {
  939. this.curNow = index;
  940. },
  941. addStock() {
  942. console.log(this.formData.extInfo.assetType);
  943. if (
  944. !(
  945. this.formData.extInfo.assetType &&
  946. this.formData.extInfo.assetType.length > 0
  947. )
  948. )
  949. return uni.$u.toast('请选择出库产品类型')
  950. if (!this.formData.bizType && this.formData.bizType !== 0)
  951. return uni.$u.toast('请选择出库场景');
  952. uni.setStorageSync('productList', this.productList)
  953. uni.navigateTo({
  954. url: '/pages/home/wt/components/salesDelivery/selectEnterType?assetType=' + this.formData.extInfo.assetType
  955. })
  956. },
  957. // 删除产品
  958. deleteProductList(row, index) {
  959. uni.showModal({
  960. title: '提示',
  961. content: '确定删除该产品吗?',
  962. success: (res) => {
  963. if (res.confirm) {
  964. this.productList.splice(index, 1);
  965. }
  966. }
  967. });
  968. },
  969. async getDetailData(id) {
  970. const data = await getByIdOnlyReplaceAPI(id);
  971. data.repliedStr = data.replied === 1 ? '是' : '否';
  972. this.form = data;
  973. console.log('form~~~', this.form)
  974. this.initFormData();
  975. },
  976. // 获取当前时间函数
  977. getNowDate() {
  978. let date = new Date(),
  979. obj = {
  980. year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
  981. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  982. strDate: date.getDate(), // 获取当前日(1-31)
  983. hour: date.getHours(), //获取当前小时(0 ~ 23)
  984. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  985. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  986. };
  987. Object.keys(obj).forEach((key) => {
  988. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  989. });
  990. return obj;
  991. },
  992. // 赋值入库时间
  993. getNowFormatDate() {
  994. const obj = this.getNowDate();
  995. const currentTime = `${obj.hour}:${obj.minute}:${obj.second}`;
  996. // this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
  997. this.formData.storageTime = Date.now() - 2*24*3600*1000;
  998. },
  999. async getReturnStorage() {
  1000. try {
  1001. const valid = await this.$refs.outForm.validate();
  1002. console.log('valid~~~', valid);
  1003. if (!this.productList?.length) {
  1004. return uni.$u.toast('请添加出库明细!');
  1005. }
  1006. let obj = JSON.parse(JSON.stringify({ ...this.formData, type: 2 }));
  1007. obj.extInfo.sourceBizNo = obj.sourceBizNo;
  1008. obj.fromType = obj.type;
  1009. // 处理物品类型assetType
  1010. obj.extInfo.assetType = obj.extInfo?.assetType.join(',');
  1011. // 处理仓库id
  1012. let warehouseId = [];
  1013. let warehouseName = [];
  1014. let warehouseIds = this.productList
  1015. .map((item) => item.warehouseId)
  1016. .flat();
  1017. let warehouseNames = this.productList
  1018. .map((item) => item.warehouseName)
  1019. .flat();
  1020. warehouseIds.forEach((item, index) => {
  1021. if (!warehouseId.includes(item)) {
  1022. warehouseId.push(item);
  1023. warehouseName.push(warehouseNames[index]);
  1024. }
  1025. });
  1026. obj.warehouseIds = warehouseId;
  1027. obj.warehouseNames = warehouseName;
  1028. console.log('2222', obj);
  1029. let isPass = false;
  1030. // 1按数量计费 2按重量计费
  1031. if (this.form.pricingWay == 2) {
  1032. // 判断包装重量是否全部大于0
  1033. isPass = this.packingList.every((item) => item.weight > 0);
  1034. } else {
  1035. isPass = true;
  1036. }
  1037. if (isPass) {
  1038. return obj;
  1039. } else {
  1040. uni.$u.toast('委外发货重量不能为空');
  1041. }
  1042. } catch (e) {
  1043. console.log('验证失败', e);
  1044. return null;
  1045. }
  1046. },
  1047. //
  1048. getTableValue() {
  1049. return new Promise(async (resolve, reject) => {
  1050. try {
  1051. // await this.$refs.uForm[0].validate()
  1052. // await this.$refs.outForm[0].validate()
  1053. resolve({
  1054. form: this.form,
  1055. returnStorageData: await this.getReturnStorage()
  1056. })
  1057. } catch {
  1058. reject(null)
  1059. }
  1060. })
  1061. },
  1062. }
  1063. }
  1064. </script>
  1065. <style scoped>
  1066. /* .task-form-container { */
  1067. /* padding-top: 20rpx; */
  1068. /* } */
  1069. .tab-content {
  1070. padding-top: 20rpx;
  1071. }
  1072. .u-subsection--subsection {
  1073. background-color: #fff;
  1074. }
  1075. .assetType_box {
  1076. padding: 12rpx 18rpx;
  1077. width: 100%;
  1078. overflow: hidden;
  1079. white-space: nowrap;
  1080. text-overflow: ellipsis;
  1081. font-size: 30rpx;
  1082. }
  1083. .add {
  1084. width: 96rpx;
  1085. height: 96rpx;
  1086. border-radius: 48rpx;
  1087. background: #3c9cff;
  1088. position: fixed;
  1089. bottom: 100rpx;
  1090. right: 24rpx;
  1091. display: flex;
  1092. align-items: center;
  1093. justify-content: center;
  1094. z-index: 99;
  1095. }
  1096. </style>