index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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="payNotifyUrl">
  196. <el-input v-model="form.payNotifyUrl" 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. <wechat-channel-form :transferParam="channelParam"></wechat-channel-form>
  211. <ali-pay-channel-form :transferParam="channelParam"></ali-pay-channel-form>
  212. </div>
  213. </template>
  214. <script>
  215. import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage } from "@/api/pay/app";
  216. import { DICT_TYPE, getDictDatas } from "@/utils/dict";
  217. import { PayType, PayChannelEnum, CommonStatusEnum } from "@/utils/constants";
  218. import wechatChannelForm from "@/views/pay/app/components/wechatChannelForm";
  219. import aliPayChannelForm from "@/views/pay/app/components/aliPayChannelForm";
  220. export default {
  221. name: "PayApp",
  222. components: {
  223. "wechatChannelForm": wechatChannelForm,
  224. "aliPayChannelForm": aliPayChannelForm
  225. },
  226. data() {
  227. return {
  228. // 遮罩层
  229. loading: true,
  230. // 显示搜索条件
  231. showSearch: true,
  232. // 总条数
  233. total: 0,
  234. // 支付应用信息列表
  235. list: [],
  236. // 弹出层标题
  237. title: "",
  238. // 是否显示弹出层
  239. open: false,
  240. // 查询参数
  241. queryParams: {
  242. pageNo: 1,
  243. pageSize: 10,
  244. name: null,
  245. status: null,
  246. createTime: []
  247. },
  248. // 表单参数
  249. form: {},
  250. // 表单校验
  251. rules: {
  252. name: [{required: true, message: "应用名不能为空", trigger: "blur"}],
  253. status: [{required: true, message: "开启状态不能为空", trigger: "blur"}],
  254. payNotifyUrl: [{required: true, message: "支付结果的回调地址不能为空", trigger: "blur"}],
  255. refundNotifyUrl: [{required: true, message: "退款结果的回调地址不能为空", trigger: "blur"}],
  256. },
  257. // 数据字典
  258. statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS),
  259. sysCommonStatusEnum: CommonStatusEnum,
  260. // 支付渠道枚举
  261. payChannelEnum: PayChannelEnum,
  262. // 支付类型
  263. payType: PayType,
  264. // 是否显示支付窗口
  265. payOpen: false,
  266. // 微信组件传参参数
  267. channelParam: {
  268. // 是否修改
  269. "edit": false,
  270. // 微信是否显示
  271. "wechatOpen": false,
  272. // 支付宝是否显示
  273. "aliPayOpen": false,
  274. // 应用ID
  275. "appId": null,
  276. // 渠道编码
  277. "payCode": null,
  278. // 商户对象
  279. "payMerchant": {
  280. // 编号
  281. "id": null,
  282. // 名称
  283. "name": null
  284. },
  285. }
  286. };
  287. },
  288. created() {
  289. this.getList();
  290. },
  291. methods: {
  292. /** 查询列表 */
  293. getList() {
  294. this.loading = true;
  295. // 执行查询
  296. getAppPage(this.queryParams).then(response => {
  297. this.list = response.data.list;
  298. this.total = response.data.total;
  299. this.loading = false;
  300. });
  301. },
  302. /** 取消按钮 */
  303. cancel() {
  304. this.open = false;
  305. this.reset();
  306. },
  307. /** 表单重置 */
  308. reset() {
  309. this.form = {
  310. id: undefined,
  311. name: undefined,
  312. status: undefined,
  313. remark: undefined,
  314. payNotifyUrl: undefined,
  315. refundNotifyUrl: undefined,
  316. };
  317. this.resetForm("form");
  318. },
  319. /** 搜索按钮操作 */
  320. handleQuery() {
  321. this.queryParams.pageNo = 1;
  322. this.getList();
  323. },
  324. /** 重置按钮操作 */
  325. resetQuery() {
  326. this.resetForm("queryForm");
  327. this.handleQuery();
  328. },
  329. /** 新增按钮操作 */
  330. handleAdd() {
  331. this.reset();
  332. this.open = true;
  333. this.title = "添加支付应用信息";
  334. },
  335. /** 修改按钮操作 */
  336. handleUpdate(row) {
  337. this.reset();
  338. const id = row.id;
  339. getApp(id).then(response => {
  340. this.form = response.data;
  341. this.open = true;
  342. this.title = "修改支付应用信息";
  343. });
  344. },
  345. // 用户状态修改
  346. handleStatusChange(row) {
  347. let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用";
  348. this.$modal.confirm('确认要"' + text + '""' + row.name + '"应用吗?').then(function () {
  349. return changeAppStatus(row.id, row.status);
  350. }).then(() => {
  351. this.$modal.msgSuccess(text + "成功");
  352. }).catch(function () {
  353. row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
  354. : CommonStatusEnum.ENABLE;
  355. });
  356. },
  357. /** 提交按钮 */
  358. submitForm() {
  359. this.$refs["form"].validate(valid => {
  360. if (!valid) {
  361. return;
  362. }
  363. // 修改的提交
  364. if (this.form.id != null) {
  365. updateApp(this.form).then(response => {
  366. this.$modal.msgSuccess("修改成功");
  367. this.open = false;
  368. this.getList();
  369. });
  370. return;
  371. }
  372. // 添加的提交
  373. createApp(this.form).then(response => {
  374. this.$modal.msgSuccess("新增成功");
  375. this.open = false;
  376. this.getList();
  377. });
  378. });
  379. },
  380. /** 删除按钮操作 */
  381. handleDelete(row) {
  382. this.$modal.confirm('是否确认删除支付应用信息编号为"' + row.id + '"的数据项?').then(function () {
  383. return deleteApp(row.id);
  384. }).then(() => {
  385. this.getList();
  386. this.$modal.msgSuccess("删除成功");
  387. }).catch(() => {
  388. this.$message({
  389. type: 'info',
  390. message: '已取消删除'
  391. });
  392. });
  393. },
  394. /**
  395. * 修改支付渠道信息
  396. */
  397. handleUpdateChannel(row, payCode, type) {
  398. this.settingChannelParam(row, payCode, type)
  399. this.channelParam.edit = true;
  400. this.channelParam.loading = true;
  401. },
  402. /**
  403. * 新增支付渠道信息
  404. */
  405. handleCreateChannel(row, payCode, type) {
  406. this.settingChannelParam(row, payCode, type)
  407. this.channelParam.edit = false;
  408. this.channelParam.loading = false;
  409. },
  410. /**
  411. * 设置支付渠道信息
  412. */
  413. settingChannelParam(row, payCode, type) {
  414. if (type === PayType.WECHAT) {
  415. this.channelParam.wechatOpen = true;
  416. this.channelParam.aliPayOpen = false;
  417. }
  418. if (type === PayType.ALIPAY) {
  419. this.channelParam.aliPayOpen = true;
  420. this.channelParam.wechatOpen = false;
  421. }
  422. this.channelParam.edit = false;
  423. this.channelParam.loading = false;
  424. this.channelParam.appId = row.id;
  425. this.channelParam.payCode = payCode;
  426. this.channelParam.payMerchant = row.payMerchant;
  427. },
  428. /**
  429. * 根据渠道编码判断渠道列表中是否存在
  430. * @param channels 渠道列表
  431. * @param channelCode 渠道编码
  432. */
  433. judgeChannelExist(channels, channelCode) {
  434. return channels.indexOf(channelCode) !== -1;
  435. }
  436. }
  437. };
  438. </script>