index.vue 9.1 KB

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