增加 zustand 框架,删除切换供应商相关页面
parent
696f2bb816
commit
7f3ed0b42c
@ -1,113 +0,0 @@
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useEffect, useState, useRef } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Button, Space, Form, Input, Row, Typography, App,Select } from "antd";
|
||||
import { useStore } from "@/stores/StoreContext.js";
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
function ChangeVendor() {
|
||||
const navigate = useNavigate();
|
||||
const { authStore,VendorList } = useStore();
|
||||
const { notification } = App.useApp();
|
||||
const [form] = Form.useForm();
|
||||
const { formVeiSn, onVeiSnChange } = useState();
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
authStore.fetchVendorList();
|
||||
},[]);
|
||||
|
||||
//币种
|
||||
function bindVendor() {
|
||||
|
||||
let arr=[];
|
||||
arr = authStore.VendorList.map((data,index) =>{
|
||||
return {
|
||||
value: data.VEI_SN,
|
||||
label: data.VEI2_CompanyBN,
|
||||
}
|
||||
})
|
||||
return arr;
|
||||
|
||||
}
|
||||
|
||||
const onFinish = (values) => {
|
||||
if (values.VEISN == authStore.login.travelAgencyId){
|
||||
notification.error({
|
||||
message: `Notification`,
|
||||
description: "切换的供应商是当前供应商.",
|
||||
placement: "top",
|
||||
duration: 4,
|
||||
});
|
||||
return ;
|
||||
}
|
||||
// console.log(values);
|
||||
// console.log(authStore.login.travelAgencyId);
|
||||
|
||||
authStore.changeVendor(values.VEISN)
|
||||
.then(()=>{
|
||||
authStore.logout();
|
||||
})
|
||||
.catch(()=>{
|
||||
//console.log(json);
|
||||
notification.error({
|
||||
message: `Notification`,
|
||||
description: "切换的供应商错误,请重试!",
|
||||
placement: "top",
|
||||
duration: 4,
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
const onFinishFailed = (errorInfo) => {
|
||||
console.log("Failed:", errorInfo);
|
||||
// form.resetFields();
|
||||
};
|
||||
|
||||
return (
|
||||
<Row justify="center" align="middle" style={{ minHeight: 500 }}>
|
||||
<Form
|
||||
name="basic"
|
||||
form={form}
|
||||
layout="vertical"
|
||||
size="large"
|
||||
style={{
|
||||
maxWidth: 600,
|
||||
}}
|
||||
onFinish={onFinish}
|
||||
onFinishFailed={onFinishFailed}
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item>
|
||||
<Title level={2}>Change your password</Title>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="VEISN"
|
||||
label="供应商"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: "请选择需要切换的供应商!",
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select
|
||||
placeholder="请选择"
|
||||
onChange={onVeiSnChange}
|
||||
options={bindVendor()}
|
||||
></Select>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space size="middle">
|
||||
<Button type="primary" htmlType="submit">
|
||||
选 择
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export default observer(ChangeVendor);
|
Loading…
Reference in New Issue