fix PointRuleDetail.vue style
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<template>
|
||||
<bottom-popup
|
||||
v-model="popupVisible"
|
||||
title="选择执行脚本"
|
||||
height="min(80vh, 48rem)"
|
||||
@left-button-click="close"
|
||||
@right-button-click="confirm"
|
||||
>
|
||||
<div class="tips orange">如需增加、调整规则请联系技术支持</div>
|
||||
<t-collapse
|
||||
v-if="availableScriptList.length"
|
||||
v-model="expandedScriptIdList"
|
||||
class="collapses"
|
||||
:expand-mutex="true"
|
||||
>
|
||||
<t-collapse-panel
|
||||
v-for="script in availableScriptList"
|
||||
:key="getScriptId(script)"
|
||||
:value="getScriptId(script)"
|
||||
class="collapse"
|
||||
placement="bottom"
|
||||
>
|
||||
<template #header>
|
||||
<t-checkbox
|
||||
:model-value="draftScriptId === getScriptId(script)"
|
||||
:label="getScriptName(script)"
|
||||
borderless
|
||||
@click.stop
|
||||
@change="selectScript(getScriptId(script))"
|
||||
/>
|
||||
</template>
|
||||
<div class="content">
|
||||
<markdown-view :content="script.description || '暂无脚本说明'" />
|
||||
</div>
|
||||
</t-collapse-panel>
|
||||
</t-collapse>
|
||||
<t-empty v-else description="暂无可选积分脚本" />
|
||||
</bottom-popup>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import { MarkdownView } from "timi-web";
|
||||
import type { GroovyScript } from "@/types/Point";
|
||||
|
||||
defineOptions({
|
||||
name: "PointRuleScriptPicker"
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: string;
|
||||
visible: boolean;
|
||||
scripts: GroovyScript[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [value: string];
|
||||
"update:visible": [value: boolean];
|
||||
}>();
|
||||
|
||||
const popupVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit("update:visible", value)
|
||||
});
|
||||
const availableScriptList = computed(() => props.scripts.filter(script => script.id));
|
||||
const draftScriptId = ref("");
|
||||
const expandedScriptIdList = ref<Array<string | number>>([]);
|
||||
|
||||
watch(() => props.visible, visible => {
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
draftScriptId.value = props.modelValue;
|
||||
expandedScriptIdList.value = props.modelValue ? [props.modelValue] : [];
|
||||
});
|
||||
|
||||
function getScriptId(script: GroovyScript): string {
|
||||
return script.id || "";
|
||||
}
|
||||
|
||||
function getScriptName(script: GroovyScript): string {
|
||||
return script.name || script.code || "未命名脚本";
|
||||
}
|
||||
|
||||
function selectScript(scriptId: string): void {
|
||||
if (scriptId && availableScriptList.value.some(script => script.id === scriptId)) {
|
||||
draftScriptId.value = scriptId;
|
||||
}
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
popupVisible.value = false;
|
||||
}
|
||||
|
||||
function confirm(): void {
|
||||
if (draftScriptId.value && availableScriptList.value.some(script => script.id === draftScriptId.value)) {
|
||||
emit("update:modelValue", draftScriptId.value);
|
||||
}
|
||||
close();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.tips {
|
||||
padding: .5rem;
|
||||
font-size: .75rem;
|
||||
text-align: center;
|
||||
}
|
||||
.collapses {
|
||||
border-top: 1px solid var(--td-component-border);
|
||||
|
||||
:deep(.t-cell) {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.collapse {
|
||||
|
||||
:deep(.t-collapse-panel__content) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 0 1rem 0 3.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
.script-description {
|
||||
color: #94a3b8;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user