✨代码生成新增导入
This commit is contained in:
parent
4b101f97d7
commit
b6ea3e685c
78
src/components/ImportData/index.vue
Normal file
78
src/components/ImportData/index.vue
Normal file
@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div class="uploadData">
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
:limit="1"
|
||||
name="file"
|
||||
accept=".xlsx,.xls"
|
||||
:data="uploadData"
|
||||
:headers="headers"
|
||||
:action="uploadFileUrl"
|
||||
:disabled="isUploading"
|
||||
:on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess"
|
||||
:auto-upload="true">
|
||||
<el-button type="primary" icon="Upload">上传文件</el-button>
|
||||
|
||||
<template #tip>
|
||||
<div class="el-upload__tip text-center">
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
<el-link type="primary" @click="importTemplate" icon="Bottom"> 下载模板 </el-link>
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const emit = defineEmits()
|
||||
|
||||
const props = defineProps({
|
||||
importUrl: {
|
||||
type: String
|
||||
},
|
||||
templateUrl: {
|
||||
type: String
|
||||
},
|
||||
// 上传携带的参数
|
||||
data: {
|
||||
type: Object
|
||||
}
|
||||
})
|
||||
|
||||
const baseUrl = import.meta.env.VITE_APP_BASE_API
|
||||
const uploadFileUrl = ref(baseUrl + props.importUrl) // 上传数据url
|
||||
const headers = ref({ Authorization: 'Bearer ' + getToken() })
|
||||
const uploadData = computed(() => props.data)
|
||||
const isUploading = ref(false)
|
||||
|
||||
/**文件上传中处理 */
|
||||
const handleFileUploadProgress = (event, file, fileList) => {
|
||||
isUploading.value = true
|
||||
}
|
||||
/** 文件上传成功处理 */
|
||||
const handleFileSuccess = (response, file, fileList) => {
|
||||
const { code, msg } = response
|
||||
|
||||
isUploading.value = false
|
||||
proxy.$refs['uploadRef'].clearFiles()
|
||||
proxy.$refs['uploadRef'].handleRemove(file)
|
||||
|
||||
if (code != 200) {
|
||||
proxy.$modal.msgError('导入数据失败,原因:' + msg)
|
||||
} else {
|
||||
emit('success', response)
|
||||
}
|
||||
}
|
||||
|
||||
function importTemplate() {
|
||||
proxy.downFile(props.templateUrl)
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.uploadData {
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
@ -184,6 +184,16 @@
|
||||
|
||||
<el-col :lg="12" v-if="info.genType == '1'">
|
||||
<el-form-item prop="generateMenu" label="添加菜单">
|
||||
<template #label>
|
||||
添加菜单
|
||||
<span>
|
||||
<el-tooltip content="将自动添加菜单到菜单栏" placement="top">
|
||||
<el-icon>
|
||||
<question-filled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
<el-switch v-model="info.generateMenu" class="ml-2" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -196,12 +206,12 @@
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-form-item prop="operBtnStyle" label="操作按钮样式">
|
||||
<el-radio v-model="info.operBtnStyle" :label="1">样式1</el-radio>
|
||||
<el-radio v-model="info.operBtnStyle" :label="2">text按钮</el-radio>
|
||||
<el-radio v-model="info.operBtnStyle" :label="1">button</el-radio>
|
||||
<el-radio v-model="info.operBtnStyle" :label="2">text button</el-radio>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="24" v-show="info.tplCategory != 'select'">
|
||||
<el-form-item label="显示按钮">
|
||||
<el-form-item label="生成功能">
|
||||
<el-checkbox-group v-model="info.checkedBtn" @change="checkedBtnSelect">
|
||||
<el-checkbox :label="1">
|
||||
<el-tag>添加</el-tag>
|
||||
@ -224,6 +234,9 @@
|
||||
<el-checkbox :label="7">
|
||||
<el-tag type="danger">批量删除</el-tag>
|
||||
</el-checkbox>
|
||||
<el-checkbox :label="8">
|
||||
<el-tag>批量导入</el-tag>
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user