newEquipmentDialog.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <el-dialog
  3. title="质检项"
  4. :visible.sync="visibleDialog"
  5. :before-close="handleClose"
  6. :close-on-click-modal="true"
  7. :close-on-press-escape="false"
  8. append-to-body
  9. width="80%"
  10. >
  11. <div class="layout">
  12. <ele-split-layout
  13. width="236px"
  14. allow-collapse
  15. :right-style="{ overflow: 'hidden' }"
  16. >
  17. <div>
  18. <div class="ele-border-lighter sys-organization-list">
  19. <AssetTree
  20. @handleNodeClick="handleNodeClick"
  21. @setRootId="setRootId"
  22. :treeIds="[12]"
  23. ref="treeList"
  24. />
  25. </div>
  26. </div>
  27. <template v-slot:content>
  28. <user-search @search="reload" ref="searchRef"> </user-search>
  29. <!-- 数据表格 -->
  30. <ele-pro-table
  31. ref="table"
  32. :columns="columns"
  33. :datasource="datasource"
  34. @done="handleDone"
  35. :selection.sync="selection"
  36. height="calc(100vh - 385px)"
  37. full-height="calc(100vh - 116px)"
  38. tool-class="ele-toolbar-form"
  39. cache-key="newEquipmentDialog"
  40. row-key="id"
  41. >
  42. <!-- 表头工具栏 -->
  43. <template v-slot:toolbar> </template>
  44. <template v-slot:textType="{ row }">
  45. <div v-if="row.itemVO && row.itemVO.textType">
  46. {{
  47. row.itemVO.textType == 1
  48. ? '数值'
  49. : row.itemVO.textType == 2
  50. ? '选择'
  51. : row.itemVO.textType == 3
  52. ? '上下限'
  53. : row.itemVO.textType == 4
  54. ? '规格'
  55. : row.itemVO.textType == 5
  56. ? '时间'
  57. : row.itemVO.textType == 6
  58. ? '范围'
  59. : ''
  60. }}
  61. </div>
  62. </template>
  63. <template v-slot:type="{ row }">
  64. <span v-if="row.itemVO.type">
  65. {{ getDictValue('质检标准类型', row.itemVO.qualityStandardType) }}
  66. </span>
  67. </template>
  68. <template v-slot:toolList="{ row }">
  69. <div
  70. style="display: inline-block"
  71. v-for="(item, idx) in row.itemVO.toolList"
  72. :key="idx"
  73. >{{ item.name }}
  74. <span
  75. v-if="
  76. row.itemVO.toolList && idx != row.itemVO.toolList.length - 1
  77. "
  78. >,
  79. </span></div
  80. >
  81. </template>
  82. <template v-slot:action="{ row }">
  83. <el-popconfirm
  84. class="ele-action"
  85. title="确定要删除此质检项吗?"
  86. @confirm="remove(row)"
  87. >
  88. <template v-slot:reference>
  89. <el-link
  90. type="danger"
  91. :underline="false"
  92. icon="el-icon-delete"
  93. >
  94. 删除
  95. </el-link>
  96. </template>
  97. </el-popconfirm>
  98. </template>
  99. </ele-pro-table>
  100. </template>
  101. </ele-split-layout>
  102. </div>
  103. <div class="btns">
  104. <el-button type="primary" size="small" @click="selected">选择</el-button>
  105. <el-button size="small" @click="handleClose">关闭</el-button>
  106. </div>
  107. </el-dialog>
  108. </template>
  109. <script>
  110. import AssetTree from '@/components/AssetTree';
  111. import userSearch from '@/views/inspectionClassify/components/user-search';
  112. import { getList } from '@/api/inspectionClassify/index';
  113. import dictMixins from '@/mixins/dictMixins';
  114. export default {
  115. mixins: [dictMixins],
  116. components: {
  117. AssetTree,
  118. userSearch
  119. },
  120. props: {
  121. qualityIds: {
  122. type: Array
  123. }
  124. },
  125. watch: {
  126. qualityIds: {
  127. immediate: true,
  128. deep: true,
  129. handler(ids) {
  130. if (ids && ids.length > 0) {
  131. this.handleDone([...ids]);
  132. }
  133. }
  134. }
  135. },
  136. data() {
  137. return {
  138. visibleDialog: true,
  139. rootId: '12',
  140. categoryLevelId: null,
  141. selection: [],
  142. columns: [
  143. {
  144. width: 45,
  145. type: 'selection',
  146. columnKey: 'selection',
  147. align: 'center',
  148. reserveSelection: true
  149. },
  150. {
  151. prop: 'itemVO.categoryLevelName',
  152. label: '质检类型',
  153. align: 'center',
  154. minWidth: 110
  155. },
  156. {
  157. prop: 'itemVO.inspectionCode',
  158. label: '参数编码',
  159. align: 'center',
  160. minWidth: 110
  161. },
  162. {
  163. prop: 'itemVO.inspectionName',
  164. label: '参数名称',
  165. align: 'center',
  166. minWidth: 110
  167. },
  168. {
  169. prop: 'itemVO.textType',
  170. label: '参数类型',
  171. showOverflowTooltip: true,
  172. align: 'center',
  173. slot: 'textType',
  174. minWidth: 110
  175. },
  176. {
  177. prop: 'itemVO.maxValue',
  178. label: '参数上限',
  179. align: 'center',
  180. showOverflowTooltip: true
  181. },
  182. {
  183. prop: 'itemVO.minValue',
  184. label: '参数下限',
  185. align: 'center',
  186. showOverflowTooltip: true
  187. },
  188. {
  189. prop: 'itemVO.defaultValue',
  190. label: '默认值',
  191. align: 'center',
  192. showOverflowTooltip: true
  193. },
  194. {
  195. label: '工艺要求',
  196. prop: 'itemVO.inspectionStandard',
  197. formatter: (row, column, cellValue) => {
  198. return (
  199. row.itemVO.symbol + ' ' + cellValue + ' ' + row.itemVO.unit
  200. );
  201. },
  202. minWidth: 150
  203. },
  204. {
  205. label: '标准类型',
  206. prop: 'itemVO.type',
  207. slot: 'type'
  208. },
  209. {
  210. prop: 'itemVO.qualityStandardName',
  211. label: '标准名称',
  212. align: 'center',
  213. minWidth: 110
  214. },
  215. {
  216. label: '状态',
  217. prop: 'status',
  218. formatter: (row, column, cellValue) => {
  219. return cellValue == 1 ? '启用' : cellValue === 0 ? '停用' : '';
  220. }
  221. },
  222. {
  223. prop: 'itemVO.toolList',
  224. slot: 'toolList',
  225. label: '工具名称',
  226. align: 'center',
  227. minWidth: 150
  228. },
  229. {
  230. label: '备注',
  231. prop: 'inspectionRemark'
  232. }
  233. ]
  234. };
  235. },
  236. created() {},
  237. methods: {
  238. datasource({ page, limit, where }) {
  239. return getList({
  240. ...where,
  241. pageNum: page,
  242. size: limit,
  243. categoryLevelId: this.categoryLevelId || 12,
  244. rootCategoryLevelId: this.rootId
  245. });
  246. },
  247. handleDone(ids) {
  248. setTimeout(() => {
  249. if (Array.isArray(ids)) {
  250. this.$refs.table &&
  251. this.$refs.table.setSelectedRowKeys([...ids]);
  252. }
  253. }, 500);
  254. },
  255. handleNodeClick(info) {
  256. this.current = info;
  257. this.$nextTick(() => {
  258. this.categoryLevelId = info.id;
  259. this.rootCategoryLevelId = info.rootCategoryLevelId;
  260. this.reload();
  261. });
  262. },
  263. // 获取根节点id
  264. setRootId(id) {
  265. if (id) {
  266. this.rootId = id;
  267. }
  268. },
  269. /* 刷新表格 */
  270. reload(where) {
  271. this.$refs.table.reload({
  272. pageNum: 1,
  273. where: where,
  274. categoryLevelId: this.categoryLevelId,
  275. rootCategoryLevelId: this.rootId
  276. });
  277. },
  278. handleClose() {
  279. this.$emit('closeDialog');
  280. },
  281. selected() {
  282. let _arr = [];
  283. if (!this.selection.length) {
  284. this.$message.error('请至少选择一条数据');
  285. return;
  286. }
  287. _arr = this.selection.map((m) => {
  288. return {
  289. ...m.itemVO
  290. };
  291. });
  292. this.$emit('chooseModal', _arr);
  293. this.handleClose();
  294. }
  295. }
  296. };
  297. </script>
  298. <style lang="scss" scoped>
  299. .layout {
  300. min-height: 50vh;
  301. max-height: 75vh;
  302. overflow-y: scroll;
  303. }
  304. .btns {
  305. text-align: center;
  306. padding: 10px 0;
  307. }
  308. </style>