wmsOutInt.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div>
  3. <seek-page :seekList="seekList" @search="search"></seek-page>
  4. <ele-pro-table
  5. ref="table"
  6. row-key="id"
  7. :columns="columns"
  8. :datasource="datasource"
  9. :cache-key="cacheKeyUrl"
  10. :selection.sync="selection"
  11. autoAmendPage
  12. height="var(--batch-record-table-height)"
  13. >
  14. <template v-slot:action="{ row }">
  15. <el-link type="primary" :underline="false" @click="goToDetail(row)">
  16. 详情
  17. </el-link>
  18. </template>
  19. <template v-slot:bizNo="{ row }">
  20. <el-link type="primary" @click="goToDetail(row)">{{
  21. row.bizNo
  22. }}</el-link>
  23. </template>
  24. <template v-slot:toolbar>
  25. <exportButton
  26. fileName="入库单"
  27. apiUrl="/wms/outintwo/exportBatchRecordPage"
  28. :params="params"
  29. ></exportButton>
  30. <print-selector :options="printOptions" @select="handlePrint" />
  31. </template>
  32. </ele-pro-table>
  33. <finished-product-warehouse ref="finishedProductWarehouse" />
  34. </div>
  35. </template>
  36. <script>
  37. import dictMixins from '@/mixins/dictMixins';
  38. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  39. import { getPages } from '@/api/wms/index';
  40. import { sceneState } from '@/utils/dict/index';
  41. import { getBatchRecordPage, printInbound } from '@/api/wms/index';
  42. import exportButton from '@/components/upload/exportButton.vue';
  43. import printSelector from '../printSelector.vue';
  44. import finishedProductWarehouse from '../../print/electrodeBatchRecord/finishedProductWarehouse.vue';
  45. export default {
  46. mixins: [dictMixins, tableColumnsMixin],
  47. components: { exportButton, printSelector, finishedProductWarehouse },
  48. props: {
  49. tableQuery: {
  50. type: Object,
  51. default: () => {
  52. return {};
  53. }
  54. }
  55. },
  56. data() {
  57. return {
  58. sceneState,
  59. columns: [
  60. {
  61. width: 45,
  62. type: 'selection',
  63. columnKey: 'selection',
  64. align: 'center',
  65. fixed: 'left'
  66. },
  67. {
  68. width: 50,
  69. type: 'index',
  70. columnKey: 'index',
  71. align: 'center',
  72. label: '序号'
  73. },
  74. {
  75. prop: 'bizNo',
  76. label: '单号',
  77. align: 'center',
  78. minWidth: 110,
  79. showOverflowTooltip: true,
  80. slot: 'bizNo'
  81. },
  82. {
  83. prop: 'warehouseName',
  84. label: '仓库名称',
  85. align: 'center',
  86. showOverflowTooltip: true,
  87. minWidth: 150
  88. },
  89. {
  90. prop: 'bizType',
  91. label: '入库类型',
  92. align: 'center',
  93. showOverflowTooltip: true,
  94. minWidth: 150,
  95. formatter: (row) => {
  96. for (const key in this.sceneState) {
  97. if (this.sceneState[key].code == row.bizType) {
  98. return this.sceneState[key].label;
  99. }
  100. }
  101. }
  102. },
  103. {
  104. prop: 'sourceBizNo',
  105. label: '来源单据',
  106. align: 'center',
  107. showOverflowTooltip: true,
  108. minWidth: 150
  109. },
  110. {
  111. prop: 'createUserName',
  112. label: '入库人',
  113. align: 'center',
  114. showOverflowTooltip: true,
  115. minWidth: 150
  116. },
  117. {
  118. prop: 'storageTime',
  119. label: '入库时间',
  120. align: 'center',
  121. showOverflowTooltip: true,
  122. minWidth: 150
  123. },
  124. {
  125. prop: 'outInStatus',
  126. label: '入库状态',
  127. align: 'center',
  128. showOverflowTooltip: true,
  129. minWidth: 150,
  130. formatter: (row) => {
  131. if (row.verifyStatus == 2) {
  132. switch (row.outInStatus) {
  133. case '1':
  134. return '预入库';
  135. case '2':
  136. return '部分入库';
  137. case '3':
  138. return '已入库';
  139. default:
  140. return '';
  141. }
  142. }
  143. }
  144. },
  145. {
  146. label: '操作',
  147. columnKey: 'action',
  148. slot: 'action',
  149. showOverflowTooltip: true,
  150. minWidth: 110,
  151. align: 'center',
  152. fixed: 'right'
  153. }
  154. ],
  155. cacheKeyUrl: 'mes-259231507-mwmsoutint-table',
  156. params: {},
  157. tableData: [],
  158. selection: [],
  159. printOptions: [
  160. {
  161. key: 'finishedProductWarehouse',
  162. label: '产成品入库单(畅捷通)',
  163. code: 'TR.D-012CG'
  164. }
  165. ]
  166. };
  167. },
  168. computed: {
  169. seekList() {
  170. return [
  171. {
  172. label: '来源单据:',
  173. value: 'sourceBizNo',
  174. type: 'input',
  175. placeholder: '请输入'
  176. },
  177. {
  178. label: '入库时间',
  179. value: 'time',
  180. type: 'date',
  181. dateType: 'daterange',
  182. valueFormat: 'yyyy-MM-dd',
  183. placeholder: '请输入'
  184. },
  185. {
  186. label: '入库单号',
  187. value: 'bizNo',
  188. type: 'input',
  189. placeholder: '请输入'
  190. }
  191. ];
  192. }
  193. },
  194. methods: {
  195. // 刷新表格
  196. reload(where = {}) {
  197. this.$refs.table.reload({
  198. where,
  199. ...this.tableQuery
  200. });
  201. },
  202. /* 表格数据源 */
  203. datasource({ page, limit, where, order }) {
  204. // 参数
  205. const body = {
  206. ...where,
  207. ...order,
  208. pageNum: page,
  209. size: limit,
  210. ...this.tableQuery,
  211. // type "1=入库 2=出库" 默认1
  212. type: 1
  213. };
  214. this.params = body;
  215. const res = getBatchRecordPage(body);
  216. Promise.resolve(res).then((data) => {
  217. this.tableData = data?.list || data?.records || [];
  218. });
  219. return res;
  220. },
  221. search(where) {
  222. console.log('where', where);
  223. if (where.time) {
  224. where.startTime = where.time[0];
  225. where.endTime = where.time[1];
  226. }
  227. // 覆盖时间
  228. this.reload({ ...where, time: null });
  229. },
  230. goToDetail(row) {
  231. const path = `/page-wms/warehouseManagement/stockManagement/details?id=${row.id}&verifyStatus=${row.verifyStatus}`;
  232. window.history.pushState(null, '', path);
  233. },
  234. openPrint(row) {
  235. this.$refs.finishedProductWarehouse.open(row);
  236. },
  237. async handlePrint(key) {
  238. try {
  239. const printRows = this.selection.length
  240. ? this.selection
  241. : this.tableData;
  242. const ids = printRows.map((item) => item.id).filter(Boolean);
  243. if (!ids.length) {
  244. this.$message.warning('列表暂无可打印的入库单');
  245. return;
  246. }
  247. const res = await printInbound(ids);
  248. const data = this.buildPrintData(res, printRows);
  249. if (!data) {
  250. this.$message.warning('未查询到可打印的入库单数据');
  251. return;
  252. }
  253. if (this.$refs[key]) {
  254. this.$refs[key].open(data);
  255. }
  256. } catch (error) {
  257. this.$message.error(error.message || '查询打印数据失败');
  258. }
  259. },
  260. buildPrintData(res, printRows = []) {
  261. const list = Array.isArray(res)
  262. ? res
  263. : Array.isArray(res?.data)
  264. ? res.data
  265. : [];
  266. const r = printRows[0] || {};
  267. const firstItem = list[0] || {};
  268. const today = this.$util?.toDateString
  269. ? this.$util.toDateString(new Date(), 'yyyy-MM-dd')
  270. : new Date().toISOString().slice(0, 10);
  271. const itemList = list.map((item) => ({
  272. ...item,
  273. itemCode: item.code || '',
  274. itemName: item.name || '',
  275. modelType: item.modelType || '',
  276. specification: item.specification || '',
  277. specificationModel: this.joinPrintValues([
  278. item.specification,
  279. item.modelType
  280. ]),
  281. batchNo: item.batchNo || '',
  282. productionDate: this.formatPrintDate(item.productionDate),
  283. expiryDate: this.formatPrintDate(item.expirationDate),
  284. unit: item.unit || '',
  285. quantity: item.quantity ?? '',
  286. remark: item.remark || ''
  287. }));
  288. if (!itemList.length) {
  289. return null;
  290. }
  291. return {
  292. batchNo: this.tableQuery.batchNo,
  293. productCode: this.tableQuery.productCode,
  294. productName: r.productName || firstItem.name || '',
  295. specification: this.joinPrintValues([
  296. firstItem.specification,
  297. firstItem.modelType
  298. ]),
  299. code: r.bizNo || '',
  300. date:
  301. this.formatPrintDate(r.storageTime || firstItem.createTime) ||
  302. today,
  303. warehouse: r.warehouseName || '',
  304. department: firstItem.groupName || r.groupName || '',
  305. processOrderCode: r.sourceBizNo || '',
  306. processOrderNo: r.sourceBizNo || '',
  307. moCode: r.sourceBizNo || '',
  308. handler: r.createUserName || '',
  309. receiver: r.createUserName || '',
  310. reporter: r.createUserName || '',
  311. creator: r.createUserName || '',
  312. reviewer:
  313. firstItem.verifyName || r.verifyName || r.reviewerName || '',
  314. totalQuantity: this.getTotalQuantity(itemList),
  315. remark: r.remark || firstItem.remark || '',
  316. itemList
  317. };
  318. },
  319. formatPrintDate(value) {
  320. if (!value) {
  321. return '';
  322. }
  323. if (typeof value === 'string') {
  324. return value.slice(0, 10);
  325. }
  326. return this.$util?.toDateString
  327. ? this.$util.toDateString(value, 'yyyy-MM-dd')
  328. : '';
  329. },
  330. joinPrintValues(values) {
  331. return values
  332. .filter(
  333. (value, index, list) => value && list.indexOf(value) === index
  334. )
  335. .join('/');
  336. },
  337. getTotalQuantity(list) {
  338. const total = list.reduce((sum, item) => {
  339. const quantity = Number(item.quantity);
  340. return Number.isNaN(quantity) ? sum : sum + quantity;
  341. }, 0);
  342. return total || '';
  343. }
  344. }
  345. };
  346. </script>
  347. <style></style>