index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. <el-button type="primary" size="mini" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button>
  18. </template>
  19. <!-- 操作列 -->
  20. <template v-slot:action="{ row }">
  21. <el-link
  22. type="primary"
  23. :underline="false"
  24. icon="el-icon-edit"
  25. @click="openEdit('edit', row)"
  26. >
  27. 修改
  28. </el-link>
  29. <el-popconfirm
  30. class="ele-action"
  31. title="确定要删除吗?"
  32. @confirm="remove(row)"
  33. >
  34. <template v-slot:reference>
  35. <el-link type="danger" :underline="false" icon="el-icon-delete">
  36. 删除
  37. </el-link>
  38. </template>
  39. </el-popconfirm>
  40. </template>
  41. </ele-pro-table>
  42. </el-card>
  43. <edit ref="edit" @done="done"></edit>
  44. <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
  45. </div>
  46. </template>
  47. <script>
  48. import search from './components/search.vue';
  49. import edit from './components/edit.vue';
  50. import { getList, removeItem } from '@/api/inspectionProject';
  51. import dictMixins from '@/mixins/dictMixins';
  52. import importDialog from "@/components/upload/import-dialog.vue";
  53. export default {
  54. mixins: [dictMixins],
  55. components: {
  56. search,
  57. edit,importDialog
  58. },
  59. data() {
  60. return {
  61. columns: [
  62. {
  63. width: 45,
  64. type: 'index',
  65. columnKey: 'index',
  66. align: 'center'
  67. },
  68. {
  69. prop: 'inspectionCode',
  70. label: '编码'
  71. },
  72. {
  73. label: '名称',
  74. prop: 'inspectionName'
  75. },
  76. {
  77. label: '质检标准',
  78. prop: 'inspectionStandard',
  79. formatter: (row, column, cellValue) => {
  80. return row.symbol+' '+cellValue+' '+row.unit
  81. }
  82. },
  83. // {
  84. // label: '是否生成过程',
  85. // prop: 'isCreateCourse',
  86. // formatter: (row, column, cellValue) => {
  87. // return cellValue==1?'是': cellValue===0?'否':''
  88. // }
  89. // },
  90. // {
  91. // label: '质检工具',
  92. // prop: 'inspectionTool'
  93. // },
  94. {
  95. label: '状态',
  96. prop: 'status',
  97. formatter: (row, column, cellValue) => {
  98. return cellValue == 1 ? '启用' : cellValue === 0 ? '停用' : '';
  99. }
  100. },
  101. {
  102. label: '描述',
  103. prop: 'description'
  104. },
  105. {
  106. label: '备注',
  107. prop: 'inspectionRemark'
  108. },
  109. {
  110. columnKey: 'action',
  111. label: '操作',
  112. width: 220,
  113. align: 'center',
  114. resizable: false,
  115. slot: 'action',
  116. showOverflowTooltip: true
  117. }
  118. ]
  119. };
  120. },
  121. created() {
  122. this.requestDict('质检标准类型');
  123. },
  124. methods: {
  125. datasource({ page, where, limit }) {
  126. return getList({
  127. ...where,
  128. pageNum: page,
  129. size: limit
  130. });
  131. },
  132. search(where) {
  133. this.$refs.table.reload({
  134. where: where,
  135. page: 1
  136. });
  137. },
  138. openEdit(type, row) {
  139. this.$refs.edit.open(type, row);
  140. },
  141. remove(row) {
  142. removeItem([row.id])
  143. .then((message) => {
  144. this.$message.success(message);
  145. this.done();
  146. })
  147. .catch((e) => {});
  148. },
  149. uploadFile () {
  150. this.$refs.importDialogRef.open();
  151. },
  152. done() {
  153. this.$refs.search.search();
  154. }
  155. }
  156. };
  157. </script>