AssetsDialog.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <ele-modal
  3. :visible.sync="visible1"
  4. :close-on-click-modal="false"
  5. width="80%"
  6. append-to-body
  7. @close="visible1 = false"
  8. :maxable="true"
  9. >
  10. <el-form :model="searchForm" label-width="100px" @submit.native.prevent>
  11. <el-row v-if="fieldShow">
  12. <el-row>
  13. <el-col :span="6">
  14. <el-form-item label="仓库名称:">
  15. <el-select v-model="searchForm.warehouseId" style="width: 100%">
  16. <el-option
  17. v-for="item in warehouseList"
  18. :key="item.id"
  19. :value="item.id"
  20. :label="item.name"
  21. ></el-option>
  22. </el-select>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="6" style="height: 43px">
  26. <el-form-item label="列表维度:" prop="dimension">
  27. <template>
  28. <el-select
  29. style="width: 100%"
  30. @change="changeDimensionHandler"
  31. v-model="dimension"
  32. placeholder="请选择"
  33. >
  34. <el-option label="物料维度" value="4"></el-option>
  35. <el-option label="包装维度" value="3"></el-option>
  36. <el-option label="批次维度" value="2"></el-option>
  37. <el-option label="物品维度" value="1"></el-option>
  38. </el-select>
  39. </template>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="6">
  43. <el-form-item label="物品编码:">
  44. <el-input
  45. style="width: 100%"
  46. type="text"
  47. placeholder="搜索物品编码"
  48. v-model="searchForm.categoryCode"
  49. ></el-input>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="6">
  53. <el-form-item label="物品名称:">
  54. <el-input
  55. style="width: 100%"
  56. type="text"
  57. placeholder="搜索物品名称"
  58. v-model="searchForm.categoryName"
  59. ></el-input>
  60. </el-form-item>
  61. </el-col>
  62. </el-row>
  63. <el-row>
  64. <el-col :span="6">
  65. <el-form-item label="批次号:">
  66. <el-input type="text" placeholder="搜索批次号" v-model="searchForm.batchNo"></el-input>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="6">
  70. <el-form-item label="刻码">
  71. <el-input type="text" placeholder="搜索物品刻码" v-model="searchForm.engrave"></el-input>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="6">
  75. <el-form-item label="发货码">
  76. <el-input type="text" placeholder="搜索发货码" v-model="searchForm.barcodes"></el-input>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="6">
  80. <el-form-item label="牌号">
  81. <el-input type="text" placeholder="搜索牌号" v-model="searchForm.brandNum"></el-input>
  82. </el-form-item>
  83. </el-col>
  84. <el-col style="text-align: right">
  85. <el-button type="primary" @click="doSearch">搜索</el-button>
  86. <el-button icon="el-icon-refresh-left" @click="reset">重置</el-button>
  87. </el-col>
  88. </el-row>
  89. </el-row>
  90. <el-row v-else>
  91. <el-row :gutter="10">
  92. <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
  93. <el-form-item label="编码">
  94. <el-input @keyup.enter.native="doSearch" clearable size="small" v-model="searchForm.code" placeholder="请输入" />
  95. </el-form-item>
  96. </el-col>
  97. <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
  98. <el-form-item label="名称">
  99. <el-input @keyup.enter.native="doSearch" clearable size="small" v-model="searchForm.name" placeholder="请输入" />
  100. </el-form-item>
  101. </el-col>
  102. <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
  103. <el-form-item label="型号">
  104. <el-input @keyup.enter.native="doSearch" clearable size="small" v-model="searchForm.modelType" placeholder="请输入" />
  105. </el-form-item>
  106. </el-col>
  107. <el-col v-bind="styleResponsive ? { md: 6 } : { span: 4 }">
  108. <el-form-item>
  109. <el-button
  110. size="small"
  111. type="primary"
  112. icon="el-icon-search"
  113. class="ele-btn-icon"
  114. @click="doSearch"
  115. >查询</el-button>
  116. <el-button @click="reset" icon="el-icon-refresh" class="ele-btn-icon" size="medium">重置</el-button>
  117. <slot></slot>
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. <el-row :gutter="10">
  122. <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
  123. <el-form-item label="牌号">
  124. <el-input @keyup.enter.native="doSearch" clearable size="small" v-model="searchForm.brandNum" placeholder="请输入" />
  125. </el-form-item>
  126. </el-col>
  127. <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
  128. <el-form-item label="规格">
  129. <el-input
  130. @keyup.enter.native="doSearch"
  131. clearable
  132. size="small"
  133. v-model="searchForm.specification"
  134. placeholder="请输入"
  135. />
  136. </el-form-item>
  137. </el-col>
  138. <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
  139. <el-form-item label="关键字">
  140. <el-input @keyup.enter.native="doSearch" clearable size="small" v-model="searchForm.searchKey" placeholder="请输入" />
  141. </el-form-item>
  142. </el-col>
  143. </el-row>
  144. </el-row>
  145. </el-form>
  146. <el-container class="assets-dialog">
  147. <el-aside width="200px" class="wrapper-assets">
  148. <AssetTree ref="treeList" :treeIds="[6]" @handleNodeClick="handleNodeClick" />
  149. </el-aside>
  150. <el-main>
  151. <el-table
  152. ref="multipleTable"
  153. :data="tableData"
  154. tooltip-effect="dark"
  155. height="25vh"
  156. border
  157. row-key="id"
  158. style="width: 100%"
  159. :header-cell-style="{ background: '#F0F3F3', border: 'none' }"
  160. highlight-current-row
  161. @current-change="currentChange"
  162. @selection-change="handleSelectionChange"
  163. >
  164. <el-table-column
  165. type="selection"
  166. :reserve-selection="true"
  167. width="55"
  168. align="center"
  169. v-if="isAll"
  170. ></el-table-column>
  171. <el-table-column label="序号" type="index" width="50"></el-table-column>
  172. <el-table-column
  173. prop="categoryCode"
  174. :label="!fieldShow?'编码':'物品编码'"
  175. min-width="120"
  176. :show-overflow-tooltip="true"
  177. ></el-table-column>
  178. <el-table-column
  179. prop="categoryName"
  180. width="200"
  181. :label="!fieldShow?'名称':'物品名称'"
  182. :show-overflow-tooltip="true"
  183. ></el-table-column>
  184. <el-table-column prop="brandNum" label="牌号" :show-overflow-tooltip="true"></el-table-column>
  185. <el-table-column prop="categoryModel" label="型号" :show-overflow-tooltip="true"></el-table-column>
  186. <el-table-column prop="specification" label="规格" :show-overflow-tooltip="true"></el-table-column>
  187. <!-- <el-table-column
  188. label="出库数量"
  189. type="index"
  190. width="100"
  191. >
  192. <template slot-scope="{ row }">
  193. <el-input
  194. type="text"
  195. placeholder="请输入"
  196. v-model="row.outboundNum"
  197. @input="handleInput(row, $event)"
  198. ></el-input>
  199. </template>
  200. </el-table-column>-->
  201. <el-table-column
  202. v-if="dimension == 3"
  203. prop="batchNo"
  204. label="批次号"
  205. key="batchNo"
  206. min-width="80"
  207. ></el-table-column>
  208. <el-table-column prop="level" label="级别"></el-table-column>
  209. <el-table-column prop="measureQuantity" v-if="fieldShow" label="计量数量" width="120"></el-table-column>
  210. <el-table-column prop="measureUnit" v-if="fieldShow" label="计量单位" width="90"></el-table-column>
  211. <el-table-column prop="weight" label="重量" min-width="120"></el-table-column>
  212. <el-table-column prop="weightUnit" label="重量单位" min-width="120"></el-table-column>
  213. <el-table-column
  214. v-if="dimension == 3"
  215. prop="packageNo"
  216. label="包装编码"
  217. min-width="120"
  218. :show-overflow-tooltip="true"
  219. ></el-table-column>
  220. <el-table-column
  221. v-if="dimension == 3"
  222. prop="packingQuantity"
  223. label="包装数量"
  224. min-width="120"
  225. :show-overflow-tooltip="true"
  226. ></el-table-column>
  227. <el-table-column
  228. v-if="dimension == 3"
  229. prop="packingUnit"
  230. label="包装单位"
  231. min-width="120"
  232. :show-overflow-tooltip="true"
  233. ></el-table-column>
  234. <el-table-column
  235. v-if="dimension == 3 || dimension == 4"
  236. label="发货条码"
  237. prop="barcodes"
  238. width="80"
  239. :show-overflow-tooltip="true"
  240. ></el-table-column>
  241. <el-table-column
  242. v-if="dimension == 4"
  243. prop="no"
  244. label="物料编码"
  245. min-width="120"
  246. :show-overflow-tooltip="true"
  247. ></el-table-column>
  248. <el-table-column
  249. v-if="dimension == 3 || dimension == 4"
  250. prop="materielDesignation"
  251. label="物料代号"
  252. min-width="100"
  253. ></el-table-column>
  254. <el-table-column
  255. v-if="dimension == 3 || dimension == 4"
  256. prop="clientCode"
  257. label="客户代号"
  258. min-width="100"
  259. ></el-table-column>
  260. <el-table-column
  261. v-if="dimension == 3 || dimension == 4"
  262. prop="engrave"
  263. label="刻码"
  264. min-width="120"
  265. ></el-table-column>
  266. <el-table-column
  267. v-if="dimension == 3 || dimension == 4"
  268. prop="warehouseName"
  269. label="仓库"
  270. min-width="200"
  271. :show-overflow-tooltip="true"
  272. ></el-table-column>
  273. </el-table>
  274. <ele-pro-table
  275. ref="table"
  276. :columns="columns"
  277. :datasource="tableList"
  278. :selection.sync="selection"
  279. v-if="isAll"
  280. row-key="id"
  281. height="20vh"
  282. :needPage="false"
  283. >
  284. <template v-slot:toolbar>
  285. <el-button type="primary" size="small" @click="add">添加</el-button>
  286. <el-button size="small" @click="del">移除</el-button>
  287. </template>
  288. </ele-pro-table>
  289. <div style="text-align: right; padding: 10px">
  290. <el-pagination
  291. background
  292. layout="total, sizes, prev, pager, next, jumper"
  293. :total="total"
  294. :page-sizes="[5, 10, 20, 50]"
  295. :page-size.sync="searchForm.size"
  296. :current-page.sync="searchForm.pageNum"
  297. @current-change="handleCurrentChange"
  298. @size-change="handleSizeChange"
  299. ></el-pagination>
  300. </div>
  301. </el-main>
  302. </el-container>
  303. <div slot="footer">
  304. <el-button type="primary" @click="confirm">确定</el-button>
  305. <el-button @click="cancel">关闭</el-button>
  306. </div>
  307. </ele-modal>
  308. </template>
  309. <script>
  310. import {
  311. getOutindetailtwoList,
  312. getBatchList,
  313. getMaterialList,
  314. getPackingList
  315. } from '@/api/wms';
  316. import AssetTree from './assetTree.vue';
  317. import { getProductList } from '@/api/saleManage/quotation';
  318. import { getWarehouseList } from '@/api/saleManage/saleorder';
  319. // import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  320. export default {
  321. components: { AssetTree },
  322. props: {
  323. treeIds: { type: Array, default: () => [] },
  324. isAll: {
  325. default: true
  326. }
  327. },
  328. computed: {
  329. // 物品字段
  330. fieldShow() {
  331. return this.dataSources == '0';
  332. },
  333. // 是否开启响应式布局
  334. styleResponsive() {
  335. return this.$store.state.theme.styleResponsive;
  336. }
  337. },
  338. data() {
  339. return {
  340. fullscreen: false,
  341. isShowTable: true,
  342. qualityResultOption: [
  343. {
  344. value: 0,
  345. label: '合格'
  346. },
  347. {
  348. value: 1,
  349. label: '不合格'
  350. }
  351. ],
  352. qualityStatusOption: [
  353. {
  354. value: 1,
  355. label: '已质检'
  356. },
  357. {
  358. value: 0,
  359. label: '未质检'
  360. }
  361. ],
  362. visible1: false,
  363. tableData: [],
  364. total: 0,
  365. categoryLevelId: '',
  366. // warehouseList: [],
  367. searchForm: {
  368. categoryCode: '',
  369. categoryName: '',
  370. batchNo: '',
  371. brandNum: '',
  372. engrave: '',
  373. barcodes: '',
  374. categoryLevelId: '',
  375. warehouseId: '',
  376. pageNum: 1,
  377. size: 20
  378. },
  379. selectionList: [],
  380. materialType: '',
  381. warehouseList: [],
  382. dimension: '1',
  383. selection: [],
  384. tableList: [],
  385. columns: [
  386. {
  387. columnKey: 'selection',
  388. type: 'selection',
  389. width: 45,
  390. align: 'center',
  391. fixed: 'left'
  392. },
  393. {
  394. columnKey: 'index',
  395. label: '序号',
  396. type: 'index',
  397. width: 55,
  398. align: 'center',
  399. showOverflowTooltip: true,
  400. fixed: 'left'
  401. },
  402. {
  403. prop: 'categoryCode',
  404. label: !this.fieldShow ? '编码' : '物品编码',
  405. align: 'center'
  406. },
  407. {
  408. prop: 'categoryName',
  409. // label: '物品名称',
  410. label: !this.fieldShow ? '名称' : '物品名称',
  411. align: 'center'
  412. },
  413. {
  414. prop: 'categoryModel',
  415. label: '型号',
  416. align: 'center'
  417. },
  418. {
  419. prop: 'specification',
  420. label: '规格',
  421. align: 'center'
  422. },
  423. {
  424. prop: 'level',
  425. label: '级别',
  426. align: 'center'
  427. },
  428. {
  429. prop: 'measureQuantity',
  430. label: '库存',
  431. align: 'center'
  432. },
  433. {
  434. prop: 'measureUnit',
  435. label: '计量单位',
  436. align: 'center',
  437. show: this.dataSources == '0'
  438. },
  439. {
  440. prop: 'warehouseName',
  441. label: '仓库',
  442. align: 'center'
  443. }
  444. ],
  445. currentRow: {},
  446. dataSources: '0' // 0:仓库;1:主数据
  447. };
  448. },
  449. created() {
  450. getWarehouseList({}).then((res) => {
  451. this.warehouseList = res;
  452. });
  453. },
  454. methods: {
  455. getRowKeys(row) {
  456. return row.id;
  457. },
  458. // 切换维度
  459. changeDimensionHandler(e) {
  460. this.searchForm.pageNum = 1;
  461. this.selectionList = [];
  462. this.$refs.multipleTable.clearSelection();
  463. this.changeDimension(e);
  464. },
  465. currentChange(val) {
  466. this.currentRow = val;
  467. },
  468. async warehouseData() {
  469. const res = await getProductList(this.searchForm);
  470. this.tableData = res.list.map((el) => {
  471. el.categoryModel = el.modelType;
  472. el.categoryName = el.name;
  473. el.categoryCode = el.code;
  474. return el;
  475. });
  476. this.total = res.count;
  477. },
  478. async changeDimension(e) {
  479. // 查询主数据
  480. if (this.dataSources == '1') {
  481. this.warehouseData();
  482. return;
  483. }
  484. this.dimension = e;
  485. if (this.dimension == 1) {
  486. // 物品维度
  487. const data = await getOutindetailtwoList(this.searchForm);
  488. this.tableData = data.list;
  489. this.total = data.count;
  490. } else if (this.dimension == 2) {
  491. // 批次维度
  492. const data = await getBatchList(this.searchForm);
  493. this.tableData = data.list;
  494. this.total = data.count;
  495. } else if (this.dimension == 4) {
  496. // 物料维度
  497. const data = await getMaterialList(this.searchForm);
  498. this.tableData = data.list;
  499. this.total = data.count;
  500. } else {
  501. // 包装维度
  502. const data = await getPackingList(this.searchForm);
  503. this.tableData = data.list;
  504. this.total = data.count;
  505. }
  506. console.log(this.tableData);
  507. },
  508. open(tableList, value) {
  509. this.dataSources = value || '0';
  510. console.log(value, 'value -- ==');
  511. this.visible1 = true;
  512. this.tableList = JSON.parse(JSON.stringify(tableList));
  513. this.$nextTick(() => {
  514. console.log(this.$refs, 'this.$refs.treeList');
  515. this.$refs.treeList.getTreeData().then((data) => {
  516. this.handleNodeClick(data);
  517. });
  518. });
  519. },
  520. async confirm() {
  521. this.$emit(
  522. 'choose',
  523. this.isAll ? this.tableList : this.currentRow,
  524. this.dimension
  525. );
  526. this.cancel();
  527. },
  528. async add() {
  529. if (!this.selectionList.length) {
  530. this.$message.error('请至少选择一条数据!');
  531. return;
  532. }
  533. // if (this.dimension == 1) {
  534. // let boolen = this.selectionList.every((item) => item.outboundNum > 0);
  535. // if (!boolen) {
  536. // this.$message.error('请输入出库数量!');
  537. // return;
  538. // }
  539. // }
  540. // let data = null;
  541. // if (this.dimension != 1) {
  542. // data = await storageApi.getHierarchyList({
  543. // ids: this.selectionList.map((item) => item.id).join(','),
  544. // type: this.dimension
  545. // });
  546. // } else {
  547. // data = await storageApi.getHierarchyFifo({
  548. // type: this.dimension,
  549. // builders: this.selectionList.map((item) => {
  550. // return {
  551. // categoryId: item.categoryId,
  552. // num: item.outboundNum || item.measureQuantity
  553. // };
  554. // })
  555. // });
  556. // }
  557. this.selectionList = this.selectionList.filter((item) => {
  558. if (item.warehouseList?.length > 0) {
  559. item['warehouseId'] = item.warehouseList[0].warehouse_id;
  560. item['warehouseName'] = item.warehouseList[0].warehouse_name;
  561. }
  562. return !this.tableList
  563. .map((item) => item.categoryCode)
  564. .includes(item.categoryCode);
  565. });
  566. this.tableList.push(...this.selectionList);
  567. },
  568. del() {
  569. let ids = this.selection.map((item) => item.id);
  570. this.tableList = this.tableList.filter((item) => !ids.includes(item.id));
  571. },
  572. cancel() {
  573. this.selectionList = [];
  574. this.$refs.multipleTable.clearSelection();
  575. this.visible1 = false;
  576. },
  577. handleSelectionChange(val) {
  578. this.selectionList = val;
  579. },
  580. handleNodeClick(data) {
  581. console.log(data);
  582. this.categoryLevelId = data.id;
  583. this.searchForm.categoryLevelId = data.id;
  584. this.doSearch();
  585. },
  586. handleCurrentChange() {
  587. this.changeDimension(this.dimension);
  588. },
  589. reset() {
  590. this.searchForm = {
  591. categoryCode: '',
  592. categoryName: '',
  593. batchNo: '',
  594. brandNum: '',
  595. engrave: '',
  596. barcodes: '',
  597. categoryLevelId: this.categoryLevelId,
  598. pageNum: 1,
  599. warehouseId: '',
  600. size: 20
  601. };
  602. this.doSearch();
  603. },
  604. doSearch() {
  605. this.searchForm.pageNum = 1;
  606. this.changeDimension(this.dimension);
  607. },
  608. handleSizeChange() {
  609. this.searchForm.pageNum = 1;
  610. this.changeDimension(this.dimension, 'page');
  611. }
  612. }
  613. };
  614. </script>
  615. <style lang="scss" scoped>
  616. .el-dialog__wrapper {
  617. ::v-deep .el-aside {
  618. background-color: #fff !important;
  619. border: 1px solid #ccc;
  620. }
  621. }
  622. .wrapper-assets {
  623. max-height: 53vh;
  624. overflow: auto;
  625. }
  626. </style>