|
@@ -1,6 +1,5 @@
|
|
|
import React, {Component} from 'react';
|
|
import React, {Component} from 'react';
|
|
|
import './index.css';
|
|
import './index.css';
|
|
|
-<<<<<<< HEAD
|
|
|
|
|
import {NoticeBar, List, InputItem, ImagePicker, Button, Stepper, DatePicker} from 'antd-mobile';
|
|
import {NoticeBar, List, InputItem, ImagePicker, Button, Stepper, DatePicker} from 'antd-mobile';
|
|
|
import {Query, Mutation} from "react-apollo";
|
|
import {Query, Mutation} from "react-apollo";
|
|
|
import {Spin} from 'antd';
|
|
import {Spin} from 'antd';
|
|
@@ -14,16 +13,7 @@ import {
|
|
|
createserviceAndcreaterepertory,
|
|
createserviceAndcreaterepertory,
|
|
|
deleteserviceAnddeleterepertory
|
|
deleteserviceAnddeleterepertory
|
|
|
} from "../../gql";
|
|
} from "../../gql";
|
|
|
-=======
|
|
|
|
|
-import {NoticeBar, List, InputItem, ImagePicker, Button, Stepper} from 'antd-mobile';
|
|
|
|
|
-import {Query, Mutation} from "react-apollo";
|
|
|
|
|
-import {Spin} from 'antd';
|
|
|
|
|
-import gql from "graphql-tag";
|
|
|
|
|
-import {servicebyid, serverbyprops, servicebyprops, createserver} from "../../gql";
|
|
|
|
|
->>>>>>> 21b37a16ee42ecadd852690593a62a558317c4cc
|
|
|
|
|
import {idGen} from "../../func";
|
|
import {idGen} from "../../func";
|
|
|
-import InputMoment from 'input-moment';
|
|
|
|
|
-import moment from 'moment';
|
|
|
|
|
|
|
|
|
|
const Item = List.Item;
|
|
const Item = List.Item;
|
|
|
const nowTimeStamp = Date.now();
|
|
const nowTimeStamp = Date.now();
|
|
@@ -122,15 +112,12 @@ class ServiceList extends Component {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
|
donotShowDetail = () => {
|
|
donotShowDetail = () => {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
serviceID: ''
|
|
serviceID: ''
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-=======
|
|
|
|
|
->>>>>>> 21b37a16ee42ecadd852690593a62a558317c4cc
|
|
|
|
|
render() {
|
|
render() {
|
|
|
let {serverID} = this.props;
|
|
let {serverID} = this.props;
|
|
|
return (
|
|
return (
|
|
@@ -181,15 +168,11 @@ class ServiceList extends Component {
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
this.state.serviceID ?
|
|
this.state.serviceID ?
|
|
|
-<<<<<<< HEAD
|
|
|
|
|
<ServiceDetail
|
|
<ServiceDetail
|
|
|
serviceID={this.state.serviceID}
|
|
serviceID={this.state.serviceID}
|
|
|
serverID={serverID}
|
|
serverID={serverID}
|
|
|
donotShowDetail={this.donotShowDetail}
|
|
donotShowDetail={this.donotShowDetail}
|
|
|
/>
|
|
/>
|
|
|
-=======
|
|
|
|
|
- <ServiceDetail serviceID={this.state.serviceID}/>
|
|
|
|
|
->>>>>>> 21b37a16ee42ecadd852690593a62a558317c4cc
|
|
|
|
|
:
|
|
:
|
|
|
''
|
|
''
|
|
|
}
|
|
}
|
|
@@ -260,250 +243,6 @@ class AddServer extends Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class SubmitServerButton extends Component {
|
|
class SubmitServerButton extends Component {
|
|
|
-<<<<<<< HEAD
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props);
|
|
|
|
|
- this.state = {}
|
|
|
|
|
-=======
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props);
|
|
|
|
|
- this.state = {}
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- let {name, description, img} = this.props;
|
|
|
|
|
- return (
|
|
|
|
|
- <Mutation
|
|
|
|
|
- mutation={gql(createserver)}
|
|
|
|
|
- refetchQueries={[{query: gql(serverbyprops), variables: {}}]}
|
|
|
|
|
- >
|
|
|
|
|
- {(createserver, {loading, error}) => {
|
|
|
|
|
- if (loading)
|
|
|
|
|
- return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
|
|
|
|
|
- if (error)
|
|
|
|
|
- return 'error';
|
|
|
|
|
- let varObj = {
|
|
|
|
|
- id: idGen('server'),
|
|
|
|
|
- name,
|
|
|
|
|
- description,
|
|
|
|
|
- img,
|
|
|
|
|
- createdAt: new Date().getTime(),
|
|
|
|
|
- updatedAt: ''
|
|
|
|
|
- };
|
|
|
|
|
- return (
|
|
|
|
|
- <Button type="primary" size="small" inline onClick={() => {
|
|
|
|
|
- createserver({variables: varObj})
|
|
|
|
|
- }}>提交</Button>
|
|
|
|
|
- )
|
|
|
|
|
- }}
|
|
|
|
|
- </Mutation>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-class ServiceDetail extends Component {
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props);
|
|
|
|
|
- this.state = {}
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- let {serviceID} = this.props;
|
|
|
|
|
- return (
|
|
|
|
|
- <Query query={gql(servicebyid)} variables={{id: serviceID}}>
|
|
|
|
|
- {
|
|
|
|
|
- ({loading, error, data}) => {
|
|
|
|
|
- if (loading) {
|
|
|
|
|
- return <Spin className={'spin'}/>
|
|
|
|
|
- }
|
|
|
|
|
- if (error) {
|
|
|
|
|
- return 'error!';
|
|
|
|
|
- }
|
|
|
|
|
- let service = data.servicebyid;
|
|
|
|
|
-
|
|
|
|
|
- var description = '',
|
|
|
|
|
- startTime = '',
|
|
|
|
|
- lastTime = '',
|
|
|
|
|
- price = '',
|
|
|
|
|
- repertory = '';
|
|
|
|
|
-
|
|
|
|
|
- if (service !== null) {
|
|
|
|
|
- description = service.description;
|
|
|
|
|
- startTime = service.startTime;
|
|
|
|
|
- lastTime = service.lastTime;
|
|
|
|
|
- price = service.price;
|
|
|
|
|
- repertory = service.repertory_id.count;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return (
|
|
|
|
|
- <ServiceDetailRender
|
|
|
|
|
- serviceID={serviceID}
|
|
|
|
|
- description={description}
|
|
|
|
|
- startTime={startTime}
|
|
|
|
|
- lastTime={lastTime}
|
|
|
|
|
- price={price}
|
|
|
|
|
- repertory={repertory}
|
|
|
|
|
- />
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- </Query>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-class ServiceDetailRender extends Component {
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props);
|
|
|
|
|
- this.state = {
|
|
|
|
|
- serviceID: props.serviceID,
|
|
|
|
|
- description: props.description,
|
|
|
|
|
- lastTime: props.lastTime,
|
|
|
|
|
- startTime: props.startTime,
|
|
|
|
|
- price: props.price,
|
|
|
|
|
- repertory: props.repertory,
|
|
|
|
|
- showCalendar: false,
|
|
|
|
|
- m: moment()
|
|
|
|
|
- }
|
|
|
|
|
->>>>>>> 21b37a16ee42ecadd852690593a62a558317c4cc
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- componentWillReceiveProps(next) {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- serviceID: next.serviceID,
|
|
|
|
|
- description: next.description,
|
|
|
|
|
- lastTime: next.lastTime,
|
|
|
|
|
- startTime: next.startTime,
|
|
|
|
|
- price: next.price,
|
|
|
|
|
- repertory: next.repertory,
|
|
|
|
|
- showCalendar: false
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- onReset = () => {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- startTime: '',
|
|
|
|
|
- lastTime: '',
|
|
|
|
|
- description: '',
|
|
|
|
|
- price: '',
|
|
|
|
|
- repertory: 1
|
|
|
|
|
- })
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- handleChange = m => {
|
|
|
|
|
- this.setState({ m });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- handleSave = () => {
|
|
|
|
|
- console.log('saved', this.state.m.format('llll'));
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- let {serviceID, description, startTime, lastTime, price, repertory} = this.state;
|
|
|
|
|
- return (
|
|
|
|
|
- <div>
|
|
|
|
|
- <List renderHeader={() => '请输入服务项信息'}>
|
|
|
|
|
- <InputItem onChange={(e) => {
|
|
|
|
|
- this.setState({name: e})
|
|
|
|
|
- }} value={description} placeholder="请输入服务类型">服务类型</InputItem>
|
|
|
|
|
- <InputItem onChange={(e) => {
|
|
|
|
|
- this.setState({price: e})
|
|
|
|
|
- }} value={price} placeholder="请输入价格">价格</InputItem>
|
|
|
|
|
- <Item arrow="horizontal"
|
|
|
|
|
- onClick={() => {
|
|
|
|
|
- document.getElementsByTagName('body')[0].style.overflowY = 'hidden';
|
|
|
|
|
- this.setState({
|
|
|
|
|
- showCalendar: true
|
|
|
|
|
- });
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- 选择开放时间
|
|
|
|
|
- </Item>
|
|
|
|
|
- <Item
|
|
|
|
|
- wrap
|
|
|
|
|
- extra={
|
|
|
|
|
- <Stepper
|
|
|
|
|
- style={{ width: '100%', minWidth: '100px' }}
|
|
|
|
|
- showNumber
|
|
|
|
|
- min={0}
|
|
|
|
|
- value={repertory}
|
|
|
|
|
- onChange={(e)=>{
|
|
|
|
|
- this.setState({repertory: e})
|
|
|
|
|
- }}
|
|
|
|
|
- />}
|
|
|
|
|
- >
|
|
|
|
|
- 库存
|
|
|
|
|
- </Item>
|
|
|
|
|
- <Item>
|
|
|
|
|
- {
|
|
|
|
|
- serviceID === 'add'?
|
|
|
|
|
- <SubmitServiceCreateButton/>
|
|
|
|
|
- :
|
|
|
|
|
- <SubmitServiceUpdateButton/>
|
|
|
|
|
- }
|
|
|
|
|
- <Button size="small" inline style={{marginLeft: '2.5px'}} onClick={this.onReset}>重置</Button>
|
|
|
|
|
- </Item>
|
|
|
|
|
- </List>
|
|
|
|
|
- {
|
|
|
|
|
- this.state.showCalendar?
|
|
|
|
|
- <InputMoment
|
|
|
|
|
- moment={this.state.m}
|
|
|
|
|
- onChange={this.handleChange}
|
|
|
|
|
- minStep={5}
|
|
|
|
|
- onSave={this.handleSave}
|
|
|
|
|
- prevMonthIcon="ion-ios-arrow-left"
|
|
|
|
|
- nextMonthIcon="ion-ios-arrow-right"
|
|
|
|
|
- style={{position: 'absoluted', top: 0, left: 0}}
|
|
|
|
|
- />
|
|
|
|
|
- :
|
|
|
|
|
- ''
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-class SubmitServiceUpdateButton extends Component {
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props);
|
|
|
|
|
- this.state = {}
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- let {name, description, img} = this.props;
|
|
|
|
|
- return (
|
|
|
|
|
- <Mutation
|
|
|
|
|
- mutation={gql(createserver)}
|
|
|
|
|
- refetchQueries={[{query: gql(serverbyprops), variables: {}}]}
|
|
|
|
|
- >
|
|
|
|
|
- {(createserver, {loading, error}) => {
|
|
|
|
|
- if (loading)
|
|
|
|
|
- return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
|
|
|
|
|
- if (error)
|
|
|
|
|
- return 'error';
|
|
|
|
|
- let varObj = {
|
|
|
|
|
- id: idGen('server'),
|
|
|
|
|
- name,
|
|
|
|
|
- description,
|
|
|
|
|
- img,
|
|
|
|
|
- createdAt: new Date().getTime(),
|
|
|
|
|
- updatedAt: ''
|
|
|
|
|
- };
|
|
|
|
|
- return (
|
|
|
|
|
- <Button type="primary" size="small" inline onClick={() => {
|
|
|
|
|
- createserver({variables: varObj})
|
|
|
|
|
- }}>提交</Button>
|
|
|
|
|
- )
|
|
|
|
|
- }}
|
|
|
|
|
- </Mutation>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-class SubmitServiceCreateButton extends Component {
|
|
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
this.state = {}
|
|
this.state = {}
|