term.vue 7.0 KB

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