|
|
@@ -1,7 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import CustomTable from '@/components/table/CustomTable.vue'
|
|
|
import { useRequest } from '@/hooks/useRequest.ts'
|
|
|
-import { useTableStore } from '@/stores/useTable.ts'
|
|
|
+import { useCommonStore } from '@/stores/useCommon.ts'
|
|
|
|
|
|
import type { ReqConfig } from '@/types/dataAnalysis.ts'
|
|
|
import type { ResponseInfo } from '@/types/res.ts'
|
|
|
@@ -37,11 +37,25 @@ interface TableConfig {
|
|
|
tableToolsConfig: TableToolsConfig
|
|
|
}
|
|
|
|
|
|
-type GameMap = Map<string, string>
|
|
|
-
|
|
|
const { AllApi } = useRequest()
|
|
|
-const { allGameInfo } = useTableStore()
|
|
|
-const gameMap: GameMap = new Map(allGameInfo.map((item) => [item.gid, item.gameName]))
|
|
|
+const { gameInfoList } = useCommonStore()
|
|
|
+let gameInfo: Map<string, string> = new Map()
|
|
|
+
|
|
|
+const allGid: string[] = []
|
|
|
+
|
|
|
+const updateGameInfo = () => {
|
|
|
+ gameInfo = new Map<string, string>(
|
|
|
+ gameInfoList.flatMap((platform) =>
|
|
|
+ platform.gidList.map((item) => [item.gid, item.gameName] as [string, string])
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ allGid.splice(
|
|
|
+ 0,
|
|
|
+ allGid.length,
|
|
|
+ ...gameInfoList.flatMap((item) => item.gidList).map((item) => item.gid)
|
|
|
+ )
|
|
|
+}
|
|
|
|
|
|
const memberTableRef = ref<CustomTableType>()
|
|
|
|
|
|
@@ -70,7 +84,7 @@ const memberForm = ref<MemberInfo>({
|
|
|
})
|
|
|
|
|
|
const getGameName = (gid: string) => {
|
|
|
- return gameMap.get(gid) || '未知游戏'
|
|
|
+ return gameInfo.get(gid) || '未知游戏'
|
|
|
}
|
|
|
|
|
|
// 表格配置
|
|
|
@@ -193,7 +207,7 @@ const editMember = (row: any) => {
|
|
|
const permission: string[] = [...row.permission]
|
|
|
|
|
|
if (isAdmin.value || row.permission[0] === 'all') {
|
|
|
- const allGid = allGameInfo.map((item) => item.gid)
|
|
|
+ // const allGid = gameInfoList.map((item) => item.gid)
|
|
|
permission.splice(0, permission.length, ...allGid)
|
|
|
isCheckAllPermission.value = true
|
|
|
console.log('执行')
|
|
|
@@ -230,7 +244,7 @@ const saveMember = async () => {
|
|
|
}
|
|
|
|
|
|
// 特殊处理一下全选的情况
|
|
|
- if (params.permission.length === allGameInfo.length) {
|
|
|
+ if (params.permission.length === allGid.length) {
|
|
|
params.permission = ['all']
|
|
|
}
|
|
|
|
|
|
@@ -291,10 +305,8 @@ const closePasswordDialog = () => {
|
|
|
|
|
|
const isCheckAllPermission = ref<boolean>(false)
|
|
|
const handleCheckAll = (isAllCheck: CheckboxValueType) => {
|
|
|
- console.log(isAllCheck)
|
|
|
- console.log(memberForm.value)
|
|
|
if (isAllCheck) {
|
|
|
- memberForm.value.permission = allGameInfo.map((item) => item.gid)
|
|
|
+ memberForm.value.permission = [...allGid]
|
|
|
} else {
|
|
|
memberForm.value.permission = []
|
|
|
}
|
|
|
@@ -303,9 +315,20 @@ const handleCheckAll = (isAllCheck: CheckboxValueType) => {
|
|
|
watch(
|
|
|
() => memberForm.value.permission,
|
|
|
(val: string[]) => {
|
|
|
- isCheckAllPermission.value = val.length === allGameInfo.length
|
|
|
+ isCheckAllPermission.value = val.length === allGid.length
|
|
|
+ },
|
|
|
+ {
|
|
|
+ deep: true
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => gameInfoList,
|
|
|
+ () => {
|
|
|
+ updateGameInfo()
|
|
|
},
|
|
|
{
|
|
|
+ immediate: true,
|
|
|
deep: true
|
|
|
}
|
|
|
)
|
|
|
@@ -377,10 +400,10 @@ watch(
|
|
|
</el-checkbox>
|
|
|
</template>
|
|
|
<el-option
|
|
|
- v-for="item in allGameInfo"
|
|
|
- :key="item.gid"
|
|
|
- :label="item.gameName"
|
|
|
- :value="item.gid"
|
|
|
+ v-for="[gid, gameName] of gameInfo"
|
|
|
+ :key="gid"
|
|
|
+ :label="gameName"
|
|
|
+ :value="gid"
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|