index.vue 13 KB

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