|
|
@@ -108,7 +108,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { getCurrentInstance, reactive, onMounted } from "vue";
|
|
|
+import { getCurrentInstance, reactive, ref, onMounted } from "vue";
|
|
|
import { useStore } from "vuex";
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
|
|
|
@@ -139,6 +139,58 @@ const table = reactive({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+const defaultThemeOptions = [
|
|
|
+ { label: "金色", value: "gold" },
|
|
|
+ { label: "银色", value: "silver" },
|
|
|
+ { label: "蓝色", value: "blue" },
|
|
|
+];
|
|
|
+const themeOptions = ref<Array<{ label: string; value: string }>>([...defaultThemeOptions]);
|
|
|
+const themeMap = ref<Record<string, string>>(
|
|
|
+ defaultThemeOptions.reduce((acc, cur) => {
|
|
|
+ acc[cur.value] = cur.label;
|
|
|
+ return acc;
|
|
|
+ }, {} as Record<string, string>)
|
|
|
+);
|
|
|
+
|
|
|
+const fillThemeMap = (options: Array<{ label: string; value: string }>) => {
|
|
|
+ themeMap.value = options.reduce((acc, cur) => {
|
|
|
+ if (cur?.value) {
|
|
|
+ acc[cur.value] = cur.label;
|
|
|
+ }
|
|
|
+ return acc;
|
|
|
+ }, {} as Record<string, string>);
|
|
|
+};
|
|
|
+
|
|
|
+const queryTheme = async () => {
|
|
|
+ try {
|
|
|
+ const { res } = await proxy.$interfaceEntry.vip.QueryDictList({
|
|
|
+ dictType: "VipColor",
|
|
|
+ });
|
|
|
+ const data = res.data || {};
|
|
|
+ const list =
|
|
|
+ data.Data ||
|
|
|
+ data.data ||
|
|
|
+ data.result ||
|
|
|
+ data.list ||
|
|
|
+ [];
|
|
|
+
|
|
|
+ if (Array.isArray(list) && list.length) {
|
|
|
+ const parsed = list.map((item: any) => ({
|
|
|
+ label: item.dictLabel,
|
|
|
+ value: item.dictValue,
|
|
|
+ }));
|
|
|
+ themeOptions.value = parsed;
|
|
|
+ fillThemeMap(parsed);
|
|
|
+ } else {
|
|
|
+ themeOptions.value = [...defaultThemeOptions];
|
|
|
+ fillThemeMap(defaultThemeOptions);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ themeOptions.value = [...defaultThemeOptions];
|
|
|
+ fillThemeMap(defaultThemeOptions);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
/* 获取表格数据 */
|
|
|
const getTableData = async (e: any = undefined) => {
|
|
|
!e && (table.page.PIndex = 1);
|
|
|
@@ -173,12 +225,13 @@ const getTableData = async (e: any = undefined) => {
|
|
|
table.data = list.map((item: any) => {
|
|
|
// 后端返回的字段可能是 IdLevelIcon(大写)或 idLevelIcon(小写)
|
|
|
const iconPath = item.IdLevelIcon || item.idLevelIcon || "";
|
|
|
+ const themeValue = item.Theme || item.theme;
|
|
|
|
|
|
return {
|
|
|
levelCode: item.IdLevelCode || item.idLevelCode,
|
|
|
levelIconLabel: iconPath,
|
|
|
levelName: item.IdLevelName || item.idLevelName,
|
|
|
- theme: item.Theme || item.theme,
|
|
|
+ theme: themeMap.value[themeValue] || themeValue || "-",
|
|
|
statusLabel: (item.Status || item.status) === 1 ? "上架" : "下架",
|
|
|
// 保存原始数据,编辑时可能需要
|
|
|
rawData: item,
|
|
|
@@ -234,7 +287,8 @@ const handleEdit = (row: any) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+onMounted(async () => {
|
|
|
+ await queryTheme();
|
|
|
getTableData();
|
|
|
});
|
|
|
</script>
|