supplier-new-product-adoption.vue 15 KB
<template>
<div class="container resource close-left-menu contaNEW">
  <div class="pop-banner clearfix">
    <div class="operate-btns">
      <a @click="acceptSupGoods()" class="fbtn fb-to-examine" >采纳商品</a>
      <a @click="acceptContent()" class="fbtn fb-to-examine" >采纳供应关系</a>
      <a @click="acceptLose()" class="fbtn fb-reject">忽略</a>
    </div>
    <h3 class="current-module">供应商新品采纳</h3>
  </div>
  <!--supply-supplylist start-->
  <div class="supplylist clearfix supply-select">
    <div class="supplylist-root pt0 w245">
        <form class="search-bar" style="min-width: 215px;" active="###">
          <div class="search-btn fr cur-poin" @click='getMedList'>
          </div>
          <input type="text" class="w163" maxlength="20" v-rule placeholder="输入供应商搜索" v-model="chinesename">
        </form>
        <div class="root-node-news">
            <b class="fl w30 t-center">序号</b>
            <b class="fl w180 t-center">供应商</b>
         </div>
        <div class="root-node-list" id="sortable" style='height: 480px;'>
            <template v-for="(indexI,suplist) in getSupLists">
            <div class="list-node" style='min-height:80px;line-height:25px;' :class="{ 'active': activeI == indexI }" @click="getMed(indexI,suplist.guid)">
              <div class="fl w30 t-center">{{$index + 1}}</div><div class="fl w180 t-left"><a style="cursor: pointer;" title="{{ suplist.chinesename }}"><p class="fl f-size12 text-color-blue f-size14">{{ suplist.chinesename }}</p><br>
              <span class="fl f-size12">{{ suplist.contacts }}</span><span class="fr f-size12">{{ suplist.contacttel }}</span></a></div>
            </div>
            </template>
          </div>
    </div>
    <div class="supplylist-table ml-265">
      <div class="fheader no-bottom pd0">
        <h4 class="fh-good">商品列表</h4>
      </div>
      <table class="itable itable-thead-13px">
        <thead>
          <tr>
            <th class="w30">
                  <div class="checkbox-control">
                  <input type="checkbox" :id="1" @click="selectAllsum(selectAllList)" v-model="selectAllList" :value="1">
                  <label class="checkbox" style="line-height: 19px;" :for="1">序号</label>
                  </div>
            </th>
            <th class="w150">商品信息</th>
            <th class="w50">价格</th>
            <th class="w50">单位</th>
            <th class="w30"></th>
            <th class="w150">单位转换系数</th>
            <th class="w70">业务员</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="mFMedGoods in getMedcontentList">
            <td
                <div class="checkbox-control">
                  <input type="checkbox" :id="mFMedGoods.guid" v-model="checkArr" :value="mFMedGoods.guid">
                  <label class="checkbox" :for="mFMedGoods.guid">{{ $index + 1 }}</label>
                </div>
            </td>
            <td><div class="t-left pr10">{{ mFMedGoods.goodscode  }}<br>{{mFMedGoods.goodsname}}<br/>{{mFMedGoods.goodsspec}}<br/>{{mFMedGoods.producer}}<br/>{{mFMedGoods.registkey}}</div></td>
            <td>
                    <input type="text" v-model='mFMedGoods.price | numDigit 2 | numFmt' class="t-right" @change="medCheckPrice(mFMedGoods.price, $index, 7)">
            </td>
            <td>{{ mFMedGoods.unitstyle}}</td>
            <td>
                <span class="ct-col w30">
                    <span class="table-detail-icon icon-green"></span>
                    <span class="table-detail-icon icon-green mt-20"></span>
              </span>
             </td>
            <td>
                  <div style="width: 102px; height: 72px; border:1px solid #999999; border-radius:8px; margin-left: 53px;">
                        <div class="w50 fl">
                            <input type="text" v-model='mFMedGoods.purconverratio' class=""
                                   style="border: 0px; height: 34px; border-radius: 8px 0px 0px 0px; box-shadow:none;"
                                   @change="medCheckInfo(mFMedGoods.purconverratio, $index, 7)">
                            <p style="background: #999999; width: 40px;height: 34px; height: 1px; margin-left: 10px;"></p>
                            <input type="text" v-model='mFMedGoods.supconverratio'
                                   style="border: 0px; border-radius: 0px 0px 0px 8px; box-shadow:none;"
                                   @change="supCheckInfo(mFMedGoods.supconverratio, $index, 7)">
                        </div>
                        <div class="w50 fl">
                            <input type="text" v-model='mFMedGoods.purchaseunit' class="t-center"
                                   style="border: 0px; height: 34px; border-radius: 0px 8px 0px 0px; box-shadow:none;"
                                   >
                            <p style="background: #999999; width: 40px; height: 1px; margin-right: 10px; "></p>
                             <p class=" lh-34 h-34" style="background-color: #ffffff;border-radius:0px 0px 8px 0px;">{{mFMedGoods.supplyunit}}</p>
                        </div>
                    </div>
            </td>
            <td>{{  mFMedGoods.staffname}}</td>
          </tr>
        </tbody>
      </table>
      <div class="pagination m-20-0">
        <em class="page">明细条目数【{{ search.total }}】</em>
        <pagination
          @page-change="getMedListClick"
          :class="['m-20-0']"
          :page-no.sync="search.page"
          :total-pages.sync="search.totalPages">
        </pagination>
      </div>
    </div>
  </div>
  <!--supply-supplylist end-->
