Commit c97e0d49 authored by agping's avatar agping

部门列表 加站点

parent 0238dcf1
......@@ -80,11 +80,16 @@
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label">所属城市:</label>
<select name="district_id" class="form-control btn6">
<option value="">选择城市</option>
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门名称:</label>
<input type="text" value="" name="title" class="form-control btn6" placeholder="部门名称">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门总监:</label>
<input type="text" value="" name="agents_id" class="form-control btn6 phone_mend" placeholder="部门总监">
......
......@@ -12,9 +12,36 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
district.event ();
},
event: function () {
district.getDistrict(function() {
$ (document).on('input', '[name=district_id],#district_id2', function() {
var _this = $(this);
var _id = _this.val();
_this.next().html(''); //先清空
//新增 编辑
var _objTemp = _this.parent().next().find('select');
_objTemp.html(''); //先清空
if(_id && _id != '0') {
agent.getDistrictStoreList(_id, function(_data) {
// var _str = '';
var _str = '<option value="0">全部</option>';
$.each(_data, function(i, item) {
_str += '<option value="' + item.id + '">' + item.store_name + '</option>';
});
_objTemp.html(_str);
_this.next().html(_str);
});
} else {};
});
});
$ (document).delegate ("#search", "click", function () {//点击搜索
district.getList(1);
});
// 点击 新增
$ (document).delegate (".edit-add", "click", function () {//点击编辑
district.district_id = '';
});
$ (document).delegate (".edit", "click", function () {//点击编辑
district.district_id = $ (this).attr ("data-id");
district.Edit();
......@@ -65,6 +92,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
if (data.data) {
$("input[name = agents_id]").val(data.data.name);
$("input[name = title]").val(data.data.district_name);
$("select[name =district_id]").val(data.data.site_id)
}
else {
alert('获取失败!');
......@@ -77,6 +105,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
par.id = district.district_id;
par.department_name = $("input[name =title]").val();
par.agents_id = district.agent_id;
par.site_id = $("select[name =district_id]").val();
$.ajax({
'type': 'POST',
'url' : '/index/adddistrict',
......@@ -144,7 +173,29 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
}
});
},
//获取站点
getDistrict: function(fn) {
$.ajax({
url: '/index/getSiteList',
type: 'GET',
async: true,
data: {
},
dataType: 'json',
success: function(data) {
if(data.code == 200 && data.data != null) {
var str = '';
$.each(data.data.list, function(i, item) {
str += '<option value="' + item.id + '">' + item.city + '</option>';
});
$('[name=district_id]').append(str);
$('#district_id2').append(str);
fn && fn();
}
}
});
},
getList: function (pageNo) {
district.pageNo = pageNo;
var params = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment