/**
|
* 按钮处理 页面展示为tab选项卡
|
*/
|
import {paramLow,callPreEvent,callPostEvent,replaceFreeMarker} from './BaseAction';
|
import {validatenull} from "@/util/validate";
|
import Vue from "vue";
|
import AddEditDialog from "@/components/actions/AddEditDialog";
|
import Layout from "@/router/page";
|
import router from '@/router/router';
|
|
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 = '@/views/base/UIContentViewerInDialog';
|
if (!validatenull(paramVOS.customurl)) {
|
//自定义js
|
component = `@/views/custom-ui/` + paramVOS.customurl;
|
}else{
|
if (!paramVOS['type'] || !paramVOS['context']) {
|
Vue.prototype.$message.error("按钮配置不正确");
|
return false;
|
}
|
}
|
let name="查看数据"
|
if(paramVOS.showname){
|
name=replaceFreeMarker(paramVOS.showname,options.dataStore,options.sourceData)
|
}
|
router.addRoutes({
|
path: '/view-form'+options.dataStore[0].oid,
|
name: name,
|
component: Layout,
|
meta: {
|
keepAlive: true,
|
isTab: true
|
},
|
children: [
|
{
|
path: '', // 空路径表示访问 '/dynamic-form' 时加载 Layout 组件
|
component: () => import(component),
|
props: 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);
|
}
|
}
|