|
|
@@ -97,6 +97,11 @@
|
|
|
<input v-model="form.flowerNum" @focus="onFlowerNumFocus" @blur="onFlowerNumBlur" placeholder-class="phcolor" class="tui-input" name="flowerNum" placeholder="用于判断花束大小" maxlength="5" type="number" />
|
|
|
</tui-list-cell>
|
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">重量(千克)</view>
|
|
|
+ <input v-model="form.weight" @focus="onWeightFocus" @blur="onWeightBlur" placeholder-class="phcolor" class="tui-input" name="weight" placeholder="单位:千克,可输入小数" maxlength="10" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
<view class="tui-title">节日涨价</view>
|
|
|
<view class="btn-group">
|
|
|
@@ -140,12 +145,10 @@
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { mapGetters } from "vuex";
|
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
|
-import AppUploader from "@/components/app-uploader";
|
|
|
const form = require("@/utils/formValidation.js");
|
|
|
import { getClass } from "@/api/category";
|
|
|
-import { getGoodsDetail, addGoodsData, updateGoodsData } from "@/api/goods";
|
|
|
+import { getGoodsDetail, updateGoodsData } from "@/api/goods";
|
|
|
//图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
|
|
|
import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
|
|
|
//import productMins from "@/mixins/product"; //复制页面代码时,没去掉,引入的话会导致页面崩溃
|
|
|
@@ -154,17 +157,13 @@ export default {
|
|
|
name: "add",
|
|
|
components: {
|
|
|
TuiListCell,
|
|
|
- AppUploader,
|
|
|
htzImageUpload
|
|
|
},
|
|
|
mixins: [inputRestore],//productMins,
|
|
|
data() {
|
|
|
return {
|
|
|
- selectJobType: "addGoodsSelectItem",
|
|
|
headers:{token:''},
|
|
|
currentImgData: [],
|
|
|
- status: 1,
|
|
|
- goodsInfo:[],
|
|
|
loading: false, // 添加加载状态
|
|
|
|
|
|
form: {
|
|
|
@@ -182,7 +181,7 @@ export default {
|
|
|
status: "1",
|
|
|
flower:1,
|
|
|
flowerNum:0,
|
|
|
- setItemNum:0,
|
|
|
+ weight: "",
|
|
|
stock:0,
|
|
|
cover: "",
|
|
|
shortCover: ""
|
|
|
@@ -192,9 +191,6 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
onLoad() {
|
|
|
- if(this.option.id){
|
|
|
- this.selectJobId = this.option.id
|
|
|
- }
|
|
|
const token = uni.getStorageSync('token')
|
|
|
this.headers.token = token
|
|
|
this.getDetail()
|
|
|
@@ -218,15 +214,6 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
init(){},
|
|
|
- changeKind(){
|
|
|
- this.pageTo({url:'/admin/goods/selectKind?style=2&flower='+this.form.flower})
|
|
|
- },
|
|
|
- setItemNumChange(e){
|
|
|
- this.form.setItemNum = e.detail.value;
|
|
|
- },
|
|
|
- selectItem(goods){
|
|
|
- this.pageTo({url:'/admin/goods/selectItem?id='+goods.id})
|
|
|
- },
|
|
|
imgDeleteFn(res){
|
|
|
const index = res.index
|
|
|
this.form.shopImg.splice(index,1)
|
|
|
@@ -299,25 +286,6 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.goodsInfo = res.data
|
|
|
-
|
|
|
- if(this.goodsInfo.goodsItem && !this.$util.isEmpty(this.goodsInfo.goodsItem)){
|
|
|
- const newItem = this.goodsInfo.goodsItem.map(ele=>{
|
|
|
- let unitType = ele.unitType
|
|
|
- let bigCount = 0
|
|
|
- let smallCount = 0
|
|
|
- let num = ele.num
|
|
|
- if(unitType == 0){
|
|
|
- bigCount = num
|
|
|
- }else{
|
|
|
- smallCount = num
|
|
|
- }
|
|
|
- return {name:ele.name,cover:ele.smallCover,itemId:ele.ptItemId,id:ele.itemId,ratio:ele.ratio,
|
|
|
- bigCount:bigCount,smallCount:smallCount,bigUnit:ele.bigName,smallUnit:ele.smallName,shortCover:ele.shortCover}
|
|
|
- })
|
|
|
- //this.pushToSave(newItem)
|
|
|
- }
|
|
|
-
|
|
|
Object.keys(this.form).forEach((i) => {
|
|
|
this.form[i] = res.data[i];
|
|
|
});
|
|
|
@@ -342,7 +310,6 @@ export default {
|
|
|
this.form.sold = res.data.sold || "";
|
|
|
// 添加仅支持自取字段
|
|
|
this.form.needSend = res.data.needSend || "0";
|
|
|
-
|
|
|
// 设置状态
|
|
|
this.form.status = res.data.status || "1";
|
|
|
|
|
|
@@ -435,6 +402,15 @@ export default {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 验证重量(千克)
|
|
|
+ if (this.form.weight !== "") {
|
|
|
+ const weightNum = parseFloat(this.form.weight);
|
|
|
+ if (isNaN(weightNum) || weightNum < 0) {
|
|
|
+ this.$msg('重量必须是大于等于0的数字!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
let formData = e.detail.value;
|
|
|
let checkRes = form.validation(formData, rules);
|
|
|
@@ -520,6 +496,7 @@ export default {
|
|
|
stock: this.form.stockSet === '1' ? parseInt(this.form.stock || 0) : 9999,
|
|
|
sold: parseInt(this.form.sold || 0),
|
|
|
flowerNum: parseInt(this.form.flowerNum || 0),
|
|
|
+ weight: parseFloat(this.form.weight || 0),
|
|
|
autoRise: this.form.autoRise,
|
|
|
needSend: this.form.needSend,
|
|
|
freightType: this.form.freightType,
|
|
|
@@ -563,12 +540,6 @@ export default {
|
|
|
freightChange(e) {
|
|
|
this.form.freightType = e.detail.value;
|
|
|
},
|
|
|
- flowerChange(e){
|
|
|
- if(this.option.id && Number(this.option.id)>0){
|
|
|
- this.$msg('不可修改')
|
|
|
- return false
|
|
|
- }
|
|
|
- },
|
|
|
statusChange(e){
|
|
|
this.form.status = e.detail.value;
|
|
|
},
|
|
|
@@ -596,6 +567,14 @@ export default {
|
|
|
// 花支数输入框失焦
|
|
|
onFlowerNumBlur() {
|
|
|
this.onInputBlur('flowerNum');
|
|
|
+ },
|
|
|
+ // 重量输入框聚焦
|
|
|
+ onWeightFocus() {
|
|
|
+ this.onInputFocus('weight');
|
|
|
+ },
|
|
|
+ // 重量输入框失焦
|
|
|
+ onWeightBlur() {
|
|
|
+ this.onInputBlur('weight');
|
|
|
}
|
|
|
}
|
|
|
};
|