|
|
@@ -1,6 +1,10 @@
|
|
|
-import React, { useRef } from 'react'
|
|
|
-import { Tabs, Tag } from 'antd'
|
|
|
+import React, { useState, useRef } from 'react'
|
|
|
+import { Button, Tabs, Tag, message } from 'antd'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
+import consts from '@/consts'
|
|
|
+import { useDispatch } from 'dva'
|
|
|
+import UpgradeModal, { titleType, upgradeTypeEnum, lockTypeEnum } from './UpgradeModal'
|
|
|
+import { apiRoadPricingUpgrade } from '@/services/product'
|
|
|
|
|
|
export const lockEnum = {
|
|
|
1: '借出',
|
|
|
@@ -12,13 +16,15 @@ const RoadpricingTabList = props => {
|
|
|
const {
|
|
|
compilationList,
|
|
|
cloudUser: { online_list = [] },
|
|
|
- projectType
|
|
|
+ projectType,
|
|
|
+ ssoId
|
|
|
} = props
|
|
|
const isUpgradeEnum = {
|
|
|
true: '已升级',
|
|
|
undefined: ''
|
|
|
}
|
|
|
const { TabPane } = Tabs
|
|
|
+ const dispatch = useDispatch()
|
|
|
const tRef = useRef(null)
|
|
|
const titleEnum = {
|
|
|
1: '养护云造价',
|
|
|
@@ -26,6 +32,32 @@ const RoadpricingTabList = props => {
|
|
|
3: '公路云计价',
|
|
|
4: '大司空概算'
|
|
|
}
|
|
|
+ const [roadPricingUpgrade, setRoadPricingUpgrade] = useState({
|
|
|
+ type: '',
|
|
|
+ compilationId: '',
|
|
|
+ compilationName: '',
|
|
|
+ upgradeTypeEnum: '',
|
|
|
+ lockTypeEnum: '',
|
|
|
+ visible: false,
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ const handleRoadPricingUpgrade = async values => {
|
|
|
+ setRoadPricingUpgrade({ ...roadPricingUpgrade, loading: true })
|
|
|
+ const { code = -1 } = await apiRoadPricingUpgrade({
|
|
|
+ ...values,
|
|
|
+ ssoId
|
|
|
+ })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ message.success('新增成功')
|
|
|
+ // 请求完了
|
|
|
+ setRoadPricingUpgrade({ ...roadPricingUpgrade, loading: false, visible: false })
|
|
|
+ // 刷新数据
|
|
|
+ dispatch({
|
|
|
+ type: 'refresh/commitAction',
|
|
|
+ payload: 'cloud'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
const columns = [
|
|
|
{
|
|
|
title: '产品',
|
|
|
@@ -53,8 +85,106 @@ const RoadpricingTabList = props => {
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
|
- // dataIndex: 'deadline',
|
|
|
- width: '25%'
|
|
|
+ width: '25%',
|
|
|
+ render: (_, record) => (
|
|
|
+ <>
|
|
|
+ {record.isUpgrade ? (
|
|
|
+ <>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ size="small"
|
|
|
+ className="m-2px"
|
|
|
+ onClick={() =>
|
|
|
+ setRoadPricingUpgrade({
|
|
|
+ ...setRoadPricingUpgrade,
|
|
|
+ visible: true,
|
|
|
+ type: titleType.GIVE,
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
+ compilationId: record._id,
|
|
|
+ compilationName: record.name,
|
|
|
+ lockTypeEnum: lockTypeEnum.GIVE,
|
|
|
+ upgradeTypeEnum: upgradeTypeEnum.UPGRADE
|
|
|
+ })
|
|
|
+ }>
|
|
|
+ 赠送
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ size="small"
|
|
|
+ className="m-2px"
|
|
|
+ onClick={() =>
|
|
|
+ setRoadPricingUpgrade({
|
|
|
+ ...setRoadPricingUpgrade,
|
|
|
+ visible: true,
|
|
|
+ type: titleType.DEMOTION
|
|
|
+ })
|
|
|
+ }>
|
|
|
+ 降级
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ size="small"
|
|
|
+ onClick={() =>
|
|
|
+ setRoadPricingUpgrade({
|
|
|
+ ...setRoadPricingUpgrade,
|
|
|
+ visible: true,
|
|
|
+ type: titleType.DEADLINE
|
|
|
+ })
|
|
|
+ }>
|
|
|
+ 限期
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ ) : (
|
|
|
+ <>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ size="small"
|
|
|
+ className="m-2px"
|
|
|
+ onClick={() =>
|
|
|
+ setRoadPricingUpgrade({
|
|
|
+ ...setRoadPricingUpgrade,
|
|
|
+ visible: true,
|
|
|
+ type: titleType.GIVE
|
|
|
+ })
|
|
|
+ }>
|
|
|
+ 赠送
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ size="small"
|
|
|
+ className="m-2px"
|
|
|
+ onClick={() =>
|
|
|
+ setRoadPricingUpgrade({
|
|
|
+ ...setRoadPricingUpgrade,
|
|
|
+ visible: true,
|
|
|
+ type: titleType.LEND
|
|
|
+ })
|
|
|
+ }>
|
|
|
+ 借出
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ size="small"
|
|
|
+ className="m-2px"
|
|
|
+ onClick={() =>
|
|
|
+ setRoadPricingUpgrade({
|
|
|
+ ...setRoadPricingUpgrade,
|
|
|
+ visible: true,
|
|
|
+ type: titleType.SALE
|
|
|
+ })
|
|
|
+ }>
|
|
|
+ 销售
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ )
|
|
|
}
|
|
|
]
|
|
|
const columnOnline = [
|
|
|
@@ -103,6 +233,19 @@ const RoadpricingTabList = props => {
|
|
|
</TabPane>
|
|
|
</Tabs>
|
|
|
</div>
|
|
|
+ <UpgradeModal
|
|
|
+ onConfirm={handleRoadPricingUpgrade}
|
|
|
+ loading={roadPricingUpgrade.loading}
|
|
|
+ visible={roadPricingUpgrade.visible}
|
|
|
+ type={roadPricingUpgrade.type}
|
|
|
+ onCancel={() => setRoadPricingUpgrade({ ...roadPricingUpgrade, visible: false })}
|
|
|
+ projectType={projectType}
|
|
|
+ ssoId={ssoId}
|
|
|
+ compilationId={roadPricingUpgrade.compilationId}
|
|
|
+ compilationName={roadPricingUpgrade.compilationName}
|
|
|
+ lock={roadPricingUpgrade.lockTypeEnum}
|
|
|
+ upgradeType={roadPricingUpgrade.upgradeTypeEnum}
|
|
|
+ />
|
|
|
</div>
|
|
|
)
|
|
|
}
|