template-items.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  2. function showSuccessMessage(msg) {
  3. layer.msg(msg, {
  4. icon: 1
  5. })
  6. }
  7. function showErrorMessage(msg) {
  8. layer.msg(msg, {
  9. icon: 5
  10. })
  11. }
  12. function showWarningMessage(msg) {
  13. layer.msg(msg, {
  14. icon: 2
  15. })
  16. }
  17. function showInfoMessage(msg) {
  18. layer.msg(msg, {
  19. icon: 6
  20. })
  21. }
  22. var TemplateItems = {
  23. template: '<div style="height: 100%;">\
  24. <el-dialog\
  25. title="计划时间"\
  26. :visible.sync="dialogVisible"\
  27. width="30%"\
  28. :before-close="handleClose">\
  29. <div>\
  30. <div>任务项目:电话/短信关怀</div>\
  31. <div>\
  32. <el-select v-model="seletc" placeholder="请选择">\
  33. <el-option\
  34. v-for="item in options"\
  35. :key="item.value"\
  36. :label="item.label"\
  37. :value="item.value">\
  38. </el-option>\
  39. </el-select>\
  40. </div>\
  41. </div>\
  42. <span slot="footer" class="dialog-footer">\
  43. <el-button @click="dialogVisible = false">取 消</el-button>\
  44. <el-button type="primary" @click="dialogVisible = false">确 定</el-button>\
  45. </span>\
  46. </el-dialog>\
  47. <div class="title-name c-f16">\
  48. <span class="c-vam">{{name}}</span>\
  49. </div>\
  50. <div v-show="!items.length" class="c-t-center" style="margin-top: 200px;">\
  51. <img src="../../../images/fanhui_icon.png" class="c-vam"/>请在左侧“服务项”列表中选择\
  52. </div>\
  53. <div class="template-items" v-show="items.length">\
  54. <div class="item-card ptb10 plr15 mt10" v-for="(o, i) in items">\
  55. <div class="c-nowrap">{{o.name}}</div>\
  56. <div class="c-row c-f14 mt5">\
  57. <div class="c-50">\
  58. <span class="c-909090">医&emsp;&emsp;院:</span>\
  59. <span class="c-909090">待选择</span>\
  60. </div>\
  61. <div class="c-50">\
  62. <span class="c-909090">执行人员:</span>\
  63. <span class="c-909090">待选择</span>\
  64. </div>\
  65. </div>\
  66. <div class="c-row c-f14 mt5">\
  67. <div class="c-50">\
  68. <span class="c-909090">计划时间:</span>\
  69. <span class="c-909090">待选择</span><img class="ml15" @click="dialogVisible = true" style="width:16px;height: 16px;vertical-align: middle;display:none;" src="../../../images/bianji_icon.png"></img>\
  70. </div>\
  71. <div class="c-50 setSelect">\
  72. <span class="c-909090">费&emsp;&emsp;用:</span>\
  73. <el-input-number v-model="o.expense" :step="1" :min="0" size="mini"></el-input-number>&emsp;元\
  74. </div>\
  75. </div>\
  76. <img v-if="name!=\'系统模板\'" src="../../../images/qingchu_icon.png" class="item-delete-btn" @click.stop="deleteItem(o, i)"/>\
  77. </div>\
  78. </div>\
  79. <div class="foot-btns">\
  80. <a class="delete-btn c-t-center mr50" @click="deleteTemplate">\
  81. 删除模板\
  82. </a>\
  83. <a class="save-btn c-t-center" @click="saveTemplate">\
  84. 保存模板\
  85. </a>\
  86. </div>\
  87. </div>',
  88. props: [],
  89. data: function() {
  90. return {
  91. name: '',
  92. items: [],
  93. isNew: null,
  94. templateId: "",
  95. dialogVisible:false,
  96. item: null,
  97. seletc:'',
  98. frequencysList1:[{"code":"qd_10-week1","name":"1周/次","type":1,mode:"week"},
  99. {"code":"qd_10-week1","name":"2周/次","type":2,mode:"week"},
  100. {"code":"qd_10-month1","name":"1月/次","type":1,mode:"month"},
  101. {"code":"qd_10-month1","name":"2月/次","type":2,mode:"month"},
  102. {"code":"qd_10-month1","name":"3月/次","type":3,mode:"month"}], //频次列表-multiple
  103. options:[{label:'0',value:'0'}]
  104. }
  105. },
  106. beforeRouteEnter: function (to, from, next) {
  107. next(function(vm) {
  108. var query = vm.$route.query
  109. vm.name = query.name || '模板未命名',
  110. vm.templateId = query.templateId
  111. if(from.path != "/template-item-detail" || from.path == "/") {
  112. vm.items = []
  113. }
  114. if(vm.isNew == true || vm.isNew === "true") {
  115. vm.isNew = true
  116. } else {
  117. vm.isNew = false
  118. }
  119. })
  120. },
  121. created: function() {
  122. var vm = this
  123. EventBus.$on("add-template-item", function(o) {
  124. vm.items.push(o)
  125. _.map(vm.items, function (item) {
  126. item.plan=[]
  127. // 过滤有执行时间的数组
  128. var arr=[]
  129. arr=_.filter(item.list,function(ee){
  130. return ee.executeTimes
  131. })
  132. item.num=arr.length
  133. if(item.num){
  134. item.plan =item.list||[]
  135. item.remark=item.list[0].remark
  136. _.map(item.plan,function(item2){
  137. item2.executeTimes?item2.executeTimesArr=item2.executeTimes.split(','):''
  138. item2.mode='multiple' //模板
  139. item2.show=false
  140. item2.doctorName=item2.type==1?'家庭医生':'专科医生'
  141. item2.doctor=item2.type
  142. _.map(vm.frequencysList1,function(it){
  143. if(it.name==item2.frequencyName){
  144. item2.frequencyName?item2.frequencyCode=it.code:''
  145. }
  146. })
  147. item2.date=_.map(item2.executeTimesArr,function(item3){
  148. return item3.substring(0,item3.length-6)
  149. })
  150. return item2
  151. })
  152. }
  153. return item
  154. })
  155. })
  156. },
  157. mounted: function() {
  158. var vm = this
  159. },
  160. methods: {
  161. deleteItem: function(o, i) {
  162. var vm = this
  163. o.enable = true
  164. vm.items.splice(i, 1)
  165. EventBus.$emit("delete-template-item", o, i)
  166. },
  167. handleClose:function(){
  168. },
  169. saveTemplate: function() {
  170. var vm = this
  171. if(this.name=='系统模板'){
  172. showErrorMessage('不能编辑系统模板!')
  173. return false
  174. }
  175. var params = []
  176. _.each(vm.items, function (item, index) {
  177. if (item.plan && item.plan.length) {
  178. _.each(item.plan, function (citem, cindex) {
  179. var param = {
  180. 'templateId': vm.templateId,
  181. "hospitalServiceItemId": item.code,
  182. "type": citem.type, //1家医2专医
  183. "executeTimes": citem.executeTimes,
  184. "frequencyCode": citem.frequencyCode.split("-")[0],
  185. 'frequencyName':citem.frequencyName,
  186. 'dateName':citem.dateName,
  187. 'dateCode':citem.dateCode,
  188. "timeType": 0, //1白天2晚上0全天
  189. 'expense':item.expense,
  190. "remark": item.remark,
  191. }
  192. params.push(param)
  193. })
  194. } else {
  195. var param = {
  196. 'templateId': vm.templateId,
  197. "hospitalServiceItemId": item.code,
  198. "type": '', //1家医2专医
  199. "executeTimes": "",
  200. "frequencyCode": "",
  201. "timeType": 0, //1白天2晚上0全天
  202. 'expense':item.expense,
  203. "remark": ""
  204. }
  205. params.push(param)
  206. }
  207. })
  208. if (params.length == 0) {
  209. mui.toast("请选择配置康复服务项");
  210. return false
  211. }
  212. vm.loading.showModal()
  213. rehaAPI.createTemplateDetail({
  214. doctor: docInfo.uid,
  215. json:JSON.stringify(params),
  216. type: vm.isNew?"create":"edit"
  217. }).then(function(res) {
  218. if(res.status == 200) {
  219. vm.loading.close()
  220. showSuccessMessage('保存成功')
  221. EventBus.$emit("refresh-index")
  222. vm.$router.replace("/")
  223. } else {
  224. vm.loading.close()
  225. showErrorMessage(res.msg)
  226. }
  227. }).catch(function(e) {
  228. vm.loading.close()
  229. console.error(e)
  230. })
  231. },
  232. deleteTemplate: function() {
  233. var vm = this
  234. if(this.name=='系统模板'){
  235. showErrorMessage('不能删除系统模板!')
  236. return false
  237. }
  238. layer.confirm('确定删除该模板?', {
  239. btn: ['确认','取消'] //按钮
  240. }, function(){
  241. vm.loading.showModal()
  242. rehaAPI.deleteTemplate({
  243. templateId: vm.templateId
  244. }).then(function(res) {
  245. vm.loading.close()
  246. if(res.status == 200) {
  247. showSuccessMessage('删除成功')
  248. } else {
  249. showErrorMessage(res.msg)
  250. }
  251. EventBus.$emit("refresh-index")
  252. vm.$router.replace("/")
  253. }).catch(function(e) {
  254. vm.loading.close()
  255. console.error(e)
  256. })
  257. }, function(){
  258. });
  259. },
  260. toDetail: function(o) {
  261. var vm = this
  262. vm.item = o
  263. vm.$router.push({
  264. path:"/template-item-detail",
  265. query: {
  266. templateId: vm.templateId,
  267. itemId: o.code
  268. }
  269. })
  270. }
  271. },
  272. // watch: {
  273. // '$route': function (to, from) {
  274. // var vm = this
  275. //// if(to.path == "/template-item-detail" && (from.path != "/template-item-detail" || from.path == "/")) {
  276. //// EventBus.$emit("show-item-detail", vm.item)
  277. //// }
  278. // if(to.path == "/template-item-detail") {
  279. // EventBus.$emit("show-item-detail", vm.item)
  280. // }
  281. // }
  282. // }
  283. }