mould-list.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div>
  3. <mould-search ref="searchRef" @search="reload" :isConsumer="isConsumer">
  4. </mould-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. height="calc(100vh - 265px)"
  11. full-height="calc(100vh - 116px)"
  12. tool-class="ele-toolbar-form"
  13. cache-key="systemOrgUserTable"
  14. >
  15. <!-- 表头工具栏 -->
  16. <template v-slot:toolbar>
  17. <el-checkbox v-model="isConsumer">显示已消耗</el-checkbox>
  18. <el-button
  19. size="small"
  20. type="primary"
  21. icon="el-icon-download"
  22. class="ele-btn-icon"
  23. @click="btnExport"
  24. >
  25. 导出
  26. </el-button>
  27. </template>
  28. <!-- 编码列 -->
  29. <template v-slot:code="{ row }">
  30. <el-link type="primary" :underline="false" @click="details(row)">
  31. {{ row.code }}
  32. </el-link>
  33. </template>
  34. <!-- 牌号列 -->
  35. <template v-slot:brandNum="{ row }">
  36. <div>
  37. {{ row.category.brandNum }}
  38. </div>
  39. </template>
  40. <!-- 型号列 -->
  41. <template v-slot:modelType="{ row }">
  42. <div>
  43. {{ row.category.modelType }}
  44. </div>
  45. </template>
  46. <!-- 分类列 -->
  47. <template v-slot:categoryLevelPath="{ row }">
  48. <div>
  49. {{ row.category.categoryLevelPath }}
  50. </div>
  51. </template>
  52. <!-- 操作列 -->
  53. <template v-slot:action="{ row }">
  54. <el-link
  55. type="primary"
  56. :underline="false"
  57. icon="el-icon-edit"
  58. @click="goEdit(row)"
  59. >
  60. 编辑
  61. </el-link>
  62. </template>
  63. </ele-pro-table>
  64. </div>
  65. </template>
  66. <script>
  67. import MouldSearch from './mould-search.vue';
  68. import { getAssetList, downloadAsset } from '@/api/ledgerAssets';
  69. import dictMixins from '@/mixins/dictMixins';
  70. import axios from 'axios';
  71. import {
  72. API_BASE_URL,
  73. TOKEN_HEADER_NAME,
  74. LAYOUT_PATH
  75. } from '@/config/setting';
  76. import { download } from '@/utils/file';
  77. import { getToken, setToken } from '@/utils/token-util';
  78. export default {
  79. components: { MouldSearch },
  80. mixins: [dictMixins],
  81. props: {
  82. // 类别id
  83. categoryId: [Number, String],
  84. rootId: [Number, String]
  85. },
  86. data() {
  87. return {
  88. // 表格列配置
  89. columns: [
  90. {
  91. columnKey: 'selection',
  92. type: 'selection',
  93. width: 45,
  94. align: 'center',
  95. fixed: 'left'
  96. },
  97. {
  98. columnKey: 'index',
  99. type: 'index',
  100. label: '序号',
  101. width: 55,
  102. align: 'center',
  103. showOverflowTooltip: true,
  104. fixed: 'left'
  105. },
  106. {
  107. prop: 'code',
  108. label: '编码',
  109. showOverflowTooltip: true,
  110. minWidth: 110,
  111. slot: 'code',
  112. fixed: 'left'
  113. },
  114. {
  115. prop: 'name',
  116. label: '名称',
  117. showOverflowTooltip: true,
  118. minWidth: 110
  119. },
  120. {
  121. prop: 'codeNumber',
  122. label: '编号',
  123. showOverflowTooltip: true,
  124. minWidth: 110
  125. },
  126. {
  127. prop: 'fixCode',
  128. label: '固资编码',
  129. showOverflowTooltip: true,
  130. minWidth: 110
  131. },
  132. {
  133. prop: 'brandNum',
  134. label: '牌号',
  135. showOverflowTooltip: true,
  136. minWidth: 110,
  137. slot: 'brandNum'
  138. },
  139. {
  140. prop: 'modelType',
  141. label: '型号',
  142. showOverflowTooltip: true,
  143. minWidth: 110,
  144. slot: 'modelType'
  145. },
  146. {
  147. prop: 'categoryLevelPath',
  148. label: '分类',
  149. showOverflowTooltip: true,
  150. minWidth: 110,
  151. slot: 'categoryLevelPath'
  152. },
  153. {
  154. prop: 'ownershipGroupName',
  155. label: '所在部门',
  156. showOverflowTooltip: true,
  157. minWidth: 110
  158. },
  159. {
  160. prop: 'totalSum',
  161. label: '生命周期',
  162. showOverflowTooltip: true,
  163. minWidth: 110,
  164. formatter: (_row, _column, cellValue) => {
  165. return this.getDictValue('生命周期', _row.position[0].type);
  166. }
  167. },
  168. {
  169. columnKey: 'action',
  170. label: '操作',
  171. width: 100,
  172. align: 'left',
  173. resizable: false,
  174. slot: 'action',
  175. showOverflowTooltip: true,
  176. fixed: 'right'
  177. }
  178. ],
  179. isConsumer: false
  180. };
  181. },
  182. created() {
  183. this.requestDict('生命周期');
  184. },
  185. methods: {
  186. /* 表格数据源 */
  187. datasource({ page, limit, where, order }) {
  188. return getAssetList({
  189. ...where,
  190. ...order,
  191. pageNum: page,
  192. size: limit,
  193. categoryLevelId: this.categoryId,
  194. rootCategoryLevelId: this.rootId
  195. });
  196. },
  197. /* 刷新表格 */
  198. reload(where) {
  199. this.$refs.table.reload({ pageNum: 1, where: where });
  200. },
  201. // 跳转到详情页
  202. details({ id }) {
  203. this.$router.push({
  204. path: '/ledgerAssets/mould/detail',
  205. query: {
  206. id
  207. }
  208. });
  209. },
  210. // 跳转到编辑页
  211. goEdit({ id }) {
  212. this.$router.push({
  213. path: '/ledgerAssets/mould/edit',
  214. query: {
  215. id
  216. }
  217. });
  218. },
  219. // 导出
  220. btnExport() {
  221. let params = {
  222. ...this.$refs.searchRef.where,
  223. exportType: 3,
  224. categoryLevelId: this.categoryId,
  225. rootCategoryLevelId: this.rootId
  226. };
  227. axios({
  228. url: `${API_BASE_URL}/main/asset/page/export`,
  229. method: 'post',
  230. responseType: 'blob',
  231. headers: {
  232. Authorization: getToken()
  233. },
  234. data: params
  235. }).then((res) => {
  236. download(res.data, '模具台账导出数据');
  237. });
  238. // downloadAsset(params, '模具台账导出数据');
  239. }
  240. },
  241. watch: {
  242. // 监听类别id变化
  243. categoryId() {
  244. this.reload();
  245. }
  246. }
  247. };
  248. </script>
  249. <style lang="scss" scoped>
  250. .ele-btn-icon {
  251. margin-left: 20px;
  252. }
  253. </style>