ysy 1 год назад
Родитель
Сommit
664df86c21
2 измененных файлов с 516 добавлено и 220 удалено
  1. 241 220
      src/views/inspectionWork/components/edit.vue
  2. 275 0
      src/views/inspectionWork/components/term.vue

+ 241 - 220
src/views/inspectionWork/components/edit.vue

@@ -183,7 +183,6 @@
               :showLib="false"
               :limit="1"
               :disabled="title == '详情'"
-
             />
           </el-form-item>
         </el-col>
@@ -191,7 +190,22 @@
     </el-form>
 
     <div class="title" v-if="title != '新增'">质检内容</div>
-    <el-table border v-if="title != '新增'"> </el-table>
+
+    <el-tabs v-model="tabTaskId" class="tab-box" type="border-card">
+      <el-tab-pane
+        v-for="(item, index) in form.categoryParamList"
+        :label="item.name"
+        :name="item.id"
+        :key="index"
+      >
+
+      <term :qualityParam="item.qualityParam" ref="qualityParamRef"></term>
+
+  
+
+      </el-tab-pane>
+    </el-tabs>
+
     <div class="title" v-if="title != '新增'">不良品列表</div>
     <el-table :data="form.voList" border v-if="title != '新增'" height="25vh">
       <el-table-column label="序号" align="center" width="60">
@@ -241,172 +255,194 @@
 </template>
 
 <script>
-import { save, update } from '@/api/inspectionWork';
-import { getProduceTaskList } from '@/api/aps';
-import EquipmentDialog from './EquipmentDialog.vue';
-import ProductionVersion from './ProductionVersion.vue';
-import dictMixins from '@/mixins/dictMixins';
-import deptSelect from '@/components/CommomSelect/dept-select.vue';
-import { getUserPage } from '@/api/system/organization';
-import fileUpload from '@/components/upload/fileUpload';
+  import { save, update } from '@/api/inspectionWork';
+  import { getProduceTaskList } from '@/api/aps';
+  import EquipmentDialog from './EquipmentDialog.vue';
+  import ProductionVersion from './ProductionVersion.vue';
+  import dictMixins from '@/mixins/dictMixins';
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import { getUserPage } from '@/api/system/organization';
+  import fileUpload from '@/components/upload/fileUpload';
+  import term from './term';
 
