user-list.vue 6.6 KB

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