修改组件

This commit is contained in:
zpc 2024-07-29 13:51:35 +08:00
parent f21e0bb29a
commit 67cc311bdc
4 changed files with 168 additions and 24 deletions

View File

@ -104,6 +104,7 @@ declare module 'vue' {
LineChartSingle: typeof import('./core/components/charts/LineChartSingle.vue')['default']
MdEditorShowCode: typeof import('./core/components/MdEditorShowCode.vue')['default']
PageContainer: typeof import('./core/components/PageContainer.vue')['default']
PersonalityCharacters: typeof import('./core/components/characters/personality-characters.vue')['default']
PieChart: typeof import('./core/components/charts/PieChart.vue')['default']
Redirect: typeof import('./core/components/Redirect.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']

View File

@ -0,0 +1,144 @@
<script setup lang="ts">
import AppDictionaryCache from "@/core/utils/AppDictionaryCache";
import T_Character_Personality_RelationService from "@/services/apps/T_Character_Personality_Relations/T_Character_Personality_RelationService";
//
const props = withDefaults(
defineProps<{
record: any;
color: string;
}>(),
{
color: "blue",
}
);
const emits = defineEmits<{
(e: "del"): void;
}>();
const open = ref<boolean>(false);
const showModal = async () => {
const _data = await AppDictionaryCache.appDictionaryTypesCache.getDataList();
const mData = [];
const keys = [];
_data.forEach((item, index) => {
const data = {
key: item.value,
title: item.name,
description: item.code,
};
// console.log(props.record.personas.filter(it=> it.value == item.value));
if (
props.record.personas.filter((it) => it.value == item.value).length > 0
) {
console.log("添加", data);
keys.push(data.key);
}
// if()
mData.push(data);
});
console.log(props.record);
mockData.value = mData;
targetKeys.value = keys;
console.log(mockData.value, targetKeys.value);
open.value = true;
};
const handleOk = async (e: MouseEvent) => {
console.log(e);
console.log(targetKeys.value);
await T_Character_Personality_RelationService.setCharacterPersonality(
props.record.id,
targetKeys.value
);
props.personas = mockData.value
.filter((it) => targetKeys.value.includes(it.value))
.map((item) => {
return {
name: item.title,
code: item.description,
value: item.key,
};
});
// setCharacterPersonality
open.value = false;
};
interface MockData {
key: number;
title: string;
description: string;
chosen: boolean;
}
// {
// "page": 1,
// "size": 50,
// "search": {},
// "searchSort": []
// }
// T_Character_Personality_RelationService.findList(1,999,{},{});
const mockData = ref<MockData[]>([]);
const targetKeys = ref<number[]>([]);
const handleChange = (
keys: number[],
direction: string,
moveKeys: string[]
) => {
console.log(keys, direction, moveKeys);
};
const filterOption = (inputValue: string, option: MockData) => {
return option.title.indexOf(inputValue) > -1||option.description.indexOf(inputValue) > -1;
};
</script>
<template>
<a-button
type="primary"
size="small"
style="width: 60px; height: 22px; font-size: 12px"
@click="showModal"
>性格管理</a-button
>
<a-modal
v-model:open="open"
title="性格管理"
@ok="handleOk"
width="800px"
:maskClosable="false"
>
<a-transfer
v-model:target-keys="targetKeys"
:data-source="mockData"
:filter-option="filterOption"
show-search
:list-style="{
width: '300px',
height: '300px',
}"
@change="handleChange"
>
<template #footer="{ direction }">
<a-button
v-if="direction === 'left'"
size="small"
style="float: left; margin: 5px"
type="primary"
>
添加性格
</a-button>
</template>
<template #render="item">
<span class="custom-item"
>{{ item.title }} - {{ item.description }}</span
>
</template>
</a-transfer>
</a-modal>
</template>
<style lang="less" scoped></style>

View File

@ -1,6 +1,7 @@
<script setup lang="ts">
import AppDictionaryCache from "@/core/utils/AppDictionaryCache";
import T_Character_Personality_RelationService from "@/services/apps/T_Character_Personality_Relations/T_Character_Personality_RelationService";
//
const props = withDefaults(
defineProps<{
record: any;
@ -60,7 +61,7 @@ const handleOk = async (e: MouseEvent) => {
value: item.key,
};
});
// setCharacterPersonality
open.value = false;
};
@ -82,27 +83,7 @@ interface MockData {
const mockData = ref<MockData[]>([]);
const targetKeys = ref<number[]>([]);
// onMounted(() => {
// getMock();
// });
const getMock = () => {
const keys = [];
const mData = [];
for (let i = 0; i < 20; i++) {
const data = {
key: i.toString(),
title: `content${i + 1}`,
description: `description of content${i + 1}`,
chosen: Math.random() * 2 > 1,
};
if (data.chosen) {
keys.push(data.key);
}
mData.push(data);
}
mockData.value = mData;
targetKeys.value = keys;
};
const handleChange = (
keys: number[],
direction: string,
@ -110,6 +91,11 @@ const handleChange = (
) => {
console.log(keys, direction, moveKeys);
};
const filterOption = (inputValue: string, option: MockData) => {
return option.title.indexOf(inputValue) > -1||option.description.indexOf(inputValue) > -1;
};
</script>
<template>
<a-button
@ -117,11 +103,11 @@ const handleChange = (
size="small"
style="width: 60px; height: 22px; font-size: 12px"
@click="showModal"
>添加性格</a-button
>分类管理</a-button
>
<a-modal
v-model:open="open"
title="性格管理"
title="分类管理"
@ok="handleOk"
width="800px"
:maskClosable="false"
@ -129,12 +115,24 @@ const handleChange = (
<a-transfer
v-model:target-keys="targetKeys"
:data-source="mockData"
:filter-option="filterOption"
show-search
:list-style="{
width: '300px',
height: '300px',
}"
@change="handleChange"
>
<template #footer="{ direction }">
<a-button
v-if="direction === 'left'"
size="small"
style="float: left; margin: 5px"
type="primary"
>
添加性格
</a-button>
</template>
<template #render="item">
<span class="custom-item"
>{{ item.title }} - {{ item.description }}</span

View File

@ -584,6 +584,7 @@ console.log(visibility,response);
>
<a-tag style="cursor: pointer" color="#f50">删除</a-tag>
</a-popconfirm>
<personality-characters v-if="power.update" :record="record" />
<types-characters v-if="power.update" :record="record" />
</template>
</a-table-column>