|
@@ -12,12 +12,8 @@
|
|
|
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"
|
|
@@ -26,7 +22,11 @@
|
|
|
class="mr-2"
|
|
|
/>
|
|
|
<span v-if="tipShow" class="tip">点击添加新的配置</span>
|
|
|
- <BasicTable ref="tableRef" :canResize="true" v-if="tableShow" @register="registerTable" />
|
|
|
+ <BasicTable ref="tableRef" :canResize="true" v-if="tableShow" @register="registerTable">
|
|
|
+ <template #action="{ record, column }">
|
|
|
+ <TableAction :actions="createActions(record, column)" stopButtonPropagation />
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
<BasicForm
|
|
|
class="config-form"
|
|
|
v-if="formShow"
|
|
@@ -34,7 +34,7 @@
|
|
|
@submit="handleFormSubmit"
|
|
|
/>
|
|
|
<div v-if="tableShow" class="actions">
|
|
|
- <a-button class="mr-2" type="default" @click="handleGroupBtn">
|
|
|
+ <a-button class="mr-2" type="default" @click="handleTableReset">
|
|
|
{{ t('common.resetText') }}
|
|
|
</a-button>
|
|
|
<a-button class="mr-2" type="primary" @click="handleTableSubmit">
|
|
@@ -44,6 +44,7 @@
|
|
|
</CollapseContainer>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
import { defineComponent, nextTick, reactive, ref, toRefs, unref } from 'vue';
|
|
|
import { CollapseContainer } from '/@/components/Container/index';
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
|
@@ -54,19 +55,27 @@
|
|
|
import {
|
|
|
BasicTable,
|
|
|
useTable,
|
|
|
- // TableAction,
|
|
|
+ TableAction,
|
|
|
// BasicColumn,
|
|
|
- // ActionItem,
|
|
|
- // EditRecordRow,
|
|
|
+ ActionItem,
|
|
|
+ EditRecordRow,
|
|
|
TableActionType,
|
|
|
} from '/@/components/Table';
|
|
|
- import { getConfigGroup, getConfigInfo, addConfigInfo } from '/@/api/sys/general';
|
|
|
+ import {
|
|
|
+ getConfigGroup,
|
|
|
+ getConfigInfo,
|
|
|
+ addConfigInfo,
|
|
|
+ editConfigInfo,
|
|
|
+ deleteConfigInfo,
|
|
|
+ } from '/@/api/sys/general';
|
|
|
import { columns } from './data';
|
|
|
|
|
|
export default defineComponent({
|
|
|
- components: { CollapseContainer, BasicTable, BasicForm },
|
|
|
+ components: { CollapseContainer, BasicTable, BasicForm, TableAction },
|
|
|
setup() {
|
|
|
const { t } = useI18n();
|
|
|
+ const { createMessage } = useMessage();
|
|
|
+ const { success /*, error */ } = createMessage;
|
|
|
const tableHeight = adapt().tableHeight;
|
|
|
const state = reactive({
|
|
|
tipShow: false,
|
|
@@ -81,6 +90,13 @@
|
|
|
maxHeight: tableHeight,
|
|
|
api: getConfigInfo,
|
|
|
afterFetch: afterFetch,
|
|
|
+ actionColumn: {
|
|
|
+ width: 160,
|
|
|
+ // title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ slots: { customRender: 'action' },
|
|
|
+ fixed: undefined,
|
|
|
+ },
|
|
|
showIndexColumn: false,
|
|
|
pagination: false,
|
|
|
});
|
|
@@ -108,21 +124,13 @@
|
|
|
|
|
|
// 处理请求数据
|
|
|
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() {
|
|
@@ -139,7 +147,6 @@
|
|
|
await nextTick();
|
|
|
getTableAction().reload();
|
|
|
state.group = group.toLowerCase();
|
|
|
- console.log(`state.group`, state.group);
|
|
|
}
|
|
|
|
|
|
function addConfig() {
|
|
@@ -147,37 +154,76 @@
|
|
|
state.formShow = true;
|
|
|
}
|
|
|
|
|
|
- function handleTableSubmit() {
|
|
|
+ function handleTableReset() {
|
|
|
+ getTableAction().reload();
|
|
|
+ }
|
|
|
+
|
|
|
+ async function handleTableSubmit() {
|
|
|
console.log('==========handleTableSubmit=========');
|
|
|
const data = getTableAction().getDataSource();
|
|
|
let flag = true;
|
|
|
- console.log(`data`, data);
|
|
|
data.map((item) => {
|
|
|
- if (item.rule) {
|
|
|
+ if (item.rule && item.type !== 'array') {
|
|
|
const rule = item.rule.split(',');
|
|
|
const res = validateType(rule, item.value);
|
|
|
item.errMsg = res.errMsg;
|
|
|
if (!res.isValid) {
|
|
|
- console.log(`item`, item);
|
|
|
flag = res.isValid;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
if (flag) {
|
|
|
- console.log('=======全部校验通过========');
|
|
|
- return;
|
|
|
+ const params = {};
|
|
|
+ data.map((item) => {
|
|
|
+ if (item.type == 'array') {
|
|
|
+ params[item.name] = JSON.stringify(item.value);
|
|
|
+ } else {
|
|
|
+ params[item.name] = item.value;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ await editConfigInfo(params).then(() => {
|
|
|
+ getTableAction().reload();
|
|
|
+ success('修改成功!');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('======未通过校验====');
|
|
|
}
|
|
|
- console.log('======未通过校验====');
|
|
|
}
|
|
|
|
|
|
async function handleFormSubmit(e) {
|
|
|
- return;
|
|
|
- await addConfigInfo(e);
|
|
|
- console.log('=======values =======');
|
|
|
- console.log(`e`, e);
|
|
|
+ if (!e.rule) {
|
|
|
+ e.rule = '';
|
|
|
+ } else {
|
|
|
+ e.rule = e.rule.toString();
|
|
|
+ }
|
|
|
+ await addConfigInfo(e).then(() => {
|
|
|
+ success('创建成功!');
|
|
|
+ handleGroupBtn('Basic'); // 跳转显示到table基础配置
|
|
|
+ });
|
|
|
+ }
|
|
|
+ async function handleDelete(record: Recordable) {
|
|
|
+ await deleteConfigInfo({ id: record.id }).then(() => {
|
|
|
+ getTableAction().reload();
|
|
|
+ success('删除成功!');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function createActions(record: EditRecordRow): ActionItem[] {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ label: '删除',
|
|
|
+ color: 'error',
|
|
|
+ icon: 'ic:outline-delete-outline',
|
|
|
+ popConfirm: {
|
|
|
+ title: '是否确认删除',
|
|
|
+ confirm: handleDelete.bind(null, record),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
}
|
|
|
return {
|
|
|
t,
|
|
|
+ createActions,
|
|
|
tableRef,
|
|
|
registerTable,
|
|
|
registerForm,
|
|
@@ -185,6 +231,7 @@
|
|
|
hideTip,
|
|
|
handleGroupBtn,
|
|
|
addConfig,
|
|
|
+ handleTableReset,
|
|
|
handleTableSubmit,
|
|
|
handleFormSubmit,
|
|
|
...toRefs(state),
|