Commit 12367cd9 authored by GuanHua's avatar GuanHua
parents d12d2ca7 46551319
......@@ -42,7 +42,7 @@
"core-js": "^3.6.5",
"god": "^0.1.26",
"lingxi-design": "^1.0.7",
"lingxi-design-ui": "^1.0.9",
"lingxi-design-ui": "^1.1.0",
"lingxi-editor-core": "^1.0.6",
"lingxi-web": "^1.0.6",
"lint-staged": "^10.0.7",
......
......@@ -9,6 +9,7 @@ export interface CheckboxTreeProps {
checkedNodes?: any[];
handleChange?(e?);
handleSubmit?();
saveLoading?: boolean;
showSave?;
disabled?: boolean;
actions?: RefObject<any>;
......@@ -22,7 +23,8 @@ const CheckboxTree: React.FC<CheckboxTreeProps> = props => {
handleChange,
disabled,
showSave,
handleSubmit,
handleSubmit,
saveLoading,
} = props;
const checkedKeys = findTreeKeys(checkedNodes, 'id');
const {
......@@ -58,16 +60,23 @@ const CheckboxTree: React.FC<CheckboxTreeProps> = props => {
<div className="flex-bet">
<div>{props.title}</div>
<div>
{!disabled && (
<Button onClick={toggleSelectAll} type="link">
{allSelected ? '取消全选' : '全选'}
</Button>
)}
{showSave && (
<Button onClick={handleSubmit} type="link" disabled={disabled}>
保存
</Button>
)}
<div>
{!disabled && (
<Button onClick={toggleSelectAll} type="link">
{allSelected ? '取消全选' : '全选'}
</Button>
)}
{showSave && (
<Button
type="link"
disabled={disabled}
loading={saveLoading}
onClick={handleSubmit}
>
保存
</Button>
)}
</div>
</div>
</div>
)}
......
......@@ -37,8 +37,10 @@ export interface TabTreeProps extends TreeProps {
customTitle?: string | number;
handleSelect?: (key: ReactText, node: any) => void | Promise<any>;
handleSubmit?();
saveLoading?: boolean;
toolsRender?: toolsRenderProps;
getMenuSelectData?(): Promise<any>;
handleCheck?: (keys: any, nodes: any) => {};
}
export interface InnermostTreeNodeProps {}
......@@ -211,7 +213,9 @@ const TabTree: React.FC<TabTreeProps> = props => {
disabled,
showSave,
getMenuSelectData,
handleSubmit,
handleSubmit,
saveLoading,
handleCheck,
} = props;
const selfActions = useTreeActions(actions)
......@@ -298,16 +302,23 @@ const TabTree: React.FC<TabTreeProps> = props => {
{title && (
<div className="god-tabtree-header">
<div>{title}</div>
{checkable && !disabled && (
<Button onClick={toggleSelectAll} disabled={disabled} type="link">
{allSelected ? '取消全选' : '全选'}
</Button>
)}
{showSave && checkable && (
<Button onClick={handleSubmit} disabled={disabled} type="link">
保存
</Button>
)}
<div className="god-tabtree-header-extra">
{checkable && !disabled && (
<Button onClick={toggleSelectAll} disabled={disabled} type="link">
{allSelected ? '取消全选' : '全选'}
</Button>
)}
{showSave && checkable && (
<Button
type="link"
disabled={disabled}
loading={saveLoading}
onClick={handleSubmit}
>
保存
</Button>
)}
</div>
</div>
)}
......@@ -323,6 +334,11 @@ const TabTree: React.FC<TabTreeProps> = props => {
checked
? batchSelect(keys as any)
: setSelected(checkedNodes.map(v => v.key));
// 用户自定义的勾选后触发事件
if (handleCheck) {
handleCheck(keys, nodes);
}
}}
onSelect={(keys, e) => {
// 控制点击node时可以展开
......
......@@ -32,6 +32,7 @@ const AddAtttribute: React.FC<{}> = () => {
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([])
const [formValue, setFormValue] = useState<any>({})
const [isSpecial, setIsSpecial] = useState(false) //特殊属性禁用展示方式
const { id, pageStatus } = usePageStatus()
useEffect(() => {
......@@ -129,6 +130,12 @@ const AddAtttribute: React.FC<{}> = () => {
// 特殊属性切换
const onChangeSpecial = (e, type) => {
if(e.target.checked){
setIsSpecial(true)
menuForm.setFieldsValue({type: 2})
}else{
setIsSpecial(false)
}
if(type === 'isDate')
menuForm.setFieldsValue({isArea: false})
if(type === 'isArea')
......@@ -204,7 +211,7 @@ const AddAtttribute: React.FC<{}> = () => {
},
]}
>
<Select placeholder="选择展示方式" disabled={pageStatus === 2}>
<Select placeholder="选择展示方式" disabled={pageStatus === 2 || isSpecial}>
<Option value={1}>单选</Option>
<Option value={2}>多选</Option>
<Option value={3}>输入</Option>
......
import React, { useState, useEffect, useRef } from 'react'
import { Row, Col, Form, Input, Select, Popconfirm, Button, Card, Modal, Tooltip, message } from 'antd';
import { Row, Col, Form, Input, Select, Popconfirm, Button, Card, Modal, Tooltip, message, Cascader, Spin } 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 { PublicApi } from '@/services/api';
import { GetManageAreaAllResponse } from '@/services/PassApi';
const layout = {
labelCol: {
......@@ -36,9 +37,27 @@ const AddPropertyValue: React.FC<{}> = () => {
const [formValue, setFormValue] = useState<any>({})
const [attributeValueId, setAttributeValueId] = useState(null) // url传入 可判断是编辑/新增
const [isSee, setIsSee] = useState(false) // 判断查看依据
const [specialType, setSpecialType] = useState<any>() // 1-日期; 2-地区
const [proviceOptions, setProviceOptions] = useState<GetManageAreaAllResponse>()
const [areaString, setAreaString] = useState<string>()
useEffect(() => {
const { attrId, attrName, attrValueId, isSee } = history.location.query
//获取省市区
PublicApi.getManageAreaAll().then(res => {
if (res.code === 1000) {
let arr = [...res.data] //裁去最后一级别
for (let index in arr) {
for (let _index in arr[index].areaResponses) {
let o = arr[index].areaResponses
//@ts-ignore
o[_index].areaResponses = null
}
}
setProviceOptions(arr)
}
})
const { attrId, attrName, attrValueId, isSee, type } = history.location.query
if(attrId){
attrValueForm.setFieldsValue({attribute: { id: Number(attrId)}})
}
......@@ -58,25 +77,44 @@ const AddPropertyValue: React.FC<{}> = () => {
if(isSee){
setIsSee(true)
}
if(type){
setSpecialType(type)
}
}, [])
const handleSubmitAllSetting = () => {
attrValueForm.validateFields().then(values => {
console.log(values, 'menu values')
let pararms = {...values}
const { attrId, attrName, type } = history.location.query
let pararms:any = {...values}
delete pararms.attributeName
if(JSON.stringify(pararms.attributeValue)==='{}')
delete pararms.attributeValue
//@ts-ignore
if(type === '2')
pararms.value = areaString
if(type === '1')
pararms.value = '自动日期' + parseInt(Math.random() * 100 + '')
PublicApi.postProductPlatformSaveOrUpdateAttributeValue(pararms).then(res => {
if(res.code === 1000)
history.goBack()
// history.goBack()
history.push(`/classAndProperty/propertyValue?attrId=${attrId}&attrName=${attrName}&type=${type}`)
})
}).catch(error => {
console.error(error)
})
}
const onCommodityAreaChange = (value: any, selected: any) => {
let arr = selected.map(item => item.name)
if(arr.length > 1){
setAreaString(arr.join('/'))
}else{
setAreaString(arr.toString())
}
}
return <PageHeaderWrapper
onBack={() => history.goBack()}
......@@ -111,18 +149,56 @@ const AddPropertyValue: React.FC<{}> = () => {
</Form.Item>
</Col>
<Col span={18}>
<Form.Item
name='value'
label='属性值名称'
rules={[
{
required: true,
message: '输入属性值名称!',
},
]}
>
<Input placeholder="输入属性值名称" disabled={isSee} />
</Form.Item>
{
specialType !== '1' && specialType !== '2' && <Form.Item
name='value'
label='属性值名称'
rules={[
{
required: true,
message: '输入属性值名称!',
},
]}
>
<Input placeholder="输入属性值名称" disabled={isSee} />
</Form.Item>
}
{
specialType === '2' && <Form.Item
name='value'
label='属性值名称'
rules={[
{
required: true,
message: '输入属性值名称!',
},
]}
>
<Cascader
disabled={isSee}
options={proviceOptions}
changeOnSelect
onChange={onCommodityAreaChange}
placeholder="请选择地区"
fieldNames={{ label: 'name', value: 'code', children: 'areaResponses' }}
notFoundContent={<Spin size="small" />}
/>
</Form.Item>
}
{
specialType === '1' && <Form.Item
name='value'
label='属性值名称'
// rules={[
// {
// required: true,
// message: '输入属性值名称!',
// },
// ]}
>
<span>日期属性无须设置属性值,属性值由系统自动生成。</span>
</Form.Item>
}
</Col>
<Col span={18}>
<Form.Item
......
......@@ -79,7 +79,7 @@ const PropertyValue: React.FC<{}> = () => {
}
const handleSee = (record: any) => {
history.push(`/classAndProperty/propertyValue/addPropertyValue?attrId=${selectKey}&attrName=${selectNode._title}&attrValueId=${record.id}&isSee=true`)
history.push(`/classAndProperty/propertyValue/addPropertyValue?attrId=${selectKey}&attrName=${selectNode._title}&attrValueId=${record.id}&isSee=true&type=${record.type}`)
}
const columns: ColumnType<any>[] = [
......@@ -226,7 +226,9 @@ const PropertyValue: React.FC<{}> = () => {
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => { history.push(`/classAndProperty/propertyValue/addPropertyValue?attrId=${selectKey}&attrName=${selectNode._title}`) }}
onClick={() => {
history.push(`/classAndProperty/propertyValue/addPropertyValue?attrId=${selectKey||history.location.query.attrId}&attrName=${selectNode._title||history.location.query.attrName}&type=${selectNode?.type||history.location.query.type}`)
}}
>
新建
</Button>
......
......@@ -106,7 +106,7 @@ const Products: React.FC<{}> = () => {
}
},
{
title: '审核时间',
title: '申请审核时间',
dataIndex: 'applyTime',
key: 'applyTime',
render: (text:any, record:any)=>text && moment(text).format('YYYY-MM-DD HH:mm:ss'),
......
......@@ -120,7 +120,7 @@ const Products: React.FC<{}> = () => {
}
},
{
title: '审核时间',
title: '申请审核时间',
dataIndex: 'applyTime',
key: 'applyTime',
render: (text:any, record:any)=>text && moment(text).format('YYYY-MM-DD HH:mm:ss'),
......
import React, { useState, useRef } from 'react';
import { Row, Col, Modal } from 'antd';
import { Row, Col, Modal, Spin } from 'antd';
import { Prompt } from 'umi';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { useTreeTabs, FormState } from '@/hooks/useTreeTabs';
import { PublicApi } from '@/services/api';
......@@ -12,8 +13,12 @@ const treeActions = createTreeActions();
const PowerInfo: React.FC<{}> = () => {
const { id, validateId, pageStatus } = usePageStatus();
const [powerLoading, setPowerLoading] = useState(false);
const [buttonInfos, setButtonInfos] = useState<any>([]);
const [powerUnsaved, setPowerUnsaved] = useState(false);
const [btnsUnsaved, setBtnsUnsaved] = useState(false);
const [powerLoading, setPowerLoading] = useState(false);
const [submitAuthLoading, setSubmitAuthLoading] = useState(false);
const [submitBtnsLoading, setSubmitBtnsLoading] = useState(false);
const actionRef = useRef<any>({});
......@@ -127,8 +132,14 @@ const PowerInfo: React.FC<{}> = () => {
selectCallback: customSelect,
});
const handleBtnsChange = () => {
setIsEditForm(true)
setBtnsUnsaved(true);
};
// 更新右侧按钮
const handleSubmitAuth = async () => {
const handleSubmitAuthBtns = async () => {
setSubmitBtnsLoading(true);
const buttonIds = [...actionRef.current.selected];
if (!nodeRecord) {
......@@ -136,45 +147,76 @@ const PowerInfo: React.FC<{}> = () => {
}
if (isEditForm) {
// 更新右侧按钮
await PublicApi.postMemberValidateCommitUpdatebutton({
await PublicApi.postMemberMaintenanceDetailAuthButtonUpdate({
memberId: id,
validateId,
menuId: nodeRecord.id,
buttonIds: buttonIds,
});
}
setSubmitBtnsLoading(false);
setIsEditForm(false);
setBtnsUnsaved(false);
};
// 更新左侧菜单
const handleSubmitAuth = async () => {
setSubmitAuthLoading(true);
const menuIds: any = treeActions.getSelectKeys();
// 更新右侧按钮
await PublicApi.postMemberMaintenanceDetailAuthMenuUpdate({
memberId: id,
validateId,
menuIds,
});
const checkddRes = await getMenuSelectData();
const { data }: {[key: string]: any} = checkddRes;
treeActions.setSelectKeys(data.ids);
setSubmitAuthLoading(false);
setPowerUnsaved(false);
};
const handleCheck = () => {
setPowerUnsaved(true);
};
return (
<Row>
<Col span={15}>
<MellowCard>
<TabTree
title="菜单列表"
getMenuSelectData={getMenuSelectData}
customKey="id"
actions={treeActions}
treeData={treeData}
handleSelect={handleSelect}
disabled={true}
checkable
/>
</MellowCard>
</Col>
<Col span={8} offset={1}>
<MellowCard>
<CheckboxTree
actions={actionRef}
disabled={true}
handleChange={e => setIsEditForm(true)}
checkedNodes={buttonInfos}
title="菜单按钮访问权限"
handleSubmit={handleSubmitAuth}
/>
</MellowCard>
</Col>
</Row>
<Spin spinning={powerLoading}>
<Row>
<Col span={15}>
<MellowCard>
<TabTree
title="菜单列表"
getMenuSelectData={getMenuSelectData}
customKey="id"
actions={treeActions}
treeData={treeData}
handleSelect={handleSelect}
handleCheck={handleCheck}
saveLoading={submitAuthLoading}
handleSubmit={handleSubmitAuth}
checkable
showSave
/>
</MellowCard>
</Col>
<Col span={8} offset={1}>
<MellowCard>
<CheckboxTree
actions={actionRef}
handleChange={e => handleBtnsChange()}
checkedNodes={buttonInfos}
title="菜单按钮访问权限"
saveLoading={submitBtnsLoading}
handleSubmit={handleSubmitAuthBtns}
/>
</MellowCard>
</Col>
</Row>
<Prompt when={powerUnsaved || btnsUnsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
);
};
......
import React, { useState, useEffect, useRef } from 'react';
import { history } from 'umi';
import { history, Prompt } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import {
PageHeader,
......@@ -57,9 +57,12 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
const [basicInfo, setBasicInfo] = useState<GetMemberValidateCommitDetailResponse>();
const [modalVisible, setModalVisible] = useState(false);
const [buttonInfos, setButtonInfos] = useState<any>([]);
const [powerUnsaved, setPowerUnsaved] = useState(false);
const [btnsUnsaved, setBtnsUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [powerLoading, setPowerLoading] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false);
const [submitBtnsLoading, setSubmitBtnsLoading] = useState(false);
const getBasicInfo = () => {
if (!id || !validateId) {
......@@ -197,7 +200,13 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
selectCallback: customSelect,
});
const handleBtnsChange = () => {
setIsEditForm(true)
setBtnsUnsaved(true);
};
const handleSubmitAuth = async () => {
setSubmitBtnsLoading(true);
const buttonIds = [...actionRef.current.selected];
if (!nodeRecord) {
......@@ -212,7 +221,10 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
buttonIds: buttonIds,
});
}
setSubmitBtnsLoading(false);
setIsEditForm(false);
setBtnsUnsaved(false);
};
const updateMenu = () => {
......@@ -220,7 +232,7 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
return PublicApi.postMemberValidateCommitUpdatemenu({
memberId: id,
validateId,
checkIds: menuIds,
menuIds,
}, {
ctlType: 'none',
});
......@@ -245,11 +257,16 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
setModalVisible(false);
}
setConfirmLoading(false);
setPowerUnsaved(false);
}).catch(() => {
setConfirmLoading(false);
});
};
const handleCheck = () => {
setPowerUnsaved(true);
};
return (
<Spin spinning={infoLoading || powerLoading}>
<PageHeaderWrapper
......@@ -351,6 +368,7 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
actions={treeActions}
treeData={treeData}
handleSelect={handleSelect}
handleCheck={handleCheck}
disabled={pageStatus === PageStatus.PREVIEW}
checkable
/>
......@@ -361,9 +379,10 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
<CheckboxTree
actions={actionRef}
disabled={pageStatus === PageStatus.PREVIEW}
handleChange={e => setIsEditForm(true)}
handleChange={e => handleBtnsChange}
checkedNodes={buttonInfos}
title="菜单按钮访问权限"
saveLoading={submitBtnsLoading}
handleSubmit={handleSubmitAuth}
showSave={pageStatus !== PageStatus.PREVIEW}
/>
......@@ -394,6 +413,7 @@ const AuditPrSubmit: React.FC<QueryProps> = props => {
/>
</Modal>
</PageHeaderWrapper>
<Prompt when={powerUnsaved || btnsUnsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
);
};
......
......@@ -70,11 +70,11 @@ const CheckBrand: React.FC<{}> = () => {
render: (text:any, record:any) => {
let component: ReactNode = null
if(record.operation === 1)
component = (<>新增</>)
component = (<>提价审核</>)
else if(record.operation === 2)
component = (<>修改</>)
component = (<>修改品牌</>)
else if(record.operation === 3)
component = (<>审核</>)
component = (<>审核品牌</>)
return component
}
},
......@@ -242,18 +242,20 @@ const CheckBrand: React.FC<{}> = () => {
<Radio value={3}>审核不通过</Radio>
</Radio.Group>
</Form.Item>
<Form.Item
name="checkRemark"
label={checkStatus===4?'审核通过原因':'审核不通过原因'}
rules={[
{
required: checkStatus===4?false:true,
message: '请填写原因'
}
]}
>
<TextArea rows={3} maxLength={60} placeholder="请填写原因" />
</Form.Item>
{
checkStatus===3 && <Form.Item
name="checkRemark"
label='审核不通过原因'
rules={[
{
required: true,
message: '请填写原因'
}
]}
>
<TextArea rows={3} maxLength={60} placeholder="请填写原因" />
</Form.Item>
}
</Form>
</Modal>
</PageHeaderWrapper>
......
......@@ -112,7 +112,7 @@ const Trademark: React.FC<{}> = () => {
type: 'string',
enum: [
{ label: '全部', value: 0 },
{ label: '待提交审核', value: 1 },
// { label: '待提交审核', value: 1 },
{ label: '待审核', value: 2 },
{ label: '审核不通过', value: 3 },
{ label: '审核通过', value: 4 }
......
......@@ -79,11 +79,11 @@ const viewBrand: React.FC<{}> = () => {
render: (text:any, record:any) => {
let component: ReactNode = null
if(record.operation === 1)
component = (<>新增</>)
component = (<>提交审核</>)
else if(record.operation === 2)
component = (<>修改</>)
component = (<>修改品牌</>)
else if(record.operation === 3)
component = (<>审核</>)
component = (<>审核品牌</>)
return component
}
},
......
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