| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 | /** * 初始化expert详情对话框 */var ExpertInfoDlg = {    expertInfoData : {},    validateFields: {        name: {            validators: {                notEmpty: {                    message: '专家姓名不能为空'                }            }        },        phone: {            validators: {                notEmpty: {                    message: '联系方式不能为空'                },                regexp: {                    regexp: /^1\d{10}$/,                    message: '手机号格式错误'                }            }        },        state: {            validators: {                notEmpty: {                    message: '有效状态不能为空'                }            }        },    }};/** * 清除数据 */ExpertInfoDlg.clearData = function() {    this.expertInfoData = {};}/** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ExpertInfoDlg.set = function(key, val) {    this.expertInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;    return this;}/** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ExpertInfoDlg.get = function(key) {    return $("#" + key).val();}/** * 关闭此对话框 */ExpertInfoDlg.close = function() {    parent.layer.close(window.parent.Expert.layerIndex);}/** * 收集数据 */ExpertInfoDlg.collectData = function() {    this.set('id')        .set('name')        .set('phone')        .set('description')        .set('state');}/** * 验证数据是否为空 */ExpertInfoDlg.validate = function () {    $('#expertInfoForm').data("bootstrapValidator").resetForm();    $('#expertInfoForm').bootstrapValidator('validate');    return $("#expertInfoForm").data('bootstrapValidator').isValid();}/** * 提交添加 */ExpertInfoDlg.addSubmit = function() {    this.clearData();    this.collectData();    if (!this.validate()) {        return;    }    //提交信息    var ajax = new $ax(Feng.ctxPath + "/expert/add", function(data){        Feng.success(data.msg);        if(data.code=="200"){            window.parent.Expert.table.refresh();            ExpertInfoDlg.close();        }    },function(data){        Feng.error("添加失败!" + data.responseJSON.message + "!");    });    ajax.set(this.expertInfoData);    ajax.start();}/** * 提交修改 */ExpertInfoDlg.editSubmit = function() {    this.clearData();    this.collectData();    if (!this.validate()) {        return;    }    //提交信息    var ajax = new $ax(Feng.ctxPath + "/expert/update", function(data){        Feng.success("修改成功!");        window.parent.Expert.table.refresh();        ExpertInfoDlg.close();    },function(data){        Feng.error("修改失败!" + data.responseJSON.message + "!");    });    ajax.set(this.expertInfoData);    ajax.start();}$(function() {    Feng.initValidator("expertInfoForm", ExpertInfoDlg.validateFields);});// 验证手机号function checkMobile(str) {    let re = /^1\d{10}$/    if (re.test(str)) {        return true;    } else {        return false;    }}
 |