/**
|
* 美牙医生管理初始化
|
*/
|
var MyDoctor = {
|
id: "MyDoctorTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
MyDoctor.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '添加时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '医生头像', field: 'avatar', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.getImageDom(value);
|
}
|
},
|
{title: '医生名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
|
{title: '所在城市', field: 'cityName', visible: true, align: 'center', valign: 'middle'},
|
{title: '所在门店', field: 'merchantName', visible: true, align: 'center', valign: 'middle'},
|
{title: '入职时间', field: 'workTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '性别', field: 'sex', visible: true, align: 'center', valign: 'middle', formatter: function (value, row) {
|
if(value == 0){
|
return "女";
|
}
|
return "男";
|
}},
|
{title: '联系电话', field: 'phone', visible: true, align: 'center', valign: 'middle'},
|
{title: '职级', field: 'position', visible: true, align: 'center', valign: 'middle'},
|
{title: '擅长领域', field: 'technique', visible: true, align: 'center', valign: 'middle'},
|
{title: '个人介绍', field: 'remark', visible: true, align: 'center', valign: 'middle'},
|
{title: '从业年限', field: 'workTimeNum', visible: true, align: 'center', valign: 'middle'},
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
MyDoctor.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
MyDoctor.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加美牙医生
|
*/
|
MyDoctor.openMyDoctorAdd = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加美牙医生',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/myDoctor/myDoctor_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑美牙医生
|
*/
|
MyDoctor.openMyDoctorUpdate = function (id) {
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(MyDoctor.id);
|
}
|
if (ids.length != 0) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑美牙医生',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/myDoctor/myDoctor_update/' + ids
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 打开查看美牙医生详情
|
*/
|
MyDoctor.openMyDoctorDetail = function (id) {
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(MyDoctor.id);
|
}
|
if (ids.length != 0) {
|
var index = layer.open({
|
type: 2,
|
title: '美牙医生详情',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/myDoctor/detail/' + ids
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除/批量删除美牙医生
|
*/
|
MyDoctor.delete = function(id){
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(MyDoctor.id);
|
}
|
if (ids.length != 0) {
|
var operation = function() {
|
// 加载动画层,0代表加载的风格,支持0-2
|
var index = parent.layer.load(0, {shade: false});
|
var ajax = new $ax(Feng.ctxPath + "/myDoctor/delete", function (data) {
|
// 关闭加载动画层
|
parent.layer.close(index);
|
Feng.success("删除成功!");
|
MyDoctor.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("ids", ids);
|
ajax.start();
|
};
|
Feng.confirm("是否删除所选中的数据?", operation);
|
}
|
};
|
|
/**
|
* 编辑美牙医生状态
|
*/
|
MyDoctor.updateState = function (id, state) {
|
var ajax = new $ax(Feng.ctxPath + "/myDoctor/updateState", function (data) {
|
if(data.code == 200){
|
Feng.success("操作成功!");
|
MyDoctor.table.refresh();
|
} else {
|
Feng.error("操作失败!" + data.message);
|
}
|
}, function () {
|
Feng.error("操作失败!");
|
});
|
ajax.set("myDoctorId", id);
|
ajax.set("state", state);
|
ajax.start();
|
};
|
|
/**
|
* 查询美牙医生列表
|
*/
|
MyDoctor.search = function () {
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['condition'] = $("#condition").val();
|
queryData['cityId'] = $("#cityId").val();
|
queryData['sex'] = $("#sex").val();
|
queryData['workTime'] = $("#workTime").val();
|
MyDoctor.table.refresh({query: queryData});
|
};
|
/**
|
* 重置查询条件
|
*/
|
MyDoctor.resetSearch = function () {
|
$("#beginTime").val("");
|
$("#endTime").val("");
|
$("#condition").val("");
|
$("#cityId").val("");
|
$("#sex").val("");
|
$("#workTime").val("");
|
MyDoctor.search();
|
};
|
$(function () {
|
var defaultColunms = MyDoctor.initColumn();
|
var table = new BSTable(MyDoctor.id, "/myDoctor/list", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
// 表单提交参数
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['condition'] = $("#condition").val();
|
queryData['cityId'] = $("#cityId").val();
|
queryData['sex'] = $("#sex").val();
|
queryData['workTime'] = $("#workTime").val();
|
table.setQueryParams(queryData);
|
MyDoctor.table = table.init();
|
|
// 初始化开始时间、结束时间
|
laydate.render({
|
elem: '#beginTime'
|
});
|
laydate.render({
|
elem: '#endTime'
|
});
|
});
|
MyDoctor.export = function () {
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['condition'] = $("#condition").val();
|
queryData['cityId'] = $("#cityId").val();
|
queryData['sex'] = $("#sex").val();
|
queryData['workTime'] = $("#workTime").val();
|
Feng.down_export( "/myDoctor/export", queryData);
|
};
|