实现阻止图片、视频自动上传
This commit is contained in:
parent
75da20582a
commit
955c9b8262
95
src/api/oroqen/OroqenHeritageInheritor.ts
Normal file
95
src/api/oroqen/OroqenHeritageInheritor.ts
Normal file
@ -0,0 +1,95 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/oroqen/heritageInheritor/list',
|
||||
save = '/oroqen/heritageInheritor/add',
|
||||
edit = '/oroqen/heritageInheritor/edit',
|
||||
deleteOne = '/oroqen/heritageInheritor/delete',
|
||||
deleteBatch = '/oroqen/heritageInheritor/deleteBatch',
|
||||
importExcel = '/oroqen/heritageInheritor/importExcel',
|
||||
exportXls = '/oroqen/heritageInheritor/exportXls',
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出api
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
/**
|
||||
* 导入api
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
/**
|
||||
* 列表接口
|
||||
*/
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
/**
|
||||
* 删除单个
|
||||
*/
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取传承人选项列表(用于下拉选择)
|
||||
*/
|
||||
export const getInheritorOptions = () => {
|
||||
return defHttp.get({
|
||||
url: Api.list,
|
||||
params: {
|
||||
pageNo: 1,
|
||||
pageSize: 1000,
|
||||
status: 1 // 只获取启用状态的传承人
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('传承人API响应:', res);
|
||||
// 修正数据结构判断,直接使用 res.records
|
||||
if (res && res.records && Array.isArray(res.records)) {
|
||||
const options = res.records.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
key: item.id
|
||||
}));
|
||||
console.log('传承人选项数据:', options);
|
||||
return options;
|
||||
}
|
||||
console.log('传承人数据为空或格式错误');
|
||||
return [];
|
||||
}).catch(error => {
|
||||
console.error('获取传承人数据失败:', error);
|
||||
return [];
|
||||
});
|
||||
};
|
@ -163,10 +163,12 @@
|
||||
// 添加可左右移动的按钮
|
||||
function onAddActionsButton(event) {
|
||||
const getUploadItem = () => {
|
||||
for (const path of event.path) {
|
||||
if (path.classList.contains(antUploadItemCls)) {
|
||||
return path;
|
||||
} else if (path.classList.contains(`${prefixCls}-container`)) {
|
||||
// 兼容不同浏览器的事件路径获取方式
|
||||
const path = event.path || (event.composedPath && event.composedPath()) || [];
|
||||
for (const element of path) {
|
||||
if (element.classList && element.classList.contains(antUploadItemCls)) {
|
||||
return element;
|
||||
} else if (element.classList && element.classList.contains(`${prefixCls}-container`)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -206,7 +208,8 @@
|
||||
const result = split(paths);
|
||||
// update-end--author:liaozhiyang---date:20250325---for:【issues/7990】图片参数中包含逗号会错误的识别成多张图
|
||||
for (const item of result) {
|
||||
let url = getFileAccessHttpUrl(item);
|
||||
// 如果是blob URL,直接使用,不通过getFileAccessHttpUrl处理
|
||||
let url = item.startsWith('blob:') ? item : getFileAccessHttpUrl(item);
|
||||
list.push({
|
||||
uid: uidGenerator(),
|
||||
name: getFileName(item),
|
||||
@ -226,7 +229,8 @@
|
||||
}
|
||||
let list: any[] = [];
|
||||
for (const item of array) {
|
||||
let url = getFileAccessHttpUrl(item.filePath);
|
||||
// 如果是blob URL,直接使用,不通过getFileAccessHttpUrl处理
|
||||
let url = item.filePath.startsWith('blob:') ? item.filePath : getFileAccessHttpUrl(item.filePath);
|
||||
list.push({
|
||||
uid: uidGenerator(),
|
||||
name: item.fileName,
|
||||
@ -273,6 +277,7 @@
|
||||
|
||||
// upload组件change事件
|
||||
function onFileChange(info) {
|
||||
console.log('onFileChange 被调用:', info.file.status, info.file.url);
|
||||
if (!info.file.status && uploadGoOn.value === false) {
|
||||
info.fileList.pop();
|
||||
}
|
||||
@ -295,7 +300,19 @@
|
||||
successFileList = fileListTemp.map((file) => {
|
||||
if (file.response) {
|
||||
let reUrl = file.response.message;
|
||||
file.url = getFileAccessHttpUrl(reUrl);
|
||||
console.log('处理文件URL:', file.url, '是否为blob:', file.url?.startsWith('blob:'));
|
||||
// 如果文件已经有URL且是blob URL(本地预览URL),则保持不变
|
||||
if (!file.url || !file.url.startsWith('blob:')) {
|
||||
file.url = getFileAccessHttpUrl(reUrl);
|
||||
console.log('设置新URL:', file.url);
|
||||
} else {
|
||||
console.log('保持blob URL:', file.url);
|
||||
}
|
||||
// 关键修复:确保response.message也使用blob URL,避免Ant Design Upload组件直接使用它作为缩略图src
|
||||
if (file.url && file.url.startsWith('blob:')) {
|
||||
file.response.message = file.url;
|
||||
console.log('同步response.message为blob URL:', file.response.message);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
});
|
||||
@ -361,10 +378,23 @@
|
||||
|
||||
// 预览文件、图片
|
||||
function onFilePreview(file) {
|
||||
console.log('预览文件URL:', file.url);
|
||||
// 确保预览时使用正确的URL
|
||||
let previewUrl = file.url;
|
||||
// 如果URL不是blob URL且response中有message,优先使用blob URL
|
||||
if (!previewUrl.startsWith('blob:') && file.response && file.response.message) {
|
||||
// 检查是否有本地预览URL可用
|
||||
const fileInList = fileList.value.find(f => f.uid === file.uid);
|
||||
if (fileInList && fileInList.url && fileInList.url.startsWith('blob:')) {
|
||||
previewUrl = fileInList.url;
|
||||
console.log('使用本地预览URL:', previewUrl);
|
||||
}
|
||||
}
|
||||
|
||||
if (isImageMode.value) {
|
||||
createImgPreview({ imageList: [file.url], maskClosable: true });
|
||||
createImgPreview({ imageList: [previewUrl], maskClosable: true });
|
||||
} else {
|
||||
window.open(file.url);
|
||||
window.open(previewUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,10 @@ export const getFileAccessHttpUrl = (fileUrl, prefix = 'http') => {
|
||||
let result = fileUrl;
|
||||
try {
|
||||
if (fileUrl && fileUrl.length > 0 && !fileUrl.startsWith(prefix)) {
|
||||
// 检查是否是blob URL,如果是则直接返回
|
||||
if (fileUrl.startsWith('blob:')) {
|
||||
return fileUrl;
|
||||
}
|
||||
//判断是否是数组格式
|
||||
let isArray = fileUrl.indexOf('[') != -1;
|
||||
if (!isArray) {
|
||||
|
@ -0,0 +1,75 @@
|
||||
import {defHttp} from '/@/utils/http/axios';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/oroqen/heritageProject/list',
|
||||
save='/oroqen/heritageProject/add',
|
||||
edit='/oroqen/heritageProject/edit',
|
||||
deleteOne = '/oroqen/heritageProject/delete',
|
||||
deleteBatch = '/oroqen/heritageProject/deleteBatch',
|
||||
importExcel = '/oroqen/heritageProject/importExcel',
|
||||
exportXls = '/oroqen/heritageProject/exportXls',
|
||||
recommend = '/oroqen/heritageProject/recommend',
|
||||
}
|
||||
/**
|
||||
* 导出api
|
||||
* @param params
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
/**
|
||||
* 导入api
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
/**
|
||||
* 列表接口
|
||||
* @param params
|
||||
*/
|
||||
export const list = (params) =>
|
||||
defHttp.get({url: Api.list, params});
|
||||
|
||||
/**
|
||||
* 删除单个
|
||||
*/
|
||||
export const deleteOne = (params,handleSuccess) => {
|
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 批量删除
|
||||
* @param params
|
||||
*/
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({url: url, params});
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐/取消推荐
|
||||
* @param params
|
||||
*/
|
||||
export const toggleRecommend = (params, handleSuccess) => {
|
||||
return defHttp.put({url: Api.recommend, params}, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
599
src/views/oroqen/heritage-project/OroqenHeritageProject.data.ts
Normal file
599
src/views/oroqen/heritage-project/OroqenHeritageProject.data.ts
Normal file
@ -0,0 +1,599 @@
|
||||
import {BasicColumn} from '/@/components/Table';
|
||||
import {FormSchema} from '/@/components/Table';
|
||||
import { h } from 'vue';
|
||||
import { Image } from 'ant-design-vue';
|
||||
import { getInheritorOptions } from '/@/api/oroqen/OroqenHeritageInheritor';
|
||||
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||
|
||||
//列表数据
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '项目名称',
|
||||
align:"left",
|
||||
dataIndex: 'projectName',
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: '封面图片',
|
||||
align:"center",
|
||||
dataIndex: 'coverImage',
|
||||
customRender: ({ text, record }) => {
|
||||
if (!text) return '-';
|
||||
// 使用 getFileAccessHttpUrl 函数来正确处理图片URL
|
||||
const imageUrl = getFileAccessHttpUrl(text);
|
||||
|
||||
return h(Image, {
|
||||
src: imageUrl,
|
||||
alt: record?.projectName || '封面图片',
|
||||
width: 60,
|
||||
height: 60,
|
||||
style: { objectFit: 'cover', borderRadius: '4px' },
|
||||
preview: true,
|
||||
fallback: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3Ik1RnG4W+FgYxN'
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '项目编码',
|
||||
align:"center",
|
||||
dataIndex: 'projectCode',
|
||||
},
|
||||
{
|
||||
title: '项目类别',
|
||||
align:"center",
|
||||
dataIndex: 'category',
|
||||
customRender: ({ text }) => {
|
||||
const categoryMap = {
|
||||
'TRADITIONAL_CRAFT': '传统技艺',
|
||||
'FOLK_CUSTOM': '民俗',
|
||||
'TRADITIONAL_MUSIC': '传统音乐',
|
||||
'TRADITIONAL_DANCE': '传统舞蹈',
|
||||
'TRADITIONAL_DRAMA': '传统戏剧',
|
||||
'QUYI': '曲艺',
|
||||
'TRADITIONAL_SPORTS': '传统体育',
|
||||
'TRADITIONAL_ART': '传统美术',
|
||||
'TRADITIONAL_MEDICINE': '传统医药',
|
||||
'LITERATURE': '文学'
|
||||
};
|
||||
return categoryMap[text] || text;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '非遗级别',
|
||||
align:"center",
|
||||
dataIndex: 'heritageLevel',
|
||||
customRender: ({ text }) => {
|
||||
const levelMap = {
|
||||
'NATIONAL': '国家级',
|
||||
'PROVINCIAL': '省级',
|
||||
'MUNICIPAL': '市级',
|
||||
'COUNTY': '县级'
|
||||
};
|
||||
const level = levelMap[text] || text;
|
||||
const colorMap = {
|
||||
'国家级': '#cf1322',
|
||||
'省级': '#fa541c',
|
||||
'市级': '#fa8c16',
|
||||
'县级': '#52c41a'
|
||||
};
|
||||
return h('span', {
|
||||
style: {
|
||||
color: colorMap[level] || '#666',
|
||||
fontWeight: '500'
|
||||
}
|
||||
}, level);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '批准年份',
|
||||
align:"center",
|
||||
dataIndex: 'approvalYear',
|
||||
},
|
||||
{
|
||||
title: '保护单位',
|
||||
align:"center",
|
||||
dataIndex: 'protectionUnit',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '浏览次数',
|
||||
align:"center",
|
||||
dataIndex: 'viewCount',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
align:"center",
|
||||
dataIndex: 'status',
|
||||
customRender: ({ text }) => {
|
||||
return text === 1 ?
|
||||
h('span', { style: { color: '#52c41a', fontWeight: '500' } }, '启用') :
|
||||
h('span', { style: { color: '#ff4d4f', fontWeight: '500' } }, '禁用');
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '推荐状态',
|
||||
align:"center",
|
||||
dataIndex: 'isRecommended',
|
||||
customRender: ({ text }) => {
|
||||
return text === 1 ?
|
||||
h('span', { style: { color: '#1890ff', fontWeight: '500' } }, '已推荐') :
|
||||
h('span', { style: { color: '#999', fontWeight: '500' } }, '未推荐');
|
||||
}
|
||||
},
|
||||
];
|
||||
//查询数据
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
label: '项目名称',
|
||||
field: 'projectName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入项目名称',
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '项目编码',
|
||||
field: 'projectCode',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入项目编码',
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '项目类别',
|
||||
field: 'category',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择项目类别',
|
||||
options: [
|
||||
{ label: '传统技艺', value: 'TRADITIONAL_CRAFT' },
|
||||
{ label: '民俗', value: 'FOLK_CUSTOM' },
|
||||
{ label: '传统音乐', value: 'TRADITIONAL_MUSIC' },
|
||||
{ label: '传统舞蹈', value: 'TRADITIONAL_DANCE' },
|
||||
{ label: '传统戏剧', value: 'TRADITIONAL_DRAMA' },
|
||||
{ label: '曲艺', value: 'QUYI' },
|
||||
{ label: '传统体育', value: 'TRADITIONAL_SPORTS' },
|
||||
{ label: '传统美术', value: 'TRADITIONAL_ART' },
|
||||
{ label: '传统医药', value: 'TRADITIONAL_MEDICINE' },
|
||||
{ label: '文学', value: 'LITERATURE' },
|
||||
]
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '非遗级别',
|
||||
field: 'heritageLevel',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择非遗级别',
|
||||
options: [
|
||||
{ label: '国家级', value: 'NATIONAL' },
|
||||
{ label: '省级', value: 'PROVINCIAL' },
|
||||
{ label: '市级', value: 'MUNICIPAL' },
|
||||
{ label: '县级', value: 'COUNTY' },
|
||||
]
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '保护单位',
|
||||
field: 'protectionUnit',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入保护单位',
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择状态',
|
||||
options: [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
]
|
||||
},
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
//表单数据
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
label: '项目名称',
|
||||
field: 'projectName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入项目名称',
|
||||
},
|
||||
dynamicRules: ({model,schema}) => {
|
||||
return [
|
||||
{ required: true, message: '请输入项目名称!'},
|
||||
];
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '项目编码',
|
||||
field: 'projectCode',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入项目编码',
|
||||
},
|
||||
dynamicRules: ({model,schema}) => {
|
||||
return [
|
||||
{ required: true, message: '请输入项目编码!'},
|
||||
];
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '项目类别',
|
||||
field: 'category',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择项目类别',
|
||||
options: [
|
||||
{ label: '传统技艺', value: 'TRADITIONAL_CRAFT' },
|
||||
{ label: '民俗', value: 'FOLK_CUSTOM' },
|
||||
{ label: '传统音乐', value: 'TRADITIONAL_MUSIC' },
|
||||
{ label: '传统舞蹈', value: 'TRADITIONAL_DANCE' },
|
||||
{ label: '传统戏剧', value: 'TRADITIONAL_DRAMA' },
|
||||
{ label: '曲艺', value: 'QUYI' },
|
||||
{ label: '传统体育', value: 'TRADITIONAL_SPORTS' },
|
||||
{ label: '传统美术', value: 'TRADITIONAL_ART' },
|
||||
{ label: '传统医药', value: 'TRADITIONAL_MEDICINE' },
|
||||
{ label: '文学', value: 'LITERATURE' },
|
||||
]
|
||||
},
|
||||
dynamicRules: ({model,schema}) => {
|
||||
return [
|
||||
{ required: true, message: '请选择项目类别!'},
|
||||
];
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '非遗级别',
|
||||
field: 'heritageLevel',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择非遗级别',
|
||||
options: [
|
||||
{ label: '国家级', value: 'NATIONAL' },
|
||||
{ label: '省级', value: 'PROVINCIAL' },
|
||||
{ label: '市级', value: 'MUNICIPAL' },
|
||||
{ label: '县级', value: 'COUNTY' },
|
||||
]
|
||||
},
|
||||
dynamicRules: ({model,schema}) => {
|
||||
return [
|
||||
{ required: true, message: '请选择非遗级别!'},
|
||||
];
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '批准年份',
|
||||
field: 'approvalYear',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '请输入批准年份',
|
||||
min: 1900,
|
||||
max: new Date().getFullYear(),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '批准文号',
|
||||
field: 'approvalNumber',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批准文号',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '项目描述',
|
||||
field: 'description',
|
||||
component: 'InputTextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入项目描述',
|
||||
rows: 3,
|
||||
maxlength: 500,
|
||||
showCount: true,
|
||||
},
|
||||
dynamicRules: ({model,schema}) => {
|
||||
return [
|
||||
{ required: true, message: '请输入项目描述!'},
|
||||
];
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '详细描述',
|
||||
field: 'fullDescription',
|
||||
component: 'InputTextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入详细描述',
|
||||
rows: 4,
|
||||
maxlength: 2000,
|
||||
showCount: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '历史渊源',
|
||||
field: 'history',
|
||||
component: 'InputTextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入历史渊源',
|
||||
rows: 4,
|
||||
maxlength: 2000,
|
||||
showCount: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '技艺特点',
|
||||
field: 'features',
|
||||
component: 'InputTextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入技艺特点',
|
||||
rows: 4,
|
||||
maxlength: 2000,
|
||||
showCount: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '传承价值',
|
||||
field: 'value',
|
||||
component: 'InputTextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入传承价值',
|
||||
rows: 4,
|
||||
maxlength: 2000,
|
||||
showCount: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '封面图片',
|
||||
field: 'coverImage',
|
||||
component: 'JUpload',
|
||||
componentProps: {
|
||||
fileType: 'image',
|
||||
maxCount: 1,
|
||||
maxSize: 5,
|
||||
bizPath: 'heritage-project/cover',
|
||||
customRequest: (options) => {
|
||||
// 验证文件类型和大小
|
||||
const { file } = options;
|
||||
const isImage = file.type.startsWith('image/');
|
||||
if (!isImage) {
|
||||
console.error('只能上传图片文件!');
|
||||
return;
|
||||
}
|
||||
const isLt5M = file.size / 1024 / 1024 < 5;
|
||||
if (!isLt5M) {
|
||||
console.error('图片大小不能超过5MB!');
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建本地预览URL
|
||||
const localUrl = URL.createObjectURL(file);
|
||||
|
||||
// 直接设置文件的url为本地预览URL
|
||||
file.url = localUrl;
|
||||
|
||||
// 模拟上传成功响应,但不返回local:前缀,避免被解析
|
||||
setTimeout(() => {
|
||||
options.onSuccess({
|
||||
success: true,
|
||||
message: file.name, // 仅使用文件名,不使用local:前缀
|
||||
}, file);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
colProps: { lg: 12, md: 12 },
|
||||
},
|
||||
{
|
||||
label: '图片集',
|
||||
field: 'images',
|
||||
component: 'JUpload',
|
||||
componentProps: {
|
||||
fileType: 'image',
|
||||
maxCount: 10,
|
||||
maxSize: 5,
|
||||
bizPath: 'heritage-project/images',
|
||||
customRequest: (options) => {
|
||||
// 验证文件类型和大小
|
||||
const { file } = options;
|
||||
const isImage = file.type.startsWith('image/');
|
||||
if (!isImage) {
|
||||
console.error('只能上传图片文件!');
|
||||
return;
|
||||
}
|
||||
const isLt5M = file.size / 1024 / 1024 < 5;
|
||||
if (!isLt5M) {
|
||||
console.error('图片大小不能超过5MB!');
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建本地预览URL
|
||||
const localUrl = URL.createObjectURL(file);
|
||||
|
||||
// 直接设置文件的url为本地预览URL
|
||||
file.url = localUrl;
|
||||
|
||||
// 模拟上传成功响应,但不返回local:前缀,避免被解析
|
||||
setTimeout(() => {
|
||||
options.onSuccess({
|
||||
success: true,
|
||||
message: file.name, // 仅使用文件名,不使用local:前缀
|
||||
}, file);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
colProps: { lg: 12, md: 12 },
|
||||
},
|
||||
{
|
||||
label: '视频链接',
|
||||
field: 'videoUrl',
|
||||
component: 'JUpload',
|
||||
componentProps: {
|
||||
fileType: 'video',
|
||||
maxCount: 1,
|
||||
maxSize: 50,
|
||||
bizPath: 'heritage-project/video',
|
||||
customRequest: (options) => {
|
||||
// 验证文件类型和大小
|
||||
const { file } = options;
|
||||
const isVideo = file.type.startsWith('video/');
|
||||
if (!isVideo) {
|
||||
console.error('只能上传视频文件!');
|
||||
return;
|
||||
}
|
||||
const isLt50M = file.size / 1024 / 1024 < 50;
|
||||
if (!isLt50M) {
|
||||
console.error('视频大小不能超过50MB!');
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建本地预览URL
|
||||
const localUrl = URL.createObjectURL(file);
|
||||
|
||||
// 直接设置文件的url为本地预览URL
|
||||
file.url = localUrl;
|
||||
|
||||
// 模拟上传成功响应,但不返回local:前缀,避免被解析
|
||||
setTimeout(() => {
|
||||
options.onSuccess({
|
||||
success: true,
|
||||
message: file.name, // 仅使用文件名,不使用local:前缀
|
||||
}, file);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
colProps: { lg: 24, md: 24 },
|
||||
},
|
||||
// {
|
||||
// label: '音频链接',
|
||||
// field: 'audioUrl',
|
||||
// component: 'JUpload',
|
||||
// componentProps: {
|
||||
// fileType: 'audio',
|
||||
// maxCount: 1,
|
||||
// maxSize: 20,
|
||||
// bizPath: 'heritage-project/audio',
|
||||
// },
|
||||
// },
|
||||
{
|
||||
label: '标签',
|
||||
field: 'tags',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入标签,多个标签用逗号分隔',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '关联传承人',
|
||||
field: 'inheritorIds',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择关联传承人',
|
||||
mode: 'multiple',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getInheritorOptions,
|
||||
immediate: true,
|
||||
resultField: '',
|
||||
labelField: 'label',
|
||||
valueField: 'value',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '保护单位',
|
||||
field: 'protectionUnit',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入保护单位',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '保护措施',
|
||||
field: 'protectionMeasures',
|
||||
component: 'InputTextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入保护措施',
|
||||
rows: 3,
|
||||
maxlength: 1000,
|
||||
showCount: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '保护现状',
|
||||
field: 'currentStatus',
|
||||
component: 'InputTextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入保护现状',
|
||||
rows: 3,
|
||||
maxlength: 1000,
|
||||
showCount: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '禁用', value: 0 },
|
||||
{ label: '启用', value: 1 },
|
||||
]
|
||||
},
|
||||
defaultValue: 1,
|
||||
ifShow: ({ values }) => {
|
||||
// 新增时隐藏状态字段,编辑时显示
|
||||
return !!values.id;
|
||||
},
|
||||
},
|
||||
// TODO 主键隐藏字段,目前写死为ID
|
||||
{
|
||||
label: '',
|
||||
field: 'id',
|
||||
component: 'Input',
|
||||
show: false
|
||||
},
|
||||
];
|
||||
|
||||
// 高级查询数据
|
||||
export const superQuerySchema = {
|
||||
projectName: {title: '项目名称',order: 0,view: 'text', type: 'string',},
|
||||
projectCode: {title: '项目编码',order: 1,view: 'text', type: 'string',},
|
||||
category: {title: '项目类别',order: 2,view: 'text', type: 'string',},
|
||||
heritageLevel: {title: '非遗级别',order: 3,view: 'text', type: 'string',},
|
||||
approvalYear: {title: '批准年份',order: 4,view: 'number', type: 'number',},
|
||||
approvalNumber: {title: '批准文号',order: 5,view: 'text', type: 'string',},
|
||||
description: {title: '项目描述',order: 6,view: 'text', type: 'string',},
|
||||
fullDescription: {title: '详细描述',order: 7,view: 'textarea', type: 'string',},
|
||||
history: {title: '历史渊源',order: 8,view: 'textarea', type: 'string',},
|
||||
features: {title: '技艺特点',order: 9,view: 'textarea', type: 'string',},
|
||||
value: {title: '传承价值',order: 10,view: 'textarea', type: 'string',},
|
||||
coverImage: {title: '封面图片',order: 11,view: 'text', type: 'string',},
|
||||
images: {title: '图片集',order: 12,view: 'textarea', type: 'string',},
|
||||
videoUrl: {title: '视频链接',order: 13,view: 'text', type: 'string',},
|
||||
audioUrl: {title: '音频链接',order: 14,view: 'text', type: 'string',},
|
||||
tags: {title: '标签',order: 15,view: 'text', type: 'string',},
|
||||
inheritorIds: {title: '关联传承人ID',order: 16,view: 'textarea', type: 'string',},
|
||||
protectionUnit: {title: '保护单位',order: 17,view: 'text', type: 'string',},
|
||||
protectionMeasures: {title: '保护措施',order: 18,view: 'text', type: 'string',},
|
||||
currentStatus: {title: '保护现状',order: 19,view: 'text', type: 'string',},
|
||||
isRecommended: {title: '是否推荐',order: 20,view: 'number', type: 'number',},
|
||||
viewCount: {title: '浏览次数',order: 21,view: 'number', type: 'number',},
|
||||
likeCount: {title: '点赞次数',order: 22,view: 'number', type: 'number',},
|
||||
status: {title: '状态',order: 23,view: 'number', type: 'number',},
|
||||
};
|
||||
|
||||
/**
|
||||
* 流程表单调用这个方法获取formSchema
|
||||
* @param param
|
||||
*/
|
||||
export function getBpmFormSchema(_formData): FormSchema[]{
|
||||
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
|
||||
return formSchema;
|
||||
}
|
219
src/views/oroqen/heritage-project/OroqenHeritageProjectList.vue
Normal file
219
src/views/oroqen/heritage-project/OroqenHeritageProjectList.vue
Normal file
@ -0,0 +1,219 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">
|
||||
导出</a-button
|
||||
>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
preIcon="ant-design:import-outlined"
|
||||
@click="onImportXls"
|
||||
>导入</j-upload-button
|
||||
>
|
||||
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button>批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<!-- 高级查询 -->
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
<!--字段回显插槽-->
|
||||
<template #bodyCell="{ column, record, index, text }">
|
||||
<!-- 这里可以添加自定义渲染逻辑 -->
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<OroqenHeritageProjectModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="oroqen-oroqenHeritageProject" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import OroqenHeritageProjectModal from './components/OroqenHeritageProjectModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema } from './OroqenHeritageProject.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, toggleRecommend } from './OroqenHeritageProject.api';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getDateByPicker } from '/@/utils';
|
||||
//日期个性化选择
|
||||
const fieldPickers = reactive({});
|
||||
const queryParam = reactive<any>({});
|
||||
const { createMessage } = useMessage();
|
||||
//注册model
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: 'oroqen_heritage_project',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
//labelWidth: 120,
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
fieldMapToNumber: [],
|
||||
fieldMapToTime: [],
|
||||
},
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
if (params && fieldPickers) {
|
||||
for (let key in fieldPickers) {
|
||||
if (params[key]) {
|
||||
params[key] = getDateByPicker(params[key], fieldPickers[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: 'oroqen_heritage_project',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
// 高级查询配置
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
/**
|
||||
* 高级查询事件
|
||||
*/
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).map((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
function handleAdd() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: false,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
/**
|
||||
* 推荐/取消推荐事件
|
||||
*/
|
||||
async function handleRecommend(record) {
|
||||
const action = record.isRecommended === 1 ? '取消推荐' : '推荐';
|
||||
createMessage.loading(`正在${action}...`, 1);
|
||||
await toggleRecommend({
|
||||
id: record.id,
|
||||
isRecommended: record.isRecommended === 1 ? 0 : 1
|
||||
}, handleSuccess);
|
||||
createMessage.success(`${action}成功!`);
|
||||
}
|
||||
/**
|
||||
* 批量删除事件
|
||||
*/
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
},
|
||||
];
|
||||
}
|
||||
/**
|
||||
* 下拉操作栏
|
||||
*/
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: record.isRecommended === 1 ? '取消推荐' : '推荐',
|
||||
onClick: handleRecommend.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
placement: 'topLeft',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-picker),
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<div style="min-height: 400px">
|
||||
<BasicForm @register="registerForm" />
|
||||
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { getBpmFormSchema } from '../OroqenHeritageProject.data';
|
||||
import { saveOrUpdate } from '../OroqenHeritageProject.api';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OroqenHeritageProjectForm',
|
||||
components: {
|
||||
BasicForm,
|
||||
},
|
||||
props: {
|
||||
formData: propTypes.object.def({}),
|
||||
formBpm: propTypes.bool.def(true),
|
||||
},
|
||||
setup(props) {
|
||||
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 150,
|
||||
schemas: getBpmFormSchema(props.formData),
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
|
||||
const formDisabled = computed(() => {
|
||||
if (props.formData.disabled === false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
let formData = {};
|
||||
const queryByIdUrl = '/oroqen/oroqenHeritageProject/queryById';
|
||||
async function initFormData() {
|
||||
let params = { id: props.formData.dataId };
|
||||
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||
formData = { ...data };
|
||||
//设置表单的值
|
||||
await setFieldsValue(formData);
|
||||
//默认是禁用
|
||||
await setProps({ disabled: formDisabled.value });
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
let data = getFieldsValue();
|
||||
let params = Object.assign({}, formData, data);
|
||||
console.log('表单数据', params);
|
||||
await saveOrUpdate(params, true);
|
||||
}
|
||||
|
||||
initFormData();
|
||||
|
||||
return {
|
||||
registerForm,
|
||||
formDisabled,
|
||||
submitForm,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" name="OroqenHeritageProjectForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, unref, reactive } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from '../OroqenHeritageProject.data';
|
||||
import { saveOrUpdate } from '../OroqenHeritageProject.api';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getDateByPicker } from '/@/utils';
|
||||
const { createMessage } = useMessage();
|
||||
// Emits声明
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
//表单配置
|
||||
const [registerForm, { setProps, resetFields, setFieldsValue, validate, scrollToField }] = useForm({
|
||||
labelWidth: 150,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
//表单赋值
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
//重置表单
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !!data?.showFooter;
|
||||
if (unref(isUpdate)) {
|
||||
//表单赋值
|
||||
await setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
}
|
||||
// 隐藏底部时禁用整个表单
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
//日期个性化选择
|
||||
const fieldPickers = reactive({});
|
||||
//设置标题
|
||||
const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑'));
|
||||
//表单提交事件
|
||||
async function handleSubmit(v) {
|
||||
try {
|
||||
let values = await validate();
|
||||
// 预处理日期数据
|
||||
changeDateValue(values);
|
||||
setModalProps({ confirmLoading: true });
|
||||
//提交表单
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeModal();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} catch ({ errorFields }) {
|
||||
if (errorFields) {
|
||||
const firstField = errorFields[0];
|
||||
if (firstField) {
|
||||
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
return Promise.reject(errorFields);
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理日期值
|
||||
* @param formData 表单数据
|
||||
*/
|
||||
const changeDateValue = (formData) => {
|
||||
if (formData && fieldPickers) {
|
||||
for (let key in fieldPickers) {
|
||||
if (formData[key]) {
|
||||
formData[key] = getDateByPicker(formData[key], fieldPickers[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
/** 时间和数字输入框样式 */
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.ant-calendar-picker) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user