| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /**
- * 满意度试题 增加或编辑
- * */
- $(function() {
- autosize($('textarea'));
- var lid = helper.request.queryString("lid");
- var edit_id = helper.request.queryString("edit_id");
- getQCategoryAlllist()
- .then(function() {
- if(lid != "undefined") {
- $('#pro_classify').val(lid);
- }
- if(edit_id) { //修改
- getProject(edit_id);
- }
- });
- //添加编辑保存按钮点击
- $('#pro_save').on('click', saveProject);
- });
- //获取详情
- function getProject(ids) {
- $.getJSON(huayi.config.callcenter_url + "Questionnaire/GetQuestionModel", {
- id: ids,
- token: $.cookie("token")
- }, function(data) {
- if(data.state == "success") {
- var res = data.data;
- if(res) {
- $('#pro_classify').val(res.F_CategoryId); //分类
- $('#pro_type').val(res.F_Type); //题型
- $('#pro_title').val(res.F_Title); // 是 string 名称
- $('#pro_remark').val(res.F_Remark); // 是 string 备注
- }
- }
- });
- }
- //保存项目
- function saveProject() {
- var edit_id = helper.request.queryString("edit_id");
- var wUrl;
- if(!$.trim($('#pro_classify').val())) {
- layer.confirm('试题分类不能为空', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#pro_title').val())) {
- layer.confirm('试题标题不能为空', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(edit_id) {
- wURL = "Questionnaire/CreateOrUpdateQuestion";
- } else {
- wURL = "Questionnaire/CreateOrUpdateQuestion";
- }
- $.post(huayi.config.callcenter_url + wURL, {
- F_QuestionId: edit_id, //试题ID
- F_CategoryId: $('#pro_classify').val(), //分类ID
- F_Title: $('#pro_title').val(), //试题标题
- //F_Content://试题内容
- F_Type: $("#pro_type").val(), //题型(1.问答题;2.单选题;3.多选题)
- F_Remark: $("#pro_remark").val(), //试题说明
- 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.$('#tbr').bootstrapTable('refresh');
- parent.layer.msg("保存成功");
- }
- });
- }
- //获取试题分类
- function getQCategoryAlllist() {
- var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "Questionnaire/GetQCategoryAlllist",
- dataType: 'json',
- async: true,
- data: {
- token: $.cookie("token")
- },
- success: function(data) {
- /*验证请求*/
- if(data.state == "success") {
- for(var i = 0; i < data.data.length; i++) {
- var html = '<option value="' + data.data[i].F_CategoryId + '">' + data.data[i].F_CategoryName + '</option>'
- $(html).appendTo("#pro_classify");
- }
- dtd.resolve(); // 改变Deferred对象的执行状态
- }
- }
- });
- return dtd.promise(); // 返回promise对象
- }
|