优化 枚举请求方式

新增 班级页面
This commit is contained in:
小肥羊 2025-08-13 18:38:11 +08:00
parent 14c4e01175
commit e1fdca95b8
4 changed files with 65 additions and 19 deletions

View File

@ -7,7 +7,7 @@ import type { Res } from "@/utils/http/types";
* @return {object} * @return {object}
*/ */
export function getenum(type) { export function getenum(type) {
return http.request<Res<any>>("get", `public/enum/${type}`); return http.request<Res<any>>("get", `Public/enum/${type}`);
} }
/** /**
* @description * @description
@ -15,5 +15,5 @@ export function getenum(type) {
* @return {object} * @return {object}
*/ */
export function getenumDic(type) { export function getenumDic(type) {
return http.request<Res<any>>("get", `public/enum/${type}/Dic`); return http.request<Res<any>>("get", `Public/enum/${type}/Dic`);
} }

View File

@ -158,7 +158,7 @@ function fetchFormData() {
format="YYYY-MM-DD" format="YYYY-MM-DD"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
:placeholder="o.label" :placeholder="o.label"
style="width: 100%" class="elWidth"
@change="o.change" @change="o.change"
/> />
</div> </div>
@ -169,12 +169,12 @@ function fetchFormData() {
clearable clearable
filterable filterable
:placeholder="o.label" :placeholder="o.label"
style="width: 100%" class="elWidth"
@change="o.change" @change="o.change"
> >
<el-option <el-option
v-for="item in o.setting.datasource" v-for="item in o.setting.datasource"
:key="item.Value" :key="item.value"
autocomplete="off" autocomplete="off"
:label="item[o.setting.maplabel]" :label="item[o.setting.maplabel]"
:value="item[o.setting.mapValue]" :value="item[o.setting.mapValue]"
@ -187,6 +187,7 @@ function fetchFormData() {
:rows="o.editRows || 4" :rows="o.editRows || 4"
type="textarea" type="textarea"
:placeholder="o.label" :placeholder="o.label"
class="elWidth"
@change="o.change" @change="o.change"
/> />
</div> </div>
@ -195,11 +196,16 @@ function fetchFormData() {
v-model="o.valueE as boolean" v-model="o.valueE as boolean"
active-text="启用" active-text="启用"
inactive-text="禁用" inactive-text="禁用"
class="elWidth"
@change="o.change" @change="o.change"
/> />
</div> </div>
<div v-else> <div v-else>
<el-input v-model="o.valueE as string" :placeholder="o.label" /> <el-input
v-model="o.valueE as string"
class="elWidth"
:placeholder="o.label"
/>
</div> </div>
</el-form-item> </el-form-item>
@ -215,3 +221,9 @@ function fetchFormData() {
</el-form> </el-form>
</div> </div>
</template> </template>
<style>
.elWidth {
width: 100%;
min-width: 220px;
}
</style>

View File

@ -281,7 +281,7 @@ function handleReloadPaged(reload = true) {
data.ConditionalType = "Like"; data.ConditionalType = "Like";
} }
data.FieldName = name.charAt(0).toUpperCase() + name.slice(1); data.FieldName = name.charAt(0).toUpperCase() + name.slice(1);
data.FieldValue = table.value.column[name].value; data.FieldValue = table.value.column[name].value.toString();
if (table.value.column[name].searchType != undefined) { if (table.value.column[name].searchType != undefined) {
data.ConditionalType = table.value.column[name].searchType || 0; data.ConditionalType = table.value.column[name].searchType || 0;
@ -303,11 +303,10 @@ async function fetchInitData() {
const element = table.value.column[key]; const element = table.value.column[key];
if (element.type === "dropdown") { if (element.type === "dropdown") {
if (!element.setting.datasource) { if (!element.setting.datasource) {
// //
// let rdata = await eval(element.setting.datasourceStr);
let rdata = await eval(element.setting.datasourceStr); // element.setting.datasource = rdata.data;
element.setting.datasource = rdata.data; // console.log(key + " " + element.setting.datasourceStr, rdata);
console.log(key + " " + element.setting.datasourceStr, rdata);
} }
} }
if ( if (

View File

@ -4,12 +4,14 @@ import { TableConfig } from "@/components/hTable/hTable";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { fa } from "element-plus/es/locales.mjs"; import { fa } from "element-plus/es/locales.mjs";
import { hTableAPI } from "@/api/hTable"; import { hTableAPI } from "@/api/hTable";
import { getenum } from "@/api/enum";
const ControllerName = "Class"; const ControllerName = "Class";
defineOptions({ defineOptions({
name: ControllerName name: ControllerName
}); });
const SchoolApi = new hTableAPI("School");
function searchCallback(data) {} function searchCallback(data) {}
const table = ref<{ initTable: (config: TableConfig) => void }>(); const table = ref<{ initTable: (config: TableConfig) => void }>();
@ -59,24 +61,46 @@ const tableData: TableConfig = {
edit: false, // edit: false, //
width: "150px" width: "150px"
}, },
schoolId: {
label: "学校",
width: "180px",
search: true,
type: "dropdown",
add: true, //
edit: true, //
setting: {}
},
name: { name: {
label: "角色名称", label: "名称",
width: "180px", width: "180px",
search: true, search: true,
searchType: "Like", searchType: "Like",
add: true, // add: true, //
edit: true // edit: true //
}, },
enable: { Grade: {
label: "启用", label: "年级",
type: "switch", width: "180px",
search: false, type: "dropdown",
add: false, // custom: row => `${row.grade ?? ""}`,
// `${row.grade ?? ""} ${row.gradeLevel + row.graduationYear}`,
search: true,
setting: {},
add: true, //
edit: false //
},
type: {
label: "类型",
width: "150px",
type: "dropdown",
search: true,
add: true, //
edit: true, // edit: true, //
valueE: true // setting: {}
}, },
createTime: { createTime: {
label: "创建时间", label: "创建时间",
width: "180px",
type: "datetime", type: "datetime",
search: true, search: true,
add: false, // add: false, //
@ -84,6 +108,8 @@ const tableData: TableConfig = {
}, },
remark: { remark: {
label: "备注", label: "备注",
type: "textarea",
editRows: 3,
search: false, search: false,
add: true, // add: true, //
edit: true // edit: true //
@ -100,6 +126,15 @@ const showTable = ref(false);
onMounted(async () => { onMounted(async () => {
// //
tableData.column.Grade.setting.datasource = (await getenum("GradeEnum")).data;
tableData.column.type.setting.datasource = (
await getenum("ClassTypeEnum")
).data;
tableData.column.schoolId.setting.datasource = (
await SchoolApi.querycombo({ TextName: "Name", ValueName: "Id" })
).data;
showTable.value = true; showTable.value = true;
}); });
</script> </script>