index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="商户类型" prop="merchantType">
  5. <el-select v-model="queryParams.merchantType" placeholder="请选择商户类型" clearable size="small">
  6. <el-option
  7. v-for="dict in sysPayModes"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <!-- <el-form-item label="应用ID" prop="appIds">-->
  15. <!-- <el-select-->
  16. <!-- v-model="queryParams.appIds"-->
  17. <!-- placeholder="请选择应用ID"-->
  18. <!-- clearable-->
  19. <!-- size="small"-->
  20. <!-- >-->
  21. <!-- <el-option-->
  22. <!-- v-for="dict in appIdOptions"-->
  23. <!-- :key="dict.appid"-->
  24. <!-- :label="dict.name"-->
  25. <!-- :value="dict.appid"-->
  26. <!-- />-->
  27. <!-- </el-select>-->
  28. <!-- </el-form-item>-->
  29. <!-- <el-form-item label="创建时间">-->
  30. <!-- <el-date-picker-->
  31. <!-- v-model="daterangeCreatedTime"-->
  32. <!-- size="small"-->
  33. <!-- style="width: 240px"-->
  34. <!-- value-format="yyyy-MM-dd"-->
  35. <!-- type="daterange"-->
  36. <!-- range-separator="-"-->
  37. <!-- start-placeholder="开始日期"-->
  38. <!-- end-placeholder="结束日期"-->
  39. <!-- ></el-date-picker>-->
  40. <!-- </el-form-item>-->
  41. <el-form-item label="状态" prop="isDeleted">
  42. <el-select v-model="queryParams.isDeleted" placeholder="请选择状态" clearable size="small">
  43. <el-option
  44. v-for="dict in isDeletedOptions"
  45. :key="dict.dictValue"
  46. :label="dict.dictLabel"
  47. :value="dict.dictValue"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item>
  52. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  53. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  54. </el-form-item>
  55. </el-form>
  56. <el-row :gutter="10" class="mb8">
  57. <el-col :span="1.5">
  58. <el-button
  59. type="primary"
  60. plain
  61. icon="el-icon-plus"
  62. size="mini"
  63. @click="handleAdd"
  64. v-hasPermi="['merchantAppConfig:merchantAppConfig:add']"
  65. >新增</el-button>
  66. </el-col>
  67. <!-- <el-col :span="1.5">-->
  68. <!-- <el-button-->
  69. <!-- type="success"-->
  70. <!-- plain-->
  71. <!-- icon="el-icon-edit"-->
  72. <!-- size="mini"-->
  73. <!-- :disabled="single"-->
  74. <!-- @click="handleUpdate"-->
  75. <!-- v-hasPermi="['merchantAppConfig:merchantAppConfig:edit']"-->
  76. <!-- >修改</el-button>-->
  77. <!-- </el-col>-->
  78. <!-- <el-col :span="1.5">-->
  79. <!-- <el-button-->
  80. <!-- type="danger"-->
  81. <!-- plain-->
  82. <!-- icon="el-icon-delete"-->
  83. <!-- size="mini"-->
  84. <!-- :disabled="multiple"-->
  85. <!-- @click="handleDelete"-->
  86. <!-- v-hasPermi="['merchantAppConfig:merchantAppConfig:remove']"-->
  87. <!-- >删除</el-button>-->
  88. <!-- </el-col>-->
  89. <!-- <el-col :span="1.5">-->
  90. <!-- <el-button-->
  91. <!-- type="warning"-->
  92. <!-- plain-->
  93. <!-- icon="el-icon-download"-->
  94. <!-- size="mini"-->
  95. <!-- :loading="exportLoading"-->
  96. <!-- @click="handleExport"-->
  97. <!-- v-hasPermi="['merchantAppConfig:merchantAppConfig:export']"-->
  98. <!-- >导出</el-button>-->
  99. <!-- </el-col>-->
  100. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  101. </el-row>
  102. <el-table border v-loading="loading" :data="merchantAppConfigList" @selection-change="handleSelectionChange">
  103. <el-table-column type="selection" width="55" align="center" />
  104. <el-table-column label="主键ID" align="center" prop="id" />
  105. <el-table-column label="商户号" align="center" prop="merchantId" />
  106. <el-table-column label="商户类型" align="center" prop="merchantType" />
  107. <!-- appId 转化 appIdOptions -->
  108. <el-table-column label="应用名称" align="center" prop="appId">
  109. <template slot-scope="scope">
  110. <span v-if="scope.row.appId">
  111. {{ getAppNames(scope.row.appId) }}
  112. </span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="应用ID" align="center" prop="appId">
  116. <template slot-scope="scope">
  117. <span>{{ scope.row.appId }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="回调地址" align="center" prop="callbackUrl" />
  121. <el-table-column label="配置详情" align="center" prop="dataJson">
  122. <template slot-scope="scope">
  123. <el-button
  124. size="mini"
  125. type="text"
  126. icon="el-icon-edit"
  127. @click="handleView(scope.row)"
  128. >详情</el-button>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="创建时间" align="center" prop="createdTime" width="180">
  132. <template slot-scope="scope">
  133. <span>{{ parseTime(scope.row.createdTime, '{y}-{m}-{d}') }}</span>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="修改时间" align="center" prop="updatedTime" width="180">
  137. <template slot-scope="scope">
  138. <span>{{ parseTime(scope.row.updatedTime, '{y}-{m}-{d}') }}</span>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="状态" align="center" prop="isDeleted">
  142. <template slot-scope="scope">
  143. <dict-tag :options="isDeletedOptions" :value="scope.row.isDeleted"/>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  147. <template slot-scope="scope">
  148. <el-button
  149. size="mini"
  150. type="text"
  151. icon="el-icon-edit"
  152. @click="handleUpdate(scope.row)"
  153. v-hasPermi="['merchantAppConfig:merchantAppConfig:edit']"
  154. >修改</el-button>
  155. <el-button
  156. size="mini"
  157. type="text"
  158. icon="el-icon-delete"
  159. @click="handleDelete(scope.row)"
  160. v-hasPermi="['merchantAppConfig:merchantAppConfig:remove']"
  161. >删除</el-button>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <pagination
  166. v-show="total>0"
  167. :total="total"
  168. :page.sync="queryParams.pageNum"
  169. :limit.sync="queryParams.pageSize"
  170. @pagination="getList"
  171. />
  172. <!-- 添加或修改商户应用配置对话框 -->
  173. <el-dialog :title="title" :visible.sync="dialogVisible" width="800px" append-to-body>
  174. <el-form ref="form" :model="form" :rules="!isViewMode ? rules : {}" label-width="160px" :disabled="isViewMode">
  175. <el-form-item label="商户类型" prop="merchantType">
  176. <el-select
  177. v-model="form.merchantType"
  178. placeholder="请选择商户类型"
  179. :disabled="form.id !== null"
  180. @change="handleMerchantTypeChange"
  181. >
  182. <el-option
  183. v-for="dict in sysPayModes"
  184. :key="dict.dictValue"
  185. :label="dict.dictLabel"
  186. :value="dict.dictValue"
  187. />
  188. </el-select>
  189. </el-form-item>
  190. <el-form-item label="应用ID" prop="appIds">
  191. <el-select
  192. v-model="form.appIds"
  193. placeholder="请选择应用ID"
  194. clearable
  195. size="small"
  196. multiple
  197. >
  198. <el-option
  199. v-for="dict in appIdOptions"
  200. :key="dict.appid"
  201. :label="dict.name"
  202. :value="dict.appid"
  203. />
  204. </el-select>
  205. </el-form-item>
  206. <el-form-item>
  207. <el-divider></el-divider>
  208. </el-form-item>
  209. <!-- 动态渲染不同商户类型的配置表单 -->
  210. <div v-if="form.merchantType">
  211. <!-- 易宝支付配置 -->
  212. <div v-if="form.merchantType === 'yb'">
  213. <el-form-item label="易宝商户号" prop="ybAccount">
  214. <el-input v-model="ybConfig.ybAccount" placeholder="请输入易宝商户号"></el-input>
  215. </el-form-item>
  216. <el-form-item label="易宝Key" prop="ybKey">
  217. <el-input v-model="ybConfig.ybKey" placeholder="请输入易宝Key"></el-input>
  218. </el-form-item>
  219. <el-form-item label="易宝回调地址" prop="ybNotifyUrl">
  220. <el-input v-model="ybConfig.ybNotifyUrl" placeholder="易宝回调地址"></el-input>
  221. </el-form-item>
  222. </div>
  223. <!-- 台州银行配置 -->
  224. <div v-else-if="form.merchantType === 'tz'">
  225. <el-form-item label="台州商户号" prop="tzPlatMerCstNo">
  226. <el-input v-model="tzConfig.tzPlatMerCstNo" placeholder="请输入台州商户号"></el-input>
  227. </el-form-item>
  228. <el-form-item label="台州appSecret" prop="tzAppSecret">
  229. <el-input v-model="tzConfig.tzAppSecret" placeholder="请输入台州appSecret"></el-input>
  230. </el-form-item>
  231. <el-form-item label="台州私钥" prop="tzPrivateKey">
  232. <el-input v-model="tzConfig.tzPrivateKey" placeholder="请输入台州私钥"></el-input>
  233. </el-form-item>
  234. <el-form-item label="台州平台公钥" prop="tzPlatformPublicKey">
  235. <el-input v-model="tzConfig.tzPlatformPublicKey" placeholder="请输入台州平台公钥"></el-input>
  236. </el-form-item>
  237. <el-form-item label="台州appKey" prop="tzAppKey">
  238. <el-input v-model="tzConfig.tzAppKey" placeholder="请输入台州appKey"></el-input>
  239. </el-form-item>
  240. <el-form-item label="台州支付回调地址" prop="tzPayDecrypt">
  241. <el-input v-model="tzConfig.tzPayDecrypt" placeholder="请输入台州支付回调地址"></el-input>
  242. </el-form-item>
  243. <el-form-item label="退款回调地址" prop="tzRefundDecrypt">
  244. <el-input v-model="tzConfig.tzRefundDecrypt" placeholder="请输入退款回调地址"></el-input>
  245. </el-form-item>
  246. <el-form-item label="分账回调地址" prop="tzOrderShareDecrypt">
  247. <el-input v-model="tzConfig.tzOrderShareDecrypt" placeholder="请输入台州分账回调地址"></el-input>
  248. </el-form-item>
  249. </div>
  250. <!-- 微信支付配置 -->
  251. <div v-else-if="form.merchantType === 'wx'">
  252. <el-form-item label="微信商户号" prop="wxMchId">
  253. <el-input v-model="wxConfig.wxMchId" placeholder="请输入微信商户号"></el-input>
  254. </el-form-item>
  255. <el-form-item label="微信Key" prop="wxMchKey">
  256. <el-input v-model="wxConfig.wxMchKey" placeholder="请输入微信Key"></el-input>
  257. </el-form-item>
  258. <el-form-item label="微信商户V3密钥" prop="wxApiV3Key">
  259. <el-input v-model="wxConfig.wxApiV3Key" placeholder="请输入商户V3密钥"></el-input>
  260. </el-form-item>
  261. <el-form-item label="微信回调地址(scrm)" prop="notifyUrlScrm">
  262. <el-input v-model="wxConfig.notifyUrlScrm" placeholder="请输入商城微信回调地址"></el-input>
  263. </el-form-item>
  264. <el-form-item label="p12证书路径" prop="keyPath">
  265. <el-input v-model="wxConfig.keyPath" placeholder="请输入p12证书文件的绝对路径"></el-input>
  266. </el-form-item>
  267. </div>
  268. <!-- 汇付支付配置 -->
  269. <div v-else-if="form.merchantType === 'hf'">
  270. <el-form-item label="汇付产品号" prop="hfProductId">
  271. <el-input v-model="hfConfig.hfProductId" placeholder="汇付产品号"></el-input>
  272. </el-form-item>
  273. <el-form-item label="系统号" prop="hfSysId">
  274. <el-input v-model="hfConfig.hfSysId" placeholder="系统号Key"></el-input>
  275. </el-form-item>
  276. <el-form-item label="商户号" prop="hfHuifuId">
  277. <el-input v-model="hfConfig.huifuId" placeholder="商户号"></el-input>
  278. </el-form-item>
  279. <el-form-item label="商户私钥" prop="hfRsaPrivateKey">
  280. <el-input v-model="hfConfig.hfRsaPrivateKey" placeholder="商户私钥"></el-input>
  281. </el-form-item>
  282. <el-form-item label="汇付公钥" prop="hfRsaPublicKey">
  283. <el-input v-model="hfConfig.hfRsaPublicKey" placeholder="汇付公钥"></el-input>
  284. </el-form-item>
  285. <el-form-item label="汇付支付回调地址" prop="hfPayNotifyUrl">
  286. <el-input v-model="hfConfig.hfPayNotifyUrl" placeholder="汇付支付回调地址"></el-input>
  287. </el-form-item>
  288. <el-form-item label="大额支付回调地址" prop="hfPayOnlineNotifyUrl">
  289. <el-input v-model="hfConfig.hfPayOnlineNotifyUrl" placeholder="汇付支付回调地址"></el-input>
  290. </el-form-item>
  291. <el-form-item label="汇付退款回调地址" prop="hfRefundNotifyUrl">
  292. <el-input v-model="hfConfig.hfRefundNotifyUrl" placeholder="汇付退款回调地址"></el-input>
  293. </el-form-item>
  294. <el-form-item label="汇付大额退款回调地址" prop="hfOnlineRefundNotifyUrl">
  295. <el-input v-model="hfConfig.hfOnlineRefundNotifyUrl" placeholder="汇付分账回调地址"></el-input>
  296. </el-form-item>
  297. </div>
  298. </div>
  299. </el-form>
  300. <div slot="footer" class="dialog-footer">
  301. <el-button type="primary" @click="submitForm" v-if="!isViewMode">确 定</el-button>
  302. <el-button @click="cancel">取 消</el-button>
  303. </div>
  304. </el-dialog>
  305. </div>
  306. </template>
  307. <script>
  308. import { listMerchantAppConfig, getMerchantAppConfig, delMerchantAppConfig, addMerchantAppConfig, updateMerchantAppConfig, exportMerchantAppConfig } from "@/api/merchantAppConfig/merchantAppConfig";
  309. import { listAll } from "@/api/course/coursePlaySourceConfig";
  310. export default {
  311. name: "MerchantAppConfig",
  312. data() {
  313. return {
  314. // 遮罩层
  315. loading: true,
  316. // 导出遮罩层
  317. exportLoading: false,
  318. // 选中数组
  319. ids: [],
  320. // 非单个禁用
  321. single: true,
  322. // 非多个禁用
  323. multiple: true,
  324. // 显示搜索条件
  325. showSearch: true,
  326. // 总条数
  327. total: 0,
  328. // 商户应用配置表格数据
  329. merchantAppConfigList: [],
  330. // 弹出层标题
  331. title: "",
  332. // 创建时间时间范围
  333. daterangeCreatedTime: [],
  334. // 删除状态:0-正常,1-已删除字典
  335. isDeletedOptions: [],
  336. sysPayModes: [],
  337. detailOpen: false, // 详情对话框开关
  338. isViewMode: false, // 是否为查看模式
  339. dialogVisible: false,
  340. // 查询参数
  341. queryParams: {
  342. pageNum: 1,
  343. pageSize: 10,
  344. merchantType: null,
  345. appIds: null,
  346. createdTime: null,
  347. isDeleted: "0",
  348. },
  349. appIdOptions:[],
  350. ybConfig: {}, // 易宝配置
  351. tzConfig: {}, // 台州银行配置
  352. wxConfig: {}, // 微信配置
  353. hfConfig: {}, // 汇付配置
  354. // 表单参数
  355. form: {
  356. id: null,
  357. merchantType: null,
  358. appIds: [],
  359. callbackUrl: null,
  360. dataJson: null,
  361. createdTime: null,
  362. updatedTime: null,
  363. isDeleted: null,
  364. createdBy: null,
  365. updatedBy: null
  366. },
  367. // 表单校验
  368. rules: {
  369. merchantType: [
  370. { required: true, message: "商户类型不能为空", trigger: "change" }
  371. ],
  372. isDeleted: [
  373. { required: true, message: "删除状态:0-正常,1-已删除不能为空", trigger: "change" }
  374. ],
  375. createdBy: [
  376. { required: true, message: "创建人ID或用户名不能为空", trigger: "blur" }
  377. ],
  378. updatedBy: [
  379. { required: true, message: "修改人ID或用户名不能为空", trigger: "blur" }
  380. ]
  381. }
  382. };
  383. },
  384. created() {
  385. this.getDicts("sys_normal_disable").then(response => {
  386. this.isDeletedOptions = response.data;
  387. });
  388. this.getDicts("sys_pay_mode").then(response => {
  389. this.sysPayModes = response.data;
  390. });
  391. listAll().then(response => {
  392. this.appIdOptions=response.data;
  393. });
  394. this.getList();
  395. },
  396. methods: {
  397. /** 详情按钮操作 */
  398. handleView(row) {
  399. this.isViewMode = true;
  400. this.dialogVisible = true; // 改为设置 dialogVisible
  401. this.title = "查看商户应用配置";
  402. // 加载数据(复用修改逻辑)
  403. getMerchantAppConfig(row.id).then(response => {
  404. // 先设置基础数据
  405. Object.keys(response.data).forEach(key => {
  406. if (key !== 'appIds') { // appIds单独处理
  407. this.$set(this.form, key, response.data[key]);
  408. }
  409. });
  410. // 单独处理 appIds,确保它是响应式的数组
  411. let appIdsArray = [];
  412. if (response.data.appId) {
  413. if (typeof response.data.appId === 'string') {
  414. appIdsArray = response.data.appId.split(',').map(item => item.trim()).filter(item => item);
  415. } else if (Array.isArray(response.data.appId)) {
  416. appIdsArray = [...response.data.appId];
  417. }
  418. }
  419. // 使用 $set 确保响应式
  420. this.$set(this.form, 'appIds', appIdsArray);
  421. // 解析配置详情JSON
  422. if (this.form.dataJson) {
  423. try {
  424. const configData = JSON.parse(this.form.dataJson);
  425. switch(this.form.merchantType) {
  426. case 'yb':
  427. this.ybConfig = { ...configData };
  428. break;
  429. case 'tz':
  430. this.tzConfig = { ...configData };
  431. break;
  432. case 'wx':
  433. this.wxConfig = { ...configData };
  434. break;
  435. case 'hf':
  436. this.hfConfig = { ...configData };
  437. break;
  438. }
  439. } catch (e) {
  440. console.error('解析配置详情失败:', e);
  441. }
  442. }
  443. });
  444. }
  445. ,
  446. /** 关闭详情对话框 */
  447. closeDetailView() {
  448. this.detailOpen = false;
  449. this.isViewMode = false;
  450. this.reset();
  451. },
  452. getAppNames(appIds) {
  453. if (!appIds) return '';
  454. // 处理逗号分隔的字符串
  455. const appIdArray = typeof appIds === 'string' ? appIds.split(',') : Array.isArray(appIds) ? appIds : [appIds];
  456. // 根据 appIdOptions 查找对应的应用名称
  457. const names = appIdArray
  458. .map(id => {
  459. const option = this.appIdOptions.find(opt => opt.appid === id.trim());
  460. return option ? option.name : id;
  461. })
  462. .filter(name => name); // 过滤掉空值
  463. return names.join(', ');
  464. },
  465. /** 商户类型变化处理 */
  466. handleMerchantTypeChange(value) {
  467. // 清空之前的选择
  468. this.ybConfig = {};
  469. this.tzConfig = {};
  470. this.wxConfig = {};
  471. this.hfConfig = {};
  472. },
  473. /** 提交按钮 */
  474. submitForm() {
  475. this.$refs["form"].validate(valid => {
  476. if (valid) {
  477. // 构建配置详情JSON
  478. let configData = {};
  479. switch(this.form.merchantType) {
  480. case 'yb':
  481. configData = { ...this.ybConfig };
  482. break;
  483. case 'tz':
  484. configData = { ...this.tzConfig };
  485. break;
  486. case 'wx':
  487. configData = { ...this.wxConfig };
  488. break;
  489. case 'hf':
  490. configData = { ...this.hfConfig };
  491. break;
  492. }
  493. // 正确处理多选应用ID转字符串
  494. if (this.form.appIds && Array.isArray(this.form.appIds) && this.form.appIds.length > 0) {
  495. this.form.appId = this.form.appIds.join(',');
  496. } else {
  497. this.form.appId = '';
  498. }
  499. // 将配置转换为JSON字符串
  500. this.form.dataJson = JSON.stringify(configData);
  501. if (this.form.id != null) {
  502. updateMerchantAppConfig(this.form).then(response => {
  503. this.msgSuccess("修改成功");
  504. this.dialogVisible = false;
  505. this.getList();
  506. });
  507. } else {
  508. addMerchantAppConfig(this.form).then(response => {
  509. this.msgSuccess("新增成功");
  510. this.dialogVisible = false;
  511. this.getList();
  512. });
  513. }
  514. }
  515. });
  516. },
  517. /** 修改按钮操作 */
  518. /** 修改按钮操作 */
  519. handleUpdate(row) {
  520. this.reset();
  521. const id = row.id || this.ids;
  522. getMerchantAppConfig(id).then(response => {
  523. // 先设置基础数据
  524. Object.keys(response.data).forEach(key => {
  525. if (key !== 'appIds') { // appIds单独处理
  526. this.$set(this.form, key, response.data[key]);
  527. }
  528. });
  529. // 单独处理 appIds,确保它是响应式的数组
  530. let appIdsArray = [];
  531. if (response.data.appId) {
  532. if (typeof response.data.appId === 'string') {
  533. appIdsArray = response.data.appId.split(',').map(item => item.trim()).filter(item => item);
  534. } else if (Array.isArray(response.data.appId)) {
  535. appIdsArray = [...response.data.appId];
  536. }
  537. }
  538. // 使用 $set 确保响应式
  539. this.$set(this.form, 'appIds', appIdsArray);
  540. // 解析配置详情JSON
  541. if (this.form.dataJson) {
  542. try {
  543. const configData = JSON.parse(this.form.dataJson);
  544. switch(this.form.merchantType) {
  545. case 'yb':
  546. this.ybConfig = { ...configData };
  547. break;
  548. case 'tz':
  549. this.tzConfig = { ...configData };
  550. break;
  551. case 'wx':
  552. this.wxConfig = { ...configData };
  553. break;
  554. case 'hf':
  555. this.hfConfig = { ...configData };
  556. break;
  557. }
  558. } catch (e) {
  559. console.error('解析配置详情失败:', e);
  560. }
  561. }
  562. this.isViewMode = false; // 添加此行
  563. this.dialogVisible = true; // 替代 this.open = true
  564. this.title = "修改商户应用配置";
  565. });
  566. }
  567. ,
  568. /** 查询商户应用配置列表 */
  569. getList() {
  570. this.loading = true;
  571. // if (this.queryParams.appIds && this.queryParams.appIds.length > 0) {
  572. // this.queryParams.appIds = this.queryParams.appIds.join(',');
  573. // }
  574. this.queryParams.params = {};
  575. if (null != this.daterangeCreatedTime && '' != this.daterangeCreatedTime) {
  576. this.queryParams.params["beginCreatedTime"] = this.daterangeCreatedTime[0];
  577. this.queryParams.params["endCreatedTime"] = this.daterangeCreatedTime[1];
  578. }
  579. listMerchantAppConfig(this.queryParams).then(response => {
  580. this.merchantAppConfigList = response.rows;
  581. this.total = response.total;
  582. this.loading = false;
  583. });
  584. },
  585. // 取消按钮
  586. cancel() {
  587. this.dialogVisible = false;
  588. this.reset();
  589. },
  590. // 表单重置
  591. reset() {
  592. this.form = {
  593. id: null,
  594. merchantType: null,
  595. appId: null, // 应该删除这一行
  596. appIds: [], // 初始化为空数组而不是null
  597. callbackUrl: null,
  598. dataJson: null,
  599. createdTime: null,
  600. updatedTime: null,
  601. isDeleted: null,
  602. createdBy: null,
  603. updatedBy: null
  604. };
  605. this.resetForm("form");
  606. },
  607. /** 搜索按钮操作 */
  608. handleQuery() {
  609. this.queryParams.pageNum = 1;
  610. this.getList();
  611. },
  612. /** 重置按钮操作 */
  613. resetQuery() {
  614. this.daterangeCreatedTime = [];
  615. this.resetForm("queryForm");
  616. this.handleQuery();
  617. },
  618. // 多选框选中数据
  619. handleSelectionChange(selection) {
  620. this.ids = selection.map(item => item.id)
  621. this.single = selection.length!==1
  622. this.multiple = !selection.length
  623. },
  624. /** 新增按钮操作 */
  625. handleAdd() {
  626. this.reset();
  627. this.isViewMode = false; // 添加此行
  628. this.dialogVisible = true; // 替代 this.open = true
  629. this.title = "添加商户应用配置";
  630. },
  631. // /** 修改按钮操作 */
  632. // handleUpdate(row) {
  633. // this.reset();
  634. // const id = row.id || this.ids
  635. // getMerchantAppConfig(id).then(response => {
  636. // this.form = response.data;
  637. // this.open = true;
  638. // this.title = "修改商户应用配置";
  639. // });
  640. // },
  641. // /** 提交按钮 */
  642. // submitForm() {
  643. // this.$refs["form"].validate(valid => {
  644. // if (valid) {
  645. // if (this.form.id != null) {
  646. // updateMerchantAppConfig(this.form).then(response => {
  647. // this.msgSuccess("修改成功");
  648. // this.open = false;
  649. // this.getList();
  650. // });
  651. // } else {
  652. // addMerchantAppConfig(this.form).then(response => {
  653. // this.msgSuccess("新增成功");
  654. // this.open = false;
  655. // this.getList();
  656. // });
  657. // }
  658. // }
  659. // });
  660. // },
  661. /** 删除按钮操作 */
  662. handleDelete(row) {
  663. const ids = row.id || this.ids;
  664. this.$confirm('是否确认删除商户应用配置编号为"' + ids + '"的数据项?', "警告", {
  665. confirmButtonText: "确定",
  666. cancelButtonText: "取消",
  667. type: "warning"
  668. }).then(function() {
  669. return delMerchantAppConfig(ids);
  670. }).then(() => {
  671. this.getList();
  672. this.msgSuccess("删除成功");
  673. }).catch(() => {});
  674. },
  675. /** 导出按钮操作 */
  676. handleExport() {
  677. const queryParams = this.queryParams;
  678. this.$confirm('是否确认导出所有商户应用配置数据项?', "警告", {
  679. confirmButtonText: "确定",
  680. cancelButtonText: "取消",
  681. type: "warning"
  682. }).then(() => {
  683. this.exportLoading = true;
  684. return exportMerchantAppConfig(queryParams);
  685. }).then(response => {
  686. this.download(response.msg);
  687. this.exportLoading = false;
  688. }).catch(() => {});
  689. }
  690. }
  691. };
  692. </script>