outbound.vue 37 KB

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