Преглед изворни кода

:art: 课件编辑页内资源列表支持点击编号跳转

zhanghe пре 6 година
родитељ
комит
36f53229bd
2 измењених фајлова са 50 додато и 3 уклоњено
  1. 35 0
      src/routes/Product/Courseware/CoursewareCreate.js
  2. 15 3
      src/utils/utils.js

+ 35 - 0
src/routes/Product/Courseware/CoursewareCreate.js

@@ -134,6 +134,40 @@ export default class CoursewareCreatePage extends Component {
       payload: rows,
     });
   };
+  /**
+   * 点击跳转到资源编辑页面
+   * @param record
+   */
+  handleResourceEdit = (record) => {
+    const { type, id } = record;
+    if (Hotax.RESOURCE_AUDIOBOOK === type) {
+      const genAudioBook = (obj = {}) => {
+        const { code, name, img, audio, status } = obj;
+        return {
+          code,
+          name,
+          status,
+          id: obj.id,
+          img: img || {},
+          audio: audio || {},
+        };
+      };
+      this.props.dispatch(routerRedux.push({
+        pathname: `/resource/audiobook-edit/${id}`,
+        state: { audioBookItem: genAudioBook(record) },
+      }));
+    } else if (Hotax.RESOURCE_VIDEO === type) {
+      this.props.dispatch(routerRedux.push({
+        pathname: `/resource/video-edit/${id}`,
+        state: { ...record },
+      }));
+    } else if (Hotax.RESOURCE_IMAGE === type) {
+      this.props.dispatch(routerRedux.push({
+        pathname: `/resource/picture-edit/${id}`,
+        state: { ...record },
+      }));
+    }
+  };
   handlePageBack = () => {
     this.props.dispatch(routerRedux.push({
       pathname: '/product/courseware/list',
@@ -224,6 +258,7 @@ export default class CoursewareCreatePage extends Component {
       dataIndex: 'code',
       key: 2,
       width: '25%',
+      render: (text, record) => <a className="a-link" onClick={() => this.handleResourceEdit(record)}>{text}</a>,
     }, {
       title: '资源名称',
       dataIndex: 'name',

+ 15 - 3
src/utils/utils.js

@@ -430,6 +430,11 @@ export function renderOrderSplitStatus(status) {
   }
 }
 
+/**
+ * 根据商品类型返回中文名称
+ * @param status
+ * @returns {string}
+ */
 export function renderGoodsType(status) {
   switch (status) {
     case Hotax.GOODS_VIRTUAL:
@@ -441,6 +446,11 @@ export function renderGoodsType(status) {
   }
 }
 
+/**
+ * 根据资源类型获取资源中文名称
+ * @param type
+ * @returns {string}
+ */
 export function getResourceTypeName(type) {
   switch (type) {
     case Hotax.RESOURCE_VIDEO:
@@ -456,18 +466,19 @@ export function getResourceTypeName(type) {
   }
 }
 
-// 视频相关常量
+// 资源类型 - 中文名称map
 const resourceTypes = {
   [Hotax.RESOURCE_AUDIO]: '音频',
   [Hotax.RESOURCE_VIDEO]: '视频',
 };
+// 资源质量 - 中文名称map
 const resourceQuality = {
   [Hotax.QUALITY_FLUENT]: '流畅',
   [Hotax.QUALITY_STANDARD]: '标清',
   [Hotax.QUALITY_HIGH]: '高清',
   [Hotax.QUALITY_SUPERCLEAR]: '超清',
 };
-// 价格相关常量
+// 价格类型 - 中文名称map
 const chargeUnitMap = {
   [Hotax.CHARGE_UNIT_DAY]: '天',
   [Hotax.CHARGE_UNIT_SEASON]: '季',
@@ -475,6 +486,7 @@ const chargeUnitMap = {
   [Hotax.CHARGE_UNIT_YEAR]: '年',
   [Hotax.CHARGE_UNIT_ITEM]: '件',
 };
+// 计价单位 - 时长map
 const durationMap = {
   [Hotax.CHARGE_UNIT_SEASON]: Hotax.DURATION_SEASON,
   [Hotax.CHARGE_UNIT_HALF_YEAR]: Hotax.DURATION_HALF_YEAR,
@@ -489,4 +501,4 @@ const sortMap = {
   [Hotax.CHARGE_UNIT_HALF_YEAR]: 2,
   [Hotax.CHARGE_UNIT_YEAR]: 3,
 };
-export { resourceTypes, resourceQuality, chargeUnitMap, durationMap, sortMap };
+export { resourceTypes, resourceType2Str, resourceQuality, chargeUnitMap, durationMap, sortMap };