Merge remote-tracking branch 'origin/main'

This commit is contained in:
wanxiaoli 2025-11-04 16:28:30 +08:00
commit f4f7511603
2 changed files with 50 additions and 29 deletions

View File

@ -300,13 +300,14 @@ $light_gray: #eee;
position: relative;
// justify-content: center;
// -webkit-justify-content: center;
text-align: center;
.login-container-title{
font-size: 60px;
font-weight: 700;
color: #fff;
margin: 0 auto;
margin-top: 2%;
width: 800px;
// width: 800px;
letter-spacing: 5px;
}
.login-container-content {

View File

@ -15,6 +15,7 @@ import {
} from "@/api/testtask";
import { storagesBytype } from "@/api/storage";
import { getDict } from '@/api/dict'
import { getUserInfo } from '@/api/user';
///////
let result2 = ref([])
let result1 = ref([
@ -43,6 +44,7 @@ const queryParams: any = ref({
endDate: ''
});
const total = ref(0);
//
const importDialog = ref(false)
const importForm: any = ref({})
const importRules: any = ref({
@ -51,6 +53,8 @@ const importRules: any = ref({
})
const fileList = ref([])
const importFormRef = ref()
//
const standAlone = ref(false)
//
function zhuandata(dateString: any) {
// Date
@ -66,7 +70,6 @@ function zhuandata(dateString: any) {
const loading = ref(false)
//
function getdata() {
loading.value = true
if (dataduan.value && dataduan.value.length > 0) {
const dataArr = []
@ -158,6 +161,11 @@ function addproject() {
localStorageId: '',
backupStorageId: ''
}
if (standAlone.value) {
projectForme.value.localStorageId = 1
projectForme.value.backupStorageId = -1
}
console.log(projectForme.value)
// formitemarr.value.length = 0
shidou.value = true
}
@ -223,26 +231,15 @@ function expproject(row: any) {
console.log(res)
console.log('响应头:', res.headers);
if (res) {
// 访
//const disposition = res.headers['Content-Disposition'];
const fileName = `${row.id}_data.sql.zip`; //
// if (disposition) {
// const filenameMatch = disposition.match(/filename="?([^"]+)"?/);
// if (filenameMatch && filenameMatch[1]) {
// fileName = decodeURIComponent(filenameMatch[1]);
// }
// }
const fileName = `${row.taskCode}_exportdata.zip`; //
//
const blob = new Blob([res.data], { type: 'application/zip' });
const blob = new Blob([res], { type: 'application/zip' });
//
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `${row.id}_data.sql.zip`;
link.download = fileName;
link.style.display = 'none';
document.body.appendChild(link);
link.click();
@ -372,6 +369,13 @@ const moderules = ref({
backupStorageId: [{ required: true, message: "请选择minio存储空间", trigger: "change" }],
});
onMounted(() => {
getUserInfo().then((res: any) => {
const roles = res.data.roles
const hasSingleMachineUser = roles.some(name => name === '单机用户');
if (hasSingleMachineUser) {
standAlone.value = true
}
})
getdata()
getDictOne()
});
@ -470,6 +474,10 @@ function reset() {
getdata()
}
function importproject() {
fileList.value = []
importForm.value.fileName = ''
importForm.value.localStorageId = ''
importForm.value.backupStorageId = ''
getMaxTaskCode().then((res: any) => {
if (res.data) {
importForm.value.taskCode = res.data
@ -485,23 +493,34 @@ function fileChange(uploadFile, uploadFiles) {
importForm.value.fileName = uploadFile.name
fileList.value = []
fileList.value = [uploadFile.raw]
console.log(fileList.value, 999)
}
const isconnect = ref(false)
function importSubmit(formEl: any) {
if (!formEl) return
formEl.validate((valid: any, fields: any) => {
if (valid) {
if (fileList.value.length == 0) {
return ElMessage.warning('请选择导入的文件!')
return ElMessage.warning('请上传导入文件!')
}
if (isconnect.value) {
return
}
const formData = new FormData()
formData.append('file', fileList.value[0])
formData.append('taskCode', importForm.value.taskCode)
formData.append('localStorageId', importForm.value.localStorageId)
formData.append('backupStorageId', importForm.value.backupStorageId)
isconnect.value = true
importTaskSql(formData).then((res: any) => {
if (res) {
if (res.code == '0') {
isconnect.value = false
importDialog.value = false
ElMessage.success('上传成功')
getdata()
} else {
isconnect.value = false
importDialog.value = false
ElMessage.error(res.msg)
}
})
}
@ -563,7 +582,7 @@ function importClose() {
<div>
<el-button type="primary" @click="addproject()">新增</el-button>
<el-button type="primary" @click="delprojectArr()" :disabled="tableIdarr.length == 0">删除</el-button>
<el-button type="primary" @click="importproject()">导入</el-button>
<el-button v-if="standAlone == false" type="primary" @click="importproject()">导入</el-button>
</div>
</div>
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange"
@ -608,12 +627,12 @@ function importClose() {
</div>
</template>
</el-table-column>
<el-table-column prop="localStorageId" label="本地存储空间" width="180">
<el-table-column v-if="standAlone == false" prop="localStorageId" label="本地存储空间" width="180">
<template #default="scope">
<span>{{ typeName1(localarr, scope.row.localStorageId) }}</span>
</template>
</el-table-column>
<el-table-column prop="backupStorageId" label="备份存储空间" width="180">
<el-table-column v-if="standAlone == false" prop="backupStorageId" label="备份存储空间" width="180">
<template #default="scope">
<span>{{ typeName1(minioarr, scope.row.backupStorageId) }}</span>
</template>
@ -626,8 +645,8 @@ function importClose() {
style="cursor: pointer;">
<img src="@/assets/MenuIcon/lbcz_sc.png" alt="" title="删除" @click="delproject(scope.row)"
style="cursor: pointer;">
<img src="@/assets/MenuIcon/lbcz_dc.png" alt="" title="导出" @click="expproject(scope.row)"
style="cursor: pointer;">
<img v-if="standAlone" src="@/assets/MenuIcon/lbcz_dc.png" alt="" title="导出"
@click="expproject(scope.row)" style="cursor: pointer;">
</span>
</template>
</el-table-column>
@ -705,7 +724,8 @@ function importClose() {
<el-button type="primary" @click="dellable(index)">删除</el-button>
</div>
</el-form-item>
<div style="width: 100%;display: flex;justify-content: space-between;align-items: center;">
<div v-if="standAlone == false"
style="width: 100%;display: flex;justify-content: space-between;align-items: center;">
<el-form-item label="本地存储空间" prop="localStorageId" style="width: 50%;">
<el-select v-model="projectForme.localStorageId" clearable placeholder=" "
:disabled="!shidou">
@ -721,7 +741,6 @@ function importClose() {
</el-select>
</el-form-item>
</div>
</el-scrollbar>
<el-form-item>
@ -781,16 +800,17 @@ function importClose() {
</el-form-item>
<el-form-item>
<div style="width: 100%;display: flex;align-items: center;">
<el-input v-model="importForm.fileName" disabled style="margin-right: 15px;" />
<el-upload v-model="fileList" :auto-upload="false" :show-file-list="false" class="upload-demo"
action="" :on-change="fileChange">
<el-button type="primary">导入</el-button>
<el-button type="primary" style="padding: 0px 5px;">上传导入文件</el-button>
</el-upload>
<el-input v-model="importForm.fileName" disabled style="margin-left: 10px;" />
</div>
</el-form-item>
</el-form>
<div style="width: 100%;display: flex;justify-content: end;margin-top: 10px;">
<el-button type="primary" @click="importSubmit(importFormRef)">确定</el-button>
<el-button type="primary" @click="importSubmit(importFormRef)">导入</el-button>
</div>
</el-dialog>
</div>