add.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息"></header-title>
  5. <!-- <basic-information
  6. ref="basicInformation"
  7. @onFormChange="formDataChange"
  8. @onClearMaterialList="clearMaterialList"
  9. :myFormData="formData"
  10. :warehousingMaterialList="warehousingMaterialList"
  11. :rules="rules"
  12. ></basic-information> -->
  13. <el-form
  14. :model="formData"
  15. ref="formName"
  16. label-width="110px"
  17. :rules="rules"
  18. >
  19. <el-row :gutter="20">
  20. <el-col :span="8">
  21. <el-form-item label="出库场景" prop="bizType">
  22. <el-select
  23. filterable
  24. placeholder="请选择"
  25. v-model="formData.bizType"
  26. clearable
  27. @change="handleBizSceneChange"
  28. :disabled="
  29. !!(warehousingMaterialList && warehousingMaterialList.length)
  30. "
  31. >
  32. <el-option
  33. v-for="item in outputSceneState"
  34. :key="item.code"
  35. :value="item.code + ''"
  36. :label="item.label"
  37. ></el-option>
  38. </el-select> </el-form-item
  39. ></el-col>
  40. <el-col :span="8">
  41. <el-form-item
  42. :label="
  43. formData.bizType == 3
  44. ? '销售发货单'
  45. : formData.bizType == 4
  46. ? '领料单'
  47. : formData.bizType == 1
  48. ? '采购退货单'
  49. : '来源单据'
  50. "
  51. prop="sourceBizNo"
  52. v-if="formData.extInfo.assetType == 7 && formData.bizType == 4"
  53. >
  54. <el-select
  55. filterable
  56. v-model="formData.sourceBizNo"
  57. :disabled="
  58. !!(formData.sourceBizNo && warehousingMaterialList.length)
  59. "
  60. clearable
  61. placeholder="请输入"
  62. @change="handleDocumentSourceChange"
  63. >
  64. <el-option
  65. v-for="item in options"
  66. :key="item"
  67. :label="item"
  68. :value="item"
  69. >
  70. </el-option> </el-select
  71. ></el-form-item>
  72. <el-form-item
  73. :label="
  74. formData.bizType == 3
  75. ? '销售发货单'
  76. : formData.bizType == 4
  77. ? '领料单'
  78. : formData.bizType == 1
  79. ? '采购退货单'
  80. : '来源单据'
  81. "
  82. v-else
  83. prop="sourceBizNo"
  84. >
  85. <el-input
  86. @input="$forceUpdate()"
  87. placeholder="请输入"
  88. @change="handleDocumentSourceChange"
  89. v-model="formData.sourceBizNo"
  90. @click.native="
  91. formData.bizType == 4
  92. ? handlePickorder()
  93. : formData.bizType == 3
  94. ? handleEom()
  95. : null
  96. "
  97. >
  98. <el-button
  99. v-if="formData.bizType == 4 || formData.bizType == 3"
  100. slot="append"
  101. icon="el-icon-circle-close"
  102. @click.stop="onClear"
  103. ></el-button>
  104. </el-input>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="8">
  108. <el-form-item label="出库物品类型" prop="extInfo.assetType">
  109. <selectTree
  110. ref="trees"
  111. class="form-ipt"
  112. :isBindPlan="
  113. !!(warehousingMaterialList && warehousingMaterialList.length)
  114. "
  115. size="medium"
  116. style="width: 100%"
  117. clearable
  118. :options="codeList"
  119. :props="{
  120. value: 'id',
  121. label: 'name',
  122. children: 'children'
  123. }"
  124. @getValue="codeListValue"
  125. :isAll="false"
  126. />
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="8" v-if="formData.bizType == 3">
  130. <el-form-item label="客户名称">
  131. <el-input
  132. placeholder="客户名称"
  133. disabled
  134. v-model="formData.clientName"
  135. clearable /></el-form-item
  136. ></el-col>
  137. <el-col :span="8" v-if="formData.bizType == 3">
  138. <el-form-item label="客户联系人">
  139. <el-input
  140. placeholder="客户联系人"
  141. disabled
  142. v-model="formData.clientUser"
  143. clearable /></el-form-item
  144. ></el-col>
  145. <el-col :span="8" v-if="formData.bizType == 3">
  146. <el-form-item label="客户电话">
  147. <el-input
  148. placeholder="客户电话"
  149. disabled
  150. v-model="formData.clientPhone"
  151. clearable /></el-form-item
  152. ></el-col>
  153. <el-col :span="8">
  154. <el-form-item label="权属部门" prop="deptName">
  155. <el-input
  156. placeholder="权属部门"
  157. disabled
  158. v-model="formData.extInfo.deptName"
  159. clearable
  160. />
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="8">
  164. <el-form-item label="出库登记人">
  165. <el-input
  166. placeholder="登记人"
  167. disabled
  168. v-model="formData.extInfo.createUserName"
  169. clearable /></el-form-item
  170. ></el-col>
  171. <el-col :span="8">
  172. <el-form-item label="领料人部门" prop="verifyDeptName">
  173. <selectTree
  174. ref="tree"
  175. class="form-ipt"
  176. size="medium"
  177. style="width: 100%"
  178. clearable
  179. :options="treeList"
  180. :props="{
  181. value: 'code',
  182. label: 'name',
  183. children: 'children'
  184. }"
  185. @getValue="auditorDeptClick"
  186. />
  187. </el-form-item>
  188. </el-col>
  189. <el-col :span="8">
  190. <el-form-item label="领料人" prop="fromUser">
  191. <el-select
  192. v-model="formData.fromUser"
  193. filterable
  194. placeholder="请选择领料人"
  195. >
  196. <el-option
  197. v-for="item in llrLsit"
  198. :key="item.id"
  199. :label="item.name"
  200. :value="item.id"
  201. @click.native="
  202. () => (formData.extInfo.fromUserPhone = item.phone)
  203. "
  204. >
  205. </el-option>
  206. </el-select> </el-form-item
  207. ></el-col>
  208. <el-col :span="8">
  209. <el-form-item label="领料人联系方式" prop="fromUserPhone">
  210. <el-input
  211. placeholder="请输入"
  212. disabled
  213. v-model="formData.extInfo.fromUserPhone"
  214. clearable /></el-form-item
  215. ></el-col>
  216. <el-col :span="24">
  217. <el-form-item label="备注" prop="remark">
  218. <el-input
  219. v-model="formData.remark"
  220. clearable
  221. type="textarea"
  222. placeholder="请详细说明"
  223. :rows="4"
  224. ></el-input>
  225. </el-form-item>
  226. </el-col>
  227. </el-row>
  228. </el-form>
  229. <div>
  230. <el-button
  231. style="margin-bottom: 20px; float: right; margin-right: 20px"
  232. type="primary"
  233. @click="addStock"
  234. >添加</el-button
  235. >
  236. </div>
  237. <div class="material">
  238. <div v-if="dimension != 4">
  239. <header-title title="物品清单"></header-title>
  240. <div class="mt10 form-table">
  241. <el-form
  242. ref="warehousingMaterialListRef"
  243. :model="{ warehousingMaterialList: warehousingMaterialList }"
  244. :show-message="false"
  245. >
  246. <el-table
  247. ref="warehousingMaterialListTable"
  248. :data="warehousingMaterialList"
  249. tooltip-effect="dark"
  250. style="width: 100%"
  251. :max-height="300"
  252. stripe
  253. :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
  254. >
  255. <el-table-column label="序号" type="index" width="50">
  256. </el-table-column>
  257. <el-table-column
  258. label="编码"
  259. prop="assetCode"
  260. width="150"
  261. :show-overflow-tooltip="true"
  262. ></el-table-column>
  263. <el-table-column
  264. label="名称"
  265. width="200"
  266. prop="assetName"
  267. :show-overflow-tooltip="true"
  268. ></el-table-column>
  269. <el-table-column
  270. v-for="(item, index) in tableHeader"
  271. :key="index"
  272. align="center"
  273. :label="item.label"
  274. :width="item.width"
  275. :prop="item.prop"
  276. :show-overflow-tooltip="true"
  277. >
  278. <template slot-scope="{ row }">
  279. <template v-if="item.formatter">{{
  280. item.formatter(row)
  281. }}</template>
  282. <template v-else>{{ row[item.prop] }}</template>
  283. </template>
  284. </el-table-column>
  285. <el-table-column
  286. label="批次号"
  287. prop="batchNo"
  288. ></el-table-column>
  289. <el-table-column label="最小包装单元" width="120">
  290. <template slot-scope="{ row }">
  291. {{ row.minPackingCount }}{{ row.measuringUnit }}/{{
  292. row.minUnit
  293. }}
  294. </template>
  295. </el-table-column>
  296. <el-table-column label="包装数量" prop="availableCountBase">
  297. <template slot-scope="{ row }">
  298. {{ row.packingCountBase }}{{ row.minUnit }}
  299. </template>
  300. </el-table-column>
  301. <el-table-column
  302. label="计量数量"
  303. prop="availableCountBase"
  304. ></el-table-column>
  305. <el-table-column
  306. label="计量单位"
  307. prop="measuringUnit"
  308. ></el-table-column>
  309. <el-table-column label="重量" prop="weight"></el-table-column>
  310. <el-table-column
  311. label="重量单位"
  312. prop="weightUnit"
  313. ></el-table-column>
  314. <el-table-column
  315. label="仓库"
  316. width="300"
  317. prop="pathName"
  318. :show-overflow-tooltip="true"
  319. ></el-table-column>
  320. <el-table-column fixed="right" label="操作" width="200">
  321. <template slot-scope="{ row, $index }">
  322. <el-button type="text" @click="listDel(row, $index)"
  323. >删除</el-button
  324. >
  325. </template>
  326. </el-table-column>
  327. </el-table>
  328. </el-form>
  329. </div>
  330. <header-title class="mt20" title="包装清单"></header-title>
  331. <div class="mt10 form-table">
  332. <BatchDetail
  333. :assetType="formData.extInfo.assetType"
  334. :data="batchDetailsVOList"
  335. />
  336. </div>
  337. </div>
  338. <div class="mt20">
  339. <header-title class="mt20" title="物料明细"></header-title>
  340. <el-tabs v-model="activeName" type="card">
  341. <el-tab-pane :label="`${title}明细`" name="a">
  342. <el-table
  343. ref="multipleTable"
  344. :data="materialCodeReqList"
  345. tooltip-effect="dark"
  346. style="width: 100%"
  347. :max-height="300"
  348. stripe
  349. :header-cell-style="rowClass"
  350. >
  351. <el-table-column label="序号" type="index" width="50">
  352. </el-table-column>
  353. <el-table-column
  354. :label="`编码`"
  355. min-width="100"
  356. prop="assetCode"
  357. :show-overflow-tooltip="true"
  358. ></el-table-column>
  359. <el-table-column
  360. label="名称"
  361. prop="name"
  362. width="200"
  363. :show-overflow-tooltip="true"
  364. >
  365. </el-table-column>
  366. <el-table-column label="批次号" prop="batchNo">
  367. </el-table-column>
  368. <el-table-column
  369. v-if="dimension == 4"
  370. label="包装编码"
  371. min-width="100"
  372. prop="onlyCode"
  373. :show-overflow-tooltip="true"
  374. ></el-table-column>
  375. <el-table-column
  376. v-for="(item, index) in tableHeader"
  377. :key="index"
  378. align="center"
  379. :label="item.label"
  380. :width="item.width"
  381. :prop="item.prop"
  382. :show-overflow-tooltip="true"
  383. >
  384. <template slot-scope="{ row }">
  385. <template v-if="item.formatter">{{
  386. item.formatter(row)
  387. }}</template>
  388. <template v-else>{{ row[item.prop] }}</template>
  389. </template>
  390. </el-table-column>
  391. <el-table-column
  392. label="物料编码"
  393. width="250"
  394. prop="no"
  395. :show-overflow-tooltip="true"
  396. ></el-table-column>
  397. <!-- <el-table-column label="生产日期" width="200">
  398. <template slot-scope="{ row }">
  399. <span v-if="row.dateType === 2">
  400. {{ row.produceTime }}
  401. </span>
  402. </template>
  403. </el-table-column>
  404. <el-table-column label="采购日期" width="200">
  405. <template slot-scope="{ row }">
  406. <span v-if="row.dateType === 1">
  407. {{ row.procureTime }}
  408. </span>
  409. </template>
  410. </el-table-column> -->
  411. <el-table-column label="计量数量" prop="">
  412. <template slot-scope="{ row }">1</template>
  413. </el-table-column>
  414. <el-table-column
  415. label="计量单位"
  416. prop="measuringUnit"
  417. ></el-table-column>
  418. <el-table-column
  419. label="物料代号"
  420. prop="materielCode"
  421. width="130"
  422. >
  423. </el-table-column>
  424. <el-table-column
  425. label="客户代号"
  426. prop="clientCode"
  427. ></el-table-column>
  428. <el-table-column label="刻码" prop="engrave"></el-table-column>
  429. <el-table-column label="重量" prop="weight"></el-table-column>
  430. <el-table-column
  431. label="重量单位"
  432. prop="weightUnit"
  433. ></el-table-column>
  434. <!-- <el-table-column
  435. label="货位"
  436. prop="pathName"
  437. show-overflow-tooltip
  438. >
  439. </el-table-column>
  440. <el-table-column label="转消耗" prop="">
  441. <template slot-scope="{ row }">
  442. <el-checkbox v-model="row.isTransferAsset"></el-checkbox>
  443. </template>
  444. </el-table-column> -->
  445. </el-table>
  446. </el-tab-pane>
  447. </el-tabs>
  448. </div>
  449. </div>
  450. <div class="center mt20">
  451. <el-button type="primary" @click="handleNewSave" :loading="saveLoading"
  452. >保存</el-button
  453. >
  454. <el-button @click="$router.go(-1)">返回</el-button>
  455. </div>
  456. </el-card>
  457. <AssetsDialog
  458. ref="assetsDialogRef"
  459. :title="title"
  460. :warehousingMaterialList="selectionList"
  461. :assetType="formData.extInfo.assetType"
  462. @detailData="detailData"
  463. />
  464. <!-- @selectTableData="onSelectTableData" -->
  465. <!-- 选桶号 -->
  466. <detailSelect
  467. ref="detailSelectRef"
  468. :title="title"
  469. :tableHeader="tableHeader"
  470. />
  471. <!-- 转资产 -->
  472. <!-- <TurnToAsset ref="turnToAssetRef" /> -->
  473. <!-- 选择仓库 -->
  474. <WareHouseDailog ref="wareHouseDailogRef"></WareHouseDailog>
  475. <!-- 选领料单 -->
  476. <pickOrder ref="pickOrderRef" @success="pickOrderRow" />
  477. <!-- 销售订单 -->
  478. <eom ref="eomRef" @success="eomSuccess" />
  479. </div>
  480. </template>
  481. <script>
  482. import outin from '@/api/warehouseManagement/outin';
  483. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  484. import {
  485. getTreeByPid,
  486. getTreeByGroup,
  487. getProductList
  488. } from '@/api/classifyManage';
  489. import selectUpload from '@/components/selectUpload';
  490. import upload from '@/components/uploadImg';
  491. import pickOrder from './components/pickOrder.vue';
  492. import {
  493. warehousingType,
  494. outputSceneState,
  495. emergencyState,
  496. materialType
  497. } from '@/utils/dict/index';
  498. import selectTree from '@/components/selectTree';
  499. import AssetsDialog from '../components/AssetsDialog.vue';
  500. import outputType from '../components/outputType.vue';
  501. // import TurnToAsset from '../components/TurnToAsset/index.vue'
  502. import WareHouseDailog from '../components/WareHouseDailog.vue';
  503. // import supplier from '@/api/main/supplier';
  504. // import org from '@/api/main/org';
  505. // import user from '@/api/main/user';
  506. import { tableHeader } from '../common';
  507. import detailSelect from './components/detailSelect';
  508. import eom from './components/eom.vue';
  509. import BatchDetail from './components/batchDetail.vue';
  510. import { watch } from 'ele-admin/lib/ele-pro-table';
  511. export default {
  512. components: {
  513. BatchDetail,
  514. pickOrder,
  515. selectUpload,
  516. selectTree,
  517. AssetsDialog,
  518. WareHouseDailog,
  519. upload,
  520. detailSelect,
  521. // TurnToAsset,
  522. outputType,
  523. eom
  524. },
  525. data() {
  526. return {
  527. dimension: '3',
  528. llList: [],
  529. codeList: [],
  530. materialType,
  531. warehousingType,
  532. outputSceneState,
  533. emergencyState,
  534. saveLoading: false,
  535. title: '',
  536. tableData2: [],
  537. uploadList: [],
  538. fromUserList: [], //人员数组
  539. warehousingMaterialList: [], // 物品列表
  540. activeName: 'a',
  541. treeList: [],
  542. staffList: [],
  543. formData: {
  544. extInfo: {
  545. assetType: '', //物品类型id
  546. assetTypeName: '', //物品类型名称
  547. deptCode: '', //部门code
  548. deptName: '', //部门名称
  549. verifyDeptCode: '', //审核部门编码
  550. verifyDeptName: '', //审核部门名称
  551. deliveryName: '', //送货人名称
  552. fromUserPhone: '', //送货人电话
  553. sourceBizNo: '', //销售订单
  554. urgent: '', //紧急状态
  555. supplierId: '', //供应商ID
  556. supplierName: '', //供应商名称
  557. createUserName: '', //创建人名字
  558. contentImage: [] //图片数组
  559. },
  560. fromUser: '', //送货人
  561. bizType: '', //物品类型
  562. verifyId: '', //审核人Id
  563. verifyName: '', //审核人名称
  564. createUserId: '',
  565. remark: ''
  566. },
  567. rules: {
  568. bizType: {
  569. required: true,
  570. message: '请选择出库场景',
  571. trigger: 'change'
  572. },
  573. fromUser: {
  574. required: true,
  575. message: '请选择领料人',
  576. trigger: 'change'
  577. }
  578. },
  579. llrLsit: [],
  580. options: [],
  581. loading: false,
  582. onSelectTableDataVal: [],
  583. batchDetailsVOList: [],
  584. materialCodeReqList: [],
  585. selectionList: [],
  586. // shouldTriggerPickorder: true,
  587. materialObj: {},
  588. wlParams: {}
  589. };
  590. },
  591. computed: {
  592. tableHeader() {
  593. return tableHeader(this.formData.extInfo.assetType);
  594. }
  595. // 条码信息
  596. // materialCodeReqList() {
  597. // return this.warehousingMaterialList
  598. // .map((i) => i.warehouseLedgerDetails || [])
  599. // .flat();
  600. // }
  601. },
  602. created() {
  603. this.initData();
  604. },
  605. methods: {
  606. // 接收表单数据动态数据
  607. formDataChange(val) {
  608. this.formData = val;
  609. },
  610. // 清空物品列表
  611. clearMaterialList() {
  612. this.warehousingMaterialList = [];
  613. },
  614. detailData(data, dimension) {
  615. this.dimension = dimension;
  616. console.log('总数居', data);
  617. this.onSelectTableDataVal = data.realTimeInventoryVOList;
  618. this.warehousingMaterialList = data.realTimeInventoryVOList.map(
  619. (next) => {
  620. delete next.updateTime;
  621. delete next.createTime;
  622. return {
  623. ...next,
  624. realInventoryAmount: 0,
  625. assetType: this.formData.extInfo.assetType,
  626. outInNum: '',
  627. assetCode: next.code,
  628. assetName: next.name,
  629. bizStatus: 2,
  630. contactCode: next.contactCode
  631. };
  632. }
  633. );
  634. // this.batchDetailsVOList = data.batchDetailsVOList;
  635. if (dimension == 4) {
  636. this.materialCodeReqList = data.wlList;
  637. this.selectionList = data.wlList;
  638. let params = {
  639. realTimeInventoryNewPOList: data.realTimeInventoryVOList
  640. };
  641. for (const item of params.realTimeInventoryNewPOList) {
  642. item.inventoryDetailsNewPOList = item.inventoryDetailsVOList;
  643. for (const detail of item.inventoryDetailsNewPOList) {
  644. detail.outInMaterialDetailsAddPOList = [];
  645. for (const wlItem of data.wlList) {
  646. if (detail.id === wlItem.recordId) {
  647. detail.outInMaterialDetailsAddPOList.push({
  648. ...wlItem
  649. });
  650. }
  651. }
  652. }
  653. }
  654. this.wlParams = params;
  655. this.materialObj = data;
  656. } else if (dimension == 3) {
  657. //包装维度出库
  658. const list = data.realTimeInventoryVOList;
  659. //获取包装维度
  660. let packArr = [];
  661. for (const item of list) {
  662. if (item.inventoryDetailsVOList.length != 0) {
  663. for (const iterator of item.inventoryDetailsVOList) {
  664. packArr.push({ ...iterator, batchNo: iterator.batchNum });
  665. }
  666. }
  667. }
  668. this.batchDetailsVOList = packArr.map((item) => {
  669. return {
  670. ...item,
  671. packingCountBase:
  672. dimension == 4 || dimension == 3 ? 1 : item.packingCountBase
  673. // weight: 0
  674. };
  675. });
  676. //物料维度数据
  677. let meteArr = [];
  678. for (const item of packArr) {
  679. if (item.materialDetailsVOList.length != 0) {
  680. for (const iterator of item.materialDetailsVOList) {
  681. meteArr.push({
  682. ...iterator
  683. });
  684. }
  685. }
  686. }
  687. this.materialCodeReqList = meteArr;
  688. //再次打开选择上
  689. this.selectionList = list;
  690. //send数据
  691. this.wlParams = { realTimeInventoryNewPOList: list };
  692. this.wlParams.realTimeInventoryNewPOList.forEach((item) => {
  693. item.inventoryDetailsNewPOList = item.inventoryDetailsVOList;
  694. item.inventoryDetailsNewPOList.forEach((ite) => {
  695. // ite.weight = 0;
  696. ite.outInMaterialDetailsAddPOList = ite.materialDetailsVOList;
  697. });
  698. });
  699. } else {
  700. // else if (dimension == 2) {
  701. // this.batchDetailsVOList = data.wlList;
  702. // this.selectionList = data.wlList;
  703. // }
  704. //物品维度出库
  705. console.log(data);
  706. const list = data.realTimeInventoryVOList;
  707. //获取包装维度
  708. let packArr = [];
  709. for (const item of list) {
  710. if (item.inventoryDetailsVOList.length != 0) {
  711. for (const iterator of item.inventoryDetailsVOList) {
  712. packArr.push({ ...iterator, batchNo: iterator.batchNum });
  713. }
  714. }
  715. }
  716. this.batchDetailsVOList = packArr.map((item) => {
  717. return {
  718. ...item,
  719. packingCountBase: dimension == 3 ? 1 : item.packingCountBase
  720. // weight: 0
  721. };
  722. });
  723. //物料维度数据
  724. let meteArr = [];
  725. for (const item of packArr) {
  726. if (item.materialDetailsVOList.length != 0) {
  727. for (const iterator of item.materialDetailsVOList) {
  728. meteArr.push({
  729. ...iterator
  730. });
  731. }
  732. }
  733. }
  734. this.materialCodeReqList = meteArr;
  735. //再次打开选择上
  736. this.selectionList = list;
  737. //send数据
  738. this.wlParams = { realTimeInventoryNewPOList: list };
  739. this.wlParams.realTimeInventoryNewPOList.forEach((item) => {
  740. item.inventoryDetailsNewPOList = item.inventoryDetailsVOList;
  741. item.inventoryDetailsNewPOList.forEach((ite) => {
  742. // ite.weight = 0;
  743. ite.outInMaterialDetailsAddPOList = ite.materialDetailsVOList;
  744. });
  745. });
  746. }
  747. },
  748. handleNewSave() {
  749. this.$refs.formName.validate(async (valid) => {
  750. if (valid) {
  751. if (!this.warehousingMaterialList?.length) {
  752. return this.$message.error('请添加出库明细!');
  753. }
  754. let obj = { ...this.formData, type: 2 };
  755. obj.extInfo.sourceBizNo = obj.sourceBizNo;
  756. // obj.fromId=
  757. obj.fromType = obj.type;
  758. this.saveLoading = true;
  759. obj = { ...obj, ...this.wlParams };
  760. if (this.dimension == 4) {
  761. obj.num = this.materialObj.wlList.length;
  762. } else {
  763. obj.num = this.materialCodeReqList.length;
  764. }
  765. console.log('2222', obj);
  766. try {
  767. const res = await outin.saveNew(obj);
  768. if (res.code == 0) {
  769. await await outin.outApprove({ outInId: res.data });
  770. this.$message.success('保存成功!');
  771. }
  772. this.$router.push('/warehouseManagement/outgoingManagement');
  773. if (res?.success) {
  774. this.$message.success('保存成功!');
  775. this.$router.go(-1);
  776. }
  777. this.saveLoading = false;
  778. } catch (error) {
  779. this.saveLoading = false;
  780. }
  781. }
  782. });
  783. },
  784. onClear() {
  785. this.formData.sourceBizNo = '';
  786. this.warehousingMaterialList = [];
  787. this.$refs.trees.valueTitle = '';
  788. this.formData.clientName = '';
  789. this.formData.clientUser = '';
  790. this.formData.clientPhone = '';
  791. this.title = '';
  792. this.$forceUpdate();
  793. },
  794. async eomSuccess(row) {
  795. console.log(row);
  796. this.formData.extInfo.assetType = 9;
  797. this.$refs.trees.valueTitle = '产品';
  798. this.title = '产品';
  799. this.formData.sourceBizNo = row.orderNo;
  800. this.formData.sid = row.id;
  801. this.formData.fromId = row.id;
  802. this.formData.clientName = row.contactName;
  803. this.formData.clientUser = row.linkName;
  804. this.formData.clientPhone = row.linkPhone;
  805. console.log('==sasa', row.tableData);
  806. this.onSelectTableData(await this.serachMainCode(row.tableData), 1);
  807. this.$forceUpdate();
  808. },
  809. async serachMainCode(arr) {
  810. let newArr = [];
  811. // 使用 Promise.all 来等待所有异步操作完成
  812. await Promise.all(
  813. arr.map(async (item) => {
  814. const data = await getProductList({
  815. pageNum: 1,
  816. size: 10,
  817. categoryLevelId: item.productCategoryId,
  818. code: item.code
  819. });
  820. newArr.push(data.list); // 将结果存储到 newArr 中
  821. })
  822. );
  823. let re = [];
  824. for (const item of newArr) {
  825. for (const it of item) {
  826. re.push(it);
  827. }
  828. }
  829. return re.map((item) => {
  830. return {
  831. ...item,
  832. minUnit: item.packingUnit,
  833. assetCode: item.code,
  834. assetName: item.name
  835. };
  836. });
  837. },
  838. async pickOrderRow(row) {
  839. this.formData.sid = row.id;
  840. row.tableData = [];
  841. this.formData.sourceBizNo = row.code;
  842. for (const key in row.orderInfoList) {
  843. if (row.orderInfoList[key].bomDetailDTOS.length != 0) {
  844. for (const i in row.orderInfoList[key].bomDetailDTOS) {
  845. row.tableData.push({
  846. ...row.orderInfoList[key].bomDetailDTOS[i],
  847. code: row.orderInfoList[key].bomDetailDTOS[i].categoryCode,
  848. name: row.orderInfoList[key].bomDetailDTOS[i].categoryName,
  849. modelType: row.orderInfoList[key].bomDetailDTOS[i].model,
  850. id: row.orderInfoList[key].bomDetailDTOS[i].categoryId
  851. });
  852. }
  853. }
  854. if (row.orderInfoList[key].instanceList.length != 0) {
  855. for (const j in row.orderInfoList[key].instanceList) {
  856. row.tableData.push({
  857. ...row.orderInfoList[key].instanceList[j],
  858. code: row.orderInfoList[key].instanceList[j].categoryCode,
  859. name: row.orderInfoList[key].instanceList[j].categoryName,
  860. modelType: row.orderInfoList[key].instanceList[j].model,
  861. id: row.orderInfoList[key].instanceList[j].instanceId
  862. });
  863. }
  864. }
  865. }
  866. const uniqueItems = [];
  867. const uniqueIds = new Set();
  868. row.tableData.forEach((item) => {
  869. if (!uniqueIds.has(item.code)) {
  870. uniqueIds.add(item.code);
  871. uniqueItems.push(item);
  872. }
  873. });
  874. row.tableData = uniqueItems;
  875. console.log(row);
  876. this.onSelectTableData(await this.serachMainCode(row.tableData), 1);
  877. this.selectTop(row);
  878. this.$forceUpdate();
  879. },
  880. async selectTop(row) {
  881. let list = row.tableData;
  882. let arr = [];
  883. for (const it of list) {
  884. arr.push({
  885. categoryLevelId: it.rootCategoryLevelId,
  886. code: it.code,
  887. count: it.demandQuantity
  888. });
  889. }
  890. const data = await outin.getDetailByCode(arr);
  891. console.log('===', data);
  892. },
  893. handleEom() {
  894. this.$refs.eomRef.open();
  895. },
  896. handlePickorder() {
  897. this.$refs.pickOrderRef.open();
  898. },
  899. async handleDocumentSourceChange() {
  900. // this.formData.sourceBizNo = '';
  901. if (!this.formData.sourceBizNo) {
  902. if (this.formData.bizType == 4) {
  903. this.warehousingMaterialList = [];
  904. }
  905. return;
  906. }
  907. if (
  908. !(this.formData.extInfo.assetType == 7 && this.formData.bizType == 4)
  909. ) {
  910. return;
  911. }
  912. const loading = this.$loading({ fullscreen: true });
  913. const res = await getSparePartsInfo({
  914. code: this.formData.sourceBizNo
  915. });
  916. if (res?.success && res.data.length) {
  917. const curMap = {
  918. assetId: 'classificationId',
  919. assetCode: 'informationCode', //编码
  920. assetName: 'informationName', //名称
  921. materialId: 'classificationId',
  922. materialName: 'informationName',
  923. batchNo: '', //批次号
  924. unit: 'measuringUnit', //单位
  925. minPackUnit: 'packingUnit' //最小包装单位
  926. };
  927. res.data.forEach((item) => {
  928. let obj = {};
  929. for (const key in curMap) {
  930. obj[key] = curMap[key] ? item[curMap[key]] : '';
  931. }
  932. obj.curId =
  933. obj.assetCode +
  934. (obj.measurementUnit || '') +
  935. (obj.minPackUnit || '') +
  936. (obj.unit || '');
  937. console.log(obj.curId);
  938. const index = this.warehousingMaterialList.findIndex(
  939. (i) => i.curId === obj.curId
  940. );
  941. if (index === -1) {
  942. Object.assign(obj, item);
  943. obj.sparePartsNum = item.num;
  944. this.warehousingMaterialList.push(obj);
  945. } else {
  946. this.warehousingMaterialList[index].sparePartsNum = item.num;
  947. }
  948. });
  949. }
  950. loading.close();
  951. },
  952. // 备品备件来源单号
  953. async remoteMethod(code) {
  954. // if (code !== '') {
  955. // this.loading = true
  956. const res = await getDocumentSource({ code });
  957. if (res?.success) {
  958. this.options = res.data;
  959. }
  960. // this.loading = false
  961. // } else {
  962. // this.options = []
  963. // }
  964. },
  965. rowClass({ row, column, rowIndex, columnIndex }) {
  966. if (rowIndex === 1) {
  967. return {
  968. display: 'none',
  969. background: '#EEEEEE',
  970. border: 'none'
  971. };
  972. }
  973. return { background: '#EEEEEE', border: 'none' };
  974. },
  975. // 部门点击事件
  976. async auditorDeptClick(data) {
  977. console.log(data);
  978. this.formData.extInfo.verifyDeptCode = data?.id;
  979. this.formData.extInfo.verifyDeptName = data?.name;
  980. this.formData.verifyId = '';
  981. this.formData.verifyName = '';
  982. this.$refs.formName.validateField('verifyDeptName');
  983. if (data) {
  984. this.getStaffList(data);
  985. }
  986. },
  987. async getStaffList(data) {
  988. let res = await warehouseDefinition.getUserPage({
  989. groupId: data.id,
  990. size: 9999,
  991. page: 1
  992. });
  993. this.llrLsit = res.list;
  994. },
  995. handleSetting(row) {
  996. row.bizTypes = this.formData.bizType;
  997. row.type = this.formData.bizType == 3 ? 1 : 0;
  998. this.$refs.detailSelectRef
  999. .open(row, row.warehouseLedgerDetails || [])
  1000. .then((res) => {
  1001. console.log(res);
  1002. console.log(row);
  1003. this.$set(
  1004. row,
  1005. 'warehouseLedgerDetails',
  1006. (res || []).map((item) => {
  1007. delete item.updateTime;
  1008. delete item.createTime;
  1009. this.$set(item, 'isTransferAsset', false);
  1010. item.isUnpack = row.isUnpack;
  1011. return item;
  1012. })
  1013. );
  1014. this.$set(row, 'outInNum', res.length);
  1015. this.$set(row, 'minPackUnit', res[0].minPackUnit);
  1016. this.$set(
  1017. row,
  1018. 'selfSum',
  1019. row.warehouseLedgerDetails.reduce((sum, pre) => {
  1020. if (row.isUnpack) {
  1021. return ++sum;
  1022. }
  1023. return sum + pre.measurementUnit;
  1024. }, 0)
  1025. );
  1026. });
  1027. },
  1028. // 仓库编辑
  1029. handleWareHouse(row) {
  1030. this.$refs.wareHouseDailogRef.open(row);
  1031. },
  1032. // 出库操作
  1033. listEdit(row) {
  1034. this.$set(row, 'isSave', false);
  1035. },
  1036. //出库明细删除
  1037. listDel(row, index) {
  1038. this.warehousingMaterialList.splice(index, 1);
  1039. if (this.warehousingMaterialList.length == 0) {
  1040. this.formData.sourceBizNo = '';
  1041. this.formData.extInfo.clientName = '';
  1042. this.formData.extInfo.clientUser = '';
  1043. this.formData.extInfo.clientUserPhone = '';
  1044. }
  1045. // 从 this.batchDetailsVOList 中删除满足条件的对象
  1046. this.removeItemsFromArray(
  1047. this.batchDetailsVOList,
  1048. (item) => item.code.substr(0, 8) === row.code
  1049. );
  1050. // 从 this.materialCodeReqList 中删除满足条件的对象
  1051. this.removeItemsFromArray(
  1052. this.materialCodeReqList,
  1053. (item) => item.assetCode === row.code
  1054. );
  1055. },
  1056. // 删除数组中满足条件的对象
  1057. removeItemsFromArray(arr, condition) {
  1058. for (let i = arr.length - 1; i >= 0; i--) {
  1059. if (condition(arr[i])) {
  1060. arr.splice(i, 1);
  1061. }
  1062. }
  1063. },
  1064. // 出库明细生成条码信息
  1065. async createMaterialCode(row) {
  1066. let arr = [];
  1067. const res = await getAssetNum({
  1068. assetCode: row.assetCode,
  1069. num: row.outInNum || 1
  1070. });
  1071. if (res?.success) {
  1072. delete row.createTime;
  1073. arr = Array.from(new Array(res.data.length), (val, idx) => ({
  1074. ...row,
  1075. num: res.data[idx],
  1076. bizStatus: 2,
  1077. isTransferAsset: false
  1078. }));
  1079. }
  1080. return arr;
  1081. },
  1082. handleSave() {
  1083. this.$refs.formName.validate(async (valid) => {
  1084. if (valid) {
  1085. if (!this.warehousingMaterialList?.length) {
  1086. return this.$message.error('请添加出库明细!');
  1087. } else if (
  1088. this.warehousingMaterialList.some(
  1089. (item) => !item.warehouseLedgerDetails?.length
  1090. )
  1091. ) {
  1092. return this.$message.error('请完善出库明细数据!');
  1093. }
  1094. console.log('qqqq===>', this.warehousingMaterialList);
  1095. let arr = this.warehousingMaterialList.map((item) => {
  1096. return {
  1097. batchNo: item.batchNo,
  1098. categoryId: item.id,
  1099. count: item.outInNum,
  1100. num: item.outInNum,
  1101. minPackingCount: item.selfSum,
  1102. packingCount: item.outInNum,
  1103. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  1104. ...item
  1105. };
  1106. });
  1107. arr.forEach((item) => {
  1108. item.warehouseId =
  1109. item.warehouseLedgerDetails[0].pathIds.split(',')[0];
  1110. delete item.id;
  1111. delete item.warehouseLedgerDetails;
  1112. if (item.outInDetailRecordAddPOList.length > 0) {
  1113. let list = item.outInDetailRecordAddPOList.map((it) => {
  1114. return {
  1115. positionId: it.positionId,
  1116. code: it.sourceBizNo,
  1117. dateType: it.dateType,
  1118. dateValue: it.dateValue,
  1119. minUnit: it.minUnit,
  1120. batchNo: it.sourceBatchNo,
  1121. position: it.pathName,
  1122. // minPositionId: it.cargoSpaceId,
  1123. minPositionId: it.minPositionId,
  1124. name: it.name,
  1125. pathIds: it.pathIds,
  1126. unit: it.unit,
  1127. packageNo: it.packageNo,
  1128. minPackingCount: it.minPackingCount,
  1129. procureTime: it.procureTime,
  1130. produceTime: it.produceTime
  1131. // num: it.minPackingCount
  1132. };
  1133. });
  1134. item.outInDetailRecordAddPOList = list;
  1135. }
  1136. });
  1137. let obj = { ...this.formData, type: 2 };
  1138. for (const key in arr) {
  1139. arr[key].count = arr[key].outInNum;
  1140. }
  1141. obj.outInDetailAddPOList = arr;
  1142. obj.extInfo.sourceBizNo = obj.sourceBizNo;
  1143. obj.fromType = obj.type;
  1144. this.saveLoading = true;
  1145. console.log('2222', obj);
  1146. const res = await outin.save(obj);
  1147. if (res.code == 0) {
  1148. this.$message.success('保存成功!');
  1149. }
  1150. this.saveLoading = false;
  1151. this.$router.push('/warehouseManagement/outgoingManagement');
  1152. if (res?.success) {
  1153. this.$message.success('保存成功!');
  1154. this.$router.go(-1);
  1155. }
  1156. }
  1157. });
  1158. },
  1159. handelArr(arr, id) {
  1160. for (const key in arr) {
  1161. arr[key].inLedgerId = arr[key].id;
  1162. arr[key].categoryLevelId = id;
  1163. for (const k in arr[key].warehouseLedgerDetails) {
  1164. arr[key].warehouseLedgerDetails[k].ledgerDetailId =
  1165. arr[key].warehouseLedgerDetails[k].id;
  1166. arr[key].warehouseLedgerDetails[k].inDetailId = arr[key].inLedgerId;
  1167. arr[key].warehouseLedgerDetails[k].isTransferAsset = arr[key]
  1168. .warehouseLedgerDetails[k].isTransferAsset
  1169. ? 1
  1170. : 0;
  1171. arr[key].warehouseLedgerDetails[k].bizStatus = 2;
  1172. }
  1173. }
  1174. return arr;
  1175. },
  1176. //添加明细
  1177. onSelectTableData(val, e) {
  1178. this.onSelectTableDataVal = val;
  1179. this.warehousingMaterialList = val.map((next) => {
  1180. delete next.updateTime;
  1181. delete next.createTime;
  1182. return {
  1183. ...next,
  1184. realInventoryAmount: 0,
  1185. assetType: this.formData.extInfo.assetType,
  1186. outInNum: '',
  1187. assetCode: next.code,
  1188. assetName: next.name,
  1189. bizStatus: 2,
  1190. contactCode: next.contactCode
  1191. };
  1192. });
  1193. console.log('sasasasa===>>>', this.warehousingMaterialList);
  1194. },
  1195. codeListValue(val) {
  1196. console.log(val);
  1197. this.formData.extInfo.assetType = val.id;
  1198. this.$forceUpdate();
  1199. this.title = val?.name;
  1200. this.selectEquiType = val?.id;
  1201. console.log(this.title);
  1202. },
  1203. async initData() {
  1204. const { data } = await getTreeByGroup({ type: 2 });
  1205. this.codeList = data;
  1206. const res = await warehouseDefinition.tree();
  1207. this.treeList = this.$util.toTreeData({
  1208. data: res,
  1209. idField: 'id',
  1210. parentIdField: 'parentId'
  1211. });
  1212. let res22 = await warehouseDefinition.getUserPage({
  1213. size: -1,
  1214. page: 1
  1215. });
  1216. this.fromUserList = res22.list;
  1217. console.log('res=====', res);
  1218. const info = JSON.parse(localStorage.getItem('info'));
  1219. console.log('info=====', info);
  1220. let obj = res.find(
  1221. (item) => item.id === info.deptId[info.deptId.length - 1]
  1222. );
  1223. console.log('obj=====', obj);
  1224. this.formData.extInfo.deptName = obj?.name;
  1225. this.formData.extInfo.deptCode = obj?.id;
  1226. this.formData.extInfo.createUserName = info.name;
  1227. this.formData.createUserId = info.userId;
  1228. },
  1229. addStock() {
  1230. // this.title = this.formData.extInfo.assetTypeName;
  1231. if (!this.title) return this.$message.error('请选择出库产品类型');
  1232. if (!this.formData.bizType && this.formData.bizType !== 0)
  1233. return this.$message.error('请选择出库场景');
  1234. this.$refs.assetsDialogRef.open();
  1235. },
  1236. handleChange(data) {
  1237. this.title = data?.dictValue;
  1238. if (this.formData.bizType == 4) {
  1239. this.formData.sourceBizNo = '';
  1240. }
  1241. },
  1242. handleChanges(code) {
  1243. const data = this.codeList.find((item) => item.dictCode == code);
  1244. this.title = data?.dictValue;
  1245. this.selectEquiType = data?.dictCode;
  1246. if (this.formData.bizType == 4) {
  1247. this.formData.sourceBizNo = '';
  1248. }
  1249. },
  1250. handleBizSceneChange() {
  1251. if (this.formData.extInfo.assetType == 7) {
  1252. this.formData.extInfo.sourceBizNo = '';
  1253. }
  1254. this.formData.sourceBizNo = '';
  1255. },
  1256. getSupplier() {
  1257. return new Promise((resolve, reject) => {
  1258. supplier.list({ page: 1, size: 999 }).then((res) => {
  1259. if (res.success) {
  1260. resolve(res);
  1261. }
  1262. });
  1263. });
  1264. },
  1265. upload(data) {
  1266. this.formData.contentImage = data;
  1267. this.$refs.formName.validateField('contentImage');
  1268. },
  1269. deptClick(data) {
  1270. this.formData.deptName = data?.name;
  1271. this.formData.deptCode = data?.code;
  1272. }
  1273. },
  1274. watch: {
  1275. // 解决右侧悬浮操作栏不对称问题
  1276. warehousingMaterialList: {
  1277. handler() {
  1278. this.$nextTick(() => {
  1279. this.$refs.warehousingMaterialListTable.doLayout();
  1280. });
  1281. },
  1282. deep: true
  1283. }
  1284. }
  1285. };
  1286. </script>
  1287. <style lang="scss" scoped>
  1288. ::v-deep.form-table {
  1289. .el-form-item {
  1290. margin-bottom: 0;
  1291. }
  1292. .el-input__inner {
  1293. padding: 0 10px;
  1294. }
  1295. }
  1296. .p20 {
  1297. padding: 20px;
  1298. }
  1299. .el-select,
  1300. .el-date-editor {
  1301. width: 100%;
  1302. }
  1303. .el-form-item {
  1304. margin-bottom: 22px;
  1305. }
  1306. .material {
  1307. margin-top: 20px;
  1308. .flex {
  1309. display: flex;
  1310. justify-content: space-between;
  1311. font-size: 14px;
  1312. align-items: center;
  1313. .red {
  1314. color: #ff4949;
  1315. }
  1316. }
  1317. }
  1318. .mt10 {
  1319. margin-top: 10px;
  1320. }
  1321. .mt20 {
  1322. margin-top: 20px;
  1323. }
  1324. .center {
  1325. text-align: center;
  1326. }
  1327. </style>