OrgProperty.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <template>
  2. <section class="org-property">
  3. <div class="org-header">
  4. <div class="part-box-header">
  5. <h1 class="part-box-title">{{ rootOrgName }}</h1>
  6. <div>
  7. <el-button type="primary" icon="icon icon-save-white" @click="save"
  8. >保存</el-button
  9. >
  10. <el-button type="danger" plain icon="icon icon-back" @click="back"
  11. >返回</el-button
  12. >
  13. </div>
  14. </div>
  15. <div class="part-tabs">
  16. <div
  17. v-for="menu in menus"
  18. :key="menu.val"
  19. :class="['part-tabs-item', { 'is-active': activeName === menu.val }]"
  20. @click="activeName = menu.val"
  21. >
  22. <div class="part-tabs-name">
  23. {{ menu.name }}
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="org-body part-box">
  29. <!-- 题型设置 -->
  30. <!-- <el-form v-if="activeName === 'tab1'" label-width="160px">
  31. <h3 class="org-body-title">可用题型</h3>
  32. <el-form-item
  33. label="基础题型"
  34. prop="properties.ROOT_ORG_QUESTION_TYPES1"
  35. >
  36. <el-checkbox-group v-model="form.properties.ROOT_ORG_QUESTION_TYPES1">
  37. <el-checkbox label="SINGLE_ANSWER_QUESTION" class="checkbox_length"
  38. >单选</el-checkbox
  39. >
  40. <el-checkbox
  41. label="MULTIPLE_ANSWER_QUESTION"
  42. class="checkbox_length"
  43. >多选</el-checkbox
  44. >
  45. <el-checkbox label="BOOL_ANSWER_QUESTION" class="checkbox_length"
  46. >判断</el-checkbox
  47. >
  48. <el-checkbox label="FILL_BLANK_QUESTION" class="checkbox_length"
  49. >填空</el-checkbox
  50. >
  51. <el-checkbox label="TEXT_ANSWER_QUESTION" class="checkbox_length"
  52. >问答</el-checkbox
  53. >
  54. </el-checkbox-group>
  55. </el-form-item>
  56. <el-form-item
  57. label="组合题型"
  58. prop="properties.ROOT_ORG_QUESTION_TYPES2"
  59. >
  60. <el-checkbox-group v-model="form.properties.ROOT_ORG_QUESTION_TYPES2">
  61. <el-checkbox label="READING_COMPREHENSION" class="checkbox_length"
  62. >阅读理解</el-checkbox
  63. >
  64. <el-checkbox label="CLOZE" class="checkbox_length"
  65. >完形填空</el-checkbox
  66. >
  67. <el-checkbox label="PARAGRAPH_MATCHING" class="checkbox_length"
  68. >段落匹配</el-checkbox
  69. >
  70. <el-checkbox label="BANKED_CLOZE" class="checkbox_length"
  71. >选词填空</el-checkbox
  72. >
  73. </el-checkbox-group>
  74. </el-form-item>
  75. <el-form-item
  76. label="特殊题型"
  77. prop="properties.ROOT_ORG_QUESTION_TYPES3"
  78. >
  79. <el-checkbox-group v-model="form.properties.ROOT_ORG_QUESTION_TYPES3">
  80. <el-checkbox label="LISTENING_QUESTION" class="checkbox_length"
  81. >听力</el-checkbox
  82. >
  83. </el-checkbox-group>
  84. </el-form-item>
  85. <h3 class="org-body-title">成卷配置</h3>
  86. <el-form-item label="特殊设置">
  87. <el-checkbox-group
  88. v-model="form.properties.QUESTION_TYPE_SPECIAL_SET"
  89. class="pull_length"
  90. >
  91. <el-checkbox label="AUTONOMY_QUESTION" class="checkbox_length"
  92. >选做题设置</el-checkbox
  93. >
  94. </el-checkbox-group>
  95. </el-form-item>
  96. </el-form> -->
  97. <!-- 审核配置 -->
  98. <el-form v-if="activeName === 'tab2'" label-width="160px">
  99. <el-form-item class="label-title" label="题库审核" label-width="90px">
  100. <el-radio-group v-model="form.properties.PAPER_AUDIT">
  101. <el-radio label="true">开启</el-radio>
  102. <el-radio label="false">关闭</el-radio>
  103. </el-radio-group>
  104. </el-form-item>
  105. <template v-if="form.properties.PAPER_AUDIT == 'true'">
  106. <el-form-item label="初级审核">
  107. <el-radio-group v-model="form.properties.PAPER_FIRST_AUDIT">
  108. <el-radio label="true">正常流程</el-radio>
  109. <el-radio label="false">免审流程</el-radio>
  110. </el-radio-group>
  111. </el-form-item>
  112. <el-form-item label="中级审核">
  113. <el-radio-group v-model="form.properties.PAPER_SECOND_AUDIT">
  114. <el-radio label="true">正常流程</el-radio>
  115. <el-radio label="false">免审流程</el-radio>
  116. </el-radio-group>
  117. </el-form-item>
  118. <el-form-item label="高级审核">
  119. <el-radio-group v-model="form.properties.PAPER_THIRD_AUDIT">
  120. <el-radio label="true">正常流程</el-radio>
  121. <el-radio label="false">免审流程</el-radio>
  122. </el-radio-group>
  123. </el-form-item>
  124. </template>
  125. <el-form-item class="label-title" label="卷库审核" label-width="90px">
  126. <el-radio-group v-model="form.properties.EXAM_PAPER_AUDIT">
  127. <el-radio label="true">开启</el-radio>
  128. <el-radio label="false">关闭</el-radio>
  129. </el-radio-group>
  130. </el-form-item>
  131. <template v-if="form.properties.EXAM_PAPER_AUDIT == 'true'">
  132. <el-form-item label="初级审核">
  133. <el-radio-group v-model="form.properties.EXAM_PAPER_FIRST_AUDIT">
  134. <el-radio label="true">正常流程</el-radio>
  135. <el-radio label="false">免审流程</el-radio>
  136. </el-radio-group>
  137. </el-form-item>
  138. <el-form-item label="中级审核">
  139. <el-radio-group v-model="form.properties.EXAM_PAPER_SECOND_AUDIT">
  140. <el-radio label="true">正常流程</el-radio>
  141. <el-radio label="false">免审流程</el-radio>
  142. </el-radio-group>
  143. </el-form-item>
  144. <el-form-item label="高级审核">
  145. <el-radio-group v-model="form.properties.EXAM_PAPER_THIRD_AUDIT">
  146. <el-radio label="true">正常流程</el-radio>
  147. <el-radio label="false">免审流程</el-radio>
  148. </el-radio-group>
  149. </el-form-item>
  150. </template>
  151. </el-form>
  152. <!-- 查重配置 -->
  153. <el-form v-if="activeName === 'tab3'" label-width="120px">
  154. <el-form-item label="选项查重">
  155. <el-radio-group
  156. v-model="form.properties.CHECK_OPTION_DUPLICATE_THRESHOLD"
  157. >
  158. <el-radio label="true">开启</el-radio>
  159. <el-radio label="false">关闭</el-radio>
  160. </el-radio-group></el-form-item
  161. >
  162. <template
  163. v-if="form.properties.CHECK_OPTION_DUPLICATE_THRESHOLD == 'true'"
  164. >
  165. <el-form-item label="选项重复阀值">
  166. <el-input-number
  167. v-model="form.properties.OPTION_DUPLICATE_THRESHOLD"
  168. :precision="1"
  169. :min="0"
  170. :max="100"
  171. ></el-input-number>
  172. <span class="tips-info margin-left-10"
  173. >*大于等于所设阈值,判定为重复</span
  174. >
  175. </el-form-item>
  176. </template>
  177. <el-form-item label="试题查重">
  178. <el-radio-group v-model="form.properties.CHECK_DUPLICATE">
  179. <el-radio label="true">开启</el-radio>
  180. <el-radio label="false">关闭</el-radio>
  181. </el-radio-group></el-form-item
  182. >
  183. <template v-if="form.properties.CHECK_DUPLICATE == 'true'">
  184. <el-form-item label="试题重复阀值">
  185. <el-input-number
  186. v-model="form.properties.CHECK_DUPLICATE_THRESHOLD"
  187. :precision="1"
  188. :min="0"
  189. :max="100"
  190. ></el-input-number>
  191. <span class="tips-info margin-left-10"
  192. >*大于等于所设阈值,判定为重复</span
  193. >
  194. </el-form-item>
  195. <el-form-item label="试题陈列数量">
  196. <el-input-number
  197. v-model="form.properties.CHECK_DUPLICATE_COUNT"
  198. :precision="0"
  199. :min="1"
  200. :max="10"
  201. ></el-input-number>
  202. <span class="tips-info margin-left-10"
  203. >*选取超过阈值的试题在查重页面显示</span
  204. >
  205. </el-form-item>
  206. </template>
  207. </el-form>
  208. <!-- 组卷配置 -->
  209. <!-- <el-form v-if="activeName === 'tab4'" label-width="120px">
  210. <el-form-item label="综合组卷">
  211. <el-radio-group v-model="form.properties.PAPER_BUILD_SYNTHESIS">
  212. <el-radio label="true">开启</el-radio>
  213. <el-radio label="false">关闭</el-radio>
  214. </el-radio-group>
  215. <div class="tips-info">
  216. *开启跨课程组卷模式,支持将多个课程试题组到一份试卷下
  217. </div>
  218. </el-form-item>
  219. </el-form> -->
  220. <div v-show="activeName === 'tab4'">
  221. <el-form label-width="60px" inline>
  222. <el-form-item label="角色">
  223. <el-select v-model="roleCode" placeholder="请选择">
  224. <el-option
  225. v-for="item in roleList"
  226. :key="item.id"
  227. :label="item.name"
  228. :value="item.code"
  229. />
  230. </el-select>
  231. </el-form-item>
  232. <el-form-item>
  233. <el-button type="primary" @click="searchTree"> 查询 </el-button>
  234. </el-form-item>
  235. </el-form>
  236. <div class="part-box tree-box">
  237. <el-tree
  238. ref="authTree"
  239. :data="treeData"
  240. show-checkbox
  241. node-key="code"
  242. :props="defaultTreeProps"
  243. @check-change="treeCheckChange"
  244. @check="tab4Entered = true"
  245. default-expand-all
  246. :filter-node-method="filterTree"
  247. >
  248. <span class="custom-tree-node" slot-scope="{ node, data }">
  249. <span>{{ node.label }}</span>
  250. <span v-if="data.privilegeType == 'BUTTON'" class="is-btn">
  251. 按钮
  252. </span>
  253. </span>
  254. </el-tree>
  255. </div>
  256. </div>
  257. <!-- AI命题 -->
  258. <el-form v-if="activeName === 'tab5'" size="small" label-width="120px">
  259. <el-form-item label="AI命题">
  260. <el-radio-group v-model="form.properties.USE_AI_QUESTION">
  261. <el-radio label="true">开启</el-radio>
  262. <el-radio label="false">关闭</el-radio>
  263. </el-radio-group></el-form-item
  264. >
  265. <el-form-item label="购买出题数据包">
  266. <el-radio-group v-model="trade">
  267. <el-radio-button
  268. v-for="item in tradeOptions"
  269. :key="item"
  270. :label="item"
  271. >{{ item + "道" }}</el-radio-button
  272. >
  273. </el-radio-group>
  274. <el-button
  275. type="primary"
  276. class="margin-left-10"
  277. :disabled="!trade"
  278. :loading="loading"
  279. @click="toBuy"
  280. >购买</el-button
  281. >
  282. </el-form-item>
  283. <el-form-item label="剩余出题数量">{{
  284. form.properties.AI_QUESTION_REMAINDER
  285. }}</el-form-item>
  286. <el-form-item label="已购记录">
  287. <el-table :data="tradeList" border class="trade-table">
  288. <el-table-column type="index" label="序号" width="70" />
  289. <el-table-column prop="questionCount" label="购买出题数量" />
  290. <el-table-column prop="creationTime" width="170" label="购买时间" />
  291. </el-table>
  292. </el-form-item>
  293. </el-form>
  294. <el-form v-if="activeName === 'tab6'" size="small" label-width="120px">
  295. <el-form-item label="组卷配置">
  296. <el-radio-group v-model="form.properties.GEN_PAPER_QUESTION_ENABLE">
  297. <el-radio label="true">开启</el-radio>
  298. <el-radio label="false">关闭</el-radio>
  299. </el-radio-group>
  300. (开启后,则必须在指定时间段内该课程新增试题数量满足条件才允许组卷,否则提示试题数量不够不允许组卷)
  301. </el-form-item>
  302. <template v-if="form.properties.GEN_PAPER_QUESTION_ENABLE == 'true'">
  303. <el-form-item label="试题创建时间">
  304. <el-date-picker
  305. v-model="timeRange"
  306. type="daterange"
  307. range-separator="-"
  308. start-placeholder="开始时间"
  309. end-placeholder="结束时间"
  310. value-format="yyyy-MM-dd"
  311. align="right"
  312. unlink-panels
  313. >
  314. </el-date-picker>
  315. </el-form-item>
  316. <el-form-item label="新增试题数量">
  317. <!-- <el-input-number
  318. style="width: 80px"
  319. v-model="form.properties.GEN_PAPER_QUESTION_COUNT"
  320. :step="1"
  321. :controls="false"
  322. ></el-input-number> -->
  323. <el-input
  324. style="width: 80px"
  325. maxLength="7"
  326. v-model="form.properties.GEN_PAPER_QUESTION_COUNT"
  327. ></el-input>
  328. </el-form-item>
  329. </template>
  330. </el-form>
  331. </div>
  332. </section>
  333. </template>
  334. <script>
  335. import { mapState } from "vuex";
  336. import { QUESTION_API } from "@/constants/constants.js";
  337. import { orgAiTransactionSaveApi, orgAiTransactionListApi } from "../api";
  338. export default {
  339. name: "OrgProperty",
  340. data() {
  341. return {
  342. tab4Entered: false,
  343. treeCheckedCodes: [],
  344. style: {
  345. label_width_tab1: "120px",
  346. label_width_tab2: "120px",
  347. label_width_tab3: "120px",
  348. },
  349. menus: [
  350. // {
  351. // name: "题型设置",
  352. // val: "tab1",
  353. // },
  354. {
  355. name: "审核配置",
  356. val: "tab2",
  357. },
  358. {
  359. name: "查重配置",
  360. val: "tab3",
  361. },
  362. // {
  363. // name: "组卷配置",
  364. // val: "tab4",
  365. // },
  366. {
  367. name: "角色管理",
  368. val: "tab4",
  369. },
  370. {
  371. name: "AI命题",
  372. val: "tab5",
  373. },
  374. { name: "组卷配置", val: "tab6" },
  375. ],
  376. activeName: "tab2",
  377. rootOrgName: "",
  378. form: {
  379. orgId: null,
  380. properties: {
  381. // ROOT_ORG_QUESTION_TYPES: [],
  382. // ROOT_ORG_QUESTION_TYPES1: [],
  383. // ROOT_ORG_QUESTION_TYPES2: [],
  384. // ROOT_ORG_QUESTION_TYPES3: [],
  385. // QUESTION_TYPE_SPECIAL_SET: [],
  386. PAPER_AUDIT: "false",
  387. PAPER_FIRST_AUDIT: "false",
  388. PAPER_SECOND_AUDIT: "false",
  389. PAPER_THIRD_AUDIT: "false",
  390. EXAM_PAPER_AUDIT: "false",
  391. EXAM_PAPER_FIRST_AUDIT: "false",
  392. EXAM_PAPER_SECOND_AUDIT: "false",
  393. EXAM_PAPER_THIRD_AUDIT: "false",
  394. CHECK_DUPLICATE: "false",
  395. CHECK_OPTION_DUPLICATE_THRESHOLD: "false",
  396. CHECK_DUPLICATE_THRESHOLD: 80,
  397. OPTION_DUPLICATE_THRESHOLD: 94,
  398. CHECK_DUPLICATE_COUNT: 5,
  399. // 综合组卷
  400. // PAPER_BUILD_SYNTHESIS: "false",
  401. // AI命题
  402. AI_QUESTION_REMAINDER: 0,
  403. USE_AI_QUESTION: "false",
  404. GEN_PAPER_QUESTION_ENABLE: "true",
  405. GEN_PAPER_QUESTION_COUNT: "",
  406. GEN_PAPER_QUESTION_START: "",
  407. GEN_PAPER_QUESTION_END: "",
  408. },
  409. },
  410. timeRange: [],
  411. roleCode: "",
  412. roleList: [],
  413. rules: {
  414. // code: [{ required: true, validator: validateCode, trigger: "blur" }],
  415. },
  416. // AI命题
  417. trade: 10000,
  418. tradeOptions: [10000, 20000, 50000],
  419. tradeList: [],
  420. loading: false,
  421. defaultTreeProps: {
  422. label: "name",
  423. children: "subRolePrivilege",
  424. },
  425. treeData: [],
  426. };
  427. },
  428. computed: {
  429. ...mapState({ user: (state) => state.user }),
  430. },
  431. created() {
  432. this.form.orgId = this.$route.params.rootOrgId;
  433. this.rootOrgName =
  434. this.$route.params.rootOrgName +
  435. "(" +
  436. this.$route.params.rootOrgCode +
  437. ")";
  438. if (!this.form.orgId) {
  439. this.form.orgId = sessionStorage.getItem("org_prop_info_org_id");
  440. this.rootOrgName = sessionStorage.getItem("org_prop_info_org_name");
  441. } else {
  442. sessionStorage.setItem("org_prop_info_org_id", this.form.orgId);
  443. sessionStorage.setItem("org_prop_info_org_name", this.rootOrgName);
  444. }
  445. this.init();
  446. this.getTradeList();
  447. },
  448. mounted() {
  449. setTimeout(() => {
  450. this.$store.commit("UPDATE_CURRENT_PATHS", [
  451. "系统管理",
  452. "顶级机构管理",
  453. "机构设置",
  454. ]);
  455. }, 200);
  456. },
  457. methods: {
  458. init() {
  459. var url = QUESTION_API + "/org/allProperties/" + this.form.orgId;
  460. this.$httpWithMsg.get(url).then((response) => {
  461. if (response.data) {
  462. // if (response.data.ROOT_ORG_QUESTION_TYPES1) {
  463. // this.form.properties.ROOT_ORG_QUESTION_TYPES1 = JSON.parse(
  464. // response.data.ROOT_ORG_QUESTION_TYPES1
  465. // );
  466. // }
  467. // if (response.data.ROOT_ORG_QUESTION_TYPES2) {
  468. // this.form.properties.ROOT_ORG_QUESTION_TYPES2 = JSON.parse(
  469. // response.data.ROOT_ORG_QUESTION_TYPES2
  470. // );
  471. // }
  472. // if (response.data.ROOT_ORG_QUESTION_TYPES3) {
  473. // this.form.properties.ROOT_ORG_QUESTION_TYPES3 = JSON.parse(
  474. // response.data.ROOT_ORG_QUESTION_TYPES3
  475. // );
  476. // }
  477. // if (response.data.QUESTION_TYPE_SPECIAL_SET) {
  478. // this.form.properties.QUESTION_TYPE_SPECIAL_SET = JSON.parse(
  479. // response.data.QUESTION_TYPE_SPECIAL_SET
  480. // );
  481. // }
  482. this.form.properties = this.$objAssign(
  483. this.form.properties,
  484. response.data
  485. );
  486. this.timeRange = [
  487. response.data.GEN_PAPER_QUESTION_START || "",
  488. response.data.GEN_PAPER_QUESTION_END || "",
  489. ];
  490. }
  491. });
  492. },
  493. getRoleList() {
  494. this.$httpWithMsg
  495. .post(QUESTION_API + "/rolePrivilege/getRoles")
  496. .then((res) => {
  497. this.roleList = res.data;
  498. if (res.data?.length) {
  499. this.roleCode = res.data[0].code;
  500. }
  501. });
  502. },
  503. searchTree() {},
  504. setParams() {
  505. for (let i of this.form.properties.ROOT_ORG_QUESTION_TYPES1) {
  506. this.form.properties.ROOT_ORG_QUESTION_TYPES.push(i);
  507. }
  508. for (let i of this.form.properties.ROOT_ORG_QUESTION_TYPES2) {
  509. this.form.properties.ROOT_ORG_QUESTION_TYPES.push(i);
  510. }
  511. for (let i of this.form.properties.ROOT_ORG_QUESTION_TYPES3) {
  512. this.form.properties.ROOT_ORG_QUESTION_TYPES.push(i);
  513. }
  514. this.form.properties.ROOT_ORG_QUESTION_TYPES = JSON.stringify(
  515. this.form.properties.ROOT_ORG_QUESTION_TYPES
  516. );
  517. if (this.form.properties.ROOT_ORG_QUESTION_TYPES1) {
  518. this.form.properties.ROOT_ORG_QUESTION_TYPES1 = JSON.stringify(
  519. this.form.properties.ROOT_ORG_QUESTION_TYPES1
  520. );
  521. }
  522. if (this.form.properties.ROOT_ORG_QUESTION_TYPES2) {
  523. this.form.properties.ROOT_ORG_QUESTION_TYPES2 = JSON.stringify(
  524. this.form.properties.ROOT_ORG_QUESTION_TYPES2
  525. );
  526. }
  527. if (this.form.properties.ROOT_ORG_QUESTION_TYPES3) {
  528. this.form.properties.ROOT_ORG_QUESTION_TYPES3 = JSON.stringify(
  529. this.form.properties.ROOT_ORG_QUESTION_TYPES3
  530. );
  531. }
  532. if (this.form.properties.QUESTION_TYPE_SPECIAL_SET) {
  533. this.form.properties.QUESTION_TYPE_SPECIAL_SET = JSON.stringify(
  534. this.form.properties.QUESTION_TYPE_SPECIAL_SET
  535. );
  536. }
  537. },
  538. async save() {
  539. // this.setParams();
  540. let url = QUESTION_API + "/org/saveOrgProperties";
  541. if (this.form.properties.GEN_PAPER_QUESTION_ENABLE == "false") {
  542. this.timeRange = [];
  543. this.form.properties.GEN_PAPER_QUESTION_COUNT = "";
  544. }
  545. let GEN_PAPER_QUESTION_START = this.timeRange[0] || "";
  546. let GEN_PAPER_QUESTION_END = this.timeRange[1] || "";
  547. let params = {
  548. orgId: this.form.orgId,
  549. properties: {
  550. ...this.form.properties,
  551. GEN_PAPER_QUESTION_START,
  552. GEN_PAPER_QUESTION_END,
  553. },
  554. };
  555. let res = await this.$httpWithMsg.put(url, params).catch(() => {});
  556. if (!res) return;
  557. if (this.tab4Entered) {
  558. let res2 = await this.$httpWithMsg
  559. .post(QUESTION_API + "/rolePrivilege/savePrivilege", {
  560. privileges: this.treeCheckedCodes,
  561. rootOrgId: this.form.orgId,
  562. role: this.roleCode,
  563. })
  564. .catch(() => {});
  565. if (!res2) return;
  566. }
  567. this.$notify({
  568. type: "success",
  569. message: "保存成功!",
  570. });
  571. this.back();
  572. },
  573. async getTradeList() {
  574. const res = await orgAiTransactionListApi(this.form.orgId);
  575. this.tradeList = res.data || [];
  576. },
  577. async toBuy() {
  578. if (!this.trade) return;
  579. const confirm = await this.$confirm(
  580. `确定要购买${this.trade}道吗?`,
  581. "提示",
  582. {
  583. type: "warning",
  584. }
  585. ).catch(() => {});
  586. if (confirm !== "confirm") return;
  587. if (this.loading) return;
  588. this.loading = true;
  589. const res = await orgAiTransactionSaveApi({
  590. rootOrgId: this.form.orgId,
  591. trade: this.trade,
  592. }).catch(() => {});
  593. this.loading = false;
  594. if (!res) return;
  595. this.$message.success("购买成功!");
  596. this.init();
  597. this.getTradeList();
  598. },
  599. back() {
  600. this.$router.push({ path: "/questions/school" });
  601. },
  602. treeCheckChange(curNode, isChecked) {
  603. let keys = this.$refs.authTree.getCheckedKeys(true);
  604. if (curNode.privilegeType === "BUTTON" && isChecked) {
  605. keys = Array.from(new Set([...keys, curNode.mountPageCode]));
  606. this.$refs.authTree.setCheckedKeys(keys);
  607. }
  608. // this.treeCheckedCodes = [...keys].filter(
  609. // (key) => !key.endsWith("__page")
  610. // );
  611. this.$nextTick(() => {
  612. let nodes = this.$refs.authTree.getCheckedNodes(false, true);
  613. this.treeCheckedCodes = nodes
  614. .map((item) => item.code)
  615. .filter((key) => !key.endsWith("__page"));
  616. });
  617. },
  618. filterTree(value, data) {
  619. return !data.originId;
  620. },
  621. },
  622. watch: {
  623. activeName(val) {
  624. if (val === "tab4" && !this.tab4Entered) {
  625. this.$nextTick(() => {
  626. this.getRoleList();
  627. });
  628. }
  629. },
  630. roleCode(val) {
  631. this.$httpWithMsg
  632. .post(
  633. QUESTION_API +
  634. `/rolePrivilege/getRolePrivileges?roleCode=${val}&rootOrgId=${this.form.orgId}`
  635. )
  636. .then((res) => {
  637. let checkedLeafCodes = [];
  638. res.data.forEach((level1) => {
  639. if (level1.subRolePrivilege?.length) {
  640. level1.subRolePrivilege = level1.subRolePrivilege.map(
  641. (level2) => {
  642. if (level2.subRolePrivilege?.length) {
  643. level2.subRolePrivilege = level2.subRolePrivilege.map(
  644. (v) => {
  645. v.mountPageCode = level2.code + "__page";
  646. v.enable && checkedLeafCodes.push(v.code);
  647. return v;
  648. }
  649. );
  650. level2.subRolePrivilege.unshift({
  651. code: level2.code + "__page",
  652. enable: level2.enable,
  653. name: "页面",
  654. privilegeType: "PAGE",
  655. originId: level2.code,
  656. });
  657. checkedLeafCodes.push(level2.code + "__page");
  658. } else {
  659. level2.enable && checkedLeafCodes.push(level2.code);
  660. }
  661. return level2;
  662. }
  663. );
  664. } else {
  665. level1.enable && checkedLeafCodes.push(level1.code);
  666. }
  667. });
  668. this.treeData = res.data;
  669. //初始化选中状态,使用叶子节点的enable进行设置
  670. this.$refs.authTree.setCheckedKeys(checkedLeafCodes);
  671. });
  672. },
  673. treeData() {
  674. this.$nextTick(() => {
  675. this.$refs.authTree?.filter("");
  676. });
  677. },
  678. },
  679. };
  680. </script>
  681. <style lang="scss" scoped>
  682. .org-property {
  683. .tree-box {
  684. :deep(.custom-tree-node) {
  685. .is-page,
  686. .is-btn {
  687. padding: 3px 5px;
  688. font-size: 10px;
  689. border-radius: 4px;
  690. background: #67c23a;
  691. color: #fff;
  692. margin-left: 8px;
  693. vertical-align: middle;
  694. position: relative;
  695. top: -2px;
  696. }
  697. }
  698. }
  699. }
  700. </style>