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

fix:交易规则会员名称显示异常/选会员同memberId的数据选择异常、modalTable反选异常

parent 0429057f
......@@ -57,11 +57,11 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
onSelect: (record, selects, selectedRows, nativeEvent) => {
if (type === 'radio') {
// 单选情况下
setSelectedRowKeys([record.id])
setSelectedRowKeys([record[customKey]])
setSelectRow([record])
return ;
}
const findIds = selectedRowKeys.indexOf(record.id)
const findIds = selectedRowKeys.indexOf(record[customKey])
if (findIds === -1) {
mergeRowKeys(record[customKey])
mergeRow(record)
......
......@@ -29,6 +29,10 @@ const AddRule:React.FC<{}> = (props) => {
const formSubmit = async (values) => {
setIsDisabled(true)
const params = omit(values, ['state'])
console.log(params, 'parmas')
// 切割memberId
let res: any = {}
if(pageStatus === PageStatus.EDIT){
res = await PublicApi.postOrderTradingRulesBackgroundUpdata(params)
......
......@@ -34,7 +34,7 @@ export interface RuleSettingProps {
const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({customKey: 'memberId'})
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({customKey: 'memberRoleId'})
const [initValue, setInitialValue] = useState({})
const [membersLength, setMembersLength] = useState(0)
......@@ -46,18 +46,20 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const fetchMembersList = async (params) => {
const res = await PublicApi.getMemberManageAllProviderPage(params)
return res.data
const { code, data } = res
let _data = data.data.map(item => ({ ...item, memberRoleId: item.memberId + '_' + item.roleId }))
return { totalCount: data.totalCount, data: _data }
}
// table删除商品
const handleDeleteTable = (id) => {
const value = addSchemaAction.getFieldValue('memberIds')
addSchemaAction.setFieldValue('memberIds', findItemAndDelete(value, id, 'memberId'))
addSchemaAction.setFieldValue('memberIds', findItemAndDelete(value, id, 'memberRoleId'))
}
const handleAddMemberBtn = () => {
const checkBoxs = addSchemaAction.getFieldValue('memberIds')
memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.memberId))
memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.memberRoleId))
memberRowCtl.setSelectRow(checkBoxs)
setVisibleChannelRroduct(true)
}
......@@ -72,9 +74,9 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
key: 'memberId'
},
{
dataIndex: 'name',
dataIndex: 'memberName',
title: '会员名称',
key: 'name',
key: 'memberName',
// render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`}>{_}</EyePreview>
},
{
......@@ -96,7 +98,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
{
dataIndex: 'ctl',
title: '操作',
render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.memberId)}>删除</Button>
render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.memberRoleId)}>删除</Button>
}
]
......@@ -108,6 +110,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// 会员添加弹窗控制
const handleOkAddMember = async () => {
setVisibleChannelRroduct(false)
console.log(memberRowCtl)
addSchemaAction.setFieldValue('memberIds', memberRowCtl.selectRow)
}
......@@ -117,6 +120,12 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const columnsSetProduct: any[] = [
{
dataIndex: 'memberRoleId',
title: 'MRID',
key: 'memberRoleId',
className: 'commonHide'
},
{
dataIndex: 'memberId',
title: 'ID',
key: 'memberId'
......@@ -176,9 +185,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
enum: [],
"x-component-props": {
placeholder: '请选择会员类型',
// style: {
// width: 160
// }
}
},
roleId: {
......@@ -186,9 +192,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
enum: [],
"x-component-props": {
placeholder: '请选择会员角色',
// style: {
// width: 160
// }
}
},
level: {
......@@ -196,9 +199,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
enum: [],
"x-component-props": {
placeholder: '请选择会员等级',
// style: {
// width: 160
// }
}
},
submit: {
......@@ -237,6 +237,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
useEffect(() => {
async function getInitValue() {
// @ts-ignore
const { data } = await PublicApi.getOrderTradingRulesBackgroundDetails({id: id});
if(data.isTacitlyApprove === 2) {
const res = await getBindingMembers({id: id.toString(), current: '1', pageSize: '10'})
......@@ -245,7 +246,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
})
setMembersLength(res.totalCount);
}
console.log(data, 'data')
addSchemaAction.setFieldValue('isTacitlyApprove', data.isTacitlyApprove === 1 ? 1 : 2)
setInitialValue(data)
}
......@@ -257,15 +257,18 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// 拿到绑定的会员
const getBindingMembers = async ({id = '1', current = '1', pageSize = '10'}) => {
const res = await PublicApi.getOrderTradingRulesBackgroundMember({id, current, pageSize})
return res.data
const { code, data } = res
let _data = data.data.map(item => ({ ...item, memberRoleId: item.memberId + '_' + item.roleId }))
return { totalCount: data.totalCount, data: _data }
}
const paginationChange = async (page: number, size: number) => {
if(id !== '') {
const result = await getBindingMembers({id, current: page.toString(), pageSize: size.toString()})
addSchemaAction.setFieldValue('memberIds', result.data)
}
}
// const paginationChange = async (page: number, size: number) => {
// if(id !== '') {
// const result = await getBindingMembers({id, current: page.toString(), pageSize: size.toString()})
// console.log(result.data, 'resu')
// addSchemaAction.setFieldValue('memberIds', result.data)
// }
// }
return (
<>
......@@ -276,7 +279,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
expressionScope={{
tableColumns,
tableAddButton,
paginationChange,
// paginationChange,
membersLength
}}
components={{
......@@ -322,7 +325,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}
}
tableProps={{
rowKey: 'memberId',
rowKey: 'memberRoleId'
}}
/>
......
......@@ -105,7 +105,7 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
type: 'array:number',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'memberId',
rowKey: 'memberRoleId',
columns: "{{tableColumns}}",
prefix: "{{tableAddButton}}"
}
......
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