index.vue 18 KB

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