田源
2024-04-07 2ac55ce0edf4870a29691b56bfad59f4830a11a2
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
102
103
104
105
106
107
108
109
110
111
/**
 * 属性的工具类,可以获取表单和表格的显示信息
 * @author weidy
 */
layui.define(['layer','element','form','table','util'],function(exports){
    var Class = function() {
        this.MODELNAME = "platform/objectService/OsAttributeUtil";
        this.moduleKey = "OsAttributeUtil";
        this.id = 'OsAttributeUtil';
        this.sourceData = {};
        this.backPath = configData.compatibility?path:configData.objectServicePath;
        this.url ={
        };
        this.vciFieldType = {
            'VTString':'VTString',
            'VTInteger':'VTInteger',
            'VTLong':'VTLong',
            'VTDobble':'VTDobble',
            'VTDateTime':'VTDateTime',
            'VTDate':'VTDate',
            'VTTime':'VTTime',
            'VTBoolean':'VTBoolean'
        };
        this.getFormItemsByAttributes = function(attributes){
            var that = this;
            //使用属性获取表单的元素
            if(attributes){
                //说明有属性
                var formItems = [];
                layui.each(attributes,function(_index,record) {
                    var formItem = {};
                    formItem['name'] = record.id;
                    formItem['title'] = record.name;
                    if (!record.nullableFlag) {
                        formItem['required'] = true;
                    }
                    if (!$webUtil.isNotNull(record.defaultValue)) {
                        formItem['defaultValue'] = record.defaultValue;
                    }
                    //如果是参照
                    if (that.vciFieldType.VTString == record.attrDataType){
                        if (record.referFlag) {
                            formItem['type'] = 'refer';
                            formItem['referConfig'] = {
                                type: 'grid',
                                url: that.url.commondRefer,
                                backPath: that.backPath,
                                textField: 'name',
                                where: {
                                    "btmTypeId": record.referBtmTypeId
                                },
                                valueField: 'oid',
                                tableConfig: {
                                    page: {
                                        limit: 15,
                                        page: 1
                                    },
                                    cols: [layui.table.getIndexColumn(), layui.table.getCheckColumn(), {
                                        field: 'id',
                                        title: '编号',
                                        sort: true,
                                        width: 150
                                    }, {
                                        field: 'name',
                                        title: '名称',
                                        sort: true,
                                        width: 150
                                    }],
                                    queryColumns: [{
                                        field: 'id',
                                        title: '编号'
                                    }, {
                                        field: 'name',
                                        title: '名称'
                                    }]
                                }
                            };
                        } else if (record.enumFlag) {
                            //说明是枚举
                            formItem['type'] = 'combox';
                            formItem['comboxKey'] = record.enumId;
                        }else {
                            //就是普通的字符串,这里不再处理
                        }
                    }else if(that.vciFieldType.VTInteger == record.attrDataType
                    || that.vciFieldType.VTLong == record.attrDataType
                    || that.vciFieldType.VTDobble == record.attrDataType){
                        formItem['verify'] = 'number';
                    }else if(that.vciFieldType.VTBoolean == record.attrDataType){
                        formItem['type'] = 'trueorfalse'
                    }else if(that.vciFieldType.VTDateTime == record.attrDataType){
                        formItem['type'] = 'datetime';
                    }else if(that.vciFieldType.VTDate == record.attrDataType){
                        formItem['type'] = 'date';
                    }else if(that.vciFieldType.VTTime == record.attrDataType){
                        formItem['type'] = 'time';
                    }else{
 
                    }
                    formItems.push(formItem);
                });
                return formItems;
            }else{
                return [];
            }
        };
 
    };
    var cs = new Class();
    exports(cs.MODELNAME,cs);
});