index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <user-search @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table
  8. ref="table"
  9. :columns="columns"
  10. :datasource="datasource"
  11. :selection.sync="selection"
  12. row-key="code"
  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. <el-button
  26. type="primary"
  27. size="mini"
  28. icon="el-icon-upload2"
  29. plain
  30. @click="uploadFile"
  31. >导入</el-button
  32. >
  33. </template>
  34. <template v-slot:status="{ row }"> </template>
  35. <template v-slot:textType="{ row }">
  36. {{
  37. row.textType == 1
  38. ? '数值'
  39. : row.textType == 2
  40. ? '选择'
  41. : row.textType == 3
  42. ? '上下限'
  43. : row.textType == 4
  44. ? '规格'
  45. : row.textType == 5
  46. ? '时间'
  47. : row.textType == 6
  48. ? '范围'
  49. : ''
  50. }}
  51. </template>
  52. <!-- 操作列 -->
  53. <template v-slot:action="{ row }">
  54. <el-link
  55. type="primary"
  56. :underline="false"
  57. icon="el-icon-edit"
  58. @click="openEdit(row)"
  59. >
  60. 修改
  61. </el-link>
  62. <el-popconfirm
  63. class="ele-action"
  64. title="确定要删除当前质检吗?"
  65. @confirm="remove(row)"
  66. >
  67. <template v-slot:reference>
  68. <el-link type="danger" :underline="false" icon="el-icon-delete">
  69. 删除
  70. </el-link>
  71. </template>
  72. </el-popconfirm>
  73. </template>
  74. </ele-pro-table>
  75. </el-card>
  76. <!-- 编辑弹窗 -->
  77. <user-edit
  78. :visible.sync="showEdit"
  79. :data="current"
  80. @done="reload"
  81. ref="userEdit"
  82. />
  83. <!-- 导入弹窗 -->
  84. <importDialog
  85. :defModule="moudleName"
  86. ref="importDialogRef"
  87. @success="reload"
  88. ></importDialog>
  89. </div>
  90. </template>
  91. <script>
  92. import UserSearch from './components/user-search.vue';
  93. import UserEdit from './components/user-edit.vue';
  94. import importDialog from '@/components/upload/import-dialog.vue';
  95. import { getList, removeItem } from '@/api/inspectionProject';
  96. export default {
  97. name: 'inspectionProject',
  98. components: {
  99. UserSearch,
  100. UserEdit,
  101. importDialog
  102. },
  103. data() {
  104. return {
  105. // 表格列配置
  106. columns: [
  107. {
  108. prop: 'inspectionCode',
  109. label: '参数编码',
  110. showOverflowTooltip: true,
  111. align: 'center',
  112. minWidth: 110
  113. },
  114. {
  115. prop: 'inspectionName',
  116. label: '参数名称',
  117. showOverflowTooltip: true,
  118. align: 'center',
  119. minWidth: 110
  120. },
  121. {
  122. prop: 'textType',
  123. label: '参数类型',
  124. showOverflowTooltip: true,
  125. align: 'center',
  126. slot: 'textType',
  127. minWidth: 110
  128. },
  129. {
  130. prop: 'maxValue',
  131. label: '参数上限',
  132. align: 'center',
  133. showOverflowTooltip: true
  134. },
  135. {
  136. prop: 'minValue',
  137. label: '参数下限',
  138. align: 'center',
  139. showOverflowTooltip: true
  140. },
  141. {
  142. prop: 'defaultValue',
  143. label: '默认值',
  144. align: 'center',
  145. showOverflowTooltip: true
  146. },
  147. {
  148. label: '工艺要求',
  149. prop: 'inspectionStandard',
  150. formatter: (row, column, cellValue) => {
  151. return row.symbol + ' ' + cellValue + ' ' + row.unit;
  152. },
  153. minWidth: 150
  154. },
  155. {
  156. label: '状态',
  157. prop: 'status',
  158. formatter: (row, column, cellValue) => {
  159. return cellValue == 1 ? '启用' : cellValue === 0 ? '停用' : '';
  160. }
  161. },
  162. {
  163. label: '备注',
  164. prop: 'inspectionRemark'
  165. },
  166. {
  167. columnKey: 'action',
  168. label: '操作',
  169. width: 220,
  170. align: 'center',
  171. resizable: false,
  172. slot: 'action',
  173. showOverflowTooltip: true
  174. }
  175. ],
  176. // 表格选中数据
  177. selection: [],
  178. // 当前编辑数据
  179. current: null,
  180. // 是否显示编辑弹窗
  181. showEdit: false,
  182. // 是否显示导入弹窗
  183. showImport: false,
  184. moudleName: ''
  185. };
  186. },
  187. methods: {
  188. /*回显类型 */
  189. /* 表格数据源 */
  190. datasource({ page, where, limit }) {
  191. return getList({
  192. ...where,
  193. pageNum: page,
  194. size: limit
  195. });
  196. },
  197. /* 刷新表格 */
  198. reload(where) {
  199. this.$refs.table.reload({ page: 1, where: where });
  200. },
  201. uploadFile() {
  202. this.$refs.importDialogRef.open();
  203. },
  204. /* 打开编辑弹窗 */
  205. openEdit(row) {
  206. this.current = row;
  207. this.showEdit = true;
  208. this.$refs.userEdit.$refs.form &&
  209. this.$refs.userEdit.$refs.form.clearValidate();
  210. },
  211. /* 删除 */
  212. remove(row) {
  213. const loading = this.$loading({ lock: true });
  214. removeItem([row.id])
  215. .then((msg) => {
  216. loading.close();
  217. this.$message.success('删除' + msg);
  218. this.reload();
  219. })
  220. .catch((e) => {
  221. loading.close();
  222. });
  223. },
  224. /* 批量删除 */
  225. removeBatch() {
  226. if (!this.selection.length) {
  227. this.$message.error('请至少选择一条数据');
  228. return;
  229. }
  230. this.$confirm('确定要删除选中的质检吗?', '提示', {
  231. type: 'warning'
  232. })
  233. .then(() => {
  234. const loading = this.$loading({ lock: true });
  235. removeItem(this.selection.map((d) => d.id))
  236. .then((msg) => {
  237. loading.close();
  238. this.$message.success('删除' + msg);
  239. this.reload();
  240. })
  241. .catch((e) => {
  242. loading.close();
  243. });
  244. })
  245. .catch(() => {});
  246. }
  247. }
  248. };
  249. </script>