Ver código fonte

spc控制图任务页面修改

dengyu 5 meses atrás
pai
commit
dcca72aa5f

+ 1 - 1
.env.development

@@ -11,7 +11,7 @@ VITE_APP_BASE_API = '/dev-api'
 VITE_APP_UPLOAD_URL = 'http://192.168.101.4:7105'
 # 开发接口地址
  VITE_APP_API_URL = 'http://139.155.176.112:7105'
-
+#  VITE_APP_API_URL = 'http://192.168.1.111:7105'
 
 # 是否启用 Mock 服务
 VITE_MOCK_DEV_SERVER = false

+ 7 - 0
src/api/analysis/index.js

@@ -36,3 +36,10 @@ export function updateData(data) {
     data,
   });
 }
+export function getTaskCode(data) {
+  return request({
+    url: "/api/v1/quality/task/list",
+    method: "post",
+    data,
+  });
+}

+ 2 - 0
src/api/spc/index.js

@@ -65,3 +65,5 @@ export function deleteRuleData(data) {
     data,
   });
 }
+
+

+ 143 - 68
src/views/analysis/process/index.vue

@@ -19,25 +19,25 @@
       </div>
       <div class="body">
         <div class="text">
-          规格上限:{{ value ? JSON.parse(value).up : "-" }}
+          Xbar-UCL:{{ value ? JSON.parse(value).avgMax : "-" }}
         </div>
         <div class="text">
-          规格下限:{{ value ? JSON.parse(value).down : "-" }}
+          Xbar-MED:{{ value ? JSON.parse(value).avgMid : "-" }}
         </div>
         <div class="text">
-          计量单位:{{ value ? JSON.parse(value).unit : "-" }}
+          Xbar-LCL:{{ value ? JSON.parse(value).avgMin : "-" }}
         </div>
         <div class="text">
-          Xbar-UCL:{{ showData.avgMax ? showData.avgMax : "-" }}
+          R-UCL:{{ value ? JSON.parse(value).rangeMax : "-" }}
         </div>
         <div class="text">
-          Xbar-LCL:{{ showData.avgMin ? showData.avgMin : "0" }}
+          R-MED:{{ value ? JSON.parse(value).rangeMid : "-" }}
         </div>
         <div class="text">
-          R-UCL:{{ showData.rangeMax ? showData.rangeMax : "-" }}
+          R-LCL:{{ value ? JSON.parse(value).rangeMin : "-" }}
         </div>
         <div class="text">
-          R-LCL:{{ showData.rangeMin ? showData.rangeMin : "0" }}
+          计量单位:{{ value ? JSON.parse(value).unit : "-" }}
         </div>
       </div>
     </div>
@@ -53,8 +53,8 @@
               <Search
                 :searchOptions="searchForm"
                 ref="searchRef"
-                @dataList="getTableData"
-                @resetList="reset"
+                @data-list="getTableData"
+                @reset-list="reset"
               />
             </div>
             <div class="btns">
@@ -161,7 +161,14 @@
                   ><span>{{ row.batchNo }}</span>
                 </template>
               </el-table-column>
-              <el-table-column align="center" :label="title">
+              <el-table-column width="100" prop="accuracys" label="数据">
+                <template #default="{ row }">
+                  <div v-for="(item, index) in row.accuracys" :key="index">
+                    <span>数值{{ index }}:{{ item }}</span>
+                  </div>
+                </template>
+              </el-table-column>
+              <!-- <el-table-column align="center" :label="title">
                 <el-table-column
                   align="center"
                   prop="accuracy1"
@@ -212,7 +219,8 @@
                     ><span>{{ row.accuracy5 }}</span>
                   </template>
                 </el-table-column> </el-table-column
-              ><el-table-column
+              > -->
+              <el-table-column
                 align="center"
                 prop="avg"
                 label="平均值"
@@ -530,14 +538,31 @@
                   value-format="YYYY-MM-DD"
                 />
               </el-form-item>
