Browse Source

计划模块

zhangli 3 years ago
parent
commit
106aecadf9
5 changed files with 604 additions and 3 deletions
  1. 22 0
      src/api/plan.js
  2. 7 1
      src/components/leftnav.vue
  3. 6 0
      src/router/index.js
  4. 2 2
      src/utils/request.js
  5. 567 0
      src/views/plan/plan.vue

+ 22 - 0
src/api/plan.js

@@ -0,0 +1,22 @@
+import request from '@/utils/request'
+
+// 计划列表
+export const selectPage = (object) => { return request({ url: "/productPlan/productPlanPage", data: object})}
+
+// 设置产品计划
+export const productPlanSet = (object) => { return request({ url: "/productPlan/productPlanSet", data: object})}
+
+// 计划新建
+export const productPlanAdd = (object) => { return request({ url: "/productPlan/productPlanAdd", data: object})}
+
+// 计划详情
+export const productPlanInfo = (object) => { return request({ url: "/productPlan/productPlanInfo/"+object.id, data: object, method:'get'})}
+
+// 修改产品计划
+export const productPlanUpdate = (object) => { return request({ url: "/productPlan/productPlanUpdate", data: object})}
+
+// 删除计划
+export const productPlanDelete = (object) => { return request({ url: "/productPlan/productPlanDelete", data: object})}
+
+// 产品列表
+export const getAllProduct = (object) => { return request({ url: "/common/getAllProduct", data: object})}

+ 7 - 1
src/components/leftnav.vue

@@ -61,7 +61,13 @@ export default {
               icon: 'el-icon-tickets',
               url: 'standingManage',
               menus: null
-            }
+            },{
+              menu_id: 12,
+              menu_name: '计划管理',
+              icon: 'el-icon-tickets',
+              url: 'plan',
+              menus: null
+            },
           ]
         }
       ],

+ 6 - 0
src/router/index.js

@@ -19,6 +19,8 @@ import task from '@/views/task/task'
 import addTask from '@/views/task/addTask'
 // 点检台账
 import standingManage from '@/views/standingManage/index'
+// 计划
+import plan from '@/views/plan/plan'
 // 启用路由
 Vue.use(Router);
 
@@ -59,6 +61,10 @@ export default new Router({
             path: '/standingManage',
             name: '台账管理',
             component: standingManage,
+        }, {
+            path: '/plan',
+            name: '计划管理',
+            component: plan
         }]
     }]
 })

+ 2 - 2
src/utils/request.js

@@ -31,9 +31,9 @@ request.interceptors.request.use(config => {
     config.headers.Authorization = accessToken
   } else {
     // config.headers.Authorization = 'Basic dnVlOnZ1ZQ=='
-    config.headers.Authorization = "jHi7Dl/bt40mdEZ1c/fKZGTJG07GB8gpc/aydZaHILo="
+    config.headers.Authorization = "2qvey0UJ00MIW9jkfmJMyh6GdyzjLr8nykEt5v3d9m0="
   }
-
+// config.headers.Authorization = "FwjrAoJGmNMh28FYHQWd7z3nlrLcIi4ODJWvbyoYQFE="
   //  添加时间戳防止IE不刷新页面
   if (config.type != 'FORM') {
     if (config.method == 'post') {

+ 567 - 0
src/views/plan/plan.vue

@@ -0,0 +1,567 @@
+<template>
+  <div>
+    <!-- 面包屑导航 -->
+    <el-breadcrumb separator-class="el-icon-arrow-right">
+      <el-breadcrumb-item>点检</el-breadcrumb-item>
+      <el-breadcrumb-item>计划管理</el-breadcrumb-item>
+    </el-breadcrumb>
+    <!-- 搜索筛选 -->
+    <el-form ref="ruleForm"
+             :model="searchData"
+             class="user-search">
+      <el-form-item style="margin-left:20px">
+        <el-button size="small" type="primary" @click="delPlan">删除</el-button>
+      </el-form-item>
+      <el-form-item style="margin-left:20px">
+        <el-button size="small" type="primary" @click="add_plan">添加计划</el-button>
+      </el-form-item>
+      <el-form-item label="区域" label-width="60px" prop="areaId" style="margin-right:20px">
+          <el-select v-model="searchareaId"
+                     placeholder="请选择区域"
+                     size="small"
+                     clearable
+                     @change="change">
+            <el-option v-for="(item,index) in areas"
+                       :label="item.name"
+                       :key="index"
+                       :value="item.id">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="工位" label-width="100px" prop="stationId">
+          <el-select v-model="searchData.producelineNo"
+                     placeholder="请选择"
+                     size="small"
+                     clearable
+                     :disabled="clickTemplate"
+                     @change="search">
+            <el-option v-for="(item,index) in station"
+                       :label="item.name"
+                       :key="index"
+                       :value="item.id">
+            </el-option>
+          </el-select>
+        </el-form-item>
+    </el-form>
+    <!--列表-->
+    <el-table @selection-change="changeFun" :data="planData"
+              highlight-current-row
+              :header-cell-style="{'background-color':'#FAFAFA','color':'#000'}"
+              border>
+        <el-table-column type="selection">
+        </el-table-column>
+      <el-table-column prop="productName" label="产品" min-width="20" align="center">
+      </el-table-column>
+      <el-table-column prop="planFinishTime" label="时间" min-width="60" align="center">
+      </el-table-column>
+      <el-table-column prop="typeName" label="类型" min-width="40" align="center">
+      </el-table-column>
+      <el-table-column prop="producelineName" label="生产线号" min-width="30" align="center">
+      </el-table-column>
+      <el-table-column prop="runTime" label="运行时间" min-width="30" align="center">
+      </el-table-column>
+      <el-table-column prop="createdUsername" label="当前产品" min-width="30" align="center">
+        <template slot-scope="scope" style="display: flex" >
+          <el-button v-if="scope.row.productNow==0" size="small" class="nowBox" >当前产品</el-button>
+          <el-button v-else type="text" size="small" @click="setNow(scope)">设置当前产品</el-button>
+        </template>
+      </el-table-column>
+      <el-table-column prop="createdUsername" label="下一个产品" min-width="30" align="center">
+        <template slot-scope="scope" style="display: flex">
+          <el-button v-if="scope.row.productNext==0" size="small" class="nextBox" >下个产品</el-button>
+          <el-button v-else type="text" size="small" @click="setNext(scope)">设置下个产品</el-button>
+        </template>
+      </el-table-column>
+      <el-table-column align="center" label="操作" min-width="50">
+        <template slot-scope="scope" style="display: flex">
+          <el-button type="text" size="small" @click="update(scope)">编辑</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页组件 -->
+    <template v-if="planData.length">
+      <Pagination :childMsg="pageInfo"
+                  style="display: flex;
+                       justify-content: flex-end;
+                       margin-top: 20px;"
+                  @currentChange="get_page">
+      </Pagination>
+    </template>
+    <!-- 新增计划 -->
+    <el-dialog :visible.sync="planStatus"
+               :close-on-click-modal="false"
+               width="40%"
+               top="20vh"
+               @click="planStatus = false"
+               center>
+      <div slot="title" style="font-size: 20px">添加产品计划</div>
+      <el-form style="display: block;justify-content: center;margin-top:10px;height:400px;overflow-y: scroll;">
+        <el-form-item label="日期" label-width="140px" prop="name" class="trBox">
+          <el-date-picker
+                  v-model="planFinishTime.date"
+                  type="date"
+                  placeholder="日期"
+                  value-format="yyyy-MM-dd"
+                ></el-date-picker>
+                <el-select v-model="planFinishTime.hour"
+                       placeholder="小时"
+                       size="small"
+                       clearable style="width:120px">
+                  <el-option v-for="(item,index) in hourArr"
+                            :label="item.value"
+                            :key="item.index"
+                            :value="item.status">
+                  </el-option>
+                </el-select>
+                <el-select v-model="planFinishTime.minute"
+                        placeholder="分钟"
+                        size="small"
+                        clearable style="width:120px">
+                  <el-option v-for="(item,index) in minuteArr"
+                            :label="item.value"
+                            :key="item.index"
+                            :value="item.status">
+                  </el-option>
+              </el-select>
+        </el-form-item>
+        <el-form-item label="区域" label-width="140px" prop="value" class="trBox">
+            <el-select v-model="planFormAreas"
+                       placeholder="请选择"
+                       size="small"
+                       clearable
+                       @change="changeAdd">
+              <el-option v-for="(item,index) in areas"
+                       :label="item.name"
+                       :key="index"
+                       :value="item.id">
+              </el-option>
+            </el-select>
+        </el-form-item>
+        <el-form-item label="生产线号" label-width="140px" prop="value" class="trBox">
+            <el-select v-model="planForm.producelineNo"
+                       placeholder="请选择"
+                       size="small"
+                       clearable>
+                <el-option v-for="(item,index) in stationAdd"
+                       :label="item.name"
+                       :key="index"
+                       :value="item.id"></el-option>
+            </el-select>
+        </el-form-item>
+        <el-form-item label="请选择类型" label-width="140px" prop="value" class="trBox">
+            <el-select v-model="planForm.typeId"
+                       placeholder="请选择"
+                       size="small"
+                       clearable>
+              <el-option v-for="(item,index) in types"
+                         :label="item.value"
+                         :key="item.index"
+                         :value="item.status">
+              </el-option>
+            </el-select>
+        </el-form-item>
+        <el-form-item label="是否使用已有产品" label-width="140px" prop="value" class="trBox">
+            <el-select v-model="planForm.useProduct"
+                       placeholder="请选择"
+                       size="small"
+                       clearable>
+              <el-option v-for="(item,index) in chanpinFlag"
+                         :label="item.value"
+                         :key="item.index"
+                         :value="item.status">
+              </el-option>
+            </el-select>
+        </el-form-item>
+        <el-form-item label="产品" label-width="140px" prop="value" class="trBox" v-if="planForm.useProduct==0">
+            <el-select v-model="planForm.productName"
+                       placeholder="请选择"
+                       size="small"
+                       clearable>
+              <el-option v-for="(item,index) in product"
+                         :label="item.name"
+                         :key="item.index"
+                         :value="item.name">
+              </el-option>
+            </el-select>
+        </el-form-item>
+        <el-form-item label="产品" label-width="140px" prop="name" v-if="planForm.useProduct==1">
+          <el-input size="small" type="text" v-model="planForm.productName"></el-input>
+        </el-form-item>
+        <el-form-item label="模具" label-width="140px" prop="value" class="trBox" >
+            <el-select v-model="planForm.mouldType"
+                       placeholder="请选择"
+                       size="small"
+                       clearable>
+              <el-option v-for="(item,index) in mjArr"
+                         :label="item.value"
+                         :key="item.index"
+                         :value="item.status">
+              </el-option>
+            </el-select>
+        </el-form-item>
+        <el-form-item label="原材料" label-width="140px" prop="name">
+          <el-input size="small" type="text" v-model="planForm.material" class="inputPlan"></el-input>
+        </el-form-item>
+        <el-form-item label="料箱" label-width="140px" prop="name">
+          <el-input size="small" type="text" v-model="planForm.materialbox" class="inputPlan"></el-input>
+        </el-form-item>
+        <el-form-item label="料箱描述" label-width="140px" prop="name">
+          <el-input size="small" type="text" v-model="planForm.describeBox" class="inputPlan"></el-input>
+        </el-form-item>
+        <el-form-item label="件/箱" label-width="140px" prop="name">
+          <el-input size="small" type="text" v-model="planForm.pieces" class="inputPlan"></el-input>
+        </el-form-item>
+        <el-form-item label="运行时间" label-width="140px" prop="name">
+          <el-input size="small" type="text" v-model="planForm.runTime" class="inputPlan"></el-input>
+        </el-form-item>
+        <el-form-item label="批次生产数量" label-width="140px" prop="name">
+          <el-input size="small" type="text" v-model="planForm.produceNum" class="inputPlan"></el-input>
+        </el-form-item>
+      </el-form>
+      <el-row style="display: flex;justify-content: center;margin-top: 50px;">
+        <el-button type="primary" size="small" style="margin-right: 40px;" @click="confirm_plan">确定</el-button>
+        <el-button type="info" size="small" @click="planStatus = false">取消</el-button>
+      </el-row>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import Pagination from '@/components/Pagination'
+  import { selectPage,productPlanSet,productPlanAdd,productPlanUpdate,productPlanDelete,getAllProduct,productPlanInfo } from '@/api/plan'
+  import { getArea,getStationByDeptId } from '@/api/common'
+  // 一页数据量
+  const pageSize = 8
+  export default {
+    name: "plan",
+    components: {
+      Pagination
+    },
+    data() {
+      return {
+        checkBoxData: [],
+        "areas": [],
+        "product":[],
+        "station": [],
+        "stationAdd": [],
+        "planFormAreas":"",
+        "planFinishTime":{
+          date:"",
+          hour:"",
+          minute:""
+        },
+        clickTemplate: true,
+        searchareaId:'',
+        // 搜索数据
+        searchData: {
+          "producelineNo": "",
+          "page": 1,
+          "size": pageSize
+        },
+        // 类型
+        types: [
+          {'status':'0' , 'value': '计划停机'},
+          {'status':'1' , 'value': '调试'},
+          {'status':'2' , 'value': '生产'},
+          {'status':'3' , 'value': '休息'}
+        ],
+        // 类型
+        chanpinFlag: [
+          {'status':0 , 'value': '是'},
+          {'status':1 , 'value': '否'}
+        ],
+        //小时
+        hourArr:[
+          {'status':'00' , 'value': '00'},
+          {'status':'01' , 'value': '01'},
+          {'status':'02' , 'value': '02'},
+          {'status':'03' , 'value': '03'},
+          {'status':'04' , 'value': '04'},
+          {'status':'05' , 'value': '05'},
+          {'status':'06' , 'value': '06'},
+          {'status':'07' , 'value': '07'},
+          {'status':'08' , 'value': '08'},
+          {'status':'09' , 'value': '09'},
+          {'status':'10' , 'value': '10'},
+          {'status':'11' , 'value': '11'},
+          {'status':'12' , 'value': '12'},
+          {'status':'13' , 'value': '13'},
+          {'status':'14' , 'value': '14'},
+          {'status':'15' , 'value': '15'},
+          {'status':'16' , 'value': '16'},
+          {'status':'17' , 'value': '17'},
+          {'status':'18' , 'value': '18'},
+          {'status':'19' , 'value': '19'},
+          {'status':'20' , 'value': '20'},
+          {'status':'21' , 'value': '21'},
+          {'status':'22' , 'value': '22'},
+          {'status':'23' , 'value': '23'}
+        ],
+        //分钟
+        minuteArr:[
+          {'status':'00' , 'value': '00'},
+          {'status':'30' , 'value': '30'},
+        ],
+        //模具
+        mjArr: [
+          {'status':0 , 'value': '空'},
+          {'status':1 , 'value': '绿色'},
+          {'status':2 , 'value': '黄色'},
+          {'status':3 , 'value': '红色'}
+        ],
+        // 计划数据
+        planData: [],
+        // 新增计划弹窗
+        planStatus: false,
+        // 分页参数
+        pageInfo: {
+          currentPage: 1,
+          pageSize: pageSize,
+          total: 5
+        },
+        planForm: {
+          	"describeBox": "",
+            "id": "",
+            "material": "",
+            "materialbox": "",
+            "mouldType": "",
+            "pieces": "",
+            "planFinishTime": "",
+            "produceNum": "",
+            "producelineNo": "",
+            "productName": "",
+            "runTime": "",
+            "typeId": "",
+            "useProduct": ""
+        },
+        isAdd:true
+      }
+    },
+    created() {
+      this.get_plan_list()
+      this.get_area()
+      this.get_product()
+    },
+    methods:{
+      // 获取所有区域
+      get_area() {
+        getArea().then(res => {
+          this.areas = res.data
+        })
+      },
+      // 获取所有产品
+      get_product() {
+        getAllProduct().then(res => {
+          this.product = res.data
+        })
+      },
+      //切换区域
+      change() {
+        getStationByDeptId({'id':this.searchareaId}).then(res=> {
+          this.station = res.data
+        })
+        this.clickTemplate = false
+      },
+      //切换区域添加
+      changeAdd() {
+        getStationByDeptId({'id':this.planFormAreas}).then(res=> {
+          this.stationAdd = res.data
+        })
+      },
+      //勾选
+      changeFun(val) {
+          this.checkBoxData = val;
+      },
+      // 计划列表
+      get_plan_list() {
+        selectPage(this.searchData).then(res=> {
+          this.planData = res.data.row
+          this.pageInfo.total = parseInt(res.data.total)
+        })
+      },
+      // 搜索
+      search() {
+        selectPage(this.searchData).then(res=> {
+          this.planData = res.data.row
+        })
+      },
+      // 显示新增计划弹窗
+      add_plan() {
+        this.isAdd=true
+        this.planStatus = true
+        Object.assign(this.$data.planForm, this.$options.data().planForm)
+      },
+      // 执行添加
+      confirm_plan() {
+        var that=this
+        if(this.planFinishTime.date==""||this.planFinishTime.hour==""||this.planFinishTime.minute==""){
+          this.$message({
+              type: 'info',
+              message: '请选择日期'
+          });  
+          return false;
+        }
+        if(this.planFormAreas==""){
+          this.$message({
+              type: 'info',
+              message: '请区域'
+          });  
+          return false;
+        }
+        if(this.planForm.producelineNo==""){
+          this.$message({
+              type: 'info',
+              message: '请选择生产线号'
+          });  
+          return false;
+        }
+        if(this.planForm.typeId==""){
+          this.$message({
+              type: 'info',
+              message: '请选择类型'
+          });  
+          return false;
+        }
+         if(this.planForm.productName==""){
+          this.$message({
+              type: 'info',
+              message: '请设置产品'
+          });  
+          return false;
+        }
+        
+        this.planForm.planFinishTime=this.planFinishTime.date+" "+this.planFinishTime.hour+":"+this.planFinishTime.minute+":00"
+        if(this.isAdd){
+          productPlanAdd(this.planForm).then(res=> {
+            this.$message({
+                type: 'info',
+                message: '保存成功'
+            });  
+            that.planStatus = false;
+            that.get_plan_list()
+          })
+        }else{
+          //this.planForm.run_time="2020-04-14 06:00:00"
+          productPlanUpdate(this.planForm).then(res=> {
+            this.$message({
+                type: 'info',
+                message: '修改成功'
+            });  
+            that.planStatus = false;
+            that.get_plan_list()
+          })
+        }
+      },
+      // 编辑
+      update(index) {
+        console.log(index)
+        var that=this
+        this.isAdd=false
+        var postData={
+          id:index.row.id
+        }
+        productPlanInfo(postData).then(res=> {
+          that.planStatus = true
+          that.planForm=res.data
+          var time=that.planForm.planFinishTime.split(" ")[1]
+          var date=that.planForm.planFinishTime.split(" ")[0]
+          var hour=time.split(":")[0]
+          var minute=time.split(":")[1]
+          this.planFinishTime={
+            date:date,
+            hour:hour,
+            minute:minute
+          }
+        })
+        //this.$router.push({ path: '/addplan', query:{ id:index.row.id, kind: 3,type: this.planData[index.$index].type}})
+      },
+      //设置当前产品
+      setNow(data){
+        var that=this
+        this.$confirm('确定设置当前产品', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+              var postData={
+                "id": data.row.id,
+              	"num": 0
+              }
+              productPlanSet(postData).then(res=> {
+                that.get_plan_list()
+              })
+            }).catch(() => {
+                this.$message({
+                    type: 'info',
+                    message: '已取消'
+                });          
+            });
+      },
+      //设置下个产品
+      setNext(data){
+        var that=this
+        this.$confirm('确定设置下个产品', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+              var postData={
+                "id": data.row.id,
+              	"num": 1
+              }
+              productPlanSet(postData).then(res=> {
+                that.get_plan_list()
+              })
+            }).catch(() => {
+                this.$message({
+                    type: 'info',
+                    message: '已取消'
+                });          
+            });
+      },
+      // 删除
+      delPlan(index) {
+        var that=this
+        var idArr=[]
+        for(var i=0;i<this.checkBoxData.length;i++){
+          idArr.push(Number(this.checkBoxData[i].id))
+        }
+        productPlanDelete(idArr).then(res=> {
+          if(res.status === '20000'){
+            this.$message.success('删除成功')
+            that.get_plan_list()
+          }
+        })
+      },
+      // 获取点击页数
+      get_page(val) {
+        this.searchData.page = val
+        this.get_plan_list()
+      }
+    }
+  }
+</script>
+
+<style scoped>
+  .user-search {
+    margin-top: 20px;
+    display: flex;
+    align-items: center;
+  }
+  .nowBox{
+    background: #1bb394;
+    color: #fff;
+    padding: 4px 15px;
+  }
+  .nextBox{
+    background: #f8ac5a;
+    color: #fff;
+    padding: 4px 15px;
+  }
+  .trBox{
+    width: 100%;
+  }
+  .inputPlan{
+    width: 60%
+  }
+</style>