| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- <!-- 用户编辑弹窗 -->
- <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-tabs v-model="activeName" type="card">
- <el-tab-pane
- :label="item.name"
- :name="item.name"
- v-for="item in activeList"
- :key="item.name"
- >
- <el-table
- v-show="activeName == '质检项'"
- 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="请输入"
- >
- <DictSelection
- style="width: 100px"
- slot="prepend"
- clearable
- dictName="数学字符"
- v-model="scope.row.symbol"
- ></DictSelection>
- </el-input>
- <!-- </el-form-item> -->
- </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>
- <el-table
- v-show="activeName == '质检点'"
- style="margin-top: 15px"
- :data="form.linePoints"
- border
- height="40vh"
- >
- <el-table-column label="编码" align="center" prop="pointCode">
- <template slot-scope="scope">
- <el-link
- type="primary"
- :underline="false"
- @click="openEdit('detail', scope.row)"
- >
- {{ scope.row.pointCode }}
- </el-link>
- </template>
- </el-table-column>
- <el-table-column
- label="名称"
- align="center"
- prop="pointName"
- ></el-table-column>
- <el-table-column
- label="区域"
- align="center"
- prop="areaName"
- ></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>
- </el-tab-pane></el-tabs
- >
- <div class="add-product" @click="add">
- <i class="el-icon-circle-plus-outline"></i>
- </div>
- </el-col>
- <!-- <inspectionProjectList v-if="visible" :linePoints="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" />
- <EquipmentDialog ref="equipmentDialogRef" @choose="choose" />
-
- <edit ref="edit" ></edit>
- </el-dialog>
- </template>
- <script>
- import { save, update, getById } from '@/api/inspectionStandard';
- import fileUpload from '@/components/upload/fileUpload';
- import standardDialog from './standardDialog';
- import EquipmentDialog from './EquipmentDialog';
- import edit from '@/views/inspectionPoint/components/edit';
- export default {
- components: {
- fileUpload,
- standardDialog,
- EquipmentDialog,edit
- },
- data() {
- const defaultForm = function () {
- return {
- id: '',
- name: '',
- status: '',
- type: '',
- version: '1.0',
- standardCode: '',
- inspectionId: '',
- singleWeightDivision: '',
- tolerance: '',
- parameterStandards: [],
- linePoints: [],
- parameterType: ''
- };
- };
- return {
- defaultForm,
- // 表单数据
- form: { ...defaultForm() },
- activeName: '质检项',
- activeList: [{ name: '质检项' }, { name: '质检点' }],
- // 表单验证规则
- 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') {
- row.linePoints=row.linePoints||[]
- 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;
- },
- openEdit(type, row) {
- console.log(row)
- this.$refs.edit.open(type, row);
- },
- choose(data) {
- if (this.activeName == '质检点') {
- this.form.linePoints = data;
- return;
- }
- let obj = {
- finalValue: data.parameter?.maxValue,
- initialValue: data.parameter?.minValue,
- toleranceValue: data.project?.inspectionStandard,
- symbol: data.project?.symbol,
- singleWeightDivision:
- data.parameter?.name + ' ' + data.parameter?.unitName,
- tolerance: data.project?.inspectionName + ' ' + data.project?.unit,
- parameterType: data.parameter?.textType,
- defaultValue: data.parameter?.defaultValue
- };
- this.$set(this.form, 'singleWeightDivision', obj.singleWeightDivision);
- this.$set(this.form, 'tolerance', obj.tolerance);
- this.form.parameterType = obj.parameterType;
- this.form.parameterStandards.push(obj);
- },
- add() {
- if (this.activeName == '质检点') {
- this.$refs.equipmentDialogRef.open();
- return;
- }
- 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.$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>
|