edit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <el-dialog
  4. class="ele-dialog-form"
  5. :title="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. >
  12. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  13. <el-row>
  14. <el-col :span="12">
  15. <el-form-item label="标准类型:" prop="type">
  16. <DictSelection
  17. dictName="质检标准类型"
  18. v-model="form.type"
  19. ></DictSelection>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="12">
  23. <el-form-item label="标准名称:" prop="name">
  24. <el-input clearable v-model="form.name" placeholder="请输入" />
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="12">
  28. <el-form-item label="标准代码:" prop="standardCode">
  29. <el-input v-model="form.standardCode"></el-input>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="12">
  33. <el-form-item label="版本号:" prop="version">
  34. <el-input v-model="form.version"></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="12">
  38. <el-form-item label="状态:" prop="status">
  39. <el-select
  40. v-model="form.status"
  41. placeholder="请选择"
  42. style="width: 100%"
  43. >
  44. <el-option label="停用" :value="0" />
  45. <el-option label="启用" :value="1" />
  46. </el-select>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="8">
  50. <el-form-item prop="imgUrl" label="附件">
  51. <fileUpload
  52. v-model="form.imgUrl"
  53. module="main"
  54. :showLib="false"
  55. :limit="1"
  56. />
  57. </el-form-item>
  58. </el-col>
  59. </el-row>
  60. <el-row>
  61. <el-col :span="24">
  62. <!-- <el-button
  63. style="margin-left: 100px"
  64. type="primary"
  65. @click="addParameter"
  66. >选择工艺参数标准</el-button
  67. > -->
  68. <el-tabs v-model="activeName" type="card">
  69. <el-tab-pane
  70. :label="item.name"
  71. :name="item.name"
  72. v-for="item in activeList"
  73. :key="item.name"
  74. >
  75. <el-table
  76. v-show="activeName == '质检项'"
  77. style="margin-top: 15px"
  78. :data="form.parameterStandards"
  79. border
  80. height="40vh"
  81. >
  82. <el-table-column
  83. :label="form.singleWeightDivision"
  84. align="center"
  85. >
  86. <el-table-column
  87. label="参数上限"
  88. align="center"
  89. v-if="form.parameterType == 3"
  90. >
  91. <template slot-scope="scope">
  92. <el-form-item label-width="0" prop="finalValue">
  93. <el-input
  94. clearable
  95. v-model="scope.row.finalValue"
  96. placeholder="请输入"
  97. />
  98. </el-form-item>
  99. </template>
  100. </el-table-column>
  101. <el-table-column
  102. label="参数下限"
  103. align="center"
  104. v-if="form.parameterType == 3"
  105. >
  106. <template slot-scope="scope">
  107. <el-form-item label-width="0" prop="initialValue">
  108. <el-input
  109. clearable
  110. v-model="scope.row.initialValue"
  111. placeholder="请输入"
  112. />
  113. </el-form-item>
  114. </template>
  115. </el-table-column>
  116. <el-table-column
  117. label="默认值"
  118. align="center"
  119. v-if="form.parameterType != 3"
  120. >
  121. <template slot-scope="scope">
  122. <el-form-item label-width="0" prop="defaultValue">
  123. <el-input
  124. clearable
  125. v-model="scope.row.defaultValue"
  126. placeholder="请输入"
  127. />
  128. </el-form-item>
  129. </template>
  130. </el-table-column>
  131. </el-table-column>
  132. <el-table-column :label="form.tolerance" align="center">
  133. <el-table-column label="质检标准" align="center">
  134. <template slot-scope="scope">
  135. <el-form-item label-width="0" prop="inspectionStandard">
  136. <el-input
  137. clearable
  138. v-model="scope.row.toleranceValue"
  139. placeholder="请输入"
  140. >
  141. <DictSelection
  142. style="width: 100px"
  143. slot="prepend"
  144. clearable
  145. dictName="数学字符"
  146. v-model="scope.row.symbol"
  147. ></DictSelection>
  148. </el-input>
  149. <!-- </el-form-item> -->
  150. </el-form-item>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="操作" align="center" width="80">
  154. <template slot-scope="scope">
  155. <el-link
  156. type="danger"
  157. :underline="false"
  158. @click="handleDeleteItem(scope.$index, scope.row.id)"
  159. >
  160. 删除
  161. </el-link>
  162. </template>
  163. </el-table-column>
  164. </el-table-column>
  165. </el-table>
  166. <el-table
  167. v-show="activeName == '质检点'"
  168. style="margin-top: 15px"
  169. :data="form.linePoints"
  170. border
  171. height="40vh"
  172. >
  173. <el-table-column label="编码" align="center" prop="pointCode">
  174. <template slot-scope="scope">
  175. <el-link
  176. type="primary"
  177. :underline="false"
  178. @click="openEdit('detail', scope.row)"
  179. >
  180. {{ scope.row.pointCode }}
  181. </el-link>
  182. </template>
  183. </el-table-column>
  184. <el-table-column
  185. label="名称"
  186. align="center"
  187. prop="pointName"
  188. ></el-table-column>
  189. <el-table-column
  190. label="区域"
  191. align="center"
  192. prop="areaName"
  193. ></el-table-column>
  194. <el-table-column label="操作" align="center" width="80">
  195. <template slot-scope="scope">
  196. <el-link
  197. type="danger"
  198. :underline="false"
  199. @click="handleDeleteItem(scope.$index, scope.row.id)"
  200. >
  201. 删除
  202. </el-link>
  203. </template>
  204. </el-table-column>
  205. </el-table>
  206. </el-tab-pane></el-tabs
  207. >
  208. <div class="add-product" @click="add">
  209. <i class="el-icon-circle-plus-outline"></i>
  210. </div>
  211. </el-col>
  212. <!-- <inspectionProjectList v-if="visible" :linePoints="form.inspectionItems" ref="inspectionProjectRef" /> -->
  213. </el-row>
  214. </el-form>
  215. <template v-slot:footer>
  216. <el-button @click="handleClose">取消</el-button>
  217. <el-button type="primary" :loading="loading" @click="save">
  218. 保存
  219. </el-button>
  220. </template>
  221. <standardDialog ref="standardDialogRef" @choose="choose" />
  222. <EquipmentDialog ref="equipmentDialogRef" @choose="choose" />
  223. <edit ref="edit" ></edit>
  224. </el-dialog>
  225. </template>
  226. <script>
  227. import { save, update, getById } from '@/api/inspectionStandard';
  228. import fileUpload from '@/components/upload/fileUpload';
  229. import standardDialog from './standardDialog';
  230. import EquipmentDialog from './EquipmentDialog';
  231. import edit from '@/views/inspectionPoint/components/edit';
  232. export default {
  233. components: {
  234. fileUpload,
  235. standardDialog,
  236. EquipmentDialog,edit
  237. },
  238. data() {
  239. const defaultForm = function () {
  240. return {
  241. id: '',
  242. name: '',
  243. status: '',
  244. type: '',
  245. version: '1.0',
  246. standardCode: '',
  247. inspectionId: '',
  248. singleWeightDivision: '',
  249. tolerance: '',
  250. parameterStandards: [],
  251. linePoints: [],
  252. parameterType: ''
  253. };
  254. };
  255. return {
  256. defaultForm,
  257. // 表单数据
  258. form: { ...defaultForm() },
  259. activeName: '质检项',
  260. activeList: [{ name: '质检项' }, { name: '质检点' }],
  261. // 表单验证规则
  262. rules: {
  263. name: [{ required: true, message: '请输入', trigger: 'blur' }],
  264. version: [{ required: true, message: '请输入', trigger: 'blur' }],
  265. type: {
  266. required: true,
  267. message: '请选择',
  268. trigger: 'change'
  269. },
  270. status: {
  271. required: true,
  272. message: '请选择',
  273. trigger: 'change'
  274. }
  275. },
  276. visible: false,
  277. type: null,
  278. title: null,
  279. loading: false
  280. };
  281. },
  282. created() {},
  283. methods: {
  284. open(type, row) {
  285. this.title = type == 'add' ? '新增' : '编辑';
  286. this.type = type;
  287. if (this.type == 'edit') {
  288. row.linePoints=row.linePoints||[]
  289. if (!row.parameterStandards) {
  290. row.parameterStandards = [];
  291. } else {
  292. row.singleWeightDivision =
  293. row.parameterStandards[0]?.singleWeightDivision;
  294. row.tolerance = row.parameterStandards[0]?.tolerance;
  295. row.parameterType = row.parameterStandards[0]?.parameterType;
  296. }
  297. this.form = JSON.parse(JSON.stringify(row));
  298. }
  299. this.visible = true;
  300. },
  301. openEdit(type, row) {
  302. console.log(row)
  303. this.$refs.edit.open(type, row);
  304. },
  305. choose(data) {
  306. if (this.activeName == '质检点') {
  307. this.form.linePoints = data;
  308. return;
  309. }
  310. let obj = {
  311. finalValue: data.parameter?.maxValue,
  312. initialValue: data.parameter?.minValue,
  313. toleranceValue: data.project?.inspectionStandard,
  314. symbol: data.project?.symbol,
  315. singleWeightDivision:
  316. data.parameter?.name + ' ' + data.parameter?.unitName,
  317. tolerance: data.project?.inspectionName + ' ' + data.project?.unit,
  318. parameterType: data.parameter?.textType,
  319. defaultValue: data.parameter?.defaultValue
  320. };
  321. this.$set(this.form, 'singleWeightDivision', obj.singleWeightDivision);
  322. this.$set(this.form, 'tolerance', obj.tolerance);
  323. this.form.parameterType = obj.parameterType;
  324. this.form.parameterStandards.push(obj);
  325. },
  326. add() {
  327. if (this.activeName == '质检点') {
  328. this.$refs.equipmentDialogRef.open();
  329. return;
  330. }
  331. if (!this.form.parameterStandards.length) {
  332. this.$refs.standardDialogRef.open();
  333. return;
  334. }
  335. let obj = {
  336. finalValue: '',
  337. initialValue: '',
  338. toleranceValue: '',
  339. singleWeightDivision: '',
  340. tolerance: ''
  341. };
  342. this.form.parameterStandards.push(obj);
  343. },
  344. handleDeleteItem(index) {
  345. this.form.parameterStandards.splice(index, 1);
  346. },
  347. /* 保存编辑 */
  348. save() {
  349. this.$refs.form.validate((valid) => {
  350. if (!valid) {
  351. return false;
  352. }
  353. this.loading = true;
  354. if (this.type == 'add') {
  355. delete this.form.id;
  356. }
  357. // this.form.inspectionId = this.$refs.inspectionProjectRef.getValue();
  358. let URL = this.type == 'add' ? save : update;
  359. URL(this.form)
  360. .then((msg) => {
  361. this.loading = false;
  362. this.$message.success(msg);
  363. this.handleClose();
  364. this.$emit('done');
  365. })
  366. .catch((e) => {
  367. this.loading = false;
  368. });
  369. });
  370. },
  371. restForm() {
  372. this.form = { ...this.defaultForm() };
  373. this.$nextTick(() => {
  374. this.$refs.form.clearValidate();
  375. });
  376. },
  377. handleClose() {
  378. this.restForm();
  379. this.visible = false;
  380. }
  381. }
  382. };
  383. </script>
  384. <style lang="scss" scoped>
  385. .location-warp {
  386. display: flex;
  387. .detail {
  388. margin-left: 10px;
  389. }
  390. }
  391. :deep(
  392. .el-dialog:not(.ele-dialog-form)
  393. .el-dialog__body
  394. .el-form
  395. .el-form-item:last-child
  396. ) {
  397. margin-bottom: 22px;
  398. }
  399. :deep(
  400. .el-dialog:not(.ele-dialog-form)
  401. .el-dialog__body
  402. .el-form
  403. .el-table__body
  404. .el-table__row
  405. .el-form-item:last-child
  406. ) {
  407. margin-bottom: 0 !important;
  408. }
  409. .add-product {
  410. width: 100%;
  411. display: flex;
  412. align-items: center;
  413. justify-content: flex-end;
  414. font-size: 30px;
  415. color: #1890ff;
  416. margin: 10px 0;
  417. cursor: pointer;
  418. }
  419. </style>