add.vue 39 KB

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