优化报修 小程序 上的部分bug

This commit is contained in:
java110 2022-06-15 11:09:12 +08:00
parent 9b849089e0
commit 0645e77bce
2 changed files with 165 additions and 138 deletions

View File

@ -1,71 +1,95 @@
<template>
<view class="select-single-resource" v-if="showModel">
<view>
<view class="cu-form-group margin-top">
<view class="title">商品类型</view>
<picker :value="goodsTypeIndex" :range="goodsTypeCloums" :range-key="'name'" @change="goodsParentTypeChange">
<view class="picker">
{{goodsTypeCloums[goodsTypeIndex].name}}
</view>
</picker>
</view>
<view v-if="isCustom">
<view class="cu-form-group margin-top">
<view class="title">商品名</view>
<input v-model="customGoodsName" placeholder="请输入商品名"></input>
<view class="cu-modal bottom-modal" :class="showModel?'show':''">
<view class="cu-dialog">
<view class="cu-bar bg-white ">
<view class="action">
<text class="cuIcon-title text-orange "></text>{{productInfo.prodName}}
</view>
<view class="cu-form-group margin-top" v-show="feeFlag == '1001'">
<view class="title">自定义价格</view>
<input type="number" v-model="singlePrice" placeholder="请输入自定义价格"></input>
<view class="action">
</view>
</view>
<view v-else>
<view class="cu-form-group margin-top">
<view class="title">二级分类</view>
<picker :value="goodsSonTypeIndex" :range="goodsSonTypeCloums" :range-key="'name'" @change="goodsTypeChange">
<view class="picker">
{{goodsSonTypeCloums[goodsSonTypeIndex].name}}
<scroll-view scroll-y style="height: 700upx;">
<block>
<view class="select-single-resource">
<view>
<view class="cu-form-group margin-top">
<view class="title">商品类型</view>
<picker :value="goodsTypeIndex" :range="goodsTypeCloums" :range-key="'name'"
@change="goodsParentTypeChange">
<view class="picker">
{{goodsTypeCloums[goodsTypeIndex].name}}
</view>
</picker>
</view>
<view v-if="isCustom">
<view class="cu-form-group margin-top">
<view class="title">商品名</view>
<input v-model="customGoodsName" placeholder="请输入商品名"></input>
</view>
<view class="cu-form-group margin-top" v-show="feeFlag == '1001'">
<view class="title">自定义价格</view>
<input type="number" v-model="singlePrice" placeholder="请输入自定义价格"></input>
</view>
</view>
<view v-else>
<view class="cu-form-group margin-top">
<view class="title">二级分类</view>
<picker :value="goodsSonTypeIndex" :range="goodsSonTypeCloums" :range-key="'name'"
@change="goodsTypeChange">
<view class="picker">
{{goodsSonTypeCloums[goodsSonTypeIndex].name}}
</view>
</picker>
</view>
<view class="cu-form-group margin-top" v-if="rstId!=''">
<view class="title">商品</view>
<picker :value="goodsIndex" :range="goodsCloums" :range-key="'resName'"
@change="goodsChange">
<view class="picker">
{{goodsCloums[goodsIndex].resName}}
</view>
</picker>
</view>
<view v-if="goodsIndex!=0">
<view class="cu-form-group margin-top" v-show="feeFlag == '1001'">
<view class="title">单价</view>
<input type="number" v-model="singlePrice" :disabled="disabledPrice"
placeholder="请输入单价"></input>
</view>
<view v-show="feeFlag == '1001'">
<view class="text-right text-grey"
v-if="goods.outHighPrice == goods.outLowPrice">价格:{{goods.outLowPrice}}
</view>
<view class="text-right text-grey" v-else>
价格范围{{goods.outLowPrice}}-{{goods.outHighPrice}}</view>
</view>
<view class="cu-form-group margin-top">
<view class="title">规格</view>
<input type="text" v-model="goods.specName" disabled="disabled"></input>
</view>
</view>
</view>
<view class="cu-form-group margin-top">
<view class="title">数量</view>
<view class="use-num-container">
<view class="dec" @tap="numDec">-</view>
<input class="use-num-input" v-model="useNumber" disabled="disabled"
@input="goodsNumChange"></input>
<view class="inc" @tap="numInc">+</view>
</view>
</view>
<view class="flex flex-direction margin-top">
<button class="cu-btn bg-green margin-tb-sm lg" @click="_save()">确定</button>
</view>
<view class="flex flex-direction margin-top">
<button class="cu-btn bg-red margin-tb-sm lg" @click="_canel()">取消</button>
</view>
</view>
</picker>
</view>
<view class="cu-form-group margin-top" v-if="rstId!=''">
<view class="title">商品</view>
<picker :value="goodsIndex" :range="goodsCloums" :range-key="'resName'" @change="goodsChange">
<view class="picker">
{{goodsCloums[goodsIndex].resName}}
</view>
</picker>
</view>
<view v-if="goodsIndex!=0">
<view class="cu-form-group margin-top" v-show="feeFlag == '1001'">
<view class="title">单价</view>
<input type="number" v-model="singlePrice" :disabled="disabledPrice" placeholder="请输入单价"></input>
</view>
<view v-show="feeFlag == '1001'">
<view class="text-right text-grey" v-if="goods.outHighPrice == goods.outLowPrice">价格:{{goods.outLowPrice}}</view>
<view class="text-right text-grey" v-else>价格范围{{goods.outLowPrice}}-{{goods.outHighPrice}}</view>
</view>
<view class="cu-form-group margin-top">
<view class="title">规格</view>
<input type="text" v-model="goods.specName" disabled="disabled"></input>
</view>
</view>
</view>
<view class="cu-form-group margin-top">
<view class="title">数量</view>
<view class="use-num-container">
<view class="dec" @tap="numDec">-</view>
<input class="use-num-input" v-model="useNumber" disabled="disabled" @input="goodsNumChange"></input>
<view class="inc" @tap="numInc">+</view>
</view>
</view>
<view class="flex flex-direction margin-top">
<button class="cu-btn bg-green margin-tb-sm lg" @click="_save()">确定</button>
</view>
<view class="flex flex-direction margin-top">
<button class="cu-btn bg-red margin-tb-sm lg" @click="_canel()">取消</button>
</view>
</block>
</scroll-view>
</view>
</view>
</template>
@ -77,11 +101,12 @@
queryResourceStoreResName,
queryRepairInfo
} from '../../api/repair/repair.js'
import {getCurrentCommunity} from '../../api/community/community.js'
import {
getCurrentCommunity
} from '../../api/community/community.js'
export default {
components: {
},
components: {},
data() {
return {
showModel: false,
@ -118,27 +143,23 @@
type: String
}
},
watch: {
},
created() {
},
computed: {
},
mounted() {
},
watch: {},
created() {},
computed: {},
mounted() {},
methods: {
switchShow: function(){
switchShow: function() {
this.resetData();
this.showModel = !this.showModel;
},
resetData: function(){
resetData: function() {
let _that = this;
let initData = {
showModel: false,
@ -172,16 +193,16 @@
this.copyObject(initData, _that);
this._loadRepairGoodsType();
},
copyObject: function (org, dst) {
copyObject: function(org, dst) {
for (let key in dst) {
if (org.hasOwnProperty(key)) {
dst[key] = org[key]
}
}
},
_loadRepairGoodsType: function(){
_loadRepairGoodsType: function() {
let _that = this;
let _data = {
page: 1,
@ -195,17 +216,17 @@
_that._appendCustomResourceStoreType();
});
},
//
_appendCustomResourceStoreType: function () {
let customeType = {
rstId: 'custom',
name: '自定义'
};
this.goodsTypeCloums.push(customeType);
},
_loadRepairGoods: function(){
_appendCustomResourceStoreType: function() {
let customeType = {
rstId: 'custom',
name: '自定义'
};
this.goodsTypeCloums.push(customeType);
},
_loadRepairGoods: function() {
let _that = this;
let _data = {
resId: "",
@ -227,21 +248,25 @@
return;
}
let _data = _json.data;
_that.goodsCloums = [{resName: '请选择商品'}]
_that.goodsCloums = [{
resName: '请选择商品'
}]
_that.goodsIndex = 0;
_that.goods = '';
_that.amount = '';
if(_data.length < 1){
if (_data.length < 1) {
return;
}
_that.goodsCloums = _that.goodsCloums.concat(_data);
});
},
// change
goodsParentTypeChange: function(e){
goodsParentTypeChange: function(e) {
//
this.goodsSonTypeCloums = [{name: '请选择商品类型'}];
this.goodsSonTypeCloums = [{
name: '请选择商品类型'
}];
this.goodsSonTypeIndex = 0;
this.rstId = '';
//
@ -251,17 +276,17 @@
return;
}
let selected = this.goodsTypeCloums[this.goodsTypeIndex] //
if(selected.rstId == 'custom'){
if (selected.rstId == 'custom') {
this.isCustom = true;
return;
}else{
} else {
this.isCustom = false;
}
this.parentRstId = selected.rstId //id
this._loadSonGoodsTypes();
},
//
_loadSonGoodsTypes: function(){
_loadSonGoodsTypes: function() {
let _that = this;
let _data = {
page: 1,
@ -278,7 +303,7 @@
});
},
// change
goodsTypeChange: function(e){
goodsTypeChange: function(e) {
this.goodsSonTypeIndex = e.target.value //
if (this.goodsSonTypeIndex == 0) {
this.rstId = ''
@ -288,8 +313,8 @@
this.rstId = selected.rstId //id
this._loadRepairGoods();
},
goodsChange: function(e){
goodsChange: function(e) {
this.goodsIndex = e.target.value //
if (this.goodsIndex == 0) {
this.goods = ''
@ -297,17 +322,17 @@
}
let selected = this.goodsCloums[this.goodsIndex] //
this.goods = selected
if(selected.outLowPrice == selected.outHighPrice){
if (selected.outLowPrice == selected.outHighPrice) {
this.singlePrice = selected.outLowPrice;
this.disabledPrice = true;
}else{
} else {
this.singlePrice = '';
this.disabledPrice = false;
}
},
numDec: function(){
if(this.useNumber <= 1){
numDec: function() {
if (this.useNumber <= 1) {
uni.showToast({
title: '不能再减少了',
icon: 'none'
@ -316,34 +341,34 @@
}
this.useNumber -= 1;
},
numInc: function(){
numInc: function() {
this.useNumber += 1;
},
_save: function(){
_save: function() {
//
let msg = '';
if(this.isCustom){
if(!this.customGoodsName){
if (this.isCustom) {
if (!this.customGoodsName) {
msg = '请输入商品名';
}else if(this.feeFlag == '1001' && !this.singlePrice){
} else if (this.feeFlag == '1001' && !this.singlePrice) {
msg = '请输入有效金额';
}
}else{
if(this.rstId == ''){
} else {
if (this.rstId == '') {
msg = "请选择商品类型";
}else if (this.useNumber < 1){
} else if (this.useNumber < 1) {
msg = "商品数量不能为零";
}else if (!this.goods){
} else if (!this.goods) {
msg = "请选择商品";
}else if (this.feeFlag == '1001' && !this.singlePrice){
} else if (this.feeFlag == '1001' && !this.singlePrice) {
msg = "请输入有效金额";
}
}
if(msg != ''){
if (msg != '') {
wx.showToast({
title:msg,
title: msg,
icon: 'none'
})
return;
@ -353,15 +378,15 @@
chooseResource.useNumber = this.useNumber;
chooseResource.isCustom = this.isCustom;
chooseResource.customGoodsName = this.customGoodsName;
if(this.isCustom){
if (this.isCustom) {
chooseResource.goodsTypeName = '自定义';
}
chooseResource = JSON.stringify(chooseResource);
this.$emit('getResourceInfo', chooseResource)
this.showModel = false;
},
_canel: function(){
_canel: function() {
this.showModel = false;
}
}
@ -369,7 +394,7 @@
</script>
<style>
.select-single-resource{
.select-single-resource {
position: fixed;
top: 100rpx;
left: 0;
@ -377,16 +402,20 @@
width: 100%;
height: 100%;
}
.use-num-container{
.use-num-container {
display: flex;
flex-direction: row;
}
.use-num-input{
.use-num-input {
width: 100rpx;
text-align: center;
padding: 0;
}
.inc,.dec{
.inc,
.dec {
border: 1px solid #000;
border-radius: 50%;
width: 40rpx;

View File

@ -389,16 +389,14 @@
wx.chooseImage({
count: 4, //9
sizeType: ['original', 'compressed'], //
sourceType: ['album'], //
sourceType: ['camera','album'], //
success: (res) => {
that.imgList.push(res.tempFilePaths[0]);
var tempFilePaths = res.tempFilePaths[0]
//#ifdef H5
TanslateImage.translate(tempFilePaths, (url) => {
that.photos.push(url);
})
//#endif
}
});
},
@ -407,15 +405,15 @@
wx.chooseImage({
count: 4, //9
sizeType: ['original', 'compressed'], //
sourceType: ['album'], //
sourceType: ['camera','album'], //
success: (res) => {
that.beforeRepairImgList.push(res.tempFilePaths[0]);
var tempFilePaths = res.tempFilePaths[0]
//#ifdef H5
TanslateImage.translate(tempFilePaths, (url) => {
that.beforeRepairPhotos.push(url);
})
//#endif
}
});
},
@ -424,7 +422,7 @@
wx.chooseImage({
count: 4, //9
sizeType: ['original', 'compressed'], //
sourceType: ['album'], //
sourceType: ['camera','album'], //
success: (res) => {
that.afterRepairImgList.push(res.tempFilePaths[0]);
var tempFilePaths = res.tempFilePaths[0]
@ -523,4 +521,4 @@
color: #0081FF;
text-decoration: underline;
}
</style>
</style>