settlement.vue 21.6 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
<template>
	<div class="container resource basic-message  close-left-menu clearfix contaNEW" style="min-height: 809px;">

  <div class="pop-banner clearfix">
    <!-- <div class="operate-btns">
    </div> -->
    <h3 class="current-module">生成结算单</h3>
  </div>
  
  
  <!-- start-->
  <div class="basic-message-root fl w280 bgc-none supplylist supply-select">
    
  <!--   <div class="min-search">
      <input class="min-search-txt" type="text" v-model="searchword">
      <button class="min-search-btn" @click="getData"></button>
    </div> --> 
    <div class="data-root h-450 pd0 top">
      <form class="search-bar mb-10" active="###">
        <input type="text" class="w210" placeholder="输入关键字" v-model="searchword">
        <div class="search-btn fl cur-poin" @click="getData">
        </div>
      </form>
      <div class="supplylist-root w280 bd-none" id="sortable">
        <div class="root-node" v-if='ZGfalg'>
          <div class="list-node active" style='background:#f5f5f5;'>
            <span class="node-btns"></span>
            {{ZG.name}}
          </div>
          <div class="list-show" style='background:#f5f5f5;'>
            <div class="checkbox-control bottom-gray" v-for="item in ZG.sonlist">
              <span @click="record(item.name,item.code,'z')" href="javascript:;">{{item.name}}</span>
            </div>
          </div>
        </div>
        <div class="root-node " v-for="items in unZG">
          <div class="list-node active" @click="delivery(items.name)"style='background:#f5f5f5;'>
            <span class="node-btns"></span>
            {{items.name}}
          </div>
          <div class="list-show" style='background:#f5f5f5;'>
            <div class="checkbox-control bottom-gray"  v-for="item in items.sonlist">
              <span @click="record(item.name,item.code,'p',items.code,items.name)" href="javascript:;">{{item.name}}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
<!--     <div class="bmr-result">
      <div class="bmr-result-top clearfix">
        <em>共选择 <i>3</i> 家供应商</em>
      </div>
      <div class="root-node bmr-result-list"  v-if='ZGfalg'>
        <div class="list-node checkbox-control checkbox-bold">
          <span class="node-btn"></span>
          {{ZG.name}}
        </div>
        <div class="list-show checkbox-control">
          <ul class="w200" style="padding-left:10px;margin:0;"  v-for="item in ZG.sonlist">
            <li @click="record(item.name,item.code,'z')">{{item.name}}</li>
          </ul>
        </div>
      </div>
      <div class="root-node bmr-result-list" v-for="items in unZG">
        <div class="list-node checkbox-control checkbox-bold" @click="delivery(items.name)" style="height:30px;">
          <span class="node-btn"></span>
          {{items.name}}
        </div>
        <div class="list-show checkbox-control">
          <ul class="w200" style="padding-left:10px;margin:0;" v-for="item in items.sonlist">
            <li @click="record(item.name,item.code,'p',items.code,items.name)">{{item.name}}</li>
          </ul>
        </div>
      </div>
    </div> -->

  </div> 
  <div class="fr bl-blue pl20 w700">
    <!-- 查询 -->
    <div class="basic-message-search">
      <div class="pd-form fast-search-form mb-0">
        <div class="group-row">
          <div class="form-group w300">
            <div class="control mar-none w300">
              <input type="text" value="" id="cn1" placeholder="入库单号" class="w310"  v-model="wvbillno">
            </div>
          </div>
          <div class="form-group w300">
            <div class="mar-none w300">
              <input type="text" value="" id="cn1" placeholder="商品名称/助记码" class="w310" v-model="goodname">
            </div>
          </div>
        </div>
        <div class="group-row"> 
          <div class="form-group">
            <div class="control control-date w310" style="height:34px;overflow: inherit;">
              <div style="width:44%;float:left;">
                <datepicker :target.sync="search.dateStart" :readonly="readonlyFlag" :placeholder="'开始日期'"styleobj="width:100% !important;border-radius:8px 0px 0px 8px !important;"></datepicker>
              </div>
              <span class="text-and"></span>
               <div style="width:48%;float:left;">
                  <datepicker :target.sync="search.dateEnd"  :readonly="readonlyFlag" :placeholder="'结束日期'"styleobj="width:100% !important;border-radius:0px 8px 8px 0px !important;"></datepicker>
               </div>
            </div>
          </div>
          <button class="fast-search-form-btn btn-d btn-d-lg btn-d-activate btn-d-circle fr" @click="query">查 询</button>
        </div>
        
      </div>
    </div>