+              <el-form-item label="任务编号" prop="qualityTaskId">
+                <el-select
+                  v-model="addData.qualityTaskId"
+                  @change="
+                    (value) => {
+                      taskChange(value);
+                    }
+                  "
+                >
+                  <el-option
+                    v-for="(item, index) in taskOption"
+                    :key="index"
+                    :label="item.taskCode"
+                    :value="item.id"
+                  />
+                </el-select>
+              </el-form-item>
               <el-form-item label="产品型号" prop="model">
-                <el-input v-model="addData.model" />
+                <el-input :disabled="true" v-model="addData.model" />
               </el-form-item>
               <el-form-item label="生产批号" prop="batchNo">
                 <el-input v-model="addData.batchNo" />
               </el-form-item>
               <el-form-item
-                v-for="(item, index) in addData.accuracy"
+                v-for="(item, index) in addData.accuracys"
                 :label="'数值' + (index + 1)"
                 :key="index"
                 :rules="[
@@ -551,7 +576,7 @@
                   :precision="2"
                   :step="0.01"
                   style="width: 100%"
-                  v-model="addData.accuracy[index]"
+                  v-model="addData.accuracys[index]"
                 />
               </el-form-item>
               <!-- <el-form-item label="平均值" prop="avg">
@@ -593,14 +618,16 @@
 
             <el-button
               type="primary"
-              v-print="'#charts'"
+              v-print="'#print'"
               style="margin-left: 10px; height: 25px"
               >打 印</el-button
             >
           </div>
           <div class="info">
-            <div id="charts" :style="{ height: maxHeight / 2 + 'px' }"></div>
-            <div id="charts1" :style="{ height: maxHeight / 2 + 'px' }"></div>
+            <div id="print">
+              <div id="charts" :style="{ height: maxHeight / 2 + 'px' }"></div>
+              <div id="charts1" :style="{ height: maxHeight / 2 + 'px' }"></div>
+            </div>
           </div>
         </div>
       </el-scrollbar>
@@ -611,7 +638,13 @@
 <script setup>
 import * as echarts from "echarts";
 import { useDictionaryStore } from "@/store";
