chen 1 ano atrás
pai
commit
6d5db57ed6

+ 12 - 0
src/api/productProcess/productProcess.js

@@ -1,5 +1,17 @@
 import request from '@/axios';
 
+export const getPage = (current, size, params) => {
+  return request({
+    url: '/pl-productProcess/productProcess/page',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size,
+    }
+  })
+}
+
 export const getList = (current, size, params) => {
   return request({
     url: '/pl-productProcess/productProcess/list',

+ 13 - 0
src/option/process/process.js

@@ -12,6 +12,7 @@ export default {
   selection: true,
   dialogClickModal: false,
   columnBtn:false,
+  delBtn: false,
   menuWidth: 300,
   column: [
     {
@@ -130,6 +131,7 @@ export default {
         label: '是',
         value: 1
       }],
+      value: 0,
       rules: [
         {
           required: true,
@@ -149,6 +151,7 @@ export default {
         label: '是',
         value: 1
       }],
+      value: 0,
       rules: [
         {
           required: true,
@@ -162,12 +165,20 @@ export default {
             isDownline: {
               display: true
             },
+            isRetrospect:{
+              display: false,
+              value:0,
+            }
           }
         } else {
           return {
             isDownline: {
               display: false
             },
+            isRetrospect:{
+              display: true,
+              value:0,
+            }
           }
         }
       },
@@ -183,6 +194,7 @@ export default {
         label: '是',
         value: 1
       }],
+      value: 0,
       rules: [
         {
           required: true,
@@ -202,6 +214,7 @@ export default {
         label: '是',
         value: 1
       }],
+      value: 0,
       search: true,
       rules: [
         {

+ 76 - 4
src/option/process/processItem.js

@@ -49,13 +49,85 @@ export default {
       }],
     },
     {
-      label: "预设达标值",
-      prop: "value",
-      type: "input",
+      label: "追溯范围值类型",
+      prop: "valueType",
+      type: 'radio',
+      dicData: [{
+        label: '判断结果',
+        value: '1'
+      }, {
+        label: '判断数值',
+        value: '2'
+      }],
+      value: '1',
       cell: true,
       rules: [{
         required: true,
-        message: "请输入预设达标值",
+        message: "请选择追溯范围值类型",
+        trigger: "blur"
+      }],
+      cascader: ['value'],
+      control: (val, form) => {
+      // change: (data) => {
+      //   let val = data.value
+        debugger
+        if (val == '1') {
+          return {
+            value: {display: true},
+            minValue:{display: false},
+            maxValue:{display: false}
+          }
+        } else {
+          return {
+            value: {display: false},
+            minValue:{display: true},
+            maxValue:{display: true}
+          }
+        }
+      },
+    },
+    // {
+    //   label: "预设达标值",
+    //   prop: "value",
+    //   type: "input",
+    //   cell: true,
+    //   display: true,
+    //   rules: [{
+    //     required: false,
+    //     message: "请输入预设达标值",
+    //     trigger: "blur"
+    //   }],
+    // },
+    {
+      label: "预设最小达标值",
+      prop: "minValue",
+      type: "number",
+      cell: true,
+      rules: [{
+        required: false,
+        message: "请输入预设最小达标值",
+        trigger: "blur"
+      }],
+    },
+    {
+      label: "预设最大达标值",
+      prop: "maxValue",
+      type: "number",
+      cell: true,
+      rules: [{
+        required: false,
+        message: "请输入预设最大达标值",
+        trigger: "blur"
+      }],
+    },
+    {
+      label: "单位",
+      prop: "unit",
+      type: "input",
+      cell: true,
+      rules: [{
+        required: false,
+        message: "请输入单位",
         trigger: "blur"
       }],
     },

+ 3 - 1
src/option/processConfig/processConfig.js

@@ -9,6 +9,7 @@ export default {
   index: true,
   viewBtn: true,
   selection: true,
+  delBtn: false,
   dialogClickModal: false,
   column: [
     {
@@ -62,6 +63,7 @@ export default {
       type: 'select',
       multiple: true,
       dataType:"String",
+      filterable: true,
       dicUrl:"/pl-process/process/select",
       typeformat (item, label, value) {
         return `${item.code}-${item.name}`
@@ -80,7 +82,7 @@ export default {
       hide: true,
     },
     {
-      label: "工序名称s",
+      label: "工序名称",
       prop: "processNames",
       type: "input",
       addDisplay: false,

+ 3 - 0
src/option/productModel/productModel.js

@@ -111,6 +111,9 @@ export default {
       prop: "inStockNum",
       type: 'select',
       dicData: [{
+        label: '6个',
+        value: 6
+      },{
         label: '7个',
         value: 7
       }, {

+ 64 - 0
src/option/productProcess/productProcessReport.js

@@ -0,0 +1,64 @@
+export default {
+  height:'auto',
+  calcHeight: 30,
+  tip: false,
+  searchShow: true,
+  searchMenuSpan: 6,
+  border: true,
+  index: true,
+  viewBtn: true,
+  selection: false,
+  dialogClickModal: false,
+  labelWidth:160,
+  columnBtn:false,
+  addBtn:false,
+  editBtn:false,
+  delBtn:false,
+  column: [
+    {
+      label: "工序",
+      prop: "processName",
+      type: "input",
+      search: true,
+    },
+    {
+      label: "产品型号",
+      prop: "productModel",
+      type: "input",
+      search: true,
+    },
+    {
+      label: "生产良品数量",
+      prop: "successCount",
+      type: "input",
+    },
+    {
+      label: "生产不良品数量",
+      prop: "errorCount",
+      type: "input",
+    },
+    {
+      label: "良品率",
+      prop: "yield",
+      type: "input",
+    },
+    {
+      label: "操作时间",
+      prop: "updateTimeArr",
+      searchType: "daterange",
+      format: "YYYY-MM-DD",
+      valueFormat: "YYYY-MM-DD",
+      dataType:'string',
+      addDisplay: false,
+      editDisplay: false,
+      viewDisplay: false,
+      search: true,
+      rules: [{
+        required: true,
+        message: "请输入操作时间",
+        trigger: "blur"
+      }],
+      hide:true
+    },
+  ]
+}

+ 126 - 7
src/views/process/process.vue

@@ -20,22 +20,22 @@
                @refresh-change="refreshChange"
                @on-load="onLoad">
       <template #menu-left>
-        <el-button type="danger"
+        <!-- <el-button type="danger"
                    icon="el-icon-delete"
                    plain
                    v-if="permission.process_delete"
                    @click="handleDelete">删 除
-        </el-button>
-        <el-button type="warning"
+        </el-button> -->
+        <!-- <el-button type="warning"
                    plain
                    icon="el-icon-download"
                    @click="handleExport">导 出
-        </el-button>
+        </el-button> -->
       </template>
       
       <template #details-form>
         <view style="margin:0 20px">
-          <avue-crud :option="optionSub" ref="detailCrud"
+          <avue-crud :option="optionSub" ref="detailCrud" 
                     :data="form.details">
                     <template #menu-left>
                       <h2>追溯要求</h2>
@@ -55,6 +55,28 @@
                       </el-popconfirm>
                     </template>
 
+                    <template #valueType-form="{row}">
+                      <el-radio-group v-model="row.valueType" @change=" (val) => { valueTypeChange(val, row); }">
+                        <el-radio label="1">判断结果</el-radio>
+                        <el-radio label="2">判断数值</el-radio>
+                      </el-radio-group>
+                    </template>
+                    
+                    <!-- <template #value-form="{row}">
+                      <el-input v-model="row.value"
+                                :disabled="row.valueType=='2'" placeholder="请输入预设达标值"></el-input>
+                    </template> -->
+
+                    <template #minValue-form="{row}">
+                      <el-input-number v-model="row.minValue"
+                                :disabled="row.valueType=='1'" placeholder="请输入预设最小达标值"></el-input-number >
+                    </template>
+
+                    <template #maxValue-form="{row}">
+                      <el-input-number v-model="row.maxValue"
+                                :disabled="row.valueType=='1'" placeholder="请输入预设最大达标值"></el-input-number >
+                    </template>
+
           </avue-crud>
         </view>
       </template>
@@ -107,6 +129,14 @@
         optionSub: optionSub
       };
     },
+    watch: {
+      'form.isPhotograph'(newValue, oldValue) {
+        if(newValue=='1'){
+          this.form.isRetrospect = 0;
+        }
+      }
+
+    },
     computed: {
       ...mapGetters(["permission"]),
       permissionList() {
@@ -136,8 +166,46 @@
       // 主表模块
       rowSave(row, done, loading) {
         if(row.isRetrospect==1){
+          if(row.details.length==0){
+            this.$message({
+                  type: "error",
+                  message: "请填写追溯范围!"
+            });
+            loading();
+            return
+          }
           this.$refs.detailCrud.$refs.cellForm.validate((valid) => {
             if (valid) {
+              for(let index in row.details){
+                let item = row.details[index]
+                if(!item.valueType){
+                    this.$message({
+                          type: "error",
+                          message: "请选择追溯范围值!"
+                    });
+                    loading();
+                    return
+                }
+                if(item.valueType=='1'){
+                  // if(!item.value){
+                  //   this.$message({
+                  //         type: "error",
+                  //         message: "匹配时预设达标值不能为空!"
+                  //   });
+                  //   loading();
+                  //   return
+                  // }
+                }else{
+                  if(!item.maxValue || !item.minValue){
+                    this.$message({
+                          type: "error",
+                          message: "范围时最小最大达标值不能为空!"
+                    });
+                    loading();
+                    return
+                  }
+                }
+              }
               add(row).then(() => {
                 this.onLoad(this.page);
                 this.$message({
@@ -170,8 +238,46 @@
       },
       rowUpdate(row, index, done, loading) {
         if(row.isRetrospect==1){
+          if(row.details.length==0){
+            this.$message({
+                  type: "error",
+                  message: "请填写追溯范围!"
+            });
+            loading();
+            return
+          }
           this.$refs.detailCrud.$refs.cellForm.validate((valid) => {
             if (valid) {
+              for(let index in row.details){
+                let item = row.details[index]
+                if(!item.valueType){
+                    this.$message({
+                          type: "error",
+                          message: "请选择追溯范围值!"
+                    });
+                    loading();
+                    return
+                }
+                if(item.valueType=='1'){
+                  // if(!item.value){
+                  //   this.$message({
+                  //         type: "error",
+                  //         message: "追溯范围值为匹配时预设达标值不能为空!"
+                  //   });
+                  //   loading();
+                  //   return
+                  // }
+                }else{
+                  if(!item.maxValue || !item.minValue){
+                    this.$message({
+                          type: "error",
+                          message: "追溯范围值为范围时最小最大达标值不能为空!"
+                    });
+                    loading();
+                    return
+                  }
+                }
+              }
               update(row).then(() => {
                 this.onLoad(this.page);
                 this.$message({
@@ -283,7 +389,7 @@
         if (["add"].includes(type)) {
           this.optionSub.menu = true;
           if(!this.form.details){
-            this.form.details = [{"$cellEdit":true}]
+            this.form.details = [{"$cellEdit":true,"$isEdit":true,'valueType':'1'}]
           }
         }
         done();
@@ -314,6 +420,7 @@
       onLoad(page, params = {}) {
         this.loading = true;
         const {
+            factoryId,
             code,
             name,
             type,
@@ -321,9 +428,10 @@
         } = this.query;
 
         let values = {
+            factoryId_equal: factoryId,
             code_like: code,
             name_like: name,
-            type_: type,
+            type_like: type,
             isRetrospect_equal: isRetrospect,
         };
         getList(page.currentPage, page.pageSize, values).then(res => {
@@ -466,6 +574,17 @@
           this.loadingSub = false;
         });
       },
+      delDetail(index){
+			  this.form.details.splice(index,1)
+      },
+      valueTypeChange(val,row){
+        if(val=="1"){
+          row.minValue=''
+          row.maxValue=''
+        }else{
+          row.value=''
+        }
+      }
     }
   };
 </script>

+ 2 - 2
src/views/processConfig/processConfig.vue

@@ -20,7 +20,7 @@
                @refresh-change="refreshChange"
                @on-load="onLoad">
       <template #menu-left>
-        <el-button type="danger"
+        <!-- <el-button type="danger"
                    icon="el-icon-delete"
                    plain
                    v-if="permission.processConfig_delete"
@@ -30,7 +30,7 @@
                    plain
                    icon="el-icon-download"
                    @click="handleExport">导 出
-        </el-button>
+        </el-button> -->
       </template>
     </avue-crud>
   </basic-container>

+ 2 - 2
src/views/productProcess/productProcess.vue

@@ -74,8 +74,8 @@
 <script>
   import {getList, getDetail, add, update, remove} from "@/api/productProcess/productProcess";
   import {getList as getListSub, getDetail as getDetailSub, add as addSub, update as updateSub, remove as removeSub} from "@/api/productProcess/productProcessItem";
-  import option from "@/const/productProcess/productProcess";
-  import optionSub from "@/const/productProcess/productProcessItem";
+  import option from "@/option/productProcess/productProcess";
+  import optionSub from "@/option/productProcess/productProcessItem";
   import {mapGetters} from "vuex";
   import {exportBlob} from "@/api/common";
   import {getToken} from '@/utils/auth';

+ 238 - 0
src/views/productProcess/productProcessReport.vue

@@ -0,0 +1,238 @@
+<template>
+  <basic-container>
+    <avue-crud :option="option"
+               v-model:search="search"
+               v-model:page="page"
+               v-model="form"
+               :table-loading="loading"
+               :data="data"
+               :permission="permissionList"
+               :before-open="beforeOpen"
+               ref="crud"
+               @row-update="rowUpdate"
+               @row-save="rowSave"
+               @row-del="rowDel"
+               @search-change="searchChange"
+               @search-reset="searchReset"
+               @selection-change="selectionChange"
+               @current-change="currentChange"
+               @size-change="sizeChange"
+               @refresh-change="refreshChange"
+               @on-load="onLoad">
+      <template #menu-left>
+        <!-- <el-button type="danger"
+                   icon="el-icon-delete"
+                   plain
+                   v-if="permission.productRework_delete"
+                   @click="handleDelete">删 除
+        </el-button> -->
+        <el-button type="warning"
+                   plain
+                   icon="el-icon-download"
+                   @click="handleExport">导 出
+        </el-button>
+      </template>
+    </avue-crud>
+  </basic-container>
+</template>
+
+<script>
+import {getPage, getDetail, add, update, remove} from "@/api/productProcess/productProcess";
+  import option from "@/option/productProcess/productProcessReport";
+  import {mapGetters} from "vuex";
+  import {exportBlob} from "@/api/common";
+  import {getToken} from '@/utils/auth';
+  import {downloadXls} from "@/utils/util";
+  import {dateNow} from "@/utils/date";
+  import NProgress from 'nprogress';
+  import 'nprogress/nprogress.css';
+
+  export default {
+    data() {
+      return {
+        form: {},
+        query: {},
+        search: {},
+        loading: true,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0
+        },
+        selectionList: [],
+        option: option,
+        data: []
+      };
+    },
+    computed: {
+      ...mapGetters(["permission"]),
+      permissionList() {
+        return {
+          addBtn: this.validData(this.permission.productRework_add, false),
+          viewBtn: this.validData(this.permission.productRework_view, false),
+          delBtn: this.validData(this.permission.productRework_delete, false),
+          editBtn: this.validData(this.permission.productRework_edit, false)
+        };
+      },
+      ids() {
+        let ids = [];
+        this.selectionList.forEach(ele => {
+          ids.push(ele.id);
+        });
+        return ids.join(",");
+      }
+    },
+    methods: {
+      rowSave(row, done, loading) {
+        add(row).then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        }, error => {
+          loading();
+          window.console.log(error);
+        });
+      },
+      rowUpdate(row, index, done, loading) {
+        update(row).then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        }, error => {
+          loading();
+          console.log(error);
+        });
+      },
+      rowDel(row) {
+        this.$confirm("确定将选择数据删除?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(row.id);
+          })
+          .then(() => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+          });
+      },
+      handleDelete() {
+        if (this.selectionList.length === 0) {
+          this.$message.warning("请选择至少一条数据");
+          return;
+        }
+        this.$confirm("确定将选择数据删除?", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            return remove(this.ids);
+          })
+          .then(() => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+            this.$refs.crud.toggleSelection();
+          });
+      },
+      handleExport() {
+        let downloadUrl = `/pl-productProcess/productProcess/export-productProcess?${this.website.tokenHeader}=${getToken()}`;
+        
+        const {
+          processName,
+          productModel,
+          updateTimeArr,
+        } = this.query;
+
+        if(updateTimeArr){
+          let createTime = updateTimeArr.split(",")
+          this.query.updateTimeStart = createTime[0]
+          this.query.updateTimeEnd = createTime[1]
+        }
+        this.$confirm("是否导出数据?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(() => {
+          NProgress.start();
+          exportBlob(downloadUrl, this.query).then(res => {
+            downloadXls(res.data, `工序统计表${dateNow()}.xlsx`);
+            NProgress.done();
+          })
+        });
+      },
+      beforeOpen(done, type) {
+        if (["edit", "view"].includes(type)) {
+          // getDetail(this.form.id).then(res => {
+          //   this.form = res.data.data;
+          // });
+        }
+        done();
+      },
+      searchReset() {
+        this.query = {};
+        this.onLoad(this.page);
+      },
+      searchChange(params, done) {
+        this.query = params;
+        this.page.currentPage = 1;
+        this.onLoad(this.page, params);
+        done();
+      },
+      selectionChange(list) {
+        this.selectionList = list;
+      },
+      selectionClear() {
+        this.selectionList = [];
+        this.$refs.crud.toggleSelection();
+      },
+      currentChange(currentPage){
+        this.page.currentPage = currentPage;
+      },
+      sizeChange(pageSize){
+        this.page.pageSize = pageSize;
+      },
+      refreshChange() {
+        this.onLoad(this.page, this.query);
+      },
+      onLoad(page, params = {}) {
+        this.loading = true;
+
+        const {
+          processName,
+          productModel,
+          updateTimeArr,
+        } = this.query;
+
+        if(updateTimeArr){
+          let createTime = updateTimeArr.split(",")
+          this.query.updateTimeStart = createTime[0]
+          this.query.updateTimeEnd = createTime[1]
+        }
+        getPage(page.currentPage, page.pageSize, this.query).then(res => {
+          const data = res.data.data;
+          this.page.total = data.total;
+          this.data = data.records;
+          this.loading = false;
+          this.selectionClear();
+        });
+      }
+    }
+  };
+</script>
+
+<style>
+</style>