<!--     <div class="basic-message-search">
      <div class="pd-form fast-search-form mb-0">
        <div class="group-row">
          <div class="form-group w310">
            <div class="control mar-none">
              <input type="text" placeholder="入库单号" class="w310" v-model="wvbillno">
            </div>
          </div>
          <div class="form-group w310">
            <div class="control mar-none">
              <input type="text" placeholder="商品名称/助记码" class="w310" v-model="goodname">
            </div>
          </div>
        </div>
        <div class="group-row">
           	<div class="form-group">
	          <div class="control control-date ml-0" style="width:336px;">
	            <div style="width:43%;float:left;">
	             <datepicker :target.sync="search.dateStart" :readonly="readonlyFlag" :placeholder="'开始日期'"></datepicker>
            	</div>
              <div class="text-and t-left"></div>
	          <div style="width:43%;float:left;">
	              <datepicker :target.sync="search.dateEnd"  :readonly="readonlyFlag" :placeholder="'结束日期'"></datepicker>
	          </div>  
          	 </div>
            </div>
          <button class="fast-search-form-btn btn-d btn-d-lg btn-d-activate btn-d-circle fr" @click="query">查 询</button>
        </div>
        
      </div>
    </div> -->

    <div class="supplylist-table clearfix mb-20">
      <div class="fheader no-bottom mb-15" v-if="supplier" style="height:70px;  border-bottom: 2px solid #4aa8e5;">
        <span class="fl text-color-gray">供应商</span><h4 class="fh-book no-icon">&nbsp;&nbsp;{{supplierName}}</h4>
        <div class="btn button-green fr icon add" @click="add">添加到待结算明细</div>
      </div>
       <div class="fheader no-bottom" v-if="distributors" style="height:55px;">
        <span class="fl text-color-gray">配送商</span><h4 class="fh-book no-icon f-size16">&nbsp;&nbsp;{{distributorsName}}</h4>
      </div>
       <div class="fl br-hei50" style="width:235px;max-height:465px; overflow-y: auto;">
        <table class=" itable itable-thead-13px" style="width:215px;">
  <!--         <thead>
            <tr>
              <th class="w50">序号</th>
              <th class="w70"></th>
              <th class="w110">商品</th>
              <th class="w140">包装单位</th>
            </tr>
          </thead> -->
          <tbody  >
            <tr style="height:80px;" v-for="item in commodity">
      <!--         <td>
                <div class="checkbox-control">
                    <input type="checkbox" :name="item.billno" :id="item.billno" v-model="item.checked">
                    <label class="checkbox" :for="item.billno"></label>
                </div>
              </td> -->
              <td>
	              <div class="p-lr-10 t-left cur-poin" @click="selected(item.billno)">
	                <span style="font-size:16px;" class="cur-poin fw">{{item.billno}}</span>
	                <br>{{item.mvdate}}
	                <br>
	                <span style="font-size:14px;" class="text-color-blue fW">待结算:{{item.detailsum}}</span>
	              </div>
              </td>
            </tr>
          </tbody>
        </table>
         <!-- <pagination 
   		 @page-change="query"
          :class="['m-20-0']"
   		  :page-no.sync="search.page"
          :total-pages.sync="search.totalPages" v-if="pageFalg">
         </pagination> -->
         
      </div>
     
      <div class="clearfix fr" style="width:440px;max-height:465px; overflow-y: auto;" id=''>
        <table class=" itable itable-thead-13px" style="width:420px;">
  <!--         <thead>
            <tr>
              <th class="w50">序号</th>
              <th class="w70"></th>
              <th class="w110">商品</th>
              <th class="w140">包装单位</th>
            </tr>
          </thead> -->
          <tbody>
            <tr style="height:80px;" v-for="item in selecctList">
              <td class="w60">{{$index+1}}
                <div class="checkbox-control">
                    <input type="checkbox" :id="item.guid+item.medplanrowno" v-model="item.checked">
                    <label class="checkbox checkboxlist-mr" :for="item.guid+item.medplanrowno"></label>
                </div>
              </td>
              <td class="w80">
                <div class="pro-pic" :style="{'background-image': url({{item.pictcontent.path}}+{{item.pictcontent.name}})}">
                  <imagebox v-bind:imgarr="item.pictcontent.path+item.pictcontent.name">
                    <span class="pic-max blue-search"></span>
                  </imagebox>
                </div>
              </td>
              <td class="w140"><div class="p-lr-10 t-left">
              {{item.purchaser_goodsname}}
              <br>{{item.purchaser_goodsspec}}
              <br>{{item.registkey}}
              <br>{{item.manufacturer}}
              </div></td>
              <td class="w80">{{item.purchaserMvqty}}{{item.purchaserMvqty}}<br>{{item.purchaserPrice}}</td>
            </tr>
          </tbody>
        </table>  
      </div>   
    </div>
     <div class="fheader no-bottom pt20" style="border-top:1px solid #4aa8e5;">
        <h4 class="fh-account">待结算商品明细</h4>
        <div class="from-button fr">
          <a href="javascript:;" class="red-button icon remove" @click="remove">全部删除<i>|</i></a>
          <!-- <a href="javascript:;" class="green-button icon again">重新选择<i>|</i></a> -->
          <a href="javascript:void(0);" class="green-button icon create" @click="save">生成结算单</a>
        </div>
       <!--  <div class="btn-d btn-d-lg btn-d-activate cur-poin fr" @click="save">生成结算单</div>
        <div class="btn-d bgc-red btn-d-lg btn-trash cur-poin fr mr-20" @click="remove">全部删除</div> -->
