123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));
- function showSuccessMessage(msg) {
- layer.msg(msg, {
- icon: 1
- })
- }
- function showErrorMessage(msg) {
- layer.msg(msg, {
- icon: 5
- })
- }
- function showWarningMessage(msg) {
- layer.msg(msg, {
- icon: 2
- })
- }
- function showInfoMessage(msg) {
- layer.msg(msg, {
- icon: 6
- })
- }
- var TemplateItems = {
- template: '<div style="height: 100%;">\
- <div class="title-name c-f16">\
- <span class="c-vam">{{name}}</span>\
- </div>\
- <div v-show="!items.length" class="c-t-center" style="margin-top: 200px;">\
- <img src="../../../images/fanhui_icon.png" class="c-vam"/>请在左侧“服务项”列表中选择\
- </div>\
- <div class="template-items" v-show="items.length">\
- <div v-for="(item, index) in items">\
- <div class="item-card ptb10 plr15 mt10" v-for="(o, i) in item.list">\
- <div class="c-nowrap">{{o.name}}</div>\
- <div class="c-row c-f14 mt5">\
- <div class="c-50">\
- <span class="c-909090">执行人员:</span>\
- <span v-if="!o.type" class="c-909090">家庭医生</span>\
- <span v-else class="c-909090">{{o.type==1?\'家庭医生\':\'专科医生\'}}</span>\
- </div>\
- <div class="c-50 c-hide">\
- <span class="c-909090">医  院:</span>\
- <span class="c-909090">待选择</span>\
- </div>\
- </div>\
- <div class="c-row c-f14 mt5">\
- <div class="c-50">\
- <span class="c-909090">计划时间:</span>\
- <span class="c-909090" v-if="item.list.length==1 && !o.executeTimes">不限频次</span>\
- <span class="c-909090" v-else>{{o.frequencyName||\'待选择\'}}</span><img v-if="o.code!=2 && o.code!=3" class="ml15" @click="showDialog(o,index,i)" style="width:16px;height: 16px;vertical-align: middle;" src="../../../images/bianji_icon.png"></img>\
- </div>\
- <el-dialog\
- title="计划时间"\
- :visible.sync="dialogVisible"\
- width="34%"\
- :before-close="handleClose">\
- <div class="c-t-center">\
- <div class="c-t-left mb20">任务项目:{{seletc[\'name\']}}</div>\
- <div class="mb10 ui-grid ui-grid-middle">\
- <div class="ui-col-0">频  次:</div>\
- <el-select class="ui-col-1" v-model="seletc[\'frequency\']" placeholder="请选择" @change="selectFrequency">\
- <el-option\
- v-for="item in frequencysList1"\
- :key="item.name"\
- :label="item.name"\
- :value="item.name">\
- </el-option>\
- </el-select>\
- </div>\
- <div v-show="seletc[\'frequency\']!=\'不限频次\'" class="mb10 ui-grid ui-grid-middle">\
- <div class="ui-col-0">执行时间:</div>\
- <el-select class="ui-col-1" v-model="seletc[\'time\']" placeholder="请选择" @focus="selectTime">\
- <el-option\
- v-for="item in multipleTimeArr"\
- :key="item.code"\
- :label="item.name"\
- :value="item.code">\
- </el-option>\
- </el-select>\
- </div>\
- <div v-show="seletc[\'frequency\']!=\'不限频次\'" class="mb10 ui-grid ui-grid-middle">\
- <div class="ui-col-0">执行人员:</div>\
- <el-select class="ui-col-1" v-model="seletc[\'doctor\']" placeholder="请选择">\
- <el-option\
- v-for="item in doctorList"\
- :key="item.name"\
- :label="item.name"\
- :value="item.code">\
- </el-option>\
- </el-select>\
- </div>\
- </div>\
- <span slot="footer" class="dialog-footer">\
- <el-button @click="dialogVisible = false">取 消</el-button>\
- <el-button type="primary" @click="confirmTaskItem(items[index].list[i])">确 定</el-button>\
- </span></el-dialog>\
- <div class="c-50 setSelect" v-if="i==0">\
- <span class="c-909090">费  用:</span>\
- <el-input-number v-model="item.expense" :step="1" :min="0" size="mini"></el-input-number> 元\
- </div>\
- </div>\
- <img v-if="name!=\'系统模板\'" src="../../../images/qingchu_icon.png" class="item-delete-btn" @click.stop="deleteItem(o, i)"/>\
- </div>\
- </div>\
- </div>\
- <div class="foot-btns">\
- <a class="delete-btn c-t-center mr50" @click="deleteTemplate">\
- 删除模板\
- </a>\
- <a class="save-btn c-t-center" @click="saveTemplate">\
- 保存模板\
- </a>\
- </div>\
- </div>',
- props: [],
- data: function() {
- return {
- name: '',
- items: [],
- isNew: null,
- templateId: "",
- dialogVisible:false,
- item: null,
- seletc:{'frequency':'','time':'','doctor':'','name':'','index':'','i':''},
- selectFrequencyItem:null,
- multipleTimeList:{},
- multipleTimeArr:[],
- doctorList:[{name:'家庭医生',code:1},{name:'专科医生',code:2}], //执行人员列表
- frequencysList1:[{'code':'','name':'不限频次'},{"code":"qd_10-week1","name":"1周/次","type":1,mode:"week"},
- {"code":"qd_10-week1","name":"2周/次","type":2,mode:"week"},
- {"code":"qd_10-month1","name":"1月/次","type":1,mode:"month"},
- {"code":"qd_10-month1","name":"2月/次","type":2,mode:"month"},
- {"code":"qd_10-month1","name":"3月/次","type":3,mode:"month"}], //频次列表-multiple
- options:[{label:'0',value:'0'}]
- }
- },
- beforeRouteEnter: function (to, from, next) {
- next(function(vm) {
- var query = vm.$route.query
- vm.name = query.name || '模板未命名',
- vm.templateId = query.templateId
- if(from.path != "/template-item-detail" || from.path == "/") {
- vm.items = []
- }
-
- if(vm.isNew == true || vm.isNew === "true") {
- vm.isNew = true
- } else {
- vm.isNew = false
- }
- })
- },
- created: function() {
- var vm = this
- // 点击添加 初始化数据
- EventBus.$on("add-template-item", function(o) {
- if(o.isInit){
- vm.items.push(o)
- }else{
- var isEast=_.findIndex(vm.items,{code:o.code})
- if(isEast==-1){
- o.list=[{}]
- o.expense=0
- vm.items.push(o)
- }else{
- _.map(vm.items,function(item){
- if(item.code==o.code){
- item.list.push({})
- return item
- }
- })
- }
- }
- _.map(vm.items, function (item) {
- if(item.list.length>=1){
- _.map(item.list,function(it){
- !it.executeTimes?it.frequencyName='待选择':''
- return it
- })
- }
- return item
- })
- _.map(vm.items, function (item) {
- _.map(item.list,function(it){
- it.name=item.name
- it.code=item.code
- return it
- })
- return item
- })
- vm.$forceUpdate()
- })
- },
- mounted: function() {
- var vm = this
- vm.initTimeData()
-
- },
- methods: {
- deleteItem: function(o, i) {
- var vm = this
- o.enable = true
- _.some(vm.items,function(item,index){
- if(item.code==o.code){
- item.list.splice(i, 1)
- if(item.list.length==0){
- vm.items.splice(index,1)
- }
- return true
- }
- })
- vm.$forceUpdate()
- EventBus.$emit("delete-template-item", o,i,vm.items)
- },
- initTimeData:function(){
- var vm=this
- vm.multipleTimeList ={"week":[],"month":[]}
- for(var i=1;i<=28;i++){
- switch(i){
- case 1:vm.multipleTimeList.week.push({name:"周一",code:String(i)});break;
- case 2:vm.multipleTimeList.week.push({name:"周二",code:String(i)});break;
- case 3:vm.multipleTimeList.week.push({name:"周三",code:String(i)});break;
- case 4:vm.multipleTimeList.week.push({name:"周四",code:String(i)});break;
- case 5:vm.multipleTimeList.week.push({name:"周五",code:String(i)});break;
- case 6:vm.multipleTimeList.week.push({name:"周六",code:String(i)});break;
- case 7:vm.multipleTimeList.week.push({name:"周日",code:String(i)});break;
- default:break;
- }
- // if(i<=7){
- vm.multipleTimeList.month.push({name:i+"号",code:String(i)})
- // }
- }
- },
- // 编辑按钮
- showDialog:function(item,index,i){
- this.seletc['frequency']=item.frequencyName
- if(this.seletc['frequency']=='待选择'){
- this.seletc['frequency']='不限频次'
- }
- // 根据频率获取执行时间选择返回
- if(this.seletc['frequency']){
- this.selectFrequencyItem=_.find(this.frequencysList1,{'name':this.seletc['frequency']})
- this.multipleTimeArr=this.multipleTimeList[this.selectFrequencyItem.mode]
- }
- this.seletc['doctor']=item.type
- this.seletc['time']=item.dateCode
- this.seletc['name']=item.name
- this.seletc['index']=index
- this.seletc['i']=i
- this.dialogVisible = true
- },
- // 点击同意按钮
- confirmTaskItem:function(){
- var index=this.seletc['index'],
- i=this.seletc['i'],
- item=this.items[index].list[i];
- if(this.seletc['frequency']=='不限频次'){
- var list=[{'name':item.name,'code':item.code,'frequencyName':'不限频次'}]
- this.items.splice(index,1,{'code':item.code,'name':item.name,'expense':0,list})
- this.dialogVisible = false
- return
- }
- item.type=this.seletc['doctor']
- item.dateCode=this.seletc['time']
- item.dateCode?item.dateName=_.find(this.multipleTimeArr,{'code':this.seletc['time']}).name:''
- item.frequencyName=this.selectFrequencyItem.name
- item.frequencyCode=this.selectFrequencyItem.code
- if(item.dateCode){
- item.date=getFreDateArr(this.selectFrequencyItem.mode+this.selectFrequencyItem.type, Number(item.dateCode)).map(function(o) {return o.format("YYYY-MM-DD")})
- item.executeTimesArr = _.map(item.date,function(citem){
- return citem+" 00:00"
- })
- item.executeTimes=item.executeTimesArr.join(",")
- }
- this.dialogVisible = false
- },
- selectFrequency:function(){
- this.selectFrequencyItem=_.find(this.frequencysList1,{'name':this.seletc['frequency']})
- this.multipleTimeArr=this.multipleTimeList[this.selectFrequencyItem.mode]
- },
- selectTime:function(item){
- if(!this.seletc['frequency']){
- showErrorMessage('请先选择频次')
- return false
- }
- },
- handleClose:function(){
- this.dialogVisible = false
- },
- saveTemplate: function() {
- var vm = this
- //检查有频次时(同一个服务项超过1个)计划时间是否填写完整
- var ispass=_.every(vm.items,function(item){
- if(item.list.length>1){
- return _.every(item.list,function(it){
- return it.dateCode && it.type && it.frequencyCode
- })
- }else{
- return true
- }
- })
- if(!ispass){
- showErrorMessage('请完善计划时间')
- return false
- }
- var ispass1=_.every(vm.items,function(item){
- if(item.code!='2'&&item.code!='3'){
- return _.every(item.list,function(it,index){
- return _.every(item.list,function(i,ind){
- if(index!=ind){
- var same=_.intersection(it.executeTimesArr,i.executeTimesArr)
- if(same.length>0){
- return false
- }else{
- return true
- }
- }else{
- return true
- }
- })
- })
- }else{
- return true
- }
- })
- if(!ispass1){ //时间重复
- showErrorMessage('存在重复时间')
- return false
- }
- _.map(vm.items, function (item) {
- item.plan=[]
- // 过滤有执行时间的数组
- var arr=[]
- arr=_.filter(item.list,function(ee){
- return ee.executeTimes
- })
- item.num=arr.length
- _.map(item.list,function(it){
- it.name=item.name
- it.code=item.code
- return it
- })
- // 存在执行时间
- if(item.num){
- item.plan =item.list||[]
- item.remark=item.list[0].remark
- _.map(item.plan,function(item2){
- item2.executeTimes?item2.executeTimesArr=item2.executeTimes.split(','):''
- item2.mode='multiple' //模板
- item2.show=false
- if(item2.type){
- item2.doctorName=item2.type==1?'家庭医生':'专科医生'
- }else{
- item2.doctorName=''
- }
- item2.doctor=item2.type
- _.map(vm.frequencysList1,function(it){
- if(it.name==item2.frequencyName){
- item2.frequencyName?item2.frequencyCode=it.code:''
- }
- })
- item2.date=_.map(item2.executeTimesArr,function(item3){
- return item3.substring(0,item3.length-6)
-
- })
- return item2
- })
- }
- return item
- })
-
- var params = []
- _.each(vm.items, function (item, index) {
- if (item.plan && item.plan.length) {
- _.each(item.plan, function (citem, cindex) {
- var param = {
- 'templateId': vm.templateId,
- "hospitalServiceItemId": item.code,
- "type": citem.type, //1家医2专医
- "executeTimes": citem.executeTimes,
- "frequencyCode": citem.frequencyCode.split("-")[0],
- 'frequencyName':citem.frequencyName,
- 'dateName':citem.dateName,
- 'dateCode':citem.dateCode,
- "timeType": 0, //1白天2晚上0全天
- 'expense':item.expense||0,
- "remark": item.remark,
- }
- params.push(param)
- })
- } else {
- var param = {
- 'templateId': vm.templateId,
- "hospitalServiceItemId": item.code,
- "type": '', //1家医2专医
- "executeTimes": "",
- "frequencyCode": "",
- "timeType": 0, //1白天2晚上0全天
- 'expense':item.expense||0,
- "remark": ""
- }
- params.push(param)
- }
- })
- vm.loading.showModal()
- rehaAPI.createTemplateDetail({
- doctor: docInfo.uid,
- json:JSON.stringify(params),
- type: vm.isNew?"create":"edit"
- }).then(function(res) {
- if(res.status == 200) {
- vm.loading.close()
- showSuccessMessage('保存成功')
- EventBus.$emit("refresh-index")
- vm.$router.replace("/")
- } else {
- vm.loading.close()
- showErrorMessage(res.msg)
- }
- }).catch(function(e) {
- vm.loading.close()
- console.error(e)
- })
- },
- deleteTemplate: function() {
- var vm = this
- if(this.name=='系统模板'){
- showErrorMessage('不能删除系统模板!')
- return false
- }
- layer.confirm('确定删除该模板?', {
- btn: ['确认','取消'] //按钮
- }, function(){
- vm.loading.showModal()
- rehaAPI.deleteTemplate({
- templateId: vm.templateId
- }).then(function(res) {
- vm.loading.close()
- if(res.status == 200) {
- showSuccessMessage('删除成功')
- } else {
- showErrorMessage(res.msg)
- }
- EventBus.$emit("refresh-index")
- vm.$router.replace("/")
- }).catch(function(e) {
- vm.loading.close()
- console.error(e)
- })
- }, function(){
- });
- },
- toDetail: function(o) {
- var vm = this
- vm.item = o
- vm.$router.push({
- path:"/template-item-detail",
- query: {
- templateId: vm.templateId,
- itemId: o.code
- }
- })
-
- }
- },
- // watch: {
- // '$route': function (to, from) {
- // var vm = this
- //// if(to.path == "/template-item-detail" && (from.path != "/template-item-detail" || from.path == "/")) {
- //// EventBus.$emit("show-item-detail", vm.item)
- //// }
- // if(to.path == "/template-item-detail") {
- // EventBus.$emit("show-item-detail", vm.item)
- // }
- // }
- // }
- }
|