Przeglądaj źródła

:bug: 标签类型下的标签删除异常问题

zhanghe 6 lat temu
rodzic
commit
d81595a281

+ 1 - 1
src/components/AXDragSortTable/index.js

@@ -32,7 +32,7 @@ class AXDragSortTable extends PureComponent {
   handleRemove = (data, index) => {
     const tmpArray = [...data];
     tmpArray.splice(index, 1);
-    this.props.onChange(tmpArray);
+    this.props.onChange(tmpArray, data[index].id);
   };
 
   render() {

+ 6 - 8
src/routes/Frontend/TagType/TagTypeCreate.js

@@ -38,12 +38,6 @@ const filterTagListByMerchantId = (merchantId, tagList) => {
 const arraySort = (subArray = [], parentArray = []) => {
   let cursor = 0;
   const newArray = [...parentArray];
-  subArray.forEach((sub) => {
-    const sInP = parentArray.findIndex(data => data.id === sub.id);
-    if (sInP !== -1) {
-      newArray.splice(sInP, 1);
-    }
-  });
   while (cursor < subArray.length - 1) {
     const prevId = subArray[cursor].id;
     const nextId = subArray[cursor + 1].id;
@@ -136,12 +130,16 @@ export default class TagTypeCreatePage extends Component {
       merchantSelectorDestroy: true,
     });
   };
-  handleDragSortTableChange = (rows) => {
+  handleDragSortTableChange = (rows, delId) => {
     const { currentItem } = this.props.tagType;
     const { tagList } = currentItem;
+    let newTagList = tagList || [];
+    if (delId) {
+      newTagList = newTagList.filter(tag => tag.id !== delId);
+    }
     this.props.dispatch({
       type: 'tagType/fixCurrentItem',
-      payload: { tagList: arraySort(rows || [], tagList || []) },
+      payload: { tagList: arraySort(rows || [], newTagList) },
     });
   };
   handlePageBack = () => {

+ 2 - 2
src/utils/config.js

@@ -77,7 +77,7 @@ Hotax.CopyRight = '2017-2020 领教信息科技有限公司';
 // 接口地址(测试)
 Hotax.API_HOST_DEV = 'http://tt-cms.api.ai160.com';
 // 接口地址(线上)
-Hotax.API_HOST_PRO = '/api';
+Hotax.API_HOST_PRO = 'http://cms.lingjiao.cn/api';
 // oss存储地址
 Hotax.OSS_HOST = 'http://efunimgs.oss-cn-beijing.aliyuncs.com';
 /********************* 常量定义结束 **********************/
@@ -144,7 +144,7 @@ function apiFormatter() {
   // 根据环境变量选取接口地址
   let prefix = '';
   if (process.env.NODE_ENV === 'development') {
-    prefix = Hotax.API_HOST_DEV;
+    prefix = Hotax.API_HOST_PRO;
   } else if (process.env.NODE_ENV === 'production') {
     prefix = Hotax.API_HOST_PRO;
   } else {