Browse Source

创建供应商模块,对接数据接口

Administrator 7 years ago
parent
commit
a5c04f6412

+ 162 - 123
components/supplier/details.vue

@@ -14,14 +14,14 @@
       </div>
       <div class="top">
         <div class="img">
-          <img src="/images/store/common/default.png">
+          <img :src="detail.cmpImg || '/images/store/common/default.png'">
         </div>
         <div class="right">
-          <h4 v-text="detail.cmpCode">32222222222222222222</h4>
+          <h4 v-text="detail.cmpCode">3</h4>
           <ul class="list-unstyled">
             <li class="item">
               <span>类目(名称)</span>
-              <p v-text="detail.prodName? spliceString(detail.prodName, 400) : '暂无信息'">3errrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr2</p>
+              <p v-text="detail.prodName? spliceString(detail.prodName, 400) : '暂无信息'">2</p>
             </li>
             <li class="item">
               <span>品牌</span>
@@ -35,62 +35,16 @@
               <span>规格</span>
               <p v-text="detail.spec ? detail.spec : '暂无信息'">32</p>
             </li>
-            <li class="item">
-              <span>种类</span>
-              <p>32</p>
-            </li>
           </ul>
           <a @click="hasDialog = true">立即询价</a>
         </div>
       </div>
       <div class="info">
-        <table>
-          <thead>
-          <tr>
-            <th colspan="4">
-              <p>产品参数 <span>(仅供参考,以实际产品为准)</span></p>
-            </th>
-          </tr>
-          </thead>
-          <tbody>
-          <tr>
-            <td width="297">工作温度范围: </td>
-            <td width="297"></td>
-            <td width="297">最大输入电压:</td>
-            <td width="297"></td>
-          </tr>
-          <tr>
-            <td>输出电压-Vout: </td>
-            <td></td>
-            <td>负载调节:</td>
-            <td></td>
-          </tr>
-          <tr>
-            <td>输出类型: </td>
-            <td></td>
-            <td>安装方式:</td>
-            <td></td>
-          </tr>
-          <tr>
-            <td>工作温度范围: </td>
-            <td></td>
-            <td>最大输入电压:</td>
-            <td></td>
-          </tr>
-          <tr>
-            <td>输出电压-Vout: </td>
-            <td></td>
-            <td>负载调节:</td>
-            <td></td>
-          </tr>
-          <tr>
-            <td>输出类型: </td>
-            <td></td>
-            <td>安装方式:</td>
-            <td></td>
-          </tr>
-          </tbody>
-        </table>
+        <ul class="list-unstyled">
+          <li><p>产品参数<span>(仅供参考,以实际产品为准)</span></p></li>
+          <li v-if="!detail.cmpUuId" class="empty">暂无相关信息!</li>
+          <li v-if="detail.cmpUuId" v-for="item in cmpInfo.properties"><span v-text="item.property.labelCn"></span><span v-text="item.value"></span></li>
+        </ul>
       </div>
     </div>
     <el-dialog
@@ -100,24 +54,25 @@
         <ul class="list-inline">
           <li class="form-item">
             <span>型号:</span>
-            <p>32432</p>
+            <p v-text="detail.cmpCode">3</p>
           </li>
           <li class="form-item">
             <span>类目:</span>
-            <p>3244333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333332</p>
+            <p v-text="detail.prodName">3</p>
           </li>
           <li class="form-item">
             <span>品牌:</span>
-            <p>32432</p>
+            <p v-text="detail.brand">3</p>
           </li>
           <li class="form-item">
             <span>规格:</span>
-            <p>32432</p>
+            <p v-text="detail.spec">3</p>
           </li>
           <li class="form-item">
             <span><i>*</i>截止日期:</span>
             <el-date-picker
-              v-model="form.name"
+              :class="{'error': !validObj.deadline}"
+              v-model="applyObj.deadline"
               type="date"
               :picker-options="pickerOptions"
               @change="setDeadLineValid"
@@ -128,36 +83,28 @@
           </li>
           <li class="form-item">
             <span>封装:</span>
