Browse Source

标签及标签组更新状态逻辑调整

zhanghe 7 years ago
parent
commit
6d7dfcc928

+ 1 - 0
package.json

@@ -77,6 +77,7 @@
     "mockjs": "^1.0.1-beta3",
     "prettier": "^1.9.0",
     "pro-download": "^1.0.0",
+    "react-markdown": "^3.1.4",
     "react-test-renderer": "^16.0.0",
     "redbox-react": "^1.3.2",
     "roadhog": "^1.3.1",

+ 4 - 0
src/common/menu.js

@@ -91,6 +91,10 @@ const menuData = [
       name: 'CMS用户',
       path: 'user',
     }]
+  },{
+    name: '使用说明',
+    icon: 'question-circle-o',
+    path: 'help',
   },
 ];
 

+ 7 - 4
src/common/router.js

@@ -36,6 +36,9 @@ export const getRouterData = (app) => {
     '/': {
       component: dynamicWrapper(app, ['user', 'login'], () => import('../layouts/BasicLayout')),
     },
+    '/help': {
+      component: dynamicWrapper(app, [], () => import('../routes/About')),
+    },
     '/dashboard': {
       component: dynamicWrapper(app, [], () => import('../routes/Dashboard')),
     },
@@ -161,10 +164,10 @@ export const getRouterData = (app) => {
     '/order': {
       component: dynamicWrapper(app, ['order/order'], () => import('../routes/Order/List')),
     },
-    // '/order/add': {
-    //   component: dynamicWrapper(app, ['order/detail'], () => import('../routes/Order/detail')),
-    //   name: '新建订单',
-    // },
+    '/order/add': {
+      component: dynamicWrapper(app, ['order/detail', 'terminal/terminal', 'mproduct/mproduct'], () => import('../routes/Order/Add')),
+      name: '新建订单',
+    },
     // '/order/edit/:id': {
     //   component: dynamicWrapper(app, ['order/detail'], () => import('../routes/Order/detail')),
     //   name: '修改订单',

+ 0 - 2
src/models/group/detail.js

@@ -44,7 +44,6 @@ export default {
       const { data, success } = yield call(create, { ...payload, status: Codes.CODE_NORMAL });
       if (success) {
         message.success('创建成功!');
-        yield put({ type: 'initState' });
         if (callback) callback();
       }
     },
@@ -52,7 +51,6 @@ export default {
       const { data, success } = yield call(update, payload);
       if (success) {
         message.success('修改成功!');
-        yield put({ type: 'initState' });
         if (callback) callback();
       }
     }

+ 27 - 20
src/models/order/detail.js

@@ -9,8 +9,9 @@ export default {
     filters: {},
     operType: 'create',
     currentItem: {},
-    modalVisible: false,
     itemLoading: false,
+    terminalModalShow: false,
+    productModalShow: false,
   },
 
   subscriptions: {
@@ -38,14 +39,14 @@ export default {
     * create ({ payload, callback }, { call, put }) {
       const { data, success } = yield call(create, { ...payload });
       if (success) {
-        yield put({ type: 'clearPage' });
+        yield put({ type: 'cacheCleaner' });
         if (callback) callback();
       }
     },
     * update ({ payload, callback }, { call, put }) {
       const { data, success } = yield call(update, payload);
       if (success) {
-        yield put({ type: 'clearPage' });
+        yield put({ type: 'cacheCleaner' });
         if (callback) callback();
       }
     }
@@ -55,33 +56,39 @@ export default {
     changeLoading(state, { payload }) {
       return { ...state, ...payload };
     },
-
     querySuccess(state, { payload }) {
       return { ...state, currentItem: payload };
     },
-
     saveFilters(state, { payload: filters }) {
       return { ...state, filters };
     },
-
-    showModal(state) {
-      return { ...state, modalVisible: true };
+    showTerminalModal(state, action) {
+      return { ...state, ...action.payload, terminalModalShow: true };
     },
-
-    hideModal(state) {
-      return { ...state, modalVisible: false };
+    hideTerminalModal(state, action) {
+      return { ...state, ...action.payload, terminalModalShow: false };
     },
-
-    saveOperType(state, { payload }) {
-      return { ...state, ...payload };
+    savePickedTerminal(state, action) {
+      return {
+        ...state,
+        currentItem: { ...state.currentItem, ...action.payload },
+        terminalModalShow: false,
+      };
     },
-
-    saveSortResult(state, { payload: { wareList } }) {
-      const currentItem = { ...state.currentItem, wareList };
-      return { ...state, modalVisible: false, currentItem };
+    showProductModal(state, action) {
+      return { ...state, ...action.payload, productModalShow: true };
     },
-
-    clearPage(state) {
+    hideProductModal(state, action) {
+      return { ...state, ...action.payload, productModalShow: false };
+    },
+    savePickedProducts(state, action) {
+      return {
+        ...state,
+        currentItem: { goods: action.payload },
+        productModalShow: false,
+      };
+    },
+    cacheCleaner(state) {
       return { ...state, currentItem: {}, itemLoading: false };
     }
   }

+ 2 - 2
src/models/tag/tag.js

@@ -3,7 +3,7 @@ import modelExtend from 'dva-model-extend';
 import queryString from 'query-string';
 import { message } from 'antd';
 import { pageModel } from '../common';
-import config from '../../utils/config';
+import { pageSize } from '../../utils/config';
 import { checkSearchParams } from '../../utils/utils';
 
 export default modelExtend(pageModel, {
@@ -36,7 +36,7 @@ export default modelExtend(pageModel, {
             list: data.list,
             pagination: {
               current: Number(payload.pageNo) || 1,
-              pageSize: Number(payload.pageSize) || config.pageSize,
+              pageSize: Number(payload.pageSize) || pageSize,
               total: data.totalSize,
             }
           }

+ 11 - 0
src/routes/About/index.js

@@ -0,0 +1,11 @@
+import React, { PureComponent } from 'react';
+import { Card, Icon } from 'antd';
+
+export default class About extends PureComponent {
+  render() {
+    return (
+      <Card title="使用说明">
+      </Card>
+    );
+  }
+}

+ 4 - 4
src/routes/Dashboard/index.js

@@ -88,7 +88,7 @@ export default class Dashboard extends Component {
               action={<Tooltip title="指标说明"><Icon type="info-circle-o" /></Tooltip>}
               total={yuan(1247238957)}
               footer={<Field label="日均销售额" value={`¥${numeral(23343).format('0,0')}`} />}
-              contentHeigth={46}
+              contentHeight={46}
             >
               <Trend flag="up" style={{ marginRight: 16 }}>
                 周同比<span className={styles.trendText}>12%</span>
@@ -105,7 +105,7 @@ export default class Dashboard extends Component {
               action={<Tooltip title="指标说明"><Icon type="info-circle-o" /></Tooltip>}
               total={100000}
               footer={<Field label="日订单量" value={5000} />}
-              contentHeigth={46}
+              contentHeight={46}
             >
               <MiniBar
                 height={46}
@@ -120,7 +120,7 @@ export default class Dashboard extends Component {
               action={<Tooltip title="指标说明"><Icon type="info-circle-o" /></Tooltip>}
               total={4000}
               footer={<Field label="日增长量" value={200} />}
-              contentHeigth={46}
+              contentHeight={46}
             >
               <MiniArea
                 color="#975FE4"
@@ -136,7 +136,7 @@ export default class Dashboard extends Component {
               action={<Tooltip title="指标说明"><Icon type="info-circle-o" /></Tooltip>}
               total={`2037个`}
               footer={<Field label="日活增长" value={200} />}
-              contentHeigth={46}
+              contentHeight={46}
             >
               <MiniArea
                 line

+ 227 - 0
src/routes/Order/Add/index.js

@@ -0,0 +1,227 @@
+import React, { Component } from 'react';
+import { Card, List, Form, Table, Button, Input } from 'antd';
+import { connect } from 'dva';
+import { routerRedux } from 'dva/router';
+
+import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
+import FooterToolbar from '../../../components/FooterToolbar';
+import TerminalSelectModal from './terminal';
+import MerchantProductSelectModal from './product';
+// import GoodsSelectModal from './product';
+import { pageSize } from '../../../utils/config';
+
+@Form.create()
+@connect(state => ({
+  terminal: state.terminal,
+  orderItem: state.orderDetail,
+  mproduct: state.mproduct,
+}))
+export default class CreateOrder extends Component {
+
+  // 终端选择弹框相关的回调方法
+  handleTerminalSelectBtnClick = () => {
+    this.props.dispatch({ type: 'orderDetail/showTerminalModal' });
+    this.props.dispatch({
+      type: 'terminal/query',
+      payload: {
+        pageNo: 1,
+        pageSize,
+      }
+    });
+  }
+
+  handleTerminalModalOk = (record) => {
+    this.props.dispatch({
+      type: 'orderDetail/savePickedTerminal',
+      payload: {
+        userCode: record.code,
+        userName: record.name,
+        campusName: record.campusName,
+        merchantName: record.merchantName,
+        merchantId: record.merchantId,
+      }
+    });
+  }
+
+  handleTerminalModalCancel = () => {
+    this.props.dispatch({ type: 'orderDetail/hideTerminalModal' });
+  }
+
+  handleTerminalModalSearch = () => {
+
+  }
+
+  handleTerminalModalTableChange = () => {
+
+  }
+
+  // 产品选择弹框相关的回调方法
+  handleProductSelectBtnClick = () => {
+    const { orderItem } = this.props;
+    const { currentItem } = orderItem;
+    const { merchantId } = currentItem;
+    this.props.dispatch({ type: 'orderDetail/showProductModal' });
+    this.props.dispatch({
+      type: 'mproduct/query',
+      payload: {
+        pageNo: 1,
+        pageSize,
+        merchantId,
+      },
+    });
+  }
+
+  handleProductModalSearch = () => {
+
+  }
+
+  handleProductModalTableChange = () => {
+
+  }
+
+  handleProductModalOk = (data) => {
+    this.props.dispatch({
+      type: 'orderDetail/savePickedProducts',
+      payload: data,
+    });
+  }
+
+  handleProductModalCancel = () => {
+    this.props.dispatch({ type: 'orderDetail/hideProductModal' });
+  }
+
+  render() {
+    const { orderItem, terminal, mproduct, form } = this.props;
+    const { terminalModalShow, productModalShow, currentItem } = orderItem;
+    const { userCode, userName, campusName, merchantName, merchantId, goods } = currentItem;
+
+    const formItemLayout = {
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 2 },
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 12 },
+        md: { span: 22 },
+      },
+    };
+
+    const columns = [{
+      title: '产品图片',
+      dataIndex: 'coverUrl',
+      key: 0,
+    },{
+      title: '产品编号',
+      dataIndex: 'code',
+      key: 1,
+    },{
+      title: '产品名称',
+      dataIndex: 'name',
+      key: 2,
+    },{
+      title: '产品类型',
+      dataIndex: 'type',
+      key: 3,
+    },{
+      title: '产品价格',
+      dataIndex: 'goods',
+      key: 4,
+    },{
+      title: '优惠价格',
+      dataIndex: 'adjustPrice',
+      key: 5,
+    },{
+      title: '实际售价',
+      dataIndex: 'finalPrice',
+      key: 6,
+    },{
+      title: '数量',
+      dataIndex: 'quantity',
+      key: 7,
+    },{
+      title: '单位',
+      dataIndex: 'chargeUnit',
+      key: 8,
+    }];
+
+    return (
+      <PageHeaderLayout>
+        <Card>
+          <Form>
+            <Form.Item label="选择终端" {...formItemLayout}>
+              <Button onClick={this.handleTerminalSelectBtnClick} type="primary" size="small" icon="plus-circle-o">选择</Button>
+              {userCode ?
+                <List
+                  size="small"
+                  bordered
+                  style={{ width: '50%' }}
+                  dataSource={[`终端编号: ${userCode}`, `终端名称: ${userName}`, `所属校区: ${campusName}`, `所属渠道: ${merchantName}`]}
+                  renderItem={item => <List.Item>{item}</List.Item>}
+                />
+              : null}
+            </Form.Item>
+            <Form.Item label="收货地址" {...formItemLayout}>
+              <Input.TextArea style={{ width: "50%" }} placeholder="请填写或使用默认地址"/>
+            </Form.Item>
+            <Form.Item label="添加备注" {...formItemLayout}>
+              <Input.TextArea style={{ width: "50%" }} placeholder="请输入(选填)" />
+            </Form.Item>
+            <Form.Item label="添加商品" {...formItemLayout}>
+              <Button onClick={this.handleProductSelectBtnClick} disabled={merchantId ? false : true} type="primary" size="small" icon="plus-circle-o">添加</Button>
+              <Table
+                rowKey={record => record.id}
+                pagination={false}
+                columns={columns}
+                dataSource={goods}
+              />
+            </Form.Item>
+          </Form>
+          {/*终端选择弹框*/}
+          <TerminalSelectModal
+            rowKeyName="id"
+            modalVisible={terminalModalShow}
+            style={{ top: 20 }}
+            width={660}
+            onOk={this.handleTerminalModalOk}
+            onCancel={this.handleTerminalModalCancel}
+            onSearch={this.handleTerminalModalSearch}
+            fsTableDataSource={terminal.list || []}
+            fsTableLoading={terminal.listLoading}
+            fsTablePagination={terminal.pagination}
+            fsTableOnChange={this.handleTerminalModalTableChange}
+          />
+          <MerchantProductSelectModal
+            rowKeyName="id"
+            modalVisible={productModalShow}
+            selTableData={goods || []}
+            style={{ top: 20 }}
+            width={660}
+            fsTableDataSource={mproduct.list}
+            fsTableLoading={mproduct.listLoading}
+            fsTablePagination={mproduct.pagination}
+            onOk={this.handleProductModalOk}
+            onCancel={this.handleProductModalCancel}
+            onSearch={this.handleProductModalSearch}
+            fsTableOnChange={this.handleProductModalTableChange}
+          />
+          {/*
+          <GoodsSelectModal
+            style={{ top: 20 }}
+            width={800}
+            modalVisible={productModalShow}
+            onOk={this.handleProductModalOk}
+            onCancel={this.handleProductModalCancel}
+            pagination={mproduct.pagination}
+            dataSource={mproduct.list}
+          />
+          */}
+        </Card>
+        <FooterToolbar>
+          <Button>取消</Button>
+          <Button type="primary">完成</Button>
+        </FooterToolbar>
+      </PageHeaderLayout>
+    );
+  }
+}

+ 136 - 0
src/routes/Order/Add/product.js

@@ -0,0 +1,136 @@
+import React, { PureComponent } from 'react';
+import SelectModal from '../../../components/SelectModal';
+import { productType } from '../../../utils/config';
+
+export default class MerchantProductSelectModal extends PureComponent {
+
+  render() {
+    const { selTableData, modalVisible, rowKeyName, onCancel, onOk, onSearch, ...fsTableOpts } = this.props;
+
+    const modalProps = {
+      title: '选则商品',
+      maskClosable: false,
+      visible: modalVisible,
+      onCancel,
+      onOk,
+    };
+
+    const searchProps = {
+      searchField: 'name',
+      searchKeyWord: '',
+      searchSize: 'default',
+      searchSelect: true,
+      searchSelectOptions: [{
+        value: 'name', name: '产品名称', mode: 'input',
+      },{
+        value: 'code', name: '产品编号', mode: 'input',
+      }],
+      searchSelectProps: {
+        defaultValue: 'name',
+      },
+      onSearch: (value) => {
+        onSearch(value);
+      },
+    };
+
+    const selTableProps = {
+      operDel: true,
+      tablePagination: false,
+      tableDataSource: selTableData,
+      rowKeyName: rowKeyName,
+      tableColumns: [{
+        title: '产品编号',
+        dataIndex: 'code',
+        key: 1,
+        width: '27%',
+      },{
+        title: '产品名称',
+        dataIndex: 'name',
+        key: 2,
+        width: '28%'
+      },{
+        title: '产品类型',
+        dataIndex: 'type',
+        key: 3,
+        render: (text, record) => productType[text],
+        width: '15%'
+      },{
+        title: '渠道名称',
+        dataIndex: 'merchantName',
+        key: 4,
+        width: '15%',
+      }],
+    };
+
+    const fsTableProps = {
+      fsTableColumns: [{
+        title: '产品编号',
+        dataIndex: 'code',
+        key: 1,
+        width: '27%',
+      },{
+        title: '产品名称',
+        dataIndex: 'name',
+        key: 2,
+        width: '28%',
+      },{
+        title: '产品类型',
+        dataIndex: 'type',
+        key: 3,
+        render: (text, record) => productType[text],
+        width: '15%',
+      },{
+        title: '渠道名称',
+        dataIndex: 'merchantName',
+        key: 4,
+        width: '15%',
+      }],
+      ...fsTableOpts,
+    }
+
+    return (
+      <SelectModal
+        mode="multiple"
+        { ...searchProps }
+        { ...modalProps }
+        { ...selTableProps }
+        { ...fsTableProps }
+      />
+    );
+  }
+}
+
+// import React, { PureComponent } from 'react';
+// import { Modal, List, Collapse, Card, Avatar, Input } from 'antd';
+//
+// const { Panel } = Collapse;
+// export default class GoodsSelectModal extends PureComponent {
+//   render() {
+//     const { modalVisible, onCancel, onOk, pagination, dataSource, ...restProps } = this.props;
+//     return (
+//       <Modal
+//         title="添加商品"
+//         visible={modalVisible}
+//         onOk={onOk}
+//         onCancel={onCancel}
+//         {...restProps}
+//       >
+//         <List
+//           size="large"
+//           bordered
+//           grid={{ gutter: 16, column: 2 }}
+//           pagination={pagination}
+//           dataSource={dataSource}
+//           renderItem={item =>
+//             <List.Item
+//             >
+//               <Card title={item.code}>
+//
+//               </Card>
+//             </List.Item>
+//           }
+//         />
+//       </Modal>
+//     );
+//   }
+// }

+ 76 - 0
src/routes/Order/Add/terminal.js

@@ -0,0 +1,76 @@
+import React, { PureComponent } from 'react';
+import SelectModal from '../../../components/SelectModal';
+import { Codes } from '../../../utils/config';
+
+export default class TerminalSelectModal extends PureComponent {
+
+  render() {
+    const {
+      modalVisible,
+      onCancel,
+      onOk,
+      onSearch,
+      ...fsTableOpts
+    } = this.props;
+
+    const modalProps = {
+      title: '选择终端',
+      maskClosable: false,
+      visible: modalVisible,
+      onCancel,
+      onOk,
+    };
+
+    const searchProps = {
+      searchField: 'name',
+      searchKeyWord: '',
+      searchSize: 'default',
+      searchSelect: true,
+      searchSelectOptions: [{
+        value: 'name', name: '终端名称', mode: 'input',
+      },{
+        value: 'code', name: '终端编号', mode: 'input',
+      }],
+      searchSelectProps: {
+        defaultValue: 'name',
+      },
+      onSearch: (value) => {
+        onSearch(value);
+      },
+    };
+
+    const fsTableProps = {
+      fsTableColumns: [{
+        title: '终端编号',
+        dataIndex: 'code',
+        key: 1,
+        width: '25%',
+      },{
+        title: '终端名称',
+        dataIndex: 'name',
+        key: 2,
+        width: '15%',
+      },{
+        title: '校区名称',
+        dataIndex: 'campusName',
+        key: 3,
+        width: '30%',
+      },{
+        title: '渠道名称',
+        dataIndex: 'merchantName',
+        key: 4,
+        width: '15%',
+      }],
+      ...fsTableOpts,
+    }
+
+    return (
+      <SelectModal
+        mode="single"
+        { ...searchProps }
+        { ...fsTableProps }
+        { ...modalProps }
+      />
+    );
+  }
+}

+ 22 - 18
src/routes/Order/List/table.js

@@ -3,9 +3,8 @@ import PropTypes from 'prop-types';
 import moment from 'moment';
 import classnames from 'classnames';
 import queryString from 'query-string';
-import { Modal, DatePicker, Table, Menu, Icon, Badge } from 'antd';
+import { Divider, Modal, DatePicker, Table, Menu, Icon, Badge, Button } from 'antd';
 import AnimTableBody from '../../../components/Animation/AnimTableBody';
-import DropOption from '../../../components/DropOption';
 import styles from './table.less';
 import { orderStatuses, Codes } from '../../../utils/config';
 
@@ -85,27 +84,34 @@ export default class TableList extends PureComponent {
           // onDeleteItem(record.id)
         },
       });
-    } else if (e.key === '4') {
-      Modal.confirm({
-        title: '你确定要恢复该订单?',
-        onOk () {
-          console.log('recovering...');
-        }
-      });
     }
   }
 
   // 根据订单状态确定下拉菜单的选项
-  renderOperationDropMenu = (record) => {
-    switch (Number(record.status)) {
+  renderOperationButton = (record) => {
+    switch (record.status) {
       case Codes.CODE_PAID:
-        return [{key: '1', name: '查看'}];
+        return (
+          <div>
+            <Button type="primary" size="small">查看</Button>
+          </div>
+        );
         break;
       case Codes.CODE_UNPAID:
-        return [{key: '1', name: '查看'}, {key: '2', name: '修改'}, {key: '3', name: '作废'}];
+        return (
+          <div>
+            <a>编辑</a>
+            <Divider type="vertical" />
+            <a>支付</a>
+          </div>
+        );
         break;
       case Codes.CODE_CANCEL:
-        return [{key: '1', name: '查看'}, {key: '4', name: '恢复'}];
+        return (
+          <div>
+            <a>查看</a>
+          </div>
+        );
         break;
       default:
         break;
@@ -176,10 +182,7 @@ export default class TableList extends PureComponent {
       title: '操作',
       dataIndex: 'operation',
       key: 'operation',
-      render: (text, record) => (
-        <DropOption onMenuClick={e => this.handleMenuClick(record, e)} menuOptions={this.renderOperationDropMenu(record)} />
-      ),
-      fixed: 'right',
+      render: (text, record) => this.renderOperationButton(record),
     }];
 
     // 数据table列表表头的筛选按钮点击重置后status值为空,此时删除该参数
@@ -200,6 +203,7 @@ export default class TableList extends PureComponent {
         { ...tableProps }
         columns={columns}
         className={classnames({ [styles.table]: true, [styles.motion]: true })}
+        scroll={{ x: 1200 }}
         rowKey={record => record.id}
         components={{
           body: { wrapper: AnimationTableBody }

+ 2 - 2
src/routes/Resource/video/table.js

@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
 import moment from 'moment';
 import classnames from 'classnames';
 import queryString from 'query-string';
-import { Popover, Modal, Table, Menu, Icon, Badge } from 'antd';
+import { Divider, Modal, Table, Menu, Icon, Badge } from 'antd';
 import AnimTableBody from '../../../components/Animation/AnimTableBody';
 import { statuses, quality, Codes } from '../../../utils/config'
 import styles from './table.less';
@@ -65,7 +65,7 @@ export default class TableList extends PureComponent {
       render: (text, record) => (
         <div>
           <a onClick={() => onPlayVideo(record)}>播放</a>
-          <span className={styles.splitLine} />
+          <Divider type="vertical" />
           <a onClick={() => this.handleDeleteItem(record)}>{record.status === Codes.CODE_NORMAL ? '删除' : '恢复'}</a>
         </div>
       )

+ 0 - 8
src/routes/Resource/video/table.less

@@ -76,11 +76,3 @@
     }
   }
 }
-
-.splitLine {
-  background: @border-color-split;
-  display: inline-block;
-  margin: 0 8px;
-  width: 1px;
-  height: 12px;
-}

+ 31 - 27
src/routes/Tag/Edit/index.js

@@ -8,10 +8,6 @@ import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
 import ItemSortModal from './modal';
 import { Codes, itemStatuses, tagType } from '../../../utils/config';
 
-const FormItem = Form.Item;
-const Option = Select.Option;
-const RadioGroup = Radio.Group;
-
 @Form.create()
 @connect(state => ({
   tagDetail: state.tagDetail,
@@ -29,7 +25,6 @@ export default class TagDetail extends PureComponent {
       payload: {
         pageNo: 1,
         pageSize: 1000,
-        status: Codes.CODE_NORMAL,
       }
     });
   }
@@ -59,7 +54,6 @@ export default class TagDetail extends PureComponent {
       form: {
         validateFields,
         getFieldsValue,
-        resetFields
       },
       tagDetail: {
         operType,
@@ -68,11 +62,22 @@ export default class TagDetail extends PureComponent {
       }
     } = this.props;
     validateFields((errors) => {
-      if (errors) { return; }
-      const data = {
-        ...currentItem,
-        ...getFieldsValue(),
-      };
+      if (errors) return;
+      let data = {};
+      if (operType === 'create') {
+        data = { ...getFieldsValue(), status: Codes.CODE_NORMAL };
+      } else if (operType === 'update') {
+        const { id, groupId, itemList, name, type, status } = currentItem;
+        data = {
+          id,
+          groupId,
+          name,
+          type,
+          status,
+          itemList: (itemList || []).map(item => item.id),
+          ...getFieldsValue(),
+        };
+      }
       dispatch({
         type: `tagDetail/${operType}`,
         payload: data,
@@ -85,7 +90,6 @@ export default class TagDetail extends PureComponent {
           );
         }
       })
-      resetFields();
     });
   }
 
@@ -149,23 +153,23 @@ export default class TagDetail extends PureComponent {
         <Spin spinning={itemLoading}>
           <Card>
             <Form layout="horizontal" onSubmit={this.handlePageSubmit}>
-              <FormItem label="标签名称:" hasFeedback {...formItemLayout}>
+              <Form.Item label="标签名称:" hasFeedback {...formItemLayout}>
                 {getFieldDecorator('name', {
                   rules: [{ required: true, type: 'string', message: "名称为必填项!" }],
                   initialValue: name,
                 })(<Input />)}
-              </FormItem>
-              <FormItem label="标签类型:" hasFeedback {...formItemLayout}>
+              </Form.Item>
+              <Form.Item label="标签类型:" hasFeedback {...formItemLayout}>
                 {getFieldDecorator('type', {
                   rules: [{ required: true, type: 'string', message: "编号为必填项!" }],
                   initialValue: type || Codes.CODE_COURSE,
                 })(
-                  <RadioGroup>
+                  <Radio.Group>
                     {Object.keys(tagType).map(key => <Radio value={key} key={key}>{tagType[key]}</Radio>)}
-                  </RadioGroup>
+                  </Radio.Group>
                 )}
-              </FormItem>
-              <FormItem label="所属标签组" hasFeedback {...formItemLayout}>
+              </Form.Item>
+              <Form.Item label="所属标签组" hasFeedback {...formItemLayout}>
                 {getFieldDecorator('groupId', {
                   rules: [{ required: true, type: 'string', message: "标签组为必选项!" }],
                   initialValue: groupId,
@@ -177,14 +181,14 @@ export default class TagDetail extends PureComponent {
                     optionFilterProp="children"
                     filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                   >
-                    {list.map(item => <Option value={item.id} key={item.id}>{`${item.code}/${item.name}`}</Option>)}
+                    {list.map(item => <Select.Option value={item.id} key={item.id}>{`${item.code}/${item.name}`}</Select.Option>)}
                   </Select>
                 )}
-              </FormItem>
-              <FormItem label="商品排序" {...formItemLayout}>
+              </Form.Item>
+              <Form.Item label="商品排序" {...formItemLayout}>
                 <Button onClick={this.handleModalShow} disabled={!(itemList || []).length} type="primary" size="small" icon="edit">排序</Button>
-              </FormItem>
-              <FormItem wrapperCol={{ offset: 7, span: 12 }}>
+              </Form.Item>
+              <Form.Item wrapperCol={{ offset: 7, span: 12 }}>
                 <Table
                   locale={{
                     emptyText: <span style={{ color: "#C6D0D6" }}>&nbsp;&nbsp;<Icon type="frown-o"/>
@@ -196,11 +200,11 @@ export default class TagDetail extends PureComponent {
                   bordered
                   pagination={false}
                 />
-              </FormItem>
-              <FormItem {...submitFormLayout} style={{ marginTop: 32 }}>
+              </Form.Item>
+              <Form.Item {...submitFormLayout} style={{ marginTop: 32 }}>
                 <Button onClick={this.handlePageCancel}>取消</Button>
                 <Button type="primary" style={{ marginLeft: 35 }} htmlType="submit">提交</Button>
-              </FormItem>
+              </Form.Item>
             </Form>
             <ItemSortModal
               itemList={itemList || []}

+ 6 - 6
src/routes/Tag/List/index.js

@@ -120,10 +120,10 @@ export default class Tag extends PureComponent {
           })
         );
       },
-      onDeleteItem: (id) => {
+      onDeleteItem: (params) => {
         dispatch({
-          type: 'tag/delete',
-          payload: id,
+          type: 'tagModel/delete',
+          payload: params,
           callback: () => {
             dispatch(
               routerRedux.push({
@@ -134,10 +134,10 @@ export default class Tag extends PureComponent {
           }
         });
       },
-      onRecoverItem: (payload) => {
+      onRecoverItem: (params) => {
         dispatch({
-          type: 'tag/recover',
-          payload,
+          type: 'tagModel/recover',
+          payload: params,
           callback: () => {
             dispatch(
               routerRedux.push({

+ 32 - 16
src/routes/TagGroup/Edit/index.js

@@ -31,7 +31,7 @@ export default class GroupDetail extends PureComponent {
       payload: {
         pageNo: 1,
         pageSize: 1000,
-        status: Codes.CODE_NORMAL
+        // status: Codes.CODE_NORMAL 不对状态进行过滤
       }
     });
   }
@@ -61,7 +61,6 @@ export default class GroupDetail extends PureComponent {
       form: {
         validateFields,
         getFieldsValue,
-        resetFields
       },
       groupDetail: {
         operType,
@@ -70,15 +69,32 @@ export default class GroupDetail extends PureComponent {
       }
     } = this.props;
     validateFields((errors) => {
-      if (errors) { return; }
-      const data = {
-        ...currentItem,
-        ...getFieldsValue(),
-      };
+      if (errors) return;
+
+      let data = {};
+      if (operType === 'create') {
+        data = {
+          ...getFieldsValue(),
+          status: Codes.CODE_NORMAL
+        };
+      } else if (operType === 'update') {
+        const { id, merchantId, status, tagList, name, code } = currentItem;
+        data = {
+          id,
+          merchantId,
+          status,
+          name,
+          code,
+          tagList: (tagList || []).map(item => item.id),
+          ...getFieldsValue(),
+        };
+      }
+
       dispatch({
         type: `groupDetail/${operType}`,
         payload: data,
         callback: () => {
+          dispatch({ type: 'groupDetail/initState' });
           dispatch(
             routerRedux.push({
               pathname: '/tag/tagGroup',
@@ -87,13 +103,12 @@ export default class GroupDetail extends PureComponent {
           );
         }
       })
-      resetFields();
     });
   }
 
   handlePageCancel = () => {
     const { dispatch, groupDetail: { filters } } = this.props;
-    dispatch({ type: 'groupDetail/clearPage' });
+    dispatch({ type: 'groupDetail/initState' });
     dispatch(
       routerRedux.push({
         pathname: '/tag/tagGroup',
@@ -104,8 +119,8 @@ export default class GroupDetail extends PureComponent {
 
   render() {
     const { dispatch, form: { getFieldDecorator }, groupDetail, merchant } = this.props;
-    const { itemLoading, currentItem, filters, modalVisible } = groupDetail;
-    const { tagList = [], name, code, merchantId } = currentItem;
+    const { itemLoading, currentItem, filters, modalVisible, operType } = groupDetail;
+    const { tagList, name, code, merchantId } = currentItem;
     const { list } = merchant;
 
     const tagTableColumns = [{
@@ -155,13 +170,13 @@ export default class GroupDetail extends PureComponent {
                 {getFieldDecorator('code', {
                   rules: [{ required: true, type: 'string', message: "编号为必填项!" }],
                   initialValue: code,
-                })(<Input />)}
+                })(<Input placeholder="请输入" />)}
               </FormItem>
               <FormItem label="标签组名称:" hasFeedback {...formItemLayout}>
                 {getFieldDecorator('name', {
                   rules: [{ required: true, type: 'string', message: "名称为必填项!" }],
                   initialValue: name,
-                })(<Input />)}
+                })(<Input placeholder="请输入" />)}
               </FormItem>
               <FormItem label="渠道平台" hasFeedback {...formItemLayout}>
                 {getFieldDecorator('merchantId', {
@@ -173,6 +188,7 @@ export default class GroupDetail extends PureComponent {
                     allowClear
                     placeholder="请输入渠道编号或者名称进行筛选"
                     optionFilterProp="children"
+                    disabled={operType === 'update' ? true : false}
                     filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                   >
                     {list.map(item => <Option value={item.id} key={item.id}>{`${item.code}/${item.name}`}</Option>)}
@@ -180,14 +196,14 @@ export default class GroupDetail extends PureComponent {
                 )}
               </FormItem>
               <FormItem label="标签排序" {...formItemLayout}>
-                <Button onClick={this.handleModalShow} disabled={!tagList.length} type="primary" size="small" icon="edit">排序</Button>
+                <Button onClick={this.handleModalShow} disabled={!tagList || !tagList.length} type="primary" size="small" icon="edit">排序</Button>
               </FormItem>
               <FormItem wrapperCol={{ offset: 7, span: 12 }}>
                 <Table
                   locale={{
                     emptyText: <span style={{ color: "#C6D0D6" }}>&nbsp;&nbsp;<Icon type="frown-o"/>该标签组下不包含任何标签,无法排序,请先去关联标签吧!</span>
                   }}
-                  dataSource={tagList}
+                  dataSource={tagList || []}
                   columns={tagTableColumns}
                   rowKey={record => record.id}
                   bordered
@@ -200,7 +216,7 @@ export default class GroupDetail extends PureComponent {
               </FormItem>
             </Form>
             <TagSortModal
-              tagList={tagList}
+              tagList={tagList || []}
               rowKeyName="id"
               modalVisible={modalVisible}
               onCancel={this.handleModalCancel}

+ 2 - 1
src/routes/TagGroup/List/index.js

@@ -11,7 +11,8 @@ import { Codes } from '../../../utils/config';
 
 @connect(state => ({
   group: state.group,
-  merchant: state.merchant, }))
+  merchant: state.merchant
+}))
 export default class TagGroup extends PureComponent {
   static propTypes = {
     group: PropTypes.object,

+ 4 - 4
src/routes/Ware/List/index.js

@@ -93,10 +93,10 @@ export default class Ware extends PureComponent {
           })
         );
       },
-      onDeleteItem: (id) => {
+      onDeleteItem: (params) => {
         dispatch({
           type: 'ware/delete',
-          payload: id,
+          payload: params,
           callback: () => {
             dispatch(
               routerRedux.push({
@@ -107,10 +107,10 @@ export default class Ware extends PureComponent {
           }
         });
       },
-      onRecoverItem: (payload) => {
+      onRecoverItem: (params) => {
         dispatch({
           type: 'ware/recover',
-          payload,
+          payload: params,
           callback: () => {
             dispatch(
               routerRedux.push({

+ 1 - 1
src/routes/Ware/List/table.js

@@ -13,7 +13,7 @@ export default class TableList extends PureComponent {
   handleOperateItem = (record) => {
     const { onDeleteItem, onRecoverItem } = this.props;
     Modal.confirm({
-      title: `您确定要${record.status === Codes.CODE_NORMAL ? '删除' : '恢复'}该条记录?`,
+      title: `您确定要${record.status === Codes.CODE_NORMAL ? '删除' : '恢复'}该课件?`,
       onOk () {
         if (record.status === Codes.CODE_NORMAL) {
           onDeleteItem({id: record.id});

+ 4 - 4
src/services/tag.js

@@ -7,7 +7,7 @@ export async function query(params) {
 }
 
 export async function queryOne({ id }) {
-  return request(`${tag.replace('/:id', `/${id}`)}`);
+  return request(`${tag}/${id}`);
 }
 
 export async function create(params) {
@@ -15,7 +15,7 @@ export async function create(params) {
     method: 'POST',
     body: JSON.stringify(params),
   };
-  return request(`${tag.replace('/:id', '')}`, options);
+  return request(`${tag}`, options);
 }
 
 export async function update(params) {
@@ -23,10 +23,10 @@ export async function update(params) {
     method: 'PUT',
     body: JSON.stringify(params),
   };
-  return request(`${tag.replace('/:id', '')}`, options);
+  return request(`${tag}`, options);
 }
 
 export async function remove({ id }) {
   const options = { method: 'DELETE' }
-  return request(`${tag.replace('/:id', `/${id}`)}`, options);
+  return request(`${tag}/${id}`, options);
 }

+ 4 - 4
src/services/ware.js

@@ -7,7 +7,7 @@ export async function query(params) {
 }
 
 export async function queryOne({ id }) {
-  return request(`${ware.replace('/:id', `/${id}`)}`);
+  return request(`${ware}/${id}`);
 }
 
 export async function create(params) {
@@ -15,7 +15,7 @@ export async function create(params) {
     method: 'POST',
     body: JSON.stringify(params),
   };
-  return request(`${ware.replace('/:id', '')}`, options);
+  return request(`${ware}`, options);
 }
 
 export async function update(params) {
@@ -23,10 +23,10 @@ export async function update(params) {
     method: 'PUT',
     body: JSON.stringify(params),
   };
-  return request(`${ware.replace('/:id', '')}`, options);
+  return request(`${ware}`, options);
 }
 
 export async function remove({ id }) {
   const options = { method: 'DELETE' }
-  return request(`${ware.replace('/:id', `/${id}`)}`, options);
+  return request(`${ware}/${id}`, options);
 }

+ 2 - 2
src/utils/api.js

@@ -19,10 +19,10 @@ module.exports = {
   groups: `${config.apiHost}/group/list`,
   group: `${config.apiHost}/group`,
   tags: `${config.apiHost}/tag/list`,
-  tag: `${config.apiHost}/tag/:id`,
+  tag: `${config.apiHost}/tag`,
   // 课件/课
   wares: `${config.apiHost}/ware/list`,
-  ware: `${config.apiHost}/ware/:id`,
+  ware: `${config.apiHost}/ware`,
   lessons: `${config.apiHost}/lesson/list`,
   lesson: `${config.apiHost}/lesson/:id`,
   // 产品接口,包括:课程、周边、课程包