wangting
2024-05-14 e330c3130c9eb0d7a10e1fe65885e5466263471e
Source/ProjectWeb/src/components/actions/base/BaseAction.js
@@ -1,5 +1,6 @@
import {validatenull} from "@/util/validate";
import Vue from 'vue';
import {handlers} from '../handlers';
/**
 * 按钮的基础服务
@@ -21,7 +22,7 @@
        if (item.indexOf('${') > -1) {
          if (item.split('=')[1].indexOf('.') > -1) {
            //initvaluenull=true允许初始值为空
            if ((options.sourceData.length < 1 || !options.sourceData.oid) && options.paramVOS['initvaluenull']!=true && options.paramVOS['initvaluenull']!="true") {
            if ((options.sourceData.length < 1 || !options.sourceData.oid) && options.paramVOS['needselect'] != false && options.paramVOS['needselect'] != "false") {
              isShow = false;
              Vue.prototype.$message.error("请先选择一条来源数据")
              return false;
@@ -33,7 +34,7 @@
              initValues[item.split('=')[0]]=""
            }
          } else {
            if (options.dataStore.length < 1 && options.paramVOS['initvaluenull'] != true && options.paramVOS['initvaluenull'] != "true") {
            if (options.dataStore.length < 1 && options.paramVOS['needselect'] != false && options.paramVOS['needselect'] != "false") {
              isShow = false;
              Vue.prototype.$message.error("请先选择一条数据");
              return false;
@@ -55,45 +56,21 @@
  if(!isShow){
    return;
  }
  if (validatenull(options.paramVOS.context)) {
    options.paramVOS.context = options.paramVOS.content;
  }
  if(button.url && button.url!='null'){
    //有配置action路径,使用路径对应的js
    import("../"+button.url+".js").then(module => {
      module.doAction(options,callback);
    })
  }else {
    //通用action
    const handlers = {
      //查看
      view: () => {import("@/components/actions/base/TabViewAction").then(module => {
        module.doAction(options,callback);
      })},
      //创建
      add: () => {import("@/components/actions/base/AddAction").then(module => {
        module.doAction(options,callback);
      })},
      //修改
      edit: () =>  {import("@/components/actions/base/EditAction").then(module => {
        module.doAction(options,callback);
      })},
      //删除
      delete: () =>  {import("@/components/actions/base/DeleteAction").then(module => {
        module.doAction(options,callback);
      })},  //删除
      del: () =>  {import("@/components/actions/base/DeleteAction").then(module => {
        module.doAction(options,callback);
      })},
    };
    if(validatenull(options.paramVOS.context)) {
      options.paramVOS.context = options.paramVOS.content;
    }
    if(handlers[button.actionVO.id.toLowerCase()]){
      handlers[button.actionVO.id.toLowerCase()]()
    }else{
      Vue.prototype.$message.error('未找到对应action,请重新配置按钮!');
    }
  }
};