| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /**
- * 添加或修改字典类别
- * */
- $(function() {
- autosize($('textarea'));
- var fid = helper.request.queryString("fid");
- if(fid) {
- getInfo(fid);
- }
- //添加或编辑保存按钮点击
- $('#save_btns').on('click', saveInfo);
- });
- //获取
- function getInfo(fid) {
- $.getJSON(huayi.config.callcenter_url + "configurationapi/api/dictionary/getdetailes", {
- id: fid,
- }, function(data) {
- if(data.state == "success") {
- var con = data.data;
- if(con) {
- $('#dic_ids').prop('disabled', true);
- $('#dic_ids').val(con.dictionarycode);
- $('#dic_title').val(con.dictionaryname);
- $('#dic_sort').val(con.sort);
- }
- }
- });
- }
- //保存
- function saveInfo() {
- var fid = helper.request.queryString("fid");
-
- if(!$.trim($('#dic_ids').val())) {
- layer.confirm('字典标识不能为空', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#dic_title').val())) {
- layer.confirm('字典名称不能为空', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if($.trim($('#dic_sort').val())){
- if(!regexs.phoneNum.test($.trim($('#dic_sort').val()))) {
- layer.confirm('排序编号必须是正整数', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- }
- var wUrl;
- if(fid) {
- wUrl = "configurationapi/api/dictionary/update"; //修改
- } else {
- wUrl = "configurationapi/api/dictionary/add"; //添加
- }
- $.post(huayi.config.callcenter_url + wUrl, {
- id: fid, //为空或null表示需要添加,有数值表示需要更新
- dictionarycode: $('#dic_ids').val(), //字典标识
- dictionaryname: $('#dic_title').val(), //字典名称
- sort: $('#dic_sort').val(), //排序
- }, function(data) {
- var data = JSON.parse(data);
- if(data.state == "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.table.bootstrapTable('refresh');
- parent.layer.msg("保存成功");
- }
- });
- }
|