【更新】批量操作组件优化且加入图标颜色支持,上传组件优多文件上传且提供主动获取文件方法

pull/121/head v2.2.10
小诺 1 year ago committed by 俞宝山
parent ddae7f6ef3
commit 004bb60d86

@ -5,9 +5,9 @@
@visibleChange="batchVisibleChange"
@confirm="deleteBatch"
>
<a-button :type="props.buttonType" :danger="props.buttonDanger">
<a-button :type="props.buttonType" :danger="props.buttonDanger" :size="props.size" :loading="buttonLoading">
<template #icon v-if="props.icon">
<component :is="props.icon" />
<component :is="props.icon" :style="{ color: props.color }" />
</template>
{{ props.buttonName }}
</a-button>
@ -18,6 +18,7 @@
import { message } from 'ant-design-vue'
const batchVisible = ref(false)
const emit = defineEmits({ batchCallBack: null })
const buttonLoading = ref(false)
const props = defineProps({
buttonName: {
type: String,
@ -35,9 +36,17 @@
type: String,
default: () => ''
},
size: {
type: String,
default: () => 'middle'
},
selectedRowKeys: {
type: Array,
default: () => []
},
color: {
type: String,
default: () => ''
}
})
//
@ -64,4 +73,12 @@
//
emit('batchCallBack', params)
}
// loading
const loading = () => {
buttonLoading.value = true
}
// loading
const closeLoading = () => {
buttonLoading.value = true
}
</script>

@ -5,11 +5,11 @@
name="file"
:action="action"
:headers="headers"
:maxCount="props.uploadMumber"
:maxCount="props.uploadNumber"
@change="handleChange"
>
<a-button>
<upload-outlined></upload-outlined>
<upload-outlined />
上传
</a-button>
</a-upload>
@ -21,11 +21,11 @@
:multiple="true"
:action="action"
:headers="headers"
:maxCount="props.uploadMumber"
:maxCount="props.uploadNumber"
@change="handleChange"
>
<p class="ant-upload-drag-icon">
<inbox-outlined></inbox-outlined>
<inbox-outlined />
</p>
<p class="ant-upload-text">单击或拖动文件到此区域上传</p>
<p class="ant-upload-hint"></p>
@ -53,7 +53,7 @@
required: false
},
//
uploadMumber: {
uploadNumber: {
type: Number,
default: 1,
required: false
@ -61,11 +61,13 @@
})
const action = sysConfig.API_URL + props.action
// 使
const handleChange = () => {
// 使
let result = []
for (let a = 0; a < props.uploadMumber; a++) {
for (let a = 0; a < props.uploadNumber; a++) {
const file = fileList.value[a]
if (file.status === 'done' && file.response && file.response.code === 200) {
if (file && file.status === 'done' && file.response && file.response.code === 200) {
const resultObj = {
name: file.name,
url: file.response.data
@ -77,4 +79,27 @@
emit('uploadDone', result)
}
}
// DOM
const uploadFileList = () => {
if (fileList.value) {
const result = []
//
fileList.value.forEach((item) => {
const obj = {
name: item.name,
type: item.type,
size: item.size,
url: item.response.data
}
result.push(obj)
})
return result
} else {
return []
}
}
//
defineExpose({
uploadFileList
})
</script>

Loading…
Cancel
Save