term.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <div>
  3. <ele-pro-table
  4. ref="table"
  5. :columns="columns"
  6. :datasource="list"
  7. :height="tableHeight"
  8. tool-class="ele-toolbar-form"
  9. cache-key="inspectionClassify"
  10. row-key="qualityLevelId"
  11. :selection.sync="selection"
  12. @selection-change="handleSelectionChange"
  13. @fullscreen-change="fullscreenChange"
  14. >
  15. <template v-slot:toolbar>
  16. <!-- <el-button @click="handAdd" size="mini" type="primary" v-if="!isView&&isQualityInspection"
  17. >新增质检项</el-button
  18. > -->
  19. <el-button @click="handSelect" size="mini" type="primary" v-if="!isView"
  20. >选择质检方案</el-button
  21. >
  22. <el-button
  23. @click="batchDelete"
  24. size="mini"
  25. type="primary"
  26. v-if="!isView"
  27. >批量删除</el-button
  28. >
  29. </template>
  30. <template v-slot:textType="{ row }">
  31. {{
  32. row.textType == 1
  33. ? '数值'
  34. : row.textType == 2
  35. ? '选择'
  36. : row.textType == 3
  37. ? '上下限'
  38. : row.textType == 4
  39. ? '规格'
  40. : row.textType == 5
  41. ? '时间'
  42. : row.textType == 6
  43. ? '范围'
  44. : row.textType == 7
  45. ? '文本'
  46. : ''
  47. }}
  48. </template>
  49. <template v-slot:type="{ row }">
  50. {{ getDictValue('质检标准类型', row.qualityStandardType) }}
  51. </template>
  52. <template v-slot:defaultValue="{ row }">
  53. <div style="width: 100%; display: flex; justify-content: space-between">
  54. <div style="width: 8%">
  55. <DictSelection
  56. style="width: 100px"
  57. clearable
  58. dictName="数学字符"
  59. v-model="row.symbol"
  60. ></DictSelection>
  61. <!-- <el-input v-model="row.symbol" :disabled="isView"> </el-input> -->
  62. </div>
  63. <!-- 上下限 -->
  64. <div
  65. v-if="row.textType == 3"
  66. style="
  67. display: flex;
  68. align-items: center;
  69. justify-content: space-between;
  70. width: 75%;
  71. "
  72. >
  73. <el-input
  74. style="width: 45%"
  75. v-model="row.minValue"
  76. :disabled="isView"
  77. ></el-input>
  78. <span>&nbsp;&nbsp;-</span>
  79. <el-input
  80. style="width: 45%; margin-left: 10px"
  81. v-model="row.maxValue"
  82. :disabled="isView"
  83. ></el-input>
  84. </div>
  85. <div v-else style="width: 75%">
  86. <el-input
  87. v-model="row.defaultValue"
  88. placeholder="请输入"
  89. :disabled="isView"
  90. >
  91. </el-input>
  92. </div>
  93. <div style="width: 15%">
  94. <DictSelection
  95. dictName="工艺参数单位"
  96. clearable
  97. filterable
  98. v-model="row.unitName"
  99. >
  100. </DictSelection>
  101. <!-- <el-input v-model="row.unit" :disabled="isView"> </el-input> -->
  102. </div>
  103. </div>
  104. </template>
  105. <template v-slot:action="{ row, $index }">
  106. <el-popconfirm
  107. class="ele-action"
  108. title="确定要删除当前质检项吗?"
  109. @confirm="handDel($index)"
  110. >
  111. <template v-slot:reference>
  112. <el-link type="danger" :underline="false" icon="el-icon-delete">
  113. 删除
  114. </el-link>
  115. </template>
  116. </el-popconfirm>
  117. </template>
  118. </ele-pro-table>
  119. <termPop ref="termRef" @selectChange="selectChange"></termPop>
  120. <inspectionTemplatePop
  121. ref="inspectionTemplateRef"
  122. @changeSel="changeSel"
  123. ></inspectionTemplatePop>
  124. </div>
  125. </template>
  126. <script>
  127. import termPop from './inspectionClassify/index.vue';
  128. import inspectionTemplatePop from './inspectionTemplate.vue';
  129. import dictMixins from '@/mixins/dictMixins';
  130. import { getByCode } from '@/api/system/dictionary-data';
  131. import { getTemplateById } from '@/api/material/inspectionClassify';
  132. export default {
  133. components: { termPop, inspectionTemplatePop },
  134. mixins: [dictMixins],
  135. props: {
  136. qualityParam: {
  137. type: Array
  138. },
  139. isView: {
  140. type: Boolean,
  141. default: false
  142. },
  143. isQualityInspection: {
  144. type: Boolean,
  145. default: true
  146. }
  147. },
  148. watch: {
  149. qualityParam: {
  150. handler(val) {
  151. this.list = val;
  152. this.$forceUpdate();
  153. },
  154. deep: true,
  155. immediate: true
  156. }
  157. },
  158. data() {
  159. return {
  160. list: [],
  161. dictList: [],
  162. selection: [],
  163. columns: [
  164. // {
  165. // prop: 'sort',
  166. // label: '排序号',
  167. // align: 'center',
  168. // },
  169. {
  170. width: 45,
  171. type: 'selection',
  172. columnKey: 'selection',
  173. align: 'center',
  174. fixed: true
  175. },
  176. {
  177. prop: 'categoryLevelClassName',
  178. label: '质检类型',
  179. align: 'center',
  180. minWidth: 110
  181. },
  182. // {
  183. // prop: 'categoryLevelName',
  184. // label: '质检类型',
  185. // align: 'center',
  186. // minWidth: 110
  187. // },
  188. {
  189. prop: 'inspectionName',
  190. label: '质检名称',
  191. showOverflowTooltip: true,
  192. align: 'center',
  193. minWidth: 110
  194. },
  195. {
  196. prop: 'defaultValue',
  197. slot: 'defaultValue',
  198. label: '工艺参数',
  199. align: 'center',
  200. width: 700
  201. },
  202. // {
  203. // label: '工艺要求',
  204. // prop: 'inspectionStandard',
  205. // formatter: (row, column, cellValue) => {
  206. // return row.symbol + ' ' + cellValue + ' ' + row.unit;
  207. // },
  208. // minWidth: 350
  209. // },
  210. {
  211. columnKey: 'action',
  212. label: '操作',
  213. width: 80,
  214. align: 'center',
  215. resizable: false,
  216. slot: 'action',
  217. fixed: 'right'
  218. }
  219. ],
  220. tableHeight: 'calc(100vh - 500px)'
  221. };
  222. },
  223. created() {
  224. this.requestDict('质检标准类型');
  225. console.log(
  226. document.documentElement.clientHeight,
  227. 'document.documentElement.clientHeight'
  228. );
  229. // this.getDictList('mathematical_symbol'); // 数学字符
  230. },
  231. methods: {
  232. handDel(index) {
  233. this.$confirm('是否删除该质检项', '删除', {
  234. type: 'warning'
  235. })
  236. .then(() => {
  237. this.list.splice(index, 1);
  238. })
  239. .catch(() => {});
  240. },
  241. handAdd() {
  242. this.$refs.termRef.open(this.list);
  243. },
  244. fullscreenChange(fullscreen) {
  245. if (fullscreen) {
  246. this.tableHeight = 'calc(100vh - 120px)';
  247. } else {
  248. this.tableHeight = 'calc(100vh - 500px)';
  249. }
  250. },
  251. async getDictList(code) {
  252. let { data: res } = await getByCode(code);
  253. this.dictList = res.map((item) => {
  254. let values = Object.keys(item);
  255. return {
  256. value: Number(values[0]),
  257. label: item[values[0]]
  258. };
  259. });
  260. },
  261. handleSelectionChange() {},
  262. batchDelete() {
  263. if (this.selection.length == 0) {
  264. this.$message.warning('请选择需要删除的质检项');
  265. }
  266. // console.log(this.list, 'this.List');
  267. // console.log(this.selection, 'this.selection');
  268. let indexList = [];
  269. if (this.selection.length == this.list.length) {
  270. this.list = [];
  271. } else {
  272. for (let i = 0; i < this.selection.length; i++) {
  273. for (let j = 0; j < this.list.length; j++) {
  274. if (this.selection[i].id == this.list[j].id) {
  275. indexList.push(j);
  276. }
  277. }
  278. }
  279. }
  280. if (indexList.length != 0) {
  281. indexList.forEach((it) => {
  282. this.list.splice(it, 1);
  283. });
  284. }
  285. // this.selection.forEach((item) => {
  286. // const index = this.list.findIndex((it) => (it.id = item.id));
  287. // console.log('1111111111111111111');
  288. // if (index) {
  289. // indexList.push(index);
  290. // }
  291. // });
  292. console.log(indexList, 'indexList');
  293. // this.selection = [];
  294. // this.$forceUpdate();
  295. },
  296. getDate() {
  297. return this.list;
  298. },
  299. selectChange(list) {
  300. this.list = list;
  301. },
  302. handSelect() {
  303. this.$refs.inspectionTemplateRef.open();
  304. },
  305. async changeSel(list) {
  306. // let ids = list.map((item) => item.id).toString();
  307. // console.log(ids, 'ids')
  308. await getTemplateById(list.id).then(({ data }) => {
  309. data.inspectionItemVOList.forEach((item) => {
  310. item.qualitySchemeTemplateCode = data.qualitySchemeTemplateCode;
  311. item.qualitySchemeTemplateName = data.qualitySchemeTemplateName;
  312. });
  313. this.list = [...this.list, ...(data.inspectionItemVOList || [])];
  314. // this.list.forEach((item) => {
  315. // item.qualitySchemeTemplateCode = data.qualitySchemeTemplateCode;
  316. // item.qualitySchemeTemplateName = data.qualitySchemeTemplateName;
  317. // });
  318. });
  319. }
  320. }
  321. };
  322. </script>
  323. <style lang="scss" scoped></style>