123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- <template>
- <div class="components-view">
- <el-affix :offset="100" style="width: 90px; float: right">
- <el-menu @select="onSelectBlock">
- <el-menu-item index="elFormRef">ElForm</el-menu-item>
- <el-menu-item index="epFormRef">EPForm</el-menu-item>
- <el-menu-item index="epFormRef1">InlineForm</el-menu-item>
- <el-menu-item index="epTableRef">EPTable</el-menu-item>
- <el-menu-item index="eChartsRef">E-Charts</el-menu-item>
- </el-menu>
- </el-affix>
- <div ref="elFormRef" class="example-block">
- <h3 class="example-title">ElForm</h3>
- <el-form ref="elFormRef" :model="formModel" :rules="forRules">
- <el-form-item prop="mainQuestion" label="Input">
- <el-input v-model="formModel.mainQuestion"></el-input>
- </el-form-item>
- <el-form-item prop="person" label="Input">
- <el-input v-model="formModel.person"></el-input>
- </el-form-item>
- <el-row>
- <el-col :span="12">
- <el-form-item prop="separate" label="Input">
- <el-input v-model="formModel.separate"></el-input>
- </el-form-item>
- <el-col :span="10">1231231</el-col>
- </el-col>
- <el-col :span="12">
- <el-form-item prop="day" label="Input">
- <el-input v-model="formModel.day"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <div ref="epFormRef" class="example-block">
- <h3 class="example-title">Form</h3>
- <div class="flex items-center example-title">
- <el-button-group>
- <el-button v-for="(_, K) in formConfig" :key="K" type="primary" @click="changeFormConfig(K)">
- {{ K }}
- </el-button>
- </el-button-group>
- </div>
- <base-form
- ref="baseFormRef"
- v-bind="form"
- :items="items"
- :model="formModel"
- :rules="forRules"
- :label-width="'110px'"
- >
- </base-form>
- </div>
- <div ref="epFormRef1" class="example-block">
- <h3 class="example-title">InlineForm</h3>
- <base-form v-bind="form" :items="inlineItems" :model="formModel" size="small" :label-width="'88px'">
- <template #form-item-cao-zuo-col>
- <el-button type="primary">132</el-button>
- </template>
- </base-form>
- </div>
- <div ref="epTableRef" class="example-block">
- <h3 class="example-title">Table</h3>
- <base-table
- ref="baseTableRef"
- height="30vw"
- :data="data"
- :columns="columns"
- highlight-current-row
- @refresh="refresh"
- @current-change="onCurrentChange"
- @row-dblclick="onDbClick"
- >
- <template #column-header-a="s">
- <button>{{ parseFloat('0.0003') }}</button>
- <button>{{ s.row }}</button>
- </template>
- <template #column-7="{ row }">
- <button>{{ row }}</button>
- </template>
- <template #expand="scope">
- <div>{{ scope }}</div>
- </template>
- </base-table>
- </div>
- <div ref="eChartsRef" class="example-block">
- <h3 class="example-title">Echarts</h3>
- <vue-e-charts class="chart-box" :option="option"></vue-e-charts>
- </div>
- </div>
- </template>
- <script setup lang="tsx" name="ComponentsView">
- import {
- toRefs,
- reactive,
- ref,
- shallowReactive,
- shallowRef,
- watch,
- watchEffect,
- getCurrentInstance,
- computed,
- unref,
- } from 'vue'
- import VueECharts from 'vue-echarts'
- import useVueECharts from '@/hooks/useVueECharts'
- import {
- ElForm,
- ElFormItem,
- ElInput,
- ElRow,
- ElCol,
- ElAffix,
- ElMenu,
- ElMenuItem,
- ElButton,
- ElButtonGroup,
- } from 'element-plus'
- import BaseTable from '@/components/element/BaseTable.vue'
- import BaseForm from '@/components/element/BaseForm.vue'
- import useFetch from '@/hooks/useFetch'
- import useVW from '@/hooks/useVW'
- import type { EpTableProps, EpFormProps } from 'global-type'
- const onCurrentChange = (...args: any) => {
- console.log(...args)
- }
- const onDbClick = (...args: any) => {
- console.log(...args)
- }
- const instance = getCurrentInstance()
- function onSelectBlock(index: string) {
- const dom = instance?.refs[index]
- if (dom) {
- ;(dom as HTMLElement).scrollIntoView(true)
- }
- }
- /** Button start */
- /** Button end */
- const { fetch, loading, cancel, error } = useFetch('userLogin')
- /** form start */
- const formModel = reactive({
- subject: void 0,
- mainQuestion: void 0,
- separate: void 0,
- publish: true,
- person: 5,
- day: 8,
- type: [],
- checkBox: [],
- })
- const items: EpFormProps<typeof formModel>['items'] = [
- {
- rowKey: 'row-1',
- label: '科目',
- slotType: 'select',
- prop: 'subject',
- slot: {
- placeholder: '科目代码-科目名称',
- optionGroup: {
- 'group-1': {
- label: 'group-1',
- },
- 'group-2': {
- label: 'group-2',
- },
- },
- options: [
- {
- groupKey: 'group-1',
- value: 1,
- label: 'label-1',
- },
- {
- groupKey: 'group-2',
- value: 2,
- label: 'label-2',
- },
- {
- value: 3,
- label: 'label-3',
- },
- {
- value: 4,
- label: 'label-4',
- },
- ],
- },
- colProp: {
- span: 6,
- },
- },
- {
- rowKey: 'row-1',
- label: '大题',
- slotType: 'select',
- prop: 'mainQuestion',
- slot: {
- placeholder: '大题号-大题名称',
- options: [
- { label: '大题一-小题一', value: '1-1' },
- { label: '大题一-小题二', value: '1-2' },
- ],
- },
- colProp: {
- offset: 2,
- span: 6,
- },
- },
- {
- rowKey: 'row-2',
- label: '分隔符',
- slotType: 'input',
- prop: 'separate',
- slot: {},
- colProp: {
- span: 6,
- },
- },
- {
- rowKey: 'row-2',
- label: '导入同时发布任务',
- slotType: 'select',
- prop: 'publish',
- slot: {
- placeholder: ' 这是一个inputNumber框',
- options: [
- { label: '是', value: true },
- { label: '否', value: false },
- ],
- },
- colProp: {
- offset: 2,
- span: 6,
- },
- },
- {
- rowKey: 'row-3',
- label: '每包打包人数',
- slotType: 'input',
- prop: 'person',
- slot: {},
- colProp: {
- span: 6,
- },
- },
- {
- rowKey: 'row-3',
- label: '计划评卷天数',
- prop: 'day',
- slotType: 'inputNumber',
- slot: {
- step: 1,
- stepStrictly: true,
- },
- itemDescription: {
- requiredAsterisk: true,
- description: '系统将按各省考生平均分配到计划评卷天数中,确保各天的评卷进度一致',
- },
- colProp: {
- offset: 2,
- span: 6,
- },
- },
- {
- rowKey: 'row-4',
- label: '导入文件',
- // upload
- slotType: 'input',
- slot: {},
- },
- {
- slotType: 'input',
- label: '',
- slot: {
- placeholder: '这是一个进度条',
- },
- },
- {
- slotType: 'checkbox',
- label: 'CheckBox',
- prop: 'type',
- rowKey: 'row-5',
- slot: {
- type: 'checkbox',
- options: [
- { label: 'JavaScript', trueLabel: 'js' },
- { label: 'TypeScript', trueLabel: 'ts' },
- { label: 'NodeJs', trueLabel: 'nodeJs' },
- ],
- },
- },
- {
- slotType: 'checkbox',
- label: 'SingleCheckBox',
- prop: 'check',
- rowKey: 'row-5',
- slot: {
- type: 'checkbox',
- options: [{ label: 'JavaScript' }],
- },
- },
- ]
- const inlineItems: EpFormProps<typeof formModel>['items'] = [
- {
- slotType: 'input',
- label: '科目',
- rowKey: 'row-1',
- colProp: {
- span: 4,
- },
- },
- {
- slotType: 'input',
- label: '培训卷组',
- rowKey: 'row-1',
- colProp: {
- span: 4,
- },
- },
- {
- slotType: 'input',
- label: '培训卷组',
- rowKey: 'row-1',
- colProp: {
- span: 4,
- },
- },
- {
- slotType: 'input',
- label: '科目',
- rowKey: 'row-2',
- colProp: {
- span: 4,
- },
- },
- {
- slotType: 'input',
- label: '培训卷组',
- rowKey: 'row-2',
- colProp: {
- span: 4,
- },
- },
- {
- slotType: 'switch',
- label: '开关',
- rowKey: 'row-2',
- prop: 'publish',
- colProp: {
- span: 4,
- },
- },
- {
- slotType: 'checkbox',
- rowKey: 'row-2',
- labelWidth: '25px',
- prop: 'checkBox',
- slot: {
- type: 'button',
- options: [{ label: '差值显示', border: true }],
- },
- colProp: {
- span: 4,
- },
- },
- {
- slotType: 'inputNumber',
- rowKey: 'row-3',
- slot: {},
- colProp: {
- span: 4,
- },
- },
- {
- rowKey: 'row-1',
- slotName: 'cao-zuo-col',
- labelWidth: '10px',
- colProp: {
- span: 4,
- },
- },
- ]
- const forRules: EpFormProps<typeof formModel>['rules'] = {
- day: [{ required: true, message: '必填' }],
- }
- type formConfigType = 'normal' | 'with-group' | 'with-multiple-group'
- const usedFormConfigType = ref<formConfigType>('normal')
- const formConfig = reactive<Record<formConfigType, Omit<EpFormProps<typeof formModel>, 'model'>>>({
- normal: {
- size: 'large',
- },
- 'with-group': {
- rows: {},
- groups: [{ groupTitle: '选择大题', rowKeys: ['row-1'] }],
- },
- 'with-multiple-group': {
- groups: [
- { groupTitle: '选择大题', rowKeys: ['row-1'] },
- { groupTitle: '任务设置', rowKeys: ['row-2', 'row-3'] },
- { groupTitle: '选择文件', rowKeys: ['row-4'] },
- { groupTitle: 'CheckBox', rowKeys: ['row-5'] },
- ],
- },
- })
- const form = computed(() => {
- return formConfig[unref(usedFormConfigType)]
- })
- function changeFormConfig(type: formConfigType) {
- usedFormConfigType.value = type
- }
- /** form end */
- /** Table start */
- interface DataType {
- a: number
- b: number
- }
- const columns: EpTableProps<DataType>['columns'] = [
- {
- type: 'index',
- label: 'index',
- },
- {
- type: 'selection',
- label: 'selection',
- },
- {
- type: 'expand',
- label: 'expand',
- },
- {
- label: 'column-1',
- prop: 'a',
- },
- {
- label: 'column-2',
- prop: 'b',
- },
- {
- label: 'column-3',
- prop: 'a',
- },
- {
- label: 'column-4',
- prop: 'b',
- },
- {
- label: 'column-5',
- formatter(row) {
- return ''
- },
- },
- ]
- const data = ref<DataType[]>(getTableData())
- function getTableData() {
- return Array.from({ length: 30 }).map((_) => ({
- a: (Math.random() * 1000) | 0,
- b: (Math.random() * 1000) | 0,
- }))
- }
- const baseTableRef = shallowRef<InstanceType<typeof BaseTable>>()
- function refresh() {
- console.log('refresh')
- }
- /** Table end */
- /** echarts start */
- const { provideInitOption } = useVueECharts()
- provideInitOption({ renderer: 'svg' })
- const option = ref({
- title: {
- text: 'Traffic Sources',
- left: 'center',
- },
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b} : {c} ({d}%)',
- },
- legend: {
- orient: 'vertical',
- left: 'left',
- data: ['Direct', 'Email', 'Ad Networks', 'Video Ads', 'Search Engines'],
- },
- series: [
- {
- name: 'Traffic Sources',
- type: 'pie',
- radius: '55%',
- center: ['50%', '60%'],
- data: [
- { value: 335, name: 'Direct' },
- { value: 310, name: 'Email' },
- { value: 234, name: 'Ad Networks' },
- { value: 135, name: 'Video Ads' },
- { value: 1548, name: 'Search Engines' },
- ],
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)',
- },
- },
- },
- ],
- })
- /** echarts end */
- </script>
- <style scoped lang="scss">
- .components-view {
- .example-block {
- padding: $BaseGapSpace;
- .example-title {
- margin-bottom: $BaseGapSpace;
- }
- }
- .chart-box {
- height: 600px;
- }
- .float-nav {
- right: 20px;
- top: 80px;
- }
- }
- </style>
|