提交 76e261a401d220e9943d56c34903996d15245144

作者 愚道
1 个父辈 81e86171

init pro blockadvanced profile

  1 +/yarn.lock
  2 +/package-lock.json
  3 +/dist
  4 +/node_modules
  5 +
  6 +.umi
  7 +.umi-production
  1 +export default {
  2 + plugins: [
  3 + ['umi-plugin-block-dev', {}],
  4 + ['umi-plugin-react', {
  5 + dva: true,
  6 + locale: true,
  7 + antd: true,
  8 + }]
  9 + ],
  10 +}
  1 +import React, { PureComponent } from 'react';
  2 +import { connect } from 'dva';
  3 +import styles from './GridContent.less';
  4 +
  5 +class GridContent extends PureComponent {
  6 + render() {
  7 + const { contentWidth, children } = this.props;
  8 + let className = `${styles.main}`;
  9 + if (contentWidth === 'Fixed') {
  10 + className = `${styles.main} ${styles.wide}`;
  11 + }
  12 + return <div className={className}>{children}</div>;
  13 + }
  14 +}
  15 +
  16 +export default connect(({ setting }) => ({
  17 + contentWidth: setting.contentWidth,
  18 +}))(GridContent);
  1 +.main {
  2 + width: 100%;
  3 + height: 100%;
  4 + min-height: 100%;
  5 + transition: 0.3s;
  6 + &.wide {
  7 + max-width: 1200px;
  8 + margin: 0 auto;
  9 + }
  10 +}
  1 +import React from 'react';
  2 +import { FormattedMessage } from 'umi/locale';
  3 +import Link from 'umi/link';
  4 +import PageHeader from 'ant-design-pro/lib/PageHeader';
  5 +import { connect } from 'dva';
  6 +import GridContent from './GridContent';
  7 +import styles from './index.less';
  8 +import MenuContext from '@/layouts/MenuContext';
  9 +
  10 +const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, top, ...restProps }) => (
  11 + <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
  12 + {top}
  13 + <MenuContext.Consumer>
  14 + {value => (
  15 + <PageHeader
  16 + wide={contentWidth === 'Fixed'}
  17 + home={<FormattedMessage id="menu.home" defaultMessage="Home" />}
  18 + {...value}
  19 + key="pageheader"
  20 + {...restProps}
  21 + linkElement={Link}
  22 + itemRender={item => {
  23 + if (item.locale) {
  24 + return <FormattedMessage id={item.locale} defaultMessage={item.title} />;
  25 + }
  26 + return item.title;
  27 + }}
  28 + />
  29 + )}
  30 + </MenuContext.Consumer>
  31 + {children ? (
  32 + <div className={styles.content}>
  33 + <GridContent>{children}</GridContent>
  34 + </div>
  35 + ) : null}
  36 + </div>
  37 +);
  38 +
  39 +export default connect(({ setting }) => ({
  40 + contentWidth: setting.contentWidth,
  41 +}))(PageHeaderWrapper);
  1 +@import '~antd/lib/style/themes/default.less';
  2 +
  3 +.content {
  4 + margin: 24px 24px 0;
  5 +}
  6 +
  7 +@media screen and (max-width: @screen-sm) {
  8 + .content {
  9 + margin: 24px 0 0;
  10 + }
  11 +}
  1 +import { createContext } from 'react';
  2 +
  3 +export default createContext();
  1 +import { stringify } from 'qs';
  2 +import request from '@/utils/request';
  3 +
  4 +export async function queryProjectNotice() {
  5 + return request('/api/project/notice');
  6 +}
  7 +
  8 +export async function queryActivities() {
  9 + return request('/api/activities');
  10 +}
  11 +
  12 +export async function queryRule(params) {
  13 + return request(`/api/rule?${stringify(params)}`);
  14 +}
  15 +
  16 +export async function removeRule(params) {
  17 + return request('/api/rule', {
  18 + method: 'POST',
  19 + body: {
  20 + ...params,
  21 + method: 'delete',
  22 + },
  23 + });
  24 +}
  25 +
  26 +export async function addRule(params) {
  27 + return request('/api/rule', {
  28 + method: 'POST',
  29 + body: {
  30 + ...params,
  31 + method: 'post',
  32 + },
  33 + });
  34 +}
  35 +
  36 +export async function updateRule(params) {
  37 + return request('/api/rule', {
  38 + method: 'POST',
  39 + body: {
  40 + ...params,
  41 + method: 'update',
  42 + },
  43 + });
  44 +}
  45 +
  46 +export async function fakeSubmitForm(params) {
  47 + return request('/api/forms', {
  48 + method: 'POST',
  49 + body: params,
  50 + });
  51 +}
  52 +
  53 +export async function fakeChartData() {
  54 + return request('/api/fake_chart_data');
  55 +}
  56 +
  57 +export async function queryTags() {
  58 + return request('/api/tags');
  59 +}
  60 +
  61 +export async function queryBasicProfile() {
  62 + return request('/api/profile/basic');
  63 +}
  64 +
  65 +export async function queryAdvancedProfile() {
  66 + return request('/api/profile/advanced');
  67 +}
  68 +
  69 +export async function queryFakeList(params) {
  70 + return request(`/api/fake_list?${stringify(params)}`);
  71 +}
  72 +
  73 +export async function removeFakeList(params) {
  74 + const { count = 5, ...restParams } = params;
  75 + return request(`/api/fake_list?count=${count}`, {
  76 + method: 'POST',
  77 + body: {
  78 + ...restParams,
  79 + method: 'delete',
  80 + },
  81 + });
  82 +}
  83 +
  84 +export async function addFakeList(params) {
  85 + const { count = 5, ...restParams } = params;
  86 + return request(`/api/fake_list?count=${count}`, {
  87 + method: 'POST',
  88 + body: {
  89 + ...restParams,
  90 + method: 'post',
  91 + },
  92 + });
  93 +}
  94 +
  95 +export async function updateFakeList(params) {
  96 + const { count = 5, ...restParams } = params;
  97 + return request(`/api/fake_list?count=${count}`, {
  98 + method: 'POST',
  99 + body: {
  100 + ...restParams,
  101 + method: 'update',
  102 + },
  103 + });
  104 +}
  105 +
  106 +export async function fakeAccountLogin(params) {
  107 + return request('/api/login/account', {
  108 + method: 'POST',
  109 + body: params,
  110 + });
  111 +}
  112 +
  113 +export async function fakeRegister(params) {
  114 + return request('/api/register', {
  115 + method: 'POST',
  116 + body: params,
  117 + });
  118 +}
  119 +
  120 +export async function queryNotices() {
  121 + return request('/api/notices');
  122 +}
  123 +
  124 +export async function getFakeCaptcha(mobile) {
  125 + return request(`/api/captcha?mobile=${mobile}`);
  126 +}
  1 +import fetch from 'dva/fetch';
  2 +import { notification } from 'antd';
  3 +import router from 'umi/router';
  4 +import hash from 'hash.js';
  5 +import { isAntdPro } from './utils';
  6 +
  7 +const codeMessage = {
  8 + 200: '服务器成功返回请求的数据。',
  9 + 201: '新建或修改数据成功。',
  10 + 202: '一个请求已经进入后台排队(异步任务)。',
  11 + 204: '删除数据成功。',
  12 + 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
  13 + 401: '用户没有权限(令牌、用户名、密码错误)。',
  14 + 403: '用户得到授权,但是访问是被禁止的。',
  15 + 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
  16 + 406: '请求的格式不可得。',
  17 + 410: '请求的资源被永久删除,且不会再得到的。',
  18 + 422: '当创建一个对象时,发生一个验证错误。',
  19 + 500: '服务器发生错误,请检查服务器。',
  20 + 502: '网关错误。',
  21 + 503: '服务不可用,服务器暂时过载或维护。',
  22 + 504: '网关超时。',
  23 +};
  24 +
  25 +const checkStatus = response => {
  26 + if (response.status >= 200 && response.status < 300) {
  27 + return response;
  28 + }
  29 + const errortext = codeMessage[response.status] || response.statusText;
  30 + notification.error({
  31 + message: `请求错误 ${response.status}: ${response.url}`,
  32 + description: errortext,
  33 + });
  34 + const error = new Error(errortext);
  35 + error.name = response.status;
  36 + error.response = response;
  37 + throw error;
  38 +};
  39 +
  40 +const cachedSave = (response, hashcode) => {
  41 + /**
  42 + * Clone a response data and store it in sessionStorage
  43 + * Does not support data other than json, Cache only json
  44 + */
  45 + const contentType = response.headers.get('Content-Type');
  46 + if (contentType && contentType.match(/application\/json/i)) {
  47 + // All data is saved as text
  48 + response
  49 + .clone()
  50 + .text()
  51 + .then(content => {
  52 + sessionStorage.setItem(hashcode, content);
  53 + sessionStorage.setItem(`${hashcode}:timestamp`, Date.now());
  54 + });
  55 + }
  56 + return response;
  57 +};
  58 +
  59 +/**
  60 + * Requests a URL, returning a promise.
  61 + *
  62 + * @param {string} url The URL we want to request
  63 + * @param {object} [option] The options we want to pass to "fetch"
  64 + * @return {object} An object containing either "data" or "err"
  65 + */
  66 +export default function request(url, option) {
  67 + const options = {
  68 + expirys: isAntdPro(),
  69 + ...option,
  70 + };
  71 + /**
  72 + * Produce fingerprints based on url and parameters
  73 + * Maybe url has the same parameters
  74 + */
  75 + const fingerprint = url + (options.body ? JSON.stringify(options.body) : '');
  76 + const hashcode = hash
  77 + .sha256()
  78 + .update(fingerprint)
  79 + .digest('hex');
  80 +
  81 + const defaultOptions = {
  82 + credentials: 'include',
  83 + };
  84 + const newOptions = { ...defaultOptions, ...options };
  85 + if (
  86 + newOptions.method === 'POST' ||
  87 + newOptions.method === 'PUT' ||
  88 + newOptions.method === 'DELETE'
  89 + ) {
  90 + if (!(newOptions.body instanceof FormData)) {
  91 + newOptions.headers = {
  92 + Accept: 'application/json',
  93 + 'Content-Type': 'application/json; charset=utf-8',
  94 + ...newOptions.headers,
  95 + };
  96 + newOptions.body = JSON.stringify(newOptions.body);
  97 + } else {
  98 + // newOptions.body is FormData
  99 + newOptions.headers = {
  100 + Accept: 'application/json',
  101 + ...newOptions.headers,
  102 + };
  103 + }
  104 + }
  105 +
  106 + const expirys = options.expirys && 60;
  107 + // options.expirys !== false, return the cache,
  108 + if (options.expirys !== false) {
  109 + const cached = sessionStorage.getItem(hashcode);
  110 + const whenCached = sessionStorage.getItem(`${hashcode}:timestamp`);
  111 + if (cached !== null && whenCached !== null) {
  112 + const age = (Date.now() - whenCached) / 1000;
  113 + if (age < expirys) {
  114 + const response = new Response(new Blob([cached]));
  115 + return response.json();
  116 + }
  117 + sessionStorage.removeItem(hashcode);
  118 + sessionStorage.removeItem(`${hashcode}:timestamp`);
  119 + }
  120 + }
  121 + return fetch(url, newOptions)
  122 + .then(checkStatus)
  123 + .then(response => cachedSave(response, hashcode))
  124 + .then(response => {
  125 + // DELETE and 204 do not return data by default
  126 + // using .json will report an error.
  127 + if (newOptions.method === 'DELETE' || response.status === 204) {
  128 + return response.text();
  129 + }
  130 + return response.json();
  131 + })
  132 + .catch(e => {
  133 + const status = e.name;
  134 + if (status === 401) {
  135 + // @HACK
  136 + /* eslint-disable no-underscore-dangle */
  137 + window.g_app._store.dispatch({
  138 + type: 'login/logout',
  139 + });
  140 + return;
  141 + }
  142 + // environment should not be used
  143 + if (status === 403) {
  144 + router.push('/exception/403');
  145 + return;
  146 + }
  147 + if (status <= 504 && status >= 500) {
  148 + router.push('/exception/500');
  149 + return;
  150 + }
  151 + if (status >= 404 && status < 422) {
  152 + router.push('/exception/404');
  153 + }
  154 + });
  155 +}
  1 +import moment from 'moment';
  2 +import React from 'react';
  3 +import nzh from 'nzh/cn';
  4 +import { parse, stringify } from 'qs';
  5 +
  6 +export function fixedZero(val) {
  7 + return val * 1 < 10 ? `0${val}` : val;
  8 +}
  9 +
  10 +export function getTimeDistance(type) {
  11 + const now = new Date();
  12 + const oneDay = 1000 * 60 * 60 * 24;
  13 +
  14 + if (type === 'today') {
  15 + now.setHours(0);
  16 + now.setMinutes(0);
  17 + now.setSeconds(0);
  18 + return [moment(now), moment(now.getTime() + (oneDay - 1000))];
  19 + }
  20 +
  21 + if (type === 'week') {
  22 + let day = now.getDay();
  23 + now.setHours(0);
  24 + now.setMinutes(0);
  25 + now.setSeconds(0);
  26 +
  27 + if (day === 0) {
  28 + day = 6;
  29 + } else {
  30 + day -= 1;
  31 + }
  32 +
  33 + const beginTime = now.getTime() - day * oneDay;
  34 +
  35 + return [moment(beginTime), moment(beginTime + (7 * oneDay - 1000))];
  36 + }
  37 +
  38 + if (type === 'month') {
  39 + const year = now.getFullYear();
  40 + const month = now.getMonth();
  41 + const nextDate = moment(now).add(1, 'months');
  42 + const nextYear = nextDate.year();
  43 + const nextMonth = nextDate.month();
  44 +
  45 + return [
  46 + moment(`${year}-${fixedZero(month + 1)}-01 00:00:00`),
  47 + moment(moment(`${nextYear}-${fixedZero(nextMonth + 1)}-01 00:00:00`).valueOf() - 1000),
  48 + ];
  49 + }
  50 +
  51 + const year = now.getFullYear();
  52 + return [moment(`${year}-01-01 00:00:00`), moment(`${year}-12-31 23:59:59`)];
  53 +}
  54 +
  55 +export function getPlainNode(nodeList, parentPath = '') {
  56 + const arr = [];
  57 + nodeList.forEach(node => {
  58 + const item = node;
  59 + item.path = `${parentPath}/${item.path || ''}`.replace(/\/+/g, '/');
  60 + item.exact = true;
  61 + if (item.children && !item.component) {
  62 + arr.push(...getPlainNode(item.children, item.path));
  63 + } else {
  64 + if (item.children && item.component) {
  65 + item.exact = false;
  66 + }
  67 + arr.push(item);
  68 + }
  69 + });
  70 + return arr;
  71 +}
  72 +
  73 +export function digitUppercase(n) {
  74 + return nzh.toMoney(n);
  75 +}
  76 +
  77 +function getRelation(str1, str2) {
  78 + if (str1 === str2) {
  79 + console.warn('Two path are equal!'); // eslint-disable-line
  80 + }
  81 + const arr1 = str1.split('/');
  82 + const arr2 = str2.split('/');
  83 + if (arr2.every((item, index) => item === arr1[index])) {
  84 + return 1;
  85 + }
  86 + if (arr1.every((item, index) => item === arr2[index])) {
  87 + return 2;
  88 + }
  89 + return 3;
  90 +}
  91 +
  92 +function getRenderArr(routes) {
  93 + let renderArr = [];
  94 + renderArr.push(routes[0]);
  95 + for (let i = 1; i < routes.length; i += 1) {
  96 + // 去重
  97 + renderArr = renderArr.filter(item => getRelation(item, routes[i]) !== 1);
  98 + // 是否包含
  99 + const isAdd = renderArr.every(item => getRelation(item, routes[i]) === 3);
  100 + if (isAdd) {
  101 + renderArr.push(routes[i]);
  102 + }
  103 + }
  104 + return renderArr;
  105 +}
  106 +
  107 +/**
  108 + * Get router routing configuration
  109 + * { path:{name,...param}}=>Array<{name,path ...param}>
  110 + * @param {string} path
  111 + * @param {routerData} routerData
  112 + */
  113 +export function getRoutes(path, routerData) {
  114 + let routes = Object.keys(routerData).filter(
  115 + routePath => routePath.indexOf(path) === 0 && routePath !== path
  116 + );
  117 + // Replace path to '' eg. path='user' /user/name => name
  118 + routes = routes.map(item => item.replace(path, ''));
  119 + // Get the route to be rendered to remove the deep rendering
  120 + const renderArr = getRenderArr(routes);
  121 + // Conversion and stitching parameters
  122 + const renderRoutes = renderArr.map(item => {
  123 + const exact = !routes.some(route => route !== item && getRelation(route, item) === 1);
  124 + return {
  125 + exact,
  126 + ...routerData[`${path}${item}`],
  127 + key: `${path}${item}`,
  128 + path: `${path}${item}`,
  129 + };
  130 + });
  131 + return renderRoutes;
  132 +}
  133 +
  134 +export function getPageQuery() {
  135 + return parse(window.location.href.split('?')[1]);
  136 +}
  137 +
  138 +export function getQueryPath(path = '', query = {}) {
  139 + const search = stringify(query);
  140 + if (search.length) {
  141 + return `${path}?${search}`;
  142 + }
  143 + return path;
  144 +}
  145 +
  146 +/* eslint no-useless-escape:0 */
  147 +const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
  148 +
  149 +export function isUrl(path) {
  150 + return reg.test(path);
  151 +}
  152 +
  153 +export function formatWan(val) {
  154 + const v = val * 1;
  155 + if (!v || Number.isNaN(v)) return '';
  156 +
  157 + let result = val;
  158 + if (val > 10000) {
  159 + result = Math.floor(val / 10000);
  160 + result = (
  161 + <span>
  162 + {result}
  163 + <span
  164 + style={{
  165 + position: 'relative',
  166 + top: -2,
  167 + fontSize: 14,
  168 + fontStyle: 'normal',
  169 + marginLeft: 2,
  170 + }}
  171 + >
  172 +
  173 + </span>
  174 + </span>
  175 + );
  176 + }
  177 + return result;
  178 +}
  179 +
  180 +// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性
  181 +export function isAntdPro() {
  182 + return window.location.hostname === 'preview.pro.ant.design';
  183 +}
  1 +# @umi-material/advancedprofile
  2 +
  3 +AdvancedProfile
  4 +
  5 +## Usage
  6 +
  7 +```sh
  8 +umi block https://github.com/umijs/umi-blocks/tree/master/advancedprofile
  9 +```
  10 +
  11 +## LICENSE
  12 +
  13 +MIT
  1 +{
  2 + "name": "@umi-block/advancedprofile",
  3 + "version": "0.0.1",
  4 + "description": "AdvancedProfile",
  5 + "main": "src/index.js",
  6 + "scripts": {
  7 + "dev": "umi dev"
  8 + },
  9 + "repository": {
  10 + "type": "git",
  11 + "url": "https://github.com/umijs/umi-blocks/advancedprofile"
  12 + },
  13 + "dependencies": {
  14 + "react": "^16.6.3",
  15 + "lodash-decorators": "^6.0.0",
  16 + "dva": "^2.4.0",
  17 + "classnames": "^2.2.6",
  18 + "ant-design-pro": "^2.1.1",
  19 + "antd": "^3.10.9",
  20 + "qs": "^6.6.0",
  21 + "hash.js": "^1.1.5",
  22 + "moment": "^2.22.2",
  23 + "nzh": "^1.0.3"
  24 + },
  25 + "devDependencies": {
  26 + "umi": "^2.3.0-beta.1",
  27 + "umi-plugin-react": "^1.3.0-beta.1",
  28 + "umi-plugin-block-dev": "^1.0.0"
  29 + },
  30 + "license": "ISC"
  31 +}
  1 +@import '~antd/lib/style/themes/default.less';
  2 +
  3 +.headerList {
  4 + margin-bottom: 4px;
  5 +}
  6 +
  7 +.tabsCard {
  8 + :global {
  9 + .ant-card-head {
  10 + padding: 0 16px;
  11 + }
  12 + }
  13 +}
  14 +
  15 +.noData {
  16 + color: @disabled-color;
  17 + text-align: center;
  18 + line-height: 64px;
  19 + font-size: 16px;
  20 + i {
  21 + font-size: 24px;
  22 + margin-right: 16px;
  23 + position: relative;
  24 + top: 3px;
  25 + }
  26 +}
  27 +
  28 +.heading {
  29 + color: @heading-color;
  30 + font-size: 20px;
  31 +}
  32 +
  33 +.stepDescription {
  34 + font-size: 14px;
  35 + position: relative;
  36 + left: 38px;
  37 + padding-top: 8px;
  38 + text-align: left;
  39 +
  40 + > div {
  41 + margin-top: 8px;
  42 + margin-bottom: 4px;
  43 + }
  44 +}
  45 +
  46 +.textSecondary {
  47 + color: @text-color-secondary;
  48 +}
  49 +
  50 +@media screen and (max-width: @screen-sm) {
  51 + .stepDescription {
  52 + left: 8px;
  53 + }
  54 +}
  1 +const basicGoods = [
  2 + {
  3 + id: '1234561',
  4 + name: '矿泉水 550ml',
  5 + barcode: '12421432143214321',
  6 + price: '2.00',
  7 + num: '1',
  8 + amount: '2.00',
  9 + },
  10 + {
  11 + id: '1234562',
  12 + name: '凉茶 300ml',
  13 + barcode: '12421432143214322',
  14 + price: '3.00',
  15 + num: '2',
  16 + amount: '6.00',
  17 + },
  18 + {
  19 + id: '1234563',
  20 + name: '好吃的薯片',
  21 + barcode: '12421432143214323',
  22 + price: '7.00',
  23 + num: '4',
  24 + amount: '28.00',
  25 + },
  26 + {
  27 + id: '1234564',
  28 + name: '特别好吃的蛋卷',
  29 + barcode: '12421432143214324',
  30 + price: '8.50',
  31 + num: '3',
  32 + amount: '25.50',
  33 + },
  34 +];
  35 +
  36 +const basicProgress = [
  37 + {
  38 + key: '1',
  39 + time: '2017-10-01 14:10',
  40 + rate: '联系客户',
  41 + status: 'processing',
  42 + operator: '取货员 ID1234',
  43 + cost: '5mins',
  44 + },
  45 + {
  46 + key: '2',
  47 + time: '2017-10-01 14:05',
  48 + rate: '取货员出发',
  49 + status: 'success',
  50 + operator: '取货员 ID1234',
  51 + cost: '1h',
  52 + },
  53 + {
  54 + key: '3',
  55 + time: '2017-10-01 13:05',
  56 + rate: '取货员接单',
  57 + status: 'success',
  58 + operator: '取货员 ID1234',
  59 + cost: '5mins',
  60 + },
  61 + {
  62 + key: '4',
  63 + time: '2017-10-01 13:00',
  64 + rate: '申请审批通过',
  65 + status: 'success',
  66 + operator: '系统',
  67 + cost: '1h',
  68 + },
  69 + {
  70 + key: '5',
  71 + time: '2017-10-01 12:00',
  72 + rate: '发起退货申请',
  73 + status: 'success',
  74 + operator: '用户',
  75 + cost: '5mins',
  76 + },
  77 +];
  78 +
  79 +const advancedOperation1 = [
  80 + {
  81 + key: 'op1',
  82 + type: '订购关系生效',
  83 + name: '曲丽丽',
  84 + status: 'agree',
  85 + updatedAt: '2017-10-03 19:23:12',
  86 + memo: '-',
  87 + },
  88 + {
  89 + key: 'op2',
  90 + type: '财务复审',
  91 + name: '付小小',
  92 + status: 'reject',
  93 + updatedAt: '2017-10-03 19:23:12',
  94 + memo: '不通过原因',
  95 + },
  96 + {
  97 + key: 'op3',
  98 + type: '部门初审',
  99 + name: '周毛毛',
  100 + status: 'agree',
  101 + updatedAt: '2017-10-03 19:23:12',
  102 + memo: '-',
  103 + },
  104 + {
  105 + key: 'op4',
  106 + type: '提交订单',
  107 + name: '林东东',
  108 + status: 'agree',
  109 + updatedAt: '2017-10-03 19:23:12',
  110 + memo: '很棒',
  111 + },
  112 + {
  113 + key: 'op5',
  114 + type: '创建订单',
  115 + name: '汗牙牙',
  116 + status: 'agree',
  117 + updatedAt: '2017-10-03 19:23:12',
  118 + memo: '-',
  119 + },
  120 +];
  121 +
  122 +const advancedOperation2 = [
  123 + {
  124 + key: 'op1',
  125 + type: '订购关系生效',
  126 + name: '曲丽丽',
  127 + status: 'agree',
  128 + updatedAt: '2017-10-03 19:23:12',
  129 + memo: '-',
  130 + },
  131 +];
  132 +
  133 +const advancedOperation3 = [
  134 + {
  135 + key: 'op1',
  136 + type: '创建订单',
  137 + name: '汗牙牙',
  138 + status: 'agree',
  139 + updatedAt: '2017-10-03 19:23:12',
  140 + memo: '-',
  141 + },
  142 +];
  143 +
  144 +const getProfileBasicData = {
  145 + basicGoods,
  146 + basicProgress,
  147 +};
  148 +
  149 +const getProfileAdvancedData = {
  150 + advancedOperation1,
  151 + advancedOperation2,
  152 + advancedOperation3,
  153 +};
  154 +
  155 +export default {
  156 + 'GET /api/profile/advanced': getProfileAdvancedData,
  157 + 'GET /api/profile/basic': getProfileBasicData,
  158 +};
  1 +module.exports = {
  2 + navTheme: 'dark', // theme for nav menu
  3 + primaryColor: '#1890FF', // primary color of ant design
  4 + layout: 'sidemenu', // nav menu position: sidemenu or topmenu
  5 + contentWidth: 'Fluid', // layout of content: Fluid or Fixed, only works when layout is topmenu
  6 + fixedHeader: false, // sticky header
  7 + autoHideHeader: false, // auto hide header
  8 + fixSiderbar: false, // sticky siderbar
  9 +};
  1 +import React, { Component, Fragment } from 'react';
  2 +import Debounce from 'lodash-decorators/debounce';
  3 +import Bind from 'lodash-decorators/bind';
  4 +import { connect } from 'dva';
  5 +import {
  6 + Button,
  7 + Menu,
  8 + Dropdown,
  9 + Icon,
  10 + Row,
  11 + Col,
  12 + Steps,
  13 + Card,
  14 + Popover,
  15 + Badge,
  16 + Table,
  17 + Tooltip,
  18 + Divider,
  19 +} from 'antd';
  20 +import classNames from 'classnames';
  21 +import DescriptionList from 'ant-design-pro/lib/DescriptionList';
  22 +import PageHeaderWrapper from '@/components/PageHeaderWrapper';
  23 +import styles from './AdvancedProfile.less';
  24 +
  25 +const { Step } = Steps;
  26 +const { Description } = DescriptionList;
  27 +const ButtonGroup = Button.Group;
  28 +
  29 +const getWindowWidth = () => window.innerWidth || document.documentElement.clientWidth;
  30 +
  31 +const menu = (
  32 + <Menu>
  33 + <Menu.Item key="1">选项一</Menu.Item>
  34 + <Menu.Item key="2">选项二</Menu.Item>
  35 + <Menu.Item key="3">选项三</Menu.Item>
  36 + </Menu>
  37 +);
  38 +
  39 +const action = (
  40 + <Fragment>
  41 + <ButtonGroup>
  42 + <Button>操作</Button>
  43 + <Button>操作</Button>
  44 + <Dropdown overlay={menu} placement="bottomRight">
  45 + <Button>
  46 + <Icon type="ellipsis" />
  47 + </Button>
  48 + </Dropdown>
  49 + </ButtonGroup>
  50 + <Button type="primary">主操作</Button>
  51 + </Fragment>
  52 +);
  53 +
  54 +const extra = (
  55 + <Row>
  56 + <Col xs={24} sm={12}>
  57 + <div className={styles.textSecondary}>状态</div>
  58 + <div className={styles.heading}>待审批</div>
  59 + </Col>
  60 + <Col xs={24} sm={12}>
  61 + <div className={styles.textSecondary}>订单金额</div>
  62 + <div className={styles.heading}>¥ 568.08</div>
  63 + </Col>
  64 + </Row>
  65 +);
  66 +
  67 +const description = (
  68 + <DescriptionList className={styles.headerList} size="small" col="2">
  69 + <Description term="创建人">曲丽丽</Description>
  70 + <Description term="订购产品">XX 服务</Description>
  71 + <Description term="创建时间">2017-07-07</Description>
  72 + <Description term="关联单据">
  73 + <a href="">12421</a>
  74 + </Description>
  75 + <Description term="生效日期">2017-07-07 ~ 2017-08-08</Description>
  76 + <Description term="备注">请于两个工作日内确认</Description>
  77 + </DescriptionList>
  78 +);
  79 +
  80 +const tabList = [
  81 + {
  82 + key: 'detail',
  83 + tab: '详情',
  84 + },
  85 + {
  86 + key: 'rule',
  87 + tab: '规则',
  88 + },
  89 +];
  90 +
  91 +const desc1 = (
  92 + <div className={classNames(styles.textSecondary, styles.stepDescription)}>
  93 + <Fragment>
  94 + 曲丽丽
  95 + <Icon type="dingding-o" style={{ marginLeft: 8 }} />
  96 + </Fragment>
  97 + <div>2016-12-12 12:32</div>
  98 + </div>
  99 +);
  100 +
  101 +const desc2 = (
  102 + <div className={styles.stepDescription}>
  103 + <Fragment>
  104 + 周毛毛
  105 + <Icon type="dingding-o" style={{ color: '#00A0E9', marginLeft: 8 }} />
  106 + </Fragment>
  107 + <div>
  108 + <a href="">催一下</a>
  109 + </div>
  110 + </div>
  111 +);
  112 +
  113 +const popoverContent = (
  114 + <div style={{ width: 160 }}>
  115 + 吴加号
  116 + <span className={styles.textSecondary} style={{ float: 'right' }}>
  117 + <Badge status="default" text={<span style={{ color: 'rgba(0, 0, 0, 0.45)' }}>未响应</span>} />
  118 + </span>
  119 + <div className={styles.textSecondary} style={{ marginTop: 4 }}>
  120 + 耗时:2小时25分钟
  121 + </div>
  122 + </div>
  123 +);
  124 +
  125 +const customDot = (dot, { status }) =>
  126 + status === 'process' ? (
  127 + <Popover placement="topLeft" arrowPointAtCenter content={popoverContent}>
  128 + {dot}
  129 + </Popover>
  130 + ) : (
  131 + dot
  132 + );
  133 +
  134 +const operationTabList = [
  135 + {
  136 + key: 'tab1',
  137 + tab: '操作日志一',
  138 + },
  139 + {
  140 + key: 'tab2',
  141 + tab: '操作日志二',
  142 + },
  143 + {
  144 + key: 'tab3',
  145 + tab: '操作日志三',
  146 + },
  147 +];
  148 +
  149 +const columns = [
  150 + {
  151 + title: '操作类型',
  152 + dataIndex: 'type',
  153 + key: 'type',
  154 + },
  155 + {
  156 + title: '操作人',
  157 + dataIndex: 'name',
  158 + key: 'name',
  159 + },
  160 + {
  161 + title: '执行结果',
  162 + dataIndex: 'status',
  163 + key: 'status',
  164 + render: text =>
  165 + text === 'agree' ? (
  166 + <Badge status="success" text="成功" />
  167 + ) : (
  168 + <Badge status="error" text="驳回" />
  169 + ),
  170 + },
  171 + {
  172 + title: '操作时间',
  173 + dataIndex: 'updatedAt',
  174 + key: 'updatedAt',
  175 + },
  176 + {
  177 + title: '备注',
  178 + dataIndex: 'memo',
  179 + key: 'memo',
  180 + },
  181 +];
  182 +
  183 +@connect(({ profile, loading }) => ({
  184 + profile,
  185 + loading: loading.effects['profile/fetchAdvanced'],
  186 +}))
  187 +class AdvancedProfile extends Component {
  188 + state = {
  189 + operationkey: 'tab1',
  190 + stepDirection: 'horizontal',
  191 + };
  192 +
  193 + componentDidMount() {
  194 + const { dispatch } = this.props;
  195 + dispatch({
  196 + type: 'profile/fetchAdvanced',
  197 + });
  198 +
  199 + this.setStepDirection();
  200 + window.addEventListener('resize', this.setStepDirection, { passive: true });
  201 + }
  202 +
  203 + componentWillUnmount() {
  204 + window.removeEventListener('resize', this.setStepDirection);
  205 + this.setStepDirection.cancel();
  206 + }
  207 +
  208 + onOperationTabChange = key => {
  209 + this.setState({ operationkey: key });
  210 + };
  211 +
  212 + @Bind()
  213 + @Debounce(200)
  214 + setStepDirection() {
  215 + const { stepDirection } = this.state;
  216 + const w = getWindowWidth();
  217 + if (stepDirection !== 'vertical' && w <= 576) {
  218 + this.setState({
  219 + stepDirection: 'vertical',
  220 + });
  221 + } else if (stepDirection !== 'horizontal' && w > 576) {
  222 + this.setState({
  223 + stepDirection: 'horizontal',
  224 + });
  225 + }
  226 + }
  227 +
  228 + render() {
  229 + const { stepDirection, operationkey } = this.state;
  230 + const { profile, loading } = this.props;
  231 + const { advancedOperation1, advancedOperation2, advancedOperation3 } = profile;
  232 + const contentList = {
  233 + tab1: (
  234 + <Table
  235 + pagination={false}
  236 + loading={loading}
  237 + dataSource={advancedOperation1}
  238 + columns={columns}
  239 + />
  240 + ),
  241 + tab2: (
  242 + <Table
  243 + pagination={false}
  244 + loading={loading}
  245 + dataSource={advancedOperation2}
  246 + columns={columns}
  247 + />
  248 + ),
  249 + tab3: (
  250 + <Table
  251 + pagination={false}
  252 + loading={loading}
  253 + dataSource={advancedOperation3}
  254 + columns={columns}
  255 + />
  256 + ),
  257 + };
  258 +
  259 + return (
  260 + <PageHeaderWrapper
  261 + title="单号:234231029431"
  262 + logo={
  263 + <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png" />
  264 + }
  265 + action={action}
  266 + content={description}
  267 + extraContent={extra}
  268 + tabList={tabList}
  269 + >
  270 + <Card title="流程进度" style={{ marginBottom: 24 }} bordered={false}>
  271 + <Steps direction={stepDirection} progressDot={customDot} current={1}>
  272 + <Step title="创建项目" description={desc1} />
  273 + <Step title="部门初审" description={desc2} />
  274 + <Step title="财务复核" />
  275 + <Step title="完成" />
  276 + </Steps>
  277 + </Card>
  278 + <Card title="用户信息" style={{ marginBottom: 24 }} bordered={false}>
  279 + <DescriptionList style={{ marginBottom: 24 }}>
  280 + <Description term="用户姓名">付小小</Description>
  281 + <Description term="会员卡号">32943898021309809423</Description>
  282 + <Description term="身份证">3321944288191034921</Description>
  283 + <Description term="联系方式">18112345678</Description>
  284 + <Description term="联系地址">
  285 + 曲丽丽 18100000000 浙江省杭州市西湖区黄姑山路工专路交叉路口
  286 + </Description>
  287 + </DescriptionList>
  288 + <DescriptionList style={{ marginBottom: 24 }} title="信息组">
  289 + <Description term="某某数据">725</Description>
  290 + <Description term="该数据更新时间">2017-08-08</Description>
  291 + <Description>&nbsp;</Description>
  292 + <Description
  293 + term={
  294 + <span>
  295 + 某某数据
  296 + <Tooltip title="数据说明">
  297 + <Icon
  298 + style={{ color: 'rgba(0, 0, 0, 0.43)', marginLeft: 4 }}
  299 + type="info-circle-o"
  300 + />
  301 + </Tooltip>
  302 + </span>
  303 + }
  304 + >
  305 + 725
  306 + </Description>
  307 + <Description term="该数据更新时间">2017-08-08</Description>
  308 + </DescriptionList>
  309 + <h4 style={{ marginBottom: 16 }}>信息组</h4>
  310 + <Card type="inner" title="多层级信息组">
  311 + <DescriptionList size="small" style={{ marginBottom: 16 }} title="组名称">
  312 + <Description term="负责人">林东东</Description>
  313 + <Description term="角色码">1234567</Description>
  314 + <Description term="所属部门">XX公司 - YY</Description>
  315 + <Description term="过期时间">2017-08-08</Description>
  316 + <Description term="描述">
  317 + 这段描述很长很长很长很长很长很长很长很长很长很长很长很长很长很长...
  318 + </Description>
  319 + </DescriptionList>
  320 + <Divider style={{ margin: '16px 0' }} />
  321 + <DescriptionList size="small" style={{ marginBottom: 16 }} title="组名称" col="1">
  322 + <Description term="学名">
  323 + Citrullus lanatus (Thunb.) Matsum. et
  324 + Nakai一年生蔓生藤本;茎、枝粗壮,具明显的棱。卷须较粗..
  325 + </Description>
  326 + </DescriptionList>
  327 + <Divider style={{ margin: '16px 0' }} />
  328 + <DescriptionList size="small" title="组名称">
  329 + <Description term="负责人">付小小</Description>
  330 + <Description term="角色码">1234568</Description>
  331 + </DescriptionList>
  332 + </Card>
  333 + </Card>
  334 + <Card title="用户近半年来电记录" style={{ marginBottom: 24 }} bordered={false}>
  335 + <div className={styles.noData}>
  336 + <Icon type="frown-o" />
  337 + 暂无数据
  338 + </div>
  339 + </Card>
  340 + <Card
  341 + className={styles.tabsCard}
  342 + bordered={false}
  343 + tabList={operationTabList}
  344 + onTabChange={this.onOperationTabChange}
  345 + >
  346 + {contentList[operationkey]}
  347 + </Card>
  348 + </PageHeaderWrapper>
  349 + );
  350 + }
  351 +}
  352 +
  353 +export default AdvancedProfile;
  1 +import { queryBasicProfile, queryAdvancedProfile } from '@/services/api';
  2 +
  3 +export default {
  4 + namespace: 'profile',
  5 +
  6 + state: {
  7 + basicGoods: [],
  8 + advancedOperation1: [],
  9 + advancedOperation2: [],
  10 + advancedOperation3: [],
  11 + },
  12 +
  13 + effects: {
  14 + *fetchBasic(_, { call, put }) {
  15 + const response = yield call(queryBasicProfile);
  16 + yield put({
  17 + type: 'show',
  18 + payload: response,
  19 + });
  20 + },
  21 + *fetchAdvanced(_, { call, put }) {
  22 + const response = yield call(queryAdvancedProfile);
  23 + yield put({
  24 + type: 'show',
  25 + payload: response,
  26 + });
  27 + },
  28 + },
  29 +
  30 + reducers: {
  31 + show(state, { payload }) {
  32 + return {
  33 + ...state,
  34 + ...payload,
  35 + };
  36 + },
  37 + },
  38 +};
  1 +import { message } from 'antd';
  2 +import defaultSettings from '../defaultSettings';
  3 +
  4 +let lessNodesAppended;
  5 +const updateTheme = primaryColor => {
  6 + // Don't compile less in production!
  7 + if (APP_TYPE !== 'site') {
  8 + return;
  9 + }
  10 + // Determine if the component is remounted
  11 + if (!primaryColor) {
  12 + return;
  13 + }
  14 + const hideMessage = message.loading('正在编译主题!', 0);
  15 + function buildIt() {
  16 + if (!window.less) {
  17 + return;
  18 + }
  19 + setTimeout(() => {
  20 + window.less
  21 + .modifyVars({
  22 + '@primary-color': primaryColor,
  23 + })
  24 + .then(() => {
  25 + hideMessage();
  26 + })
  27 + .catch(() => {
  28 + message.error('Failed to update theme');
  29 + hideMessage();
  30 + });
  31 + }, 200);
  32 + }
  33 + if (!lessNodesAppended) {
  34 + // insert less.js and color.less
  35 + const lessStyleNode = document.createElement('link');
  36 + const lessConfigNode = document.createElement('script');
  37 + const lessScriptNode = document.createElement('script');
  38 + lessStyleNode.setAttribute('rel', 'stylesheet/less');
  39 + lessStyleNode.setAttribute('href', '/color.less');
  40 + lessConfigNode.innerHTML = `
  41 + window.less = {
  42 + async: true,
  43 + env: 'production',
  44 + javascriptEnabled: true
  45 + };
  46 + `;
  47 + lessScriptNode.src = 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js';
  48 + lessScriptNode.async = true;
  49 + lessScriptNode.onload = () => {
  50 + buildIt();
  51 + lessScriptNode.onload = null;
  52 + };
  53 + document.body.appendChild(lessStyleNode);
  54 + document.body.appendChild(lessConfigNode);
  55 + document.body.appendChild(lessScriptNode);
  56 + lessNodesAppended = true;
  57 + } else {
  58 + buildIt();
  59 + }
  60 +};
  61 +
  62 +const updateColorWeak = colorWeak => {
  63 + document.body.className = colorWeak ? 'colorWeak' : '';
  64 +};
  65 +
  66 +export default {
  67 + namespace: 'setting',
  68 + state: defaultSettings,
  69 + reducers: {
  70 + getSetting(state) {
  71 + const setting = {};
  72 + const urlParams = new URL(window.location.href);
  73 + Object.keys(state).forEach(key => {
  74 + if (urlParams.searchParams.has(key)) {
  75 + const value = urlParams.searchParams.get(key);
  76 + setting[key] = value === '1' ? true : value;
  77 + }
  78 + });
  79 + const { primaryColor, colorWeak } = setting;
  80 + if (state.primaryColor !== primaryColor) {
  81 + updateTheme(primaryColor);
  82 + }
  83 + updateColorWeak(colorWeak);
  84 + return {
  85 + ...state,
  86 + ...setting,
  87 + };
  88 + },
  89 + changeSetting(state, { payload }) {
  90 + const urlParams = new URL(window.location.href);
  91 + Object.keys(defaultSettings).forEach(key => {
  92 + if (urlParams.searchParams.has(key)) {
  93 + urlParams.searchParams.delete(key);
  94 + }
  95 + });
  96 + Object.keys(payload).forEach(key => {
  97 + if (key === 'collapse') {
  98 + return;
  99 + }
  100 + let value = payload[key];
  101 + if (value === true) {
  102 + value = 1;
  103 + }
  104 + if (defaultSettings[key] !== value) {
  105 + urlParams.searchParams.set(key, value);
  106 + }
  107 + });
  108 + const { primaryColor, colorWeak, contentWidth } = payload;
  109 + if (state.primaryColor !== primaryColor) {
  110 + updateTheme(primaryColor);
  111 + }
  112 + if (state.contentWidth !== contentWidth && window.dispatchEvent) {
  113 + window.dispatchEvent(new Event('resize'));
  114 + }
  115 + updateColorWeak(colorWeak);
  116 + window.history.replaceState(null, 'setting', urlParams.href);
  117 + return {
  118 + ...state,
  119 + ...payload,
  120 + };
  121 + },
  122 + },
  123 +};
注册登录 后发表评论