index.vue 8.5 KB

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