index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  70. </el-row>
  71. <el-table border v-loading="loading" :data="moreList" @selection-change="handleSelectionChange">
  72. <el-table-column type="selection" width="55" align="center" />
  73. <el-table-column label="id" align="center" prop="id" />
  74. <el-table-column label="商户类型" align="center" prop="isNew" >
  75. <template slot-scope="scope">
  76. {{ scope.row.isNew === 0 ? '老商户' : '新商户' }}
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="公众号appId" align="center" prop="appId" />
  80. <el-table-column label="小程序appId" align="center" prop="miniappId" />
  81. <el-table-column label="商户号" align="center" prop="mchId" />
  82. <el-table-column label="商户密钥" align="center" prop="mchKey" />
  83. <el-table-column label="p12证书文件" align="center" prop="keyPath" />
  84. <el-table-column label="apiclient_key.pem证书" align="center" prop="privateKeyPath" />
  85. <el-table-column label="apiclient_cert.pem证书" align="center" prop="privateCertPath" />
  86. <el-table-column label="apiV3" align="center" prop="apiV3Key" />
  87. <el-table-column label="公钥ID" align="center" prop="publicKeyId" />
  88. <el-table-column label="pub_key.pem证书" align="center" prop="publicKeyPath" />
  89. <el-table-column label="回调地址" align="center" prop="notifyUrl" />
  90. <el-table-column label="回调地址" align="center" prop="notifyUrlScrm" />
  91. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  92. <template slot-scope="scope">
  93. <el-button
  94. size="mini"
  95. type="text"
  96. icon="el-icon-edit"
  97. @click="handleUpdate(scope.row)"
  98. v-hasPermi="['redPacket:more:edit']"
  99. >修改</el-button>
  100. <el-button
  101. size="mini"
  102. type="text"
  103. icon="el-icon-delete"
  104. @click="handleDelete(scope.row)"
  105. v-hasPermi="['redPacket:more:remove']"
  106. >删除</el-button>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <pagination
  111. v-show="total>0"
  112. :total="total"
  113. :page.sync="queryParams.pageNum"
  114. :limit.sync="queryParams.pageSize"
  115. @pagination="getList"
  116. />
  117. <!-- 添加或修改多商户配置对话框 -->
  118. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  119. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  120. <el-form-item label="商户类型" prop="isNew">
  121. <el-radio-group v-model="form.isNew">
  122. <el-radio :label="0">商家转账到零钱(旧)</el-radio>
  123. <el-radio :label="1">商家转账(新)</el-radio>
  124. </el-radio-group>
  125. </el-form-item>
  126. <el-form-item label="公众号appId" prop="appId">
  127. <el-input v-model="form.appId" placeholder="请输入公众号appId" />
  128. </el-form-item>
  129. <el-form-item label="小程序appId" prop="miniappId">
  130. <el-input v-model="form.miniappId" placeholder="请输入小程序appId" />
  131. </el-form-item>
  132. <el-form-item label="商户号" prop="mchId">
  133. <el-input v-model="form.mchId" placeholder="请输入商户号" />
  134. </el-form-item>
  135. <el-form-item label="商户密钥" prop="mchKey">
  136. <el-input v-model="form.mchKey" placeholder="请输入商户密钥" />
  137. </el-form-item>
  138. <el-form-item label="p12证书文件" prop="keyPath">
  139. <el-input v-model="form.keyPath" placeholder="请输入p12证书文件的绝对路径或者以classpath:开头的类路径." />
  140. </el-form-item>
  141. <el-form-item label="apiclient_key证书地址" prop="privateKeyPath">
  142. <el-input v-model="form.privateKeyPath" placeholder="请输入apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径." />
  143. </el-form-item>
  144. <el-form-item label="apiclient_cert证书地址" prop="privateCertPath">
  145. <el-input v-model="form.privateCertPath" placeholder="请输入apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径." />
  146. </el-form-item>
  147. <el-form-item label="apiV3秘钥" prop="apiV3Key">
  148. <el-input v-model="form.apiV3Key" placeholder="请输入apiV3 秘钥值." />
  149. </el-form-item>
  150. <el-form-item label="公钥ID" prop="publicKeyId">
  151. <el-input v-model="form.publicKeyId" placeholder="请输入公钥ID" />
  152. </el-form-item>
  153. <el-form-item label="pub_key.pem证书地址" prop="publicKeyPath">
  154. <el-input v-model="form.publicKeyPath" placeholder="请输入pub_key.pem证书文件的绝对路径或者以classpath:开头的类路径." />
  155. </el-form-item>
  156. <el-form-item label="回调地址" prop="notifyUrl">
  157. <el-input v-model="form.notifyUrl" placeholder="请输入回调地址notifyUrl" />
  158. </el-form-item>
  159. <el-form-item label="回调地址" prop="notifyUrlScrm">
  160. <el-input v-model="form.notifyUrlScrm" placeholder="请输入回调地址notifyUrlScrm" />
  161. </el-form-item>
  162. </el-form>
  163. <div slot="footer" class="dialog-footer">
  164. <el-button type="primary" @click="submitForm">确 定</el-button>
  165. <el-button @click="cancel">取 消</el-button>
  166. </div>
  167. </el-dialog>
  168. </div>
  169. </template>
  170. <script>
  171. import {
  172. listMore,
  173. getMore,
  174. delMore,
  175. addMore,
  176. updateMore,
  177. getRedPacketMchId,
  178. updateChangeMchId
  179. } from '@/api/his/redPacketConfig'
  180. export default {
  181. name: "redPacketConfig",
  182. data() {
  183. return {
  184. // 遮罩层
  185. loading: true,
  186. // 导出遮罩层
  187. exportLoading: false,
  188. // 选中数组
  189. ids: [],
  190. // 非单个禁用
  191. single: true,
  192. // 非多个禁用
  193. multiple: true,
  194. // 显示搜索条件
  195. showSearch: true,
  196. // 总条数
  197. total: 0,
  198. redPacketMchId: null,
  199. redPacketOpen:{
  200. open:false,
  201. title:null,
  202. oldChangeMchId:null,
  203. newChangeMchId:null,
  204. },
  205. // 多商户配置表格数据
  206. moreList: [],
  207. // 弹出层标题
  208. title: "",
  209. // 是否显示弹出层
  210. open: false,
  211. // 查询参数
  212. queryParams: {
  213. pageNum: 1,
  214. pageSize: 10,
  215. isNew: null,
  216. appId: null,
  217. miniappId: null,
  218. mchId: null,
  219. mchKey: null,
  220. keyPath: null,
  221. privateKeyPath: null,
  222. privateCertPath: null,
  223. apiV3Key: null,
  224. publicKeyId: null,
  225. publicKeyPath: null,
  226. notifyUrl: null,
  227. notifyUrlScrm: null
  228. },
  229. // 表单参数
  230. form: {},
  231. // 表单校验
  232. rules: {},
  233. redPacketOpenRule:{
  234. newChangeMchId:[{ required: true, trigger: "blur", message: "商户号不能为空" }]
  235. },
  236. };
  237. },
  238. created() {
  239. this.getList();
  240. },
  241. methods: {
  242. /** 查询多商户配置列表 */
  243. getList() {
  244. this.loading = true;
  245. listMore(this.queryParams).then(response => {
  246. console.log("response.rows",response.rows)
  247. this.moreList = response.rows;
  248. this.total = response.total;
  249. this.loading = false;
  250. });
  251. getRedPacketMchId().then(res=>{
  252. this.redPacketMchId=res.data
  253. })
  254. },
  255. // 取消按钮
  256. cancel() {
  257. this.open = false;
  258. this.reset();
  259. },
  260. // 表单重置
  261. reset() {
  262. this.form = {
  263. id: null,
  264. isNew: null,
  265. appId: null,
  266. miniappId: null,
  267. mchId: null,
  268. mchKey: null,
  269. keyPath: null,
  270. privateKeyPath: null,
  271. privateCertPath: null,
  272. apiV3Key: null,
  273. publicKeyId: null,
  274. publicKeyPath: null,
  275. notifyUrl: null,
  276. notifyUrlScrm: null
  277. };
  278. this.resetForm("form");
  279. },
  280. /** 搜索按钮操作 */
  281. handleQuery() {
  282. this.queryParams.pageNum = 1;
  283. this.getList();
  284. },
  285. /** 重置按钮操作 */
  286. resetQuery() {
  287. this.resetForm("queryForm");
  288. this.handleQuery();
  289. },
  290. // 多选框选中数据
  291. handleSelectionChange(selection) {
  292. this.ids = selection.map(item => item.id)
  293. this.single = selection.length!==1
  294. this.multiple = !selection.length
  295. },
  296. /** 新增按钮操作 */
  297. handleAdd() {
  298. this.reset();
  299. this.open = true;
  300. this.title = "添加多商户配置";
  301. },
  302. /** 修改按钮操作 */
  303. handleUpdate(row) {
  304. this.reset();
  305. const id = row.id || this.ids
  306. getMore(id).then(response => {
  307. this.form = response.data;
  308. this.open = true;
  309. this.title = "修改多商户配置";
  310. });
  311. },
  312. /** 提交按钮 */
  313. submitForm() {
  314. this.$refs["form"].validate(valid => {
  315. if (valid) {
  316. if (this.form.id != null) {
  317. updateMore(this.form).then(response => {
  318. this.msgSuccess("修改成功");
  319. this.open = false;
  320. this.getList();
  321. });
  322. } else {
  323. addMore(this.form).then(response => {
  324. this.msgSuccess("新增成功");
  325. this.open = false;
  326. this.getList();
  327. });
  328. }
  329. }
  330. });
  331. },
  332. /** 提交修改发送红包的商户号- */
  333. submitFormChangeMchId() {
  334. this.$refs["redPacketOpen"].validate(valid => {
  335. if (valid) {
  336. this.redPacketOpen.oldChangeMchId=this.redPacketMchId;
  337. if (this.redPacketOpen.newChangeMchId==null){
  338. return this.$message.error("修改的商户号不能为空")
  339. }
  340. updateChangeMchId(this.redPacketOpen).then(response => {
  341. this.msgSuccess("修改成功");
  342. this.cancelChangeMchId();
  343. this.getList();
  344. });
  345. }
  346. });
  347. },
  348. /** 删除按钮操作 */
  349. handleDelete(row) {
  350. const ids = row.id || this.ids;
  351. this.$confirm('是否确认删除多商户配置编号为"' + ids + '"的数据项?', "警告", {
  352. confirmButtonText: "确定",
  353. cancelButtonText: "取消",
  354. type: "warning"
  355. }).then(function() {
  356. return delMore(ids);
  357. }).then(() => {
  358. this.getList();
  359. this.msgSuccess("删除成功");
  360. }).catch(() => {});
  361. },
  362. }
  363. };
  364. </script>