废弃的添加批注的前端代码
作者:互联网
1.主页面
afterOnCellMouseOut (mouseEvent, coords, td){
let range = this.hot.getSelected();
let row = coords.row;//当前行
let col = coords.col;//当前列
//获取当前批注
//获取当前行数据
let rowData = this.tableFilterData[row];
if(util.isEmpty(rowData)){
return;
}
//获取当前cell的item
let item = this.columns[this.currentSalTypeCode][col];
if(util.isEmpty(item)){
return;
}
if(util.isNotEmpty(comment)) {
//在批注中寻找
if(this.comments.length != 0) {
let com = _.find(this.comments, c => {
return c.typeCode == this.currentSalTypeCode && c.itemCode == item.data && c.empCode == rowData.empCode;
});
if (util.isNotEmpty(com)) {//修改
com.comments = comment;
return;
}
}
let c = {
id: util.generateUUID(),
typeCode: this.currentSalTypeCode,
empCode: rowData.empCode,
empName: rowData.empName,
itemCode: item.data,
itemName: item.itemName,
mo: rowData.mo,
moNo: rowData.moNo,
comments: comment,
fiscal: rowData.fiscal,
agyCode: rowData.agyCode,
operator: this.GET_LOGIN_INFO.userCode,
operatedTime: util.getDateInfo().dateTimeInfo,
ver: 0
}
/**
* 动态添加属性:区分编辑2与审核1
*/
if(this.mode===0){
this.$set(c,'examine',2)
}else{
this.$set(c,'examine',1)
}
this.comments.push(c);
}else{
//删除批注
if(this.comments.length != 0) {
//倒着删除,保证位置
for (let i = this.comments.length - 1; i >= 0; i--) {
if(util.isNotEmpty(this.comments[i]) && this.comments[i].typeCode == this.currentSalTypeCode && this.comments[i].itemCode == item.data && this.comments[i].empCode == rowData.empCode){
this.comments.splice(i,1);
return;
}
}
}
}
},
2.其他页面的保存批注
<el-button type="primary" size="mini" @click="handleSaveCommentEdit" v-if="isAuditMode() || isRsAuditMode()">保存批注</el-button>
/**保存审核和编辑批注
* 1自定义params用做删除批注条件
* 2过滤赋值:编辑页面 examine为2 否则为1
* 3过滤删除条件
* 如果批注长度为0删除批注
* 否则走保存批注方法
*/
handleSaveCommentEdit(){
console.log(999)
return new Promise((resolve,reject)=>{
let params = [
{
agyCode: this.query.agy.madCode,
fiscal: this.GET_LOGIN_INFO.fiscal,
mofDivCode: this.GET_LOGIN_INFO.mofDivCode,
mo: this.currentSalType.mo,
moNo: this.currentSalType.moNo,
operator:this.GET_LOGIN_INFO.userCode,
typeCode:this.currentSalTypeCode,
examine:1,
}
]
_.filter(params, e=>{
if(this.mode == 0){
return e.examine = 2;
}
});
let commnet = _.filter(this.comments, e =>{
return e.typeCode == this.currentSalTypeCode && e.examine == params[0].examine;
});
if(commnet.length==0){
fetch.post('/sal/data/comment/del',params).then(({msg})=>{
});
}else{
_.filter(commnet, e => {
if (this.GET_LOGIN_INFO.userCode != e.operator){
return e.id = util.generateUUID() , e.operator = this.GET_LOGIN_INFO.userCode;
}
});
fetch.post('/sal/data/comment/insertBatchEdit',commnet).then(({msg})=>{
return resolve();
}).catch(({msg})=>{
this.$message({
type:'error',
message:msg
});
return reject(msg);
});
}
})
},
标签:批注,return,前端,comments,util,rowData,let,废弃 来源: https://blog.csdn.net/qq_40756936/article/details/122821746