dryArea-list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div>
  3. <dryArea-search @search="reload" ref="searchRef"> </dryArea-search>
  4. <!-- 数据表格 -->
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="datasource"
  9. height="calc(100vh - 375px)"
  10. full-height="calc(100vh - 116px)"
  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="openEdit()"
  22. >
  23. 新增
  24. </el-button> -->
  25. </template>
  26. <!-- 编码列 -->
  27. <template v-slot:status="{ row }">
  28. <!-- 0空闲1占用 -->
  29. {{ row.status == 0 ? '空闲' : row.status == 1 ? '占用' : '' }}
  30. </template>
  31. <template v-slot:action="{ row }">
  32. <el-link
  33. type="primary"
  34. :underline="false"
  35. icon="el-icon-edit"
  36. @click="openEdit(row)"
  37. >
  38. 编辑
  39. </el-link>
  40. <el-popconfirm
  41. class="ele-action"
  42. title="确定要删除此干燥区吗?"
  43. @confirm="remove(row)"
  44. >
  45. <template v-slot:reference>
  46. <el-link type="danger" :underline="false" icon="el-icon-delete">
  47. 删除
  48. </el-link>
  49. </template>
  50. </el-popconfirm>
  51. </template>
  52. </ele-pro-table>
  53. <user-edit
  54. :visible.sync="showEdit"
  55. :rootId="rootId"
  56. :data="current"
  57. @done="reload"
  58. ref="userEdit"
  59. />
  60. </div>
  61. </template>
  62. <script>
  63. import dryAreaSearch from './dryArea-search.vue';
  64. import {
  65. getAssetList,
  66. downloadAsset,
  67. getNetworkCount,
  68. batchDel
  69. } from '@/api/ledgerAssets';
  70. import { getList, removeItem } from '@/api/ledgerAssets/dryArea';
  71. import dictMixins from '@/mixins/dictMixins';
  72. import UserEdit from './user-edit.vue';
  73. export default {
  74. mixins: [dictMixins],
  75. components: { dryAreaSearch, UserEdit },
  76. props: {
  77. // 类别id
  78. categoryId: [Number, String],
  79. rootId: [Number, String]
  80. },
  81. data() {
  82. return {
  83. // 当前编辑数据
  84. current: null,
  85. // 是否显示编辑弹窗
  86. showEdit: false,
  87. // 表格列配置
  88. columns: [
  89. {
  90. columnKey: 'index',
  91. type: 'index',
  92. label: '序号',
  93. width: 55,
  94. align: 'center',
  95. showOverflowTooltip: true,
  96. fixed: 'left'
  97. },
  98. {
  99. prop: 'code',
  100. label: '干燥区编码',
  101. showOverflowTooltip: true,
  102. minWidth: 110
  103. },
  104. {
  105. prop: 'name',
  106. label: '干燥区名称',
  107. showOverflowTooltip: true,
  108. minWidth: 110
  109. },
  110. {
  111. prop: 'codeNumber',
  112. label: '编号',
  113. showOverflowTooltip: true,
  114. minWidth: 110
  115. },
  116. {
  117. prop: 'specification',
  118. label: '规格',
  119. showOverflowTooltip: true,
  120. minWidth: 110
  121. },
  122. {
  123. prop: 'region',
  124. label: '位置',
  125. showOverflowTooltip: true,
  126. minWidth: 110
  127. },
  128. {
  129. prop: 'status',
  130. label: '状态',
  131. showOverflowTooltip: true,
  132. minWidth: 110,
  133. slot: 'status'
  134. },
  135. {
  136. label: '操作',
  137. prop: 'action',
  138. slot: 'action',
  139. action: 'action'
  140. }
  141. ]
  142. };
  143. },
  144. created() {
  145. this.requestDict('角度');
  146. },
  147. methods: {
  148. /* 表格数据源 */
  149. datasource({ page, limit, where }) {
  150. return getAssetList({
  151. ...where,
  152. pageNum: page,
  153. size: limit,
  154. categoryLevelId: this.categoryId,
  155. rootCategoryLevelId: this.rootId
  156. });
  157. },
  158. /* 刷新表格 */
  159. reload(where) {
  160. this.$refs.table.reload({ pageNum: 1, where: where });
  161. },
  162. /* 打开编辑弹窗 */
  163. openEdit(row) {
  164. this.current = row;
  165. this.showEdit = true;
  166. this.$refs.userEdit.$refs.form &&
  167. this.$refs.userEdit.$refs.form.clearValidate();
  168. },
  169. /* 删除 */
  170. remove(row) {
  171. const loading = this.$loading({ lock: true });
  172. removeItem([row.id])
  173. .then((msg) => {
  174. loading.close();
  175. this.$message.success(msg);
  176. this.reload();
  177. })
  178. .catch((e) => {
  179. loading.close();
  180. });
  181. }
  182. },
  183. watch: {
  184. // 监听类别id变化
  185. categoryId() {
  186. this.reload();
  187. }
  188. }
  189. };
  190. </script>