파일 이식(0.31.1)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-for="(rowValue, rowIdx) in props.params.cells" :key="rowIdx" class="row gx-1 m-0 cell-sp">
|
||||
<template v-for="colValue of rowValue" :key="colValue.target">
|
||||
<div v-if="params.data[colValue.target] == null">?</div>
|
||||
<div
|
||||
v-else-if="colValue.iActionMap"
|
||||
v-b-tooltip.hover
|
||||
class="col"
|
||||
:title="colValue.iActionMap[params.data[colValue.target] as string ].info??''"
|
||||
>
|
||||
{{ colValue.iActionMap[params.data[colValue.target] as string ].name }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="colValue.converter"
|
||||
v-b-tooltip.hover
|
||||
class="col"
|
||||
:title="colValue.converter(params.data)[1] ?? ''"
|
||||
>
|
||||
{{ colValue.converter(params.data)[0] }}
|
||||
</div>
|
||||
<div v-else v-b-tooltip.hover class="col" :title="colValue.info ?? ''">
|
||||
{{params.data[colValue.target] as string}}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import type { GeneralListItemP2 } from "@/defs/API/Nation";
|
||||
import type { GameIActionInfo } from "@/defs/GameObj";
|
||||
import type { CellClassParams } from "ag-grid-community";
|
||||
|
||||
//제일 큰 타입 기준
|
||||
export type GridCellInfo = {
|
||||
iActionMap?: Record<string, GameIActionInfo>;
|
||||
info?: string;
|
||||
converter?: (value: GeneralListItemP2) => [string, string?];
|
||||
target: keyof GeneralListItemP2;
|
||||
};
|
||||
</script>
|
||||
<script lang="ts" setup>
|
||||
import type { PropType } from "vue";
|
||||
interface GenCellClassParams extends CellClassParams {
|
||||
data: GeneralListItemP2;
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
params: {
|
||||
type: Object as PropType<
|
||||
GenCellClassParams & {
|
||||
cells: GridCellInfo[][];
|
||||
}
|
||||
>,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<span v-if="props.params.value == null">?</span>
|
||||
<span v-else-if="params.iActionMap" v-b-tooltip.hover :title="params.iActionMap[props.params.value].info ?? ''">{{
|
||||
params.iActionMap[props.params.value].name
|
||||
}}</span>
|
||||
<span v-else-if="params.info" v-b-tooltip.hover :title="params.info">{{ displayValue }}</span>
|
||||
<span v-else>{{ displayValue }}</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { GameIActionInfo } from "@/defs/GameObj";
|
||||
import type { ValueFormatterParams } from "ag-grid-community";
|
||||
import { isNumber, isString } from "lodash";
|
||||
import { ref, watch, type PropType } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
params: {
|
||||
type: Object as PropType<
|
||||
ValueFormatterParams & {
|
||||
info?: string;
|
||||
iActionMap?: Record<string, GameIActionInfo>;
|
||||
}
|
||||
>,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
function convertValue(value: unknown): string {
|
||||
if (isString(value)) {
|
||||
return value;
|
||||
}
|
||||
if (isNumber(value)) {
|
||||
return value.toLocaleString();
|
||||
}
|
||||
return `${value}`;
|
||||
}
|
||||
|
||||
const displayValue = ref<string>(convertValue(props.params.value));
|
||||
watch(
|
||||
() => props.params,
|
||||
(newParams) => {
|
||||
displayValue.value = convertValue(newParams.value);
|
||||
}
|
||||
);
|
||||
</script>
|
||||
Reference in New Issue
Block a user