|
@@ -231,3 +231,125 @@ export const goodsPurchaseOperate = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+* 根据产品发布询价
|
|
|
+* */
|
|
|
+export const seekProduct = {
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ applyObj: {
|
|
|
+ unitPrice: '',
|
|
|
+ currency: 'RMB',
|
|
|
+ encapsulation: '',
|
|
|
+ produceDate: '',
|
|
|
+ amount: '',
|
|
|
+ deadline: ''
|
|
|
+ },
|
|
|
+ validObj: {
|
|
|
+ unitPrice: true,
|
|
|
+ amount: true,
|
|
|
+ deadline: true
|
|
|
+ },
|
|
|
+ pickerOptions: {
|
|
|
+ disabledDate (time) {
|
|
|
+
|
|
|
+ return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
|
|
|
+ }
|
|
|
+ },
|
|
|
+ hasDialog: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ setDeadLineValid: function () {
|
|
|
+ this.applyObj.deadline = this.baseUtils.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.productItem.brand
|
|
|
+ inquiryItem.currency = currency
|
|
|
+ inquiryItem.cmpCode = this.productItem.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.productItem.spec
|
|
|
+ inquiryItem.prodTitle = this.productItem.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('请输入正确的数值')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|