index.vue 18 KB

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