/**
|
* 按钮处理 业务类型修改
|
*/
|
import {paramLow,callPreEvent,callPostEvent} from '../BaseAction';
|
import {validatenull} from "@/util/validate";
|
import Vue from "vue";
|
import AddEditDialog from "@/components/actions/base/AddEditDialog";
|
|
export const doAction = (options,callback) => {
|
const paramVOS = Object.assign({
|
getdataurl: '/api/uiDataController/dataFormQuery',
|
getdatamethod: 'post',
|
url: '/api/uiDataController/editSave',
|
method: 'put',
|
uploadfileurl: 'vciFileUploadController/uploadFile'
|
}, 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;
|
}
|
|
if(!validatenull(paramVOS.checknotedit)) {
|
let notedit = paramVOS.checknotedit.split('&');
|
let checknotedit=false;
|
notedit.forEach((item,i)=>{
|
if (options.dataStore[0][item.split('=')[0]] == item.split('=')[1]) {
|
checknotedit=true;
|
return false;
|
}
|
})
|
if (checknotedit) {
|
Vue.prototype.$message.error(replaceFreeMarker(paramVOS.checknoteditmsg,options.dataStore,{}) || "当前数据不允许修改");
|
return false;
|
}
|
}
|
callPreEvent(options, doBefore, function (options) {
|
doEdit(options, function (type,formData) {
|
callPostEvent(options, doAfter,type, callback);
|
});
|
});
|
};
|
|
/**
|
* 执行
|
* @param options 按钮的配置信息
|
* @param callback 回调
|
*/
|
export const doEdit = (options,callback)=> {
|
const paramVOS = options.paramVOS;
|
if (!paramVOS['form'] && !paramVOS['context']) {
|
Vue.prototype.$message.error("按钮配置不正确");
|
return false;
|
}
|
const dialogConstructor = Vue.extend(AddEditDialog);
|
let instance = new dialogConstructor();
|
instance.sourceData = options.sourceData;
|
instance.dataStore = options.dataStore;
|
instance.paramVOS = paramVOS;
|
|
instance.type = 'edit';
|
instance.dialogClose = function () {
|
vm.visible = false;
|
document.body.removeChild(vm.$el);
|
instance.$destroy();
|
instance = null;
|
};
|
if (callback) {
|
instance.saveCallback = callback;
|
}
|
let vm = instance.$mount();
|
document.body.appendChild(vm.$el);
|
instance.visible = true;
|
}
|
/**
|
* 前置事件
|
* @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);
|
}
|
}
|