auxiliary.vue
3.09 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
<template>
<a-card title="辅助设置">
<a-form ref="formRef" :model="form" auto-label-width>
<!--辅助线-->
<a-form-item field="isShowLine" label="辅助线">
<a-checkbox v-model="form.isShowLine" @change="handleIsShowLine">是</a-checkbox>
</a-form-item>
<template v-if="form.isShowLine">
<!--添加辅助线-->
<a-form-item>
<a-button type="outline" @click="addGuide" :disabled="form.lineChildren.length>=4">添加辅助线</a-button>
<a-tooltip content="最多可添加4条" position="top" mini>
<icon-exclamation-circle class="guide-tip" />
</a-tooltip>
</a-form-item>
<!--横线竖向-->
<a-form-item v-if="form.lineChildren.length>0">
<a-row :gutter="[0, 8]">
<a-col v-for="(item,index) in form.lineChildren" :key="index" :span="24">
<a-radio-group v-model="item.lineDirection">
<a-radio v-for="(itemTwo, indexTwo) in datav_line_direction" :key="indexTwo" :value="itemTwo.value">{{itemTwo.label}}</a-radio>
</a-radio-group>
<a-input v-model="item.lineName" placeholder="辅助线名称" style="width: 160px;margin-right: 8px" />
<a-input v-model="item.lineValue" placeholder="值" style="width: 150px" />
<icon-close-circle-fill class="delete-icon" @click="handleDeleteLine(index)" />
</a-col>
</a-row>
</a-form-item>
</template>
<!--图例位置-->
<a-form-item field="legendPosition" label="图例位置">
<a-radio-group v-model="form.legendPosition">
<a-radio v-for="(item,index) in datav_legend_position" :key="index" :value="item.value">{{item.label}}</a-radio>
</a-radio-group>
</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_line_direction, datav_legend_position } = proxy?.useDict("datav_line_direction", "datav_legend_position");
// 辅助线
const formRef = ref<FormInstance>();
const form = ref({
isShowLine: false, //辅助线
legendPosition: 2, //图例位置(1上 2下 3左 4右)
lineChildren: []
});
// 添加辅助线
const addGuide = () => {
const newGuide = {
lineName: '',
lineValue: '',
lineDirection: 0
};
form.value.lineChildren.push(newGuide);
};
// 删除辅助线
const handleDeleteLine = (index: number) => {
form.value.lineChildren.splice(index,1);
};
// 是否显示辅助线
const handleIsShowLine = (val: any) => {
if(!val){
form.value.lineChildren = [];
}
};
defineExpose({
form,
formRef,
setForm(val:any){
// console.log(val, 'val')
if(!val.lineChildren){
val.lineChildren = [];
}
form.value = val;
}
});
</script>
<style lang="less" scoped>
.guide-tip{
color:var(--color-neutral-8);
cursor: pointer;
font-size: 20px;
margin-left: 10px;
}
.delete-icon{
font-size: 20px;
margin-left: 12px;
}
</style>