Commit 0a13076e authored by 武广's avatar 武广

feat: 添加商品属性

parent 08f4062b
...@@ -37,6 +37,7 @@ import { ...@@ -37,6 +37,7 @@ import {
addGoods, addGoods,
editGoods, editGoods,
queryAllAfterAddress, queryAllAfterAddress,
apiGetAttribute,
} from '../service'; } from '../service';
import styles from '../style.less'; import styles from '../style.less';
import Upload from '../../components/sortablUpload'; import Upload from '../../components/sortablUpload';
...@@ -74,6 +75,7 @@ class goodsManage extends Component { ...@@ -74,6 +75,7 @@ class goodsManage extends Component {
this.getSpecData(); this.getSpecData();
this.getBrandData(); this.getBrandData();
this.getAfterAddressData(); this.getAfterAddressData();
this.getAttribute();
} }
componentWillReceiveProps() { componentWillReceiveProps() {
...@@ -204,8 +206,19 @@ class goodsManage extends Component { ...@@ -204,8 +206,19 @@ class goodsManage extends Component {
this.setState({ initForm }); this.setState({ initForm });
}; };
// 获取属性
getAttribute = async categoryId => {
console.log('categoryId :>> ', categoryId);
const res = await apiGetAttribute({
categoryId,
});
console.log('res :>> ', res);
};
treeChange = value => { treeChange = value => {
this.setState({ categoryId: value[value.length - 1], initCascader: value }); const cid = value[value.length - 1];
this.setState({ categoryId: cid, initCascader: value });
this.getAttribute(cid);
}; };
remove = (flag, k) => { remove = (flag, k) => {
...@@ -525,6 +538,8 @@ class goodsManage extends Component { ...@@ -525,6 +538,8 @@ class goodsManage extends Component {
} = this.state; } = this.state;
const skuSpeFirstKeys = initData.firstSpecList || []; const skuSpeFirstKeys = initData.firstSpecList || [];
const skuSpeSecondKeys = initData.secondSpecList || []; const skuSpeSecondKeys = initData.secondSpecList || [];
const skuAttr = initData.productAttributeApplyList?.productAttributeApplyList || [];
const skuOldAttr = initData.productAttributeApplyList?.oldProductAttributeApplyList || [];
const treeDataArray = productType === 2 ? virtualTreeData : treeData; const treeDataArray = productType === 2 ? virtualTreeData : treeData;
const brandListArray = productType === 2 ? brandList : normalBrandList; const brandListArray = productType === 2 ? brandList : normalBrandList;
dataInit(this.state.editData); dataInit(this.state.editData);
...@@ -721,6 +736,42 @@ class goodsManage extends Component { ...@@ -721,6 +736,42 @@ class goodsManage extends Component {
: ''} : ''}
</Row> </Row>
</Card> </Card>
{/* 商品属性 */}
<Card className={styles.card} bordered={false}>
<div className={styles.cardTitle}>商品属性</div>
<Row>
{skuAttr.length > 0 &&
skuAttr.map(k => (
<FormItem label={k.name} required={false} key={k}>
{getFieldDecorator(`specs[${k}]`, {
initialValue: this.state.initForm.second[k] || '',
validateTrigger: ['onChange', 'onBlur'],
rules: +k.required === 1 ? { required: true, message: '请选择' } : [],
})(
<Select mode={this.getMode(k.supportCustomValue, k.optionType)}>
{k.valueList &&
k.valueList.length &&
k.valueList.map(a => (
<Option key={a.id} value={a}>
{a.name}
</Option>
))}
</Select>,
)}
</FormItem>
))}
</Row>
<Row>
{skuOldAttr.length > 0 &&
skuOldAttr.map(s => (
<FormItem label={s.productAttributeName} required={false} key={s.id}>
{s.value}
</FormItem>
))}
</Row>
</Card>
<Card className={styles.card} bordered={false}> <Card className={styles.card} bordered={false}>
<Row> <Row>
<FormItem label="一级规格"> <FormItem label="一级规格">
......
import React, { useState, useEffect } from 'react';
import { Modal, Button } from 'antd';
import { apiQueryLastAuditRecord } from '../service';
const InfoAudit = props => {
const getRecord = async () => {
console.log('333 :>> ', props.skuInfo.skuId);
// const res = await apiQueryLastAuditRecord(props.skuInfo.skuId);
// console.log('res :>> ', res);
};
useEffect(() => {
console.log('1111 :>> ', 1111);
if (props.visible) {
console.log('222 :>> ', 222);
getRecord();
}
}, [props.visible]);
return (
<Modal
title="商品信息变更审核"
visible={props.visible}
footer={[
<Button key="back" type="primary" onClick={() => props.onEdit()}>
再次编辑
</Button>,
<Button key="close" onClick={() => props.onCancel()}>
关闭
</Button>,
]}
>
<p>审核状态:审核拒绝</p>
<p>申请时间:</p>
<p>审核结果:</p>
</Modal>
);
};
export default InfoAudit;
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 { Card, Pagination, Table, notification, Drawer, Spin, Button } from 'antd'; import { Card, Pagination, Table, notification, Drawer, Spin, Button, Modal } from 'antd';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { connect } from 'dva'; import { connect } from 'dva';
import { sortBy } from 'lodash'; import { sortBy } from 'lodash';
import { da } from 'date-fns/locale';
import styles from './style.less'; import styles from './style.less';
import LocalStroage from '@/utils/localStorage'; import LocalStroage from '@/utils/localStorage';
import configApi from '../../../config/env.config'; import configApi from '../../../config/env.config';
...@@ -27,6 +26,7 @@ import { column, JDSHOPID, ProcessEditData } from './staticdata'; ...@@ -27,6 +26,7 @@ import { column, JDSHOPID, ProcessEditData } from './staticdata';
import SearchForm from './SearchForm'; import SearchForm from './SearchForm';
import TempleatModal from './TempleatModal'; import TempleatModal from './TempleatModal';
import ServiceGoods from '../ServiceGoods'; import ServiceGoods from '../ServiceGoods';
import InfoAudit from './createModal/infoAudit';
import { GOOD_MANAGE } from '@/../config/permission.config'; import { GOOD_MANAGE } from '@/../config/permission.config';
...@@ -58,6 +58,8 @@ class goodsManage extends Component { ...@@ -58,6 +58,8 @@ class goodsManage extends Component {
serviceVisble: false, serviceVisble: false,
serviceData: {}, serviceData: {},
visibleAuditModal: false,
auditRow: {}, // 查看审核信息使用
}; };
currentLog = null; currentLog = null;
...@@ -537,6 +539,21 @@ class goodsManage extends Component { ...@@ -537,6 +539,21 @@ class goodsManage extends Component {
specListData={this.state.specListData} specListData={this.state.specListData}
/> />
</Spin> </Spin>
<InfoAudit
visible={this.state.visibleAuditModal}
skuInfo={this.state.auditRow}
onCancel={() => {
this.setState({ visibleAuditModal: false, auditRow: {} });
}}
onEdit={() => {
this.setState({ visibleAuditModal: false, auditRow: {} });
if (this.state.auditRow.type === 4) {
this.serviceVisbleChange(this.state.auditRow);
} else {
this.onUpdateInfo(this.state.auditRow);
}
}}
/>
</PageHeaderWrapper> </PageHeaderWrapper>
); );
} }
......
...@@ -42,6 +42,15 @@ export async function getBrandList() { ...@@ -42,6 +42,15 @@ export async function getBrandList() {
}); });
} }
// 获取类目关联属性
export async function apiGetAttribute(params) {
const data = await request.get('/api/kdsp/category/template/ref/attribute', {
prefix: goodsApi,
params,
});
return data;
}
// 编辑--获取详情 // 编辑--获取详情
export async function spuDetail(params) { export async function spuDetail(params) {
return request.post('/product/api/merchant/detail', { return request.post('/product/api/merchant/detail', {
...@@ -240,3 +249,9 @@ export const apiChangeStateGoods = async params => { ...@@ -240,3 +249,9 @@ export const apiChangeStateGoods = async params => {
}); });
return data; return data;
}; };
// 查询sku最后一条审核记录
export const apiQueryLastAuditRecord = skuId =>
request.get(`/api/kdsp/sku/last/audit/record?skuId=${skuId}`, {
prefix: goodsApi,
});
...@@ -50,6 +50,12 @@ export function column() { ...@@ -50,6 +50,12 @@ export function column() {
}, },
}); });
}; };
const onShowAudit = row => {
this.setState({
auditRow: row,
visibleAuditModal: true,
});
};
return [ return [
{ {
...@@ -183,7 +189,10 @@ export function column() { ...@@ -183,7 +189,10 @@ export function column() {
render: (_, row) => ( render: (_, row) => (
<div> <div>
<p>{row.state >= 5 ? '审核通过' : _}</p> <p>{row.state >= 5 ? '审核通过' : _}</p>
<p>{row.updateStateDesc || '_ _'}</p> <div onClick={() => onShowAudit(row)}>
{' '}
{row.updateStateDesc ? <span>{row.updateStateDesc}</span> : '--'}
</div>
</div> </div>
), ),
}, },
......
...@@ -110,3 +110,8 @@ ...@@ -110,3 +110,8 @@
color: #d9363e; color: #d9363e;
line-height: 1; line-height: 1;
} }
.cardTitle {
padding: 15px;
font-weight: bold;
font-size: 18px;
}
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