index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. :page-size="20"
  14. >
  15. <!-- 表头工具栏 -->
  16. <template v-slot:toolbar>
  17. <el-button
  18. size="small"
  19. type="primary"
  20. icon="el-icon-plus"
  21. class="ele-btn-icon"
  22. @click="openEdit()"
  23. >
  24. 新建
  25. </el-button>
  26. <el-button
  27. type="primary"
  28. size="mini"
  29. icon="el-icon-upload2"
  30. plain
  31. @click="uploadFile"
  32. >导入</el-button
  33. >
  34. </template>
  35. <template v-slot:maxValue="{ row }">
  36. {{ row.maxValue }} <span v-if="row.maxValue">{{ row.unitName }}</span>
  37. </template>
  38. <template v-slot:minValue="{ row }">
  39. {{ row.minValue }} <span v-if="row.minValue">{{ row.unitName }}</span>
  40. </template>
  41. <template v-slot:defaultValue="{ row }">
  42. <span v-if="row.defaultValue">{{ row.symbol }}</span>
  43. {{ row.defaultValue }}
  44. </template>
  45. <template v-slot:textType="{ row }">
  46. {{
  47. row.textType == 1
  48. ? '数值'
  49. : row.textType == 2
  50. ? '选择'
  51. : row.textType == 3
  52. ? '上下限'
  53. : row.textType == 4
  54. ? '规格'
  55. : row.textType == 5
  56. ? '时间'
  57. : row.textType == 6
  58. ? '范围'
  59. : row.textType == 7
  60. ? '文本'
  61. : ''
  62. }}
  63. </template>
  64. <template v-slot:type="{ row }">
  65. {{ getDictValue('质检标准类型', row.qualityStandardType) }}
  66. </template>
  67. <template v-slot:toolList="{ row }">
  68. <div
  69. style="display: inline-block"
  70. v-for="(item, idx) in row.toolList"
  71. :key="idx"
  72. >{{ item.name }}
  73. <span v-if="row.toolList && idx != row.toolList.length - 1"
  74. >,
  75. </span>
  76. </div>
  77. </template>
  78. <!-- 操作列 -->
  79. <template v-slot:action="{ row }">
  80. <el-popconfirm
  81. class="ele-action"
  82. title="确定要复制当前质检吗?"
  83. @confirm="copy(row)"
  84. >
  85. <template v-slot:reference>
  86. <el-link type="primary" :underline="false" icon="el-icon-tickets">
  87. 复制
  88. </el-link>
  89. </template>
  90. </el-popconfirm>
  91. <el-link
  92. type="primary"
  93. :underline="false"
  94. icon="el-icon-edit"
  95. @click="openEdit(row)"
  96. >
  97. 修改
  98. </el-link>
  99. <el-popconfirm
  100. class="ele-action"
  101. title="确定要删除当前质检吗?"
  102. @confirm="remove(row)"
  103. >
  104. <template v-slot:reference>
  105. <el-link type="danger" :underline="false" icon="el-icon-delete">
  106. 删除
  107. </el-link>
  108. </template>
  109. </el-popconfirm>
  110. </template>
  111. </ele-pro-table>
  112. </el-card>
  113. <!-- 编辑弹窗 -->
  114. <user-edit
  115. :visible.sync="showEdit"
  116. :data="current"
  117. @done="reload"
  118. ref="userEdit"
  119. />
  120. <!-- 导入弹窗 -->
  121. <importDialog
  122. ref="importDialogRef"
  123. @success="reload"
  124. :fileUrl="'/qms/static/质检项导入模板.xlsx'"
  125. fileName="质检项导入模板"
  126. apiUrl="/qms/inspectionProject/importFile"
  127. ></importDialog>
  128. </div>
  129. </template>
  130. <script>
  131. import UserSearch from './components/user-search.vue';
  132. import UserEdit from './components/user-edit.vue';
  133. import importDialog from './components/import-dialog.vue';
  134. import { getList, removeItem, copyItem } from '@/api/inspectionProject';
  135. import dictMixins from '@/mixins/dictMixins';
  136. export default {
  137. name: 'inspectionProject',
  138. components: {
  139. UserSearch,
  140. UserEdit,
  141. importDialog
  142. },
  143. mixins: [dictMixins],
  144. data() {
  145. return {
  146. // 表格列配置
  147. columns: [
  148. {
  149. prop: 'inspectionCode',
  150. label: '参数编码',
  151. align: 'center',
  152. minWidth: 130
  153. },
  154. {
  155. prop: 'inspectionName',
  156. label: '参数名称',
  157. align: 'center',
  158. minWidth: 110
  159. },
  160. {
  161. prop: 'textType',
  162. label: '参数类型',
  163. align: 'center',
  164. slot: 'textType',
  165. minWidth: 110
  166. },
  167. {
  168. prop: 'defaultValue',
  169. slot: 'defaultValue',
  170. label: '默认值',
  171. align: 'center',
  172. showOverflowTooltip: true
  173. },
  174. {
  175. prop: 'maxValue',
  176. slot: 'maxValue',
  177. label: '参数上限',
  178. align: 'center',
  179. showOverflowTooltip: true
  180. },
  181. {
  182. prop: 'minValue',
  183. slot: 'minValue',
  184. label: '参数下限',
  185. align: 'center',
  186. showOverflowTooltip: true
  187. },
  188. // {
  189. // label: '工艺要求',
  190. // prop: 'inspectionStandard',
  191. // formatter: (row, column, cellValue) => {
  192. // return row.symbol + ' ' + cellValue + ' ' + row.unit;
  193. // },
  194. // minWidth: 150
  195. // },
  196. {
  197. label: '标准类型',
  198. prop: 'type',
  199. slot: 'type'
  200. },
  201. {
  202. prop: 'unitName',
  203. label: '参数单位',
  204. align: 'center'
  205. },
  206. {
  207. prop: 'qualityStandardName',
  208. label: '标准名称',
  209. align: 'center',
  210. minWidth: 110
  211. },
  212. {
  213. prop: 'standardCode',
  214. label: '标准代码',
  215. align: 'center',
  216. minWidth: 110
  217. },
  218. {
  219. prop: 'toolList',
  220. slot: 'toolList',
  221. label: '工具名称',
  222. align: 'center',
  223. minWidth: 150
  224. },
  225. {
  226. label: '状态',
  227. prop: 'status',
  228. formatter: (row, column, cellValue) => {
  229. return cellValue == 1 ? '启用' : cellValue === 0 ? '停用' : '';
  230. }
  231. },
  232. {
  233. label: '备注',
  234. prop: 'inspectionRemark'
  235. },
  236. {
  237. columnKey: 'action',
  238. label: '操作',
  239. width: 220,
  240. align: 'center',
  241. resizable: false,
  242. slot: 'action',
  243. showOverflowTooltip: true
  244. }
  245. ],
  246. // 表格选中数据
  247. selection: [],
  248. // 当前编辑数据
  249. current: null,
  250. // 是否显示编辑弹窗
  251. showEdit: false,
  252. // 是否显示导入弹窗
  253. showImport: false,
  254. moudleName: ''
  255. };
  256. },
  257. methods: {
  258. /*回显类型 */
  259. /* 表格数据源 */
  260. datasource({ page, where, limit }) {
  261. return getList({
  262. ...where,
  263. pageNum: page,
  264. size: limit
  265. });
  266. },
  267. /* 刷新表格 */
  268. reload(where) {
  269. this.$refs.table.reload({ page: 1, where: where });
  270. },
  271. uploadFile() {
  272. this.$refs.importDialogRef.open();
  273. },
  274. /* 打开编辑弹窗 */
  275. openEdit(row) {
  276. this.current = row;
  277. this.showEdit = true;
  278. this.$refs.userEdit.$refs.form &&
  279. this.$refs.userEdit.$refs.form.clearValidate();
  280. },
  281. /* 删除 */
  282. remove(row) {
  283. const loading = this.$loading({ lock: true });
  284. removeItem([row.id])
  285. .then((msg) => {
  286. loading.close();
  287. this.$message.success('删除' + msg);
  288. this.reload();
  289. })
  290. .catch((e) => {
  291. loading.close();
  292. });
  293. },
  294. // 复制
  295. copy(row) {
  296. console.log(row, '33333');
  297. const loading = this.$loading({ lock: true });
  298. copyItem(row.id)
  299. .then((msg) => {
  300. loading.close();
  301. this.$message.success('复制成功');
  302. this.reload();
  303. })
  304. .catch((e) => {
  305. loading.close();
  306. });
  307. },
  308. /* 批量删除 */
  309. removeBatch() {
  310. if (!this.selection.length) {
  311. this.$message.error('请至少选择一条数据');
  312. return;
  313. }
  314. this.$confirm('确定要删除选中的质检吗?', '提示', {
  315. type: 'warning'
  316. })
  317. .then(() => {
  318. const loading = this.$loading({ lock: true });
  319. removeItem(this.selection.map((d) => d.id))
  320. .then((msg) => {
  321. loading.close();
  322. this.$message.success('删除' + msg);
  323. this.reload();
  324. })
  325. .catch((e) => {
  326. loading.close();
  327. });
  328. })
  329. .catch(() => {});
  330. }
  331. }
  332. };
  333. </script>