Commit 6c9749d1 authored by baixian's avatar baixian

积分

parent 91885b91
......@@ -144,6 +144,10 @@ export default {
integralsetting: {
goodsList: `${dakaapi}member/integral_goods`,
goodsDelete: `${dakaapi}member/integral_goods/good_status`,
scoreSave: `${dakaapi}member/integral/distribution`, // 积分配置
goodsAdd: `${dakaapi}member/integral_goods/store`,
goodsEdit: `${dakaapi}member/integral_goods/update`,
journalList: `${dakaapi}member/integral/records`,
},
};
......@@ -8,12 +8,36 @@ import {
} from '../utils/index';
import errorcode from '../common/errorcode';
import * as goodsAjax from '../services/integral';
import * as studentsAjax from '../services/students';
import * as courseAjax from '../services/course';
import * as teachersAjax from '../services/teachers';
import * as classMgtAjax from '../services/classmgt';
export default {
namespace: 'integral',
state: {
goodsList: [],
sid: 0,
allStudentList: [],
editScoreVisible: false,
editCouponModalShow: false,
editGoodsModalShow: false,
recordList: [],
recordListTotal: 0,
couponImg: '',
editCouponInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
editGoodsInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
},
subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line
......@@ -22,25 +46,195 @@ export default {
effects: {
* integralModelList({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
console.log(sid, 'dsa');
const loadmessage = message.loading('数据加载中...', 0);
const courselistinfo = yield call(goodsAjax.goodsList, {
const goodslistinfo = yield call(goodsAjax.goodsList, {
school_id: sid,
});
setTimeout(loadmessage);
if (courselistinfo.code == 200) {
if (goodslistinfo.code == 200) {
yield put({
type: 'updateState',
payload: {
sid,
goodsList: courselistinfo.data && courselistinfo.data.list,
goodsList: goodslistinfo.data && goodslistinfo.data.list,
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: courselistinfo,
data: goodslistinfo,
},
});
}
},
* integralModelScoreSave({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
const { courseSubmiting } = yield select(state => state.integral);
if (courseSubmiting) {
return;
}
yield put({
type: 'updateState',
payload: {
courseSubmiting: true,
},
});
const {
student_ids,
number,
remark,
} = payload;
if (!sid) {
return;
}
const loadmessage = message.loading('数据保存中...', 0);
const scoreAdd = yield call(goodsAjax.scoreSave, {
school_id: sid,
student_ids,
number,
remark,
});
yield put({
type: 'updateState',
payload: {
courseSubmiting: false,
},
});
setTimeout(loadmessage);
if (scoreAdd.code == 200) {
yield put({
type: 'updateState',
payload: {
editScoreVisible: false,
},
});
} else if (scoreAdd.code == 4000) {
message.error(scoreAdd.msg, 1);
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: scoreAdd,
},
});
}
yield put(routerRedux.push({
pathname: '/sjd/integralmanage',
}));
},
* integralModelStudentsList({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
if (!sid) {
return;
}
const { studentListQueryParams } = yield select(state => state.studentclass);
const loadmessage = message.loading('数据加载中...', 0);
const newClassListQueryParams = Object.assign(studentListQueryParams, {
school_id: sid,
});
const studentsinfo = yield call(studentsAjax.studentsList, newClassListQueryParams);
setTimeout(loadmessage);
if (studentsinfo.code == 200) {
yield put({
type: 'updateState',
payload: {
allStudentList: (studentsinfo.data && studentsinfo.data.list) || [],
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: studentsinfo,
},
});
}
},
* integralModelGoodAdd({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
const {
studentSubmiting, couponImg, couponBanner, editCouponInfo,
} = yield select(state => state.integral);
if (!sid) {
return;
}
if (studentSubmiting) {
return;
}
yield put({
type: 'updateState',
payload: {
studentSubmiting: true,
},
});
const {
price,
title,
inventory,
remark,
type,
cover,
status,
banner,
} = payload;
console.log(payload, 'payload');
const loadmessage = message.loading('保存中...', 0);
const postFunction = editCouponInfo.id != 0 ? goodsAjax.goodsEdit : goodsAjax.goodsAdd;
const data = yield call(postFunction, Object.assign(editCouponInfo, {
school_id: sid,
cover: couponImg || editCouponInfo.cover,
price,
title,
inventory,
remark,
type,
status,
banner: 'banner',
}));
yield put({
type: 'updateState',
payload: {
studentSubmiting: false,
},
});
setTimeout(loadmessage);
if (data.code == 200) {
yield put({
type: 'integralModelList',
});
yield put({
type: 'updateState',
payload: {
editCouponModalShow: false,
editGoodsModalShow: false,
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data,
},
});
}
},
* integralModelGoodEdit({ payload }, { call, put, select }) {
const { record } = payload;
if (record.type == 1) {
yield put({
type: 'updateState',
payload: {
editCouponInfo: { ...record },
editGoodsModalShow: true,
},
});
} else {
yield put({
type: 'updateState',
payload: {
editCouponInfo: { ...record },
editCouponModalShow: true,
},
});
}
......@@ -48,36 +242,102 @@ export default {
* integralModelDelete({ payload }, { call, put, select }) {
const { id } = payload;
const loadmessage = message.loading('数据提交中...', 0);
const coursedelete = yield call(goodsAjax.goodsDelete, {
const goodsdelete = yield call(goodsAjax.goodsDelete, {
id: payload.id,
});
setTimeout(loadmessage);
if (coursedelete.code == 200) {
if (goodsdelete.code == 200) {
yield put({
type: 'webapp/updateState',
});
yield put({
type: 'integralModelList',
payload: {
// 1
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: coursedelete,
data: goodsdelete,
},
});
// message.error(coursedelete.msg, 1);
}
},
* integralModeljournalList({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
const { recordListTotal } = yield select(state => state.integral);
let newClassListTotal = recordListTotal;
const loadmessage = message.loading('数据加载中...', 0);
const courselistinfo = yield call(goodsAjax.journalList, {
school_id: sid,
page: 1,
perPage: 100,
});
setTimeout(loadmessage);
if (courselistinfo.code == 200) {
if (courselistinfo.data.total != undefined) {
newClassListTotal = courselistinfo.data.total;
}
yield put({
type: 'updateState',
payload: {
sid,
recordList: courselistinfo.data && courselistinfo.data.list,
recordListTotal: newClassListTotal,
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: courselistinfo,
},
});
}
},
* paginationchange({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
const { params } = payload;
yield put({
type: 'integralModeljournalList',
payload: {
school_id: sid,
page: params.page,
perPage: params.perPage,
},
});
},
* updateCouponThumb({ payload }, { call, put, select }) {
const { avatar } = payload;
yield put({
type: 'updateState',
payload: {
couponImg: avatar,
},
});
},
* pageInit({ payload }, { call, put, select }) {
yield put({
type: 'updateState',
payload: {
sid: 0,
goodslist: [],
editCourseModalShow: false,
editCouponInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
editGoodsInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
},
});
},
......
......@@ -228,6 +228,13 @@ export default {
avatar: `${filename}?x-oss-process=${cropperUrl}`,
},
});
} else if (uploadtype == 'goodsAvatorupload') {
yield put({
type: 'integral/updateCouponThumb',
payload: {
avatar: `${filename}?x-oss-process=${cropperUrl}`,
},
});
}
},
* unloadstates({ payload }, { call, put }) { // 释放该页面存储的所有状态
......
......@@ -520,6 +520,11 @@ export default {
payload: {
},
});
dispatch({
type: 'integral/integralModeljournalList',
payload: {
},
});
dispatch({
type: 'webapp/updateState',
payload: {
......
import { connect } from 'dva';
import React from 'react';
import { Icon, Button, Tabs, Select, Form } from 'antd';
import { Icon, Button, Tabs, Select, Form, InputNumber, Row, Col, Input, Radio, Modal, message } from 'antd';
import pageStyle from './index.less';
import { pageIn, hasBtnPower } from '../../utils/index';
import Integralsetting from './integralsetting/index';
import Storesetting from './storesetting/index';
import Operationlog from './operationlog/index';
const { TabPane } = Tabs;
class Integralmanage extends React.Component {
const FormItem = Form.Item;
const { Option } = Select;
const { TextArea } = Input;
class ClassMgtForm extends React.Component {
componentDidMount() { // 挂载
pageIn('轻校-积分管理');
}
......@@ -16,20 +21,77 @@ class Integralmanage extends React.Component {
componentWillUnmount() { // 卸载
}
callback=(key) => {
console.log(key);
const { dispatch } = this.props;
if (key === 3) {
dispatch({
type: 'integral/integralModeljournalList',
payload: {
},
});
}
}
integralBtn=(modalVisible) => {
const { dispatch, form } = this.props;
dispatch({
type: 'integral/integralModelStudentsList',
payload: {
},
});
dispatch({
type: 'integral/updateState',
payload: {
editScoreVisible: modalVisible,
},
});
}
handleScoreSubmit = (e) => {
const { dispatch, form, handleScoreCancel } = this.props;
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
const {
school_id,
student_ids,
number,
remark,
type,
} = values;
dispatch({
type: 'integral/integralModelScoreSave',
payload: {
school_id,
student_ids,
remark,
number: type == 0 ? number : -number,
},
});
}
});
}
integralBtn=() => {
console.log(111);
handleScoreCancel = () => {
}
render() {
const that = this;
const {
staticcenter,
form: { getFieldDecorator, getFieldValue },
courseSubmiting,
allStudentList,
editScoreVisible,
} = this.props;
const operations = <Button onClick={() => this.integralBtn()} type="primary">积分变动</Button>;
const operations = <Button onClick={() => this.integralBtn(true)} type="primary">积分变动</Button>;
const formItemModalLineLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 24 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 24 },
},
};
return (
<div className={pageStyle.container}>
<Tabs defaultActiveKey="2" onChange={this.callback} tabBarExtraContent={operations}>
<Tabs defaultActiveKey="1" onChange={this.callback} tabBarExtraContent={operations}>
<TabPane tab="积分设置" key="1">
<Integralsetting />
</TabPane>
......@@ -37,18 +99,96 @@ class Integralmanage extends React.Component {
<Storesetting />
</TabPane>
<TabPane tab="操作日志" key="3">
Content of Tab Pane 3
<Operationlog />
</TabPane>
</Tabs>
<Modal
visible={editScoreVisible}
title="积分变动"
okText="保存"
onCancel={() => this.integralBtn(false)}
onOk={this.handleScoreSubmit}
confirmLoading={courseSubmiting}
centered
width={586}
destroyOnClose
>
<Form labelAlign="left">
<FormItem {...formItemModalLineLayout} label="学员">
{getFieldDecorator('student_ids', {
rules: [
{
required: true,
message: '请选择学员',
},
],
})(
<Select placeholder="请选择学员" style={{ width: 174 }} showSearch onChange={this.handleStudentChange}>
{allStudentList.map(ele => <Option value={ele.id}>{ele.name}</Option>)}
</Select>,
)}
</FormItem>
<FormItem {...formItemModalLineLayout} label="类型">
{getFieldDecorator('type', {
initialValue: 0,
rules: [
{
required: true,
message: '请选择类型',
},
],
})(
<Radio.Group>
<Radio value={0}>增加积分</Radio>
<Radio value={-1}>减少积分</Radio>
</Radio.Group>,
)}
</FormItem>
<FormItem {...formItemModalLineLayout} label="积分值">
{getFieldDecorator('number', {
rules: [
{
required: true,
message: '请输入积分值',
},
],
})(<InputNumber />)}
</FormItem>
<FormItem {...formItemModalLineLayout} label="备注">
{getFieldDecorator('remark', {
rules: [
{
required: true,
message: '请输入备注',
},
],
})(<TextArea
autosize={{ minRows: 3, maxRows: 5 }}
placeholder="请输入"
/>)}
</FormItem>
</Form>
</Modal>
</div>
);
}
}
Integralmanage.propTypes = {
ClassMgtForm.propTypes = {
};
const ClassMgt = Form.create()(ClassMgtForm);
function mapStateToProps(state) {
const {
courseSubmiting,
editScoreVisible,
allStudentList,
} = state.integral;
return {
courseSubmiting,
editScoreVisible,
allStudentList,
};
}
export default connect(mapStateToProps)(Integralmanage);
export default connect(mapStateToProps)(ClassMgt);
......@@ -41,3 +41,12 @@
line-height:22px;
margin-left: 15px;
}
.formItem {
display: flex;
align-items: center;
margin-top: 15px;
.formflex {
display: flex;
align-items: center;
}
}
import { connect } from 'dva';
import React from 'react';
import { Form, Icon, Button, Tabs, Modal, Row, Col, Tag, Divider, Table, Pagination, message } from 'antd';
import pageStyle from './index.less';
import { hasBtnPower, imagify } from '../../../utils';
const { TabPane } = Tabs;
const FormItem = Form.Item;
class StoreMgt extends React.Component {
componentDidUpdate() {
}
componentWillUnmount() { // 卸载
}
changePagination = (page, perPage) => {
console.log(page, perPage);
const { dispatch } = this.props;
dispatch({
type: 'integral/paginationchange',
payload: {
params: {
page,
perPage,
},
},
});
}
render() {
const {
recordList,
recordListTotal,
} = this.props;
console.log(recordList);
const columns = [
{
title: '姓名',
dataIndex: 'student.name',
},
{
title: '积分操作',
dataIndex: 'change_integral',
render: (text, row) => {
if (row.type == 2) {
return <div>-{text}</div>;
}
return <div>{text}</div>;
},
},
{
title: '操作时间',
dataIndex: 'created_at',
},
{
title: '操作人',
dataIndex: 'operator.nickname',
},
];
return (
<div className={pageStyle.container}>
<div className={pageStyle.tablebox}>
<Table
dataSource={recordList}
columns={columns}
pagination={false}
footer={() => (
<div className="tablefooterbox">
<span className="tablefooterstatic">{recordListTotal}条数据</span>
<Pagination
showSizeChanger
showQuickJumper
onShowSizeChange={this.sizeChange}
total={Number(recordListTotal)}
onChange={this.changePagination}
/>
</div>
)}
/>
</div>
</div>
);
}
}
StoreMgt.propTypes = {
};
function mapStateToProps(state) {
const {
recordList,
editCouponModalShow,
classSubmitting,
recordListTotal,
} = state.integral;
return {
recordList,
editCouponModalShow,
classSubmitting,
recordListTotal,
};
}
export default connect(mapStateToProps)(StoreMgt);
.container {
background-color: #fff;
padding: 24px 0 0;
position: relative;
overflow-y: hidden;
}
.tablebox {
padding: 20px 0;
background: #fff;
}
import { connect } from 'dva';
import React from 'react';
import PropTypes from 'prop-types';
import { message, Row, Col, Input, Select, Modal, Form, InputNumber } from 'antd';
import { imagify, pageIn } from '../../../utils/index';
import pageStyle from './CouponAddModal.less';
const { Option } = Select;
const { TextArea } = Input;
const FormItem = Form.Item;
class CouponAddModal extends React.Component {
state = {
classRoomId: '',
title: '',
};
componentWillMount() {
}
componentDidUpdate() {
}
componentWillUpdate() {
}
componentDidMount() { // 挂载
pageIn('积分管理');
}
componentWillUnmount() { // 卸载
}
componentWillReceiveProps(nextProps) {
}
save = () => {
const {
form, save, editCouponInfo, couponImg,
} = this.props;
console.log(couponImg, 'couponImg');
if (editCouponInfo.id == 0 && (couponImg == '' || couponImg == undefined)) {
message.error('请上传卡券封面', 0.5);
return;
}
form.validateFields((err, values) => {
if (!err) {
console.log(values, 'values');
const {
price,
title,
cover,
inventory,
remark,
type,
status,
} = values;
save({
price,
title,
cover,
remark,
inventory,
type,
status,
});
}
});
}
close = () => {
const { form, close } = this.props;
form.resetFields();
close();
}
uploadAvator = (e) => {
const { uploadAvator } = this.props;
uploadAvator({
files: e.target,
uploadtype: 'goodsAvatorupload',
});
}
render() {
const {
visible,
isEdit,
couponImg,
uploadAvator,
editCouponInfo,
form: { getFieldDecorator, getFieldValue },
} = this.props;
console.log(this.props);
const { classRoomId, title } = this.state;
const formItemModalLineLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
};
return (
<Modal
visible={visible}
title={isEdit == 1 ? '编辑卡券' : '新增卡券'}
okText="确定"
onCancel={this.close}
onOk={this.save}
className="modifyclassModal"
maskClosable={false}
zIndex={110}
>
<Form className="modalform" labelAlign="left">
<FormItem
labelCol={{
xs: { span: 24 },
sm: { span: 24 },
}}
wrapperCol={{
xs: { span: 24 },
sm: { span: 24 },
}}
>
<div className={pageStyle.thumb}>
<img className={pageStyle.avatar} src={imagify(couponImg) ? imagify(couponImg) : imagify(editCouponInfo.cover)} alt="" />
<span className={pageStyle.uploadThumb}>
<input type="file" id="uploadinput" className={pageStyle.fileuploadinput} onChange={(e) => { this.uploadAvator(e); }} accept="image/*" />
新增图片
</span>
<div className={pageStyle.thumbTip}><span>建议尺寸:310*270 最多上传1 </span></div>
</div>
</FormItem>
{getFieldDecorator('type', { initialValue: 2 })(<Input type="hidden" />)}
{getFieldDecorator('status', { initialValue: 1 })(<Input type="hidden" />)}
<FormItem {...formItemModalLineLayout} label="卡券标题">
{getFieldDecorator('title', {
initialValue: editCouponInfo.title,
rules: [
{
required: true,
message: '请输入卡券标题',
},
],
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem {...formItemModalLineLayout} label="兑换卡券需要">
{getFieldDecorator('price', {
initialValue: editCouponInfo.price,
rules: [
{
required: true,
message: '请输入积分',
},
],
})(<InputNumber min={0} />)}
<span className="ant-form-text">积分</span>
</FormItem>
<FormItem {...formItemModalLineLayout} label="该卡券数量">
{getFieldDecorator('inventory', {
initialValue: editCouponInfo.inventory,
rules: [
{
required: true,
message: '请输入数量',
},
],
})(<InputNumber min={0} />)}
<span className="ant-form-text"> </span>
</FormItem>
<FormItem {...formItemModalLineLayout} label="其他说明">
{getFieldDecorator('remark', {
initialValue: editCouponInfo.remark,
})(<TextArea
autosize={{ minRows: 3, maxRows: 5 }}
placeholder="请输入"
/>)}
</FormItem>
</Form>
</Modal>
);
}
}
CouponAddModal.propTypes = {
isEdit: false,
};
CouponAddModal.defaultProps = {
isEdit: false,
};
const ClassMgt = Form.create()(CouponAddModal);
export default ClassMgt;
.thumb {
display: flex;
position: relative;
.thumbTip {
position: absolute;
font-size:14px;
font-family:PingFangSC;
font-weight:400;
color:rgba(0,0,0,0.85);
line-height:22px;
top: 50px;
left: 160px;
}
}
.avatar {
width: 130px;
height: 110px;
background-color: #D8D8D8;
margin-right: 30px;
}
.uploadThumb {
width: 78px;
height: 32px;
position: relative;
background-color: #1890FF;
border-radius: 4px;
text-align: center;
line-height: 32px;
color: #fff;
cursor: pointer;
}
.changeOperate {
margin-left: 10px;
}
.fileuploadinput {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 1;
opacity: 0;
}
:global {
.addstudentcontent {
.ant-form-item {
margin-bottom: 20px;
}
}
}
import { connect } from 'dva';
import React from 'react';
import PropTypes from 'prop-types';
import { message, Row, Col, Input, Select, Modal, Form, InputNumber } from 'antd';
import { imagify, pageIn } from '../../../utils/index';
import pageStyle from './GoodsAddModal.less';
const { Option } = Select;
const { TextArea } = Input;
const FormItem = Form.Item;
class GoodsAddModal extends React.Component {
state = {
};
componentWillMount() {
}
componentDidUpdate() {
}
componentWillUpdate() {
}
componentDidMount() { // 挂载
pageIn('积分管理');
}
componentWillUnmount() { // 卸载
}
componentWillReceiveProps(nextProps) {
}
save = () => {
const {
form, save, editCouponInfo, couponImg,
} = this.props;
console.log(couponImg, 'couponImg');
if (editCouponInfo.id == 0 && (couponImg == '' || couponImg == undefined)) {
message.error('请上传卡券封面', 0.5);
return;
}
form.validateFields((err, values) => {
if (!err) {
console.log(values, 'values');
const {
price,
title,
cover,
inventory,
remark,
type,
status,
} = values;
save({
price,
title,
cover,
remark,
inventory,
type,
status,
});
}
});
}
close = () => {
const { form, close } = this.props;
form.resetFields();
close();
}
uploadAvator = (e) => {
const { uploadAvator } = this.props;
uploadAvator({
files: e.target,
uploadtype: 'goodsAvatorupload',
});
}
render() {
const {
visible,
isEdit,
couponImg,
uploadAvator,
editCouponInfo,
form: { getFieldDecorator, getFieldValue },
} = this.props;
console.log(this.props);
const { classRoomId, title } = this.state;
const formItemModalLineLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
};
return (
<Modal
visible={visible}
title={isEdit == 1 ? '编辑商品' : '新增商品'}
okText="确定"
onCancel={this.close}
onOk={this.save}
className="modifyclassModal"
maskClosable={false}
zIndex={110}
>
<Form className="modalform" labelAlign="left">
<FormItem
labelCol={{
xs: { span: 24 },
sm: { span: 24 },
}}
wrapperCol={{
xs: { span: 24 },
sm: { span: 24 },
}}
>
<div className={pageStyle.thumb}>
<img className={pageStyle.avatar} src={imagify(couponImg) ? imagify(couponImg) : imagify(editCouponInfo.cover)} alt="" />
<span className={pageStyle.uploadThumb}>
<input type="file" id="uploadinput" className={pageStyle.fileuploadinput} onChange={(e) => { this.uploadAvator(e); }} accept="image/*" />
新增图片
</span>
<div className={pageStyle.thumbTip}><span>建议尺寸:310*270 最多上传1 </span></div>
</div>
</FormItem>
<FormItem
labelCol={{
xs: { span: 24 },
sm: { span: 24 },
}}
wrapperCol={{
xs: { span: 24 },
sm: { span: 24 },
}}
>
<div className={pageStyle.banner}>
<img className={pageStyle.avatar} src={imagify(couponImg) ? imagify(couponImg) : imagify(editCouponInfo.cover)} alt="" />
<span className={pageStyle.uploadThumb}>
<input type="file" id="uploadinput" className={pageStyle.fileuploadinput} onChange={(e) => { this.uploadAvator(e); }} accept="image/*" />
新增图片
</span>
<div className={pageStyle.thumbTip}><span>建议尺寸:750*310 最多上传4 </span></div>
</div>
</FormItem>
{getFieldDecorator('type', { initialValue: 1 })(<Input type="hidden" />)}
{getFieldDecorator('status', { initialValue: 1 })(<Input type="hidden" />)}
<FormItem {...formItemModalLineLayout} label="卡券标题">
{getFieldDecorator('title', {
initialValue: editCouponInfo.title,
rules: [
{
required: true,
message: '请输入卡券标题',
},
],
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem {...formItemModalLineLayout} label="兑换卡券需要">
{getFieldDecorator('price', {
initialValue: editCouponInfo.price,
rules: [
{
required: true,
message: '请输入积分',
},
],
})(<InputNumber min={0} />)}
<span className="ant-form-text">积分</span>
</FormItem>
<FormItem {...formItemModalLineLayout} label="该卡券数量">
{getFieldDecorator('inventory', {
initialValue: editCouponInfo.inventory,
rules: [
{
required: true,
message: '请输入数量',
},
],
})(<InputNumber min={0} />)}
<span className="ant-form-text"> </span>
</FormItem>
<FormItem {...formItemModalLineLayout} label="其他说明">
{getFieldDecorator('remark', {
initialValue: editCouponInfo.remark,
})(<TextArea
autosize={{ minRows: 3, maxRows: 5 }}
placeholder="请输入"
/>)}
</FormItem>
</Form>
</Modal>
);
}
}
GoodsAddModal.propTypes = {
isEdit: false,
};
GoodsAddModal.defaultProps = {
isEdit: false,
};
const ClassMgt = Form.create()(GoodsAddModal);
export default ClassMgt;
.thumb {
display: flex;
position: relative;
.thumbTip {
position: absolute;
font-size:14px;
font-family:PingFangSC;
font-weight:400;
color:rgba(0,0,0,0.85);
line-height:22px;
top: 50px;
left: 160px;
}
.avatar {
width: 130px;
height: 110px;
background-color: #D8D8D8;
margin-right: 30px;
}
}
.banner {
display: flex;
position: relative;
.thumbTip {
position: absolute;
font-size:14px;
font-family:PingFangSC;
font-weight:400;
color:rgba(0,0,0,0.85);
line-height:22px;
top: 50px;
left: 252px;
}
.avatar {
width: 223px;
height: 92px;
background-color: #D8D8D8;
margin-right: 30px;
}
}
.uploadThumb {
width: 78px;
height: 32px;
position: relative;
background-color: #1890FF;
border-radius: 4px;
text-align: center;
line-height: 32px;
color: #fff;
cursor: pointer;
}
.changeOperate {
margin-left: 10px;
}
.fileuploadinput {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 1;
opacity: 0;
}
:global {
.addstudentcontent {
.ant-form-item {
margin-bottom: 20px;
}
}
}
......@@ -3,6 +3,9 @@ import React from 'react';
import { Form, Icon, Button, Tabs, Modal, Row, Col, Tag, Divider, Table, Pagination, message } from 'antd';
import pageStyle from './index.less';
import { hasBtnPower, imagify } from '../../../utils';
import CouponAddModal from './CouponAddModal';
import GoodsAddModal from './GoodsAddModal';
import Cropper from '../../../components/Cropper';
const { TabPane } = Tabs;
const FormItem = Form.Item;
class StoreMgt extends React.Component {
......@@ -11,6 +14,29 @@ class StoreMgt extends React.Component {
this.state = {
previewVisible: false,
previewImage: '',
isEdit: 2,
avatorUploader: {
maxsize: 8192, // 奖品图片最大尺寸KBcropper: {
cropper: {
croppered_params: [], // 图片裁剪后的参数
config: {
dragMode: 'move',
viewMode: 1,
aspectRatio: 1,
autoCropArea: 0.8,
guides: !1,
center: !0,
highlight: !1,
dragCrop: !1,
cropBoxMovable: !1,
cropBoxResizable: !1,
zoom: -0.2,
checkImageOrigin: !0,
background: !1,
rotatable: !0,
},
},
},
};
}
componentDidUpdate() {
......@@ -24,7 +50,6 @@ class StoreMgt extends React.Component {
});
};
deleteItem = (item) => {
console.log(item);
const me = this;
const { dispatch } = me.props;
Modal.confirm({
......@@ -49,13 +74,140 @@ class StoreMgt extends React.Component {
},
});
};
addGoods=() => {
const { dispatch } = this.props;
this.setState({
isEdit: 2,
});
dispatch({
type: 'integral/updateState',
payload: {
editGoodsModalShow: true,
editCouponInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
},
});
}
addCoupon=() => {
const { dispatch } = this.props;
this.setState({
isEdit: 2,
});
dispatch({
type: 'integral/updateState',
payload: {
editCouponModalShow: true,
editCouponInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
},
});
}
editCoupon = (record) => {
const { dispatch } = this.props;
dispatch({
type: 'integral/integralModelGoodEdit',
payload: {
record,
},
});
}
closeCouponModal= () => {
const { dispatch } = this.props;
dispatch({
type: 'integral/updateState',
payload: {
editCouponModalShow: false,
editCouponInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
},
});
}
closeGoodsModal= () => {
const { dispatch } = this.props;
dispatch({
type: 'integral/updateState',
payload: {
editGoodsModalShow: false,
editGoodsInfo: {
id: 0,
title: '',
cover: '',
price: 0,
inventory: 0,
},
},
});
}
uploadAvator = ({ files, uploadtype }) => {
const { dispatch } = this.props;
dispatch({
type: 'uploader/queryimgsignature',
payload: {
files,
avatorUploader: this.state.avatorUploader,
uploadtype,
},
});
}
getCropperUrl = (url) => {
const { dispatch } = this.props;
dispatch({
type: 'uploader/updateState',
payload: {
cropperUrl: url,
},
});
}
cancelCropper = () => {
const { dispatch } = this.props;
dispatch({
type: 'uploader/cancelcropper',
});
}
sureCropper = () => {
const { dispatch } = this.props;
dispatch({
type: 'uploader/surecropper',
payload: {
},
});
}
save = (value) => {
const { dispatch } = this.props;
dispatch({
type: 'integral/integralModelGoodAdd',
payload: value,
});
}
render() {
const {
goodsList,
editCouponModalShow,
studentSubmiting,
cropperboxShow,
uploadImgUrl,
avatorUploader,
couponImg,
editCouponInfo,
editGoodsModalShow,
} = this.props;
const {
previewVisible, previewImage,
previewVisible, previewImage, isEdit, type,
} = this.state;
const columns = [
{
......@@ -93,8 +245,7 @@ class StoreMgt extends React.Component {
<span>
<a
href="javascript:;"
onClick={() => {
}}
onClick={() => this.editCoupon(row)}
>
编辑
</a>
......@@ -114,8 +265,8 @@ class StoreMgt extends React.Component {
return (
<div className={pageStyle.container}>
<Row>
<Col span={2}> <Button onClick={() => this.addCoupon()} type="primary"><Icon type="credit-card" />添加卡券</Button></Col>
<Col span={2}> <Button onClick={() => this.integralBtn()} type="primary"><Icon type="shopping" />添加商品</Button></Col>
<Col span={2}> <Button onClick={this.addCoupon} type="primary"><Icon type="credit-card" />添加卡券</Button></Col>
<Col span={2}> <Button onClick={() => this.addGoods()} type="primary"><Icon type="shopping" />添加商品</Button></Col>
</Row>
<div className={pageStyle.tablebox}>
<Table
......@@ -132,6 +283,33 @@ class StoreMgt extends React.Component {
>
<img alt="example" style={{ width: '100%' }} src={previewImage} />
</Modal>
<CouponAddModal
visible={editCouponModalShow}
isEdit={isEdit}
studentSubmiting={studentSubmiting}
close={this.closeCouponModal}
save={this.save}
uploadAvator={this.uploadAvator}
couponImg={couponImg}
editCouponInfo={editCouponInfo}
/>
<GoodsAddModal
visible={editGoodsModalShow}
isEdit={isEdit}
studentSubmiting={studentSubmiting}
close={this.closeGoodsModal}
save={this.save}
uploadAvator={this.uploadAvator}
couponImg={couponImg}
editCouponInfo={editCouponInfo}
/>
{cropperboxShow && <Cropper
avatorUploader={this.state.avatorUploader}
cancelCropper={this.cancelCropper}
getCropperUrl={this.getCropperUrl}
sureCropper={this.sureCropper}
uploadImgUrl={uploadImgUrl}
/>}
</div>
);
}
......@@ -139,11 +317,29 @@ class StoreMgt extends React.Component {
StoreMgt.propTypes = {
};
function mapStateToProps(state) {
const {
cropperboxShow,
uploadImgUrl,
avatorUploader,
} = state.uploader;
const {
goodsList,
editCouponModalShow,
editCouponInfo,
studentSubmiting,
couponImg,
editGoodsModalShow,
} = state.integral;
return {
goodsList,
editCouponModalShow,
studentSubmiting,
cropperboxShow,
uploadImgUrl,
avatorUploader,
couponImg,
editCouponInfo,
editGoodsModalShow,
};
}
export default connect(mapStateToProps)(StoreMgt);
......
import qs from 'qs';
import request from '../utils/request';
import api from '../common/api';
export function journalList(parmas) {
const data = qs.stringify(parmas);
return request({
url: `${api.integralsetting.journalList}?${data}`,
method: 'GET',
data,
});
}
export function goodsList(parmas) {
const data = qs.stringify(parmas);
return request({
......@@ -17,3 +25,28 @@ export function goodsDelete(params) {
data,
});
}
export function scoreSave(params) {
const data = qs.stringify(params);
return request({
url: `${api.integralsetting.scoreSave}`,
method: 'POST',
data,
});
}
export function goodsEdit(params) {
const data = qs.stringify(params);
return request({
url: `${api.integralsetting.goodsEdit}/${params.id}`,
method: 'PUT',
data,
});
}
export function goodsAdd(params) {
const data = qs.stringify(params);
return request({
url: `${api.integralsetting.goodsAdd}`,
method: 'POST',
data,
});
}
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