1
xuxueyang
2024-07-31 7e247648201b208cfb5a5901803f784b7dbda948
sub_pages/supplier/flower-manage/flower-add.vue
@@ -197,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>
@@ -338,10 +338,15 @@
      methods: {
         updateValue(item, value) {
            item.value = value
            this.$set(item, 'value', value)
            if (item.value.indexOf(value) >= 0) {
               item.value.splice(item.value.indexOf(value), 1)
            } else {
               item.value.push(value)
            }
            // item.value = value
            // this.$set(item, 'value', value)
            this.$forceUpdate()
            console.log('updateValue')
            // console.log('updateValue')
         },
         async updateSearch(search) {
            this.columns_categorys_search = search || ''
@@ -496,6 +501,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)
               }
            }
@@ -524,6 +537,16 @@
               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()
               // }
@@ -557,9 +580,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
            }
@@ -569,12 +592,13 @@
                  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 +621,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'}`, {
@@ -707,7 +732,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(',')