فهرست منبع

求购后台接口对接

yangc 7 سال پیش
والد
کامیت
738a1013b7
3فایلهای تغییر یافته به همراه119 افزوده شده و 45 حذف شده
  1. 56 33
      components/applyPurchase/ApplyInfo.vue
  2. 62 11
      components/applyPurchase/PublishApply.vue
  3. 1 1
      store/applyPurchase.js

+ 56 - 33
components/applyPurchase/ApplyInfo.vue

@@ -36,7 +36,7 @@
       <ul>
         <li v-for="(purchaseMan, index) in purchaseManList.content" :class="{'active': purchaseMan.active}">
           <div>{{purchaseMan.date| date}}</div>
-          <div :title="purchaseMan.userName || purchaseMan.inquiry.enterprise.enName || '-'">{{purchaseMan.userName || purchaseMan.inquiry.enterprise.enName || '-'}}</div>
+          <div :title="purchaseMan.userName || purchaseMan.inquiry.enterprise ? purchaseMan.inquiry.enterprise.enName ? purchaseMan.inquiry.enterprise.enName : '-' : '-' || '-'">{{purchaseMan.userName || purchaseMan.inquiry.enterprise ? purchaseMan.inquiry.enterprise.enName ? purchaseMan.inquiry.enterprise.enName : '-' : '-' || '-'}}</div>
           <div :title="purchaseMan.cmpCode">{{purchaseMan.cmpCode || '-'}}</div>
           <div :title="purchaseMan.inbrand">{{purchaseMan.inbrand || '-'}}</div>
           <div class="date-content"><span>剩余&nbsp;</span><span v-if="getDay(purchaseMan.remainingTime) > 0" v-text="getDay(purchaseMan.remainingTime)"></span><i v-if="getDay(purchaseMan.remainingTime) > 0">&nbsp;天&nbsp;</i><span v-if="getDay(purchaseMan.remainingTime) <= 0" v-text="getHours(purchaseMan.remainingTime)"></span><i v-if="getDay(purchaseMan.remainingTime) <= 0" >&nbsp;小时</i></div>
