Kaynağa Gözat

fix: 修复入住店铺编辑信息中店铺等级下拉选项错误问题

周玉环 1 gün önce
ebeveyn
işleme
6456345aff

+ 65 - 41
xinkeaboard-admin/src/pages/manage/store/edit_settled_store.js

@@ -47,6 +47,8 @@ export default class EditSettledStore extends Component {
       show_radio_flag: false,
       query: props.location.query,
       siteList: [],
+      storeGradeIdList: {},
+      openTimeList: {},
       currentSite: {}, // 当前站点
       store_detail: {},
       store_base_info: [{ //店铺信息
@@ -322,31 +324,32 @@ export default class EditSettledStore extends Component {
       type: 'global/getLayoutCollapsed',
     });
     const { query } = this.state;
-    await this.getStoreOpenTime();
     this.get_detail({ storeId: query.id });
-    this.get_store_grade();
   }
 
   //获取开店时长列表
-  getStoreOpenTime = async () => {
-    let { store_business_info } = this.state;
-    const { dispatch } = this.props;
-    await dispatch({
-      type: 'store/get_store_open_time',
-      callback: (res) => {
-        if (res.state == 200) {
-          let tmp_data = [];
-          res.data.map(item => {
-            tmp_data.push({ key: item, name: item + '年' });
-          });
-          let tar_data = store_business_info.filter(item => item.name == 'openTime')[0];
-          tar_data.sel_data = tmp_data;
-          this.setState({
-            store_business_info,
-          });
-        }
-      },
-    });
+  getStoreOpenTime = (webSite) => {
+    return new Promise((resolve) => {
+      let { openTimeList } = this.state;
+      const { dispatch } = this.props;
+      dispatch({
+        type: 'store/get_store_open_time',
+        payload: {webSite},
+        callback: (res) => {
+          if (res.state == 200) {
+            let tmp_data = [];
+            res.data.map(item => {
+              tmp_data.push({ key: item, name: item + '年' });
+            });
+            openTimeList[webSite] = tmp_data;
+            this.setState({
+              openTimeList,
+            }, () => resolve());
+          }
+        },
+      });
+    })
+    
   };
 
   switchBillType = (e) => {
@@ -376,31 +379,42 @@ export default class EditSettledStore extends Component {
   };
 
   //获取店铺等级
-  get_store_grade = () => {
-    let { store_business_info } = this.state;
-    const { dispatch } = this.props;
-    dispatch({
-      type: 'store/get_grade_lists',
-      payload: { pageSize: list_com_page_more },
-      callback: (res) => {
-        if (res.state == 200) {
-          let tar_data = store_business_info.filter(item => item.name == 'storeGradeId')[0];
-          tar_data.sel_data = res.data.list;
-          this.setState({
-            store_business_info,
-          });
-        }
-      },
-    });
+  get_store_grade = (webSite) => {
+    return new Promise((resolve) => {
+      let { storeGradeIdList } = this.state;
+      const { dispatch } = this.props;
+      dispatch({
+        type: 'store/get_grade_lists',
+        payload: { pageSize: list_com_page_more, webSite },
+        callback: (res) => {
+          if (res.state == 200) {
+            storeGradeIdList[webSite] = res.data.list
+            this.setState({
+              storeGradeIdList,
+            }, () => resolve());
+          }
+        },
+      });
+    })
+    
   };
 
+  getInitData = async (siteList) => {
+    const promiseList = [];
+    siteList.forEach(site => {
+      promiseList.push(this.get_store_grade(site.webSite));
+      promiseList.push(this.getStoreOpenTime(site.webSite))
+    })
+    await Promise.all(promiseList)
+  }
+
   get_detail = (params) => {
     const { dispatch } = this.props;
     let { store_detail, store_base_info, personal_front_card_img, store_business_info, replenish_img, business_license_img, settle_info } = this.state;
     dispatch({
       type: 'store/get_settled_store_apply_detail',
       payload: params,
-      callback: res => {
+      callback: async res => {
         if (res.state == 200) {
           store_detail = res.data;
           for (let i = 0; i < store_base_info.length; i++) {
@@ -562,6 +576,7 @@ export default class EditSettledStore extends Component {
             }
           });
           if (siteListData.length) {
+            await this.getInitData(siteListData)
             siteListData.forEach(item => {
               const matchItem = storeBusinessVOList.find(vo => vo.webSite === item.webSite);
               if (matchItem) {
@@ -570,7 +585,7 @@ export default class EditSettledStore extends Component {
                   name: `${info.name}_${matchItem.webSite}`,
                   text: matchItem[info.name] ?? '',
                   initialValue: matchItem[info.name]
-                })).map(this.parseSiteItem)
+                })).map((tag) => this.parseSiteItem(tag, item.webSite))
               }
             })
             const sortSiteList = siteListData.sort((a, b) => Number(a.webSite) - Number(b.webSite));
@@ -595,11 +610,20 @@ export default class EditSettledStore extends Component {
     });
   };
 
-  parseSiteItem = (item) => {
+  parseSiteItem = (item, webSite) => {
+    const { storeGradeIdList, openTimeList} = this.state;
     if (item.name == 'billCycle') {
      item.initialValue = 1;
     }
 
+    if (item.name.includes('storeGradeId')) {
+      item.sel_data = storeGradeIdList[webSite]
+    }
+
+    if (item.name.includes('openTime')) {
+      item.sel_data = openTimeList[webSite]
+    }
+
    return item;
   }
 
@@ -833,7 +857,7 @@ export default class EditSettledStore extends Component {
             <Scrollbars autoHeight
                         autoHeightMax={300}>
               <Table rowKey={'bindId'} pagination={false} columns={columns}
-                     dataSource={store_detail.storeGoodsCateVOList} size={'small'}/>
+                     dataSource={store_detail.storeGoodsCateVOList?.filter(item => item.webSite === currentSite.webSite)} size={'small'}/>
             </Scrollbars>
           </div>
           {getSldEmptyH(10)}

+ 1 - 1
xinkeaboard-admin/src/utils/utils.js

@@ -1332,7 +1332,7 @@ export function sldComRequest(method, url, params, data_type = '') {
   const currentSite = state.global.currentSite || localStorage.getItem('currentSite');
   const currentPath = state.routing.location.pathname;
   if (!currentPath.includes('/user/login')) {
-    params = Object.assign({}, params ?? {}, { webSite: currentSite })
+    params = Object.assign({}, { webSite: currentSite }, params ?? {})
   }
 
   if (params && params.isAll) {