|
|
@@ -8,3 +8,110 @@ export const carousel = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+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) {
|
|
|
+ this.$message.error('品牌输入不合法')
|
|
|
+ } 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) {
|
|
|
+ this.$message.error('型号输入不合法')
|
|
|
+ } 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|