From e876fed618abd4237b9818424b72d01e24f8908c Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期四, 01 八月 2024 16:22:17 +0800
Subject: [PATCH] update
---
sub_pages/supplier/flower-manage/flower-add.vue | 84 ++++++++++++++++++++++++++++-------------
1 files changed, 57 insertions(+), 27 deletions(-)
diff --git a/sub_pages/supplier/flower-manage/flower-add.vue b/sub_pages/supplier/flower-manage/flower-add.vue
index 5caa9c1..185a721 100644
--- a/sub_pages/supplier/flower-manage/flower-add.vue
+++ b/sub_pages/supplier/flower-manage/flower-add.vue
@@ -163,11 +163,6 @@
<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>
@@ -202,8 +197,8 @@
<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>
@@ -342,11 +337,20 @@
},
methods: {
- updateValue(item, value) {
- item.value = value
- this.$set(item, 'value', value)
+ updateValue(item, 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 || ''
@@ -390,7 +394,7 @@
}
}
},
- mapCategoryTree(node, arr) {
+ mapCategoryTree(node, arr, parentCheckTrue = false) {
var has = true
if (arr) {
var hasTrue = false
@@ -401,6 +405,9 @@
has = true
if (this.columns_categorys_search) {
has = false
+ }
+ if (parentCheckTrue) {
+ has = true
}
var tmp = {
...item,
@@ -424,12 +431,14 @@
// }
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
}
@@ -496,6 +505,14 @@
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)
}
}
@@ -523,7 +540,17 @@
// // console.log('this.dto', this.dto)
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()
// }
@@ -540,7 +567,7 @@
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
}
@@ -557,9 +584,9 @@
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
}
@@ -568,13 +595,14 @@
this.$message.showToast(`${field.name}信息未填写`)
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
}
@@ -597,10 +625,11 @@
// 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'}`, {
@@ -629,7 +658,7 @@
uploadIcon(key) {
console.log('that dto key', key)
const that = this
- if (key == 'video') {
+ if (key === 'video') {
uni.chooseVideo({
maxDuration: 30,
sourceType: ['camera', 'album'],
@@ -707,7 +736,7 @@
var strs = []
for (var i of this.dto.params) {
if (i.value) {
- strs.push(i.value)
+ strs.push(i.value.join(","))
}
}
return strs.join(',')
@@ -738,8 +767,9 @@
// height: 100px;
.label {
- width: 300rpx;
+ width: 240rpx;
line-height: 60px;
+ min-width: 240rpx;
}
--
Gitblit v1.9.3