|
@@ -0,0 +1,176 @@
|
|
|
+<template>
|
|
|
+ <div class="school-set-font">
|
|
|
+ <div class="part-box part-box-pad">
|
|
|
+ <el-form
|
|
|
+ ref="modalFormComp"
|
|
|
+ label-width="100px"
|
|
|
+ :model="modalForm"
|
|
|
+ :rules="rules"
|
|
|
+ >
|
|
|
+ <el-form-item prop="attachmentId" label="选择文件:">
|
|
|
+ <upload-file-view
|
|
|
+ :upload-data="uploadData"
|
|
|
+ :upload-url="uploadUrl"
|
|
|
+ :format="format"
|
|
|
+ input-width="300px"
|
|
|
+ :maxSize="100 * 1024 * 1024"
|
|
|
+ :disabled="loading"
|
|
|
+ @valid-error="validError"
|
|
|
+ @upload-success="uploadSuccess"
|
|
|
+ ref="UploadFileView"
|
|
|
+ ></upload-file-view>
|
|
|
+ <div>
|
|
|
+ <p class="tips-info">
|
|
|
+ 说明:支持格式{{ format.join(",") }},文件大小不超过100M
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div class="part-box part-box-pad">
|
|
|
+ <el-table :data="fontList">
|
|
|
+ <el-table-column type="index" label="序号" width="80"></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="fontName"
|
|
|
+ label="名称"
|
|
|
+ min-width="200"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column prop="format" label="格式"></el-table-column>
|
|
|
+ <el-table-column prop="choose" label="是否选中" width="100">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <i
|
|
|
+ v-if="scope.row.choose"
|
|
|
+ class="el-icon-success color-success"
|
|
|
+ ></i>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ class-name="action-column"
|
|
|
+ label="操作"
|
|
|
+ fixed="right"
|
|
|
+ width="120"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope" v-if="scope.row.attachmentId !== -1">
|
|
|
+ <el-button
|
|
|
+ v-if="!scope.row.choose"
|
|
|
+ class="btn-primary"
|
|
|
+ type="text"
|
|
|
+ @click="toSelect(scope.row)"
|
|
|
+ >选中</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ class="btn-danger"
|
|
|
+ type="text"
|
|
|
+ @click="toDelete(scope.row)"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import UploadFileView from "@/components/UploadFileView.vue";
|
|
|
+import {
|
|
|
+ schoolSetFontInfo,
|
|
|
+ schoolSetFontAdd,
|
|
|
+ schoolSetFontUpdate,
|
|
|
+ schoolSetFontDelete,
|
|
|
+} from "../../api";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "school-set-font",
|
|
|
+ components: {
|
|
|
+ UploadFileView,
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ school: {
|
|
|
+ type: Object,
|
|
|
+ default() {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ fontList: [],
|
|
|
+ modalForm: { schoolId: "", attachmentId: "" },
|
|
|
+ rules: {
|
|
|
+ attachmentId: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请上传模板文件",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ // upload
|
|
|
+ format: ["ttf", "ttc"],
|
|
|
+ uploadUrl: "/api/admin/common/file/upload",
|
|
|
+ uploadData: {
|
|
|
+ type: "UPLOAD",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async initData() {
|
|
|
+ this.modalForm.schoolId = this.school.id;
|
|
|
+ const data = await schoolSetFontInfo(this.school.id);
|
|
|
+ if (data && data.value) {
|
|
|
+ this.fontList = JSON.parse(data.value);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ validError(errorData) {
|
|
|
+ this.$message.error(errorData.message);
|
|
|
+ },
|
|
|
+ async uploadSuccess(data) {
|
|
|
+ this.modalForm.attachmentId = data.id;
|
|
|
+
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
+ const res = await schoolSetFontAdd(this.modalForm).catch(() => {});
|
|
|
+ this.loading = false;
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ this.$message.success("上传字体成功!");
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
+ async toSelect(row) {
|
|
|
+ this.loading = true;
|
|
|
+ const res = await schoolSetFontUpdate({
|
|
|
+ schoolId: this.school.id,
|
|
|
+ attachmentId: row.attachmentId,
|
|
|
+ }).catch(() => {});
|
|
|
+ this.loading = false;
|
|
|
+ if (!res) return;
|
|
|
+ this.$message.success("选中字体成功!");
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
+ async toDelete(row) {
|
|
|
+ const confirm = await this.$confirm("确认删除字体?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }).catch(() => {});
|
|
|
+ if (!confirm !== "confirm") return;
|
|
|
+
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
+ const res = await schoolSetFontDelete({
|
|
|
+ schoolId: this.school.id,
|
|
|
+ attachmentId: row.attachmentId,
|
|
|
+ }).catch(() => {});
|
|
|
+ this.loading = false;
|
|
|
+ if (!res) return;
|
|
|
+ this.$message.success("删除字体成功!");
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|