|
@@ -195,14 +195,12 @@
|
|
|
<van-uploader
|
|
|
:after-read="afterRead"
|
|
|
v-model="fileList"
|
|
|
- :max-count="1"
|
|
|
+ :max-count="5"
|
|
|
capture="camera"
|
|
|
accept=""
|
|
|
+ :before-delete="deleteRead"
|
|
|
>
|
|
|
<van-button>上传文件</van-button>
|
|
|
- <template #preview-cover="file">
|
|
|
- <div class="preview-cover van-ellipsis">{{ file.name }}</div>
|
|
|
- </template>
|
|
|
</van-uploader>
|
|
|
</template>
|
|
|
</van-field>
|
|
@@ -380,30 +378,42 @@ export default {
|
|
|
};
|
|
|
// 文件上传
|
|
|
let fileList = ref([]);
|
|
|
+ let fileupList = ref([]);
|
|
|
const afterRead = (file) => {
|
|
|
- fileList.value = [];
|
|
|
// 此时可以自行将文件上传至服务器
|
|
|
new tools()
|
|
|
.uploadFile(file, `reporting/reportingActivities`)
|
|
|
- .then(({ data }) => {
|
|
|
- if (res.status == 200 || res.statusText == "OK") {
|
|
|
+ .then(({ data, status, statusText }) => {
|
|
|
+ if (status == 200 || statusText == "OK") {
|
|
|
xm.showToast({
|
|
|
message: "上传成功",
|
|
|
});
|
|
|
- placeActivity.value.safetyPlan = data.url;
|
|
|
- fileList.value.push(data);
|
|
|
- fileList.value[0].url = `${$base}` + fileList.value[0].url;
|
|
|
- fileList.value[0].name = decodeURIComponent(
|
|
|
- fileList.value[0].url.substring(
|
|
|
- fileList.value[0].url.lastIndexOf("/") + 1
|
|
|
- )
|
|
|
+ data.name = decodeURIComponent(
|
|
|
+ data.url.substring(data.url.lastIndexOf("/") + 1)
|
|
|
);
|
|
|
+ fileupList.value.push(data);
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
+ // 删除文件
|
|
|
+ const deleteRead = (file) => {
|
|
|
+ //删除文件操作
|
|
|
+ for (let index = 0; index < fileList.value.length; index++) {
|
|
|
+ if (file.file == fileList.value[index].file) {
|
|
|
+ let delurl = fileupList.value[index].url;
|
|
|
+ new tools().uploadFiledelete("", delurl).then(({ data }) => {});
|
|
|
+ fileupList.value.splice(index, 1);
|
|
|
+ fileList.value.splice(index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
// 提交数据
|
|
|
const submit = () => {
|
|
|
isLoading.value = true;
|
|
|
+ //保存前附件处理
|
|
|
+ siteInspection.enclosure = fileupList.value
|
|
|
+ .map((option) => option.url)
|
|
|
+ .join("|");
|
|
|
new placeActivityServer().save(placeActivity.value).then((res) => {
|
|
|
if (res.status == 200 || res.statusText == "OK") {
|
|
|
xm.showToast({
|
|
@@ -436,6 +446,7 @@ export default {
|
|
|
reselected,
|
|
|
// 文件上传
|
|
|
afterRead,
|
|
|
+ deleteRead,
|
|
|
fileList,
|
|
|
submit,
|
|
|
subjectContentEditor,
|
|
@@ -445,9 +456,6 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.van-cell__value .van-field__right-icon .van-icon-location {
|
|
|
- color: #36a7f3 !important;
|
|
|
-}
|
|
|
.van-uploader .van-button {
|
|
|
border: none;
|
|
|
color: #36a7f3;
|
|
@@ -461,15 +469,4 @@ export default {
|
|
|
text-align: center;
|
|
|
margin-top: 80px;
|
|
|
}
|
|
|
-.preview-cover {
|
|
|
- position: absolute;
|
|
|
- bottom: 0;
|
|
|
- box-sizing: border-box;
|
|
|
- width: 100%;
|
|
|
- padding: 4px;
|
|
|
- color: #fff;
|
|
|
- font-size: 12px;
|
|
|
- text-align: center;
|
|
|
- background: rgba(0, 0, 0, 0.3);
|
|
|
-}
|
|
|
</style>
|