From 0f33f25daf5146e8bd6757da56662524e1912d9d Mon Sep 17 00:00:00 2001 From: "271556543@qq.com" <271556543@qq.com> Date: Tue, 11 Oct 2022 17:13:00 +0800 Subject: [PATCH] 2022.10.11 --- pages/detailNursing/components/imgUpload.vue | 130 ++ pages/detailNursing/detailNursing.vue | 107 +- uview-ui/components/u-upload/u-upload.vue | 1176 +++++++++--------- 3 files changed, 783 insertions(+), 630 deletions(-) create mode 100644 pages/detailNursing/components/imgUpload.vue diff --git a/pages/detailNursing/components/imgUpload.vue b/pages/detailNursing/components/imgUpload.vue new file mode 100644 index 0000000..68ceebb --- /dev/null +++ b/pages/detailNursing/components/imgUpload.vue @@ -0,0 +1,130 @@ + + + + + diff --git a/pages/detailNursing/detailNursing.vue b/pages/detailNursing/detailNursing.vue index 8bb0c5c..9adb6f1 100644 --- a/pages/detailNursing/detailNursing.vue +++ b/pages/detailNursing/detailNursing.vue @@ -84,7 +84,7 @@ - 过程打卡 ({{detail.logs_count + 1}}) @@ -111,6 +111,8 @@ 定位时间:{{$u.timeFormat(location.time,'hh:MM:ss')}} {{location.address}} + + @@ -120,9 +122,15 @@ } from '@/common/config.js' import QQMapWX from '@/libs/qqmap-wx-jssdk.js' + import imgUpload from './components/imgUpload.vue' export default { + components: { + imgUpload + }, data() { return { + type: 0, //打卡类型,1签到 2过程打卡 3签退 + isShowImg: false, id: '', flag: false, //未开始护理时,是否更新过定位(真为更新过定位) qqmapsdk: null, @@ -233,41 +241,61 @@ }, //图片批量上传 - async uploadImgs() { - let res = await uni.chooseImage({ - sourceType: ['camera'] - }) - if (res[1]) { - let promiseAll = res[1].tempFilePaths.map(item => { - console.log(`${ROOTPATH}/api/nurse/upload-file`); - return new Promise((resolve, reject) => { - uni.uploadFile({ - url: `${ROOTPATH}/api/nurse/upload-file`, - header: { - Authorization: `Bearer ${this.vuex_token}` - }, - filePath: item, - name: 'file', - success: (res1) => { - resolve(res1) - }, - fail: (err) => { - reject(err) - } - }) + uploadImgs(files) { + let promiseAll = files.map(item => { + return new Promise((resolve, reject) => { + uni.uploadFile({ + url: `${ROOTPATH}/api/nurse/upload-file`, + header: { + Authorization: `Bearer ${this.vuex_token}` + }, + filePath: item, + name: 'file', + success: (res1) => { + resolve(res1) + }, + fail: (err) => { + reject(err) + } }) }) + }) - return Promise.all(promiseAll) - } else { - - return Promise.reject(res[0].errMsg) - } + return Promise.all(promiseAll) + // let res = await uni.chooseImage({ + // sourceType: ['camera'] + // }) + // if (res[1]) { + // let promiseAll = res[1].tempFilePaths.map(item => { + // console.log(`${ROOTPATH}/api/nurse/upload-file`); + // return new Promise((resolve, reject) => { + // uni.uploadFile({ + // url: `${ROOTPATH}/api/nurse/upload-file`, + // header: { + // Authorization: `Bearer ${this.vuex_token}` + // }, + // filePath: item, + // name: 'file', + // success: (res1) => { + // resolve(res1) + // }, + // fail: (err) => { + // reject(err) + // } + // }) + // }) + // }) + + // return Promise.all(promiseAll) + // } else { + + // return Promise.reject(res[0].errMsg) + // } }, //打卡 - clock(type) { + clock(files, type) { let title; switch (type) { case 1: @@ -282,19 +310,20 @@ default: title = '操作成功' } - this.uploadImgs().then(res => { + this.uploadImgs(files).then(res => { this.form.upload_list = res.map(item => { return { upload_id: JSON.parse(item.data).id } }) this.form.type = type - console.log(this.form); this.$u.api.processSave(this.form).then(res => { uni.showToast({ icon: 'success', title }) + this.$refs['imgUpload'].clearList() + this.isShowImg = false this.getDeatil(this.id) }).catch(err => { uni.showToast({ @@ -333,7 +362,9 @@ //签到 sign() { - this.clock(1) + this.type = 1 + this.isShowImg = true + //this.clock(1) }, //过程打卡 @@ -353,7 +384,8 @@ return } this.saveSku().then(res => { - this.clock(2) + this.type = 2 + this.isShowImg = true }).catch(err => { console.log(err); uni.showToast({ @@ -365,10 +397,10 @@ //签退 signOut() { - if (this.detail.logs_count < 3) { + if (this.detail.logs_count < this.detail.product.process_total) { uni.showToast({ icon: 'none', - title: `请先完成3次打卡,再签退。当前完成打卡次数${this.detail.logs_count}` + title: `请先完成${this.detail.product.process_total}次打卡,再签退。当前完成打卡次数${this.detail.logs_count}` }) return } @@ -405,7 +437,8 @@ } this.saveSku().then(() => { - this.clock(3) + this.type = 3 + this.isShowImg = true }).catch(err => { console.log(err); uni.showToast({ @@ -444,7 +477,7 @@ }, mounted() { this.load() - //this.getLoaction() + this.getLoaction() } } diff --git a/uview-ui/components/u-upload/u-upload.vue b/uview-ui/components/u-upload/u-upload.vue index f4d4b76..c644d74 100644 --- a/uview-ui/components/u-upload/u-upload.vue +++ b/uview-ui/components/u-upload/u-upload.vue @@ -1,48 +1,29 @@