index.vue 25 KB

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