refector: opl创建编辑时图片必填

This commit is contained in:
caoqianming 2023-04-13 14:19:20 +08:00
parent 982a69b65e
commit 1fcca2467a
10 changed files with 223 additions and 150 deletions

View File

@ -137,11 +137,12 @@
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="form-left"> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text> <text class="form-left-text">照片</text>
</view> </view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -419,24 +420,29 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
// debugger; // debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
debugger; // filter100(100)
if(item.id){ files = this.$refs.uUpload.lists.filter(val => {
console.log(item.id); return val.progress == 100;
that.formData.create_imgs.push(item.id)
}else{
console.log(item.response.id)
that.formData.create_imgs.push(item.response.id)
}
// let imgId = item.response.id?item.response.id:item.id;
// that.formData.create_imgs.push(imgId)
}) })
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
}
})
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();

View File

@ -136,10 +136,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -291,10 +294,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0,
id:item.id, id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -424,21 +424,29 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
debugger; debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();

View File

@ -147,10 +147,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -303,10 +306,8 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0,
id:item.id, id:item.id,
error: false, error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -435,21 +436,29 @@
}, },
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
debugger; debugger;
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {

View File

@ -146,10 +146,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -283,9 +286,6 @@
Authorization: "Bearer " + this.vuex_token Authorization: "Bearer " + this.vuex_token
} }
}, },
imgUpSuccess(data,index,lists){
this.fileList=lists;
},
//operation //operation
getOperation() { getOperation() {
let that = this; let that = this;
@ -307,10 +307,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0,
id:item.id, id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -454,21 +451,29 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
// //
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
console.log(1, that.oplCateCode) console.log(1, that.oplCateCode)
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {

View File

@ -145,10 +145,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -301,10 +304,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0,
id:item.id, id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -434,21 +434,29 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
debugger; debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();

View File

@ -137,11 +137,12 @@
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="form-left"> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text> <text class="form-left-text">照片</text>
</view> </view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -284,10 +285,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0, id:item.id
id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -412,22 +410,29 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
// debugger; // debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
debugger; // filter100(100)
if(item.id){ files = this.$refs.uUpload.lists.filter(val => {
console.log(item.id); return val.progress == 100;
that.formData.create_imgs.push(item.id) })
}else{
console.log(item.response.id) files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();

View File

@ -136,10 +136,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -291,10 +294,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0, id:item.id
id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -424,21 +424,29 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
debugger; debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();

View File

@ -146,10 +146,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -300,10 +303,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0, id:item.id
id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -447,21 +447,29 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
debugger; debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();

View File

@ -145,10 +145,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -302,10 +305,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0, id:item.id
id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -449,23 +449,31 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
debugger; debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
that.formData.start_time = that.formData.start_time+':00'; // that.formData.start_time = that.formData.start_time+':00';
that.formData.end_time = that.formData.end_time+':00'; // that.formData.end_time = that.formData.end_time+':00';
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();

View File

@ -238,10 +238,13 @@
</view> </view>
<view class="form-info"> <view class="form-info">
<view class="form-item " style="height: fit-content;"> <view class="form-item " style="height: fit-content;">
<view class="title">照片</view> <view class="form-left">
<text class="star">*</text>
<text class="form-left-text">照片</text>
</view>
<view style="flex: 3;"> <view style="flex: 3;">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" <u-upload :action="vuex_apifile" :header="header" ref="uUpload"
:file-list="fileList" max-count="9" @on-success="imgUpSuccess"></u-upload> :file-list="fileList" max-count="9"></u-upload>
</view> </view>
</view> </view>
</view> </view>
@ -412,10 +415,7 @@
res.create_imgs_.forEach(item=>{ res.create_imgs_.forEach(item=>{
that.fileList.push({ that.fileList.push({
url: that.vuex_host+item.path, url: that.vuex_host+item.path,
progress: 0, id:item.id
id:item.id,
error: false,
file: item
}) })
}) })
this.getOplcates() this.getOplcates()
@ -559,9 +559,6 @@
edit(row) {}, edit(row) {},
saveSubmit() { saveSubmit() {
debugger; debugger;
uni.showLoading({
title: '提交中'
});
let that = this; let that = this;
let params = null; let params = null;
// that.formData.start_time = that.formData.start_time; // that.formData.start_time = that.formData.start_time;
@ -570,15 +567,26 @@
// that.formData.power_end_time = that.formData.power_end_time; // that.formData.power_end_time = that.formData.power_end_time;
// that.formData.work_time = that.formData.work_time; // that.formData.work_time = that.formData.work_time;
that.formData.create_imgs = []; that.formData.create_imgs = [];
that.fileList.forEach(item=>{ let files = [];
if(item.id){ // filter100(100)
console.log(item.id); files = this.$refs.uUpload.lists.filter(val => {
that.formData.create_imgs.push(item.id) return val.progress == 100;
}else{ })
console.log(item.response.id)
files.forEach(item=>{
if(item.response){
that.formData.create_imgs.push(item.response.id) that.formData.create_imgs.push(item.response.id)
}else{
that.formData.create_imgs.push(item.id)
} }
}) })
if(that.formData.create_imgs.length === 0){
uni.showToast({
title: '请上传作业准备照片',
icon: 'none'
})
return
}
if (that.oplId !== null) { if (that.oplId !== null) {
that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => {
uni.hideLoading(); uni.hideLoading();