Commit 97be610e authored by 张子雨's avatar 张子雨

feat: 接口联调

parent f6093a53
......@@ -34,6 +34,7 @@ const prodApi = {
querysApi: 'https://sc-merchant-api.q-gp.com/admin/merchant/sc-settlement',
wsApi: 'wss://push.q-gp.com',
msgApi: 'https://msgapi.q-gp.com',
keystoneApi: '//sc-op-api.q-gp.com',
apiPrefix,
};
......@@ -48,6 +49,7 @@ const preProdApi = {
querysApi: 'https://sc-settlement-api.q-gp.com',
wsApi: 'wss://push.q-gp.com',
msgApi: 'https://msgapi.q-gp.com',
keystoneApi: '//sc-op-api-pre.q-gp.com',
apiPrefix,
};
......
......@@ -5,13 +5,13 @@ import { apiStaffBlack } from '../service';
const { Item } = Form;
const BlacklistModal = ({ visible, onClose, list, employeeId }) => {
const BlacklistModal = ({ visible, onClose, list, enterpriseId }) => {
const [form] = Form.useForm();
const handleSave = () => {
form.validateFields().then(values => {
const params = {
employeeId,
enterpriseId,
ids: list,
isBlack: 1,
balanceBackFlag: 1,
......@@ -33,7 +33,7 @@ const BlacklistModal = ({ visible, onClose, list, employeeId }) => {
</Item>
<Item name="reason" label="加入黑名单吗?">
<div className={styles.blackList}>
<Checkbox disabled></Checkbox>
<Checkbox defaultChecked disabled></Checkbox>
<div className={styles.left}>
<span>请确定要回收员工账户内的剩余余额&餐券吗? </span>
<br />
......
import React, { useState } from 'react';
import { Modal, Form, Input, Button, Select, message, Upload, Radio } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import { apiStaffSave, apiStaffExcel } from '../service';
import { apiStaffSave, apiStaffExcel, apiDepartmentList } from '../service';
import styles from '../index.less';
const { Dragger } = Upload;
......@@ -12,10 +12,10 @@ const layout = {
wrapperCol: { span: 16 },
};
const NewEmployeeModal = props => {
const { departmentList, visible, onClose, enterpriseList, getDepartmentList } = props;
const { visible, onClose, enterpriseList } = props;
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
const [importMode, setImportMode] = useState(false);
const [departmentList, setDepartmentList] = useState([]);
const handleCancel = val => {
form.resetFields();
setImportMode(false);
......@@ -23,7 +23,6 @@ const NewEmployeeModal = props => {
};
const handleSave = () => {
form.validateFields().then(async values => {
setLoading(true);
if (importMode) {
const res = await apiStaffExcel(values);
if (res.businessCode === '0000') {
......@@ -34,7 +33,6 @@ const NewEmployeeModal = props => {
}
const res = await apiStaffSave(values);
if (res.businessCode === '0000') {
setLoading(false);
message.success('保存成功');
handleCancel(true);
}
......@@ -51,6 +49,20 @@ const NewEmployeeModal = props => {
return Promise.reject('请输入有效的手机号码');
};
// 部门查询
const getDepartmentList = async id => {
const res = await apiDepartmentList({ data: { enterpriseId: id }, page: 1, size: 10000 });
if (res.businessCode === '0000' && res.data?.records?.length) {
const list = res.data.records;
const optionData = list.map(item => ({
value: item.id,
label: item.name,
}));
setDepartmentList(optionData);
return;
}
setDepartmentList([]);
};
const onChange = value => {
getDepartmentList(value);
};
......@@ -63,7 +75,7 @@ const NewEmployeeModal = props => {
<Button key="cancel" onClick={onClose}>
取消
</Button>,
<Button key="save" type="primary" loading={loading} onClick={handleSave}>
<Button key="save" type="primary" onClick={handleSave}>
保存
</Button>,
]}
......@@ -141,7 +153,6 @@ const NewEmployeeModal = props => {
</>
) : (
<>
{' '}
<Form.Item
name="departmentId"
label="部门"
......
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Modal, Form, Input, Button, Table, Space, Row, Col, Select, message } from 'antd';
import { apiDepartmentList, apiDepartmentUpdate } from '../service';
......@@ -9,47 +9,45 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
const [refForm] = Form.useForm();
const [dataSource, setDataSource] = useState([]);
const [nameVisible, setNameVisible] = useState(false);
const [value, setValue] = useState('');
const [enterpriseId, setEnterpriseId] = useState('');
const [name, setName] = useState('');
const [id, setId] = useState('');
const [pagination, setPagination] = useState({
const [total, setTotal] = useState(0);
const [pageInfo, setPageInfo] = useState({
page: 1,
size: 10,
});
const handleCancel = () => {
form.resetFields();
setDataSource([]);
setPageInfo({ page: 1, size: 10 });
setTotal(0);
onClose();
};
const editName = row => {
setName(row.department);
setName(row.name);
setId(row.id);
setNameVisible(true);
};
const handleSearch = async values => {
setPagination({ ...pagination, page: 1 });
setValue(value);
const res = await apiDepartmentList({ value, ...pagination });
if (res.businessCode === '0000' && res.data?.records?.length) {
const getDepartmentList = async params => {
const res = await apiDepartmentList(params);
if (res.businessCode === '0000') {
const list = res.data.records;
const optionData = list.map(item => ({
value: item.id,
label: item.name,
}));
setDataSource(optionData);
setTotal(res.data.total);
setDataSource(list);
}
};
const handleTableChange = (pag, filters, sorter) => {
setPagination(pag);
handleSearch();
const handleSearch = async values => {
setEnterpriseId(values.enterpriseId);
getDepartmentList({ data: { enterpriseId: values.enterpriseId }, ...pageInfo });
};
const handleSave = () => {
form.validateFields().then(async values => {
refForm.validateFields().then(async values => {
const params = {
enterpriseId: form.id,
enterpriseId,
id,
name: values.name,
};
......@@ -57,7 +55,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
if (res.businessCode === '0000') {
message.success('修改成功');
setNameVisible(false);
handleSearch();
getDepartmentList({ data: { enterpriseId: values.enterpriseId }, ...pageInfo });
}
});
};
......@@ -69,18 +67,18 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
},
{
title: '部门',
dataIndex: 'department',
key: 'department',
dataIndex: 'name',
key: 'name',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
dataIndex: 'createdAt',
key: 'createdAt',
},
{
title: '创建人',
dataIndex: 'creator',
key: 'creator',
dataIndex: 'createdBy',
key: 'createdBy',
},
{
title: '操作',
......@@ -88,20 +86,39 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
key: 'operation',
render: (_, record) => (
<Space>
<Button type="link" onClick={editName(record)}>
<Button type="link" onClick={() => editName(record)}>
修改部门名称
</Button>
</Space>
),
},
];
const onCancel = () => {
setNameVisible(false);
setName('');
};
const onChange = (page, size) => {
const json = {
page,
size,
};
setPageInfo(json);
getDepartmentList({ data: { enterpriseId }, ...json });
};
const pagination = {
...pageInfo,
total,
showTotal: t => `共 ${t} 项数据`,
onChange,
onShowSizeChange: onChange,
};
return (
<Modal visible={visible} onCancel={handleCancel} width={800} footer={null} title="查看部门">
<Form form={form} onFinish={handleSearch}>
<Row gutter={16}>
<Col span={10}>
<Item name="id" style={{ width: '300px' }}>
<Item name="enterpriseId" style={{ width: '300px' }}>
<Select
placeholder="请选择企业"
allowClear
......@@ -125,25 +142,28 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
<Table
dataSource={dataSource}
columns={columns}
pagination={pagination}
onChange={handleTableChange}
bordered
rowKey={r => r.id}
pagination={pagination}
/>
<Modal
title="修改部门名称"
visible={nameVisible}
footer={[
<Button key="cancel">取消</Button>,
<Button key="cancel" onClick={onCancel}>
取消
</Button>,
<Button key="save" type="primary" onClick={() => handleSave()}>
保存
</Button>,
]}
onCancel={onCancel}
>
<Form form={refForm}>
<Form.Item
label="部门名称"
name="name"
initialValues={name}
initialValue={name}
rules={[{ required: true, message: '请填写部门名称' }]}
>
<Input />
......
......@@ -51,14 +51,11 @@ export const columns = props => [
key: 'isLimit',
dataIndex: 'isLimit',
align: 'center',
width: '150px',
render: (_, row) => (
<>
<Switch
checkedChildren="限额"
unCheckedChildren="不限额"
defaultChecked={row?.isLimit}
onChange={val => props.handleLimitChange(val, row)}
/>
<Switch defaultChecked={row?.isLimit} onChange={val => props.handleLimitChange(val, row)} />
&nbsp;<span>{row?.isLimit ? '已开启' : '已关闭'}</span>
</>
),
},
......
This diff is collapsed.
......@@ -9,7 +9,7 @@ const { goodsApi, apiPrefix, keystoneApi } = config;
// http://yapi.quantgroups.com/project/389/interface/api/65359
export const apiStaffList = async params => {
const data = await request.post(`${apiPrefix}/enterprise/staff/pageList`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -32,7 +32,7 @@ export const apiEnterpriseList = async () => {
// http://yapi.quantgroups.com/project/389/interface/api/65344
export const apiDepartmentList = async params => {
const data = await request.post(`${apiPrefix}/enterprise/department/pageList`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -42,7 +42,7 @@ export const apiDepartmentList = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65364
export const apiStaffSave = async params => {
const data = await request.post(`${apiPrefix}/enterprise/staff/save`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -51,11 +51,12 @@ export const apiStaffSave = async params => {
// [企业员工]-导入员工
// http://yapi.quantgroups.com/project/389/interface/api/65384
export const apiStaffExcel = async file => {
console.log(file);
const params = new FormData();
params.append('file', file.file);
params.append('file', file.file.file);
params.append('enterpriseId', file.enterpriseId);
const data = await request.post(`${apiPrefix}/enterprise/staff/excel`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -65,7 +66,7 @@ export const apiStaffExcel = async file => {
// http://yapi.quantgroups.com/project/389/interface/api/65349
export const apiDepartmentSave = async params => {
const data = await request.post(`${apiPrefix}/enterprise/department/save`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -75,10 +76,10 @@ export const apiDepartmentSave = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65354
export const apiDepartmentExcel = async file => {
const params = new FormData();
params.append('file', file.file);
params.append('file', file.file.file);
params.append('enterpriseId', file.enterpriseId);
const data = await request.post(`${apiPrefix}/enterprise/department/excel`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -88,7 +89,7 @@ export const apiDepartmentExcel = async file => {
// http://yapi.quantgroups.com/project/389/interface/api/65374
export const apiStaffDelete = async params => {
const data = await request.post(`${apiPrefix}/enterprise/staff/delete`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -98,7 +99,7 @@ export const apiStaffDelete = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65474
export const apiDepartmentUpdate = async params => {
const data = await request.post(`${apiPrefix}/enterprise/department/update`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -108,7 +109,7 @@ export const apiDepartmentUpdate = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65489
export const apiGenerateLogList = async params => {
const data = await request.get(`${apiPrefix}/enterprise/staff/generateLog/list`, {
prefix: goodsApi,
prefix: keystoneApi,
params,
});
return data;
......@@ -118,7 +119,7 @@ export const apiGenerateLogList = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65379
export const apiStaffLimit = async params => {
const data = await request.post(`${apiPrefix}/enterprise/staff/limit`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -128,7 +129,7 @@ export const apiStaffLimit = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65369
export const apiStaffBlack = async params => {
const data = await request.post(`${apiPrefix}/enterprise/staff/black`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......
......@@ -4,11 +4,12 @@ import { stringify } from 'qs';
import _ from 'lodash';
const { goodsApi, apiPrefix, keystoneApi } = config;
console.log(apiPrefix, 'apiPrefix');
// [企业店铺]-列表查询
// http://yapi.quantgroups.com/project/389/interface/api/65284
export const setShopList = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/list`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -18,7 +19,7 @@ export const setShopList = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65319
export const setShopDelete = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/delete`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -28,7 +29,7 @@ export const setShopDelete = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65314
export const mealTypeList = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/mealType/list`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -38,7 +39,7 @@ export const mealTypeList = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65304
export const shopAdd = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/add`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -48,7 +49,7 @@ export const shopAdd = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65309
export const apiShopUpdate = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/update`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -70,7 +71,7 @@ export const apiEnterpriseList = async () => {
// http://yapi.quantgroups.com/project/389/interface/api/65524
export const apiSelectList = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/select/list`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -80,7 +81,7 @@ export const apiSelectList = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65304
export const busineesTypeCheck = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/busineesType/check`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -90,7 +91,7 @@ export const busineesTypeCheck = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65304
export const apiShopAdd = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/add`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......@@ -100,7 +101,7 @@ export const apiShopAdd = async params => {
// http://yapi.quantgroups.com/project/389/interface/api/65534
export const apiSelectedList = async params => {
const data = await request.post(`${apiPrefix}/enterprise/shop/selected/list`, {
prefix: goodsApi,
prefix: keystoneApi,
data: params,
});
return data;
......
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