Commit 106241a0 by liangjianmin

js

parent c63230d5
Showing with 94 additions and 66 deletions
......@@ -38,15 +38,17 @@
</view>
</view>
<view class="question-box">
<block v-for="(v, d) in form" :key="d">
<view class="top row verCenter">
<text class="t1">问题类型</text>
<text class="iconfont icon-sanjiaoxing1"></text>
<view class="el-select-box">
<picker @change="bindPickerChange" :value="index" :range="typeList" range-key="content">
<view class="uni-input">{{ typeList[index].content || '请选择' }}</view>
<picker @change="bindPickerChange($event, d)" :value="questionTypeIndex[d]" :range="typeList" range-key="content">
<view class="uni-input">{{ typeList[questionTypeIndex[d]].content || '请选择' }}</view>
</picker>
</view>
</view>
<!-- 问题列表 -->
<view class="uni-table">
<view class="uni-th row">
<text class="row verCenter">规格型号</text>
......@@ -54,35 +56,37 @@
<text class="row verCenter">实到{{ text }}</text>
<text class="row verCenter rowCenter" style="padding-left: 0;flex: 0 0 20%;">是否异常</text>
</view>
<view class="uni-tr row verCenter" v-for="(item, index) in form.exceptionlist" :key="index">
<view class="uni-tr row verCenter" v-for="(item, index) in form[d].exceptionlist" :key="index">
<text class="txt w row verCenter">{{ item.model }}</text>
<text class="txt w row verCenter">{{ item.order_data }}</text>
<input class="w uni-input" type="text" @input="onInput($event, index)" :disabled="!form.exception[index].is" :class="{bg:!form.exception[index].is}"/>
<view class="w" style="padding-left: 0;text-align: center;flex: 0 0 20%;"><switch @change="switchChange($event, index)" style="transform: scale(0.5);" color="#197ADB" /></view>
<input class="w uni-input" type="text" @input="onInput($event, d, index)" :disabled="!form[d].exception[index].is" :class="{ bg: !form[d].exception[index].is }" />
<view class="w" style="padding-left: 0;text-align: center;flex: 0 0 20%;"><switch :checked="form.exception[index].is" @change="switchChange($event, d, index)" style="transform: scale(0.5);" color="#197ADB" /></view>
</view>
</view>
<!-- 图片上传 -->
<view class="upload-box">
<view class="title row bothSide verCenter">
<text class="tt-l">来货图片上传(必填)</text>
<text class="tt-r">{{ attachAddress.length }}/4</text>
<text class="tt-r">{{ form[d].sort_goods_img.length }}/4</text>
</view>
<view class="upload-list row verCenter">
<template v-if="attachAddress.length > 0">
<view class="pic-box" v-for="(v, index) in attachAddress" :key="index">
<image :src="v" mode="aspectFill" lazy-load="true" @click="previewChange(attachAddress, index)"></image>
<view class="delete row rowCenter verCenter" @click="deletePic(index)"><text class="iconfont icon-shanchu"></text></view>
<template v-if="form[d].sort_goods_img.length > 0">
<view class="pic-box" v-for="(v, index) in form[d].sort_goods_img" :key="index">
<image :src="v" mode="aspectFill" lazy-load="true" @click="previewChange(form[d].sort_goods_img, index)"></image>
<view class="delete row rowCenter verCenter" @click="deletePic(d, index)"><text class="iconfont icon-shanchu"></text></view>
</view>
</template>
<view class="default row rowCenter verCenter" @click="chooseImageChange()" v-if="attachAddress.length < 4"><text class="iconfont icon-xingzhuangjiehe"></text></view>
<view class="default row rowCenter verCenter" @click="chooseImageChange(d)" v-if="form[d].sort_goods_img.length < 4"><text class="iconfont icon-xingzhuangjiehe"></text></view>
</view>
</view>
</block>
<view class="textarea-box">
<textarea @input="inputChange()" maxlength="200" placeholder="请输入异常备注" placeholder-style="color:#6E767A;" v-model="form.ask_customer_remark"></textarea>
<textarea @input="inputChange()" maxlength="200" placeholder="请输入异常备注" placeholder-style="color:#6E767A;" v-model="ask_customer_remark"></textarea>
<text class="text">{{ limitword }}/200</text>
</view>
</view>
<view class="btn row rowCenter verCenter" @click="submit()">提交委托单问客</view>
<view class="rebtn row rowCenter verCenter">保存并继续添加问题</view>
<view class="rebtn row rowCenter verCenter" @click="add()">保存并继续添加问题</view>
</view>
</template>
......@@ -95,27 +99,28 @@ export default {
return {
flag: false, //toggle
limitword: 0, //备注文字限制
index: 0,
attachAddress: [],
goodsArrangeData: {}, //理货列表数据
noexebshowFalg: true, //控制是否会触发生命周期
limitword: 0, //备注文字限制,
typeList: [],
text: '',
form: {
exceptionlist: [],
typeList: [], //问题类型列表
questionTypeIndex: [0], //问题类型索引
erp_order_sn: 'B50413', //form入仓号
ask_customer_remark: '', //form仓库问客备注
entrys: {}, //form 金蝶数据,
index: 0, //记录form当前操作索引
form: [
{
ask_customer_exception_id: '', //异常id
erp_order_sn: 'B50413', //入仓号
sort_goods_img: '', //问题图片
ask_customer_remark: '', //仓库问客备注
entrys: {},
exception: [],
originalData: [] //原始数据
sort_goods_img: [], //问题图片
exception: [], //异常开关监听列表
exceptionlist: [] //原始订单列表数据
}
]
};
},
onLoad(options) {
this.form.erp_order_sn = options.number || 'B50413'; //获取参数入仓号
this.erp_order_sn = options.number || 'B50413'; //获取参数入仓号
},
onShow() {
if (this.noexebshowFalg) {
......@@ -123,12 +128,15 @@ export default {
}
},
methods: {
/**
* 获取基础数据
*/
getData() {
this.request(API.getGoodsArrangeData, 'POST', { page: this.page, number: '' }, true).then(res => {
if (res.err_code === 0) {
this.goodsArrangeData = res.data[0];
this.form.entrys = res.data[0];
this.getAllException();
this.goodsArrangeData = res.data[0]; //理货列表数据
this.entrys = res.data[0]; //form 金蝶数据,
this.getAllException(0);
} else {
uni.showToast({
title: res.err_msg,
......@@ -137,13 +145,16 @@ export default {
}
});
},
getAllException() {
/**
* 获取问题类型
*/
getAllException(index) {
this.request(API.getAllException, 'POST', {}, true).then(res => {
if (res.err_code === 0) {
this.typeList = res.data;
this.form.ask_customer_exception_id = res.data[0].ask_customer_exception_id; //默认
this.form[index].ask_customer_exception_id = res.data[0].ask_customer_exception_id; //默认
this.text = res.data[0].content.substr(0, 2); //默认
this.getExceptionData();
this.getExceptionData(index);
} else {
uni.showToast({
title: res.err_msg,
......@@ -152,14 +163,19 @@ export default {
}
});
},
getExceptionData() {
this.request(API.getExceptionData, 'POST', { ask_customer_exception_id: this.form.ask_customer_exception_id, entrys: this.form.entrys }, true).then(res => {
/**
* 获取异常订单数据
*/
getExceptionData(index) {
this.request(API.getExceptionData, 'POST', { ask_customer_exception_id: this.form[index].ask_customer_exception_id, entrys: this.entrys }, true).then(res => {
if (res.err_code === 0) {
this.form.exception = []; //清空异常数据
this.form.exceptionlist = res.data;
this.form[index].exception = []; //清空异常开关监听列表
this.form[index].exceptionlist = res.data; //原始订单列表数据
//创建异常开关监听列表
if (res.data.length > 0) {
for (let i = 0; i < res.data.length; i++) {
this.form.exception.push({
this.form[index].exception.push({
val: '',
is: false
});
......@@ -173,12 +189,12 @@ export default {
}
});
},
onInput(e, index) {
this.form.exception[index].val = e.detail.value;
onInput(e, d, index) {
this.form[d].exception[index].val = e.detail.value;
},
switchChange(e, index) {
switchChange(e, d, index) {
console.log(e.target.value);
this.$set(this.form.exception[index], 'is', e.target.value);
this.$set(this.form[d].exception[index], 'is', e.target.value);
},
toggle() {
this.flag = !this.flag;
......@@ -191,21 +207,21 @@ export default {
});
},
inputChange() {
if (this.form.ask_customer_remark.length <= 200) {
this.limitword = this.form.ask_customer_remark.length;
if (this.ask_customer_remark.length <= 200) {
this.limitword = this.ask_customer_remark.length;
}
},
deletePic(index) {
this.attachAddress.splice(index, 1);
deletePic(d, index) {
this.form[d].sort_goods_img.splice(index, 1);
},
bindPickerChange: function(e) {
bindPickerChange(e, d) {
console.log('picker发送选择改变,携带值为', e.target.value);
this.index = e.target.value;
this.form.ask_customer_exception_id = this.typeList[e.target.value].ask_customer_exception_id;
this.questionTypeIndex[d] = e.target.value; //问题索引
this.form[d].ask_customer_exception_id = this.typeList[e.target.value].ask_customer_exception_id; //异常id
this.text = this.typeList[e.target.value].content.substr(0, 2); //文字
this.getExceptionData();
this.getExceptionData(d);
},
chooseImageChange() {
chooseImageChange(index) {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
var self = this;
var time = parseInt(new Date().getTime() / 1000);
......@@ -217,7 +233,7 @@ export default {
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFilePaths;
let maxNum = tempFilePaths.length * 1 + self.attachAddress.length * 1;
let maxNum = tempFilePaths.length * 1 + self.form[index].sort_goods_img.length * 1;
if (maxNum > 4) {
uni.hideLoading();
uni.showToast({
......@@ -241,7 +257,7 @@ export default {
var data = JSON.parse(uploadFileRes.data);
console.log(data);
if (data.code === 200) {
self.attachAddress.push(data.data[0]);
self.form[index].sort_goods_img.push(data.data[0]);
} else {
uni.showToast({
title: data.message,
......@@ -258,23 +274,30 @@ export default {
}
});
},
add() {
this.form.push({
ask_customer_exception_id: '',
sort_goods_img: [],
exception: [],
exceptionlist: []
});
this.index++;
this.questionTypeIndex.push(0);
uni.showLoading({
title: '添加问题中'
});
setTimeout(() => {
uni.hideLoading();
this.getAllException(this.index);
}, 500);
},
submit() {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
this.form.sort_goods_img = this.attachAddress; //复制图片
if (this.form.exception.length > 0) {
for (let i = 0; i < this.form.exception.length; i++) {
if (this.form.exception[i].is && this.form.exception[i].val == '') {
uni.showToast({
title: '请填写实到' + this.text,
icon: 'error'
});
return false;
}
}
}
if (this.attachAddress.length <= 0) {
//判断来货图片
if (this.form.length > 0) {
for (let i = 0; i < this.form.length; i++) {
if (this.form[i].sort_goods_img.length <= 0) {
uni.showModal({
title: '提示',
content: '请上传来货图片',
......@@ -288,9 +311,14 @@ export default {
});
return false;
}
}
}
this.request(API.addAskCustomer, 'POST', this.form, true).then(res => {
var params = { form: this.form, erp_order_sn: this.erp_order_sn, ask_customer_remark: this.ask_customer_remark, entrys: this.entrys };
this.request(API.addAskCustomer, 'POST', params, true).then(res => {
if (res.err_code === 0) {
} else {
uni.showToast({
title: res.err_msg,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment