Browse Source

重构主生产计划部分代码

pull/155/head
xuxiaoming 3 years ago
parent
commit
76aed9db7e
1 changed files with 166 additions and 167 deletions
  1. +166
    -167
      src/views/productionPlanning/customerForecastDemandReview/resourceContent/index.vue

+ 166
- 167
src/views/productionPlanning/customerForecastDemandReview/resourceContent/index.vue View File

@ -1,177 +1,176 @@
<template>
<ContentContainer class="homepage-beta-wrapper">
<el-tabs v-model="activeName" type="card" >
<el-tab-pane label="资源负荷" name="evaluation">
<Evaluation @handlePublic="handlePublic" />
</el-tab-pane>
<el-tab-pane label="资源产能评估" name="resourceLoad">
<ResourceLoad />
</el-tab-pane>
</el-tabs>
</ContentContainer>
<ContentContainer class="homepage-beta-wrapper">
<el-tabs v-model="activeName"
type="card">
<el-tab-pane label="资源负荷"
name="evaluation">
<Evaluation />
</el-tab-pane>
<el-tab-pane label="资源产能评估"
name="resourceLoad">
<ResourceLoad />
</el-tab-pane>
</el-tabs>
</ContentContainer>
</template>
<script>
import Evaluation from './evaluation'
import ResourceLoad from './resourceLoad'
import { getMpsPlan, changeMpsPlan } from "@/server/productionPlanning/customerForecastDemandReview";
import { mapState, mapMutations } from 'vuex'
import Evaluation from './evaluation'
import ResourceLoad from './resourceLoad'
import { getMpsPlan, changeMpsPlan,saveMpsPlan} from "@/server/productionPlanning/customerForecastDemandReview";
import { mapState,mapMutations } from 'vuex'
export default {
components: {
//
Evaluation,
//
ResourceLoad
},
data() {
return {
activeName: 'evaluation'
}
},
export default {
components:{
//
Evaluation,
//
ResourceLoad
},
data() {
return {
activeName: 'evaluation'
}
},
computed: {
...mapState("customerForecastDemandReview", [
"artId",
"resourceId",
"resourceType",
"changeMpsPlanParam",
"evaluationSecondResourceLoading",
"evaluationMainResourceLoading",
"evaluationSecondResourceData",
"evaluationMainResourceData",
"selectArticleDemandRow"
])
},
watch: {
changeMpsPlanParam:{
handler(param) {
if(Object.keys(param).length==0) {
return
}
this.SET_evaluationSecondResourceLoading(true)
this.SET_evaluationMainResourceLoading(true)
this.INIT_evaluationMainResourceData()
this.INIT_evaluationSecondResourceListData()
this.SET_evaluationLoadPercent(true)
changeMpsPlan(param).then( ({ data = []}) => {
this.SET_evaluationMainResourceLoading(false)
this.SET_evaluationSecondResourceLoading(false)
this.SET_evaluationMainResourceData(data['ArticleResourceMpsGroupLst']|| [])
this.SET_evaluationSecondResourceListData(data['ArticleSecondResourceMpsGroupLst']|| [])
this.SET_articleDemandData(data['CustArtStockItem']|| [])
let row = this.selectArticleDemandRow
this.INIT_selectArticleDemandRow()
this.SET_selectArticleDemandRow(row)
this.SET_evaluationLoadPercent(false)
} ).catch(()=> {
this.SET_evaluationMainResourceLoading(false)
this.SET_evaluationSecondResourceLoading(false)
this.SET_evaluationLoadPercent(false)
})
},
deep:true
},
resourceId:function(value) {
if(value == '' || value == undefined || this.resourceType == -1) {
return
}
this.INIT_evaluationSecondResourceListData()
this.INIT_evaluationMainResourceData()
if(this.activeName == "evaluation") {
this.SET_evaluationSecondResourceLoading(true)
this.SET_evaluationMainResourceLoading(true)
computed: {
...mapState("customerForecastDemandReview", [
"artId",
"resourceId",
"resourceType",
"changeMpsPlanParam",
"evaluationSecondResourceLoading",
"evaluationMainResourceLoading",
"evaluationSecondResourceData",
"evaluationMainResourceData",
"selectArticleDemandRow"
])
},
watch: {
changeMpsPlanParam: {
handler(param) {
if (Object.keys(param).length == 0) {
return
}
this.initEvaluationSecondResource()
this.setLoading(true)
changeMpsPlan(param).then(({ data = [] }) => {
this.setLoading(false)
this.setEvaluationSecondResource(data)
this.SET_evaluationLoadPercent(true)
getMpsPlan({[this.resourceType==1?"resouceid":"secondresourceid"] : value}).then( ({data = [] }) => {
this.SET_evaluationMainResourceData(data['ArticleResourceMpsGroupLst']|| [])
this.SET_evaluationSecondResourceListData(data['ArticleSecondResourceMpsGroupLst']|| [])
this.SET_evaluationSecondResourceLoading(false)
this.SET_evaluationMainResourceLoading(false)
this.SET_evaluationLoadPercent(false)
if(this.evaluationMainResourceData.length == 0) {
this.$message({
type:"error",
message:"主资源负荷数据为空"
})
}
}).catch(() => {
this.SET_evaluationSecondResourceLoading(false)
this.SET_evaluationMainResourceLoading(false)
this.SET_evaluationLoadPercent(false)
})
}
},
artId:function(value){
if(value == '' || value == undefined) {
return
}
this.INIT_evaluationSecondResourceListData()
this.INIT_evaluationMainResourceData()
if(this.activeName == "evaluation") {
this.SET_evaluationSecondResourceLoading(true)
this.SET_evaluationMainResourceLoading(true)
getMpsPlan({artid : value}).then( ({data = [] }) => {
this.SET_evaluationMainResourceData(data['ArticleResourceMpsGroupLst']|| [])
this.SET_evaluationSecondResourceListData(data['ArticleSecondResourceMpsGroupLst']|| [])
this.SET_evaluationSecondResourceLoading(false)
this.SET_evaluationMainResourceLoading(false)
if(this.evaluationMainResourceData.length == 0) {
this.$message({
type:"error",
message:"主资源负荷数据为空"
})
}
}).catch(() => {
this.SET_evaluationSecondResourceLoading(false)
this.SET_evaluationMainResourceLoading(false)
})
}
}
},
methods: {
...mapMutations("customerForecastDemandReview",[
"SET_evaluationSecondResourceLoading",
"SET_evaluationMainResourceLoading",
"SET_evaluationSecondResourceData",
"SET_evaluationMainResourceData",
"INIT_evaluationSecondResourceData",
"INIT_evaluationMainResourceData",
"SET_articleDemandData",
"SET_selectArticleDemandRow",
"INIT_selectArticleDemandRow",
"SET_evaluationSecondResourceListData",
"INIT_evaluationSecondResourceListData",
"SET_evaluationLoadPercent"
]),
//
handlePublic(param){
param.data = JSON.stringify(param.data);
saveMpsPlan(param).then( ({ code}) => {
if( code == 200) {
this.$message({ showClose: true, message: "发布成功", type: "success" });
this.SET_evaluationMainResourceData(this.evaluationSecondResourceData)
}
});
},
},
}
this.SET_articleDemandData(data['CustArtStockItem'] || [])
let row = this.selectArticleDemandRow
this.INIT_selectArticleDemandRow()
this.SET_selectArticleDemandRow(row)
}).catch(() => {
this.setLoading(false)
})
},
deep: true
},
resourceId: function (value) {
if (value == '' || value == undefined || this.resourceType == -1) {
return
}
this.initEvaluationSecondResource()
if (this.activeName == "evaluation") {
this.setLoading(true)
getMpsPlan({
[this.resourceType == 1 ? "resouceid" : "secondresourceid"]: value
}).then(({ data = [] }) => {
this.setEvaluationSecondResource(data)
this.setLoading(false)
if (this.evaluationMainResourceData.length == 0) {
this.$message({
type: "error",
message: "主资源负荷数据为空"
})
}
}).catch(() => {
this.setLoading(false)
})
}
},
artId: function (value) {
if (value == '' || value == undefined) {
return
}
this.initEvaluationSecondResource()
if (this.activeName == "evaluation") {
this.setLoading(true)
getMpsPlan({ artid: value }).then(({ data = [] }) => {
this.setEvaluationSecondResource(data)
this.setLoading(false)
if (this.evaluationMainResourceData.length == 0) {
this.$message({
type: "error",
message: "主资源负荷数据为空"
})
}
}).catch(() => {
this.setLoading(false)
})
}
}
},
methods: {
...mapMutations("customerForecastDemandReview", [
"SET_evaluationSecondResourceLoading",
"SET_evaluationMainResourceLoading",
"SET_evaluationSecondResourceData",
"SET_evaluationMainResourceData",
"INIT_evaluationSecondResourceData",
"INIT_evaluationMainResourceData",
"SET_articleDemandData",
"SET_selectArticleDemandRow",
"INIT_selectArticleDemandRow",
"SET_evaluationSecondResourceListData",
"INIT_evaluationSecondResourceListData",
"SET_evaluationLoadPercent"
]),
setEvaluationSecondResource(data) {
this.SET_evaluationMainResourceData(data['ArticleResourceMpsGroupLst'] || [])
this.SET_evaluationSecondResourceListData(data['ArticleSecondResourceMpsGroupLst'] || [])
},
initEvaluationSecondResource() {
this.INIT_evaluationSecondResourceListData()
this.INIT_evaluationMainResourceData()
},
setLoading(flag) {
this.SET_evaluationSecondResourceLoading(flag)
this.SET_evaluationMainResourceLoading(flag)
this.SET_evaluationLoadPercent(flag)
},
//
// handlePublic(param) {
// param.data = JSON.stringify(param.data);
// saveMpsPlan(param).then(({ code }) => {
// if (code == 200) {
// this.$message({ showClose: true, message: "", type: "success" });
// this.SET_evaluationMainResourceData(this.evaluationSecondResourceData)
// }
// });
// },
},
}
</script>
<style lang="less">
.homepage-beta-wrapper {
height: 100%;
overflow-y: auto;
overflow-x: auto;
padding: 0 !important;
.el-tabs {
el-tabs__header{
margin:0;
}
.el-tabs__content {
overflow: inherit;
height: calc(100% - 60px) !important;
}
}
}
.homepage-beta-wrapper {
height: 100%;
overflow-y: auto;
overflow-x: auto;
padding: 0 !important;
.el-tabs {
el-tabs__header {
margin: 0;
}
.el-tabs__content {
overflow: inherit;
height: calc(100% - 60px) !important;
}
}
}
</style>

Loading…
Cancel
Save