index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <div id="knowledgeManagement">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. :tableSets="tableSet"
  12. :tableData="tableData"
  13. :navText="navText"
  14. @addClick="addClick"
  15. :loading="loading"
  16. @editInfo="editInfo"
  17. >
  18. <template slot="btn" slot-scope="props">
  19. <el-button type="text" @click="addClick(props.scope.row, 0)"
  20. >修改</el-button
  21. >
  22. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  23. </template>
  24. </table-list>
  25. <pagination
  26. :total="total"
  27. :pageSize="formData.pageSize"
  28. :currentPage="formData.pageNum"
  29. @handleSizeChange="handleSizeChange"
  30. @handleCurrentChange="handleCurrentChange"
  31. />
  32. <el-dialog
  33. :visible.sync="dialogVisible"
  34. width="780px"
  35. :show-close="false"
  36. :close-on-click-modal="false"
  37. >
  38. <div slot="title" class="hearders">
  39. <div class="leftTitle">
  40. {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
  41. </div>
  42. <div class="rightBoxs">
  43. <img src="@/assets/images/Close@2x.png" alt="" @click="close" />
  44. </div>
  45. </div>
  46. <div>
  47. <el-form label-position="right" label-width="110px" :model="listData">
  48. <el-form-item
  49. v-for="(items, indexs) in listitem"
  50. :key="indexs"
  51. :label="items.label"
  52. :prop="items.prop"
  53. >
  54. <div v-if="items.scope === 'buss'">
  55. <el-select
  56. v-model="eduType"
  57. placeholder="请选择教育类型"
  58. @change="changeEduType"
  59. >
  60. <el-option
  61. v-for="(item, index) in eduTypeOptions"
  62. :key="index"
  63. :label="item.educationName"
  64. :value="item.id"
  65. >
  66. </el-option>
  67. </el-select>
  68. <el-select
  69. v-model="courType"
  70. placeholder="请选择业务层次"
  71. @change="changecourseType"
  72. >
  73. <el-option
  74. v-for="(item, index) in newCourTypeOptions"
  75. :key="index"
  76. :label="item.businessName"
  77. :value="item.id"
  78. >
  79. </el-option>
  80. </el-select>
  81. <el-popover
  82. ref="popovers"
  83. placement="bottom"
  84. trigger="click"
  85. @show="showHandle"
  86. @hide="hideHandle"
  87. :disabled="courType ? false : true"
  88. >
  89. <el-checkbox-group v-model="sujectArray" class="checkboxSty">
  90. <el-checkbox
  91. v-for="(item, index) in newSujectOption"
  92. :label="item.newId"
  93. :key="index"
  94. >{{ item.subjectName }}</el-checkbox
  95. >
  96. </el-checkbox-group>
  97. <div
  98. style="display: block; text-align: center; margin-top: 10px"
  99. >
  100. <el-button
  101. size="mini"
  102. type="primary"
  103. @click="submitSujectArray"
  104. >确定</el-button
  105. >
  106. </div>
  107. <el-button slot="reference" style="margin-left: 12px"
  108. >请选择科目</el-button
  109. >
  110. </el-popover>
  111. </div>
  112. <div v-else-if="items.scope === 'activeBox'">
  113. <div :class="changeHeight ? 'ach' : 'clh'">
  114. <div
  115. v-for="(item, index) in newSujectApis"
  116. :key="index"
  117. class="listBoxStys"
  118. >
  119. {{
  120. item.educationName +
  121. " - " +
  122. item.projectName +
  123. " - " +
  124. item.businessName +
  125. " - " +
  126. item.subjectName
  127. }}
  128. <i
  129. class="el-icon-error closeIcons"
  130. @click="closeType(index)"
  131. ></i>
  132. </div>
  133. </div>
  134. <el-button
  135. size="mini"
  136. v-if="newSujectApis.length > 1"
  137. @click="changeType"
  138. >{{ changeHeight ? "展开" : "关闭" }}</el-button
  139. >
  140. <span v-if="newSujectApis.length === 0">未选项目类型</span>
  141. </div>
  142. <div v-else>
  143. <div v-if="statusPop === 0">
  144. {{ listData.knowledgeName }}
  145. </div>
  146. <div v-else>
  147. <div v-if="!BusNameList.length">请在下面输入框添加知识点</div>
  148. <ul v-else class="BusBoxs">
  149. <li
  150. class="fot_Le"
  151. v-for="(item, index) in BusNameList"
  152. :key="index"
  153. >
  154. {{ item }}
  155. <i
  156. class="el-icon-error icon_clear"
  157. @click="clearBusName(index)"
  158. ></i>
  159. </li>
  160. <div style="clear: both"></div>
  161. </ul>
  162. <el-input
  163. style="width: 40%; margin-right: 10px"
  164. v-model="BusName"
  165. ></el-input
  166. ><el-button @click="addBusName">添加</el-button>
  167. </div>
  168. </div>
  169. </el-form-item>
  170. </el-form>
  171. </div>
  172. <span slot="footer" class="dialog-footer">
  173. <el-button @click="close">取 消</el-button>
  174. <el-button type="primary" @click="submit">确 定</el-button>
  175. </span>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script>
  180. import searchBoxNew from "@/components/searchBoxNew";
  181. import tableList from "@/components/tableList";
  182. import pagination from "@/components/pagination";
  183. export default {
  184. components: { searchBoxNew, tableList, pagination },
  185. data() {
  186. return {
  187. loading: false, //当前表单加载是否加载动画
  188. navText: {
  189. title: "知识点",
  190. index: 0,
  191. ch: "条",
  192. num: false,
  193. choice: true,
  194. addHide: false,
  195. backFatherBtn: {
  196. status: false,
  197. title: "未定义",
  198. },
  199. },
  200. //搜索
  201. formList: [
  202. {
  203. prop: "educationId",
  204. placeholder: "教育类型",
  205. scope: "educationType",
  206. },
  207. {
  208. prop: "businessId",
  209. placeholder: "业务层次",
  210. scope: "businessLevel",
  211. edu:"educationId",
  212. },
  213. {
  214. prop: "subjectId",
  215. placeholder: "科目",
  216. scope: "sujectType",
  217. edu:"educationId",
  218. },
  219. {
  220. prop: "knowledgeName",
  221. placeholder: "请输入知识点名称",
  222. },
  223. ],
  224. formData: {
  225. status: "0,1",
  226. pageSize: 10,
  227. pageNum: 1,
  228. },
  229. // 表单
  230. tableSet: [
  231. {
  232. label: "知识点编码",
  233. prop: "encoder",
  234. hidden: true,
  235. },
  236. {
  237. label: "知识点标题",
  238. prop: "knowledgeName",
  239. scope: "editInfo",
  240. hidden: true,
  241. },
  242. {
  243. label: "适用业务层级",
  244. prop: "courseBusinessList",
  245. hidden: true,
  246. scope: "mapTypesMores",
  247. width: "400",
  248. },
  249. ],
  250. eduTypeOptions: [], //教育类型数据
  251. projectTypeOptions: [], //项目类型数据
  252. courTypeOptions: [], //业务层次数据
  253. newCourTypeOptions: [], //当前业务层次数据
  254. sujectOption: [], //科目数据
  255. newSujectOption: [], //当前科目数据数据
  256. eduType: "", //当前选中教育类型
  257. courType: "", //当前选中业务层次
  258. sujectApis: [], //当前存在的科目
  259. newSujectApis: [],
  260. sujectArray: [], //选中的科目
  261. BusName: "", //标签名称
  262. BusNameList: [], //标签列表
  263. tableData: [], //表单数据
  264. total: 0, //一共多少条
  265. changeHeight: false,
  266. rules: [],
  267. listData: {},
  268. listitem: [
  269. {
  270. label: "适用业务层级",
  271. scope: "buss",
  272. },
  273. {
  274. label: "已选科目",
  275. scope: "activeBox",
  276. },
  277. {
  278. label: "知识点",
  279. },
  280. ],
  281. statusPop: 1,
  282. dialogVisible: false,
  283. };
  284. },
  285. watch: {
  286. sujectApis: {
  287. immediate: true,
  288. handler(newName, oldName) {
  289. this.changeTypes();
  290. },
  291. },
  292. },
  293. mounted() {
  294. this.getDict();
  295. this.search();
  296. },
  297. methods: {
  298. addBusName() {
  299. if (this.BusName.trim()) {
  300. this.BusNameList.push(this.BusName);
  301. this.BusName = "";
  302. } else {
  303. this.$message({
  304. message: "请输入知识点内容",
  305. type: "warning",
  306. duration: 1200,
  307. });
  308. this.BusName = "";
  309. }
  310. },
  311. changeTypes() {
  312. var self = this;
  313. var arrays = [];
  314. this.sujectApis.map((item, index) => {
  315. this.courTypeOptions.map((items) => {
  316. if (items.id === item.split("-").map(Number)[0]) {
  317. var obj = {
  318. educationTypeId: items.educationId,
  319. educationName: items.educationName,
  320. projectId: items.projectId,
  321. projectName: items.projectName,
  322. businessId: items.id,
  323. businessName: items.businessName,
  324. };
  325. self.sujectOption.map((i) => {
  326. if (
  327. i.id === item.split("-").map(Number)[1] &&
  328. i.courseArrays.indexOf(items.projectId) !== -1
  329. ) {
  330. obj.subjectName = i.subjectName;
  331. obj.subjectId = i.id;
  332. }
  333. });
  334. arrays.push(obj);
  335. }
  336. });
  337. });
  338. this.newSujectApis = arrays;
  339. console.log(this.newSujectApis);
  340. },
  341. getDict() {
  342. this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
  343. this.eduTypeOptions = res.rows;
  344. });
  345. this.$api.inquireCourseProjectType({ status: 1 }).then((res) => {
  346. this.projectTypeOptions = res.rows;
  347. });
  348. this.$api.inquirebusinessList({ status: 1 }).then((res) => {
  349. this.courTypeOptions = res.rows;
  350. this.newCourTypeOptions = res.rows;
  351. });
  352. this.$api.inquireCourseSubject({ status: 1 }).then((res) => {
  353. res.rows.map((item, index) => {
  354. var array = [];
  355. item.courseProjectTypes.map((items, indexs) => {
  356. array.push(items.id);
  357. });
  358. item.courseArrays = array;
  359. });
  360. this.sujectOption = res.rows;
  361. });
  362. },
  363. editInfo(v) {
  364. this.addClick(v, 0);
  365. },
  366. //int === 1搜索 页码归1 int === 2重置 条件初始化
  367. search(int) {
  368. this.loading = true;
  369. if (int === 1) {
  370. this.formData.pageNum = 1;
  371. }
  372. if (int === 2) {
  373. this.formData = {
  374. status: "0,1",
  375. pageSize: 10,
  376. pageNum: 1,
  377. };
  378. }
  379. this.$api.inquireKnowledgeExamListS(this.formData).then((res) => {
  380. this.tableData = res.rows;
  381. this.total = res.total;
  382. this.navText.index = res.total;
  383. }).finally(()=>{
  384. this.loading = false;
  385. })
  386. },
  387. init() {
  388. this.search(2);
  389. },
  390. changeType() {
  391. this.changeHeight = !this.changeHeight;
  392. },
  393. changeEduType() {
  394. if (!(this.courType === undefined || this.courType === "")) {
  395. this.courType = "";
  396. }
  397. var arrays = [];
  398. this.courTypeOptions.map((item) => {
  399. if (item.educationId === this.eduType) {
  400. arrays.push(item);
  401. }
  402. });
  403. this.newCourTypeOptions = arrays;
  404. },
  405. changecourseType() {
  406. this.newCourTypeOptions.map((item, index) => {
  407. if (item.id === this.courType) {
  408. this.eduType = item.educationId;
  409. var array = [];
  410. this.sujectOption.map((items, indexs) => {
  411. if (items.courseArrays.indexOf(item.projectId) !== -1) {
  412. array.push(items);
  413. }
  414. });
  415. this.newSujectOption = array;
  416. }
  417. });
  418. var arrays = [];
  419. this.courTypeOptions.map((item) => {
  420. if (item.educationId === this.eduType) {
  421. arrays.push(item);
  422. }
  423. });
  424. this.newCourTypeOptions = arrays;
  425. this.$refs.popovers[0].doClose();
  426. },
  427. submitSujectArray() {
  428. var self = this;
  429. this.sujectApis = this.sujectApis.filter((item, index) => {
  430. return item.split("-").map(Number)[0] !== Number(self.courType);
  431. });
  432. for (let i = 0; i < this.sujectArray.length; i++) {
  433. this.sujectApis.push(this.sujectArray[i]);
  434. }
  435. this.$refs.popovers[0].doClose();
  436. },
  437. submit() {
  438. if (this.statusPop === 1) {
  439. var dataInfos = {
  440. status: 1,
  441. examKnowledgeBusinessAddBoList: this.newSujectApis,
  442. knowledgeName: this.BusNameList,
  443. };
  444. this.$api.addKnowledgeExam(dataInfos).then((res) => {
  445. this.$message.success("添加成功");
  446. this.dialogVisible = false;
  447. this.search();
  448. });
  449. } else {
  450. var dataInfos = {
  451. status: this.listData.status,
  452. knowledgeId: this.listData.knowledgeId,
  453. examKnowledgeBusinessAddBoList: this.newSujectApis,
  454. };
  455. this.$api.editKnowledgeExam(dataInfos).then((res) => {
  456. this.$message.success("修改成功");
  457. this.dialogVisible = false;
  458. this.search();
  459. });
  460. }
  461. },
  462. del(v) {
  463. this.$alert(
  464. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  465. "提示",
  466. {
  467. dangerouslyUseHTMLString: true,
  468. }
  469. )
  470. .then(() => {
  471. var data = {
  472. knowledgeId: v.knowledgeId,
  473. status: -1,
  474. };
  475. this.$api.editKnowledgeExam(data).then((res) => {
  476. this.$message.success("删除成功");
  477. this.search();
  478. });
  479. })
  480. .catch(() => {
  481. this.$message({
  482. type: "info",
  483. message: "已取消删除",
  484. });
  485. });
  486. },
  487. hideHandle() {},
  488. showHandle() {
  489. var array = [];
  490. for (let i = 0; i < this.sujectApis.length; i++) {
  491. if (
  492. this.sujectApis[i].split("-").map(Number)[0] === Number(this.courType)
  493. ) {
  494. array.push(this.sujectApis[i]);
  495. }
  496. }
  497. this.sujectArray = array;
  498. this.newSujectOption.map((item) => {
  499. item.newId = this.courType + "-" + item.id;
  500. });
  501. },
  502. addClick(v, int) {
  503. if (v === undefined) {
  504. this.statusPop = 1;
  505. this.listData = {};
  506. this.eduType = ""; //当前选中教育类型
  507. this.courType = ""; //当前选中业务层次
  508. this.sujectApis = []; //当前存在的科目
  509. this.newSujectApis = [];
  510. this.sujectArray = []; //选中的科目
  511. this.BusName = "";
  512. this.BusNameList = [];
  513. } else {
  514. this.statusPop = int;
  515. this.eduType = ""; //当前选中教育类型
  516. this.courType = ""; //当前选中业务层次
  517. this.BusName = "";
  518. this.BusNameList = [];
  519. var arrays = [];
  520. this.listData = v;
  521. v.courseBusinessList.map((item) => {
  522. arrays.push(item.businessId + "-" + item.subjectId);
  523. });
  524. this.sujectApis = arrays;
  525. }
  526. this.$nextTick(() => {
  527. this.changeHeight = true;
  528. });
  529. this.dialogVisible = true;
  530. },
  531. close() {
  532. this.dialogVisible = false;
  533. },
  534. closeType(index) {
  535. this.sujectApis.splice(index, 1);
  536. },
  537. clearBusName(index) {
  538. this.BusNameList.splice(index, 1);
  539. },
  540. handleSizeChange(v) {
  541. this.formData.pageSize = v;
  542. this.formData.pageNum = 1;
  543. this.search();
  544. },
  545. handleCurrentChange(v) {
  546. this.formData.pageNum = v;
  547. this.search();
  548. },
  549. },
  550. };
  551. </script>
  552. <style lang="less" scoped>
  553. /deep/.el-button {
  554. border-radius: 8px;
  555. }
  556. /deep/.el-dialog {
  557. border-radius: 8px;
  558. .el-dialog__header {
  559. padding: 0;
  560. .hearders {
  561. height: 40px;
  562. display: flex;
  563. align-items: center;
  564. justify-content: space-between;
  565. padding: 0px 18px 0px 20px;
  566. border-bottom: 1px solid #e2e2e2;
  567. .leftTitle {
  568. font-size: 14px;
  569. font-weight: bold;
  570. color: #2f4378;
  571. }
  572. .rightBoxs {
  573. display: flex;
  574. align-items: center;
  575. img {
  576. width: 14px;
  577. height: 14px;
  578. margin-left: 13px;
  579. cursor: pointer;
  580. }
  581. }
  582. }
  583. }
  584. .el-dialog__footer {
  585. padding: 0;
  586. .dialog-footer {
  587. padding: 0px 40px;
  588. height: 70px;
  589. border-top: 1px solid #e2e2e2;
  590. display: flex;
  591. align-items: center;
  592. justify-content: flex-end;
  593. }
  594. }
  595. }
  596. .imgBox {
  597. width: 100%;
  598. // height: 210px;
  599. border: 1px solid #e2e2e2;
  600. border-radius: 8px;
  601. padding: 8px 8px 3px;
  602. display: flex;
  603. flex-direction: column;
  604. align-items: center;
  605. .imgLabel {
  606. flex: 1;
  607. width: 100%;
  608. border: 1px dotted #e2e2e2;
  609. color: #999;
  610. font-size: 14px;
  611. cursor: pointer;
  612. border-radius: 8px;
  613. .msPhoto {
  614. display: flex;
  615. justify-content: center;
  616. align-items: center;
  617. max-width: 100%;
  618. max-height: 270px;
  619. img {
  620. max-width: 100%;
  621. max-height: 270px;
  622. }
  623. }
  624. .imgbbx {
  625. display: flex;
  626. flex-direction: column;
  627. align-items: center;
  628. justify-content: center;
  629. width: 100%;
  630. height: 100%;
  631. i {
  632. font-weight: bold;
  633. margin: 14px 0;
  634. font-size: 24px;
  635. }
  636. }
  637. }
  638. p {
  639. margin: 5px 0px;
  640. }
  641. }
  642. .listBoxStys {
  643. flex-shrink: 0;
  644. padding: 0px 10px;
  645. border-radius: 8px;
  646. border: 1px solid #eee;
  647. margin-right: 10px;
  648. margin-bottom: 6px;
  649. }
  650. .closeIcons {
  651. color: red;
  652. cursor: pointer;
  653. margin-left: 6px;
  654. }
  655. .ach {
  656. display: flex;
  657. align-items: center;
  658. overflow: hidden;
  659. }
  660. .clh {
  661. display: flex;
  662. align-items: center;
  663. flex-wrap: wrap;
  664. }
  665. .BusBoxs {
  666. min-height: 100px;
  667. border: 1px solid #a4a4a4;
  668. margin-bottom: 10px;
  669. border-radius: 8px;
  670. max-height: 280px;
  671. padding: 10px;
  672. overflow-y: auto;
  673. .fot_Le {
  674. border-radius: 12px;
  675. border: 1px solid yellowgreen;
  676. padding: 0px 10px;
  677. height: 30px;
  678. line-height: 30px;
  679. text-align: center;
  680. float: left;
  681. margin-right: 6px;
  682. margin-bottom: 6px;
  683. .icon_clear {
  684. margin-left: 2px;
  685. font-size: 15px;
  686. color: #f56c6c;
  687. cursor: pointer;
  688. }
  689. }
  690. }
  691. </style>