Browse Source

Modify Credit Limit (Add Suspension)
https://dev.wormwood.com.sg/zentao/task-view-412.html

vbea 1 year ago
parent
commit
0173ba6d4f

+ 12 - 0
Strides-Admin/src/api/limit.js

@@ -41,6 +41,18 @@ const limit = {
   },
   rejectCreditLimit(data) {
     return post(prefix + "group-credit-limit-reject", data)
+  },
+  getSuspendStatusOptions() {
+    return get(prefix + "suspend-status-select")
+  },
+  getSuspendLimitAssignmentPages(params) {
+    return post(prefix + 'group-credit-limit-plan-assigned-user-pages', params)
+  },
+  suspendCreditLimitPlanUser(params) {
+    return post(prefix + "suspend-group-credit-limit-plan-user", params)
+  },
+  unsuspendCreditLimitPlanUser(params) {
+    return post(prefix + "unsuspend-group-credit-limit-plan-user", params)
   }
 }
 

+ 2 - 2
Strides-Admin/src/views/limit2/detail.vue

@@ -166,11 +166,11 @@
           </el-button>
           <el-button
             v-if="!form.onlyView"
-            style="margin-left: 20px;"
+            style="margin-left: 15px;"
             type="primary"
             :loading="loading.save"
             @click="onSaveClick">
-            Save
+            &nbsp;Save&nbsp;
           </el-button>
         </div>
         <div

+ 49 - 4
Strides-Admin/src/views/limit2/plans.vue

@@ -37,10 +37,33 @@
       </el-table-column>
       <el-table-column
         align="center"
