import DynamicView from "@/layouts/DynamicView"; var DialogBox = {}; import FormBoListApi from "@/api/form/core/formBoList"; import FormPcDialog from "@/views/modules/form/core/FormPcDialog"; import FormMobileDialog from "@/views/modules/form/core/FormMobileDialog"; import FormSolutionDialog from "@/views/modules/form/core/FormSolutionDialog"; import FormRegLibDialog from "@/views/modules/form/core/FormRegLibDialog"; import FormBoListTreeDialog from "@/views/modules/form/core/FormBoListTreeDialog"; import FormSolutionShow from "@/views/modules/form/core/FormSolutionShow"; import FormSolutionTreeShow from "@/views/modules/form/core/FormSolutionTreeShow"; import FormBoListPreview from "@/views/modules/form/core/FormBoListPreview"; import FormBoListEdit3 from "@/views/modules/form/core/FormBoListEdit3"; import OsUserGet from "@/views/modules/user/org/OsUserGet"; import OsGroupGet from "@/views/modules/user/org/OsGroupGet"; import OsInstGet from "@/views/modules/user/org/OsInstGet"; import SysMenuAddNode from "@/views/modules/system/core/SysMenuAddNode"; import FormUserPermissionEditDialog from '@/views/modules/form/core/formPermission/FormUserPermissionEditDialog'; import SysTreeDialog from "@/views/modules/system/core/SysTreeDialog"; import FormBoListExportExcelDialog from "@/views/modules/form/core/FormBoListExportExcelDialog"; import FormBoListImportExcelDialog from "@/views/modules/form/core/FormBoListImportExcelDialog"; import ButtonFunConfig from "@/views/modules/form/core/ButtonFunConfig"; import FormBoListFieldRang from "@/views/modules/form/core/FormBoListFieldRang"; import SysMenuReleaseDialog from "@/views/modules/system/core/SysMenuReleaseDialog"; import LodopError from "@/views/modules/form/core/LodopError"; import BpmInstStart from "@/views/modules/bpm/core/BpmInstStart"; import FormBusSolutionDialog from "@/views/modules/form/core/FormBusSolutionDialog"; import FormBusSolutionShow from "@/views/modules/form/core/FormBusSolutionShow"; import {Util} from 'jpaas-common-lib' import store from '@/store' DialogBox.openLodopError = function (config) { var baseConf = { component: LodopError, widthHeight: ['400px', '300px'], title: '错误提示' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { }) } DialogBox.openMenuReleaseDialog = function (config) { var baseConf = { component: SysMenuReleaseDialog, widthHeight: ['800px', '600px'], title: '查看发布菜单记录' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { }) } DialogBox.openFieldRangConfig = function (config, callback) { var baseConf = { component: FormBoListFieldRang, title: '数据范围配置' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action, data) { if (action == 'ok' && callback) { callback(data); } }) } DialogBox.openButtonFunConfig = function (config, callback) { var baseConf = { component: ButtonFunConfig, title: '按钮方法配置' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action, data) { if (action == 'ok' && callback) { callback(data); } }) } DialogBox.openPermissionUser = function (serf_, eidt, callback) { var config = { curVm: serf_, widthHeight: ['800px', '500px'] } Object.assign(config, { data: { value: eidt, type: serf_.type, dataType: serf_.dataType } }); var baseConf = { component: FormUserPermissionEditDialog, title: '权限设置' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action, data) { if (action != 'ok') { return; } if (callback) { callback(this.$parent, data); } }); } DialogBox.openForm = function (config, callBack) { var baseConf = { component: FormPcDialog, title: '表单对话框' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { var form = this.getForm(); if (callBack) { callBack(form); } }) } DialogBox.openMobileFormList = function (config, callBack) { var baseConf = { component: FormMobileDialog, title: '手机表单' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { var form = this.getForm(); if (callBack) { callBack(form); } }) } DialogBox.openSoution = function (config, callback) { var baseConf = { component: FormSolutionDialog, title: '表单对话框' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { if (action != 'ok') return; var soutions = this.getSoutions(); if (callback) { callback(soutions); } }) } DialogBox.openRegLib = function (config, callback) { var baseConf = { component: FormRegLibDialog, title: '数据校验对话框' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { if (action != 'ok') return; var data = this.getData(); if (callback) { callback(data); } }) } DialogBox.openTreeList = function (config, callback) { var baseConf = { component: FormBoListTreeDialog, title: '树形对话框' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { if (action != 'ok') return; var trees = this.getCustomQuery(); if (callback) { callback(this.$parent, trees); } }) } /** * DialogBox.showForm({ title:title, curVm: self, data: {alias: alias, pkId: pkId, readOnly: readOnly, parent: parent}, max:true }, function (action) { self.onRefresh(); }); * @param config * @param callback */ DialogBox.showForm = function (config, callback) { //是否是树形表单方案 var component = config.tree == 1 ? FormSolutionTreeShow : FormSolutionShow; let _showType = store.state.appSetting.showType; if (_showType && _showType == "newPage") {//新页面打开,非弹窗类型; let _key = component.name + config.urlType ; //获取当前打开组件的 path。component.__source (生产环境下组件path),component.__file (开发环境下path) let _path = component.__source || component.__file ; _path = _path.replace('src/views/',''); let obj = { component:_path,//组件路径 props:config.data, key:_key, title:config.title, cmptKey:_key + new Date().getTime() } if(config.data && config.data.alias){ obj.key=config.data.alias; } store.commit('appSetting/setActiveKey',obj.key); let _navigation = store.state.appSetting.navigation; //如果this.navigation没有存在当前要打开的控件则返回 -1 ; let _isObj = _navigation.findIndex(item => { return item.key == obj.key && item.title == obj.title }); if(_isObj == -1){ let _arr = [..._navigation,obj]; store.commit('appSetting/setNavigation',_arr); }else { //存在的情况下,替换; let _idx = null ; let _navArr = _navigation.concat(); for (let i in _navArr){ if(_navArr[i].key == obj.key){ _idx = i ; } } _navArr[_idx] = obj ; store.commit('appSetting/setNavigation',_navArr); } } else {//弹窗打开; var title = config.title ? config.title : "使用表单"; var baseConf = { component: component, title: title }; let conf = {...baseConf, ...config}; Util.open(conf, function (action,data) { callback(action,data); }); } } /** * 打开列表对话框。 * @param parameter {key:"对话框KEY",params:"Q_NAME__S_EQ=老王"} * @param config {max:true,widthHeight:[data.width + 'px', data.height + 'px']} * @param callback */ DialogBox.dialog = function (parameter, config, callback) { FormBoListApi.setConf(parameter).then(res => { if (!res.success) return; var data = res.data; if (!config.widthHeight && data.isDialog == 'YES') { config.widthHeight = [data.width + 'px', data.height + 'px']; } let obj = {alias: parameter.key}; let _parameter = {...obj, ...parameter} var baseConf = { component: FormBoListPreview, data: _parameter, title: data.name }; let conf = {...baseConf, ...config}; Util.open(conf, function (action, data) { if (action != 'ok') return; if (callback) { callback(data); } }) }); } DialogBox.editHtml = function (pkId, config,showModal) { var baseConf = { component: FormBoListEdit3, data: {pkId: pkId,showModal:showModal}, title: 'HTML代码预览' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { }); } DialogBox.openDeploymenuDialog = function (parameter, config, callback) { var baseConf = { component: SysMenuAddNode, data: parameter, title: '发布菜单' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action, data) { if (action != 'ok') return; if (callback) { callback(data); } }) } DialogBox.getUserDetail = function (self, userId) { var baseConf = { "curVm": self, component: OsUserGet, title: "用户信息", widthHeight: ['1200px', '90vh'], "data": { "pkId": userId, callback: function (data) { console.info(data); } } }; Util.open(baseConf, function (action) { }); } DialogBox.getGroupDetail = function (self, groupId) { var baseConf = { "curVm": self, component: OsGroupGet, title: "用户组信息", widthHeight: ['1200px', '90vh'], "data": { "pkId": groupId, callback: function (data) { console.info(data); } } }; Util.open(baseConf, function (action) { }); } DialogBox.getInstDetail = function (self, instId) { var baseConf = { "curVm": self, component: OsInstGet, title: "机构信息", widthHeight: ['1200px', '90vh'], "data": { "pkId": instId } }; Util.open(baseConf, function (action) { }); } DialogBox.openSysTreeDialog = function (config, callback) { var baseConf = { component: SysTreeDialog, title: '分类对话框' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action) { if (action != 'ok') return; var data = this.getData(); if (callback) { callback(data); } }) } DialogBox.openExportExcelDialog = function (config,callback) { var name = config.data.name; var baseConf = { component: FormBoListExportExcelDialog, title: name + '导出EXCEL表单', max:true } let conf = {...baseConf, ...config}; Util.open(conf, function (action,data) { if(callback){ callback(action,data); } }) } DialogBox.openImportExcelDialog = function (config, callback) { var name = config.data.name; var baseConf = { component: FormBoListImportExcelDialog, title: name + '导入EXCEL' } let conf = {...baseConf, ...config}; Util.open(conf, function (action) { if (action != 'ok') return; if (callback) { callback(); } }) } DialogBox.loadView = (view) => { // 路由懒加载 return require(`@/views/${view}`).default; //return () => import(`@/views/${view}`) } /** * 打开自定义组件。 * * @param config { * component:"组件的URL", * title:"标题", * max:true, * curVm:this, * widthHeight:['800px','600px'], * data:{user:{name:"ray",address:"gz"}}, * } * @param callBack 回调方法 function(action,data){ * * } */ DialogBox.openComponent = function (config, callBack) { var component = DialogBox.loadView(config.component); var title = config.title || "自定义对话框"; var conf = { component: DynamicView, curVm: config.curVm, title: title, data: {currentView: component, data: config.data} }; if (config.widthHeight) { conf.widthHeight = config.widthHeight; } else { conf.max = true; } if (config.cancel) { conf.cancel = config.cancel; } Util.open(conf, function (action, data) { if (callBack) { callBack(action, data); } }) } /** * 启动流程。 * @param config * var data={defId:"1418459535940534274",formData:{address:"gz"}}; var config={ curVm:this, max:true, data: data } * @param callback (action,data) */ DialogBox.openStartFlow = function (config,callback) { var baseConf = { component: BpmInstStart, title: '启动流程' } let conf = {...baseConf, ...config}; Util.open(conf, function (action,data) { if (callback) { callback(action,data); } }) } DialogBox.openBusSolutionDialog= function (config, callback) { var baseConf = { component: FormBusSolutionDialog, title: '业务方案对话框' }; let conf = {...baseConf, ...config}; Util.open(conf, function (action,data) { if (action != 'ok') return; if (callback) { callback(data); } }) } DialogBox.showBusSolutionForm = function (config, callback) { var baseConf = { component: FormBusSolutionShow, title: config.title }; let conf = {...baseConf, ...config}; Util.open(conf, function (action,data) { if (action != 'ok') return; if (callback) { callback(data); } }) } export default DialogBox;