add.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息"></header-title>
  5. <el-form
  6. :model="formData"
  7. ref="formName"
  8. label-width="110px"
  9. :rules="rules"
  10. >
  11. <el-row :gutter="20">
  12. <el-col :span="6">
  13. <el-form-item label="出库场景" prop="bizType">
  14. <el-select
  15. filterable
  16. placeholder="请选择"
  17. v-model="formData.bizType"
  18. clearable
  19. @change="handleBizSceneChange"
  20. >
  21. <el-option
  22. v-for="item in outputSceneState"
  23. :key="item.code"
  24. :value="item.code + ''"
  25. :label="item.label"
  26. ></el-option>
  27. </el-select> </el-form-item
  28. ></el-col>
  29. <el-col :span="6">
  30. <el-form-item label="客户名称" prop="">
  31. <el-input
  32. placeholder="请选择"
  33. v-model="formData.clientName"
  34. style="width: calc(100% - 80px)"
  35. >
  36. </el-input>
  37. <openContactDialog
  38. style="margin-left: 3px"
  39. @changeParent="contactDialogSuccess"
  40. ></openContactDialog>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="6">
  44. <el-form-item label="单据来源" prop="sourceBizNo">
  45. <el-input
  46. placeholder="请选择"
  47. v-model="formData.sourceBizNo"
  48. @click.native="openDocumentSourceDialog"
  49. >
  50. <el-button
  51. @click.stop="clearDocumentSource"
  52. slot="append"
  53. icon="el-icon-circle-close"
  54. ></el-button>
  55. </el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="6">
  59. <el-form-item label="出库物品类型" prop="extInfo.assetType">
  60. <el-select
  61. style="width: 100%"
  62. multiple
  63. v-model="formData.extInfo.assetType"
  64. placeholder="请选择"
  65. >
  66. <el-option
  67. v-for="item in goodsLists"
  68. :key="item.id"
  69. :label="item.name"
  70. :value="item.id"
  71. >
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="6">
  77. <el-form-item label="出库登记人">
  78. <el-input
  79. placeholder="登记人"
  80. disabled
  81. v-model="formData.extInfo.createUserName"
  82. clearable /></el-form-item
  83. ></el-col>
  84. <el-col :span="6">
  85. <el-form-item label="领料人部门" prop="extInfo.verifyDeptCode">
  86. <selectTree
  87. ref="tree"
  88. class="form-ipt"
  89. size="medium"
  90. style="width: 100%"
  91. :value="formData.extInfo.verifyDeptCode"
  92. clearable
  93. :options="treeList"
  94. :props="{
  95. value: 'id',
  96. label: 'name',
  97. children: 'children'
  98. }"
  99. @getValue="auditorDeptClick"
  100. />
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="6">
  104. <el-form-item label="领料人" prop="fromId">
  105. <el-select
  106. v-model="formData.fromId"
  107. filterable
  108. placeholder="请选择领料人"
  109. >
  110. <el-option
  111. v-for="item in llrLsit"
  112. :key="item.id"
  113. :label="item.name"
  114. :value="item.id"
  115. @click.native="userSlected(item)"
  116. >
  117. </el-option>
  118. </el-select> </el-form-item
  119. ></el-col>
  120. <!-- <el-col :span="6">
  121. <el-form-item label="领料人联系方式" prop="fromUserPhone">
  122. <el-input
  123. placeholder="请输入"
  124. disabled
  125. v-model="formData.extInfo.fromUserPhone"
  126. clearable /></el-form-item
  127. ></el-col> -->
  128. <el-col :span="12">
  129. <el-form-item label="备注" prop="remark">
  130. <el-input
  131. v-model="formData.remark"
  132. placeholder="请详细说明"
  133. ></el-input>
  134. </el-form-item>
  135. </el-col>
  136. </el-row>
  137. </el-form>
  138. <div>
  139. <el-button
  140. style="margin-bottom: 20px; float: right; margin-right: 20px"
  141. type="primary"
  142. @click="addStock"
  143. >添加</el-button
  144. >
  145. </div>
  146. <div class="material">
  147. <div>
  148. <header-title title="物品清单"></header-title>
  149. <div class="mt10 form-table">
  150. <el-table
  151. ref="productListTable"
  152. :data="productList"
  153. border
  154. tooltip-effect="dark"
  155. :max-height="300"
  156. :header-cell-style="rowClass"
  157. >
  158. <el-table-column label="序号" type="index" width="50">
  159. </el-table-column>
  160. <el-table-column
  161. label="编码"
  162. prop="categoryCode"
  163. align="center"
  164. :show-overflow-tooltip="true"
  165. ></el-table-column>
  166. <el-table-column
  167. label="名称"
  168. align="center"
  169. prop="categoryName"
  170. :show-overflow-tooltip="true"
  171. ></el-table-column>
  172. <el-table-column
  173. v-if="clientEnvironmentId == 4"
  174. label="级别"
  175. prop="level"
  176. align="center"
  177. >
  178. </el-table-column>
  179. <el-table-column
  180. label="型号"
  181. align="center"
  182. prop="categoryModel"
  183. :show-overflow-tooltip="true"
  184. ></el-table-column>
  185. <el-table-column
  186. label="规格"
  187. align="center"
  188. prop="specification"
  189. :show-overflow-tooltip="true"
  190. ></el-table-column>
  191. <el-table-column
  192. label="牌号"
  193. align="center"
  194. prop="brandNum"
  195. :show-overflow-tooltip="true"
  196. ></el-table-column>
  197. <el-table-column
  198. v-for="(item, index) in newColumns"
  199. :label="item.label"
  200. :align="item.align"
  201. :prop="item.prop"
  202. :show-overflow-tooltip="item.showOverflowTooltip"
  203. ></el-table-column>
  204. <el-table-column
  205. label="批次号"
  206. prop="batchNo"
  207. width="150"
  208. align="center"
  209. :show-overflow-tooltip="true"
  210. >
  211. </el-table-column>
  212. <el-table-column
  213. label="包装数量"
  214. v-if="clientEnvironmentId == 3"
  215. prop="packingQuantity"
  216. align="center"
  217. >
  218. <template slot-scope="{ row, $index }">
  219. {{ row.packingQuantity }} {{ row.packingUnit }}
  220. </template>
  221. </el-table-column>
  222. <el-table-column
  223. v-else
  224. label="包装数量"
  225. prop="packingQuantity"
  226. width="80"
  227. ></el-table-column>
  228. <el-table-column
  229. v-if="clientEnvironmentId == 3"
  230. label="最小包装单元"
  231. align="center"
  232. width="120"
  233. prop="minPackingQuantity"
  234. >
  235. <template slot-scope="{ row, $index }">
  236. {{ row.minPackingQuantity }} {{ row.measureUnit }} /{{
  237. row.packingUnit
  238. }}
  239. </template>
  240. </el-table-column>
  241. <el-table-column
  242. v-else
  243. label="包装单位"
  244. prop="packingUnit"
  245. ></el-table-column>
  246. <el-table-column
  247. label="计量数量"
  248. prop="measureQuantity"
  249. width="100"
  250. align="center"
  251. >
  252. </el-table-column>
  253. <el-table-column
  254. label="计量单位"
  255. prop="measureUnit"
  256. align="center"
  257. >
  258. <template slot-scope="{ row, $index }">
  259. <template>
  260. {{ row.measureUnit }}
  261. </template>
  262. </template>
  263. </el-table-column>
  264. <el-table-column
  265. label="重量"
  266. prop="weight"
  267. align="center"
  268. :show-overflow-tooltip="true"
  269. >
  270. </el-table-column>
  271. <el-table-column
  272. label="重量单位"
  273. prop="weightUnit"
  274. align="center"
  275. :show-overflow-tooltip="true"
  276. >
  277. </el-table-column>
  278. <el-table-column
  279. label="库存"
  280. prop="stockNum"
  281. align="center"
  282. :show-overflow-tooltip="true"
  283. >
  284. </el-table-column>
  285. <el-table-column
  286. label="单价"
  287. prop="price"
  288. align="center"
  289. v-if="isPrice == 1"
  290. >
  291. <template slot-scope="{ row }">
  292. <template>
  293. {{ row.price ? row.price : '-' + '元' }}/{{
  294. row.measureUnit
  295. }}
  296. </template>
  297. </template>
  298. </el-table-column>
  299. <el-table-column
  300. label="金额"
  301. align="center"
  302. v-if="isPrice == 1"
  303. prop="totalMoney"
  304. :show-overflow-tooltip="true"
  305. >
  306. <template slot-scope="{ row, $index }">
  307. {{ row.totalMoney ? row.totalMoney : 0 }}
  308. </template>
  309. </el-table-column>
  310. <el-table-column
  311. v-if="clientEnvironmentId == 4"
  312. label="采购原因"
  313. align="center"
  314. prop="purpose"
  315. :show-overflow-tooltip="true"
  316. ></el-table-column>
  317. <el-table-column
  318. label="仓库"
  319. prop="warehouseName"
  320. :show-overflow-tooltip="true"
  321. >
  322. </el-table-column>
  323. <el-table-column
  324. prop="supplierName"
  325. label="供应商"
  326. min-width="200"
  327. :show-overflow-tooltip="true"
  328. ></el-table-column>
  329. <el-table-column
  330. prop="supplierCode"
  331. label="供应商代号"
  332. min-width="200"
  333. :show-overflow-tooltip="true"
  334. ></el-table-column>
  335. </el-table>
  336. </div>
  337. <header-title class="mt20" title="包装清单"></header-title>
  338. <div class="mt10 form-table">
  339. <el-table
  340. ref="showPackingListTable"
  341. :data="showPackingList"
  342. tooltip-effect="dark"
  343. :max-height="300"
  344. border
  345. :row-class-name="tableRowClassName"
  346. :header-cell-style="rowClass"
  347. v-el-table-infinite-scroll="pickingHandleScroll"
  348. >
  349. <el-table-column label="序号" type="index" width="50">
  350. </el-table-column>
  351. <el-table-column
  352. label="编码"
  353. prop="categoryCode"
  354. :show-overflow-tooltip="true"
  355. ></el-table-column>
  356. <el-table-column
  357. label="名称"
  358. prop="categoryName"
  359. :show-overflow-tooltip="true"
  360. ></el-table-column>
  361. <el-table-column
  362. label="批次号"
  363. prop="batchNo"
  364. width="150"
  365. :show-overflow-tooltip="true"
  366. ></el-table-column>
  367. <el-table-column
  368. label="发货条码"
  369. prop="barcodes"
  370. :show-overflow-tooltip="true"
  371. ></el-table-column>
  372. <el-table-column
  373. label="包装编码"
  374. prop="packageNo"
  375. :show-overflow-tooltip="true"
  376. ></el-table-column>
  377. <el-table-column
  378. label="包装数量"
  379. prop="packingQuantity"
  380. :show-overflow-tooltip="true"
  381. ></el-table-column>
  382. <el-table-column
  383. label="包装单位"
  384. prop="packingUnit"
  385. :show-overflow-tooltip="true"
  386. ></el-table-column>
  387. <el-table-column
  388. label="计量数量"
  389. prop="measureQuantity"
  390. :show-overflow-tooltip="true"
  391. ></el-table-column>
  392. <el-table-column
  393. label="计量单位"
  394. prop="measureUnit"
  395. :show-overflow-tooltip="true"
  396. ></el-table-column>
  397. <el-table-column
  398. label="物料代号"
  399. prop="materielDesignation"
  400. :show-overflow-tooltip="true"
  401. >
  402. </el-table-column>
  403. <el-table-column
  404. label="客户代号"
  405. prop="clientCode"
  406. :show-overflow-tooltip="true"
  407. >
  408. </el-table-column>
  409. <el-table-column
  410. label="刻码"
  411. prop="engrave"
  412. :show-overflow-tooltip="true"
  413. >
  414. </el-table-column>
  415. <el-table-column
  416. label="重量"
  417. prop="weight"
  418. :show-overflow-tooltip="true"
  419. >
  420. </el-table-column>
  421. <el-table-column
  422. label="重量单位"
  423. prop="weightUnit"
  424. :show-overflow-tooltip="true"
  425. >
  426. </el-table-column>
  427. <el-table-column
  428. label="质检结果"
  429. prop="result"
  430. :show-overflow-tooltip="true"
  431. >
  432. <template slot-scope="{ row }">
  433. <span>{{ qualityResults[row.result] }}</span>
  434. </template>
  435. </el-table-column>
  436. <el-table-column
  437. label="质检状态"
  438. prop="status"
  439. :show-overflow-tooltip="true"
  440. >
  441. <template slot-scope="{ row }">
  442. <span>{{ qualityStatus[row.status] }}</span>
  443. </template>
  444. </el-table-column>
  445. <el-table-column
  446. label="生产日期"
  447. prop="productionDate"
  448. :show-overflow-tooltip="true"
  449. >
  450. </el-table-column>
  451. <el-table-column
  452. label="采购日期"
  453. prop="purchaseDate"
  454. :show-overflow-tooltip="true"
  455. >
  456. </el-table-column>
  457. <el-table-column
  458. prop="supplierName"
  459. label="供应商"
  460. min-width="200"
  461. :show-overflow-tooltip="true"
  462. ></el-table-column>
  463. <el-table-column
  464. prop="supplierCode"
  465. label="供应商代号"
  466. min-width="200"
  467. :show-overflow-tooltip="true"
  468. ></el-table-column>
  469. </el-table>
  470. </div>
  471. </div>
  472. <!-- <div class="mt20">
  473. <header-title class="mt20" title="物料明细"></header-title>
  474. <el-table ref="multipleTable" :data="showMaterialList" tooltip-effect="dark" :max-height="300"
  475. :row-class-name="tableRowClassName" :header-cell-style="rowClass" border style="width: 100%" stripe
  476. height="300px" v-el-table-infinite-scroll="materielHandleScroll">
  477. <el-table-column label="序号" type="index" width="50">
  478. </el-table-column>
  479. <el-table-column label="编码" prop="categoryCode" :show-overflow-tooltip="true"></el-table-column>
  480. <el-table-column label="名称" prop="categoryName" :show-overflow-tooltip="true"></el-table-column>
  481. <el-table-column label="批次号" prop="batchNo"></el-table-column>
  482. <el-table-column label="物料编码" prop="materialCode" :show-overflow-tooltip="true"></el-table-column>
  483. <el-table-column label="发货条码" prop="barcodes" :show-overflow-tooltip="true"></el-table-column>
  484. <el-table-column label="计量数量" prop="minPackingCount"></el-table-column>
  485. <el-table-column label="计量单位" prop="measuringUnit"></el-table-column>
  486. <el-table-column label="物料代号" prop="materielDesignation">
  487. </el-table-column>
  488. <el-table-column label="客户代号" prop="clientCode">
  489. </el-table-column>
  490. <el-table-column label="刻码" prop="engrave"> </el-table-column>
  491. <el-table-column width="100" label="重量" prop="weight">
  492. </el-table-column>
  493. <el-table-column label="重量单位" prop="weightUnit">
  494. </el-table-column>
  495. <el-table-column label="质检结果" prop="result" width="120">
  496. <template slot-scope="{ row }">
  497. <span>{{ qualityResults[row.result] }}</span>
  498. </template>
  499. </el-table-column>
  500. <el-table-column label="质检状态" prop="status" width="120">
  501. <template slot-scope="{ row }">
  502. <span>{{ qualityStatus[row.status] }}</span>
  503. </template>
  504. </el-table-column>
  505. </el-table>
  506. </div> -->
  507. </div>
  508. <div class="center mt20">
  509. <el-button
  510. type="primary"
  511. @click="handleSave('save')"
  512. :loading="saveLoading"
  513. >保存</el-button
  514. >
  515. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  516. >出库</el-button
  517. >
  518. <el-button @click="$router.go(-1)">返回</el-button>
  519. </div>
  520. </el-card>
  521. <AssetsDialog
  522. ref="assetsDialogRef"
  523. :treeIds="formData.extInfo.assetType"
  524. @detailData="detailData"
  525. />
  526. <outboundRequisitionDialog
  527. ref="outboundRequisitionDialogRef"
  528. @detailData="outboundRequisitionSelection"
  529. type="2"
  530. />
  531. </div>
  532. </template>
  533. <script>
  534. import storageApi from '@/api/warehouseManagement/index.js';
  535. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  536. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  537. import { getTreeByGroup } from '@/api/classifyManage';
  538. import openContactDialog from '@/components/contactDialog/openContactDialog.vue';
  539. import {
  540. outputSceneState,
  541. qualityStatus,
  542. qualityResults
  543. } from '@/utils/dict/index';
  544. import outboundRequisitionDialog from '../components/outboundRequisitionDialog.vue';
  545. import selectTree from '@/components/selectTree';
  546. import AssetsDialog from '../components/AssetsDialog.vue';
  547. import { deepClone } from '@/utils';
  548. import { parameterGetByCode } from '@/api/sys/index.js';
  549. export default {
  550. name: 'outgoingManagementAdd',
  551. components: {
  552. selectTree,
  553. AssetsDialog,
  554. outboundRequisitionDialog,
  555. openContactDialog
  556. },
  557. directives: {
  558. 'el-table-infinite-scroll': elTableInfiniteScroll
  559. },
  560. data() {
  561. return {
  562. newColumns: [], // 动态表头
  563. goodsLists: [], // 商品列表
  564. qualityStatus, // 质检状态 0未检 1待检 2已检
  565. qualityResults, // 质检结果 0无 1合格 2不合格
  566. productList: [], // 产品列表
  567. showPackingList: [], // 展示的包装列表
  568. packingList: [], // 包装列表
  569. showMaterialList: [], // 展示物料列表
  570. materialList: [], // 物料列表
  571. extInfo: {}, // 扩展信息
  572. pageSize: 20,
  573. pickingPageNum: 1,
  574. materielPageNum: 1,
  575. dimension: '3',
  576. outputSceneState: outputSceneState.filter(
  577. (item) => item.code != '4' && item.code != '11'
  578. ), // 出库场景状态
  579. saveLoading: false,
  580. treeList: [],
  581. isPrice: 1,
  582. formData: {
  583. extInfo: {
  584. assetType: [], //物品类型id
  585. assetTypeName: '', //物品类型名称
  586. deptCode: '', //部门code
  587. deptName: '', //部门名称
  588. verifyDeptCode: '', //审核部门编码
  589. verifyDeptName: '', //审核部门名称
  590. deliveryName: '', //送货人名称
  591. fromUserPhone: '', //送货人电话
  592. sourceBizNo: '', //销售订单
  593. urgent: '', //紧急状态
  594. supplierId: '', //供应商ID
  595. supplierName: '', //供应商名称
  596. createUserName: '', //创建人名字
  597. contentImage: [] //图片数组
  598. },
  599. fromUser: '', //送货人
  600. bizType: '', //物品类型
  601. verifyId: '', //审核人Id
  602. verifyName: '', //审核人名称
  603. createUserId: '',
  604. remark: ''
  605. },
  606. rules: {
  607. bizType: {
  608. required: true,
  609. message: '请选择出库场景',
  610. trigger: 'change'
  611. },
  612. 'extInfo.assetType': {
  613. required: true,
  614. message: '请选择物品类型',
  615. trigger: ['change', 'blur']
  616. },
  617. fromId: {
  618. required: true,
  619. message: '请选择领料人',
  620. trigger: 'change'
  621. },
  622. 'extInfo.verifyDeptCode': {
  623. required: true,
  624. message: '请选择领料人部门',
  625. trigger: ['change', 'blur']
  626. }
  627. },
  628. llrLsit: []
  629. };
  630. },
  631. computed: {
  632. clientEnvironmentId() {
  633. return this.$store.state.user.info.clientEnvironmentId;
  634. }
  635. },
  636. async created() {
  637. this.getFieldModel();
  638. this.getListItems();
  639. this.initUserInfo();
  640. this.initDeptData();
  641. //仓库出入库是否显示金额(0:不显示 1:显示)
  642. parameterGetByCode({
  643. code: 'wms_price'
  644. }).then((res) => {
  645. this.isPrice = res.value;
  646. });
  647. let queryObj = this.$route.query;
  648. console.log('queryObj------', queryObj);
  649. if (queryObj.ids) {
  650. this.formData.bizType = queryObj.bizType;
  651. this.formData.extInfo.assetType = queryObj.assetType.split(',');
  652. let data = await storageApi.getHierarchyList({
  653. ids: this.$route.query.ids,
  654. type: 3
  655. });
  656. this.detailData(data, 3);
  657. }
  658. if (queryObj.type) {
  659. this.formData.sourceBizNo = queryObj.code;
  660. this.$nextTick(() => {
  661. this.$refs.outboundRequisitionDialogRef.handleMine([queryObj]);
  662. });
  663. }
  664. console.log(queryObj, 'queryObj.detailId');
  665. if (queryObj.detailId) {
  666. this._getInfo(queryObj.detailId);
  667. }
  668. },
  669. methods: {
  670. outboundRequisitionSelection(data, dimension, query) {
  671. console.log(data, dimension, query);
  672. this.formData.sourceBizNo = query.sourceBizNo;
  673. this.formData.bizType = query.bizType;
  674. this.formData.extInfo.assetType = query.assetType.split(',');
  675. this.detailData(data, dimension);
  676. },
  677. // 获取动态表头
  678. getFieldModel() {
  679. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  680. let newRes = res.map((m) => {
  681. return {
  682. prop: 'extField.' + m.prop,
  683. label: m.label,
  684. align: 'center',
  685. showOverflowTooltip: true
  686. };
  687. });
  688. this.newColumns = [...newRes];
  689. });
  690. },
  691. userSlected(data) {
  692. console.log(data);
  693. this.formData.fromId = data.id;
  694. this.formData.fromUser = data.name;
  695. this.formData.fromUserPhone = data.phone;
  696. },
  697. clearDocumentSource() {
  698. console.log('清空');
  699. },
  700. pickingHandleScroll() {
  701. console.log('---------pickingHandleScroll------------');
  702. if (this.showPackingList.length < this.packingList.length) {
  703. if (this.packingList.length > this.pageSize) {
  704. this.pickingPageNum += 1;
  705. }
  706. this.pickingFetchData();
  707. }
  708. },
  709. pickingFetchData() {
  710. const start = (this.pickingPageNum - 1) * this.pageSize;
  711. const end = start + this.pageSize;
  712. this.showPackingList = this.showPackingList.concat(
  713. this.packingList.slice(start, end)
  714. );
  715. },
  716. materielHandleScroll() {
  717. console.log('---------materielHandleScroll------------');
  718. if (this.showMaterialList.length < this.materialList.length) {
  719. if (this.materialList.length > this.pageSize) {
  720. this.materielPageNum += 1;
  721. }
  722. this.materielFetchData();
  723. }
  724. },
  725. materielFetchData() {
  726. const start = (this.materielPageNum - 1) * this.pageSize;
  727. const end = start + this.pageSize;
  728. this.showMaterialList = this.showMaterialList.concat(
  729. this.materialList.slice(start, end)
  730. );
  731. console.log(this.showMaterialList);
  732. },
  733. // 获取物品列表
  734. async getListItems() {
  735. const { data } = await getTreeByGroup({ type: 2 });
  736. this.goodsLists = data;
  737. },
  738. // 打开单据来源弹窗
  739. openDocumentSourceDialog() {
  740. this.$refs.outboundRequisitionDialogRef.open();
  741. },
  742. tableRowClassName({ row, rowIndex }) {
  743. console.log(row);
  744. if (row.result == 1) {
  745. return 'warning-row';
  746. } else {
  747. return '';
  748. }
  749. },
  750. // getDeptName() {
  751. // if (this.formData?.extInfo?.createUserId) {
  752. // storageApi.getGroupById(this.formData.extInfo.createUserId).then((res) => {
  753. // this.formData.extInfo.deptName = res?.groupName
  754. // });
  755. // }
  756. // },
  757. async _getInfo(detailId) {
  758. let res = await storageApi.getInboundDetailsById(detailId);
  759. this.formData = res;
  760. this.formData.extInfo.assetType = res.extInfo?.assetType?.split(',');
  761. this.formData.bizType = res.bizType + '';
  762. console.log(this.formData.extInfo, '');
  763. this.auditorDeptClick({
  764. id: this.formData.extInfo?.verifyDeptCode,
  765. name: this.formData.extInfo?.verifyDeptName
  766. });
  767. // this.getDeptName()
  768. this.productList = res.outInDetailList.map(
  769. (productItem, productIndex) => {
  770. return {
  771. ...productItem,
  772. outInDetailRecordRequestList:
  773. productItem.outInDetailRecordRequestList.map((packingItem) => {
  774. return {
  775. ...packingItem,
  776. categoryName: productItem.categoryName,
  777. categoryCode: productItem.categoryCode,
  778. materialDetailList: packingItem.materialDetailList.map(
  779. (materialItem) => {
  780. return {
  781. ...materialItem,
  782. categoryName: productItem.categoryName,
  783. categoryCode: productItem.categoryCode
  784. };
  785. }
  786. )
  787. };
  788. })
  789. };
  790. }
  791. );
  792. // 获取包装维度数据
  793. const arr = [];
  794. for (const key in this.productList) {
  795. for (const k in this.productList[key].outInDetailRecordRequestList) {
  796. arr.push({
  797. ...this.productList[key].outInDetailRecordRequestList[k]
  798. });
  799. }
  800. }
  801. this.packingList = arr;
  802. // 获取物料维度数据
  803. let iArr = [];
  804. arr.forEach((item) => {
  805. item.materialDetailList.forEach((ele) => {
  806. iArr.push({ ...ele });
  807. });
  808. });
  809. this.materialList = iArr;
  810. console.log(this.packingList);
  811. console.log(this.materialList);
  812. this.pickingFetchData();
  813. this.materielFetchData();
  814. },
  815. detailData(data, dimension) {
  816. this.dimension = dimension;
  817. const mergedData = [...(this.formData.outInDetailList || []), ...data];
  818. this.formData.outInDetailList = mergedData;
  819. this.productList = mergedData.map((productItem) => {
  820. console.log(productItem, 'productItem');
  821. return {
  822. ...productItem,
  823. outInDetailRecordRequestList:
  824. productItem.outInDetailRecordRequestList.map((packingItem) => {
  825. return {
  826. ...packingItem,
  827. categoryName: productItem.categoryName,
  828. categoryCode: productItem.categoryCode,
  829. supplierCode: productItem.supplierCode,
  830. supplierName: productItem.supplierName,
  831. materialDetailList: packingItem.materialDetailList.map(
  832. (materialItem) => {
  833. return {
  834. ...materialItem,
  835. categoryName: productItem.categoryName,
  836. categoryCode: productItem.categoryCode
  837. };
  838. }
  839. )
  840. };
  841. })
  842. };
  843. });
  844. const newProducts = mergedData.map((productItem) => ({
  845. ...productItem,
  846. outInDetailRecordRequestList:
  847. productItem.outInDetailRecordRequestList.map((packingItem) => ({
  848. ...packingItem,
  849. categoryName: productItem.categoryName,
  850. categoryCode: productItem.categoryCode,
  851. supplierCode: productItem.supplierCode,
  852. supplierName: productItem.supplierName,
  853. materialDetailList: packingItem.materialDetailList.map(
  854. (materialItem) => ({
  855. ...materialItem,
  856. categoryName: productItem.categoryName,
  857. categoryCode: productItem.categoryCode,
  858. supplierCode: productItem.supplierCode,
  859. supplierName: productItem.supplierName
  860. })
  861. )
  862. }))
  863. }));
  864. // 去重合并产品列表和新产品列表
  865. const uniqueProducts = [
  866. ...new Map(
  867. [...this.productList, ...newProducts].map((item) => [item.id, item])
  868. ).values()
  869. ];
  870. this.productList = uniqueProducts;
  871. //排序
  872. this.productList.sort((a, b) => a.categoryCode - b.categoryCode);
  873. console.log(this.productList, '物品清单');
  874. // 获取包装维度数据
  875. const arr = [];
  876. for (const key in this.productList) {
  877. for (const k in this.productList[key].outInDetailRecordRequestList) {
  878. arr.push({
  879. ...this.productList[key].outInDetailRecordRequestList[k]
  880. });
  881. }
  882. }
  883. this.packingList = arr;
  884. const newPacking = [];
  885. newProducts.forEach((item) => {
  886. newPacking.push(...item.outInDetailRecordRequestList);
  887. });
  888. //去重
  889. const newPackingList = [
  890. ...new Map(
  891. [...this.packingList, ...newPacking].map((item) => [item.id, item])
  892. ).values()
  893. ];
  894. this.packingList = newPackingList;
  895. this.packingList.sort((a, b) => a.categoryCode - b.categoryCode);
  896. console.log(this.packingList, '包装');
  897. // 获取物料维度数据
  898. let iArr = [];
  899. arr.forEach((item) => {
  900. item.materialDetailList.forEach((ele) => {
  901. iArr.push({ ...ele });
  902. });
  903. });
  904. this.materialList = iArr;
  905. const newMaterial = [];
  906. newPacking.forEach((item) => {
  907. newMaterial.push(...item.materialDetailList);
  908. });
  909. this.materialList = [...this.materialList, ...newMaterial];
  910. // 触发分页更新
  911. this.pickingPageNum = 1;
  912. this.materielPageNum = 1;
  913. this.pickingFetchData();
  914. this.materielFetchData();
  915. },
  916. handleSave(type) {
  917. this.$refs.formName.validate(async (valid) => {
  918. if (valid) {
  919. if (!this.productList?.length) {
  920. return this.$message.error('请添加出库明细!');
  921. }
  922. let obj = deepClone({ ...this.formData, type: 2 });
  923. obj.extInfo.sourceBizNo = obj.sourceBizNo;
  924. obj.fromType = obj.type;
  925. this.saveLoading = true;
  926. // 处理物品类型assetType
  927. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  928. // 处理仓库id
  929. let warehouseId = [];
  930. let warehouseName = [];
  931. let warehouseIds = this.productList
  932. .map((item) => item.warehouseId)
  933. .flat();
  934. let warehouseNames = this.productList
  935. .map((item) => item.warehouseName)
  936. .flat();
  937. warehouseIds.forEach((item, index) => {
  938. if (!warehouseId.includes(item)) {
  939. warehouseId.push(item);
  940. warehouseName.push(warehouseNames[index]);
  941. }
  942. });
  943. obj.warehouseIds = warehouseId;
  944. obj.warehouseNames = warehouseName;
  945. try {
  946. let api = obj.id ? storageApi.outUpdate : storageApi.outStorage;
  947. const res = await api(obj);
  948. if (res.code == 0) {
  949. if (type != 'save') {
  950. await storageApi.submitInsideTwo({ outInIds: res.data });
  951. this.$message.success('出库成功!');
  952. } else {
  953. this.$message.success('保存成功!');
  954. }
  955. this.$router.push('/warehouseManagement/outgoingManagement');
  956. }
  957. this.saveLoading = false;
  958. } catch (error) {
  959. this.saveLoading = false;
  960. this.$router.push('/warehouseManagement/outgoingManagement');
  961. this.$message.error('保存失败!');
  962. }
  963. } else {
  964. this.$message.error('请选择领料人!');
  965. }
  966. });
  967. },
  968. contactDialogSuccess(data) {
  969. this.$set(this.formData, 'clientName', data.name);
  970. this.$set(this.formData, 'clientCode', data.code);
  971. },
  972. onClear() {
  973. this.formData.sourceBizNo = '';
  974. this.warehousingMaterialList = [];
  975. this.$refs.trees.valueTitle = '';
  976. this.formData.clientName = '';
  977. this.formData.clientUser = '';
  978. this.formData.clientPhone = '';
  979. this.$forceUpdate();
  980. },
  981. rowClass({ row, column, rowIndex, columnIndex }) {
  982. if (rowIndex === 1) {
  983. return {
  984. display: 'none',
  985. background: '#EEEEEE'
  986. };
  987. }
  988. return { background: '#0000' };
  989. },
  990. // 部门点击事件
  991. async auditorDeptClick(data) {
  992. console.log(data);
  993. this.formData.extInfo.verifyDeptCode = data?.id;
  994. this.formData.extInfo.verifyDeptName = data?.name;
  995. this.$set(this.formData.extInfo, 'verifyDeptCode', data?.id);
  996. this.$set(this.formData.extInfo, 'verifyDeptName', data?.name);
  997. this.formData.verifyId = '';
  998. this.formData.verifyName = '';
  999. this.$refs.formName.validateField('verifyDeptName');
  1000. if (data) {
  1001. this.getStaffList(data);
  1002. }
  1003. },
  1004. async getStaffList(data) {
  1005. let res = await warehouseDefinition.getUserPage({
  1006. groupId: data.id,
  1007. size: 9999,
  1008. page: 1
  1009. });
  1010. this.llrLsit = res.list;
  1011. },
  1012. // 初始化用户信息
  1013. async initUserInfo() {
  1014. const res = await warehouseDefinition.tree();
  1015. let info = JSON.parse(localStorage.getItem('info'));
  1016. let obj = res.find(
  1017. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1018. );
  1019. // if (!obj) return;
  1020. if (obj) {
  1021. this.formData.extInfo.deptCode = obj.id;
  1022. this.formData.extInfo.deptName = obj.name;
  1023. } else {
  1024. this.formData.extInfo.deptName = info.deptName
  1025. ? info.deptName
  1026. : info.groupName
  1027. ? info.groupName
  1028. : '';
  1029. }
  1030. this.formData.extInfo.createUserName = info.name;
  1031. this.formData.createUserId = info.userId;
  1032. // 默认领料人部门
  1033. console.log(info);
  1034. // this.formData.extInfo.verifyDeptCode = info?.groupId;
  1035. // this.formData.extInfo.verifyDeptName = info?.groupName;
  1036. // this.$set(this.formData.extInfo, 'verifyDeptCode', info?.groupId);
  1037. // this.$set(this.formData.extInfo, 'verifyDeptName', info?.groupName);
  1038. // // // 领料人
  1039. // this.getStaffList({ id: info?.groupId });
  1040. // this.formData.fromId = info.userId;
  1041. // this.formData.fromUser = info.name;
  1042. // this.formData.fromUserPhone = info.phone;
  1043. // this.$set(this.formData, 'fromId', info.userId);
  1044. // this.$set(this.formData, 'fromUser', info.name);
  1045. // this.$set(this.formData, 'fromUserPhone', info.phone);
  1046. },
  1047. // 初始化部门数据
  1048. async initDeptData() {
  1049. const res = await warehouseDefinition.tree();
  1050. this.treeList = this.$util.toTreeData({
  1051. data: res,
  1052. idField: 'id',
  1053. parentIdField: 'parentId'
  1054. });
  1055. },
  1056. addStock() {
  1057. if (
  1058. !(
  1059. this.formData.extInfo.assetType &&
  1060. this.formData.extInfo.assetType.length > 0
  1061. )
  1062. )
  1063. return this.$message.error('请选择出库产品类型');
  1064. if (!this.formData.bizType && this.formData.bizType !== 0)
  1065. return this.$message.error('请选择出库场景');
  1066. this.$refs.assetsDialogRef.open(this.productList);
  1067. },
  1068. handleBizSceneChange() {
  1069. if (this.formData.extInfo.assetType == 7) {
  1070. this.formData.extInfo.sourceBizNo = '';
  1071. }
  1072. this.formData.sourceBizNo = '';
  1073. }
  1074. },
  1075. watch: {
  1076. packingList: {
  1077. handler(newVal) {
  1078. console.log('包装列表', newVal);
  1079. console.log('当前包装列表加载页数', this.pickingPageNum);
  1080. this.showPackingList = newVal.slice(
  1081. 0,
  1082. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1083. );
  1084. },
  1085. deep: true
  1086. },
  1087. materialList: {
  1088. handler(newVal) {
  1089. console.log('物料列表', newVal);
  1090. console.log('当前物料列表加载页数', this.materielPageNum);
  1091. this.showMaterialList = newVal.slice(
  1092. 0,
  1093. this.pageSize *
  1094. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1095. );
  1096. },
  1097. deep: true
  1098. },
  1099. '$route.query': {
  1100. handler(newQuery, oldQuery) {
  1101. if (newQuery?.detailId) {
  1102. this._getInfo(newQuery.detailId);
  1103. }
  1104. },
  1105. deep: true // 确保对象内部的属性变化也能被监听到
  1106. }
  1107. }
  1108. };
  1109. </script>
  1110. <style lang="scss" scoped>
  1111. ::v-deep .el-row {
  1112. display: flex;
  1113. flex-wrap: wrap;
  1114. }
  1115. ::v-deep.form-table {
  1116. .el-form-item {
  1117. margin-bottom: 0;
  1118. }
  1119. .el-input__inner {
  1120. padding: 0 10px;
  1121. }
  1122. }
  1123. .p20 {
  1124. padding: 20px;
  1125. }
  1126. .el-select,
  1127. .el-date-editor {
  1128. width: 100%;
  1129. }
  1130. .el-form-item {
  1131. margin-bottom: 22px;
  1132. }
  1133. .material {
  1134. margin-top: 20px;
  1135. .flex {
  1136. display: flex;
  1137. justify-content: space-between;
  1138. font-size: 14px;
  1139. align-items: center;
  1140. .red {
  1141. color: #ff4949;
  1142. }
  1143. }
  1144. }
  1145. .mt10 {
  1146. margin-top: 10px;
  1147. }
  1148. .mt20 {
  1149. margin-top: 20px;
  1150. }
  1151. .center {
  1152. text-align: center;
  1153. }
  1154. </style>