Commit 0205326f authored by baixian's avatar baixian

选班

parent fd34b90b
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EslintConfiguration">
<custom-configuration-file used="true" path="E:\work\biz.qingxiao.com\.eslintrc" />
</component>
</project>
\ No newline at end of file
......@@ -4,15 +4,15 @@ const basepath = `${location.protocol}//${pathify(window.location.host)}/`;
let api = '';
let dakaapi = '';
if (ENVIRONMENT == 'pro') {
// api = 'https://test.wp53.cn/v2/api/';
// dakaapi = 'https:clock.wp53.cn/v3/';
api = 'https://wx.m.shangjiadao.cn/v2/api/';
dakaapi = 'https://qxapi.qingxiao.online/daka/v3/';
api = 'https://test.wp53.cn/v2/api/';
dakaapi = 'https:clock.wp53.cn/v3/';
// api = 'https://wx.m.shangjiadao.cn/v2/api/';
// dakaapi = 'https://qxapi.qingxiao.online/daka/v3/';
} else if (ENVIRONMENT == 'dev') {
api = 'https://wx.m.shangjiadao.cn/v2/api/';
dakaapi = 'https://qxapi.qingxiao.online/daka/v3/';
// api = 'https://test.wp53.cn/v2/api/';
// dakaapi = 'https:clock.wp53.cn/v3/';
// api = 'https://wx.m.shangjiadao.cn/v2/api/';
// dakaapi = 'https://qxapi.qingxiao.online/daka/v3/';
api = 'https://test.wp53.cn/v2/api/';
dakaapi = 'https:clock.wp53.cn/v3/';
} else if (ENVIRONMENT == 'testenv') {
api = 'https://test.wp53.cn/v2/api/';
dakaapi = 'https:clock.wp53.cn/v3/';
......@@ -75,6 +75,7 @@ export default {
studentsUnBindWx: `${dakaapi}member/erp/student/wechat/remove`,
},
teachers: `${dakaapi}member/erp/teachers`,
choose_teacher: `${dakaapi}member/erp/teacher/distribution`,
courses: {
courses: `${dakaapi}member/erp/courses`,
coursesBuyOrRenew: `${dakaapi}member/erp/course/make`,
......
......@@ -8,6 +8,9 @@ import {
} from '../utils/index';
import errorcode from '../common/errorcode';
import * as teachersAjax from '../services/teachers';
import * as courseAjax from '../services/course';
import classmgt from './classmgt';
import * as classMgtAjax from '../services/classmgt';
export default {
namespace: 'teachers',
state: {
......@@ -50,6 +53,10 @@ export default {
invitationTeacherList: [],
invitationTeacherTotal: 0,
invitationShow: false,
chooseClassVisible: false,
coursesList: [],
teacher_id: 0, // 老师id
allClassList: [],
},
subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line
......@@ -328,6 +335,82 @@ export default {
// message.error(teacherstatus.msg, 1);
}
},
* checkClass({ payload }, { call, put, select }) {
const { courseId } = payload;
const { teacher_id } = yield select(state => state.teachers);
const { sid } = yield select(state => state.webapp);
const classInfo = yield call(classMgtAjax.getClassList, {
school_id: sid,
page: 1,
perPage: 100,
extra: 'teacher.course',
course_id: courseId,
check_in_class_teacher_id: teacher_id,
});
if (classInfo.code == 200) {
yield put({
type: 'updateState',
payload: {
sid,
allClassList: classInfo.data && classInfo.data.list,
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: classInfo,
},
});
}
},
* saveChooseClass({ payload }, { call, put, select }) {
const { value } = payload;
const { class_ids, callBack } = value;
const { teacher_id, submitting } = yield select(state => state.teachers);
const { sid } = yield select(state => state.webapp);
if (submitting) {
return;
}
yield put({
type: 'updateState',
payload: {
submitting: true,
},
});
const loadmessage = message.loading('数据保存中...', 0);
const res = yield call(teachersAjax.teachersChoose, {
class_ids: JSON.stringify(class_ids),
teacher_id,
});
yield put({
type: 'updateState',
payload: {
submitting: false,
},
});
setTimeout(loadmessage);
if (res.code === 200) {
yield put({
type: 'updateState',
payload: {
chooseClassVisible: false,
teacher_id: 0,
allClassList: [],
},
});
if (callBack && (typeof callBack == 'function')) {
callBack();
}
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data: res,
},
});
}
},
* pageInit({ payload }, { call, put, select }) {
yield put({
type: 'updateState',
......@@ -371,6 +454,13 @@ export default {
invitationTeacherList: [],
invitationTeacherTotal: 0,
invitationShow: false,
chooseClassVisible: false,
coursesList: [],
teacher_id: 0,
allClassList: [],
courseList: [],
classIdList: [],
courseId: '',
},
});
},
......
import { connect } from 'dva';
import React from 'react';
import { Icon, Button, Row, Col, Input, Select, Checkbox, Table, Modal, Form, Alert, message } from 'antd';
import pageStyle from './ChooseClassModal.less';
import { pageIn } from '../../utils/index';
const { Option } = Select;
const { TextArea } = Input;
const FormItem = Form.Item;
const CheckboxGroup = Checkbox.Group;
class ChooseClassModal extends React.Component {
componentDidMount() { // 挂载
pageIn('班级管理');
}
componentWillUnmount() { // 卸载
}
save = () => {
const {
form, save,
} = this.props;
form.validateFields((err, values) => {
if (!err) {
const {
class_ids,
} = values;
console.log(class_ids, 'class_ids12222222222222');
save({
class_ids,
callBack: () => {
form.resetFields();
},
});
}
});
}
close = () => {
const { form, close } = this.props;
form.resetFields();
close();
}
render() {
const {
visible,
submitting,
courseList,
selectChange,
classList,
handleCheckClass,
form: { getFieldDecorator, getFieldValue },
} = this.props;
const formItemModalLineLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
};
return (
<Modal
visible={visible}
title="选班"
okText={submitting ? '保存中...' : '保存'}
onCancel={this.close}
onOk={this.save}
width={570}
heigh={432}
confirmLoading={submitting}
>
<Form labelAlign="left">
<FormItem {...formItemModalLineLayout} label="课程">
{getFieldDecorator('course_id', {
rules: [
{
required: true,
message: '请选择课程',
},
],
})(
<Select className={pageStyle.selectitem} placeholder="请选择课程" onChange={e => selectChange(e)}>
<Option value="">全部课程</Option>
{courseList.map(ele => <Option value={ele.id}>{ele.title}</Option>)}
</Select>,
)}
</FormItem>
{courseList.length > 0 &&
<div className={pageStyle.checkwrap}>
<FormItem {...formItemModalLineLayout}>
{getFieldDecorator('class_ids', {
rules: [
{
required: true,
message: '请选择班级',
},
],
})(
<CheckboxGroup
onChange={e => handleCheckClass(e)}
>
{ classList.map((item, index) =>
<div className={pageStyle.listwrap}> <Checkbox checked={item.teacher_in_class} value={item.id}>{item.title}</Checkbox></div>,
)}
</CheckboxGroup>,
)}
</FormItem>
</div> }
</Form>
</Modal>
);
}
}
ChooseClassModal.propTypes = {
};
const ChooseClass = Form.create()(ChooseClassModal);
export default ChooseClass;
.checkwrap {
:global {
.ant-form-item-control-wrapper {
width: 100%;
max-height: 300px;
overflow-y: scroll;
}
.ant-checkbox-group {
width: 100%;
display: flex;
align-items: center;
flex-wrap: wrap;
}
}
}
.listwrap {
width: 50%;
margin-bottom: 10px;
}
import { connect } from 'dva';
import React from 'react';
import { Icon, Button, Row, Col, Input, Select, Modal, InputNumber, Radio, Table, Form, Pagination } from 'antd';
import { Icon, Button, Row, Col, Input, Select, Modal, InputNumber, Radio, Table, Form, Pagination, message } from 'antd';
import pageStyle from './index.less';
import EditTeacher from './EditTeacher';
import ChooseClass from './ChooseClassModal';
import { pageIn, hasBtnPower } from '../../utils/index';
import CouponAddModal from '../integralmanage/storesetting/CouponAddModal';
const { Option } = Select;
const { TextArea } = Input;
......@@ -174,6 +176,68 @@ class ClassMgt extends React.Component {
},
});
}
handleChooseClass = (record) => {
const { dispatch } = this.props;
dispatch({
type: 'teachers/updateState',
payload: {
chooseClassVisible: true,
teacher_id: record.id,
},
});
dispatch({
type: 'teachers/courseModelList',
payload: {
},
});
}
closeChooseClass = () => {
const { dispatch } = this.props;
dispatch({
type: 'teachers/updateState',
payload: {
chooseClassVisible: false,
teacher_id: 0,
allClassList: [],
courseListModal: [],
classIdList: [],
courseId: 0,
},
});
}
selectChangeCourse = (e) => {
const { dispatch } = this.props;
dispatch({
type: 'teachers/checkClass',
payload: {
chooseClassVisible: false,
courseId: e,
},
});
}
handleCheckClass = (e) => {
const { dispatch } = this.props;
console.log(e, 'eeeeeeeeeee');
dispatch({
type: 'teachers/updateState',
payload: {
classIdList: e,
},
});
}
saveChooseClass = (value) => {
const { dispatch } = this.props;
// if (classIdList.length === 0) {
// message.error('请先选择班级', 1);
// return;
// }
dispatch({
type: 'teachers/saveChooseClass',
payload: {
value,
},
});
}
render() {
const {
teachersinfo,
......@@ -188,6 +252,9 @@ class ClassMgt extends React.Component {
invitationTeacherTotal,
queryTeacherInvitationParams,
invitationShow,
chooseClassVisible,
allClassList,
submitting,
} = this.props;
const { getFieldDecorator } = this.props.form;
const columns = [
......@@ -268,6 +335,18 @@ class ClassMgt extends React.Component {
);
},
},
{
title: '启动状态',
dataIndex: 'status',
key: 'status',
render: (text, record) => {
return (
<div>
<a href="javascript:;" onClick={() => this.handleChooseClass(record)} >选班</a>
</div>
);
},
},
];
return (
<div className={pageStyle.container}>
......@@ -347,6 +426,16 @@ class ClassMgt extends React.Component {
editTeacherInfo={editTeacherInfo}
editType="add"
/>
<ChooseClass
visible={chooseClassVisible}
close={this.closeChooseClass}
save={this.saveChooseClass}
courseList={courseList}
selectChange={this.selectChangeCourse}
classList={allClassList}
submitting={submitting}
handleCheckClass={this.handleCheckClass}
/>
<Modal
visible={invitationShow}
title={<span style={{ fontSize: '16px', fontWeight: 700 }}>老师加入通知</span>}
......@@ -407,6 +496,10 @@ function mapStateToProps(state) {
queryTeacherInvitationParams,
invitationTeacherTotal,
invitationShow,
chooseClassVisible,
teacher_id,
allClassList,
submitting,
} = state.teachers;
const {
courseList,
......@@ -424,6 +517,10 @@ function mapStateToProps(state) {
queryTeacherInvitationParams,
invitationTeacherTotal,
invitationShow,
chooseClassVisible,
teacher_id,
allClassList,
submitting,
};
}
export default connect(mapStateToProps)(ForgotPassword);
......
......@@ -16,6 +16,15 @@ export function teachersAdd(params) {
data,
});
}
export function teachersChoose(params) {
const data = qs.stringify(params);
return request({
url: `${api.choose_teacher}`,
method: 'POST',
data,
});
}
export function teachersPut(params) {
const data = qs.stringify(params);
return request({
......
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