| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /**
- * 期号增加或编辑
- * */
- var pid = helper.request.queryString("pid");
- $(function() {
- var pro_Id = helper.request.queryString("edit_id");
- if(pro_Id) { //修改
- getProject(pro_Id);
- }
- //添加编辑保存按钮点击
- $('#pro_save').on('click', saveProject);
- });
- //获取单个期号
- function getProject(ids) {
- $.getJSON(huayi.config.callcenter_url + "CusRegionCategory/GetInfo", {
- id: ids,
- token: $.cookie("token")
- }, function(data) {
- if(data.state == "success") {
- var res = data.data;
- $('#pro_title').val(res.F_RegionName); // 是 string 名称
- $('#pro_sort').val(res.F_Sort); // 是 int 排序
- }
- });
- }
- //保存期号
- function saveProject() {
- var pro_Id = helper.request.queryString("edit_id");
- var wUrl;
- if(!$.trim($('#pro_title').val())) {
- layer.confirm('期号名称不能为空', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#pro_sort').val())) {
- layer.confirm('请输入排序', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!regexs.nums.test($.trim($('#pro_sort').val()))) {
- layer.confirm('排序只能输入数字', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(pro_Id) {
- wURL = "CusRegionCategory/Update";
- } else {
- wURL = "CusRegionCategory/Add";
- }
- $.post(huayi.config.callcenter_url + wURL, {
- F_RegionId: pro_Id, // 是 int 期号项目id
- F_RegionName: $('#pro_title').val(), // 是 string 名称
- F_ParentId: pid, // 是 int 父级id
- F_AreaId: 1,// 是 int 分类 期号默认1
- F_Sort: $('#pro_sort').val(), // 是 int 排序
- token: $.cookie("token")
- }, function(data) {
- data = JSON.parse(data);
- if(data.state == "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.$('#table2').bootstrapTable('refresh');
- parent.layer.msg("保存成功");
- }
- });
- }
|