import React, {Component} from 'react'; import {Layout, Card, Button, Avatar, Spin, Icon, Row, Col, notification, Tag} from 'antd'; import lo from '../../../images/lo.png' import './index.css' import {graphqlUrl} from "../../../config"; import {SHOW_ALL_CASE, SHOW_CASE, SEARCH_SCHEMA} from "../../../gql"; import {FormattedMessage} from 'react-intl'; import {request} from 'graphql-request' import UserCustom from "./UserCustom"; import {Query} from "react-apollo"; import gql from "graphql-tag"; import {getCookie} from "../../../cookie"; const {Content} = Layout; const {Meta} = Card; // caseshow 与 usercustom 展示于一个三目运算符 // 因此刷新 usercustom 将不存在,并且他没有路径 class CaseShow extends Component { constructor(props) { super(props); this.state = { examplesIoobot: [], examplesOthers: [], showCustom: false, chosenSchemaID: '' } } componentWillMount() { this._isMounted = true; // 查询是否登录 let userID = getCookie('user_id'); if (userID !== undefined && userID !== '') { this.setState({ userID }); } request(graphqlUrl, SHOW_ALL_CASE, {}).then(data => { let cases = data.case_by_props; // console.log(cases); let examplesIoobot = cases.filter(case1 => case1.user_id.id === 'ioobot'); let IooList = this.examplesFilter(examplesIoobot); let examplesOthers = cases.filter(case2 => case2.user_id.id !== 'ioobot'); let UserList = this.examplesFilter(examplesOthers); if (this._isMounted) { this.setState({ examplesIoobot: IooList, examplesOthers: UserList }) } } ) } examplesFilter(example) { // console.log('examples',example); let hash = {}, i = 0, list = []; example.forEach(function (item) { let {title} = item; hash[title] ? list[hash[title] - 1].content.push(item) : hash[title] = ++i && list.push({ title, content: [item], }); }); // console.log('list',list); return list; } componentWillUnmount() { this._isMounted = false; } schemaIDChangeBucket = async (schemaID) => { let bucketname = await request(graphqlUrl, SEARCH_SCHEMA, {id: schemaID}) console.log(bucketname.schema_by_id.schemaName, 'is schemaName,is equal to bucketName') return bucketname.schema_by_id.schemaName; }; backToMe = () => { this.setState({ showCustom: false }) }; showCustom = (item) => { this.setState({ showCustom: true, chosenSchemaID: item }) }; render() { let {userID, showCustom, chosenSchemaID} = this.state; return (
我们永久无年费 告别高成本
省钱、更省心
数据完全私有 安全更可靠
数据分析图表为您提供更细致的服务
模板不满意 快来定制化吧!
上手有困难,联系我们即可