create-apply-bills.vue 33.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
<template>
    <div class="container resource close-left-menu">
        <div class="pop-banner clearfix">
            <div class="operate-btns">
                <a class="fbtn fb-select" @click='select'>选择模板</a>
                <upload-excel-plan :class="['fbtn fb-upload']"
                                   :tag="tagType"
                                   :type="fileType"
                                   :label="fileLabel"
                                   :exceltype="med"
                                   v-on:file-change="getBackTips"
                ></upload-excel-plan>
                <!-- <a class="fbtn "></a> -->
                <a class="fbtn fb-download" @click='open'>下载导入文件</a>
            </div>
            <!-- <span class="view-title"></span> -->
            <h3 class="current-module">制定申领单</h3>
        </div>
        <div class="purchase-add-plan">
            <div class="fpart pd-form">
                <div class="fheader">
                    <h4 class="fh-shop">科室申领单</h4>
                    <div class="from-button fr">
                        <a href="javascript:;" class="green-button icon save" @click='save'>保存<i>|</i></a>
                        <a href="javascript:;" class="blue-button icon delivery" @click='submit'>提交</a>
                    </div>
                    <div class="fl pap-tit-right">
                        <div class="checkbox-control checkbox-inline">
                            <input type="checkbox" name="cb" id="cball" v-model="collectionflag">
                            <label class="checkbox" for="cball">收藏为订单模版</label>
                        </div>
                        <input type="text" placeholder="请为模版起个好名字" v-model="collectionName">
                    </div>
                </div>
                <div class="group-row group-row-3">
                    <div class="form-group form-label">
                        <label for="cn1" class="label">单据单号</label>
                        <div class="control">
                            <input type="text" id="cn1" v-model="trmedplan.billno" readonly="readonly" class="inp4">
                        </div>
                    </div>
                    <div class="form-group form-label">
                        <label for="cn2" class="label">制单人</label>
                        <div class="control">
                            <input type="text" id="cn2" v-model="trmedplan.operatername" readonly="readonly" class="inp3">
                        </div>
                    </div>
                    <div class="form-group form-label">
                        <label for="cn3" class="label">执行状态</label>
                        <div class="control">
                            <input type="text" id="cn3" :model="trmedplan.billstate | applyState" readonly="readonly" class="inp4">
                        </div>
                    </div>
                </div>
                <div class="group-row group-row-3">
                    <div class="form-group form-required form-label">
                        <label for="cn4" class="label">申领日期</label>
                        <div>
                            <input type="text" id="cn4" :model="trmedplan.applydate | getYMD" readonly="readonly" class="inp4">
                        </div>
                    </div>
                    <div class="form-group form-label form-required">
                        <label for="cn5" class="label">库房</label>
                        <div class="control form-label">
                            <select id="cn5" class="inp2" v-model="trmedplan.depotguid" @change="detchange()">
                                <option selected>请选择</option>
                                <option v-for='item in storageList' :value="item.value">{{item.label}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group form-required form-label">
                        <label for="cn6" class="label w120">申领科室</label>
                        <div class="control form-label">
                            <select id="cn5" class="inp4" v-model="trmedplan.meddeptguid">
                                <option selected>请选择</option>
                                <option v-for='item in officeList' :value="item.value">{{item.label}}</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="form-group form-label">
                    <label for="cn13" class="label">备注</label>
                    <div class="control">
                        <textarea id="cn13" v-model="trmedplan.memo" class="inp2" rows="1"></textarea>
                    </div>
                </div>
            </div>
            <table class="itable itable-thead-13px itable-td-long-text">
                <thead>
                <tr>
                    <th class="w50">序号</th>
                    <th class="w230 t-left">
                        <div class="p-lr-10">商品</div>
                    </th>
                    <th class="w120">生产厂商</th>
                    <th class="w120">商品编码</th>
                    <th class="w120">注册证号</th>
                    <th class="w120">规格</th>
                    <th class="w70">单位</th>
                    <th class="w70">最小单位</th>
                    <th class="w100">申领数量</th>
                    <th class="w120">操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="item in goodList">
                    <td>
                        <div>{{$index+1}}</div>
                    </td>
                    <td class="t-left pr10">{{item.goodsname}}</td>
                    <td class="t-left pr10">{{item.producer}}</td>
                    <td class="t-left pr10">{{item.goodscode}}</td>
                    <td class="t-left pr10">{{item.registkey}}</td>
                    <td>{{item.goodsspec}}</td>
                    <td>{{item.unit}}</td>
                    <td>{{item.minunit}}</td>
                    <td><input type="text" v-model="item.applyqty" style='width:50px;'></td>
                    <td>
                        <a href="javascript:;" class="btn button-red" @click='remove($index)'>删除</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div></div>
                    </td>
                    <td class="t-left">
                        <div class="control w230 h-30 fl">
                            <input id="cn1" type="text" maxlength="50" v-rule v-model="medname" title='请输入商品名称' @click='state=true' placeholder="商品名称、编号、厂商、注册证号">
                            <div class="select-template" id="searchMore" v-if='state'>
                                <div class="div-select before-none" style="width:100%;">
                                    <ul  style="z-index:3;top:0px;width:300%; margin-top: 0px;">
                                        <li class="div-select-item pl10 hover-none" style='line-height:20px;height:auto;'>
                                            <table class="itable itable-thead-13px itable-td-long-text">
                                                <thead id="t_header">
                                                </thead>
                                                <tbody>
                                                <tr v-for="item in goodsList" @click='goodsData(item)' track-by="$index">
                                                    <td class="w50">
                                                        <div>{{$index+1}}</div>
                                                    </td>
                                                    <td class="t-left w260">
                                                        {{item.goodsname}}
                                                    </td>
                                                    <td class="t-left w120">{{item.producer}}</td>
                                                    <td class="t-left pr10 w120">{{item.goodscode}}</td>
                                                    <td class="t-left w120">{{item.registkey}}</td>

                                                    <td class="t-left w120">{{item.goodsspec}} </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </li>
                                        <li class="div-select-item pl10" v-show="goodsList.length==0 || goodsList == undefined">
                                            <span style="width:100%;">未查询到结果!</span>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="modal" v-if='model'>
        <div class="container resource">
            <div class="audit-detail" style="width:740px; margin: 200px zuto; padding: 20px;">
                <span class="close-win" @click='model=false'></span>
                <div class="statistics">
                    您一共有<em>{{total}}</em>个模板,<em>{{totolcountNum}}</em>个品规数。
                </div>
                <div class="ctable ct-parent mt-30">
                    <div class="ct-head" id="t_header">
                        <span class="ct-col w30"></span>
                        <span class="ct-col w70">序号</span>
                        <span class="ct-col w150">模版名称</span>
                        <span class="ct-col w100">品规数</span>
                        <span class="ct-col w80">收藏时间</span>
                        <span class="ct-col w80">收藏人</span>
                    </div>
                    <div class="ct-row" id="ct-r{{$index}}" v-for='item in modelList'>
                        <div class="row-line">
			          <span class="ct-col w30">
			          	<div class="checkbox-control checkbox-alone">
							<input type="checkbox" :id="item.guid" v-model="item.checked" @click='checkbox(item.guid,$index,item.depotguid,item.meddeptguid)'>
							<label :for="item.guid" class="checkbox"></label>
						</div>
			          </span>
                            <span class="ct-col w70">{{$index+1}}</span>
                            <span class="ct-col w150">{{item.name}}</span>
                            <span class="ct-col w100">
			          	<div>
			              <a href="javascript:void(0) " class="text-color-blue" @click="slidedown($index,item.guid)">{{item.detailrecordsum}}</a>
			            </div>
			          </span>
                            <span class="ct-col w80">{{item.collectiontime | getYMD}} <br>{{item.collectiontime | getHMS}}</span>
                            <span class="ct-col w80 pr10" id="isFocus1{{$index}}">
			            {{item.collectionstaffname}}
			          </span>
                        </div>
                        <div class="row-launch" id="row-l1{{$index}}" style='display:none;' >
                            <h3>品规数({{item.detailrecordsum}}</h3>
                            <div class="ctable">
                                <div class="ct-head">
                                    <span class="ct-col w40">序号</span>
                                    <span class="ct-col w150">商品名称</span>
                                    <span class="ct-col w100">生产厂商</span>
                                    <span class="ct-col w100">规格</span>
                                    <span class="ct-col w70">单位</span>
                                    <span class="ct-col w70">最小单位</span>
                                    <span class="ct-col w70">申领数量</span>
                                </div>
                                <div class="ct-row" v-for='slide in slideList' id="ct-r1-1{{i2}}{{$index}}">
                                    <div class="row-line">
                                        <span class="ct-col w40">{{$index+1}}</span>
                                        <span class="ct-col w150 t-left pr10">{{slide.goodsname}}</span>
                                        <span class="ct-col w100 break-it t-left pr10">
			                  <span class="break">{{slide.producer}}</span>
			                </span>
                                        <span class="ct-col w100 st-invalid">{{slide.goodsspec}}</span>
                                        <span class="ct-col w70 st-invalid">{{slide.unit}}</span>
                                        <span class="ct-col w70 st-invalid">{{slide.minunit}}</span>
                                        <span class="ct-col w70 st-invalid">{{slide.applyqty}}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="zip" @click="slideup($index)"></div>
                        </div>
                    </div>
                    <div class="pagination page-line">
                        <pagination
                            @page-change="select"
                            :class="['m-20-0']"
                            :page-no.sync="search.pageNo"
                            :total-pages.sync="search.totalPages"></pagination>
                    </div>
                </div>
                <div class="from-button" style='margin:50px 0 0 290px;'>
                    <a href="javascript:;" class="green-button p-lr-10" @click='confirm'>确定<i>|</i></a>
                    <a href="javascript:;" class="red-button p-lr-10" @click='model=false'>取消</a>
                </div>
            </div>
        </div>
    </div>
    <!--star 9-9 弹出导入提示信息-->
    <div class="modal" v-if='errorFlag'>
        <div class="container resource">
            <div class="audit-detail" style="width:540px;">
                <span class="close-win"  v-on:click="errorFlag=false"></span>

                <div class="sdiv-9-9b">
                    <a class="btn-d btn-d-activate btn-d-lg" href="javascript:;">导入信息提示</a>
                </div>
                <div class="status-process wbe-0 clearfix pd20" style="padding-top:0px;">

                    <div class="sp-head sp-headb" v-for="m in errorList">
                  <span class="sp-col w300"  >
                    <span class="control radio-control ">
                      <span>{{m.errorType}}</span>
                    </span>
                  </span>
                    </div>

                </div>
                <div class="sdiv9-9">
                    <button v-on:click="errorFlag=false" class="btn button-red mar-none">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal" v-if='modelFlag'>
        <div class="container resource">
            <div class="audit-detail" style="margin:200px auto;">
                <span class="close-win" @click='close'></span>
                <div class="fheader no-bottom" style="margin-left:100px;">
                    <h4 class="fh-book no-icon">{{storename}}申领单【{{billno}}】已提交成功!</h4>
                </div>
                <div class="pd-form">
                    <a href="javascript:void(0);" class="button-green btn"  style='margin:30px 0 0 200px;' @click='init'>继续制定申领单</a>
                </div>
            </div>
        </div>
    </div>
    <!--新加提示信息 start -->
    <div class="roll-bg" v-show='requestS'>
        <div class="w60" style="margin:0 auto;">
            <img src="/images/roll.gif">
        </div>
        <div class="container resource t-center text-color-red">
            正在处理中,请勿关闭!
        </div>
    </div>
    <!--新加提示信息 end-->
</template>
<script>
    module.exports={
        data: function(){
            return {
                requestS:false,
                noSave:false,
                noSubmit:false,
                fileType:'file',
                tagType:'a',
                med:'importApply',
                fileLabel:'导入外部文件',
                trplanperiod:[],
                listTrmedplanperioddetail:[],
                listTrmedplanperioddetailImg:{},
                operationFlag:"0",
                search: {
                    pageSize: 50,
                    page: 1,
                    totalPages: 0,
                    total: 0,
                    search_EQ_guid: '',
                },
                sh1:true,
                model:false,
                modelFlag:false,
                fourthCheckbox:true,
                trmedplan:{
                    depotguid:'',
                    meddeptguid:''
                },
                storageList:[],
                officeList:[],
                departmentsSearch:{
                    parameter_category:1
                },
                medname:'',
                // 查询的商品列表
                goodsList:[],
                goodList:[],
                state:false,
                HospitalDeptApplyVO:{},
                // 收藏夹名称
                collectionName:'',
                collectionflag:false,
                trmeddeptapply:{

                },
                storename:'',
                billno:'',
                totolcountNum:0,
                total:'',
                slideList:{},
                confirmGuid:'',
                errorList:[],
                errorFlag:false,
                modelList:[],
            };
        },
        methods: {
            getData: function(){
                var self = this;
                self.$set('trmedplan',{});
                Ajax.post('/billType/getTrmeddeptapplyByManual')
                    .then(function (response){
                        var data = response.data;
                        if(data.errorCode == 0){

                            self.$set('trmedplan',response.data.data);
                            // 库房查询
                            self.depart(1);
                            // 科室查询
                            self.depart(2);
                        }else{
                            self.MessageBox({ title:'提示',message:data.message,type:'alert' })
                        }
                    })
            },
            // 科室、库房查询
            depart:function(state){
                var self = this;
                self.departmentsSearch.parameter_category=state;
                Ajax.get('/util/departmentsInfo',self.departmentsSearch)
                    .then(function (response){
                        var data = response.data.data;
                        if(response.data.errorCode==0){
                            if(state==1){
                                self.$set('storageList',response.data.data);
                                // self.$set('trmedplan',Object.assign( {},self.trmedplan, { 'depotguid': self.storageList[0].value}))
                            }else{
                                self.$set('officeList',response.data.data);
                                // self.$set('trmedplan',Object.assign( {},self.trmedplan, { 'meddeptguid': self.officeList[0].value}))
                            }

                        }
                    })
            },
            slidedown: function(index,guid) {
                var self = this;
                Ajax.post('/billType/findCollectionDetail',{'guid':guid})
                    .then(function (response){
                        var res = response.data.data;
                        if(response.data.errorCode == 0){


                            self.$set('slideList',res);

                        }else{
                            self.MessageBox({ title:'提示',message:data.message,type:'alert' })
                        }
                    })
                for(var a=0;a<self.modelList.length;a++){
                    if(a==index){
                        $(".ct-row:eq(" + index + ")").addClass("active");
                        $(".row-launch:eq(" + index + ")").slideDown(400, function() {});
                    }else{
                        $(".row-launch:eq(" + a + ")").slideUp(400, function() {
                            $(".ct-row:eq(" + a + ")").removeClass('active');
                        });
                    }
                }


            },
            // 单选模板
            checkbox:function(guid,index,depotguid,meddeptguid){
                var self = this;
                self.confirmGuid = guid;
                self.trmedplan.depotguid = depotguid;
                self.trmedplan.meddeptguid = meddeptguid;
                for(var a=0;a<self.modelList.length;a++){
                    if(a==index){
                        self.modelList[a].checked=true;
                    }else{
                        self.modelList[a].checked=false;
                    }

                }
                Ajax.post('/billType/findCollectionDetail',{'guid':guid})
                    .then(function (response){
                        var res = response.data.data;
                        if(response.data.errorCode == 0){
                            self.$set('slideList',res);
                        }else{
                            self.MessageBox({ title:'提示',message:data.message,type:'alert' })
                        }
                    })

            },
            // 确定模板
            confirm:function(){
                var self = this;
                self.model=false;
                if(!self.confirmGuid){
                    self.MessageBox({ title:'提示',message:'请选择模板',type:'alert' })
                }
                Ajax.post('/billType/createApplyByCollection',{'guid':self.confirmGuid})
                    .then(function (response){
                        var data = response.data.data;
                        if(response.data.errorCode == 0){
                            // self.$set('slideList',res);
                            // self.$set('trmedplan',res.trmeddeptapply);
                            // self.trmedplan.depotguid = data.trmeddeptapply.depotguid;
                            // self.trmedplan.meddeptguid = data.trmeddeptapply.meddeptguid;
                            self.$set('goodList',data.trmeddeptapplydetailList);
                        }else{
                            self.MessageBox({ title:'提示',message:data.message,type:'alert' })
                        }
                    })
            },
            slideup: function(index) {
                $(".row-launch:eq(" + index + ")").slideUp(400, function() {
                    $(".ct-row:eq(" + index + ")").removeClass('active');
                });
            },
            init:function(){

                this.getData();
                this.modelFlag=false;
                this.billno='';
                this.storename='';
                this.collectionflag=false;
                this.collectionName='';
                this.$set('goodList',[]);
            },
            getBackTips:function(data){
                var self = this;
                // self.depart(2);
                // if(data.errorCode>)
                if(data.errorCode==0){
                    self.$set('trmedplan',data.data.trmeddeptapply);
                    self.$set('goodList',data.data.trmeddeptapplydetailList);
                    self.depart(2);
                }else{
                    self.errorFlag=true;
                    self.$set('errorList', JSON.parse(data.message));
                }

            },
            close:function(){
                var self =this;
                self.collectionflag=false;
                self.collectionName='';
                self.modelFlag=false;
                self.$router.go({ 'path': '/applyBills' });
            },
            // 选择魔板
            select:function(){
                var self = this;
                self.model = true;
                Ajax.post('/billType/findCollectionByStaff',self.search)
                    .then(function (response){
                        var res = response.data.data;
                        if(response.data.errorCode == 0){
                            for(var a=0;a<res.list.length;a++){
                                res.list[a].checked=false;
                            }
                            self.$set('modelList',res.list);
                            self.$set('totolcountNum',res.list[0].num1);
                            self.$set('total',res.total);
                            self.search.totalPages=res.totalPages;

                        }else{
                            self.MessageBox({ title:'提示',message:data.message,type:'alert' })
                        }
                    })

            },
            detchange:function(){
                var self = this;
                this.goodList=[];
                this.goodsList=[];
            },
            remove:function(index){
                var self = this;
                self.goodList.splice(index,1);
            },
            open:function(){
                window.open ('/Hosapply-mp.xls')
            },
            // 查询的数据结果出来
            goodsData:function(data){
                var self = this;
                var state=false;

                if(self.goodList==0){
                    self.goodList.splice(self.goodList.length,1,data);
                }else{
                    for(var a=0;a<self.goodList.length;a++){
                        if(self.goodList[a].goodsguid==data.goodsguid){

                            self.MessageBox({ title:'提示',message:'该商品已存在',type:'alert' });
                            state=true;
                        }

                    }
                    if(!state){
                        self.goodList.splice(self.goodList.length,1,data);
                    }
                }
                // self.goodList.splice(self.goodList.length,1,data);
                // self.goodList.splice(self.goodList.length,1,data);
                self.$set('state',false)
                self.medname='';
                self.$set('goodsList',[]);
            },
            // 商品名称搜索
            mednameGet:function(){
                var self = this;
                if(self.medname==''){
                    return;
                }
                if(self.trmedplan.depotguid == null || self.trmedplan.depotguid == ''){
                    self.MessageBox({ title:'提示',message:'请选择库房!',type:'alert' });
                    return;
                }
                Ajax.post('/billType/findStockGoodsByStore',{'storeguid':self.trmedplan.depotguid,'goodsinfo':self.medname})
                    .then(function (response){
                        var data = response.data;
                        if(data.errorCode == 0){
                            self.$set('goodsList',response.data.data)
                        }else{
                            self.MessageBox({ title:'提示',message:data.message,type:'alert' })
                        }
                    })

            },
            // 保存
            save:function(){
                var self = this;
                var VO = self.HospitalDeptApplyVO;
                if(self.collectionflag && !self.collectionName.trim()){
                    self.MessageBox({ title:'提示',message:'请填写保存的魔板名称!',type:'alert' })
                }
                // 申领数量校验
                if(self.goodList.length<=0){
                    self.MessageBox({ title:'提示',message:'请选择需要申领的商品!',type:'alert' })
                    return;
                }else{
                    for(var a=0;a<self.goodList.length;a++){
                        if(!self.goodList[a].applyqty || self.goodList[a].applyqty<=0){
                            self.MessageBox({ title:'提示',message:'请正确填写申领数量',type:'alert' })
                        }
                    }
                }
                var depotname,officename,depotguid,meddeptguid;
                for(var a=0;a<self.storageList.length;a++){
                    if(self.storageList[a].value==self.trmedplan.depotguid){
                        depotname=self.storageList[a].label;
                        depotguid=self.storageList[a].value;
                    }
                }

                for(var a=0;a<self.officeList.length;a++){
                    if(self.officeList[a].value==self.trmedplan.meddeptguid){
                        officename=self.officeList[a].label;
                        meddeptguid=self.officeList[a].value;
                    }
                }

                VO.collectionName=self.collectionName;
                VO.collectionflag=self.collectionflag;
                VO.trmeddeptapply=self.trmedplan;
                VO.trmeddeptapplydetailList=self.goodList;
                VO.trmeddeptapply.depotguid=depotguid;
                VO.trmeddeptapply.meddeptguid=meddeptguid;
                VO.trmeddeptapply.depotname=depotname;
                VO.trmeddeptapply.meddeptname=officename;
                VO.trmeddeptapply.inputdate=self.trmedplan.applydate;
                self.requestS = true;
                if(self.noSave){
                    return;
                }
                self.noSave = true;
                Ajax.post('/billType/saveDeptApply',VO)
                    .then(function (response){
                        var res = response.data.data;
                        self.requestS = false;
                        self.noSave = false;
                        if(response.data.errorCode == 0){
                            self.MessageBox({ title:'提示',message:'保存成功!',type:'alert' })
                            self.$set('trmedplan',res.trmeddeptapply);
                            self.$set('goodList',res.trmeddeptapplydetailList)
                        }else{
                            self.MessageBox({ title:'提示',message:response.data.message,type:'alert' })
                        }
                    })


            },
            submit:function(){
                var self = this;
                var VO = self.HospitalDeptApplyVO;
                if(self.collectionflag && !self.collectionName.trim()){
                    self.MessageBox({ title:'提示',message:'请填写保存的魔板名称!',type:'alert' })
                }
                // 申领数量校验
                if(self.goodList.length<=0){
                    self.MessageBox({ title:'提示',message:'请选择需要申领的商品!',type:'alert' })
                    return;
                }else{
                    for(var a=0;a<self.goodList.length;a++){
                        if(!self.goodList[a].applyqty || self.goodList[a].applyqty<=0){
                            self.MessageBox({ title:'提示',message:'请正确填写的申领数量',type:'alert' })
                        }
                    }
                }
                var depotname,officename,depotguid,meddeptguid;
                for(var a=0;a<self.storageList.length;a++){
                    if(self.storageList[a].value==self.trmedplan.depotguid){
                        depotname=self.storageList[a].label;
                        depotguid=self.storageList[a].value;
                    }
                }

                for(var a=0;a<self.officeList.length;a++){
                    if(self.officeList[a].value==self.trmedplan.meddeptguid){
                        officename=self.officeList[a].label;
                        meddeptguid=self.officeList[a].value;
                    }
                }

                VO.collectionName=self.collectionName;
                VO.collectionflag=self.collectionflag;
                VO.trmeddeptapply=self.trmedplan;
                VO.trmeddeptapplydetailList=self.goodList;
                VO.trmeddeptapply.depotguid=depotguid;
                VO.trmeddeptapply.meddeptguid=meddeptguid;
                VO.trmeddeptapply.depotname=depotname;
                VO.trmeddeptapply.meddeptname=officename;
                VO.trmeddeptapply.inputdate=self.trmedplan.applydate;
                self.requestS = true;
                if(self.noSubmit){
                    return;
                }
                self.noSubmit = true;
                Ajax.post('/billType/commitDeptApply',VO)
                    .then(function (response){
                        var res = response.data.data;
                        self.requestS = false;
                        self.noSubmit = false;
                        if(response.data.errorCode == 0){
                            self.modelFlag=true;
                            self.billno=response.data.data.billno;
                            self.storename=response.data.data.storename;
                        }else{
                            self.MessageBox({ title:'提示',message:response.data.message,type:'alert' })
                        }
                    })
            }
        },

        route:{
            activate : function(){
                this.getData();
            }
        },
        watch:{
            'medname':function(){
                var self = this;
                self.mednameGet();
            },
        }
    };
</script>