添加,编辑,查看,创建并复制(走添加接口)如何判断
2020-08-21 本文已影响0人
流泪手心_521
1.给每一个点击事件传个参数(add,edit,view,copyEdit)
<template slot-scope="scope">
<div class="handle-btn" @click="openDia('add',scope.row)" type="text" size="small"
v-if="scope.row.update">添加
</div>
<div class="handle-btn" @click="openDia('edit',scope.row)" type="text" size="small"
v-if="scope.row.update">编辑
</div>
<div class="split" v-if="scope.row.update">|</div>
<div class="handle-btn" @click="openDia('copyEdit',scope.row)" type="text" size="small"
v-if="scope.row.update">复制并创建
</div>
<div class="split" v-if="scope.row.update">|</div>
<div class="handle-btn" @click="openDia('view',scope.row)" type="text" size="small">查看</div>
<div class="split" v-if="scope.row.del">|</div>
<div class="handle-btn" @click="deleteRemind(scope.row)" type="text" size="small"
v-if="scope.row.del">删除
</div>
</template>
2.把参数传过来
openDia(operationType, obj) {
this.operateType = operationType;//把这个值给全局定义的变量
this.$set(this.remindForm, 'userId', "");
this.operationType = operationType;
if (operationType === 'edit' || operationType === 'copyEdit') {
this.dialogTitle = '编辑日程';
this.searchDetails(obj);
} else if (operationType === 'view') {
this.dialogTitle = '查看日程';
this.searchDetails(obj);
} else {
this.dialogTitle = '添加日程';
this.cssFlag = 'noSeprate';
this.resetData();
}
},
3.在保存的时候判断
submitRemind() {
this.$refs['remindForm'].validate((valid) => {
if (valid) {
this.packageShareMember();
if (this.operationType === 'add'||this.operationType === 'copyEdit') {
this.addRemind()
} else {
this.editRemind()
}
} else {
return false;
}
}
) ;
},