zhangjiaqing
8 天以前 1cef3adee31c6934c0da4b4f0b8a6f5ac03b364f
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/**
    入驻小区
**/
(function(vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 100;
    vc.extends({
        data: {
            newOaWorkflowFormEditInfo: {
                formJson: {},
                components: [],
                conditions: {},
                flowId: '',
                id: '',
                fileName: '',
                realFileName: ''
            }
        },
        _initMethod: function() {
            $that.newOaWorkflowFormEditInfo.flowId = vc.getParam('flowId');
            $that.newOaWorkflowFormEditInfo.id = vc.getParam('id');
            vc.component._listOaWorkflowFormEdit(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function() {
            vc.on('newOaWorkflowFormEdit', 'fileName', function(_param) {
                $that.newOaWorkflowFormEditInfo.fileName = _param.fileName;
                $that.newOaWorkflowFormEditInfo.realFileName = _param.realFileName;
            })
        },
        methods: {
            _listOaWorkflowFormEdit: function(_page, _rows) {
                var param = {
                    params: {
                        page: 1,
                        row: 1,
                        flowId: $that.newOaWorkflowFormEditInfo.flowId
                    }
                };
 
                //发送get请求
                vc.http.apiGet('/oaWorkflow/queryOaWorkflowForm',
                    param,
                    function(json, res) {
                        let _newOaWorkflowFormEditInfo = JSON.parse(json);
                        $that.newOaWorkflowFormEditInfo.formJson = JSON.parse(_newOaWorkflowFormEditInfo.data[0].formJson);
                        $that.newOaWorkflowFormEditInfo.components = $that.newOaWorkflowFormEditInfo.formJson.components;
                        $that._listOaWorkflowDetails();
 
                    },
                    function(errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _listOaWorkflowDetails: function() {
                var param = {
                    params: {
                        page: 1,
                        row: 1,
                        id: $that.newOaWorkflowFormEditInfo.id,
                        flowId: $that.newOaWorkflowFormEditInfo.flowId
                    }
                };
 
                //发送get请求
                vc.http.apiGet('/oaWorkflow/queryOaWorkflowFormData',
                    param,
                    function(json, res) {
                        var _newOaWorkflowDetailInfo = JSON.parse(json);
                        let _data = _newOaWorkflowDetailInfo.data[0];
                        $that.newOaWorkflowFormEditInfo.components.forEach(item => {
                            item.value = _data[item.key];
                        })
                        if (_data.files) {
                            $that.newOaWorkflowFormEditInfo.fileName = _data.files[0].fileName;
                            $that.newOaWorkflowFormEditInfo.realFileName = _data.files[0].realFileName;
                            vc.emit('newOaWorkflowFormEdit', 'uploadFile', 'notifyVedio', _data.files[0].fileName)
                        }
                        $that.$forceUpdate();
                    },
                    function(errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _submitFormData() {
                //做数据校验
                let _components = $that.newOaWorkflowFormEditInfo.components;
                let _data = {
                    id: $that.newOaWorkflowFormEditInfo.id,
                    flowId: $that.newOaWorkflowFormEditInfo.flowId,
                    fileName: $that.newOaWorkflowFormEditInfo.fileName,
                    realFileName: $that.newOaWorkflowFormEditInfo.realFileName
                };
 
                _components.forEach(item => {
                    if (item.validate && item.validate.required == true && !item.value) {
                        vc.toast(item.label + "不能为空")
                        throw Error(item.label + "不能为空");
                    }
                    if (item.type != 'button' && item.type != 'text') {
                        _data[item.key] = item.value;
                        if (item.type == 'checkbox') {
                            _data[item.key] = item.value.length > 0 ? item.value[0] : '';
                        }
                    }
                });
 
                vc.http.apiPost(
                    '/oaWorkflow.updateOaWorkflowFormData',
                    JSON.stringify(_data), {
                        emulateJSON: true
                    },
                    function(json, res) {
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            vc.toast('提交成功');
                            $that.closeEditInfo();
                            return;
                        }
                        vc.toast(_json.msg);
                    },
                    function(errInfo, error) {
                        console.log('请求失败处理');
 
                        vc.toast(errInfo);
 
                    });
            },
            closeEditInfo: function() {
                vc.goBack();
            }
        }
    });
})(window.vc);