Commit 8710eda0 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix

parent 74f76cf5
......@@ -26,7 +26,7 @@
"@umijs/preset-react": "1.x",
"@umijs/test": "^3.2.0",
"bizcharts": "^4.0.7",
"god": "0.0.28",
"god": "0.0.31",
"lint-staged": "^10.0.7",
"mobx": "^5.15.4",
"mobx-react": "^6.2.2",
......
......@@ -25,7 +25,7 @@ const MenuSlider:React.FC<MenuSliderProps> = (props) => {
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
mode="inline"
inlineCollapsed={innerCollapsed}
// inlineCollapsed={innerCollapsed}
>
<Menu.Item key="1">
通用
......
export default {
'menu.welcome': '欢迎',
'menu.index': '主页',
'menu.home': '首页',
'menu.admin': '管理页',
'menu.admin.sub-page': '二级管理页',
......
import React, { ReactNode, useRef } from 'react'
import React, { ReactNode, useRef, useState } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card } from 'antd'
import { Button, Popconfirm, Card, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
......@@ -10,111 +10,87 @@ import {
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { IFormFilter, IButtonFilter } from 'god/dist/src/standard-table/TableController'
const data = [
{
key: '1',
attrName: '采购商',
attrGroup: '采购',
displayType: '单选',
required: '是',
status: 1,
},
{
key: '2',
attrName: '供应商',
attrGroup: '供应',
displayType: '双选',
required: '否',
status: 0,
},
]
// 模拟请求
const fetchData = (params:any) => {
return new Promise((resolve, reject) => {
const queryResult = data.find(v => v.key === params.keywords)
setTimeout(() => {
resolve({
code: 200,
message: '',
data: queryResult ? [queryResult] : data
})
}, 1000)
})
}
import { getAttributeLists, updateAttributeStatus, deleteAttribute } from '@/services/classAndProperty/attribute'
const Attribute: React.FC<{}> = () => {
const ref = useRef({})
const [currentPage, setCurrentPage] = useState(1)
const [pageSize, setpageSize] = useState(10)
const [searchName, setsearchName] = useState('')
const fetchData = (params?:any) => {
console.log(params, '搜索参数')
return new Promise((resolve, reject) => {
getAttributeLists({current: currentPage, name: searchName, pageSize}).then( res =>{
resolve(res.data)
})
})
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'key',
align: 'center',
key: 'key',
dataIndex: 'id',
key: 'id',
},
{
title: '属性名称',
dataIndex: 'attrName',
align: 'center',
key: 'attrName',
render: (text:any, record:any) => <span className="commonPickColor" onClick={()=>handleSee(record)}>{text}&nbsp;<EyeOutlined /></span>
dataIndex: 'name',
key: 'name',
// onClick={()=>handleSee(record)}
render: (text:any, record:any) => <span className="commonPickColor">{text}&nbsp;<EyeOutlined /></span>
},
{
title: '属性组名',
align: 'center',
dataIndex: 'attrGroup',
key: 'attrGroup',
dataIndex: 'groupName',
key: 'groupName',
},
{
title: '展示方式',
align: 'center',
dataIndex: 'displayType',
key: 'displayType',
dataIndex: 'type',
key: 'type',
render: (text:number) => {
let txt = new Map([[1, '单选'], [2, '多选'], [3, '输入']])
return txt.get(text)
}
},
{
title: '是否必填',
align: 'center',
dataIndex: 'required',
key: 'required',
dataIndex: 'isEmpty',
key: 'isEmpty',
render: (text: any) => text?'是':'否'
},
{
title: '状态',
align: 'center',
dataIndex: 'status',
key: 'status',
render: (text: any, record:any) => {
let component: ReactNode = null
component = (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={confirm}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button type="link" onClick={()=>handleModify(record)} style={record.status===1?{color:'#00B37A'}:{color:'red'}}>{record.status===1?'有效':'无效'} <PlayCircleOutlined /></Button>
</Popconfirm>
)
return component
}
dataIndex: 'isEnable',
key: 'isEnable',
render: (text: any, record:any) => (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={()=>confirm(record)}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button type="link" style={record.isEnable?{color:'#00B37A'}:{color:'red'}}>{record.isEnable?'有效':'无效'} <PlayCircleOutlined /></Button>
</Popconfirm>
)
},
{
title: '操作',
dataIndex: 'option',
align: 'center',
render: (text:any, record:any) => {
return (
<>
{
record.status === 0 ? <><Button type='link'>编辑</Button><Button type='link'>删除</Button></>:''
}
{/* <Button type='link'>编辑</Button>
<Button type='link'>删除</Button> */}
</>
)
}
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>
</>
}
];
......@@ -130,8 +106,8 @@ const Attribute: React.FC<{}> = () => {
const searchBarActions: IButtonFilter[] = [
{
text: '查询',
handler: () => {
console.log('查询')
handler: (params) => {
console.log('查询', params, ref)
}
},
{
......@@ -145,21 +121,36 @@ const Attribute: React.FC<{}> = () => {
]
const handleSee = (record:any) => {
console.log('see')
history.push(`/trademark/viewBrand?id=${record.id}`)
}
const confirm = () => {
console.log('confirm')
const confirm = (record:any) => {
console.log(record,'record')
updateAttributeStatus({id: record.id, status: !record.isEnable}).then(res=>{
if(res.code===1000){
message.success(res.message)
//@ts-ignore
ref.current.reload()
}
})
}
const cancel = () => {
console.log('cancel')
const clickDelete = (record: any) => {
deleteAttribute({id: record.id}).then(res=>{
if(res.code===1000){
message.success(res.message)
//@ts-ignore
ref.current.reload()
}
})
}
const handleModify = (record: object) => {
// 通过传入的params字符串判断是修改那种类型的数据
console.log('执行状态修改', record)
const handleEdit = (record: any) => {
history.push(`/classAndProperty/attribute/addAttribute?id=${record.id}`)
}
const cancel = () => {
console.log('cancel')
}
return (
......
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import { Row, Col, Tooltip, Form, Input, Select, Popconfirm, Button, Card, Upload, message, Modal } from 'antd';
import { DeleteOutlined, FormOutlined, 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 { getCustomerCategoryTree } from '@/services/classAndProperty/class'
const { Option } = Select;
......@@ -88,12 +89,21 @@ function beforeUpload(file: UploadFile) {
const ClassProperty: React.FC<{}> = () => {
const [menuForm] = Form.useForm();
const [treeData, setTreeData] = useState({}) // 初始树数据
const [loading, setLoading] = useState(false)
const [imageUrl, setImageUrl] = useState('')
const [selectKeys, setSelectKeys] = useState(undefined)
const [roleVisible, setRoleVisible] = useState(false)
const [selectRow, setSelectRow] = useState<Item[]>([]) // 模态框选择的行数据
useEffect(() => {
getCustomerCategoryTree().then( res => {
const { data } = res
setTreeData(data)
console.log(res, 'res')
})
}, [])
const handleSubmitAllSetting = () => {
menuForm.validateFields().then(values => {
console.log(values, 'menu values')
......@@ -149,8 +159,7 @@ const ClassProperty: React.FC<{}> = () => {
<Card>
<h3>选择要编辑的项目</h3>
<MenuTree
headerTitle='菜单头部'
// checkedText='全选'
headerTitle='品类列表'
menuData={menuData}
menuProps={
{
......@@ -160,16 +169,10 @@ const ClassProperty: React.FC<{}> = () => {
setSelectKeys(selectItem.key);
},
selectedKeys: selectKeys,
// onChecked: key => {
// console.log(key);
// // @ts-ignore
// setCheckKeys(key)
// },
// checkedList: checkKeys,
renderIcons: [
<Tooltip placement="top" title="修改">
<FormOutlined onClick={(e)=>{console.log('modify',e)}} key='modfiy' />
</Tooltip>,
// <Tooltip placement="top" title="修改">
// <FormOutlined onClick={(e)=>{console.log('modify',e)}} key='modfiy' />
// </Tooltip>,
<Tooltip placement="top" title="添加同级菜单">
<PlusCircleOutlined onClick={(e)=>{console.log('add1',e)}} key='add1' />
</Tooltip>,
......
......@@ -12,6 +12,7 @@ import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { IButtonFilter, IFormFilter } from 'god/dist/src/standard-table/TableController'
import styles from "./index.less"
import { getProductLists } from '@/services/commodity/products'
// 定义选择的行数据的类型
interface Item {
......@@ -88,20 +89,6 @@ const data = [
},
]
// 模拟请求
const fetchData = (params:any) => {
return new Promise((resolve, reject) => {
const queryResult = data.find(v => v.key === params.keywords)
setTimeout(() => {
resolve({
code: 200,
message: '',
data: queryResult ? [queryResult] : data
})
}, 1000)
})
}
let timeChange: any;
const Products: React.FC<{}> = () => {
......@@ -115,38 +102,63 @@ const Products: React.FC<{}> = () => {
const [isUp, setIsUp] = useState(1) // 1上0下架状态
const [upDownModal, setUpDownModal] = useState(false)
const [searchName, setSearchName] = useState('')
const [searchStatus, setSearchStatus] = useState(0)
const [current, setCurrent] = useState(1)
const [pageSize, setPageSize] = useState(10)
// afterService: "售后服务"
// area: (2) ["广东省", "广州市"]
// brandId: 1
// categoryId: 1
// commodityAttribute: (2) [{…}, {…}]
// goodsList: (2) [{…}, {…}]
// id: 11
// isInvoice: true
// logistics: {weight: 50, company: "顺丰", sendAddress: "广东省广州市", carriageType: 1, deliveryType: 1}
// marks: "中国驰名商标"
// minOrder: 12.123
// name: "苹果电脑"
// packing: "包装清单"
// priceType: 1
// sellingPoint: "好用-便宜-美观"
// slogan: "性能杠杠的"
// status: 1
// unitId: 1
// unitPriceAndPic: (2) [
const columns: ColumnType<any>[] = [
{
title: '货号',
dataIndex: 'key',
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'key',
key: 'id',
},
{
title: '商品名称',
dataIndex: 'productName',
dataIndex: 'name',
align: 'center',
key: 'productName',
key: 'name',
className: 'commonPickColor',
render: (text:any, record:any) => <span className="commonPickColor" onClick={()=>handleSee(record)}>{text}&nbsp;<EyeOutlined /></span>
},
{
title: '品类',
dataIndex: 'type',
dataIndex: ['customerCategory', 'name'],
align: 'center',
key: 'type',
key: 'customerCategory.name',
},
{
title: '品牌',
dataIndex: 'brand',
dataIndex: ['brand', 'name'],
align: 'center',
key: 'brand',
key: 'brand.name',
},
{
title: '单位',
dataIndex: 'unit',
dataIndex: 'unitName',
align: 'center',
key: 'unit',
key: 'unitName',
},
{
title: '价格',
......@@ -156,9 +168,9 @@ const Products: React.FC<{}> = () => {
},
{
title: '审核时间',
dataIndex: 'time',
dataIndex: 'checkTime',
align: 'center',
key: 'time',
key: 'checkTime',
},
{
title: '审核状态',
......@@ -167,17 +179,17 @@ const Products: React.FC<{}> = () => {
key: 'status',
render: (text:any, record:any) => {
let component: ReactNode = null
if(record.status === '0')
component = (<><span className="commonStatusInvalid"></span>待提交</>)
else if(record.status === '1')
component = (<><span className="commonStatusModify"></span>待审核</>)
else if(record.status === '2')
component = (<><span className="commonStatusValid"></span>审核通过</>)
else if(record.status === '3')
component = (<><span className="commonStatusStop"></span>审核不通过</>)
else if(record.status === '4')
if(record.status === 1)
component = (<><span className="commonStatusModify"></span>待提交审核</>)
else if(record.status === 2)
component = (<><span className="commonStatusValid"></span>待审核</>)
else if(record.status === 3)
component = (<><span className="commonStatusStop"></span>审核通过</>)
else if(record.status === 4)
component = (<><span className="commonStatusInvalid">审核不通过</span></>)
else if(record.status === 0)
component = (<span style={{color:'#00B37A',padding:'2px 5px',background:'rgba(235,247,242,1)',borderRadius:'4px'}}>已上架</span>)
else if(record.status === '5')
else if(record.status === 5)
component = (<span style={{padding:'2px 5px',background:'rgba(244,245,247,1)',borderRadius:'4px'}}>已下架</span>)
return component
}
......@@ -292,6 +304,18 @@ const Products: React.FC<{}> = () => {
},
]
// 模拟请求
const fetchData = (params:any) => {
return new Promise((resolve, reject) => {
getProductLists({current, pageSize, name: searchName, status: searchStatus}).then(res=>{
console.log(res,'res')
const { data } = res
resolve(data)
})
})
}
const handleSee = (record:any) => {
console.log('see')
history.push(`/commodity/products/viewProducts?id=${record.id}`)
......
declare namespace API {
export interface ResponseModel {
}
}
\ No newline at end of file
declare namespace AttributeApi {
interface innerAttribute {
id: number;
groupName: string;
name: string;
}
export interface AttributeItem {
id: number;
groupName: string;
name: string;
type: number;
isEnable: boolean;
isEmpty: boolean;
isImage: boolean;
isName: boolean;
isPrice: boolean;
isSearch: boolean;
attribute: innerAttribute;
}
export interface AttributeListsModel {
totalCount: number;
data: AttributeItem[];
}
export interface AttributeListsByQueryDTO {
current: number;
pageSize: number;
name: string;
}
// 查询 删除共用
export interface AttributeByQueryDTO {
id: number;
}
export interface AttributeByUpdateStatusDTO {
id: number;
status: boolean;
}
interface AttributeTreeItem {
key: string;
title: string ;
checked: boolean;
}
export interface AttributeTreeModel {
key: string;
title: string ;
checked: boolean;
children: AttributeTreeItem[];
}
//关联平台后台属性
export interface PlatformAttributeItem {
id: number;
groupName: string;
name: string;
type: number;
isEnable: boolean;
isEmpty: boolean;
isImage: boolean;
isName: boolean;
isPrice: boolean;
isSearch: boolean;
}
export interface PlatformAttributeByQueryDTO {
current: number;
pageSize: number;
name: string;
groupName: string;
// isEnable: boolean;
}
}
\ No newline at end of file
import request from '@/utils/request';
const prefix = '/product'
/**
* @description 获取属性树形列表
*/
export async function getAttributeTree() {
return request<AttributeApi.AttributeTreeModel>('/customer/getCustomerAttributeTree', {
prefix
})
}
/**
* @description 查询属性信息
* @param {AttributeApi.AttributeByQueryDTO} params
*/
export async function getAttributeDetail(params: AttributeApi.AttributeByQueryDTO) {
return request<AttributeApi.AttributeItem>('/customer/getCustomerAttribute', {
prefix,
params
})
}
/**
* @description 查询属性列表
* @param {AttributeApi.AttributeListsByQueryDTO} params
*/
export async function getAttributeLists(params: AttributeApi.AttributeListsByQueryDTO) {
return request<AttributeApi.AttributeListsModel>('/customer/getCustomerAttributeList', {
prefix,
params
})
}
/**
* @description 新增/修改属性
* @param {AttributeApi.AttributeItem} params
*/
export async function updateAttribute(params: AttributeApi.AttributeItem) {
return request('/customer/saveOrUpdateCustomerAttribute', {
prefix,
method: 'post',
data: params
})
}
/**
* @description 删除属性
* @param {AttributeApi.AttributeByQueryDTO} params
*/
export async function deleteAttribute(params: AttributeApi.AttributeByQueryDTO) {
return request('/customer/deleteCustomerAttribute', {
prefix,
params
})
}
/**
* @description 启用停用属性
* @param {AttributeApi.AttributeByUpdateStatusDTO} params
*/
export async function updateAttributeStatus(params: AttributeApi.AttributeByUpdateStatusDTO) {
return request('/customer/updateCustomerAttributeStatus', {
prefix,
params,
// ctlType: 'message'
})
}
// 关联 平台后台属性列表
/**
* @description 关联平台后台属性
* @param {AttributeApi.PlatformAttributeByQueryDTO} params
*/
export async function getPlatformAttribute(params: AttributeApi.PlatformAttributeByQueryDTO) {
return request<AttributeApi.PlatformAttributeItem>('/platform/getAttributeList', {
prefix,
params
})
}
\ No newline at end of file
declare namespace CategoryTreeApi {
interface CategoryTreeItem {
key: string;
title: string ;
checked: boolean;
}
export interface CategoryTreeModel {
key: string;
title: string ;
checked: boolean;
children: CategoryTreeItem[];
}
// 查询 删除共用
export interface CategoryByQueryDTO {
id: number;
}
// export interface CategoryDetailModel {
// id: number;
// key: string;
// name: string;
// type: number;
// imageUrl: string;
// categoryKey: string;
// }
export interface CategoryListItem {
id: number;
key: string;
name: string;
type: number;
imageUrl: string;
categoryKey: string;
}
export interface CategoryListsByQueryDTO {
current: number;
pageSize: number;
name: string;
}
export interface CategroyListsModel {
totalCount: number;
data: CategoryListItem[];
}
/**以下为参考案例 */
interface RegisterBasicDTO {
phone: string;
smsCode: string;
password: string;
email: string;
}
interface RegisterBasicModel {
id: number;
}
interface RegisterTypeDTO {
id: number;
typeId: number;
businessTypeId: number;
}
interface MemberTypeItem {
id: number;
typeName: string;
}
interface BusinessTypeItem {
id: number;
businessTypeName: string;
}
interface RegisterTypeModel {
memberType: MemberTypeItem[];
businessType: BusinessTypeItem[];
}
interface CheckRulesItem {
id: number;
ruleName: string;
ruleType: string;
rulePattern: RegExp;
msg: string;
}
interface RegisterElementItem {
id: number;
fieldName: string;
fieldCNName: string;
fieldType: string;
fieldLength: number;
fieldEmpty: number;
fieldOrder: number;
fieldRemark: string;
checkRules: CheckRulesItem[];
}
interface RegisterDetailElementModel{
groupName: string;
elements: RegisterElementItem[];
}
}
\ No newline at end of file
import request from '@/utils/request';
const prefix = '/product'
/**
* @description 获取品类树形列表
*/
export async function getCustomerCategoryTree() {
return request<CategoryTreeApi.CategoryTreeModel>('/customer/getCustomerCategoryTree', {
prefix
})
}
/**
* @description 查询品类信息
* @param {CategoryTreeApi.CategoryByQueryDTO} params
*/
export async function getCategoryDetail(params: CategoryTreeApi.CategoryByQueryDTO) {
return request<CategoryTreeApi.CategoryListItem>('/customer/getCustomerCategory', {
prefix,
params
})
}
/**
* @description 查询品类列表
* @param {CategoryTreeApi.CategoryListsByQueryDTO} params
*/
export async function getCategoryLists(params: CategoryTreeApi.CategoryListsByQueryDTO) {
return request<CategoryTreeApi.CategroyListsModel>('/customer/getCustomerCategoryList', {
prefix,
params
})
}
/**
* @description 新增/修改品类信息
* @param {CategoryTreeApi.CategoryDetailModel} params
*/
export async function updateCategory(params: CategoryTreeApi.CategoryListItem) {
return request('/customer/saveOrUpdateCustomerCategory', {
prefix,
method: 'post',
data: params
})
}
/**
* @description 删除品类
* @param {CategoryTreeApi.CategoryByQueryDTO} params
*/
export async function deleteCategory(params: CategoryTreeApi.CategoryByQueryDTO) {
return request('/customer/deleteCustomerCategory', {
prefix,
})
}
//** 以下为参考案例 */
/**
* @description 用户基础注册接口
* @param {MemberApi.RegisterBasicModel} params
*/
export async function postMemberRegister(params: MemberApi.RegisterBasicDTO) {
return request<MemberApi.RegisterBasicModel>('/member/register/basic', {
prefix,
method: 'post',
data: params
})
}
/**
* @description 用户会员注册 获取会员/业务类型
*
*/
export async function getRegisterTypeList() {
return request<MemberApi.RegisterTypeModel>('/menu/member/register/type', {
prefix
})
}
/**
* @description 用户会员注册 提交会员类型业务类型
* @param {MemberApi.RegisterTypeDTO}
*/
export async function postMemberRegisterType(params: MemberApi.RegisterTypeDTO) {
return request('/member/register/type', {
prefix,
method: 'post',
data: params
})
}
/**
* @description 获取注册详情页 element元素数据
*
*/
export async function getRegisterElementList() {
return request<MemberApi.RegisterDetailElementModel>('/menu/member/register/detail', {
prefix
})
}
/**
* @description 用户会员注册 提交注册详情
* @param {T}
*/
export async function postMemberRegisterDetail<T>(params: T) {
return request('/member/register/detail', {
prefix,
method: 'post',
data: params
})
}
\ No newline at end of file
declare namespace ProductsAPI {
interface customerCategoryObject {
id: number;
key: string;
level: number;
name: string;
type: number;
imageUrl: string;
categoryKey: string;
}
interface brandObject {
id: number;
name: string;
logoUrl: string;
applyTime: string
status: number;
checkTime: string;
isEnable: boolean;
}
interface goodItem {
id: number;
code: string;
name: string;
type: string;
customerCategoryId: number;
customerCategory: customerCategoryObject;
brandId: number;
brand: object;
unitId: number;
unitName: string;
costPrice: number;
batch: string;
}
export interface ProductListsByQueryDTO {
current: number;
pageSize: number;
name: string;
status: number;
}
export interface ProductItem {
id: number;
status: number;
categoryId: number;
brandId: number;
goodsList: goodItem[];
name: string;
slogan: string;
sellingPoint: string;
area: string[];
// commodityAttribute: commodityAttributeItem[];
commodityAttribute: any[];
unitId: string;
minOrder: number;
priceType: number;
// unitPriceAndPic: unitPriceAndPicItem[];
unitPriceAndPic: any[];
logistics: object;
isInvoice: boolean;
marks: string;
packing: string;
afterService: string;
}
}
\ No newline at end of file
import request from '@/utils/request';
const prefix = '/product'
/**
* @description 查询商品列表
* @param {ProductsAPI.ProductListsByQueryDTO} params
*/
export async function getProductLists(params: ProductsAPI.ProductListsByQueryDTO) {
return request<CategoryTreeApi.CategroyListsModel>('/commodity/getCommodityList', {
prefix,
params
})
}
\ No newline at end of file
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