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

fix:

parent d45b058e
......@@ -185,7 +185,7 @@ function transformSingleTitle(
// 使选中样式受控
data[item].className = cx(
'god-tabtree-select',
Number(nowKey) === Number(data[item].key) ? 'show' : 'hide',
String(nowKey) === String(data[item].key) ? 'show' : 'hide',
);
if (disabled) {
data[item].disableCheckbox = disabled;
......
......@@ -81,18 +81,16 @@ const CategoryAttributes: React.FC<{}> = () => {
const handleSee = (record: any) => {
history.push(`/memberCenter/commodityAbility/classAndProperty/categoryAttributes/viewAttributes?id=${record.id}`)
console.log(record)
}
const handleSelectOk = () => {
setRoleVisible(false)
if (goodsRowCtl.selectRow.length) {
// if (goodsRowCtl.selectRow.length) {
PublicApi.postProductCustomerSaveCustomerCategoryAttribute({ customerCategoryId: selectKey, customerAttributeIds: goodsRowCtl.selectedRowKeys }).then(res=>{
//@ts-ignore
ref.current.reload()
if(res.code === 1000)
setTimeout(() => ref.current.reload(), 500)
})
}
console.log(selectRow)
// }
}
const handleSelectCancel = () => {
setRoleVisible(false)
......@@ -157,7 +155,7 @@ const CategoryAttributes: React.FC<{}> = () => {
render: (text: any, record: any) => {
return (
<>
{record.isEnable ? <></> : <Button type='link' onClick={() => clickRelief(record.id)}>解除关联</Button>}
<Button type='link' onClick={() => clickRelief(record.id)}>解除关联</Button>
</>
)
}
......@@ -221,6 +219,7 @@ const CategoryAttributes: React.FC<{}> = () => {
const clickRelief = (paramsId: number) => {
PublicApi.postProductCustomerDeleteCustomerCategoryAttribute({ customerCategoryId: +currentCategoryRef.current, customerAttributeIds: [paramsId] }).then(res=>{
if(res.code === 1000)
ref.current.reload()
})
}
......
......@@ -22,7 +22,10 @@ enum FormState {
ADD, // 新增状态
}
let flag = false; // 全局变量 用于控制表单编辑退出提示
const formActions = createFormActions()
const treeActions = createTreeActions()
const fetchClassTreeData = async (params?) => { // 商品品类树
const res = await PublicApi.getProductCustomerGetCustomerCategoryTree()
......@@ -52,8 +55,10 @@ const ClassProperty: React.FC<{}> = () => {
setTreeMaps,
resetMenu,
toolsRender,
isEditForm,
handleDeleteMenu
} = useTreeTabs({
treeActions,
deleteMenu: PublicApi.postProductCustomerDeleteCustomerCategory,
fetchMenuData: fetchClassTreeData,
fetchItemDetailData: PublicApi.getProductCustomerGetCustomerCategory
......@@ -61,8 +66,16 @@ const ClassProperty: React.FC<{}> = () => {
const formInitValue = (nodeRecord && treeStatus === FormState.EDIT) ? getTreeMaps(nodeRecord.key) : {}
// useEffect(() => {
// if(treeActions.setExpandedKeys){
// console.log(treeActions.setExpandedKeys)
// treeActions.setSelectKey(85)
// treeActions.setExpandedKeys([85])
// }
// }, [])
/* 关联平台后台品类树 */
const {
const {
treeData: plateformTreeData,
} = useTreeTabs({
fetchMenuData: fetchPlatformTreeData,
......@@ -88,7 +101,6 @@ const ClassProperty: React.FC<{}> = () => {
const handleSelectOk = () => {
setPlateformVisible(false)
console.log(plateformSelectNode, 'plateformSelectNode')
if(plateformSelectNode?.id){
formActions.setFieldValue('category', plateformSelectNode)
}
......@@ -114,6 +126,11 @@ const ClassProperty: React.FC<{}> = () => {
}
}
const clickSelect = (key, node) => {
handleSelect(key, node)
flag = false
}
// 关联平台品类input
const connectCategory = <div className='connectBtn' onClick={handleConnectCategroyBtn}><LinkOutlined style={{marginRight: 4}}/>关联</div>
......@@ -131,7 +148,8 @@ const ClassProperty: React.FC<{}> = () => {
fetchData = {params => fetchClassTreeData(params)}
treeData={treeData}
toolsRender={toolsRender}
handleSelect={(key, node) => handleSelect(key, node)}
actions={treeActions}
handleSelect={(key, node) => clickSelect(key, node)}
customKey="id"
/>
:
......@@ -151,6 +169,20 @@ const ClassProperty: React.FC<{}> = () => {
name='classForm'
onSubmit={onFinish}
actions={formActions}
effects={($, action)=>{
flag = false
$(ON_FORM_INPUT_CHANGE).subscribe(() => {
setIsEditForm(true)
})
$('onFieldValueChange', 'name, type, imageUrl, category').subscribe(state => {
if(flag){
setIsEditForm(true)
flag = false
}
else
flag = true
})
}}
schema={classSchema}
expressionScope={{
connectCategory
......@@ -161,9 +193,11 @@ const ClassProperty: React.FC<{}> = () => {
保存
</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={handleDeleteMenu}>
<Button style={{ marginTop: 32, marginBottom: 16}}>
删除
</Button>
{
treeStatus !== FormState.ADD && <Button style={{ marginTop: 32, marginBottom: 16}}>
删除
</Button>
}
</Popconfirm>
</FormButtonGroup>
</NiceForm>
......
......@@ -74,7 +74,6 @@ const AddPropertyValue: React.FC<{}> = () => {
const handleSubmitAllSetting = () => {
attrValueForm.validateFields().then(values => {
console.log(values, 'menu values')
let pararms = {...values}
delete pararms.attributeName
if(JSON.stringify(pararms.attributeValue)==='{}')
......@@ -82,7 +81,8 @@ const AddPropertyValue: React.FC<{}> = () => {
//@ts-ignore
PublicApi.postProductCustomerSaveOrUpdateCustomerAttributeValue(pararms).then(res => {
if(res.code === 1000)
history.goBack()
// history.goBack()
history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue?before=${history.location.query.attrId}`)
})
}).catch(error => {
......
import React, { useState, useRef, ReactNode, useEffect } from 'react'
import React, { useState, useRef, ReactNode, useEffect, useMemo } from 'react'
import { Row, Col, message, Popconfirm, Button, Card } from 'antd';
import {
DeleteOutlined,
......@@ -16,10 +16,11 @@ import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { createFormActions } from '@formily/antd';
import { useTreeTabs } from '@/hooks/useTreeTabs';
import TabTree from '@/components/TabTree';
import TabTree, { createTreeActions } from '@/components/TabTree';
import { GetProductCustomerGetCustomerAttributeResponse } from '@/services';
const formActions = createFormActions()
const treeActions = createTreeActions()
const fetchAttributeTreeData = async (params?) => {
const res = await PublicApi.getProductCustomerGetCustomerAttributeTree({filterInput: true})
......@@ -35,7 +36,7 @@ const PropertyValue: React.FC<{}> = () => {
treeStatus,
setTreeStatus,
treeData,
setIsEditForm, //是否编辑状态
setIsEditForm, // 是否编辑状态
nodeRecord,
setNodeRecord,
handleSelect,
......@@ -43,12 +44,25 @@ const PropertyValue: React.FC<{}> = () => {
setTreeMaps,
resetMenu
} = useTreeTabs({
treeActions,
fetchMenuData: fetchAttributeTreeData,
})
useEffect(() => {
let prefix = sessionStorage.getItem('beforeKeyPrefix')
let beforeKey = history.location.query.before
console.log(prefix, beforeKey)
if(beforeKey){
setSelectKey(beforeKey)
treeActions.setExpandedKeys([`${prefix}_${beforeKey}`]) // 拼接不正常的key
console.log(`${prefix}_${beforeKey}`)
}
}, [])
useEffect(()=>{
if(selectKey)
if(selectKey){
ref.current.reload({current: 1, pageSize: 10, name: '', customerAttributeId: selectKey})
}
}, [selectKey])
const onHandleSelect = (key, node) => {
......@@ -57,13 +71,14 @@ const PropertyValue: React.FC<{}> = () => {
}
if(key){
let arr = key.split('_');
sessionStorage.setItem('beforeKeyPrefix', arr[0])
console.log(arr[0],'prefix')
setSelectKey(arr[arr.length-1])
setSelectNode(node)
}
}
const fetchData = (params: any) => {
console.log(params, 'params')
return new Promise((resolve, reject) => {
PublicApi.getProductCustomerGetCustomerAttributeValueList({
...params,
......@@ -153,7 +168,7 @@ const PropertyValue: React.FC<{}> = () => {
const confirm = (record: any) => {
PublicApi.postProductCustomerUpdateCustomerAttributeValueStatus({id: record.id, isEnable: !record.isEnable}).then(res=>{
ref.current.reload()
ref.current.reload()
})
}
......@@ -177,6 +192,7 @@ const PropertyValue: React.FC<{}> = () => {
? <TabTree
fetchData = {params => fetchAttributeTreeData(params)}
treeData={treeData}
actions={treeActions}
handleSelect={(key, node) => onHandleSelect(key, node)}
customKey="id"
/>
......
......@@ -10,6 +10,7 @@ import {
DeleteOutlined,
CaretUpOutlined,
CaretDownOutlined,
ExclamationCircleOutlined,
} from '@ant-design/icons'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
......@@ -25,7 +26,7 @@ import { goodsSchema } from './schema'
import { FORM_FILTER_PATH } from '@/formSchema/const'
const { Option } = Select;
const { confirm } = Modal
// 定义选择的行数据的类型
interface Item {
key: string;
......@@ -294,9 +295,19 @@ const Goods: React.FC<{}> = () => {
const handleMenuClick = (e: any) => {
// console.log('menu', e, selectedRowKeys); // 1 批量删除;2 删除导入批次
if (e.key === '1') {
PublicApi.postProductGoodsDeleteBatchGoods({ idList: goodsRowCtl.selectedRowKeys }).then(res => {
//@ts-ignore
ref.current.reload()
confirm({
title: '确定要执行批量删除操作?',
icon: <ExclamationCircleOutlined />,
onOk() {
PublicApi.postProductGoodsDeleteBatchGoods({ idList: goodsRowCtl.selectedRowKeys }).then(res => {
ref.current.reload()
})
},
onCancel() {
console.log('Cancel');
},
okText: '确定',
cancelText: '取消'
})
} else if (e.key === '2') {
console.log('删除导入批次')
......
......@@ -78,7 +78,7 @@ const Products: React.FC<{}> = () => {
const [brandValue, setBrandValue] = useState(undefined)
const [classData, setClassData] = useState<any>([])
const [classValue, setClassValue] = useState(undefined)
const [shopId, setShopId] = useState<number>()
const [shopId, setShopId] = useState<any>()
const columns: ColumnType<any>[] = [
{
......@@ -442,8 +442,8 @@ const Products: React.FC<{}> = () => {
const onChangeUpShop = (values) => {
// 判断上架之前是否有店铺 有即可以上下架
PublicApi.getTemplateShopFindShop().then(res => {
if(res.data.shopId){
setShopId(res.data.shopId)
if(res.data.id){
setShopId(res.data.id)
setCheckedValues(values)
}else{
message.error('您还没有开通店铺,无法上下架商品!')
......
......@@ -180,11 +180,11 @@ const viewProducts: React.FC<{}> = () => {
component = (<><span className="commonStatusValid"></span>审核通过</>)
else if (status === 3)
component = (<><span className="commonStatusInvalid"></span>审核不通过</>)
}
if (status === 5)
component = (<span style={{ color: '#00B37A', padding: '2px 5px', background: 'rgba(235,247,242,1)', borderRadius: '4px' }}>已上架</span>)
else if (status === 6)
component = (<span style={{ padding: '2px 5px', background: 'rgba(244,245,247,1)', borderRadius: '4px' }}>已下架</span>)
}else
if (status === 5)
component = (<span style={{ color: '#00B37A', padding: '2px 5px', background: 'rgba(235,247,242,1)', borderRadius: '4px' }}>已上架</span>)
else if (status === 6)
component = (<span style={{ padding: '2px 5px', background: 'rgba(244,245,247,1)', borderRadius: '4px' }}>已下架</span>)
return component
}
......
......@@ -9,12 +9,14 @@ import {
LoadingOutlined,
ArrowLeftOutlined,
LikeFilled,
RestTwoTone
RestTwoTone,
DeleteOutlined
} from '@ant-design/icons'
import { UploadFile, UploadChangeParam } from 'antd/lib/upload/interface';
import ReutrnEle from '@/components/ReturnEle'
import { PublicApi } from '@/services/api'
import { UPLOAD_TYPE } from '@/constants'
import styles from './index.less'
const { Step } = Steps;
......@@ -197,6 +199,7 @@ const AddBrand: React.FC<{}> = () => {
{...layout}
initialValues={formValues}
autoComplete="off"
className="addForm"
>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="基本信息">
......@@ -239,6 +242,7 @@ const AddBrand: React.FC<{}> = () => {
message: '上传图片!',
},
]}
className={styles.uploadForm}
>
<Upload
disabled={banSomeField}
......@@ -252,6 +256,9 @@ const AddBrand: React.FC<{}> = () => {
data={{ fileType: UPLOAD_TYPE }}
>
{logoUrl ? <img src={logoUrl} alt="avatar" style={{ width: '100%' }} /> : uploadLogoButton}
<div className={styles.hoverDelete}>
<Button type="text" icon={<DeleteOutlined/>} />
</div>
</Upload>
</Form.Item>
</Card>
......
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