Browse Source

fix: 所有地方的产品名都要映射

wzl 1 year ago
parent
commit
2fb33cdd99

+ 3 - 2
src/views/Assignlicense.vue

@@ -1,5 +1,6 @@
 <script>
 import { post, get } from '../../utils/request'
+import { productListNameMapping } from '../../utils/mapping'
 
 export default {
   data() {
@@ -44,7 +45,7 @@ export default {
             '/pdf-tech/product/listWithSimpleInfo?teamId=' +
               this.signleAssign
           ).then((res) => {
-            this.productList = res.data.result
+            this.productList = productListNameMapping(res.data.result)
           })
         }
       }
@@ -66,7 +67,7 @@ export default {
             '/pdf-tech/product/listWithSimpleInfo?teamId=' +
               this.teamAssign
           ).then((res) => {
-            this.productList = res.data.result
+            this.productList = productListNameMapping(res.data.result)
           })
         }
       }

+ 2 - 17
src/views/Dashboard.vue

@@ -2,6 +2,7 @@
 import { get } from '../../utils/request'
 import * as echarts from 'echarts'
 import { userStore } from '@/store/userInfo'
+import { productListNameMapping } from '../../utils/mapping'
 
 
 export default {
@@ -333,7 +334,7 @@ export default {
     getProductList () {
       get('/pdf-tech/product/listWithAdmin').then((res) => {
         if (res.data.code === 200) {
-          this.productList = this.productNameMapping(res.data.result)
+          this.productList = productListNameMapping(res.data.result)
         }
       })
     },
@@ -358,22 +359,6 @@ export default {
       if (!data) return ''
       const dateArr = data.split('-')
       return dateArr[1] + '/' + dateArr[2]
-    },
-    // 产品名映射
-    productNameMapping (data) {
-      const nameMapping = {
-        'com.brother.pdfreaderpro.mac.product_1': 'PDF Reader Pro for Mac',
-        'com.brother.pdfreaderpro.windows.product_1': 'PDF Reader Pro for Windows',
-        'com.brother.pdfreaderpro.mac.product_3': 'PDF Reader Pro for Mac (With PDF to Office Pack)',
-        'com.brother.pdfreaderpro.windows.product_3': 'PDF Reader Pro for Windows (With PDF to Office Pack)',
-        'com.brother.pdfreaderpro.cross.platform.product_3': 'PDF Reader Pro Cross-Platform (With PDF to Office Pack)'
-      }
-      return data.map((item) => {
-        if (Object.prototype.hasOwnProperty.call(nameMapping, item.code)) {
-          item.name = nameMapping[item.code]
-        }
-        return item
-      })
     }
   }
 }

+ 3 - 2
src/views/Device.vue

@@ -3,6 +3,7 @@ import Download from '@/components/icon/download.vue'
 import Warning from '@/components/icon/warning.vue'
 import Search from '@/components/icon/search.vue'
 import { get, post, downLoad } from '../../utils/request'
+import { productListNameMapping } from '../../utils/mapping'
 
 export default {
   components: {
@@ -76,7 +77,7 @@ export default {
               data[i].status = ''
             }
           }
-          this.tableData = data
+          this.tableData = productListNameMapping(data)
           this.total = res.data.result.total
         }
       })
@@ -96,7 +97,7 @@ export default {
     getproductList() {
       get('/pdf-tech/product/listWithAdmin').then(
         (res) => {
-          this.productList = res.data.result
+          this.productList = productListNameMapping(res.data.result)
         }
       )
     },

+ 3 - 2
src/views/LicenseManage.vue

@@ -4,6 +4,7 @@ import Download from '@/components/icon/download.vue'
 import Warning from '@/components/icon/warning.vue'
 import Search from '@/components/icon/search.vue'
 import { get, post, downLoad } from '../../utils/request'
+import { productListNameMapping } from '../../utils/mapping'
 
 const { proxy } = getCurrentInstance()
 const currentPage = ref(1)
@@ -108,7 +109,7 @@ const pagingQuery = (val) => {
         // data[i].endDate = ''
       }
     }
