add.vue 42 KB

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