index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="所属公司" prop="companyId">
  14. <el-select
  15. v-model="queryParams.companyId"
  16. filterable
  17. remote
  18. reserve-keyword
  19. placeholder="请输入公司名称搜索"
  20. :remote-method="searchCompanies"
  21. :loading="companySearchLoading"
  22. style="width: 220px"
  23. clearable
  24. size="small"
  25. >
  26. <el-option
  27. v-for="item in companyOptions"
  28. :key="item.dictValue"
  29. :label="item.dictLabel"
  30. :value="item.dictValue"
  31. />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="appid" prop="appid">
  35. <el-input
  36. v-model="queryParams.appid"
  37. placeholder="请输入appid"
  38. clearable
  39. size="small"
  40. @keyup.enter.native="handleQuery"
  41. />
  42. </el-form-item>
  43. <el-form-item label="状态" prop="status">
  44. <el-select
  45. v-model="queryParams.status"
  46. placeholder="请选择状态"
  47. clearable
  48. size="small"
  49. >
  50. <el-option
  51. v-for="item in statusOptions"
  52. :key="item.value"
  53. :label="item.label"
  54. :value="item.value"
  55. />
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item>
  59. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  60. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  61. </el-form-item>
  62. </el-form>
  63. <el-row :gutter="10" class="mb8">
  64. <el-col :span="1.5">
  65. <el-button
  66. type="primary"
  67. plain
  68. icon="el-icon-plus"
  69. size="mini"
  70. @click="handleAdd"
  71. v-hasPermi="['course:playSourceConfig:add']"
  72. >新增</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="success"
  77. plain
  78. icon="el-icon-edit"
  79. size="mini"
  80. :disabled="single"
  81. @click="handleUpdate"
  82. v-hasPermi="['course:playSourceConfig:edit']"
  83. >修改</el-button>
  84. </el-col>
  85. <el-col :span="1.5">
  86. <el-button
  87. type="danger"
  88. plain
  89. icon="el-icon-delete"
  90. size="mini"
  91. :disabled="multiple"
  92. @click="handleDelete"
  93. v-hasPermi="['course:playSourceConfig:remove']"
  94. >删除</el-button>
  95. </el-col>
  96. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  97. </el-row>
  98. <!-- 开关配置对话框 -->
  99. <el-dialog title="开关配置" :visible.sync="switchDialogVisible" width="500px" class="switch-dialog">
  100. <el-form :model="switchForm" label-width="100px">
  101. <el-form-item label="AppId">
  102. <el-input v-model="switchForm.appId" :disabled="true"></el-input>
  103. </el-form-item>
  104. <el-form-item label="开关状态">
  105. <el-switch
  106. v-model="switchForm.switchStatus"
  107. active-text="开启"
  108. inactive-text="关闭"
  109. active-value="001"
  110. inactive-value="002">
  111. </el-switch>
  112. </el-form-item>
  113. <el-form-item label="配置信息" v-if="switchForm.configInfo">
  114. <el-input
  115. type="textarea"
  116. :rows="4"
  117. v-model="switchForm.configInfo"
  118. :disabled="true">
  119. </el-input>
  120. </el-form-item>
  121. </el-form>
  122. <span slot="footer" class="dialog-footer">
  123. <el-button @click="switchDialogVisible = false">取 消</el-button>
  124. <el-button type="primary" @click="submitSwitchConfig">确 定</el-button>
  125. </span>
  126. </el-dialog>
  127. <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange" border>
  128. <el-table-column type="selection" width="55" align="center" />
  129. <el-table-column label="ID" align="center" prop="id" />
  130. <el-table-column label="名称" align="center" prop="name" />
  131. <el-table-column label="所属公司" align="center" prop="companyId" :formatter="companyNameFormatter"/>
  132. <el-table-column label="图标" align="center" prop="img">
  133. <template slot-scope="scope">
  134. <el-image
  135. style="width: 80px; height: 80px"
  136. :src="scope.row.img"
  137. :preview-src-list="[scope.row.img]">
  138. </el-image>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="原始ID" align="center" prop="originalId" />
  142. <el-table-column label="appId" align="center" prop="appid" />
  143. <el-table-column label="secret" align="center" prop="secret" />
  144. <el-table-column label="token" align="center" prop="token" />
  145. <el-table-column label="aesKey" align="center" prop="aesKey" />
  146. <el-table-column label="msgDataFormat" align="center" prop="msgDataFormat" />
  147. <el-table-column label="类型" align="center" prop="type">
  148. <template slot-scope="scope">
  149. <dict-tag :options="typesOptions" :value="scope.row.type"/>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="互医/商城小程序" align="center" prop="isMall" width="80px">
  153. <template slot-scope="scope">
  154. <el-tag prop="isMall" v-for="(item, index) in isMallOptions" v-if="scope.row.isMall==item.dictValue">{{item.dictLabel}}</el-tag>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="状态" align="center" prop="status" width="100px">
  158. <template slot-scope="scope">
  159. <el-tag
  160. :type="scope.row.status === 0 ? 'success' : scope.row.status === 1 ? 'warning' : 'danger'"
  161. >
  162. {{ getStatusLabel(scope.row.status) }}
  163. </el-tag>
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="配置绑定Id" align="center" prop="merchantConfigId" />
  167. <el-table-column label="创建时间" align="center" prop="createTime" />
  168. <el-table-column label="修改时间" align="center" prop="updateTime" />
  169. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  170. <template slot-scope="scope">
  171. <el-button
  172. size="mini"
  173. type="text"
  174. icon="el-icon-edit"
  175. @click="handleUpdate(scope.row)"
  176. v-hasPermi="['course:playSourceConfig:edit']"
  177. >修改</el-button>
  178. <el-button
  179. size="mini"
  180. type="text"
  181. icon="el-icon-delete"
  182. @click="handleDelete(scope.row)"
  183. v-hasPermi="['course:playSourceConfig:remove']"
  184. >删除</el-button>
  185. <el-button
  186. size="mini"
  187. type="text"
  188. icon="el-icon-setting"
  189. @click="handleSwitchConfig(scope.row)"
  190. >是否展示销售</el-button>
  191. <el-button
  192. size="mini"
  193. type="text"
  194. icon="el-icon-edit"
  195. @click="handleBind(scope.row)"
  196. v-hasPermi="['course:playSourceConfig:bind']"
  197. v-if="!scope.row.merchantConfigId"
  198. >绑定</el-button>
  199. <el-button
  200. size="mini"
  201. type="text"
  202. icon="el-icon-edit"
  203. @click="handleUnbind(scope.row)"
  204. v-hasPermi="['course:playSourceConfig:unbind']"
  205. v-if="scope.row.merchantConfigId"
  206. >解绑</el-button>
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. <pagination
  211. v-show="total>0"
  212. :total="total"
  213. :page.sync="queryParams.pageNum"
  214. :limit.sync="queryParams.pageSize"
  215. @pagination="getList"
  216. />
  217. <!-- 添加或修改点播配置对话框 -->
  218. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :before-close="resetOption">
  219. <el-form ref="form" :model="form" :rules="rules" label-width="130px">
  220. <el-form-item label="名称" prop="name">
  221. <el-input v-model="form.name" placeholder="请输入名称" />
  222. </el-form-item>
  223. <el-form-item label="所属公司" prop="companyId">
  224. <el-select
  225. v-model="form.companyId"
  226. filterable
  227. remote
  228. reserve-keyword
  229. placeholder="请输入公司名称搜索"
  230. :remote-method="searchCompanies"
  231. :loading="companySearchLoading"
  232. style="width: 220px"
  233. clearable
  234. size="small"
  235. >
  236. <el-option
  237. v-for="item in companyOptions"
  238. :key="item.dictValue"
  239. :label="item.dictLabel"
  240. :value="item.dictValue"
  241. />
  242. </el-select>
  243. </el-form-item>
  244. <el-form-item label="可查看设置公司" prop="setCompanyIdList">
  245. <el-select
  246. v-model="form.setCompanyIdList"
  247. filterable
  248. multiple
  249. remote
  250. reserve-keyword
  251. placeholder="请输入公司名称搜索"
  252. :remote-method="searchCompanies"
  253. :loading="companySearchLoading"
  254. style="width: 220px"
  255. clearable
  256. size="small"
  257. >
  258. <el-option
  259. v-for="item in companyOptions"
  260. :key="item.dictValue"
  261. :label="item.dictLabel"
  262. :value="item.dictValue"
  263. />
  264. </el-select>
  265. </el-form-item>
  266. <el-form-item label="是否是互医/商城小程序" prop="isMall">
  267. <el-select
  268. v-model="form.isMall"
  269. style="width: 220px"
  270. clearable
  271. size="small"
  272. >
  273. <el-option
  274. v-for="item in isMallOptions"
  275. :key="item.dictValue"
  276. :label="item.dictLabel"
  277. :value="item.dictValue"
  278. />
  279. </el-select>
  280. </el-form-item>
  281. <el-form-item label="状态" prop="status">
  282. <el-select
  283. v-model="form.status"
  284. placeholder="请选择状态"
  285. style="width: 220px"
  286. clearable
  287. size="small"
  288. >
  289. <el-option
  290. v-for="item in statusOptions"
  291. :key="item.value"
  292. :label="item.label"
  293. :value="item.value"
  294. />
  295. </el-select>
  296. </el-form-item>
  297. <el-form-item label="图标" prop="img">
  298. <image-upload v-model="form.img" :file-type='["png", "jpg", "jpeg"]' :limit="1"/>
  299. </el-form-item>
  300. <el-form-item label="类型" prop="type">
  301. <el-select
  302. v-model="form.type"
  303. placeholder="请选择类型">
  304. <el-option
  305. v-for="item in typesOptions"
  306. :key="item.dictValue"
  307. :label="item.dictLabel"
  308. :value="item.dictValue"/>
  309. </el-select>
  310. </el-form-item>
  311. <el-form-item label="原始id" prop="originalId">
  312. <el-input v-model="form.originalId" placeholder="请输入原始id" />
  313. </el-form-item>
  314. <el-form-item label="appid" prop="appid">
  315. <el-input v-model="form.appid" placeholder="请输入appid" />
  316. </el-form-item>
  317. <el-form-item label="secret" prop="secret">
  318. <el-input v-model="form.secret" placeholder="请输入secret" />
  319. </el-form-item>
  320. <el-form-item label="token" prop="token">
  321. <el-input v-model="form.token" placeholder="请输入token" />
  322. </el-form-item>
  323. <el-form-item label="aesKey" prop="aesKey">
  324. <el-input v-model="form.aesKey" placeholder="请输入aesKey" />
  325. </el-form-item>
  326. <el-form-item label="msgDataFormat" prop="msgDataFormat">
  327. <el-input v-model="form.msgDataFormat" placeholder="请输入msgDataFormat" />
  328. </el-form-item>
  329. </el-form>
  330. <div slot="footer" class="dialog-footer">
  331. <el-button type="primary" @click="submitForm">确 定</el-button>
  332. <el-button @click="cancel">取 消</el-button>
  333. </div>
  334. </el-dialog>
  335. <!-- 绑定 -->
  336. <el-dialog :title="bindForm.bindTitle" :visible.sync="bindForm.bindShow" width="800px" append-to-body :before-close="handleBindClose">
  337. <el-form ref="bindForm" :model="bindForm" :rules="bindRules" label-width="130px">
  338. <el-form-item label="商户类型" prop="merchantType">
  339. <el-select v-model="bindForm.merchantType" placeholder="请选择商户类型" clearable size="small" @change="changeSysPayModes">
  340. <el-option
  341. v-for="dict in sysPayModes"
  342. :key="dict.dictValue"
  343. :label="dict.dictLabel"
  344. :value="dict.dictValue"
  345. />
  346. </el-select>
  347. </el-form-item>
  348. <el-form-item label="商户号" prop="merchantId">
  349. <el-select v-model="bindForm.id" placeholder="请选择商户号" clearable size="small">
  350. <el-option
  351. v-for="dict in merchantAppConfigList"
  352. :key="dict.id"
  353. :label="dict.merchantId"
  354. :value="dict.id"
  355. />
  356. </el-select>
  357. </el-form-item>
  358. </el-form>
  359. <div slot="footer" class="dialog-footer">
  360. <el-button type="primary" @click="submitFormBind(bindCurrentRow)" >确 定</el-button>
  361. <el-button @click="cancelBind">取 消</el-button>
  362. </div>
  363. </el-dialog>
  364. </div>
  365. </template>
  366. <script>
  367. import {
  368. list,
  369. get,
  370. update,
  371. add,
  372. del,
  373. updateBindConfig,
  374. updateUnbindConfig
  375. } from '@/api/course/coursePlaySourceConfig'
  376. import {updateIsTownOn} from "@/api/system/config";
  377. import { allList } from '@/api/company/company'
  378. import { resetForm } from '@/utils/common'
  379. import { listMerchantAppConfig } from "@/api/merchantAppConfig/merchantAppConfig";
  380. export default {
  381. name: 'CoursePlaySourceConfig',
  382. data() {
  383. return {
  384. sysPayModes: [],
  385. bindCurrentRow: {},
  386. bindForm:{
  387. bindTitle: '绑定支付配置',
  388. bindShow: false,
  389. merchantType: null,
  390. id:null,
  391. },
  392. merchantAppConfigList:[],
  393. switchDialogVisible: false,
  394. // 公司搜索相关
  395. companySearchLoading: false,
  396. companyOptions: [],
  397. formatterCompanyOptions: [],
  398. switchForm: {
  399. appId: '',
  400. switchStatus: '001',
  401. },
  402. queryParams: {
  403. pageNum: 1,
  404. pageSize: 10,
  405. name: null,
  406. appid: null,
  407. status: null
  408. },
  409. showSearch: true,
  410. single: true,
  411. multiple: true,
  412. ids: [],
  413. loading: false,
  414. list: [],
  415. total: 0,
  416. typesOptions: [],
  417. statusOptions: [
  418. {
  419. label: "正常",
  420. value: 0
  421. },
  422. {
  423. label: "半封禁",
  424. value: 1
  425. },
  426. {
  427. label: "封禁",
  428. value: 2
  429. }
  430. ],
  431. isMallOptions:[
  432. {
  433. dictLabel: "是",
  434. dictValue: 1
  435. },
  436. {
  437. dictLabel: "否",
  438. dictValue: 0
  439. }
  440. ],
  441. title: null,
  442. open: false,
  443. form: {
  444. setCompanyIdList: []
  445. },
  446. bindRules:{
  447. merchantType: [
  448. { required: true, message: "商户类型不能为空", trigger: "blur" }
  449. ],
  450. id: [
  451. { required: true, message: "商户号不能为空", trigger: "blur" }
  452. ]
  453. },
  454. rules: {
  455. name: [
  456. { required: true, message: "名称不能为空", trigger: "blur" }
  457. ],
  458. // companyId: [
  459. // { required: true, message: "所属公司不能为空", trigger: "blur" }
  460. // ],
  461. appid: [
  462. { required: true, message: "appid不能为空", trigger: "blur" }
  463. ],
  464. img: [
  465. { required: true, message: "图标不能为空", trigger: "blur" }
  466. ],
  467. type: [
  468. { required: true, message: "类型不能为空", trigger: "blur" }
  469. ],
  470. originalId: [
  471. { required: true, message: "原始id不能为空", trigger: "blur" }
  472. ],
  473. secret: [
  474. { required: true, message: "secret不能为空", trigger: "blur" }
  475. ],
  476. token: [
  477. { required: true, message: "token不能为空", trigger: "blur" }
  478. ],
  479. aesKey: [
  480. { required: true, message: "aesKey不能为空", trigger: "blur" }
  481. ],
  482. msgDataFormat: [
  483. { required: true, message: "msgDataFormat不能为空", trigger: "blur" }
  484. ]
  485. }
  486. }
  487. },
  488. created() {
  489. this.getDicts("sys_pay_mode").then(response => {
  490. this.sysPayModes = response.data;
  491. });
  492. this.getDicts("play_source_type").then(response => {
  493. this.typesOptions = response.data.map(item => {
  494. return {
  495. ...item,
  496. listClass: 'primary'}
  497. })
  498. });
  499. //初始化formatterCompanyOptions
  500. allList().then(e => {
  501. this.formatterCompanyOptions = e.rows;
  502. });
  503. this.getList();
  504. },
  505. methods: {
  506. resetForm,
  507. resetOption(){
  508. console.log(1)
  509. this.companyOptions = [];
  510. this.open = false;
  511. },
  512. handleUnbind(row) {
  513. this.$confirm('是否确认解绑该配置?', "警告", {
  514. confirmButtonText: "确定",
  515. cancelButtonText: "取消",
  516. type: "warning"
  517. }).then(() => {
  518. const params = {
  519. id: row.id
  520. };
  521. updateUnbindConfig(params).then(response => {
  522. if (response.code === 200) {
  523. this.msgSuccess("解绑成功");
  524. this.getList();
  525. } else {
  526. this.msgError("解绑失败: " + response.msg);
  527. }
  528. }).catch(error => {
  529. this.msgError("请求失败: " + error.message);
  530. });
  531. }).catch(() => {
  532. // 用户取消操作
  533. });
  534. }
  535. ,
  536. submitFormBind(row) {
  537. this.$refs["bindForm"].validate(valid => {
  538. if (valid) {
  539. // 构造请求参数
  540. const params = {
  541. id: row.id, // 使用传入行数据的ID
  542. merchantType: this.bindForm.merchantType,
  543. merchantConfigId: this.bindForm.id
  544. };
  545. // 调用API更新绑定关系
  546. updateBindConfig(params).then(response => {
  547. if (response.code === 200) {
  548. this.msgSuccess("绑定配置更新成功");
  549. this.bindForm.bindShow = false;
  550. this.getList(); // 刷新列表数据
  551. this.resetForm("bindForm");
  552. } else {
  553. this.msgError("更新失败: " + response.msg);
  554. }
  555. }).catch(error => {
  556. this.msgError("请求失败: " + error.message);
  557. });
  558. }
  559. });
  560. },
  561. handleBindClose(done) {
  562. this.resetForm("bindForm");
  563. this.bindForm.bindShow = false;
  564. this.bindForm.id = null;
  565. done();
  566. },
  567. cancelBind(){
  568. this.resetForm("bindForm");
  569. this.bindForm.bindShow = false; // 关闭对话框
  570. },
  571. // 绑定支付配置
  572. handleBind(row) {
  573. this.merchantAppConfigList= [];
  574. this.bindForm.merchantType = null;
  575. this.bindForm.id = null;
  576. this.bindCurrentRow = row; // 保存当前行数据
  577. this.bindForm.bindShow = true;
  578. },
  579. changeSysPayModes(value,row){
  580. const query = {
  581. pageNum: 1,
  582. pageSize: 100,
  583. merchantType: value,
  584. isDeleted: 0,
  585. appId:this.bindCurrentRow.appid
  586. }
  587. listMerchantAppConfig(query).then( response => {
  588. this.merchantAppConfigList = response.rows;
  589. }
  590. )
  591. },
  592. // 处理开关配置
  593. handleSwitchConfig(row) {
  594. this.switchForm.appId = row.appid;
  595. this.switchForm.switchStatus = "001"; // 默认关闭状态
  596. // 调用接口获取开关状态
  597. this.getSwitchConfig(row.appid);
  598. this.switchDialogVisible = true;
  599. },
  600. /** 搜索公司 */
  601. searchCompanies(query) {
  602. this.companySearchLoading = true;
  603. allList().then(response => {
  604. this.companyOptions = response.rows;
  605. if (query) {
  606. this.companyOptions = this.companyOptions.filter(item =>
  607. item.dictLabel.includes(query)
  608. );
  609. }
  610. this.companySearchLoading = false;
  611. }).catch(()=>{
  612. this.companySearchLoading = false;
  613. });
  614. },
  615. companyNameFormatter(row){
  616. let company = this.formatterCompanyOptions.filter(item => item.dictValue === row.companyId)[0];
  617. return company ? company.dictLabel : '';
  618. },
  619. // 获取开关配置
  620. getSwitchConfig(appId) {
  621. const params = {
  622. appId: this.switchForm.appId
  623. };
  624. updateIsTownOn(params).then(response=>{
  625. if (response.code === 200) {
  626. if ( response.date){
  627. this.switchForm.switchStatus = response.date;
  628. }
  629. } else {
  630. this.$message.error('获取配置失败: ' + response.msg);
  631. }
  632. }).catch(error => {
  633. this.$message.error('请求失败: ' + error.message);
  634. });
  635. },
  636. // 提交开关配置
  637. submitSwitchConfig() {
  638. const params = {
  639. appId: this.switchForm.appId,
  640. bock: this.switchForm.switchStatus
  641. };
  642. updateIsTownOn(params).then(response=>{
  643. if (response.code === 200) {
  644. this.$message.success('配置更新成功');
  645. this.switchDialogVisible = false;
  646. } else {
  647. this.$message.error('更新失败: ' + response.msg);
  648. }
  649. })
  650. },
  651. getList() {
  652. this.loading = true;
  653. list(this.queryParams).then(response => {
  654. this.list = response.rows;
  655. this.total = response.total;
  656. this.loading = false;
  657. });
  658. },
  659. handleQuery() {
  660. this.queryParams.pageNum = 1;
  661. this.getList();
  662. },
  663. resetQuery() {
  664. this.resetForm("queryForm");
  665. this.getList();
  666. },
  667. handleAdd() {
  668. this.reset()
  669. this.open = true
  670. this.form.isMall = 0;
  671. this.title = "添加小程序配置"
  672. },
  673. handleUpdate(row) {
  674. this.reset()
  675. const id = row.id || this.ids
  676. get(id).then(response => {
  677. this.form = {
  678. ...response.data,
  679. type: response.data.type.toString()
  680. }
  681. if(!!this.form.setCompanyIds){
  682. this.$set(
  683. this.form,
  684. "setCompanyIdList",
  685. this.form.setCompanyIds.split(",").map(str => parseInt(str, 10))
  686. );
  687. // this.form.setCompanyIdList = this.form.setCompanyIds.split(",").map(str => parseInt(str, 10));
  688. }
  689. console.log( this.form);
  690. this.searchCompanies("");
  691. this.open = true
  692. this.title = "修改小程序配置"
  693. })
  694. },
  695. handleDelete(row) {
  696. const id = row.id || this.ids
  697. this.$confirm('是否确认删除小程序配置编号为"' + id + '"的数据项?', "警告", {
  698. confirmButtonText: "确定",
  699. cancelButtonText: "取消",
  700. type: "warning"
  701. }).then(function() {
  702. return del(id);
  703. }).then(() => {
  704. this.getList();
  705. this.msgSuccess("删除成功");
  706. }).catch(() => {});
  707. },
  708. handleSelectionChange(selection) {
  709. this.ids = selection.map(item => item.id)
  710. this.single = selection.length!==1
  711. this.multiple = !selection.length
  712. },
  713. submitForm() {
  714. this.$refs["form"].validate(valid => {
  715. if (valid) {
  716. if(!!this.form.setCompanyIdList && this.form.setCompanyIdList.length > 0){
  717. this.form.setCompanyIds = this.form.setCompanyIdList.join(',')
  718. }else{
  719. this.form.setCompanyIds = "";
  720. }
  721. console.log(this.form);
  722. if (this.form.id != null) {
  723. update(this.form).then(response => {
  724. const {code, msg} = response
  725. if (code !== 200) {
  726. this.msgError(msg)
  727. return
  728. }
  729. this.msgSuccess("修改成功");
  730. this.open = false;
  731. this.getList();
  732. });
  733. } else {
  734. add(this.form).then(response => {
  735. const {code, msg} = response
  736. if (code !== 200) {
  737. this.msgError(msg)
  738. return
  739. }
  740. this.msgSuccess("新增成功");
  741. this.open = false;
  742. this.getList();
  743. });
  744. }
  745. }
  746. });
  747. },
  748. cancel() {
  749. this.open = false;
  750. this.reset();
  751. },
  752. reset() {
  753. this.form = {
  754. id: null,
  755. name: null,
  756. appid: null,
  757. secret: null,
  758. img: null,
  759. originalId: null,
  760. setCompanyIdList: [],
  761. token: 'cbnd7lJvkripVOpyTFAna6NAWCxCrvC',
  762. aesKey: 'HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E',
  763. msgDataFormat: 'JSON',
  764. type: '1',
  765. status: 0
  766. }
  767. this.resetForm("form");
  768. },
  769. getStatusLabel(status) {
  770. const statusMap = {
  771. 0: '正常',
  772. 1: '半封禁',
  773. 2: '封禁'
  774. };
  775. return statusMap[status] || '未知';
  776. }
  777. },
  778. }
  779. </script>
  780. <style scoped>
  781. </style>