Просмотр исходного кода

dashboard筛选、team manage编辑添加删除接口联调

wzl 2 лет назад
Родитель
Сommit
d9e95b2bb4

+ 43 - 29
src/views/Dashboard.vue

@@ -11,17 +11,16 @@ export default {
         availableLicenses: null,
         activatedDevices: null,
       },
-      codeList: ['com.brother.pdfreaderpro.mac.product_3'],
+      productList: [],
       overviewProduct: {
         totalLicenses: null,
         availableLicenses: null,
-        activedLicenses: null,
+        activatedDevices: null,
         validPeriod: null,
         expireDate: null,
         timeLeft: null
       },
       dataFilterProductSelect: '',
-      dataFilterPlanSelect: '',
       chartData: {
         date: [],
         assignedLicensesYData: [],
@@ -38,9 +37,9 @@ export default {
         assignedMember: null,
         teamAvailableLicense: null
       },
+      teamList: [],
       teamSelect: '',
-      teamFilterProductSelect: '',
-      teamFilterPlanSelect: ''
+      teamFilterProductSelect: ''
     }
   },
   created () {
@@ -49,6 +48,8 @@ export default {
     this.getChartStatistics(1)
     this.getTeamData()
     this.getTeamMemberData()
+    this.getProductList()
+    this.getTeamList()
   },
   mounted () {
     this.drawLine()
@@ -68,12 +69,12 @@ export default {
     // 获取全局预览数据,区分产品
     getOverviewProduct () {
       get('http://81.68.234.235:8032/pdf-tech/vppDashboard/getOverviewProduct', {
-        codeList: this.codeList + ''
+        codeList: this.dataFilterProductSelect
       }).then((res) => {
         if (res.data.code === 200) {
           this.overviewProduct.totalLicenses = res.data.result.totalLicenses
           this.overviewProduct.availableLicenses = res.data.result.availableLicenses
-          this.overviewProduct.activedLicenses = res.data.result.activedLicenses
+          this.overviewProduct.activatedDevices = res.data.result.activatedDevices
           this.overviewProduct.validPeriod = res.data.result.validPeriod
           this.overviewProduct.expireDate = res.data.result.expireDate
           this.overviewProduct.timeLeft = res.data.result.timeLeft
@@ -84,6 +85,8 @@ export default {
     getChartStatistics (type) {
       if (this.chartSelectValue !== '') {
         type = this.chartSelectValue
+      } else {
+        type = 1
       }
       get('http://81.68.234.235:8032/pdf-tech/vppDashboard/getChartStatistics/' + type).then((res) => {
         if (res.data.code === 200) {
@@ -114,8 +117,8 @@ export default {
     // 获取团队成员数据
     getTeamMemberData () {
       get('http://81.68.234.235:8032/pdf-tech/vppDashboard/getTeamMemberData', {
-        teamId: '1',
-        codeList: this.codeList + ''
+        teamId: this.teamSelect,
+        codeList: this.teamFilterProductSelect
       }).then((res) => {
         if (res.data.code === 200) {
           this.teamMemberData.teamMember = res.data.result.teamMember
@@ -229,6 +232,31 @@ export default {
       window.onresize = function () {
         myChart.resize()
       }
+    },
+    // 获取所有产品
+    getProductList () {
+      get('http://81.68.234.235:8032/pdf-tech/product/listWithAdmin').then((res) => {
+        if (res.data.code === 200) {
+          this.productList = res.data.result
+          console.log(this.productList)
+        }
+      })
+    },
+    // 获取所有团队
+    getTeamList() {
+      get('http://81.68.234.235:8032/pdf-tech/vppTeam/getManageTeamList', {
+        teamId: '',
+        keyword: ''
+      }).then((res) => {
+        if (res.data.code === 200) {
+          res.data.result.list.forEach(item => {
+            this.teamList.push({
+                label: item.name,
+                value: item.id
+            })
+          })
+        }
+      })
     }
   }
 }
@@ -273,16 +301,9 @@ export default {
       <div class="flex">
         <select v-model="dataFilterProductSelect" name="dataFilterProduct" class="min-w-180px mr-16px">
           <option value="">Product</option>
-          <option value="PDF Reader Pro Win">PDF Reader Pro Win</option>
-          <option value="PDF Reader Pro Mac">PDF Reader Pro Mac</option>
-          <option value="PDF Reader Pro">PDF Reader Pro(无版本则为一码双端)</option>
-        </select>
-        <select v-model="dataFilterPlanSelect" name="dataFilterPlan" class="min-w-140px mr-16px">
-          <option value="">Plan</option>
-          <option value="Premiun">Premiun</option>
-          <option value="Permanent">Permanent</option>
+          <option v-for="item in productList" :key="item.id" :value="item.code">{{ item.name }}</option>
         </select>
-        <div class="w-70px h-28px border-[#1460F3] border-1px rounded-4px px-10px py-4px text-14px leading-20px text-[#1460F3] cursor-pointer">Confirm</div>
+        <div @click="getOverviewProduct" class="w-70px h-28px border-[#1460F3] border-1px rounded-4px px-10px py-4px text-14px leading-20px text-[#1460F3] cursor-pointer">Confirm</div>
       </div>
       <div class="flex flex-wrap justify-between mt-24px">
         <div class="h-56px flex-1 bg-[#F6F7F9] border-[#D9D9D9] border-1px rounded-4px py-18px pl-24px pr-40px flex justify-between items-center mr-24px">
@@ -295,7 +316,7 @@ export default {
         </div>
         <div class="h-56px flex-1 bg-[#F6F7F9] border-[#D9D9D9] border-1px rounded-4px py-18px pl-24px pr-40px flex justify-between items-center">
           <span class="text-14px font-bold text-[#505258]">Actived Licenses</span>
-          <span class="text-16px font-bold text-[#232A40]">{{ overviewProduct.activedLicenses }}</span>
+          <span class="text-16px font-bold text-[#232A40]">{{ overviewProduct.activatedDevices }}</span>
         </div>
       </div>
       <div class="flex flex-wrap justify-between mt-24px">
@@ -361,20 +382,13 @@ export default {
       <div class="flex">
         <select v-model="teamSelect" name="team" class="min-w-140px mr-16px">
           <option value="">Team</option>
-          <option value="2">2</option>
+          <option v-for="item in teamList" :key="item.value" :value="item.value">{{ item.label }}</option>
         </select>
         <select v-model="teamFilterProductSelect" name="teamFilterProduct" class="min-w-180px mr-16px">
           <option value="">Product</option>
-          <option value="PDF Reader Pro Win">PDF Reader Pro Win</option>
-          <option value="PDF Reader Pro Mac">PDF Reader Pro Mac</option>
-          <option value="PDF Reader Pro">PDF Reader Pro(无版本则为一码双端)</option>
-        </select>
-        <select v-model="teamFilterPlanSelect" name="teamFilterPlan" class="min-w-140px mr-16px">
-          <option value="">Plan</option>
-          <option value="Premiun">Premiun</option>
-          <option value="Permanent">Permanent</option>
+          <option v-for="item in productList" :key="item.id" :value="item.code">{{ item.name }}</option>
         </select>
-        <div class="w-70px h-28px border-[#1460F3] border-1px rounded-4px px-10px py-4px text-14px leading-20px text-[#1460F3] cursor-pointer">Confirm</div>
+        <div @click="getTeamMemberData" class="w-70px h-28px border-[#1460F3] border-1px rounded-4px px-10px py-4px text-14px leading-20px text-[#1460F3] cursor-pointer">Confirm</div>
       </div>
       <div class="flex flex-wrap justify-between mt-24px">
         <div class="h-56px bg-[#F6F7F9] border-[#D9D9D9] border-1px rounded-4px py-18px pl-24px pr-40px flex-auto flex justify-between items-center mr-24px">

+ 9 - 2
src/views/TeamManagement/ManageTeam.vue

@@ -74,8 +74,10 @@ function handleDelete() {
   }).then((res) => {
     if (res.data.code === 200) {
       proxy.$message('Delete Success')
-      proxy.tableData.splice(deleteTeamIndex.value, 1)
-    } else proxy.$message.error(res.data.msg)
+      tableData.value.splice(deleteTeamIndex.value, 1)
+    } else (
+      proxy.$message.error(res.data.msg)
+    )
     dialogVisible.value = false
   })
 }
@@ -216,6 +218,7 @@ onMounted(() => {
         <el-table-column label="Operate" min-width="10%">
           <template slot-scope="scope">
             <div>
+<<<<<<< HEAD
               <router-link
                 :to="{
                   name: 'EditManageTeam',
@@ -243,6 +246,10 @@ onMounted(() => {
                 >
                   Edit
                 </div>
+=======
+              <router-link :to="{ name: 'EditManageTeam', params: { flag: 'edit', teamInfo: scope.row } }">
+                <div class="w-61px h-20px border-1 border-[#1460F3] rounded-4px text-center text-14px leading-20px text-[#1460F3] cursor-pointer mb-8px">Edit</div>
+>>>>>>> develop_wzl
               </router-link>
               <div
                 class="

+ 49 - 39
src/views/TeamManagement/ManageTeamOperate.vue

@@ -1,5 +1,5 @@
 <script>
-import { post, put, postWithHeader } from '../../../utils/request'
+import { get, post, put, postWithHeader, putWithHeader } from '../../../utils/request'
 
 export default {
   data () {
@@ -14,26 +14,8 @@ export default {
         }]
       },
       flag: '',
-      adminOptions: [{
-        value: 1,
-        label: 'HTML'
-      }, {
-        value: '2',
-        label: 'CSS'
-      }, {
-        value: '3',
-        label: 'JavaScript'
-      }],
-      projectOptions: [{
-        value: 1,
-        label: 'HTML'
-      }, {
-        value: '2',
-        label: 'CSS'
-      }, {
-        value: '3',
-        label: 'JavaScript'
-      }],
+      adminOptions: [],
+      projectOptions: [],
       dialogVisible: false
     }
   },
@@ -61,19 +43,15 @@ export default {
     }
     this.flag = rowData.flag
     if (rowData.flag === 'edit') {
-      if (rowData.teamId) {
-        this.formData.teamId = rowData.teamId
-      }
-      if (rowData.teamName) {
-        this.formData.teamName = rowData.teamName
-      }
-      if (rowData.teamDescription) {
-        this.formData.teamDescription = rowData.teamDescription
-      }
-      if (rowData.licenseAmount) {
-        this.formData.productList[0].licenseNumber = rowData.licenseAmount
+      if (rowData.teamInfo) {
+        this.formData.teamId = rowData.teamInfo.id
+        this.formData.teamName = rowData.teamInfo.name
+        this.formData.teamDescription = rowData.teamInfo.description
+        this.formData.productList[0].licenseNumber = rowData.teamInfo.licenseAmount
       }
     }
+    this.getAdmin()
+    this.getProduct()
   },
   methods: {
     // 提交表单
@@ -113,15 +91,15 @@ export default {
     },
     // 创建团队
     createTeam () {
-      // const data = {
-      //   data: JSON.stringify(this.formData),
-      //   headers: {
-      //     'Content-Type': 'application/json'
-      //   }
-      // }
+      this.formData.productList.forEach(item =>{
+        if (item.licenseNumber === null || item.licenseNumber === '') {
+          item.licenseNumber = 0
+        }
+      })
       postWithHeader('http://81.68.234.235:8032/pdf-tech/vppTeam/createTeam', JSON.stringify(this.formData)).then((res) => {
         if (res.data.code === 200) {
           this.$message('Change Success')
+          this.$router.push({name:'ManageTeam'})
         } else (
           this.$message.error(res.data.msg)
         )
@@ -129,13 +107,45 @@ export default {
     },
     // 编辑团队
     editTeam () {
-      put('http://81.68.234.235:8032/pdf-tech/vppTeam/editTeam', JSON.stringify(this.formData)).then((res) => {
+      this.formData.productList.forEach(item =>{
+        if (item.licenseNumber === null || item.licenseNumber === '') {
+          item.licenseNumber = 0
+        }
+      })
+      putWithHeader('http://81.68.234.235:8032/pdf-tech/vppTeam/editTeam', JSON.stringify(this.formData)).then((res) => {
         if (res.data.code === 200) {
           this.$message('Change Success')
+          this.$router.push({name:'ManageTeam'})
         } else (
           this.$message.error(res.data.msg)
         )
       })
+    },
+    // 获取所有管理员
+    getAdmin () {
+      get('http://81.68.234.235:8032/pdf-tech/vppRTeamMemberRole/pageForAdmin').then((res) => {
+        if (res.data.code === 200) {
+          res.data.result.list.forEach(item => {
+            this.adminOptions.push({
+                label: item.email,
+                value: item.id
+            })
+          })
+        }
+      })
+    },
+    // 获取所有产品
+    getProduct () {
+      get('http://81.68.234.235:8032/pdf-tech/product/listWithAdmin').then((res) => {
+        if (res.data.code === 200) {
+          res.data.result.forEach(item => {
+            this.projectOptions.push({
+                label: item.name,
+                value: item.id
+            })
+          })
+        }
+      })
     }
   },
   // 切换路由时清除本地存储数据

+ 16 - 1
utils/request.js

@@ -118,7 +118,6 @@ export function _delete(url, params = {}) {
  * @param {object} data
  */
 export function postWithHeader(url, data = {}) {
-  // data = Qs.stringify(data)
   return instance({
     method: 'post',
     url,
@@ -130,4 +129,20 @@ export function postWithHeader(url, data = {}) {
   });
 }
 
+/**
+ * @param {string} url
+ * @param {object} data
+ */
+export function putWithHeader(url, data = {}) {
+  return instance({
+    method: 'put',
+    url,
+    data,
+    headers: {
+      'Content-Type': 'application/json'
+    },
+    dataType: "json",
+  });
+}
+
 export default instance;