12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283 |
- <template>
- <div id="chapterEdit">
- <el-form
- label-position="right"
- label-width="120px"
- :model="listData"
- :rules="rules"
- ref="listData"
- >
- <div class="boxWidth">
- <el-form-item label="适用业务层级">
- <el-select
- v-model="eduType"
- placeholder="请选择教育类型"
- @change="changeEduType"
- >
- <el-option
- v-for="(item, index) in eduTypeOptions"
- :key="index"
- :label="item.educationName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-select
- v-model="courType"
- placeholder="请选择业务层次"
- @change="changecourseType"
- >
- <el-option
- v-for="(item, index) in newCourTypeOptions"
- :key="index"
- :label="item.projectName + '-' + item.businessName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-popover
- ref="popovers"
- placement="bottom"
- trigger="click"
- @show="showHandle"
- @hide="hideHandle"
- :disabled="courType ? false : true"
- >
- <el-checkbox
- v-model="checkAll"
- @change="handleCheckAllChange"
- :indeterminate="isIndeterminate"
- >全选</el-checkbox
- >
- <el-checkbox-group
- v-model="sujectArray"
- class="checkboxSty"
- @change="handleCheckedCitiesChange"
- >
- <el-checkbox
- v-for="(item, index) in newSujectOption"
- :label="item.newId"
- :key="index"
- >{{ item.subjectName }}</el-checkbox
- >
- </el-checkbox-group>
- <div style="display: block; text-align: center; margin-top: 10px">
- <el-button size="mini" type="primary" @click="submitSujectArray"
- >确定</el-button
- >
- </div>
- <el-button
- slot="reference"
- style="margin-left: 12px"
- @click="getMessage"
- >请选择科目</el-button
- >
- </el-popover>
- <span style="margin-left: 10px">注:可多选</span>
- </el-form-item>
- <el-form-item label="">
- <div :class="changeHeight ? 'ach' : 'clh'">
- <div
- v-for="(item, index) in newSujectApis"
- :key="index"
- class="listBoxStys"
- >
- {{
- item.educationName +
- " - " +
- item.projectName +
- " - " +
- item.businessName +
- " - " +
- item.subjectName
- }}
- <i class="el-icon-error closeIcons" @click="closeType(index)"></i>
- </div>
- </div>
- <el-popover
- placement="bottom-start"
- trigger="hover"
- :close-delay="50"
- >
- <ul style="margin: 0; max-width: 600px">
- <li
- class="copyDataLi"
- :class="changeSty(itemT)"
- v-for="(itemT, indexT) in localData"
- :key="indexT"
- @click="unTime(itemT)"
- >
- {{
- `${itemT.educationName}-${itemT.projectName}-${itemT.businessName}-${itemT.subjectName}`
- }}
- </li>
- </ul>
- <el-button
- v-show="localData.length"
- type="danger"
- slot="reference"
- size="mini"
- style="margin-right: 10px"
- >最近选择</el-button
- >
- </el-popover>
- <el-button
- size="mini"
- v-if="newSujectApis.length > 1"
- @click="changeType"
- >{{ changeHeight ? "展开" : "关闭" }}</el-button
- ><el-button
- size="mini"
- v-if="newSujectApis.length > 0"
- @click="sujectApis = []"
- >清空</el-button
- >
- <!-- <span v-if="newSujectApis.length === 0">未选项目类型</span> -->
- </el-form-item>
- <el-form-item label="标题前缀" prop="prefixName">
- <el-input v-model="listData.prefixName"></el-input>
- <div style="color: #999">注:便于检索、归类,以及区分一样的标题</div>
- </el-form-item>
- <el-form-item label="章标题" prop="name">
- <el-input v-model="listData.name"></el-input>
- <div style="color: #999">
- 注:请尽量规范易懂,方便在课程目录表呈现给学员
- </div>
- </el-form-item>
- <el-form-item label="章封面">
- <el-row :gutter="10" style="margin-bottom: 10px">
- <el-col :span="12">
- <div
- style="
- width: 100%;
- height: 150px;
- border: 2px dashed #999;
- border-radius: 28px;
- line-height: 150px;
- text-align: center;
- "
- v-if="!listData.coverUrl"
- >
- <label for="uplose">
- <i class="el-icon-circle-plus-outline iconStsz"></i
- ></label>
- <input
- ref="file"
- type="file"
- style="display: none"
- id="uplose"
- @change="getImgFile"
- />
- </div>
- <el-image
- v-else
- style="width: 100%"
- :src="$methodsTools.splitImgHost(listData.coverUrl)"
- :preview-src-list="[
- $methodsTools.splitImgHost(listData.coverUrl),
- ]"
- >
- </el-image>
- </el-col>
- <el-col :span="11">
- <span style="color: #999; font-size: 14px"
- >注:请上传小于300kb,尺寸为750*440的图片,支持gif、jpg、jpeg、png等类型</span
- >
- </el-col>
- </el-row>
- <el-button
- v-if="listData.coverUrl"
- type="danger"
- size="mini"
- class="margin-top: 20px;"
- @click="clearImgs"
- >删除</el-button
- >
- </el-form-item>
- <el-form-item label="是否发布" prop="publishStatus">
- <el-radio-group v-model="listData.publishStatus">
- <el-radio :label="1">是</el-radio>
- <el-radio :label="0">否</el-radio>
- </el-radio-group>
- </el-form-item>
- </div>
- <el-form-item label="管理节">
- <div class="dis_plays">
- <div>
- <el-button size="small" @click="openBoxs">调用已有数据</el-button>
- <el-button size="small" type="success" @click="dialogDR = true"
- >Excel批量新增</el-button
- >
- </div>
- <div style="color: #f56c6c">
- <span style="margin-right: 10px"
- >节总数:{{ tableData.length }}</span
- >
- <!-- <span>总时长:{{ minTimeAll }}分钟</span> -->
- </div>
- </div>
- <el-table
- :data="tableData"
- border
- :header-cell-style="{
- 'background-color': '#eee',
- padding: '8px',
- color: '#333',
- }"
- :default-sort="{ prop: 'sort', order: 'ascending' }"
- >
- <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"
- :sortable="item.prop === 'sort'"
- sort-by="sort"
- :prop="item.prop"
- >
- <template slot-scope="scope">
- <span v-if="item.scope === 'types'">{{
- scope.row[item.prop] === 1
- ? "录播"
- : scope.row[item.prop] === 2
- ? "直播"
- : scope.row[item.prop] === 3
- ? "回放"
- : "未知"
- }}</span>
- <span v-else-if="item.scope === 'Status'">
- {{
- scope.row[item.prop] === 1
- ? "发布"
- : scope.row[item.prop] === 0
- ? "未发布"
- : "未知"
- }}
- </span>
- <div v-else-if="item.scope === 'inputs'">
- <el-input-number
- style="width: 50px"
- size="small"
- :controls="false"
- v-model="scope.row[item.prop]"
- controls-position="right"
- :min="0"
- ></el-input-number>
- </div>
- <span v-else>{{ scope.row[item.prop] }}</span></template
- >
- </el-table-column>
- <el-table-column
- label="操作"
- align="center"
- fixed="right"
- width="100px"
- >
- <template slot-scope="scope">
- <el-button type="text" @click="seeTheVideo(scope.row)"
- >预览</el-button
- >
- <el-button type="text" @click="delList(scope.row)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </el-form-item>
- <el-form-item>
- <el-button @click="backPage">取消</el-button>
- <el-button
- :loading="disabledBtn"
- type="primary"
- @click="submit('listData')"
- >确定</el-button
- >
- </el-form-item>
- </el-form>
- <el-dialog
- :visible.sync="dialogVisible"
- width="1000px"
- :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="dialogVisible = false"
- />
- </div>
- </div>
- <search-box-new
- ref="searchBox"
- :formData="formData"
- :formList="formList"
- @search="getInfos"
- @init="init"
- />
- <el-table
- ref="multipleTable"
- :data="boxtableData"
- border
- @select-all="selectAll"
- @select="select"
- :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>
- <template v-for="(item, index) in tableSet">
- <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 === 'types'">{{
- scope.row[item.prop] === 1
- ? "录播"
- : scope.row[item.prop] === 2
- ? "直播"
- : scope.row[item.prop] === 3
- ? "回放"
- : ""
- }}</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="total"
- :pageSize="formData.pageSize"
- :currentPage="formData.pageNum"
- @handleSizeChange="handleSizeChange"
- @handleCurrentChange="handleCurrentChange"
- />
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button
- type="primary"
- :disabled="activeLists.length === 0"
- @click="submitForm"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- <el-dialog
- :visible.sync="dialogDR"
- width="660px"
- :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="dialogDR = false"
- />
- </div>
- </div>
- <div>
- <div class="swq">
- <img
- style="width: 182px; height: 168px"
- src="@/assets/images/dr.png"
- alt=""
- />
- </div>
- <div style="padding-left: 100px">
- <p>第一步:下载导入模板</p>
- <p style="padding-left: 50px">
- <i class="el-icon-upload"></i
- ><span class="dowmStys" @click="getDowm">下载模板</span>
- </p>
- <p>第二步:(批量新增):点击“上传Excel”完成导入</p>
- <label
- for="mobles"
- class="el-button el-button--primary"
- style="margin-left: 50px; padding: 10px 20px"
- >上传Excel</label
- ><input
- style="display: none"
- type="file"
- id="mobles"
- ref="input1"
- @change="importMobleadd"
- />
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogDR = false">取消</el-button>
- <!-- <el-button type="primary" @click="submitChecksDR">确定</el-button> -->
- </span>
- </el-dialog>
- <el-dialog
- append-to-body
- :visible.sync="dialogERROR"
- width="660px"
- :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="dialogERROR = false"
- />
- </div>
- </div>
- <div>
- <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
- 导入失败原因
- </h4>
- <el-input
- readonly
- type="textarea"
- :autosize="{ minRows: 6, maxRows: 24 }"
- v-model="errorData"
- >
- </el-input>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogERROR = false">确定</el-button>
- </span>
- </el-dialog>
- <video-preview ref="preview" />
- </div>
- </template>
- <script>
- import * as baseUrls from "@/utils/request.js";
- import searchBoxNew from "@/components/searchBoxNew";
- import pagination from "@/components/pagination";
- import videoPreview from "@/components/videoPreview";
- export default {
- components: { searchBoxNew, pagination, videoPreview },
- name: "ChapterAdd",
- data() {
- return {
- dialogDR: false,
- errorData: "", //导入错误原因
- dialogERROR: false,
- disabledBtn: false,
- isIndeterminate: false,
- checkAll: false,
- // 弹窗数据
- changeHeight: true,
- bfImg: "oss/images/avatar/20211013/1634097664410_1397766697",
- listData: {
- publishStatus: 1,
- recordingUrl: "",
- liveUrl: "",
- coverUrl: "oss/images/avatar/20211013/1634097664410_1397766697",
- },
- eduTypeOptions: [], //教育类型数据
- projectTypeOptions: [], //项目类型数据
- courTypeOptions: [], //业务层次数据
- newCourTypeOptions: [], //当前业务层次数据
- sujectOption: [], //科目数据
- newSujectOption: [], //当前科目数据数据
- eduType: "", //当前选中教育类型
- courType: "", //当前选中业务层次
- sujectApis: [], //当前存在的科目
- newSujectApis: [],
- sujectArray: [], //选中的科目
- //表单验证
- rules: {
- prefixName: [
- { required: false, message: "请输入标题前缀", trigger: "blur" },
- ],
- name: [{ required: true, message: "请输入章标题", trigger: "blur" }],
- // liveDuration: [
- // { required: true, message: "节时长不能为空" },
- // { type: "number", message: "节时长必须为数字值" },
- // ],
- publishStatus: [
- { required: true, message: "请选择是否发布", trigger: "change" },
- ],
- },
- numberAll: 0, //节总数
- minTimeAll: 0, //总时长
- tableSet: [
- { label: "排序", prop: "sort", scope: "inputs", width: "100" },
- { label: "节编码", prop: "code", width: "120" },
- { label: "标题前缀", prop: "prefixName", width: "180" },
- { label: "节标题", prop: "name", width: "310" },
- { label: "节类型", prop: "sectionType", scope: "types" },
- {
- label: "发布状态",
- prop: "publishStatus",
- scope: "Status",
- width: "120",
- },
- ],
- tableData: [],
- dialogVisible: false,
- boxtableData: [],
- formList: [
- {
- prop: "educationTypeId",
- placeholder: "教育类型",
- scope: "educationType",
- },
- {
- prop: "businessId",
- placeholder: "业务层次",
- scope: "businessLevel",
- edu: "educationTypeId",
- },
- {
- prop: "subjectId",
- placeholder: "科目",
- scope: "sujectType",
- edu: "educationTypeId",
- },
- {
- prop: "sectionType",
- placeholder: "节类型",
- scope: "select",
- options: [
- {
- label: "录播",
- value: 1,
- },
- {
- label: "直播",
- value: 2,
- },
- {
- label: "回放",
- value: 3,
- },
- ],
- },
- {
- prop: "key",
- placeholder: "请输入节标题/节编码/标题前缀",
- },
- ],
- total: 0, //一共多少条
- formData: {
- status: 1,
- pageSize: 10,
- pageNum: 1,
- },
- disCheckList: [], //已选转禁用复选列表
- activeLists: [],
- localData: [],
- };
- },
- watch: {
- sujectApis: {
- immediate: true,
- handler(newName, oldName) {
- this.changeTypes();
- },
- },
- },
- mounted() {
- this.localData = this.$methodsTools.getBusinessList();
- this.getDict();
- },
- methods: {
- seeTheVideo(item) {
- this.$refs.preview.diavosFun(item)
- },
- getDowm() {
- let url =
- baseUrls.BASE_IMG_URL + "/oss/images/file/20220304/1646382321115.xlsx";
- let link = document.createElement("a");
- let fileName = "导入模板" + ".xlsx";
- document.body.appendChild(link);
- link.href = url;
- link.dowmload = fileName;
- link.click();
- link.remove();
- },
- importMobleadd(e) {
- var self = this;
- var file = e.target.files[0];
- let formData = new FormData();
- formData.append("file", file);
- this.$api
- .drCourseSectionimportData(formData)
- .then(async (res) => {
- if (res.code === 200) {
- if (!res.data.errorLog) {
- await this.awaitGetFestivalList(res.data.importNo, 1)
- .then((result) => {
- self.dialogDR = false;
- })
- .catch(() => {
- e.target.value = "";
- });
- } else {
- await this.awaitGetFestivalList(res.data.importNo, 2)
- .then((result) => {
- let ary = res.data.errorLog.split("\r\n");
- ary = ary
- .filter((item) => {
- return item.length > 0;
- })
- .reverse();
- self.$message({
- message: `${ary.length}条数据导入失败,请查看失败原因`,
- customClass: "myMessageClass",
- });
- ary = ary.join("\r\n");
- self.errorData = ary;
- self.dialogERROR = true;
- })
- .catch(() => {
- e.target.value = "";
- });
- }
- }
- })
- .finally(() => {
- e.target.value = "";
- });
- },
- awaitGetFestivalList(ids, type) {
- return new Promise((resolve, reject) => {
- this.$api
- .inquireCourseSection({ importNo: ids })
- .then((res) => {
- if (type === 2 && res.rows.length) {
- this.$message({
- type: "success",
- message: `成功导入${res.rows.length}条数据,`,
- customClass: "myMessageClass",
- });
- }
- if (res.rows.length) {
- this.activeLists = res.rows;
- if (type === 1) {
- this.submitForm();
- } else {
- this.submitForm(1);
- }
- }
- resolve();
- })
- .catch(() => {
- reject();
- });
- });
- },
- unTime(val) {
- let a = `${val.businessId}-${val.subjectId}`;
- if (this.sujectApis.includes(a)) {
- this.sujectApis.splice(this.sujectApis.indexOf(a), 1);
- } else {
- this.sujectApis.push(a);
- }
- },
- changeSty(val) {
- var arr = "";
- this.sujectApis.forEach((item) => {
- let arr1 = item.split("-").map(Number);
- if (val.businessId == arr1[0] && val.subjectId == arr1[1]) {
- arr = "activeStyIcons";
- }
- });
- return arr;
- },
- handleCheckedCitiesChange() {
- let nid = this.newSujectOption.map((item) => {
- return item.newId;
- });
- this.checkAll = this.sujectArray.length === nid.length;
- this.isIndeterminate =
- this.sujectArray.length > 0 && this.sujectArray.length < nid.length;
- },
- setFunc(arr) {
- var arrays = [];
- for (let i = 0; i < arr.length; i++) {
- if (!arrays.includes(arr[i])) {
- arrays.push(arr[i]);
- }
- }
- return arrays;
- },
- handleCheckAllChange(val) {
- if (val) {
- let nid = this.newSujectOption.map((item) => {
- return item.newId;
- });
- let arrays = this.sujectArray.concat(nid);
- this.sujectArray = this.setFunc(arrays);
- this.isIndeterminate = false;
- } else {
- let nid = this.newSujectOption.map((item) => {
- return item.newId;
- });
- let newArr = [];
- this.sujectArray.forEach((item) => {
- if (!nid.includes(item)) {
- newArr.push(item);
- }
- });
- this.sujectArray = newArr;
- this.isIndeterminate = false;
- }
- },
- getMessage() {
- if (!this.courType) {
- this.$message.warning("请先选择业务层级");
- }
- },
- openBoxs() {
- var self = this;
- this.$api.inquireCourseSection(this.formData).then((res) => {
- var aList = [];
- this.tableData.map((item) => {
- aList.push(item.sectionId);
- });
- this.disCheckList = aList;
- this.boxtableData = res.rows;
- this.total = res.total;
- this.dialogVisible = true;
- this.$nextTick(function () {
- self.$refs.multipleTable.clearSelection();
- });
- });
- },
- getInfos(int) {
- this.loading = true;
- if (int === 1) {
- this.formData.pageNum = 1;
- }
- if (int === 2) {
- this.formData = {
- status: 1,
- pageSize: 10,
- pageNum: 1,
- };
- }
- this.$api
- .inquireCourseSection(this.formData)
- .then((res) => {
- this.boxtableData = res.rows;
- this.total = res.total;
- })
- .finally(() => {
- this.loading = false;
- });
- },
- init() {
- this.getInfos(2);
- },
- getInfosList() {
- this.$api
- .inquireCoursechaptersectionlist(this.$route.query.id)
- .then((result) => {
- // this.numberAll = result.total;
- // this.minTimeAll = result.timeTotal;
- this.tableData = result.rows;
- });
- },
- search() {
- this.$api.obtainCoursechapter(this.$route.query.id).then((res) => {
- this.bfImg = res.data.coverUrl;
- this.listData = res.data;
- this.$api
- .obtainCoursechapterbusiness(this.$route.query.id)
- .then((result) => {
- var arrays = [];
- result.data.map((item) => {
- arrays.push(item.businessId + "-" + item.subjectId);
- });
- this.sujectApis = arrays;
- this.getInfosList();
- });
- });
- },
- clearImgs() {
- this.listData.coverUrl = "";
- },
- changeTypes() {
- var self = this;
- var arrays = [];
- this.sujectApis.map((item, index) => {
- this.courTypeOptions.map((items) => {
- if (items.id === item.split("-").map(Number)[0]) {
- var obj = {
- educationTypeId: items.educationId,
- educationName: items.educationName,
- projectId: items.projectId,
- projectName: items.projectName,
- businessId: items.id,
- businessName: items.businessName,
- };
- self.sujectOption.map((i) => {
- if (
- i.id === item.split("-").map(Number)[1] &&
- i.courseArrays.indexOf(items.projectId) !== -1
- ) {
- obj.subjectName = i.subjectName;
- obj.subjectId = i.id;
- }
- });
- arrays.push(obj);
- }
- });
- });
- this.newSujectApis = arrays;
- },
- changeType() {
- this.changeHeight = !this.changeHeight;
- },
- submitSujectArray() {
- var self = this;
- this.sujectApis = this.sujectApis.filter((item, index) => {
- return item.split("-").map(Number)[0] !== Number(self.courType);
- });
- for (let i = 0; i < this.sujectArray.length; i++) {
- this.sujectApis.push(this.sujectArray[i]);
- }
- this.$refs.popovers.doClose();
- },
- showHandle() {
- var array = [];
- for (let i = 0; i < this.sujectApis.length; i++) {
- if (
- this.sujectApis[i].split("-").map(Number)[0] === Number(this.courType)
- ) {
- array.push(this.sujectApis[i]);
- }
- }
- this.sujectArray = array;
- if (!this.newSujectOption.length) {
- this.$message.warning("该业务层次暂无关联科目");
- this.$refs.popovers.doClose();
- return;
- }
- this.newSujectOption.map((item) => {
- item.newId = this.courType + "-" + item.id;
- });
- this.handleCheckedCitiesChange();
- },
- hideHandle() {},
- getDict() {
- this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
- this.eduTypeOptions = res.rows;
- });
- this.$api.inquireCourseProjectType({ status: 1 }).then((res) => {
- this.projectTypeOptions = res.rows;
- });
- this.$api.inquirebusinessList({ status: 1 }).then((res) => {
- this.courTypeOptions = res.rows;
- this.newCourTypeOptions = res.rows;
- });
- this.$api.inquireCourseSubject({ status: 1 }).then((res) => {
- res.rows.map((item, index) => {
- var array = [];
- item.courseProjectTypes.map((items, indexs) => {
- array.push(items.id);
- });
- item.courseArrays = array;
- });
- this.sujectOption = res.rows;
- });
- },
- changeEduType() {
- if (!(this.courType === undefined || this.courType === "")) {
- this.courType = "";
- }
- var arrays = [];
- this.courTypeOptions.map((item) => {
- if (item.educationId === this.eduType) {
- arrays.push(item);
- }
- });
- this.newCourTypeOptions = arrays;
- },
- changecourseType() {
- this.newCourTypeOptions.map((item, index) => {
- if (item.id === this.courType) {
- this.eduType = item.educationId;
- var array = [];
- this.sujectOption.map((items, indexs) => {
- if (items.courseArrays.indexOf(item.projectId) !== -1) {
- array.push(items);
- }
- });
- this.newSujectOption = array;
- }
- });
- var arrays = [];
- this.courTypeOptions.map((item) => {
- if (item.educationId === this.eduType) {
- arrays.push(item);
- }
- });
- this.newCourTypeOptions = arrays;
- this.$refs.popovers.doClose();
- },
- submit(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- // if (
- // this.listData.coverUrl === "" ||
- // this.listData.coverUrl === null ||
- // this.listData.coverUrl === undefined
- // ) {
- // this.$message.error("请上传章封面");
- // return false;
- // }
- for (let i = 0; i < this.tableData.length; i++) {
- if (!this.tableData[i].sort && this.tableData[i].sort !== 0) {
- this.$message.warning(`管理节第${i + 1}条请输入排序`);
- return;
- }
- }
- let arr = this.tableData.map((items) => {
- return items.sort;
- });
- if (new Set(arr).size != arr.length) {
- this.$message.warning("排序不允许有重复值");
- return;
- }
- this.rulesTableSumbit();
- } else {
- return false;
- }
- });
- },
- async rulesTableSumbit() {
- this.disabledBtn = true;
- var sectionIdList = [];
- this.tableData.map((item) => {
- sectionIdList.push({
- sectionId: item.sectionId,
- sort: Number(item.sort),
- });
- });
- var dataInfos = {
- status: 1,
- businessList: this.newSujectApis,
- sectionIdList: sectionIdList,
- coverUrl: this.listData.coverUrl,
- name: this.listData.name,
- prefixName: this.listData.prefixName,
- publishStatus: this.listData.publishStatus,
- };
- this.$api
- .addCoursechapter(dataInfos)
- .then((res) => {
- this.$methodsTools.cacheBusinessList(this.newSujectApis);
- this.$message.success("新增成功");
- setTimeout(() => {
- this.$store
- .dispatch("tagsView/exitView", this.$route)
- .then((res) => {
- this.$router.push({
- path: "chapter",
- });
- });
- }, 500);
- })
- .catch(() => {
- this.disabledBtn = false;
- });
- },
- backPage() {
- this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
- this.$router.push({
- path: "chapter",
- });
- });
- },
- closeType(index) {
- this.sujectApis.splice(index, 1);
- },
- getImgFile() {
- var self = this;
- var file = self.$refs.file.files[0];
- if (file === undefined) {
- self.$set(self.listData, "coverUrl", "");
- return;
- }
- if (file.size > 0.3 * 1024 * 1024) {
- self.$message.error("图片不得大于300kb");
- return;
- }
- var type = self.$refs.file.value.toLowerCase().split(".").splice(-1);
- if (
- type[0] != "jpg" &&
- type[0] != "png" &&
- type[0] != "jpeg" &&
- type[0] != "gif"
- ) {
- self.$message.error("上传格式需为:.jpg/.png/.jpeg/gif");
- self.$refs.file.value = "";
- return;
- }
- this.$upload.upload(file, 0).then((res) => {
- self.listData.coverUrl = res;
- });
- },
- handleSizeChange(v) {
- this.formData.pageSize = v;
- this.formData.pageNum = 1;
- this.getInfos();
- },
- handleCurrentChange(v) {
- this.formData.pageNum = v;
- this.getInfos();
- },
- selectAll(value) {
- this.activeLists = value;
- },
- select(value) {
- this.activeLists = value;
- },
- checkboxT(row, index) {
- if (this.disCheckList.indexOf(row.sectionId) !== -1) {
- return false;
- } else {
- return true;
- }
- },
- getRowKeys(row) {
- return row.sectionId;
- },
- submitForm(int) {
- if (this.activeLists.length === 0) {
- this.dialogVisible = false;
- return;
- }
- if (this.tableData.length) {
- let maxIndex = 0;
- this.tableData.forEach((item) => {
- if (item.sort > maxIndex) {
- maxIndex = item.sort;
- }
- });
- this.activeLists.forEach((item, index) => {
- item.sort = maxIndex + index + 1;
- });
- } else {
- this.activeLists.forEach((item, index) => {
- item.sort = index + 1;
- });
- }
- this.tableData = this.tableData.concat(this.activeLists);
- this.dialogVisible = false;
- if (!int) {
- this.$message({
- type: "success",
- message: `添加成功`,
- customClass: "myMessageClass",
- });
- }
- this.activeLists = [];
- },
- delList(item) {
- this.tableData.map((items, indexs) => {
- if (items.sectionId === item.sectionId) {
- this.tableData.splice(indexs, 1);
- this.$message.success("删除成功");
- }
- });
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .swq {
- text-align: center;
- border-bottom: 1px solid #eee;
- }
- .dowmStys {
- color: blue;
- cursor: pointer;
- }
- .boxWidth {
- width: 800px;
- }
- .numInputs {
- width: 150px;
- }
- .checkboxSty {
- max-height: 210px;
- overflow: auto;
- display: flex;
- flex-direction: column;
- }
- .listBoxStys {
- flex-shrink: 0;
- padding: 0px 10px;
- border-radius: 8px;
- border: 1px solid #eee;
- margin-right: 10px;
- margin-bottom: 6px;
- }
- .closeIcons {
- color: red;
- cursor: pointer;
- margin-left: 6px;
- }
- .ach {
- display: flex;
- align-items: center;
- overflow: hidden;
- }
- .clh {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- }
- .imgBoxins {
- width: 375px;
- height: 220px;
- text-align: center;
- img {
- height: 100%;
- }
- }
- .iconStsz {
- font-size: 40px;
- color: #67c23a;
- cursor: pointer;
- }
- .dis_plays {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 10px;
- }
- .comInputsty {
- width: 50px;
- height: 24px;
- text-align: center;
- border: none;
- }
- /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;
- }
- }
- }
- .imgBox {
- width: 100%;
- // height: 210px;
- border: 1px solid #e2e2e2;
- border-radius: 8px;
- padding: 8px 8px 3px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .imgLabel {
- flex: 1;
- width: 100%;
- border: 1px dotted #e2e2e2;
- color: #999;
- font-size: 14px;
- cursor: pointer;
- border-radius: 8px;
- .msPhoto {
- display: flex;
- justify-content: center;
- align-items: center;
- max-width: 100%;
- max-height: 270px;
- img {
- max-width: 100%;
- max-height: 270px;
- }
- }
- .imgbbx {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- i {
- font-weight: bold;
- margin: 14px 0;
- font-size: 24px;
- }
- }
- }
- p {
- margin: 5px 0px;
- }
- }
- </style>
|