Commit 560d4549 authored by LeeJiancong's avatar LeeJiancong

新增支付策略列表,合并menu.ts

parents 9e3fd333 643ece4f
/*
* 品牌审核路由
*/
const router = {
path: '/trademark',
name: 'trademark',
icon: 'SmileOutlined',
hidePageHeader: true,
routes: [
{
path: '/trademark/trademarkSearch',
name: 'trademarkSearch',
component: '@/pages/trademark/trademarkSearch',
},
{
path: '/trademark/trademarkSearch/checkBrand',
name: 'checkBrand',
hideInMenu: true,
component: '@/pages/trademark/trademarkSearch/checkBrand',
},
{
path: '/trademark/trademarkSearch/viewBrand',
name: 'viewBrand',
hideInMenu: true,
component: '@/pages/trademark/trademarkSearch/viewBrand',
},
{
path: '/trademark/trademarkWillCheck',
name: 'trademarkWillCheck',
component: '@/pages/trademark/trademarkWillCheck',
},
]
}
export default router
/*
* 商品能力路由
* @Author: ghua
* @Date: 2020-07-10 11:36:32
* @Last Modified by: ghua
* @Last Modified time: 2020-07-18 11:19:36
*/
const router = {
path: '/classAndProperty',
name: 'classAndProperty',
icon: 'SmileOutlined',
hidePageHeader: true,
routes: [
{
path: '/classAndProperty/class',
name: 'class',
component: '@/pages/classAndProperty/class',
},
{
path: '/classAndProperty/attribute',
name: 'attribute',
component: '@/pages/classAndProperty/attribute',
},
{
path: '/classAndProperty/attribute/addAttribute',
name: 'addAttribute',
component: '@/pages/classAndProperty/attribute/addAttribute',
hideInMenu: true,
},
{
path: '/classAndProperty/propertyValue',
name: 'propertyValue',
component: '@/pages/classAndProperty/propertyValue',
},
{
path: '/classAndProperty/propertyValue/addPropertyValue',
name: 'addPropertyValue',
component: '@/pages/classAndProperty/propertyValue/addPropertyValue',
hideInMenu: true,
},
{
path: '/classAndProperty/categoryAttributes',
name: 'categoryAttributes',
component: '@/pages/classAndProperty/categoryAttributes',
},
{
path: '/classAndProperty/categoryAttributes/viewAttributes',
name: 'viewAttributes',
component: '@/pages/classAndProperty/categoryAttributes/viewAttributes',
hideInMenu: true,
},
]
}
export default router
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
* @description 路由配置页, 更多配置可查看 https://umijs.org/zh-CN/docs/routing#routes * @description 路由配置页, 更多配置可查看 https://umijs.org/zh-CN/docs/routing#routes
*/ */
import pageCustomized from './pageCustomized' import pageCustomized from './pageCustomized'
import commodityRoute from './commodityRoute' // 商品能力路由
import trademarkRoute from './brandRoute' // 品牌路由
import logisticsRoutes from './logisticsRoutes' import logisticsRoutes from './logisticsRoutes'
import memberAbility from './memberAbility' import memberAbility from './memberAbility'
import ruleSettingRoutes from './ruleSettingRoutes' import ruleSettingRoutes from './ruleSettingRoutes'
const routeList = [pageCustomized,logisticsRoutes,memberAbility,ruleSettingRoutes] const routeList = [pageCustomized, commodityRoute, trademarkRoute, logisticsRoutes, memberAbility, ruleSettingRoutes]
const router = [ const router = [
{ {
path: '/login', path: '/login',
......
import React from 'react'
import { Popconfirm, Button } from 'antd'
import { PlayCircleOutlined } from '@ant-design/icons'
export interface StatusSwitchProps {
record: any,
fieldNames?: string, // 自定义字段名称
expectTrueValue?: boolean|number|string, //期望为ture(有效)的值
handleConfirm?(),
handleCancel?()
}
const StatusSwitch:React.FC<StatusSwitchProps> = (props) => {
const { record, fieldNames = 'state', expectTrueValue = 1 } = props
return (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={props.handleConfirm}
onCancel={props.handleCancel}
okText="是"
cancelText="否"
>
<Button type="link" style={record[fieldNames] === expectTrueValue?{color:'#00B37A'}:{color:'red'}}>{record[fieldNames] === expectTrueValue?'有效':'无效'} <PlayCircleOutlined /></Button>
</Popconfirm>
)
}
StatusSwitch.defaultProps = {}
export default StatusSwitch
\ No newline at end of file
import React, { useState } from 'react';
import { IApiRequest } from '@/utils/request';
export interface IHttpRequestReturn<T> {
data: T | null,
loading: boolean,
err: any,
run(params?: any)
}
/**
* 简易版本的useRequest hooks, 用于处理带有loading的业务场景
* @auth xjm
*/
export function useHttpRequest<T>(api: (params?, config?) => Promise<T>, config?: IApiRequest): IHttpRequestReturn<T> {
const [loading, setLoading] = useState(false)
const [data, setData] = useState<T | null>(null)
const [err, setErr] = useState()
const run = (params) => {
setLoading(true)
api(params).then((res: any) => {
setData(res.data)
}).catch(err => {
setErr(err)
}).finally(() => {
setTimeout(() => {
setLoading(false)
}, 200)
})
}
return {
data,
loading,
err,
run
}
}
\ No newline at end of file
import { history } from 'umi'
import { useState } from 'react'
export enum PageStatus {
ADD,
EDIT,
PREVIEW
}
export const usePageStatus = () => {
const { preview, id = '' } = history.location.query
// 默认预览状态
let pageStatus = PageStatus.PREVIEW
if (preview === '1') {
pageStatus = PageStatus.PREVIEW
} else {
if (id) {
pageStatus = PageStatus.EDIT
} else {
pageStatus = PageStatus.ADD
}
}
return {
pageStatus,
id,
preview
}
}
\ No newline at end of file
import { useState } from 'react'
import { TableRowSelection } from 'antd/es/table/interface'
interface useRowSelectionTableCtl {
selectRow: any[],
selectedRowKeys: any[],
setSelectRow(rows: any[]),
setSelectedRowKeys(rows: any)
}
interface useRowSelectionOptions {
type?: 'checkbox' | 'radio'
}
/**
* 用于处理table 多选或者单选时的hooks
* @auth xjm
*/
export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [TableRowSelection<any>, useRowSelectionTableCtl] => {
const { type = 'checkbox' } = options
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>(() => [])
const rowSelection = {
selectedRowKeys: selectedRowKeys,
type,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectRow(selectedRows);
setSelectedRowKeys(selectedRowKeys);
}
}
return [rowSelection, { selectRow, setSelectRow, selectedRowKeys, setSelectedRowKeys }]
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: LeeJiancong * @Author: LeeJiancong
* @Date: 2020-08-04 15:05:52 * @Date: 2020-08-04 15:05:52
* @LastEditors: LeeJiancong * @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-07 14:01:50 * @LastEditTime: 2020-08-07 16:07:31
*/ */
import utils from '@/utils' import utils from '@/utils'
import menu from '../en-US/menu' import menu from '../en-US/menu'
...@@ -75,5 +75,23 @@ export default { ...@@ -75,5 +75,23 @@ export default {
'menu.ruleSettingManager.paySetting': '平台支付参数配置', 'menu.ruleSettingManager.paySetting': '平台支付参数配置',
'menu.ruleSettingManager.payStrategyList': '会员支付策略配置', 'menu.ruleSettingManager.payStrategyList': '会员支付策略配置',
'menu.ruleSettingManager.payStrategyDetail': '会员支付策略配置', 'menu.ruleSettingManager.payStrategyDetail': '会员支付策略配置',
// 品类和属性
'menu.classAndProperty': '平台品类及属性',
'menu.classAndProperty.class': '品类',
'menu.classAndProperty.attribute': '属性',
'menu.classAndProperty.viewAttributes': '查看属性',
'menu.classAndProperty.addAttribute': '新建属性',
'menu.classAndProperty.propertyValue': '属性值',
'menu.classAndProperty.addPropertyValue': '添加属性值',
'menu.classAndProperty.categoryAttributes': '品类属性',
//品牌审核
'menu.trademark': '品牌审核',
'menu.trademark.trademarkSearch': '品牌查询',
'menu.trademark.checkBrand': '品牌审核',
'menu.trademark.viewBrand': '品牌详情',
'menu.trademark.trademarkWillCheck': '待审核品牌',
} }
// export default utils.transformDataPre(data, 'menu') // export default utils.transformDataPre(data, 'menu')
import React, { useState, useRef, useEffect } from 'react'
import { history } from 'umi'
import { Row, Col, Form, Input, Select, Popconfirm, Button, Card, Modal, Checkbox, Tooltip, message, Table } from 'antd';
import { LinkOutlined, QuestionCircleOutlined, InfoCircleOutlined } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { StandardTable } from 'god'
import {ColumnType} from 'antd/lib/table/interface';
import ReutrnEle from '@/components/ReturnEle';
import { PublicApi } from '@/services/api';
import { usePageStatus } from '@/hooks/usePageStatus';
const { Option } = Select;
const layout = {
labelCol: {
span: 5,
},
wrapperCol: {
span: 16,
},
};
const tailLayout = {
wrapperCol: {
offset: 6,
span: 12,
},
};
const AddAtttribute: React.FC<{}> = () => {
const ref = useRef({})
const [menuForm] = Form.useForm();
const [roleVisible, setRoleVisible] = useState(false)
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([])
const [formValue, setFormValue] = useState<any>({})
const { id, pageStatus } = usePageStatus()
useEffect(() => {
const { location } = history
if(id) {
PublicApi.getProductPlatformGetAttribute({id: id}).then(res=>{
const { data } = res
setFormValue(data)
menuForm.setFieldsValue(data)
})
console.log(usePageStatus())
}
}, [])
const handleSubmitAllSetting = () => {
menuForm.validateFields().then((values:any) => {
delete values.attributeShow
if(JSON.stringify(values.attribute)==='{}')
delete values.attribute
PublicApi.postProductCustomerSaveOrUpdateCustomerAttribute(values)
}).catch(error => {
console.error(error)
})
}
const handleSelectOk = () => {
setRoleVisible(false)
if(selectRow.length){
console.log(selectRow[0], 'handleSelectOk')
//@ts-ignore
menuForm.setFieldsValue({attribute: selectRow[0], attributeShow: `${selectRow[0].groupName}-->${selectRow[0].name}`})
}
}
const fetchData = (params:any) => {
console.log(params,'params')
return new Promise((resolve, reject) => {
//@ts-ignore
PublicApi.getProductPlatformGetAttributeList({current: params.page, pageSize: params.rows, name: params.name||'', groupName: params.groupName||'', isEnable: true}).then(res=>{
resolve(res.data)
})
})
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
},
{
title: '属性名称',
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: '属性组名',
dataIndex: 'groupName',
align: 'center',
key: 'groupName',
},
{
title: '展示方式',
align: 'center',
dataIndex: 'type',
key: 'type',
render: (text:number) => {
let txt = new Map([[1, '单选'], [2, '多选'], [3, '输入']])
return txt.get(text)
}
},
{
title: '是否必填',
align: 'center',
dataIndex: 'isEmpty',
key: 'isEmpty',
render: (text: boolean) => text?'是':'否'
}
]
const rowSelection: any = {
type: 'radio',
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectRow(selectedRows)
setSelectedRowKeys(selectedRowKeys)
console.log(selectedRowKeys, selectedRows, 'rowSelection')
}
};
return <PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title={pageStatus === 0
? '新建属性'
: pageStatus === 1
? '编辑属性'
: '查看属性'}
>
<Card>
<Row gutter={[36, 36]}>
<Col span={16}>
<Form
form={menuForm}
name="edit_infomation"
layout="horizontal"
labelAlign="left"
{...layout}
initialValues={formValue}
>
<Row gutter={24}>
<Col span={18}>
<Form.Item
name='groupName'
label='属性组名'
rules={[
{
required: true,
message: '输入属性组名!',
},
]}
>
<Input placeholder="输入属性组名" disabled={pageStatus === 2} />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='id'
style={{display:'none'}}
>
<Input disabled />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='name'
label='属性名称'
rules={[
{
required: true,
message: '输入属性名称!',
},
]}
>
<Input placeholder="输入属性名称" disabled={pageStatus === 2} />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='type'
label='展示方式'
rules={[
{
required: true,
message: '展示方式为必须项!',
},
]}
>
<Select placeholder="选择展示方式" disabled={pageStatus === 2}>
<Option value={1}>单选</Option>
<Option value={2}>多选</Option>
<Option value={3}>输入</Option>
</Select>
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
label='属性设置'
>
<Row>
<Col span={24}>
<Form.Item name="isEmpty" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={pageStatus === 2}>必填</Checkbox></Form.Item>
</Col>
<Col span={24}>
<Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={pageStatus === 2}>价格属性</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性的每个属性值会在商品发布时按属性设置不同的价格!">
<InfoCircleOutlined />
</Tooltip>
</Col>
<Col span={24}>
<Form.Item name="isSearch" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={pageStatus === 2}>搜索属性</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性会在商城店铺商品列表进行筛选操作时作为筛选项!">
<InfoCircleOutlined />
</Tooltip>
</Col>
</Row>
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
label='状态'
name="isEnable"
initialValue={true}
>
{
pageStatus === 2 ? (formValue.isEnable?<><span className="commonStatusValid"></span>有效</>:<><span className="commonStatusInvalid"></span>无效</>) :
(id?<><span className="commonStatusInvalid"></span>无效</>:<><span className="commonStatusValid"></span>有效</>)
}
</Form.Item>
</Col>
{pageStatus !== 2 && <Col span={18}>
<Form.Item {...tailLayout}>
<Button onClick={handleSubmitAllSetting} type="primary" style={{ marginTop: 32, marginBottom: 16, marginRight: 24}}>
保存
</Button>
<Popconfirm
title="确定要取消吗?"
onConfirm={()=>history.goBack()}
onCancel={()=>console.log('取消')}
okText="是"
cancelText="否"
>
<Button style={{ marginTop: 32, marginBottom: 16}}>
取消
</Button>
</Popconfirm>
</Form.Item>
</Col>}
</Row>
</Form>
</Col>
</Row>
</Card>
</PageHeaderWrapper>
}
export default AddAtttribute
.commonSearchBtn {
border-left: none;
border-radius: 0 2px 2px 0;
background-color: #EBECF0FF;
&:hover, &:focus, &:active{
text-decoration: none;
color: rgba(0, 0, 0, 0.65);
background: #EBECF0FF;
border-color: #d9d9d9;
}
}
\ No newline at end of file
import React, { ReactNode, useRef, useState } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
PlayCircleOutlined,
EyeOutlined,
PauseCircleOutlined
} from '@ant-design/icons'
import { StandardTable } from 'god'
import EyePreview from '@/components/EyePreview'
import StatusSwitch from '@/components/StatusSwitch'
import { ColumnType } from 'antd/lib/table/interface'
import { PublicApi } from '@/services/api'
const Attribute: React.FC<{}> = () => {
const ref = useRef({})
const fetchData = (params?: any) => {
return new Promise((resolve, reject) => {
PublicApi.getProductPlatformGetAttributeList({ ...params, name: params.name || '' }).then(res => {
resolve(res.data)
})
})
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: '属性名称',
dataIndex: 'name',
key: 'name',
render: (text: any, record: any) => <EyePreview
url={`/classAndProperty/attribute/addAttribute?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
},
{
title: '属性组名',
dataIndex: 'groupName',
key: 'groupName',
},
{
title: '展示方式',
dataIndex: 'type',
key: 'type',
render: (text: number) => {
let txt = new Map([[1, '单选'], [2, '多选'], [3, '输入']])
return txt.get(text)
}
},
{
title: '是否必填',
dataIndex: 'isEmpty',
key: 'isEmpty',
render: (text: any) => text ? '是' : '否'
},
{
title: '状态',
dataIndex: 'isEnable',
key: 'isEnable',
render: (text: any, record: any) => (
<StatusSwitch
handleConfirm={() => confirm(record)}
record={record}
fieldNames="isEnable"
expectTrueValue={true}
/>
)
},
{
title: '操作',
dataIndex: 'option',
render: (text: any, record: any) => record.isEnable ? '' : <>
<Button type='link' onClick={() => handleEdit(record)}>编辑</Button>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => clickDelete(record)}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button type='link'>删除</Button>
</Popconfirm>
</>
}
];
const confirm = (record: any) => {
PublicApi.postProductPlatformUpdateAttributeStatus({id: record.id, isEnable: !record.isEnable}).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
const clickDelete = (record: any) => {
PublicApi.postProductPlatformDeleteAttribute({ id: record.id }).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
const handleEdit = (record: any) => {
history.push(`/classAndProperty/attribute/addAttribute?id=${record.id}`)
}
const cancel = () => {
console.log('cancel')
}
return (
<PageHeaderWrapper>
<Card>
<StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
formilyLayouts={{
justify: 'space-between'
}}
formilyProps={{
layouts: {
order: 1,
span: 4
},
ctx: {
inline: false,
schema: {
type: 'object',
properties: {
megaLayout0: {
type: 'object',
'x-component': 'mega-layout',
"x-component-props": {
grid: true,
columns: 1,
},
properties: {
name: {
type: 'string',
'x-component-props': {
placeholder: '属性名称',
},
'x-component': 'Search'
}
}
}
}
}
}
}}
formilyChilds={{
layouts: {
order: 0
},
children: (
<>
<Button type="primary" icon={<PlusOutlined />} onClick={() => { history.push('/classAndProperty/attribute/addAttribute') }}>
新建
</Button>
</>
)
}}
/>
</Card>
</PageHeaderWrapper>
)
}
export default Attribute
.innerBox{
padding: 24px;
background-color: #fff;
}
\ No newline at end of file
import React, { useState, useRef, ReactNode, useEffect } from 'react'
import { Row, Col, Tooltip, Popconfirm, Button, Modal, message } from 'antd';
import {
PauseCircleOutlined,
PlayCircleOutlined,
PlusOutlined,
EyeOutlined
} from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { history } from 'umi';
import { MenuTree, StandardTable } from 'god';
import { ColumnType, TableRowSelection } from 'antd/lib/table/interface';
import styles from './index.less';
import { PublicApi } from '@/services/api';
function formatter(params: any) { // 字段title转换为name
params.name = params.title
delete params.title
if (params.children.length > 0)
params.children.map((item: any) => formatter(item))
return params
}
let requestLinkFlag: boolean = false
const CategoryAttributes: React.FC<{}> = () => {
const ref = useRef({})
const refLink = useRef({})
const [selectKeys, setSelectKeys] = useState(undefined)
const [roleVisible, setRoleVisible] = useState(false)
const [selectRow, setSelectRow] = useState<any>({})
const [selectTableRow, setSelectTableRow] = useState<any[]>([])
const [selectedTableRowKeys, setSelectedTableRowKeys] = useState<Array<number>>([]) //表格选择
const [linkTableRowData, setLinkTableRowData] = useState<any[]>([])
const [treeData, setTreeData] = useState<CategoryTreeApi.CategoryTreeModel[]>([]) // 初始品类树
useEffect(() => {
PublicApi.getProductCustomerGetCustomerCategoryTree().then(res=>{
const { data } = res
let newArr: CategoryTreeApi.CategoryTreeModel[] = []
//@ts-ignore
data.length > 0 && data.map((item: any) => {
let arrItem = formatter(item)
newArr.push(arrItem)
})
setTreeData(newArr)
})
}, [])
// 获取选中项的关联属性列表
useEffect(() => {
if (JSON.stringify(selectRow) != '{}') {
requestLinkFlag = true
//@ts-ignore
ref.current.reload({ page: 1, rows: 5, name: '', customerAttributeId: selectRow.id })
}
}, [selectRow])
const fetchLinkAttributeData = (params: any) => {
if (requestLinkFlag) {
return new Promise((resolve, reject) => {
PublicApi.getProductCustomerGetCustomerCategoryAttributeList({current: params.page, pageSize: params.rows, categoryId: selectRow.id, name: params.name || ''}).then(res=>{
resolve(res.data)
setLinkTableRowData(res.data.data)
})
})
} else {
return new Promise((resolve, reject) => { })
}
}
// 获取所有属性列表
const fetchAttributeData = (params: any) => {
return new Promise((resolve, reject) => {
PublicApi.getProductCustomerGetCustomerAttributeList({ current: params.page, name: params.name || '', pageSize: params.rows }).then(res=>{
resolve(res.data)
})
})
}
const handleSee = (record: any) => {
history.push(`/memberCenter/commodityAbility/classAndProperty/categoryAttributes/viewAttributes?id=${record.id}`)
console.log(record)
}
const handleSelectOk = () => {
setRoleVisible(false)
if (selectTableRow.length) {
PublicApi.postProductCustomerSaveCustomerCategoryAttribute({ customerCategoryId: selectRow.id, customerAttributeIds: selectedTableRowKeys }).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
console.log(selectRow)
}
const handleSelectCancel = () => {
setRoleVisible(false)
setSelectedTableRowKeys([])
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
},
{
title: '属性名称',
dataIndex: 'name',
align: 'center',
key: 'name',
render: (text: any, record: any) => <span className="commonPickColor" onClick={() => handleSee(record)}>{text}&nbsp;<EyeOutlined /></span>
},
{
title: '属性组名称',
dataIndex: 'groupName',
align: 'center',
key: 'groupName',
},
{
title: '展示方式',
dataIndex: 'type',
align: 'center',
key: 'type',
render: (text: any, record: any) => {
let _txt: string = ''
if (text === 2) {
_txt = '多选'
} else if (text === 1) {
_txt = '单选'
} else if (text === 3) {
_txt = '输入'
}
return _txt
}
},
{
title: '是否必填',
dataIndex: 'isEmpty',
align: 'center',
key: 'isEmpty',
render: (text: any, record: any) => (<>{text ? '是' : '否'}</>)
},
{
title: '状态',
align: 'center',
dataIndex: 'isEnable',
key: 'isEnable',
render: (text: any, record: any) => {
let component: ReactNode = null
component = (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => confirm(record)}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button
type="link"
style={text ? { color: '#00B37A' } : { color: 'red' }}
>
{text ? <>有效 <PlayCircleOutlined /></> : <>无效 <PauseCircleOutlined /></>}
</Button>
</Popconfirm>
)
return component
}
},
{
title: '操作',
dataIndex: 'option',
align: 'center',
render: (text: any, record: any) => {
return (
<>
{record.isEnable ? <></> : <Button type='link' onClick={() => clickRelief(record.id)}>解除关联</Button>}
</>
)
}
}
];
const columnsLink: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
},
{
title: '属性名称',
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: '属性组名称',
dataIndex: 'groupName',
align: 'center',
key: 'groupName',
},
{
title: '展示方式',
dataIndex: 'type',
align: 'center',
key: 'type',
render: (text: any, record: any) => {
let _txt: string = ''
if (text === 2) {
_txt = '多选'
} else if (text === 2) {
_txt = '单选'
} else if (text === 3) {
_txt = '输入'
}
return _txt
}
},
{
title: '是否必填',
dataIndex: 'isEmpty',
align: 'center',
key: 'isEmpty',
render: (text: any, record: any) => (<>{text ? '是' : '否'}</>)
}
]
const rowSelection: TableRowSelection<any> = {
type: 'checkbox',
selectedRowKeys: selectedTableRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectTableRow(selectedRows);
setSelectedTableRowKeys(selectedRowKeys);
console.log(selectedRowKeys, 'selected: ', selectedRows);
}
};
const clickRelief = (paramsId: number) => {
PublicApi.postProductCustomerDeleteCustomerCategoryAttribute({ customerCategoryId: selectRow.id, customerAttributeIds: [paramsId] }).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
const confirm = (record: any) => {
console.log(record, 'record')
PublicApi.postProductCustomerUpdateCustomerAttributeStatus({ id: record.id, isEnable: !record.isEnable }).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
const cancel = () => {
console.log('cancel')
}
const handleNewLink = () => {
setRoleVisible(true)
let linkArray: number[] = []
linkTableRowData.forEach((item, index) => {
linkArray.push(item.id)
})
console.log(linkArray)
setSelectedTableRowKeys(linkArray)
}
return <PageHeaderWrapper>
<Row gutter={[24, 36]}>
<Col span={8}>
<div className={styles.innerBox}>
{/* 商品品类列表 */}
<MenuTree
headerTitle='选择要编辑的项目'
menuData={treeData}
menuProps={
{
// @ts-ignore
onSelect: (key: string, item: any) => {
console.log(key, item)
//@ts-ignore
setSelectKeys(key)
setSelectRow(item)
},
selectedKeys: selectKeys,
}
}
/>
</div>
</Col>
<Col span={16}>
{
selectKeys && (<div className={styles.innerBox}><StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchLinkAttributeData(params)}
formilyLayouts={{
justify: 'space-between'
}}
formilyProps={{
layouts: {
order: 1
},
ctx: {
schema: {
type: 'object',
properties: {
name: {
type: 'string',
'x-component-props': {
placeHolder: '属性名称'
},
'x-component': 'Search'
}
}
}
}
}}
formilyChilds={{
layouts: {
order: 0
},
children: (
<>
<Button type="primary" icon={<PlusOutlined />} onClick={handleNewLink}>
新建
</Button>
</>
)
}}
/></div>)
}
</Col>
<Modal
title="关联属性"
visible={roleVisible}
onOk={handleSelectOk}
onCancel={handleSelectCancel}
okText="确认"
cancelText="取消"
>
<StandardTable
columns={columnsLink}
currentRef={refLink}
rowSelection={rowSelection}
fetchTableData={(params: any) => fetchAttributeData(params)}
tableProps={{
rowKey: 'id'
}}
formilyProps={{
ctx: {
schema: {
type: 'object',
properties: {
name: {
type: 'string',
'x-component-props': {
placeHolder: '属性名称'
},
'x-component': 'Search'
}
}
}
}
}}
/>
</Modal>
</Row>
</PageHeaderWrapper>
}
export default CategoryAttributes
\ No newline at end of file
import React, { useState, useEffect } from 'react'
import { Row, Col, Form, Input, Select, Popconfirm, Button, Card, Checkbox, Tooltip } from 'antd';
import { history } from 'umi';
import { InfoCircleOutlined } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ReutrnEle from '@/components/ReturnEle';
import { PublicApi } from '@/services/api';
const { Option } = Select;
const layout = {
labelCol: {
span: 5,
},
wrapperCol: {
span: 16,
},
};
const viewAtttributes: React.FC<{}> = () => {
const [menuForm] = Form.useForm();
const [queryId, setQueryId] = useState('')
const [formValue, setFormValue] = useState<any>({})
useEffect(() => {
const { location } = history
if(location.query.id) {
setQueryId(location.query.id)
PublicApi.getProductCustomerGetCustomerAttribute({id: location.query.id}).then(res=>{
const { data } = res
setFormValue(data)
menuForm.setFieldsValue(data)
})
}
}, [])
return <PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title="查看品类属性"
>
<Card>
<Row gutter={[36, 36]}>
<Col span={16}>
<Form
form={menuForm}
name="edit_infomation"
layout="horizontal"
labelAlign="left"
{...layout}
initialValues={formValue}
>
<Row gutter={24}>
<Col span={18}>
<Form.Item
name='id'
label='属性ID'
>
<Input disabled />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='groupName'
label='属性组名'
>
<Input disabled />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='name'
label='属性名称'
>
<Input disabled />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='type'
label='展示方式'
>
<Select disabled>
<Option value={2}>多选</Option>
<Option value={1}>单选</Option>
<Option value={3}>输入</Option>
</Select>
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
label='属性设置'
>
<Row>
<Col span={24}>
<Form.Item name="isEmpty" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled>必填</Checkbox></Form.Item>
</Col>
<Col span={24}>
<Form.Item name="isImage" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled>上传图片</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性的属性值可以上传属性值的对应图片!">
<InfoCircleOutlined />
</Tooltip>
</Col>
<Col span={24}>
<Form.Item name="isName" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled>名称属性</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性的属性值会将属性值添加到商品名称之后,中间以/区隔!">
<InfoCircleOutlined />
</Tooltip>
</Col>
<Col span={24}>
<Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled>价格属性</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性的每个属性值会在商品发布时按属性设置不同的价格!">
<InfoCircleOutlined />
</Tooltip>
</Col>
<Col span={24}>
<Form.Item name="isSearch" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled>搜索属性</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性会在商城店铺商品列表进行筛选操作时作为筛选项!">
<InfoCircleOutlined />
</Tooltip>
</Col>
</Row>
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
label='状态'
name="isEnable"
>
{formValue.isEnable?<><span className="commonStatusValid"></span>有效</>:<><span className="commonStatusInvalid"></span>无效</>}
</Form.Item>
</Col>
</Row>
</Form>
</Col>
</Row>
</Card>
</PageHeaderWrapper>
}
export default viewAtttributes
import React, { useState, useEffect } from 'react'
import { Row, Col, Tooltip, Form, Input, Select, Popconfirm, Button, Card, Upload, message, Modal } from 'antd';
import {
DeleteOutlined,
PlusCircleOutlined,
LoadingOutlined,
PlusOutlined,
LinkOutlined
} from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import {MenuTree} from 'god';
import { UploadFile, UploadChangeParam } from 'antd/lib/upload/interface';
import { PublicApi } from '@/services/api';
const { Option } = Select;
const layout = {
labelCol: {
span: 24,
},
wrapperCol: {
span: 24,
},
}
function beforeUpload(file: UploadFile) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg';
if (!isJpgOrPng) {
message.error('仅支持上传JPEG/JPG/PNG文件!');
}
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) {
message.error('上传图片不超过2MB!');
}
return isJpgOrPng && isLt2M;
}
function formatter(params:any){ // 字段title转换为name
params.name = params.title
delete params.title
if(params.children.length>0)
params.children.map((item:any) => formatter(item))
return params
}
/**
* 查找对应key的object和父节点
* @param data 源树形数据数组 {children:data}
* @param aim 目标key
* @param type 节点类型 p父节点 s目标节点
*/
function findObject(data:any, aim:any, type:any):any{
let result;
if (!data) {
return;
}
for (let i = 0; i < data.children.length; i++) {
let item = data.children[i];
if (item.key == aim) {
let returnData = type === 'p' ? data : item
return returnData
} else if (item.children && item.children.length > 0) {
result= findObject(item, aim, type);
if(result){
return result;
}
}
}
return result;
}
/**
* 添加子级
* @param data 目标对象
* @param newdata 添加的新数据对象
*/
function addChild(data:any, newdata:any): any{
let arr = data.children
let childKey, firstStr, secondStr;
if(arr.length>0){
childKey = data.children[arr.length-1].key
let keyLen = childKey.length
firstStr = childKey.slice(0, keyLen-1)
secondStr = childKey.slice(keyLen-1, keyLen)
}else{
childKey = data.key
}
let _newObj = {...newdata, key: arr.length>0?`${firstStr}${Number(secondStr)+1}`:`${childKey}-0`}
console.log(_newObj, 'new Data')
return _newObj
}
/**
* 添加同级
* @param originData 源树形数据
* @param aimKey 目标key _为undefined的时候添加首层
* @param newdata 添加的新数据对象
*/
function addEqual(originData:any, aimKey:any, newdata:any){
let parent = findObject({children: originData}, aimKey, 'p')
let newObject = addChild(parent, newdata)
console.log(parent, newObject, '添加同级数据', aimKey)
return newObject
}
/**
* 添加首层
* @param originData 源树形数据
* @param newdata 表单新数据
*/
function addFirstClass(originData:any, newdata:any){
let _newObj = {}
if(!originData.length){
_newObj = {...newdata, key: '0'}
}else{
let lastNode = Number(originData[0].key) //顺序是倒着显示
_newObj = {...newdata, key: `${lastNode+1}`}
}
return _newObj
}
const ClassProperty: React.FC<{}> = () => {
const [treeForm] = Form.useForm();
const [treeData, setTreeData] = useState<CategoryTreeApi.CategoryTreeModel[]>([]) // 初始树数据
const [platformTreeData, setPlatformTreeData] = useState<CategoryTreeApi.CategoryTreeModel[]>([]) // 初始平台后台树数据
const [loading, setLoading] = useState(false)
const [imageUrl, setImageUrl] = useState('')
const [selectKeys, setSelectKeys] = useState(undefined)
const [selectRow, setSelectRow] = useState<any>({})
const [selectLinkKeys, setSelectLinkKeys] = useState(undefined)
const [selectLinkRow, setSelectLinkRow] = useState<CategoryTreeApi.CategoryTreeModel|{}>({})
const [roleVisible, setRoleVisible] = useState(false)
const [addType, setAddType] = useState('') // 添加s同级 c子级 f首层
useEffect(() => {
initGetCategoryTree()
}, [])
useEffect(()=>{
//@ts-ignore
treeForm.setFieldsValue({category: {id: selectLinkRow && selectLinkRow.key}, categoryName: selectLinkRow && selectLinkRow.name })
}, [selectLinkRow])
const initGetCategoryTree = () => {
// 商品品类
PublicApi.getProductCustomerGetCustomerCategoryTree().then(res=>{
const { data } = res
let newArr:CategoryTreeApi.CategoryTreeModel[] = []
//@ts-ignore
data.length > 0 && data.map((item: any) => {
let arrItem = formatter(item)
newArr.push(arrItem)
})
setTreeData(newArr)
})
// 平台品类
PublicApi.getProductPlatformGetCategoryTree().then(res=>{
const { data } = res
let tempArr:CategoryTreeApi.CategoryTreeModel[] = []
//@ts-ignore
data.length > 0 && data.map((item: any) => {
let arrItem = formatter(item)
tempArr.push(arrItem)
})
setPlatformTreeData(tempArr)
})
}
const getClassTreeDetail = (id: number) => {
PublicApi.getProductCustomerGetCustomerCategory({id: id.toString()}).then(res=>{
const { data } = res
treeForm.setFieldsValue(data)
treeForm.setFieldsValue({categoryName: data.categoryKey})
setImageUrl(data.imageUrl)
})
}
const handleSubmitAllSetting = () => {
treeForm.validateFields().then(values => {
let obj = {...values}
delete obj.categoryName
if(addType==='c'){
obj = addChild(selectRow, obj)
}else if(addType==='s'){
//@ts-ignore
obj = addEqual(treeData ,selectRow.key, obj)
}else if(addType==='f'){
obj = addFirstClass(treeData, obj)
}
//@ts-ignore
PublicApi.postProductCustomerSaveOrUpdateCustomerCategory(obj).then(res=>{
initGetCategoryTree()
})
})
}
const handleDeleteMenu = () => {
console.log('delete', selectRow)
if(selectRow && selectRow.id){
PublicApi.postProductCustomerDeleteCustomerCategory({id: selectRow.id}).then(res=>{
setSelectKeys(undefined)
initGetCategoryTree() // reload
})
}else{
message.info('请选择对应项!')
}
}
const uploadButton = (
<div>
{loading ? <LoadingOutlined /> : <PlusOutlined />}
<div className="ant-upload-text">上传图片</div>
</div>
);
const handleUploadChange = (info: UploadChangeParam) => {
if (info.file.status === 'uploading') {
setLoading(true)
return;
}
if (info.file.status === 'done') {
// 图片回显
console.log(info)
const { code, data } = info.file.response
if (code === 1000) {
setImageUrl(data)
treeForm.setFieldsValue({imageUrl: data})
}
setLoading(false)
}
};
const handleSelectOk = () => {
setRoleVisible(false)
console.log(selectRow)
}
const handleSelectCancel = () => {
setRoleVisible(false)
setSelectLinkKeys(undefined)
setSelectLinkRow({})
}
const handleAddEqual = () => {
console.log('添加同级', selectRow) // 空对象{}的时候为首层添加
setAddType('s')
treeForm.resetFields()
setImageUrl('')
if (JSON.stringify(selectRow) === '{}') {
setAddType('f')
}
}
const handleAddChild = () => {
console.log('添加子级', selectRow)
setAddType('c')
treeForm.resetFields()
setImageUrl('')
if (JSON.stringify(selectRow) === '{}') {
setAddType('f')
}
}
const titleRender = () => (<Row>
<Col span={21}>
<h3 className="mb-30">选择要编辑的项目</h3>
</Col>
<Col span={3}>
<div style={{display:'flex',justifyContent:'space-between'}}>
<Tooltip placement="top" title="添加同级菜单">
<PlusCircleOutlined onClick={handleAddEqual} key='add_s' />
</Tooltip>
<Tooltip placement="top" title="添加子级菜单">
<PlusCircleOutlined onClick={handleAddChild} key='add_c' />
</Tooltip>
<Tooltip placement="top" title="删除">
<DeleteOutlined onClick={handleDeleteMenu} key='delete' />
</Tooltip>
</div>
</Col>
</Row>
)
return <PageHeaderWrapper
title="品类"
>
<Row gutter={[36, 36]}>
<Col span={8}>
<Card>
{/* <h3 className="mb-30">选择要编辑的项目</h3> */}
<MenuTree
headerTitle='选择要编辑的项目'
titleRender={titleRender}
menuData={treeData}
menuProps={
{
//@ts-ignore
onSelect: (key: string, item: any) => {
console.log(item, 'onSelect')
// @ts-ignore
setSelectKeys(key)
setSelectRow(item)
getClassTreeDetail(item.id); // 获取树项详情
},
selectedKeys: selectKeys,
renderIcons: [ ]
}
}
/>
</Card>
</Col>
<Col span={16}>
<Card>
<h3>编辑</h3>
{
(selectKeys||addType==='f') && (<Form
form={treeForm}
name="edit_infomation"
layout="horizontal"
{...layout}
>
<Row gutter={24}>
<Col span={14} style={{display:'none'}}>
<Form.Item
name='id'
label='ID'
>
<Input />
</Form.Item>
</Col>
<Col span={14} style={{display:'none'}}>
<Form.Item
name='key'
label='Key'
>
<Input />
</Form.Item>
</Col>
<Col span={14}>
<Form.Item
name='name'
label={<>品类名称&nbsp;&nbsp;</>}
rules={[
{
required: true,
message: '输入品类名称!',
},
]}
>
<Input placeholder="输入品类名称" />
</Form.Item>
</Col>
<Col span={14}>
<Form.Item
name='type'
label={<>品类类型&nbsp;&nbsp;</>}
rules={[
{
required: true,
message: '品类类型为必须项!',
},
]}
>
<Select placeholder="选择品类类型">
<Option value={1}>实物商品</Option>
<Option value={2}>虚拟商品</Option>
<Option value={3}>服务商品</Option>
<Option value={4}>积分兑换商品</Option>
</Select>
</Form.Item>
</Col>
<Col span={14}>
<Form.Item
name="imageUrl"
label="品类图片"
// valuePropName="fileList"
extra="支持JPG/PNG/JPEG,最大不超过 30K,尺寸xx为了减少加载数据量,只建议一级项目使用"
>
<Upload
name="file"
listType="picture-card"
className="avatar-uploader"
showUploadList={false}
action="/api/file/file/upload"
beforeUpload={beforeUpload}
onChange={handleUploadChange}
data={{fileType: 2}}
>
{imageUrl ? <img src={imageUrl} alt="avatar" style={{ width: '100%' }} /> : uploadButton}
</Upload>
</Form.Item>
</Col>
<Col span={14}>
<Form.Item
label='对应平台品类'
>
<Row>
<Col span={20}>
<Form.Item name={['category','id']} style={{display:'none'}}>
<Input disabled />
</Form.Item>
<Form.Item name='categoryName'>
<Input disabled />
</Form.Item>
</Col>
<Col span={4}>
<Button type="primary" icon={<LinkOutlined />} style={{backgroundColor: '#6B778C', borderColor: '#6B778C'}} onClick={()=>setRoleVisible(true)}>
关联
</Button>
</Col>
</Row>
</Form.Item>
</Col>
<Col span={14}>
<Button onClick={handleSubmitAllSetting} type="primary" style={{ marginTop: 32, marginBottom: 16, marginRight: 24}}>
保存
</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={handleDeleteMenu}>
<Button style={{ marginTop: 32, marginBottom: 16}}>
删除
</Button>
</Popconfirm>
</Col>
</Row>
</Form>)
}
</Card>
</Col>
</Row>
<Modal
title="关联平台品类"
visible={roleVisible}
onOk={handleSelectOk}
onCancel={handleSelectCancel}
okText="确认"
cancelText="取消"
>
<MenuTree
headerTitle="品类列表"
menuData={platformTreeData}
menuProps={
{
//@ts-ignore
onSelect: (key: string, item: any) => {
console.log(key, item);
// @ts-ignore
setSelectLinkKeys(key);
setSelectLinkRow(item)
},
selectedKeys: selectLinkKeys,
onChecked: key => {
// console.log(key);
// @ts-ignore
setCheckKeys(key)
},
multiple: false,
}
}
/>
</Modal>
</PageHeaderWrapper>
}
export default ClassProperty
import React, { useState, useEffect, useRef } from 'react'
import { Row, Col, Form, Input, Select, Popconfirm, Button, Card, Modal, Tooltip, message } from 'antd';
import { LinkOutlined, QuestionCircleOutlined, } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import {MenuTree} from 'god';
import { history } from 'umi';
import ReutrnEle from '@/components/ReturnEle';
import { PropertyValueApi } from '@/services/classAndProperty/propertyValue/API'
import { PublicApi } from '@/services/api';
const layout = {
labelCol: {
span: 5,
},
wrapperCol: {
span: 16,
},
}
const tailLayout = {
wrapperCol: {
offset: 6,
span: 12,
},
}
function formatter(params:any){ // 字段title转换为name
params.name = params.title
delete params.title
if(params.children.length>0)
params.children.map((item:any) => formatter(item))
return params
}
const AddPropertyValue: React.FC<{}> = () => {
const ref = useRef({})
const [attrValueForm] = Form.useForm();
const [roleVisible, setRoleVisible] = useState(false)
const [formValue, setFormValue] = useState<any>({})
const [treeData, setTreeData] = useState<PropertyValueApi.PlatformPropertyValueTreeModel[]>([]) // 初始平台属性值树数据
const [selectKeys, setSelectKeys] = useState<any>(undefined)
const [selectRow, setSelectRow] = useState<any>({})
const [attributeValueId, setAttributeValueId] = useState(null) // url传入 可判断是编辑/新增
const [isSee, setIsSee] = useState(false) // 判断查看依据
useEffect(() => {
const { attrId, attrName, attrValueId, isSee } = history.location.query
if(attrId){
attrValueForm.setFieldsValue({customerAttribute: { id: Number(attrId)}})
}
if(attrName){
attrValueForm.setFieldsValue({attributeName: attrName})
}
if(attrValueId){ // 编辑
attrValueForm.setFieldsValue({id: attrValueId})
setAttributeValueId(attrValueId)
PublicApi.getProductCustomerGetCustomerAttributeValue({id: attrValueId}).then(res=>{
console.log(res, 'detail')
if(res.code===1000){
setFormValue(res.data)
attrValueForm.setFieldsValue(res.data)
}
})
}
if(isSee){
setIsSee(true)
}
PublicApi.getProductPlatformGetAttributeValueTree().then(res=>{ // 初始平台属性值树数据
const { data } = res
let tempArr:PropertyValueApi.PlatformPropertyValueTreeModel[] = []
//@ts-ignore
data.length > 0 && data.map((item: any) => {
let arrItem = formatter(item)
tempArr.push(arrItem)
})
setTreeData(tempArr)
})
}, [])
const handleSubmitAllSetting = () => {
attrValueForm.validateFields().then(values => {
console.log(values, 'menu values')
let pararms = {...values}
delete pararms.attributeName
if(JSON.stringify(pararms.attributeValue)==='{}')
delete pararms.attributeValue
//@ts-ignore
PublicApi.postProductCustomerSaveOrUpdateCustomerAttributeValue(pararms)
}).catch(error => {
console.error(error)
})
}
const handleSelectOk = () => {
setRoleVisible(false)
if(JSON.stringify(selectRow)!=='{}'){
attrValueForm.setFieldsValue({attributeValue: {id: selectRow.id, value: selectRow.name}})
}
}
const handleLink = () => {
setRoleVisible(true)
let formData = attrValueForm.getFieldValue('attributeValue')
console.log(formData, 'formData')
let chooseKey = formData && formData.id || undefined
setSelectKeys(`${chooseKey}`)
}
return <PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title={attributeValueId?`${isSee?'查看属性值':'编辑属性值'}`:'新建属性值'}
>
<Card>
<Row gutter={[36, 36]}>
<Col span={16}>
<Form
form={attrValueForm}
name="edit_infomation"
layout="horizontal"
labelAlign="left"
{...layout}
initialValues={formValue}
>
<Row gutter={24}>
<Col span={18} style={{display:'none'}}>
<Form.Item
name='id'
label='属性值ID'
>
<Input disabled />
</Form.Item>
<Form.Item
name={['customerAttribute','id']}
label='属性ID'
>
<Input disabled />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='value'
label='属性值名称'
rules={[
{
required: true,
message: '输入属性值名称!',
},
]}
>
<Input placeholder="输入属性值名称" disabled={isSee} />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
label={
<span>
对应平台属性值&nbsp;
<Tooltip title="如果需要在商城中通过平台定义的品类及属性筛选商品,需要在对应平台属性值一栏中关联平台定义的商品属性值。">
<QuestionCircleOutlined />
</Tooltip>
</span>
}
>
<Row>
<Col span={20} style={{display: 'none'}}><Form.Item name={['attributeValue', 'id']}><Input disabled /></Form.Item></Col>
<Col span={20}><Form.Item name={['attributeValue', 'value']}><Input disabled /></Form.Item></Col>
<Col span={4}>
<Button type="primary" icon={<LinkOutlined />} style={{backgroundColor: '#6B778C', borderColor: '#6B778C'}} onClick={handleLink}>
关联
</Button>
</Col>
</Row>
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='attributeName'
label='属性名称'
>
<Input disabled placeholder="输入属性名称" />
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
label='状态'
name="isEnable"
initialValue={true}
>
{
!isSee && (attributeValueId?<><span className="commonStatusInvalid"></span>无效</>:<><span className="commonStatusValid"></span>有效</>)
}
{
isSee && (formValue.isEnable?<><span className="commonStatusValid"></span>有效</>:<><span className="commonStatusInvalid"></span>无效</>)
}
</Form.Item>
</Col>
{
!isSee && <Col span={18}>
<Form.Item {...tailLayout}>
<Button onClick={handleSubmitAllSetting} type="primary" style={{ marginTop: 32, marginBottom: 16, marginRight: 24}}>
保存
</Button>
<Popconfirm title="确定要取消吗?" okText="是" cancelText="否" onConfirm={()=>history.goBack()}>
<Button style={{ marginTop: 32, marginBottom: 16}}>
取消
</Button>
</Popconfirm>
</Form.Item>
</Col>
}
</Row>
</Form>
</Col>
</Row>
<Modal
title="关联平台属性值"
visible={roleVisible}
onOk={handleSelectOk}
onCancel={()=>setRoleVisible(false)}
okText="确认"
cancelText="取消"
>
<MenuTree
headerTitle='平台属性值列表'
menuData={treeData}
menuProps={
{
//@ts-ignore
onSelect: (key: string, item: any) => {
console.log(item, key,'onSelect')
// @ts-ignore
setSelectKeys(key)
setSelectRow(item)
},
selectedKeys: selectKeys,
}
}
/>
</Modal>
</Card>
</PageHeaderWrapper>
}
export default AddPropertyValue
import React, { useState, useRef, ReactNode, useEffect } from 'react'
import { Row, Col, message, Popconfirm, Button, Card } from 'antd';
import {
DeleteOutlined,
PauseCircleOutlined,
PlusCircleOutlined,
PlayCircleOutlined,
PlusOutlined,
EyeOutlined,
SearchOutlined
} from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { history } from 'umi';
import { MenuTree, StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
function formatter(params: any) { // 字段title转换为name
params.name = params.title
delete params.title
if (params.children.length > 0)
params.children.map((item: any) => formatter(item))
return params
}
let requestFlag: boolean = false
const PropertyValue: React.FC<{}> = () => {
const ref = useRef({})
const [selectKeys, setSelectKeys] = useState(undefined)
const [selectRow, setSelectRow] = useState<any>({})
const [attributeTreeData, setAttributeTreeData] = useState<AttributeApi.AttributeTreeModel[]>([])
// 加载属性树 转换字段
useEffect(() => {
PublicApi.getProductCustomerGetCustomerAttributeTree().then(res=>{
const { data } = res
let newArr: CategoryTreeApi.CategoryTreeModel[] = []
//@ts-ignore
data.length > 0 && data.map((item: any) => {
let arrItem = formatter(item)
newArr.push(arrItem)
})
setAttributeTreeData(newArr)
console.log(res, 'res', newArr, 'newArr')
})
}, [])
// 获取选中项的属性值列表
useEffect(() => {
if (JSON.stringify(selectRow) != '{}') {
requestFlag = true
//@ts-ignore
ref.current.reload({ page: 1, rows: 5, name: '', customerAttributeId: selectRow.id })
}
}, [selectRow])
const fetchData = (params: any) => {
if (requestFlag) {
return new Promise((resolve, reject) => {
PublicApi.getProductCustomerGetCustomerAttributeValueList({ current: params.page, pageSize: params.rows, name: params.name || '', customerAttributeId: selectRow.id }).then(res=>{
const { data } = res
resolve(data)
})
})
} else {
return new Promise((resolve, reject) => { })
}
}
const handleSee = (record: any) => {
history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue/addPropertyValue?attrId=${selectRow.id}&attrName=${selectRow.name}&attrValueId=${record.id}&isSee=true`)
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
},
{
title: '属性值',
dataIndex: 'value',
align: 'center',
key: 'value',
render: (text: any, record: any) => <span className="commonPickColor" onClick={() => handleSee(record)}>{text}&nbsp;<EyeOutlined /></span>
},
{
title: '状态',
align: 'center',
dataIndex: 'isEnable',
key: 'isEnable',
render: (text: any, record: any) => {
let component: ReactNode = null
component = (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => confirm(record)}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button
type="link"
style={record.isEnable ? { color: '#00B37A' } : { color: 'red' }}>
{record.isEnable ? <>有效 <PlayCircleOutlined /></> : <>无效 <PauseCircleOutlined /></>}
</Button>
</Popconfirm>
)
return component
}
},
{
title: '操作',
dataIndex: 'option',
align: 'center',
render: (text: any, record: any) => {
return (
<>
{
record.isEnable ? '' : <>
<Button
type='link'
onClick={() => history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue/addPropertyValue?attrId=${selectRow.id}&attrName=${selectRow.name}&attrValueId=${record.id}`)}
>
编辑
</Button>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => clickDelete(record)}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button type='link'>删除</Button>
</Popconfirm>
</>
}
</>
)
}
}
];
const confirm = (record: any) => {
PublicApi.postProductCustomerUpdateCustomerAttributeValueStatus({id: record.id, isEnable: !record.isEnable}).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
const clickDelete = (record: any) => {
PublicApi.postProductCustomerDeleteCustomerAttributeValue({ id: record.id }).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
const cancel = () => {
console.log('cancel')
}
return <PageHeaderWrapper>
<Row gutter={[24, 36]}>
<Col span={8}>
<Card>
<MenuTree
headerTitle='选择要编辑的项目'
// checkedText='全选'
menuData={attributeTreeData}
menuProps={
{
//@ts-ignore
onSelect: (key: string, item: any) => {
console.log(item, key)
setSelectRow(item)
//@ts-ignore
setSelectKeys(key)
},
selectedKeys: selectKeys,
}
}
/>
</Card>
</Col>
<Col span={16}>
<Card>
{
selectKeys && (<StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
formilyLayouts={{
justify: 'space-between'
}}
formilyProps={{
layouts: {
order: 1
},
ctx: {
schema: {
type: 'object',
properties: {
name: {
type: 'string',
'x-component-props': {
placeholder: '属性值名称'
},
'x-component': 'Search'
}
}
}
}
}}
formilyChilds={{
layouts: {
order: 0
},
children: (
<>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => { history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue/addPropertyValue?attrId=${selectRow.id}&attrName=${selectRow.name}`) }}
>
新建
</Button>
</>
)
}}
/>)
}
</Card>
</Col>
</Row>
</PageHeaderWrapper>
}
export default PropertyValue
import React, { useState, useRef, ReactNode, useEffect } from 'react'
import { history } from 'umi'
import { Button, Steps, Card, Space, Tooltip, Row, Col, Descriptions, Table } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
QuestionCircleOutlined,
FormOutlined,
CheckSquareOutlined,
} from '@ant-design/icons'
import { ColumnType } from 'antd/lib/table/interface'
import ReutrnEle from '@/components/ReturnEle'
import moment from 'moment'
import styles from './index.less'
import { PublicApi } from '@/services/api'
const { Step } = Steps;
const CheckBrand: React.FC<{}> = () => {
const [queryId, setQueryId] = useState<number>()
const [brandInfo, setBrandInfo] = useState<any>({})
const [fixStep, setFixStep] = useState(0)
const [recordData, setRecordData] = useState<any[]>([])
useEffect(() => {
const { id } = history.location.query
if(id){
setQueryId(id)
PublicApi.getProductBrandGetBrand({id: id}).then(res => {
console.log(res.data, 'data')
if(res.code===1000){
setBrandInfo(res.data)
if(res.data.status===1)
setFixStep(0)
else if(res.data.status===2)
setFixStep(1)
}
})
PublicApi.getProductBrandGetBrandCheckRecord({brandId: id}).then(res=> {
if(res.code===1000)
setRecordData(res.data)
})
}
}, [])
const columns: ColumnType<any>[] = [
{
title: '序号',
dataIndex: 'id',
key: 'id',
render: (text, record, index)=> index+1
},
{
title: '角色',
dataIndex: 'merchantRoleName',
key: 'merchantRoleName',
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
render: (text:any, record:any) => {
let component: ReactNode = null
if(record.status === 1)
component = (<><span className="commonStatusInvalid"></span>待提交审核</>)
else if(record.status === 2)
component = (<><span className="commonStatusModify"></span>待审核</>)
else if(record.status === 3)
component = (<><span className="commonStatusStop"></span>审核不通过</>)
else if(record.status === 4)
component = (<><span className="commonStatusValid"></span>审核通过</>)
return component
}
},
{
title: '操作',
dataIndex: 'operation',
key: 'operation',
render: (text:any, record:any) => {
let component: ReactNode = null
if(record.operation === 1)
component = (<>新增</>)
else if(record.operation === 2)
component = (<>修改</>)
else if(record.operation === 3)
component = (<>审核</>)
return component
}
},
{
title: '操作时间',
dataIndex: 'createTime',
key: 'createTime',
render: (text:any, record:any) => moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '意见',
dataIndex: 'checkRemark',
key: 'checkRemark',
},
];
const fixStatus = (state: number) => {
if(state === 1)
return <><span className="commonStatusInvalid"></span>待提交审核</>
else if(state === 2)
return <><span className="commonStatusModify"></span>待审核</>
else if(state === 3)
return <><span className="commonStatusStop"></span>审核不通过</>
else if(state === 4)
return <><span className="commonStatusValid"></span>审核通过</>
else if(state === 5)
return <><span className="commonStatusValid"></span>已上架</>
else if(state === 6)
return <><span className="commonStatusStop"></span>已下架</>
}
const fixProveUrl = (proveInfo: any) => {
if(proveInfo){
let imgArray = Object.values(proveInfo)
return imgArray.map((item: any, index: number) => <Col key={index} span={3}>
<div className={styles.proveBox}>
<img src={item} alt=""/>
</div>
</Col>
)
}
}
const tips = <>证明材料<Tooltip title="证明材料:如商标注册证书、品牌授权证书等证明材料"><span>&nbsp;<QuestionCircleOutlined /></span></Tooltip></>
const content = <>
<Descriptions colon={true} style={{textAlign: 'left', marginLeft: 200}}>
<Descriptions.Item span={1} label="商家名称">{brandInfo?.memberName}</Descriptions.Item>
<Descriptions.Item span={1} label="申请审核时间">{brandInfo.applyTime && moment(brandInfo.applyTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
<Descriptions.Item span={1} label="审核状态">
{
fixStatus(brandInfo?.status)
}
</Descriptions.Item>
<Descriptions.Item span={1} label="品牌状态">{brandInfo.isEnable?'有效':'无效'}</Descriptions.Item>
</Descriptions>
</>
const handleApplyCheck = (status: string) => {
PublicApi.getProductBrandCheckBrand({ id: brandInfo.id, status: status }) // post问题
}
return (
<PageHeaderWrapper
title={brandInfo?.name}
onBack={() => history.goBack()}
backIcon={<ReutrnEle logoSrc={brandInfo?.logoUrl} />}
content={content}
extra={[
<Button
key="1"
onClick={()=>handleApplyCheck('3')}
>
审核不通过
</Button>,
<Button
icon={<CheckSquareOutlined />}
key="1"
type="primary"
onClick={()=>handleApplyCheck('4')}
>
审核通过
</Button>
]}
>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title={tips}>
<Row gutter={24}>
{
fixProveUrl(brandInfo.proveUrl)
}
</Row>
</Card>
</Space>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="流程进度">
<Steps progressDot current={fixStep}>
<Step title="提交审核" description="供应商" />
<Step title="审核品牌" description="平台" />
<Step title="完成" description="" />
</Steps>
</Card>
</Space>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="审核历史">
<Table dataSource={recordData} columns={columns} pagination={false} />
</Card>
</Space>
</PageHeaderWrapper>
)
}
export default CheckBrand
.proveBox{
width:175px;
height:120px;
border:1px solid rgba(235,236,240,1);
img {
height: 100%;
padding: 18px;
}
}
\ No newline at end of file
import React, { ReactNode, useRef, useEffect } from 'react'
import { history } from 'umi'
import { Button, Row, Col, Card, Input, Dropdown, Menu } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlayCircleOutlined,
EyeOutlined,
PauseCircleOutlined,
} from '@ant-design/icons'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import moment from 'moment'
import { PublicApi } from '@/services/api'
import EyePreview from '@/components/EyePreview'
const Trademark: React.FC<{}> = () => {
const ref = useRef({})
const fetchData = (params: any) => {
return new Promise((resolve, reject) => {
PublicApi.getProductBrandGetPlatformBrandList({ ...params, name: params.name || '', status: params.status || 0 }).then(res => {
const { data } = res
resolve(data)
})
})
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: '品牌名称',
dataIndex: 'name',
key: 'name',
className: 'commonPickColor',
render: (text: any, record: any) => <EyePreview
url={`/trademark/trademarkSearch/viewBrand?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
},
{
title: '商家名称',
dataIndex: 'memberName',
key: 'memberName',
},
{
title: '申请时间',
dataIndex: 'applyTime',
key: 'applyTime',
render: (text: any, record: any) => text && moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '审核状态',
dataIndex: 'status',
key: 'status',
render: (text: any, record: any) => {
let component: ReactNode = null
if (record.status === 1)
component = (<><span className="commonStatusInvalid"></span>待提交审核</>)
else if (record.status === 2)
component = (<><span className="commonStatusModify"></span>待审核</>)
else if (record.status === 3)
component = (<><span className="commonStatusStop"></span>审核不通过</>)
else if (record.status === 4)
component = (<><span className="commonStatusValid"></span>审核通过</>)
return component
}
},
];
const handleReset = (actions: any) => {
actions.reset({})
//@ts-ignore
ref.current.reload()
}
const handleSee = (record: any) => {
console.log('see')
history.push(`/trademark/viewBrand?id=${record.id}`)
}
const cancel = () => {
console.log('cancel')
}
return (
<PageHeaderWrapper>
<Card>
<StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
formilyProps={{
layouts: {
span: 8,
},
ctx: {
inline: false,
schema: {
type: 'object',
properties: {
megaLayout0: {
type: 'object',
'x-component': 'mega-layout',
"x-component-props": {
grid: true,
columns: 2,
},
properties: {
status: {
type: 'string',
enum: [
{ label: '全部', value: 0 },
{ label: '待提交审核', value: 1 },
{ label: '待审核', value: 2 },
{ label: '审核不通过', value: 3 },
{ label: '审核通过', value: 4 }
],
'x-component-props': {
placeholder: '状态',
}
},
name: {
type: 'string',
'x-component-props': {
placeholder: '品牌名称',
},
'x-component': 'Search'
},
}
},
}
}
},
}}
formilyChilds={{
children: ({actions}) => (
<>
<Button onClick={() => handleReset(actions) } style={{marginLeft:16}}>
重置
</Button>
</>
)
}}
/>
</Card>
</PageHeaderWrapper>
)
}
export default Trademark
import React, { useState, useRef, ReactNode, useEffect } from 'react'
import { history } from 'umi'
import { Button, Steps, Card, Space, Tooltip, Row, Col, Descriptions, Table } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
QuestionCircleOutlined,
FormOutlined,
} from '@ant-design/icons'
import { ColumnType } from 'antd/lib/table/interface'
import ReutrnEle from '@/components/ReturnEle'
import moment from 'moment'
import styles from './index.less'
import { PublicApi } from '@/services/api'
const { Step } = Steps;
const viewBrand: React.FC<{}> = () => {
const [queryId, setQueryId] = useState<number|null>(null)
const [brandInfo, setBrandInfo] = useState<any>({})
const [fixStep, setFixStep] = useState(0)
const [recordData, setRecordData] = useState<any[]>([])
useEffect(() => {
const { id } = history.location.query
if(id){
setQueryId(id)
PublicApi.getProductBrandGetBrand({id: id}).then(res => {
console.log(res.data, 'data')
if(res.code===1000){
setBrandInfo(res.data)
if(res.data.status===1)
setFixStep(0)
else if(res.data.status===2)
setFixStep(1)
}
})
PublicApi.getProductBrandGetBrandCheckRecord({brandId: id}).then(res=> {
if(res.code===1000)
setRecordData(res.data)
})
}
}, [])
const columns: ColumnType<any>[] = [
{
title: '序号',
dataIndex: 'id',
key: 'id',
render: (text, record, index)=> index+1
},
{
title: '角色',
dataIndex: 'merchantRoleName',
key: 'merchantRoleName',
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
render: (text:any, record:any) => {
let component: ReactNode = null
if(record.status === 1)
component = (<><span className="commonStatusInvalid"></span>待提交审核</>)
else if(record.status === 2)
component = (<><span className="commonStatusModify"></span>待审核</>)
else if(record.status === 3)
component = (<><span className="commonStatusStop"></span>审核不通过</>)
else if(record.status === 4)
component = (<><span className="commonStatusValid"></span>审核通过</>)
return component
}
},
{
title: '操作',
dataIndex: 'operation',
key: 'operation',
render: (text:any, record:any) => {
let component: ReactNode = null
if(record.operation === 1)
component = (<>新增</>)
else if(record.operation === 2)
component = (<>修改</>)
else if(record.operation === 3)
component = (<>审核</>)
return component
}
},
{
title: '操作时间',
dataIndex: 'createTime',
key: 'createTime',
render: (text:any, record:any) => moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '意见',
dataIndex: 'checkRemark',
key: 'checkRemark',
},
];
const fixStatus = (state: number) => {
if(state === 1)
return <><span className="commonStatusInvalid"></span>待提交审核</>
else if(state === 2)
return <><span className="commonStatusModify"></span>待审核</>
else if(state === 3)
return <><span className="commonStatusStop"></span>审核不通过</>
else if(state === 4)
return <><span className="commonStatusValid"></span>审核通过</>
else if(state === 5)
return <><span className="commonStatusValid"></span>已上架</>
else if(state === 6)
return <><span className="commonStatusStop"></span>已下架</>
}
const fixProveUrl = (proveInfo: any) => {
if(proveInfo){
let imgArray = Object.values(proveInfo)
return imgArray.map((item: any, index: number) => <Col key={index} span={3}>
<div className={styles.proveBox}>
<img src={item} alt=""/>
</div>
</Col>
)
}
}
const tips = <>证明材料<Tooltip title="证明材料:如商标注册证书、品牌授权证书等证明材料"><span>&nbsp;<QuestionCircleOutlined /></span></Tooltip></>
const content = <>
<Descriptions colon={true} style={{textAlign: 'left', marginLeft: 200}}>
<Descriptions.Item span={1} label="商家名称">{brandInfo?.memberName}</Descriptions.Item>
<Descriptions.Item span={1} label="申请审核时间">{brandInfo.applyTime && moment(brandInfo.applyTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
<Descriptions.Item span={1} label="审核状态">
{
fixStatus(brandInfo?.status)
}
</Descriptions.Item>
<Descriptions.Item span={1} label="品牌状态">{brandInfo.isEnable?'有效':'无效'}</Descriptions.Item>
</Descriptions>
</>
return (
<PageHeaderWrapper
title={brandInfo?.name}
onBack={() => history.goBack()}
backIcon={<ReutrnEle logoSrc={brandInfo?.logoUrl} />}
content={content}
extra={[
// <Button
// icon={<FormOutlined />}
// key="1"
// type="primary"
// onClick={()=>history.push(`/trademark/addBrand?id=${brandInfo.id}`)}
// disabled={!(brandInfo.status===1||brandInfo.status===3)}
// >
// 修改
// </Button>,
]}
>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title={tips}>
<Row gutter={24}>
{
fixProveUrl(brandInfo.proveUrl)
}
</Row>
</Card>
</Space>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="流程进度">
<Steps progressDot current={fixStep}>
<Step title="提交审核" description="供应商" />
<Step title="审核品牌" description="平台" />
<Step title="完成" description="" />
</Steps>
</Card>
</Space>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="审核历史">
<Table dataSource={recordData} columns={columns} pagination={false} />
</Card>
</Space>
</PageHeaderWrapper>
)
}
export default viewBrand
.proveBox{
width:175px;
height:120px;
border:1px solid rgba(235,236,240,1);
img {
height: 100%;
padding: 18px;
}
}
\ No newline at end of file
import React, { ReactNode, useRef, useEffect } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card, message, Dropdown, Menu } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
PlayCircleOutlined,
EyeOutlined,
PauseCircleOutlined,
CaretDownOutlined
} from '@ant-design/icons'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import moment from 'moment'
import { PublicApi } from '@/services/api'
import EyePreview from '@/components/EyePreview'
const Trademark: React.FC<{}> = () => {
const ref = useRef({})
const fetchData = (params: any) => {
return new Promise((resolve, reject) => {
PublicApi.getProductBrandGetPlatformBrandList({ ...params, name: params.name || '', status: 2 }).then(res => {
const { data } = res
resolve(data)
})
})
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: '品牌名称',
dataIndex: 'name',
key: 'name',
className: 'commonPickColor',
render: (text: any, record: any) => <EyePreview
url={`/trademark/trademarkSearch/viewBrand?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
},
{
title: '商家名称',
dataIndex: 'memberName',
key: 'memberName',
},
{
title: '申请时间',
dataIndex: 'applyTime',
key: 'applyTime',
render: (text: any, record: any) => text && moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '审核状态',
dataIndex: 'status',
key: 'status',
render: (text: any, record: any) => {
let component: ReactNode = null
if (record.status === 1)
component = (<><span className="commonStatusInvalid"></span>待提交审核</>)
else if (record.status === 2)
component = (<><span className="commonStatusModify"></span>待审核</>)
else if (record.status === 3)
component = (<><span className="commonStatusStop"></span>审核不通过</>)
else if (record.status === 4)
component = (<><span className="commonStatusValid"></span>审核通过</>)
return component
}
},
{
title: '操作',
dataIndex: 'option',
render: (text: any, record: any) => {
return (
<>
<Button type='link' onClick={()=> history.push(`/trademark/trademarkSearch/checkBrand?id=${record.id}`)}>审核</Button>
</>
)
}
}
];
const handleSee = (record: any) => {
console.log('see')
// history.push(`/memberCenter/commodityAbility/trademark/viewBrand?id=${record.id}`)
}
const confirm = (record: any) => {
PublicApi.postProductBrandUpdateBrandEnable({ id: record.id, isEnable: !record.isEnable }).then(res => {
//@ts-ignore
ref.current.reload()
})
}
const cancel = () => {
console.log('cancel')
}
const handelDelete = (record: any) => {
PublicApi.postProductBrandDeleteBrand({ id: record.id }).then(res => {
//@ts-ignore
ref.current.reload()
})
}
const handleApplyCheck = (record:any) => {
PublicApi.getProductBrandApplyCheckBrand({id: record.id}).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
const handleReset = (actions: any) => {
actions.reset({})
//@ts-ignore
ref.current.reload()
}
return (
<PageHeaderWrapper>
<Card>
<StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
formilyProps={{
layouts: {
span: 4,
},
ctx: {
inline: false,
schema: {
type: 'object',
properties: {
megaLayout0: {
type: 'object',
'x-component': 'mega-layout',
"x-component-props": {
grid: true,
columns: 2,
},
properties: {
// status: {
// type: 'string',
// enum: [
// { label: '全部', value: 0 },
// { label: '待提交审核', value: 1 },
// { label: '待审核', value: 2 },
// { label: '审核不通过', value: 3 },
// { label: '审核通过', value: 4 }
// ],
// default: 2,
// 'x-component-props': {
// placeholder: '状态',
// }
// },
name: {
type: 'string',
'x-component-props': {
placeholder: '品牌名称',
},
'x-component': 'Search'
}
}
}
}
}
}
}}
// formilyChilds={{
// layouts: {
// order: 0
// },
// children: ({actions}) => (
// <>
// <Button onClick={() => handleReset(actions) } style={{marginLeft:16}}>
// 重置
// </Button>
// </>
// )
// }}
/>
</Card>
</PageHeaderWrapper>
)
}
export default Trademark
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