prescription-consulting.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. var request = getRequest(),
  2. sessionId = request.sessionId,
  3. patiCode,
  4. patiName,
  5. consultCode,
  6. prescriptionStatus,
  7. prescriptionCode,
  8. page = 1,
  9. members = [],
  10. fv_id,
  11. quickReplyList,
  12. survey_1_obj, //身体异常症状问卷obj
  13. survey_2_obj; //体征及生活方式调查问卷obj
  14. var docInfo = window.localStorage.getItem("docInfo");
  15. docInfo = JSON.parse(docInfo);
  16. $(function(){
  17. //续方咨询的sessionId 格式 居民code+咨询code+咨询类型( 8 )
  18. patiCode = sessionId.split("_")[0];
  19. consultCode = sessionId.split("_")[1];
  20. getConsultStatus();
  21. //获得会话参与人员
  22. consultingAPI.getMembers(sessionId).then(function(res){
  23. members = res;
  24. for(var i=0; i<members.length; i++){
  25. if(members[i].is_patient == 1){
  26. patiName = members[i].name;
  27. break;
  28. }
  29. }
  30. getMessage(true);
  31. })
  32. getPrescriptionInfo();
  33. getPatientServiceType(); //获得患者的标签类型
  34. connectSocket();
  35. bindEvents();
  36. })
  37. function getConsultStatus(){
  38. var params = {consult: consultCode};
  39. consultingAPI.getConsultStatus({data: params}).then(function(res){
  40. if(res.status == 200){
  41. //咨询状态(0进行中,1已完成,-1患者取消,-2超时未响应自动关闭)
  42. if(res.data == 0) { //咨询未结束
  43. } else { //咨询已结束
  44. $('.info-panel').html('咨询求助已结束');
  45. $('.send-btn').addClass("disabled");
  46. $("#file_head").attr("disabled", true);
  47. $('.icon-reply').hide()
  48. }
  49. }else{
  50. }
  51. });
  52. }
  53. function getMessage(isInit){
  54. var params = {
  55. page: page,
  56. pagesize: 10,
  57. end_msg_id: '',
  58. start_msg_id: '',
  59. user: docInfo.code,
  60. session_id: sessionId,
  61. content_type: '',
  62. isoffset: ''
  63. }
  64. consultingAPI.getMessages(sessionId, {data: params}).then(function(res){
  65. var list = res;
  66. if (list && list.length > 0) {
  67. id = list[list.length - 1].id;
  68. var html = '',
  69. length = list.length;
  70. for (var j = list.length-1; j >= 0; j--) {
  71. var reply = list[j];
  72. html += formatMsg(reply);
  73. }
  74. if(isInit){
  75. $("#talkBox").append(html);
  76. $("#talkBox").slimScroll({
  77. height: '100%',
  78. width: '100%',
  79. alwaysVisible: true,
  80. start : 'bottom',
  81. }).bind('slimscroll', function(e, pos) {
  82. if(pos == 'top'){
  83. if(length == 10){
  84. page++;
  85. getMessage();
  86. }
  87. }
  88. });
  89. }else{
  90. $("#talkBox").prepend(html);
  91. $("#talkBox").slimScroll({
  92. scrollTo: 'bottom'
  93. });
  94. }
  95. $(".fancybox").fancybox({openEffect:"none",closeEffect:"none"});
  96. plyr.setup();
  97. }
  98. });
  99. }
  100. function formatMsg(reply){
  101. try{
  102. reply = JSON.parse(reply);
  103. }catch(e){
  104. }
  105. var isSelf = (reply.sender_id==docInfo.code) ? true : false;
  106. var isSystem = reply.sender_id == 'system';
  107. var html = '';
  108. if(reply.content_type == 7 || reply.content_type == 10 || reply.content_type == 13 || reply.content_type == 14){
  109. var content = reply.content;
  110. if(isSystem){
  111. content = '居民24小时内未回复,系统自动结束咨询';
  112. }
  113. html = template('sys_msg_tmp', {content: content});
  114. }else{
  115. var member;
  116. for(var i=0; i<members.length; i++){
  117. if(reply.sender_id == members[i].id){
  118. member = members[i];
  119. break;
  120. }
  121. }
  122. var img = APIService.getImgUrl(member.avatar);
  123. if((img.indexOf('http') == -1) && (img.indexOf("https") == -1)){
  124. img = member.is_patient ? 'img/p-default.png' : 'img/d-male.png';
  125. }
  126. var content = '';
  127. try{
  128. content = JSON.parse(reply.content);
  129. }catch(e){
  130. if(reply.content_type == 12){ //视频文件
  131. var arr = reply.content.split(",");
  132. content = {};
  133. content.img = arr[0];
  134. content.path = arr[1];
  135. content.time = arr[2];
  136. }else{
  137. content = reply.content;
  138. }
  139. }
  140. var obj = {
  141. isSelf: isSelf,
  142. time: new Date(reply.timestamp).format('yyyy-MM-dd HH:mm:ss'),
  143. type: reply.content_type,
  144. name: member.name,
  145. img: img,
  146. content: content
  147. };
  148. html = template('msg_tmp', obj);
  149. }
  150. return html;
  151. }
  152. function getPrescriptionInfo(){
  153. var params = { consult: consultCode};
  154. consultingAPI.getPrescriptionInfo({data: params}).then(function(res){
  155. if(res.status == 200){
  156. //获得随访相关内容
  157. var followup = res.data.followup;
  158. if(followup){
  159. followup = JSON.parse(followup);
  160. fv_id = followup.id;
  161. }
  162. var html = template('prescriptionInfo_tmp', res.data);
  163. prescriptionStatus = res.data.status;
  164. prescriptionCode = res.data.code;
  165. var statusName = getStatusName(res.data.status == '69' ? '61' : res.data.status);
  166. $(".status-btn").text(statusName);
  167. $("#prescriptionInfo").empty().append(html);
  168. $("#prescriptionInfo").slimscroll({
  169. height: '100%',
  170. width: '100%'
  171. });
  172. }else{
  173. showWarningMsg(res.msg)
  174. }
  175. });
  176. }
  177. function getPatientServiceType(){
  178. var params = {patient: patiCode};
  179. consultingAPI.getPatientServiceType({data: params}).then(function(res){
  180. if(res.status == 200){
  181. //slowDiseasePatient: 0 //0表示没有慢病服务类型,1表示有
  182. if(res.data.slowDiseasePatient == 0){
  183. $(".diseaseInfo").html("此居民未被标注【慢病】相关标签,请在i健康APP上核实");
  184. }else{
  185. var disease = "";
  186. for(var i=0; i<res.data.signFamilyServer.length; i++){
  187. var item = res.data.signFamilyServer[i];
  188. if(i>0){
  189. disease += ','+item.name;
  190. }else{
  191. disease += item.name;
  192. }
  193. }
  194. $(".diseaseInfo").text("该居民为"+disease+"患者");
  195. }
  196. }else{
  197. showWarningMsg(res.msg)
  198. }
  199. });
  200. }
  201. function connectSocket(){
  202. jQuery.getScript(APIService.socketUrl+"/socket.io/socket.io.js").done(function() {
  203. var socket = io.connect(APIService.socketUrl );
  204. socket.emit('login', {
  205. userId: docInfo.code,
  206. password: docInfo.code,
  207. sessionId: sessionId,
  208. clientType: "doctor"
  209. });
  210. socket.on('message', function (data) {
  211. console.log(data);
  212. if(data.read && data.read == "all"){
  213. return ;
  214. }
  215. var html = formatMsg(data);
  216. $("#talkBox").append(html);
  217. $("#talkBox").slimscroll({
  218. scrollTo: 'bottom'
  219. });
  220. });
  221. socket.on('error', function (data) {
  222. console.log(data)
  223. });
  224. socket.on('ack', function (data) {
  225. });
  226. }).fail(function() {
  227. // dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:"医生实时对话连接失败!"}).show();
  228. });
  229. }
  230. function sendMessage(contentType, content){
  231. var params = {
  232. sender_id: docInfo.code,
  233. sender_name: docInfo.name,
  234. content_type: contentType,
  235. content: content,
  236. view: 0
  237. };
  238. consultingAPI.sendMessage(sessionId, {data: params}).then(function(res){
  239. console.log(res);
  240. // var html = "";
  241. // for(var i=0; i<res.messages.length; i++){
  242. // var reply = res.messages[i];
  243. // console.log(reply);
  244. // html += formatMsg(reply);
  245. // }
  246. // $("#talkBox").append(html);
  247. // $("#talkBox").slimscroll({
  248. // scrollTo: this.height
  249. // });
  250. });
  251. }
  252. //结束咨询
  253. function finish(){
  254. //判断续方状态,如果未审核,则不可以结束咨询
  255. if(prescriptionStatus > 0 && prescriptionStatus < 21){
  256. dialog({
  257. content:'续方申请未审核,不能结束咨询',
  258. width: 460,
  259. okValue:'我知道了',
  260. ok: function() {
  261. return;
  262. }
  263. }).width(320).showModal();
  264. return false;
  265. }
  266. dialog({
  267. content:'结束咨询后,居民及所有医生均无法再次回复,是否确认继续结束?',
  268. width: '460px',
  269. okValue:'继续结束',
  270. ok: function() {
  271. var params = {consult: consultCode};
  272. consultingAPI.finishConsult({data: params}).then(function(res){
  273. if(res.status == 200) {
  274. var content = docInfo.name+'结束了咨询',
  275. html = template('sys_msg_tmp', {content: content});
  276. $("#talkBox").append(html);
  277. $("#talkBox").slimScroll({
  278. scrollTo: 'bottom'
  279. });
  280. $('.info-panel').html("咨询求助已结束");
  281. $(".send-btn").addClass("disabled");
  282. $("#file_head").attr("disabled", true);
  283. $('.icon-reply').hide()
  284. showSuccessMsg("已结束咨询");
  285. } else {
  286. showErrorMsg(res.msg);
  287. }
  288. })
  289. },
  290. cancelValue: '我再看看',
  291. cancel: function(){}
  292. }).showModal();
  293. }
  294. function bindEvents(){
  295. $(".send-btn").on('click', function(){
  296. var $this = $(this);
  297. if($this.hasClass("disabled")){
  298. return false;
  299. }else{
  300. var text = $.trim($("#input_content").text());
  301. if(text.length == 0){
  302. showWarningMsg('发送内容不能为空');
  303. return false;
  304. }else{
  305. sendMessage(1, text);
  306. $("#input_content").text('');
  307. var obj = {
  308. content: text,
  309. content_type: '1',
  310. sender_id: docInfo.code,
  311. timestamp: new Date().getTime()
  312. }
  313. var html = formatMsg(obj);
  314. $("#talkBox").append(html);
  315. $("#talkBox").slimscroll({
  316. scrollTo: 'bottom'
  317. });
  318. }
  319. }
  320. });
  321. $("#file_head").on('change', function(){
  322. var file = this.files[0];
  323. //先上传图片去服务器,然后再发送消息
  324. var fd=new FormData();
  325. fd.append("action", "UploadVMKImagePath");
  326. fd.append("file", file); //加入文件对象
  327. fd.append("type", '2');
  328. var ajaxObj = {
  329. data: fd,
  330. cache: false,
  331. processData: false,
  332. contentType: false
  333. }
  334. consultingAPI.uploadImage(ajaxObj).then(function(res){
  335. if(res.status == 200){
  336. sendMessage(2, res.urls);
  337. var obj = {
  338. content: res.urls,
  339. content_type: '2',
  340. sender_id: docInfo.code,
  341. timestamp: new Date().getTime()
  342. }
  343. var html = formatMsg(obj);
  344. $("#talkBox").append(html);
  345. $("#talkBox").slimscroll({
  346. scrollTo: 'bottom'
  347. });
  348. }else{
  349. }
  350. });
  351. });
  352. //查看详情
  353. $("body").on('click', '.view-detail', function(){
  354. //修改顶部tab页面的
  355. var url = parent.document.getElementById("tab").src;
  356. parent.document.getElementById("tab").src = "prescription-tabs.html?sessionId="+sessionId+"&patiCode="+patiCode+"&code="+prescriptionCode+"&tab=1&fromTabIdx=0";
  357. });
  358. template.helper('getSourceUrl', function(str){
  359. return APIService.getImgUrl(str);
  360. });
  361. //导入随访相关控件监听
  362. $("body").on('click', '.import-fv', function(){
  363. var $this = $(this),
  364. type = $this.attr("data-type"), // 1-血压,2-血糖
  365. health = $this.attr("data-health"),
  366. params = {
  367. prescriptioncode: prescriptionCode,
  368. followupid: fv_id,
  369. healthindexid: health
  370. };
  371. if(type == 1){
  372. consultingAPI.importbloodpressure(params).then(function(res){
  373. if(res.status == 200){
  374. showSuccessMsg("已填入");
  375. }else{
  376. showErrorMsg(res.msg)
  377. }
  378. })
  379. }else if(type == 2){
  380. consultingAPI.importbloodsugar(params).then(function(res){
  381. if(res.status == 200){
  382. showSuccessMsg("已填入");
  383. }else{
  384. showErrorMsg(res.msg)
  385. }
  386. })
  387. }
  388. });
  389. //导入药品到随访记录中
  390. $(".import-drugs").on('click', function(){
  391. var params = {
  392. prescriptioncode: prescriptionCode,
  393. followupid: fv_id
  394. };
  395. consultingAPI.importdrugs(params).then(function(res){
  396. if(res.status == 200){
  397. showSuccessMsg("已将续方药品填入本次随访记录");
  398. }else{
  399. showErrorMsg(res.msg);
  400. }
  401. });
  402. });
  403. //查看问卷记录
  404. $("body").on('click', '.view-survey', function(){
  405. var $this = $(this),
  406. msgType = $this.attr("data-type");
  407. parent.gotoPrescriptionTab(8);
  408. });
  409. //快捷回复相关监听事件
  410. bindReplyEvents();
  411. }
  412. //-------------------------------快捷回复相关内容--------------------------
  413. var count = 0;
  414. function showQuickReplyPanel(e){
  415. var $el = $(e),
  416. offset = $el.offset();
  417. if(count == 0){
  418. $(".quick-reply-panel").css({"left": offset.left});
  419. //获得快捷回复列表
  420. getQuickReplayList();
  421. $(".quick-reply-panel").toggle("show");
  422. }else{
  423. //渲染前4条记录
  424. var list = quickReplyList.slice(0, 4),
  425. html = template("quick_reply_tmp", {list: list});
  426. $(".quick-reply-panel ul").empty().append(html);
  427. $(".quick-reply-panel").toggle("show");
  428. }
  429. }
  430. function getQuickReplayList(){
  431. consultingAPI.getReplyList({type: 1}).then(function(res){
  432. if(res.status == 200){
  433. count ++;
  434. formatReplyList(res.data);
  435. //渲染前4条记录
  436. var list = quickReplyList.slice(0, 4),
  437. html = template("quick_reply_tmp", {list: list});
  438. $(".quick-reply-panel ul").empty().append(html);
  439. //判断问卷是否填写
  440. getFollowupContentList();
  441. }else{
  442. showErrorMsg(res.msg);
  443. }
  444. })
  445. }
  446. function formatReplyList(data){
  447. quickReplyList = _.map(data, function(o){
  448. //"systag":0为医生自定义消息,大于0的为系统该消息,1体征生活方式 2症状 3血糖 4血压
  449. if(o.systag == 1 || o.systag == 2){
  450. o.name = "survey"; //问卷
  451. }else if(o.systag == 3 || o.systag == 4){
  452. o.name = "test"; //体检
  453. }else{
  454. o.name = "";
  455. }
  456. if(o.systag == 1 || o.systag == 3){
  457. o.tagType = 2;
  458. }else if(o.systag == 2 || o.systag == 4){
  459. o.tagType = 1;
  460. }else{
  461. o.tagType = 0;
  462. }
  463. return o;
  464. });
  465. }
  466. //获得问卷列表,判断个问卷是否已经填写
  467. function getFollowupContentList(){
  468. var params = {
  469. prescriptioncode: prescriptionCode
  470. };
  471. consultingAPI.getFollowupCountList(params).then(function(res){
  472. if(res.status == 200){
  473. //'type': '1',//1身份异常症状问卷,2体征及生活方式调查问卷
  474. // 'statue': '1',//1已填写,2未填写
  475. var len = res.data.length;
  476. for(i=0; i<len; i++){
  477. var item = res.data[i];
  478. if(item.type == '1'){
  479. survey_1_obj = item;
  480. }
  481. if(item.type == '2'){
  482. survey_2_obj = item;
  483. }
  484. }
  485. }else{
  486. showErrorMsg(res.msg);
  487. }
  488. })
  489. }
  490. function bindReplyEvents(){
  491. $("body").on('click', ".reply-item", function(){
  492. var $this = $(this),
  493. json = $this.data("json"),
  494. name = json.name,
  495. type = json.tagType;
  496. var params = {
  497. prescriptionCode: prescriptionCode,
  498. type: type,
  499. followupid: fv_id
  500. };
  501. if(name == "test"){ //发送血糖血压快捷回复咨询
  502. consultingAPI.addPrescriptionBloodStatusConsult(params).then(function(res){
  503. if(res.status == 200){
  504. $(".quick-reply-panel").hide();
  505. layer.close(layer.index);
  506. //发送成功后,socket会响应退出最新的消息
  507. }else{
  508. showErrorMsg(res.msg);
  509. }
  510. })
  511. }else if(name == "survey"){//发送问卷快捷回复咨询
  512. //判断是否已经填写过问卷
  513. if(type == '1' && survey_1_obj.statue == '1'){
  514. var content = "居民"+patiName+"已在"+survey_1_obj.createtime+"填写"+survey_1_obj.name;
  515. layer.open({
  516. title: " ",
  517. content: content,
  518. skin: 'alert-info',
  519. btn: ['查看问卷'],
  520. yes: function(index){
  521. parent.gotoPrescriptionTab(8);
  522. layer.close(index);
  523. }
  524. });
  525. return false;
  526. }
  527. if(type == '2' && survey_2_obj.statue == '1'){
  528. var content = "居民"+patiName+"已在<br/>"+survey_2_obj.createtime+"填写"+survey_2_obj.name;
  529. layer.open({
  530. title: " ",
  531. content: content,
  532. skin: 'alert-info',
  533. btn: ['查看问卷'],
  534. yes: function(index){
  535. parent.gotoPrescriptionTab(8);
  536. layer.close(index);
  537. }
  538. });
  539. return false;
  540. }
  541. consultingAPI.addPrescriptionFollowupContentConsult(params).then(function(res){
  542. if(res.status == 200){
  543. layer.close(layer.index);
  544. $(".quick-reply-panel").hide();
  545. //发送成功后,socket会响应退出最新的消息
  546. }else{
  547. showErrorMsg(res.msg);
  548. }
  549. })
  550. }else{
  551. //发送普通文本
  552. sendMessage(1, json.content);
  553. var obj = {
  554. content: json.content,
  555. content_type: '1',
  556. sender_id: docInfo.code,
  557. timestamp: new Date().getTime()
  558. }
  559. var html = formatMsg(obj);
  560. $("#talkBox").append(html);
  561. $("#talkBox").slimscroll({
  562. scrollTo: 'bottom'
  563. });
  564. layer.close(layer.index);
  565. $(".quick-reply-panel").hide();
  566. }
  567. });
  568. $("body").on("click", '.addMore', function(){
  569. showReplyListPanel();
  570. $(".quick-reply-panel").hide();
  571. })
  572. template.helper("getJsonStr", function(obj){
  573. if(typeof obj == "object"){
  574. return JSON.stringify(obj);
  575. }else{
  576. return "";
  577. }
  578. });
  579. $("body").on("click", ".del-icon", function(e){
  580. e.stopPropagation();
  581. var $this = $(this),
  582. $parent = $this.closest(".reply-item"),
  583. json = $parent.data("json"),
  584. systag = json.systag;
  585. if(systag > 0){
  586. layer.msg('系统默认回复内容不可删除');
  587. }else{
  588. //删除快捷回复
  589. consultingAPI.deleteQuickReply({id: json.id}).then(function(res){
  590. if(res.status == 200){
  591. showSuccessMsg(res.msg);
  592. $parent.remove();
  593. //将quickReplyList数组中对应的元素删除
  594. for(i=0; i< quickReplyList.length; i++){
  595. var item = quickReplyList[i];
  596. if(item.id == json.id){
  597. quickReplyList.splice(i, 1);
  598. break;
  599. }
  600. }
  601. }else{
  602. showErrorMsg(res.msg);
  603. }
  604. });
  605. }
  606. });
  607. $("body").on('click', '.up-icon', function(e){
  608. e.stopPropagation();
  609. var li = this.parentNode.parentNode;
  610. if(li.previousElementSibling){
  611. swapNode(li,li.previousElementSibling);
  612. }
  613. });
  614. $("body").on('click', '.down-icon', function(e){
  615. e.stopPropagation();
  616. //通过链接对象获取表格行的引用
  617. var li = this.parentNode.parentNode;
  618. //如果不是最后一行,则与下一行交换顺序
  619. if(li.nextElementSibling){
  620. swapNode(li,li.nextElementSibling);
  621. }
  622. })
  623. }
  624. function showReplyListPanel(){
  625. //准备content html 内容
  626. var html = template('reply_tmp', {list: quickReplyList});
  627. layer.open({
  628. type: "1",
  629. title: '<img src="img/shezi_tankuang_icon.png" class="mr10">快捷回复设置',
  630. content: html,
  631. area: ['430px', '360px'],
  632. skin: 'quick-reply-setting',
  633. btn: ['添加', '取消'],
  634. yes: function(index){
  635. var html2 = '<div class="pl30 pr20"><p>回复内容:</p><textarea style="margin:0px; width: 100%; height: 80px;" maxlength="100" id="reply_content"></textarea></div>';
  636. layer.open({
  637. type: "1",
  638. title: '<img src="img/shezi_tankuang_icon.png" class="mr10">添加自动回复',
  639. content: html2,
  640. area: ['420px', '227px'],
  641. skin: 'quick-reply-setting',
  642. btn: ['确定', '取消'],
  643. yes: function(index2){
  644. var text = $.trim($("#reply_content").val());
  645. saveNewReply(text, index2);
  646. }
  647. });
  648. }
  649. });
  650. }
  651. //定义通用的函数交换两个结点显示的内容,不移动DOM
  652. function swapNode(node1,node2){
  653. //获取两个节点的json数据和content数据
  654. var json1 = $(node1).attr("data-json"),
  655. content1 = $(node1).find(".content").text(),
  656. id1 = $(node1).data("id"),
  657. json2 = $(node2).attr("data-json"),
  658. content2 = $(node2).find(".content").text(),
  659. id2 = $(node2).data("id");
  660. $(node1).attr("data-json", json2);
  661. //data修改和attr修改不一致
  662. $(node1).data("id", id2);
  663. $(node1).attr("data-id", id2);
  664. $(node1).find(".content").text(content2);
  665. $(node2).attr("data-json", json1);
  666. $(node2).data("id", id1);
  667. $(node2).attr("data-id", id1);
  668. $(node2).find(".content").text(content1);
  669. //请求排序接口
  670. sortQuickReply();
  671. }
  672. function sortQuickReply(){
  673. var $lis = $(".reply-list2 li"),
  674. len = $lis.length,
  675. ids = [];
  676. for(i=0; i<len; i++){
  677. var $li = $($lis[i]),
  678. id = $li.data("id");
  679. ids.push(id);
  680. }
  681. //重新排序
  682. var params = {
  683. id: ids.join(","),
  684. type: 1 //"type":1,//快捷回复类型(1为续方咨询,0为健康咨询)
  685. };
  686. consultingAPI.sortList(params).then(function(res){
  687. consultingAPI.getReplyList({type: 1}).then(function(res){
  688. if(res.status == 200){
  689. formatReplyList(res.data);
  690. }
  691. })
  692. })
  693. }
  694. function saveNewReply(text, layerIndex){
  695. var params = {
  696. content: text,
  697. type: 1
  698. }
  699. consultingAPI.addQuickReply(params).then(function(res){
  700. if(res.status == 200){
  701. showSuccessMsg("保存成功");
  702. consultingAPI.getReplyList({type: 1}).then(function(res){
  703. if(res.status == 200){
  704. formatReplyList(res.data);
  705. //重新渲染列表
  706. var html = template('reply_tmp', {list: quickReplyList});
  707. var preLayerIndex = layerIndex - 1;
  708. $("#layui-layer"+preLayerIndex).find(".layui-layer-content").empty().append(html);
  709. layer.close(layerIndex);
  710. }
  711. })
  712. }else{
  713. showErrorMsg(res.msg);
  714. }
  715. });
  716. }