-            <input type="text" class="form-control" v-model="form.date1"/>
+            <input type="text" class="form-control" v-model="applyObj.encapsulation"/>
           </li>
           <li class="form-item">
             <span>单价预算:</span>
-            <select v-model="form.date1" class="form-control" style="width:40px;">
-            <option value="RMB">¥</option>
-            <option value="USD">$</option>
+            <select v-model="applyObj.currency" class="form-control" style="width:40px;">
+              <option value="RMB">¥</option>
+              <option value="USD">$</option>
             </select>
-            <input type="number" class="form-control"/>
+            <input type="number" v-model="applyObj.unitPrice" class="form-control" :class="{'error': !validObj.unitPrice}"/>
           </li>
           <li class="form-item">
             <span>生产日期:</span>
-            <el-date-picker
-              v-model="form.date2"
-              type="date"
-              :picker-options="pickerOptions"
-              @change="setDeadProduction"
-              :editable="false"
-              :clearable="true"
-              size="mini">
-            </el-date-picker>
+            <input type="text" class="form-control" v-model="applyObj.produceDate"/>
           </li>
           <li class="form-item">
             <span>采购数量:</span>
-            <input type="number" class="form-control"/>
+            <input type="number" class="form-control" v-model="applyObj.amount" :class="{'error': !validObj.amount}"/>
           </li>
         </ul>
       </div>
       <span slot="footer" class="dialog-footer">
-        <a type="button" @click="hasDialog=false">询价提交</a>
+        <a type="button" @click="goPublish">询价提交</a>
       </span>
     </el-dialog>
   </div>