-    tableData.value = data
+    tableData.value = productListNameMapping(data)
     total.value = res.data.result.total
   })
 }
@@ -116,7 +117,7 @@ const pagingQuery = (val) => {
 const getproductList = (val) => {
   get('/pdf-tech/product/listWithAdmin').then(
     (res) => {
-      productList.value = res.data.result
+      productList.value = productListNameMapping(res.data.result)
     }
   )
 }

+ 3 - 18
src/views/ProductManagement.vue

@@ -5,6 +5,7 @@ import Warning from '@/components/icon/warning.vue'
 import Search from '@/components/icon/search.vue'
 import { get } from '../../utils/request'
 import { userStore } from '@/store/userInfo'
+import { productListNameMapping } from '../../utils/mapping'
 
 const currentPage = ref(1)
 const size = ref(5)
@@ -50,7 +51,7 @@ const pagingQuery = () => {
       'code=' +
       productId.value
   ).then((res) => {
-    tableData.value = productNameMapping(res.data.result.list)
+    tableData.value = productListNameMapping(res.data.result.list)
     total.value = res.data.result.total
   })
 }
@@ -58,7 +59,7 @@ const pagingQuery = () => {
 const getproductList = (val) => {
   get('/pdf-tech/product/listWithAll').then(
     (res) => {
-      productList.value = productNameMapping(res.data.result)
+      productList.value = productListNameMapping(res.data.result)
     }
   )
 }
@@ -77,22 +78,6 @@ const handleCurrentChange = (value) => {
   currentPage.value = value
   pagingQuery()
 }
-// 产品名映射
-const productNameMapping = (data) => {
-  const nameMapping = {
-    'com.brother.pdfreaderpro.mac.product_1': 'PDF Reader Pro for Mac',
-    'com.brother.pdfreaderpro.windows.product_1': 'PDF Reader Pro for Windows',
-    'com.brother.pdfreaderpro.mac.product_3': 'PDF Reader Pro for Mac (With PDF to Office Pack)',
-    'com.brother.pdfreaderpro.windows.product_3': 'PDF Reader Pro for Windows (With PDF to Office Pack)',
-    'com.brother.pdfreaderpro.cross.platform.product_3': 'PDF Reader Pro Cross-Platform (With PDF to Office Pack)'
-  }
-  return data.map((item) => {
-    if (Object.prototype.hasOwnProperty.call(nameMapping, item.code)) {
-      item.name = nameMapping[item.code]
-    }
-    return item
-  })
-}
 </script>
 
 <template>

+ 3 - 2
src/views/Reseller/License.vue

@@ -5,6 +5,7 @@ import Warning from '@/components/icon/warning.vue'
 import Search from '@/components/icon/search.vue'
 import { get, post, downLoad } from '../../../utils/request'
 import { userStore } from '@/store/userInfo'
+import { productListNameMapping } from '../../../utils/mapping'
 
 const { proxy } = getCurrentInstance()
 const currentPage = ref(1)
@@ -65,7 +66,7 @@ const pagingQuery = (val) => {
       }
     }
 
-    tableData.value = data
+    tableData.value = productListNameMapping(data)
     total.value = res.data.result.total
   })
 }
@@ -81,7 +82,7 @@ const getproductList = (val) => {
           data[i].name = 'PDF Reader Pro Win Premium'
         }
       }
-      productList.value = res.data.result
+      productList.value = productListNameMapping(res.data.result)
     }
   )
 }

+ 3 - 2
src/views/Reseller/Product.vue

@@ -2,6 +2,7 @@
 import { onMounted, ref, getCurrentInstance } from 'vue'
 import { get } from '../../../utils/request'
 import { userStore } from '@/store/userInfo'
+import { productListNameMapping } from '../../../utils/mapping'
 
 const { proxy } = getCurrentInstance()
 
