index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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="deptName">
  44. <el-input
  45. v-model="queryParams.deptName"
  46. placeholder="请输入部门信息"
  47. clearable
  48. size="small"
  49. @keyup.enter.native="handleQuery"
  50. />
  51. </el-form-item>
  52. <el-form-item label="状态" prop="status">
  53. <el-select
  54. v-model="queryParams.status"
  55. placeholder="请选择状态"
  56. clearable
  57. size="small"
  58. >
  59. <el-option
  60. v-for="item in statusOptions"
  61. :key="item.value"
  62. :label="item.label"
  63. :value="item.value"
  64. />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item>
  68. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  69. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  70. </el-form-item>
  71. </el-form>
  72. <el-row :gutter="10" class="mb8">
  73. <el-col :span="1.5">
  74. <el-button
  75. type="primary"
  76. plain
  77. icon="el-icon-plus"
  78. size="mini"
  79. @click="handleAdd"
  80. v-hasPermi="['course:playSourceConfig:add']"
  81. >新增</el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="success"
  86. plain
  87. icon="el-icon-edit"
  88. size="mini"
  89. :disabled="single"
  90. @click="handleUpdate"
  91. v-hasPermi="['course:playSourceConfig:edit']"
  92. >修改</el-button>
  93. </el-col>
  94. <el-col :span="1.5">
  95. <el-button
  96. type="danger"
  97. plain
  98. icon="el-icon-delete"
  99. size="mini"
  100. :disabled="multiple"
  101. @click="handleDelete"
  102. v-hasPermi="['course:playSourceConfig:remove']"
  103. >删除</el-button>
  104. </el-col>
  105. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  106. </el-row>
  107. <!-- 开关配置对话框 -->
  108. <el-dialog title="开关配置" :visible.sync="switchDialogVisible" width="500px" class="switch-dialog">
  109. <el-form :model="switchForm" label-width="100px">
  110. <el-form-item label="AppId">
  111. <el-input v-model="switchForm.appId" :disabled="true"></el-input>
  112. </el-form-item>
  113. <el-form-item label="开关状态">
  114. <el-switch
  115. v-model="switchForm.switchStatus"
  116. active-text="开启"
  117. inactive-text="关闭"
  118. active-value="001"
  119. inactive-value="002">
  120. </el-switch>
  121. </el-form-item>
  122. <el-form-item label="配置信息" v-if="switchForm.configInfo">
  123. <el-input
  124. type="textarea"
  125. :rows="4"
  126. v-model="switchForm.configInfo"
  127. :disabled="true">
  128. </el-input>
  129. </el-form-item>
  130. </el-form>
  131. <span slot="footer" class="dialog-footer">
  132. <el-button @click="switchDialogVisible = false">取 消</el-button>
  133. <el-button type="primary" @click="submitSwitchConfig">确 定</el-button>
  134. </span>
  135. </el-dialog>
  136. <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange" border>
  137. <el-table-column type="selection" width="55" align="center" />
  138. <el-table-column label="ID" align="center" prop="id" />
  139. <el-table-column label="名称" align="center" prop="name" />
  140. <el-table-column label="所属公司" align="center" prop="companyId" :formatter="companyNameFormatter"/>
  141. <el-table-column label="所属部门" align="center" width="120px">
  142. <template v-slot="scope">
  143. <span style="font-size: 20px">{{scope.row.deptName}}</span>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="图标" align="center" prop="img">
  147. <template slot-scope="scope">
  148. <el-image
  149. style="width: 80px; height: 80px"
  150. :src="scope.row.img"
  151. :preview-src-list="[scope.row.img]">
  152. </el-image>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="原始ID" align="center" prop="originalId" />
  156. <el-table-column label="appId" align="center" prop="appid" />
  157. <el-table-column label="secret" align="center" prop="secret" />
  158. <el-table-column label="token" align="center" prop="token" />
  159. <el-table-column label="aesKey" align="center" prop="aesKey" />
  160. <el-table-column label="msgDataFormat" align="center" prop="msgDataFormat" />
  161. <el-table-column label="类型" align="center" prop="type">
  162. <template slot-scope="scope">
  163. <dict-tag :options="typesOptions" :value="scope.row.type"/>
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="互医/商城小程序" align="center" prop="isMall" width="80px">
  167. <template slot-scope="scope">
  168. <el-tag prop="isMall" v-for="(item, index) in isMallOptions" v-if="scope.row.isMall==item.dictValue">{{item.dictLabel}}</el-tag>
  169. </template>
  170. </el-table-column>
  171. <el-table-column label="状态" align="center" prop="status" width="100px">
  172. <template slot-scope="scope">
  173. <el-tag
  174. :type="scope.row.status === -1 ? 'info' : scope.row.status === 0 ? 'success' : scope.row.status === 1 ? 'warning' : 'danger'"
  175. >
  176. {{ getStatusLabel(scope.row.status) }}
  177. </el-tag>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="协议状态" align="center" prop="settingsProtocolType" width="100">
  181. <template v-slot="scope">
  182. <el-tag
  183. :type="scope.row.settingsProtocolType === 2 ? 'success' : scope.row.settingsProtocolType === 1 ? 'warning' : 'info'"
  184. >
  185. {{ getProtocolStatusLabel(scope.row.settingsProtocolType) }}
  186. </el-tag>
  187. </template>
  188. </el-table-column>
  189. <el-table-column label="创建时间" align="center" prop="createTime" />
  190. <el-table-column label="修改时间" align="center" prop="updateTime" />
  191. <el-table-column label="操作" align="center" fixed="right" width="120px">
  192. <template slot-scope="scope">
  193. <el-button
  194. size="mini"
  195. type="text"
  196. icon="el-icon-edit"
  197. @click="handleUpdate(scope.row)"
  198. v-hasPermi="['course:playSourceConfig:edit']"
  199. >修改</el-button>
  200. <el-button
  201. size="mini"
  202. type="text"
  203. icon="el-icon-delete"
  204. @click="handleDelete(scope.row)"
  205. v-hasPermi="['course:playSourceConfig:remove']"
  206. >删除</el-button>
  207. <el-button
  208. size="mini"
  209. type="text"
  210. icon="el-icon-setting"
  211. @click="handleSwitchConfig(scope.row)"
  212. >是否展示销售</el-button>
  213. <el-button
  214. size="mini"
  215. type="text"
  216. icon="el-icon-document"
  217. @click="handlePrivacyConfig(scope.row)"
  218. >隐私协议</el-button>
  219. </template>
  220. </el-table-column>
  221. </el-table>
  222. <pagination
  223. v-show="total>0"
  224. :total="total"
  225. :page.sync="queryParams.pageNum"
  226. :limit.sync="queryParams.pageSize"
  227. @pagination="getList"
  228. />
  229. <!-- 添加或修改点播配置对话框 -->
  230. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :before-close="resetOption">
  231. <el-form ref="form" :model="form" :rules="rules" label-width="130px">
  232. <el-form-item label="名称" prop="name">
  233. <el-input v-model="form.name" placeholder="请输入名称" />
  234. </el-form-item>
  235. <el-form-item label="所属公司" prop="companyId">
  236. <el-select
  237. v-model="form.companyId"
  238. filterable
  239. remote
  240. reserve-keyword
  241. placeholder="请输入公司名称搜索"
  242. :remote-method="searchCompanies"
  243. :loading="companySearchLoading"
  244. style="width: 220px"
  245. clearable
  246. size="small"
  247. >
  248. <el-option
  249. v-for="item in companyOptions"
  250. :key="item.dictValue"
  251. :label="item.dictLabel"
  252. :value="item.dictValue"
  253. />
  254. </el-select>
  255. </el-form-item>
  256. <el-form-item label="所属部门" prop="createDeptId">
  257. <treeselect v-model="form.createDeptId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" :disabled="(username !== 'admin' && title === '修改小程序配置')" />
  258. </el-form-item>
  259. <el-form-item label="是否是互医/商城小程序" prop="isMall">
  260. <el-select
  261. v-model="form.isMall"
  262. style="width: 220px"
  263. clearable
  264. size="small"
  265. >
  266. <el-option
  267. v-for="item in isMallOptions"
  268. :key="item.dictValue"
  269. :label="item.dictLabel"
  270. :value="item.dictValue"
  271. />
  272. </el-select>
  273. </el-form-item>
  274. <el-form-item label="状态" prop="status">
  275. <el-select
  276. v-model="form.status"
  277. placeholder="请选择状态"
  278. style="width: 220px"
  279. clearable
  280. size="small"
  281. >
  282. <el-option
  283. v-for="item in statusOptions"
  284. :key="item.value"
  285. :label="item.label"
  286. :value="item.value"
  287. />
  288. </el-select>
  289. </el-form-item>
  290. <el-form-item label="图标" prop="img">
  291. <image-upload v-model="form.img" :file-type='["png", "jpg", "jpeg"]' :limit="1"/>
  292. </el-form-item>
  293. <el-form-item label="类型" prop="type">
  294. <el-select
  295. v-model="form.type"
  296. placeholder="请选择类型">
  297. <el-option
  298. v-for="item in typesOptions"
  299. :key="item.dictValue"
  300. :label="item.dictLabel"
  301. :value="item.dictValue"/>
  302. </el-select>
  303. </el-form-item>
  304. <el-form-item label="原始id" prop="originalId">
  305. <el-input v-model="form.originalId" placeholder="请输入原始id" />
  306. </el-form-item>
  307. <el-form-item label="appid" prop="appid">
  308. <el-input v-model="form.appid" placeholder="请输入appid" />
  309. </el-form-item>
  310. <el-form-item label="secret" prop="secret">
  311. <el-input v-model="form.secret" placeholder="请输入secret" />
  312. </el-form-item>
  313. <el-form-item label="token" prop="token">
  314. <el-input v-model="form.token" placeholder="请输入token" />
  315. </el-form-item>
  316. <el-form-item label="aesKey" prop="aesKey">
  317. <el-input v-model="form.aesKey" placeholder="请输入aesKey" />
  318. </el-form-item>
  319. <el-form-item label="msgDataFormat" prop="msgDataFormat">
  320. <el-input v-model="form.msgDataFormat" placeholder="请输入msgDataFormat" />
  321. </el-form-item>
  322. </el-form>
  323. <div slot="footer" class="dialog-footer">
  324. <el-button type="primary" @click="submitForm">确 定</el-button>
  325. <el-button @click="cancel">取 消</el-button>
  326. </div>
  327. </el-dialog>
  328. <!-- 隐私协议配置对话框 -->
  329. <el-dialog
  330. :title="privacyTitle"
  331. :visible.sync="privacyDialogVisible"
  332. width="60%"
  333. class="privacy-dialog"
  334. :close-on-click-modal="false"
  335. >
  336. <el-form
  337. ref="privacyFormRef"
  338. :model="privacyForm"
  339. :rules="privacyRules"
  340. label-width="100px"
  341. >
  342. <el-form-item label="医生注册协议" prop="doctorRegister">
  343. <editor v-model="privacyForm.doctorRegister" :min-height="292"/>
  344. </el-form-item>
  345. <el-form-item label="医生多机构备案协议" prop="doctorFiling">
  346. <editor v-model="privacyForm.doctorFiling" :min-height="292"/>
  347. </el-form-item>
  348. <el-form-item label="药师注册协议" prop="pharmacistRegister">
  349. <editor v-model="privacyForm.pharmacistRegister" :min-height="292"/>
  350. </el-form-item>
  351. <el-form-item label="药师多机构备案协议" prop="pharmacistFiling">
  352. <editor v-model="privacyForm.pharmacistFiling" :min-height="292"/>
  353. </el-form-item>
  354. <el-form-item label="用户协议" prop="userRegister">
  355. <editor v-model="privacyForm.userRegister" :min-height="292"/>
  356. </el-form-item>
  357. <el-form-item label="隐私协议" prop="userPrivacy">
  358. <editor v-model="privacyForm.userPrivacy" :min-height="292"/>
  359. </el-form-item>
  360. <el-form-item label="健康客服协议" prop="userHealth">
  361. <editor v-model="privacyForm.userHealth" :min-height="292"/>
  362. </el-form-item>
  363. <el-form-item label="会员服务协议" prop="vipService">
  364. <editor v-model="privacyForm.vipService" :min-height="292"/>
  365. </el-form-item>
  366. <el-form-item label="会员自动续费协议" prop="vipAutomaticService">
  367. <editor v-model="privacyForm.vipAutomaticService" :min-height="292"/>
  368. </el-form-item>
  369. <el-form-item label="用户注销协议" prop="userRemoveService">
  370. <editor v-model="privacyForm.userRemoveService" :min-height="292"/>
  371. </el-form-item>
  372. <el-form-item label="商家规则" prop="storeRules">
  373. <editor v-model="privacyForm.storeRules" :min-height="292"/>
  374. </el-form-item>
  375. <el-form-item label="入驻协议" prop="residencyAgreement">
  376. <editor v-model="privacyForm.residencyAgreement" :min-height="292"/>
  377. </el-form-item>
  378. </el-form>
  379. <span slot="footer" class="dialog-footer">
  380. <el-button @click="privacyDialogVisible = false">取消</el-button>
  381. <el-button type="primary" @click="submitPrivacyConfig">保存</el-button>
  382. </span>
  383. </el-dialog>
  384. </div>
  385. </template>
  386. <script>
  387. import {list, get, update, add, del,getProtocolConfig,updateProtocolConfig} from '@/api/course/coursePlaySourceConfig'
  388. import {updateIsTownOn} from "@/api/system/config";
  389. import { allList } from '@/api/company/company'
  390. import { resetForm } from '@/utils/common'
  391. import Treeselect from "@riophae/vue-treeselect";
  392. import {listDept} from "@/api/system/dept";
  393. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  394. import { getUserProfile } from "@/api/system/user";
  395. import Template from '@/views/his/complaint/template.vue'
  396. export default {
  397. name: 'CoursePlaySourceConfig',
  398. components: { Template, Treeselect},
  399. data() {
  400. return {
  401. privacyTitle:null,
  402. privacyDialogVisible: false,
  403. privacyForm: {
  404. appId: '',
  405. doctorRegister:null,
  406. doctorFiling:null,
  407. pharmacistRegister:null,
  408. pharmacistFilinga:null,
  409. userRegister:null,
  410. userPrivacy:null,
  411. userHealth:null,
  412. vipService:null,
  413. vipAutomaticService:null,
  414. userRemoveService:null,
  415. storeRules:null,
  416. residencyAgreement:null,
  417. },
  418. authOptions:[
  419. {
  420. dictLabel: "食品",
  421. dictValue: 0
  422. },
  423. {
  424. dictLabel: "药品",
  425. dictValue: 1
  426. }
  427. ],
  428. username:null,
  429. // 部门树选项
  430. deptOptions: [],
  431. switchDialogVisible: false,
  432. // 公司搜索相关
  433. companySearchLoading: false,
  434. companyOptions: [],
  435. formatterCompanyOptions: [],
  436. switchForm: {
  437. appId: '',
  438. switchStatus: '001',
  439. },
  440. queryParams: {
  441. pageNum: 1,
  442. pageSize: 10,
  443. name: null,
  444. appid: null,
  445. status: null,
  446. deptName:null
  447. },
  448. showSearch: true,
  449. single: true,
  450. multiple: true,
  451. ids: [],
  452. loading: false,
  453. list: [],
  454. total: 0,
  455. typesOptions: [],
  456. statusOptions: [
  457. {
  458. label: "待审核",
  459. value: -1
  460. },
  461. {
  462. label: "正常",
  463. value: 0
  464. },
  465. {
  466. label: "半封禁",
  467. value: 1
  468. },
  469. {
  470. label: "封禁",
  471. value: 2
  472. }
  473. ],
  474. isMallOptions:[
  475. {
  476. dictLabel: "是",
  477. dictValue: 1
  478. },
  479. {
  480. dictLabel: "否",
  481. dictValue: 0
  482. }
  483. ],
  484. title: null,
  485. open: false,
  486. form: {isMall:0},
  487. rules: {
  488. name: [
  489. { required: true, message: "名称不能为空", trigger: "blur" }
  490. ],
  491. // companyId: [
  492. // { required: true, message: "所属公司不能为空", trigger: "blur" }
  493. // ],
  494. appid: [
  495. { required: true, message: "appid不能为空", trigger: "blur" }
  496. ],
  497. img: [
  498. { required: true, message: "图标不能为空", trigger: "blur" }
  499. ],
  500. type: [
  501. { required: true, message: "类型不能为空", trigger: "blur" }
  502. ],
  503. originalId: [
  504. { required: true, message: "原始id不能为空", trigger: "blur" }
  505. ],
  506. secret: [
  507. { required: true, message: "secret不能为空", trigger: "blur" }
  508. ],
  509. token: [
  510. { required: true, message: "token不能为空", trigger: "blur" }
  511. ],
  512. aesKey: [
  513. { required: true, message: "aesKey不能为空", trigger: "blur" }
  514. ],
  515. msgDataFormat: [
  516. { required: true, message: "msgDataFormat不能为空", trigger: "blur" }
  517. ]
  518. }
  519. }
  520. },
  521. created() {
  522. this.getDicts("play_source_type").then(response => {
  523. this.typesOptions = response.data.map(item => {
  524. return {
  525. ...item,
  526. listClass: 'primary'}
  527. })
  528. });
  529. //初始化formatterCompanyOptions
  530. allList().then(e => {
  531. this.formatterCompanyOptions = e.rows;
  532. });
  533. this.getList();
  534. listDept().then(response => {
  535. this.deptOptions = this.handleTree(response.data, "deptId");
  536. });
  537. getUserProfile().then(response => {
  538. const data = response.data;
  539. this.username = data.userName;
  540. });
  541. },
  542. methods: {
  543. resetForm,
  544. resetOption(){
  545. console.log(1)
  546. this.companyOptions = [];
  547. this.open = false;
  548. },
  549. /** 转换部门数据结构 */
  550. normalizer(node) {
  551. if (node.hasOwnProperty('id') && !node.hasOwnProperty('deptId')) {
  552. return {
  553. id: node.id,
  554. label: this.getDeptNameById(node.id) || '未知部门',
  555. children: node.children || []
  556. };
  557. }
  558. if (node.children && !node.children.length) {
  559. delete node.children;
  560. }
  561. return {
  562. id: node.deptId,
  563. label: node.deptName,
  564. children: node.children
  565. };
  566. },
  567. getDeptNameById(targetId) {
  568. const deptOptions =this.deptOptions
  569. console.log("text:"+JSON.stringify(deptOptions))
  570. for (let i = 0; i < deptOptions.length; i++) {
  571. const dept = deptOptions[i];
  572. if (dept.deptId === targetId) {
  573. return dept.deptName;
  574. }
  575. }
  576. return '未知部门';
  577. },
  578. // 处理开关配置
  579. handleSwitchConfig(row) {
  580. this.switchForm.appId = row.appid;
  581. this.switchForm.switchStatus = "001"; // 默认关闭状态
  582. // 调用接口获取开关状态
  583. this.getSwitchConfig(row.appid);
  584. this.switchDialogVisible = true;
  585. },
  586. /** 搜索公司 */
  587. searchCompanies(query) {
  588. this.companySearchLoading = true;
  589. allList().then(response => {
  590. this.companyOptions = response.rows;
  591. if (query) {
  592. this.companyOptions = this.companyOptions.filter(item =>
  593. item.dictLabel.includes(query)
  594. );
  595. }
  596. this.companySearchLoading = false;
  597. }).catch(()=>{
  598. this.companySearchLoading = false;
  599. });
  600. },
  601. companyNameFormatter(row){
  602. let company = this.formatterCompanyOptions.filter(item => item.dictValue === row.companyId)[0];
  603. return company ? company.dictLabel : '';
  604. },
  605. departmentNameFormatter(row) {
  606. // 容错处理:检查必要参数
  607. if (!this.deptOptions || !this.deptOptions.length || !row.deptId) {
  608. return '';
  609. }
  610. // 使用 deptId 匹配(与表格 prop 保持一致)
  611. const targetId = String(row.deptId);
  612. // 递归查找树形结构中的部门
  613. const findDept = (depts) => {
  614. for (const dept of depts) {
  615. // 先检查当前节点
  616. if (String(dept.deptId) === targetId) {
  617. return dept;
  618. }
  619. // 如果有子节点,递归查找
  620. if (dept.children && dept.children.length > 0) {
  621. const found = findDept(dept.children);
  622. if (found) return found;
  623. }
  624. }
  625. return null;
  626. };
  627. const dept = findDept(this.deptOptions);
  628. return dept?.deptName || '';
  629. },
  630. // 获取开关配置
  631. getSwitchConfig(appId) {
  632. const params = {
  633. appId: this.switchForm.appId
  634. };
  635. updateIsTownOn(params).then(response=>{
  636. if (response.code === 200) {
  637. if ( response.date){
  638. this.switchForm.switchStatus = response.date;
  639. }
  640. } else {
  641. this.$message.error('获取配置失败: ' + response.msg);
  642. }
  643. }).catch(error => {
  644. this.$message.error('请求失败: ' + error.message);
  645. });
  646. },
  647. // 提交开关配置
  648. submitSwitchConfig() {
  649. const params = {
  650. appId: this.switchForm.appId,
  651. bock: this.switchForm.switchStatus
  652. };
  653. updateIsTownOn(params).then(response=>{
  654. if (response.code === 200) {
  655. this.$message.success('配置更新成功');
  656. this.switchDialogVisible = false;
  657. } else {
  658. this.$message.error('更新失败: ' + response.msg);
  659. }
  660. })
  661. },
  662. getList() {
  663. this.loading = true;
  664. list(this.queryParams).then(response => {
  665. this.list = response.rows;
  666. this.total = response.total;
  667. this.loading = false;
  668. });
  669. },
  670. handleQuery() {
  671. this.queryParams.pageNum = 1;
  672. this.getList();
  673. },
  674. resetQuery() {
  675. this.resetForm("queryForm");
  676. this.getList();
  677. },
  678. handleAdd() {
  679. this.reset()
  680. this.open = true
  681. this.form.isMall = 0;
  682. this.title = "添加小程序配置"
  683. },
  684. handleUpdate(row) {
  685. this.reset()
  686. const id = row.id || this.ids
  687. get(id).then(response => {
  688. this.form = {
  689. ...response.data,
  690. type: response.data.type.toString()
  691. }
  692. this.searchCompanies("");
  693. this.open = true
  694. this.title = "修改小程序配置"
  695. })
  696. },
  697. handleDelete(row) {
  698. const id = row.id || this.ids
  699. this.$confirm('是否确认删除小程序配置编号为"' + id + '"的数据项?', "警告", {
  700. confirmButtonText: "确定",
  701. cancelButtonText: "取消",
  702. type: "warning"
  703. }).then(function() {
  704. return del(id);
  705. }).then(() => {
  706. this.getList();
  707. this.msgSuccess("删除成功");
  708. }).catch(() => {});
  709. },
  710. handleSelectionChange(selection) {
  711. this.ids = selection.map(item => item.id)
  712. this.single = selection.length!==1
  713. this.multiple = !selection.length
  714. },
  715. submitForm() {
  716. this.$refs["form"].validate(valid => {
  717. if (valid) {
  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. token: 'Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC',
  757. aesKey: 'HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E',
  758. msgDataFormat: 'JSON',
  759. type: '1',
  760. isMall: 0,
  761. status: 0
  762. }
  763. this.resetForm("form");
  764. },
  765. getStatusLabel(status) {
  766. const statusMap = {
  767. '-1': '待审核',
  768. '0': '正常',
  769. '1': '半封禁',
  770. '2': '封禁'
  771. };
  772. return statusMap[status] || '未知';
  773. },
  774. // 处理隐私协议配置
  775. async handlePrivacyConfig(row) {
  776. try {
  777. this.privacyTitle = '《' + row.name + '》' + '隐私协议配置';
  778. this.privacyForm.id = row.id;
  779. this.privacyForm.appid = row.appid;
  780. this.privacyForm.name = row.name;
  781. // 显示加载
  782. this.$loading({
  783. lock: true,
  784. text: '正在加载协议配置...',
  785. spinner: 'el-icon-loading',
  786. background: 'rgba(0, 0, 0, 0.7)'
  787. });
  788. // 调用接口获取协议配置
  789. const response = await getProtocolConfig(row.id);
  790. if (response.code === 200 && response.data) {
  791. const data = response.data;
  792. // 将接口返回的数据映射到表单
  793. this.privacyForm.doctorRegister = data.doctorRegister || null;
  794. this.privacyForm.doctorFiling = data.doctorFiling || null;
  795. this.privacyForm.pharmacistRegister = data.pharmacistRegister || null;
  796. this.privacyForm.pharmacistFiling = data.pharmacistFiling || null;
  797. this.privacyForm.userRegister = data.userRegister || null;
  798. this.privacyForm.userPrivacy = data.userPrivacy || null;
  799. this.privacyForm.userHealth = data.userHealth || null;
  800. this.privacyForm.vipService = data.vipService || null;
  801. this.privacyForm.vipAutomaticService = data.vipAutomaticService || null;
  802. this.privacyForm.userRemoveService = data.userRemoveService || null;
  803. this.privacyForm.storeRules = data.storeRules || null;
  804. this.privacyForm.residencyAgreement = data.residencyAgreement || null;
  805. this.privacyForm.settingsProtocolType = data.settingsProtocolType || 0;
  806. this.$message.success('协议配置加载成功');
  807. } else {
  808. this.$message.warning('未找到协议配置,将创建新的配置');
  809. // 清空表单
  810. Object.keys(this.privacyForm).forEach(key => {
  811. if (key !== 'id' && key !== 'appid' && key !== 'name') {
  812. this.privacyForm[key] = null;
  813. }
  814. });
  815. }
  816. this.privacyDialogVisible = true;
  817. } catch (error) {
  818. this.$message.error('加载协议配置失败: ' + (error.message || error));
  819. } finally {
  820. this.$loading().close();
  821. }
  822. },
  823. // 提交隐私协议配置
  824. async submitPrivacyConfig() {
  825. try {
  826. // 验证必要字段
  827. if (!this.privacyForm.id) {
  828. this.$message.error('配置ID不能为空');
  829. return;
  830. }
  831. // 显示加载
  832. const loadingInstance = this.$loading({
  833. lock: true,
  834. text: '正在保存协议配置...',
  835. spinner: 'el-icon-loading',
  836. background: 'rgba(0, 0, 0, 0.7)'
  837. });
  838. // 调用更新接口
  839. const response = await updateProtocolConfig(this.privacyForm);
  840. if (response.code === 200) {
  841. this.$message.success(response.msg || '保存成功');
  842. this.privacyDialogVisible = false;
  843. // 刷新列表
  844. this.getList();
  845. } else {
  846. this.$message.error(response.msg || '保存失败');
  847. }
  848. } catch (error) {
  849. this.$message.error('保存失败: ' + (error.message || error));
  850. } finally {
  851. this.$loading().close();
  852. }
  853. },
  854. // 获取协议状态标签
  855. getProtocolStatusLabel(type) {
  856. const statusMap = {
  857. '0': '未设置',
  858. '1': '部分设置',
  859. '2': '已设置'
  860. };
  861. return statusMap[type] || '未知';
  862. }
  863. },
  864. }
  865. </script>
  866. <style scoped>
  867. </style>