发布代码生成、更新20+表单组件,优化数据字典,gf版本更新到2.3.1

This commit is contained in:
孟帅
2023-01-18 16:23:39 +08:00
parent 50207ded90
commit 87c27a17a3
386 changed files with 27926 additions and 44297 deletions

View File

@@ -1,5 +1,55 @@
import { h } from 'vue';
import { NAvatar, NTag } from 'naive-ui';
import { h, ref } from 'vue';
import { NAvatar, NImage, NTag } from 'naive-ui';
import { getFileExt } from '@/utils/urlUtils';
import { Dicts } from '@/api/dict/dict';
import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo';
import { FormSchema } from '@/components/Form';
import { isNullOrUnDef } from '@/utils/is';
export const options = ref<Options>({
sys_normal_disable: [],
config_upload_drive: [],
});
export const schemas = ref<FormSchema[]>([
{
field: 'member_id',
component: 'NInput',
label: '用户ID',
componentProps: {
placeholder: '请输入用户ID',
onUpdateValue: (e: any) => {
console.log(e);
},
},
rules: [{ message: '请输入用户ID', trigger: ['blur'] }],
},
{
field: 'drive',
component: 'NSelect',
label: '选择驱动',
defaultValue: null,
componentProps: {
placeholder: '请选择驱动',
options: [],
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
{
field: 'status',
component: 'NSelect',
label: '状态',
defaultValue: null,
componentProps: {
placeholder: '请选择类型',
options: [],
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
]);
export const columns = [
{
@@ -11,7 +61,7 @@ export const columns = [
key: 'appId',
},
{
title: '会员ID',
title: '用户ID',
key: 'memberId',
},
{
@@ -45,16 +95,40 @@ export const columns = [
key: 'fileUrl',
width: 80,
render(row) {
return h(NAvatar, {
size: 40,
if (row.fileUrl === '') {
return ``;
}
if (row.kind !== 'images') {
return h(
NAvatar,
{
width: '40px',
height: '40px',
'max-width': '100%',
'max-height': '100%',
},
{
default: () => getFileExt(row.fileUrl),
}
);
}
return h(NImage, {
width: 40,
height: 40,
src: row.fileUrl,
style: {
width: '40px',
height: '40px',
'max-width': '100%',
'max-height': '100%',
},
});
},
},
{
title: '本地路径',
key: 'path',
},
// {
// title: '本地路径',
// key: 'path',
// },
{
title: '扩展名',
key: 'ext',
@@ -67,24 +141,44 @@ export const columns = [
title: '状态',
key: 'status',
render(row) {
if (isNullOrUnDef(row.status)) {
return ``;
}
return h(
NTag,
{
style: {
marginRight: '6px',
},
type: row.status == 1 ? 'success' : 'warning',
type: getOptionTag(options.value.sys_normal_disable, row.status),
bordered: false,
},
{
default: () => (row.status == 1 ? '正常' : '隐藏'),
default: () => getOptionLabel(options.value.sys_normal_disable, row.status),
}
);
},
},
{
title: '上传时间',
key: 'createdAt',
},
];
async function loadOptions() {
options.value = await Dicts({
types: ['sys_normal_disable', 'config_upload_drive'],
});
for (const item of schemas.value) {
switch (item.field) {
case 'status':
item.componentProps.options = options.value.sys_normal_disable;
break;
case 'drive':
item.componentProps.options = options.value.config_upload_drive;
break;
}
}
}
await loadOptions();

View File

@@ -14,6 +14,7 @@
</BasicForm>
<BasicTable
:openChecked="true"
:columns="columns"
:request="loadDataTable"
:row-key="(row) => row.id"
@@ -29,7 +30,16 @@
<UploadOutlined />
</n-icon>
</template>
上传附件
上传图片
</n-button>
&nbsp;
<n-button type="primary" @click="addFileTable">
<template #icon>
<n-icon>
<UploadOutlined />
</n-icon>
</template>
上传文件
</n-button>
&nbsp;
<n-button type="error" @click="batchDelete" :disabled="batchDeleteDisabled">
@@ -48,12 +58,12 @@
:show-icon="false"
preset="dialog"
style="width: 60%"
title="上传附件"
title="上传图片"
>
<n-upload
multiple
directory-dnd
:action="`${uploadUrl}/admin/upload/image`"
:action="`${uploadUrl}${urlPrefix}/upload/image`"
:headers="uploadHeaders"
:data="{ type: 0 }"
@before-upload="beforeUpload"
@@ -66,7 +76,39 @@
<n-upload-dragger>
<div style="margin-bottom: 12px">
<n-icon size="48" :depth="3">
<archive-icon />
<CloudUploadOutlined />
</n-icon>
</div>
<n-text style="font-size: 16px"> 点击或者拖动图片到该区域来上传</n-text>
<n-p depth="3" style="margin: 8px 0 0 0"> 单次最多允许20个图片</n-p>
</n-upload-dragger>
</n-upload>
</n-modal>
<n-modal
v-model:show="showFileModal"
:show-icon="false"
preset="dialog"
style="width: 60%"
title="上传文件"
>
<n-upload
multiple
directory-dnd
:action="`${uploadUrl}${urlPrefix}/upload/file`"
:headers="uploadHeaders"
:data="{ type: 0 }"
@before-upload="beforeUpload"
@finish="finish"
name="file"
:max="20"
:default-file-list="fileList"
list-type="image"
>
<n-upload-dragger>
<div style="margin-bottom: 12px">
<n-icon size="48" :depth="3">
<FileAddOutlined />
</n-icon>
</div>
<n-text style="font-size: 16px"> 点击或者拖动文件到该区域来上传</n-text>
@@ -82,125 +124,38 @@
import { h, reactive, ref } from 'vue';
import { UploadFileInfo, useDialog, useMessage } from 'naive-ui';
import { BasicTable, TableAction } from '@/components/Table';
import { BasicForm, FormSchema, useForm } from '@/components/Form/index';
import { Delete, Edit, List, Status } from '@/api/apply/attachment';
import { columns } from './columns';
import { DeleteOutlined, UploadOutlined } from '@vicons/antd';
import { statusActions, statusOptions } from '@/enums/optionsiEnum';
import { BasicForm, useForm } from '@/components/Form/index';
import { Delete, List } from '@/api/apply/attachment';
import { columns, schemas } from './columns';
import {
DeleteOutlined,
UploadOutlined,
FileAddOutlined,
CloudUploadOutlined,
} from '@vicons/antd';
import { useGlobSetting } from '@/hooks/setting';
import { useUserStoreWidthOut } from '@/store/modules/user';
import componentSetting from '@/settings/componentSetting';
import { ResultEnum } from '@/enums/httpEnum';
const useUserStore = useUserStoreWidthOut();
const globSetting = useGlobSetting();
const { uploadUrl } = globSetting;
const urlPrefix = globSetting.urlPrefix || '';
const uploadHeaders = reactive({
Authorization: useUserStore.token,
});
const fileList = ref<UploadFileInfo[]>([
// {
// id: 'c',
// name: '图片.png',
// status: 'finished',
// url: 'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg',
// },
]);
const driveOptions = [
{
value: 'local',
label: '本地',
},
].map((s) => {
return s;
});
const params = ref({
pageSize: 10,
title: '',
content: '',
status: null,
});
const rules = {
title: {
// required: true,
trigger: ['blur', 'input'],
message: '请输入标题',
},
};
const schemas: FormSchema[] = [
{
field: 'member_id',
component: 'NInput',
label: '用户ID',
componentProps: {
placeholder: '请输入用户ID',
onUpdateValue: (e: any) => {
console.log(e);
},
},
rules: [{ message: '请输入用户ID', trigger: ['blur'] }],
},
{
field: 'drive',
component: 'NSelect',
label: '驱动',
defaultValue: null,
componentProps: {
placeholder: '请选择驱动',
options: driveOptions,
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
{
field: 'status',
component: 'NSelect',
label: '状态',
defaultValue: null,
componentProps: {
placeholder: '请选择类型',
options: statusOptions,
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
];
const fileList = ref<UploadFileInfo[]>([]);
const message = useMessage();
const actionRef = ref();
const dialog = useDialog();
const showFileModal = ref(false);
const showModal = ref(false);
const formBtnLoading = ref(false);
const searchFormRef = ref({});
const formRef = ref({});
const searchFormRef = ref<any>({});
const batchDeleteDisabled = ref(true);
const checkedIds = ref([]);
const resetFormParams = {
basicLogo: '',
id: 0,
title: '',
name: '',
type: 1,
receiver: '',
remark: '',
sort: 0,
status: 1,
created_at: '',
updated_at: '',
};
let formParams = ref(resetFormParams);
const actionColumn = reactive({
width: 220,
title: '操作',
@@ -211,18 +166,14 @@
style: 'button',
actions: [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
label: '下载',
onClick: handleDown.bind(null, record),
},
{
label: '删除',
onClick: handleDelete.bind(null, record),
},
],
dropDownActions: statusActions,
select: (key) => {
updateStatus(record.id, key);
},
});
},
});
@@ -234,22 +185,23 @@
});
function addTable() {
showFileModal.value = false;
showModal.value = true;
fileList.value = [];
}
function addFileTable() {
showModal.value = false;
showFileModal.value = true;
fileList.value = [];
}
const loadDataTable = async (res) => {
return await List({ ...params.value, ...res, ...searchFormRef.value.formModel });
return await List({ ...res, ...searchFormRef.value?.formModel });
};
function onCheckedRow(rowKeys) {
console.log(rowKeys);
if (rowKeys.length > 0) {
batchDeleteDisabled.value = false;
} else {
batchDeleteDisabled.value = true;
}
batchDeleteDisabled.value = rowKeys.length <= 0;
checkedIds.value = rowKeys;
}
@@ -257,58 +209,25 @@
actionRef.value.reload();
}
function confirmForm(e) {
e.preventDefault();
formBtnLoading.value = true;
formRef.value.validate((errors) => {
if (!errors) {
console.log('formParams:' + JSON.stringify(formParams.value));
Edit(formParams.value)
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
setTimeout(() => {
showModal.value = false;
reloadTable();
formParams.value = ref(resetFormParams);
});
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
});
} else {
message.error('请填写完整信息');
}
formBtnLoading.value = false;
});
}
function handleEdit(record: Recordable) {
console.log('点击了编辑', record);
showModal.value = true;
formParams.value = record;
function handleDown(record: Recordable) {
window.open(record.fileUrl);
}
function handleDelete(record: Recordable) {
console.log('点击了删除', record);
dialog.warning({
title: '警告',
content: '你确定要删除?',
positiveText: '确定',
negativeText: '不确定',
negativeText: '取消',
onPositiveClick: () => {
Delete(record)
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
reloadTable();
})
.catch((e: Error) => {
// message.error(e.message ?? '操作失败');
});
Delete(record).then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('不确定');
// message.error('取消');
},
});
}
@@ -318,51 +237,29 @@
title: '警告',
content: '你确定要删除?',
positiveText: '确定',
negativeText: '不确定',
negativeText: '取消',
onPositiveClick: () => {
Delete({ id: checkedIds.value })
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
reloadTable();
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
});
Delete({ id: checkedIds.value }).then((_res) => {
message.success('操作成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('不确定');
// message.error('取消');
},
});
}
function handleSubmit(values: Recordable) {
console.log(values);
params.value = values;
function handleSubmit(_values: Recordable) {
reloadTable();
}
function handleReset(values: Recordable) {
params.value = values;
function handleReset(_values: Recordable) {
reloadTable();
}
function updateStatus(id, status) {
Status({ id: id, status: status })
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
setTimeout(() => {
reloadTable({});
});
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
});
}
//上传之前
function beforeUpload({ file }) {
function beforeUpload({ _file }) {
return true;
}

View File

@@ -14,6 +14,7 @@
</BasicForm>
<BasicTable
:openChecked="true"
:columns="columns"
:request="loadDataTable"
:row-key="(row) => row.id"
@@ -133,7 +134,7 @@
].map((s) => {
return s;
});
const params = ref({
const params = ref<any>({
pageSize: 10,
title: '',
content: '',
@@ -193,8 +194,8 @@
const dialog = useDialog();
const showModal = ref(false);
const formBtnLoading = ref(false);
const searchFormRef = ref({});
const formRef = ref({});
const searchFormRef = ref<any>({});
const formRef = ref<any>({});
const batchDeleteDisabled = ref(true);
const checkedIds = ref([]);
@@ -210,7 +211,7 @@
created_at: '',
updated_at: '',
};
let formParams = ref(resetFormParams);
let formParams = ref<any>(resetFormParams);
const actionColumn = reactive({
width: 220,
@@ -250,11 +251,10 @@
}
const loadDataTable = async (res) => {
return await List({ ...params.value, ...res, ...searchFormRef.value.formModel });
return await List({ ...params.value, ...res, ...searchFormRef.value?.formModel });
};
function onCheckedRow(rowKeys) {
console.log(rowKeys);
if (rowKeys.length > 0) {
batchDeleteDisabled.value = false;
} else {
@@ -273,20 +273,14 @@
formBtnLoading.value = true;
formRef.value.validate((errors) => {
if (!errors) {
console.log('formParams:' + JSON.stringify(formParams.value));
Edit(formParams.value)
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
setTimeout(() => {
showModal.value = false;
reloadTable();
formParams.value = ref(resetFormParams);
});
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
Edit(formParams.value).then((_res) => {
message.success('操作成功');
setTimeout(() => {
showModal.value = false;
reloadTable();
formParams.value = ref(resetFormParams);
});
});
} else {
message.error('请填写完整信息');
}
@@ -295,31 +289,24 @@
}
function handleEdit(record: Recordable) {
console.log('点击了编辑', record);
showModal.value = true;
formParams.value = record;
}
function handleDelete(record: Recordable) {
console.log('点击了删除', record);
dialog.warning({
title: '警告',
content: '你确定要删除?',
positiveText: '确定',
negativeText: '不确定',
negativeText: '取消',
onPositiveClick: () => {
Delete(record)
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
reloadTable();
})
.catch((e: Error) => {
// message.error(e.message ?? '操作失败');
});
Delete(record).then((_res) => {
message.success('操作成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('不确定');
// message.error('取消');
},
});
}
@@ -329,26 +316,20 @@
title: '警告',
content: '你确定要删除?',
positiveText: '确定',
negativeText: '不确定',
negativeText: '取消',
onPositiveClick: () => {
Delete({ id: checkedIds.value })
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
reloadTable();
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
});
Delete({ id: checkedIds.value }).then((_res) => {
message.success('操作成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('不确定');
// message.error('取消');
},
});
}
function handleSubmit(values: Recordable) {
console.log(values);
params.value = values;
reloadTable();
}
@@ -359,17 +340,12 @@
}
function updateStatus(id, status) {
Status({ id: id, status: status })
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
setTimeout(() => {
reloadTable({});
});
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
Status({ id: id, status: status }).then((_res) => {
message.success('操作成功');
setTimeout(() => {
reloadTable();
});
});
}
</script>

View File

@@ -1,5 +1,5 @@
import { h } from 'vue';
import { NAvatar, NTag } from 'naive-ui';
import { NTag } from 'naive-ui';
export const columns = [
{

View File

@@ -14,6 +14,7 @@
</BasicForm>
<BasicTable
:openChecked="true"
:columns="columns"
:request="loadDataTable"
:row-key="(row) => row.id"
@@ -133,7 +134,7 @@
].map((s) => {
return s;
});
const params = ref({
const params = ref<any>({
pageSize: 10,
title: '',
content: '',
@@ -193,8 +194,8 @@
const dialog = useDialog();
const showModal = ref(false);
const formBtnLoading = ref(false);
const searchFormRef = ref({});
const formRef = ref({});
const searchFormRef = ref<any>({});
const formRef = ref<any>({});
const batchDeleteDisabled = ref(true);
const checkedIds = ref([]);
@@ -210,7 +211,7 @@
created_at: '',
updated_at: '',
};
let formParams = ref(resetFormParams);
let formParams = ref<any>(resetFormParams);
const actionColumn = reactive({
width: 220,
@@ -250,11 +251,10 @@
}
const loadDataTable = async (res) => {
return await List({ ...params.value, ...res, ...searchFormRef.value.formModel });
return await List({ ...params.value, ...res, ...searchFormRef.value?.formModel });
};
function onCheckedRow(rowKeys) {
console.log(rowKeys);
if (rowKeys.length > 0) {
batchDeleteDisabled.value = false;
} else {
@@ -273,10 +273,8 @@
formBtnLoading.value = true;
formRef.value.validate((errors) => {
if (!errors) {
console.log('formParams:' + JSON.stringify(formParams.value));
Edit(formParams.value)
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
setTimeout(() => {
showModal.value = false;
@@ -295,31 +293,24 @@
}
function handleEdit(record: Recordable) {
console.log('点击了编辑', record);
showModal.value = true;
formParams.value = record;
}
function handleDelete(record: Recordable) {
console.log('点击了删除', record);
dialog.warning({
title: '警告',
content: '你确定要删除?',
positiveText: '确定',
negativeText: '不确定',
negativeText: '取消',
onPositiveClick: () => {
Delete(record)
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
reloadTable();
})
.catch((e: Error) => {
// message.error(e.message ?? '操作失败');
});
Delete(record).then((_res) => {
message.success('操作成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('不确定');
// message.error('取消');
},
});
}
@@ -329,20 +320,15 @@
title: '警告',
content: '你确定要删除?',
positiveText: '确定',
negativeText: '不确定',
negativeText: '取消',
onPositiveClick: () => {
Delete({ id: checkedIds.value })
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
reloadTable();
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
});
Delete({ id: checkedIds.value }).then((_res) => {
message.success('操作成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('不确定');
// message.error('取消');
},
});
}
@@ -359,17 +345,12 @@
}
function updateStatus(id, status) {
Status({ id: id, status: status })
.then((_res) => {
console.log('_res:' + JSON.stringify(_res));
message.success('操作成功');
setTimeout(() => {
reloadTable({});
});
})
.catch((e: Error) => {
message.error(e.message ?? '操作失败');
Status({ id: id, status: status }).then((_res) => {
message.success('操作成功');
setTimeout(() => {
reloadTable();
});
});
}
</script>