Commit a62735c5 authored by xiaoman's avatar xiaoman

Merge branch 'feature/develop_0713' of...

Merge branch 'feature/develop_0713' of http://gitlab.wanwudezhi.work/quanku/qk_admin into feature/develop_0713
parents b9c95dfc b3e9fdc3
......@@ -46,7 +46,12 @@
</el-form-item>
<el-form-item label="商品详细介绍">
<editor :init="editorInit" :style="{'min-height':'800px' }" v-model="goods.detail"/>
<!-- <editor :init="editorInit" :style="{'min-height':'800px' }" v-model="goods.detail"/>-->
<el-input
v-model="goods.detail"
:rows="10"
type="textarea"
placeholder="请输入详情"/>
</el-form-item>
</el-form>
</el-card>
......@@ -98,7 +103,7 @@
<script>
import { detailGoods, editGoods, listCategories } from '@/api/business/goods'
import { createStorage, uploadPath } from '@/api/business/storage'
import { uploadPath } from '@/api/business/storage'
import Editor from '@tinymce/tinymce-vue'
import { MessageBox } from 'element-ui'
import { getToken } from '@/utils/auth'
......@@ -119,8 +124,8 @@ export default {
goods: { images: [] },
rules: {
name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }]
},
editorInit: {
}
/* editorInit: {
language: 'zh_CN',
convert_urls: false,
plugins: [
......@@ -141,7 +146,7 @@ export default {
failure('上传失败,请重新上传')
})
}
}
}*/
}
},
computed: {
......@@ -157,13 +162,9 @@ export default {
methods: {
limitInput(value) {
this.goods.price = ('' + value) // 第一步:转成字符串
.replace(/[^\d^\.]+/g, '') // 第二步:把不是数字,不是小数点的过滤掉
.replace(/^0+(\d)/, '$1') // 第三步:第一位0开头,0后面为数字,则过滤掉,取后面的数字
.replace(/^\./, '0.') // 第四步:如果输入的第一位为小数点,则替换成 0. 实现自动补全
.match(/^\d*(\.?\d{0,2})/g)[0] || '' // 第五步:最终匹配得到结果 以数字开头,只有一个小数点, 而且小数点后面只能有0到2位小数
},
init: function() {
......@@ -174,6 +175,7 @@ export default {
const goodsId = this.$route.query.id
detailGoods(goodsId).then(response => {
this.goods = response.data.data.goods
this.goods.detail = this.trimHtml(this.goods.detail)
this.categoryIds = response.data.data.categoryIds
this.itemImages = []
......@@ -193,6 +195,10 @@ export default {
this.categoryList = response.data.data.categoryList
})
},
trimHtml(html_str) {
const text = html_str && html_str.replace(/<[^<>]+>/g, '') || ''
return text
},
handleCategoryChange(value) {
this.goods.cid = value[value.length - 1]
},
......
......@@ -171,13 +171,13 @@
@change="handleCategoryChange"/>
</el-form-item>
<el-form-item label="直径(mm):" prop="name">
<el-input v-model="goodsParams.diameter" :style="{ 'width':'300px' }" placeholder="请输入直径(mm)" />
<el-input v-model="goodsParams.diameter" :style="{ 'width':'300px' }" placeholder="请输入直径(mm)" type="number" @input="limitInput($event, 1)"/>
</el-form-item>
<el-form-item label="厚度(mm):" prop="name">
<el-input v-model="goodsParams.thickness" :style="{ 'width':'300px' }" placeholder="请输入厚度(mm)" />
<el-input v-model="goodsParams.thickness" :style="{ 'width':'300px' }" placeholder="请输入厚度(mm)" type="number" @input="limitInput($event, 2)"/>
</el-form-item>
<el-form-item label="质量(g):" prop="name">
<el-input v-model="goodsParams.weight" :style="{ 'width':'300px' }" placeholder="请输入质量(g)" />
<el-input v-model="goodsParams.weight" :style="{ 'width':'300px' }" placeholder="请输入质量(g)" type="number" @input="limitInput($event, 3)"/>
</el-form-item>
<el-form-item label="是否作为标准货币:" prop="isOnSale">
<el-radio-group v-model="goodsParams.isStd">
......@@ -302,6 +302,20 @@ export default {
window.addEventListener('scroll', this.handleScroll)
},
methods: {
limitInput(value, type) {
const newValue = ('' + value) // 第一步:转成字符串
.replace(/[^\d^\.]+/g, '') // 第二步:把不是数字,不是小数点的过滤掉
.replace(/^0+(\d)/, '$1') // 第三步:第一位0开头,0后面为数字,则过滤掉,取后面的数字
.replace(/^\./, '0.') // 第四步:如果输入的第一位为小数点,则替换成 0. 实现自动补全
.match(/^\d*(\.?\d{0,2})/g)[0] || '' // 第五步:最终匹配得到结果 以数字开头,只有一个小数点, 而且小数点后面只能有0到2位小数
if (type === 1) {
this.goodsParams.diameter = newValue
} else if (type === 2) {
this.goodsParams.thickness = newValue
} else if (type === 3) {
this.goodsParams.weight = newValue
}
},
handleScroll() {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
const testEle = this.$refs.top
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment