|
@@ -1,7 +1,7 @@
|
|
|
import React, {Component} from 'react';
|
|
import React, {Component} from 'react';
|
|
|
import {Input, Spin, Button, Icon, Modal} from 'antd';
|
|
import {Input, Spin, Button, Icon, Modal} from 'antd';
|
|
|
import './index.css';
|
|
import './index.css';
|
|
|
-import {UPDATE_WXCONFIG, SHOW_WXCONTENT, DELETE_WXCONFIG, SHOW_WXCONFIG} from "../../../gql";
|
|
|
|
|
|
|
+import {UPDATE_WXCONFIG, SHOW_WXCONTENT, DELETE_WXCONFIG, SHOW_WXCONFIG,DELETE_PROJECT,SHOW_PROJECT} from "../../../gql";
|
|
|
import gql from "graphql-tag";
|
|
import gql from "graphql-tag";
|
|
|
import {Mutation, Query} from "react-apollo";
|
|
import {Mutation, Query} from "react-apollo";
|
|
|
import {getCookie} from "../../../cookie";
|
|
import {getCookie} from "../../../cookie";
|
|
@@ -15,13 +15,17 @@ class WxConfig extends Component {
|
|
|
configs: ['appName', 'appID', 'appSecret', 'enter_url', 'token', 'welcome_words', 'pay_api_key', 'attach', 'mch_id', 'body', 'spbill_create_ip', 'notify_url'],
|
|
configs: ['appName', 'appID', 'appSecret', 'enter_url', 'token', 'welcome_words', 'pay_api_key', 'attach', 'mch_id', 'body', 'spbill_create_ip', 'notify_url'],
|
|
|
configID: props.location.state === undefined ? props.defaultConfigID : props.location.state.configID,
|
|
configID: props.location.state === undefined ? props.defaultConfigID : props.location.state.configID,
|
|
|
appName: props.location.state === undefined ? props.defaultAppName : props.location.state.appName,
|
|
appName: props.location.state === undefined ? props.defaultAppName : props.location.state.appName,
|
|
|
|
|
+ projectID: props.location.state === undefined ? props.projectID : props.location.state.projectID,
|
|
|
|
|
+ userID:props.userID
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(next) {
|
|
componentWillReceiveProps(next) {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
|
|
+ userID:next.userID,
|
|
|
configID: next.location.state === undefined ? next.defaultConfigID : next.location.state.configID,
|
|
configID: next.location.state === undefined ? next.defaultConfigID : next.location.state.configID,
|
|
|
appName: next.location.state === undefined ? next.defaultAppName : next.location.state.appName,
|
|
appName: next.location.state === undefined ? next.defaultAppName : next.location.state.appName,
|
|
|
|
|
+ projectID: next.location.state === undefined ? next.projectID : next.location.state.projectID,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -37,10 +41,12 @@ class WxConfig extends Component {
|
|
|
return 'error!';
|
|
return 'error!';
|
|
|
}
|
|
}
|
|
|
let {history, location, trialcase} = this.props;
|
|
let {history, location, trialcase} = this.props;
|
|
|
- let {appName, configID, configs} = this.state;
|
|
|
|
|
|
|
+ let {appName, configID, configs,projectID,userID} = this.state;
|
|
|
return (
|
|
return (
|
|
|
<Display
|
|
<Display
|
|
|
configs={configs}
|
|
configs={configs}
|
|
|
|
|
+ userID={userID}
|
|
|
|
|
+ projectID={projectID}
|
|
|
configID={configID}
|
|
configID={configID}
|
|
|
appName={appName}
|
|
appName={appName}
|
|
|
location={location}
|
|
location={location}
|
|
@@ -62,8 +68,10 @@ class Display extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
this.state = {
|
|
this.state = {
|
|
|
|
|
+ userID:props.userID,
|
|
|
configID: props.configID,
|
|
configID: props.configID,
|
|
|
appName: props.appName,
|
|
appName: props.appName,
|
|
|
|
|
+ projectID:props.projectID,
|
|
|
mch_id: props.data === null ? '' : props.data.mch_id,
|
|
mch_id: props.data === null ? '' : props.data.mch_id,
|
|
|
notify_url: props.data === null ? '' : props.data.notify_url,
|
|
notify_url: props.data === null ? '' : props.data.notify_url,
|
|
|
appSecret: props.data === null ? '' : props.data.appSecret,
|
|
appSecret: props.data === null ? '' : props.data.appSecret,
|
|
@@ -80,8 +88,10 @@ class Display extends Component {
|
|
|
|
|
|
|
|
componentWillReceiveProps(next) {
|
|
componentWillReceiveProps(next) {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
|
|
+ userID:next.userID,
|
|
|
configID: next.configID,
|
|
configID: next.configID,
|
|
|
appName: next.appName,
|
|
appName: next.appName,
|
|
|
|
|
+ projectID:next.projectID,
|
|
|
mch_id: next.data === null ? '' : next.data.mch_id,
|
|
mch_id: next.data === null ? '' : next.data.mch_id,
|
|
|
notify_url: next.data === null ? '' : next.data.notify_url,
|
|
notify_url: next.data === null ? '' : next.data.notify_url,
|
|
|
appSecret: next.data === null ? '' : next.data.appSecret,
|
|
appSecret: next.data === null ? '' : next.data.appSecret,
|
|
@@ -107,7 +117,7 @@ class Display extends Component {
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
let {configs} = this.props;
|
|
let {configs} = this.props;
|
|
|
- let {configID, appName, mch_id, notify_url, appSecret, appID, token, spbill_create_ip, enter_url, pay_api_key, body, welcome_words, attach} = this.state;
|
|
|
|
|
|
|
+ let {userID,configID, appName,projectID, mch_id, notify_url, appSecret, appID, token, spbill_create_ip, enter_url, pay_api_key, body, welcome_words, attach} = this.state;
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
{
|
|
{
|
|
@@ -139,8 +149,10 @@ class Display extends Component {
|
|
|
welcome_words={welcome_words}
|
|
welcome_words={welcome_words}
|
|
|
attach={attach}
|
|
attach={attach}
|
|
|
/>
|
|
/>
|
|
|
- <DeleteWXConfigButton
|
|
|
|
|
|
|
+ <DeleteWXProjectButton
|
|
|
id={configID}
|
|
id={configID}
|
|
|
|
|
+ userID={userID}
|
|
|
|
|
+ projectID={projectID}
|
|
|
history={this.props.history}
|
|
history={this.props.history}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -194,21 +206,22 @@ class UpdateWXConfigButton extends Component {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-class DeleteWXConfigButton extends Component {
|
|
|
|
|
|
|
+class DeleteWXProjectButton extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
this.state = {
|
|
this.state = {
|
|
|
- userID: getCookie('user_id')
|
|
|
|
|
|
|
+ userID: props.userID,
|
|
|
|
|
+ projectID:props.projectID
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- showConfirm = (delete_wxConfig, id) => {
|
|
|
|
|
|
|
+ showConfirm = (delete_wx_project, projectID, userID) => {
|
|
|
let _this = this;
|
|
let _this = this;
|
|
|
confirm({
|
|
confirm({
|
|
|
title: 'Do you want to delete this config?',
|
|
title: 'Do you want to delete this config?',
|
|
|
content: 'It cannot be found back!',
|
|
content: 'It cannot be found back!',
|
|
|
onOk() {
|
|
onOk() {
|
|
|
- delete_wxConfig({variables: {id}});
|
|
|
|
|
|
|
+ delete_wx_project({variables: {id:projectID, user_id: userID}});
|
|
|
_this.props.history.push({
|
|
_this.props.history.push({
|
|
|
pathname: `/wechat-service/trial-case/index`,
|
|
pathname: `/wechat-service/trial-case/index`,
|
|
|
});
|
|
});
|
|
@@ -219,21 +232,24 @@ class DeleteWXConfigButton extends Component {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
|
|
+ let {userID,projectID} = this.state;
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<Mutation
|
|
<Mutation
|
|
|
- mutation={gql(DELETE_WXCONFIG)}
|
|
|
|
|
- refetchQueries={[{query: gql(SHOW_WXCONFIG), variables: {user_id: this.state.userID}}]}
|
|
|
|
|
|
|
+ mutation={gql(DELETE_PROJECT)}
|
|
|
|
|
+ refetchQueries={[{query: gql(SHOW_PROJECT), variables: {projectType:'wx',user_id: userID}}]}
|
|
|
>
|
|
>
|
|
|
- {(delete_wxConfig, {loading, error}) => {
|
|
|
|
|
|
|
+ {(delete_wx_project, {loading, error}) => {
|
|
|
if (loading)
|
|
if (loading)
|
|
|
return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
|
|
return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
|
|
|
if (error)
|
|
if (error)
|
|
|
return 'error';
|
|
return 'error';
|
|
|
- let {id} = this.props;
|
|
|
|
|
return (
|
|
return (
|
|
|
- <Button type={'danger'} onClick={() => {
|
|
|
|
|
- this.showConfirm(delete_wxConfig, id);
|
|
|
|
|
- }}>delete</Button>
|
|
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type={'danger'}
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ this.showConfirm(delete_wx_project, projectID, userID);
|
|
|
|
|
+ }}>delete</Button>
|
|
|
)
|
|
)
|
|
|
}}
|
|
}}
|
|
|
</Mutation>
|
|
</Mutation>
|