|
@@ -1,50 +1,46 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <el-dialog
|
|
|
- :title="type == 'edit' ? '编辑办学特色' : '编辑师资力量'"
|
|
|
- class="table"
|
|
|
- :visible.sync="show"
|
|
|
- :close-on-click-modal="false"
|
|
|
- width="800px"
|
|
|
- top="8vh"
|
|
|
- >
|
|
|
+ <el-dialog :title="dialogTitle" class="table" :visible.sync="show" :close-on-click-modal="false" width="800px"
|
|
|
+ top="8vh">
|
|
|
<div v-loading="loading">
|
|
|
- <el-image
|
|
|
- style="
|
|
|
+ <el-image style="
|
|
|
width: 50px;
|
|
|
height: 50px;
|
|
|
cursor: pointer;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
- "
|
|
|
- :src="form.icon"
|
|
|
- fit="cover"
|
|
|
- v-if="this.type == 0"
|
|
|
- @click="addUrlIcon()"
|
|
|
- >
|
|
|
+ " :src="form.icon" fit="cover" v-if="this.type === 2" @click="addUrlIcon()">
|
|
|
<div slot="error" class="image-slot" @click="addUrlIcon()">
|
|
|
<i class="el-icon-picture-outline"></i>
|
|
|
</div>
|
|
|
</el-image>
|
|
|
|
|
|
- <div>
|
|
|
+ <el-image style="
|
|
|
+ width: 50px;
|
|
|
+ height: 50px;
|
|
|
+ cursor: pointer;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ " :src="form.icon" fit="cover" v-if="this.type === 0" @click="addUrlIcon()">
|
|
|
+ <div slot="error" class="image-slot" @click="addUrlIcon()">
|
|
|
+ <i class="el-icon-picture-outline"></i>
|
|
|
+ </div>
|
|
|
+ </el-image>
|
|
|
+
|
|
|
+ <div v-if="this.type != 2">
|
|
|
<div class="Tit">标题</div>
|
|
|
<div>
|
|
|
<el-input v-model="form.name" placeholder="请输入内容"></el-input>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div>
|
|
|
+ <div v-if="this.type != 2">
|
|
|
<div class="Tit">描述</div>
|
|
|
<div>
|
|
|
- <el-input
|
|
|
- type="textarea"
|
|
|
- :rows="3"
|
|
|
- resize="none"
|
|
|
- placeholder="请输入描述"
|
|
|
- v-model="form.bri">
|
|
|
- </el-input>
|
|
|
+ <el-input type="textarea" :rows="3" resize="none" placeholder="请输入描述" v-model="form.bri">
|
|
|
+ </el-input>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -72,12 +68,31 @@ export default {
|
|
|
type: null,
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ dialogTitle() {
|
|
|
+ if (this.type === 0) {
|
|
|
+ return '编辑办学特色';
|
|
|
+ } else if (this.type === 1) {
|
|
|
+ return '编辑师资力量';
|
|
|
+ } else if (this.type === 2) {
|
|
|
+ return '编辑特色应用';
|
|
|
+ } else {
|
|
|
+ return '未知类型'; // 默认值
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
open(data, type) {
|
|
|
this.form = JSON.parse(JSON.stringify(data));
|
|
|
- console.log('type',type);
|
|
|
-
|
|
|
+ console.log('form', this.form);
|
|
|
+
|
|
|
this.type = type;
|
|
|
+
|
|
|
+ // 根据 type 处理图片字段
|
|
|
+ if (type === 2) {
|
|
|
+ // 如果是特色应用,图片在 form.json.icon
|
|
|
+ this.form.icon = this.form.setIcon ? this.form.setIcon : this.form.json.icon; // 确保 json 存在,避免报错
|
|
|
+ }
|
|
|
this.show = true;
|
|
|
},
|
|
|
close() {
|
|
@@ -95,19 +110,37 @@ export default {
|
|
|
if (this.type == 0) {
|
|
|
if (!this.form.name || !this.form.icon || !this.form.bri)
|
|
|
return this.$message.error("请完善表单");
|
|
|
- } else {
|
|
|
+ } else if (this.type == 1) {
|
|
|
if (!this.form.name || !this.form.bri)
|
|
|
return this.$message.error("请完善表单");
|
|
|
+ } else if (this.type == 2) {
|
|
|
+ if (!this.form.icon) {
|
|
|
+ return this.$message.error("请完善表单");
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('!this.form',this.form);
|
|
|
+
|
|
|
+ // 将 form.icon 保存回 form.json.icon
|
|
|
+ // this.form.json = this.form.json || {};
|
|
|
+ // this.form.json.icon = this.form.icon;
|
|
|
+ // console.log('form.json', this.form.json);
|
|
|
+
|
|
|
}
|
|
|
this.$emit("success", { item: this.form });
|
|
|
- this.close()
|
|
|
+ this.close()
|
|
|
},
|
|
|
async addUrlIcon() {
|
|
|
let _url = await this.uploadFile("image/*");
|
|
|
console.log("addUrlIcon", _url);
|
|
|
|
|
|
if (_url) {
|
|
|
- this.form.icon = _url;
|
|
|
+ if (this.type === 2) {
|
|
|
+ this.form.setIcon = _url;
|
|
|
+ }else {
|
|
|
+ this.form.icon = _url;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
} else {
|
|
|
return console.log("无图片");
|
|
|
}
|
|
@@ -171,16 +204,17 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.table >>> .el-dialog__header {
|
|
|
+.table>>>.el-dialog__header {
|
|
|
padding: 15px 20px;
|
|
|
background: #454545;
|
|
|
}
|
|
|
|
|
|
-.table >>> .el-dialog__title {
|
|
|
+.table>>>.el-dialog__title {
|
|
|
color: #fff;
|
|
|
}
|
|
|
-.Tit{
|
|
|
- padding: 15px 0;
|
|
|
- font-size: 14px;
|
|
|
+
|
|
|
+.Tit {
|
|
|
+ padding: 15px 0;
|
|
|
+ font-size: 14px;
|
|
|
}
|
|
|
</style>
|