allTable.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <div class="allTable">
  3. <el-card shadow="never">
  4. <ele-pro-table ref="table1" :columns="columns" :datasource="datasource" height="calc(100vh-300px)" :pageSize="20"
  5. @cell-click="cellClick" cache-key="systemRoleTable">
  6. <template v-slot:selection="{ row }">
  7. <el-radio class="radio" v-model="currentId" :label="row.id"><i></i></el-radio>
  8. </template>
  9. <template v-slot:bizNo="{ row }">
  10. <el-link type="primary" :underline="false" @click="toDetail(row)">{{ row.bizNo }}</el-link>
  11. </template>
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <el-button icon="el-icon-plus" type="primary" @click="downLoad">导出</el-button>
  15. </template>
  16. <!-- 状态 -->
  17. <template v-slot:verifyStatus="{ row }">
  18. <span :class="status[row.verifyStatus].class">
  19. {{ status[row.verifyStatus].label }}
  20. </span>
  21. </template>
  22. <template v-slot:bizType="{ row }">
  23. {{ handleBizType(row.bizType, row.type) }}
  24. </template>
  25. <template v-slot:assetType="{ row }">
  26. {{ handleAssetType(row.extInfo.assetType) }}
  27. </template>
  28. </ele-pro-table>
  29. <tgDetails ref="tgDetailsRefs"></tgDetails>
  30. </el-card>
  31. </div>
  32. </template>
  33. <script>
  34. import * as XLSX from 'xlsx';
  35. import storageApi from '@/api/warehouseManagement';
  36. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  37. import { allCategoryLevel } from '@/api/classifyManage';
  38. import tgDetails from './tgDetails.vue';
  39. import {
  40. warehousingType,
  41. sceneState,
  42. outputSceneState,
  43. auditStatus,
  44. useDict
  45. } from '@/utils/dict/index';
  46. export default {
  47. components: {
  48. tgDetails
  49. },
  50. data() {
  51. return {
  52. type: '',
  53. params: {},
  54. auditStatus,
  55. outputSceneState,
  56. warehousingType,
  57. sceneState,
  58. codeList: [],
  59. factoryList: [],
  60. tableData: [],
  61. formData: {
  62. deptIds: '',
  63. categoryCode: '',
  64. categoryName: '',
  65. sourceBizNo: '',
  66. startTime: '',
  67. endTime: '',
  68. status: '',
  69. factoryId: '',
  70. time: []
  71. },
  72. total: 0,
  73. status: [
  74. { label: '未审核', class: 'ele-text-info' },
  75. { label: '审核中', class: 'ele-text-primary' },
  76. { label: '审核通过', class: 'ele-text-success' },
  77. { label: '驳回', class: 'ele-text-danger' }
  78. ],
  79. currentId: '',
  80. currentRow: {},
  81. columns: [
  82. {
  83. slot: 'selection',
  84. label: '选择',
  85. width: 50,
  86. align: 'center'
  87. },
  88. {
  89. type: 'index',
  90. label: '序号',
  91. width: 50,
  92. align: 'center'
  93. },
  94. {
  95. prop: 'bizNo',
  96. label: '单号',
  97. align: 'center',
  98. slot: 'bizNo',
  99. showOverflowTooltip: true,
  100. width: 150
  101. },
  102. {
  103. prop: 'bizType',
  104. slot: 'bizType',
  105. label: '出入库类型',
  106. align: 'center',
  107. showOverflowTooltip: true,
  108. width: 150
  109. },
  110. {
  111. prop: 'assetType',
  112. slot: 'assetType',
  113. label: '物品类型',
  114. align: 'center',
  115. showOverflowTooltip: true,
  116. width: 150
  117. },
  118. {
  119. prop: 'categoryNames',
  120. label: '物品名称',
  121. align: 'center',
  122. showOverflowTooltip: true,
  123. width: 150
  124. },
  125. {
  126. prop: 'categoryCodes',
  127. label: '物品编码',
  128. align: 'center',
  129. showOverflowTooltip: true,
  130. width: 150
  131. },
  132. {
  133. prop: 'sourceBizNo',
  134. label: '来源单据',
  135. align: 'center',
  136. showOverflowTooltip: true
  137. },
  138. {
  139. prop: 'createUserName',
  140. label: '操作人',
  141. align: 'center',
  142. showOverflowTooltip: true
  143. },
  144. {
  145. width: 160,
  146. prop: 'createTime',
  147. label: '出入库时间',
  148. align: 'center',
  149. showOverflowTooltip: true
  150. },
  151. {
  152. prop: 'verifyName',
  153. label: '审核人',
  154. align: 'center',
  155. showOverflowTooltip: true
  156. },
  157. {
  158. prop: 'verifyStatus',
  159. label: '状态',
  160. align: 'center',
  161. slot: 'verifyStatus',
  162. showOverflowTooltip: true,
  163. width: 100
  164. }
  165. ]
  166. };
  167. },
  168. computed: {
  169. clientEnvironmentId() {
  170. return this.$store.state.user.info.clientEnvironmentId;
  171. }
  172. },
  173. created() {
  174. this.getTypeList();
  175. },
  176. methods: {
  177. downLoad() {
  178. if (this.currentId) {
  179. storageApi.getOutinList({ id: this.currentId }).then((res) => {
  180. console.log(res);
  181. let tableData = [
  182. [
  183. '申请出库编码',
  184. '申请人',
  185. '申请人部门',
  186. '申请时间',
  187. '工单编码',
  188. '关联设备名称',
  189. '设备固资编码',
  190. '物品编码',
  191. '物品名称',
  192. '型号',
  193. '规格',
  194. '级别',
  195. '数量',
  196. '计量单位',
  197. '用途',
  198. '审核人',
  199. '仓库',
  200. '出库单号',
  201. '出库时间'
  202. ] //导出表头
  203. ];
  204. if (res?.length > 0) {
  205. res.forEach((item) => {
  206. tableData.push([
  207. item.code,
  208. item.applyUserName,
  209. item.applyDeptName,
  210. item.applyTime,
  211. item.orderCode,
  212. item.deviceName,
  213. item.assetsCode,
  214. item.categoryCode,
  215. item.categoryName,
  216. item.categoryModel,
  217. item.specification,
  218. item.level,
  219. item.measureQuantity,
  220. item.measureUnit,
  221. item.purpose,
  222. item.verifyName,
  223. item.warehouseName,
  224. item.bizNo,
  225. item.storageTime
  226. ]);
  227. });
  228. let workSheet = XLSX.utils.aoa_to_sheet(tableData);
  229. let bookNew = XLSX.utils.book_new();
  230. XLSX.utils.book_append_sheet(bookNew, workSheet, '文件'); // 工作簿名称
  231. let name = '明细文件.xlsx';
  232. XLSX.writeFile(bookNew, name); // 保存的文件名
  233. }
  234. });
  235. } else {
  236. return this.$message.warning('请选择单据');
  237. }
  238. },
  239. toDetail(row) {
  240. this.$refs.tgDetailsRefs.open(row);
  241. },
  242. // 单击获取id
  243. cellClick(row) {
  244. this.currentRow = row;
  245. this.currentId = row.id;
  246. },
  247. async getTypeList() {
  248. const { data } = await allCategoryLevel();
  249. this.codeList = data.map((item) => {
  250. return { dictCode: item.id, dictValue: item.name };
  251. });
  252. },
  253. handleAssetType(r) {
  254. const code = this.codeList.find((item) => item.dictCode == r);
  255. return code?.dictValue;
  256. },
  257. handleBizType(code, type) {
  258. if (type == 1) {
  259. // 入库
  260. for (const key in this.sceneState) {
  261. if (this.sceneState[key].code == code) {
  262. return this.sceneState[key].label;
  263. }
  264. }
  265. } else {
  266. // 出库
  267. for (const key in this.outputSceneState) {
  268. if (this.outputSceneState[key].code == code) {
  269. return this.outputSceneState[key].label;
  270. }
  271. }
  272. }
  273. },
  274. async datasource({ page, limit, where }) {
  275. if (where.time && where.time.length > 0) {
  276. where.startTime = where.time[0];
  277. where.endTime = where.time[1];
  278. delete where.time;
  279. }
  280. const res = await storageApi.getInboundList({
  281. pageNum: page,
  282. size: limit,
  283. type: this.type,
  284. ...where
  285. });
  286. return res;
  287. },
  288. /* 刷新表格 */
  289. reload(where) {
  290. this.$nextTick(() => {
  291. if (this.$refs.table1 && this.$refs.table1.reload) {
  292. this.$refs.table1.reload({ page: 1, where });
  293. }
  294. });
  295. },
  296. getAuditStatus: useDict(auditStatus),
  297. getList() {
  298. this.$refs.table1.reload();
  299. },
  300. handleCurrentChange() {
  301. this.getList();
  302. },
  303. handleSizeChange() {
  304. this.formData.page = 1;
  305. this.getList();
  306. },
  307. search() {
  308. this.formData.page = 1;
  309. this.getList();
  310. },
  311. reset() {
  312. this.$refs.formName.resetFields();
  313. this.search();
  314. }
  315. }
  316. };
  317. </script>
  318. <style lang="scss" scoped>
  319. .allTable {
  320. height: 100%;
  321. box-sizing: border-box;
  322. display: flex;
  323. flex-direction: column;
  324. .ele-pro-table {
  325. flex: 1;
  326. display: flex;
  327. flex-direction: column;
  328. .el-table {
  329. flex: 1;
  330. // display: flex;
  331. // flex-direction: column;
  332. // .el-table__body-wrapper {
  333. // flex: 1;
  334. // }
  335. }
  336. }
  337. }
  338. </style>