123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- export const carousel = {
- computed: {
- isIE () {
- return /(MSIE)|(Trident)/.test(this.$store.state.option.userAgent)
- },
- effect () {
- return this.isIE ? 'slide' : 'fade'
- }
- }
- }
- export const sayPriceReplace = {
- data () {
- return {
- showSimilarCodeList: false,
- showSimilarBrandList: false,
- similarCode: [],
- similarBrand: []
- }
- },
- methods: {
- clearSimilar: function () {
- this.showSimilarCodeList = false
- this.showSimilarBrandList = false
- },
- checkBrand: function () {
- let nullStrFlag = this.baseUtils.checkNullStr(this.sayPriceObj.replaceBrand)
- this.validSayPrice.replaceBrand = this.sayPriceObj.replaceBrand && this.sayPriceObj.replaceBrand !== '' && nullStrFlag
- if (!this.validSayPrice.replaceBrand) {
- if (!nullStrFlag) {
- if (this.$store.state.option.isMobile === true) {
- this.remindText = '品牌输入不合法'
- this.timeoutCount++
- } else {
- this.$message.error('品牌输入不合法')
- }
- } else {
- if (this.$store.state.option.isMobile === true) {
- this.remindText = '品牌不能为空'
- this.timeoutCount++
- } else {
- this.$message.error('品牌不能为空')
- }
- }
- }
- return this.validSayPrice.brand
- },
- checkCode: function () {
- let code = this.sayPriceObj.replaceCmpCode.trim()
- let nullStrFlag = this.baseUtils.checkNullStr(code)
- this.validSayPrice.replaceCmpCode = code && code !== '' && nullStrFlag
- if (!this.validSayPrice.replaceCmpCode) {
- if (!nullStrFlag) {
- if (this.$store.state.option.isMobile === true) {
- this.remindText = '型号输入不合法'
- this.timeoutCount++
- } else {
- this.$message.error('型号输入不合法')
- }
- } else {
- if (this.$store.state.option.isMobile === true) {
- this.remindText = '型号不能为空'
- this.timeoutCount++
- } else {
- this.$message.error('型号不能为空')
- }
- }
- }
- return this.validSayPrice.replaceCmpCode
- },
- onBrandChange: function () {
- this.sayPriceObj.replaceBrand = this.sayPriceObj.replaceBrand.trim()
- if ((/[^\x00-\xff]/g).test(this.sayPriceObj.replaceBrand)) {
- let chineseIndex = -1
- for (let i = 0; i < this.sayPriceObj.replaceBrand.length; i++) {
- if ((/[^\x00-\xff]/g).test(this.sayPriceObj.replaceBrand.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(this.sayPriceObj.replaceBrand.charAt(i))) {
- chineseIndex = i
- break
- }
- }
- if (chineseIndex > -1) {
- this.sayPriceObj.replaceBrand = this.sayPriceObj.replaceBrand.substring(0, chineseIndex)
- }
- } else if (this.sayPriceObj.replaceBrand && this.baseUtils.getRealLen(this.sayPriceObj.replaceBrand) > 50) {
- this.sayPriceObj.replaceBrand = this.baseUtils.cutOutString(this.sayPriceObj.replaceBrand, 50)
- } else {
- this.getSimilarBrand()
- }
- },
- onCodeChange: function () {
- if ((/[^\x00-\xff]/g).test(this.sayPriceObj.replaceCmpCode)) {
- let chineseIndex = -1
- for (let i = 0; i < this.sayPriceObj.replaceCmpCode.length; i++) {
- if ((/[^\x00-\xff]/g).test(this.sayPriceObj.replaceCmpCode.charAt(i))) {
- chineseIndex = i
- break
- }
- }
- this.sayPriceObj.replaceCmpCode = this.baseUtils.cutOutString(this.sayPriceObj.replaceCmpCode, chineseIndex)
- } else if (this.sayPriceObj.replaceCmpCode && this.baseUtils.getRealLen(this.sayPriceObj.replaceCmpCode) > 100) {
- this.sayPriceObj.replaceCmpCode = this.baseUtils.cutOutString(this.sayPriceObj.replaceCmpCode, 100)
- } else {
- this.getSimilarCode()
- }
- },
- getSimilarBrand: function () {
- if (this.sayPriceObj.replaceBrand) {
- this.$http.get('/search/similarBrands', {params: {keyword: this.sayPriceObj.replaceBrand}})
- .then(response => {
- this.similarBrand = response.data
- this.showSimilarBrandList = response.data.length > 0
- })
- } else {
- this.showSimilarBrandList = false
- }
- },
- getSimilarCode: function () {
- if (this.sayPriceObj.replaceCmpCode) {
- this.$http.get('/search/similarComponents', {params: {keyword: this.sayPriceObj.replaceCmpCode}})
- .then(response => {
- this.similarCode = response.data
- this.showSimilarCodeList = response.data.length > 0
- })
- } else {
- this.showSimilarCodeList = false
- }
- },
- setBrand: function (brand) {
- this.sayPriceObj.replaceBrand = brand
- this.showSimilarBrandList = false
- },
- setCode: function (code) {
- this.sayPriceObj.replaceCmpCode = code
- this.showSimilarCodeList = false
- }
- }
- }
- export const goodsPurchaseOperate = {
- methods: {
- initGoodsStatus (goodsItem, purchaseNumber) {
- let pack = goodsItem.perQty || goodsItem.minPackQty
- if (goodsItem.breakUp) {
- goodsItem.purchaseNumber = purchaseNumber || goodsItem.minBuyQty
- goodsItem.canSub = false
- goodsItem.canAdd = goodsItem.purchaseNumber < goodsItem.reserve
- } else {
- if (pack >= goodsItem.minBuyQty) {
- goodsItem.purchaseNumber = purchaseNumber || pack
- } else {
- let max = Math.max(pack, goodsItem.minBuyQty)
- goodsItem.purchaseNumber = purchaseNumber || (max + max % pack)
- }
- goodsItem.canSub = false
- goodsItem.canAdd = goodsItem.purchaseNumber + goodsItem.minPackQty <= goodsItem.reserve
- }
- goodsItem.currentPrice = Number((this.baseUtils.getPriceByLevel(goodsItem.prices, goodsItem.purchaseNumber, goodsItem.currencyName) * goodsItem.purchaseNumber).toFixed(6))
- },
- onPurchaseNumberInput: function (goods) {
- let showPrice = this.baseUtils.getPriceByLevel(goods.goods.prices, goods.goods.purchaseNumber, goods.goods.currencyName)
- goods.goods.currentPrice = Number(((showPrice || goods.goods.currentPrice) * goods.goods.purchaseNumber).toFixed(6))
- },
- checkPurchaseNumber: function (goods) {
- if ((/^[\d]*$/).test(goods.goods.purchaseNumber)) {
- this.changeNum(goods.goods.purchaseNumber, goods)
- } else {
- this.setRemindText('请输入整数')
- goods.goods.purchaseNumber = goods.goods.minBuyQty
- }
- },
- setGoods: function (type, goods) {
- if (type === 'set') {
- this.checkPurchaseNumber(goods)
- } else {
- let isAdd = type === 'add'
- let pack = goods.goods.perQty || goods.goods.minPackQty
- let newNum = 0
- if (goods.goods.breakUp) {
- newNum = isAdd ? goods.goods.purchaseNumber + 1 : goods.goods.purchaseNumber - 1
- } else {
- newNum = isAdd ? goods.goods.purchaseNumber + pack : goods.goods.purchaseNumber - pack
- }
- this.changeNum(newNum, goods)
- }
- },
- changeNum: function (newNum, goods) {
- let pack = goods.goods.perQty || goods.goods.minPackQty
- let buy = goods.goods.minBuyQty
- let reserve = goods.goods.reserve
- let breakUp = goods.goods.breakUp
- if (!newNum && newNum !== 0) {
- goods.goods.purchaseNumber = buy
- } else {
- newNum = parseInt(newNum)
- if (breakUp) {
- if (newNum < buy) {
- this.setRemindText('最小起订量为' + buy)
- goods.goods.purchaseNumber = buy
- goods.goods.canSub = false
- } else if (newNum > reserve) {
- this.setRemindText('库存不足')
- goods.goods.purchaseNumber = reserve
- goods.goods.canAdd = false
- } else {
- goods.goods.canSub = true
- goods.goods.canAdd = true
- goods.goods.purchaseNumber = newNum
- newNum === buy && (goods.goods.canSub = false)
- newNum === reserve && (goods.goods.canAdd = false)
- }
- } else {
- if (newNum < buy) {
- this.setRemindText('最小起订量为' + buy)
- goods.goods.purchaseNumber = buy
- goods.goods.canSub = false
- if (newNum > reserve) {
- this.setRemindText('库存不足')
- goods.goods.purchaseNumber = reserve - (reserve % pack)
- goods.goods.canAdd = false
- }
- } else if (newNum > reserve) {
- goods.goods.canSub = true
- goods.goods.canAdd = false
- this.setRemindText('库存不足')
- goods.goods.purchaseNumber = reserve - (reserve % pack)
- } else {
- goods.goods.canSub = true
- goods.goods.canAdd = true
- let remainder = newNum % pack
- if (remainder !== 0) {
- this.setRemindText('不支持拆包且包装量为' + pack)
-
- let res = (Math.floor(newNum / pack) + 1) * pack
- goods.goods.purchaseNumber = res > reserve ? Math.floor(newNum / pack) * pack : res
- } else {
- goods.goods.purchaseNumber = newNum
- }
- newNum === buy && (goods.goods.canSub = false)
- newNum === reserve && (goods.goods.canAdd = false)
- }
- }
- }
- this.onPurchaseNumberInput(goods)
- }
- }
- }
- 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.baseUtils.getFullDay(new Date(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.emptyForm()
- this.showObj.show = false
- }, error => {
- console.log(error)
- this.$message.error('发布失败')
- })
- } else {
- if (!this.validObj.deadline) {
- this.$message.error('截止日期不能为空')
- } else if (!this.validObj.amount) {
- this.$message.error('请输入正确的数值')
- }
- }
- }
- }
- }
|