Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
f2ce8723
提交
f2ce8723
authored
7月 06, 2023
作者:
ZhangLingKun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
功能:租赁租期默认,租期时间判断
上级
3f2825d3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
69 行增加
和
19 行删除
+69
-19
.eslintrc.json
.eslintrc.json
+6
-1
[id].page.tsx
pages/equipmentLeasing/detail/[id].page.tsx
+63
-18
没有找到文件。
.eslintrc.json
浏览文件 @
f2ce8723
...
...
@@ -7,6 +7,9 @@
"extends"
:
[
"airbnb-base"
,
"next/core-web-vitals"
,
"plugin:react/recommended"
,
"plugin:react-hooks/recommended"
,
"plugin:jsx-a11y/recommended"
,
"plugin:prettier/recommended"
],
"rules"
:
{
...
...
@@ -69,7 +72,9 @@
"unused-imports/no-unused-vars"
:
[
"error"
,
{
"argsIgnorePattern"
:
"^_"
}
]
],
"jsx-a11y/click-events-have-key-events"
:
"off"
,
"jsx-a11y/no-static-element-interactions"
:
"off"
}
}
]
...
...
pages/equipmentLeasing/detail/[id].page.tsx
浏览文件 @
f2ce8723
...
...
@@ -14,6 +14,7 @@ import {
DatePicker
,
}
from
'antd'
;
import
{
RangePickerProps
}
from
'antd/es/date-picker'
;
import
dayjs
from
'dayjs'
;
import
moment
from
'moment'
;
import
Image
from
'next/image'
;
import
{
useRouter
}
from
'next/router'
;
...
...
@@ -23,6 +24,7 @@ import { UserContext } from '~/lib/userProvider';
import
api
,
{
GetWebDeviceDetailResult
,
GetWebDeviceWareSkuById
,
GetLeaseGoodsResult
}
from
'./api'
;
import
flowPat
from
'./assets/flow-path.png'
;
// eslint-disable-next-line import/no-cycle
import
OrderForGoods
from
'./components/orderForGoods'
;
import
ImagePreview
from
'./components/picture-preview'
;
import
{
Box
}
from
'./styled'
;
...
...
@@ -75,10 +77,10 @@ export default function EquipmentLeasingDetail() {
const
[
form
]
=
Form
.
useForm
();
const
[
formDate
]
=
Form
.
useForm
();
const
tagsData
=
[
{
id
:
0
,
label
:
'1-7天'
,
disable
:
false
},
{
id
:
1
,
label
:
'8-15天'
,
disable
:
false
},
{
id
:
2
,
label
:
'16-30天'
,
disable
:
false
},
{
id
:
3
,
label
:
'3
0天以上'
,
disable
:
false
},
{
id
:
0
,
label
:
'1-7天'
,
disable
:
false
,
minDay
:
1
,
maxDay
:
7
},
{
id
:
1
,
label
:
'8-15天'
,
disable
:
false
,
minDay
:
8
,
maxDay
:
15
},
{
id
:
2
,
label
:
'16-30天'
,
disable
:
false
,
minDay
:
16
,
maxDay
:
30
},
{
id
:
3
,
label
:
'3
1天以上'
,
disable
:
false
,
minDay
:
31
,
maxDay
:
-
1
},
];
const
[
discount
,
setDiscount
]
=
useState
<
GetLeaseGoodsResult
|
null
>
();
...
...
@@ -86,6 +88,17 @@ export default function EquipmentLeasingDetail() {
const
[
selectedTagsData
,
setSelectedTagsData
]
=
useState
<
number
>
();
const
[
shopDetail
,
setShopDetail
]
=
useState
<
ShopDetail
>
();
// 获取价格
const
getPrice
=
(
tag
:
number
)
=>
{
const
Id
=
wareSkuList
?.
filter
((
item
)
=>
item
.
id
===
form
.
getFieldValue
(
'id'
))[
0
].
productSpec
;
if
(
Id
)
{
api
.
GoodsPriceDetail
({
leaseTerm
:
tag
,
productSpecId
:
Id
}).
then
((
res
)
=>
{
setDiscount
(
res
.
result
);
});
}
};
// 显示弹窗
const
showModal
=
()
=>
{
if
(
userInfo
)
{
setIsModalOpen
(
true
);
...
...
@@ -101,14 +114,32 @@ export default function EquipmentLeasingDetail() {
}
};
// 租期天数
const
[
days
,
setDays
]
=
useState
<
number
>
();
// 规格弹窗选择规格之后点击提交
const
handleOk
=
()
=>
{
setLoading
(
true
);
form
.
validateFields
()
.
then
(
async
(
values
)
=>
{
.
then
(
async
(
_
values
)
=>
{
setLoading
(
false
);
setIsModalOpen
(
false
);
setIsModalDateOpen
(
true
);
// 当前选择的租期范围
const
leaseTime
=
tagsData
.
find
((
i
)
=>
i
.
id
===
selectedTagsData
);
// 设置日期默认值
formDate
.
setFieldValue
(
'dateDetail'
,
[
dayjs
(),
dayjs
().
add
(
Number
(
leaseTime
?.
minDay
)
>
1
?
Number
(
leaseTime
?.
minDay
)
-
1
:
Number
(
leaseTime
?.
minDay
),
'day'
,
),
]);
// 设置默认天数
setDays
(
leaseTime
?.
minDay
);
})
.
catch
((
err
)
=>
{
message
...
...
@@ -120,9 +151,23 @@ export default function EquipmentLeasingDetail() {
});
};
const
[
days
,
setDays
]
=
useState
<
number
>
();
// 确认租期点击事件
const
handleOkDate
=
async
()
=>
{
// 当前选择的租期范围
const
leaseTime
=
tagsData
.
find
((
i
)
=>
i
.
id
===
selectedTagsData
);
// 判断租期
if
(
leaseTime
?.
maxDay
===
-
1
&&
Number
(
days
)
<
Number
(
leaseTime
?.
minDay
))
{
message
.
warning
(
`租期最少
${
leaseTime
?.
minDay
}
天
`);
return;
}
if (leaseTime?.maxDay !== -1 && Number(leaseTime) < Number(leaseTime?.minDay)) {
message.warning(`
租期至少
$
{
leaseTime
?.
minDay
}
天
`);
return;
}
if (leaseTime?.maxDay !== -1 && Number(days) > Number(leaseTime?.maxDay)) {
message.warning(`
租期最多
$
{
leaseTime
?.
maxDay
}
天
`);
return;
}
setLoading(true);
try {
const result = await Promise.all([form.validateFields(), formDate.validateFields()]);
...
...
@@ -153,6 +198,7 @@ export default function EquipmentLeasingDetail() {
}
};
// 选择租期点击事件
const handleChangeDate = (tag: number, checked: boolean, disable: boolean) => {
if (checked && !disable) {
const nextSelectedTags = checked ? tag : tagsData.filter((t) => t.id !== tag)[0].id;
...
...
@@ -162,23 +208,22 @@ export default function EquipmentLeasingDetail() {
}
};
const
getPrice
=
(
tag
:
number
)
=>
{
const
Id
=
wareSkuList
?.
filter
((
item
)
=>
item
.
id
===
form
.
getFieldValue
(
'id'
))[
0
].
productSpec
;
if
(
Id
)
{
api
.
GoodsPriceDetail
({
leaseTerm
:
tag
,
productSpecId
:
Id
}).
then
((
res
)
=>
{
setDiscount
(
res
.
result
);
});
}
};
const onChangeNum = (value: number | string | null) => {
console.log('changed', value);
};
// 选择租期返回事件
const goBack = () => {
// 日期选择弹窗隐藏
setIsModalDateOpen(false);
// 租赁弹窗显示
setIsModalOpen(true);
// 重置日期选择表单
formDate.resetFields();
};
const
onchanges
=
(
values
:
any
)
=>
{
// 租期选择监听事件
const onDateChanges = (values: any) => {
if (values) {
const day = new Date(values[1]).getTime() - new Date(values[0]).getTime();
const totalDays = Math.floor(day / (1000 * 3600 * 24));
...
...
@@ -397,7 +442,7 @@ export default function EquipmentLeasingDetail() {
<RangePicker
style={{ width: 376, marginTop: 10 }}
disabledDate={disabledDate}
onChange=
{
on
c
hanges
}
onChange={on
DateC
hanges}
/>
</Form.Item>
</Form>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论