瀏覽代碼

公司通话充值模块
公司短信充值模块

xdd 1 月之前
父節點
當前提交
762c1d9730

+ 10 - 1
src/api/company/companySms.js

@@ -9,6 +9,15 @@ export function listCompanySms(query) {
   })
 }
 
+// 充值公司套餐
+export function buySms(query) {
+  return request({
+    url: '/company/companySms/buySms',
+    method: 'post',
+    params: query
+  })
+}
+
 // 查询公司短信详细
 export function getCompanySms(smsId) {
   return request({
@@ -50,4 +59,4 @@ export function exportCompanySms(query) {
     method: 'get',
     params: query
   })
-}
+}

+ 11 - 1
src/api/company/companySmsPackage.js

@@ -9,6 +9,16 @@ export function listCompanySmsPackage(query) {
   })
 }
 
+// 查询所有短信套餐包
+export function listCompanySmsPackageAll(query) {
+  return request({
+    url: '/company/companySmsPackage/listAll',
+    method: 'get',
+    params: query
+  })
+}
+
+
 // 查询短信套餐包详细
 export function getCompanySmsPackage(packageId) {
   return request({
@@ -50,4 +60,4 @@ export function exportCompanySmsPackage(query) {
     method: 'get',
     params: query
   })
-}
+}

+ 9 - 2
src/api/company/companyVoice.js

@@ -16,7 +16,14 @@ export function getCompanyVoice(voiceId) {
     method: 'get'
   })
 }
-
+// 购买通话
+export function companyBuyVoice(param) {
+  return request({
+    url: '/company/companyVoice/buy',
+    data: param,
+    method: 'post'
+  })
+}
 // 新增企业通话
 export function addCompanyVoice(data) {
   return request({
@@ -50,4 +57,4 @@ export function exportCompanyVoice(query) {
     method: 'get',
     params: query
   })
-}
+}

+ 9 - 2
src/api/company/companyVoicePackage.js

@@ -8,7 +8,14 @@ export function listCompanyVoicePackage(query) {
     params: query
   })
 }
-
+// 查询所有套餐
+export function listAllCompanyVoicePackage(query) {
+  return request({
+    url: '/company/companyVoicePackage/listAll',
+    method: 'get',
+    params: query
+  })
+}
 // 查询套餐详细
 export function getCompanyVoicePackage(packageId) {
   return request({
@@ -50,4 +57,4 @@ export function exportCompanyVoicePackage(query) {
     method: 'get',
     params: query
   })
-}
+}

+ 107 - 1
src/views/company/companySms/index.vue

@@ -27,6 +27,9 @@
           @click="handleExport"
           v-hasPermi="['company:companySms:export']"
         >导出</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button type="primary" @click="rechargeSmsHandle" size="mini">充值短信</el-button>
       </el-col>
 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
@@ -70,16 +73,78 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+
+    <!-- 充值短信对话框 -->
+    <el-dialog :title="recharge.title" :visible.sync="recharge.open" width="500px" append-to-body>
+      <el-form ref="buyForm" :model="recharge.form" :rules="recharge.rules" label-width="80px">
+        <el-form-item label="公司名" prop="companyId">
+          <el-select style="width: 320px" v-model="recharge.form.companyId" placeholder="请选择公司" clearable size="small">
+            <el-option
+              v-for="item in companys"
+              :key="item.companyId"
+              :label="item.companyName"
+              :value="item.companyId"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="短信套餐" prop="packageId">
+          <el-select style="width: 320px" v-model="recharge.form.packageId" placeholder="请选择公司" clearable size="small">
+            <el-option
+              v-for="item in recharge.allCompanySmsData"
+              :key="item.packageId"
+              :label="item.title"
+              :value="item.packageId"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitBuyForm" :disabled="recharge.btnDisable">确 定</el-button>
+        <el-button @click="rechargeCancel">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-import { listCompanySms, getCompanySms, delCompanySms, addCompanySms, updateCompanySms, exportCompanySms } from "@/api/company/companySms";
+import {
+  listCompanySms,
+  getCompanySms,
+  delCompanySms,
+  addCompanySms,
+  updateCompanySms,
+  exportCompanySms,
+  buySms
+} from "@/api/company/companySms";
 import { getCompanyList } from "@/api/company/company";
