| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <div class="mobile-modal" v-if="showSayPriceBox">
- <div class="mobile-modal-box">
- <div class="mobile-modal-header">发布求购<i class="icon-guanbi iconfont" @click="cancel"></i></div>
- <div class="publish-seek">
- <div class="content-line">
- <span><i>*</i>型号:</span>
- <input type="text" v-model="applyObj.code" placeholder="请勿填中文符号">
- </div>
- <div class="content-line">
- <span><i>*</i>品牌:</span>
- <input type="text" v-model="applyObj.brand" placeholder="请勿填中文符号">
- </div>
- <div class="content-line">
- <span><i>*</i>截止日期:</span>
- <input type="text" v-model="applyObj.deadline" @blur="formatDeadLine" placeholder="如2017-02-11">
- </div>
- <div class="content-line">
- <span>币种:</span>
- <a v-text="applyObj.currency" @click="showCurrencyList = !showCurrencyList"></a>
- <img v-if="!showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-down.png" alt="">
- <img v-if="showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-up.png" alt="">
- <ul v-if="showCurrencyList">
- <li @click="setCurrency('RMB')">RMB</li>
- <li @click="setCurrency('USD')">USD</li>
- </ul>
- </div>
- <div class="content-line">
- <span>数量:</span>
- <input type="text" v-model="applyObj.amount">
- </div>
- <div class="content-line">
- <span>生产日期:</span>
- <input type="text" v-model="applyObj.produceDate">
- </div>
- <a @click="goPublish">确认发布</a>
- </div>
- </div>
- </div>
- </template>
- <script>
- let formatDate = function (date, fmt) {
- if (typeof date === 'string') {
- date = new Date(Date.parse(date.replace(/-/g, '/')))
- }
- let o = {
- 'M+': date.getMonth() + 1, // 月份
- 'd+': date.getDate(), // 日
- 'h+': 23, // 小时
- 'm+': 59, // 分
- 's+': 59, // 秒
- 'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
- 'S': date.getMilliseconds() // 毫秒
- }
- if (/(y+)/.test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
- }
- for (let k in o) {
- if (new RegExp('(' + k + ')').test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
- }
- }
- return fmt
- }
- export default {
- props: ['showSayPriceBox'],
- data () {
- return {
- applyObj: {
- code: '',
- brand: '',
- unitPrice: '',
- currency: 'RMB',
- encapsulation: '',
- produceDate: '',
- amount: '',
- deadline: ''
- },
- showCurrencyList: false
- }
- },
- computed: {
- user () {
- return this.$store.state.option.user
- }
- },
- methods: {
- cancel: function () {
- this.$emit('cancelAction')
- },
- emptyForm: function () {
- for (let attr in this.applyObj) {
- this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
- }
- },
- goPublish: function () {
- let inquiry = {}
- let inquiryItem = {}
- if (this.user.data.enterprise) {
- inquiry.enUU = this.user.data.enterprise.uu
- }
- let date = new Date()
- 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.prodTitle = this.applyObj.code
- 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 = this.applyObj.unitPrice ? this.applyObj.currency : null
- inquiryItem.cmpCode = (this.applyObj.code).toUpperCase()
- 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
- this.emptyForm()
- // this.validObj.deadline = true
- this.$emit('reloadAction')
- this.cancel()
- }, error => {
- console.log(error)
- this.$message.error('发布失败')
- })
- },
- formatDeadLine: function () {
- if (this.applyObj.deadline) {
- this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
- }
- },
- setCurrency: function (type) {
- this.applyObj.currency = type
- this.showCurrencyList = false
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .mobile-modal {
- .mobile-modal-box {
- .publish-seek {
- background: #fff;
- padding-top: .1rem;
- padding-bottom: .4rem;
- .content-line {
- height: .8rem;
- line-height: .8rem;
- font-size: .26rem;
- text-align: left;
- border-bottom: .01rem solid #b7d5fe;
- position: relative;
- input {
- width: 3.49rem;
- height: .52rem;
- padding-left: .19rem;
- border: .01rem solid #7e7e7e;
- }
- > span {
- display: inline-block;
- width: 1.76rem;
- text-align: right;
- i {
- color: #ff0000;
- margin-right: .05rem;
- font-style: normal;
- }
- }
- > a {
- font-size: .26rem;
- color: #666;
- }
- > img {
- width: .12rem;
- height: .06rem;
- margin-left: .04rem;
- }
- > ul {
- position: absolute;
- top: .6rem;
- left: 1.16rem;
- z-index: 1;
- width: 1.75rem;
- background: #fff;
- text-align: center;
- border-radius: .1rem;
- border: .01rem solid #dfdfdf;
- -webkit-box-shadow: 0 0 .12rem .02rem #e2d9d975;
- -moz-box-shadow: 0 0 .12rem .02rem #e2d9d975;
- box-shadow: 0 0 .12rem .02rem #e2d9d975;
- li {
- height: .52rem;
- line-height: .52rem;
- border-bottom: .01rem solid #dfdfdf;
- &:hover, &:active {
- background: #dedede;
- }
- }
- }
- }
- > a {
- display: block;
- width: 5.19rem;
- height: .84rem;
- text-align: center;
- line-height: .84rem;
- font-size: .38rem;
- margin: .3rem auto 0;
- background: #3f84f6;
- color: #fff;
- border-radius: .08rem;
- }
- }
- }
- }
- </style>
|