index.vue 9.1 KB

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