From 1fcca2467a1be3bcd4e10e1dba4a9893b205e295 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 13 Apr 2023 14:19:20 +0800 Subject: [PATCH] =?UTF-8?q?refector:=20opl=E5=88=9B=E5=BB=BA=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=97=B6=E5=9B=BE=E7=89=87=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/workSpace/opls/clear.vue | 36 +++++++++++++++----------- pages/workSpace/opls/cooler.vue | 36 +++++++++++++++----------- pages/workSpace/opls/fire.vue | 35 ++++++++++++++++---------- pages/workSpace/opls/high.vue | 39 +++++++++++++++------------- pages/workSpace/opls/hoisting.vue | 36 +++++++++++++++----------- pages/workSpace/opls/normal.vue | 35 +++++++++++++++----------- pages/workSpace/opls/preheat.vue | 38 +++++++++++++++++----------- pages/workSpace/opls/soil.vue | 38 +++++++++++++++++----------- pages/workSpace/opls/space.vue | 42 ++++++++++++++++++------------- pages/workSpace/opls/usecl.vue | 38 +++++++++++++++++----------- 10 files changed, 223 insertions(+), 150 deletions(-) diff --git a/pages/workSpace/opls/clear.vue b/pages/workSpace/opls/clear.vue index 239a028..07f0b32 100644 --- a/pages/workSpace/opls/clear.vue +++ b/pages/workSpace/opls/clear.vue @@ -137,11 +137,12 @@ + * 照片 + :file-list="fileList" max-count="9"> @@ -419,24 +420,29 @@ edit(row) {}, saveSubmit() { // debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - debugger; - if(item.id){ - console.log(item.id); - 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) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading(); diff --git a/pages/workSpace/opls/cooler.vue b/pages/workSpace/opls/cooler.vue index 3f95dbc..4e14981 100644 --- a/pages/workSpace/opls/cooler.vue +++ b/pages/workSpace/opls/cooler.vue @@ -136,10 +136,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -291,10 +294,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, id:item.id, - error: false, - file: item }) }) this.getOplcates() @@ -424,21 +424,29 @@ edit(row) {}, saveSubmit() { debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading(); diff --git a/pages/workSpace/opls/fire.vue b/pages/workSpace/opls/fire.vue index 6c8b15f..a7fbe2a 100644 --- a/pages/workSpace/opls/fire.vue +++ b/pages/workSpace/opls/fire.vue @@ -147,10 +147,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -303,10 +306,8 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, id:item.id, error: false, - file: item }) }) this.getOplcates() @@ -435,21 +436,29 @@ }, edit(row) {}, saveSubmit() { - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { debugger; that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { diff --git a/pages/workSpace/opls/high.vue b/pages/workSpace/opls/high.vue index cd72540..94cd9f5 100644 --- a/pages/workSpace/opls/high.vue +++ b/pages/workSpace/opls/high.vue @@ -146,10 +146,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -283,9 +286,6 @@ Authorization: "Bearer " + this.vuex_token } }, - imgUpSuccess(data,index,lists){ - this.fileList=lists; - }, //获取工作operation getOperation() { let that = this; @@ -307,10 +307,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, id:item.id, - error: false, - file: item }) }) this.getOplcates() @@ -454,21 +451,29 @@ edit(row) {}, saveSubmit() { // - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { console.log(1, that.oplCateCode) that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { diff --git a/pages/workSpace/opls/hoisting.vue b/pages/workSpace/opls/hoisting.vue index bc6a8d3..f44ab10 100644 --- a/pages/workSpace/opls/hoisting.vue +++ b/pages/workSpace/opls/hoisting.vue @@ -145,10 +145,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -301,10 +304,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, id:item.id, - error: false, - file: item }) }) this.getOplcates() @@ -434,21 +434,29 @@ edit(row) {}, saveSubmit() { debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading(); diff --git a/pages/workSpace/opls/normal.vue b/pages/workSpace/opls/normal.vue index 9c61fc3..66a86d6 100644 --- a/pages/workSpace/opls/normal.vue +++ b/pages/workSpace/opls/normal.vue @@ -137,11 +137,12 @@ + * 照片 + :file-list="fileList" max-count="9"> @@ -284,10 +285,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, - id:item.id, - error: false, - file: item + id:item.id }) }) this.getOplcates() @@ -412,22 +410,29 @@ edit(row) {}, saveSubmit() { // debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - debugger; - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading(); diff --git a/pages/workSpace/opls/preheat.vue b/pages/workSpace/opls/preheat.vue index 6eb11f6..fbdf6ea 100644 --- a/pages/workSpace/opls/preheat.vue +++ b/pages/workSpace/opls/preheat.vue @@ -136,10 +136,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -291,10 +294,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, - id:item.id, - error: false, - file: item + id:item.id }) }) this.getOplcates() @@ -424,21 +424,29 @@ edit(row) {}, saveSubmit() { debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading(); diff --git a/pages/workSpace/opls/soil.vue b/pages/workSpace/opls/soil.vue index 3e7726e..734460f 100644 --- a/pages/workSpace/opls/soil.vue +++ b/pages/workSpace/opls/soil.vue @@ -146,10 +146,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -300,10 +303,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, - id:item.id, - error: false, - file: item + id:item.id }) }) this.getOplcates() @@ -447,21 +447,29 @@ edit(row) {}, saveSubmit() { debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading(); diff --git a/pages/workSpace/opls/space.vue b/pages/workSpace/opls/space.vue index f1da2da..ba66262 100644 --- a/pages/workSpace/opls/space.vue +++ b/pages/workSpace/opls/space.vue @@ -145,10 +145,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -302,10 +305,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, - id:item.id, - error: false, - file: item + id:item.id }) }) this.getOplcates() @@ -449,23 +449,31 @@ edit(row) {}, saveSubmit() { debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; - that.formData.start_time = that.formData.start_time+':00'; - that.formData.end_time = that.formData.end_time+':00'; + // that.formData.start_time = that.formData.start_time+':00'; + // that.formData.end_time = that.formData.end_time+':00'; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading(); diff --git a/pages/workSpace/opls/usecl.vue b/pages/workSpace/opls/usecl.vue index 634e395..e6bc86b 100644 --- a/pages/workSpace/opls/usecl.vue +++ b/pages/workSpace/opls/usecl.vue @@ -238,10 +238,13 @@ - 照片 + + * + 照片 + + :file-list="fileList" max-count="9"> @@ -412,10 +415,7 @@ res.create_imgs_.forEach(item=>{ that.fileList.push({ url: that.vuex_host+item.path, - progress: 0, - id:item.id, - error: false, - file: item + id:item.id }) }) this.getOplcates() @@ -559,9 +559,6 @@ edit(row) {}, saveSubmit() { debugger; - uni.showLoading({ - title: '提交中' - }); let that = this; let params = null; // that.formData.start_time = that.formData.start_time; @@ -570,15 +567,26 @@ // that.formData.power_end_time = that.formData.power_end_time; // that.formData.work_time = that.formData.work_time; that.formData.create_imgs = []; - that.fileList.forEach(item=>{ - if(item.id){ - console.log(item.id); - that.formData.create_imgs.push(item.id) - }else{ - console.log(item.response.id) + let files = []; + // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作) + files = this.$refs.uUpload.lists.filter(val => { + return val.progress == 100; + }) + + 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) { that.$u.api.oplUpdate(that.oplId, that.formData).then(res => { uni.hideLoading();