-export default {
-  components: { ProductionVersion, EquipmentDialog, deptSelect, fileUpload },
-  mixins: [dictMixins],
+  export default {
+    components: { ProductionVersion, EquipmentDialog, deptSelect, fileUpload, term },
+    mixins: [dictMixins],
 
-  data() {
-    const defaultForm = function () {
-      return {
-        produceRoutingName: '',
-        produceRoutingId: '',
-        produceTaskId: '',
-        produceTaskName: '',
-        code: '',
-        workOrderCode: '',
-        batchNo: '',
-        productName: '',
-        productCode: '',
-        specification: '',
-        brandNo: '',
-        qualityType: '',
-        total: '',
-        qualifiedNumber: '',
-        noQualifiedNumber: '',
-        hours: '',
-        qualityTime: '',
-        qualityName: '',
-        qualityId: '',
-        voList: [],
-        groupId: '',
-        groupName: '',
-        id: '',
-        accessory: [],
-        qualityMode: ''
+    data() {
+      const defaultForm = function () {
+        return {
+          produceRoutingName: '',
+          produceRoutingId: '',
+          produceTaskId: '',
+          produceTaskName: '',
+          code: '',
+          workOrderCode: '',
+          batchNo: '',
+          productName: '',
+          productCode: '',
+          specification: '',
+          brandNo: '',
+          qualityType: '',
+          total: '',
+          qualifiedNumber: '',
+          noQualifiedNumber: '',
+          hours: '',
+          qualityTime: '',
+          qualityName: '',
+          qualityId: '',
+          voList: [],
+          groupId: '',
+          groupName: '',
+          id: '',
+          accessory: [],
+          qualityMode: '',
+
+          tabTaskId: null
+        };
       };
-    };
-    return {
-      defaultForm,
-      // 表单数据
-      form: { ...defaultForm() },
+      return {
+        defaultForm,
+        // 表单数据
+        form: { ...defaultForm() },
 
-      // 表单验证规则
-      rules: {
-        productName: [{ required: true, message: '请输入', trigger: 'change' }],
-        qualifiedNumber: [
-          { required: true, message: '请输入', trigger: 'blur' }
-        ],
-        qualityTime: [{ required: true, message: '请输入', trigger: 'blur' }],
-        groupId: [{ required: true, message: '请输入', trigger: 'change' }],
-        qualityId: [{ required: true, message: '请输入', trigger: 'change' }]
-      },
-      visible: false,
-      type: null,
-      title: null,
-      loading: false,
-      produceTaskList: [],
-      executorList: ''
-    };
-  },
+        // 表单验证规则
+        rules: {
+          productName: [
+            { required: true, message: '请输入', trigger: 'change' }
+          ],
+          qualifiedNumber: [
+            { required: true, message: '请输入', trigger: 'blur' }
+          ],
+          qualityTime: [{ required: true, message: '请输入', trigger: 'blur' }],
+          groupId: [{ required: true, message: '请输入', trigger: 'change' }],
+          qualityId: [{ required: true, message: '请输入', trigger: 'change' }]
+        },
+        visible: false,
+        type: null,
+        title: null,
+        loading: false,
+        produceTaskList: [],
+        executorList: ''
+      };
+    },
 
-  created() {},
-  methods: {
-    open(type, row) {
-      this.title = type == 'add' ? '新增' : type == 'edit' ? '报工' : '详情';
-      this.type = type;
-      if (this.type != 'add') {
-        row.accessory=row.accessory||[]
+    created() {},
+    methods: {
+      open(type, row) {
+        this.title = type == 'add' ? '新增' : type == 'edit' ? '报工' : '详情';
+        this.type = type;
+        if (this.type != 'add') {
+          row.accessory = row.accessory || [];
 
-        this.form = JSON.parse(JSON.stringify(row));
-        if (this.form.groupId) {
-          this.getUserList({ groupId: this.form.groupId });
+          this.form = JSON.parse(JSON.stringify(row));
+          this.tabTaskId = this.form.categoryParamList[0].id;
+          if (this.form.groupId) {
+            this.getUserList({ groupId: this.form.groupId });
+          }
+          this.getProduceTaskList();
         }
+        this.visible = true;
+      },
+      inputValue() {
+        this.form.total =
+          Number(this.form.qualifiedNumber) +
+          Number(this.form.noQualifiedNumber);
+      },
+      addProduct() {
+        this.$refs.equipmentRefs.open();
+      },
+      openVersion() {
+        this.$refs.versionRefs.open();
+      },
+      //工艺路线回调
+      changeProduct(data) {
+        this.form.produceRoutingId = data.id;
+        this.form.produceRoutingName = data.name;
+        this.form.produceTaskId = '';
+        this.form.produceTaskName = '';
         this.getProduceTaskList();
-      }
-      this.visible = true;
-    },
-    inputValue() {
-      this.form.total =
-        Number(this.form.qualifiedNumber) + Number(this.form.noQualifiedNumber);
-    },
-    addProduct() {
-      this.$refs.equipmentRefs.open();
-    },
-    openVersion() {
-      this.$refs.versionRefs.open();
-    },
-    //工艺路线回调
-    changeProduct(data) {
-      this.form.produceRoutingId = data.id;
-      this.form.produceRoutingName = data.name;
-      this.form.produceTaskId = '';
-      this.form.produceTaskName = '';
-      this.getProduceTaskList();
-    },
-    async getProduceTaskList() {
-      if (!this.form.produceRoutingId) {
-        return;
-      }
-      const res = await getProduceTaskList({
-        isDetail: true,
-        pageNum: 1,
-        routingId: this.form.produceRoutingId,
-        size: -1
-      });
-      this.produceTaskList = res.list;
-    },
-    produceTaskChange() {
-      if (!this.form.produceTaskId) {
-        return;
-      }
-      this.form.produceTaskName = this.produceTaskList.find(
-        (item) => item.id == this.form.produceTaskId
-      ).name;
-    },
-    choose(data) {
-      this.form.productName = data[0].name;
-      this.form.productCode = data[0].code;
-      this.form.specification = data[0].specification;
-      this.form.brandNo = data[0].brandNum;
-    },
-    //选择部门(搜索)
-    searchDeptNodeClick(info, row) {
-      if (info) {
-        const params = { groupId: info };
-        this.getUserList(params);
-        this.form.groupName = row.name;
-      } else {
-        this.form.executeGroupId = null;
-      }
-    },
-    // 获取审核人列表、巡点检人员
-    async getUserList(params) {
-      try {
-        let data = { pageNum: 1, size: -1 };
-        // 如果传了参数就是获取巡点检人员数据
-        if (params) {
-          data = Object.assign(data, params);
+      },
+      async getProduceTaskList() {
+        if (!this.form.produceRoutingId) {
+          return;
         }
-        const res = await getUserPage(data);
-        this.executorList = res.list;
-      } catch (error) {}
-    },
-    // 执行人选择
-    changeExecutor(val) {
-      if (val) {
-        this.form.qualityId = val;
-        this.form.qualityName = this.executorList.filter(
-          (item) => item.id === val
-        )[0].name;
-      }
-    },
-    /* 保存编辑 */
-    save() {
-      this.$refs.form.validate((valid) => {
-        if (!valid) {
-          return false;
+        const res = await getProduceTaskList({
+          isDetail: true,
+          pageNum: 1,
+          routingId: this.form.produceRoutingId,
+          size: -1
+        });
+        this.produceTaskList = res.list;
+      },
+      produceTaskChange() {
+        if (!this.form.produceTaskId) {
+          return;
         }
+        this.form.produceTaskName = this.produceTaskList.find(
+          (item) => item.id == this.form.produceTaskId
+        ).name;
+      },
+      choose(data) {
+        this.form.productName = data[0].name;
+        this.form.productCode = data[0].code;
+        this.form.specification = data[0].specification;
+        this.form.brandNo = data[0].brandNum;
+      },
+      //选择部门(搜索)
+      searchDeptNodeClick(info, row) {
+        if (info) {
+          const params = { groupId: info };
+          this.getUserList(params);
+          this.form.groupName = row.name;
+        } else {
+          this.form.executeGroupId = null;
+        }
+      },
+      // 获取审核人列表、巡点检人员
+      async getUserList(params) {
+        try {
+          let data = { pageNum: 1, size: -1 };
+          // 如果传了参数就是获取巡点检人员数据
+          if (params) {
+            data = Object.assign(data, params);
+          }
+          const res = await getUserPage(data);
+          this.executorList = res.list;
+        } catch (error) {}
+      },
+      // 执行人选择
+      changeExecutor(val) {
+        if (val) {
+          this.form.qualityId = val;
+          this.form.qualityName = this.executorList.filter(
+            (item) => item.id === val
+          )[0].name;
+        }
+      },
+      /* 保存编辑 */
+      save() {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+          this.loading = true;
+          save(this.form)
+            .then((msg) => {
+              this.loading = false;
+              this.$message.success(msg);
+              this.handleClose();
+              this.$emit('done');
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+      update() {
         this.loading = true;
-        save(this.form)
+        this.form['status'] = 1;
+        update({ ...this.form })
           .then((msg) => {
             this.loading = false;
             this.$message.success(msg);
@@ -416,75 +452,60 @@ export default {
           .catch((e) => {
             this.loading = false;
           });
-      });
-    },
-    update() {
-      this.loading = true;
-      this.form['status'] = 1;
-      update({ ...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();
         });
-    },
-    restForm() {
-      this.form = { ...this.defaultForm() };
-      this.$nextTick(() => {
-        this.$refs.form.clearValidate();
-      });
-    },
-    handleClose() {
-      this.restForm();
-      this.visible = false;
+      },
+      handleClose() {
+        this.restForm();
+        this.visible = false;
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-.title {
-  font-size: 16px;
-  line-height: 45px;
-}
-.location-warp {
-  display: flex;
+  .title {
+    font-size: 16px;
+    line-height: 45px;
+  }
+  .location-warp {
+    display: flex;
 
-  .detail {
-    margin-left: 10px;
+    .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;
-}
+  :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>

+ 275 - 0
src/views/inspectionWork/components/term.vue

@@ -0,0 +1,275 @@
+<template>
+  <div>
+    <div class="content_box" v-if="list.length > 0">
+      <div class="content_box_list" v-for="(item, idx) in list" :key="idx">
+        <div class="content_ll">
+          <div class="name">质检类型</div>
+          <div>
+            {{ item.categoryLevelName }}
+          </div>
+        </div>
+
+        <div class="content_ll">
+          <div class="name">标准类型</div>
+          <div>
+            {{
+              getDictValue(
+                '质检标准类型',
+                item.qualityStandard && item.qualityStandard.type
+              )
+            }}
+          </div>
+        </div>
+
+        <div class="content_ll">
+          <div class="name">标准编码</div>
+          <div class="">{{
+            item.qualityStandard && item.qualityStandard.code
+          }}</div>
+        </div>
+
+        <div class="content_ll">
+          <div class="name">标准名称</div>
+          <div class="">{{
+            item.qualityStandard && item.qualityStandard.name
+          }}</div>
+        </div>
+
+        <el-link
+          type="danger"
+          :underline="false"
+          icon="el-icon-delete"
+          @click="handDel(idx)"
+        >
+          删除
+        </el-link>
+
+        <el-form ref="form" style="width: 100%">
+          <el-table
+            style="margin-top: 15px"
+            :data="
+              item.qualityStandard && item.qualityStandard.parameterStandards
+            "
+            border
+          >
+            <el-table-column
+              :label="
+                item.qualityStandard &&
+                item.qualityStandard.singleWeightDivision
+              "
+              align="center"
+            >
+              <el-table-column
+                label="参数上限"
+                align="center"
+                v-if="
+                  item.qualityStandard &&
+                  item.qualityStandard.parameterType == 3
+                "
+              >
+                <template slot-scope="scope">
+                  <el-form-item label-width="0" prop="finalValue">
+                    <el-input
+                      clearable
+                      :disabled="type == 'detail'"
+                      v-model="scope.row.finalValue"
+                      placeholder="请输入"
+                    />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column
+                label="参数下限"
+                align="center"
+                v-if="
+                  item.qualityStandard &&
+                  item.qualityStandard.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="
+                  item.qualityStandard &&
+                  item.qualityStandard.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="item.qualityStandard && item.qualityStandard.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>
+                </template>
+              </el-table-column>
+            </el-table-column>
+
+            <el-table-column label="操作" align="center" width="70">
+              <template slot-scope="scope">
+                <el-link
+                  type="danger"
+                  :underline="false"
+                  icon="el-icon-delete"
+                  @click="handDel2(idx, scope.$index)"
+                >
+                  删除
+                </el-link>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-form>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import { getByCode } from '@/api/system/dictionary-data';
+
+  export default {
+    components: {},
+    mixins: [dictMixins],
+    props: {
+      qualityParam: {
+        type: Array
+      }
+    },
+
+    watch: {
+      qualityParam: {
+        handler(val) {
+          this.list = val;
+          this.$forceUpdate();
+        },
+        deep: true,
+        immediate: true
+      }
+    },
+
+    data() {
+      return {
+        list: [],
+        dictList: []
+      };
+    },
+
+    created() {
+      this.requestDict('质检标准类型');
+      this.getDictList('mathematical_symbol');
+    },
+
+    methods: {
+      updateOrCreateObjectInArray(array, newObj, idKey = 'id') {
+        // 用来检查是否已存在具有特定 id 的对象
+        const exists = array.some((obj) => obj[idKey] === newObj[idKey]);
+
+        if (exists) {
+          // 如果存在,使用 map 来替换找到的对象
+          return array.map((obj) =>
+            obj[idKey] === newObj[idKey] ? newObj : obj
+          );
+        } else {
+          // 如果不存在,将新对象添加到数组中
+          return [...array, newObj];
+        }
+      },
+
+      handDel(index) {
+        this.$confirm('是否删除该质检项', '删除', {
+          type: 'warning'
+        })
+          .then(() => {
+            this.list.splice(index, 1);
+          })
+          .catch(() => {});
+      },
+
+      async getDictList(code) {
+        let { data: res } = await getByCode(code);
+        this.dictList = res.map((item) => {
+          let values = Object.keys(item);
+          return {
+            value: Number(values[0]),
+            label: item[values[0]]
+          };
+        });
+      },
+
+      handDel2(idx, index) {
+        this.list[idx].qualityStandard.parameterStandards.splice(index, 1);
+      },
+
+      getDate() {
+        return this.list;
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .content_box {
+    width: 100%;
+    margin-top: 12px;
+    max-height: 42vh;
+    overflow-y: scroll;
+  }
+
+  .content_box_list {
+    display: flex;
+    flex-wrap: wrap;
+    margin-bottom: 30px;
+  }
+
+  .content_ll {
+    width: 23%;
+    display: flex;
+    flex-direction: row;
+
+    margin: auto;
+    margin-top: 10px;
+
+    .name {
+      width: 130px;
+      color: #000;
+      font-weight: 500;
+    }
+  }
+</style>