puzhibing
2023-07-30 03a4584d7d58fc073649a3ef821e1b2ebc0ed6cb
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
137
138
139
140
141
142
143
144
/**
 * 初始化详情对话框
 */
var TAgentInfoDlg = {
    tAgentInfoData : {},
    validateFields: {
        principal: {
            validators: {
                notEmpty: {
                    message: '负责人姓名不能为空'
                },
                regexp: {
                    regexp:  /^[\u4E00-\u9FA5A-Za-z\s]+$/,
                    message: '不能输入特殊字符和数字'
                }
            }
        },
        principalPhone: {
            validators: {
                notEmpty: {
                    message: '联系电话不能为空'
                },
                regexp: {
                    regexp: /^1[3-9]\d{9}$/,
                    message: '请输入合法手机号'
                }
            }
        },
        area: {
            validators: {
                notEmpty: {
                    message: '请选择代理区域'
                }
            }
        },
        account: {
            validators: {
                notEmpty: {
                    message: '登录账号不能为空'
                }
            }
        }
    }
};
 
/**
 * 验证数据是否为空
 */
TAgentInfoDlg.validate = function () {
    $('#tAgentInfoForm').data("bootstrapValidator").resetForm();
    $('#tAgentInfoForm').bootstrapValidator('validate');
    return $("#tAgentInfoForm").data('bootstrapValidator').isValid();
};
 
/**
 * 清除数据
 */
TAgentInfoDlg.clearData = function() {
    this.tAgentInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TAgentInfoDlg.set = function(key, val) {
    this.tAgentInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TAgentInfoDlg.get = function(key) {
    return $("#" + key).val();
}
 
/**
 * 关闭此对话框
 */
TAgentInfoDlg.close = function() {
    parent.layer.close(window.parent.TAgent.layerIndex);
}
 
/**
 * 收集数据
 */
TAgentInfoDlg.collectData = function() {
    this
        .set('id')
        .set('principal')
        .set('principalPhone')
        .set('email')
        .set('provinceCode')
        .set('provinceName')
        .set('cityCode')
        .set('cityName')
        .set('status')
        .set('area')
        .set('areaId')
        .set('account')
        .set('password');
}
 
 
 
/**
 * 提交修改
 */
TAgentInfoDlg.editSubmit = function() {
 
    this.clearData();
    this.collectData();
 
    if(!this.validate()){
        return ;
    }
    let password = $('#password').val();
    let rePassword = $('#rePassword').val();
    if(null != password && '' != password && password != rePassword){
        Feng.error("两个密码不一致");
        return
    }
 
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tAgent/update", function(data){
        Feng.success("修改成功!");
        window.parent.TAgent.table.refresh();
        TAgentInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.tAgentInfoData);
    ajax.start();
}
 
$(function() {
    Feng.initValidator("tAgentInfoForm", TAgentInfoDlg.validateFields);
});