index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="公众号appId" prop="appId">
  5. <el-input
  6. v-model="queryParams.appId"
  7. placeholder="请输入公众号appId"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="小程序appId" prop="miniappId">
  14. <el-input
  15. v-model="queryParams.miniappId"
  16. placeholder="请输入小程序appId"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="商户号" prop="mchId">
  23. <el-input
  24. v-model="queryParams.mchId"
  25. placeholder="请输入商户号"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="handleAdd"
  44. v-hasPermi="['redPacket:more:add']"
  45. >新增</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="success"
  50. plain
  51. icon="el-icon-edit"
  52. size="mini"
  53. :disabled="single"
  54. @click="handleUpdate"
  55. v-hasPermi="['redPacket:more:edit']"
  56. >修改</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="danger"
  61. plain
  62. icon="el-icon-delete"
  63. size="mini"
  64. :disabled="multiple"
  65. @click="handleDelete"
  66. v-hasPermi="['redPacket:more:remove']"
  67. >删除</el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-tag
  71. type="primary"
  72. size="large"
  73. style="font-size: 16px;"
  74. >
  75. 当前使用的商户号:{{this.redPacketMchId}}
  76. </el-tag>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="success"
  81. plain
  82. icon="el-icon-edit"
  83. size="small"
  84. @click="handleEditRedPacket"
  85. v-hasPermi="['redPacket:more:editRedPacket']"
  86. >修改当前发送的红包的商户号</el-button>
  87. </el-col>
  88. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  89. </el-row>
  90. <el-table border v-loading="loading" :data="moreList" @selection-change="handleSelectionChange">
  91. <el-table-column type="selection" width="55" align="center" />
  92. <el-table-column label="id" align="center" prop="id" />
  93. <el-table-column label="商户类型" align="center" prop="isNew" >
  94. <template slot-scope="scope">
  95. {{ scope.row.isNew === 0 ? '老商户' : '新商户' }}
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="公众号appId" align="center" prop="appId" />
  99. <el-table-column label="小程序appId" align="center" prop="miniappId" />
  100. <el-table-column label="商户号" align="center" prop="mchId" />
  101. <el-table-column label="商户密钥" align="center" prop="mchKey" />
  102. <el-table-column label="p12证书文件" align="center" prop="keyPath" />
  103. <el-table-column label="apiclient_key.pem证书" align="center" prop="privateKeyPath" />
  104. <el-table-column label="apiclient_cert.pem证书" align="center" prop="privateCertPath" />
  105. <el-table-column label="apiV3" align="center" prop="apiV3Key" />
  106. <el-table-column label="公钥ID" align="center" prop="publicKeyId" />
  107. <el-table-column label="pub_key.pem证书" align="center" prop="publicKeyPath" />
  108. <el-table-column label="回调地址" align="center" prop="notifyUrl" />
  109. <el-table-column label="回调地址" align="center" prop="notifyUrlScrm" />
  110. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  111. <template slot-scope="scope">
  112. <el-button
  113. size="mini"
  114. type="text"
  115. icon="el-icon-edit"
  116. @click="handleUpdate(scope.row)"
  117. v-hasPermi="['redPacket:more:edit']"
  118. >修改</el-button>
  119. <el-button
  120. size="mini"
  121. type="text"
  122. icon="el-icon-delete"
  123. @click="handleDelete(scope.row)"
  124. v-hasPermi="['redPacket:more:remove']"
  125. >删除</el-button>
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. <pagination
  130. v-show="total>0"
  131. :total="total"
  132. :page.sync="queryParams.pageNum"
  133. :limit.sync="queryParams.pageSize"
  134. @pagination="getList"
  135. />
  136. <!-- 添加或修改多商户配置对话框 -->
  137. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  138. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  139. <el-form-item label="商户类型" prop="isNew">
  140. <el-radio-group v-model="form.isNew">
  141. <el-radio :label="0">商家转账到零钱(旧)</el-radio>
  142. <el-radio :label="1">商家转账(新)</el-radio>
  143. </el-radio-group>
  144. </el-form-item>
  145. <el-form-item label="公众号appId" prop="appId">
  146. <el-input v-model="form.appId" placeholder="请输入公众号appId" />
  147. </el-form-item>
  148. <el-form-item label="小程序appId" prop="miniappId">
  149. <el-input v-model="form.miniappId" placeholder="请输入小程序appId" />
  150. </el-form-item>
  151. <el-form-item label="商户号" prop="mchId">
  152. <el-input v-model="form.mchId" placeholder="请输入商户号" />
  153. </el-form-item>
  154. <el-form-item label="商户密钥" prop="mchKey">
  155. <el-input v-model="form.mchKey" placeholder="请输入商户密钥" />
  156. </el-form-item>
  157. <el-form-item label="p12证书文件" prop="keyPath">
  158. <el-input v-model="form.keyPath" placeholder="请输入p12证书文件的绝对路径或者以classpath:开头的类路径." />
  159. </el-form-item>
  160. <el-form-item label="apiclient_key证书地址" prop="privateKeyPath">
  161. <el-input v-model="form.privateKeyPath" placeholder="请输入apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径." />
  162. </el-form-item>
  163. <el-form-item label="apiclient_cert证书地址" prop="privateCertPath">
  164. <el-input v-model="form.privateCertPath" placeholder="请输入apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径." />
  165. </el-form-item>
  166. <el-form-item label="apiV3秘钥" prop="apiV3Key">
  167. <el-input v-model="form.apiV3Key" placeholder="请输入apiV3 秘钥值." />
  168. </el-form-item>
  169. <el-form-item label="公钥ID" prop="publicKeyId">
  170. <el-input v-model="form.publicKeyId" placeholder="请输入公钥ID" />
  171. </el-form-item>
  172. <el-form-item label="pub_key.pem证书地址" prop="publicKeyPath">
  173. <el-input v-model="form.publicKeyPath" placeholder="请输入pub_key.pem证书文件的绝对路径或者以classpath:开头的类路径." />
  174. </el-form-item>
  175. <el-form-item label="回调地址" prop="notifyUrl">
  176. <el-input v-model="form.notifyUrl" placeholder="请输入回调地址notifyUrl" />
  177. </el-form-item>
  178. <el-form-item label="回调地址" prop="notifyUrlScrm">
  179. <el-input v-model="form.notifyUrlScrm" placeholder="请输入回调地址notifyUrlScrm" />
  180. </el-form-item>
  181. </el-form>
  182. <div slot="footer" class="dialog-footer">
  183. <el-button type="primary" @click="submitForm">确 定</el-button>
  184. <el-button @click="cancel">取 消</el-button>
  185. </div>
  186. </el-dialog>
  187. <el-dialog :title="redPacketOpen.title" :visible.sync="redPacketOpen.open" width="600px" append-to-body>
  188. <el-form ref="redPacketOpen" :model="redPacketOpen" label-width="110px">
  189. <el-form-item label="商户号" prop="cateId">
  190. <el-select v-model="redPacketOpen.newChangeMchId" placeholder="请选择" clearable size="small">
  191. <el-option
  192. v-for="dict in moreList"
  193. :key="dict.mchId"
  194. :label="dict.mchId"
  195. :value="dict.mchId"
  196. />
  197. </el-select>
  198. </el-form-item>
  199. </el-form>
  200. <div slot="footer" class="dialog-footer">
  201. <el-button type="primary" @click="submitFormChangeMchId">确 定</el-button>
  202. <el-button @click="cancelChangeMchId">取 消</el-button>
  203. </div>
  204. </el-dialog>
  205. </div>
  206. </template>
  207. <script>
  208. import {
  209. listMore,
  210. getMore,
  211. delMore,
  212. addMore,
  213. updateMore,
  214. getRedPacketMchId,
  215. updateChangeMchId
  216. } from '@/api/his/redPacketConfig'
  217. export default {
  218. name: "redPacketConfig",
  219. data() {
  220. return {
  221. // 遮罩层
  222. loading: true,
  223. // 导出遮罩层
  224. exportLoading: false,
  225. // 选中数组
  226. ids: [],
  227. // 非单个禁用
  228. single: true,
  229. // 非多个禁用
  230. multiple: true,
  231. // 显示搜索条件
  232. showSearch: true,
  233. // 总条数
  234. total: 0,
  235. redPacketMchId: null,
  236. redPacketOpen:{
  237. open:false,
  238. title:null,
  239. oldChangeMchId:null,
  240. newChangeMchId:null,
  241. },
  242. // 多商户配置表格数据
  243. moreList: [],
  244. // 弹出层标题
  245. title: "",
  246. // 是否显示弹出层
  247. open: false,
  248. // 查询参数
  249. queryParams: {
  250. pageNum: 1,
  251. pageSize: 10,
  252. isNew: null,
  253. appId: null,
  254. miniappId: null,
  255. mchId: null,
  256. mchKey: null,
  257. keyPath: null,
  258. privateKeyPath: null,
  259. privateCertPath: null,
  260. apiV3Key: null,
  261. publicKeyId: null,
  262. publicKeyPath: null,
  263. notifyUrl: null,
  264. notifyUrlScrm: null
  265. },
  266. // 表单参数
  267. form: {},
  268. // 表单校验
  269. rules: {},
  270. redPacketOpenRule:{
  271. newChangeMchId:[{ required: true, trigger: "blur", message: "商户号不能为空" }]
  272. },
  273. };
  274. },
  275. created() {
  276. this.getList();
  277. },
  278. methods: {
  279. /** 查询多商户配置列表 */
  280. getList() {
  281. this.loading = true;
  282. listMore(this.queryParams).then(response => {
  283. console.log("response.rows",response.rows)
  284. this.moreList = response.rows;
  285. this.total = response.total;
  286. this.loading = false;
  287. });
  288. getRedPacketMchId().then(res=>{
  289. this.redPacketMchId=res.data
  290. })
  291. },
  292. // 取消按钮
  293. cancel() {
  294. this.open = false;
  295. this.reset();
  296. },
  297. cancelChangeMchId() {
  298. this.redPacketOpen.open=false;
  299. this.redPacketOpen.title=false;
  300. this.redPacketOpen.oldChangeMchId=false;
  301. this.redPacketOpen.newChangeMchId=false;
  302. },
  303. // 表单重置
  304. reset() {
  305. this.form = {
  306. id: null,
  307. isNew: null,
  308. appId: null,
  309. miniappId: null,
  310. mchId: null,
  311. mchKey: null,
  312. keyPath: null,
  313. privateKeyPath: null,
  314. privateCertPath: null,
  315. apiV3Key: null,
  316. publicKeyId: null,
  317. publicKeyPath: null,
  318. notifyUrl: null,
  319. notifyUrlScrm: null
  320. };
  321. this.resetForm("form");
  322. },
  323. /** 搜索按钮操作 */
  324. handleQuery() {
  325. this.queryParams.pageNum = 1;
  326. this.getList();
  327. },
  328. /** 重置按钮操作 */
  329. resetQuery() {
  330. this.resetForm("queryForm");
  331. this.handleQuery();
  332. },
  333. // 多选框选中数据
  334. handleSelectionChange(selection) {
  335. this.ids = selection.map(item => item.id)
  336. this.single = selection.length!==1
  337. this.multiple = !selection.length
  338. },
  339. /** 新增按钮操作 */
  340. handleAdd() {
  341. this.reset();
  342. this.open = true;
  343. this.title = "添加多商户配置";
  344. },
  345. /** 修改按钮操作 */
  346. handleUpdate(row) {
  347. this.reset();
  348. const id = row.id || this.ids
  349. getMore(id).then(response => {
  350. this.form = response.data;
  351. this.open = true;
  352. this.title = "修改多商户配置";
  353. });
  354. },
  355. handleEditRedPacket(){
  356. this.redPacketOpen.open= true;
  357. this.redPacketOpen.title="修改发送红包的商户号";
  358. },
  359. /** 提交按钮 */
  360. submitForm() {
  361. this.$refs["form"].validate(valid => {
  362. if (valid) {
  363. if (this.form.id != null) {
  364. updateMore(this.form).then(response => {
  365. this.msgSuccess("修改成功");
  366. this.open = false;
  367. this.getList();
  368. });
  369. } else {
  370. addMore(this.form).then(response => {
  371. this.msgSuccess("新增成功");
  372. this.open = false;
  373. this.getList();
  374. });
  375. }
  376. }
  377. });
  378. },
  379. /** 提交修改发送红包的商户号- */
  380. submitFormChangeMchId() {
  381. this.$refs["redPacketOpen"].validate(valid => {
  382. if (valid) {
  383. this.redPacketOpen.oldChangeMchId=this.redPacketMchId;
  384. if (this.redPacketOpen.newChangeMchId==null){
  385. return this.$message.error("修改的商户号不能为空")
  386. }
  387. updateChangeMchId(this.redPacketOpen).then(response => {
  388. this.msgSuccess("修改成功");
  389. this.cancelChangeMchId();
  390. this.getList();
  391. });
  392. }
  393. });
  394. },
  395. /** 删除按钮操作 */
  396. handleDelete(row) {
  397. const ids = row.id || this.ids;
  398. this.$confirm('是否确认删除多商户配置编号为"' + ids + '"的数据项?', "警告", {
  399. confirmButtonText: "确定",
  400. cancelButtonText: "取消",
  401. type: "warning"
  402. }).then(function() {
  403. return delMore(ids);
  404. }).then(() => {
  405. this.getList();
  406. this.msgSuccess("删除成功");
  407. }).catch(() => {});
  408. },
  409. }
  410. };
  411. </script>