item-list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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: 'engrave',
  313. label: '刻码',
  314. showOverflowTooltip: true
  315. });
  316. // 寻找现有的 'code' 对象的索引
  317. let codeIndex = obj.findIndex((item) => item.prop === 'code');
  318. if (codeIndex !== -1) {
  319. // 删除现有的 'code' 对象
  320. obj.splice(codeIndex, 1, {
  321. prop: 'materialCode',
  322. label: '物料编码',
  323. showOverflowTooltip: true
  324. });
  325. }
  326. }
  327. return obj;
  328. }
  329. },
  330. methods: {
  331. handledime(val) {
  332. this.$set(this, 'isShow', val == 2);
  333. this.$set(this, 'isPack', val == 3);
  334. this.$set(this, 'isMeta', val == 4);
  335. // this.reload({
  336. // ...this.$refs.refSeavch.params,
  337. // dimension: this.$refs.refSeavch.dimension
  338. // });
  339. // if (val == 2) {
  340. // // this.handleBatchDimension(val);
  341. // this.reload();
  342. // } else if (val == 3) {
  343. // this.handleInventoryDimension(val);
  344. // }else{}
  345. this.reload();
  346. this.selectedDime = val;
  347. },
  348. //批次维度
  349. async handleBatchDimension(event) {
  350. // const treeId = this.$parent.$parent.$parent.current.id;
  351. // const params = {
  352. // page: 1,
  353. // size: 10,
  354. // categoryLevelId: treeId
  355. // };
  356. // const res = await getBatchDetails(params);
  357. // console.log(res);
  358. // 待完善
  359. },
  360. //库存维度
  361. async handleInventoryDimension(val) {
  362. // const treeId = this.$parent.$parent.$parent.current.id;
  363. // const rep = await ouint.getInventoryDetails({
  364. // pageNum: 1,
  365. // size: 10,
  366. // categoryLevelId: treeId
  367. // });
  368. // console.log(rep);
  369. //待完善
  370. },
  371. /* 表格数据源 */
  372. datasource({ page, limit, where, order }) {
  373. const dimension = this.$refs.refSeavch.dimension;
  374. const treeId = this.$parent.$parent.$parent.current.id;
  375. if (this.selectedDime == 1) {
  376. const data = ouint.getRealTimeInventory({
  377. ...where,
  378. ...order,
  379. pageNum: page,
  380. size: limit,
  381. dimension: dimension
  382. });
  383. const result = data.then((res) => {
  384. let item = res.list.map((item) => {
  385. return {
  386. ...item,
  387. paths: item.pathName.split(',')[0],
  388. qualityResult:
  389. typeof item.qualityResult != 'number'
  390. ? 3
  391. : item.qualityResult,
  392. qualityStatus:
  393. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  394. };
  395. });
  396. return { ...res, list: item };
  397. });
  398. return result;
  399. } else if (this.selectedDime == 2) {
  400. const params = {
  401. categoryLevelId: treeId,
  402. ...where,
  403. ...order,
  404. dimension: dimension
  405. };
  406. const data = getBatchDetails({
  407. ...params,
  408. pageNum: page,
  409. size: limit
  410. });
  411. const result = data.then((res) => {
  412. let item = res.list.map((item) => {
  413. return {
  414. ...item,
  415. minUnit: item.packingUnit,
  416. qualityResult:
  417. typeof item.qualityResult != 'number'
  418. ? 3
  419. : item.qualityResult,
  420. qualityStatus:
  421. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  422. };
  423. });
  424. return { ...res, list: item };
  425. });
  426. return result;
  427. } else if (this.selectedDime == 4) {
  428. const params = {
  429. categoryLevelId: treeId,
  430. ...where,
  431. ...order,
  432. dimension: dimension
  433. };
  434. const data = ouint.getMaterielDetails({
  435. ...params,
  436. pageNum: page,
  437. size: limit
  438. });
  439. const result = data.then((res) => {
  440. const data = res.list.map((item) => {
  441. return {
  442. ...item,
  443. minUnit: item.packingUnit,
  444. paths: item.pathName,
  445. availableCountBase: 1,
  446. packingCountBase: 1,
  447. materialCode: item.code,
  448. batchNum: item.batchNo,
  449. qualityResult:
  450. typeof item.qualityResult != 'number'
  451. ? 3
  452. : item.qualityResult,
  453. qualityStatus:
  454. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  455. };
  456. });
  457. console.log(data);
  458. return { ...res, list: data };
  459. });
  460. console.log(result);
  461. return result;
  462. } else {
  463. const params = {
  464. categoryLevelId: treeId,
  465. ...where,
  466. ...order,
  467. dimension: dimension
  468. };
  469. const data = ouint.getInventoryDetails({
  470. ...params,
  471. pageNum: page,
  472. size: limit
  473. });
  474. const result = data.then((res) => {
  475. const data = res.list.map((item) => {
  476. return {
  477. ...item,
  478. minUnit: item.packingUnit,
  479. paths: item.pathName.split(',')[0],
  480. // availableCountBase: 1,
  481. packingCountBase: 1,
  482. packagingCode: item.code,
  483. qualityResult:
  484. typeof item.qualityResult != 'number'
  485. ? 3
  486. : item.qualityResult,
  487. qualityStatus:
  488. typeof item.qualityStatus != 'number' ? 3 : item.qualityStatus
  489. };
  490. });
  491. return { ...res, list: data };
  492. });
  493. return result;
  494. }
  495. },
  496. /* 刷新表格 */
  497. reload(where) {
  498. this.$nextTick(() => {
  499. this.$refs.table.reload({
  500. pageNum: 1,
  501. where: {
  502. ...where,
  503. categoryLevelId: this.current?.data?.id || this.current?.id
  504. }
  505. });
  506. });
  507. },
  508. details(row) {
  509. const key = Date.now();
  510. this.$store.commit('stockManagement/CLEAR_BASEINFO');
  511. this.$store.commit('stockManagement/CHANGE_BASEINFO', {
  512. key,
  513. value: row
  514. });
  515. const url =
  516. this.$refs.refSeavch.dimension == 1
  517. ? '/warehouseManagement/stockLedger/allBatchDetails'
  518. : '/warehouseManagement/stockLedger/batchDetails';
  519. this.$router.push({
  520. path: url,
  521. query: {
  522. key,
  523. dimension: this.$refs.refSeavch.dimension,
  524. id: this.$refs.refSeavch.dimension != 3 ? row.id : row.categoryId,
  525. assetId: row.assetId,
  526. batchNo: row.batchNo
  527. }
  528. });
  529. }
  530. },
  531. watch: {
  532. // 监听机构id变化
  533. current: {
  534. handler() {
  535. this.reload();
  536. }
  537. }
  538. }
  539. };
  540. </script>
  541. <style lang="scss" scoped></style>