index.vue 7.9 KB

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