edit.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <el-dialog
  4. class="ele-dialog-form"
  5. title="质检项"
  6. :visible.sync="visible"
  7. :before-close="handleClose"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. width="1000px"
  11. append-to-body
  12. >
  13. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  14. <el-table
  15. style="margin-top: 15px"
  16. :data="form.parameterStandards"
  17. border
  18. height="40vh"
  19. @selection-change="handleSelectionChange"
  20. >
  21. <el-table-column type="selection" align="center" width="55">
  22. </el-table-column>
  23. <el-table-column :label="form.singleWeightDivision" align="center">
  24. <el-table-column
  25. label="参数上限"
  26. align="center"
  27. v-if="form.parameterType == 3"
  28. >
  29. <template slot-scope="scope">
  30. <el-form-item label-width="0" prop="finalValue">
  31. <el-input
  32. clearable
  33. :disabled="type == 'detail'"
  34. v-model="scope.row.finalValue"
  35. placeholder="请输入"
  36. />
  37. </el-form-item>
  38. </template>
  39. </el-table-column>
  40. <el-table-column
  41. label="参数下限"
  42. align="center"
  43. v-if="form.parameterType == 3"
  44. >
  45. <template slot-scope="scope">
  46. <el-form-item label-width="0" prop="initialValue">
  47. <el-input
  48. :disabled="type == 'detail'"
  49. clearable
  50. v-model="scope.row.initialValue"
  51. placeholder="请输入"
  52. />
  53. </el-form-item>
  54. </template>
  55. </el-table-column>
  56. <el-table-column
  57. label="默认值"
  58. align="center"
  59. v-if="form.parameterType != 3"
  60. >
  61. <template slot-scope="scope">
  62. <el-form-item label-width="0" prop="defaultValue">
  63. <el-input
  64. clearable
  65. :disabled="type == 'detail'"
  66. v-model="scope.row.defaultValue"
  67. placeholder="请输入"
  68. />
  69. </el-form-item>
  70. </template>
  71. </el-table-column>
  72. </el-table-column>
  73. <el-table-column :label="form.tolerance" align="center">
  74. <el-table-column label="质检标准" align="center">
  75. <template slot-scope="scope">
  76. <el-form-item label-width="0" prop="inspectionStandard">
  77. <el-input
  78. clearable
  79. v-model="scope.row.toleranceValue"
  80. placeholder="请输入"
  81. :disabled="type == 'detail'"
  82. >
  83. <DictSelection
  84. style="width: 100px"
  85. slot="prepend"
  86. clearable
  87. :disabled="type == 'detail'"
  88. dictName="数学字符"
  89. v-model="scope.row.symbol"
  90. ></DictSelection>
  91. </el-input>
  92. <!-- </el-form-item> -->
  93. </el-form-item>
  94. </template>
  95. </el-table-column>
  96. </el-table-column>
  97. </el-table>
  98. </el-form>
  99. <template v-slot:footer>
  100. <el-button @click="handleClose">取消</el-button>
  101. <el-button type="primary" :loading="loading" @click="save">
  102. 保存
  103. </el-button>
  104. </template>
  105. </el-dialog>
  106. </template>
  107. <script>
  108. import { EventBus } from '@/utils/eventBus';
  109. export default {
  110. components: {},
  111. data() {
  112. const defaultForm = function () {
  113. return {
  114. parameterStandards: [],
  115. linePoints: []
  116. };
  117. };
  118. return {
  119. defaultForm,
  120. // 表单数据
  121. form: { ...defaultForm() },
  122. // 表单验证规则
  123. rules: {},
  124. visible: false,
  125. type: '',
  126. loading: false,
  127. multipleSelection: [],
  128. rowObj: {}
  129. };
  130. },
  131. created() {},
  132. methods: {
  133. open(type, rowItem) {
  134. this.rowObj = rowItem;
  135. let row = rowItem.qualityStandard || {};
  136. this.type = type;
  137. if (this.type != 'add') {
  138. row.linePoints = row.linePoints || [];
  139. if (!row.parameterStandards) {
  140. row.parameterStandards = [];
  141. } else {
  142. row.singleWeightDivision =
  143. row.parameterStandards[0]?.singleWeightDivision;
  144. row.tolerance = row.parameterStandards[0]?.tolerance;
  145. row.parameterType = row.parameterStandards[0]?.parameterType;
  146. }
  147. this.form = JSON.parse(JSON.stringify(row));
  148. }
  149. this.visible = true;
  150. },
  151. handleSelectionChange(val) {
  152. this.multipleSelection = val;
  153. },
  154. /* 保存编辑 */
  155. save() {
  156. let _row = JSON.parse(JSON.stringify(this.rowObj));
  157. let row = _row.qualityStandard || {};
  158. if (!row.parameterStandards) {
  159. row.parameterStandards = [];
  160. } else {
  161. row.singleWeightDivision =
  162. row.parameterStandards[0]?.singleWeightDivision;
  163. row.tolerance = row.parameterStandards[0]?.tolerance;
  164. row.parameterType = row.parameterStandards[0]?.parameterType;
  165. }
  166. row.parameterStandards = this.multipleSelection;
  167. _row.qualityStandard = row;
  168. EventBus.$emit('inspectionSelection', { message: _row });
  169. this.handleClose();
  170. },
  171. restForm() {
  172. this.form = { ...this.defaultForm() };
  173. this.$nextTick(() => {
  174. this.$refs.form.clearValidate();
  175. });
  176. },
  177. handleClose() {
  178. this.restForm();
  179. this.visible = false;
  180. }
  181. }
  182. };
  183. </script>
  184. <style lang="scss" scoped>
  185. .location-warp {
  186. display: flex;
  187. .detail {
  188. margin-left: 10px;
  189. }
  190. }
  191. :deep(
  192. .el-dialog:not(.ele-dialog-form)
  193. .el-dialog__body
  194. .el-form
  195. .el-form-item:last-child
  196. ) {
  197. margin-bottom: 22px;
  198. }
  199. :deep(
  200. .el-dialog:not(.ele-dialog-form)
  201. .el-dialog__body
  202. .el-form
  203. .el-table__body
  204. .el-table__row
  205. .el-form-item:last-child
  206. ) {
  207. margin-bottom: 0 !important;
  208. }
  209. .add-product {
  210. width: 100%;
  211. display: flex;
  212. align-items: center;
  213. justify-content: flex-end;
  214. font-size: 30px;
  215. color: #1890ff;
  216. margin: 10px 0;
  217. cursor: pointer;
  218. }
  219. </style>