// ==================================================================================== 页面数据 // vue 实例化 var vm = null; var editor = null; doui.onReady(function() { vm = new Vue({ el: "#allwai", // 数据 data: { // ---------------------------------------------------------------- 新建问题数据 // 问题编辑 question: { type: 'new', // 新建还是修改? id: '', // 问题的id contentType: "text", title: "", // 问题的标题 content: "", // 问题的答案的文本 }, }, // 初始化事件 methods: { // 初始化 问题编辑 creatQuestion: function () { vm.question.type = 'new'; vm.question.id = ''; vm.question.contentType = "text"; vm.question.title = ""; vm.question.content = ""; }, }, }); // 获取传递值 var urldata = doui.urlParamGet(); if (urldata.type) { vm.question.type = urldata.type; } if (urldata.id) { vm.question.id = urldata.id; } // 编辑器初始化 // editor = wang.createGet({ // ids: ['editor1'], // menus: ['undo', 'redo'], // 菜单项设置 // }); // // 编辑器样式 // wang.style_scrollbar(); // wang.style_menu(editor, "font-size:0.08rem"); // wang.style_editor(editor, "font-size:0.08rem"); // 问题获取 questionGet(); $("body").css("display","block"); }); // ==================================================================================== 数据请求 // 获取某个问题详情 function questionGet () { if (vm.question.id) { // 数据准备 var myurl = gethttp() + "/admin/new/api/v1/commonQuestion/getInfo"; var mydata = doui.AjaxData({ id: vm.question.id, }); // 数据请求 doui.showLoading("加载回复"); doui.AjaxJsonp(myurl, mydata, function(res) { if (res.code != 0) { doui.hideLoading(); doui.showToast(res.msg); } else { var mo = res.data.result; // 类型 vm.question.contentType = mo.contentType; // 标题赋值 vm.question.title = mo.key; // 保存内容 vm.question.content = mo.content; // 编辑器内容显示 // wang.valueSet(editor, vm.question.content); doui.hideLoading(); } }); } } // 提交问题编辑 function submitQuestionSet () { // 获取编辑器内容 // vm.question.content = wang.textGet(editor); vm.question.content = $("#mytext").val(); // 检测是否填写完毕 if (vm.question.title.length <= 0) { doui.showToast("未填写标题"); return false; } if (vm.question.content.length <= 0) { doui.showToast("未填写回复"); return false; } // 数据准备 var myurl = gethttp() + "/admin/new/api/v1/commonQuestion/save"; var mydata = { uid: adminCookieGet().id, id: vm.question.id, contentType: vm.question.contentType, key: vm.question.title, content: vm.question.content, }; // 数据请求 doui.showLoading("正在处理"); doui.AjaxUpload(myurl, mydata, function(res) { if (res.code != 0) { doui.hideLoading(); doui.showToast(res.msg); } else { doui.hideLoading(); doui.showToast("处理成功"); // 初始化 编辑页 vm.creatQuestion(); $("#mytext").val(''); // wang.valueClear(editor); // 返回上一页,且重新请求列表 setTimeout(function(){ pageReplaceUrl("workerAnswer.html"); }, 500); } }); }