Commit 315b92db authored by 张子雨's avatar 张子雨

feat: 代码优化

parent 31bbc3be
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import * as Sentry from '@sentry/react'; import * as Sentry from '@sentry/react';
import localStorage from '@/utils/localStorage'; import localStorage from '@/utils/localStorage';
if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production') { if (process.env.SENTRY_ENV !== 'prod' && process.env.NODE_ENV === 'production') {
try { try {
Sentry.init({ Sentry.init({
dsn: 'https://b3f60c62e1234e26a5b851b9f26fba07@sentry.q-gp.com/34', dsn: 'https://b3f60c62e1234e26a5b851b9f26fba07@sentry.q-gp.com/34',
......
...@@ -8,21 +8,19 @@ const { Item } = Form; ...@@ -8,21 +8,19 @@ const { Item } = Form;
const BlacklistModal = ({ visible, onClose, list, enterpriseId, selectedRows }) => { const BlacklistModal = ({ visible, onClose, list, enterpriseId, selectedRows }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const handleSave = () => { const handleSave = async () => {
form.validateFields().then(values => { const values = await form.validateFields();
const params = { const params = {
enterpriseId, enterpriseId,
ids: list, ids: list,
isBlack: 1, isBlack: 1,
balanceBackFlag: 1, balanceBackFlag: 1,
}; };
apiStaffBlack(params).then(res => { const res = apiStaffBlack(params);
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
message.success('设置成功'); message.success('设置成功');
onClose(true, 'blacklist'); onClose(true, 'blacklist');
} }
});
});
}; };
return ( return (
......
...@@ -46,20 +46,19 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -46,20 +46,19 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
file: values.file, file: values.file,
}; };
const res = await apiDepartmentExcel(params); const res = await apiDepartmentExcel(params);
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
message.success('保存成功'); message.success('保存成功');
handleCancel(true); handleCancel(true);
} }
}; };
const handleSave = () => { const handleSave = async () => {
form.validateFields().then(values => { const values = await form.validateFields();
if (importMode) { if (importMode) {
getDepartmentExcel(values); getDepartmentExcel(values);
return; return;
} }
getDepartmentSave(values); getDepartmentSave(values);
});
}; };
return ( return (
......
...@@ -21,22 +21,21 @@ const NewEmployeeModal = props => { ...@@ -21,22 +21,21 @@ const NewEmployeeModal = props => {
setImportMode(false); setImportMode(false);
onClose(val, 'newEmployee'); onClose(val, 'newEmployee');
}; };
const handleSave = () => { const handleSave = async () => {
form.validateFields().then(async values => { const values = await form.validateFields();
if (importMode) { if (importMode) {
const res = await apiStaffExcel(values); const res = await apiStaffExcel(values);
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
message.success('上传成功'); message.success('上传成功');
handleCancel(true); handleCancel(true);
} }
return; return;
} }
const res = await apiStaffSave(values); const res = await apiStaffSave(values);
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
message.success('保存成功'); message.success('保存成功');
handleCancel(true); handleCancel(true);
} }
});
}; };
const validatePhone = (_, value) => { const validatePhone = (_, value) => {
...@@ -51,7 +50,7 @@ const NewEmployeeModal = props => { ...@@ -51,7 +50,7 @@ const NewEmployeeModal = props => {
// 部门查询 // 部门查询
const getDepartmentList = async id => { const getDepartmentList = async id => {
const res = await apiDepartmentList({ data: { enterpriseId: id }, page: 1, size: 10000 }); const res = await apiDepartmentList({ data: { enterpriseId: id }, page: 1, size: 10000 });
if (res.businessCode === '0000' && res.data?.records?.length) { if (res?.businessCode === '0000' && res.data?.records?.length) {
const list = res.data.records; const list = res.data.records;
const optionData = list.map(item => ({ const optionData = list.map(item => ({
value: item.id, value: item.id,
......
...@@ -53,7 +53,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -53,7 +53,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
name: values.name, name: values.name,
}; };
const res = await apiDepartmentUpdate(params); const res = await apiDepartmentUpdate(params);
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
message.success('修改成功'); message.success('修改成功');
setNameVisible(false); setNameVisible(false);
getDepartmentList({ data: { enterpriseId }, ...pageInfo }); getDepartmentList({ data: { enterpriseId }, ...pageInfo });
......
...@@ -94,7 +94,7 @@ const StoreManagement = () => { ...@@ -94,7 +94,7 @@ const StoreManagement = () => {
// 部门查询 // 部门查询
const getDepartmentList = async id => { const getDepartmentList = async id => {
const res = await apiDepartmentList({ data: { enterpriseId: id }, page: 1, size: 10000 }); const res = await apiDepartmentList({ data: { enterpriseId: id }, page: 1, size: 10000 });
if (res.businessCode === '0000' && res.data?.records?.length) { if (res?.businessCode === '0000' && res.data?.records?.length) {
const list = res.data.records; const list = res.data.records;
const optionData = list.map(item => ({ const optionData = list.map(item => ({
value: item.id, value: item.id,
...@@ -140,7 +140,7 @@ const StoreManagement = () => { ...@@ -140,7 +140,7 @@ const StoreManagement = () => {
// 企业查询 // 企业查询
const getEnterpriseList = async () => { const getEnterpriseList = async () => {
const res = await apiEnterpriseList(); const res = await apiEnterpriseList();
if (res.businessCode === '0000' && res.data?.records?.length) { if (res?.businessCode === '0000' && res.data?.records?.length) {
const list = res.data.records; const list = res.data.records;
const firstOption = list[0].id; const firstOption = list[0].id;
const optionData = list.map(item => ({ const optionData = list.map(item => ({
...@@ -169,7 +169,7 @@ const StoreManagement = () => { ...@@ -169,7 +169,7 @@ const StoreManagement = () => {
// 删除 // 删除
const deleteEmployee = async id => { const deleteEmployee = async id => {
const res = await apiStaffDelete({ id, enterpriseId: searchForm.enterpriseId, state: 0 }); const res = await apiStaffDelete({ id, enterpriseId: searchForm.enterpriseId, state: 0 });
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
message.success('删除成功!'); message.success('删除成功!');
shopList({ ...page, data: searchForm }); shopList({ ...page, data: searchForm });
} }
...@@ -219,7 +219,7 @@ const StoreManagement = () => { ...@@ -219,7 +219,7 @@ const StoreManagement = () => {
const goDetails = async ({ staffNo }) => { const goDetails = async ({ staffNo }) => {
setRechargeDetailsVisible(true); setRechargeDetailsVisible(true);
const res = await apiGenerateLogList({ staffNo, enterpriseId: searchForm.enterpriseId }); const res = await apiGenerateLogList({ staffNo, enterpriseId: searchForm.enterpriseId });
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
const list = res.data; const list = res.data;
setGenerateLog(list); setGenerateLog(list);
} }
...@@ -230,7 +230,7 @@ const StoreManagement = () => { ...@@ -230,7 +230,7 @@ const StoreManagement = () => {
isLimit: checked ? 1 : 0, isLimit: checked ? 1 : 0,
enterpriseId: searchForm.enterpriseId, enterpriseId: searchForm.enterpriseId,
}); });
if (res.businessCode === '0000') { if (res?.businessCode === '0000') {
message.success('设置成功'); message.success('设置成功');
shopList({ ...page, data: searchForm }); shopList({ ...page, data: searchForm });
} }
......
...@@ -456,7 +456,7 @@ export const getDefaultRule = data => { ...@@ -456,7 +456,7 @@ export const getDefaultRule = data => {
// 输入空格校验 // 输入空格校验
export const validateSpaces = (rule, value, callback) => { export const validateSpaces = (rule, value, callback) => {
// 输入不能包括空格 // 输入不能包括空格
if (value && value.includes(' ')) { if (value?.includes(' ')) {
// eslint-disable-next-line prefer-promise-reject-errors // eslint-disable-next-line prefer-promise-reject-errors
return Promise.reject('输入不能为空格'); return Promise.reject('输入不能为空格');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment