田源
2024-04-11 76ef266068b240c93ebb174733c068d15829f310
Merge remote-tracking branch 'origin/master'
已修改7个文件
已删除1个文件
已重命名1个文件
已添加1个文件
295 ■■■■ 文件已修改
Source/ProjectWeb/src/actions/BaseAction.js 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/actions/base/AddAction.js 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/actions/base/BaseAction.js 175 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/components/dynamic-components/dynamic-custom.vue 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/page/index/top/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/permission.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/router/avue-router.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/store/modules/user.js 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/views/base/UIContentViewer.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/views/base/UIContentViewerInDialog.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/actions/BaseAction.js
ÎļþÒÑɾ³ý
Source/ProjectWeb/src/actions/base/AddAction.js
Source/ProjectWeb/src/actions/base/BaseAction.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,175 @@
import {validatenull} from "@/util/validate";
import {findArray} from "@/util/util";
/**
 * æŒ‰é’®çš„基础服务
 */
/**
 * æ›¿æ¢æ–‡æœ¬ä¸­çš„${xxx}
 * @param text æ–‡æœ¬
 * @param dataStore é€‰æ‹©çš„æ•°æ®
 * @param sourceData æ¥æºæ•°æ®
 * @returns æ›¿æ¢åŽçš„值,字符串
 */
export const replaceFreeMarker = (text,dataStore,sourceData) => {
  //替换表达式
  if (!sourceData) {
    sourceData = {};
  }
  if (!dataStore) {
    dataStore = [];
  }
  let replaceData = dataStore.length > 0 ? dataStore[0] : {};
  if (text && text.indexOf("${") > -1 && text.indexOf("}")) {
    //js只能使用${xxx}这种的方式
    let reg = "root.${";
    while (text.indexOf(reg) > -1) {
      let temp = text.substring(0, text.indexOf(reg));
      let field = text.substring(text.indexOf(reg) + reg.length, text.indexOf("}"));
      let end = text.substring(text.indexOf("}") + 1);
      field = replaceData[field] || sourceData[field] || '';
      text = temp + field + end;
    }
    reg = "sourceData.${";
    while (text.indexOf(reg) > -1) {
      let temp = text.substring(0, text.indexOf(reg));
      let field = text.substring(text.indexOf(reg) + reg.length, text.indexOf("}"));
      let end = text.substring(text.indexOf("}") + 1);
      field = replaceData[field] || sourceData[field] || '';
      text = temp + field + end;
    }
    reg = "${";
    while (text.indexOf(reg) > -1) {
      let temp = text.substring(0, text.indexOf(reg));
      let field = text.substring(text.indexOf(reg) + reg.length, text.indexOf("}"));
      let end = text.substring(text.indexOf("}") + 1);
      field = replaceData[field] || sourceData[field] || '';
      text = temp + field + end;
    }
  }
  return text;
};
/**
 * å‚数转换为小写
 * @param paramsVOs å‚æ•°
 * @returns å°å†™åŽçš„参数对象
 */
export const paramLow = (paramsVOs) => {
  //
  if (!paramsVOs) {
    paramsVOs = {};
  }
  var params = {};
  for (var key in paramsVOs) {
    params[key.toLowerCase()] = paramsVOs[key];
  }
  return params;
};
/**
 * æ‰§è¡Œå‰ç½®äº‹ä»¶
 * @param options æŒ‰é’®çš„配置信息,前置事件里配置的参数会替换这个里的参数的信息
 * @param buttonTarget æŒ‰é’®js所在的对象
 * @param callback å›žè°ƒï¼Œå¦‚果存在前置事件,会在执行完成后执行回调,否则直接回调
 * @param preEventName å‰ç½®äº‹ä»¶åç§°ï¼Œé»˜è®¤beforeevent
 */
export const callPreEvent = (options,buttonTarget,callback,preEventName) => {
  const params = paramLow(options.paramVOS);
  options.paramVOS = params;
  let beforeEvent = params[preEventName || 'beforeevent'];
  if(beforeEvent) {
    let buttonParse = parseEventByUrl(beforeEvent,options,true);
    buttonParse.options.callback = callback;
    if(validatenull(buttonParse)){
      buttonTarget[buttonParse.methodName](buttonParse);
    }else{
      layui.use(buttonParse.jsPath,function () {
        layui[buttonParse.jsPath][buttonParse.methodName](options);
      });
    }
  }else{
    if(callback){
      callback(options);
    }
  }
};
/**
 * æ‰§è¡ŒåŽç½®æ—¶é—´
 * @param options æŒ‰é’®çš„配置信息,后置事件里配置的参数会替换这个里的参数的信息
 * @param buttonTarget æŒ‰é’®Js所在的对象
 */
