index.vue 19 KB

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