<!--         <div class="btn-d bgc-red btn-d-lg btn-trash cur-poin fr mr-20">删除</div> -->
    </div>
    <div class="ctable-line" style="height:40px;">
       <!--  <section class="big-sums" style="top:-5px;left:10px;">结算周期&nbsp;&nbsp;
          <span class="text-color-blue" style="position:absolute;top:2px;">*</span>
        </section> -->
      <div class="control control-date w310" style="height:34px;overflow: inherit;">
         <div style="width:43%;float:left;height:34px;">
           <datepicker :target.sync="dateStart" :readonly="readonlyFlag" :placeholder="'结算开始日期'"styleobj="width:100% !important;border-radius:8px 0px 0px 8px !important;"></datepicker>
         </div>
         <span class="text-and" style='background-color:#fff;'></span>
         <div style="width:48%;float:left;height:34px;">
          <datepicker :target.sync="dateEnd"  :readonly="readonlyFlag" :placeholder="'结算结束日期'"styleobj="width:100% !important;border-radius:0px 8px 8px 0px !important;"></datepicker>
         </div>  
      </div>
 <!--        <div class="big-sum bd-color-gray2 pd-form" style="font-size:15px;">
          <div class="group-row">
          	<div class="form-group">
	          <div class="control control-date ml-0" style="width:336px;">
	            <div style="width:43%;float:left;padding-top:10px;">
	             <datepicker :target.sync="dateStart" :readonly="readonlyFlag" :placeholder="'结算开始日期'"></datepicker>
            	</div>
              <div class="text-and t-left"></div>
	          <div style="width:43%;float:left;padding-top:10px;">
	              <datepicker :target.sync="dateEnd"  :readonly="readonlyFlag" :placeholder="'结算结束日期'"></datepicker>
	          </div>  
          	 </div>
            </div>
          </div>
        </div> -->
      </div>
    <div class="supplylist-table clearfix">
        <div class="fheader no-bottom">
          <h4 class="fh-book no-icon f-size16">待结算:{{totle}}</h4>
        </div>
    </div>
      <div class="close-right pd-form" style="width:700px;float:none;padding:0px;">
            <table class="itable itable-bordertop itable-thead-13px">
    <!--         <thead>
              <tr>
                <th class="w50">序号</th>
                <th class="w70"></th>
                <th class="w110">商品</th>
                <th class="w140">包装单位</th>
              </tr>
            </thead> -->
            <tbody v-for="item in settle">
              <tr style="height:90px;">
                <td>{{$index+1}}</td>
                <td>
                  <div class="pro-pic" :style="{'background-image': url({{item.pictcontent.path}}+{{item.pictcontent.name}})}" style='border: 1px solid rgba(96, 111, 122, 0.2);'>
                    <imagebox v-bind:imgarr="item.pictcontent.path+item.pictcontent.name">
                      <span class="pic-max blue-search"></span>
                    </imagebox>
                  </div>
                </td>
                <td class="w300"><div class="p-lr-10 t-left">
                {{item.purchaserGoodsname}}
                <br>{{item.purchaserUnit}}
                <br>{{item.registkey}}
                <br>{{item.manufacturer}}
                </div></td>
                <td>{{item.purchaser_mvqty}}{{item.purchaser_unit}}<br>{{item.purchaser_price}}</td>
                <td class="text-color-blue">待结算金额
                  <br>{{item.num4 | numDigit 2}}
                </td>
                <td><a class="btn button-red" @click="del(item.guid,item.rowno)">删除</a></td>
              </tr>
            </tbody>
          </table> 
        </div> 
      </div>
     </div>
     
  
  <!-- end-->


