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; position: relative;
// justify-content: center; // justify-content: center;
// -webkit-justify-content: center; // -webkit-justify-content: center;
text-align: center;
.login-container-title{ .login-container-title{
font-size: 60px; font-size: 60px;
font-weight: 700; font-weight: 700;
color: #fff; color: #fff;
margin: 0 auto; margin: 0 auto;
margin-top: 2%; margin-top: 2%;
width: 800px; // width: 800px;
letter-spacing: 5px; letter-spacing: 5px;
} }
.login-container-content { .login-container-content {

View File

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