wangting
2024-11-19 83e67ff491fd9a789cfecd5b271a83602a134469
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
 * 按钮处理 弹窗展示详情
 */
import {paramLow,callPreEvent,callPostEvent,replaceFreeMarker} from '../BaseAction';
import {validatenull} from "@/util/validate";
import Vue from "vue";
import ViewTab from "@/views/base/ViewTab";
import router from "@/router/router"
import store from "@/store/index"
 
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;
  if(paramVOS.showname){
    const name="查看【"+replaceFreeMarker(paramVOS.showname,options.dataStore,options.sourceData)+"】";
    paramVOS.title=name;
  }
  const params= {
    options: {
      sourceData: options.sourceData,
      dataStore: options.dataStore,
      paramVOS: paramVOS
    },
    saveCallback: callback,
    title: paramVOS.title
  }
 
  store.dispatch("setViewtabparams", params);
  router.push({
    name: "查看详情",
    query:{
      name:params.title
    }
    //params:params //加参数后页面刷新时会多一个选项卡
  });
}
 
/**
 * 前置事件
 * @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);
  }
}