@@ -48,7 +49,7 @@ const pagingQuery = () => {
         data[i].name = 'PDF Reader Pro Win Premium'
       }
     }
-    tableData.value = res.data.result.list
+    tableData.value = productListNameMapping(res.data.result.list)
     total.value = res.data.result.total
   })
 }
@@ -64,7 +65,7 @@ const getproductList = (val) => {
           data[i].name = 'PDF Reader Pro Win Premium'
         }
       }
-      productList.value = res.data.result
+      productList.value = productListNameMapping(res.data.result)
     }
   )
 }

+ 4 - 2
src/views/TeamManagement/ManageMember.vue

@@ -3,6 +3,7 @@ import { onMounted, ref, getCurrentInstance } from 'vue'
 import Search from '@/components/icon/search.vue'
 import Warning from '@/components/icon/warning.vue'
 import { get, downLoad, post } from '../../../utils/request'
+import { productListNameMapping } from '../../../utils/mapping'
 
 const { proxy } = getCurrentInstance()
 const tableData = ref([])
@@ -71,7 +72,7 @@ const getTeamList = () => {
 const getproductList = () => {
   get('/pdf-tech/product/listWithAdmin').then(
     (res) => {
-      productList.value = res.data.result
+      productList.value = productListNameMapping(res.data.result)
     }
   )
 }
@@ -98,7 +99,8 @@ function getManageMemberList() {
       'productCode=' +
       product.value
   ).then((res) => {
-    const data = res.data.result.list
+    let data = res.data.result.list
+    data = productListNameMapping(data)
     for (let i = 0; i < data.length; i++) {
       if (data[i].validFlag === '0') {
         data[i].validFlag = 'Deleted'

+ 2 - 1
src/views/TeamManagement/ManageTeamOperate.vue

@@ -1,6 +1,7 @@
 <script>
 import { get, post, put, postWithHeader, putWithHeader } from '../../../utils/request'
 import { userStore } from '@/store/userInfo'
+import { productListNameMapping } from '../../../utils/mapping'
 
 export default {
   data () {
@@ -235,7 +236,7 @@ export default {
           this.formData.teamName = res.data.result.teamName
           this.formData.teamDescription = res.data.result.teamDescription
           if (res.data.result.productList.length > 0) {
-            this.formData.productList = res.data.result.productList
+            this.formData.productList = productListNameMapping(res.data.result.productList)
           }
           const teamAdminId = []
           res.data.result.teamAdminList.forEach(item => {

+ 31 - 0
utils/mapping.js

@@ -0,0 +1,31 @@
+
+// 产品名映射
+function productListNameMapping (data) {
+  const nameMapping = {
+    'com.brother.pdfreaderpro.mac.product_1': 'PDF Reader Pro for Mac',
+    'com.brother.pdfreaderpro.windows.product_1': 'PDF Reader Pro for Windows',
+    'com.brother.pdfreaderpro.mac.product_3': 'PDF Reader Pro for Mac (With PDF to Office Pack)',
+    'com.brother.pdfreaderpro.windows.product_3': 'PDF Reader Pro for Windows (With PDF to Office Pack)',
+    'com.brother.pdfreaderpro.cross.platform.product_3': 'PDF Reader Pro Cross-Platform (With PDF to Office Pack)'
+  }
+  return data.map((item) => {
+    const code = item.code || item.productCode
+    if (code && Object.prototype.hasOwnProperty.call(nameMapping, code)) {
+      if (item.name) item.name = nameMapping[code]
+      if (item.productName) item.productName = nameMapping[code]
+    }
+
+    const codes = item.codes || item.productCodes
+    if (codes) {
+      const multipleCodes = codes.split(',')
+      const multipleNames = multipleCodes.map((code) => nameMapping[code])
+      if (multipleNames.length > 0) {
+        if (item.names) item.names = multipleNames.join(',')
+        if (item.productNames) item.productNames = multipleNames.join(',')
+      }
+    }
+    return item
+  })
+}
+
+export { productListNameMapping }