增加自动化代码文件组件
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-upload
|
||||
multiple
|
||||
:action="`${path}/fileUploadAndDownload/upload?noSave=1`"
|
||||
:headers="{ 'x-token': userStore.token }"
|
||||
:on-error="uploadError"
|
||||
:on-success="uploadSuccess"
|
||||
:show-file-list="true"
|
||||
:file-list="fileList"
|
||||
class="upload-btn"
|
||||
>
|
||||
<el-button type="primary">上传文件</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import { ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUserStore } from '@/pinia/modules/user'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
|
||||
const path = ref(import.meta.env.VITE_BASE_API)
|
||||
|
||||
const userStore = useUserStore()
|
||||
const fullscreenLoading = ref(false)
|
||||
|
||||
const fileList = ref(props.modelValue)
|
||||
|
||||
const emits = defineEmits(['update:modelValue'])
|
||||
|
||||
watch(fileList.value, (val) => {
|
||||
console.log(val)
|
||||
emits('update:modelValue', val)
|
||||
})
|
||||
|
||||
const uploadSuccess = (res) => {
|
||||
const { data } = res
|
||||
if (data.file) {
|
||||
fileList.value.push({
|
||||
name: data.file.name,
|
||||
url: data.file.url
|
||||
})
|
||||
fullscreenLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const uploadError = () => {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '上传失败'
|
||||
})
|
||||
fullscreenLoading.value = false
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'UploadCommon',
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -89,15 +89,13 @@ const page = ref(1)
|
||||
const total = ref(0)
|
||||
const pageSize = ref(20)
|
||||
|
||||
const props = defineProps({
|
||||
defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
})
|
||||
|
||||
console.log(props)
|
||||
|
||||
const emits = defineEmits(['update:modelValue'])
|
||||
|
||||
// 分页
|
||||
|
||||
@@ -172,20 +172,14 @@ const typeOptions = ref([
|
||||
label: '单图片(字符串)',
|
||||
value: 'picture',
|
||||
},
|
||||
{
|
||||
label: '文件(json字符串)',
|
||||
value: 'file',
|
||||
},
|
||||
{
|
||||
label: '多图片(开发中)',
|
||||
value: 'pictures',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
label: '文件(开发中)',
|
||||
value: 'file',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
label: '多文件(开发中)',
|
||||
value: 'files',
|
||||
disabled: true
|
||||
}
|
||||
])
|
||||
const rules = ref({
|
||||
|
||||
Reference in New Issue
Block a user