|
|
@@ -1,261 +1,144 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <BasicTable @register="registerTable" @resizeColumn="resizeColumn">
|
|
|
- <template #bodyCell="{ column, record }">
|
|
|
- <template v-if="column.key === 'disable'">
|
|
|
- <Tag :color="record.disable ? 'error' : 'success'">
|
|
|
- {{ commonDict(record.disable, 1) }}
|
|
|
- </Tag>
|
|
|
- </template>
|
|
|
- <template v-if="column.key === 'sysInner'">
|
|
|
- <Tag :color="record.sysInner ? 'success' : 'error'">
|
|
|
- {{ commonDict(record.sysInner, 1) }}
|
|
|
- </Tag>
|
|
|
- </template>
|
|
|
- <template v-if="column.key === 'action'">
|
|
|
- <TableAction
|
|
|
- :actions="[
|
|
|
- {
|
|
|
- icon: 'icon-edit|iconfont',
|
|
|
- tooltip: '编辑',
|
|
|
- onClick: handleEdit.bind(null, record),
|
|
|
- },
|
|
|
- {
|
|
|
- icon: 'icon-delete|iconfont',
|
|
|
- tooltip: '删除',
|
|
|
- color: 'error',
|
|
|
- popConfirm: {
|
|
|
- title: '是否确认删除',
|
|
|
- placement: 'left',
|
|
|
- confirm: handleDelete.bind(null, record),
|
|
|
- },
|
|
|
- },
|
|
|
- ]"
|
|
|
- />
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- <template #search="{ onSearch }">
|
|
|
- <div class="search">
|
|
|
- <a-input-search
|
|
|
- class="table-search-item"
|
|
|
- v-model:value="tableSearch.value1"
|
|
|
- placeholder="请输入姓名"
|
|
|
- @search="onSearch"
|
|
|
- />
|
|
|
- <a-select
|
|
|
- ref="select"
|
|
|
- placeholder="选择病区"
|
|
|
- v-model:value="tableSearch.value2"
|
|
|
- style="width: 120px"
|
|
|
- @change="onSearch"
|
|
|
- class="table-search-item"
|
|
|
- >
|
|
|
- <a-select-option value="1"> <span class="mr-1">病区</span>全部 </a-select-option>
|
|
|
- <a-select-option value="jack"> <span class="mr-1">病区</span>Jack </a-select-option>
|
|
|
- <a-select-option value="lucy"><span class="mr-1">病区</span>Lucy</a-select-option>
|
|
|
- <a-select-option value="Yiminghe"
|
|
|
- ><span class="mr-1">病区</span>yiminghe</a-select-option
|
|
|
- >
|
|
|
- </a-select>
|
|
|
- <a-select
|
|
|
- ref="select"
|
|
|
- placeholder="选择设备"
|
|
|
- v-model:value="tableSearch.value3"
|
|
|
- style="width: 120px"
|
|
|
- @change="onSearch"
|
|
|
- class="table-search-item"
|
|
|
- >
|
|
|
- <a-select-option value="1"> <span class="mr-1">设备</span>全部 </a-select-option>
|
|
|
- <a-select-option value="jack"> <span class="mr-1">设备</span>111 </a-select-option>
|
|
|
- <a-select-option value="lucy"><span class="mr-1">设备</span>222</a-select-option>
|
|
|
- <a-select-option value="Yiminghe"><span class="mr-1">设备</span>333</a-select-option>
|
|
|
- </a-select>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #toolbar>
|
|
|
- <a-button
|
|
|
- v-auth="['system:sysConfig:add']"
|
|
|
- preIcon="icon-plus|iconfont"
|
|
|
- type="primary"
|
|
|
- @click="handleCreate"
|
|
|
- >新增
|
|
|
- </a-button>
|
|
|
- <!-- <a-button
|
|
|
- v-auth="['system:sysConfig:export']"
|
|
|
- color="warning"
|
|
|
- preIcon="ant-design:download-outlined"
|
|
|
- @click="handleExport"
|
|
|
- >导出
|
|
|
- </a-button> -->
|
|
|
- <a-button
|
|
|
- v-auth="['system:sysConfig:refresh']"
|
|
|
- color="success"
|
|
|
- preIcon="icon-redo|iconfont"
|
|
|
- @click="handleRefresh"
|
|
|
- >刷新缓存
|
|
|
- </a-button>
|
|
|
- </template>
|
|
|
- </BasicTable>
|
|
|
- <FormModal @register="registerModal" @success="handleSuccess" />
|
|
|
+ <div class="flex mt-6">
|
|
|
+ <div class="w-1/2 -enter-x">
|
|
|
+ <BasicForm @register="register" @submit="handleSubmit" />
|
|
|
+ </div>
|
|
|
+ <div class="w-1/2 -enter-x">
|
|
|
+ <Textarea
|
|
|
+ v-model:value="textSchemas"
|
|
|
+ :rows="10"
|
|
|
+ placeholder="请输入 schemas"
|
|
|
+ @change="onChange"
|
|
|
+ wrap="soft"
|
|
|
+ />
|
|
|
+ <CodeEditor v-model:value="codeValue" :mode="modeValue" @change="handleChange" />
|
|
|
+ {{ data111 }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
-<script lang="ts" setup>
|
|
|
- import { ref, onBeforeMount, reactive } from 'vue';
|
|
|
- import { Tag } from 'ant-design-vue';
|
|
|
- import { BasicTable, TableAction, useTable } from '/@/components/Table';
|
|
|
- import { useModal } from '/@/components/Modal';
|
|
|
- import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
- import FormModal from './FormModal.vue';
|
|
|
- import { columns, searchBasicFormSchema, searchFormSchema } from './data';
|
|
|
|
|
|
- // import { exportList, fetchList, refresh, removeObj } from '/@/api/modules/system/sysConfigApi';
|
|
|
- import { sysConfigQueryList, sysConfigRemove } from '/@/api/sys/sysConfigApi';
|
|
|
- // import { downloadFile, listDictModel } from '/@/api/common';
|
|
|
- // import { listDictModel } from '/@/api/common';
|
|
|
- import { commonDict } from '/@/utils';
|
|
|
- import { templateRef } from '@vueuse/core';
|
|
|
- import { useDebounceFn } from '@vueuse/shared';
|
|
|
+<script setup lang="ts">
|
|
|
+ import { BasicForm, useForm } from '/@/components/Form';
|
|
|
+ import { Textarea } from 'ant-design-vue';
|
|
|
+ import { useDebounceFn } from '@vueuse/core';
|
|
|
+ import { ref, onMounted, watch, computed } from 'vue';
|
|
|
+ import { CodeEditor } from '/@/components/CodeEditor';
|
|
|
+ import { listDictModel } from '/@/api/common';
|
|
|
|
|
|
- defineOptions({
|
|
|
- name: 'sysConfig',
|
|
|
- });
|
|
|
+ const codeValue = ref(null);
|
|
|
+ const modeValue = ref('application/json');
|
|
|
|
|
|
- // const sysStatusOptions = ref([]);
|
|
|
- onBeforeMount(async () => {
|
|
|
- // sysStatusOptions.value = await listDictModel({ dictCode: 'sys_status' });
|
|
|
- });
|
|
|
- const tableSearch = reactive({
|
|
|
- value1: '',
|
|
|
- value2: '1',
|
|
|
- value3: '1',
|
|
|
+ onMounted(() => {
|
|
|
+ console.log('1231231');
|
|
|
});
|
|
|
- const { createMessage, createConfirm } = useMessage();
|
|
|
- const [registerTable, { reload, getCacheColumns, setColumns }] = useTable({
|
|
|
- id: 'sys_config',
|
|
|
- storage: true,
|
|
|
- title: '参数列表',
|
|
|
- api: sysConfigQueryList,
|
|
|
- rowKey: 'id',
|
|
|
- columns,
|
|
|
- formConfig: {
|
|
|
- formId: 'sys_config',
|
|
|
- layout: 'vertical',
|
|
|
- labelWidth: 100,
|
|
|
- schemas: searchFormSchema,
|
|
|
- actionColOptions: {
|
|
|
- span: 23,
|
|
|
+
|
|
|
+ const schemas = ref([
|
|
|
+ {
|
|
|
+ field: 'field1',
|
|
|
+ component: 'Input',
|
|
|
+ label: '字段1',
|
|
|
+ colProps: {
|
|
|
+ span: 8,
|
|
|
+ },
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '自定义placeholder',
|
|
|
+ onChange: (e: any) => {
|
|
|
+ console.log(e);
|
|
|
+ },
|
|
|
},
|
|
|
- showActionButtonGroup: false,
|
|
|
- // autoSubmitOnEnter: true,
|
|
|
- // baseColProps: { xs: 24, sm: 12, md: 12, lg: 8 },
|
|
|
- // resetButtonOptions: {
|
|
|
- // preIcon: 'ant-design:delete-outlined',
|
|
|
- // },
|
|
|
- // submitButtonOptions: {
|
|
|
- // preIcon: 'ant-design:search-outlined',
|
|
|
- // },
|
|
|
},
|
|
|
- basicSearch: {
|
|
|
- schemas: searchBasicFormSchema,
|
|
|
- fields: tableSearch,
|
|
|
+ {
|
|
|
+ field: 'field2',
|
|
|
+ component: 'Input',
|
|
|
+ label: '字段2',
|
|
|
+ colProps: {
|
|
|
+ span: 8,
|
|
|
+ },
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '自定义placeholder222222222',
|
|
|
+ onChange: (e: any) => {
|
|
|
+ console.log(e);
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- showIndexColumn: true,
|
|
|
- useSearchForm: true,
|
|
|
- showTableSetting: true,
|
|
|
- bordered: true,
|
|
|
- actionColumn: {
|
|
|
- auth: ['system:sysConfig:edit', 'system:sysConfig:remove'],
|
|
|
- width: 80,
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'action',
|
|
|
+ ]) as any;
|
|
|
+
|
|
|
+ watch(
|
|
|
+ () => schemas.value,
|
|
|
+ (newVal, oldVal) => {
|
|
|
+ console.log('🚀 ~ file: index.vue:67 ~ oldVal:', oldVal);
|
|
|
+ console.log('🚀 ~ file: index.vue:67 ~ newVal:', newVal);
|
|
|
},
|
|
|
+ );
|
|
|
+ const count = ref(1);
|
|
|
+ const data111 = computed(() => {
|
|
|
+ return count.value + 1;
|
|
|
});
|
|
|
- const [registerModal, { openModal }] = useModal();
|
|
|
-
|
|
|
- // 新增按钮事件
|
|
|
- function handleCreate() {
|
|
|
- openModal(true, {
|
|
|
- isUpdate: false,
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 编辑按钮事件
|
|
|
- function handleEdit(record: Recordable) {
|
|
|
- console.log(record);
|
|
|
- openModal(true, {
|
|
|
- record,
|
|
|
- isUpdate: true,
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
- // 删除按钮事件
|
|
|
- async function handleDelete(record: Recordable) {
|
|
|
- console.log(record);
|
|
|
- await sysConfigRemove([record.id]);
|
|
|
- createMessage.success('删除成功!');
|
|
|
- await reload();
|
|
|
- }
|
|
|
-
|
|
|
- // 导出按钮事件
|
|
|
- // async function handleExport() {
|
|
|
- // createConfirm({
|
|
|
- // iconType: 'warning',
|
|
|
- // title: '提示',
|
|
|
- // content: '确认导出?',
|
|
|
- // onOk: async () => {
|
|
|
- // const params = getForm().getFieldsValue();
|
|
|
- // const filepath = await exportList(params);
|
|
|
- // downloadFile(filepath);
|
|
|
- // },
|
|
|
- // });
|
|
|
- // }
|
|
|
+ const [register, { resetSchema }] = useForm({
|
|
|
+ labelWidth: 120,
|
|
|
+ schemas,
|
|
|
+ actionColOptions: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ });
|
|
|
+ const textSchemas = ref(null);
|
|
|
|
|
|
- // 刷新缓存按钮事件
|
|
|
- async function handleRefresh() {
|
|
|
- createConfirm({
|
|
|
- iconType: 'warning',
|
|
|
- title: '提示',
|
|
|
- content: '确认刷新所有参数缓存?',
|
|
|
- onOk: async () => {
|
|
|
- await sysConfigQueryList({});
|
|
|
- createMessage.success('刷新成功!');
|
|
|
+ const debounceFn = useDebounceFn(data => {
|
|
|
+ const span = Math.round(Math.random() * 20 + 5);
|
|
|
+ schemas.value = [
|
|
|
+ {
|
|
|
+ field: 'field1',
|
|
|
+ component: 'Input',
|
|
|
+ label: '字段' + span,
|
|
|
+ colProps: {
|
|
|
+ span,
|
|
|
+ },
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '自定义placeholder',
|
|
|
+ onChange: e => {
|
|
|
+ console.log(e);
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 弹窗回调事件
|
|
|
- async function handleSuccess({ isUpdate, values }) {
|
|
|
- console.log(isUpdate);
|
|
|
- console.log(values);
|
|
|
- await reload();
|
|
|
- }
|
|
|
-
|
|
|
- const debounceFn = useDebounceFn(async (w, col) => {
|
|
|
- const cacheColumns = await getCacheColumns();
|
|
|
- const columns = cacheColumns.map(ele => {
|
|
|
- if (ele.dataIndex == col.dataIndex) {
|
|
|
- ele.width = w;
|
|
|
- }
|
|
|
- return ele;
|
|
|
- }) as any;
|
|
|
- setColumns(columns);
|
|
|
+ ];
|
|
|
+ resetSchema(data);
|
|
|
+ console.log('🚀 ~ file: index.vue:107 ~ debounceFn ~ data:', data);
|
|
|
+ console.log('🚀 ~ file: index.vue:89 ~ debounceFn ~ schemas.value:', schemas.value);
|
|
|
+ // console.log('🚀 ~ file: index.vue:91 ~ debounceFn ~ data:', data);
|
|
|
+ // resetSchema([data]);
|
|
|
}, 1000 * 3);
|
|
|
|
|
|
- // 动态设置宽度
|
|
|
- async function resizeColumn(w, col) {
|
|
|
- col.width = w;
|
|
|
- debounceFn(w, col);
|
|
|
+ function onChange(e) {
|
|
|
+ // const str = "[{field: 'field1',component: 'Input',label: '字段1',colProps: {span: 24,},}]";
|
|
|
+ // const val = JSON.parse(str);
|
|
|
+ // const val = JSON.stringify(e.target.value, null, 4).replace(/\n/g, '');
|
|
|
+ // console.log(val);
|
|
|
+ // console.log('🚀 ~ file: index.vue:71 ~ onChange ~ val:', val);
|
|
|
+ // debounceFn();
|
|
|
+ count.value = Math.round(Math.random() * 100);
|
|
|
}
|
|
|
+ function handleChange(val) {
|
|
|
+ console.log('🚀 ~ file: index.vue:100 ~ handleChange ~ val:', val);
|
|
|
+ if (Array.isArray(val)) {
|
|
|
+ const arr = val.map(ele => {
|
|
|
+ if (ele?.componentProps) {
|
|
|
+ if (ele.componentProps?.api) {
|
|
|
+ ele.componentProps.api = listDictModel;
|
|
|
+ }
|
|
|
+ if (ele.componentProps?.onChange) {
|
|
|
+ ele.componentProps.onChange = new Function('e', ele.componentProps.onChange);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ele;
|
|
|
+ });
|
|
|
+ console.log('🚀 ~ file: index.vue:126 ~ arr ~ arr:', arr);
|
|
|
+ debounceFn(arr);
|
|
|
+ }
|
|
|
+ textSchemas.value = JSON.stringify(val);
|
|
|
+ }
|
|
|
+ function handleSubmit() {}
|
|
|
</script>
|
|
|
|
|
|
-<sytle scoped lang="less">
|
|
|
-.table-search {
|
|
|
- display: flex;
|
|
|
- justify-content: space-between;
|
|
|
- align-items: center;
|
|
|
- &-item {
|
|
|
- margin-right: 10px;
|
|
|
- max-width: 180px;
|
|
|
- }
|
|
|
-}
|
|
|
-</sytle>
|
|
|
+<style scoped></style>
|