|
@@ -5,10 +5,19 @@
|
|
|
:canExpan="false"
|
|
|
helpMessage="可以在此增改系统的变量和分组,也可以自定义分组和变量"
|
|
|
>
|
|
|
- <a-button type="default" class="mr-2" @click="onBasicConfig"> 基础配置 </a-button>
|
|
|
- <a-button type="default" class="mr-2" @click="onBasicConfig"> 邮件配置 </a-button>
|
|
|
- <a-button type="default" class="mr-2" @click="onBasicConfig"> 字典配置 </a-button>
|
|
|
- <a-button type="default" class="mr-2" @click="onBasicConfig"> 会员配置 </a-button>
|
|
|
+ <a-button
|
|
|
+ v-for="(group, index) in groupList"
|
|
|
+ :key="index"
|
|
|
+ type="default"
|
|
|
+ class="mr-2"
|
|
|
+ @click="handleGroupBtn(group)"
|
|
|
+ >
|
|
|
+ <!-- 基础配置 -->
|
|
|
+ {{ group }}
|
|
|
+ </a-button>
|
|
|
+ <!-- <a-button type="default" class="mr-2" @click="onEmailConfig"> 邮件配置 </a-button>
|
|
|
+ <a-button type="default" class="mr-2" @click="handleGroupBtn"> 字典配置 </a-button>
|
|
|
+ <a-button type="default" class="mr-2" @click="handleGroupBtn"> 会员配置 </a-button> -->
|
|
|
<a-button
|
|
|
preIcon="bx:bx-plus-medical"
|
|
|
@mouseenter="showTip"
|
|
@@ -22,20 +31,20 @@
|
|
|
class="config-form"
|
|
|
v-if="formShow"
|
|
|
@register="registerForm"
|
|
|
- @submit="handleSubmit"
|
|
|
+ @submit="handleFormSubmit"
|
|
|
/>
|
|
|
<div v-if="tableShow" class="actions">
|
|
|
- <a-button class="mr-2" type="default" @click="onBasicConfig">
|
|
|
+ <a-button class="mr-2" type="default" @click="handleGroupBtn">
|
|
|
{{ t('common.resetText') }}
|
|
|
</a-button>
|
|
|
- <a-button class="mr-2" type="primary" @click="onSubmit">
|
|
|
+ <a-button class="mr-2" type="primary" @click="handleTableSubmit">
|
|
|
{{ t('common.submitText') }}
|
|
|
</a-button>
|
|
|
</div>
|
|
|
</CollapseContainer>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
- import { defineComponent, reactive, ref, toRefs, unref } from 'vue';
|
|
|
+ import { defineComponent, nextTick, reactive, ref, toRefs, unref } from 'vue';
|
|
|
import { CollapseContainer } from '/@/components/Container/index';
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
import { schemas } from './data';
|
|
@@ -51,6 +60,7 @@
|
|
|
// EditRecordRow,
|
|
|
TableActionType,
|
|
|
} from '/@/components/Table';
|
|
|
+ import { getConfigGroup, getConfigInfo, addConfigInfo } from '/@/api/sys/general';
|
|
|
import { columns } from './data';
|
|
|
|
|
|
export default defineComponent({
|
|
@@ -62,109 +72,15 @@
|
|
|
tipShow: false,
|
|
|
tableShow: true,
|
|
|
formShow: false,
|
|
|
+ groupList: [] as object[],
|
|
|
+ group: 'basic',
|
|
|
});
|
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
|
|
const [registerTable] = useTable({
|
|
|
columns: columns,
|
|
|
maxHeight: tableHeight,
|
|
|
- dataSource: [
|
|
|
- {
|
|
|
- title: 'helloWorld',
|
|
|
- name: 'helloworld',
|
|
|
- value: 'helloWorld',
|
|
|
- type: 'Input',
|
|
|
- tip: '我是helloworld字段的提示',
|
|
|
- rules: [],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'test',
|
|
|
- name: 'test',
|
|
|
- value: 'test',
|
|
|
- type: 'Input',
|
|
|
- tip: '我是test字段的提示',
|
|
|
- rules: ['require', 'url'],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello1',
|
|
|
- name: 'hello1',
|
|
|
- value: 'hello1',
|
|
|
- type: 'Select',
|
|
|
- tip: 'hello select',
|
|
|
- option: [{ value: 'hello1' }, { value: 'world' }, { value: 'java' }],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello1',
|
|
|
- name: 'hello1',
|
|
|
- value: ['hello1'],
|
|
|
- type: 'MultipleSelect',
|
|
|
- tip: 'MultipleSelect',
|
|
|
- option: [{ value: 'hello1' }, { value: 'world' }, { value: 'java' }],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello1',
|
|
|
- name: 'hello1',
|
|
|
- value: 'Orange',
|
|
|
- type: 'Radio',
|
|
|
- option: [
|
|
|
- { label: 'Apple', value: 'Apple' },
|
|
|
- { label: 'Pear', value: 'Pear' },
|
|
|
- { label: 'Orange', value: 'Orange' },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello1',
|
|
|
- name: 'hello1',
|
|
|
- value: ['Apple', 'Orange'],
|
|
|
- type: 'Checkbox',
|
|
|
- option: [
|
|
|
- { label: 'Apple', value: 'Apple' },
|
|
|
- { label: 'Pear', value: 'Pear' },
|
|
|
- { label: 'Orange', value: 'Orange' },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello2',
|
|
|
- name: 'hello2',
|
|
|
- value: '2021-10-25',
|
|
|
- type: 'DatePicker',
|
|
|
- tip: '日期选择',
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'time',
|
|
|
- name: 'timename',
|
|
|
- value: '11:12:25',
|
|
|
- type: 'TimePicker',
|
|
|
- tip: '时间选择',
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello3',
|
|
|
- name: 'hello3',
|
|
|
- value: 10,
|
|
|
- type: 'InputNumber',
|
|
|
- tip: '我是test字段的提示',
|
|
|
- rules: ['require', 'qq'],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello4',
|
|
|
- name: 'hello4',
|
|
|
- value: 'InputTextAreasdafasdf',
|
|
|
- type: 'InputTextArea',
|
|
|
- tip: '我是InputTextArea字段的提示123456789112',
|
|
|
- rules: ['require', 'email'],
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello4',
|
|
|
- name: 'hello4',
|
|
|
- value: true,
|
|
|
- type: 'Switch',
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'hello4',
|
|
|
- name: 'hello4',
|
|
|
- value: true,
|
|
|
- type: 'ArrayCom',
|
|
|
- },
|
|
|
- ],
|
|
|
+ api: getConfigInfo,
|
|
|
+ afterFetch: afterFetch,
|
|
|
showIndexColumn: false,
|
|
|
pagination: false,
|
|
|
});
|
|
@@ -190,6 +106,25 @@
|
|
|
return tableAction;
|
|
|
}
|
|
|
|
|
|
+ // 处理请求数据
|
|
|
+ function afterFetch(result) {
|
|
|
+ console.log(`result`, result);
|
|
|
+ // let obj = result.dictionary.list[0].value;
|
|
|
+ // console.log(`result.dictionary.list[0].value`, obj)
|
|
|
+ // var keys = Object.keys(obj);
|
|
|
+ // console.log(`keys`, keys);
|
|
|
+ result = result[state.group].list;
|
|
|
+ console.log(`result----after`, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ getGroupList();
|
|
|
+ async function getGroupList() {
|
|
|
+ const res = await getConfigGroup();
|
|
|
+ console.log(`res.group`, res.group);
|
|
|
+ state.groupList = Object.values(res.group);
|
|
|
+ console.log(`state.groupList`, state.groupList);
|
|
|
+ }
|
|
|
+
|
|
|
function showTip() {
|
|
|
state.tipShow = true;
|
|
|
}
|
|
@@ -198,9 +133,13 @@
|
|
|
state.tipShow = false;
|
|
|
}
|
|
|
|
|
|
- function onBasicConfig() {
|
|
|
+ async function handleGroupBtn(group) {
|
|
|
state.tableShow = true;
|
|
|
state.formShow = false;
|
|
|
+ await nextTick();
|
|
|
+ getTableAction().reload();
|
|
|
+ state.group = group.toLowerCase();
|
|
|
+ console.log(`state.group`, state.group);
|
|
|
}
|
|
|
|
|
|
function addConfig() {
|
|
@@ -208,24 +147,32 @@
|
|
|
state.formShow = true;
|
|
|
}
|
|
|
|
|
|
- function onSubmit() {
|
|
|
- console.log('==========onSubmit=========');
|
|
|
+ function handleTableSubmit() {
|
|
|
+ console.log('==========handleTableSubmit=========');
|
|
|
const data = getTableAction().getDataSource();
|
|
|
let flag = true;
|
|
|
+ console.log(`data`, data);
|
|
|
data.map((item) => {
|
|
|
- if (item.rules && item.rules.length) {
|
|
|
- console.log(`item`, item.rules);
|
|
|
- const res = validateType(item.rules, item.value);
|
|
|
+ if (item.rule) {
|
|
|
+ const rule = item.rule.split(',');
|
|
|
+ const res = validateType(rule, item.value);
|
|
|
item.errMsg = res.errMsg;
|
|
|
- flag = res.isValid;
|
|
|
+ if (!res.isValid) {
|
|
|
+ console.log(`item`, item);
|
|
|
+ flag = res.isValid;
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
if (flag) {
|
|
|
console.log('=======全部校验通过========');
|
|
|
+ return;
|
|
|
}
|
|
|
+ console.log('======未通过校验====');
|
|
|
}
|
|
|
|
|
|
- function handleSubmit(e) {
|
|
|
+ async function handleFormSubmit(e) {
|
|
|
+ return;
|
|
|
+ await addConfigInfo(e);
|
|
|
console.log('=======values =======');
|
|
|
console.log(`e`, e);
|
|
|
}
|
|
@@ -236,10 +183,10 @@
|
|
|
registerForm,
|
|
|
showTip,
|
|
|
hideTip,
|
|
|
- onBasicConfig,
|
|
|
+ handleGroupBtn,
|
|
|
addConfig,
|
|
|
- onSubmit,
|
|
|
- handleSubmit,
|
|
|
+ handleTableSubmit,
|
|
|
+ handleFormSubmit,
|
|
|
...toRefs(state),
|
|
|
};
|
|
|
},
|