equipment-list.vue 5.1 KB

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