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

fix:

parent 1e846765
......@@ -41,7 +41,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",
......
......@@ -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>
......
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