|
@@ -4,50 +4,52 @@ import { provinceSelect, provinceList, getProvince } from '../../../NewDicProvin
|
|
import { companySearch } from '../../../tools.js';
|
|
import { companySearch } from '../../../tools.js';
|
|
import ajax from 'jquery/src/ajax/xhr.js';
|
|
import ajax from 'jquery/src/ajax/xhr.js';
|
|
import $ from 'jquery/src/ajax';
|
|
import $ from 'jquery/src/ajax';
|
|
|
|
+import {customerStatus} from '../../../dataDic.js'
|
|
|
|
|
|
const ProvinceAdd = React.createClass({
|
|
const ProvinceAdd = React.createClass({
|
|
- getInitialState() {
|
|
|
|
- return {
|
|
|
|
- cityOption: [],
|
|
|
|
- theProvince: [],
|
|
|
|
- citys: []
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- componentWillMount() {
|
|
|
|
- let theArr = [];
|
|
|
|
- this.state.theProvince = [this.props.locations[this.props.index].province];
|
|
|
|
- this.state.citys = this.props.locations[this.props.index].city || [];
|
|
|
|
- this.props.provinceList.map((item) => {
|
|
|
|
- if (item.id == this.props.locations[this.props.index].province) {
|
|
|
|
- item.cityList.map((city) => {
|
|
|
|
- theArr.push({
|
|
|
|
- value: city.id,
|
|
|
|
- label: city.name
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
- this.state.cityOption = theArr;
|
|
|
|
- },
|
|
|
|
- componentWillReceiveProps(nextProps) {
|
|
|
|
- let theArr = [];
|
|
|
|
- this.state.theProvince = [nextProps.locations[nextProps.index].province];
|
|
|
|
- this.state.citys = nextProps.locations[nextProps.index].city || [];
|
|
|
|
- this.props.provinceList.map((item) => {
|
|
|
|
- if (item.id == nextProps.locations[nextProps.index].province) {
|
|
|
|
- item.cityList.map((city) => {
|
|
|
|
- theArr.push({
|
|
|
|
- value: city.id,
|
|
|
|
- label: city.name
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
- this.state.cityOption = theArr;
|
|
|
|
- },
|
|
|
|
- render() {
|
|
|
|
- return (
|
|
|
|
- <div style={{ display: 'inline-block', marginRight: '20px', marginBottom: '10px' }}>
|
|
|
|
|
|
+ getInitialState() {
|
|
|
|
+ return {
|
|
|
|
+ cityOption: [],
|
|
|
|
+ theProvince: [],
|
|
|
|
+ citys: [],
|
|
|
|
+ departmentArr:[]
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ componentWillMount() {
|
|
|
|
+ let theArr = [];
|
|
|
|
+ this.state.theProvince = [this.props.locations[this.props.index].province];
|
|
|
|
+ this.state.citys = this.props.locations[this.props.index].city || [];
|
|
|
|
+ this.props.provinceList.map((item) => {
|
|
|
|
+ if(item.id == this.props.locations[this.props.index].province) {
|
|
|
|
+ item.cityList.map((city) => {
|
|
|
|
+ theArr.push({
|
|
|
|
+ value: city.id,
|
|
|
|
+ label: city.name
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ this.state.cityOption = theArr;
|
|
|
|
+ },
|
|
|
|
+ componentWillReceiveProps(nextProps) {
|
|
|
|
+ let theArr = [];
|
|
|
|
+ this.state.theProvince = [nextProps.locations[nextProps.index].province];
|
|
|
|
+ this.state.citys = nextProps.locations[nextProps.index].city || [];
|
|
|
|
+ this.props.provinceList.map((item) => {
|
|
|
|
+ if(item.id == nextProps.locations[nextProps.index].province) {
|
|
|
|
+ item.cityList.map((city) => {
|
|
|
|
+ theArr.push({
|
|
|
|
+ value: city.id,
|
|
|
|
+ label: city.name
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ this.state.cityOption = theArr;
|
|
|
|
+ },
|
|
|
|
+ render() {
|
|
|
|
+ return(
|
|
|
|
+ <div style={{ display: 'inline-block', marginRight: '20px', marginBottom: '10px' }}>
|
|
<Cascader placeholder="选择省份"
|
|
<Cascader placeholder="选择省份"
|
|
style={{ width: 80, marginRight: '20px', verticalAlign: 'middle' }}
|
|
style={{ width: 80, marginRight: '20px', verticalAlign: 'middle' }}
|
|
options={this.props.provinceOption}
|
|
options={this.props.provinceOption}
|
|
@@ -105,270 +107,284 @@ const ProvinceAdd = React.createClass({
|
|
<Icon type="minus" />
|
|
<Icon type="minus" />
|
|
</Button>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
- );
|
|
|
|
- },
|
|
|
|
|
|
+ );
|
|
|
|
+ },
|
|
})
|
|
})
|
|
|
|
|
|
const TheModal = React.createClass({
|
|
const TheModal = React.createClass({
|
|
- postData() {
|
|
|
|
- this.setState({
|
|
|
|
- loading: true
|
|
|
|
- });
|
|
|
|
- let theArr = [];
|
|
|
|
- let theLocations = this.state.locations.concat();
|
|
|
|
- theLocations.map((item, i) => {
|
|
|
|
- if (item.province) {
|
|
|
|
- theArr.push(item);
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
- theArr.map((item) => {
|
|
|
|
- if (item.city && item.city.length) {
|
|
|
|
- item.city = item.city.join(',');
|
|
|
|
- } else {
|
|
|
|
- item.city = null;
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
- $.ajax({
|
|
|
|
- type: "POST",
|
|
|
|
- url: this.state.id ? globalConfig.context + "/api/admin/supervise/updateAdmin" : globalConfig.context + "/api/admin/supervise/insertAdmin",
|
|
|
|
- data: {
|
|
|
|
- data: JSON.stringify({
|
|
|
|
- 'id': this.state.id,
|
|
|
|
- 'name': this.state.name,
|
|
|
|
- 'email': this.state.email,
|
|
|
|
- 'mobile': this.state.mobile,
|
|
|
|
- 'position': this.state.position,
|
|
|
|
- 'locations': theArr,
|
|
|
|
- 'superiorId': this.state.superiorId
|
|
|
|
- }),
|
|
|
|
- 'roles': this.state.bindroles
|
|
|
|
- }
|
|
|
|
- }).done((res) => {
|
|
|
|
- if (res.error.length) {
|
|
|
|
- message.error(res.error[0].message);
|
|
|
|
- } else {
|
|
|
|
- message.success("保存成功");
|
|
|
|
- this.setState({
|
|
|
|
- visible: false,
|
|
|
|
- });
|
|
|
|
- this.props.handleReturn(false, true);
|
|
|
|
- //第二个参数表示保存
|
|
|
|
- }
|
|
|
|
- }).always(() => {
|
|
|
|
- this.setState({
|
|
|
|
- loading: false
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- this.props.postData;
|
|
|
|
- },
|
|
|
|
- getInitialState() {
|
|
|
|
- return {
|
|
|
|
- name: '',
|
|
|
|
- email: '',
|
|
|
|
- mobile: '',
|
|
|
|
- roles: [],
|
|
|
|
- visible: false,
|
|
|
|
- loading: false,
|
|
|
|
- theSwitch: true,
|
|
|
|
- bindroles: [],
|
|
|
|
- locations: [],
|
|
|
|
- cityOption: [],
|
|
|
|
- locationsObj: {},
|
|
|
|
- adminSelectObj: {}
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- handleCancel() {
|
|
|
|
- this.setState({
|
|
|
|
- visible: false,
|
|
|
|
- locations:[]
|
|
|
|
- });
|
|
|
|
- this.props.handleReturn(false, false);
|
|
|
|
- },
|
|
|
|
- loadAdminSelectList() {
|
|
|
|
- this.setState({
|
|
|
|
- loading: true
|
|
|
|
- });
|
|
|
|
- $.ajax({
|
|
|
|
- url: globalConfig.context + '/api/admin/supervise/adminSelectList',
|
|
|
|
- cache: false
|
|
|
|
- }).done((data) => {
|
|
|
|
- if (!data.data) {
|
|
|
|
- if (data.error && data.error.length) {
|
|
|
|
- message.warning(data.error[0].message);
|
|
|
|
- return;
|
|
|
|
- };
|
|
|
|
- };
|
|
|
|
- let theArr = [], i;
|
|
|
|
- for (i in data.data) {
|
|
|
|
- theArr.push(
|
|
|
|
- <Select.Option key={i}>{data.data[i]}</Select.Option>
|
|
|
|
- )
|
|
|
|
- };
|
|
|
|
- this.setState({
|
|
|
|
- adminSelectOption: theArr,
|
|
|
|
- adminSelectObj: data.data,
|
|
|
|
- loading: false
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- loadAdminOwnLocation() {
|
|
|
|
- this.setState({
|
|
|
|
- loading: true
|
|
|
|
- });
|
|
|
|
- $.ajax({
|
|
|
|
- url: globalConfig.context + '/api/admin/supervise/adminOwnLocation',
|
|
|
|
- cache: false
|
|
|
|
- }).done((data) => {
|
|
|
|
- if (!data.data) {
|
|
|
|
- if (data.error && data.error.length) {
|
|
|
|
- message.warning(data.error[0].message);
|
|
|
|
- return;
|
|
|
|
- };
|
|
|
|
- };
|
|
|
|
- let theArr = [], theList = [];
|
|
|
|
- if ((typeof (data.data)).indexOf('string') == -1) {
|
|
|
|
- data.data.map((item) => {
|
|
|
|
- theArr.push({
|
|
|
|
- value: item.province,
|
|
|
|
- label: getProvince(item.province)
|
|
|
|
- });
|
|
|
|
- let cityList = [];
|
|
|
|
- if (item.city) {
|
|
|
|
- item.city.split(',').map((c) => {
|
|
|
|
- cityList.push({
|
|
|
|
- id: Number(c),
|
|
|
|
- name: getProvince(c)
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- };
|
|
|
|
- theList.push({
|
|
|
|
- id: item.province,
|
|
|
|
- name: getProvince(item.province),
|
|
|
|
- cityList: cityList.length ? cityList : null
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- theArr = provinceSelect();
|
|
|
|
- theList = provinceList;
|
|
|
|
- }
|
|
|
|
- this.setState({
|
|
|
|
- provinceOption: theArr,
|
|
|
|
- provinceList: theList,
|
|
|
|
- loading: false
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- loadBindRoles(uid) {
|
|
|
|
- this.setState({
|
|
|
|
- loading: true
|
|
|
|
- });
|
|
|
|
- $.ajax({
|
|
|
|
- url: globalConfig.context + '/api/admin/role',
|
|
|
|
- cache: false,
|
|
|
|
- data: {
|
|
|
|
- "uid": uid
|
|
|
|
- }
|
|
|
|
- }).done((data) => {
|
|
|
|
- if (!data.data) {
|
|
|
|
- if (data.error && data.error.length) {
|
|
|
|
- message.warning(data.error[0].message);
|
|
|
|
- };
|
|
|
|
- return;
|
|
|
|
- } else if (data.data) {
|
|
|
|
- this.state.theSwitch = true;
|
|
|
|
- for (let i = 0; i < data.data.length; i++) {
|
|
|
|
- for (let n = 0; n < this.props.currentRoles.length; n++) {
|
|
|
|
- if (data.data[i] === this.props.currentRoles[n] && uid != 1) {
|
|
|
|
- this.state.theSwitch = false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- };
|
|
|
|
- this.setState({
|
|
|
|
- bindroles: data.data || [],
|
|
|
|
- theSwitch: this.state.theSwitch,
|
|
|
|
- loading: false
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- loadLocations(id) {
|
|
|
|
- this.setState({
|
|
|
|
- loading: true
|
|
|
|
- });
|
|
|
|
- $.ajax({
|
|
|
|
- url: globalConfig.context + '/api/admin/supervise/adminDetailLocation',
|
|
|
|
- cache: false,
|
|
|
|
- data: {
|
|
|
|
- "id": id
|
|
|
|
- }
|
|
|
|
- }).done((data) => {
|
|
|
|
- if (!data.data) {
|
|
|
|
- if (data.error && data.error.length) {
|
|
|
|
- message.warning(data.error[0].message);
|
|
|
|
- return;
|
|
|
|
- };
|
|
|
|
- };
|
|
|
|
- data.data.map((item) => {
|
|
|
|
- if (item.city) {
|
|
|
|
- item.city = item.city.split(',');
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- this.setState({
|
|
|
|
- locations: data.data,
|
|
|
|
- loading: false
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- componentWillMount() {
|
|
|
|
- this.loadAdminSelectList();
|
|
|
|
- this.loadAdminOwnLocation();
|
|
|
|
- },
|
|
|
|
- componentWillReceiveProps(nextProps) {
|
|
|
|
- if (!this.state.visible && nextProps.show) {
|
|
|
|
- if (nextProps.data.id) {
|
|
|
|
- this.loadBindRoles(nextProps.data.id);
|
|
|
|
- this.loadLocations(nextProps.data.id);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- let nextState = {
|
|
|
|
- visible: nextProps.show,
|
|
|
|
- id: nextProps.data ? nextProps.data.id : '',
|
|
|
|
- name: nextProps.data ? nextProps.data.name : '',
|
|
|
|
- email: nextProps.data ? nextProps.data.email : '',
|
|
|
|
- mobile: nextProps.data ? nextProps.data.mobile : '',
|
|
|
|
- position: nextProps.data ? nextProps.data.position : '',
|
|
|
|
- superiorId: nextProps.data ? nextProps.data.superiorId : '',
|
|
|
|
- };
|
|
|
|
- this.setState(nextState)
|
|
|
|
- },
|
|
|
|
- resetPwd(e) {
|
|
|
|
- this.setState({
|
|
|
|
- loading: true
|
|
|
|
- })
|
|
|
|
- $.ajax({
|
|
|
|
- type: 'post',
|
|
|
|
- url: globalConfig.context + "/api/admin/supervise/resetPwd",
|
|
|
|
- dataType: "json",
|
|
|
|
- data: {
|
|
|
|
- id: this.state.id
|
|
|
|
- }
|
|
|
|
- }).done((res) => {
|
|
|
|
- if (res.error && res.error.length) {
|
|
|
|
- message.error(res.error[0].message);
|
|
|
|
- } else {
|
|
|
|
- message.success("密码重置成功");
|
|
|
|
- }
|
|
|
|
- }).always(() => {
|
|
|
|
- this.setState({
|
|
|
|
- loading: false
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- getRolesSelection() {
|
|
|
|
- if (!this.state.id) {
|
|
|
|
- return <li></li>
|
|
|
|
- } else if (this.state.id != '1') {
|
|
|
|
- return <li className="list">
|
|
|
|
|
|
+ postData() {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: true
|
|
|
|
+ });
|
|
|
|
+ let theArr = [];
|
|
|
|
+ let theLocations = this.state.locations.concat();
|
|
|
|
+ theLocations.map((item, i) => {
|
|
|
|
+ if(item.province) {
|
|
|
|
+ theArr.push(item);
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ theArr.map((item) => {
|
|
|
|
+ if(item.city && item.city.length) {
|
|
|
|
+ item.city = item.city.join(',');
|
|
|
|
+ } else {
|
|
|
|
+ item.city = null;
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ let departmentIds='';
|
|
|
|
+ if(!this.state.department){
|
|
|
|
+ departmentIds=''
|
|
|
|
+ }else if((this.state.department).length>30){
|
|
|
|
+ departmentIds=this.state.department
|
|
|
|
+ }else{
|
|
|
|
+ departmentIds=this.state.departmentId
|
|
|
|
+ }
|
|
|
|
+ $.ajax({
|
|
|
|
+ type: "POST",
|
|
|
|
+ url: this.state.id ? globalConfig.context + "/api/admin/supervise/updateAdmin" : globalConfig.context + "/api/admin/supervise/insertAdmin",
|
|
|
|
+ data: {
|
|
|
|
+ data: JSON.stringify({
|
|
|
|
+ 'id': this.state.id,
|
|
|
|
+ 'name': this.state.name,
|
|
|
|
+ 'email': this.state.email,
|
|
|
|
+ 'mobile': this.state.mobile,
|
|
|
|
+ 'position': this.state.position,
|
|
|
|
+ 'locations': theArr,
|
|
|
|
+ 'departmentId':departmentIds,
|
|
|
|
+ 'superiorId': this.state.superiorId
|
|
|
|
+ }),
|
|
|
|
+ 'roles': this.state.bindroles
|
|
|
|
+ }
|
|
|
|
+ }).done((res) => {
|
|
|
|
+ if(res.error.length) {
|
|
|
|
+ message.error(res.error[0].message);
|
|
|
|
+ } else {
|
|
|
|
+ message.success("保存成功");
|
|
|
|
+ this.setState({
|
|
|
|
+ visible: false,
|
|
|
|
+ });
|
|
|
|
+ this.props.handleReturn(false, true);
|
|
|
|
+ //第二个参数表示保存
|
|
|
|
+ }
|
|
|
|
+ }).always(() => {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: false
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ this.props.postData;
|
|
|
|
+ },
|
|
|
|
+ getInitialState() {
|
|
|
|
+ return {
|
|
|
|
+ name: '',
|
|
|
|
+ email: '',
|
|
|
|
+ mobile: '',
|
|
|
|
+ roles: [],
|
|
|
|
+ visible: false,
|
|
|
|
+ loading: false,
|
|
|
|
+ theSwitch: true,
|
|
|
|
+ bindroles: [],
|
|
|
|
+ locations: [],
|
|
|
|
+ cityOption: [],
|
|
|
|
+ locationsObj: {},
|
|
|
|
+ adminSelectObj: {}
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ handleCancel() {
|
|
|
|
+ this.setState({
|
|
|
|
+ visible: false,
|
|
|
|
+ locations: []
|
|
|
|
+ });
|
|
|
|
+ this.props.handleReturn(false, false);
|
|
|
|
+ },
|
|
|
|
+ loadAdminSelectList() {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: true
|
|
|
|
+ });
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: globalConfig.context + '/api/admin/supervise/adminSelectList',
|
|
|
|
+ cache: false
|
|
|
|
+ }).done((data) => {
|
|
|
|
+ if(!data.data) {
|
|
|
|
+ if(data.error && data.error.length) {
|
|
|
|
+ message.warning(data.error[0].message);
|
|
|
|
+ return;
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ let theArr = [],
|
|
|
|
+ i;
|
|
|
|
+ for(i in data.data) {
|
|
|
|
+ theArr.push(
|
|
|
|
+ <Select.Option key={i}>{data.data[i]}</Select.Option>
|
|
|
|
+ )
|
|
|
|
+ };
|
|
|
|
+ this.setState({
|
|
|
|
+ adminSelectOption: theArr,
|
|
|
|
+ adminSelectObj: data.data,
|
|
|
|
+ loading: false
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ loadAdminOwnLocation() {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: true
|
|
|
|
+ });
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: globalConfig.context + '/api/admin/supervise/adminOwnLocation',
|
|
|
|
+ cache: false
|
|
|
|
+ }).done((data) => {
|
|
|
|
+ if(!data.data) {
|
|
|
|
+ if(data.error && data.error.length) {
|
|
|
|
+ message.warning(data.error[0].message);
|
|
|
|
+ return;
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ let theArr = [],
|
|
|
|
+ theList = [];
|
|
|
|
+ if((typeof(data.data)).indexOf('string') == -1) {
|
|
|
|
+ data.data.map((item) => {
|
|
|
|
+ theArr.push({
|
|
|
|
+ value: item.province,
|
|
|
|
+ label: getProvince(item.province)
|
|
|
|
+ });
|
|
|
|
+ let cityList = [];
|
|
|
|
+ if(item.city) {
|
|
|
|
+ item.city.split(',').map((c) => {
|
|
|
|
+ cityList.push({
|
|
|
|
+ id: Number(c),
|
|
|
|
+ name: getProvince(c)
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ theList.push({
|
|
|
|
+ id: item.province,
|
|
|
|
+ name: getProvince(item.province),
|
|
|
|
+ cityList: cityList.length ? cityList : null
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ theArr = provinceSelect();
|
|
|
|
+ theList = provinceList;
|
|
|
|
+ }
|
|
|
|
+ this.setState({
|
|
|
|
+ provinceOption: theArr,
|
|
|
|
+ provinceList: theList,
|
|
|
|
+ loading: false
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ loadBindRoles(uid) {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: true
|
|
|
|
+ });
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: globalConfig.context + '/api/admin/role',
|
|
|
|
+ cache: false,
|
|
|
|
+ data: {
|
|
|
|
+ "uid": uid
|
|
|
|
+ }
|
|
|
|
+ }).done((data) => {
|
|
|
|
+ if(!data.data) {
|
|
|
|
+ if(data.error && data.error.length) {
|
|
|
|
+ message.warning(data.error[0].message);
|
|
|
|
+ };
|
|
|
|
+ return;
|
|
|
|
+ } else if(data.data) {
|
|
|
|
+ this.state.theSwitch = true;
|
|
|
|
+ for(let i = 0; i < data.data.length; i++) {
|
|
|
|
+ for(let n = 0; n < this.props.currentRoles.length; n++) {
|
|
|
|
+ if(data.data[i] === this.props.currentRoles[n] && uid != 1) {
|
|
|
|
+ this.state.theSwitch = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ this.setState({
|
|
|
|
+ bindroles: data.data || [],
|
|
|
|
+ theSwitch: this.state.theSwitch,
|
|
|
|
+ loading: false
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ loadLocations(id) {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: true
|
|
|
|
+ });
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: globalConfig.context + '/api/admin/supervise/adminDetailLocation',
|
|
|
|
+ cache: false,
|
|
|
|
+ data: {
|
|
|
|
+ "id": id
|
|
|
|
+ }
|
|
|
|
+ }).done((data) => {
|
|
|
|
+ if(!data.data) {
|
|
|
|
+ if(data.error && data.error.length) {
|
|
|
|
+ message.warning(data.error[0].message);
|
|
|
|
+ return;
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ data.data.map((item) => {
|
|
|
|
+ if(item.city) {
|
|
|
|
+ item.city = item.city.split(',');
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.setState({
|
|
|
|
+ locations: data.data,
|
|
|
|
+ loading: false
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ componentWillMount() {
|
|
|
|
+ this.loadAdminSelectList();
|
|
|
|
+ this.loadAdminOwnLocation();
|
|
|
|
+ },
|
|
|
|
+ componentWillReceiveProps(nextProps) {
|
|
|
|
+ if(!this.state.visible && nextProps.show) {
|
|
|
|
+ if(nextProps.data.id) {
|
|
|
|
+ this.loadBindRoles(nextProps.data.id);
|
|
|
|
+ this.loadLocations(nextProps.data.id);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ let nextState = {
|
|
|
|
+ visible: nextProps.show,
|
|
|
|
+ id: nextProps.data ? nextProps.data.id : '',
|
|
|
|
+ name: nextProps.data ? nextProps.data.name : '',
|
|
|
|
+ email: nextProps.data ? nextProps.data.email : '',
|
|
|
|
+ mobile: nextProps.data ? nextProps.data.mobile : '',
|
|
|
|
+ position: nextProps.data ? nextProps.data.position : '',
|
|
|
|
+ department: nextProps.data ? nextProps.data.departmentName : '',
|
|
|
|
+ departmentId:nextProps.data ? nextProps.data.departmentId : '',
|
|
|
|
+ superiorId: nextProps.data ? nextProps.data.superiorId : '',
|
|
|
|
+ };
|
|
|
|
+ this.setState(nextState)
|
|
|
|
+ },
|
|
|
|
+ resetPwd(e) {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: true
|
|
|
|
+ })
|
|
|
|
+ $.ajax({
|
|
|
|
+ type: 'post',
|
|
|
|
+ url: globalConfig.context + "/api/admin/supervise/resetPwd",
|
|
|
|
+ dataType: "json",
|
|
|
|
+ data: {
|
|
|
|
+ id: this.state.id
|
|
|
|
+ }
|
|
|
|
+ }).done((res) => {
|
|
|
|
+ if(res.error && res.error.length) {
|
|
|
|
+ message.error(res.error[0].message);
|
|
|
|
+ } else {
|
|
|
|
+ message.success("密码重置成功");
|
|
|
|
+ }
|
|
|
|
+ }).always(() => {
|
|
|
|
+ this.setState({
|
|
|
|
+ loading: false
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ getRolesSelection() {
|
|
|
|
+ if(!this.state.id) {
|
|
|
|
+ return <li></li>
|
|
|
|
+ } else if(this.state.id != '1') {
|
|
|
|
+ return <li className="list">
|
|
<span className='modal-text'>角色</span>
|
|
<span className='modal-text'>角色</span>
|
|
<Select
|
|
<Select
|
|
multiple
|
|
multiple
|
|
@@ -379,44 +395,45 @@ const TheModal = React.createClass({
|
|
{this.getRolesOptions()}
|
|
{this.getRolesOptions()}
|
|
</Select>
|
|
</Select>
|
|
</li>
|
|
</li>
|
|
- } else if (this.state.id == "1") {
|
|
|
|
- return <li><span className='modal-text'>角色</span><span>系统管理员</span></li>
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- bindRoles(val) {
|
|
|
|
- this.setState({
|
|
|
|
- bindroles: val
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- getRolesOptions() {
|
|
|
|
- let options = [];
|
|
|
|
- for (let i = 0; i < this.props.roles.length; i++) {
|
|
|
|
- options.push(<Select.Option key={String(this.props.roles[i].id)}>{this.props.roles[i].roleName}</Select.Option>);
|
|
|
|
- }
|
|
|
|
- return options;
|
|
|
|
- },
|
|
|
|
- getLocations(index, p, c) {
|
|
|
|
- this.state.locations.map((item, i) => {
|
|
|
|
- if (index == i) {
|
|
|
|
- item.province = p;
|
|
|
|
- item.city = c || [];
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- delLocations(index) {
|
|
|
|
- this.state.locations.splice(index, 1);
|
|
|
|
- this.setState({ locations: this.state.locations });
|
|
|
|
- },
|
|
|
|
- provinceAdd() {
|
|
|
|
- this.state.locations.push({
|
|
|
|
- province: null,
|
|
|
|
- city: null
|
|
|
|
- });
|
|
|
|
- this.setState({ locations: this.state.locations });
|
|
|
|
- },
|
|
|
|
- render() {
|
|
|
|
- return (
|
|
|
|
- <div className="modal" >
|
|
|
|
|
|
+ } else if(this.state.id == "1") {
|
|
|
|
+ return <li><span className='modal-text'>角色</span><span style={{width:'150px'}}>系统管理员</span></li>
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ bindRoles(val) {
|
|
|
|
+ this.setState({
|
|
|
|
+ bindroles: val
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ getRolesOptions() {
|
|
|
|
+ let options = [];
|
|
|
|
+ for(let i = 0; i < this.props.roles.length; i++) {
|
|
|
|
+ options.push(<Select.Option key={String(this.props.roles[i].id)}>{this.props.roles[i].roleName}</Select.Option>);
|
|
|
|
+ }
|
|
|
|
+ return options;
|
|
|
|
+ },
|
|
|
|
+ getLocations(index, p, c) {
|
|
|
|
+ this.state.locations.map((item, i) => {
|
|
|
|
+ if(index == i) {
|
|
|
|
+ item.province = p;
|
|
|
|
+ item.city = c || [];
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ delLocations(index) {
|
|
|
|
+ this.state.locations.splice(index, 1);
|
|
|
|
+ this.setState({ locations: this.state.locations });
|
|
|
|
+ },
|
|
|
|
+ provinceAdd() {
|
|
|
|
+ this.state.locations.push({
|
|
|
|
+ province: null,
|
|
|
|
+ city: null
|
|
|
|
+ });
|
|
|
|
+ this.setState({ locations: this.state.locations });
|
|
|
|
+ },
|
|
|
|
+ render() {
|
|
|
|
+ let departmentArr=this.props.departmentArr||[];
|
|
|
|
+ return(
|
|
|
|
+ <div className="modal" >
|
|
<Modal maskClosable={false} title="管理员详情"
|
|
<Modal maskClosable={false} title="管理员详情"
|
|
closable={false} width={1000}
|
|
closable={false} width={1000}
|
|
visible={this.state.visible}
|
|
visible={this.state.visible}
|
|
@@ -434,6 +451,18 @@ const TheModal = React.createClass({
|
|
<Input value={this.state.position} onChange={(e) => { this.state.position = e.target.value; this.setState({ position: this.state.position }); }} />
|
|
<Input value={this.state.position} onChange={(e) => { this.state.position = e.target.value; this.setState({ position: this.state.position }); }} />
|
|
</li>
|
|
</li>
|
|
<li className="list">
|
|
<li className="list">
|
|
|
|
+ <span className='modal-text'>部门</span>
|
|
|
|
+ <Select placeholder="选择部门" style={{width:'200px'}}
|
|
|
|
+ value={this.state.department}
|
|
|
|
+ onChange={(e) => { this.setState({ department: e }) }}>
|
|
|
|
+ {
|
|
|
|
+ departmentArr.map(function (item) {
|
|
|
|
+ return <Select.Option key={item.id} >{item.name}</Select.Option>
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ </Select>
|
|
|
|
+ </li>
|
|
|
|
+ <li className="list">
|
|
<span className='modal-text'>上级</span>
|
|
<span className='modal-text'>上级</span>
|
|
<Select style={{ verticalAlign: 'middle', width: 200 }}
|
|
<Select style={{ verticalAlign: 'middle', width: 200 }}
|
|
placeholder="选择一个上级" notFoundContent="没有获取到管理员列表"
|
|
placeholder="选择一个上级" notFoundContent="没有获取到管理员列表"
|
|
@@ -526,8 +555,8 @@ const TheModal = React.createClass({
|
|
</Spin>
|
|
</Spin>
|
|
</Modal>
|
|
</Modal>
|
|
</div >
|
|
</div >
|
|
- );
|
|
|
|
- }
|
|
|
|
|
|
+ );
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
|
|
export default TheModal;
|
|
export default TheModal;
|