user-list.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <div>
  3. <user-search @search="reload" ref="searchRef"> </user-search>
  4. <!-- 数据表格 -->
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="datasource"
  9. height="calc(100vh - 365px)"
  10. full-height="calc(100vh - 116px)"
  11. tool-class="ele-toolbar-form"
  12. cache-key="inspectionClassify"
  13. row-key="id"
  14. :page-size="20"
  15. >
  16. <!-- 表头工具栏 -->
  17. <template v-slot:toolbar>
  18. <el-button
  19. size="small"
  20. type="primary"
  21. icon="el-icon-plus"
  22. class="ele-btn-icon"
  23. @click="openAdd()"
  24. >
  25. 添加质检项
  26. </el-button>
  27. </template>
  28. <template v-slot:textType="{ row }">
  29. {{
  30. row.itemVO.textType == 1
  31. ? '数值'
  32. : row.itemVO.textType == 2
  33. ? '选择'
  34. : row.itemVO.textType == 3
  35. ? '上下限'
  36. : row.itemVO.textType == 4
  37. ? '规格'
  38. : row.itemVO.textType == 5
  39. ? '时间'
  40. : row.itemVO.textType == 6
  41. ? '范围'
  42. : row.itemVO.textType == 7
  43. ? '文本'
  44. : ''
  45. }}
  46. </template>
  47. <template v-slot:type="{ row }">
  48. {{ getDictValue('质检标准类型', row.itemVO.qualityStandardType) }}
  49. </template>
  50. <template v-slot:toolList="{ row }">
  51. <div
  52. style="display: inline-block"
  53. v-for="(item, idx) in row.itemVO.toolList"
  54. :key="idx"
  55. >{{ item.name }}
  56. <span
  57. v-if="row.itemVO.toolList && idx != row.itemVO.toolList.length - 1"
  58. >,
  59. </span>
  60. </div>
  61. </template>
  62. <template v-slot:action="{ row }">
  63. <el-link
  64. type="primary"
  65. :underline="false"
  66. icon="el-icon-edit"
  67. @click="openEdit(row)"
  68. >
  69. 修改
  70. </el-link>
  71. <el-popconfirm
  72. class="ele-action"
  73. title="确定要删除此质检项吗?"
  74. @confirm="remove(row)"
  75. >
  76. <template v-slot:reference>
  77. <el-link type="danger" :underline="false" icon="el-icon-delete">
  78. 删除
  79. </el-link>
  80. </template>
  81. </el-popconfirm>
  82. </template>
  83. </ele-pro-table>
  84. <qualityItem
  85. ref="qualityItemRef"
  86. @chooseProcess="chooseProcess"
  87. ></qualityItem>
  88. <!-- 编辑弹窗 -->
  89. <user-edit
  90. :visible.sync="showEdit"
  91. :data="current"
  92. @done="reload"
  93. ref="userEdit"
  94. />
  95. </div>
  96. </template>
  97. <script>
  98. import userSearch from './user-search.vue';
  99. import {
  100. getList,
  101. removeItem,
  102. saveBatch
  103. } from '@/api/inspectionClassify/index';
  104. import dictMixins from '@/mixins/dictMixins';
  105. import qualityItem from './qualityItem.vue';
  106. import UserEdit from './user-edit.vue';
  107. export default {
  108. mixins: [dictMixins],
  109. components: { userSearch, qualityItem, UserEdit },
  110. props: {
  111. rootId: [Number, String]
  112. },
  113. data() {
  114. return {
  115. // 当前编辑数据
  116. current: null,
  117. columns: [
  118. {
  119. prop: 'itemVO.categoryLevelClassName',
  120. label: '质检分类层级',
  121. align: 'center',
  122. showOverflowTooltip: true,
  123. minWidth: 150
  124. },
  125. {
  126. prop: 'itemVO.categoryLevelName',
  127. label: '质检类型',
  128. align: 'center',
  129. minWidth: 110
  130. },
  131. {
  132. prop: 'itemVO.inspectionCode',
  133. label: '参数编码',
  134. showOverflowTooltip: true,
  135. align: 'center',
  136. minWidth: 110
  137. },
  138. {
  139. prop: 'itemVO.inspectionName',
  140. label: '参数名称',
  141. showOverflowTooltip: true,
  142. align: 'center',
  143. minWidth: 110
  144. },
  145. {
  146. prop: 'itemVO.textType',
  147. label: '参数类型',
  148. showOverflowTooltip: true,
  149. align: 'center',
  150. slot: 'textType',
  151. minWidth: 110
  152. },
  153. {
  154. prop: 'itemVO.maxValue',
  155. label: '参数上限',
  156. align: 'center',
  157. showOverflowTooltip: true
  158. },
  159. {
  160. prop: 'itemVO.minValue',
  161. label: '参数下限',
  162. align: 'center',
  163. showOverflowTooltip: true
  164. },
  165. {
  166. prop: 'itemVO.defaultValue',
  167. label: '默认值',
  168. align: 'center',
  169. showOverflowTooltip: true
  170. },
  171. {
  172. prop: 'itemVO.unitName',
  173. label: '参数单位',
  174. align: 'center'
  175. },
  176. // {
  177. // label: '工艺要求',
  178. // prop: 'itemVO.inspectionStandard',
  179. // formatter: (row, column, cellValue) => {
  180. // return (
  181. // row.itemVO.symbol + ' ' + cellValue + ' ' + row.itemVO.unit
  182. // );
  183. // },
  184. // align: 'center',
  185. // minWidth: 150,
  186. // showOverflowTooltip: true
  187. // },
  188. {
  189. label: '标准类型',
  190. prop: 'itemVO.type',
  191. slot: 'type',
  192. align: 'center',
  193. minWidth: 120
  194. },
  195. {
  196. prop: 'itemVO.qualityStandardName',
  197. label: '标准名称',
  198. align: 'center',
  199. minWidth: 120
  200. },
  201. {
  202. label: '状态',
  203. prop: 'status',
  204. align: 'center',
  205. formatter: (row, column, cellValue) => {
  206. return cellValue == 1 ? '启用' : cellValue === 0 ? '停用' : '';
  207. }
  208. },
  209. {
  210. prop: 'itemVO.toolList',
  211. slot: 'toolList',
  212. label: '工具名称',
  213. align: 'center',
  214. minWidth: 120,
  215. showOverflowTooltip: true
  216. },
  217. {
  218. label: '备注',
  219. prop: 'inspectionRemark',
  220. align: 'center',
  221. minWidth: 150
  222. },
  223. {
  224. label: '操作',
  225. align: 'center',
  226. fixed: 'right',
  227. minWidth: 150,
  228. slot: 'action',
  229. showOverflowTooltip: true
  230. }
  231. ],
  232. showEdit: false
  233. };
  234. },
  235. created() {},
  236. methods: {
  237. // 编辑
  238. openEdit(row) {
  239. console.log('row', row);
  240. this.current = row.itemVO;
  241. this.showEdit = true;
  242. },
  243. /* 表格数据源 */
  244. datasource({ page, limit, where }) {
  245. return getList({
  246. ...where,
  247. pageNum: page,
  248. size: limit,
  249. categoryLevelId: this.categoryLevelId || 12,
  250. rootCategoryLevelId: this.rootId
  251. });
  252. },
  253. /* 刷新表格 */
  254. reload(where) {
  255. this.$refs.table.reload({
  256. pageNum: 1,
  257. where: where,
  258. categoryLevelId: this.categoryLevelId,
  259. rootCategoryLevelId: this.rootId
  260. });
  261. },
  262. /* 打开编辑弹窗 */
  263. openAdd() {
  264. this.$refs.qualityItemRef.open(this.categoryLevelId || 12);
  265. },
  266. openDetail(row) {
  267. console.log(row);
  268. },
  269. chooseProcess(data) {
  270. saveBatch(data).then((res) => {
  271. if (res.code == 0) {
  272. this.$message.success(res.message);
  273. this.reload();
  274. }
  275. });
  276. },
  277. /* 删除 */
  278. remove(row) {
  279. const loading = this.$loading({ lock: true });
  280. removeItem([row.id])
  281. .then((msg) => {
  282. loading.close();
  283. this.$message.success(msg);
  284. this.reload();
  285. })
  286. .catch((e) => {
  287. loading.close();
  288. });
  289. },
  290. done() {
  291. this.$refs.searchRef.search();
  292. },
  293. clickSearch(info) {
  294. this.categoryLevelId = info.id;
  295. this.rootCategoryLevelId = info.rootCategoryLevelId;
  296. this.reload();
  297. }
  298. }
  299. };
  300. </script>