index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="应用名" prop="name">
  6. <el-input v-model="queryParams.name" placeholder="请输入应用名" clearable size="small"
  7. @keyup.enter.native="handleQuery"/>
  8. </el-form-item>
  9. <el-form-item label="商户名称" prop="merchantName">
  10. <el-input v-model="queryParams.merchantName" placeholder="请输入商户名称" clearable size="small"
  11. @keyup.enter.native="handleQuery"/>
  12. </el-form-item>
  13. <el-form-item label="开启状态" prop="status">
  14. <el-select v-model="queryParams.status" placeholder="请选择开启状态" clearable size="small">
  15. <el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label"
  16. :value="parseInt(dict.value)"/>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  21. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  22. </el-form-item>
  23. </el-form>
  24. <!-- 操作工具栏 -->
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  28. v-hasPermi="['pay:app:create']">新增
  29. </el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  33. v-hasPermi="['pay:app:export']">导出
  34. </el-button>
  35. </el-col>
  36. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  37. </el-row>
  38. <!-- 列表 -->
  39. <el-table v-loading="loading" :data="list">
  40. <el-table-column label="应用编号" align="center" prop="id"/>
  41. <el-table-column label="应用名" align="center" prop="name"/>
  42. <el-table-column label="开启状态" align="center" prop="status">
  43. <template slot-scope="scope">
  44. <el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1"
  45. @change="handleStatusChange(scope.row)"/>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="商户名称" align="center" prop="payMerchant.name"/>
  49. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  50. <template slot-scope="scope">
  51. <span>{{ parseTime(scope.row.createTime) }}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="支付宝配置" align="center">
  55. <el-table-column :label="payChannelEnum.ALIPAY_APP.name" align="center">
  56. <template slot-scope="scope">
  57. <el-button type="success" icon="el-icon-check" circle
  58. v-if="scope.row.payChannel.alipayApp === sysCommonStatusEnum.ENABLE"></el-button>
  59. <el-button type="danger" icon="el-icon-close" circle
  60. v-if="scope.row.payChannel.alipayApp === sysCommonStatusEnum.DISABLE"></el-button>
  61. </template>
  62. </el-table-column>
  63. <el-table-column :label="payChannelEnum.ALIPAY_PC.name" align="center">
  64. <template slot-scope="scope">
  65. <el-button type="success" icon="el-icon-check" circle
  66. v-if="scope.row.payChannel.alipayPc === sysCommonStatusEnum.ENABLE"></el-button>
  67. <el-button type="danger" icon="el-icon-close" circle
  68. v-if="scope.row.payChannel.alipayPc === sysCommonStatusEnum.DISABLE"></el-button>
  69. </template>
  70. </el-table-column>
  71. <el-table-column :label="payChannelEnum.ALIPAY_WAP.name" align="center">
  72. <template slot-scope="scope">
  73. <el-button type="success" icon="el-icon-check" circle
  74. v-if="scope.row.payChannel.alipayWap === sysCommonStatusEnum.ENABLE"></el-button>
  75. <el-button type="danger" icon="el-icon-close" circle
  76. v-if="scope.row.payChannel.alipayWap === sysCommonStatusEnum.DISABLE"></el-button>
  77. </template>
  78. </el-table-column>
  79. <el-table-column :label="payChannelEnum.ALIPAY_QR.name" align="center">
  80. <template slot-scope="scope">
  81. <el-button type="success" icon="el-icon-check" circle
  82. v-if="scope.row.payChannel.alipayQr === sysCommonStatusEnum.ENABLE"></el-button>
  83. <el-button type="danger" icon="el-icon-close" circle
  84. v-if="scope.row.payChannel.alipayQr === sysCommonStatusEnum.DISABLE"></el-button>
  85. </template>
  86. </el-table-column>
  87. </el-table-column>
  88. <el-table-column label="微信配置" align="center">
  89. <el-table-column :label="payChannelEnum.WX_LITE.name" align="center">
  90. <template slot-scope="scope">
  91. <el-button type="success" icon="el-icon-check" circle
  92. @click="handleUpdateChannel(scope.row,payChannelEnum.WX_LITE.code)"
  93. v-if="scope.row.payChannel.wxLite === sysCommonStatusEnum.ENABLE"></el-button>
  94. <el-button type="danger" icon="el-icon-close" circle
  95. @click="handleCreateChannel(scope.row,payChannelEnum.WX_LITE.code)"
  96. v-if="scope.row.payChannel.wxLite === sysCommonStatusEnum.DISABLE"></el-button>
  97. </template>
  98. </el-table-column>
  99. <el-table-column :label="payChannelEnum.WX_PUB.name" align="center">
  100. <template slot-scope="scope">
  101. <el-button
  102. type="success" icon="el-icon-check" circle
  103. @click="handleUpdateChannel(scope.row,payChannelEnum.WX_PUB.code)"
  104. v-if="scope.row.payChannel.wxPub === sysCommonStatusEnum.ENABLE">
  105. </el-button>
  106. <el-button type="danger" icon="el-icon-close" circle
  107. @click="handleCreateChannel(scope.row,payChannelEnum.WX_PUB.code)"
  108. v-if="scope.row.payChannel.wxPub === sysCommonStatusEnum.DISABLE"></el-button>
  109. </template>
  110. </el-table-column>
  111. <el-table-column :label="payChannelEnum.WX_APP.name" align="center">
  112. <template slot-scope="scope">
  113. <el-button type="success" icon="el-icon-check" circle
  114. @click="handleUpdateChannel(scope.row,payChannelEnum.WX_APP.code)"
  115. v-if="scope.row.payChannel.wxApp === sysCommonStatusEnum.ENABLE"></el-button>
  116. <el-button type="danger" icon="el-icon-close" circle
  117. @click="handleCreateChannel(scope.row,payChannelEnum.WX_APP.code)"
  118. v-if="scope.row.payChannel.wxApp === sysCommonStatusEnum.DISABLE"></el-button>
  119. </template>
  120. </el-table-column>
  121. </el-table-column>
  122. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  123. <template slot-scope="scope">
  124. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  125. v-hasPermi="['pay:app:update']">修改
  126. </el-button>
  127. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  128. v-hasPermi="['pay:app:delete']">删除
  129. </el-button>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <!-- 分页组件 -->
  134. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  135. @pagination="getList"/>
  136. <!-- 对话框(添加 / 修改) -->
  137. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  138. <el-form ref="form" :model="form" :rules="rules" label-width="160px">
  139. <el-form-item label="应用名" prop="name">
  140. <el-input v-model="form.name" placeholder="请输入应用名"/>
  141. </el-form-item>
  142. <el-form-item label="所属商户" prop="merchantId">
  143. <el-select
  144. v-model="form.merchantId"
  145. filterable
  146. remote
  147. reserve-keyword
  148. placeholder="请选择所属商户"
  149. :remote-method="handleGetMerchantListByName"
  150. :loading="loading">
  151. <el-option
  152. v-for="item in merchantList"
  153. :key="item.id"
  154. :label="item.name"
  155. :value="item.id">
  156. </el-option>
  157. </el-select>
  158. <!-- <el-input v-model="form.merchantId" placeholder="请输入商户编号"/>-->
  159. </el-form-item>
  160. <el-form-item label="开启状态" prop="status">
  161. <el-radio-group v-model="form.status">
  162. <el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
  163. {{ dict.label }}
  164. </el-radio>
  165. </el-radio-group>
  166. </el-form-item>
  167. <el-form-item label="支付结果的回调地址" prop="payNotifyUrl">
  168. <el-input v-model="form.payNotifyUrl" placeholder="请输入支付结果的回调地址"/>
  169. </el-form-item>
  170. <el-form-item label="退款结果的回调地址" prop="refundNotifyUrl">
  171. <el-input v-model="form.refundNotifyUrl" placeholder="请输入退款结果的回调地址"/>
  172. </el-form-item>
  173. <el-form-item label="备注" prop="remark">
  174. <el-input v-model="form.remark" placeholder="请输入备注"/>
  175. </el-form-item>
  176. </el-form>
  177. <div slot="footer" class="dialog-footer">
  178. <el-button type="primary" @click="submitForm">确 定</el-button>
  179. <el-button @click="cancel">取 消</el-button>
  180. </div>
  181. </el-dialog>
  182. <wechat-js-api-form :transferParam="wechatChannelParam"></wechat-js-api-form>
  183. </div>
  184. </template>
  185. <script>
  186. import {createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage, exportAppExcel} from "@/api/pay/app";
  187. import {DICT_TYPE, getDictDatas} from "@/utils/dict";
  188. import {PayChannelEnum, SysCommonStatusEnum} from "@/utils/constants";
  189. import {getMerchantListByName} from "@/api/pay/merchant";
  190. import wechatJsApiForm from "@/views/pay/app/components/wechatJsApiForm";
  191. export default {
  192. name: "App",
  193. components: {
  194. "wechatJsApiForm": wechatJsApiForm
  195. },
  196. data() {
  197. return {
  198. // 遮罩层
  199. loading: true,
  200. // 显示搜索条件
  201. showSearch: true,
  202. // 总条数
  203. total: 0,
  204. // 支付应用信息列表
  205. list: [],
  206. // 弹出层标题
  207. title: "",
  208. // 是否显示弹出层
  209. open: false,
  210. dateRangeCreateTime: [],
  211. // 查询参数
  212. queryParams: {
  213. pageNo: 1,
  214. pageSize: 10,
  215. name: null,
  216. status: null,
  217. remark: null,
  218. payNotifyUrl: null,
  219. refundNotifyUrl: null,
  220. merchantName: null,
  221. },
  222. // 表单参数
  223. form: {},
  224. // 表单校验
  225. rules: {
  226. name: [{required: true, message: "应用名不能为空", trigger: "blur"}],
  227. status: [{required: true, message: "开启状态不能为空", trigger: "blur"}],
  228. payNotifyUrl: [{required: true, message: "支付结果的回调地址不能为空", trigger: "blur"}],
  229. refundNotifyUrl: [{required: true, message: "退款结果的回调地址不能为空", trigger: "blur"}],
  230. merchantId: [{required: true, message: "商户编号不能为空", trigger: "blur"}],
  231. },
  232. // 数据字典
  233. statusDictDatas: getDictDatas(DICT_TYPE.PAY_APP_STATUS),
  234. sysCommonStatusEnum: SysCommonStatusEnum,
  235. // 支付渠道枚举
  236. payChannelEnum: PayChannelEnum,
  237. // 商户列表
  238. merchantList: [],
  239. // 是否显示支付窗口
  240. payOpen: false,
  241. // 微信组件传参参数
  242. wechatChannelParam: {
  243. // 是否修改
  244. "edit":false,
  245. // 是否显示
  246. "open":false,
  247. // 应用ID
  248. "appId": null,
  249. // 渠道编码
  250. "payCode": null,
  251. // 商户对象
  252. "payMerchant": {
  253. // 编号
  254. "id": null,
  255. // 名称
  256. "name": null
  257. },
  258. }
  259. };
  260. },
  261. created() {
  262. this.getList();
  263. },
  264. methods: {
  265. /** 查询列表 */
  266. getList() {
  267. this.loading = true;
  268. // 处理查询参数
  269. let params = {...this.queryParams};
  270. this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
  271. // 执行查询
  272. getAppPage(params).then(response => {
  273. console.log(response.data);
  274. this.list = response.data.list;
  275. this.total = response.data.total;
  276. this.loading = false;
  277. });
  278. },
  279. /** 取消按钮 */
  280. cancel() {
  281. this.open = false;
  282. this.reset();
  283. },
  284. /** 表单重置 */
  285. reset() {
  286. this.form = {
  287. id: undefined,
  288. name: undefined,
  289. status: undefined,
  290. remark: undefined,
  291. payNotifyUrl: undefined,
  292. refundNotifyUrl: undefined,
  293. merchantId: undefined,
  294. };
  295. this.resetForm("form");
  296. },
  297. /** 搜索按钮操作 */
  298. handleQuery() {
  299. this.queryParams.pageNo = 1;
  300. this.getList();
  301. },
  302. /** 重置按钮操作 */
  303. resetQuery() {
  304. this.dateRangeCreateTime = [];
  305. this.resetForm("queryForm");
  306. this.handleQuery();
  307. },
  308. /** 新增按钮操作 */
  309. handleAdd() {
  310. this.reset();
  311. this.open = true;
  312. this.title = "添加支付应用信息";
  313. },
  314. /** 修改按钮操作 */
  315. handleUpdate(row) {
  316. this.reset();
  317. const id = row.id;
  318. getApp(id).then(response => {
  319. this.form = response.data;
  320. this.open = true;
  321. this.title = "修改支付应用信息";
  322. });
  323. },
  324. // 用户状态修改
  325. handleStatusChange(row) {
  326. let text = row.status === SysCommonStatusEnum.ENABLE ? "启用" : "停用";
  327. this.$confirm('确认要"' + text + '""' + row.name + '"应用吗?', "警告", {
  328. confirmButtonText: "确定",
  329. cancelButtonText: "取消",
  330. type: "warning"
  331. }).then(function () {
  332. return changeAppStatus(row.id, row.status);
  333. }).then(() => {
  334. this.msgSuccess(text + "成功");
  335. }).catch(function () {
  336. row.status = row.status === SysCommonStatusEnum.ENABLE ? SysCommonStatusEnum.DISABLE
  337. : SysCommonStatusEnum.ENABLE;
  338. });
  339. },
  340. /** 提交按钮 */
  341. submitForm() {
  342. this.$refs["form"].validate(valid => {
  343. if (!valid) {
  344. return;
  345. }
  346. // 修改的提交
  347. if (this.form.id != null) {
  348. updateApp(this.form).then(response => {
  349. this.msgSuccess("修改成功");
  350. this.open = false;
  351. this.getList();
  352. });
  353. return;
  354. }
  355. // 添加的提交
  356. createApp(this.form).then(response => {
  357. this.msgSuccess("新增成功");
  358. this.open = false;
  359. this.getList();
  360. });
  361. });
  362. },
  363. /** 删除按钮操作 */
  364. handleDelete(row) {
  365. const id = row.id;
  366. this.$confirm('是否确认删除支付应用信息编号为"' + id + '"的数据项?', "警告", {
  367. confirmButtonText: "确定",
  368. cancelButtonText: "取消",
  369. type: "warning"
  370. }).then(function () {
  371. return deleteApp(id);
  372. }).then(() => {
  373. this.getList();
  374. this.msgSuccess("删除成功");
  375. })
  376. },
  377. /** 导出按钮操作 */
  378. handleExport() {
  379. // 处理查询参数
  380. let params = {...this.queryParams};
  381. params.pageNo = undefined;
  382. params.pageSize = undefined;
  383. this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
  384. // 执行导出
  385. this.$confirm('是否确认导出所有支付应用信息数据项?', "警告", {
  386. confirmButtonText: "确定",
  387. cancelButtonText: "取消",
  388. type: "warning"
  389. }).then(function () {
  390. return exportAppExcel(params);
  391. }).then(response => {
  392. this.downloadExcel(response, '支付应用信息.xls');
  393. })
  394. },
  395. /**
  396. * 根据商户名称模糊匹配商户信息
  397. * @param name 商户名称
  398. */
  399. handleGetMerchantListByName(name) {
  400. getMerchantListByName(name).then(response => {
  401. console.log(response)
  402. this.merchantList = response.data;
  403. });
  404. },
  405. /**
  406. * 修改支付渠道信息
  407. */
  408. handleUpdateChannel(row, payCode) {
  409. this.wechatChannelParam.edit = true;
  410. this.wechatChannelParam.loading = true;
  411. this.wechatChannelParam.appId = row.id;
  412. this.wechatChannelParam.payCode = payCode;
  413. this.wechatChannelParam.payMerchant = row.payMerchant;
  414. this.wechatChannelParam.open = true;
  415. },
  416. /**
  417. * 新增支付渠道信息
  418. */
  419. handleCreateChannel(row, payCode) {
  420. this.wechatChannelParam.edit = false;
  421. this.wechatChannelParam.loading = false;
  422. this.wechatChannelParam.appId = row.id;
  423. this.wechatChannelParam.payCode = payCode;
  424. this.wechatChannelParam.payMerchant = row.payMerchant;
  425. this.wechatChannelParam.open = true;
  426. },
  427. refreshTable(){
  428. this.getList();
  429. }
  430. }
  431. };
  432. </script>