sparepart-list.vue 5.4 KB

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