| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <!-- 用户编辑弹窗 -->
- <template>
- <el-dialog
- class="ele-dialog-form"
- :title="title"
- :visible.sync="visible"
- :before-close="handleClose"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- width="1000px"
- >
- <el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-row>
- <el-col :span="12">
- <el-form-item label="标准类型:" prop="type">
- <DictSelection
- dictName="质检标准类型"
- v-model="form.type"
- ></DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="标准名称:" prop="name">
- <el-input clearable v-model="form.name" placeholder="请输入" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="标准代码:" prop="standardCode">
- <el-input v-model="form.standardCode"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="版本号:" prop="version">
- <el-input v-model="form.version"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="状态:" prop="status">
- <el-select
- v-model="form.status"
- placeholder="请选择"
- style="width: 100%"
- >
- <el-option label="停用" :value="0" />
- <el-option label="启用" :value="1" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item prop="imgUrl" label="附件">
- <fileUpload
- v-model="form.imgUrl"
- module="main"
- :showLib="false"
- :limit="1"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <!-- <el-button
- style="margin-left: 100px"
- type="primary"
- @click="addParameter"
- >选择工艺参数标准</el-button
- > -->
- <el-table
- style="margin-top: 15px"
- :data="form.parameterStandards"
- border
- height="40vh"
- >
- <el-table-column :label="form.singleWeightDivision" align="center">
- <el-table-column label="参数上限" align="center" v-if='form.parameterType==3'>
- <template slot-scope="scope">
- <el-form-item label-width="0" prop="finalValue">
- <el-input
- clearable
- v-model="scope.row.finalValue"
- placeholder="请输入"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="参数下限" align="center" v-if='form.parameterType==3'>
- <template slot-scope="scope">
- <el-form-item label-width="0" prop="initialValue">
- <el-input
- clearable
- v-model="scope.row.initialValue"
- placeholder="请输入"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="默认值" align="center" v-if='form.parameterType!=3'>
- <template slot-scope="scope">
- <el-form-item label-width="0" prop="defaultValue">
- <el-input
- clearable
- v-model="scope.row.defaultValue"
- placeholder="请输入"
- />
- </el-form-item>
- </template>
- </el-table-column>
- </el-table-column>
- <el-table-column :label="form.tolerance" align="center">
- <el-table-column label="质检标准" align="center">
- <template slot-scope="scope">
- <el-form-item label-width="0" prop="inspectionStandard">
- <el-input
- clearable
- v-model="scope.row.toleranceValue"
- placeholder="请输入"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="80">
- <template slot-scope="scope">
- <el-link
- type="danger"
- :underline="false"
- @click="handleDeleteItem(scope.$index, scope.row.id)"
- >
- 删除
- </el-link>
- </template>
- </el-table-column>
- </el-table-column>
- </el-table>
- <div class="add-product" @click="add">
- <i class="el-icon-circle-plus-outline"></i>
- </div>
- </el-col>
- <!-- <inspectionProjectList v-if="visible" :list="form.inspectionItems" ref="inspectionProjectRef" /> -->
- </el-row>
- </el-form>
- <template v-slot:footer>
- <el-button @click="handleClose">取消</el-button>
- <el-button type="primary" :loading="loading" @click="save">
- 保存
- </el-button>
- </template>
- <standardDialog ref="standardDialogRef" @choose="choose" />
- </el-dialog>
- </template>
- <script>
- import { save, update, getById } from '@/api/inspectionStandard';
- import fileUpload from '@/components/upload/fileUpload';
- import standardDialog from './standardDialog';
- // import EquipmentDialog from '../../../views/inspectionPoint/components/EquipmentDialog';
- export default {
- components: {
- fileUpload,
- standardDialog
- },
- data() {
- const defaultForm = function () {
- return {
- id: '',
- name: '',
- status: '',
- type: '',
- version: '1.0',
- standardCode: '',
- inspectionId: '',
- singleWeightDivision: '',
- tolerance: '',
- parameterStandards: [],
- parameterType:''
- };
- };
- return {
- defaultForm,
- // 表单数据
- form: { ...defaultForm() },
- // 表单验证规则
- rules: {
- name: [{ required: true, message: '请输入', trigger: 'blur' }],
- version: [{ required: true, message: '请输入', trigger: 'blur' }],
- type: {
- required: true,
- message: '请选择',
- trigger: 'change'
- },
- status: {
- required: true,
- message: '请选择',
- trigger: 'change'
- }
- },
- visible: false,
- type: null,
- title: null,
- loading: false
- };
- },
- created() {},
- methods: {
- open(type, row) {
- this.title = type == 'add' ? '新增' : '编辑';
- this.type = type;
- if (this.type == 'edit') {
- if (!row.parameterStandards) {
- row.parameterStandards = [];
- }else{
- row.singleWeightDivision=row.parameterStandards[0]?.singleWeightDivision
- row.tolerance=row.parameterStandards[0]?.tolerance
- row.parameterType=row.parameterStandards[0]?.parameterType
- }
- this.form = JSON.parse(JSON.stringify(row)) ;
- }
- this.visible = true;
- },
- choose(data) {
- let obj = {
- finalValue: data.parameter?.maxValue,
- initialValue: data.parameter?.minValue,
- toleranceValue: data.project?.inspectionStandard,
- singleWeightDivision: data.parameter?.name +' '+ data.parameter?.unitName,
- tolerance: data.project?.inspectionName+' '+data.project?.unit,
- parameterType:data.parameter?.textType,
- defaultValue:data.parameter?.defaultValue,
- };
- this.form.singleWeightDivision =obj.singleWeightDivision
- this.form.tolerance = obj.tolerance
- this.form.parameterType = obj.parameterType
- this.form.parameterStandards.push(obj);
- },
- add() {
- if (!this.form.parameterStandards.length) {
- this.$refs.standardDialogRef.open();
- return;
- }
- let obj = {
- finalValue: '',
- initialValue: '',
- toleranceValue: '',
- singleWeightDivision: '',
- tolerance: ''
- };
- this.form.parameterStandards.push(obj);
- },
- handleDeleteItem(index) {
- this.form.parameterStandards.splice(index, 1);
- },
- /* 保存编辑 */
- save() {
- this.$refs.form.validate((valid) => {
- if (!valid) {
- return false;
- }
- this.loading = true;
- if (this.type == 'add') {
- delete this.form.id;
- }
- // this.form.inspectionId = this.$refs.inspectionProjectRef.getValue();
- let URL = this.type == 'add' ? save : update;
- URL(this.form)
- .then((msg) => {
- this.loading = false;
- this.$message.success(msg);
- this.handleClose();
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- });
- });
- },
- restForm() {
- this.form = { ...this.defaultForm() };
- this.list = [];
- this.$nextTick(() => {
- this.$refs.form.clearValidate();
- });
- },
- handleClose() {
- this.restForm();
- this.visible = false;
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .location-warp {
- display: flex;
- .detail {
- margin-left: 10px;
- }
- }
- :deep(
- .el-dialog:not(.ele-dialog-form)
- .el-dialog__body
- .el-form
- .el-form-item:last-child
- ) {
- margin-bottom: 22px;
- }
- :deep(
- .el-dialog:not(.ele-dialog-form)
- .el-dialog__body
- .el-form
- .el-table__body
- .el-table__row
- .el-form-item:last-child
- ) {
- margin-bottom: 0 !important;
- }
- .add-product {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- font-size: 30px;
- color: #1890ff;
- margin: 10px 0;
- cursor: pointer;
- }
- </style>
|