baseSetting.vue
3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
<a-card title="基础设置">
<a-form ref="formRef" :rules="rules" :model="form" auto-label-width>
<!--模块名称-->
<a-row :gutter="[12,0]">
<!-- <a-col :span="18">-->
<a-form-item field="cardName" label="卡片名称" :validate-trigger="['change','input']">
<a-input v-model="form.cardName" :maxLength="20" placeholder="请输入字母或数字,最多20个字符" />
</a-form-item>
<!-- </a-col>-->
<!-- <a-col :span="6">-->
<!-- <!–智能拼接–>-->
<!-- <a-checkbox v-model="form.isSplit">智能拼接</a-checkbox>-->
<!-- </a-col>-->
</a-row>
<!--时间维度-->
<!-- <a-form-item field="dateDim" label="时间维度">-->
<!-- <a-select v-model="form.dateDim" placeholder="请选择" allow-clear>-->
<!-- <a-option :value="item.value" v-for="(item,index) in sys_config_page_x" :key="item.id">{{item.label}}</a-option>-->
<!-- </a-select>-->
<!-- </a-form-item>-->
<a-form-item field="dateDim" label="时间维度">
<a-row :gutter="[0,16]">
<!--时间维度-->
<a-col :span="24">
<a-select v-model="form.dateDim" placeholder="请选择" allow-clear style="width: 400px" @change="handleDateDim">
<!--单值-->
<template v-if="defaultVar.chartType==14">
<a-option v-for="(item,index) in datav_date_dim"
:value="Number(item.value)" :key="index">
{{ item.label }}
</a-option>
</template>
<!--其他-->
<template v-else>
<a-option v-for="(item,index) in datav_date_dim" v-show="item.value!=100"
:value="Number(item.value)" :key="index">
{{ item.label }}
</a-option>
</template>
</a-select>
</a-col>
<!--具体时间-->
<a-col v-show="[70].includes(form.dateDim)" :span="24">
<a-radio-group v-model="form.secondDateDim">
<a-radio v-for="(item,index) in datav_date_second_dim" :key="index" :value='Number(item.value)'>
{{ item.label }}
</a-radio>
</a-radio-group>
</a-col>
</a-row>
</a-form-item>
</a-form>
</a-card>
</template>
<script setup lang="ts">
import {getCurrentInstance, ref} from "vue";
import {FormInstance} from "@arco-design/web-vue/es/form";
const proxy = getCurrentInstance()?.appContext.config.globalProperties;
const {datav_date_dim, datav_date_second_dim} = proxy?.useDict("datav_date_dim", "datav_date_second_dim");
const formRef = ref<any>({});
const rules: any = {
cardName: [
{
required: true,
message: '请输入卡片名称'
}
]
};
const props = defineProps({
defaultVar: {
type: Object,
default: {}
}
});
const emit = defineEmits(["handleDateDim"]);
// 初始化数据配置
const initDataConfig = () => {
return {
cardName: '',
dateDim: 70,
secondDateDim: 60,
}
};
// 初始化form
const form = ref<any>(initDataConfig());
// 日期
const handleDateDim = (val:any) => {
emit("handleDateDim", val)
}
// 校验
const validateForm = async() => {
try {
const valid = await formRef.value.validate();
return {
valid
}
} catch (error) {
console.error('验证时发生错误', error);
}
};
defineExpose({
form,
formRef,
validateForm,
setForm:(val:any)=>{
if (Object.keys(val).length === 0) {
form.value = initDataConfig();
} else {
form.value = val;
}
}
});
</script>
<style scoped lang="less">
</style>