Browse Source

Merge branch 'master_migration_wx_pay_20250805'

xdd 4 days ago
parent
commit
1e142e5541

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

@@ -50,4 +50,13 @@ export function exportCompanyRecharge(query) {
     method: 'get',
     params: query
   })
-}
+}
+
+// 充值接口
+export function recharge(data) {
+  return request({
+    url: '/company/companyRecharge/recharge',
+    method: 'post',
+    data: data
+  })
+}

+ 104 - 51
src/views/company/companyRecharge/doRecharge.vue

@@ -7,26 +7,22 @@
              <span style="font-size:20px;color:red;">{{money}}</span>元
           </el-form-item>
           <el-form-item label="充值金额" prop="money">
-            <el-input v-model="form.money" style="width:200px" placeholder="请输入充值金额" />
+            <el-input-number  v-model="form.money" style="width:200px" placeholder="请输入充值金额" />
           </el-form-item>
           <el-form-item label="支付方式" prop="payType">
                <div class="radio">
                  <div class="radio-item">
                      <el-radio v-model="form.payType" :label=1><img class="radio-img" src="../../../assets/image/WeChat_icon30.png">微信</el-radio>
                  </div>
-                 <div class="radio-item">
-                     <el-radio v-model="form.payType" :label=2><img class="radio-img" src="../../../assets/image/alipay_icon30.png">支付宝</el-radio>
-                 </div>
                </div>
             </el-form-item>
             <div class="footer-btn">
               <el-button type="primary" @click="submitForm">充值</el-button>
             </div>
-            
         </el-form>
       </el-tab-pane>
     </el-tabs>
-    <el-dialog :title="payTitle" :visible.sync="payVisible" top="10vh" width="550px" class="my-dialog">
+    <el-dialog :title="payTitle" :visible.sync="payVisible" top="10vh" width="550px" class="my-dialog" @close="handleDialogClose">
       <div class="pay-dialog-cont">
         <div class="price">
           <span class="label">应付金额</span>
@@ -36,7 +32,6 @@
         <div class="order-sn">订单编号:{{orderNo}}</div>
         <div class="code-box">
           <div class="qrcode" ref="qrCodeUrl"></div>
-          <!-- <img src="../../assets/image/qr.png" alt=""> -->
         </div>
         <div class="tip-box">
           <span>请使用<span class="orange">微信</span>扫一扫</span>
@@ -44,40 +39,68 @@
         </div>
       </div>
     </el-dialog>
-     
+
   </div>
 </template>
 
 <script>
 import { listCompanyRecharge, getCompanyRecharge, delCompanyRecharge, addCompanyRecharge, updateCompanyRecharge, exportCompanyRecharge } from "@/api/company/companyRecharge";
 import { getCompanyInfo } from "@/api/company/company";
-import { weixinPay } from "@/api/company/pay";
+import {queryOrder, weixinPay, wxQrPay} from "@/api/company/pay";
 import QRCode from 'qrcodejs2'
 
 export default {
   name: "CompanyRecharge",
   data() {
     return {
+      qrLoading: false,
+      qrPayUrl: '',
       orderNo:"",
-      payVisible: false, // 支付弹窗
+      payVisible: false,
       payTitle: '微信支付',
       toPayFlag:true,
       activeName:"first",
+      timer: null,
       money:0,
-      // 表单参数
       form: {
         payType:1,
       },
-      // 表单校验
       rules: {
         money: [
           { required: true, message: "金额不能为空", trigger: "blur" },
+          {
+            validator: (rule, value, callback) => {
+              if (value === '' || value === undefined || value === null) {
+                callback();
+                return;
+              }
+              const numValue = Number(value);
+              if (isNaN(numValue)) {
+                callback(new Error('请输入有效的金额'));
+                return;
+              }
+              if (numValue < 0.01) {
+                callback(new Error('最小充值金额为0.01元'));
+                return;
+              }
+              if (numValue > 10000) {
+                callback(new Error('最大充值金额为10000元'));
+                return;
+              }
+              if (!/^\d+(\.\d{1,2})?$/.test(value.toString())) {
+                callback(new Error('金额最多支持两位小数'));
+                return;
+              }
+              callback();
+            },
+            trigger: 'blur'
+          }
         ],
       }
     };
   },
   created() {
-     
+
     this.getDicts("company_pay_status").then((response) => {
       this.statusOptions = response.data;
     });
@@ -88,53 +111,83 @@ export default {
       this.money = response.data.money;
     });
   },
