index.vue 9.5 KB

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