|
|
@@ -2,7 +2,7 @@
|
|
|
<div>
|
|
|
<el-button size="mini" type="primary" @click="onShow(drawer = true)">编 辑</el-button>
|
|
|
<el-drawer
|
|
|
- title="我是标题"
|
|
|
+ title="新建阶段"
|
|
|
:visible.sync="drawer"
|
|
|
direction="rtl"
|
|
|
append-to-body
|
|
|
@@ -29,11 +29,11 @@
|
|
|
|
|
|
<div class="inline-16">
|
|
|
<el-checkbox disabled v-model="form.onparties" :true-label="1" :false-label="0" @change="onPartiesChange">关联客户对象</el-checkbox>
|
|
|
- <!-- <AssociateCustomerObject ref="onparties" :data="form" class="inline-16" style="margin-left: 10px" @selectObject="selectObject"></AssociateCustomerObject> -->
|
|
|
+ <!-- <AssociateCustomerObject ref="onparties" :data="form" class="inline-16" style="margin-left: 10px" @selectObject="selectFormObject"></AssociateCustomerObject> -->
|
|
|
</div>
|
|
|
<div class="inline-16">
|
|
|
<el-checkbox disabled v-model="form.onstage" :true-label="1" :false-label="0" style="font-size: 14px" @change="onOnstageChange">关联项目阶段</el-checkbox>
|
|
|
- <!-- <AssociatedProjectPhases ref="onstage" :data="form" class="inline-16" style="margin-left: 10px" @selectStage="selectStage"></AssociatedProjectPhases> -->
|
|
|
+ <!-- <AssociatedProjectPhases ref="onstage" :data="form" class="inline-16" style="margin-left: 10px" @selectStage="selectFormStage"></AssociatedProjectPhases> -->
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -43,13 +43,12 @@
|
|
|
<div class="normal-margin">
|
|
|
<div class="normal-margin flex-align-center flex-between">
|
|
|
<p class="normal-title">评估项</p>
|
|
|
- <!-- <el-button type="primary" size="small" @click="addOptions">添加任务</el-button> -->
|
|
|
+ <el-button type="primary" size="small" @click="addOptions">添加任务</el-button>
|
|
|
</div>
|
|
|
<el-table
|
|
|
:data="form.projtaskmag_options"
|
|
|
style="width: 100%"
|
|
|
@row-click="rowClick"
|
|
|
- :row-class-name="tableRowClassName"
|
|
|
highlight-current-row
|
|
|
border>
|
|
|
<el-table-column
|
|
|
@@ -85,13 +84,13 @@
|
|
|
width="100"
|
|
|
label="操作">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="text" size="mini" :disabled="form.projtaskmag_options.length === 1" @click="deleteOption(scope.$index)">删除</el-button>
|
|
|
+ <el-button type="text" size="mini" :disabled="form.projtaskmag_options.length === 1" @click="deleteOptions(scope.$index)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</div>
|
|
|
- <div>
|
|
|
- <p class="normal-title normal-margin">关联设置({{activeOptions}})</p>
|
|
|
+ <div v-if="act_projtask">
|
|
|
+ <p class="normal-title normal-margin">关联设置({{act_projtask?act_projtask.optionname:""}})</p>
|
|
|
<el-table
|
|
|
:data="optionscore"
|
|
|
border
|
|
|
@@ -112,8 +111,7 @@
|
|
|
prop="score"
|
|
|
label="分值">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-input v-model="scope.row.score" placeholder="" @change="onScoreChange"></el-input>
|
|
|
- <!-- <input type="text" v-model="scope.row.score" @input="onScoreChange"> -->
|
|
|
+ <el-input v-model="scope.row.score" placeholder=""></el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -147,13 +145,18 @@
|
|
|
"onstage": 0,
|
|
|
"projtaskmag_options": []
|
|
|
},
|
|
|
- oldData:[],
|
|
|
- oldStage:[],
|
|
|
optionscore:[],
|
|
|
- optionscoreStr:'',
|
|
|
- n_index:null,
|
|
|
- activeOptions:null
|
|
|
+
|
|
|
+ partiesType:[],
|
|
|
+ projectStage:[],
|
|
|
+
|
|
|
+ act_projtask:null,
|
|
|
+
|
|
|
+ objects: new Map(),
|
|
|
+ stages: new Map(),
|
|
|
+ relateForm: []
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
methods:{
|
|
|
onShow () {
|
|
|
@@ -167,164 +170,203 @@
|
|
|
}
|
|
|
})
|
|
|
this.form = res.data
|
|
|
- },
|
|
|
- selectObject (val) {
|
|
|
- this.oldData = val
|
|
|
- if (val.length === 0) {
|
|
|
- this.form.onparties = 0
|
|
|
- } else {
|
|
|
- if (this.oldStage.length > 0) {
|
|
|
- let arr = []
|
|
|
- this.oldData.forEach(e=>{
|
|
|
- this.oldStage.forEach(vl=>{
|
|
|
- arr.push({
|
|
|
- sa_projtaskmag_optionscoreid:0,
|
|
|
- partiestype:e.partiestype,
|
|
|
- stagename:vl.stagename,
|
|
|
- sa_projstagemagid:vl.sa_projstagemagid,
|
|
|
- score:0
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- this.optionscore = arr.sort()
|
|
|
- } else {
|
|
|
- this.optionscore = val
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- selectStage (val) {
|
|
|
- this.oldStage = val
|
|
|
- if (val.length === 0) {
|
|
|
- this.form.onstage = 0
|
|
|
- } else {
|
|
|
- if (this.oldData.length > 0) {
|
|
|
- let arr = []
|
|
|
- this.oldData.forEach(e=>{
|
|
|
- this.oldStage.forEach(vl=>{
|
|
|
- arr.push({
|
|
|
- sa_projtaskmag_optionscoreid:0,
|
|
|
- partiestype:e.partiestype,
|
|
|
- stagename:vl.stagename,
|
|
|
- sa_projstagemagid:vl.sa_projstagemagid,
|
|
|
- score:0
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- this.optionscore = arr.sort()
|
|
|
- } else {
|
|
|
- this.optionscore = val
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- rowClick (row, column, event) {
|
|
|
- try {
|
|
|
- this.n_index = row.index
|
|
|
- this.activeOptions = this.form.projtaskmag_options[this.n_index].optionname
|
|
|
- this.optionscore = this.form.projtaskmag_options[row.index].projtaskmag_optionscore
|
|
|
- } catch (error) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- onScoreChange (row) {
|
|
|
- if (!this.activeOptions) return this.$message({
|
|
|
- message:'请先点击要设置的任务行',
|
|
|
- type:'error'
|
|
|
+ this.form.projtaskmag_options[0].projtaskmag_optionscore.forEach(e=>{
|
|
|
+ this.objects.set(e.partiestype,{ partiestype: e.partiestype})
|
|
|
+ this.stages.set(e.stagename,{stagename: e.stagename, sa_projstagemagid: e.sa_projstagemagid})
|
|
|
+ this.partiesType.push({
|
|
|
+ partiestype: e.partiestype
|
|
|
+ })
|
|
|
+ this.projectStage.push({
|
|
|
+ stagename: e.stagename,
|
|
|
+ sa_projstagemagid: e.sa_projstagemagid
|
|
|
+ })
|
|
|
})
|
|
|
- this.form.projtaskmag_options[this.n_index].projtaskmag_optionscore = this.optionscore
|
|
|
},
|
|
|
- arraySpanMethod({ row, column, rowIndex, columnIndex }) {
|
|
|
- // 合并行列产品名字相同合并(计算组长度以内的列,需要进行合并操作的列)
|
|
|
- let mergeLength = 1;//需要进行横纵合并的列
|
|
|
- if (columnIndex < mergeLength) {
|
|
|
- let finArray = [1,1];
|
|
|
- // 处理行数据
|
|
|
- let cgname = Object.keys(row)[columnIndex]
|
|
|
- console.log(cgname,'---')
|
|
|
- // let cgname = 'value'
|
|
|
- if(rowIndex === 0 || row[cgname] !== this.optionscore[rowIndex-1][cgname]){
|
|
|
- let rowspan = 1;
|
|
|
- //计算需要进行合并操作的行
|
|
|
- for(let i=0; i<this.optionscore.length-1; i++){
|
|
|
- // 只合并连续的
|
|
|
- if(this.optionscore[i][cgname] === row[cgname] && this.optionscore[i+1][cgname] === row[cgname]){
|
|
|
- rowspan ++;
|
|
|
- }
|
|
|
- }
|
|
|
- finArray[0] = rowspan;
|
|
|
- }else {
|
|
|
- finArray[0] = 0;
|
|
|
- }
|
|
|
+ selectFormObject(val) {
|
|
|
+ this.partiesType = val
|
|
|
|
|
|
- // 处理列数据
|
|
|
- let colkeys = Object.keys(row);
|
|
|
- let cgvalue = Object.values(row)[columnIndex]
|
|
|
- if(columnIndex ===0 || row[colkeys[columnIndex-1]] !== row[colkeys[columnIndex]]){
|
|
|
- let colspan = 1;
|
|
|
- //计算需要进行合并操作的列
|
|
|
- for(let i=columnIndex; i<mergeLength; i++) {
|
|
|
- // 只合并连续的
|
|
|
- if (row[colkeys[i]]===cgvalue && row[colkeys[i+1]]===cgvalue && i+1<mergeLength) {
|
|
|
- colspan ++;
|
|
|
- }
|
|
|
- }
|
|
|
- finArray[1] = colspan;
|
|
|
- } else {
|
|
|
- finArray[1] = 0;
|
|
|
- }
|
|
|
- return finArray
|
|
|
- }
|
|
|
+ this.selectObject(val);
|
|
|
},
|
|
|
- refreshTable() {
|
|
|
- this.show = false
|
|
|
- setTimeout(() => {
|
|
|
- this.show = true
|
|
|
- }, 1000);
|
|
|
+ selectFormStage(val) {
|
|
|
+ this.projectStage = val
|
|
|
+
|
|
|
+ this.selectStage(val);
|
|
|
},
|
|
|
- onPartiesChange (val) {
|
|
|
- if (val === 1) {
|
|
|
- let arr = []
|
|
|
+ // 选择客户对象
|
|
|
+ selectObject (val) {
|
|
|
+ // val.length === 0?this.form.onparties = 0:""
|
|
|
|
|
|
- this.$refs.onparties.drawer = true
|
|
|
- this.optionscore = arr.sort()
|
|
|
- } else {
|
|
|
- this.oldData = []
|
|
|
- const res = new Map();
|
|
|
- this.optionscore = this.optionscore.filter((item) => !res.has(item['stagename']) && res.set(item['stagename'], 1));
|
|
|
- this.form.projtaskmag_options.forEach(e=>{
|
|
|
- e.projtaskmag_optionscore = this.optionscore
|
|
|
+
|
|
|
+ // // 表格插入数据
|
|
|
+ // this.optionscore = val.map(e=>{
|
|
|
+ // return {
|
|
|
+ // partiestype:e.partiestype,
|
|
|
+ // stagename:''
|
|
|
+ // }
|
|
|
+ // // })
|
|
|
+ // (e == 0 && val.length === 0) ? this.form.onparties = 0 : ""
|
|
|
+ this.objects = new Map()
|
|
|
+ val.forEach(v => this.objects.set(v.partiestype, v))
|
|
|
+ console.log('try calculate')
|
|
|
+ this.optionscore = this.calculate(this.optionscore)
|
|
|
+ this.act_projtask?this.act_projtask.projtaskmag_optionscore = this.optionscore:''
|
|
|
+
|
|
|
+ this.form.projtaskmag_options
|
|
|
+ .filter(task => task != this.act_projtask)
|
|
|
+ .map(task => {
|
|
|
+ console.log(`88888 re-build optionscore for task ${task.optionname}`)
|
|
|
+ return task
|
|
|
})
|
|
|
- }
|
|
|
+ .forEach(task => task.projtaskmag_optionscore = this.calculate(task.projtaskmag_optionscore))
|
|
|
},
|
|
|
- onOnstageChange (val) {
|
|
|
- if (val === 1) {
|
|
|
- this.$refs.onstage.drawer = true
|
|
|
+ // 选择项目阶段
|
|
|
+ selectStage (val) {
|
|
|
+
|
|
|
+ // (e == 0 && val.length === 0) ? this.form.onparties = 0 : ""
|
|
|
+ this.stages = new Map()
|
|
|
+ val.forEach(v => this.stages.set(v.stagename, v))
|
|
|
+ this.optionscore = this.calculate(this.optionscore)
|
|
|
+ this.act_projtask?this.act_projtask.projtaskmag_optionscore = this.optionscore:''
|
|
|
+
|
|
|
+ this.form.projtaskmag_options
|
|
|
+ .filter(task => task != this.act_projtask)
|
|
|
+ .map(task => {
|
|
|
+ console.log(`88888 re-build optionscore for task ${task.optionname}`)
|
|
|
+ return task
|
|
|
+ })
|
|
|
+ .forEach(task => task.projtaskmag_optionscore = this.calculate(task.projtaskmag_optionscore))
|
|
|
+ // // 判断是否选中数据,若无数据则自动取消勾选
|
|
|
+ // val.length === 0?this.form.onstage = 0:""
|
|
|
+ // this.projectStage = val
|
|
|
+ // // 判断客户对象是否有数据,若有数据指循环插入阶段数据
|
|
|
+ // if (this.partiesType.length > 0) {
|
|
|
+ // let arr = []
|
|
|
+ // val.forEach(ele => {
|
|
|
+ // this.optionscore.forEach(opt => {
|
|
|
+ // arr.push({
|
|
|
+ // "sa_projtaskmag_optionscoreid":0,
|
|
|
+ // "partiestype": opt.partiestype,
|
|
|
+ // "stagename":ele.stagename,
|
|
|
+ // "sa_projstagemagid": ele.sa_projstagemagid,
|
|
|
+ // "score": 0
|
|
|
+ // })
|
|
|
+ // });
|
|
|
+ // })
|
|
|
+ // this.optionscore = this.tool.sortArr(arr,'partiestype')
|
|
|
+ // } else {
|
|
|
+ // this.optionscore = val.map(e=>{
|
|
|
+ // return {
|
|
|
+ // partiestype:e.partiestype,
|
|
|
+ // stagename:e.stagename,
|
|
|
+ // sa_projstagemagid: ele.sa_projstagemagid,
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ calculate(optionscore) {
|
|
|
+ var list = [];
|
|
|
+ if (this.stages == null || this.stages.size == 0){
|
|
|
+ this.objects.forEach((item, key) => {
|
|
|
+ list.push({
|
|
|
+ sa_projtaskmag_optionscoreid: 0,
|
|
|
+ partiestype: item.partiestype,
|
|
|
+ stagename : '',
|
|
|
+ score: optionscore ? this.getScore(optionscore, item.partiestype, '') : 0
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else if (this.objects == null || this.objects.size == 0) {
|
|
|
+ this.stages.forEach((item, key) => {
|
|
|
+ list.push({
|
|
|
+ sa_projtaskmag_optionscoreid: 0,
|
|
|
+ partiestype: '',
|
|
|
+ stagename: item.stagename,
|
|
|
+ sa_projstagemagid: item.sa_projstagemagid,
|
|
|
+ score: optionscore ? this.getScore(optionscore, '', item.stagename) : 0
|
|
|
+ })
|
|
|
+ })
|
|
|
} else {
|
|
|
- this.oldStage = []
|
|
|
- const res = new Map();
|
|
|
- this.optionscore = this.optionscore.filter((item) => !res.has(item['partiestype']) && res.set(item['partiestype'], 1));
|
|
|
- this.form.projtaskmag_options.forEach(e=>{
|
|
|
- e.projtaskmag_optionscore = this.optionscore
|
|
|
+ this.objects.forEach((objItem, objKey) => {
|
|
|
+ this.stages.forEach((stageItem, stageKey) => {
|
|
|
+ list.push({
|
|
|
+ sa_projtaskmag_optionscoreid: 0,
|
|
|
+ partiestype: objItem.partiestype,
|
|
|
+ stagename: stageItem.stagename,
|
|
|
+ sa_projstagemagid: stageItem.sa_projstagemagid,
|
|
|
+ score: optionscore ? this.getScore(optionscore, objItem.partiestype, stageItem.stagename) : 0
|
|
|
+ })
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
+ return list;
|
|
|
+ },
|
|
|
+ getScore(optionscore, partiestype, stagename) {
|
|
|
+ let result = optionscore.filter(item => item.partiestype == partiestype && item.stagename == stagename)
|
|
|
+ return result.length > 0 ? result[0].score : 0
|
|
|
+ },
|
|
|
+ // 勾选对象状态
|
|
|
+ onPartiesChange(val) {
|
|
|
+ this.selectObject(val ? this.partiesType : [])
|
|
|
+
|
|
|
+ // 取消勾选
|
|
|
+ // if (!val) {
|
|
|
+ // // 更新节点所有数据
|
|
|
+ // console.log(this.projectStage)
|
|
|
+ // this.optionscore = this.projectStage.map(e=>{
|
|
|
+ // return {
|
|
|
+ // partiestype:'',
|
|
|
+ // stagename:e.stagename,
|
|
|
+ // sa_projstagemagid: e.sa_projstagemagid,
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
},
|
|
|
- tableRowClassName({row,rowIndex}) {
|
|
|
- row.index = rowIndex
|
|
|
+ // 勾选阶段状态
|
|
|
+ onOnstageChange(val) {
|
|
|
+ this.selectStage(val ? this.projectStage : [])
|
|
|
+ // 取消勾选
|
|
|
+ // if (!val) {
|
|
|
+ // // 若有客户对象数据则改变结构
|
|
|
+ // this.optionscore = this.partiesType.map(e=>{
|
|
|
+ // return {
|
|
|
+ // partiestype:e.partiestype,
|
|
|
+ // stagename:'',
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
},
|
|
|
+
|
|
|
+ // 新建任务
|
|
|
addOptions(){
|
|
|
- this.form.projtaskmag_options.push({
|
|
|
+ let row = {
|
|
|
"sa_projtaskmag_optionsid": 0,
|
|
|
"optionname": "",
|
|
|
"remarks": "",
|
|
|
"score": 0,
|
|
|
- "projtaskmag_optionscore": {
|
|
|
- "sa_projtaskmag_optionscoreid":0,
|
|
|
- "partiestype": "",
|
|
|
- "sa_projstagemagid": "",
|
|
|
- "score": 0
|
|
|
+ "projtaskmag_optionscore": this.calculate(null)
|
|
|
+ }
|
|
|
+ this.form.projtaskmag_options.push(row)
|
|
|
+ if (!this.act_projtask) {
|
|
|
+ this.rowClick(row)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 删除任务
|
|
|
+ deleteOptions(index) {
|
|
|
+ console.log(index)
|
|
|
+ this.form.projtaskmag_options = this.form.projtaskmag_options.filter((e,idx)=>{
|
|
|
+ if (idx !== index) {
|
|
|
+ return e
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 点击任务行
|
|
|
+ rowClick (row) {
|
|
|
+ // 记录当前选中行的行
|
|
|
+ this.act_projtask = row
|
|
|
+
|
|
|
+ this.optionscore = row.projtaskmag_optionscore
|
|
|
+ },
|
|
|
async onSubmit () {
|
|
|
const res = await this.$api.requested({
|
|
|
"id": "20221128144204",
|
|
|
@@ -335,13 +377,6 @@
|
|
|
this.drawer = false
|
|
|
})
|
|
|
},
|
|
|
- deleteOption (index) {
|
|
|
- this.form.projtaskmag_options = this.form.projtaskmag_options.filter((e,idx)=>{
|
|
|
- if (index !== idx) return e
|
|
|
- })
|
|
|
- this.activeOptions = ''
|
|
|
- console.log(this.form.projtaskmag_options)
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
</script>
|