| | |
| | | <view class="form-item before-line">
|
| | | <view class="label required">商品等级</view>
|
| | | <view class="m-l-a m-r-0 flex " :class="[!dto.level?'desc-gray':'']" @click="()=>{
|
| | | show_select_level=true
|
| | | if(dto.category){
|
| | | show_select_level=true
|
| | | }else{
|
| | | $message.showToast('请选择分类')
|
| | | }
|
| | | }">
|
| | | <view>{{dto.levelStr||dto.level || '请选择'}}</view>
|
| | | <u-icon class="m-l-a" name="arrow-right"></u-icon>
|
| | |
| | | <view class="form-item before-line">
|
| | | <view class="label required">售价(元)</view>
|
| | | <view class="m-l-a m-r-0 flex">
|
| | | <input v-model="dto.price" placeholder="请输入数字" type="digit"
|
| | | style="margin-top: 16px;text-align: right;"></input>
|
| | | <input v-model="dto.price" placeholder="请输入数字" type="digit" class="text-right m-t-15"></input>
|
| | | </view>
|
| | | </view>
|
| | | <view class="form-item ">
|
| | | <view class="label required">库存</view>
|
| | | <view class="m-l-a m-r-0 flex">
|
| | | <input v-model="dto.stock" placeholder="请输入数字" type="number"
|
| | | style="margin-top: 16px;text-align: right;"></input>
|
| | | <input v-model="dto.stock" placeholder="请输入数字" type="number" class="text-right m-t-15"></input>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | |
| | | </view>
|
| | | </view>
|
| | | <view v-if="dto.video">
|
| | | <video :src="dto.video" style="display: block;margin: 0 auto;"></video>
|
| | | <video :src="dto.video" :auto-pause-if-navigate="true" style="display: block;margin: 0 auto;"></video>
|
| | | </view>
|
| | | <view class="form-item bottom-border-no">
|
| | | <view class="label">商品描述</view>
|
| | | <view class="m-l-a m-r-0 flex">
|
| | | <!-- <u-input type="textarea" v-model="dto.description" placeholder="请输入商品描述" type="number"
|
| | | ></u-input> -->
|
| | | <!-- <u--textarea v-model="dto.description" style="margin-top: 16px;"
|
| | | placeholder="请输入商品描述" count></u--textarea> -->
|
| | | <!-- <uni-easyinput v-model="dto.description" placeholder="请输入商品描述" ></uni-easyinput> -->
|
| | |
|
| | | </view>
|
| | | </view>
|
| | |
| | | <view v-for="(item,i) in dto.params" :key="i" class="m-t-20">
|
| | | <view class="title topic-font" style="font-size: 40rpx;font-weight: 600;">{{item.name}}</view>
|
| | | <view class="m-t-12 flex value-items">
|
| | | <view class="value-item" @click="updateValue(item,each)" :class="[item.value===each?'cur':'']"
|
| | | v-for="(each, j) in item.values" :key="j">
|
| | | <view class="value-item" @click="updateValue(item,each)"
|
| | | :class="[item.value.indexOf(each)>=0?'cur':'']" v-for="(each, j) in item.values" :key="j">
|
| | | {{each || '-'}}
|
| | | </view>
|
| | | </view>
|
| | |
| | | columns_categorys_dict: {},
|
| | | columns_categorys_search: '',
|
| | | columns_levels: [],
|
| | | columns_levels_all: [],
|
| | | // columns_params: [], //弹窗选择具体的值
|
| | | // cancel: {
|
| | | // color: '#999',
|
| | |
| | | }
|
| | | }).then(res => {
|
| | | var data = res.data
|
| | | this.columns_levels_all = data || []
|
| | | this.columns_levels = [data || []]
|
| | | // this.columns_levels[0].unshift({
|
| | | // label: '全部',
|
| | |
| | |
|
| | | methods: {
|
| | | updateValue(item, value) {
|
| | | item.value = value
|
| | | this.$set(item, 'value', value)
|
| | |
|
| | | if (item.name == '优点' || item.name === '缺点') {
|
| | | if (item.value.indexOf(value) < 0) {
|
| | | item.value.push(value)
|
| | | } else {
|
| | | item.value.splice(item.value.indexOf(value), 1)
|
| | | }
|
| | | } else {
|
| | | //单选
|
| | | item.value = [value]
|
| | | }
|
| | |
|
| | | this.$forceUpdate()
|
| | | console.log('updateValue')
|
| | | },
|
| | | async updateSearch(search) {
|
| | | this.columns_categorys_search = search || ''
|
| | |
| | | this.$refs.picker_category.selectedClear()
|
| | | },
|
| | | async PickCategory(item, e) {
|
| | | console.log('PickCategory', item, e)
|
| | | console.log('PickCategory', item, e, this.columns_categorys_dict)
|
| | | if (e.detail.value) {
|
| | | var currentnode = this.columns_categorys_dict['@' + e.detail.value[e.detail.value.length - 1]
|
| | | .value]
|
| | | let levelLimit = currentnode && currentnode.levelLimit || ''
|
| | | if (!levelLimit) {
|
| | | if (currentnode.parentId) {
|
| | | var currentnodeParentNode = this.columns_categorys_dict['@' + currentnode.parentId]
|
| | | if (currentnodeParentNode) {
|
| | | levelLimit = currentnodeParentNode.levelLimit || ''
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | let tmpe = e
|
| | |
|
| | |
|
| | | if (this.dto.category && this.dto.category !== currentnode.id) {
|
| | | this.$message.confirm('修改分类将清空商品参数,确定修改吗').then(async res => {
|
| | | // console.log('currentnode',currentnode,this.columns_categorys_dict,'@'+e.detail.value[e.detail.value.length - 1].value)
|
| | | this.dto.categoryStr = currentnode.name
|
| | | this.dto.category = currentnode.id
|
| | |
|
| | | this.dto.name = currentnode.name
|
| | | this.dto.unit = currentnode.unit
|
| | | this.dto.color = currentnode.color
|
| | | //设置等级
|
| | | // console.log('tmpe', currentnode)
|
| | | if (levelLimit) {
|
| | |
|
| | | this.columns_levels = []
|
| | | var tarr = []
|
| | | var filterLevel = levelLimit.split(",")
|
| | | for (var t of this.columns_levels_all) {
|
| | | if (filterLevel.indexOf(t.value) >= 0) {
|
| | | tarr.push(t)
|
| | | }
|
| | | }
|
| | | this.columns_levels = [tarr]
|
| | | //如果不包含等级需要清除
|
| | | if (this.dto.level) {
|
| | | if (filterLevel.indexOf(this.dto.level) >= 0) {
|
| | |
|
| | | } else {
|
| | | this.dto.level = ''
|
| | | this.dto.levelStr = ''
|
| | | }
|
| | | }
|
| | | } else {
|
| | | this.columns_levels = [this.columns_levels_all]
|
| | | }
|
| | | //递归获取category的其他数据,用来做map?
|
| | | this.$message.showLoading()
|
| | | await this.refresh_category()
|
| | |
| | | this.$refs.picker_category.onchange(tmpe.detail.value)
|
| | | })
|
| | | } else {
|
| | | //设置等级
|
| | | // console.log('tmpe', currentnode)
|
| | | if (levelLimit) {
|
| | |
|
| | | this.columns_levels = []
|
| | | var tarr = []
|
| | | var filterLevel = levelLimit.split(",")
|
| | | for (var t of this.columns_levels_all) {
|
| | | if (filterLevel.indexOf(t.value) >= 0) {
|
| | | tarr.push(t)
|
| | | }
|
| | | }
|
| | | this.columns_levels = [tarr]
|
| | | //如果不包含等级需要清除
|
| | | if (this.dto.level) {
|
| | | if (filterLevel.indexOf(this.dto.level) >= 0) {
|
| | |
|
| | | } else {
|
| | | this.dto.level = ''
|
| | | this.dto.levelStr = ''
|
| | | }
|
| | | }
|
| | | } else {
|
| | | this.columns_levels = [this.columns_levels_all]
|
| | | }
|
| | | this.dto.categoryStr = currentnode.name
|
| | | this.dto.category = currentnode.id
|
| | | this.dto.name = currentnode.name
|
| | |
| | | }
|
| | | }
|
| | | },
|
| | | mapCategoryTree(node, arr) {
|
| | | mapCategoryTree(node, arr, parentCheckTrue = false) {
|
| | | var has = true
|
| | | if (arr) {
|
| | | var hasTrue = false
|
| | |
| | | has = true
|
| | | if (this.columns_categorys_search) {
|
| | | has = false
|
| | | }
|
| | | if (parentCheckTrue) {
|
| | | has = true
|
| | | }
|
| | | var tmp = {
|
| | | ...item,
|
| | |
| | | // }
|
| | | this.columns_categorys_dict['@' + item.id] = item
|
| | | if (item.children && item.children.length > 0) {
|
| | | //如果上级已经有了,下级都包含
|
| | | tmp.children = []
|
| | | var childrenhas = this.mapCategoryTree(tmp.children, item.children)
|
| | | var childrenhas = this.mapCategoryTree(tmp.children, item.children, has)
|
| | | if (childrenhas) {
|
| | | has = true
|
| | | hasTrue = true
|
| | | }
|
| | |
|
| | | } else {
|
| | | tmp.children = undefined
|
| | | }
|
| | |
| | | if (res.code == 0) {
|
| | | // this.columns_params = res.data || []
|
| | | this.dto.params = res.data || []
|
| | | for (var k of this.dto.params) {
|
| | | if (!k.value) {
|
| | | k.value = []
|
| | | } else {
|
| | | k.value = k.value.split(',') || []
|
| | | }
|
| | | }
|
| | | // console.log('init params',this.dto.params)
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | },
|
| | |
| | | if (!this.dto.bannerList) {
|
| | | this.dto.bannerList = []
|
| | | }
|
| | | if (this.dto.params) {
|
| | | for (var k of this.dto.params) {
|
| | | if (!k.value) {
|
| | | k.value = []
|
| | | } else {
|
| | | k.value = k.value.split(',') || []
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // if (this.dto.category) {
|
| | | // await this.refresh_category()
|
| | | // }
|
| | |
| | | var tmp = parseFloat(this.dto.price)
|
| | | if (isNaN(tmp) || parseFloat('' + tmp).toFixed(3) !== parseFloat('' + this.dto.price).toFixed(3)) {
|
| | | this.$message.showToast('商品价格格式错误,精确到分')
|
| | | console.log('a1', ('' + tmp) )
|
| | | console.log('a1', ('' + tmp))
|
| | | console.log('a1', ('' + this.dto.price))
|
| | | return
|
| | | }
|
| | |
| | | this.$message.showToast('商品价格不能小于等于0')
|
| | | return
|
| | | }
|
| | | tmp = parseFloat(this.dto.stock)
|
| | | if (isNaN(tmp) || ('' + tmp.toFixed(0)) !== ('' + this.dto.stock) || tmp < 0) {
|
| | | this.$message.showToast('商品库存格式错误,需要大于等于0')
|
| | | tmp = parseInt(this.dto.stock)
|
| | | if (isNaN(tmp) || ('' + tmp.toFixed(0)) !== ('' + this.dto.stock) || tmp <= 0) {
|
| | | this.$message.showToast('商品库存格式错误,需要大于0')
|
| | | return
|
| | | }
|
| | |
|
| | |
| | | return
|
| | | }
|
| | | }
|
| | |
|
| | | if (this.dto.params.length < 1) {
|
| | | this.$message.showToast('商品参数详情未设置')
|
| | | return
|
| | | } else {
|
| | | for (var item of this.dto.params) {
|
| | | if (!item.value) {
|
| | | if (item.value.length < 1) {
|
| | | this.$message.showToast('存在商品参数详情未设置')
|
| | | return
|
| | | }
|
| | |
| | |
|
| | | // this.$message.showToast('1')
|
| | | // return
|
| | | var dto = {
|
| | | ...this.dto,
|
| | | // applicationDate: this.$util.toDate(new Date()),
|
| | | // applicantId: this.currentInfo.id
|
| | | var dto = JSON.parse(JSON.stringify(this.dto))
|
| | | if (dto.params) {
|
| | | for (var k of dto.params) {
|
| | | k.value = k.value.join(",")
|
| | | }
|
| | | }
|
| | | this.$message.showLoading()
|
| | | const re = await this.$http.request('post', `/api/supplier/flower/list/${this.id?'edit':'new'}`, {
|
| | |
| | | uploadIcon(key) {
|
| | | console.log('that dto key', key)
|
| | | const that = this
|
| | | if (key == 'video') {
|
| | | if (key === 'video') {
|
| | | uni.chooseVideo({
|
| | | maxDuration: 30,
|
| | | sourceType: ['camera', 'album'],
|
| | |
| | | var strs = []
|
| | | for (var i of this.dto.params) {
|
| | | if (i.value) {
|
| | | strs.push(i.value)
|
| | | strs.push(i.value.join(","))
|
| | | }
|
| | | }
|
| | | return strs.join(',')
|
| | |
| | | // height: 100px;
|
| | |
|
| | | .label {
|
| | | width: 300rpx;
|
| | | width: 240rpx;
|
| | | line-height: 60px;
|
| | | min-width: 240rpx;
|
| | |
|
| | | }
|
| | |
|