|
@@ -1,80 +1,44 @@
|
|
|
<template>
|
|
|
- <div class="setting login-body">
|
|
|
- <div class="login-form">
|
|
|
- <h2 class="login-form-title">设置</h2>
|
|
|
- <el-form ref="setForm" :model="setModel" :rules="setRules" inline>
|
|
|
- <h3 class="mb-1">服务器IP地址:</h3>
|
|
|
- <el-form-item prop="ipCont1">
|
|
|
- <el-input-number
|
|
|
- style="width: 60px"
|
|
|
- v-model="setModel.ipCont1"
|
|
|
- :min="0"
|
|
|
- :max="255"
|
|
|
- :step="1"
|
|
|
- step-strictly
|
|
|
- :controls="false"
|
|
|
- ></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- <span class="ip-split">—</span>
|
|
|
- <el-form-item prop="ipCont2">
|
|
|
- <el-input-number
|
|
|
- style="width: 60px"
|
|
|
- v-model="setModel.ipCont2"
|
|
|
- :min="0"
|
|
|
- :max="255"
|
|
|
- :step="1"
|
|
|
- step-strictly
|
|
|
- :controls="false"
|
|
|
- ></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- <span class="ip-split">—</span>
|
|
|
- <el-form-item prop="ipCont3">
|
|
|
- <el-input-number
|
|
|
- style="width: 60px"
|
|
|
- v-model="setModel.ipCont3"
|
|
|
- :min="0"
|
|
|
- :max="255"
|
|
|
- :step="1"
|
|
|
- step-strictly
|
|
|
- :controls="false"
|
|
|
- ></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- <span class="ip-split">—</span>
|
|
|
- <el-form-item prop="ipCont4">
|
|
|
- <el-input-number
|
|
|
- style="width: 60px"
|
|
|
- v-model="setModel.ipCont4"
|
|
|
- :min="0"
|
|
|
- :max="255"
|
|
|
- :step="1"
|
|
|
- step-strictly
|
|
|
- :controls="false"
|
|
|
- ></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- <span class="ip-split">:</span>
|
|
|
- <el-form-item prop="port">
|
|
|
- <el-input-number
|
|
|
- style="width: 60px"
|
|
|
- v-model="setModel.port"
|
|
|
- :min="1"
|
|
|
- :max="1000000"
|
|
|
- :step="1"
|
|
|
- step-strictly
|
|
|
- :controls="false"
|
|
|
- ></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- <br />
|
|
|
- <h3 class="mb-1">学校编号:</h3>
|
|
|
- <el-form-item prop="schoolCode">
|
|
|
- <el-input v-model="setModel.schoolCode" clearable></el-input>
|
|
|
+ <div class="login">
|
|
|
+ <div class="login-spin">
|
|
|
+ <h1>欢迎使用</h1>
|
|
|
+ <h4>知学知考-档案电子化扫描系统</h4>
|
|
|
+ </div>
|
|
|
+ <div class="login-body">
|
|
|
+ <div class="login-head">
|
|
|
+ <div class="login-head-left">
|
|
|
+ <h2 class="login-head-title">设置</h2>
|
|
|
+ <h4 class="login-head-subtitle">服务器IP地址设置</h4>
|
|
|
+ </div>
|
|
|
+ <div class="login-head-right">
|
|
|
+ <el-button class="login-btn btn-setting" @click="toSetScan"
|
|
|
+ >配置扫描仪</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-form ref="setForm" :model="setModel" :rules="setRules">
|
|
|
+ <el-form-item prop="host">
|
|
|
+ <div class="box-justify">
|
|
|
+ <el-select
|
|
|
+ v-model="setModel.protocol"
|
|
|
+ style="width: 70px; margin-right: 8px; flex-shrink: 0"
|
|
|
+ >
|
|
|
+ <el-option value="http" label="http"></el-option>
|
|
|
+ <el-option value="https" label="https"></el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-input
|
|
|
+ v-model.trim="setModel.host"
|
|
|
+ placeholder="服务器IP地址"
|
|
|
+ clearable
|
|
|
+ ></el-input>
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
- <br />
|
|
|
<el-form-item>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
+ class="login-submit"
|
|
|
+ style="margin-top: 126px"
|
|
|
:disabled="loading"
|
|
|
- size="large"
|
|
|
@click="submit"
|
|
|
>确定</el-button
|
|
|
>
|
|
@@ -86,99 +50,64 @@
|
|
|
|
|
|
<script>
|
|
|
import db from "@/plugins/db";
|
|
|
+import { setScanner } from "../../../plugins/scanner";
|
|
|
|
|
|
export default {
|
|
|
name: "setting",
|
|
|
data() {
|
|
|
- const contValidator = [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: " ",
|
|
|
- trigger: "change",
|
|
|
- },
|
|
|
- ];
|
|
|
return {
|
|
|
setModel: {
|
|
|
- ipCont1: undefined,
|
|
|
- ipCont2: undefined,
|
|
|
- ipCont3: undefined,
|
|
|
- ipCont4: undefined,
|
|
|
- port: undefined,
|
|
|
- schoolCode: "",
|
|
|
+ protocol: "http",
|
|
|
+ host: "",
|
|
|
},
|
|
|
setRules: {
|
|
|
- ipCont1: [...contValidator],
|
|
|
- ipCont2: [...contValidator],
|
|
|
- ipCont3: [...contValidator],
|
|
|
- ipCont4: [...contValidator],
|
|
|
- port: [...contValidator],
|
|
|
- schoolCode: [...contValidator],
|
|
|
+ host: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入服务器IP地址",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
loading: false,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
- domainEdited() {
|
|
|
- return `http://${this.setModel.ipCont1}.${this.setModel.ipCont2}.${this.setModel.ipCont3}.${this.setModel.ipCont4}:${this.setModel.port}`;
|
|
|
- },
|
|
|
domain() {
|
|
|
return this.$store.state.domain;
|
|
|
},
|
|
|
- schoolCode() {
|
|
|
- return this.$store.state.schoolCode;
|
|
|
- },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.initData();
|
|
|
},
|
|
|
methods: {
|
|
|
initData() {
|
|
|
- if (!this.domain) {
|
|
|
- this.setModel = {
|
|
|
- ipCont1: undefined,
|
|
|
- ipCont2: undefined,
|
|
|
- ipCont3: undefined,
|
|
|
- ipCont4: undefined,
|
|
|
- port: undefined,
|
|
|
- schoolCode: this.schoolCode,
|
|
|
- };
|
|
|
- return;
|
|
|
+ const domain = this.domain || "";
|
|
|
+ if (domain.indexOf("https") !== -1) {
|
|
|
+ this.setModel.protocol = "https";
|
|
|
+ } else {
|
|
|
+ this.setModel.protocol = "http";
|
|
|
}
|
|
|
-
|
|
|
- const [ipCont1, ipCont2, ipCont3, ipCont4, port] = this.domain
|
|
|
- .replace("http://", "")
|
|
|
- .split(/\.|:/);
|
|
|
-
|
|
|
- this.setModel = {
|
|
|
- ipCont1: Number(ipCont1),
|
|
|
- ipCont2: Number(ipCont2),
|
|
|
- ipCont3: Number(ipCont3),
|
|
|
- ipCont4: Number(ipCont4),
|
|
|
- port: Number(port),
|
|
|
- schoolCode: this.schoolCode,
|
|
|
- };
|
|
|
+ this.setModel.host = domain.replace(`${this.setModel.protocol}://`, "");
|
|
|
+ },
|
|
|
+ async toSetScan() {
|
|
|
+ await setScanner().catch((error) => {
|
|
|
+ console.dir(error);
|
|
|
+ this.$message.error("连接扫描仪异常");
|
|
|
+ });
|
|
|
},
|
|
|
async submit() {
|
|
|
- if (this.loading) return;
|
|
|
- this.loading = true;
|
|
|
-
|
|
|
const valid = await this.$refs.setForm.validate().catch(() => {});
|
|
|
- if (!valid) {
|
|
|
- this.loading = false;
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (!valid) return;
|
|
|
|
|
|
- this.$store.commit("setDomain", this.domainEdited);
|
|
|
- let res1 = await db.setDict("domain", this.domainEdited).catch(() => {});
|
|
|
- let res2 = await db
|
|
|
- .setDict("schoolCode", this.setModel.schoolCode)
|
|
|
- .catch(() => {});
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
|
|
|
- if (res1 && res2) {
|
|
|
- this.$ls.set("domain", this.domainEdited);
|
|
|
- this.$store.commit("setDomain", this.domainEdited);
|
|
|
- this.$ls.set("schoolCode", this.setModel.schoolCode);
|
|
|
- this.$store.commit("setSchoolCode", this.setModel.schoolCode);
|
|
|
+ const domain = `${this.setModel.protocol}://${this.setModel.host}`;
|
|
|
+ this.$store.commit("setDomain", domain);
|
|
|
+ const res = await db.setDict("domain", domain).catch(() => {});
|
|
|
+ if (res) {
|
|
|
+ this.$ls.set("domain", domain);
|
|
|
this.$message.success("设置成功!");
|
|
|
this.$router.go(-1);
|
|
|
} else {
|