item-list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <item-search @search="reload" ref="refSeavch" @handledime="handledime">
  5. </item-search>
  6. <ele-pro-table
  7. ref="table"
  8. :initLoad="false"
  9. :columns="columns"
  10. :datasource="datasource"
  11. height="calc(100vh - 355px)"
  12. full-height="calc(100vh - 116px)"
  13. tool-class="ele-toolbar-form"
  14. cache-key="systemOrgUserTable"
  15. >
  16. <!-- 表头工具栏 -->
  17. <template v-slot:toolbar> </template>
  18. <!-- 批次号 -->
  19. <template v-slot:batchNo="{ row }">
  20. <el-popover placement="right-start" width="800" trigger="hover">
  21. <el-table :data="row.outInBatchDetailsVOList">
  22. <el-table-column
  23. width="150"
  24. property="bizNo"
  25. label="入库单号"
  26. ></el-table-column>
  27. <el-table-column
  28. width="100"
  29. property="bizType"
  30. label="入库场景"
  31. ></el-table-column>
  32. <el-table-column
  33. width="120"
  34. property="count"
  35. label="入库数量"
  36. ></el-table-column>
  37. <el-table-column
  38. width="80"
  39. property="measuringUnit"
  40. label="计量单位"
  41. ></el-table-column>
  42. <el-table-column
  43. width="100"
  44. property="packageCount"
  45. label="包装数量"
  46. ></el-table-column>
  47. <el-table-column
  48. width="80"
  49. property="packingUnit"
  50. label="包装单位"
  51. ></el-table-column>
  52. <el-table-column
  53. width="330"
  54. property="position"
  55. label="库位"
  56. ></el-table-column>
  57. <el-table-column
  58. width="160"
  59. property="createTime"
  60. label="入库时间"
  61. ></el-table-column>
  62. </el-table>
  63. <span slot="reference"> {{ row.batchNo }}</span>
  64. </el-popover>
  65. </template>
  66. <!-- 库存保质期 -->
  67. <template v-slot:expirationDate="{ row }">
  68. <span v-if="row.expirationDate">
  69. {{ row.expirationDate ? row.expirationDate : '-' }}
  70. {{
  71. row.expirationDateUnit == 'year'
  72. ? '年'
  73. : row.expirationDateUnit == 'month'
  74. ? '月'
  75. : '日'
  76. }}
  77. </span>
  78. </template>
  79. <!-- 质检状态 -->
  80. <template v-slot:qualityStatus="{ row }">
  81. <span v-if="row.qualityResult == 0 || row.qualityResult == 1"
  82. >已检</span
  83. >
  84. <span v-else-if="row.qualityStatus == 1">已检</span>
  85. <span v-else-if="row.qualityStatus == 0">未检</span>
  86. <span v-else>-</span>
  87. </template>
  88. <!-- 质检结果 -->
  89. <template v-slot:qualityResult="{ row }">
  90. <span v-if="row.qualityResult == 0 || row.qualityResult == ''"
  91. >合格</span
  92. >
  93. <span v-else-if="row.qualityResult == 1">不合格</span>
  94. <span v-else-if="row.qualityResult == 3">让步接收</span>
  95. <span v-else>-</span>
  96. </template>
  97. <!-- 操作列 -->
  98. <template v-slot:action="{ row }">
  99. <el-link
  100. type="primary"
  101. :underline="false"
  102. icon="el-icon-edit"
  103. @click="details(row)"
  104. >
  105. 详情
  106. </el-link>
  107. </template>
  108. </ele-pro-table>
  109. </div>
  110. </template>
  111. <script>
  112. import ItemSearch from './item-search.vue';
  113. // import {
  114. // getUserPage,
  115. // removePersonnel,
  116. // unbindLoginName
  117. // } from '@/api/system/organization';
  118. import {
  119. pageeLedgerMain,
  120. removeItem,
  121. getWarehouseList
  122. } from '@/api/classifyManage/itemInformation';
  123. import ouint from '@/api/warehouseManagement/outin';
  124. import { getBatchDetails } from '@/api/classifyManage/index';
  125. export default {
  126. components: { ItemSearch },
  127. props: {
  128. // 机构id
  129. organizationId: [Number, String],
  130. // 全部机构
  131. organizationList: Array,
  132. current: {
  133. type: Object,
  134. default: () => ({})
  135. }
  136. },
  137. data() {
  138. return {
  139. searchForm: {
  140. dimension: 1
  141. },
  142. isShow: false,
  143. isPack: false,
  144. isMeta: false,
  145. selectedDime: 1
  146. };
  147. },
  148. computed: {
  149. // 表格列配置
  150. columns() {
  151. let obj = [
  152. {
  153. columnKey: 'index',
  154. type: 'index',
  155. width: 50,
  156. align: 'center',
  157. label: '序号',
  158. showOverflowTooltip: true,
  159. fixed: 'left'
  160. },
  161. {
  162. prop: 'code',
  163. label: '编码',
  164. showOverflowTooltip: true
  165. },
  166. {
  167. prop: 'name',
  168. label: '名称',
  169. showOverflowTooltip: true
  170. },
  171. {
  172. prop: 'brandNum',
  173. label: '牌号',
  174. showOverflowTooltip: true
  175. },
  176. {
  177. prop: 'modelType',
  178. label: '型号',
  179. showOverflowTooltip: true
  180. },
  181. {
  182. prop: 'packingCountBase',
  183. label: '包装库存数量',
  184. sortable: 'custom',
  185. showOverflowTooltip: true,
  186. width: 130,
  187. align: 'center'
  188. },
  189. {
  190. prop: 'minUnit',
  191. label: '包装单位',
  192. showOverflowTooltip: true
  193. },
  194. {
  195. prop: 'availableCountBase',
  196. label: '计量库存数量',
  197. sortable: 'custom',
  198. showOverflowTooltip: true,
  199. width: 130,
  200. align: 'center'
  201. },
  202. {
  203. prop: 'measuringUnit',
  204. label: '计量单位',
  205. align: 'center'
  206. },
  207. {
  208. prop: 'expirationDate',
  209. slot: 'expirationDate',
  210. label: '库存保质期',
  211. showOverflowTooltip: true,
  212. width: 100
  213. },
  214. {
  215. prop: 'expirationTime',
  216. label: '周期倒计时',
  217. showOverflowTooltip: true,
  218. width: 100
  219. },
  220. {
  221. prop: 'qualityResult',
  222. slot: 'qualityResult',
  223. label: '质检结果',
  224. showOverflowTooltip: true,
  225. width: 100
  226. },
  227. {
  228. prop: 'qualityStatus',
  229. slot: 'qualityStatus',
  230. label: '质检状态',
  231. showOverflowTooltip: true,
  232. width: 100
  233. },
  234. {
  235. prop: 'paths',
  236. width: 230,
  237. label: '仓库',
  238. showOverflowTooltip: true
  239. },
  240. // {
  241. // prop: '',
  242. // label: '安全库存',
  243. // showOverflowTooltip: true
  244. // },
  245. // {
  246. // prop: '',
  247. // label: '质保期',
  248. // showOverflowTooltip: true
  249. // },
  250. {
  251. columnKey: 'action',
  252. label: '操作',
  253. width: 100,
  254. align: 'left',
  255. resizable: false,
  256. slot: 'action'
  257. }
  258. ];
  259. if (this.isShow) {
  260. obj.splice(1, 0, {
  261. slot: 'batchNo',
  262. prop: 'batchNo',
  263. label: '批次号',
  264. showOverflowTooltip: true
  265. });
  266. let index = obj.findIndex((item) => item.label == '仓库');
  267. if (index !== -1) {
  268. obj.splice(index, 1);
  269. }
  270. }
  271. if (this.isPack) {
  272. obj.splice(1, 0, {
  273. slot: 'batchNum',
  274. prop: 'batchNum',
  275. label: '批次号',
  276. showOverflowTooltip: true
  277. });
  278. // 寻找现有的 'code' 对象的索引
  279. let codeIndex = obj.findIndex((item) => item.prop === 'code');
  280. if (codeIndex !== -1) {
  281. // 删除现有的 'code' 对象
  282. obj.splice(codeIndex, 1, {
  283. prop: 'packagingCode',
  284. label: '包装编码',
  285. showOverflowTooltip: true
  286. });
  287. }
  288. }
  289. if (this.isMeta) {
  290. obj.splice(1, 0, {
  291. slot: 'batchNum',
  292. prop: 'batchNum',
  293. label: '批次号',
  294. showOverflowTooltip: true
  295. });
  296. obj.splice(10, 0, {
  297. prop: 'weight',
  298. label: '重量',
  299. showOverflowTooltip: true
  300. });
  301. obj.splice(11, 0, {
  302. prop: 'weightUnit',
  303. label: '重量单位',
  304. showOverflowTooltip: true
  305. });
  306. obj.splice(6, 0, {
  307. prop: 'meterielCode',
  308. label: '物料代号',
  309. showOverflowTooltip: true
  310. });
  311. obj.splice(7, 0, {
  312. prop: 'clientCode',
  313. label: '客户代号',
  314. showOverflowTooltip: true
  315. });
  316. obj.splice(8, 0, {
  317. prop: 'engrave',
  318. label: '刻码',
  319. showOverflowTooltip: true
  320. });
  321. // 寻找现有的 'code' 对象的索引
  322. let codeIndex = obj.findIndex((item) => item.prop === 'code');
  323. if (codeIndex !== -1) {
  324. // 删除现有的 'code' 对象
  325. obj.splice(codeIndex, 1, {
  326. prop: 'no',
  327. label: '物料编码',
  328. showOverflowTooltip: true
  329. });
  330. }
  331. }
  332. return obj;
  333. }
  334. },
  335. methods: {
  336. handledime(val) {
  337. this.$set(this, 'isShow', val == 2);
  338. this.$set(this, 'isPack', val == 3);
  339. this.$set(this, 'isMeta', val == 4);
  340. // this.reload({
  341. // ...this.$refs.refSeavch.params,
  342. // dimension: this.$refs.refSeavch.dimension
  343. // });
  344. // if (val == 2) {
  345. // // this.handleBatchDimension(val);
  346. // this.reload();
  347. // } else if (val == 3) {
  348. // this.handleInventoryDimension(val);
  349. // }else{}
  350. this.reload();
  351. this.selectedDime = val;
  352. },
  353. //批次维度
  354. async handleBatchDimension(event) {
  355. // const treeId = this.$parent.$parent.$parent.current.id;
  356. // const params = {
  357. // page: 1,
  358. // size: 10,
  359. // categoryLevelId: treeId
  360. // };
  361. // const res = await getBatchDetails(params);
  362. // console.log(res);
  363. // 待完善
  364. },
  365. //库存维度
  366. async handleInventoryDimension(val) {
  367. // const treeId = this.$parent.$parent.$parent.current.id;
  368. // const rep = await ouint.getInventoryDetails({
  369. // pageNum: 1,
  370. // size: 10,
  371. // categoryLevelId: treeId
  372. // });
  373. // console.log(rep);
  374. //待完善
  375. },
  376. /* 表格数据源 */
  377. datasource({ page, limit, where, order }) {
  378. const dimension = this.$refs.refSeavch.dimension;
  379. const treeId = this.$parent.$parent.$parent.current.id;
  380. if (this.selectedDime == 1) {
  381. const data = ouint.getRealTimeInventory({
  382. ...where,
  383. ...order,
  384. pageNum: page,
  385. size: limit,
  386. dimension: dimension
  387. });
  388. const result = data.then((res) => {
  389. let item = res.list.map((item) => {
  390. return {
  391. ...item,
  392. paths: item.pathName.split(',')[0],
  393. qualityResult:
  394. typeof item.qualityResult != 'number'
  395. ? 3
  396. : item.qualityResult,
  397. qualityStatus:
  398. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  399. };
  400. });
  401. return { ...res, list: item };
  402. });
  403. return result;
  404. } else if (this.selectedDime == 2) {
  405. const params = {
  406. categoryLevelId: treeId,
  407. ...where,
  408. ...order,
  409. dimension: dimension
  410. };
  411. const data = getBatchDetails({
  412. ...params,
  413. pageNum: page,
  414. size: limit
  415. });
  416. const result = data.then((res) => {
  417. let item = res.list.map((item) => {
  418. return {
  419. ...item,
  420. minUnit: item.packingUnit,
  421. qualityResult:
  422. typeof item.qualityResult != 'number'
  423. ? 3
  424. : item.qualityResult,
  425. qualityStatus:
  426. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  427. };
  428. });
  429. return { ...res, list: item };
  430. });
  431. return result;
  432. } else if (this.selectedDime == 4) {
  433. const params = {
  434. categoryLevelId: treeId,
  435. ...where,
  436. ...order,
  437. dimension: dimension
  438. };
  439. const data = ouint.getMaterielDetails({
  440. ...params,
  441. pageNum: page,
  442. size: limit
  443. });
  444. const result = data.then((res) => {
  445. const data = res.list.map((item) => {
  446. return {
  447. ...item,
  448. minUnit: item.packingUnit,
  449. paths: item.pathName,
  450. availableCountBase: 1,
  451. packingCountBase: 1,
  452. materialCode: item.code,
  453. batchNum: item.batchNo,
  454. qualityResult:
  455. typeof item.qualityResult != 'number'
  456. ? 3
  457. : item.qualityResult,
  458. qualityStatus:
  459. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  460. };
  461. });
  462. console.log(data);
  463. return { ...res, list: data };
  464. });
  465. console.log(result);
  466. return result;
  467. } else {
  468. const params = {
  469. categoryLevelId: treeId,
  470. ...where,
  471. ...order,
  472. dimension: dimension
  473. };
  474. const data = ouint.getInventoryDetails({
  475. ...params,
  476. pageNum: page,
  477. size: limit
  478. });
  479. const result = data.then((res) => {
  480. const data = res.list.map((item) => {
  481. return {
  482. ...item,
  483. minUnit: item.packingUnit,
  484. paths: item.pathName.split(',')[0],
  485. // availableCountBase: 1,
  486. packingCountBase: 1,
  487. packagingCode: item.code,
  488. qualityResult:
  489. typeof item.qualityResult != 'number'
  490. ? 3
  491. : item.qualityResult,
  492. qualityStatus:
  493. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  494. };
  495. });
  496. return { ...res, list: data };
  497. });
  498. return result;
  499. }
  500. },
  501. /* 刷新表格 */
  502. reload(where) {
  503. this.$nextTick(() => {
  504. this.$refs.table.reload({
  505. pageNum: 1,
  506. where: {
  507. ...where,
  508. categoryLevelId: this.current?.data?.id || this.current?.id
  509. }
  510. });
  511. });
  512. },
  513. details(row) {
  514. const key = Date.now();
  515. this.$store.commit('stockManagement/CLEAR_BASEINFO');
  516. this.$store.commit('stockManagement/CHANGE_BASEINFO', {
  517. key,
  518. value: row
  519. });
  520. const url =
  521. this.$refs.refSeavch.dimension == 1
  522. ? '/warehouseManagement/stockLedger/allBatchDetails'
  523. : '/warehouseManagement/stockLedger/batchDetails';
  524. this.$router.push({
  525. path: url,
  526. query: {
  527. key,
  528. dimension: this.$refs.refSeavch.dimension,
  529. id: this.$refs.refSeavch.dimension != 3 ? row.id : row.categoryId,
  530. assetId: row.assetId,
  531. batchNo: row.batchNo
  532. }
  533. });
  534. }
  535. },
  536. watch: {
  537. // 监听机构id变化
  538. current: {
  539. handler() {
  540. this.reload();
  541. }
  542. }
  543. }
  544. };
  545. </script>
  546. <style lang="scss" scoped></style>