1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372 |
- <template>
- <div id="chapterContent">
- <el-tabs v-model="activeName" type="card" v-if="status">
- <el-tab-pane label="课程基本信息" name="first" disabled></el-tab-pane>
- <el-tab-pane label="课程章节内容" name="second"></el-tab-pane>
- </el-tabs>
- <ul class="fatherSty">
- <li class="floatLefts" v-for="(item, index) in headerData" :key="index">
- {{ item.label }}:{{
- item.scope === "more"
- ? pageInfo[item.prop1] + "-" + pageInfo[item.prop2]
- : pageInfo[item.prop]
- }}
- </li>
- <div style="clear: both"></div>
- </ul>
- <div class="mar_b">
- <el-button slot="reference" type="success" @click="openBoxs"
- >添加 模块/章/节</el-button
- >
- <el-button type="primary" @click="openSortBoxs">排序</el-button>
- </div>
- <el-tree
- ref="tree"
- :data="tableDataInfos"
- lazy
- :load="load"
- :props="layoutTreeProps"
- default-expand-all
- @node-click="handleNodeClick"
- >
- <span class="custom-tree-node" slot-scope="{ node, data }">
- <span>{{ node.label }}</span>
- <span>
- <el-button
- v-if="data.isDels"
- type="text"
- size="mini"
- @click.stop="del(node, data)"
- >
- 删除
- </el-button>
- <el-button
- type="text"
- size="mini"
- style="color: green"
- @click.stop="openExamBox(node, data)"
- >
- 关联试卷
- </el-button>
- <el-button
- v-if="data.type === 2 && getShowStatus(data)"
- type="text"
- size="mini"
- style="color: orange"
- @click.stop="preview(node, data)"
- >
- 预览
- </el-button>
- <el-button
- v-if="data.type === 3"
- type="text"
- size="mini"
- style="color: orange"
- @click.stop="preview(node, data)"
- >
- 预览
- </el-button>
- </span>
- </span>
- </el-tree>
- <div class="dis-f">
- <el-button @click="backPage">取消</el-button>
- <el-button
- type="primary"
- @click="submit"
- :disabled="!noStudent"
- :loading="disabledBtn"
- >确定</el-button
- >
- </div>
- <el-dialog
- :visible.sync="centerDialogVisible"
- width="300px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">添加模块/章/节</div>
- <div class="rightBoxs">
- <img
- src="@/assets/images/Close@2x.png"
- alt=""
- @click="centerDialogVisible = false"
- />
- </div>
- </div>
- <el-radio-group v-model="radio" class="dis-f">
- <el-radio :label="1">模块</el-radio>
- <el-radio :label="2">章</el-radio>
- <el-radio :label="3">节</el-radio>
- </el-radio-group>
- <span slot="footer" class="dialog-footer">
- <el-button @click="centerDialogVisible = false" size="small"
- >取 消</el-button
- >
- <el-button type="primary" @click="activeCheckBoxs" size="small"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- <el-dialog
- :visible.sync="dialogVisible"
- width="800px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">
- {{ radio === 1 ? "添加模块" : radio === 2 ? "添加章" : "添加节" }}
- </div>
- <div class="rightBoxs">
- <img
- src="@/assets/images/Close@2x.png"
- alt=""
- @click="dialogVisible = false"
- />
- </div>
- </div>
- <search-box-new
- ref="searchBox"
- :formData="formData5"
- :formList="formList5"
- @search="getInfos"
- @init="init5"
- />
- <el-table
- ref="multipleTable"
- :data="boxtableData"
- border
- @selection-change="selectionChange"
- :row-key="getRowKeys"
- :header-cell-style="{
- 'background-color': '#eee',
- padding: '8px',
- color: '#333',
- }"
- >
- <el-table-column
- align="center"
- type="selection"
- width="55"
- header-align="center"
- :selectable="checkboxT"
- :reserve-selection="true"
- >
- </el-table-column>
- <el-table-column
- v-for="(item, index) in tableSet"
- :width="item.width"
- :key="index"
- :label="item.label"
- align="center"
- :show-overflow-tooltip="true"
- header-align="center"
- >
- <template slot-scope="scope">
- <span v-if="item.scope === 'Status'">
- {{
- scope.row[item.prop] === 1
- ? "发布"
- : scope.row[item.prop] === 0
- ? "未发布"
- : "未知"
- }}
- </span>
- <span v-else-if="item.scope === 'teshu'">
- {{ radio === 1 ? scope.row[item.prop] : scope.row[item.prop1] }}
- </span>
- <span v-else>{{ scope.row[item.prop] }}</span></template
- >
- </el-table-column>
- </el-table>
- <pagination
- :total="total5"
- :pageSize="formData5.pageSize"
- :currentPage="formData5.pageNum"
- @handleSizeChange="handleSizeChange"
- @handleCurrentChange="handleCurrentChange"
- />
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button
- type="primary"
- @click="submitForm"
- :disabled="activeLists.length === 0"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- <el-dialog
- :visible.sync="aboutExamStatus"
- width="560px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">关联题卷</div>
- <div class="rightBoxs">
- <img src="@/assets/images/Close@2x.png" alt="" @click="closeExam" />
- </div>
- </div>
- <div>
- <div><el-button @click="openExamBoxs">选择题卷</el-button></div>
- <div>
- <span>{{ goodsName }}</span>
- <el-button
- v-if="goodsName && templateRadio"
- type="text"
- style="margin-left: 10px"
- @click="delExam"
- >删除</el-button
- >
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closeExam">取 消</el-button>
- <el-button type="primary" @click="submitExam">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog
- :visible.sync="sortTablesBoxs"
- width="560px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">排序</div>
- <div class="rightBoxs">
- <img
- src="@/assets/images/Close@2x.png"
- alt=""
- @click="sortTablesBoxs = false"
- />
- </div>
- </div>
- <div>
- <el-row>
- <el-col :span="22">
- <ul>
- <li
- v-for="(item, index) in sortList"
- :key="index"
- style="margin-bottom: 6px"
- >
- <el-input-number
- :controls="false"
- size="mini"
- v-model="sortList[index].sort"
- :min="0"
- style="width: 50px"
- ></el-input-number>
- <span style="margin-left: 10px">{{ item.name }}</span>
- </li>
- </ul>
- </el-col>
- <el-col :span="2">
- <button @click="initSort">重置</button>
- </el-col>
- </el-row>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="sortTablesBoxs = false">取 消</el-button>
- <el-button type="primary" @click="submitTableBoxs">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog
- :visible.sync="dialogVisiblePZDown"
- width="1100px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">选择题卷</div>
- <div class="rightBoxs">
- <img src="@/assets/images/Close@2x.png" alt="" @click="closePZ" />
- </div>
- </div>
- <div>
- <search-box-new
- ref="searchBox"
- :formData="formData6"
- :formList="formList6"
- @search="getSJ(1)"
- @init="init6"
- />
- <el-table
- :data="tableDataExam"
- border
- :header-cell-style="{
- 'background-color': '#eee',
- padding: '8px',
- color: '#333',
- }"
- >
- <el-table-column label="" width="45" align="center">
- <template scope="scope">
- <el-radio
- class="radioTables"
- :label="scope.row.examId"
- v-model="templateRadioLS"
- @change.native="getTemplateRow(scope.$index, scope.row)"
- >{{ "" }}</el-radio
- >
- </template>
- </el-table-column>
- <template v-for="(item, index) in tableListExam">
- <el-table-column
- v-if="item.scope !== 'inputs'"
- :width="item.width"
- :key="index"
- :label="item.label"
- align="center"
- :show-overflow-tooltip="true"
- header-align="center"
- >
- <template slot-scope="scope">
- <span v-if="item.scope === 'moreList'">
- {{
- scope.row[item.prop1] +
- "-" +
- scope.row[item.prop2] +
- "-" +
- scope.row[item.prop3]
- }}
- </span>
- <span v-else-if="item.scope === 'status'">{{
- scope.row[item.prop] === 1
- ? "发布"
- : scope.row[item.prop] === 0
- ? "未发布"
- : "未知"
- }}</span>
- <span v-else>{{ scope.row[item.prop] }}</span></template
- >
- </el-table-column></template
- >
- </el-table>
- <pagination
- :total="total6"
- :pageSize="formData6.pageSize"
- :currentPage="formData6.pageNum"
- @handleSizeChange="handleSizeChange6"
- @handleCurrentChange="handleCurrentChange6"
- />
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closePZ">取 消</el-button>
- <el-button type="primary" @click="submitPZ">确 定</el-button>
- </span>
- </el-dialog>
- <test-paper-preview ref="testPaperPreview" />
- <video-preview ref="preview" />
- </div>
- </template>
- <script>
- import searchBoxNew from "@/components/searchBoxNew";
- import pagination from "@/components/pagination";
- import testPaperPreview from "@/components/testPaperPreview";
- import videoPreview from "@/components/videoPreview";
- export default {
- name: "ChapterContent",
- components: { searchBoxNew, pagination, testPaperPreview, videoPreview },
- data() {
- return {
- disabledBtn: false,
- sortTablesBoxs: false,
- activeName: "second",
- status: false,
- tableDataExam: [],
- tableListExam: [
- {
- label: "试卷编码",
- prop: "code",
- width: "120px",
- },
- {
- label: "标题前缀",
- prop: "prefixName",
- width: "160px",
- },
- {
- label: "试卷标题",
- prop: "examName",
- width: "300px",
- },
- {
- label: "业务层级",
- prop1: "educationName",
- prop2: "projectName",
- prop3: "businessName",
- scope: "moreList",
- width: "300px",
- },
- {
- label: "发布状态",
- prop: "publishStatus",
- scope: "status",
- },
- ],
- templateRadioLS: "",
- goodsNameLS: "",
- templateRadio: "",
- goodsName: "",
- menuExamList: [], //关联试卷列表
- onlyId: "",
- newShowObj: {}, //当前关联题卷OBJ
- dialogVisiblePZDown: false,
- aboutExamStatus: false, //关联试卷弹出
- centerDialogVisible: false,
- radio: "",
- headerData: [
- {
- label: "课程名称",
- prop: "courseName",
- },
- {
- label: "业务层次",
- prop1: "projectName",
- prop2: "businessName",
- scope: "more",
- },
- {
- label: "所属院校",
- prop: "schoolName",
- },
- {
- label: "所属专业",
- prop: "categoryName",
- },
- {
- label: "科目",
- prop: "subjectName",
- },
- ],
- pageInfo: {},
- tableData: [],
- tableDataInfos: [],
- tableSet: [
- { label: "编码", prop: "code", width: "120" },
- { label: "标题前缀", prop: "prefixName", width: "160" },
- {
- label: "标题",
- prop: "moduleName",
- prop1: "name",
- scope: "teshu",
- width: "300",
- },
- {
- label: "发布状态",
- prop: "publishStatus",
- scope: "Status",
- },
- ],
- dialogVisible: false,
- boxtableData: [],
- activeLists: [],
- total5: 0, //一共多少条
- formData5: {
- pageSize: 10,
- pageNum: 1,
- status: 1,
- publishStatus: 1,
- name: "",
- key: "",
- },
- formList5: [],
- total6: 0,
- formData6: {
- pageSize: 10,
- pageNum: 1,
- status: 1,
- publishStatus: 1,
- name: "",
- key: "",
- },
- formList6: [
- {
- placeholder: "试卷标题/试卷编码/标题前缀",
- prop: "key",
- },
- ],
- theModuleList: [],
- theChapterList: [],
- theSectionList: [],
- sortList: [],
- noStudent: true,
- layoutTreeProps: {
- label(data, node) {
- return data.name;
- },
- isLeaf(data, node) {
- return data.hasChildren ? false : true;
- },
- },
- };
- },
- computed: {
- /**
- * 查询是否关联试卷
- */
- getShowStatus: function () {
- return function (item) {
- var ints = item.id.split("-").map(Number);
- var arr = [];
- if (ints[0] === 1) {
- arr.push(ints[1]);
- if (ints[2]) {
- arr.push(ints[2]);
- } else {
- arr.push(0);
- }
- if (ints[3]) {
- arr.push(ints[3]);
- } else {
- arr.push(0);
- }
- }
- if (ints[0] === 2) {
- arr.push(0);
- arr.push(ints[1]);
- if (ints[2]) {
- arr.push(ints[2]);
- } else {
- arr.push(0);
- }
- }
- if (ints[0] === 3) {
- arr.push(0);
- arr.push(0);
- arr.push(ints[1]);
- }
- var atys = arr.join("-");
- var setTs = this.menuExamList.some((items) => {
- return items.onlyId == atys;
- });
- return setTs;
- };
- },
- },
- mounted() {
- this.$api
- .gradecheckGoodsChange({ courseId: this.$route.query.id })
- .then((res) => {
- if (res.data > 0) {
- // this.noStudent = false;
- }
- });
- this.getDs();
- this.search();
- },
- methods: {
- preview(node, data) {
- if (data.type === 2) {
- var ints = data.id.split("-").map(Number);
- var arr = [];
- if (ints[0] === 1) {
- arr.push(ints[1]);
- if (ints[2]) {
- arr.push(ints[2]);
- } else {
- arr.push(0);
- }
- if (ints[3]) {
- arr.push(ints[3]);
- } else {
- arr.push(0);
- }
- }
- if (ints[0] === 2) {
- arr.push(0);
- arr.push(ints[1]);
- if (ints[2]) {
- arr.push(ints[2]);
- } else {
- arr.push(0);
- }
- }
- if (ints[0] === 3) {
- arr.push(0);
- arr.push(0);
- arr.push(ints[1]);
- }
- var atys = arr.join("-");
- var setTs = this.menuExamList.some((items) => {
- return items.onlyId == atys;
- });
- if (setTs) {
- this.menuExamList.map((items) => {
- if (items.onlyId == atys) {
- this.$refs.testPaperPreview.openBox(1, items.examId);
- }
- });
- }
- }
- if (data.type === 3) {
- this.$api.obtainCourseSection(data.CodeId).then((res) => {
- this.$refs.preview.diavosFun(res.data);
- });
- }
- },
- initSort() {
- this.sortList = JSON.parse(JSON.stringify(this.tableDataInfos));
- },
- submitTableBoxs() {
- let arr = this.sortList.map((items) => {
- return items.sort;
- });
- if (new Set(arr).size != arr.length) {
- this.$message.warning("排序不允许有重复值");
- return;
- }
- this.tableDataInfos = this.sortList.sort((a, b) => a.sort - b.sort);
- this.sortTablesBoxs = false;
- },
- openSortBoxs() {
- this.sortList = JSON.parse(JSON.stringify(this.tableDataInfos));
- this.sortTablesBoxs = true;
- },
- openExamBoxs() {
- this.getSJ(2);
- this.templateRadioLS = this.templateRadio;
- this.dialogVisiblePZDown = true;
- },
- //单选触发
- getTemplateRow(index, row) {
- this.templateRadioLS = row.examId;
- this.goodsNameLS = row.examName;
- },
- //2确定变化选项
- submitPZ() {
- this.templateRadio = this.templateRadioLS;
- this.goodsName = this.goodsNameLS;
- this.dialogVisiblePZDown = false;
- },
- closePZ() {
- this.dialogVisiblePZDown = false;
- },
- //删除题卷
- delExam() {
- this.templateRadio = "";
- this.goodsName = "";
- },
- //1确定关联试卷弹窗
- submitExam() {
- if (!this.templateRadio && !this.goodsName) {
- console.log(this.menuExamList, "this.menuExamList111111");
- this.menuExamList = this.menuExamList.filter((item) => {
- return item.onlyId != this.onlyId;
- });
- } else {
- console.log(this.menuExamList, "this.menuExamList222222");
- var arrays = {};
- let ast = this.onlyId.split("-").map(Number);
- arrays = {
- onlyId: this.onlyId,
- courseId: Number(this.$route.query.id),
- moduleId: ast[0],
- chapterId: ast[1],
- sectionId: ast[2],
- examId: this.templateRadio,
- examName: this.goodsName,
- };
- var stu = this.menuExamList.some((item) => {
- return item.onlyId == this.onlyId;
- });
- if (stu) {
- for (let i = 0; i < this.menuExamList.length; i++) {
- if (this.menuExamList[i].onlyId == this.onlyId) {
- this.menuExamList[i] = arrays;
- }
- }
- } else {
- this.menuExamList.push(arrays);
- }
- }
- this.aboutExamStatus = false;
- },
- //开启关联试卷盒子
- openExamBox(node, item) {
- console.log(this.tableDataInfos, "this.tableDataInfos");
- var ints = item.id.split("-").map(Number);
- var arr = [];
- if (ints[0] === 1) {
- arr.push(ints[1]);
- if (ints[2]) {
- arr.push(ints[2]);
- } else {
- arr.push(0);
- }
- if (ints[3]) {
- arr.push(ints[3]);
- } else {
- arr.push(0);
- }
- }
- if (ints[0] === 2) {
- arr.push(0);
- arr.push(ints[1]);
- if (ints[2]) {
- arr.push(ints[2]);
- } else {
- arr.push(0);
- }
- }
- if (ints[0] === 3) {
- arr.push(0);
- arr.push(0);
- arr.push(ints[1]);
- }
- var atys = arr.join("-");
- var setTs = this.menuExamList.some((items) => {
- return items.onlyId == atys;
- });
- if (setTs) {
- this.menuExamList.map((items) => {
- if (items.onlyId == atys) {
- this.templateRadio = items.examId;
- this.goodsName = items.examName;
- }
- });
- } else {
- this.templateRadio = "";
- this.goodsName = "";
- }
- this.onlyId = atys;
- this.aboutExamStatus = true;
- },
- //关闭关联试卷盒子
- closeExam() {
- this.aboutExamStatus = false;
- },
- search() {
- this.$api.obtainCourseS(this.$route.query.id).then((res) => {
- this.pageInfo = res.data;
- });
- this.$api
- .inquireCoursemenuListS({ courseId: this.$route.query.id })
- .then((res) => {
- this.tableData = res.rows;
- this.changeApis();
- this.getList();
- });
- },
- getList() {
- this.$api
- .inquireCourseListSmenuexam({ courseId: this.$route.query.id })
- .then((res) => {
- res.rows.forEach((item) => {
- var lets = [];
- if (!item.moduleId) {
- lets.push(0);
- } else {
- lets.push(item.moduleId);
- }
- if (!item.chapterId) {
- lets.push(0);
- } else {
- lets.push(item.chapterId);
- }
- if (!item.sectionId) {
- lets.push(0);
- } else {
- lets.push(item.sectionId);
- }
- item.onlyId = lets.join("-");
- });
- this.menuExamList = res.rows;
- });
- },
- getDs() {
- this.$api.inquireCourseListmodule({ status: 1 }).then((res) => {
- this.theModuleList = res.rows;
- });
- this.$api.inquireCourseListchapter({ status: 1 }).then((res) => {
- this.theChapterList = res.rows;
- });
- this.$api.inquireCourseSection({ status: 1 }).then((res) => {
- this.theSectionList = res.rows;
- });
- },
- getSJ(int) {
- if (int === 1) {
- this.formData6.pageNum = 1;
- }
- if (int === 2) {
- this.formData6.name = "";
- this.formData6.key = "";
- this.formData6.pageNum = 1;
- this.formData6.pageSize = 10;
- }
- var data = JSON.parse(JSON.stringify(this.formData6));
- data.businessId = this.pageInfo.businessId;
- data.subjectId = this.pageInfo.subjectId;
- data.name = this.formData6.name;
- data.exclude = 1;
- this.$api.inquirebankexamList(data).then((res) => {
- this.tableDataExam = res.rows;
- this.total6 = res.total;
- });
- },
- openBoxs() {
- this.radio = "";
- this.centerDialogVisible = true;
- },
- activeCheckBoxs() {
- var self = this;
- if (!this.radio) {
- this.$message.error("请选择添加类型");
- return;
- }
- if (this.radio === 1) {
- this.formList5 = [
- {
- placeholder: "模块标题/模块编码/标题前缀",
- prop: "key",
- },
- ];
- this.moduleApi(2);
- }
- if (this.radio === 2) {
- this.formList5 = [
- {
- placeholder: "章标题/章编码/标题前缀",
- prop: "key",
- },
- ];
- this.chapterApi(2);
- }
- if (this.radio === 3) {
- this.formList5 = [
- {
- placeholder: "节标题/节编码/标题前缀",
- prop: "key",
- },
- ];
- this.sectionApi(2);
- }
- this.centerDialogVisible = false;
- this.dialogVisible = true;
- this.$nextTick(function () {
- self.activeLists = [];
- self.$refs.multipleTable.clearSelection();
- });
- },
- init5() {
- this.getInfos(2);
- },
- getInfos(int) {
- if (this.radio === 1) {
- this.moduleApi(int);
- }
- if (this.radio === 2) {
- this.chapterApi(int);
- }
- if (this.radio === 3) {
- this.sectionApi(int);
- }
- },
- moduleApi(int) {
- if (int === 1) {
- this.formData5.pageNum = 1;
- }
- if (int === 2) {
- this.formData5.name = "";
- this.formData5.key = "";
- this.formData5.pageNum = 1;
- this.formData5.pageSize = 10;
- }
- var data = JSON.parse(JSON.stringify(this.formData5));
- data.businessId = this.pageInfo.businessId;
- data.subjectId = this.pageInfo.subjectId;
- data.name = this.formData5.name;
- this.$api.inquireCourseListmodule(data).then((res) => {
- this.boxtableData = res.rows;
- this.total5 = res.total;
- });
- },
- chapterApi(int) {
- if (int === 1) {
- this.formData5.pageNum = 1;
- }
- if (int === 2) {
- this.formData5.name = "";
- this.formData5.pageNum = 1;
- this.formData5.key = "";
- this.formData5.pageSize = 10;
- }
- var data = JSON.parse(JSON.stringify(this.formData5));
- data.businessId = this.pageInfo.businessId;
- data.subjectId = this.pageInfo.subjectId;
- data.name = this.formData5.name;
- this.$api.inquireCourseListchapter(data).then((res) => {
- this.boxtableData = res.rows;
- this.total5 = res.total;
- });
- },
- sectionApi(int) {
- if (int === 1) {
- this.formData5.pageNum = 1;
- }
- if (int === 2) {
- this.formData5.name = "";
- this.formData5.key = "";
- this.formData5.pageNum = 1;
- this.formData5.pageSize = 10;
- }
- var data = JSON.parse(JSON.stringify(this.formData5));
- data.businessId = this.pageInfo.businessId;
- data.subjectId = this.pageInfo.subjectId;
- data.name = this.formData5.name;
- this.$api.inquireCourseSection(data).then((res) => {
- this.boxtableData = res.rows;
- this.total5 = res.total;
- });
- },
- // 查询是否存在下级 模块
- quireModule(id) {
- return new Promise((resolve, reject) => {
- this.$api.inquireCourseListmodulechapter(id).then((result) => {
- if (result.data.length === 0) {
- resolve(false);
- } else {
- resolve(true);
- }
- });
- });
- },
- // 查询是否存在下级 章
- quireChapter(id) {
- return new Promise((resolve, reject) => {
- this.$api.inquireCoursechaptersectionlist(id).then((result) => {
- if (result.data.length === 0) {
- resolve(false);
- } else {
- resolve(true);
- }
- });
- });
- },
- changeApis() {
- //inquireCourseListmodulechapter 模块与章关系
- // inquireCoursechaptersectionlist 章与节关系
- var arrays = [];
- this.tableData.map((item, index) => {
- if (item.type === 1) {
- // this.$api.obtainCoursemodule(item.menuId).then(async (res) => {
- var arr = {
- id: "1-" + item.menuId,
- CodeId: item.menuId,
- name: item.menuName,
- hasChildren: true,
- type: 1,
- isDels: true,
- sort: item.sort,
- };
- //查询是否存在下级
- arrays.push(arr);
- // });
- }
- if (item.type === 2) {
- // this.$api.obtainCoursechapter(item.menuId).then(async (res) => {
- var arr = {
- id: "2-" + item.menuId,
- CodeId: item.menuId,
- name: item.menuName,
- hasChildren: true,
- type: 2,
- isDels: true,
- sort: item.sort,
- };
- arrays.push(arr);
- // });
- }
- if (item.type === 3) {
- // this.$api.obtainCourseSection(item.menuId).then((res) => {
- var arr = {
- id: "3-" + item.menuId,
- CodeId: item.menuId,
- name: item.menuName,
- hasChildren: false,
- type: 3,
- isDels: true,
- sort: item.sort,
- };
- arrays.push(arr);
- // });
- }
- });
- this.$nextTick(() => {
- this.tableDataInfos = arrays;
- });
- },
- del(node, item) {
- this.tableDataInfos.map((items, indexs) => {
- if (items.id === item.id) {
- this.tableDataInfos.splice(indexs, 1);
- }
- });
- this.tableDataInfos = JSON.parse(JSON.stringify(this.tableDataInfos));
- if (item.type === 1) {
- this.menuExamList = this.menuExamList.filter((items) => {
- return items.moduleId !== item.CodeId;
- });
- }
- if (item.type === 2) {
- this.menuExamList = this.menuExamList.filter((items) => {
- if (items.moduleId === 0) {
- if (items.chapterId !== item.CodeId) {
- return true;
- } else {
- return false;
- }
- } else {
- return true;
- }
- });
- }
- },
- getRowKeys(row) {
- if (this.radio === 1) {
- return row.moduleId;
- }
- if (this.radio === 2) {
- return row.chapterId;
- }
- if (this.radio === 3) {
- return row.sectionId;
- }
- },
- checkboxT(row, index) {
- var array = [];
- array = this.tableDataInfos.map((item) => {
- if (item.type === this.radio) {
- return item.CodeId;
- }
- });
- if (
- array.indexOf(
- this.radio === 1
- ? row.moduleId
- : this.radio === 2
- ? row.chapterId
- : row.sectionId
- ) !== -1
- ) {
- return false;
- } else {
- return true;
- }
- },
- submitForm() {
- if (this.activeLists.length === 0) {
- this.dialogVisible = false;
- return;
- }
- var array = [];
- if (this.tableDataInfos.length) {
- if (this.radio === 1) {
- this.activeLists.map((item) => {
- array.push({
- id: 1 + "-" + item.moduleId,
- CodeId: item.moduleId,
- name: item.moduleName,
- isDels: true,
- hasChildren: true,
- type: 1,
- sort: 0,
- });
- });
- } else if (this.radio === 2) {
- this.activeLists.map((item) => {
- array.push({
- id: 2 + "-" + item.chapterId,
- CodeId: item.chapterId,
- name: item.name,
- isDels: true,
- hasChildren: true,
- type: 2,
- sort: 0,
- });
- });
- } else if (this.radio === 3) {
- this.activeLists.map((item) => {
- array.push({
- id: 3 + "-" + item.sectionId,
- CodeId: item.sectionId,
- name: item.name,
- type: 3,
- sort: 0,
- isDels: true,
- });
- });
- }
- let maxIndex = 0;
- this.tableDataInfos.forEach((item) => {
- if (item.sort > maxIndex) {
- maxIndex = item.sort;
- }
- });
- array.forEach((item, index) => {
- item.sort = maxIndex + index + 1;
- });
- } else {
- if (this.radio === 1) {
- this.activeLists.map((item) => {
- array.push({
- id: 1 + "-" + item.moduleId,
- CodeId: item.moduleId,
- name: item.moduleName,
- isDels: true,
- hasChildren: true,
- type: 1,
- sort: 0,
- });
- });
- } else if (this.radio === 2) {
- this.activeLists.map((item) => {
- array.push({
- id: 2 + "-" + item.chapterId,
- CodeId: item.chapterId,
- name: item.name,
- isDels: true,
- hasChildren: true,
- type: 2,
- sort: 0,
- });
- });
- } else if (this.radio === 3) {
- this.activeLists.map((item) => {
- array.push({
- id: 3 + "-" + item.sectionId,
- CodeId: item.sectionId,
- name: item.name,
- type: 3,
- sort: 0,
- isDels: true,
- });
- });
- }
- array.forEach((item, index) => {
- item.sort = index + 1;
- });
- }
- for (let i = 0; i < array.length; i++) {
- this.tableDataInfos.unshift(array[i]);
- }
- // this.tableDataInfos = this.tableDataInfos.concat(array);
- this.activeLists = [];
- this.dialogVisible = false;
- this.$message.success("添加成功");
- },
- handleNodeClick() {},
- async load(node, resolve) {
- const tree = node.data;
- if (tree.type === 1) {
- var arrays = [];
- await this.$api
- .inquireCourseListmodulechapter(tree.CodeId)
- .then((res) => {
- res.data.map((item, index) => {
- var arr = {
- id: tree.id + "-" + item.chapterId,
- CodeId: item.chapterId,
- name: item.name,
- hasChildren: true,
- type: 2,
- };
- arrays.push(arr);
- });
- });
- resolve(arrays);
- }
- if (tree.type === 2) {
- this.$api.inquireCoursechaptersectionlist(tree.CodeId).then((res) => {
- var arrays = [];
- res.data.map((item, index) => {
- var arr = {
- id: tree.id + "-" + item.sectionId,
- CodeId: item.sectionId,
- name: item.name,
- type: 3,
- };
- arrays.push(arr);
- });
- resolve(arrays);
- });
- }
- if (tree.type === 3) {
- resolve([]);
- }
- return;
- },
- handleSizeChange(v) {
- this.formData5.pageSize = v;
- this.formData5.pageNum = 1;
- this.getInfos();
- },
- handleCurrentChange(v) {
- this.formData5.pageNum = v;
- this.getInfos();
- },
- handleSizeChange6(v) {
- this.formData6.pageSize = v;
- this.formData6.pageNum = 1;
- this.getSJ();
- },
- handleCurrentChange6(v) {
- this.formData6.pageNum = v;
- this.getSJ();
- },
- init6() {
- this.getSJ(2);
- },
- /**
- * 多选框变化触发
- */
- selectionChange(arr) {
- this.activeLists = arr;
- },
- backPage() {
- this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
- this.$router.push({
- path: "courseManagement",
- });
- });
- },
- submit() {
- this.disabledBtn = true;
- var array = [];
- this.tableDataInfos.map((item) => {
- array.push({
- courseId: Number(this.$route.query.id),
- menuId: item.CodeId,
- parentId: 0,
- status: 1,
- type: item.type,
- sort: item.sort,
- });
- });
- if (this.menuExamList && this.menuExamList.length > 0) {
- this.menuExamList.forEach((item) => {
- if (
- item.moduleId != 0 &&
- item.sectionId == 0 &&
- item.chapterId == 0
- ) {
- item.type = 3;
- } else if (item.sectionId != 0) {
- item.type = 2;
- } else {
- item.type = 1;
- }
- });
- }
- var data = {
- courseId: Number(this.$route.query.id),
- menuExamList: this.menuExamList,
- menuList: array,
- };
- this.$api
- .editCoursemenu(data)
- .then((res) => {
- this.$message.success("编辑成功");
- setTimeout(() => {
- this.$store
- .dispatch("tagsView/exitView", this.$route)
- .then((res) => {
- this.$router.push({
- path: "courseManagement",
- });
- });
- }, 300);
- })
- .catch(() => {
- this.disabledBtn = false;
- });
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .fatherSty {
- background-color: #eee;
- padding: 10px;
- margin-bottom: 15px;
- }
- .floatLefts {
- font-size: 14px;
- float: left;
- margin-right: 30px;
- }
- .mar_b {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 12px;
- }
- .dis-f {
- margin-top: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- /deep/.el-tree-node__content {
- height: 35px;
- }
- .custom-tree-node {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-right: 8px;
- }
- /deep/.el-button {
- border-radius: 8px;
- }
- /deep/.el-dialog {
- border-radius: 8px;
- .el-dialog__header {
- padding: 0;
- .hearders {
- height: 40px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0px 18px 0px 20px;
- border-bottom: 1px solid #e2e2e2;
- .leftTitle {
- font-size: 14px;
- font-weight: bold;
- color: #2f4378;
- }
- .rightBoxs {
- display: flex;
- align-items: center;
- img {
- width: 14px;
- height: 14px;
- margin-left: 13px;
- cursor: pointer;
- }
- }
- }
- }
- .el-dialog__footer {
- padding: 0;
- .dialog-footer {
- padding: 0px 40px;
- height: 70px;
- border-top: 1px solid #e2e2e2;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- }
- }
- }
- </style>
|