app/views/educode_sales/ideas/new.html.erb in educode_sales-0.9.61 vs app/views/educode_sales/ideas/new.html.erb in educode_sales-0.9.62

- old
+ new

@@ -7,17 +7,17 @@ </div> <div class="layui-row" style="padding-top: 15px"> <div class="layui-col-md6"> <labeL class="layui-form-label required">学校/单位:</labeL> <div class="layui-input-block"> - <input type="text" name="school_name" autocomplete="off" lay-verify="required" lay-reqtext="学校不能为空" placeholder="请输入学校/单位名称" value="<%= @idea&.school_name %>" class="layui-input"> + <div id="school_id" style="width: 600px;"></div> </div> </div> <div class="layui-col-md6"> <labeL class="layui-form-label">院系/部门:</labeL> <div class="layui-input-block"> - <input type="text" name="department_name" autocomplete="off" placeholder="请输入院系/部门名称" value="<%= @idea&.department_name %>" class="layui-input"> + <div id="department_id" style="width: 600px;"></div> </div> </div> </div> <div class="layui-row" style="padding-top: 15px"> <div class="layui-col-md6"> @@ -192,10 +192,91 @@ laydate.render({ elem: '#new_time' }); form.render(); + var school_list = xmSelect.render({ + el: '#school_id', + remoteSearch: true, + autoRow: true, + radio: true, + delay: 1000, + tips: '支持学校名称搜索,请至少输入一个字符', + searchTips: '支持名称/省份搜索,请至少输入一个字符', + paging: true, + pageRemote: true, + filterable: true, + remoteMethod: function (val, cb, show, pageIndex) { + if (!val) { + return cb([]); + } + $.ajax('/missions/staff_schools', { + method: 'get', + data: { + q: val, + page: pageIndex + }, + dataType: 'json', + success: function (res) { + var data = res.data; + if (res.code == 0) { + cb(res.data, res.count); + } else { + layer.msg(res.msg, {time: 2000, icon: 2, shade: 0.01}); + } + } + }) + } + }) + + var department_list = xmSelect.render({ + el: '#department_id', + remoteSearch: true, + autoRow: true, + radio: true, + delay: 1000, + tips: '支持学校名称搜索,请至少输入一个字符', + searchTips: '支持名称/省份搜索,请至少输入一个字符', + paging: true, + pageRemote: true, + filterable: true, + remoteMethod: function (val, cb, show, pageIndex) { + + var schools = []; + school_list.getValue().forEach(function (d) { + schools.push(d.value); + }) + // if (schools.length == 0) { + // layer.alert("请选择学校"); + // return false; + // } + school_id = schools[0]; + + + if (!val) { + return cb([]); + } + $.ajax('/missions/staff_departments?school_id=' + school_id, { + method: 'get', + data: { + q: val, + page: pageIndex + }, + dataType: 'json', + success: function (res) { + var data = res.data; + if (res.code == 0) { + cb(res.data, res.count); + } else { + layer.msg(res.msg, {time: 2000, icon: 2, shade: 0.01}); + } + } + }) + } + }) + + upload.render({ elem: '#test8' , url: '/missions/upload_files' //此处配置你自己的上传接口即可 , auto: true , accept: 'file' //普通文件 @@ -250,29 +331,44 @@ }) var assist_staff_list = xmSelect.render({ el: '#assist_staff_ids', data: gon.staffs, filterable: true, - multiple:true + multiple: true }) //监听提交 form.on('submit(saveBtn)', function (data) { // if (department.getValue() == "" && department_id == "") { // layer.alert("请选择单位部门") // return false; // } else { - data.field.department_id = department.getValue() || department_id; - data.field.staff_id = staff_list.getValue('valueStr'); - data.field.sale_staff_id = sale_staff_list.getValue('valueStr'); - data.field.assist_staff_ids = assist_staff_list.getValue('valueStr'); - request.authPost("missions/ideas/", data.field, function (res) { - if (res.success == false) { - layer.alert(res.msg) - } else { - layer.close(parent.add_idea_index); - parent.layer.close(parent.layer.getFrameIndex(window.name)) - parent.table.reload('ideas_table', { + + var schools = []; + school_list.getValue().forEach(function (d) { + schools.push(d.value); + }) + if (schools.length == 0) { + layer.alert("请选择学校"); + return false; + } + data.field.school_id = schools[0]; + + var departments = []; + department_list.getValue().forEach(function (d) { + departments.push(d.value); + }) + data.field.department_id = departments[0]; + data.field.staff_id = staff_list.getValue('valueStr'); + data.field.sale_staff_id = sale_staff_list.getValue('valueStr'); + data.field.assist_staff_ids = assist_staff_list.getValue('valueStr'); + request.authPost("missions/ideas/", data.field, function (res) { + if (res.success == false) { + layer.alert(res.msg) + } else { + layer.close(parent.add_idea_index); + parent.layer.close(parent.layer.getFrameIndex(window.name)) + parent.table.reload('ideas_table', { done: function () { } }); } }) \ No newline at end of file