mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 00:02:51 +08:00
perf: 格式化表格组件代码
This commit is contained in:
parent
5122ecf862
commit
efbeeff0c7
@ -24,7 +24,7 @@ export const option = {
|
|||||||
borderColor: 'black',
|
borderColor: 'black',
|
||||||
borderStyle: 'solid'
|
borderStyle: 'solid'
|
||||||
},
|
},
|
||||||
inputShow:"none"
|
inputShow: 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||||
|
@ -2,10 +2,15 @@
|
|||||||
<collapse-item name="表格设置" :expanded="true">
|
<collapse-item name="表格设置" :expanded="true">
|
||||||
<setting-item-box :alone="true" name="对齐方式">
|
<setting-item-box :alone="true" name="对齐方式">
|
||||||
<setting-item :alone="true">
|
<setting-item :alone="true">
|
||||||
<n-select v-model:value="optionData.align" size="small"
|
<n-select
|
||||||
|
v-model:value="optionData.align"
|
||||||
|
size="small"
|
||||||
:options="[
|
:options="[
|
||||||
{label:'靠左',value:'left'},{label:'居中',value:'center'},{label:'靠右',value:'right'}
|
{ label: '靠左', value: 'left' },
|
||||||
]" />
|
{ label: '居中', value: 'center' },
|
||||||
|
{ label: '靠右', value: 'right' }
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box :alone="false" name="分页设置">
|
<setting-item-box :alone="false" name="分页设置">
|
||||||
@ -13,8 +18,7 @@
|
|||||||
<n-input-number v-model:value="optionData.pagination.page" size="small" placeholder="字体大小"></n-input-number>
|
<n-input-number v-model:value="optionData.pagination.page" size="small" placeholder="字体大小"></n-input-number>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<setting-item name="分页" :alone="true">
|
<setting-item name="分页" :alone="true">
|
||||||
<n-select v-model:value="optionData.pagination.pageSize" size="small"
|
<n-select v-model:value="optionData.pagination.pageSize" size="small" :options="page" />
|
||||||
:options="page" />
|
|
||||||
</setting-item>
|
</setting-item>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box :alone="false" name="表格数据">
|
<setting-item-box :alone="false" name="表格数据">
|
||||||
@ -26,55 +30,57 @@
|
|||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box :alone="false" name="表格样式">
|
<setting-item-box :alone="false" name="表格样式">
|
||||||
<SettingItem name="显示边框" :alone="true">
|
<SettingItem name="显示边框" :alone="true">
|
||||||
<n-select v-model:value="(optionData as any).style.border" size="small"
|
<n-select v-model:value="(optionData as any).style.border" size="small" :options="borderFlag" />
|
||||||
:options="borderFlag" />
|
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem name="底部边框" :alone="true">
|
<SettingItem name="底部边框" :alone="true">
|
||||||
<n-select v-model:value="(optionData as any).style.bottomBordered" size="small"
|
<n-select
|
||||||
:options="bottom_borderedFlag" />
|
v-model:value="(optionData as any).style.bottomBordered"
|
||||||
|
size="small"
|
||||||
|
:options="bottom_borderedFlag"
|
||||||
|
/>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem name="列分割线" :alone="true">
|
<SettingItem name="列分割线" :alone="true">
|
||||||
<n-select v-model:value="(optionData as any).style.singleLine" size="small"
|
<n-select v-model:value="(optionData as any).style.singleLine" size="small" :options="columnFlag" />
|
||||||
:options="columnFlag" />
|
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem name="行分割线" :alone="true">
|
<SettingItem name="行分割线" :alone="true">
|
||||||
<n-select v-model:value="(optionData as any).style.singleColumn" size="small"
|
<n-select v-model:value="(optionData as any).style.singleColumn" size="small" :options="lineFlag" />
|
||||||
:options="lineFlag" />
|
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem name="斑马条纹" :alone="true">
|
<SettingItem name="斑马条纹" :alone="true">
|
||||||
<n-select v-model:value="(optionData as any).style.striped" size="small"
|
<n-select v-model:value="(optionData as any).style.striped" size="small" :options="stripedFlag" />
|
||||||
:options="stripedFlag" />
|
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<setting-item name="字体大小" :alone="true">
|
<setting-item name="字体大小" :alone="true">
|
||||||
<n-input-number v-model:value="optionData.style.fontSize" :min="12" size="small" placeholder="字体大小"></n-input-number>
|
<n-input-number
|
||||||
|
v-model:value="optionData.style.fontSize"
|
||||||
|
:min="12"
|
||||||
|
size="small"
|
||||||
|
placeholder="字体大小"
|
||||||
|
></n-input-number>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<setting-item name="边框宽度" :alone="true">
|
<setting-item name="边框宽度" :alone="true">
|
||||||
<n-input-number v-model:value="optionData.style.borderWidth" :min="0" size="small" placeholder="字体大小"></n-input-number>
|
<n-input-number
|
||||||
|
v-model:value="optionData.style.borderWidth"
|
||||||
|
:min="0"
|
||||||
|
size="small"
|
||||||
|
placeholder="字体大小"
|
||||||
|
></n-input-number>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<setting-item name="边框颜色" :alone="true">
|
<setting-item name="边框颜色" :alone="true">
|
||||||
<n-color-picker
|
<n-color-picker size="small" :modes="['rgb']" v-model:value="optionData.style.borderColor"></n-color-picker>
|
||||||
size="small"
|
|
||||||
:modes="['rgb']"
|
|
||||||
v-model:value="optionData.style.borderColor"
|
|
||||||
></n-color-picker>
|
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<setting-item name="边框样式" :alone="true">
|
<setting-item name="边框样式" :alone="true">
|
||||||
<n-select v-model:value="optionData.style.borderStyle" size="small"
|
<n-select v-model:value="optionData.style.borderStyle" size="small" :options="borderStyleFlag" />
|
||||||
:options="borderStyleFlag" />
|
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<SettingItem name="表格搜索" :alone="true">
|
<SettingItem name="表格搜索" :alone="true">
|
||||||
<n-select v-model:value="optionData.inputShow" size="small"
|
<n-select v-model:value="optionData.inputShow" size="small" :options="inputSelect" />
|
||||||
:options="inputSelect" />
|
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
</collapse-item>
|
</collapse-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType,watch,ref } from 'vue';
|
import { PropType, watch, ref } from 'vue'
|
||||||
import { option } from './config';
|
import { option } from './config'
|
||||||
|
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||||
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting';
|
|
||||||
|
|
||||||
const page = [
|
const page = [
|
||||||
{ label: '2', value: 2 },
|
{ label: '2', value: 2 },
|
||||||
@ -120,19 +126,19 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const header = ref();
|
const header = ref()
|
||||||
const median = ref<string[]>([])
|
const median = ref<string[]>([])
|
||||||
props.optionData.dataset.dimensions.forEach(item => {
|
props.optionData.dataset.dimensions.forEach(item => {
|
||||||
median.value.push(item.title);
|
median.value.push(item.title)
|
||||||
})
|
})
|
||||||
|
|
||||||
//转string
|
//转string
|
||||||
watch(
|
watch(
|
||||||
() => props.optionData,
|
() => props.optionData,
|
||||||
() => {
|
() => {
|
||||||
median.value = [];
|
median.value = []
|
||||||
props.optionData.dataset.dimensions.forEach(item => {
|
props.optionData.dataset.dimensions.forEach(item => {
|
||||||
median.value.push(item.title);
|
median.value.push(item.title)
|
||||||
})
|
})
|
||||||
header.value = median.value.toString()
|
header.value = median.value.toString()
|
||||||
},
|
},
|
||||||
@ -152,5 +158,4 @@ watch([header], ([headerNew], [headerOld]) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-tables-basic">
|
<div class="go-tables-basic">
|
||||||
<n-input v-model:value="inputData"
|
<n-input
|
||||||
|
v-model:value="inputData"
|
||||||
placeholder="请输入信息"
|
placeholder="请输入信息"
|
||||||
:style="`display:${option.inputShow}`"
|
:style="`display: ${inputShow}`"
|
||||||
style="margin-bottom: 5px;float:right;width: 240px" />
|
style="margin-bottom: 5px; float: right; width: 240px"
|
||||||
<n-data-table :style="`
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<n-icon :component="SearchIcon" />
|
||||||
|
</template>
|
||||||
|
</n-input>
|
||||||
|
<n-data-table
|
||||||
|
:style="`
|
||||||
width: ${w}px;
|
width: ${w}px;
|
||||||
height: ${h}px;
|
height: ${h}px;
|
||||||
font-size: ${option.style.fontSize}px;
|
font-size: ${option.style.fontSize}px;
|
||||||
@ -26,8 +33,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed,PropType, toRefs, watch, reactive,ref } from 'vue';
|
import { computed, PropType, toRefs, watch, reactive, ref } from 'vue'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import { icon } from '@/plugins'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
@ -36,8 +44,10 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { SearchIcon } = icon.ionicons5
|
||||||
|
|
||||||
//查询字段
|
//查询字段
|
||||||
const inputData = ref('');
|
const inputData = ref('')
|
||||||
//前台过滤
|
//前台过滤
|
||||||
const filterData = computed(() => {
|
const filterData = computed(() => {
|
||||||
return option?.dataset?.source?.filter((item: any) => {
|
return option?.dataset?.source?.filter((item: any) => {
|
||||||
@ -47,12 +57,8 @@ const filterData = computed(()=>{
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const {
|
const { align, pagination, inputShow } = toRefs(props.chartConfig.option)
|
||||||
align,
|
|
||||||
pagination
|
|
||||||
} = toRefs(
|
|
||||||
props.chartConfig.option
|
|
||||||
)
|
|
||||||
pagination.value.onChange = (page: number) => {
|
pagination.value.onChange = (page: number) => {
|
||||||
pagination.value.page = page
|
pagination.value.page = page
|
||||||
}
|
}
|
||||||
@ -61,31 +67,29 @@ const { w, h } = toRefs(props.chartConfig.attr)
|
|||||||
|
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
dataset: props.chartConfig.option.dataset,
|
dataset: props.chartConfig.option.dataset,
|
||||||
style : props.chartConfig.option.style,
|
style: props.chartConfig.option.style
|
||||||
inputShow : props.chartConfig.option.inputShow
|
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData: any) => {
|
(newData: any) => {
|
||||||
option.dataset = newData;
|
option.dataset = newData
|
||||||
option?.dataset?.dimensions?.forEach((header: any) => {
|
option?.dataset?.dimensions?.forEach((header: any) => {
|
||||||
//对齐方式更新
|
header.align = align.value
|
||||||
header.align = align.value;
|
})
|
||||||
});
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include go('tables-basic') {
|
@include go('tables-basic') {
|
||||||
margin: 0 !important;
|
display: flex;
|
||||||
padding: 0 !important;
|
flex-direction: column;
|
||||||
|
gap: 15px;
|
||||||
|
align-items: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user