</div>
</template>
<script>
module.exports={
data: function(){
  return {
        getSupLists: [],     //左侧列表
        chinesename:'',
        goodsinfo:'',
        getMedcontentList:[],
        search: {
        pageSize: 5,
        page: 1,
        total: 0,
        totalPages: 0
        },
        activeI :[],
        selectAllList: false,
        checkArr:[],
        noAudit:false,//防止重复点击审核
        goodsLists:[],
  };
},
methods: {
    selectAllsum: function(flag) {
        var self = this;
        self.checkArr = [];
        if(!flag) {
          self.getMedcontentList.forEach(function(item, i) {
            var data = item.guid;
            self.checkArr.push(data);
          });
          console.log(self.checkArr);
        } else {
          self.$set('checkArr', []);
          self.getMedcontentList.forEach(function(item, i) {
          });
        }
      },
      //左侧列表 加载数据
      getMedList:function(){
         var self = this;
         Ajax.post('/procurment/getAcceptSupplier',{'chinesename':self.chinesename})
          .then(function(response){
          var data=response.data.data;
          if (response.data.errorCode == 0) {
               self.$set("getSupLists",data);
               for (var i = 0; i < data.length; i++) {
                     self.supplierguid =data[0].guid;
               }
               self.getMedListClick();
            }else{
              layer.msg(response.data.message);
            }
         })
      },
      getMed:function(indexI,supplierguid){
         var self =this;
          self.activeI = indexI;
          self.supplierguid = supplierguid;
          self.search.page = 1;
          self.getMedListClick();
      },
      //加载右侧商品数据
      getMedListClick:function(){
         var self = this;
         self.selectAllList = false;
         self.checkArr = [];
         self.getMedcontentList = [];
         Ajax.post('/procurment/getAcceptSupGoods',{'page':self.search.page,'pageSize':self.search.pageSize,'totalPages':self.search.totalPages,'supplierguid':self.supplierguid})
          .then(function(response){
          var data=response.data.data;
          self.$set("getMedcontentList",data.list);
          self.search.totalPages=data.totalPages;
          self.search.total=data.total;
         })
      },
       // 验证价格
      medCheckPrice: function(price, index, code) {
        var self = this;
        if (price <= 0 || isNaN(price)) {
          self.MessageBox({title:'警告', message:"请输入大于0的数!", type: 'alert'},function(action){
            if (action == 'confirm') {
              if (code == 1) {
                self.$set('getMedcontentList['+index+'].price', '');
              } else {
                self.$set('getMedcontentList['+index+'].price', '');
              }
            }
          });
        }
      },
      // 验证医院单位系数
            medCheckInfo: function (po, index, code) {
                var self = this;
                if (po <= 0 || po > 99 || isNaN(po)) {
                    self.MessageBox({title: '警告', message: "请输入大于0小于99的正整数!", type: 'alert'}, function (action) {
                        if (action == 'confirm') {
                            if (code == 1) {
                                self.$set('getMedcontentList[' + index + '].purconverratio', 1);
                            } else {
                                self.$set('getMedcontentList[' + index + '].purconverratio', 1);
                            }
                        }
                    });
                }
            },
            //验证供应商单位系数
            supCheckInfo: function (po, index, code) {
                var self = this;
                if (po <= 0 || po > 99 || isNaN(po)) {
                    self.MessageBox({title: '警告', message: "请输入大于0小于99的正整数!", type: 'alert'}, function (action) {
                        if (action == 'confirm') {
                            if (code == 1) {
                                self.$set('getMedcontentList[' + index + '].supconverratio', 1);
                            } else {
                                self.$set('getMedcontentList[' + index + '].supconverratio', 1);
                            }
                        }
                    });
                }
            },
      //全部采纳商品
      acceptSupGoods:function(){
         var self = this;
         self.goodsLists = [];
         for (var i = 0; i < self.checkArr.length; i++) {
            for (var j = 0; j < self.getMedcontentList.length; j++) {
                if(self.getMedcontentList[j].guid  == self.checkArr[i]){
                    self.goodsLists.push(self.getMedcontentList[j]);
                }
              }
         }
        for (var l = 0; l < self.goodsLists.length; l++) {
           if(self.goodsLists[l].price == 0 || self.goodsLists[l].price == ''){
                self.MessageBox({title:'提示', message:'商品名【' + self.goodsLists[l].goodsname +'】的价格不能为0!', type: 'alert'},function(action){
                });
           }
        }
         if(self.checkArr.length == 0){
                layer.msg('请选择商品!');
                return;
         }
          if(self.noAudit){
              return;
          }
          self.noAudit = true;
         Ajax.post('/procurment/acceptSupGoods',{'list':self.goodsLists})
          .then(function(response){
          self.noAudit = false;
          var data=response.data.data;
          self.getMedList();
          if (response.data.errorCode == 0) {
            if(response.data.data == 0){
                self.MessageBox({title:'提示', message:'采纳成功!', type: 'alert'},function(action){
                });
             }else{
                layer.msg('采纳成功!');
                return;
             }
            }else{
               self.MessageBox({title:'提示', message:response.data.message, type: 'alert'},function(action){
                });
            }
         })
      },
       //全部采纳供应关系
      acceptContent:function(){
         var self = this;
         self.goodsLists = [];
         for (var i = 0; i < self.checkArr.length; i++) {
            for (var j = 0; j < self.getMedcontentList.length; j++) {
                if(self.getMedcontentList[j].guid  == self.checkArr[i]){
                    self.goodsLists.push(self.getMedcontentList[j]);
                }
              }
         }
         if(self.checkArr.length == 0){
                layer.msg('请选择商品!');
                return;
         }
         for (var l = 0; l < self.goodsLists.length; l++) {
           if(self.goodsLists[l].price == 0 || self.goodsLists[l].price == ''){
                self.MessageBox({title:'提示', message:'商品名【' + self.goodsLists[l].goodsname +'】的价格不能为0!', type: 'alert'},function(action){
                });
           }
        }
          if(self.noAudit){
              return;
          }
          self.noAudit = true;
         Ajax.post('/procurment/acceptContent',{'list':self.goodsLists})
          .then(function(response){
          self.noAudit = false;
          var data=response.data.data;
          self.getMedList();
          if (response.data.errorCode == 0) {
            if(response.data.data == 0){
                self.MessageBox({title:'提示', message:'采纳供应关系成功!', type: 'alert'},function(action){
                });
             }else{
                layer.msg('采纳供应关系成功!');
                return;
             }
            }else{
               self.MessageBox({title:'提示', message:response.data.message, type: 'alert'},function(action){
                });
            }
         })
      },
      //全部忽略
      acceptLose:function(){
         var self = this;
         self.goodsLists = [];
         for (var i = 0; i < self.checkArr.length; i++) {
            for (var j = 0; j < self.getMedcontentList.length; j++) {
                if(self.getMedcontentList[j].guid  == self.checkArr[i]){
                    self.goodsLists.push(self.getMedcontentList[j]);
                }
              }
         }
         if(self.checkArr.length == 0){
                layer.msg('请选择商品!');
                return;
         }
          if(self.noAudit){
              return;
          }
          self.noAudit = true;
         Ajax.post('/procurment/acceptLose',{'list':self.goodsLists})
          .then(function(response){
          self.noAudit = false;
          var data=response.data.data;
          self.getMedList();
          if (response.data.errorCode == 0) {
            if(response.data.data == 0){
                self.MessageBox({title:'提示', message:'忽略成功!', type: 'alert'},function(action){
                });
             }else{
                layer.msg('忽略成功!');
                return;
             }
            }else{
               self.MessageBox({title:'提示', message:response.data.message, type: 'alert'},function(action){
                });
            }
         })
      },
      closeUp:function(flag) {
        var self = this;
        self.$set('showPopupUp',flag);
     },
     close:function(flag) {
        var self = this;
        self.$set('showPopupUp',flag);
     },
},
route:{
activate : function(){
this.getMedList();
}
},
watch: {
      'checkArr': function(val) {
        var self = this;
        if(self.checkArr.length == 0){
            self.selectAllList = false;
          }
      },
      },
};
</script>