增加无权限提醒

This commit is contained in:
liamzi
2025-01-15 15:31:08 +08:00
parent e4db203a9f
commit 81008d0159
13 changed files with 68 additions and 50 deletions

View File

@@ -228,8 +228,7 @@ export default function ProjectDetail() {
.select();
}
if (result.error) throw result.error;
if (result.error||result.data.length===0) throw 'error';
message.success("保存成功");
navigate("/company/project");
} catch (error) {

View File

@@ -268,7 +268,10 @@ const QuotationForm = () => {
}
if (result.error) throw result.error;
if(result.length===0){
message.error('暂无权限');
return;
};
message.success("保存成功");
navigate("/company/quotation");
} catch (error) {

View File

@@ -8,9 +8,9 @@ const ProjectTemplate = ({ form, id, isView }) => {
layout="vertical"
disabled={isView}
>
{/* 专案模板特有的字段和组件 */}
<Card>
{/* 项目阶段、时间线等内容 */}
</Card>
</Form>
);

View File

@@ -103,21 +103,17 @@ const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => {
};
if (id) {
// 更新
await supabaseService.update('resources',
{ id },
serviceData
);
await supabaseService.update('resources', { id }, serviceData);
} else {
// 新增
await supabaseService.insert('resources', serviceData);
}
message.success("保存成功");
onCancel();
} catch (error) {
const errorMsg = error instanceof Error ? error.message : '保存失败';
console.error("保存失败:", error);
message.error("保存失败");
message.error(errorMsg);
} finally {
setLoading(false);
}

View File

@@ -104,15 +104,14 @@ const TaskTemplate = ({ id, isView, onCancel,isEdit }) => {
serviceData
);
} else {
// 新增
await supabaseService.insert('resources', serviceData);
}
message.success("保存成功");
onCancel();
} catch (error) {
message.error('保存失败');
console.error("保存失败:", error);
message.error("保存失败");
} finally {
setLoading(false);
}

View File

@@ -7,7 +7,6 @@ import TaskTemplate from './components/TaskTemplate';
const { Title } = Typography;
// 模板类型配置
const TEMPLATE_CONFIG = {
quotation: {
title: '报价单模板',
@@ -36,7 +35,6 @@ const ServiceForm = () => {
if (!currentTemplate) {
return <div>无效的模板类型</div>;
}
return (
<div className="bg-gradient-to-b from-gray-50 to-white dark:from-gray-800 dark:to-gray-900/90 min-h-screen p-2" >
<Card

View File

@@ -88,7 +88,7 @@ const ServicePage = () => {
setData(services || []);
} catch (error) {
console.error("获取服务模板失败:", error);
message.error("获取服<EFBFBD><EFBFBD><EFBFBD>模板失败");
message.error("获取服模板失败");
} finally {
setLoading(false);
}
@@ -127,7 +127,7 @@ const ServicePage = () => {
fetchServices();
} catch (error) {
console.error("删除失败:", error);
message.error("删除失败");
message.error(error);
}
};
@@ -173,7 +173,7 @@ const ServicePage = () => {
}
} catch (error) {
console.error("保存失败:", error);
message.error("保存失败");
message.error(error);
}
};

View File

@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
import { Form, Input, Select, Button, Space, Card, Typography } from 'antd';
import { Form, Input, Select, Button, Space, Card, Typography, message } from 'antd';
import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons';
import { supabase } from '@/config/supabase';
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
@@ -22,9 +22,8 @@ const SupplierForm = () => {
.select('*')
.eq('id', id)
.single();
if (error) throw error;
if (id) {
// 设置表单初始值
form.setFieldsValue({
@@ -74,10 +73,14 @@ const SupplierForm = () => {
.insert([supplierData])
.select();
}
if(result.data.length===0){
message.error('暂无权限');
return;
};
if (result.error) throw result.error;
navigate('/company/supplier');
} catch (error) {
message.error('暂无权限');
console.error('保存失败:', error);
}
};

View File

@@ -251,9 +251,7 @@ const TaskPage = () => {
setLoading(true);
const newAttributes = JSON.parse(JSON.stringify(record.attributes));
// 修改任务名称,添加"副本"标识
newAttributes.taskName = `${newAttributes.taskName} (副本)`;
const { data, error } = await supabase
.from("resources")
.insert([
@@ -261,10 +259,12 @@ const TaskPage = () => {
type: "task",
attributes: newAttributes,
},
]);
]).select()
if(!data||data?.length===0){
message.error('暂无权限');
return;
};
if (error) throw error;
message.success("复制成功");
fetchTasks(); // 刷新列表
} catch (error) {