add.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  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>
  350. </div>
  351. <header-title class="mt20" title="包装清单"></header-title>
  352. <div class="mt10 form-table">
  353. <el-table
  354. ref="showPackingListTable"
  355. :data="showPackingList"
  356. tooltip-effect="dark"
  357. :max-height="300"
  358. border
  359. :row-class-name="tableRowClassName"
  360. :header-cell-style="rowClass"
  361. v-el-table-infinite-scroll="pickingHandleScroll"
  362. >
  363. <el-table-column label="序号" type="index" width="50">
  364. </el-table-column>
  365. <el-table-column
  366. label="编码"
  367. prop="categoryCode"
  368. :show-overflow-tooltip="true"
  369. ></el-table-column>
  370. <el-table-column
  371. label="名称"
  372. prop="categoryName"
  373. :show-overflow-tooltip="true"
  374. ></el-table-column>
  375. <el-table-column
  376. label="批次号"
  377. prop="batchNo"
  378. width="150"
  379. :show-overflow-tooltip="true"
  380. ></el-table-column>
  381. <el-table-column
  382. label="发货条码"
  383. prop="barcodes"
  384. :show-overflow-tooltip="true"
  385. ></el-table-column>
  386. <el-table-column
  387. label="包装编码"
  388. prop="packageNo"
  389. :show-overflow-tooltip="true"
  390. ></el-table-column>
  391. <el-table-column
  392. label="包装数量"
  393. prop="packingQuantity"
  394. :show-overflow-tooltip="true"
  395. ></el-table-column>
  396. <el-table-column
  397. label="包装单位"
  398. prop="packingUnit"
  399. :show-overflow-tooltip="true"
  400. ></el-table-column>
  401. <el-table-column
  402. label="计量数量"
  403. prop="measureQuantity"
  404. :show-overflow-tooltip="true"
  405. ></el-table-column>
  406. <el-table-column
  407. label="计量单位"
  408. prop="measureUnit"
  409. :show-overflow-tooltip="true"
  410. ></el-table-column>
  411. <el-table-column
  412. label="物料代号"
  413. prop="materielDesignation"
  414. :show-overflow-tooltip="true"
  415. >
  416. </el-table-column>
  417. <el-table-column
  418. label="客户代号"
  419. prop="clientCode"
  420. :show-overflow-tooltip="true"
  421. >
  422. </el-table-column>
  423. <el-table-column
  424. label="刻码"
  425. prop="engrave"
  426. :show-overflow-tooltip="true"
  427. >
  428. </el-table-column>
  429. <el-table-column
  430. label="重量"
  431. prop="weight"
  432. :show-overflow-tooltip="true"
  433. >
  434. </el-table-column>
  435. <el-table-column
  436. label="重量单位"
  437. prop="weightUnit"
  438. :show-overflow-tooltip="true"
  439. >
  440. </el-table-column>
  441. <el-table-column label="机型" prop="modelKey" width="200">
  442. </el-table-column>
  443. <el-table-column label="颜色" prop="colorKey" width="200">
  444. </el-table-column>
  445. <el-table-column
  446. label="质检结果"
  447. prop="result"
  448. :show-overflow-tooltip="true"
  449. >
  450. <template slot-scope="{ row }">
  451. <span>{{ qualityResults[row.result] }}</span>
  452. </template>
  453. </el-table-column>
  454. <el-table-column
  455. label="质检状态"
  456. prop="status"
  457. :show-overflow-tooltip="true"
  458. >
  459. <template slot-scope="{ row }">
  460. <span>{{ qualityStatus[row.status] }}</span>
  461. </template>
  462. </el-table-column>
  463. <el-table-column
  464. label="生产日期"
  465. prop="productionDate"
  466. :show-overflow-tooltip="true"
  467. >
  468. </el-table-column>
  469. <el-table-column
  470. label="采购日期"
  471. prop="purchaseDate"
  472. :show-overflow-tooltip="true"
  473. >
  474. </el-table-column>
  475. <el-table-column
  476. prop="supplierName"
  477. label="供应商"
  478. min-width="200"
  479. :show-overflow-tooltip="true"
  480. ></el-table-column>
  481. <el-table-column
  482. prop="supplierCode"
  483. label="供应商代号"
  484. min-width="200"
  485. :show-overflow-tooltip="true"
  486. ></el-table-column>
  487. </el-table>
  488. </div>
  489. </div>
  490. <!-- <div class="mt20">
  491. <header-title class="mt20" title="物料明细"></header-title>
  492. <el-table ref="multipleTable" :data="showMaterialList" tooltip-effect="dark" :max-height="300"
  493. :row-class-name="tableRowClassName" :header-cell-style="rowClass" border style="width: 100%" stripe
  494. height="300px" v-el-table-infinite-scroll="materielHandleScroll">
  495. <el-table-column label="序号" type="index" width="50">
  496. </el-table-column>
  497. <el-table-column label="编码" prop="categoryCode" :show-overflow-tooltip="true"></el-table-column>
  498. <el-table-column label="名称" prop="categoryName" :show-overflow-tooltip="true"></el-table-column>
  499. <el-table-column label="批次号" prop="batchNo"></el-table-column>
  500. <el-table-column label="物料编码" prop="materialCode" :show-overflow-tooltip="true"></el-table-column>
  501. <el-table-column label="发货条码" prop="barcodes" :show-overflow-tooltip="true"></el-table-column>
  502. <el-table-column label="计量数量" prop="minPackingCount"></el-table-column>
  503. <el-table-column label="计量单位" prop="measuringUnit"></el-table-column>
  504. <el-table-column label="物料代号" prop="materielDesignation">
  505. </el-table-column>
  506. <el-table-column label="客户代号" prop="clientCode">
  507. </el-table-column>
  508. <el-table-column label="刻码" prop="engrave"> </el-table-column>
  509. <el-table-column width="100" label="重量" prop="weight">
  510. </el-table-column>
  511. <el-table-column label="重量单位" prop="weightUnit">
  512. </el-table-column>
  513. <el-table-column label="质检结果" prop="result" width="120">
  514. <template slot-scope="{ row }">
  515. <span>{{ qualityResults[row.result] }}</span>
  516. </template>
  517. </el-table-column>
  518. <el-table-column label="质检状态" prop="status" width="120">
  519. <template slot-scope="{ row }">
  520. <span>{{ qualityStatus[row.status] }}</span>
  521. </template>
  522. </el-table-column>
  523. </el-table>
  524. </div> -->
  525. </div>
  526. <div class="center mt20">
  527. <el-button
  528. type="primary"
  529. @click="handleSave('save')"
  530. :loading="saveLoading"
  531. >保存</el-button
  532. >
  533. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  534. >出库</el-button
  535. >
  536. <el-button @click="$router.go(-1)">返回</el-button>
  537. </div>
  538. </el-card>
  539. <AssetsDialog
  540. ref="assetsDialogRef"
  541. :treeIds="formData.extInfo.assetType"
  542. @detailData="detailData"
  543. />
  544. <outboundRequisitionDialog
  545. ref="outboundRequisitionDialogRef"
  546. @detailData="outboundRequisitionSelection"
  547. type="2"
  548. />
  549. </div>
  550. </template>
  551. <script>
  552. import storageApi from '@/api/warehouseManagement/index.js';
  553. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  554. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  555. import { getTreeByGroup } from '@/api/classifyManage';
  556. import openContactDialog from '@/components/contactDialog/openContactDialog.vue';
  557. import {
  558. outputSceneState,
  559. qualityStatus,
  560. qualityResults
  561. } from '@/utils/dict/index';
  562. import outboundRequisitionDialog from '../components/outboundRequisitionDialog.vue';
  563. import selectTree from '@/components/selectTree';
  564. import AssetsDialog from '../components/AssetsDialog.vue';
  565. import { deepClone } from '@/utils';
  566. import { parameterGetByCode } from '@/api/sys/index.js';
  567. export default {
  568. name: 'outgoingManagementAdd',
  569. components: {
  570. selectTree,
  571. AssetsDialog,
  572. outboundRequisitionDialog,
  573. openContactDialog
  574. },
  575. directives: {
  576. 'el-table-infinite-scroll': elTableInfiniteScroll
  577. },
  578. data() {
  579. return {
  580. newColumns: [], // 动态表头
  581. goodsLists: [], // 商品列表
  582. qualityStatus, // 质检状态 0未检 1待检 2已检
  583. qualityResults, // 质检结果 0无 1合格 2不合格
  584. productList: [], // 产品列表
  585. showPackingList: [], // 展示的包装列表
  586. packingList: [], // 包装列表
  587. showMaterialList: [], // 展示物料列表
  588. materialList: [], // 物料列表
  589. extInfo: {}, // 扩展信息
  590. pageSize: 20,
  591. pickingPageNum: 1,
  592. materielPageNum: 1,
  593. dimension: '3',
  594. // outputSceneState: outputSceneState.filter(
  595. // (item) => item.code != '4' && item.code != '11'
  596. // ), // 出库场景状态
  597. outputSceneState,
  598. saveLoading: false,
  599. treeList: [],
  600. isPrice: 1,
  601. formData: {
  602. storageTime: '',
  603. extInfo: {
  604. assetType: [], //物品类型id
  605. assetTypeName: '', //物品类型名称
  606. deptCode: '', //部门code
  607. deptName: '', //部门名称
  608. verifyDeptCode: '', //审核部门编码
  609. verifyDeptName: '', //审核部门名称
  610. deliveryName: '', //送货人名称
  611. fromUserPhone: '', //送货人电话
  612. sourceBizNo: '', //销售订单
  613. urgent: '', //紧急状态
  614. supplierId: '', //供应商ID
  615. supplierName: '', //供应商名称
  616. createUserName: '', //创建人名字
  617. contentImage: [] //图片数组
  618. },
  619. fromUser: '', //送货人
  620. bizType: '', //物品类型
  621. verifyId: '', //审核人Id
  622. verifyName: '', //审核人名称
  623. createUserId: '',
  624. remark: ''
  625. },
  626. rules: {
  627. bizType: {
  628. required: true,
  629. message: '请选择出库场景',
  630. trigger: 'change'
  631. },
  632. 'extInfo.assetType': {
  633. required: true,
  634. message: '请选择物品类型',
  635. trigger: ['change', 'blur']
  636. },
  637. fromId: {
  638. required: true,
  639. message: '请选择领料人',
  640. trigger: 'change'
  641. },
  642. 'extInfo.verifyDeptCode': {
  643. required: true,
  644. message: '请选择领料人部门',
  645. trigger: ['change', 'blur']
  646. }
  647. },
  648. llrLsit: []
  649. };
  650. },
  651. computed: {
  652. clientEnvironmentId() {
  653. return this.$store.state.user.info.clientEnvironmentId;
  654. }
  655. },
  656. async created() {
  657. this.getFieldModel();
  658. this.getListItems();
  659. this.initUserInfo();
  660. this.initDeptData();
  661. this.getNowFormatDate();
  662. //仓库出入库是否显示金额(0:不显示 1:显示)
  663. parameterGetByCode({
  664. code: 'wms_price'
  665. }).then((res) => {
  666. this.isPrice = res.value;
  667. });
  668. let queryObj = this.$route.query;
  669. console.log('queryObj------', queryObj);
  670. if (queryObj.ids) {
  671. this.formData.bizType = queryObj.bizType;
  672. this.formData.extInfo.assetType = queryObj.assetType.split(',');
  673. let data = await storageApi.getHierarchyList({
  674. ids: this.$route.query.ids,
  675. type: 3
  676. });
  677. this.detailData(data, 3);
  678. }
  679. if (queryObj.type) {
  680. this.formData.sourceBizNo = queryObj.code;
  681. this.$nextTick(() => {
  682. this.$refs.outboundRequisitionDialogRef.handleMine([queryObj]);
  683. });
  684. }
  685. console.log(queryObj, 'queryObj.detailId');
  686. if (queryObj.detailId) {
  687. this._getInfo(queryObj.detailId);
  688. }
  689. },
  690. methods: {
  691. // 获取当前时间函数
  692. getNowDate() {
  693. let date = new Date(),
  694. obj = {
  695. year: date.getFullYear(), //获取完整的年份(4位)
  696. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  697. strDate: date.getDate(), // 获取当前日(1-31)
  698. hour: date.getHours(), //获取当前小时(0 ~ 23)
  699. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  700. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  701. };
  702. Object.keys(obj).forEach((key) => {
  703. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  704. });
  705. return obj;
  706. },
  707. // 赋值出库时间
  708. getNowFormatDate() {
  709. let obj = this.getNowDate();
  710. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  711. },
  712. outboundRequisitionSelection(data, dimension, query) {
  713. console.log(data, dimension, query);
  714. this.formData.sourceBizNo = query.sourceBizNo;
  715. this.formData.bizType = Number(query.bizType);
  716. this.formData.extInfo.assetType = query.assetType.split(',');
  717. this.detailData(data, dimension);
  718. },
  719. // 获取动态表头
  720. getFieldModel() {
  721. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  722. let newRes = res.map((m) => {
  723. return {
  724. prop: 'extField.' + m.prop,
  725. label: m.label,
  726. align: 'center',
  727. showOverflowTooltip: true
  728. };
  729. });
  730. this.newColumns = [...newRes];
  731. });
  732. },
  733. userSlected(data) {
  734. console.log(data);
  735. this.formData.fromId = data.id;
  736. this.formData.fromUser = data.name;
  737. this.formData.fromUserPhone = data.phone;
  738. },
  739. clearDocumentSource() {
  740. console.log('清空');
  741. },
  742. pickingHandleScroll() {
  743. console.log('---------pickingHandleScroll------------');
  744. if (this.showPackingList.length < this.packingList.length) {
  745. if (this.packingList.length > this.pageSize) {
  746. this.pickingPageNum += 1;
  747. }
  748. this.pickingFetchData();
  749. }
  750. },
  751. pickingFetchData() {
  752. const start = (this.pickingPageNum - 1) * this.pageSize;
  753. const end = start + this.pageSize;
  754. this.showPackingList = this.showPackingList.concat(
  755. this.packingList.slice(start, end)
  756. );
  757. },
  758. materielHandleScroll() {
  759. console.log('---------materielHandleScroll------------');
  760. if (this.showMaterialList.length < this.materialList.length) {
  761. if (this.materialList.length > this.pageSize) {
  762. this.materielPageNum += 1;
  763. }
  764. this.materielFetchData();
  765. }
  766. },
  767. materielFetchData() {
  768. const start = (this.materielPageNum - 1) * this.pageSize;
  769. const end = start + this.pageSize;
  770. this.showMaterialList = this.showMaterialList.concat(
  771. this.materialList.slice(start, end)
  772. );
  773. console.log(this.showMaterialList);
  774. },
  775. // 获取物品列表
  776. async getListItems() {
  777. const { data } = await getTreeByGroup({ type: 2 });
  778. this.goodsLists = data;
  779. },
  780. // 打开单据来源弹窗
  781. openDocumentSourceDialog() {
  782. this.$refs.outboundRequisitionDialogRef.open();
  783. },
  784. tableRowClassName({ row, rowIndex }) {
  785. console.log(row);
  786. if (row.result == 1) {
  787. return 'warning-row';
  788. } else {
  789. return '';
  790. }
  791. },
  792. // getDeptName() {
  793. // if (this.formData?.extInfo?.createUserId) {
  794. // storageApi.getGroupById(this.formData.extInfo.createUserId).then((res) => {
  795. // this.formData.extInfo.deptName = res?.groupName
  796. // });
  797. // }
  798. // },
  799. async _getInfo(detailId) {
  800. let res = await storageApi.getInboundDetailsById(detailId);
  801. this.formData = res;
  802. this.formData.extInfo.assetType = res.extInfo?.assetType?.split(',');
  803. this.formData.bizType = res.bizType;
  804. console.log(this.formData.extInfo, '');
  805. this.auditorDeptClick({
  806. id: this.formData.extInfo?.verifyDeptCode,
  807. name: this.formData.extInfo?.verifyDeptName
  808. });
  809. // this.getDeptName()
  810. this.productList = res.outInDetailList.map(
  811. (productItem, productIndex) => {
  812. return {
  813. ...productItem,
  814. outInDetailRecordRequestList:
  815. productItem.outInDetailRecordRequestList.map((packingItem) => {
  816. return {
  817. ...packingItem,
  818. categoryName: productItem.categoryName,
  819. categoryCode: productItem.categoryCode,
  820. materialDetailList: packingItem.materialDetailList.map(
  821. (materialItem) => {
  822. return {
  823. ...materialItem,
  824. categoryName: productItem.categoryName,
  825. categoryCode: productItem.categoryCode
  826. };
  827. }
  828. )
  829. };
  830. })
  831. };
  832. }
  833. );
  834. // 获取包装维度数据
  835. const arr = [];
  836. for (const key in this.productList) {
  837. for (const k in this.productList[key].outInDetailRecordRequestList) {
  838. arr.push({
  839. ...this.productList[key].outInDetailRecordRequestList[k]
  840. });
  841. }
  842. }
  843. this.packingList = arr;
  844. // 获取物料维度数据
  845. let iArr = [];
  846. arr.forEach((item) => {
  847. item.materialDetailList.forEach((ele) => {
  848. iArr.push({ ...ele });
  849. });
  850. });
  851. this.materialList = iArr;
  852. console.log(this.packingList);
  853. console.log(this.materialList);
  854. this.pickingFetchData();
  855. this.materielFetchData();
  856. },
  857. detailData(data, dimension) {
  858. this.dimension = dimension;
  859. const mergedData = [...(this.formData.outInDetailList || []), ...data];
  860. this.formData.outInDetailList = mergedData;
  861. this.productList = mergedData.map((productItem) => {
  862. console.log(productItem, 'productItem');
  863. return {
  864. ...productItem,
  865. outInDetailRecordRequestList:
  866. productItem.outInDetailRecordRequestList.map((packingItem) => {
  867. return {
  868. ...packingItem,
  869. categoryName: productItem.categoryName,
  870. categoryCode: productItem.categoryCode,
  871. supplierCode: productItem.supplierCode,
  872. supplierName: productItem.supplierName,
  873. materialDetailList: packingItem.materialDetailList.map(
  874. (materialItem) => {
  875. return {
  876. ...materialItem,
  877. categoryName: productItem.categoryName,
  878. categoryCode: productItem.categoryCode
  879. };
  880. }
  881. )
  882. };
  883. })
  884. };
  885. });
  886. const newProducts = mergedData.map((productItem) => ({
  887. ...productItem,
  888. outInDetailRecordRequestList:
  889. productItem.outInDetailRecordRequestList.map((packingItem) => ({
  890. ...packingItem,
  891. categoryName: productItem.categoryName,
  892. categoryCode: productItem.categoryCode,
  893. supplierCode: productItem.supplierCode,
  894. supplierName: productItem.supplierName,
  895. materialDetailList: packingItem.materialDetailList.map(
  896. (materialItem) => ({
  897. ...materialItem,
  898. categoryName: productItem.categoryName,
  899. categoryCode: productItem.categoryCode,
  900. supplierCode: productItem.supplierCode,
  901. supplierName: productItem.supplierName
  902. })
  903. )
  904. }))
  905. }));
  906. // 去重合并产品列表和新产品列表
  907. const uniqueProducts = [
  908. ...new Map(
  909. [...this.productList, ...newProducts].map((item) => [item.id, item])
  910. ).values()
  911. ];
  912. this.productList = uniqueProducts;
  913. //排序
  914. this.productList.sort((a, b) => a.categoryCode - b.categoryCode);
  915. console.log(this.productList, '物品清单');
  916. // 获取包装维度数据
  917. const arr = [];
  918. for (const key in this.productList) {
  919. for (const k in this.productList[key].outInDetailRecordRequestList) {
  920. arr.push({
  921. ...this.productList[key].outInDetailRecordRequestList[k]
  922. });
  923. }
  924. }
  925. this.packingList = arr;
  926. const newPacking = [];
  927. newProducts.forEach((item) => {
  928. newPacking.push(...item.outInDetailRecordRequestList);
  929. });
  930. //去重
  931. const newPackingList = [
  932. ...new Map(
  933. [...this.packingList, ...newPacking].map((item) => [item.id, item])
  934. ).values()
  935. ];
  936. this.packingList = newPackingList;
  937. this.packingList.sort((a, b) => a.categoryCode - b.categoryCode);
  938. console.log(this.packingList, '包装');
  939. // 获取物料维度数据
  940. let iArr = [];
  941. arr.forEach((item) => {
  942. item.materialDetailList.forEach((ele) => {
  943. iArr.push({ ...ele });
  944. });
  945. });
  946. this.materialList = iArr;
  947. const newMaterial = [];
  948. newPacking.forEach((item) => {
  949. newMaterial.push(...item.materialDetailList);
  950. });
  951. this.materialList = [...this.materialList, ...newMaterial];
  952. // 触发分页更新
  953. this.pickingPageNum = 1;
  954. this.materielPageNum = 1;
  955. this.pickingFetchData();
  956. this.materielFetchData();
  957. },
  958. handleSave(type) {
  959. this.$refs.formName.validate(async (valid) => {
  960. if (valid) {
  961. if (!this.productList?.length) {
  962. return this.$message.error('请添加出库明细!');
  963. }
  964. let obj = deepClone({ ...this.formData, type: 2 });
  965. obj.extInfo.sourceBizNo = obj.sourceBizNo;
  966. obj.fromType = obj.type;
  967. this.saveLoading = true;
  968. // 处理物品类型assetType
  969. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  970. // 处理仓库id
  971. let warehouseId = [];
  972. let warehouseName = [];
  973. let warehouseIds = this.productList
  974. .map((item) => item.warehouseId)
  975. .flat();
  976. let warehouseNames = this.productList
  977. .map((item) => item.warehouseName)
  978. .flat();
  979. warehouseIds.forEach((item, index) => {
  980. if (!warehouseId.includes(item)) {
  981. warehouseId.push(item);
  982. warehouseName.push(warehouseNames[index]);
  983. }
  984. });
  985. obj.warehouseIds = warehouseId;
  986. obj.warehouseNames = warehouseName;
  987. try {
  988. let api = obj.id ? storageApi.outUpdate : storageApi.outStorage;
  989. const res = await api(obj);
  990. if (res.code == 0) {
  991. if (type != 'save') {
  992. await storageApi.submitInsideTwo({ outInIds: res.data });
  993. this.$message.success('出库成功!');
  994. } else {
  995. this.$message.success('保存成功!');
  996. }
  997. this.$router.push('/warehouseManagement/outgoingManagement');
  998. }
  999. this.saveLoading = false;
  1000. } catch (error) {
  1001. this.saveLoading = false;
  1002. this.$router.push('/warehouseManagement/outgoingManagement');
  1003. this.$message.error('保存失败!');
  1004. }
  1005. } else {
  1006. this.$message.error('请选择领料人!');
  1007. }
  1008. });
  1009. },
  1010. contactDialogSuccess(data) {
  1011. this.$set(this.formData, 'clientName', data.name);
  1012. this.$set(this.formData, 'clientCode', data.code);
  1013. },
  1014. onClear() {
  1015. this.formData.sourceBizNo = '';
  1016. this.warehousingMaterialList = [];
  1017. this.$refs.trees.valueTitle = '';
  1018. this.formData.clientName = '';
  1019. this.formData.clientUser = '';
  1020. this.formData.clientPhone = '';
  1021. this.$forceUpdate();
  1022. },
  1023. rowClass({ row, column, rowIndex, columnIndex }) {
  1024. if (rowIndex === 1) {
  1025. return {
  1026. display: 'none',
  1027. background: '#EEEEEE'
  1028. };
  1029. }
  1030. return { background: '#0000' };
  1031. },
  1032. // 部门点击事件
  1033. async auditorDeptClick(data) {
  1034. console.log(data);
  1035. this.formData.extInfo.verifyDeptCode = data?.id;
  1036. this.formData.extInfo.verifyDeptName = data?.name;
  1037. this.$set(this.formData.extInfo, 'verifyDeptCode', data?.id);
  1038. this.$set(this.formData.extInfo, 'verifyDeptName', data?.name);
  1039. this.formData.verifyId = '';
  1040. this.formData.verifyName = '';
  1041. this.$refs.formName.validateField('verifyDeptName');
  1042. if (data) {
  1043. this.getStaffList(data);
  1044. }
  1045. },
  1046. async getStaffList(data) {
  1047. let res = await warehouseDefinition.getUserPage({
  1048. groupId: data.id,
  1049. size: 9999,
  1050. page: 1
  1051. });
  1052. this.llrLsit = res.list;
  1053. const user = this.llrLsit.find(
  1054. (item) => item.id == this.formData.fromId
  1055. );
  1056. if (!user) {
  1057. this.$set(this.formData, 'fromId', '');
  1058. this.$set(this.formData, 'fromUser', '');
  1059. this.$set(this.formData, 'fromUserPhone', '');
  1060. }
  1061. },
  1062. // 初始化用户信息
  1063. async initUserInfo() {
  1064. const res = await warehouseDefinition.tree();
  1065. let info = JSON.parse(localStorage.getItem('info'));
  1066. let obj = res.find(
  1067. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1068. );
  1069. // if (!obj) return;
  1070. if (obj) {
  1071. this.formData.extInfo.deptCode = obj.id;
  1072. this.formData.extInfo.deptName = obj.name;
  1073. } else {
  1074. this.formData.extInfo.deptName = info.deptName
  1075. ? info.deptName
  1076. : info.groupName
  1077. ? info.groupName
  1078. : '';
  1079. }
  1080. this.formData.extInfo.createUserName = info.name;
  1081. this.formData.createUserId = info.userId;
  1082. console.log(this.$route.query.detailId);
  1083. if (!this.$route.query.detailId) {
  1084. // 默认领料人部门
  1085. this.$set(this.formData.extInfo, 'verifyDeptCode', info?.groupId);
  1086. this.$set(this.formData.extInfo, 'verifyDeptName', info?.groupName);
  1087. // 领料人
  1088. await this.getStaffList({ id: info?.groupId });
  1089. this.$set(this.formData, 'fromId', info.userId);
  1090. this.$set(this.formData, 'fromUser', info.name);
  1091. this.$set(this.formData, 'fromUserPhone', info.phone);
  1092. }
  1093. },
  1094. // 初始化部门数据
  1095. async initDeptData() {
  1096. const res = await warehouseDefinition.tree();
  1097. this.treeList = this.$util.toTreeData({
  1098. data: res,
  1099. idField: 'id',
  1100. parentIdField: 'parentId'
  1101. });
  1102. },
  1103. addStock() {
  1104. if (
  1105. !(
  1106. this.formData.extInfo.assetType &&
  1107. this.formData.extInfo.assetType.length > 0
  1108. )
  1109. )
  1110. return this.$message.error('请选择出库产品类型');
  1111. if (!this.formData.bizType && this.formData.bizType !== 0)
  1112. return this.$message.error('请选择出库场景');
  1113. this.$refs.assetsDialogRef.open(this.productList);
  1114. },
  1115. handleBizSceneChange() {
  1116. if (this.formData.extInfo.assetType == 7) {
  1117. this.formData.extInfo.sourceBizNo = '';
  1118. }
  1119. this.formData.sourceBizNo = '';
  1120. }
  1121. },
  1122. watch: {
  1123. packingList: {
  1124. handler(newVal) {
  1125. console.log('包装列表', newVal);
  1126. console.log('当前包装列表加载页数', this.pickingPageNum);
  1127. this.showPackingList = newVal.slice(
  1128. 0,
  1129. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1130. );
  1131. },
  1132. deep: true
  1133. },
  1134. materialList: {
  1135. handler(newVal) {
  1136. console.log('物料列表', newVal);
  1137. console.log('当前物料列表加载页数', this.materielPageNum);
  1138. this.showMaterialList = newVal.slice(
  1139. 0,
  1140. this.pageSize *
  1141. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1142. );
  1143. },
  1144. deep: true
  1145. },
  1146. '$route.query': {
  1147. handler(newQuery, oldQuery) {
  1148. if (newQuery?.detailId) {
  1149. this._getInfo(newQuery.detailId);
  1150. }
  1151. },
  1152. deep: true // 确保对象内部的属性变化也能被监听到
  1153. }
  1154. }
  1155. };
  1156. </script>
  1157. <style lang="scss" scoped>
  1158. ::v-deep .el-row {
  1159. display: flex;
  1160. flex-wrap: wrap;
  1161. }
  1162. ::v-deep.form-table {
  1163. .el-form-item {
  1164. margin-bottom: 0;
  1165. }
  1166. .el-input__inner {
  1167. padding: 0 10px;
  1168. }
  1169. }
  1170. .p20 {
  1171. padding: 20px;
  1172. }
  1173. .el-select,
  1174. .el-date-editor {
  1175. width: 100%;
  1176. }
  1177. .el-form-item {
  1178. margin-bottom: 22px;
  1179. }
  1180. .material {
  1181. margin-top: 20px;
  1182. .flex {
  1183. display: flex;
  1184. justify-content: space-between;
  1185. font-size: 14px;
  1186. align-items: center;
  1187. .red {
  1188. color: #ff4949;
  1189. }
  1190. }
  1191. }
  1192. .mt10 {
  1193. margin-top: 10px;
  1194. }
  1195. .mt20 {
  1196. margin-top: 20px;
  1197. }
  1198. .center {
  1199. text-align: center;
  1200. }
  1201. </style>