|
|
@@ -46,12 +46,14 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="upload-btn">
|
|
|
- <el-icon>
|
|
|
- <Plus />
|
|
|
- </el-icon>
|
|
|
- <span>点击上传照片</span>
|
|
|
- </div>
|
|
|
+ <uploader class="upload-wrap" multiple :max-count="10" :after-read="afterReadUpload">
|
|
|
+ <div class="upload-btn">
|
|
|
+ <el-icon>
|
|
|
+ <Plus />
|
|
|
+ </el-icon>
|
|
|
+ <span>点击上传照片</span>
|
|
|
+ </div>
|
|
|
+ </uploader>
|
|
|
<!-- <div class="question-wrapper">
|
|
|
<div class="question-text">
|
|
|
<span class="text-title">{{ item.phenologyName }}占比</span>
|
|
|
@@ -75,7 +77,7 @@
|
|
|
<!-- 比例信息(已上传状态显示) -->
|
|
|
<div class="proportion-info" v-show="item.isConfirmed != null">
|
|
|
<span class="proportion-text" v-if="item.replyText">当前果园{{ item.phenologyName }}占比: {{ item.replyText
|
|
|
- }}%</span>
|
|
|
+ }}%</span>
|
|
|
<span class="proportion-text" v-else>暂无数据</span>
|
|
|
<div class="toggle-btn" @click="toggleExpand(item)">
|
|
|
<span>{{ item.expanded ? "收起" : "展开" }}</span>
|
|
|
@@ -104,10 +106,11 @@
|
|
|
<popup v-model:show="showUploadProgressPopup" round class="upload-progress-popup">
|
|
|
<div class="upload-progress-title">
|
|
|
<span>照片上传进度</span>
|
|
|
- <el-progress class="upload-progress" :percentage="50" stroke-width="10" :format="format" />
|
|
|
+ <el-progress class="upload-progress" :percentage="50" :stroke-width="10" :format="format" />
|
|
|
</div>
|
|
|
<div class="upload-wrap">
|
|
|
- <upload :maxCount="10" @handleUpload="handleUploadSuccess">
|
|
|
+ <!-- 把已经上传成功的图片传给 upload 组件做回显,同时保持原有上传事件不变 -->
|
|
|
+ <upload :maxCount="10" :initImgArr="imgArr" @handleUpload="handleUploadSuccess">
|
|
|
</upload>
|
|
|
</div>
|
|
|
<el-input v-model="uploadProgressText" placeholder="请输入您咨询的问题" clearable />
|
|
|
@@ -121,12 +124,16 @@
|
|
|
<script setup>
|
|
|
import { ref, onMounted } from "vue";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
-import { Popup } from "vant";
|
|
|
+import { Uploader, Popup } from "vant";
|
|
|
import customHeader from "@/components/customHeader.vue";
|
|
|
import upload from "@/components/upload.vue";
|
|
|
import FarmInfoPopup from "@/components/popup/farmInfoPopup.vue";
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
import { base_img_url2 } from "@/api/config";
|
|
|
+import UploadFile from "@/utils/upliadFile";
|
|
|
+import { getFileExt } from "@/utils/util";
|
|
|
+
|
|
|
+
|
|
|
const showFarmInfoPopup = ref(false);
|
|
|
const loading = ref(false);
|
|
|
const router = useRouter();
|
|
|
@@ -138,6 +145,38 @@ const showUploadProgressPopup = ref(false);
|
|
|
const uploadProgressText = ref('');
|
|
|
const format = (percentage) => (percentage === 100 ? '上传完成' : `5/10`)
|
|
|
|
|
|
+const uploadFileObj = new UploadFile();
|
|
|
+const imgArr = ref([]);
|
|
|
+const miniUserId = localStorage.getItem("MINI_USER_ID");
|
|
|
+const afterReadUpload = async (data) => {
|
|
|
+ console.log(data)
|
|
|
+ if (!Array.isArray(data)) {
|
|
|
+ data = [data];
|
|
|
+ }
|
|
|
+ for (let file of data) {
|
|
|
+ // 将文件上传至服务器
|
|
|
+ let fileVal = file.file;
|
|
|
+ file.status = "uploading";
|
|
|
+ file.message = "上传中...";
|
|
|
+ let ext = getFileExt(fileVal.name);
|
|
|
+ let key = `birdseye-look-mini/${miniUserId}/${new Date().getTime()}.${ext}`;
|
|
|
+ let resFilename = await uploadFileObj.put(key, fileVal)
|
|
|
+ file.status = "done";
|
|
|
+ file.message = "";
|
|
|
+ if (resFilename) {
|
|
|
+ imgArr.value.push(resFilename)
|
|
|
+ } else {
|
|
|
+ file.status = 'failed';
|
|
|
+ file.message = '上传失败';
|
|
|
+ ElMessage.error('图片上传失败,请稍后再试!')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 所有文件上传结束后再打开进度弹窗,此时 imgArr 已包含全部图片
|
|
|
+ if (imgArr.value.length > 0) {
|
|
|
+ showUploadProgressPopup.value = true;
|
|
|
+ console.log("imgArr", imgArr.value);
|
|
|
+ }
|
|
|
+};
|
|
|
//示例照片
|
|
|
const showExamplePopup = ref(false);
|
|
|
const exampleImgData = ref(null);
|
|
|
@@ -253,6 +292,7 @@ const handleDrawRegion = (item) => {
|
|
|
const uploadData = ref([]);
|
|
|
const handleUploadSuccess = (data) => {
|
|
|
uploadData.value = data.imgArr;
|
|
|
+ imgArr.value = [];
|
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
|
|
@@ -419,16 +459,28 @@ const getFarmList = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- .upload-btn {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- gap: 4px;
|
|
|
- color: #0B84E4;
|
|
|
- padding: 6px;
|
|
|
- border: 0.5px solid rgba(33, 153, 248, 0.5);
|
|
|
- border-radius: 4px;
|
|
|
+ .upload-wrap {
|
|
|
+ width: 100%;
|
|
|
margin-top: 12px;
|
|
|
+
|
|
|
+ ::v-deep {
|
|
|
+ .van-uploader__input-wrapper {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .upload-btn {
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ gap: 4px;
|
|
|
+ color: #0B84E4;
|
|
|
+ padding: 6px;
|
|
|
+ border: 0.5px solid rgba(33, 153, 248, 0.5);
|
|
|
+ border-radius: 4px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|