From 52d463e03c1f074099ed8e8a6b7c3ddde52d2708 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Fri, 27 Oct 2023 14:50:28 +0800 Subject: [PATCH] fix:小程序初版 --- pages/actionChange/components/fileUpload.vue | 79 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 79 insertions(+), 0 deletions(-) diff --git a/pages/actionChange/components/fileUpload.vue b/pages/actionChange/components/fileUpload.vue new file mode 100644 index 0000000..72461e8 --- /dev/null +++ b/pages/actionChange/components/fileUpload.vue @@ -0,0 +1,79 @@ +<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: '', + } + }, + created() { + this.token = uni.getStorageSync('tonken') + console.log('tonken', this.token) + }, + computed: { + uploadTermExcelUrl() { + return `${this.baseUrl}/file/upload` || '' + }, + hearder() { + let obj = { + token: this.token, + Authorization: this.token + } + return obj + }, + }, + methods: { + onSuccess(res) { + 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) + 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> \ No newline at end of file -- Gitblit v1.8.0