优化 枚举请求方式

新增 班级页面
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}
*/
export function getenum(type) {
return http.request<Res<any>>("get", `public/enum/${type}`);
return http.request<Res<any>>("get", `Public/enum/${type}`);
}
/**
* @description
@ -15,5 +15,5 @@ export function getenum(type) {
* @return {object}
*/
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"
value-format="YYYY-MM-DD"
:placeholder="o.label"
style="width: 100%"
class="elWidth"
@change="o.change"
/>
</div>
@ -169,12 +169,12 @@ function fetchFormData() {
clearable
filterable
:placeholder="o.label"
style="width: 100%"
class="elWidth"
@change="o.change"
>
<el-option
v-for="item in o.setting.datasource"
:key="item.Value"
:key="item.value"
autocomplete="off"
:label="item[o.setting.maplabel]"
:value="item[o.setting.mapValue]"
@ -187,6 +187,7 @@ function fetchFormData() {
:rows="o.editRows || 4"
type="textarea"
:placeholder="o.label"
class="elWidth"
@change="o.change"
/>
</div>
@ -195,11 +196,16 @@ function fetchFormData() {
v-model="o.valueE as boolean"
active-text="启用"
inactive-text="禁用"
class="elWidth"
@change="o.change"
/>
</div>
<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>
</el-form-item>
@ -215,3 +221,9 @@ function fetchFormData() {
</el-form>
</div>
</template>
<style>
.elWidth {
width: 100%;
min-width: 220px;
}
</style>

View File

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

View File

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