Commit 95a0b54e authored by 武广's avatar 武广

feat: 添加超出折叠显示

parent 9939024c
...@@ -2,7 +2,13 @@ ...@@ -2,7 +2,13 @@
import { Form } from '@ant-design/compatible'; import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css'; import '@ant-design/compatible/assets/index.css';
import { MinusCircleOutlined, PlusOutlined, RestOutlined } from '@ant-design/icons'; import {
MinusCircleOutlined,
PlusOutlined,
RestOutlined,
DownOutlined,
UpOutlined,
} from '@ant-design/icons';
import { import {
Modal, Modal,
Table, Table,
...@@ -234,7 +240,9 @@ class goodsManage extends Component { ...@@ -234,7 +240,9 @@ class goodsManage extends Component {
treeChange = value => { treeChange = value => {
const cid = value[value.length - 1]; const cid = value[value.length - 1];
this.setState({ categoryId: cid, initCascader: value }); this.setState({ categoryId: cid, initCascader: value });
this.getAttribute(cid); if (value.length === 3) {
this.getAttribute(cid);
}
}; };
remove = (flag, k) => { remove = (flag, k) => {
...@@ -842,56 +850,76 @@ class goodsManage extends Component { ...@@ -842,56 +850,76 @@ class goodsManage extends Component {
{/* 商品属性 */} {/* 商品属性 */}
<Card className={styles.card} bordered={false}> <Card className={styles.card} bordered={false}>
<div className={styles.cardTitle}>商品属性</div> <div className={styles.cardTitle}>商品属性</div>
<Row> <div
{this.state.categoryAttrs.length > 0 && className={styles.attrbox + (this.state.isMore ? styles.attrboxMore : '')}
this.state.categoryAttrs.map((k, i) => ( more={this.state.isMore}
<Col span={12} key={k.id}> >
<FormItem label={k.name} {...formItemAttr} key={k.id}> <Row>
{getFieldDecorator(`attributeApplyList[${i}]['attr${k.id}']`, { {this.state.categoryAttrs.length > 0 &&
initialValue: this.getInitAttrValue( this.state.categoryAttrs.map((k, i) => (
k.id, <Col span={12} key={k.id}>
k.supportCustomValue, <FormItem label={k.name} {...formItemAttr} key={k.id}>
k.optionType, {getFieldDecorator(`attributeApplyList[${i}]['attr${k.id}']`, {
), // +k.supportCustomValue.code === 1 || +k.optionType.code === 2 ? [] : '', initialValue: this.getInitAttrValue(
validateTrigger: ['onChange'], k.id,
rules: k.supportCustomValue,
+k.required.code === 1 k.optionType,
? [ ), // +k.supportCustomValue.code === 1 || +k.optionType.code === 2 ? [] : '',
{ validateTrigger: ['onChange'],
required: true, rules:
type: +k.required.code === 1
+k.supportCustomValue.code === 1 || +k.optionType.code === 2 ? [
? 'array' {
: 'string', required: true,
message: '请选择', type:
}, +k.supportCustomValue.code === 1 || +k.optionType.code === 2
] ? 'array'
: [], : 'string',
})( message: '请选择',
<Select },
mode={this.getMode(k.supportCustomValue, k.optionType)} ]
maxTagTextLength={8} : [],
allowClear })(
> <Select
{k.valueList && mode={this.getMode(k.supportCustomValue, k.optionType)}
k.valueList.length && maxTagTextLength={8}
k.valueList.map(a => ( allowClear
<Option >
key={a.id} {k.valueList &&
value={JSON.stringify({ k.valueList.length &&
attributeValueId: a.id, k.valueList.map(a => (
attributeValueName: a.name, <Option
})} key={a.id}
> value={JSON.stringify({
{a.name} attributeValueId: a.id,
</Option> attributeValueName: a.name,
))} })}
</Select>, >
)} {a.name}
</FormItem> </Option>
</Col> ))}
))} </Select>,
</Row> )}
</FormItem>
</Col>
))}
</Row>
</div>
{this.state.categoryAttrs.length > 12 && (
<div>
<Button
type="link"
onClick={() =>
this.setState(state => ({
isMore: !state.isMore,
}))
}
>
{this.state.isMore ? '收起' : '展示更多'}
{this.state.isMore ? <UpOutlined /> : <DownOutlined />}
</Button>
</div>
)}
{skuOldAttr.length > 0 && ( {skuOldAttr.length > 0 && (
<div> <div>
<Row>注:以下商品属性已失效,请使用新的属性</Row> <Row>注:以下商品属性已失效,请使用新的属性</Row>
......
...@@ -87,6 +87,15 @@ export async function categoryList() { ...@@ -87,6 +87,15 @@ export async function categoryList() {
prefix: goodsApi, prefix: goodsApi,
}); });
} }
/**
* 商品分类
* type 商品类型:1-实物类,2-虚拟类,4-服务类
* */
export async function apiCategoryListType(type) {
return request.get(`/product/category/getByProductType/${type}`, {
prefix: goodsApi,
});
}
// 批量修改 // 批量修改
export async function uploadFile(file) { export async function uploadFile(file) {
......
...@@ -119,3 +119,10 @@ ...@@ -119,3 +119,10 @@
color: #1890ff; color: #1890ff;
cursor: pointer; cursor: pointer;
} }
.attrbox {
max-height: 384px;
overflow: hidden;
}
.attrboxMore {
max-height: max-content;
}
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