<div class="modal" v-if="modal">
  <div class="container resource">
    <div class="audit-detail" style="margin:200px auto;">
		<span class="close-win" @click="modal=false"></span>
		<div class="fheader no-bottom" style="margin-left:162px;">
        	<h4 class="fh-book no-icon">结算单【{{statement}}】已生成!</h4>
    	</div>
      <div class="pd-form">
         <div class="group-row t-center">
          <a href="javascript:void(0);" class="fast-search-form-btn btn-d btn-d-lg btn-d-activate" @click='next'>查看结算单</a>
          <a href="javascript:void(0);" class="fast-search-form-btn btn-d btn-d-lg btn-d-activate ml-20" @click="init">继续制作结算单</a>
        </div>
      </div>
    </div>
  </div>
</div>
</template>
<script>
  module.exports = {
    data: function () {
      return {
      	modal:false,
      	supplier:false,
      	wvbillno:null,
      	goodname:null,
      	distributors:false,
      	supplierName:'',
      	distributorsName:'',
      	selecctList:{},
      	search:{
      		dateStart:null,
      		dateEnd:null,
      		page:'1',
      		pageSize:'50',
      		totalPages:'1'
      	},
      	dateStart:null,
      	dateEnd:null,
      	flag:'',
      	ZG:{},
      	unZG:{},
      	ZGfalg:true,
      	supplierguid:'',
      	distrbguid:'',
      	commodity:{},	
      	settle:{},
      	totle:'',
      	billno:null,
      	searchword:null,
      	pageFalg:false,
        statement:''
      };
    },
    methods: {
      next:function(){
        window.sessionStorage.setItem('statement',this.statement);
        this.$router.go({'path': '/settlementList'});
        

      },
      getData: function () {
        var self = this;

         Ajax.post('/settle/queryRelation',{'searchword':self.searchword})
         .then(function(response){
         	var res= response.data.data;
         	self.ZG=res.ZG;
         	self.unZG=res.unZG;
         	// self.totalPages=
         	if(self.ZG.name!='直供'){
         		self.ZGfalg=false;
         	}
         })
      },
      //查询订单
      query:function(){
      	var self=this;
      	var search=self.search;
      	if(!search.dateStart ||  !search.dateEnd){
          layer.msg('请选择开始日期和结束日期');
			    return;
      	}

      	if(!self.supplierguid){
          layer.msg('请选择供应商');
			    return;
      	}

      	Ajax.post('/settle/getBillInfor',{
      		'dateStart':search.dateStart,'dateEnd':search.dateEnd,'distrbguid':self.distrbguid,
      		'supplierguid':self.supplierguid,'page':search.page,'pageSize':search.pageSize,
      		'wvbillno':self.wvbillno,'goodname':self.goodname})
          .then(function (response) {
          	if(response.data.errorCode==0){
				self.goods(response);
          	}

          	
          });
      },
      //查询结果数据处理
      goods:function(response){
      	var self=this;
      	var res=response.data.data;
      	if(res.pageNo==undefined || res.pageNo==0){
      		self.search.page=1;
      	}else{
      		self.search.page=res.pageNo;
      	}
      	

      	if(res.list.length>0){
      		self.pageFalg=true;
      	}else{
      		self.pageFalg=false;
      	}
      	self.search.totalPages=res.totalPages;
      	self.commodity=res.list;
        self.selecctList=[];
      },
      //查询已选数据
      selected:function(billno){
      	var self=this;
      	self.billno=billno;
      	Ajax.post('/settle/getBillDetailInfor',{
      		'billno':billno,'distrbguid':self.distrbguid,'supplierguid':self.supplierguid})
          .then(function (response) {
          	var res=response.data.data;
          	for (var i = 0; i <res.length; i++) {
          		res[i].checked=true;
          	}
          	self.selecctList=res;
          });
      },
      add:function(){
      	var guids=[];
        var self=this;
        for(var i=0;i<self.selecctList.length;i++){
          if(self.selecctList[i].checked==true){
            guids.push(self.selecctList[i].guid+"-"+self.selecctList[i].rowno);
          }
        };
      	Ajax.post('/settle/addSelectGoods',{'guids':guids,'supplierguid':self.supplierguid,
         	'distrbguid':self.distrbguid})
          .then(function (response) {
          	if(response.data.errorCode==0){
          		self.final();
          		self.selected(self.billno);
          		self.query();
          	}
          });
      },
      final:function(){
      	var self=this;
      	Ajax.post('/settle/getSelectGoods',{'supplierguid':self.supplierguid,
         	'distrbguid':self.distrbguid})
          .then(function (response) {
          		var res=response.data.data;
          		self.totle=res.totle;
          		self.settle=res.detaillist;
          });
      	
      },
      record:function(supplierName,supplierguid,flag,distrbguid,distributorsName){
      	var self=this;
      	//初始化
        self.supplierName=supplierName;
        self.distributorsName=distributorsName;
        self.supplierguid=supplierguid; 
        self.flag=flag;

      	self.commodity=null;
      	self.selecctList=null;
      	self.settle=null;
      	self.pageFalg=false;
      	self.final();

      	
      	self.supplier=false;
      	self.distributors=false;

      	if(flag=='z'){
      		self.supplier=true;
      		self.distrbguid=null;
      	}else{
      		self.supplier=true;
      		self.distributors=true;
      		self.distrbguid=distrbguid;
      	}
        

      },
      remove:function(){
       	var self=this;
      	Ajax.post('/settle/delAllSelectGoods',{'supplierguid':self.supplierguid,
      			'distrbguid':self.distrbguid})
          .then(function (response) {
          	var res=response.data.data;
          		if(response.data.errorCode==0){
          			self.selected(self.billno);
          			self.totle=res.totle;
          			self.settle=res.detaillist;
          		}
          		
          });	
      },
      delivery:function(name){

      	var self=this;
      	var name=name;
      	if(name){
      		self.supplier=false;
      		self.distributors=true;
      		self.distributorsName=name;
      	}
      },
      del:function(guid,rowno){
      	var self=this;
      		Ajax.post('/settle/delSelectGoods',{'supplierguid':self.supplierguid,
      			'distrbguid':self.distrbguid,'guid':guid+"-"+rowno})
          .then(function (response) {
          	var res=response.data.data;
          		if(response.data.errorCode==0){
          			// self.selected(self.billno);
          			self.totle=res.totle;
          			self.settle=res.detaillist;
          		}
          });
      },
      save:function(){
      	var self=this;
      	var dateStart=self.dateStart;
      	var dateEnd=self.dateEnd;
      	// 参数:dateStart 开始日期; dateEnd 结束日期
      	if( !dateStart || !dateEnd){
          layer.msg('请输入结算开始日期和结算结束日期');
			    return;
      	}
      	Ajax.post('/settle/creatSettle',{'supplierguid':self.supplierguid,
      			'distrbguid':self.distrbguid,'dateStart':dateStart,'dateEnd':dateEnd})
          .then(function (response) {
          	var result=response.data;
          	if(result.errorCode==0){
              self.statement=result.data;
          		self.modal=true;
          		self.selected(self.billno);
          		self.query();
          		self.final();
          	}else{
              layer.msg(result.message);

          	}
          });
      },
      init:function(){
      	var self=this;
      	self.supplier=false;
      	self.distributors=false;
      	self.modal=false;
      	self.selected(self.billno);
        self.query();
        self.final();
        window.location.reload();
      }
    },
    route: {
      activate: function () {
        this.getData();
      }
    }
  }

</script>