|
|
@@ -18,6 +18,14 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :md="6" :sm="12">
|
|
|
+ <el-form-item label="类别属性">
|
|
|
+ <el-select v-model="table.where.attr_type" placeholder="请选择类别属性" clearable>
|
|
|
+ <el-option v-for="(label, key) in attrTypeOptions" :key="key" :label="label"
|
|
|
+ :value="key" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="6" :sm="12">
|
|
|
<el-form-item label="状态">
|
|
|
<el-select v-model="table.where.status" placeholder="请选择" clearable>
|
|
|
<el-option label="有效" :value="1" />
|
|
|
@@ -54,11 +62,25 @@
|
|
|
<el-table-column type="selection" width="45" align="center" fixed="left" />
|
|
|
<el-table-column type="index" label="编号" width="60" align="center" fixed="left" />
|
|
|
<el-table-column prop="subject_name" label="科目名称" min-width="150" />
|
|
|
+ <el-table-column prop="description" label="描述" min-width="120" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="icon" label="图标" width="100">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <img v-if="row.icon" :src="row.icon" style="width: 30px; height: 30px;" />
|
|
|
+ <span v-else>-</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="type" label="所属栏目" width="120">
|
|
|
<template slot-scope="{ row }">
|
|
|
<el-tag type="info">{{ typeOptions[row.type] || '未知' }}</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column prop="attr_type" label="类别属性" width="120" v-if="showAttrTypeColumn">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tag type="success" v-if="row.attr_type">{{ attrTypeOptions[row.attr_type] || '未知'
|
|
|
+ }}</el-tag>
|
|
|
+ <span v-else>-</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="sort" label="排序" width="100" />
|
|
|
<el-table-column label="状态" width="80">
|
|
|
<template slot-scope="{ row }">
|
|
|
@@ -84,11 +106,24 @@
|
|
|
<el-form-item label="科目名称" prop="subject_name">
|
|
|
<el-input v-model="formData.subject_name" placeholder="请输入科目名称" />
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="描述" prop="description">
|
|
|
+ <el-input v-model="formData.description" placeholder="请输入描述" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图标" prop="icon">
|
|
|
+ <uploadImage :limit="1" v-model="formData.icon" @upload-success="onImageUploadSuccess">
|
|
|
+ </uploadImage>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="所属栏目" prop="type">
|
|
|
<el-select v-model="formData.type" placeholder="请选择栏目">
|
|
|
<el-option v-for="(label, key) in typeOptions" :key="key" :label="label" :value="Number(key)" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="类别属性" prop="attr_type" v-if="showAttrTypeField">
|
|
|
+ <el-select v-model="formData.attr_type" placeholder="请选择类别属性" clearable>
|
|
|
+ <el-option v-for="(label, key) in attrTypeOptions" :key="key" :label="label"
|
|
|
+ :value="Number(key)" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="排序" prop="sort">
|
|
|
<el-input-number v-model="formData.sort" :min="0" />
|
|
|
</el-form-item>
|
|
|
@@ -106,16 +141,21 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from 'vuex'
|
|
|
+import uploadImage from '@/components/uploadImage.vue'
|
|
|
+
|
|
|
export default {
|
|
|
name: "SubjectPage",
|
|
|
+ components: {
|
|
|
+ uploadImage
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
table: {
|
|
|
url: "/subjects/index",
|
|
|
- where: { keyword: "", type: null, status: null }
|
|
|
+ where: { keyword: "", type: null, attr_type: null, status: null }
|
|
|
},
|
|
|
choose: [],
|
|
|
- formData: { id: null, subject_name: "", type: 1, sort: 0, status: 1 },
|
|
|
+ formData: { id: null, subject_name: "", type: 1, attr_type: null, description: "", icon: "", sort: 0, status: 1 },
|
|
|
isEdit: false,
|
|
|
formVisible: false,
|
|
|
formRules: {
|
|
|
@@ -123,6 +163,7 @@ export default {
|
|
|
type: [{ required: true, message: "请选择所属栏目", trigger: "change" }]
|
|
|
},
|
|
|
typeOptions: { 1: "单招", 2: "对口", 3: "专升本" },
|
|
|
+ attrTypeOptions: { 1: "文化基础" },
|
|
|
permissionMap: {
|
|
|
delete: "sys:subject:delete",
|
|
|
edit: "sys:subject:edit",
|
|
|
@@ -131,19 +172,47 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
- computed: { ...mapGetters(["permission"]) },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["permission"]),
|
|
|
+ // 是否显示类别属性列(只有对口和专升本才显示)
|
|
|
+ showAttrTypeColumn() {
|
|
|
+ return this.table.where.type === 2 || this.table.where.type === 3;
|
|
|
+ },
|
|
|
+ // 是否显示类别属性字段(只有对口和专升本才显示)
|
|
|
+ showAttrTypeField() {
|
|
|
+ return this.formData.type === 2 || this.formData.type === 3;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // 监听类型变化,自动设置 attr_type
|
|
|
+ 'formData.type'(newType) {
|
|
|
+ if (newType === 1) {
|
|
|
+ // 单招时设置为0
|
|
|
+ this.formData.attr_type = 0;
|
|
|
+ } else if (newType === 2 || newType === 3) {
|
|
|
+ // 对口和专升本时设置为null(可选)
|
|
|
+ this.formData.attr_type = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
resetSearch() {
|
|
|
- this.table.where = { keyword: "", type: null, status: null };
|
|
|
+ this.table.where = { keyword: "", type: null, attr_type: null, status: null };
|
|
|
this.$refs.table.reload();
|
|
|
},
|
|
|
openForm(row) {
|
|
|
if (row) {
|
|
|
this.isEdit = true;
|
|
|
- this.formData = { ...row, type: Number(row.type) }; // 转成数字
|
|
|
+ this.formData = {
|
|
|
+ ...row,
|
|
|
+ type: Number(row.type),
|
|
|
+ attr_type: row.attr_type ? Number(row.attr_type) : (Number(row.type) === 1 ? 0 : null),
|
|
|
+ description: row.description || "",
|
|
|
+ icon: row.icon || ""
|
|
|
+ }; // 转成数字
|
|
|
} else {
|
|
|
this.isEdit = false;
|
|
|
- this.formData = { id: null, subject_name: "", type: 1, sort: 0, status: 1 };
|
|
|
+ this.formData = { id: null, subject_name: "", type: 1, attr_type: 0, description: "", icon: "", sort: 0, status: 1 };
|
|
|
}
|
|
|
this.formVisible = true;
|
|
|
},
|
|
|
@@ -188,6 +257,11 @@ export default {
|
|
|
this.$http.post("/subjects/status", { id: row.id, status: row.status }).then(res => {
|
|
|
if (res.data.code !== 0) this.$message.error(res.data.msg);
|
|
|
});
|
|
|
+ },
|
|
|
+
|
|
|
+ // 图片上传成功回调
|
|
|
+ onImageUploadSuccess(data) {
|
|
|
+ this.$message.success('图标上传成功');
|
|
|
}
|
|
|
}
|
|
|
};
|