|
@@ -0,0 +1,344 @@
|
|
|
+<template>
|
|
|
+ <div class="school-set-database-sync">
|
|
|
+ <div class="part-box part-box-pad">
|
|
|
+ <el-form
|
|
|
+ ref="modalFormComp"
|
|
|
+ :model="modalForm"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="100px"
|
|
|
+ style="max-width: 1000px"
|
|
|
+ >
|
|
|
+ <el-form-item prop="type" label="数据库类型:">
|
|
|
+ <el-radio-group v-model="modalForm.type">
|
|
|
+ <el-radio
|
|
|
+ v-for="(val, key) in DATABASE_TYPE"
|
|
|
+ :key="key"
|
|
|
+ :label="key"
|
|
|
+ >{{ val }}</el-radio
|
|
|
+ >
|
|
|
+ </el-radio-group>
|
|
|
+ </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="12">
|
|
|
+ <el-form-item prop="username" label="用户名:">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="modalForm.username"
|
|
|
+ placeholder="请输入用户名"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item prop="password" label="密码:">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="modalForm.password"
|
|
|
+ placeholder="请输入密码"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="toSave">保存</el-button>
|
|
|
+ <el-button type="primary" @click="toTest">测试链接</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="part-box part-box-pad">
|
|
|
+ <div class="box-justify mb-2">
|
|
|
+ <div></div>
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" @click="toAdd">新增</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-table ref="TableList" :data="dataList">
|
|
|
+ <el-table-column
|
|
|
+ prop="semesterName"
|
|
|
+ label="学年学期"
|
|
|
+ min-width="210"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="name"
|
|
|
+ label="考试名称"
|
|
|
+ min-width="160"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="courseName"
|
|
|
+ label="同步数据类型"
|
|
|
+ width="120"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="courseCode"
|
|
|
+ label="同步记录数"
|
|
|
+ width="120"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column prop="createTime" label="同步开始时间" width="170">
|
|
|
+ <span slot-scope="scope">{{
|
|
|
+ scope.row.createTime | timestampFilter
|
|
|
+ }}</span>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="createTime" label="同步结束时间" width="170">
|
|
|
+ <span slot-scope="scope">{{
|
|
|
+ scope.row.createTime | timestampFilter
|
|
|
+ }}</span>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="courseCode"
|
|
|
+ label="状态"
|
|
|
+ width="100"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ class-name="action-column"
|
|
|
+ label="操作"
|
|
|
+ width="220"
|
|
|
+ fixed="right"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ class="btn-primary"
|
|
|
+ type="text"
|
|
|
+ @click="toEdit(scope.row)"
|
|
|
+ >设置</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ class="btn-primary"
|
|
|
+ type="text"
|
|
|
+ @click="toViewLog(scope.row)"
|
|
|
+ >查看日志</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ class="btn-primary"
|
|
|
+ type="text"
|
|
|
+ @click="toSync(scope.row)"
|
|
|
+ >手动同步</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ class="btn-danger"
|
|
|
+ type="text"
|
|
|
+ @click="toCloseSync(scope.row)"
|
|
|
+ >结束同步</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div class="part-page">
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :pager-count="5"
|
|
|
+ :current-page="current"
|
|
|
+ :total="total"
|
|
|
+ :page-size="size"
|
|
|
+ @current-change="toPage"
|
|
|
+ @size-change="pageSizeChange"
|
|
|
+ >
|
|
|
+ </el-pagination>
|
|
|
+ </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
|
|
|
+ ref="ModifyDatabaseSync"
|
|
|
+ :instance="curRow"
|
|
|
+ :school-id="school.id"
|
|
|
+ @modified="getList"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ schoolSetDatabaseSyncBaseinfo,
|
|
|
+ schoolSetDatabaseSyncBaseinfoUpdate,
|
|
|
+ schoolSetDatabaseSyncBaseinfoTest,
|
|
|
+ schoolSetDatabaseSyncList,
|
|
|
+ schoolSetDatabaseSyncHandleSync,
|
|
|
+ schoolSetDatabaseSyncClose,
|
|
|
+} from "../../api";
|
|
|
+import { DATABASE_TYPE } from "@/constants/enumerate";
|
|
|
+import ModifyDatabaseSync from "./ModifyDatabaseSync.vue";
|
|
|
+
|
|
|
+const initModalForm = {
|
|
|
+ type: "",
|
|
|
+ url: "",
|
|
|
+ username: "",
|
|
|
+ password: "",
|
|
|
+};
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "school-set-database-sync",
|
|
|
+ components: { ModifyDatabaseSync },
|
|
|
+ props: {
|
|
|
+ school: {
|
|
|
+ type: Object,
|
|
|
+ default() {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ modalForm: { ...initModalForm },
|
|
|
+ rules: {
|
|
|
+ type: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请选择数据库类型",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ url: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入URL",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ message: "url不能超过999个字符",
|
|
|
+ max: 999,
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ username: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入用户名",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ message: "用户名不能超过50个字符",
|
|
|
+ max: 50,
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ password: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入密码",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ message: "密码不能超过50个字符",
|
|
|
+ max: 50,
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ isSubmit: false,
|
|
|
+ dataList: [],
|
|
|
+ current: 1,
|
|
|
+ size: this.GLOBAL.pageSize,
|
|
|
+ total: 0,
|
|
|
+ curRow: {},
|
|
|
+ DATABASE_TYPE,
|
|
|
+ // log
|
|
|
+ logList: [],
|
|
|
+ logModalIsShow: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getBaseInfo() {
|
|
|
+ const res = await schoolSetDatabaseSyncBaseinfo(this.school.id);
|
|
|
+ this.modalForm = this.$objAssign(initModalForm, res || {});
|
|
|
+ },
|
|
|
+ async toSave() {
|
|
|
+ const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ if (this.isSubmit) return;
|
|
|
+ this.isSubmit = true;
|
|
|
+ const datas = { ...this.modalForm };
|
|
|
+ const res = await schoolSetDatabaseSyncBaseinfoUpdate(datas).catch(
|
|
|
+ () => {}
|
|
|
+ );
|
|
|
+ this.isSubmit = false;
|
|
|
+
|
|
|
+ if (!res) return;
|
|
|
+ this.$message.success("保存成功!");
|
|
|
+ },
|
|
|
+ async toTest() {
|
|
|
+ const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ if (this.isSubmit) return;
|
|
|
+ this.isSubmit = true;
|
|
|
+ const datas = { ...this.modalForm };
|
|
|
+ const res = await schoolSetDatabaseSyncBaseinfoTest(datas).catch(
|
|
|
+ () => {}
|
|
|
+ );
|
|
|
+ this.isSubmit = false;
|
|
|
+
|
|
|
+ if (!res) return;
|
|
|
+ this.$message.success("测试成功!");
|
|
|
+ },
|
|
|
+ async getList() {
|
|
|
+ const datas = {
|
|
|
+ schoolId: this.school.id,
|
|
|
+ pageNumber: this.current,
|
|
|
+ pageSize: this.size,
|
|
|
+ };
|
|
|
+ const data = await schoolSetDatabaseSyncList(datas);
|
|
|
+ this.exams = data.records;
|
|
|
+ this.total = data.total;
|
|
|
+ },
|
|
|
+ toPage(page) {
|
|
|
+ this.current = page;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ toEdit(row) {
|
|
|
+ this.curRow = row;
|
|
|
+ this.$refs.ModifyDatabaseSync.open();
|
|
|
+ },
|
|
|
+ toAdd() {
|
|
|
+ this.curRow = {};
|
|
|
+ this.$refs.ModifyDatabaseSync.open();
|
|
|
+ },
|
|
|
+ toViewLog(row) {
|
|
|
+ this.logList = (row.summary || "").split("\n");
|
|
|
+ this.logModalIsShow = true;
|
|
|
+ },
|
|
|
+ async toSync(row) {
|
|
|
+ const res = await schoolSetDatabaseSyncHandleSync(row.id).catch(() => {});
|
|
|
+ if (!res) return;
|
|
|
+ this.$message.success("操作成功!");
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ async toCloseSync(row) {
|
|
|
+ const confirm = await this.$confirm(`确定要结束当前同步记录吗?`, "提示", {
|
|
|
+ type: "warning",
|
|
|
+ }).catch(() => {});
|
|
|
+ if (confirm !== "confirm") return;
|
|
|
+
|
|
|
+ await schoolSetDatabaseSyncClose(row.id);
|
|
|
+ this.$message.success("操作成功!");
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|