/**
|
* 按钮处理 页面展示为tab选项卡
|
*/
|
import {paramLow,callPreEvent,callPostEvent,replaceFreeMarker} from './BaseAction';
|
import {validatenull} from "@/util/validate";
|
import Vue from "vue";
|
import ViewDialog from "@/components/actions/ViewDialog";
|
|
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;
|
}
|
|
callPreEvent(options, doBefore, function (options) {
|
doView(options, function (type,formData) {
|
callPostEvent(options, doAfter,type, callback);
|
});
|
});
|
};
|
|
/**
|
* 执行
|
* @param options 按钮的配置信息
|
* @param callback 回调
|
*/
|
export const doView = (options,callback)=> {
|
const paramVOS = options.paramVOS;
|
let component = 'base/UIContentViewerInDialog';
|
if (!validatenull(paramVOS.customurl)) {
|
//自定义js
|
component = `custom-ui/` + paramVOS.customurl;
|
}else{
|
if (!paramVOS['type'] || !paramVOS['context']) {
|
Vue.prototype.$message.error("按钮配置不正确");
|
return false;
|
}
|
}
|
paramVOS.component=component;
|
let name="查看详情"
|
if(paramVOS.showname){
|
name="查看【"+replaceFreeMarker(paramVOS.showname,options.dataStore,options.sourceData)+"】"
|
}
|
paramVOS.title=name;
|
const dialogConstructor = Vue.extend(ViewDialog);
|
let instance = new dialogConstructor();
|
instance.sourceData = options.sourceData;
|
instance.dataStore = options.dataStore;
|
instance.paramVOS = paramVOS
|
|
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);
|
}
|
}
|