@@ -278,26 +278,30 @@
       commitSayPrice: function () {
         if (this.user.logged) {
           if (this.user.data.enterprise.uu) {
-            let purchaseMan = this.purchaseManList.content[this.currentSayPriceIndex]
-            this.showLoading = true
-            purchaseMan.leadtime = this.sayPriceObj.leadtime
-            purchaseMan.replies = this.sayPriceObj.replies
-            purchaseMan.vendUU = this.user.data.enterprise.uu
-            purchaseMan.vendorUserUU = this.user.data.userUU
-            this.$http.post('/inquiry/sale/item/save', purchaseMan).then(response => {
-              this.showLoading = false
-              if (response.data.success === false) {
-                this.$message.error(response.data.message)
-              } else {
-                this.$message.success('报价成功')
-                this.resetSayPrice()
-                this.resetList()
-              }
-            }, error => {
-              console.log(error)
-              this.$message.error('系统错误')
-              this.showLoading = false
-            })
+            if (this.checkValid()) {
+              let purchaseMan = this.purchaseManList.content[this.currentSayPriceIndex]
+              this.showLoading = true
+              purchaseMan.leadtime = this.sayPriceObj.leadtime
+              purchaseMan.replies = this.sayPriceObj.replies
+              purchaseMan.vendUU = this.user.data.enterprise.uu
+              purchaseMan.vendorUserUU = this.user.data.userUU
+              this.$http.post('/inquiry/sale/item/save', purchaseMan).then(response => {
+                this.showLoading = false
+                if (response.data.success === false) {
+                  this.$message.error(response.data.message)
+                } else {
+                  this.$message.success('报价成功')
+                  this.resetSayPrice()
+                  this.resetList()
+                }
+              }, error => {
+                console.log(error)
+                this.$message.error('系统错误')
+                this.showLoading = false
+              })
+            } else {
+              this.$message.error('请输入正确的报价信息')
+            }
           } else {
             this.$message.error('个人账户不可报价')
           }
@@ -369,21 +373,26 @@
       },
       onReplyPriceBlur: function (index) {
         let price = this.sayPriceObj.replies[index].price
-        if (price) {
-          if (price <= 0) {
-            this.$message.error('单价必须是大于0的数字')
-            this.validSayPrice.repliesPrice = false
-          } else {
-            this.validSayPrice.repliesPrice = true
-          }
-        } else {
-          this.$message.error('单价必须是大于0的数字')
+        let limitDownObj = this.getLimitDownPrice()
+        if (!price || price <= 0) {
+          this.sayPriceObj.replies[index].price = ''
+          this.$message.error('输入值必须为正整数')
+          this.validSayPrice.repliesPrice = false
+        } else if (limitDownObj.index !== index && limitDownObj.price > price) {
+          this.$message.error('输入值必须大于#该梯度的下限#')
+          this.sayPriceObj.replies[index].price = ''
+          this.validSayPrice.repliesPrice = false
+        } else if ((index - 1 >= 0 && this.sayPriceObj.replies[index - 1].price >= price) || (index + 1 < this.sayPriceObj.replies.length && this.sayPriceObj.replies[index + 1].price <= price)) {
+          this.$message.error('输入值会导致梯度重叠,请重新修改')
+          this.sayPriceObj.replies[index].price = ''
           this.validSayPrice.repliesPrice = false
+        } else {
+          this.validSayPrice.repliesPrice = true
         }
       },
       onReplyLapQtyBlur: function (index) {
         let lapQty = this.sayPriceObj.replies[index].lapQty
-        let limitDownObj = this.getLimitDown()
+        let limitDownObj = this.getLimitDownQty()
         if (!lapQty || lapQty < 1) {
           this.sayPriceObj.replies[index].lapQty = ''
           this.$message.error('输入值必须为正整数')
@@ -392,7 +401,7 @@
           this.$message.error('输入值必须大于#该梯度的下限#')
           this.sayPriceObj.replies[index].lapQty = ''
           this.validSayPrice.repliesLapQty = false
-        } else if ((index - 1 >= 0 && this.sayPriceObj.replies[index - 1].lapQty >= lapQty) || (index + 1 <= 4 && this.sayPriceObj.replies[index + 1].lapQty <= lapQty)) {
+        } else if ((index - 1 >= 0 && this.sayPriceObj.replies[index - 1].lapQty >= lapQty) || (index + 1 < this.sayPriceObj.replies.length && this.sayPriceObj.replies[index + 1].lapQty <= lapQty)) {
           this.$message.error('输入值会导致梯度重叠,请重新修改')
           this.sayPriceObj.replies[index].lapQty = ''
           this.validSayPrice.repliesLapQty = false
@@ -400,7 +409,7 @@
           this.validSayPrice.repliesLapQty = true
         }
       },
-      getLimitDown: function () {
+      getLimitDownQty: function () {
         for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
           if (this.sayPriceObj.replies[i].lapQty) {
             return {
@@ -411,6 +420,20 @@
         }
         return {index: -1}
       },
+      getLimitDownPrice: function () {
+        for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
+          if (this.sayPriceObj.replies[i].price) {
+            return {
+              price: this.sayPriceObj.replies[i].price,
+              index: i
+            }
+          }
+        }
+        return {index: -1}
+      },
+      checkValid: function () {
+        return this.validSayPrice.leadtime && this.validSayPrice.repliesLapQty && this.validSayPrice.repliesPrice
+      },
 //      onUnitPriceBlur: function () {
 //        if (this.sayPriceObj.unitPrice) {
 //          if (this.sayPriceObj.unitPrice <= 0) {

+ 62 - 11
components/applyPurchase/PublishApply.vue

@@ -73,7 +73,7 @@
           </div>
           <div class="form-item">
             <span>
-              规格
+              生产日期
             </span>
             <input type="text" class="form-control" v-model="applyObj.produceDate" @input="onProduceDateChange" />
           </div>
@@ -105,17 +105,30 @@
         <thead>
           <tr>
             <th width="62">排名</th>
-            <th width="124">求购型号</th>
-            <th width="57">数量</th>
-            <th width="72">求购次数</th>
+            <th width="90">买家</th>
+            <th width="90">卖家</th>
+            <th width="72">状态</th>
           </tr>
         </thead>
         <tbody>
-          <tr v-for="(rank, index) in purchaseRank">
+          <tr v-for="(rank, index) in purchaseRank.content">
             <td><div>NO.<span>{{index + 1}}</span><i>|</i></div></td>
-            <td :title="rank.spCode"><div><span>{{rank.spCode}}</span><i>|</i></div></td>
-            <td :title="rank.spAmount"><div><span>{{rank.spAmount}}</span><i>|</i></div></td>
-            <td :title="rank.uuAmount"><div>{{rank.uuAmount}}</div></td>
+            <td>
+              <div>
+                <span v-if="rank.inquiry.userName">{{rank.inquiry.userName | userNameFilter}}</span>
+                <span v-if="!rank.inquiry.userName && rank.inquiry.enterprise.enName">{{rank.inquiry.enterprise.enName | enterpriseFilter}}</span>
+                <span v-if="!rank.inquiry.userName && !rank.inquiry.enterprise.enName">-</span>
+                <i>|</i>
+              </div>
+            </td>
+            <td>
+              <div>
+                <span v-if="rank.vendName">{{rank.vendName | enterpriseFilter}}</span>
+                <span v-if="!rank.vendName">-</span>
+                <i>|</i>
+              </div>
+            </td>
+            <td><div>已采纳</div></td>
           </tr>
         </tbody>
       </table>
@@ -205,6 +218,14 @@
         return this.$store.state.option.user
       }
     },
+    filters: {
+      enterpriseFilter (str) {
+        return str.length > 4 ? str.substring(0, 2) + '**' + str.substring(str.length - 2, str.length) : str
+      },
+      userNameFilter (str) {
+        return str.substring(0, 1) + '**'
+      }
+    },
     mounted () {
       document.getElementsByClassName('el-upload-dragger')[0].onclick = function (event) {
         event.stopPropagation()
@@ -227,7 +248,37 @@
       goPublish: function () {
         if (this.user.logged) {
           if (this.checkAll()) {
-            this.$http.post('/seek/saveOneSeekPurchase', this.applyObj)
+            let inquiry = {}
+            let inquiryItem = {}
+            if (this.user.enterprise) {
+              inquiry.enUU = this.user.enterprise.uu
+            }
+            let date = new Date()
+            inquiry.recorderUU = this.user.userUU
+            inquiry.code = 'MALL' + date.getTime()
+            inquiry.date = date
+            inquiry.recorder = this.user.userName
+            inquiry.endDate = this.applyObj.deadline
+            inquiry.sourceapp = 'MALL'
+            inquiry.amount = 1
+            inquiryItem.prodTitle = this.applyObj.code
+            inquiryItem.userUU = this.user.userUU
+            inquiryItem.source = 'MALL'
+            inquiryItem.userName = this.user.userName
+            inquiryItem.userTel = this.user.userTel
+            inquiryItem.needquantity = this.applyObj.amount
+            inquiryItem.inbrand = this.applyObj.brand
+            inquiryItem.currency = this.applyObj.currency
+            inquiryItem.cmpCode = this.applyObj.code
+            inquiryItem.unitPrice = this.applyObj.unitPrice
+            inquiryItem.produceDate = this.applyObj.produceDate
+            inquiryItem.date = date
+            inquiryItem.endDate = this.applyObj.deadline
+            inquiryItem.encapsulation = this.applyObj.encapsulation
+            let inquiryItems = []
+            inquiryItems.push(inquiryItem)
+            inquiry.inquiryItems = inquiryItems
+            this.$http.post('/inquiry/buyer/save', inquiry)
               .then(response => {
                 this.$message.success('发布成功')
 //                this.showRemindBox = true
@@ -672,12 +723,12 @@
               }
               &:nth-child(2) {
                 >div {
-                  width: 122px;
+                  width: 90px;
                 }
               }
               &:nth-child(3) {
                 >div {
-                  width: 55px;
+                  width: 87px;
                 }
               }
               &:nth-child(4) {

+ 1 - 1
store/applyPurchase.js

@@ -48,7 +48,7 @@ export const actions = {
   // 求购排行榜
   loadPurchaseApplyRank ({ commit }, params = {}) {
     commit('purchaseApplyRank/REQUEST_PURCHASERANK', params)
-    return axios.get(`/seek/getSeekRanking`)
+    return axios.get(`/inquiry/public/quotationList?_state=agreed&pageNumber=1&pageSize=5`)
       .then(response => {
         commit('purchaseApplyRank/GET_PURCHASERANK_SUCCESS', response.data)
       }, err => {