-import { getData, addDatas, deleteData, updateData } from "@/api/analysis";
+import {
+  getData,
+  addDatas,
+  deleteData,
+  updateData,
+  getTaskCode,
+} from "@/api/analysis";
 import Search from "@/components/Search/index.vue";
 const year = ref("0");
 const currentOption = reactive({
@@ -622,6 +655,12 @@ const currentOption = reactive({
 });
 const lableValue = ref("");
 const searchRef = ref(null);
+const getTaskOption = async () => {
+  const { data } = await getTaskCode({
+    operationCode: JSON.parse(value.value).value,
+  });
+  taskOption.value = data;
+};
 const getTableData = async () => {
   const { data, code, msg } = await getData({
     ...searchRef.value.searchForm,
@@ -688,8 +727,8 @@ const setY1value = () => {
 
   chartsOption1.value.series[0].data = Y1value.value;
 };
-const setX1array = () => {
-  X1array.value = [];
+const setX1array = async () => {
+  X1array.value = await [];
   tableData.value.forEach((item, index) => {
     X1array.value.push(index + 1);
   });
@@ -722,6 +761,12 @@ const addItem = {
   range: 0,
 };
 const rules = {
+  qualityTaskId: [
+    {
+      required: true,
+      trigger: "change",
+    },
+  ],
   dateStr: [
     {
       required: true,
@@ -815,34 +860,39 @@ const rules = {
 };
 const resItem = {
   // abnormal: "",
-  accuracy1: 0,
-  accuracy2: 0,
-  accuracy3: 0,
-  accuracy4: 0,
-  accuracy5: 0,
   analyseUser: "",
-  avg: 0,
   batchNo: "",
   checkDeviceNo: "",
   checkUser: "",
   dateStr: "",
   measure: "",
   model: "",
-  range: 0,
 };
 const addData = ref({
   // abnormal: "",
-  accuracy: [0, 0, 0, 0],
   analyseUser: "",
-  avg: 0,
   batchNo: "",
   checkDeviceNo: "",
   checkUser: "",
   dateStr: "",
   measure: "",
   model: "",
-  range: 0,
 });
+const accuracysSum = ref(0);
+const taskChange = (value) => {
+  taskOption.value.forEach((item) => {
+    if (item.id == value) {
+      addData.value.model = item.prodtModel;
+      accuracysSum.value = Number(item.processCount);
+      addData.value.accuracys = [];
+      let array = [];
+      for (let i = 0; i < accuracysSum.value; i++) {
+        array.push(0);
+      }
+      addData.value.accuracys = array;
+    }
+  });
+};
 const oldDataJSON = ref("");
 const showData = ref({});
 const url = ref(import.meta.env.VITE_APP_BASE_API + "/api/v1/spc/import");
@@ -851,29 +901,47 @@ const opOptions = ref([...dicts.spc_operation]);
 const setChart1Info = () => {
   // chartsOption1.value.title[0].text = `上限=${showData.value.avgMax ? showData.value.avgMax : "-"}`;
   // chartsOption1.value.title[0].text = `x̄=${showData.value.avgAvg ? showData.value.avgAvg : "-"}`;
-  chartsOption1.value.series[0].markLine.data[0].yAxis = showData.value.avgMax;
-  chartsOption1.value.series[0].markLine.data[0].label.formatter = `                          上限=${showData.value.avgMax ? showData.value.avgMax : "0"}`;
-  chartsOption1.value.series[0].markLine.data[1].yAxis = showData.value.avgMin
-    ? showData.value.avgMin
+  chartsOption1.value.series[0].markLine.data[0].yAxis = JSON.parse(
+    value.value
+  ).avgMax;
+  chartsOption1.value.series[0].markLine.data[0].label.formatter = `                          上限=${
+    JSON.parse(value.value).avgMax ? JSON.parse(value.value).avgMax : "0"
+  }`;
+  chartsOption1.value.series[0].markLine.data[1].yAxis = JSON.parse(value.value)
+    .avgMin
+    ? JSON.parse(value.value).avgMin
     : 0;
-  chartsOption1.value.series[0].markLine.data[1].label.formatter = `           下限=${showData.value.avgMin ? showData.value.avgMin : "0"}`;
-  chartsOption1.value.series[0].markLine.data[2].yAxis = showData.value.avgAvg;
-  chartsOption1.value.series[0].markLine.data[2].label.formatter = `x̄=${showData.value.avgAvg}`;
+  chartsOption1.value.series[0].markLine.data[1].label.formatter = `           下限=${JSON.parse(value.value).avgMin ? JSON.parse(value.value).avgMin : "0"}`;
+  chartsOption1.value.series[0].markLine.data[2].yAxis = JSON.parse(
+    value.value
+  ).avgMid;
+  chartsOption1.value.series[0].markLine.data[2].label.formatter = `x̄=${
+    JSON.parse(value.value).avgMid
+  }`;
   // chartsOption1.value.title[2].text = `下限=${showData.value.avgMin ? showData.value.avgMin : "0"}`;
 };
 const setChart2Info = () => {
   // chartsOption2.value.title[0].text = `上限=${showData.value.rangeMax ? showData.value.rangeMax : "-"}`;
   // chartsOption2.value.title[0].text = `R=${showData.value.rangeAvg ? showData.value.rangeAvg : "-"}`;
-  chartsOption2.value.series[0].markLine.data[0].yAxis =
-    showData.value.rangeMax;
-  chartsOption2.value.series[0].markLine.data[0].label.formatter = `                          上限=${showData.value.rangeMax ? showData.value.rangeMax : "0"}`;
-  chartsOption2.value.series[0].markLine.data[1].yAxis = showData.value.rangeMin
-    ? showData.value.rangeMin
+  chartsOption2.value.series[0].markLine.data[0].yAxis = JSON.parse(
+    value.value
+  ).rangeMax;
+  chartsOption2.value.series[0].markLine.data[0].label.formatter = `                          上限=${
+    JSON.parse(value.value).rangeMax ? JSON.parse(value.value).rangeMax : "0"
+  }`;
+  chartsOption2.value.series[0].markLine.data[1].yAxis = JSON.parse(value.value)
+    .rangeMin
+    ? JSON.parse(value.value).rangeMin
     : 0;
-  chartsOption2.value.series[0].markLine.data[1].label.formatter = `           下限=${showData.value.rangeMin ? showData.value.rangeMin : "0"}`;
-  chartsOption2.value.series[0].markLine.data[2].yAxis =
-    showData.value.rangeAvg;
-  chartsOption2.value.series[0].markLine.data[2].label.formatter = `x̄=${showData.value.rangeAvg}`;
+  chartsOption2.value.series[0].markLine.data[1].label.formatter = `           下限=${
+    JSON.parse(value.value).rangeMin ? JSON.parse(value.value).rangeMin : "0"
+  }`;
+  chartsOption2.value.series[0].markLine.data[2].yAxis = JSON.parse(
+    value.value
+  ).rangeMid;
+  chartsOption2.value.series[0].markLine.data[2].label.formatter = `x̄=${
+    JSON.parse(value.value).rangeMid
+  }`;
   // chartsOption2.value.title[2].text = `下限=${showData.value.rangeMin ? showData.value.rangeMin : "0"}`;
 };
 const setChart1 = () => {
@@ -909,13 +977,14 @@ const onSuccess = (res) => {
     ElMessage.success(msg);
   }
 };
-
+const taskOption = ref([]);
 const value = ref(opOptions.value[0].remark);
 const title = ref("调阻精度");
 
 const showLable = ref("调阻");
 const changeSelect = () => {
-  setTimeout(() => {
+  setTimeout(async () => {
+    getTaskOption();
     showLable.value = selectRef.value.currentPlaceholder;
     opOptions.value.forEach((item) => {
       if (item.dictLabel == showLable.value) {
@@ -936,8 +1005,8 @@ const changeSelect = () => {
         title.value = "调阻精度";
         break;
     }
-    getTableData();
-    chartsOption1.value.title[3].text = `${title.value}的Xbar-R控制图`;
+    await getTableData();
+    chartsOption1.value.title[0].text = `${title.value}的Xbar-R控制图`;
     // tableData.value.forEach((item) => {
     //   item.accuracy1 = 0;
     //   item.accuracy2 = 0;
@@ -1051,15 +1120,15 @@ const chartsOption1 = ref({
       symbol: "circle",
       itemStyle: {
         color: (params) => {
-          const dataIndex = params.dataIndex;
-          if (dataIndex == 0) {
+          const avg = JSON.parse(value.value);
+          const paramValue = Number(params.value);
+          if (
+            paramValue <= Number(avg.avgMax) &&
+            paramValue >= Number(avg.avgMin)
+          ) {
             return "rgb(26, 122, 240)";
           } else {
-            return tableData.value[dataIndex - 1]
-              ? tableData.value[dataIndex - 1].abnormal != "否"
-                ? "red"
-                : "rgb(26, 122, 240)"
-              : "rgb(26, 122, 240)";
+            return "red";
           }
         },
       },
@@ -1071,7 +1140,7 @@ const chartsOption1 = ref({
             yAxis: 0,
             label: {
               position: "end",
-              formatter: `上限=${showData.value.avgMax ? showData.value.avgMax : "-"}`,
+              formatter: `上限=${JSON.parse(value.value).avgMax ? JSON.parse(value.value).avgMax : "-"}`,
               color: "#333",
             },
             lineStyle: { type: "solid", color: "#333", width: 2 },
@@ -1081,7 +1150,7 @@ const chartsOption1 = ref({
             yAxis: 0,
             label: {
               position: "end",
-              formatter: `下限=${showData.value.avgMin ? showData.value.avgMin : "-"}`,
+              formatter: `下限=${JSON.parse(value.value).avgMin ? JSON.parse(value.value).avgMin : "-"}`,
               color: "#333",
             },
             lineStyle: {
@@ -1176,15 +1245,15 @@ const chartsOption2 = ref({
       symbol: "circle",
       itemStyle: {
         color: (params) => {
-          const dataIndex = params.dataIndex;
-          if (dataIndex == 0) {
+          const range = JSON.parse(value.value);
+          const paramValue = Number(params.value);
+          if (
+            paramValue <= Number(range.rangeMax) &&
+            paramValue >= Number(range.rangeMin)
+          ) {
             return "rgb(26, 122, 240)";
           } else {
-            return tableData.value[dataIndex - 1]
-              ? tableData.value[dataIndex - 1].abnormal != "否"
-                ? "red"
-                : "rgb(26, 122, 240)"
-              : "rgb(26, 122, 240)";
+            return "red";
           }
         },
       },
@@ -1196,7 +1265,7 @@ const chartsOption2 = ref({
             yAxis: 0,
             label: {
               position: "end",
-              formatter: `上限=${showData.value.rangeMax ? showData.value.rangeMax : "-"}`,
+              formatter: `上限=${JSON.parse(value.value).rangeMax ? JSON.parse(value.value).rangeMax : "-"}`,
               color: "#333",
             },
             lineStyle: { type: "solid", color: "#333", width: 2 },
@@ -1206,7 +1275,7 @@ const chartsOption2 = ref({
             yAxis: 0,
             label: {
               position: "end",
-              formatter: `下限=${showData.value.rangeMin ? showData.value.rangeMin : "-"}`,
+              formatter: `下限=${JSON.parse(value.value).rangeMin ? JSON.parse(value.value).rangeMin : "-"}`,
               color: "#333",
             },
             lineStyle: { type: "solid", color: "#333", width: 2 },
@@ -1324,6 +1393,7 @@ const setView = () => {
   charts2.value.setOption(chartsOption2.value, true);
 };
 onMounted(() => {
+  getTaskOption();
   setHeight();
   year.value = new Date().getFullYear() + "";
   opOptions.value.forEach((item) => {
@@ -1346,6 +1416,11 @@ onBeforeUnmount(() => {
 </script>
 
 <style lang="scss" scoped>
+@media print {
+  #print {
+    margin-left: -18%;
+  }
+}
 .formStyle {
   width: 400px;
   margin: 20px auto;

+ 46 - 36
src/views/analysis/spc/index.vue

@@ -89,6 +89,9 @@
           label-width="auto"
           class="formStyle"
         >
+          <el-form-item label="任务编号" prop="taskCode">
+            <el-input v-model="formData.taskCode" />
+          </el-form-item>
           <el-form-item label="产品型号" prop="Index1">
             <el-select v-model="formData.Index1">
               <el-option
@@ -99,13 +102,13 @@
               />
             </el-select>
           </el-form-item>
-          <el-form-item label="工序名称" prop="operationName">
-            <el-select v-model="formData.operationName">
+          <el-form-item label="工序名称" prop="Index2">
+            <el-select v-model="formData.Index2">
               <el-option
                 v-for="(item, index) in opOptions"
                 :key="index"
                 :label="item.dictLabel"
-                :value="item.dictLabel"
+                :value="index"
               />
             </el-select>
           </el-form-item>
@@ -116,7 +119,7 @@
             </el-select>
           </el-form-item>
           <el-form-item label="控制参数" prop="param">
-            <el-input-number v-model="formData.param" :min="1" :step="1" />
+            <el-input v-model="formData.param" />
           </el-form-item>
           <el-form-item label="控制图" prop="chart">
             <el-input :disabled="true" v-model="formData.chart" />
@@ -128,15 +131,19 @@
               :step="1"
             />
           </el-form-item>
-          <el-form-item label="中心值" prop="centralValue">
-            <el-input-number v-model="formData.centralValue" />
-          </el-form-item>
           <el-form-item label="上限" prop="upperLimit">
             <el-input-number v-model="formData.upperLimit" />
           </el-form-item>
           <el-form-item label="下限" prop="floor">
             <el-input-number v-model="formData.floor" />
           </el-form-item>
+          <el-form-item label="中心值" prop="centralValue">
+            <el-input-number
+              :min="formData.floor"
+              :max="formData.upperLimit"
+              v-model="formData.centralValue"
+            />
+          </el-form-item>
         </el-form>
         <div style="display: flex; justify-content: space-evenly">
           <el-button
@@ -170,6 +177,7 @@ import {
   add,
   updateData,
   deleteData,
+
 } from "@/api/spc";
 defineOptions({
   name: "SPCrules",
@@ -207,6 +215,7 @@ const searchForm = [
     type: "input",
   },
 ];
+
 const maxHeight = ref(null);
 const setHeight = () => {
   maxHeight.value = document.querySelector(".table").clientHeight;
@@ -241,11 +250,18 @@ const { dicts } = useDictionaryStore();
 const opOptions = ref([...dicts.spc_operation]);
 
 const rules = {
-  Index1: [
+  taskCode: [
     {
       required: true,
       trigger: "change",
+      message: "请输入任务编号",
+    },
+  ],
+  Index1: [
+    {
+      required: true,
       message: "请选择产品型号",
+      trigger: "change",
     },
   ],
   Index2: [
@@ -255,6 +271,13 @@ const rules = {
       trigger: "change",
     },
   ],
+  operationName: [
+    {
+      required: true,
+      trigger: "change",
+      message: "请选择工序名称",
+    },
+  ],
   source: [
     {
       required: true,
@@ -322,8 +345,8 @@ const setEditFormData = (row) => {
       formData.value.Index1 = index;
     }
   });
-  opInfoData.value[formData.value.Index1].operations.forEach((item, index) => {
-    if (item.code == row.operationCode) {
+  opOptions.value.forEach((item, index) => {
+    if (item.dictLabel == row.operationName) {
       formData.value.Index2 = index;
     }
   });
@@ -355,26 +378,19 @@ const toSubmit = async () => {
       if (valid) {
         const { data, code } = await add({
           chart: formData.value.chart,
-          // operationCode:
-          //   opInfoData.value[formData.value.Index1].operations[
-          //     formData.value.Index2
-          //   ].code,
-          // operationName:
-          //   opInfoData.value[formData.value.Index1].operations[
-          //     formData.value.Index2
-          //   ].name,
-
-          // prodtCode: opInfoData.value[formData.value.Index1].prodtCode,
-          // prodtModel: opInfoData.value[formData.value.Index1].prodtModel,
-          // prodtName: opInfoData.value[formData.value.Index1].prodtName,
-          // unit: opInfoData.value[formData.value.Index1].unit,
-          operationName: formData.value.operationName,
+          operationCode: opOptions.value[formData.value.Index2].dictValue,
+          operationName: opOptions.value[formData.value.Index2].dictLabel,
+          prodtCode: opInfoData.value[formData.value.Index1].prodtCode,
+          prodtModel: opInfoData.value[formData.value.Index1].prodtModel,
+          prodtName: opInfoData.value[formData.value.Index1].prodtName,
+          unit: opInfoData.value[formData.value.Index1].unit,
           param: formData.value.param,
           source: formData.value.source,
           processCount: formData.value.processCount,
           centralValue: formData.value.centralValue,
           upperLimit: formData.value.upperLimit,
           floor: formData.value.floor,
+          taskCode: formData.value.taskCode,
         });
         if (code == "200") {
           ElMessage.success("添加成功!");
@@ -390,18 +406,12 @@ const toSubmit = async () => {
       if (valid) {
         const { data, code } = await updateData({
           ...formData.value,
-          // operationCode:
-          //   opInfoData.value[formData.value.Index1].operations[
-          //     formData.value.Index2
-          //   ].code,
-          // operationName:
-          //   opInfoData.value[formData.value.Index1].operations[
-          //     formData.value.Index2
-          //   ].name,
-          // prodtCode: opInfoData.value[formData.value.Index1].prodtCode,
-          // prodtModel: opInfoData.value[formData.value.Index1].prodtModel,
-          // prodtName: opInfoData.value[formData.value.Index1].prodtName,
-          // unit: opInfoData.value[formData.value.Index1].unit,
+          operationCode: opOptions.value[formData.value.Index2].dictValue,
+          operationName: opOptions.value[formData.value.Index2].dictLabel,
+          prodtCode: opInfoData.value[formData.value.Index1].prodtCode,
+          prodtModel: opInfoData.value[formData.value.Index1].prodtModel,
+          prodtName: opInfoData.value[formData.value.Index1].prodtName,
+          unit: opInfoData.value[formData.value.Index1].unit,
         });
         if (code == "200") {
           ElMessage.success("修改成功!");