index.vue 9.2 KB

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