term.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. :isQualityInspection="isQualityInspection"
  123. @changeSel="changeSel"
  124. ></inspectionTemplatePop>
  125. </div>
  126. </template>
  127. <script>
  128. import termPop from './inspectionClassify/index.vue';
  129. import inspectionTemplatePop from './inspectionTemplate.vue';
  130. import dictMixins from '@/mixins/dictMixins';
  131. import { getByCode } from '@/api/system/dictionary-data';
  132. import { getTemplateById } from '@/api/material/inspectionClassify';
  133. export default {
  134. components: { termPop, inspectionTemplatePop },
  135. mixins: [dictMixins],
  136. props: {
  137. qualityParam: {
  138. type: Array
  139. },
  140. isView: {
  141. type: Boolean,
  142. default: false
  143. },
  144. isQualityInspection: {
  145. type: Boolean,
  146. default: true
  147. }
  148. },
  149. watch: {
  150. qualityParam: {
  151. handler(val) {
  152. this.list = val;
  153. this.$forceUpdate();
  154. },
  155. deep: true,
  156. immediate: true
  157. }
  158. },
  159. data() {
  160. return {
  161. list: [],
  162. dictList: [],
  163. selection: [],
  164. columns: [
  165. // {
  166. // prop: 'sort',
  167. // label: '排序号',
  168. // align: 'center',
  169. // },
  170. {
  171. width: 45,
  172. type: 'selection',
  173. columnKey: 'selection',
  174. align: 'center',
  175. fixed: true
  176. },
  177. {
  178. prop: 'categoryLevelClassName',
  179. label: '质检类型',
  180. align: 'center',
  181. minWidth: 110
  182. },
  183. // {
  184. // prop: 'categoryLevelName',
  185. // label: '质检类型',
  186. // align: 'center',
  187. // minWidth: 110
  188. // },
  189. {
  190. prop: 'inspectionName',
  191. label: '质检名称',
  192. showOverflowTooltip: true,
  193. align: 'center',
  194. minWidth: 110
  195. },
  196. {
  197. prop: 'defaultValue',
  198. slot: 'defaultValue',
  199. label: '工艺参数',
  200. align: 'center',
  201. width: 700
  202. },
  203. // {
  204. // label: '工艺要求',
  205. // prop: 'inspectionStandard',
  206. // formatter: (row, column, cellValue) => {
  207. // return row.symbol + ' ' + cellValue + ' ' + row.unit;
  208. // },
  209. // minWidth: 350
  210. // },
  211. {
  212. columnKey: 'action',
  213. label: '操作',
  214. width: 80,
  215. align: 'center',
  216. resizable: false,
  217. slot: 'action',
  218. fixed: 'right'
  219. }
  220. ],
  221. tableHeight: 'calc(100vh - 500px)',
  222. isQualityInspection: true
  223. };
  224. },
  225. created() {
  226. this.requestDict('质检标准类型');
  227. console.log(
  228. document.documentElement.clientHeight,
  229. 'document.documentElement.clientHeight'
  230. );
  231. // this.getDictList('mathematical_symbol'); // 数学字符
  232. },
  233. methods: {
  234. handDel(index) {
  235. this.$confirm('是否删除该质检项', '删除', {
  236. type: 'warning'
  237. })
  238. .then(() => {
  239. this.list.splice(index, 1);
  240. })
  241. .catch(() => {});
  242. },
  243. handAdd() {
  244. this.$refs.termRef.open(this.list);
  245. },
  246. fullscreenChange(fullscreen) {
  247. if (fullscreen) {
  248. this.tableHeight = 'calc(100vh - 120px)';
  249. } else {
  250. this.tableHeight = 'calc(100vh - 500px)';
  251. }
  252. },
  253. async getDictList(code) {
  254. let { data: res } = await getByCode(code);
  255. this.dictList = res.map((item) => {
  256. let values = Object.keys(item);
  257. return {
  258. value: Number(values[0]),
  259. label: item[values[0]]
  260. };
  261. });
  262. },
  263. handleSelectionChange() {},
  264. batchDelete() {
  265. if (this.selection.length == 0) {
  266. this.$message.warning('请选择需要删除的质检项');
  267. }
  268. // console.log(this.list, 'this.List');
  269. // console.log(this.selection, 'this.selection');
  270. let indexList = [];
  271. if (this.selection.length == this.list.length) {
  272. this.list = [];
  273. } else {
  274. for (let i = 0; i < this.selection.length; i++) {
  275. for (let j = 0; j < this.list.length; j++) {
  276. if (this.selection[i].id == this.list[j].id) {
  277. indexList.push(j);
  278. }
  279. }
  280. }
  281. }
  282. if (indexList.length != 0) {
  283. indexList.forEach((it) => {
  284. this.list.splice(it, 1);
  285. });
  286. }
  287. // this.selection.forEach((item) => {
  288. // const index = this.list.findIndex((it) => (it.id = item.id));
  289. // console.log('1111111111111111111');
  290. // if (index) {
  291. // indexList.push(index);
  292. // }
  293. // });
  294. console.log(indexList, 'indexList');
  295. // this.selection = [];
  296. // this.$forceUpdate();
  297. },
  298. getDate() {
  299. return this.list;
  300. },
  301. selectChange(list) {
  302. this.list = list;
  303. },
  304. handSelect() {
  305. this.$refs.inspectionTemplateRef.open();
  306. },
  307. async changeSel(list) {
  308. // let ids = list.map((item) => item.id).toString();
  309. // console.log(ids, 'ids')
  310. await getTemplateById(list.id).then(({ data }) => {
  311. data.inspectionItemVOList.forEach((item) => {
  312. item.qualitySchemeTemplateCode = data.qualitySchemeTemplateCode;
  313. item.qualitySchemeTemplateName = data.qualitySchemeTemplateName;
  314. });
  315. this.list = [...this.list, ...(data.inspectionItemVOList || [])];
  316. // this.list.forEach((item) => {
  317. // item.qualitySchemeTemplateCode = data.qualitySchemeTemplateCode;
  318. // item.qualitySchemeTemplateName = data.qualitySchemeTemplateName;
  319. // });
  320. });
  321. }
  322. }
  323. };
  324. </script>
  325. <style lang="scss" scoped></style>