-        label="Current Consumption"
-        prop="individualCurrentConsumption"
+        label="Suspend Users"
+        prop="suspendUsers"
+        min-width="170">
+        <template slot-scope="{row}">
+          <span
+            v-if="canEdit"
+            class="link-type"
+            @click="suspendPlan(row)">{{row.suspendUsers}}</span>
+          <span v-else>{{row.suspendUsers}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column
+        align="center"
+        label="Suspend Credit"
+        prop="suspendCredit"
         min-width="170"/>
       <el-table-column
+        align="center"
+        label="Not Suspend Credit"
+        prop="notSuspendCredit"
+        min-width="170"/>
+<!--      <el-table-column
+        align="center"
+        label="Current Consumption"
+        prop="individualCurrentConsumption"
+        min-width="170"/> -->
+      <!-- <el-table-column
         align="center"
         label="Action"
         min-width="80"
@@ -63,7 +86,7 @@
             </el-dropdown-menu>
           </el-dropdown>
         </template>
-      </el-table-column>
+      </el-table-column> -->
     </el-table>
     <div class="right">
       <Pagination
@@ -104,6 +127,9 @@
     <assignment
       v-bind="dialogAssign"
       @hide="hideAssignDialog"/>
+    <suspendment
+      v-bind="dialogSuspend"
+      @hide="hideSuspendDialog"/>
   </div>
 </template>
 
@@ -111,6 +137,7 @@
 import limit from '@/api/limit.js'
 import Pagination from '@/components/Pagination'
 import assignment from './assignment.vue'
+import suspendment from './suspendment.vue'
 export default {
   name: "plans",
   props: {
@@ -158,10 +185,15 @@ export default {
         item: {},
         groupPk: "",
         visible: false
+      },
+      dialogSuspend: {
+        item: {},
+        groupPk: "",
+        visible: false
       }
     };
   },
-  components: {Pagination, assignment},
+  components: {Pagination, assignment, suspendment},
   mounted() {
     if (this.id) {
       this.addPlan.form.groupCreditPk = this.id;
@@ -217,6 +249,11 @@ export default {
       this.dialogAssign.groupPk = this.groupPk;
       this.dialogAssign.visible = true;
     },
+    suspendPlan(item) {
+      this.dialogSuspend.item = item;
+      this.dialogSuspend.groupPk = this.groupPk;
+      this.dialogSuspend.visible = true;
+    },
     deletePlan(item) {
       this.$confirm('Are you sure you want to delete this plan?', 'Delete', {
         confirmButtonText: 'OK',
@@ -247,6 +284,14 @@ export default {
         this.getPlanList();
         this.$emit("refresh");
       }
+    },
+    hideSuspendDialog(e) {
+      this.dialogSuspend.item = {};
+      this.dialogSuspend.visible = false;
+      if (e) {
+        this.getPlanList();
+        this.$emit("refresh");
+      }
     }
   }
 }

+ 315 - 0
Strides-Admin/src/views/limit2/suspendment.vue

@@ -0,0 +1,315 @@
+<template>
+  <el-dialog
+    :title="title"
+    :visible="visible"
+    :before-close="onHide"
+    class="assign-limit-dialog">
+    <div class="filter-container filter-view">
+      <el-select
+        style="min-width: 70px; max-width: 120px;"
+        clearable
+        v-model="filter.pageCriteria.suspendStatus"
+        placeholder="Status"
+        @change="onSearch">
+        <el-option
+          v-for="(item, index) in statusOptions"
+          :key="index"
+          :label="item"
+          :value="item"/>
+      </el-select>
+      <div style="flex: 1; min-width: 150px; max-width: 300px;">
+        <el-input
+          clearable
+          v-model="filter.pageCriteria.criteria"
+          placeholder="Search by Site Name or Service Provider"
+          @keyup.enter.native="onSearch"/>
+      </div>
+      <el-button
+        type="primary"
+        @click="onSearch">
+        Search
+      </el-button>
+    </div>
+    <div class="assign-label-actions">
+      <el-button
+        type="danger"
+        :disabled="selectRow.length == 0"
+        :loading="loading.unassign"
+        @click="onClickUnassign">
+        Batch Un-suspend
+      </el-button>
+      <el-button
+        type="accent"
+        :disabled="selectRow.length == 0"
+        :loading="loading.assign"
+        @click="onClickAssign">
+        Batch Suspend
+      </el-button>
+    </div>
+    <div class="table-view" v-loading="table.loading">
+      <el-table
+        :data="table.data"
+        height="100%"
+        class="no-border"
+        @selection-change="changeSelection">
+        <el-table-column
+          align="center"
+          label="User Name"
+          prop="userName"
+          min-width="120"/>
+        <el-table-column
+          align="center"
+          label="Contact Number"
+          prop="contactNumber"
+          min-width="120"/>
+        <el-table-column
+          align="center"
+          label="E-Mail"
+          prop="email"
+          min-width="120"/>
+        <el-table-column
+          align="center"
+          label="Suspend Status"
+          prop="suspendStatus"
+          min-width="120"/>
+        <el-table-column
+          align="center"
+          label="Select"
+          type="selection"/>
+      </el-table>
+    </div>
+    <div class="center" style="margin-bottom: -20px;">
+      <Pagination
+        v-show="table.total"
+        :total="table.total"
+        :page.sync="filter.pageNo"
+        :limit.sync="filter.pageSize"
+        @pagination="getTableData"/>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import api from '@/api/limit.js'
+import Pagination from '@/components/Pagination'
+export default {
+  name: "SuspendUser",
+  props: {
+    visible: {
+      type: Boolean,
+      default: false
+    },
+    item: {
+      type: Object,
+      default: () => ({})
+    },
+    groupPk: {
+      type: Number|String,
+      default: ""
+    }
+  },
+  data() {
+    return {
+      filter: {
+        pageNum: 1,
+        pageSize: 10,
+        pageCriteria: {
+          criteria: "",
+          groupPk: "",
+          groupCreditPlanId: "",
+          suspendStatus: ""
+        }
+      },
+      table: {
+        data: [],
+        total: 0,
+        loading: false
+      },
+      loading: {
+        assign: false,
+        unassign: false
+      },
+      statusOptions: [],
+      selectRow: []
+    };
+  },
+  components: {Pagination},
+  computed: {
+    title() {
+      return "SUSPEND USER"
+    }
+  },
+  watch: {
+    visible: {
+      handler(n, o) {
+        console.log("watch.visible", n, o);
+        if (n) {
+          this.filter.pageCriteria.groupCreditPlanId = this.item.groupCreditPlanId;
+          this.filter.pageCriteria.suspendStatus = "";
+          this.filter.pageCriteria.groupPk = this.groupPk;
+          this.onSearch()
+        }
+      }
+    }
+  },
+  mounted() {
+    this.getStatusOptions();
+  },
+  methods: {
+    onHide() {
+      this.$emit("hide", true);
+    },
+    onSearch() {
+      this.filter.pageNo = 1;
+      this.getTableData();
+    },
+    getStatusOptions() {
+      api.getSuspendStatusOptions().then(res => {
+        if (res.data) {
+          this.statusOptions = res.data
+        }
+      }).catch(error => {
+        this.$message({
+          type: 'error',
+          message: error
+        })
+      })
+    },
+    getTableData() {
+      this.table.loading = true;
+      api.getSuspendLimitAssignmentPages(this.filter).then(res => {
+        if (res.data.totalRow && res.data.records) {
+          this.table.total = res.data.totalRow;
+          this.table.data = res.data.records;
+        } else {
+          this.table.total = 0;
+          this.table.data = [];
+        }
+        this.table.loading = false;
+      }).catch(error => {
+        this.$message({
+          type: 'error',
+          message: error
+        })
+        this.table.total = 0;
+        this.table.data = [];
+        this.table.loading = false;
+      })
+    },
+    changeSelection(val) {
+      this.selectRow = val;
+    },
+    getSelectIds() {
+      const ids = [];
+      this.selectRow.forEach(item => {
+        ids.push(item.groupCreditPlanUserId)
+      })
+      return ids;
+    },
+    onClickAssign() {
+      const params = {
+        groupCreditPlanId: this.item.groupCreditPlanId,
+        groupCreditPlanUserIds: this.getSelectIds()
+      }
+      this.loading.assign = true;
+      api.suspendCreditLimitPlanUser(params).then(res => {
+        this.$message({
+          type: 'success',
+          message: res.msg || "Success"
+        })
+        this.getTableData()
+      }).catch(error => {
+        this.$message({
+          type: 'error',
+          message: error
+        })
+      }).finally(() => {
+        this.loading.assign = false;
+      })
+    },
+    onClickUnassign() {
+      const params = {
+        groupCreditPlanId: this.item.groupCreditPlanId,
+        groupCreditPlanUserIds: this.getSelectIds()
+      }
+      this.loading.unassign = true;
+      api.unsuspendCreditLimitPlanUser(params).then(res => {
+        this.$message({
+          type: 'success',
+          message: res.msg || "Success"
+        })
+        this.getTableData()
+      }).catch(error => {
+        this.$message({
+          type: 'error',
+          message: error
+        })
+      }).finally(() => {
+        this.loading.unassign = false;
+      })
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.assign-limit-dialog
+  ::v-deep .el-dialog {
+    width: 65vw;
+    height: 90vh;
+    display: flex;
+    max-width: 1200px;
+    flex-direction: column;
+    margin-top: 5vh !important;
+  .el-dialog__header {
+    padding: 20px 20px 0;
+    font-weight: bold;
+  }
+  .el-dialog__body {
+    flex: 1;
+    padding: 20px;
+    display: flex;
+    overflow: hidden;
+    flex-direction: column;
+  }
+  @media screen and (max-width: 1200px) {
+    & {
+      width: 70vw;
+    }
+  }
+  @media screen and (max-width: 1000px) {
+    & {
+      width: 80vw;
+    }
+  }
+  @media screen and (max-width: 800px) {
+    & {
+      width: 90vw;
+    }
+  }
+  @media screen and (max-width: 700px) {
+    & {
+      width: 99vw;
+    }
+  }
+  @media screen and (max-width: 320px) {
+    & {
+      width: 100%;
+      min-width: 300px;
+    }
+  }
+}
+.assign-limit-dialog .table-view {
+  flex: 1;
+  overflow-y: auto;
+  padding-top: 10px;
+  margin-bottom: -10px;
+}
+.assign-label-actions {
+  display: flex;
+  padding-top: 5px;
+  flex-wrap: wrap-reverse;
+  align-items: center;
+  justify-content: flex-end;
+}
+</style>