Explorar el Código

Merge branch 'feature/v2.4.46' of https://jygit.jydev.jianyu360.cn/jianyu/qmx_page_admin into feature/v2.4.46

tangshizhe hace 1 mes
padre
commit
bf583a92fb

+ 22 - 7
src/store/order.js

@@ -54,8 +54,10 @@ export default {
       orderChannel: [],
       bigServiceInfo: {},
     },
-    // 产品列表
+    // 产品列表(正在上架的,没区分权限)
     productList: [],
+    // 所有产品列表(包含上架下架的所有历史产品)
+    productListAll: [],
     // 历史选择的产品列表
     historyProductList: [],
     // 页面表单数据
@@ -265,6 +267,9 @@ export default {
     setProductList (state, payload = []) {
       state.productList = payload
     },
+    setProductListAll (state, payload = []) {
+      state.productListAll = payload
+    },
     setOrderEditDisabled(state, f = false) {
       state.orderInfo.disabled = f
     },
@@ -373,26 +378,36 @@ export default {
         }
     },
     // 获取产品备选项信息
-    async getProductList ({ commit, dispatch, state }, payload) {
+    async getProductList ({ commit, dispatch, state }, payload = {}) {
       // 此处不能用缓存,需要实时查询subject=1/2的数据
       // if (Array.isArray(state.productList) && state.productList.length > 0) {
       //   return state.productList
       // }
-
+      const showAll = payload.showAll
       const p = {
         subject: state.pageForm.buySubject,
         ...payload,
       }
 
+      if (showAll) {
+        p.showAll = 1
+      }
+
       commit('setLoadingState', { key: 'productList', value: true })
       try {
         const { error_code: code, error_msg: msg, data } = await ajaxGetProductionList(p)
         if (code === 0 && data) {
-          await dispatch('initProductListData', data)
+          const productList = await dispatch('initProductListData', data)
+          if (showAll) {
+            commit('setProductListAll', productList)
+          } else {
+            commit('setProductList', productList)
+          }
+          return productList
         } else {
           showNotify({ message: msg })
         }
-        return state.productList
+        return []
       } catch (error) {
         console.log(error)
       } finally {
@@ -400,7 +415,7 @@ export default {
       }
     },
     // 初始化产品备选项信息
-    initProductListData({ commit }, payload = {}) {
+    initProductListData(_, payload = {}) {
       const { productList, activityList } = payload
       let pList = []
       // 整理productList
@@ -453,7 +468,7 @@ export default {
         children: aList
       })
 
-      commit('setProductList', pList)
+      return pList
     },
     async getBigServiceInfo({ commit, state }, payload = {}) {
       // 有数据,直接返回数据

+ 2 - 2
src/views/create-order/admin-order-list.vue

@@ -290,7 +290,7 @@ export default {
   },
   created() {
     this.$store.dispatch('order/getSelectOptions')
-    this.$store.dispatch('order/getProductList')
+    this.$store.dispatch('order/getProductList', { showAll: 1 })
   },
   data () {
     return {
@@ -969,7 +969,7 @@ export default {
       'saleChannelOptions',
     ]),
     ...mapState({
-      productTypeOptions: state => state.order.productList,
+      productTypeOptions: state => state.order.productListAll,
       productInfoList: state => state.order.orderInfo.productInfoList,
       pageForm: state => state.order.pageForm,
     }),

+ 1 - 0
src/views/create-order/components/ProductInfoCard.vue

@@ -9,6 +9,7 @@
             :value="productTypeResult"
             :loading="loading"
             :showLoading="true"
+            checkPower
             @input="onProductionInput"
             @change="onProductionChange"
           />

+ 23 - 2
src/views/create-order/components/product-info-submodule/ProductTypeSelector.vue

@@ -2,7 +2,7 @@
   <div class="product-type-selector-container">
     <el-form-item label="选择产品" required :error="productTypeError">
       <el-cascader
-        :options="productTypeOptions"
+        :options="powerProductTypeOptions"
         class="product-type-cascader"
         popper-class="product-type-cascader-popper"
         :append-to-body="false"
@@ -50,6 +50,11 @@ import { productKeyMap } from '@/views/create-order/data'
 export default {
   name: 'ProductTypeSelector',
   props: {
+    // 检查是否有显示权限
+    checkPower: {
+      type: Boolean,
+      default: false,
+    },
     collapseTags: {
       type: Boolean,
       default: false,
@@ -130,6 +135,22 @@ export default {
         return this.findProductWithNameAndCode(this.productType1)
       }
     },
+    powerProductTypeOptions() {
+      if (this.checkPower) {
+        return this.productTypeOptions.filter(p => {
+          let availableChildren = []
+          if (Array.isArray(p.children) && p.children.length > 0) {
+            availableChildren = p.children.filter(p2 => p2.state === 1)
+          }
+          return {
+            ...p,
+            children: availableChildren
+          }
+        })
+      } else {
+        return this.productTypeOptions
+      }
+    },
     noActivityProductTypeOptions() {
       return this.productTypeOptions.filter(p => !p.activityMark)
     },
@@ -229,7 +250,7 @@ export default {
     findProductWithNameAndCode(e) {
       const firstName = e[0]
       const secondName = e[1]
-      const targetItem = this.productTypeOptions.find(item => item.value === firstName)
+      const targetItem = this.powerProductTypeOptions.find(item => item.value === firstName)
       if (targetItem) {
         return targetItem.children.find(oc => oc.code === secondName)
       }

+ 2 - 2
src/views/create-order/order-list.vue

@@ -210,7 +210,7 @@ export default {
   },
   created() {
     this.$store.dispatch('order/getSelectOptions')
-    this.$store.dispatch('order/getProductList')
+    this.$store.dispatch('order/getProductList', { showAll: 1 })
     this.getQueryParams()
   },
   data () {
@@ -868,7 +868,7 @@ export default {
   },
   computed: {
     ...mapState({
-      productTypeOptions: state => state.order.productList,
+      productTypeOptions: state => state.order.productListAll,
       productInfoList: state => state.order.orderInfo.productInfoList,
       pageForm: state => state.order.pageForm,
     }),