From d8b41fff43a2cee6a8f714ffa807623b15803786 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Fri, 20 Oct 2023 15:21:35 +0800 Subject: [PATCH] fix:立行立改Uniapp小程序新建项目 --- pages/actionChange/components/fileUpload.vue | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 deletions(-) diff --git a/pages/actionChange/components/fileUpload.vue b/pages/actionChange/components/fileUpload.vue new file mode 100644 index 0000000..c9d6d82 --- /dev/null +++ b/pages/actionChange/components/fileUpload.vue @@ -0,0 +1,87 @@ +<template> + <view class=""> + <cl-upload + v-model="fileList" + :action="uploadTermExcelUrl" + cloud-type="other" + :data="{ sysCode }" + :headers="hearder" + :image-form-data="{ + compress: true, + }" + :list-style="{ + columns: 3, + columnGap: '10rpx', + rowGap: '10rpx', + padding: '10rpx', + radius: '20rpx' + }" + use-before-delete + @beforeDelete="beforeDelete" + @onSuccess="onSuccess" + /> + </cl-upload> + </view> +</template> + +<script> +export default { + props: { + sysCode: { + type: String, + }, + }, + data() { + return { + fileList: [], + upLoadList: [], + beforFileList: [], + baseUrl: this.$storage.get('baseUrl'), + token: this.$storage.get('token'), + } + }, + computed: { + uploadTermExcelUrl() { + return `${this.baseUrl}/file/upload` || '' + }, + hearder() { + let obj = { token: this.token, Authorization: this.token } + return obj + }, + }, + methods: { + onSuccess(res) { + console.log(res.data.fileId) + let fileId = res.data.fileId + let name = res.data.fileType === 1 ? 'name.png' : '' + this.fileList.push(`${this.baseUrl}/file/preview/${fileId}?${name}`) // ������ + this.upLoadList.push(res.data) + console.log(this.fileList) + this.$emit('handleFile', this.upLoadList) + }, + /** + * ��������������� + * @param {Object} item ��������������������������������������� + * @param {Number} index ������������������������������������ + * @param {Function} next ��������������������������������������������� + * */ + beforeDelete(item, index, next) { + + uni.showModal({ + title: '������������', + content: '���������������������������������', + success: res=> { + if (res.confirm) { + this.fileList.splice(index, 1) + this.upLoadList.splice(index, 1) + console.log('this.fileList', this.upLoadList) + this.$emit('handleFile', this.upLoadList) + } + } + }) + }, + }, +} +</script> + +<style></style> -- Gitblit v1.8.0