Browse Source

调整多支付页面

yfh 2 weeks ago
parent
commit
6e1230e738

+ 53 - 0
src/api/system/wxMiniProgramConfig.js

@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 查询微信小程序支付配置列表
+export function listWxMiniProgramConfig(query) {
+  return request({
+    url: '/system/wxMiniProgramConfig/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询微信小程序支付配置详细
+export function getWxMiniProgramConfig(id) {
+  return request({
+    url: '/system/wxMiniProgramConfig/' + id,
+    method: 'get'
+  })
+}
+
+// 新增微信小程序支付配置
+export function addWxMiniProgramConfig(data) {
+  return request({
+    url: '/system/wxMiniProgramConfig',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改微信小程序支付配置
+export function updateWxMiniProgramConfig(data) {
+  return request({
+    url: '/system/wxMiniProgramConfig',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除微信小程序支付配置
+export function delWxMiniProgramConfig(id) {
+  return request({
+    url: '/system/wxMiniProgramConfig/' + id,
+    method: 'delete'
+  })
+}
+
+// 导出微信小程序支付配置
+export function exportWxMiniProgramConfig(query) {
+  return request({
+    url: '/system/wxMiniProgramConfig/export',
+    method: 'get',
+    params: query
+  })
+}

+ 0 - 204
src/views/system/coursePlaySourceConfig/index.vue

@@ -10,27 +10,6 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="所属公司" prop="companyId">
-        <el-select
-          v-model="queryParams.companyId"
-          filterable
-          remote
-          reserve-keyword
-          placeholder="请输入公司名称搜索"
-          :remote-method="searchCompanies"
-          :loading="companySearchLoading"
-          style="width: 220px"
-          clearable
-          size="small"
-        >
-          <el-option
-            v-for="item in companyOptions"
-            :key="item.dictValue"
-            :label="item.dictLabel"
-            :value="item.dictValue"
-          />
-        </el-select>
-      </el-form-item>
       <el-form-item label="appid" prop="appid">
         <el-input
           v-model="queryParams.appid"
@@ -97,41 +76,10 @@
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <!-- 开关配置对话框 -->
-    <el-dialog title="开关配置" :visible.sync="switchDialogVisible" width="500px" class="switch-dialog">
-      <el-form :model="switchForm" label-width="100px">
-        <el-form-item label="AppId">
-          <el-input v-model="switchForm.appId" :disabled="true"></el-input>
-        </el-form-item>
-        <el-form-item label="开关状态">
-          <el-switch
-            v-model="switchForm.switchStatus"
-            active-text="开启"
-            inactive-text="关闭"
-            active-value="001"
-            inactive-value="002">
-          </el-switch>
-        </el-form-item>
-        <el-form-item label="配置信息" v-if="switchForm.configInfo">
-          <el-input
-            type="textarea"
-            :rows="4"
-            v-model="switchForm.configInfo"
-            :disabled="true">
-          </el-input>
-        </el-form-item>
-      </el-form>
-      <span slot="footer" class="dialog-footer">
-                <el-button @click="switchDialogVisible = false">取 消</el-button>
-                <el-button type="primary" @click="submitSwitchConfig">确 定</el-button>
-            </span>
-    </el-dialog>
-
     <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange" border>
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="ID" align="center" prop="id" />
       <el-table-column label="名称" align="center" prop="name" />
-      <el-table-column label="所属公司" align="center" prop="companyId" :formatter="companyNameFormatter"/>
       <el-table-column label="图标" align="center" prop="img">
         <template slot-scope="scope">
           <el-image
@@ -147,16 +95,6 @@
       <el-table-column label="token" align="center" prop="token" />
       <el-table-column label="aesKey" align="center" prop="aesKey" />
       <el-table-column label="msgDataFormat" align="center" prop="msgDataFormat" />
-      <el-table-column label="类型" align="center" prop="type">
-        <template slot-scope="scope">
-          <dict-tag  :options="typesOptions" :value="scope.row.type"/>
-        </template>
-      </el-table-column>
-      <el-table-column label="互医/商城小程序" align="center" prop="isMall" width="80px">
-        <template slot-scope="scope">
-          <el-tag prop="isMall" v-for="(item, index) in isMallOptions" v-if="scope.row.isMall==item.dictValue">{{item.dictLabel}}</el-tag>
-        </template>
-      </el-table-column>
             <el-table-column label="状态" align="center" prop="status" width="100px">
         <template slot-scope="scope">
           <el-tag
@@ -184,12 +122,6 @@
             @click="handleDelete(scope.row)"
             v-hasPermi="['course:playSourceConfig:remove']"
           >删除</el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-setting"
-            @click="handleSwitchConfig(scope.row)"
-          >是否展示销售</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -207,64 +139,6 @@
       <el-form ref="form" :model="form" :rules="rules" label-width="130px">
         <el-form-item label="名称" prop="name">
           <el-input v-model="form.name" placeholder="请输入名称" />
-        </el-form-item>
-        <el-form-item label="所属公司" prop="companyId">
-          <el-select
-            v-model="form.companyId"
-            filterable
-            remote
-            reserve-keyword
-            placeholder="请输入公司名称搜索"
-            :remote-method="searchCompanies"
-            :loading="companySearchLoading"
-            style="width: 220px"
-            clearable
-            size="small"
-          >
-            <el-option
-              v-for="item in companyOptions"
-              :key="item.dictValue"
-              :label="item.dictLabel"
-              :value="item.dictValue"
-            />
-          </el-select>
-        </el-form-item>
-         <el-form-item label="可查看设置公司" prop="setCompanyIdList">
-          <el-select
-            v-model="form.setCompanyIdList"
-            filterable
-            multiple
-            remote
-            reserve-keyword
-            placeholder="请输入公司名称搜索"
-            :remote-method="searchCompanies"
-            :loading="companySearchLoading"
-            style="width: 220px"
-            clearable
-            size="small"
-          >
-            <el-option
-              v-for="item in companyOptions"
-              :key="item.dictValue"
-              :label="item.dictLabel"
-              :value="item.dictValue"
-            />
-          </el-select>
-        </el-form-item>
-        <el-form-item label="是否是互医/商城小程序" prop="isMall">
-          <el-select
-            v-model="form.isMall"
-            style="width: 220px"
-            clearable
-            size="small"
-          >
-            <el-option
-              v-for="item in isMallOptions"
-              :key="item.dictValue"
-              :label="item.dictLabel"
-              :value="item.dictValue"
-            />
-          </el-select>
         </el-form-item>
                 <el-form-item label="状态" prop="status">
           <el-select
@@ -285,17 +159,6 @@
         <el-form-item label="图标" prop="img">
           <image-upload v-model="form.img" :file-type='["png", "jpg", "jpeg"]' :limit="1"/>
         </el-form-item>
-        <el-form-item label="类型" prop="type">
-          <el-select
-            v-model="form.type"
-            placeholder="请选择类型">
-            <el-option
-              v-for="item in typesOptions"
-              :key="item.dictValue"
-              :label="item.dictLabel"
-              :value="item.dictValue"/>
-          </el-select>
-        </el-form-item>
         <el-form-item label="原始id" prop="originalId">
           <el-input v-model="form.originalId" placeholder="请输入原始id" />
         </el-form-item>
@@ -335,15 +198,10 @@ export default {
   name: 'CoursePlaySourceConfig',
   data() {
     return {
-      switchDialogVisible: false,
       // 公司搜索相关
       companySearchLoading: false,
       companyOptions: [],
       formatterCompanyOptions: [],
-      switchForm: {
-        appId: '',
-        switchStatus: '001',
-      },
       queryParams: {
         pageNum: 1,
         pageSize: 10,
@@ -401,9 +259,6 @@ export default {
         img: [
           { required: true, message: "图标不能为空", trigger: "blur" }
         ],
-        type: [
-          { required: true, message: "类型不能为空", trigger: "blur" }
-        ],
         originalId: [
           { required: true, message: "原始id不能为空", trigger: "blur" }
         ],
@@ -444,54 +299,6 @@ export default {
       this.open = false;
     },
 
-
-    // 处理开关配置
-    handleSwitchConfig(row) {
-      this.switchForm.appId = row.appid;
-      this.switchForm.switchStatus = "001"; // 默认关闭状态
-
-      // 调用接口获取开关状态
-      this.getSwitchConfig(row.appid);
-      this.switchDialogVisible = true;
-    },
-    /** 搜索公司 */
-    searchCompanies(query) {
-      // this.companySearchLoading = true;
-      // allList().then(response => {
-      //   this.companyOptions = response.rows;
-      //   if (query) {
-      //     this.companyOptions = this.companyOptions.filter(item =>
-      //       item.dictLabel.includes(query)
-      //     );
-      //   }
-      //   this.companySearchLoading = false;
-      // }).catch(()=>{
-      //   this.companySearchLoading = false;
-      // });
-    },
-    companyNameFormatter(row){
-      let company = this.formatterCompanyOptions.filter(item => item.dictValue === row.companyId)[0];
-      return company ? company.dictLabel : '';
-    },
-
-    // 获取开关配置
-    getSwitchConfig(appId) {
-      const params = {
-        appId: this.switchForm.appId
-      };
-      updateIsTownOn(params).then(response=>{
-        if (response.code === 200) {
-          if ( response.date){
-            this.switchForm.switchStatus = response.date;
-          }
-        } else {
-          this.$message.error('获取配置失败: ' + response.msg);
-        }
-      }).catch(error => {
-        this.$message.error('请求失败: ' + error.message);
-      });
-    },
-
     // 提交开关配置
     submitSwitchConfig() {
       const params = {
@@ -537,18 +344,7 @@ export default {
       get(id).then(response => {
         this.form = {
           ...response.data,
-          type: response.data.type.toString()
-        }
-        if(!!this.form.setCompanyIds){
-           this.$set(
-            this.form,
-            "setCompanyIdList",
-            this.form.setCompanyIds.split(",").map(str => parseInt(str, 10))
-          );
-          // this.form.setCompanyIdList = this.form.setCompanyIds.split(",").map(str => parseInt(str, 10));
         }
-        console.log( this.form);
-        this.searchCompanies("");
         this.open = true
         this.title = "修改小程序配置"
       })

+ 407 - 0
src/views/system/wxMiniProgramConfig/index.vue

@@ -0,0 +1,407 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="小程序名称" prop="appName">
+        <el-input
+          v-model="queryParams.appName"
+          placeholder="请输入小程序名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="小程序appid" prop="appid">
+        <el-input
+          v-model="queryParams.appid"
+          placeholder="请输入小程序appid"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </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>
+      </el-form-item>
+    </el-form>
+
+    <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="['system:wxMiniProgramConfig:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['system:wxMiniProgramConfig:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['system:wxMiniProgramConfig:remove']"
+        >删除</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['system:wxMiniProgramConfig:export']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="wxMiniProgramConfigList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+            <el-table-column label="主键ID" align="center" prop="id" />
+      <el-table-column label="小程序名称" align="center" prop="appName" />
+      <el-table-column label="小程序appid" align="center" prop="appid" />
+      <el-table-column label="小程序密钥" align="center" prop="appSecret" />
+      <el-table-column label="微信商户号" align="center" prop="wxMerchantNo" />
+      <el-table-column label="商户简称" align="center" prop="merchantShortName" />
+      <el-table-column label="管理员" align="center" prop="adminName" />
+      <el-table-column label="签约时间" align="center" prop="signingTime" width="180">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.signingTime) }}</span>
+        </template>
+      </el-table-column>
+    <el-table-column label="微信API密钥" align="center" prop="wxKey" />
+      <el-table-column label="微信V3密钥" align="center" prop="wxV3Key" />
+      <el-table-column label="微信证书路径" align="center" prop="wxKeyPath" />
+      <el-table-column label="微信支付回调地址" align="center" prop="wxNotifyUrl" />
+      <el-table-column label="状态" align="center" prop="status">
+        <template slot-scope="scope">
+          <dict-tag :options="statusOptions" :value="scope.row.status"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="备注" align="center" prop="remark" />
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['system:wxMiniProgramConfig:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['system:wxMiniProgramConfig:remove']"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 添加或修改微信小程序支付配置对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="小程序" prop="appid">
+          <el-select
+            v-model="form.appid"
+            placeholder="请选择小程序"
+            clearable
+            size="small"
+            style="width: 100%"
+          >
+            <el-option
+              v-for="item in miniAppList"
+              :key="item.appId"
+              :label="item.appName"
+              :value="item.appId"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="商户号" prop="wxMerchantNo">
+          <el-input v-model="form.wxMerchantNo" placeholder="请输入微信商户号" />
+        </el-form-item>
+        <el-form-item label="商户简称" prop="merchantShortName">
+          <el-input v-model="form.merchantShortName" placeholder="请输入微信商户简称" />
+        </el-form-item>
+        <el-form-item label="管理员" prop="adminName">
+          <el-input v-model="form.adminName" placeholder="请输入微信商户号管理员" />
+        </el-form-item>
+        <el-form-item label="签约时间" prop="signingTime">
+          <el-date-picker clearable size="small" style="width: 215px"
+                          v-model="form.signingTime"
+                          type="date"
+                          value-format="yyyy-MM-dd"
+                          placeholder="请选择">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="API密钥" prop="wxKey">
+          <el-input v-model="form.wxKey" placeholder="请输入微信API密钥" />
+        </el-form-item>
+        <el-form-item label="微信V3密钥" prop="wxV3Key">
+          <el-input v-model="form.wxV3Key" placeholder="请输入微信V3密钥" />
+        </el-form-item>
+        <el-form-item label="证书路径" prop="wxKeyPath">
+          <el-input v-model="form.wxKeyPath" type="textarea" placeholder="请输入内容" />
+        </el-form-item>
+        <el-form-item label="支付回调地址" prop="wxNotifyUrl">
+          <el-input v-model="form.wxNotifyUrl" type="textarea" placeholder="请输入内容" />
+        </el-form-item>
+        <el-form-item label="状态" prop="status">
+          <el-select style="width: 220px" v-model="form.status" placeholder="请选择状态" size="small">
+            <el-option
+              v-for="dict in statusOptions"
+              :key="dict.dictValue"
+              :label="dict.dictLabel"
+              :value="dict.dictValue"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listWxMiniProgramConfig, getWxMiniProgramConfig, delWxMiniProgramConfig, addWxMiniProgramConfig, updateWxMiniProgramConfig, exportWxMiniProgramConfig } from "@/api/system/wxMiniProgramConfig";
+import { listAll } from '@/api/system/coursePlaySourceConfig'
+export default {
+  name: "WxMiniProgramConfig",
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      miniAppList: [],
+      // 总条数
+      total: 0,
+      // 微信小程序支付配置表格数据
+      wxMiniProgramConfigList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      statusOptions: [],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        appName: null,
+        appid: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        appid: [
+          { required: true, message: "小程序appid不能为空", trigger: "blur" }
+        ],
+        wxMerchantNo: [
+          { required: true, message: "微信商户号不能为空", trigger: "blur" }
+        ],
+        wxKey: [
+          { required: true, message: "微信API密钥不能为空", trigger: "blur" }
+        ],
+        wxV3Key: [
+          { required: true, message: "微信V3密钥不能为空", trigger: "blur" }
+        ],
+        wxNotifyUrl: [
+          { required: true, message: "微信支付回调地址不能为空", trigger: "blur" }
+        ],
+      }
+    };
+  },
+  created() {
+    this.getList();
+    this.getDicts("sys_normal_disable").then(response => {
+      this.statusOptions = response.data;
+    });
+  },
+  methods: {
+
+    getAppList() {
+      this.miniAppList = []
+      listAll().then(response => {
+        const { code, data } = response
+        if (code === 200) {
+          if (data) {
+            this.miniAppList = data.map(v => {
+              return { appId: v.appid, appName: v.name }
+            })
+          }
+        }
+      })
+    },
+
+    /** 查询微信小程序支付配置列表 */
+    getList() {
+      this.loading = true;
+      listWxMiniProgramConfig(this.queryParams).then(response => {
+        // 确保状态字段是字符串类型,以便正确显示字典标签
+        this.wxMiniProgramConfigList = response.rows.map(item => ({
+          ...item,
+          status: String(item.status)  // 转换为字符串类型
+        }));
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        appName: null,
+        appid: null,
+        appSecret: null,
+        wxMerchantNo: null,
+        wxKey: null,
+        wxKeyPath: null,
+        wxNotifyUrl: null,
+        status: "0",  // 改为字符串类型,与字典值一致
+        createTime: null,
+        updateTime: null,
+        createBy: null,
+        updateBy: null,
+        remark: null
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length !== 1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      // 确保状态字段有默认值
+      this.getAppList()
+      this.form.status = "0";
+      this.open = true;
+      this.title = "添加微信小程序支付配置";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      this.getAppList()
+      const id = row.id || this.ids;
+      getWxMiniProgramConfig(id).then(response => {
+        // 确保获取到的状态字段是字符串类型
+        this.form = {
+          ...response.data,
+          status: String(response.data.status || "0")
+        };
+        this.open = true;
+        this.title = "修改微信小程序支付配置";
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          // 提交前确保状态字段是字符串类型
+          const submitData = {
+            ...this.form,
+            status: String(this.form.status || "0")
+          };
+
+          if (submitData.id != null) {
+            updateWxMiniProgramConfig(submitData).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("修改成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          } else {
+            addWxMiniProgramConfig(submitData).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("新增成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+      this.$confirm('是否确认删除微信小程序支付配置编号为"' + ids + '"的数据项?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function() {
+        return delWxMiniProgramConfig(ids);
+      }).then(() => {
+        this.getList();
+        this.msgSuccess("删除成功");
+      }).catch(function() {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm('是否确认导出所有微信小程序支付配置数据项?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function() {
+        return exportWxMiniProgramConfig(queryParams);
+      }).then(response => {
+        this.download(response.msg);
+      }).catch(function() {});
+    }
+  }
+};
+</script>