turnovercar-list.vue 6.5 KB

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