export const callPostEvent = (options,buttonTarget,callback,postEventName)=>{
  const params = paramLow(options.paramVOS);
  options.paramVOS = params;
  var afterEvent = params[postEventName || 'afterevent'];
  if(afterEvent) {
    var buttonParse = parseEventByUrl(afterEvent,options,false);
    if(validatenull(buttonParse)){
      buttonTarget[buttonParse.methodName](buttonParse);
    }else{
      layui.use(buttonParse.jsPath,function () {
        layui[buttonParse.jsPath][buttonParse.methodName](options);
      });
    }
  }else{
    if(callback){
      callback(options);
    }
  }
};
/**
 * ä½¿ç”¨url获取事件的信息
 * @param url è·¯å¾„,格式如jsPath#methodName?param=aaa&param1=bbb
 * @param options æŒ‰é’®çš„配置信息,会自动覆盖相同属性的参数
 * @param isBefore æ˜¯å¦ä¸ºå‰ç½®äº‹ä»¶ï¼Œå¦åˆ™ä¸ºåŽç½®
 * @returns {{jsPath: js的路径, options: æŒ‰é’®çš„配置信息, methodName: (string)方法的名字}}
 */
export const parseEventByUrl = (url,options,isBefore) => {
  //根据配置格式化事件
  var jsPath = url;
  var methodName = isBefore?"doBefore":"doAfter";
  var params = {};
  if (url.indexOf("?")) {
    var temp = url.substring(0, url.indexOf("?"));
    if (temp.indexOf("#") > -1) {
      var array = temp.split("#");
      if(array.length == 1){
        jsPath = array[0];
      }else{
        jsPath = array[0];
        methodName = array[1];
      }
    }else{
      jsPath = temp;
    }
    var paramArray = url.substring(url.indexOf("?") + 1).split("&");
    layui.each(paramArray, function (_index, _item) {
      if (_item.indexOf("=") < 0) {
        this.$message.error(isBefore?"前置事件":"后置事件" + "的参数配置错误,需要要xxx=yyy&zzz=a的方式");
        return true;
      }
      params[_item.split("=")[0]] = _item.split("=")[1];
    });
  }else{
    if (url.indexOf("#") > -1) {
      var array = url.split("#");
      if(array.length == 1){
        jsPath = array[0];
      }else{
        jsPath = array[0];
        methodName = array[1];
      }
    }else{
      jsPath = url;
    }
  }
  for (var key in params) {
    options.paramVOS[key.toLowerCase()] = params[key];
  }
  return {
    jsPath:jsPath,
    methodName:methodName,
    options:options
  };
};
Source/ProjectWeb/src/components/dynamic-components/dynamic-custom.vue
@@ -2,11 +2,12 @@
  <div class="UI-dynamic" :id="'UI-dynamic-'+areasName+componentVO.oid">
    <el-alert
      class="alert"
      :closable="false"
      v-if="isError"
      title="自定义组件配置信息错误!"
      type="error"
      show-icon
      description="这个自定义页面的地址格式不正确。推荐使用bs=组件name?type=xxx&context=yyy&pparam=zzz这种形式">
      description="这个自定义页面的地址格式不正确。推荐使用“组件name?param=xxx”(自定义组件)或者“?type=xxx&context=yyy&pparam=zzz”(UI引擎)这2种形式">
    </el-alert>
    <component v-else :is="currentComponent"
               :btmType="btmType"
@@ -23,6 +24,7 @@
<script>
import {queryStringToObject} from '@/util/util'
import {validatenull} from "@/util/validate";
export default {
  name: "dynamic-custom",
  components: {
@@ -69,7 +71,7 @@
      content: '',
      urlParams: {},
      height: '300px',
      customClass: this.componentVO.customClass, //bs=?type=xxx&context=yyy&param=zzz  æˆ–者 bs=组件name?type=xxx&context=yyy&param=zzz
      customClass: '', //?type=xxx&context=yyy&param=zzz  æˆ–者 ç»„ä»¶name?type=xxx&context=yyy&param=zzz
      isError: false, //路径解析失败
      currentComponent: 'UI',//组件name
    }
@@ -88,24 +90,31 @@
  },
  mounted() {
    if (this.customClass.indexOf("bs=") < 0) {
    this.componentVO.customClass.split(';').forEach(item=>{
      if(item.indexOf('web=')==0){
        this.customClass=item.split('web=')[1];
      }
    })
    // å¦‚果路径中存在 '?',则取问号前面部分给 parts
    if (this.customClass.includes('?')) {
      this.currentComponent = this.customClass.split("?")[0];
    } else {
      this.currentComponent = this.customClass; // ä¸å­˜åœ¨ '?' æ•´æ¡è·¯å¾„就是 parts
    }
    if(validatenull(this.currentComponent)){
      this.currentComponent='UI';
    }
    if (['UI', 'ui'].includes(this.currentComponent) && (this.customClass.indexOf("type=") < 0 || this.customClass.indexOf("context=") < 0)) {
      this.isError = true;
      return;
    }
    this.customClass = this.componentVO.customClass.split("bs=")[1];
    if (this.customClass.indexOf("?") < 0 || this.customClass.indexOf("type=") < 0 || this.customClass.indexOf("context=") < 0) {
      this.isError = true;
      return;
    let urlParams = {};
    if(this.customClass.includes('?')) {
      urlParams = queryStringToObject(this.customClass);
    }
    if (this.customClass.split('?')[0] != '' && this.customClass.split('?')[0] != 'UI' && this.customClass.split('?')[0] != 'ui') {
      this.currentComponent = this.customClass.split('?')[0];
    }
    let urlParams = queryStringToObject(this.customClass);
    let btmType = urlParams.type;
    let content = urlParams.context;
    this.btmType = btmType;
    this.content = content;
    this.btmType = urlParams.type;
    this.content = urlParams.context;
    this.urlParams = Object.assign(this.paramVOS, urlParams)
    //this.getHeight(this.$parent);
Source/ProjectWeb/src/page/index/top/index.vue
@@ -242,10 +242,10 @@
          cancelButtonText: this.$t("cancelText"),
          type: "warning"
        }).then(() => {
          this.$store.dispatch("LogOut").then(() => {
          //this.$store.dispatch("LogOut").then(() => {
            resetRouter();
            this.$router.push({path: "/login"});
          });
          //});
        });
      }
    }