@@ -169,6 +116,19 @@
     name: 'DetailsView',
     data () {
       return {
+        applyObj: {
+          unitPrice: '',
+          currency: 'RMB',
+          encapsulation: '',
+          produceDate: '',
+          amount: '',
+          deadline: ''
+        },
+        validObj: {
+          unitPrice: true,
+          amount: true,
+          deadline: true
+        },
         pickerOptions: {
           disabledDate (time) {
             // 大于等于今天 小于三个月后
@@ -176,40 +136,109 @@
           }
         },
         hasDialog: false,
-        form: {
-          name: '',
-          region: '',
-          date1: '',
-          date2: '',
-          delivery: false,
-          type: [],
-          resource: '',
-          desc: ''
-        },
-        dialogVisible: false,
         searchCode: '',
         test: '322222222222222222222222222222222222222222222222222222'
       }
     },
     computed: {
       detail () {
-        console.log(this.$store.state.supplier.detail.detail.data)
         return this.$store.state.supplier.detail.detail.data
+      },
+      cmpInfo () {
+        return this.$store.state.supplier.detail.cmpInfo.data
+      },
+      user () {
+        return this.$store.state.option.user
       }
     },
     methods: {
-      setDeadProduction () {
-        this.form.name = formatDate(this.form.name, 'yyyy-MM-dd hh:mm:ss')
+      spliceString (str, length) {
+        return spliceStr(str, length)
       },
+      // 时间格式化
       setDeadLineValid: function () {
-        this.form.date2 = formatDate(this.form.date2, 'yyyy-MM-dd hh:mm:ss')
-        // this.validObj.deadline = true
+        this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
+        this.validObj.deadline = true
       },
-      onSubmit () {
-        console.log('submit!')
+      // 检查单价预算
+      checkUnitPrice () {
+        this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
+        if (!this.validObj.unitPrice && this.applyObj.unitPrice <= 0) {
+          this.$message.error('单价必须是大于0的数字')
+        }
+        return this.validObj.unitPrice
       },
-      spliceString (str, length) {
-        return spliceStr(str, length)
+      // 检查采购数量
+      checkAmount () {
+        this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
+        return this.validObj.amount
+      },
+      // 检查时间是否有输入
+      checkDeadline () {
+        this.validObj.deadline = Boolean(this.applyObj.deadline)
+        return this.validObj.deadline
+      },
+      // 检查各个字段输入正常数据
+      checkAll () {
+        return this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
+      },
+      emptyForm () {
+        for (let attr in this.applyObj) {
+          this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
+        }
+      },
+      // 请求询价信息
+      goPublish () {
+        if (this.checkAll()) {
+          let inquiry = {}
+          let inquiryItem = {}
+          if (this.user.data.enterprise) {
+            inquiry.enUU = this.user.data.enterprise.uu
+          }
+          let date = new Date()
+          let currency = this.applyObj.unitPrice ? this.applyObj.currency : null
+          inquiry.recorderUU = this.user.data.userUU
+          inquiry.code = 'MALL' + date.getTime()
+          inquiry.date = date
+          inquiry.recorder = this.user.data.userName
+          inquiry.endDate = this.applyObj.deadline
+          inquiry.sourceapp = 'MALL'
+          inquiry.amount = 1
+          inquiryItem.userUU = this.user.data.userUU
+          inquiryItem.source = 'MALL'
+          inquiryItem.userName = this.user.data.userName
+          inquiryItem.userTel = this.user.data.userTel
+          inquiryItem.needquantity = this.applyObj.amount
+          inquiryItem.inbrand = this.detail.brand
+          inquiryItem.currency = currency
+          inquiryItem.cmpCode = this.detail.cmpCode.toUpperCase()
+          inquiryItem.unitPrice = this.applyObj.unitPrice
+          inquiryItem.produceDate = this.applyObj.produceDate
+          inquiryItem.date = date
+          inquiryItem.endDate = this.applyObj.deadline
+          inquiryItem.encapsulation = this.applyObj.encapsulation
+          inquiryItem.spec = this.detail.spec
+          inquiryItem.prodTitle = this.detail.prodName
+          let inquiryItems = []
+          inquiryItems.push(inquiryItem)
+          inquiry.inquiryItems = inquiryItems
+          inquiry.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
+          this.$http.post('/inquiry/buyer/save', inquiry)
+            .then(res => {
+              this.$message.success('发布成功')
+              this.hasDialog = false
+              this.emptyForm()
+            }, error => {
+              console.log(error)
+              this.$message.error('发布失败')
+            })
+        } else {
+          if (!this.validObj.deadline) {
+            this.$message.error('截止日期不能为空')
+          } else if (!this.validObj.amount) {
+            this.$message.error('请输入正确的数值')
+          }
+        }
       }
     }
   }
@@ -249,6 +278,14 @@
     }
   }
   .form_dialog{
+    .el-date-editor--date {
+      width: 230px;
+      &.error {
+        input {
+          border: 1px solid #f4645f !important;
+        }
+      }
+    }
     ul{
       li{
         width:50%;
@@ -423,37 +460,39 @@
   }
   .info{
     padding-bottom:90px;
-    table{
-      thead{
-        tr{
-          line-height: 34px;
-          th{
-            font-weight: bold;
-            color:#fff;
-            background: #3c7cf5;
-            padding-left:15px;
-            p{
-              font-size: 16px;
-              margin:0;
-              span{
-                font-size: 12px;
-              }
+    ul{
+      margin-left:0;
+      li{
+        line-height: 34px;
+        text-align: center;
+        overflow: hidden;
+        > span{
+          display:inline-block;
+          width:50%;
+        }
+        &:nth-child(odd){
+          background: #fff;
+        }
+        &:nth-child(even){
+          background: #f5f6f8;
+        }
+        &:first-child{
+          font-weight: bold;
+          color:#fff;
+          background: #3c7cf5;
+          padding-left:15px;
+          text-align: left;
+          p{
+            font-size: 16px;
+            margin:0;
+            span{
+              font-size: 12px;
             }
           }
         }
-      }
-      tbody{
-        tr{
-          line-height: 34px;
-          &:nth-child(odd){
-            background: #fff;
-          }
-          &:nth-child(even){
-            background: #f5f6f8;
-          }
-          td{
-            text-align: center;
-          }
+        &.empty{
+          padding: 100px 0;
+          font-size: 24px;
         }
       }
     }

+ 80 - 10
components/supplier/merchant.vue

@@ -18,10 +18,10 @@
     </div>
     <div class="list_info">
       <ul class="list-inline">
-        <li v-for="item in list.content" @click="jumpResource(item.enUU)">
+        <li v-for="item in list.content" @click="jumpResource(item.enUU, item.hasProduct)">
           <div class="has_shop" v-if="item.isStore === 1">已开店</div>
           <div class="enterprise_name" v-text="item.enName">深圳英优软科技有限公司</div>
-          <div class="select_btn" v-html="isInFrame ? '添加为<br/>供应商' : '查看<br/>更多'" @mouseleave="hasJump = false" @mouseenter="hasJump = true" @click="addResource(item.enUU)"></div>
+          <div class="select_btn" v-html="isInFrame ? '添加为<br/>供应商' : '查看<br/>更多'" @mouseleave="hasJump = false" @mouseenter="hasJump = true" @click="addResource(item.enUU, item.hasProduct)"></div>
           <div class="popups">
             <p>企业执照号:</p><p v-text="item.enBusinesscode ? item.enBusinesscode : '暂无信息'">1</p>
             <p>地址:</p><p v-text="item.enAddress ? item.enAddress : '暂无信息'">1</p>
@@ -37,6 +37,16 @@
         </page>
       </div>
     </div>
+    <el-dialog
+      title="提示"
+      :visible.sync="hasDialog ">
+      <div class="form_dialog">
+        <p><span>供应商正在完善产品信息,</span>暂时不能查看更多。 </p>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <a type="button" @click="hasDialog=false">我知道了</a>
+      </span>
+    </el-dialog>
   </div>
 </div>
 </template>
@@ -47,6 +57,7 @@
     name: 'MerchantView',
     data () {
       return {
+        hasDialog: false,
         hasJump: false,
         searchCode: '',
         pageParams: {
@@ -69,16 +80,32 @@
       }
     },
     methods: {
-      addResource (id) {
+      addResource (id, type) {
         if (this.isInFrame) {
-          window.open(this.$route.query.localPath + this.$route.query.erpPath)
+          this.$http.get(`/basic/enterprise /${id}/info`)
+            .then(res => {
+              if (res.data) {
+                window.open(this.$route.query.localPath + this.$route.query.erpPath + '?b2bdata=' + encodeURIComponent(JSON.stringify(res.data)))
+              }
+            })
+            .catch(err => {
+              console.log(err)
+            })
         } else {
-          this.$router.push('supplier/' + id)
+          if (type === 1) {
+            this.$router.push('supplier/' + id)
+          } else {
+            this.hasDialog = true
+          }
         }
       },
-      jumpResource (id) {
-        if (!this.hasJump) {
-          this.$router.push('supplier/' + id)
+      jumpResource (id, type) {
+        if (!this.hasJump && type === 1) {
+          if (type === 1) {
+            this.$router.push('supplier/' + id)
+          } else {
+            this.hasDialog = true
+          }
         }
       },
       goodsSearch (type) {
@@ -94,12 +121,55 @@
   }
 </script>
 
-<style scoped type="text/scss" lang="scss">
+<style type="text/scss" lang="scss">
 .merchant{
   background: #ecf1f1 url(/images/supplier/banner.jpg)no-repeat;
   border-top:3px solid #000;
   padding-bottom:25px;
   margin-top:-1.5em;
+  .el-dialog{
+    width: 290px!important;
+    .el-dialog__header{
+      background: #4290f7;
+      line-height: 40px;
+      padding: 0 20px 0;
+      .el-dialog__title{
+        color:#fff;
+      }
+      .el-dialog__headerbtn:hover .el-dialog__close, .el-dialog__headerbtn:focus .el-dialog__close{
+        color:#fff;
+      }
+    }
+    .el-dialog__body{
+      padding: 10px 20px;
+    }
+    .el-dialog__footer{
+      text-align: center;
+      a{
+        display:inline-block;
+        background: #3c7cf5;
+        color:#fff;
+        font-size: 14px;
+        line-height: 30px;
+        height:30px;
+        padding:0 10px;
+        border-radius:5px;
+      }
+    }
+  }
+  .form_dialog{
+    p{
+      width:200px;
+      font-size: 14px;
+      color:#666666;
+      margin:0 auto;
+      padding-top:5px;
+      line-height: 20px;
+      span{
+        color:#eb6054;
+      }
+    }
+  }
   .top{
     padding-top:30px;
     margin-bottom:40px;
@@ -152,7 +222,7 @@
   }
   .list_info{
     padding: 0 10px;
-    ul{
+    > ul{
       margin-left:5px;
       li{
         position:relative;

+ 152 - 49
components/supplier/resource.vue

@@ -15,19 +15,19 @@
     <div class="user_info">
       <div class="user_title">
         <div class="user_name">
-          <span>深圳优软科技有限公司 &nbsp;<i class="fa fa-angle-down"></i></span>
-          <a href="/">进入店铺</a>
+          <span>{{enUser.enName}}&nbsp;&nbsp;<i class="fa fa-angle-down"></i></span>
+          <a :href="/store/+ storeInfo.uuid" target="_blank">进入店铺</a>
         </div>
         <div class="user_mes">
           <div class="mes-list">
             <p>
-              <span><i class="supplier_icon1"></i>企业执照号:155</span>
-              <span><i class="supplier_icon2"></i> 地址:145</span>
+              <span><i class="supplier_icon1"></i>企业执照号:{{enUser.enBussinessCode ? enUser.enBussinessCode : '暂无信息'}}</span>
+              <span><i class="supplier_icon2"></i> 地址:{{enUser.enAddress ? enUser.enAddress : '暂无信息'}}</span>
             </p>
             <p>
-              <span><i class="supplier_icon3"></i> 邮箱:1</span>
-              <span><i class="supplier_icon4"></i> 电话:14553</span>
-              <span><i class="supplier_icon5"></i> 行业:14444</span>
+              <span><i class="supplier_icon3"></i> 邮箱:{{enUser.enEmail ? enUser.enEmail : '暂无信息'}}</span>
+              <span><i class="supplier_icon4"></i> 电话:{{enUser.enTel ? enUser.enTel : '暂无信息'}}</span>
+              <span><i class="supplier_icon5"></i> 行业:{{enUser.enIndustry ? enUser.enIndustry : '暂无信息'}}</span>
             </p>
           </div>
         </div>
@@ -85,7 +85,7 @@
               </ul>
             </td>
             <td>
-              <a @click="hasDialog = true" @mouseleave="hasClick = false" @mouseenter="hasClick = true">立即询价</a>
+              <a @click="immediatelyClick(item)" @mouseleave="hasClick = false" @mouseenter="hasClick = true">立即询价</a>
             </td>
           </tr>
         </tbody>
@@ -98,29 +98,30 @@
     </div>
     <el-dialog
       title="我要询价"
-      :visible.sync="hasDialog ">
+      :visible.sync="hasDialog">
       <div class="form_dialog">
         <ul class="list-inline">
           <li class="form-item">
             <span>型号:</span>
-            <p>32432</p>
+            <p v-text="applyObj.cmpCode">32432</p>
           </li>
           <li class="form-item">
             <span>类目:</span>
-            <p>3244333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333332</p>
+            <p v-text="applyObj.prodName">32</p>
           </li>
           <li class="form-item">
             <span>品牌:</span>
-            <p>32432</p>
+            <p v-text="applyObj.brand">32432</p>
           </li>
           <li class="form-item">
             <span>规格:</span>
-            <p>32432</p>
+            <p v-text="applyObj.spec">32432</p>
           </li>
           <li class="form-item">
             <span><i>*</i>截止日期:</span>
             <el-date-picker
-              v-model="form.name"
+              :class="{'error': !validObj.deadline}"
+              v-model="applyObj.deadline"
               type="date"
               :picker-options="pickerOptions"
               @change="setDeadLineValid"
@@ -131,36 +132,28 @@
           </li>
           <li class="form-item">
             <span>封装:</span>
-            <input type="text" class="form-control" v-model="form.date1"/>
+            <input type="text" class="form-control" v-model="applyObj.encapsulation"/>
           </li>
           <li class="form-item">
             <span>单价预算:</span>
-            <select v-model="form.date1" class="form-control" style="width:40px;">
+            <select v-model="applyObj.currency" class="form-control" style="width:40px;">
               <option value="RMB">¥</option>
               <option value="USD">$</option>
             </select>
-            <input type="number" class="form-control"/>
+            <input type="number" v-model="applyObj.unitPrice" class="form-control" :class="{'error': !validObj.unitPrice}"/>
           </li>
           <li class="form-item">
             <span>生产日期:</span>
-            <el-date-picker
-              v-model="form.date2"
-              type="date"
-              :picker-options="pickerOptions"
-              @change="setDeadProduction"
-              :editable="false"
-              :clearable="true"
-              size="mini">
-            </el-date-picker>
+            <input type="text" class="form-control" v-model="applyObj.produceDate"/>
           </li>
           <li class="form-item">
             <span>采购数量:</span>
-            <input type="number" class="form-control"/>
+            <input type="number" class="form-control" v-model="applyObj.amount" :class="{'error': !validObj.amount}"/>
           </li>
         </ul>
       </div>
       <span slot="footer" class="dialog-footer">
-        <a type="button" @click="hasDialog=false">询价提交</a>
+        <a type="button" @click="goPublish">询价提交</a>
       </span>
     </el-dialog>
   </div>
@@ -174,6 +167,23 @@
     name: 'ResourceView',
     data () {
       return {
+        applyObj: {
+          cmpCode: '',
+          brand: '',
+          unitPrice: '',
+          currency: 'RMB',
+          prodName: '',
+          spec: '',
+          encapsulation: '',
+          produceDate: '',
+          amount: '',
+          deadline: ''
+        },
+        validObj: {
+          unitPrice: true,
+          amount: true,
+          deadline: true
+        },
         pickerOptions: {
           disabledDate (time) {
             // 大于等于今天 小于三个月后
@@ -182,17 +192,6 @@
         },
         hasDialog: false,
         hasClick: false,
-        form: {
-          name: '',
-          region: '',
-          date1: '',
-          date2: '',
-          delivery: false,
-          type: [],
-          resource: '',
-          desc: ''
-        },
-        dialogVisible: false,
         searchCode: '',
         pageParams: {
           count: 10,
@@ -206,31 +205,34 @@
     computed: {
       list () {
         return this.$store.state.supplier.material.material.data
-      }
-    },
-    methods: {
-      setDeadProduction () {
-        this.form.name = formatDate(this.form.name, 'yyyy-MM-dd hh:mm:ss')
       },
-      setDeadLineValid: function () {
-        this.form.date2 = formatDate(this.form.date2, 'yyyy-MM-dd hh:mm:ss')
-        // this.validObj.deadline = true
+      enUser () {
+        return this.$store.state.supplier.material.enUser.data
       },
-      onSubmit () {
-        console.log('submit!')
+      storeInfo () {
+        return this.$store.state.shop.storeInfo.store.data
       },
+      user () {
+        return this.$store.state.option.user
+      }
+    },
+    methods: {
+      // 格式化字符串长度
       spliceString (str, length) {
         return spliceStr(str, length)
       },
+      // 跳转到器件详情页面
       jumpDetail (id) {
         if (!this.hasClick) {
           this.$router.push(this.$route.path + '/' + id)
         }
       },
+      // 获取分页数据
       handleCurrentChange (type) {
         this.pageParams.page = type
         this.$store.dispatch('supplier/loadMaterialList', {page: type, size: 20, vendUU: this.$route.params.uuid})
       },
+      // 根据搜索信息获取数据
       goodsSearch (type) {
         if (type) {
           this.$store.dispatch('supplier/loadMaterialList', {
@@ -240,6 +242,99 @@
             keyword: type
           })
         }
+      },
+      // 弹出询价界面
+      immediatelyClick (type) {
+        this.hasDialog = true
+        this.applyObj.cmpCode = type.cmpCode
+        this.applyObj.brand = type.brand
+        this.applyObj.spec = type.spec
+        this.applyObj.prodName = type.prodName
+      },
+      // 时间格式化
+      setDeadLineValid: function () {
+        this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
+        this.validObj.deadline = true
+      },
+      // 检查单价预算
+      checkUnitPrice () {
+        this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
+        if (!this.validObj.unitPrice && this.applyObj.unitPrice <= 0) {
+          this.$message.error('单价必须是大于0的数字')
+        }
+        return this.validObj.unitPrice
+      },
+      // 检查采购数量
+      checkAmount () {
+        this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
+        return this.validObj.amount
+      },
+      // 检查时间是否有输入
+      checkDeadline () {
+        this.validObj.deadline = Boolean(this.applyObj.deadline)
+        return this.validObj.deadline
+      },
+      // 检查各个字段输入正常数据
+      checkAll () {
+        return this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
+      },
+      emptyForm () {
+        for (let attr in this.applyObj) {
+          this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
+        }
+      },
+      // 请求询价信息
+      goPublish () {
+        if (this.checkAll()) {
+          let inquiry = {}
+          let inquiryItem = {}
+          if (this.user.data.enterprise) {
+            inquiry.enUU = this.user.data.enterprise.uu
+          }
+          let date = new Date()
+          let currency = this.applyObj.unitPrice ? this.applyObj.currency : null
+          inquiry.recorderUU = this.user.data.userUU
+          inquiry.code = 'MALL' + date.getTime()
+          inquiry.date = date
+          inquiry.recorder = this.user.data.userName
+          inquiry.endDate = this.applyObj.deadline
+          inquiry.sourceapp = 'MALL'
+          inquiry.amount = 1
+          inquiryItem.userUU = this.user.data.userUU
+          inquiryItem.source = 'MALL'
+          inquiryItem.userName = this.user.data.userName
+          inquiryItem.userTel = this.user.data.userTel
+          inquiryItem.needquantity = this.applyObj.amount
+          inquiryItem.inbrand = this.applyObj.brand
+          inquiryItem.currency = currency
+          inquiryItem.cmpCode = this.applyObj.cmpCode.toUpperCase()
+          inquiryItem.unitPrice = this.applyObj.unitPrice
+          inquiryItem.produceDate = this.applyObj.produceDate
+          inquiryItem.date = date
+          inquiryItem.endDate = this.applyObj.deadline
+          inquiryItem.encapsulation = this.applyObj.encapsulation
+          inquiryItem.spec = this.applyObj.spec
+          inquiryItem.prodTitle = this.applyObj.prodName
+          let inquiryItems = []
+          inquiryItems.push(inquiryItem)
+          inquiry.inquiryItems = inquiryItems
+          inquiry.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
+          this.$http.post('/inquiry/buyer/save', inquiry)
+            .then(res => {
+              this.$message.success('发布成功')
+              this.hasDialog = false
+              this.emptyForm()
+            }, error => {
+              console.log(error)
+              this.$message.error('发布失败')
+            })
+        } else {
+          if (!this.validObj.deadline) {
+            this.$message.error('截止日期不能为空')
+          } else if (!this.validObj.amount) {
+            this.$message.error('请输入正确的数值')
+          }
+        }
       }
     }
   }
@@ -279,6 +374,14 @@
     }
   }
   .form_dialog{
+    .el-date-editor--date{
+      width: 230px;
+      &.error {
+        input {
+          border: 1px solid #f4645f !important;
+        }
+      }
+    }
     ul{
       li{
         width:50%;

+ 1 - 0
nuxt.config.js

@@ -129,6 +129,7 @@ module.exports = {
     '/logout/**': baseUrl,
     '/static/**': baseUrl,
     '/vendor**': baseUrl,
+    '/vendor/introduction/**': baseUrl,
     '/trade/**': baseUrl,
     '/recommendation/**': baseUrl,
     '/store-service/**': baseUrl,

+ 1 - 0
pages/supplier/_uuid/_id.vue

@@ -9,6 +9,7 @@
   export default {
     name: 'SupplierDetails',
     layout: 'main',
+    middleware: 'authenticated',
     fetch ({store, route}) {
       return Promise.all([
         store.dispatch('supplier/loadMaterialDetail', {id: route.params.id})

+ 4 - 1
pages/supplier/_uuid/index.vue

@@ -9,9 +9,12 @@
   export default {
     name: 'SupplierResource',
     layout: 'main',
+    middleware: 'authenticated',
     fetch ({store, route}) {
       return Promise.all([
-        store.dispatch('supplier/loadMaterialList', {page: 1, size: 20, vendUU: route.params.uuid})
+        store.dispatch('supplier/loadMaterialList', {page: 1, size: 20, vendUU: route.params.uuid}),
+        store.dispatch('supplier/loadEnUser', {enUU: route.params.uuid, filter: 'enUU'}),
+        store.dispatch('shop/findStoreInfoFromUuid', {enUU: route.params.uuid, filter: 'enUU'})
       ])
     },
     components: {

+ 4 - 1
pages/supplier/index.vue

@@ -13,9 +13,12 @@
   export default {
     name: 'SupplierView',
     layout: 'main',
+    middleware: 'authenticated',
     fetch ({store}) {
       return Promise.all([
-        store.dispatch('supplier/loadVendorList', {page: 1, size: 20})
+        store.dispatch('supplier/loadVendorList', {page: 1, size: 20}),
+        store.dispatch('loadBanners', {type: 'home'}),
+        store.dispatch('loadProductKinds', { id: 0 })
       ])
     },
     components: {

+ 19 - 0
store/supplier.js

@@ -27,8 +27,27 @@ export const actions = {
     return axios.get('/vendor/introduction/product/detail', {params})
       .then(res => {
         commit('detail/GET_DETAIL_SUCCESS', res.data)
+        if (res.data.cmpUuId) {
+          commit('detail/REQUEST_CMPINFO')
+          return axios.get(`/api/commodity/component/${res.data.cmpUuId}`)
+            .then(res => {
+              commit('detail/GET_CMPINFO_SUCCESS', res.data)
+            }, (err) => {
+              commit('detail/GET_CMPINFO_FAILURE', err)
+            })
+        }
       }, (err) => {
         commit('detail/GET_DETAIL_FAILURE', err)
       })
+  },
+  // 获取企业信息
+  loadEnUser ({commit}, params = {}) {
+    commit('material/REQUEST_ENUSER')
+    return axios.get(`/basic/enterprise/${params.enUU}/info`)
+      .then(res => {
+        commit('material/GET_ENUSER_SUCCESS', res.data)
+      }, (err) => {
+        commit('material/GET_ENUSER_FAILURE', err)
+      })
   }
 }

+ 14 - 0
store/supplier/detail.js

@@ -2,6 +2,10 @@ export const state = () => ({
   detail: {
     fetching: false,
     data: []
+  },
+  cmpInfo: {
+    fetching: false,
+    data: []
   }
 })
 
@@ -15,5 +19,15 @@ export const mutations = {
   },
   GET_DETAIL_FAILURE (state) {
     state.detail.fetching = false
+  },
+  REQUEST_CMPINFO (state) {
+    state.cmpInfo.detching = true
+  },
+  GET_CMPINFO_SUCCESS (state, result) {
+    state.cmpInfo.fetching = false
+    state.cmpInfo.data = result
+  },
+  GET_CMPINFO_FAILURE (state) {
+    state.cmpInfo.fetching = false
   }
 }

+ 15 - 1
store/supplier/material.js

@@ -2,12 +2,16 @@ export const state = () => ({
   material: {
     fetching: false,
     data: []
+  },
+  enUser: {
+    fetching: false,
+    data: []
   }
 })
 
 export const mutations = {
   REQUEST_MATERIAL (state) {
-    state.detching = true
+    state.material.fetching = true
   },
   GET_MATERIAL_SUCCESS (state, result) {
     state.material.fetching = false
@@ -15,5 +19,15 @@ export const mutations = {
   },
   GET_MATERIAL_FAILURE (state) {
     state.material.fetching = false
+  },
+  REQUEST_ENUSER (state) {
+    state.enUser.fetching = true
+  },
+  GET_ENUSER_SUCCESS (state, result) {
+    state.enUser.fetching = false
+    state.enUser.data = result
+  },
+  GET_ENUSER_FAILURE (state) {
+    state.enUser.fetching = false
   }
 }