/**
|
* 按钮处理 业务类型删除
|
*/
|
import {paramLow,callPreEvent,callPostEvent,replaceFreeMarker} from './BaseAction';
|
import {validatenull} from "@/util/validate";
|
import Vue from "vue";
|
import { del} from "@/api/base/actions"
|
|
export const doAction = (options,callback) => {
|
options.paramVOS = paramLow(options.paramVOS)
|
const paramVOS = Object.assign({
|
url: 'uiDataController/deleteData',
|
method: 'delete'
|
}, options.paramVOS)
|
options.paramVOS = paramVOS;
|
|
options.sourceData = options.sourceData || {};
|
options.dataStore = options.dataStore || [];
|
if (!options.dataStore || options.dataStore.length < 1) {
|
Vue.prototype.$message.error("请选择需要删除的数据");
|
return false;
|
}
|
if (!paramVOS.multi && options.dataStore.length > 1) {
|
Vue.prototype.$message.error("仅能选择一条数据来操作");
|
return false;
|
}
|
let msg=replaceFreeMarker(paramVOS.confirmmsg,options.dataStore,options.sourceData) || ('是否删除' + (options.dataStore.length==1?"这条":"这些") + '数据' + (paramVOS.cascade?",如果有下级数据会级联删除":""));
|
Vue.prototype.$confirm(msg,'提示',{}).then(()=>{
|
callPreEvent(options, doBefore,function (options) {
|
doDelete(options, function (type) {
|
callPostEvent(options,doAfter , callback,type);
|
});
|
});
|
}).catch(()=>{
|
|
})
|
};
|
|
/**
|
* 执行
|
* @param options 按钮的配置信息
|
* @param callback 回调
|
*/
|
export const doDelete = (options,callback)=> {
|
let submitData = {
|
checkLinkedFlag:options.paramVOS.checklinkedflag,
|
cascade:options.paramVOS.cascade,
|
adminCascade:options.paramVOS.admincascade
|
}
|
if(options.paramVOS.checkonback){
|
submitData['checkNotDelete']=options.paramVOS.checknotdelete;
|
submitData['checkNotDeleteMsg']=options.paramVOS.checknotdeletemsg;
|
}else if(options.paramVOS.checknotdelete){
|
const notdelete = options.paramVOS.checknotdelete.split('&');
|
let checknotdelete=false;
|
let msgStore={};
|
notdelete.forEach((item,i)=>{
|
for (let j=0;j<options.dataStore.length;j++){
|
if (options.dataStore[j][item.split('=')[0]] == item.split('=')[1]) {
|
checknotdelete=true;
|
msgStore=options.dataStore[j]
|
return false;
|
}
|
}
|
})
|
if (checknotdelete) {
|
Vue.prototype.$message.error(replaceFreeMarker(options.paramVOS.checknotdeletemsg,msgStore,{}) || '当前数据不允许删除');
|
return false;
|
}
|
}
|
submitData.dataList = options.dataStore;
|
del(submitData,options.paramVOS.url,options.paramVOS.method).then(() => {
|
Vue.prototype.$message({
|
type: "success",
|
message: options.paramVOS.successmsg||"删除成功!"
|
});
|
if(callback){
|
callback("del");
|
}
|
});
|
}
|
/**
|
* 前置事件
|
* @param options 按钮的配置信息
|
* @param callback 回调
|
*/
|
export const doBefore = (options,callback)=> {
|
console.log('执行删除前置事件');
|
if(callback){
|
callback(options);
|
}
|
}
|
/**
|
* 后置事件
|
* @param options 按钮的配置信息
|
* @param callback 回调
|
*/
|
export const doAfter = (options,callback,actionType)=> {
|
console.log('执行删除后置事件');
|
if(callback){
|
callback(actionType);
|
}
|
}
|