AssetsDialog.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <el-dialog :visible.sync="visible" title="物品信息" width="80vw">
  3. <el-form :model="searchForm" label-width="100px">
  4. <el-row>
  5. <el-col :span="6">
  6. <el-form-item label="列表维度:" prop="dimension">
  7. <template>
  8. <el-select
  9. style="width: 100%"
  10. @change="changeDimensionHandler"
  11. v-model="dimension"
  12. placeholder="请选择"
  13. >
  14. <el-option label="物料维度" value="4"> </el-option>
  15. <el-option label="包装维度" value="3"> </el-option>
  16. <el-option label="批次维度" value="2"> </el-option>
  17. <el-option label="物品维度" value="1"> </el-option>
  18. </el-select>
  19. </template>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="6">
  23. <el-form-item label="物品编码:">
  24. <el-input
  25. type="text"
  26. placeholder="搜索物品编码"
  27. v-model="searchForm.categoryCode"
  28. ></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item label="物品名称:">
  33. <el-input
  34. type="text"
  35. placeholder="搜索物品名称"
  36. v-model="searchForm.categoryName"
  37. ></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="6">
  41. <el-form-item label="批次号:">
  42. <el-input
  43. type="text"
  44. placeholder="搜索批次号"
  45. v-model="searchForm.batchNo"
  46. ></el-input>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="6">
  50. <el-form-item label="刻码">
  51. <el-input
  52. type="text"
  53. placeholder="搜索物品刻码"
  54. v-model="searchForm.engrave"
  55. ></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="6">
  59. <el-form-item label="发货码">
  60. <el-input
  61. type="text"
  62. placeholder="搜索发货码"
  63. v-model="searchForm.barcodes"
  64. ></el-input>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="6">
  68. <el-form-item label="牌号">
  69. <el-input
  70. type="text"
  71. placeholder="搜索牌号"
  72. v-model="searchForm.brandNum"
  73. ></el-input>
  74. </el-form-item>
  75. </el-col>
  76. <el-col style="text-align: right">
  77. <el-button type="primary" @click="doSearch">搜索</el-button>
  78. <el-button icon="el-icon-refresh-left" @click="reset">重置</el-button>
  79. </el-col>
  80. </el-row>
  81. </el-form>
  82. <el-container class="assets-dialog">
  83. <el-aside width="200px" class="wrapper-assets">
  84. <AssetTree
  85. ref="treeList"
  86. :treeIds="[6]"
  87. @handleNodeClick="handleNodeClick"
  88. />
  89. </el-aside>
  90. <el-main>
  91. <el-table
  92. ref="multipleTable"
  93. :data="tableData"
  94. tooltip-effect="dark"
  95. height="50vh"
  96. border
  97. row-key="id"
  98. style="width: 100%"
  99. :header-cell-style="{ background: '#F0F3F3', border: 'none' }"
  100. @selection-change="handleSelectionChange"
  101. >
  102. <el-table-column
  103. type="selection"
  104. :reserve-selection="true"
  105. width="55"
  106. align="center"
  107. >
  108. </el-table-column>
  109. <el-table-column label="序号" type="index" width="50">
  110. </el-table-column>
  111. <el-table-column
  112. prop="categoryCode"
  113. label="物品编码"
  114. min-width="120"
  115. :show-overflow-tooltip="true"
  116. ></el-table-column>
  117. <el-table-column
  118. prop="categoryName"
  119. width="200"
  120. label="物品名称"
  121. :show-overflow-tooltip="true"
  122. ></el-table-column>
  123. <el-table-column
  124. prop="brandNum"
  125. label="牌号"
  126. :show-overflow-tooltip="true"
  127. ></el-table-column>
  128. <el-table-column
  129. prop="categoryModel"
  130. label="型号"
  131. :show-overflow-tooltip="true"
  132. ></el-table-column>
  133. <el-table-column
  134. prop="specification"
  135. label="规格"
  136. :show-overflow-tooltip="true"
  137. ></el-table-column>
  138. <el-table-column
  139. v-if="dimension == 1"
  140. label="出库数量"
  141. type="index"
  142. width="100"
  143. >
  144. <template slot-scope="{ row }">
  145. <el-input
  146. type="text"
  147. placeholder="请输入"
  148. v-model="row.outboundNum"
  149. @input="handleInput(row, $event)"
  150. ></el-input>
  151. </template>
  152. </el-table-column>
  153. <el-table-column
  154. v-else
  155. prop="batchNo"
  156. label="批次号"
  157. key="batchNo"
  158. min-width="80"
  159. ></el-table-column>
  160. <el-table-column prop="level" label="级别"></el-table-column>
  161. <el-table-column
  162. prop="measureQuantity"
  163. label="计量数量"
  164. width="120"
  165. ></el-table-column>
  166. <el-table-column
  167. prop="measureUnit"
  168. label="计量单位"
  169. width="90"
  170. ></el-table-column>
  171. <el-table-column
  172. prop="weight"
  173. label="重量"
  174. min-width="120"
  175. ></el-table-column>
  176. <el-table-column
  177. prop="weightUnit"
  178. label="重量单位"
  179. min-width="120"
  180. ></el-table-column>
  181. <el-table-column
  182. v-if="dimension == 3"
  183. prop="packageNo"
  184. label="包装编码"
  185. min-width="120"
  186. :show-overflow-tooltip="true"
  187. ></el-table-column>
  188. <el-table-column
  189. v-if="dimension == 3"
  190. prop="packingQuantity"
  191. label="包装数量"
  192. min-width="120"
  193. :show-overflow-tooltip="true"
  194. ></el-table-column>
  195. <el-table-column
  196. v-if="dimension == 3"
  197. prop="packingUnit"
  198. label="包装单位"
  199. min-width="120"
  200. :show-overflow-tooltip="true"
  201. ></el-table-column>
  202. <el-table-column
  203. v-if="dimension == 3 || dimension == 4"
  204. label="发货条码"
  205. prop="barcodes"
  206. width="80"
  207. :show-overflow-tooltip="true"
  208. ></el-table-column>
  209. <el-table-column
  210. v-if="dimension == 4"
  211. prop="no"
  212. label="物料编码"
  213. min-width="120"
  214. :show-overflow-tooltip="true"
  215. ></el-table-column>
  216. <el-table-column
  217. v-if="dimension == 3 || dimension == 4"
  218. prop="materielDesignation"
  219. label="物料代号"
  220. min-width="100"
  221. ></el-table-column>
  222. <el-table-column
  223. v-if="dimension == 3 || dimension == 4"
  224. prop="clientCode"
  225. label="客户代号"
  226. min-width="100"
  227. ></el-table-column>
  228. <el-table-column
  229. v-if="dimension == 3 || dimension == 4"
  230. prop="engrave"
  231. label="刻码"
  232. min-width="120"
  233. ></el-table-column>
  234. <el-table-column
  235. v-if="dimension == 3 || dimension == 4"
  236. prop="warehouseName"
  237. label="仓库"
  238. min-width="200"
  239. :show-overflow-tooltip="true"
  240. ></el-table-column>
  241. </el-table>
  242. <div style="text-align: right; padding: 10px">
  243. <el-pagination
  244. background
  245. layout="total, sizes, prev, pager, next, jumper"
  246. :total="total"
  247. :page-sizes="[5, 10, 20, 50]"
  248. :page-size.sync="searchForm.size"
  249. :current-page.sync="searchForm.pageNum"
  250. @current-change="handleCurrentChange"
  251. @size-change="handleSizeChange"
  252. >
  253. </el-pagination>
  254. </div>
  255. </el-main>
  256. </el-container>
  257. <div slot="footer">
  258. <el-button type="primary" @click="confirm">确定</el-button>
  259. <el-button @click="cancel">关闭</el-button>
  260. </div>
  261. </el-dialog>
  262. </template>
  263. <script>
  264. import storageApi from '@/api/warehouseManagement';
  265. import AssetTree from './assetTree.vue';
  266. export default {
  267. components: { AssetTree },
  268. props: {
  269. treeIds: { type: Array, default: () => [] }
  270. },
  271. data() {
  272. return {
  273. isShowTable: true,
  274. qualityResultOption: [
  275. {
  276. value: 0,
  277. label: '合格'
  278. },
  279. {
  280. value: 1,
  281. label: '不合格'
  282. }
  283. ],
  284. qualityStatusOption: [
  285. {
  286. value: 1,
  287. label: '已质检'
  288. },
  289. {
  290. value: 0,
  291. label: '未质检'
  292. }
  293. ],
  294. visible: false,
  295. tableData: [],
  296. total: 0,
  297. categoryLevelId: '',
  298. searchForm: {
  299. categoryCode: '',
  300. categoryName: '',
  301. batchNo: '',
  302. brandNum: '',
  303. engrave: '',
  304. barcodes: '',
  305. categoryLevelId: '',
  306. pageNum: 1,
  307. size: 20
  308. },
  309. selectionList: [],
  310. materialType: '',
  311. warehouseList: [],
  312. dimension: '1'
  313. };
  314. },
  315. created() {},
  316. methods: {
  317. getRowKeys(row) {
  318. return row.id;
  319. },
  320. // 出库数量限制
  321. handleInput(row, value) {
  322. if (row.outboundNum <= row.measureQuantity) {
  323. return (row.outboundNum = value.replace(/^(0+)|[^\d]+/g, ''));
  324. } else {
  325. row.outboundNum = row.measureQuantity;
  326. }
  327. },
  328. // 切换维度
  329. changeDimensionHandler(e) {
  330. this.searchForm.pageNum = 1;
  331. this.selectionList = [];
  332. this.$refs.multipleTable.clearSelection();
  333. this.changeDimension(e);
  334. },
  335. async changeDimension(e) {
  336. this.dimension = e;
  337. if (this.dimension == 1) {
  338. // 物品维度
  339. const data = await storageApi.getProductList(this.searchForm);
  340. this.tableData = data.list;
  341. this.total = data.count;
  342. } else if (this.dimension == 2) {
  343. // 批次维度
  344. const data = await storageApi.getBatchList(this.searchForm);
  345. this.tableData = data.list;
  346. this.total = data.count;
  347. } else if (this.dimension == 4) {
  348. // 物料维度
  349. const data = await storageApi.getMaterialList(this.searchForm);
  350. this.tableData = data.list;
  351. this.total = data.count;
  352. } else {
  353. // 包装维度
  354. const data = await storageApi.getPackingList(this.searchForm);
  355. this.tableData = data.list;
  356. this.total = data.count;
  357. }
  358. console.log(this.tableData);
  359. },
  360. open() {
  361. this.visible = true;
  362. this.$nextTick(() => {
  363. this.$refs.treeList.getTreeData().then((data) => {
  364. this.handleNodeClick(data);
  365. });
  366. });
  367. },
  368. async confirm() {
  369. if (!this.selectionList.length) {
  370. this.$message.error('请至少选择一条数据!');
  371. return;
  372. }
  373. if (this.dimension == 1) {
  374. let boolen = this.selectionList.every((item) => item.outboundNum > 0);
  375. if (!boolen) {
  376. this.$message.error('请输入出库数量!');
  377. return;
  378. }
  379. }
  380. console.log(this.selectionList);
  381. let data = null;
  382. if (this.dimension != 1) {
  383. data = await storageApi.getHierarchyList({
  384. ids: this.selectionList.map((item) => item.id).join(','),
  385. type: this.dimension
  386. });
  387. } else {
  388. data = await storageApi.getHierarchyFifo({
  389. type: this.dimension,
  390. builders: this.selectionList.map((item) => {
  391. return {
  392. categoryId: item.categoryId,
  393. num: item.outboundNum
  394. };
  395. })
  396. });
  397. }
  398. console.log('data-------------------', data);
  399. this.$emit('detailData', data, this.dimension);
  400. this.cancel();
  401. },
  402. cancel() {
  403. this.selectionList = [];
  404. this.$refs.multipleTable.clearSelection();
  405. this.visible = false;
  406. },
  407. handleSelectionChange(val) {
  408. this.selectionList = val;
  409. },
  410. handleNodeClick(data) {
  411. console.log(data);
  412. this.categoryLevelId = data.id;
  413. this.searchForm.categoryLevelId = data.id;
  414. this.doSearch();
  415. },
  416. handleCurrentChange() {
  417. this.changeDimension(this.dimension);
  418. },
  419. reset() {
  420. this.searchForm = {
  421. categoryCode: '',
  422. categoryName: '',
  423. batchNo: '',
  424. brandNum: '',
  425. engrave: '',
  426. barcodes: '',
  427. categoryLevelId: this.categoryLevelId,
  428. pageNum: 1,
  429. size: 20
  430. };
  431. this.doSearch();
  432. },
  433. doSearch() {
  434. this.searchForm.pageNum = 1;
  435. this.changeDimension(this.dimension);
  436. },
  437. handleSizeChange() {
  438. this.searchForm.pageNum = 1;
  439. this.changeDimension(this.dimension, 'page');
  440. }
  441. }
  442. };
  443. </script>
  444. <style lang="scss" scoped>
  445. .el-dialog__wrapper {
  446. ::v-deep .el-aside {
  447. background-color: #fff !important;
  448. border: 1px solid #ccc;
  449. }
  450. }
  451. .wrapper-assets {
  452. max-height: 53vh;
  453. overflow: auto;
  454. }
  455. </style>