|
@@ -0,0 +1,285 @@
|
|
|
|
|
+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 { lockEnum } from '@/pages/Product/Cloud/components/Detail/TabList'
|
|
|
|
|
+import UpgradeModalv2 from './UpgradeModal'
|
|
|
|
|
+import {
|
|
|
|
|
+ upgradeTypeEnum,
|
|
|
|
|
+ lockTypeEnum,
|
|
|
|
|
+ titleType,
|
|
|
|
|
+ modalTitleEnum
|
|
|
|
|
+} from '@/pages/Product/Cloud/components/Detail/UpgradeModal'
|
|
|
|
|
+import { apiRoadPricingUpgradeV2 } from '@/services/product'
|
|
|
|
|
+
|
|
|
|
|
+const PersonalTabList = props => {
|
|
|
|
|
+ const {
|
|
|
|
|
+ compilationList,
|
|
|
|
|
+ cloudUser: { online_list = [], mobile, username },
|
|
|
|
|
+ projectType,
|
|
|
|
|
+ ssoId
|
|
|
|
|
+ } = props
|
|
|
|
|
+ const isUpgradeEnum = {
|
|
|
|
|
+ true: '已升级',
|
|
|
|
|
+ undefined: ''
|
|
|
|
|
+ }
|
|
|
|
|
+ const { TabPane } = Tabs
|
|
|
|
|
+ const dispatch = useDispatch()
|
|
|
|
|
+ const tRef = useRef(null)
|
|
|
|
|
+ const [roadPricingUpgradev2, setRoadPricingUpgradev2] = useState({
|
|
|
|
|
+ type: '',
|
|
|
|
|
+ compilationId: '',
|
|
|
|
|
+ compilationName: '',
|
|
|
|
|
+ upgradeTypeEnum: '',
|
|
|
|
|
+ compilationListName: '',
|
|
|
|
|
+ deadline: '',
|
|
|
|
|
+ lockTypeEnum: '',
|
|
|
|
|
+ visible: false,
|
|
|
|
|
+ loading: false
|
|
|
|
|
+ })
|
|
|
|
|
+ const handleRoadPricingUpgradev2 = async values => {
|
|
|
|
|
+ setRoadPricingUpgradev2({ ...roadPricingUpgradev2, loading: true })
|
|
|
|
|
+ const { code = -1 } = await apiRoadPricingUpgradeV2({
|
|
|
|
|
+ ...values,
|
|
|
|
|
+ ssoId
|
|
|
|
|
+ })
|
|
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
|
|
+ message.success('新增成功')
|
|
|
|
|
+ // 请求完了
|
|
|
|
|
+ setRoadPricingUpgradev2({ ...roadPricingUpgradev2, loading: false, visible: false })
|
|
|
|
|
+ // 刷新数据
|
|
|
|
|
+ dispatch({
|
|
|
|
|
+ type: 'refresh/commitAction',
|
|
|
|
|
+ payload: 'road'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ const columns = [
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '产品',
|
|
|
|
|
+ dataIndex: 'name',
|
|
|
|
|
+ width: '10%',
|
|
|
|
|
+ render: (_, record) => <Tag color="purple">{record.name}</Tag>
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '状态',
|
|
|
|
|
+ dataIndex: 'lock',
|
|
|
|
|
+ onFilter: true,
|
|
|
|
|
+ width: '8%',
|
|
|
|
|
+ render: lock => <span>{lockEnum[lock]}</span>
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '专业版',
|
|
|
|
|
+ dataIndex: 'isUpgrade',
|
|
|
|
|
+ width: '10%',
|
|
|
|
|
+ render: isUpgrade => <span>{isUpgradeEnum[isUpgrade]}</span>
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '限期',
|
|
|
|
|
+ dataIndex: 'deadline',
|
|
|
|
|
+ width: '10%'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '操作',
|
|
|
|
|
+ width: '25%',
|
|
|
|
|
+ render: (_, record) => (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ ghost
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ className="m-2px"
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setRoadPricingUpgradev2({
|
|
|
|
|
+ ...setRoadPricingUpgradev2,
|
|
|
|
|
+ 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>
|
|
|
|
|
+ {record.lock === 1 ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ ghost
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ className="m-2px"
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setRoadPricingUpgradev2({
|
|
|
|
|
+ ...setRoadPricingUpgradev2,
|
|
|
|
|
+ visible: true,
|
|
|
|
|
+ type: titleType.SALE,
|
|
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
|
|
+ compilationId: record._id,
|
|
|
|
|
+ compilationName: record.name,
|
|
|
|
|
+ lockTypeEnum: lockTypeEnum.SALE,
|
|
|
|
|
+ upgradeTypeEnum: upgradeTypeEnum.UPGRADE
|
|
|
|
|
+ })
|
|
|
|
|
+ }>
|
|
|
|
|
+ 销售
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ {record.isUpgrade ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ ghost
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ className="m-2px"
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setRoadPricingUpgradev2({
|
|
|
|
|
+ ...setRoadPricingUpgradev2,
|
|
|
|
|
+ visible: true,
|
|
|
|
|
+ type: titleType.DEMOTION,
|
|
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
|
|
+ compilationId: record._id,
|
|
|
|
|
+ compilationName: record.name,
|
|
|
|
|
+ compilationListName: record.name,
|
|
|
|
|
+ upgradeTypeEnum: upgradeTypeEnum.DEMOTION
|
|
|
|
|
+ })
|
|
|
|
|
+ }>
|
|
|
|
|
+ 降级
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ ghost
|
|
|
|
|
+ danger
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setRoadPricingUpgradev2({
|
|
|
|
|
+ ...setRoadPricingUpgradev2,
|
|
|
|
|
+ visible: true,
|
|
|
|
|
+ type: titleType.DEADLINE,
|
|
|
|
|
+ deadline: record.deadline,
|
|
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
|
|
+ compilationId: record._id,
|
|
|
|
|
+ compilationName: record.name,
|
|
|
|
|
+ compilationListName: record.name,
|
|
|
|
|
+ lockTypeEnum: record.lock,
|
|
|
|
|
+ upgradeTypeEnum: upgradeTypeEnum.DEADLINE
|
|
|
|
|
+ })
|
|
|
|
|
+ }>
|
|
|
|
|
+ 限期
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ ghost
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ className="m-2px"
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setRoadPricingUpgradev2({
|
|
|
|
|
+ ...setRoadPricingUpgradev2,
|
|
|
|
|
+ visible: true,
|
|
|
|
|
+ type: titleType.LEND,
|
|
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
|
|
+ compilationId: record._id,
|
|
|
|
|
+ compilationName: record.name,
|
|
|
|
|
+ lockTypeEnum: lockTypeEnum.LEND,
|
|
|
|
|
+ upgradeTypeEnum: upgradeTypeEnum.UPGRADE
|
|
|
|
|
+ })
|
|
|
|
|
+ }>
|
|
|
|
|
+ 借出
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ ghost
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ className="m-2px"
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setRoadPricingUpgradev2({
|
|
|
|
|
+ ...setRoadPricingUpgradev2,
|
|
|
|
|
+ visible: true,
|
|
|
|
|
+ type: titleType.SALE,
|
|
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
|
|
+ compilationId: record._id,
|
|
|
|
|
+ compilationName: record.name,
|
|
|
|
|
+ lockTypeEnum: lockTypeEnum.SALE,
|
|
|
|
|
+ upgradeTypeEnum: upgradeTypeEnum.UPGRADE
|
|
|
|
|
+ })
|
|
|
|
|
+ }>
|
|
|
|
|
+ 销售
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ const columnOnline = [
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '日期',
|
|
|
|
|
+ dataIndex: 'dateString',
|
|
|
|
|
+ width: '12%'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '时长',
|
|
|
|
|
+ dataIndex: 'online_times',
|
|
|
|
|
+ width: '17%'
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div className="pl-15px">
|
|
|
|
|
+ <Tabs>
|
|
|
|
|
+ <TabPane tab="个人版" key="个人版">
|
|
|
|
|
+ <div className="sheet-right-panel" ref={tRef}>
|
|
|
|
|
+ <ProTable
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ columns={columns}
|
|
|
|
|
+ search={false}
|
|
|
|
|
+ toolBarRender={false}
|
|
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
|
|
+ rowKey={record => record._id}
|
|
|
|
|
+ dataSource={compilationList}
|
|
|
|
|
+ pagination={false}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </TabPane>
|
|
|
|
|
+ <TabPane tab="在线时长" key="在线时长">
|
|
|
|
|
+ <div className="sheet-right-panel">
|
|
|
|
|
+ <ProTable
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ columns={columnOnline}
|
|
|
|
|
+ search={false}
|
|
|
|
|
+ toolBarRender={false}
|
|
|
|
|
+ // eslint-disable-next-line no-underscore-dangle
|
|
|
|
|
+ rowKey={record => record._id}
|
|
|
|
|
+ dataSource={online_list}
|
|
|
|
|
+ pagination={false}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </TabPane>
|
|
|
|
|
+ </Tabs>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <UpgradeModalv2
|
|
|
|
|
+ onConfirm={handleRoadPricingUpgradev2}
|
|
|
|
|
+ loading={roadPricingUpgradev2.loading}
|
|
|
|
|
+ visible={roadPricingUpgradev2.visible}
|
|
|
|
|
+ type={roadPricingUpgradev2.type}
|
|
|
|
|
+ onCancel={() => setRoadPricingUpgradev2({ ...roadPricingUpgradev2, visible: false })}
|
|
|
|
|
+ projectType={projectType}
|
|
|
|
|
+ ssoId={ssoId}
|
|
|
|
|
+ cloudUser={{ mobile, username }}
|
|
|
|
|
+ compilationId={roadPricingUpgradev2.compilationId}
|
|
|
|
|
+ compilationName={roadPricingUpgradev2.compilationName}
|
|
|
|
|
+ lock={roadPricingUpgradev2.lockTypeEnum}
|
|
|
|
|
+ upgradeType={roadPricingUpgradev2.upgradeTypeEnum}
|
|
|
|
|
+ compilationListName={roadPricingUpgradev2.compilationListName}
|
|
|
|
|
+ deadline={roadPricingUpgradev2.deadline}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export default PersonalTabList
|