+import {listCompanySmsPackageAll} from "@/api/company/companySmsPackage";
 export default {
   name: "CompanySms",
   data() {
     return {
+      recharge: {
+        btnDisable:false,
+        title: '充值短信',
+        open: false,
+        allCompanySmsData:[],
+        form: {
+          companyId: null,
+          packageId: null
+        },
+        rules: {
+          companyId: [{
+            required: true,
+            message: '请选择公司',
+            trigger: 'blur'
+          }],
+          packageId: [{
+            required: true,
+            message: '请选择公司',
+            trigger: 'blur'
+          }]
+        }
+      },
       companys:[],
       // 遮罩层
       loading: true,
@@ -120,8 +185,19 @@ export default {
 
     });
     this.getList();
+    listCompanySmsPackageAll().then(response => {
+      this.recharge.allCompanySmsData = response.data;
+    });
   },
   methods: {
+    rechargeSmsHandle(scope){
+      this.recharge.open = true;
+      this.recharge.form = {
+        companyId: null,
+        packageId: null
+      };
+      this.resetForm("buyForm");
+    },
     /** 查询公司短信列表 */
     getList() {
       this.loading = true;
@@ -136,6 +212,14 @@ export default {
       this.open = false;
       this.reset();
     },
+    rechargeCancel(){
+      this.recharge.open = false;
+      this.recharge.form = {
+        companyId: null,
+        packageId: null
+      };
+      this.resetForm("buyForm");
+    },
     // 表单重置
     reset() {
       this.form = {
@@ -178,6 +262,28 @@ export default {
         this.title = "修改公司短信";
       });
     },
+    submitBuyForm(){
+
+      this.$refs["buyForm"].validate(valid => {
+        if (valid) {
+          this.recharge.btnDisable = true;
+          buySms(this.recharge.form).then(response => {
+            if (response.code === 200) {
+              this.msgSuccess("充值成功!");
+              this.recharge.open = false;
+              this.getList();
+            }
+          }).catch(e=>{
+            this.recharge.open = false;
+          })
+            .finally(() => {
+            setTimeout(()=>{
+              this.recharge.btnDisable = false;
+            },2000)
+          });
+        }
+      });
+    },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {

+ 62 - 29
src/views/company/companyVoice/index.vue

@@ -19,6 +19,13 @@
 
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['company:companyVoice:add']"
+        >充值</el-button>
         <el-button
           type="warning"
           icon="el-icon-download"
@@ -50,18 +57,35 @@
     <!-- 添加或修改企业通话对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="公司ID" prop="companyId">
-          <el-input v-model="form.companyId" placeholder="请输入公司ID" />
-        </el-form-item>
-        <el-form-item label="剩余时长 分" prop="times">
-          <el-input v-model="form.times" placeholder="请输入剩余时长 分" />
+        <el-form-item label="公司" prop="companyId">
+          <el-select style="width: 320px" v-model="form.companyId" placeholder="请选择公司" clearable size="small">
+            <el-option
+              v-for="item in companys"
+              :key="item.companyId"
+              :label="item.companyName"
+              :value="item.companyId"
+            />
+          </el-select>
         </el-form-item>
-        <el-form-item label="累计时长 分" prop="totalTimes">
-          <el-input v-model="form.totalTimes" placeholder="请输入累计时长 分" />
+        <el-form-item label="通话套餐" prop="packageId">
+          <el-select style="width: 320px" v-model="form.packageId" placeholder="请选择套餐" clearable size="small">
+            <el-option
+              v-for="item in allVoicePackageData"
+              :key="item.packageId"
+              :label="item.packageName"
+              :value="item.packageId"
+            />
+          </el-select>
         </el-form-item>
+<!--        <el-form-item label="剩余时长 分" prop="times">-->
+<!--          <el-input v-model="form.times" placeholder="请输入剩余时长 分" />-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="累计时长 分" prop="totalTimes">-->
+<!--          <el-input v-model="form.totalTimes" placeholder="请输入累计时长 分" />-->
+<!--        </el-form-item>-->
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button type="primary" @click="submitForm" :disabled="buyBtnDisable">确 定</el-button>
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
@@ -69,7 +93,14 @@
 </template>
 
 <script>
-import { listCompanyVoice, getCompanyVoice, delCompanyVoice, addCompanyVoice, updateCompanyVoice, exportCompanyVoice } from "@/api/company/companyVoice";
+import {
+  listCompanyVoice,
+  getCompanyVoice,
+  updateCompanyVoice,
+  exportCompanyVoice,
+  companyBuyVoice
+} from "@/api/company/companyVoice";
+import {listAllCompanyVoicePackage} from "@/api/company/companyVoicePackage";
 import { getCompanyList } from "@/api/company/company";
 export default {
   name: "CompanyVoice",
@@ -86,10 +117,12 @@ export default {
       multiple: true,
       // 显示搜索条件
       showSearch: true,
+      buyBtnDisable: false,
       // 总条数
       total: 0,
       // 企业通话表格数据
       companyVoiceList: [],
+      allVoicePackageData: [],
       // 弹出层标题
       title: "",
       // 是否显示弹出层
@@ -115,6 +148,9 @@ export default {
       this.companys = response.data;
 
     });
+    listAllCompanyVoicePackage({status:1}).then(response => {
+      this.allVoicePackageData = response.data;
+    });
   },
   methods: {
     /** 查询企业通话列表 */
@@ -134,10 +170,8 @@ export default {
     // 表单重置
     reset() {
       this.form = {
-        voiceId: null,
         companyId: null,
-        times: null,
-        totalTimes: null
+        packageId: null
       };
       this.resetForm("form");
     },
@@ -177,23 +211,22 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-          if (this.form.voiceId != null) {
-            updateCompanyVoice(this.form).then(response => {
-              if (response.code === 200) {
-                this.msgSuccess("修改成功");
-                this.open = false;
-                this.getList();
-              }
-            });
-          } else {
-            addCompanyVoice(this.form).then(response => {
-              if (response.code === 200) {
-                this.msgSuccess("新增成功");
-                this.open = false;
-                this.getList();
-              }
-            });
-          }
+          this.buyBtnDisable = true
+          companyBuyVoice(this.form).then(response=>{
+            if (response.code === 200) {
+              this.msgSuccess("充值成功");
+              this.open = false;
+              this.getList();
+            }
+          }).catch(err=>{
+            this.msgError(err.message)
+            this.open = false
+          }).finally(()=>{
+            this.reset();
+            setTimeout(()=>{
+              this.buyBtnDisable = false
+            },1000)
+          })
         }
       });
     },