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

feat: 添加超出折叠显示

parent 9939024c
......@@ -2,7 +2,13 @@
import { Form } from '@ant-design/compatible';
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 {
Modal,
Table,
......@@ -234,7 +240,9 @@ class goodsManage extends Component {
treeChange = value => {
const cid = value[value.length - 1];
this.setState({ categoryId: cid, initCascader: value });
this.getAttribute(cid);
if (value.length === 3) {
this.getAttribute(cid);
}
};
remove = (flag, k) => {
......@@ -842,56 +850,76 @@ class goodsManage extends Component {
{/* 商品属性 */}
<Card className={styles.card} bordered={false}>
<div className={styles.cardTitle}>商品属性</div>
<Row>
{this.state.categoryAttrs.length > 0 &&
this.state.categoryAttrs.map((k, i) => (
<Col span={12} key={k.id}>
<FormItem label={k.name} {...formItemAttr} key={k.id}>
{getFieldDecorator(`attributeApplyList[${i}]['attr${k.id}']`, {
initialValue: this.getInitAttrValue(
k.id,
k.supportCustomValue,
k.optionType,
), // +k.supportCustomValue.code === 1 || +k.optionType.code === 2 ? [] : '',
validateTrigger: ['onChange'],
rules:
+k.required.code === 1
? [
{
required: true,
type:
+k.supportCustomValue.code === 1 || +k.optionType.code === 2
? 'array'
: 'string',
message: '请选择',
},
]
: [],
})(
<Select
mode={this.getMode(k.supportCustomValue, k.optionType)}
maxTagTextLength={8}
allowClear
>
{k.valueList &&
k.valueList.length &&
k.valueList.map(a => (
<Option
key={a.id}
value={JSON.stringify({
attributeValueId: a.id,
attributeValueName: a.name,
})}
>
{a.name}
</Option>
))}
</Select>,
)}
</FormItem>
</Col>
))}
</Row>
<div
className={styles.attrbox + (this.state.isMore ? styles.attrboxMore : '')}
more={this.state.isMore}
>
<Row>
{this.state.categoryAttrs.length > 0 &&
this.state.categoryAttrs.map((k, i) => (
<Col span={12} key={k.id}>
<FormItem label={k.name} {...formItemAttr} key={k.id}>
{getFieldDecorator(`attributeApplyList[${i}]['attr${k.id}']`, {
initialValue: this.getInitAttrValue(
k.id,
k.supportCustomValue,
k.optionType,
), // +k.supportCustomValue.code === 1 || +k.optionType.code === 2 ? [] : '',
validateTrigger: ['onChange'],
rules:
+k.required.code === 1
? [
{
required: true,
type:
+k.supportCustomValue.code === 1 || +k.optionType.code === 2
? 'array'
: 'string',
message: '请选择',
},
]
: [],
})(
<Select
mode={this.getMode(k.supportCustomValue, k.optionType)}
maxTagTextLength={8}
allowClear
>
{k.valueList &&
k.valueList.length &&
k.valueList.map(a => (
<Option
key={a.id}
value={JSON.stringify({
attributeValueId: a.id,
attributeValueName: a.name,
})}
>
{a.name}
</Option>
))}
</Select>,
)}
</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 && (
<div>
<Row>注:以下商品属性已失效,请使用新的属性</Row>
......
......@@ -87,6 +87,15 @@ export async function categoryList() {
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) {
......
......@@ -119,3 +119,10 @@
color: #1890ff;
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