|
@@ -18,13 +18,36 @@
|
|
>
|
|
>
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item prop="url" label="URL:">
|
|
|
|
- <el-input
|
|
|
|
- v-model.trim="modalForm.url"
|
|
|
|
- placeholder="请输入URL"
|
|
|
|
- clearable
|
|
|
|
- ></el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item prop="host" label="host:">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model.trim="modalForm.host"
|
|
|
|
+ placeholder="请输入URL"
|
|
|
|
+ clearable
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item prop="port" label="port:">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model.trim="modalForm.port"
|
|
|
|
+ placeholder="请输入URL"
|
|
|
|
+ clearable
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item prop="dataname" label="dataname:">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model.trim="modalForm.dataname"
|
|
|
|
+ placeholder="请输入URL"
|
|
|
|
+ clearable
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
<el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-col :span="12">
|
|
<el-form-item prop="username" label="用户名:">
|
|
<el-form-item prop="username" label="用户名:">
|
|
@@ -55,7 +78,9 @@
|
|
|
|
|
|
<div class="part-box part-box-pad">
|
|
<div class="part-box part-box-pad">
|
|
<div class="box-justify mb-2">
|
|
<div class="box-justify mb-2">
|
|
- <div></div>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <el-button type="primary" @click="getList">更新列表</el-button>
|
|
|
|
+ </div>
|
|
<div>
|
|
<div>
|
|
<el-button type="primary" @click="toAdd">新增</el-button>
|
|
<el-button type="primary" @click="toAdd">新增</el-button>
|
|
</div>
|
|
</div>
|
|
@@ -68,39 +93,46 @@
|
|
min-width="210"
|
|
min-width="210"
|
|
></el-table-column>
|
|
></el-table-column>
|
|
<el-table-column
|
|
<el-table-column
|
|
- prop="name"
|
|
|
|
|
|
+ prop="examName"
|
|
label="考试名称"
|
|
label="考试名称"
|
|
min-width="160"
|
|
min-width="160"
|
|
></el-table-column>
|
|
></el-table-column>
|
|
<el-table-column
|
|
<el-table-column
|
|
- prop="courseName"
|
|
|
|
|
|
+ prop="dataType"
|
|
label="同步数据类型"
|
|
label="同步数据类型"
|
|
width="120"
|
|
width="120"
|
|
></el-table-column>
|
|
></el-table-column>
|
|
<el-table-column
|
|
<el-table-column
|
|
- prop="courseCode"
|
|
|
|
- label="同步记录数"
|
|
|
|
- width="120"
|
|
|
|
|
|
+ prop="detail"
|
|
|
|
+ label="同步结果"
|
|
|
|
+ min-width="100"
|
|
></el-table-column>
|
|
></el-table-column>
|
|
- <el-table-column prop="createTime" label="同步开始时间" width="170">
|
|
|
|
|
|
+ <el-table-column prop="startTime" label="同步开始时间" width="170">
|
|
<span slot-scope="scope">{{
|
|
<span slot-scope="scope">{{
|
|
- scope.row.createTime | timestampFilter
|
|
|
|
|
|
+ scope.row.startTime | timestampFilter
|
|
}}</span>
|
|
}}</span>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column prop="createTime" label="同步结束时间" width="170">
|
|
|
|
|
|
+ <el-table-column prop="endTime" label="同步结束时间" width="170">
|
|
<span slot-scope="scope">{{
|
|
<span slot-scope="scope">{{
|
|
- scope.row.createTime | timestampFilter
|
|
|
|
|
|
+ scope.row.endTime | timestampFilter
|
|
}}</span>
|
|
}}</span>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column
|
|
|
|
- prop="courseCode"
|
|
|
|
- label="状态"
|
|
|
|
- width="100"
|
|
|
|
- ></el-table-column>
|
|
|
|
|
|
+ <el-table-column prop="cron" label="定时同步时间" width="140">
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="status" label="同步状态" width="100">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ {{ scope.row.status ? "同步中" : "已同步" }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="enable" label="启用/禁用" width="100">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ {{ scope.row.enable | enableFilter }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
<el-table-column
|
|
<el-table-column
|
|
class-name="action-column"
|
|
class-name="action-column"
|
|
label="操作"
|
|
label="操作"
|
|
- width="220"
|
|
|
|
|
|
+ width="260"
|
|
fixed="right"
|
|
fixed="right"
|
|
>
|
|
>
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
@@ -123,10 +155,10 @@
|
|
>手动同步</el-button
|
|
>手动同步</el-button
|
|
>
|
|
>
|
|
<el-button
|
|
<el-button
|
|
- class="btn-danger"
|
|
|
|
|
|
+ :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
|
|
type="text"
|
|
type="text"
|
|
- @click="toCloseSync(scope.row)"
|
|
|
|
- >结束同步</el-button
|
|
|
|
|
|
+ @click="toEnable(scope.row)"
|
|
|
|
+ >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
|
|
>
|
|
>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -146,22 +178,6 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <!-- 日志 -->
|
|
|
|
- <el-dialog
|
|
|
|
- class="log-dialog"
|
|
|
|
- :visible.sync="logModalIsShow"
|
|
|
|
- title="日志"
|
|
|
|
- :close-on-click-modal="false"
|
|
|
|
- :close-on-press-escape="false"
|
|
|
|
- append-to-body
|
|
|
|
- top="10vh"
|
|
|
|
- width="800px"
|
|
|
|
- >
|
|
|
|
- <div style="min-height: 300px; overflow: auto">
|
|
|
|
- <p v-for="(cont, cidx) in logList" :key="cidx">{{ cont }}</p>
|
|
|
|
- </div>
|
|
|
|
- </el-dialog>
|
|
|
|
-
|
|
|
|
<!-- ModifyDatabaseSync -->
|
|
<!-- ModifyDatabaseSync -->
|
|
<ModifyDatabaseSync
|
|
<ModifyDatabaseSync
|
|
ref="ModifyDatabaseSync"
|
|
ref="ModifyDatabaseSync"
|
|
@@ -169,6 +185,8 @@
|
|
:school-id="school.id"
|
|
:school-id="school.id"
|
|
@modified="getList"
|
|
@modified="getList"
|
|
/>
|
|
/>
|
|
|
|
+ <!-- DatabaseSyncLogDialog -->
|
|
|
|
+ <DatabaseSyncLogDialog ref="DatabaseSyncLogDialog" :row-data="curRow" />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -179,21 +197,24 @@ import {
|
|
schoolSetDatabaseSyncBaseinfoTest,
|
|
schoolSetDatabaseSyncBaseinfoTest,
|
|
schoolSetDatabaseSyncList,
|
|
schoolSetDatabaseSyncList,
|
|
schoolSetDatabaseSyncHandleSync,
|
|
schoolSetDatabaseSyncHandleSync,
|
|
- schoolSetDatabaseSyncClose,
|
|
|
|
|
|
+ schoolSetDatabaseSyncEnable,
|
|
} from "../../api";
|
|
} from "../../api";
|
|
import { DATABASE_TYPE } from "@/constants/enumerate";
|
|
import { DATABASE_TYPE } from "@/constants/enumerate";
|
|
import ModifyDatabaseSync from "./ModifyDatabaseSync.vue";
|
|
import ModifyDatabaseSync from "./ModifyDatabaseSync.vue";
|
|
|
|
+import DatabaseSyncLogDialog from "./DatabaseSyncLogDialog.vue";
|
|
|
|
|
|
const initModalForm = {
|
|
const initModalForm = {
|
|
type: "",
|
|
type: "",
|
|
- url: "",
|
|
|
|
|
|
+ host: "",
|
|
|
|
+ port: "",
|
|
|
|
+ dataname: "",
|
|
username: "",
|
|
username: "",
|
|
password: "",
|
|
password: "",
|
|
};
|
|
};
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "school-set-database-sync",
|
|
name: "school-set-database-sync",
|
|
- components: { ModifyDatabaseSync },
|
|
|
|
|
|
+ components: { ModifyDatabaseSync, DatabaseSyncLogDialog },
|
|
props: {
|
|
props: {
|
|
school: {
|
|
school: {
|
|
type: Object,
|
|
type: Object,
|
|
@@ -204,6 +225,7 @@ export default {
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ baseinfo: [],
|
|
modalForm: { ...initModalForm },
|
|
modalForm: { ...initModalForm },
|
|
rules: {
|
|
rules: {
|
|
type: [
|
|
type: [
|
|
@@ -213,15 +235,44 @@ export default {
|
|
trigger: "change",
|
|
trigger: "change",
|
|
},
|
|
},
|
|
],
|
|
],
|
|
- url: [
|
|
|
|
|
|
+ host: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请输入host",
|
|
|
|
+ trigger: "change",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ message: "host不能超过99个字符",
|
|
|
|
+ max: 99,
|
|
|
|
+ trigger: "change",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ port: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请输入port",
|
|
|
|
+ trigger: "change",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ message: "port只能是数字",
|
|
|
|
+ pattern: /^\d*$/,
|
|
|
|
+ trigger: "change",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ message: "port不能超过6个字符",
|
|
|
|
+ max: 6,
|
|
|
|
+ trigger: "change",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ dataname: [
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
- message: "请输入URL",
|
|
|
|
|
|
+ message: "请输入dataname",
|
|
trigger: "change",
|
|
trigger: "change",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- message: "url不能超过999个字符",
|
|
|
|
- max: 999,
|
|
|
|
|
|
+ message: "dataname不能超过99个字符",
|
|
|
|
+ max: 99,
|
|
trigger: "change",
|
|
trigger: "change",
|
|
},
|
|
},
|
|
],
|
|
],
|
|
@@ -262,10 +313,33 @@ export default {
|
|
logModalIsShow: false,
|
|
logModalIsShow: false,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ mounted() {
|
|
|
|
+ this.getBaseInfo();
|
|
|
|
+ this.toPage(1);
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
async getBaseInfo() {
|
|
async getBaseInfo() {
|
|
const res = await schoolSetDatabaseSyncBaseinfo(this.school.id);
|
|
const res = await schoolSetDatabaseSyncBaseinfo(this.school.id);
|
|
- this.modalForm = this.$objAssign(initModalForm, res || {});
|
|
|
|
|
|
+ this.baseinfo = res.result || [];
|
|
|
|
+ // const codeMap = {
|
|
|
|
+ // "data.datasource.type": "type",
|
|
|
|
+ // "data.datasource.host": "host",
|
|
|
|
+ // "data.datasource.port": "port",
|
|
|
|
+ // "data.datasource.dataname": "dataname",
|
|
|
|
+ // "data.datasource.username": "username",
|
|
|
|
+ // "data.datasource.password": "password",
|
|
|
|
+ // };
|
|
|
|
+ this.baseinfo.forEach((item) => {
|
|
|
|
+ const k = item.code.replace("data.datasource.", "");
|
|
|
|
+ this.modalForm[k] = item.value;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ getData() {
|
|
|
|
+ return this.baseinfo.map((item) => {
|
|
|
|
+ const k = item.code.replace("data.datasource.", "");
|
|
|
|
+ item.value = this.modalForm[k];
|
|
|
|
+ return item;
|
|
|
|
+ });
|
|
},
|
|
},
|
|
async toSave() {
|
|
async toSave() {
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
@@ -273,7 +347,7 @@ export default {
|
|
|
|
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
this.isSubmit = true;
|
|
this.isSubmit = true;
|
|
- const datas = { ...this.modalForm };
|
|
|
|
|
|
+ const datas = { param: this.getData(), schoolId: this.school.id };
|
|
const res = await schoolSetDatabaseSyncBaseinfoUpdate(datas).catch(
|
|
const res = await schoolSetDatabaseSyncBaseinfoUpdate(datas).catch(
|
|
() => {}
|
|
() => {}
|
|
);
|
|
);
|
|
@@ -288,14 +362,21 @@ export default {
|
|
|
|
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
this.isSubmit = true;
|
|
this.isSubmit = true;
|
|
- const datas = { ...this.modalForm };
|
|
|
|
|
|
+ const datas = { param: this.getData(), schoolId: this.school.id };
|
|
|
|
+ let errorMsg = "";
|
|
const res = await schoolSetDatabaseSyncBaseinfoTest(datas).catch(
|
|
const res = await schoolSetDatabaseSyncBaseinfoTest(datas).catch(
|
|
- () => {}
|
|
|
|
|
|
+ (error) => {
|
|
|
|
+ errorMsg = error.message || "测试失败!";
|
|
|
|
+ }
|
|
);
|
|
);
|
|
this.isSubmit = false;
|
|
this.isSubmit = false;
|
|
|
|
+ const result = res ? "测试成功!" : errorMsg;
|
|
|
|
|
|
- if (!res) return;
|
|
|
|
- this.$message.success("测试成功!");
|
|
|
|
|
|
+ this.$alert(result, {
|
|
|
|
+ type: res ? "success" : "error",
|
|
|
|
+ customClass: "alert-message",
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
+ });
|
|
},
|
|
},
|
|
async getList() {
|
|
async getList() {
|
|
const datas = {
|
|
const datas = {
|
|
@@ -304,7 +385,7 @@ export default {
|
|
pageSize: this.size,
|
|
pageSize: this.size,
|
|
};
|
|
};
|
|
const data = await schoolSetDatabaseSyncList(datas);
|
|
const data = await schoolSetDatabaseSyncList(datas);
|
|
- this.exams = data.records;
|
|
|
|
|
|
+ this.dataList = data.records;
|
|
this.total = data.total;
|
|
this.total = data.total;
|
|
},
|
|
},
|
|
toPage(page) {
|
|
toPage(page) {
|
|
@@ -320,24 +401,37 @@ export default {
|
|
this.$refs.ModifyDatabaseSync.open();
|
|
this.$refs.ModifyDatabaseSync.open();
|
|
},
|
|
},
|
|
toViewLog(row) {
|
|
toViewLog(row) {
|
|
- this.logList = (row.summary || "").split("\n");
|
|
|
|
- this.logModalIsShow = true;
|
|
|
|
|
|
+ this.curRow = row;
|
|
|
|
+ this.$refs.DatabaseSyncLogDialog.open();
|
|
},
|
|
},
|
|
async toSync(row) {
|
|
async toSync(row) {
|
|
- const res = await schoolSetDatabaseSyncHandleSync(row.id).catch(() => {});
|
|
|
|
|
|
+ const res = await schoolSetDatabaseSyncHandleSync({
|
|
|
|
+ schoolId: row.schoolId,
|
|
|
|
+ examId: row.examId,
|
|
|
|
+ }).catch(() => {});
|
|
if (!res) return;
|
|
if (!res) return;
|
|
this.$message.success("操作成功!");
|
|
this.$message.success("操作成功!");
|
|
this.getList();
|
|
this.getList();
|
|
},
|
|
},
|
|
- async toCloseSync(row) {
|
|
|
|
- const confirm = await this.$confirm(`确定要结束当前同步记录吗?`, "提示", {
|
|
|
|
- type: "warning",
|
|
|
|
- }).catch(() => {});
|
|
|
|
- if (confirm !== "confirm") return;
|
|
|
|
|
|
+ async toEnable(row) {
|
|
|
|
+ const action = row.enable ? "禁用" : "启用";
|
|
|
|
+ const result = await this.$confirm(
|
|
|
|
+ `确定要${action}当前同步记录吗?`,
|
|
|
|
+ "提示",
|
|
|
|
+ {
|
|
|
|
+ type: "warning",
|
|
|
|
+ }
|
|
|
|
+ ).catch(() => {});
|
|
|
|
+ if (result !== "confirm") return;
|
|
|
|
|
|
- await schoolSetDatabaseSyncClose(row.id);
|
|
|
|
|
|
+ const enable = !row.enable;
|
|
|
|
+ await schoolSetDatabaseSyncEnable({
|
|
|
|
+ schoolId: row.schoolId,
|
|
|
|
+ examId: row.examId,
|
|
|
|
+ enable,
|
|
|
|
+ });
|
|
|
|
+ row.enable = enable;
|
|
this.$message.success("操作成功!");
|
|
this.$message.success("操作成功!");
|
|
- this.getList();
|
|
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|