index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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 this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :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="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_APP.code)"
  49. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_APP.code)">
  50. </el-button>
  51. <el-button v-else type="danger" icon="el-icon-close" circle
  52. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_APP.code)">
  53. </el-button>
  54. </template>
  55. </el-table-column>
  56. <el-table-column :label="payChannelEnum.ALIPAY_PC.name" align="center">
  57. <template v-slot="scope">
  58. <el-button type="success" icon="el-icon-check" circle
  59. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_PC.code)"
  60. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_PC.code)">
  61. </el-button>
  62. <el-button v-else type="danger" icon="el-icon-close" circle
  63. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_PC.code)">
  64. </el-button>
  65. </template>
  66. </el-table-column>
  67. <el-table-column :label="payChannelEnum.ALIPAY_WAP.name" align="center">
  68. <template v-slot="scope">
  69. <el-button type="success" icon="el-icon-check" circle
  70. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_WAP.code)"
  71. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_WAP.code)">
  72. </el-button>
  73. <el-button v-else type="danger" icon="el-icon-close" circle
  74. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_WAP.code)">
  75. </el-button>
  76. </template>
  77. </el-table-column>
  78. <el-table-column :label="payChannelEnum.ALIPAY_QR.name" align="center">
  79. <template v-slot="scope">
  80. <el-button type="success" icon="el-icon-check" circle
  81. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_QR.code)"
  82. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_QR.code)">
  83. </el-button>
  84. <el-button v-else type="danger" icon="el-icon-close" circle
  85. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_QR.code)">
  86. </el-button>
  87. </template>
  88. </el-table-column>
  89. <el-table-column :label="payChannelEnum.ALIPAY_BAR.name" align="center">
  90. <template v-slot="scope">
  91. <el-button type="success" icon="el-icon-check" circle
  92. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.ALIPAY_BAR.code)"
  93. @click="handleChannel(scope.row,payChannelEnum.ALIPAY_BAR.code)">
  94. </el-button>
  95. <el-button v-else type="danger" icon="el-icon-close" circle
  96. @click="handleChannel(scope.row, payChannelEnum.ALIPAY_BAR.code)">
  97. </el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table-column>
  101. <el-table-column label="微信配置" align="center">
  102. <el-table-column :label="payChannelEnum.WX_LITE.name" align="center">
  103. <template v-slot="scope">
  104. <el-button type="success" icon="el-icon-check" circle
  105. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_LITE.code)"
  106. @click="handleChannel(scope.row, payChannelEnum.WX_LITE.code)">
  107. </el-button>
  108. <el-button v-else type="danger" icon="el-icon-close" circle
  109. @click="handleChannel(scope.row, payChannelEnum.WX_LITE.code)">
  110. </el-button>
  111. </template>
  112. </el-table-column>
  113. <el-table-column :label="payChannelEnum.WX_PUB.name" align="center">
  114. <template v-slot="scope">
  115. <el-button type="success" icon="el-icon-check" circle
  116. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_PUB.code)"
  117. @click="handleChannel(scope.row, payChannelEnum.WX_PUB.code)">
  118. </el-button>
  119. <el-button v-else type="danger" icon="el-icon-close" circle
  120. @click="handleChannel(scope.row, payChannelEnum.WX_PUB.code)">
  121. </el-button>
  122. </template>
  123. </el-table-column>
  124. <el-table-column :label="payChannelEnum.WX_APP.name" align="center">
  125. <template v-slot="scope">
  126. <el-button type="success" icon="el-icon-check" circle
  127. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_APP.code)"
  128. @click="handleChannel(scope.row, payChannelEnum.WX_APP.code)">
  129. </el-button>
  130. <el-button v-else type="danger" icon="el-icon-close" circle
  131. @click="handleChannel(scope.row, payChannelEnum.WX_APP.code)">
  132. </el-button>
  133. </template>
  134. </el-table-column>
  135. <el-table-column :label="payChannelEnum.WX_NATIVE.name" align="center">
  136. <template v-slot="scope">
  137. <el-button type="success" icon="el-icon-check" circle
  138. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_NATIVE.code)"
  139. @click="handleChannel(scope.row, payChannelEnum.WX_NATIVE.code)">
  140. </el-button>
  141. <el-button v-else type="danger" icon="el-icon-close" circle
  142. @click="handleChannel(scope.row, payChannelEnum.WX_NATIVE.code)">
  143. </el-button>
  144. </template>
  145. </el-table-column>
  146. <el-table-column :label="payChannelEnum.WX_BAR.name" align="center">
  147. <template v-slot="scope">
  148. <el-button type="success" icon="el-icon-check" circle
  149. v-if="isChannelExists(scope.row.channelCodes, payChannelEnum.WX_BAR.code)"
  150. @click="handleChannel(scope.row, payChannelEnum.WX_BAR.code)">
  151. </el-button>
  152. <el-button v-else type="danger" icon="el-icon-close" circle
  153. @click="handleChannel(scope.row, payChannelEnum.WX_BAR.code)">
  154. </el-button>
  155. </template>
  156. </el-table-column>
  157. </el-table-column>
  158. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  159. <template v-slot="scope">
  160. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  161. v-hasPermi="['pay:app:update']">修改
  162. </el-button>
  163. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  164. v-hasPermi="['pay:app:delete']">删除
  165. </el-button>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. <!-- 分页组件 -->
  170. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  171. @pagination="getList"/>
  172. <!-- 对话框(添加 / 修改) -->
  173. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  174. <el-form ref="form" :model="form" :rules="rules" label-width="160px">
  175. <el-form-item label="应用名" prop="name">
  176. <el-input v-model="form.name" placeholder="请输入应用名"/>
  177. </el-form-item>
  178. <el-form-item label="开启状态" prop="status">
  179. <el-radio-group v-model="form.status">
  180. <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
  181. {{ dict.label }}
  182. </el-radio>
  183. </el-radio-group>
  184. </el-form-item>
  185. <el-form-item label="支付结果的回调地址" prop="orderNotifyUrl">
  186. <el-input v-model="form.orderNotifyUrl" placeholder="请输入支付结果的回调地址"/>
  187. </el-form-item>
  188. <el-form-item label="退款结果的回调地址" prop="refundNotifyUrl">
  189. <el-input v-model="form.refundNotifyUrl" placeholder="请输入退款结果的回调地址"/>
  190. </el-form-item>
  191. <el-form-item label="备注" prop="remark">
  192. <el-input v-model="form.remark" placeholder="请输入备注"/>
  193. </el-form-item>
  194. </el-form>
  195. <div slot="footer" class="dialog-footer">
  196. <el-button type="primary" @click="submitForm">确 定</el-button>
  197. <el-button @click="cancel">取 消</el-button>
  198. </div>
  199. </el-dialog>
  200. <!-- 对话框(支付应用的配置) -->
  201. <weixin-channel-form ref="weixinChannelFormRef" @success="getList" />
  202. <alipay-channel-form ref="alipayChannelFormRef" @success="getList" />
  203. </div>
  204. </template>
  205. <script>
  206. import { createApp, updateApp, changeAppStatus, deleteApp, getApp, getAppPage } from "@/api/pay/app";
  207. import { PayChannelEnum, CommonStatusEnum } from "@/utils/constants";
  208. import weixinChannelForm from "@/views/pay/app/components/weixinChannelForm";
  209. import alipayChannelForm from "@/views/pay/app/components/alipayChannelForm";
  210. export default {
  211. name: "PayApp",
  212. components: {
  213. weixinChannelForm,
  214. alipayChannelForm
  215. },
  216. data() {
  217. return {
  218. // 遮罩层
  219. loading: true,
  220. // 显示搜索条件
  221. showSearch: true,
  222. // 总条数
  223. total: 0,
  224. // 支付应用信息列表
  225. list: [],
  226. // 弹出层标题
  227. title: "",
  228. // 是否显示弹出层
  229. open: false,
  230. // 查询参数
  231. queryParams: {
  232. pageNo: 1,
  233. pageSize: 10,
  234. name: null,
  235. status: null,
  236. createTime: []
  237. },
  238. // 表单参数
  239. form: {},
  240. // 表单校验
  241. rules: {
  242. name: [{required: true, message: "应用名不能为空", trigger: "blur"}],
  243. status: [{required: true, message: "开启状态不能为空", trigger: "blur"}],
  244. orderNotifyUrl: [{required: true, message: "支付结果的回调地址不能为空", trigger: "blur"}],
  245. refundNotifyUrl: [{required: true, message: "退款结果的回调地址不能为空", trigger: "blur"}],
  246. },
  247. // 支付渠道枚举
  248. payChannelEnum: PayChannelEnum,
  249. };
  250. },
  251. created() {
  252. this.getList();
  253. },
  254. methods: {
  255. /** 查询列表 */
  256. getList() {
  257. this.loading = true;
  258. // 执行查询
  259. getAppPage(this.queryParams).then(response => {
  260. this.list = response.data.list;
  261. this.total = response.data.total;
  262. this.loading = false;
  263. });
  264. },
  265. /** 取消按钮 */
  266. cancel() {
  267. this.open = false;
  268. this.reset();
  269. },
  270. /** 表单重置 */
  271. reset() {
  272. this.form = {
  273. id: undefined,
  274. name: undefined,
  275. status: CommonStatusEnum.ENABLE,
  276. remark: undefined,
  277. orderNotifyUrl: undefined,
  278. refundNotifyUrl: undefined,
  279. };
  280. this.resetForm("form");
  281. },
  282. /** 搜索按钮操作 */
  283. handleQuery() {
  284. this.queryParams.pageNo = 1;
  285. this.getList();
  286. },
  287. /** 重置按钮操作 */
  288. resetQuery() {
  289. this.resetForm("queryForm");
  290. this.handleQuery();
  291. },
  292. /** 新增按钮操作 */
  293. handleAdd() {
  294. this.reset();
  295. this.open = true;
  296. this.title = "添加支付应用信息";
  297. },
  298. /** 修改按钮操作 */
  299. handleUpdate(row) {
  300. this.reset();
  301. const id = row.id;
  302. getApp(id).then(response => {
  303. this.form = response.data;
  304. this.open = true;
  305. this.title = "修改支付应用信息";
  306. });
  307. },
  308. // 用户状态修改
  309. handleStatusChange(row) {
  310. let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用";
  311. this.$modal.confirm('确认要"' + text + '""' + row.name + '"应用吗?').then(function () {
  312. return changeAppStatus(row.id, row.status);
  313. }).then(() => {
  314. this.$modal.msgSuccess(text + "成功");
  315. }).catch(function () {
  316. row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
  317. : CommonStatusEnum.ENABLE;
  318. });
  319. },
  320. /** 提交按钮 */
  321. submitForm() {
  322. this.$refs["form"].validate(valid => {
  323. if (!valid) {
  324. return;
  325. }
  326. // 修改的提交
  327. if (this.form.id != null) {
  328. updateApp(this.form).then(response => {
  329. this.$modal.msgSuccess("修改成功");
  330. this.open = false;
  331. this.getList();
  332. });
  333. return;
  334. }
  335. // 添加的提交
  336. createApp(this.form).then(response => {
  337. this.$modal.msgSuccess("新增成功");
  338. this.open = false;
  339. this.getList();
  340. });
  341. });
  342. },
  343. /** 删除按钮操作 */
  344. handleDelete(row) {
  345. this.$modal.confirm('是否确认删除支付应用信息编号为"' + row.id + '"的数据项?').then(function () {
  346. return deleteApp(row.id);
  347. }).then(() => {
  348. this.getList();
  349. this.$modal.msgSuccess("删除成功");
  350. }).catch(() => {
  351. this.$message({
  352. type: 'info',
  353. message: '已取消删除'
  354. });
  355. });
  356. },
  357. /**
  358. * 修改支付渠道信息
  359. */
  360. handleChannel(row, code) {
  361. if (code.indexOf('alipay_') === 0) {
  362. this.$refs['alipayChannelFormRef'].open(row.id, code);
  363. return
  364. }
  365. if (code.indexOf('wx_') === 0) {
  366. this.$refs['weixinChannelFormRef'].open(row.id, code);
  367. return
  368. }
  369. },
  370. /**
  371. * 根据渠道编码判断渠道列表中是否存在
  372. *
  373. * @param channels 渠道列表
  374. * @param channelCode 渠道编码
  375. */
  376. isChannelExists(channels, channelCode) {
  377. return channels.indexOf(channelCode) !== -1;
  378. }
  379. }
  380. }
  381. </script>