index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <search ref="search" @search="search"></search>
  5. <ele-pro-table ref="table" :columns="columns" :datasource="datasource">
  6. <!-- 表头工具栏 -->
  7. <template v-slot:toolbar>
  8. <el-button
  9. size="small"
  10. type="primary"
  11. icon="el-icon-plus"
  12. class="ele-btn-icon"
  13. @click="openEdit('add')"
  14. >
  15. 添加
  16. </el-button>
  17. </template>
  18. <template v-slot:files="scope">
  19. <el-link
  20. v-for="link in scope.row.files"
  21. :key="link.id"
  22. type="primary"
  23. :underline="false"
  24. @click="downloadFile(link)"
  25. >
  26. {{ link.name }}
  27. </el-link>
  28. </template>
  29. <!-- 操作列 -->
  30. <template v-slot:action="{ row }">
  31. <el-link
  32. type="primary"
  33. :underline="false"
  34. icon="el-icon-edit"
  35. @click="openEdit('edit', row)"
  36. >
  37. 修改
  38. </el-link>
  39. <el-popconfirm
  40. class="ele-action"
  41. title="确定要删除吗?"
  42. @confirm="remove(row)"
  43. >
  44. <template v-slot:reference>
  45. <el-link type="danger" :underline="false" icon="el-icon-delete">
  46. 删除
  47. </el-link>
  48. </template>
  49. </el-popconfirm>
  50. </template>
  51. </ele-pro-table>
  52. </el-card>
  53. <newEdit
  54. v-if="showEdit"
  55. :type="editType"
  56. :editObj="editObj"
  57. @close="close"
  58. ></newEdit>
  59. </div>
  60. </template>
  61. <script>
  62. import search from './components/search.vue';
  63. import newEdit from './components/newEdit.vue';
  64. import { getList, removeItem } from '@/api/inspectionPoint';
  65. import dictMixins from '@/mixins/dictMixins';
  66. import { getFile } from '@/api/system/file';
  67. export default {
  68. mixins: [dictMixins],
  69. components: {
  70. search,
  71. newEdit
  72. },
  73. data() {
  74. return {
  75. columns: [
  76. {
  77. width: 45,
  78. type: 'index',
  79. columnKey: 'index',
  80. align: 'center'
  81. },
  82. {
  83. prop: 'pointCode',
  84. label: '编码'
  85. },
  86. {
  87. label: '名称',
  88. prop: 'pointName'
  89. },
  90. {
  91. label: '区域',
  92. prop: 'areaName'
  93. },
  94. {
  95. label: '附件',
  96. slot: 'files'
  97. },
  98. {
  99. prop: 'createUserName',
  100. label: '创建人',
  101. align: 'center'
  102. },
  103. {
  104. prop: 'createTime',
  105. label: '创建时间',
  106. align: 'center',
  107. showOverflowTooltip: true,
  108. minWidth: 110
  109. },
  110. {
  111. columnKey: 'action',
  112. label: '操作',
  113. width: 220,
  114. align: 'center',
  115. resizable: false,
  116. slot: 'action',
  117. showOverflowTooltip: true
  118. }
  119. ],
  120. editType: null,
  121. editObj: {},
  122. showEdit: false
  123. };
  124. },
  125. created() {
  126. },
  127. methods: {
  128. datasource({ page, where, limit }) {
  129. return getList({
  130. ...where,
  131. pageNum: page,
  132. size: limit
  133. });
  134. },
  135. search(where) {
  136. this.$refs.table.reload({
  137. where: where,
  138. page: 1
  139. });
  140. },
  141. openEdit(type, row) {
  142. this.editType = type;
  143. this.editObj = row || {};
  144. this.showEdit = true;
  145. },
  146. close() {
  147. this.showEdit = false;
  148. },
  149. downloadFile(file) {
  150. getFile({ objectName: file.storePath }, file.name);
  151. },
  152. remove(row) {
  153. removeItem([row.id])
  154. .then((message) => {
  155. this.$message.success(message);
  156. this.done();
  157. })
  158. .catch((e) => {});
  159. }
  160. }
  161. };
  162. </script>