Source/ProjectWeb/src/permission.js
@@ -11,7 +11,6 @@
 NProgress.configure({showSpinner: false});
 const lockPage = store.getters.website.lockPage; //锁屏页
 router.beforeEach((to, from, next) => {
   // debugger;
   const meta = to.meta || {};
   const isMenu = meta.menu === undefined ? to.query.menu : meta.menu;
   store.commit('SET_IS_MENU', isMenu === undefined);
Source/ProjectWeb/src/router/avue-router.js
@@ -1,3 +1,5 @@
import {validatenull} from "@/util/validate";
let RouterPlugin = function () {
  this.$router = null;
  this.$store = null;
@@ -131,22 +133,18 @@
        } else {
          parts = path; // ä¸å­˜åœ¨ '?' æ•´æ¡è·¯å¾„就是 parts
        }
        // å¦‚果问号前面部分不在 ['ui', 'UI', 'base'] ä¸­ï¼Œåˆ™æ˜¯è‡ªå®šä¹‰ç»„ä»¶
        if (!['ui', 'UI', 'base'].includes(parts)) {
          component = `views/custom-ui/${parts}`;
        if(validatenull(parts)){
          parts='UI';
        }
        // å¦‚果问号前面等于空,则默认为UI引擎
        if (!parts) {
          component = 'views/base/UIContentViewer';
        // å¦‚果问号前面部分不在 ['ui', 'UI', 'base'] ä¸­ï¼Œåˆ™æ˜¯è‡ªå®šä¹‰ç»„ä»¶
        if (!['ui', 'UI', 'base','bs'].includes(parts)) {
          component = `views/custom-ui/${parts}`;
        }
        // å¦‚果问号前面等于 UI、ui åˆ™ä¸ºUI引擎
        if (['UI', 'ui'].includes(parts)) {
          component = 'views/base/UIContentViewer';
        }
        let name = oMenu[propsDefault.label],
          icon = oMenu[propsDefault.icon],
          children = oMenu[propsDefault.children],
Source/ProjectWeb/src/store/modules/user.js
@@ -37,7 +37,9 @@
    item.pathValue = item.path;
    item.path = '/' + item.code;
    item.query = {}; // åˆå§‹åŒ– item.query
    item.query = queryStringToObject(item.pathValue)
    if(item.pathValue.indexOf('?')!=-1) {
      item.query = queryStringToObject(item.pathValue)
    }
    if (item.children && item.children.length > 0) {
      updateCode(item.children);
    }
Source/ProjectWeb/src/views/base/UIContentViewer.vue
@@ -90,7 +90,7 @@
  },
  created() {
    if (verifyNull(this.$route.query.type) || (verifyNull(this.$route.query.context) && verifyNull(this.$route.query.content))) {
      this.$message.error("配置的信息错误,请参考bs=组件name?type=xxx&context=yyy&param=zzz这种形式。其中type是业务类型(或链接类型),context是UI上下文的名称");
      this.$message.error("配置的信息错误,请参考“?type=xxx&context=yyy&param=zzz”这种形式。其中type是业务类型(或链接类型),context是UI上下文的名称");
      return false;
    }
    this.getTheParameters()
Source/ProjectWeb/src/views/base/UIContentViewerInDialog.vue
@@ -115,7 +115,7 @@
  },
  created() {
    if (verifyNull(this.btmType) || verifyNull(this.content) ) {
      this.$message.error("自定义组件配置的信息错误,请参考bs=name?type=xxx&context=yyy&param=zzz这种形式。其中type是业务类型(或链接类型),context是UI上下文的名称,name为组件名称,空值时默认展示UI引擎");
      this.$message.error("自定义组件配置的信息错误,请参考”?type=xxx&context=yyy&param=zzz“这种形式。其中type是业务类型(或链接类型),context是UI上下文的名称");
      return false;
    }
  },