outbound.vue 43 KB

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