+  beforeDestroy() {
+    this.clearTimer();
+  },
   methods: {
-    creatQrCode(url) {
-      var qrcode = new QRCode(this.$refs.qrCodeUrl, {
-          text: url, // 需要转换为二维码的内容
-          width: 200,
-          height: 200,
-          colorDark: '#000000',
-          colorLight: '#ffffff',
-          correctLevel: QRCode.CorrectLevel.H
-      })
+    clearTimer() {
+      if (this.timer) {
+        clearInterval(this.timer);
+        this.timer = null;
+      }
     },
-    toPay(orderNo) {
-      if(this.form.payType == 1) {
-        this.payTitle = '微信支付'
-        var param={orderNo:orderNo,orderType:1};
-        weixinPay(param).then(response => {
-          this.creatQrCode(response.qr)
-        });
-        this.payVisible = true
-        
-      } else {
-        this.payTitle = '支付宝支付'
+    /**
+     * 创建二维码
+     * @param {string} url - 二维码内容URL
+     */
+    creatQrCode(url) {
+      // 首先清空容器,避免重复创建
+      if (this.$refs.qrCodeUrl) {
+        this.$refs.qrCodeUrl.innerHTML = '';
       }
-      
+
+      // 使用nextTick确保DOM已更新
+      this.$nextTick(() => {
+        try {
+          if (this.$refs.qrCodeUrl) {
+            new QRCode(this.$refs.qrCodeUrl, {
+              text: url, // 需要转换为二维码的内容
+              width: 200,
+              height: 200,
+              colorDark: '#000000',
+              colorLight: '#ffffff',
+              correctLevel: QRCode.CorrectLevel.H
+            });
+            console.log('二维码创建成功');
+          } else {
+            console.error('二维码容器不存在');
+            this.$message.error('二维码生成失败:容器不存在');
+          }
+        } catch (error) {
+          console.error('二维码创建失败:', error);
+          this.$message.error('二维码生成失败,请重试');
+        }
+      });
+    },
+    handleDialogClose(){
+      clearInterval(this.timer);
+      this.timer=null;
     },
     /** 提交按钮 */
     submitForm() {
-      this.msgError("未开放此功能");
-      return;
       var that=this;
-       if(this.orderNo!=""){
-        this.payVisible = true
-        return;
-      }
-      if(!this.toPayFlag){
-        return;
-      }
       this.$refs["form"].validate(valid => {
         if (valid) {
           that.toPayFlag=false;
-            addCompanyRecharge(this.form).then(response => {
-              if (response.code === 200) {
-                
-                that.orderNo=response.rechargeNo
-                that.toPay(response.rechargeNo);
-              }
-            });
+          wxQrPay({
+            amount: this.form.money
+          }).then(res=>{
+            if(res.code === 200) {
+              this.payVisible = true;
+              this.creatQrCode(res.data.qrLink);
+              this.orderNo = res.data.orderNo;
+
+
+              // 轮询订单是否完成
+              this.timer = setInterval(()=>{
+                queryOrder(res.data.orderNo).then(res=>{
+                  if(res.code === 200 && res.data.transactionId != null) {
+                    this.$message.success("支付成功!");
+                    clearInterval(this.timer);
+                    this.timer=null;
+                    setTimeout(()=>{
+                      window.location.reload()
+                    },2000)
+                  }
+                })
+              },1000)
+            }
+          })
         }
       });
     },
@@ -148,7 +201,7 @@ export default {
 .radio{
   display: flex;
   align-items: center;
-   
+
 
 }
 .radio-item{

+ 107 - 10
src/views/company/companyRecharge/index.vue

@@ -24,7 +24,7 @@
               />
         </el-select>
       </el-form-item>
-      
+
       <el-form-item>
         <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -39,6 +39,12 @@
           @click="handleExport"
           v-hasPermi="['company:companyRecharge:export']"
         >导出</el-button>
+        <el-button
+          size="mini"
+          type="primary"
+          icon="el-icon-edit"
+          @click="handleRecharge"
+        >充值</el-button>
       </el-col>
 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
@@ -53,7 +59,19 @@
               <el-tag prop="status" v-for="(item, index) in payTypeOptions"   v-if="scope.row.payType==item.dictValue">{{item.dictLabel}}</el-tag>
         </template>
       </el-table-column>
-       <el-table-column label="状态" align="center" prop="status" >
+      <el-table-column label="凭证照片" align="center" prop="images" >
+        <template slot-scope="scope">
+          <div v-if="scope.row.imgs != null && scope.row.imgs != undefined && scope.row.imgs != ''">
+            <el-image
+              style="width: 80px; height: 80px"
+              :src="scope.row.imgs.split(',')[0]"
+              :preview-src-list="scope.row.imgs.split(',')">
+            </el-image>
+            <p style="margin: 0">({{scope.row.imgs.split(',').length}} 张)</p>
+          </div>
+        </template>
+      </el-table-column>
+       <el-table-column label="支付状态" align="center" prop="status" >
         <template slot-scope="scope">
               <el-tag prop="status" v-for="(item, index) in statusOptions"  :type="scope.row.status==1?'success':'danger'"  v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
         </template>
@@ -63,6 +81,18 @@
           <span>{{ parseTime(scope.row.payTime) }}</span>
         </template>
       </el-table-column>
+      <el-table-column label="审核状态" align="center" prop="isAudit" >
+        <template slot-scope="scope">
+          <el-tag prop="isAudit" type="danger"  v-if="scope.row.isAudit === -1">已驳回</el-tag>
+          <el-tag prop="isAudit" type="warning"  v-if="scope.row.isAudit === 0">待审核</el-tag>
+          <el-tag prop="isAudit" type="success"  v-if="scope.row.isAudit === 1">已审核</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="审核时间" align="center" prop="auditTime" width="180">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.auditTime) }}</span>
+        </template>
+      </el-table-column>
     </el-table>
     <pagination
       v-show="total>0"
@@ -103,17 +133,43 @@
         <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="rechargeForm" :rules="rechargeRules" :model="rechargeForm"  label-width="80px">
+<!--        <el-form-item label="公司" >-->
+<!--          <el-input v-model="rechargeForm.companyName" disabled />-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="余额" >-->
+<!--          <el-input v-model="rechargeForm.balance" disabled />-->
+<!--        </el-form-item>-->
+        <el-form-item label="充值金额" prop="money">
+          <el-input-number v-model="rechargeForm.money" :min="0" placeholder="请输入充值金额" />
+        </el-form-item>
+        <el-form-item label="凭证" prop="imgs">
+          <image-upload v-model="rechargeForm.imgs" :limit="9" />
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="rechargeForm.remark" placeholder="请输入备注" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitRechargeForm">确 定</el-button>
+        <el-button @click="recharge.open=false">取 消</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
 <script>
-import { listCompanyRecharge, getCompanyRecharge, delCompanyRecharge, addCompanyRecharge, updateCompanyRecharge, exportCompanyRecharge } from "@/api/company/companyRecharge";
-
+import { listCompanyRecharge, getCompanyRecharge, delCompanyRecharge, addCompanyRecharge, updateCompanyRecharge, exportCompanyRecharge, recharge } from "@/api/company/companyRecharge";
+import { getInfo } from '@/api/login';
 export default {
   name: "CompanyRecharge",
   data() {
     return {
-       
+
       payTypeOptions:[],
       statusOptions:[],
       // 遮罩层
@@ -149,15 +205,32 @@ export default {
       form: {},
       // 表单校验
       rules: {
-      }
+      },
+      recharge:{
+        open:false,
+        title:"后台充值"
+      },
+      // 表单校验
+      rechargeRules: {
+        money: [
+          { required: true, message: "充值金额不能为空", trigger: "blur" }
+        ],
+        imgs: [
+          { required: true, message: "凭证不能为空", trigger: "change" }
+        ],
+      },
+      // 表单参数
+      rechargeForm: {
+        money: 0,
+      },
     };
   },
   created() {
-     
-    this.getDicts("sys_company_pay_status").then((response) => {
+
+    this.getDicts("company_pay_status").then((response) => {
       this.statusOptions = response.data;
     });
-    this.getDicts("sys_comapny_recharge_pay_type").then((response) => {
+    this.getDicts("comapny_recharge_pay_type").then((response) => {
       this.payTypeOptions = response.data;
     });
     this.getList();
@@ -272,7 +345,31 @@ export default {
         }).then(response => {
           this.download(response.msg);
         }).catch(function() {});
-    }
+    },
+    /** 充值按钮操作 */
+    handleRecharge() {
+      this.rechargeForm = {
+        money: 0,
+        balance: 0, //默认余额为0
+        remark: '',
+        imgs: []
+      };
+      this.recharge.open = true;
+    },
+    /** 提交按钮 */
+    submitRechargeForm() {
+      this.$refs["rechargeForm"].validate(valid => {
+        if (valid) {
+          recharge(this.rechargeForm).then(response => {
+            if (response.code === 200) {
+              this.msgSuccess(response.msg);
+              this.recharge.open = false;
+              this.getList();
+            }
+          });
+        }
+      });
+    },
   }
 };
 </script>

+ 3 - 7
src/views/qw/sopTemp/index.vue

@@ -58,7 +58,7 @@
         <!--        >新增</el-button>-->
 
         <el-dropdown
-          v-if="roles.includes('qw:sopTemp:add')"
+          v-hasPermi="['qw:sopTemp:add']"
           @command="handleCommand"
           trigger="click"
           placement="bottom-start"
@@ -89,7 +89,6 @@
           size="mini"
           :disabled="multiple"
           @click="handleDelete"
-          v-if="roles.includes('qw:sopTemp:remove')"
           v-hasPermi="['qw:sopTemp:remove']"
         >删除
         </el-button>
@@ -139,7 +138,7 @@
             size="mini"
             type="text"
             icon="el-icon-connection"
-            v-if="roles.includes('qw:sopTemp:edit')"
+
             @click="copyTemplate(scope.row)"
             v-hasPermi="['qw:sopTemp:edit']"
           >复制模板
@@ -163,7 +162,6 @@
             size="mini"
             type="text"
             icon="el-icon-edit"
-            v-if="roles.includes('qw:sopTemp:edit')"
             @click="handleUpdate(scope.row)"
             v-hasPermi="['qw:sopTemp:edit']"
           >修改
@@ -173,7 +171,6 @@
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate2(scope.row)"
-            v-if="roles.includes('qw:sopTemp:edit')"
             v-hasPermi="['qw:sopTemp:edit']"
           >管理规则
           </el-button>
@@ -182,7 +179,7 @@
             type="text"
             icon="el-icon-edit"
             @click="handleUpdateRed(scope.row)"
-            v-if="scope.row.sendType == 5 && roles.includes('qw:sopTemp:edit')"
+            v-if="scope.row.sendType == 5"
             v-hasPermi="['qw:sopTemp:edit']"
           >红包设置
           </el-button>
@@ -191,7 +188,6 @@
             type="text"
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
-            v-if="roles.includes('qw:sopTemp:remove')"
             v-hasPermi="['qw:sopTemp:remove']"
           >删除
           </el-button>