index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  1. <template>
  2. <div id="moduleManagementEdit">
  3. <el-form
  4. label-position="right"
  5. label-width="120px"
  6. :model="listData"
  7. :rules="rules"
  8. ref="listData"
  9. >
  10. <div class="boxWidth">
  11. <el-form-item label="适用业务层级" required>
  12. <el-select
  13. v-model="eduType"
  14. placeholder="请选择教育类型"
  15. @change="changeEduType"
  16. >
  17. <el-option
  18. v-for="(item, index) in eduTypeOptions"
  19. :key="index"
  20. :label="item.educationName"
  21. :value="item.id"
  22. >
  23. </el-option>
  24. </el-select>
  25. <el-select
  26. v-model="courType"
  27. placeholder="请选择业务层次"
  28. @change="changecourseType"
  29. >
  30. <el-option
  31. v-for="(item, index) in newCourTypeOptions"
  32. :key="index"
  33. :label="item.projectName + '-' + item.businessName"
  34. :value="item.id"
  35. >
  36. </el-option>
  37. </el-select>
  38. <el-popover
  39. ref="popovers"
  40. placement="bottom"
  41. trigger="click"
  42. @show="showHandle"
  43. @hide="hideHandle"
  44. :disabled="courType ? false : true"
  45. ><el-checkbox
  46. v-model="checkAll"
  47. @change="handleCheckAllChange"
  48. :indeterminate="isIndeterminate"
  49. >全选</el-checkbox
  50. >
  51. <el-checkbox-group
  52. v-model="sujectArray"
  53. class="checkboxSty"
  54. @change="handleCheckedCitiesChange"
  55. >
  56. <el-checkbox
  57. v-for="(item, index) in newSujectOption"
  58. :label="item.newId"
  59. :key="index"
  60. >{{ item.subjectName }}</el-checkbox
  61. >
  62. </el-checkbox-group>
  63. <div style="display: block; text-align: center; margin-top: 10px">
  64. <el-button size="mini" type="primary" @click="submitSujectArray"
  65. >确定</el-button
  66. >
  67. </div>
  68. <el-button
  69. slot="reference"
  70. style="margin-left: 12px"
  71. @click="getMessage"
  72. >请选择科目</el-button
  73. >
  74. </el-popover>
  75. <span style="margin-left: 10px">注:可多选</span>
  76. </el-form-item>
  77. <el-form-item label="">
  78. <div :class="changeHeight ? 'ach' : 'clh'">
  79. <div
  80. v-for="(item, index) in newSujectApis"
  81. :key="index"
  82. class="listBoxStys"
  83. >
  84. {{
  85. item.educationName +
  86. " - " +
  87. item.projectName +
  88. " - " +
  89. item.businessName +
  90. " - " +
  91. item.subjectName
  92. }}
  93. <i class="el-icon-error closeIcons" @click="closeType(index)"></i>
  94. </div>
  95. </div>
  96. <el-button
  97. size="mini"
  98. v-if="newSujectApis.length > 1"
  99. @click="changeType"
  100. >{{ changeHeight ? "展开" : "关闭" }}</el-button
  101. ><el-button
  102. size="mini"
  103. v-if="newSujectApis.length > 0"
  104. @click="sujectApis = []"
  105. >清空</el-button
  106. >
  107. <!-- <span v-if="newSujectApis.length === 0">未选项目类型</span> -->
  108. </el-form-item>
  109. <el-form-item label="标题前缀" prop="prefixName">
  110. <el-input v-model="listData.prefixName"></el-input>
  111. <div style="color: #999">注:便于检索、归类,以及区分一样的标题</div>
  112. </el-form-item>
  113. <el-form-item label="模块标题" prop="moduleName">
  114. <el-input v-model="listData.moduleName"></el-input>
  115. <div style="color: #999">
  116. 注:请尽量规范易懂,方便在课程目录表呈现给学员
  117. </div>
  118. </el-form-item>
  119. <el-form-item label="模块封面">
  120. <el-row :gutter="10" style="margin-bottom: 10px">
  121. <el-col :span="12">
  122. <div
  123. style="
  124. width: 100%;
  125. height: 150px;
  126. border: 2px dashed #999;
  127. border-radius: 28px;
  128. line-height: 150px;
  129. text-align: center;
  130. "
  131. v-if="!listData.coverUrl"
  132. >
  133. <label for="uplose">
  134. <i class="el-icon-circle-plus-outline iconStsz"></i
  135. ></label>
  136. <input
  137. ref="file"
  138. type="file"
  139. style="display: none"
  140. id="uplose"
  141. @change="getImgFile"
  142. />
  143. </div>
  144. <el-image
  145. v-else
  146. style="width: 100%"
  147. :src="$methodsTools.splitImgHost(listData.coverUrl)"
  148. :preview-src-list="[
  149. $methodsTools.splitImgHost(listData.coverUrl),
  150. ]"
  151. >
  152. </el-image>
  153. </el-col>
  154. <el-col :span="11">
  155. <span style="color: #999; font-size: 14px"
  156. >注:请上传小于300kb,尺寸为750*440的图片,支持gif、jpg、jpeg、png等类型</span
  157. >
  158. </el-col>
  159. </el-row>
  160. <el-button
  161. v-if="listData.coverUrl"
  162. type="danger"
  163. size="mini"
  164. class="margin-top: 20px;"
  165. @click="clearImgs"
  166. >删除</el-button
  167. >
  168. </el-form-item>
  169. <el-form-item label="是否发布" prop="publishStatus">
  170. <el-radio-group v-model="listData.publishStatus">
  171. <el-radio :label="1">是</el-radio>
  172. <el-radio :label="0">否</el-radio>
  173. </el-radio-group>
  174. </el-form-item>
  175. </div>
  176. <el-form-item label="管理章">
  177. <div class="dis_plays">
  178. <div>
  179. <el-button size="small" @click="openBoxs">调用已有数据</el-button>
  180. <el-button size="small" @click="addChapter">自定义添加章</el-button>
  181. </div>
  182. <div style="color: #f56c6c">
  183. <span style="margin-right: 10px"
  184. >章总数:{{ tableData.length }}</span
  185. >
  186. <!-- <span>总时长:{{ minTimeAll }}分钟</span> -->
  187. </div>
  188. </div>
  189. <el-table
  190. :data="tableData"
  191. border
  192. :header-cell-style="{
  193. 'background-color': '#eee',
  194. padding: '8px',
  195. color: '#333',
  196. }"
  197. :default-sort="{ prop: 'sort', order: 'ascending' }"
  198. >
  199. <el-table-column
  200. v-for="(item, index) in tableSet"
  201. :width="item.width"
  202. :key="index"
  203. :label="item.label"
  204. align="center"
  205. :show-overflow-tooltip="true"
  206. header-align="center"
  207. :sortable="item.prop === 'sort'"
  208. sort-by="sort"
  209. :prop="item.prop"
  210. >
  211. <template slot-scope="scope">
  212. <span v-if="item.scope === 'types'">{{
  213. scope.row[item.prop] === 1
  214. ? "录播"
  215. : scope.row[item.prop] === 2
  216. ? "直播"
  217. : scope.row[item.prop] === 3
  218. ? "回放"
  219. : "未知"
  220. }}</span>
  221. <span v-else-if="item.scope === 'Status'">
  222. {{
  223. scope.row[item.prop] === 1
  224. ? "发布"
  225. : scope.row[item.prop] === 0
  226. ? "未发布"
  227. : "未知"
  228. }}
  229. </span>
  230. <div v-else-if="item.scope === 'inputs'">
  231. <el-input-number
  232. style="width: 50px"
  233. size="small"
  234. :controls="false"
  235. v-model="scope.row[item.prop]"
  236. controls-position="right"
  237. :min="0"
  238. ></el-input-number>
  239. </div>
  240. <span v-else>{{ scope.row[item.prop] }}</span></template
  241. >
  242. </el-table-column>
  243. <el-table-column
  244. label="操作"
  245. align="center"
  246. fixed="right"
  247. width="180px"
  248. >
  249. <template slot-scope="scope">
  250. <el-button type="text" @click="jumpChapter(scope.row)"
  251. >章节内容</el-button
  252. >
  253. <el-button type="text" @click="delList(scope.row)"
  254. >删除</el-button
  255. >
  256. </template>
  257. </el-table-column>
  258. </el-table>
  259. </el-form-item>
  260. <el-form-item>
  261. <el-button @click="backPage">取消</el-button>
  262. <el-button
  263. :loading="disabledBtn"
  264. type="primary"
  265. @click="submit('listData')"
  266. :disabled="!noStudent"
  267. >确定</el-button
  268. >
  269. </el-form-item>
  270. </el-form>
  271. <el-dialog
  272. @closed="closedFunc"
  273. :visible.sync="dialogVisible"
  274. width="800px"
  275. :show-close="false"
  276. :close-on-click-modal="false"
  277. >
  278. <div slot="title" class="hearders">
  279. <div class="leftTitle">添加章</div>
  280. <div class="rightBoxs">
  281. <img
  282. src="@/assets/images/Close@2x.png"
  283. alt=""
  284. @click="dialogVisible = false"
  285. />
  286. </div>
  287. </div>
  288. <search-box-new
  289. ref="searchBox"
  290. :formData="formData"
  291. :formList="formList"
  292. @search="getInfos"
  293. @init="init"
  294. />
  295. <el-table
  296. ref="multipleTable"
  297. :data="boxtableData"
  298. border
  299. @select-all="selectAll"
  300. @select="select"
  301. :row-key="getRowKeys"
  302. :header-cell-style="{
  303. 'background-color': '#eee',
  304. padding: '8px',
  305. color: '#333',
  306. }"
  307. >
  308. <el-table-column
  309. align="center"
  310. type="selection"
  311. width="55"
  312. header-align="center"
  313. :selectable="checkboxT"
  314. :reserve-selection="true"
  315. >
  316. </el-table-column>
  317. <template v-for="(item, index) in tableSet">
  318. <el-table-column
  319. v-if="item.scope !== 'inputs'"
  320. :width="item.width"
  321. :key="index"
  322. :label="item.label"
  323. align="center"
  324. :show-overflow-tooltip="true"
  325. header-align="center"
  326. >
  327. <template slot-scope="scope">
  328. <span v-if="item.scope === 'types'">{{
  329. scope.row[item.prop] === 1
  330. ? "录播"
  331. : scope.row[item.prop] === 2
  332. ? "直播"
  333. : scope.row[item.prop] === 3
  334. ? "回放"
  335. : "未知"
  336. }}</span>
  337. <span v-else-if="item.scope === 'Status'">
  338. {{
  339. scope.row[item.prop] === 1
  340. ? "发布"
  341. : scope.row[item.prop] === 0
  342. ? "未发布"
  343. : "未知"
  344. }}
  345. </span>
  346. <span v-else>{{ scope.row[item.prop] }}</span></template
  347. >
  348. </el-table-column></template
  349. >
  350. </el-table>
  351. <pagination
  352. :total="total"
  353. :pageSize="formData.pageSize"
  354. :currentPage="formData.pageNum"
  355. @handleSizeChange="handleSizeChange"
  356. @handleCurrentChange="handleCurrentChange"
  357. />
  358. <span slot="footer" class="dialog-footer">
  359. <el-button @click="dialogVisible = false">取 消</el-button>
  360. <el-button
  361. type="primary"
  362. :disabled="activeLists.length === 0"
  363. @click="submitForm"
  364. >确 定</el-button
  365. >
  366. </span>
  367. </el-dialog>
  368. <addChapter ref="addChapter" @backData="backData" />
  369. </div>
  370. </template>
  371. <script>
  372. import searchBoxNew from "@/components/searchBoxNew";
  373. import pagination from "@/components/pagination";
  374. import addChapter from "../addChapter.vue";
  375. export default {
  376. name: "ModuleManagementEdit",
  377. components: { searchBoxNew, pagination, addChapter },
  378. data() {
  379. return {
  380. disabledBtn: false,
  381. isIndeterminate: false,
  382. checkAll: false,
  383. // 弹窗数据
  384. changeHeight: true,
  385. bfImg: "oss/images/avatar/20211013/1634097664410_1397766697",
  386. listData: {
  387. recordingUrl: "",
  388. liveUrl: "",
  389. coverUrl: "oss/images/avatar/20211013/1634097664410_1397766697",
  390. },
  391. eduTypeOptions: [], //教育类型数据
  392. projectTypeOptions: [], //项目类型数据
  393. courTypeOptions: [], //业务层次数据
  394. newCourTypeOptions: [], //当前业务层次数据
  395. sujectOption: [], //科目数据
  396. newSujectOption: [], //当前科目数据数据
  397. eduType: "", //当前选中教育类型
  398. courType: "", //当前选中业务层次
  399. sujectApis: [], //当前存在的科目
  400. newSujectApis: [],
  401. sujectArray: [], //选中的科目
  402. //表单验证
  403. rules: {
  404. prefixName: [
  405. { required: false, message: "请输入标题前缀", trigger: "blur" },
  406. ],
  407. moduleName: [
  408. { required: true, message: "请输入节标题", trigger: "blur" },
  409. ],
  410. // liveDuration: [
  411. // { required: true, message: "节时长不能为空" },
  412. // { type: "number", message: "节时长必须为数字值" },
  413. // ],
  414. publishStatus: [
  415. { required: true, message: "请选择是否发布", trigger: "change" },
  416. ],
  417. },
  418. numberAll: 0, //节总数
  419. minTimeAll: 0, //总时长
  420. tableSet: [
  421. { label: "排序", prop: "sort", scope: "inputs", width: "100" },
  422. { label: "章编码", prop: "code", width: "120" },
  423. { label: "标题前缀", prop: "prefixName", width: "180" },
  424. { label: "章标题", prop: "name" },
  425. { label: "节数量", prop: "sectionNum" , width: "120" },
  426. {
  427. label: "发布状态",
  428. prop: "publishStatus",
  429. scope: "Status",
  430. width: "120",
  431. },
  432. ],
  433. tableData: [],
  434. dialogVisible: false,
  435. boxtableData: [],
  436. formList: [
  437. {
  438. prop: "educationTypeId",
  439. placeholder: "教育类型",
  440. scope: "educationType",
  441. },
  442. {
  443. prop: "businessId",
  444. placeholder: "业务层次",
  445. scope: "businessLevel",
  446. edu: "educationTypeId",
  447. },
  448. {
  449. prop: "subjectId",
  450. placeholder: "科目",
  451. scope: "sujectType",
  452. edu: "educationTypeId",
  453. },
  454. // {
  455. // prop: "publishStatus",
  456. // placeholder: "发布状态",
  457. // scope: "select",
  458. // options: [
  459. // {
  460. // label: "已发布",
  461. // value: 1,
  462. // },
  463. // {
  464. // label: "未发布",
  465. // value: 0,
  466. // },
  467. // ],
  468. // },
  469. {
  470. prop: "key",
  471. placeholder: "请输入章标题/章编码/标题前缀",
  472. },
  473. ],
  474. total: 0, //一共多少条
  475. formData: {
  476. status: 1,
  477. pageSize: 10,
  478. pageNum: 1,
  479. publishStatus: 1,
  480. },
  481. disCheckList: [], //已选转禁用复选列表
  482. activeLists: [],
  483. noStudent: true,
  484. pageId:this.$route.query.id
  485. };
  486. },
  487. watch: {
  488. sujectApis: {
  489. immediate: true,
  490. handler(newName, oldName) {
  491. this.changeTypes();
  492. },
  493. },
  494. },
  495. async mounted() {
  496. this.$modal.loading("正在导入数据,请稍后...");
  497. this.$api
  498. .gradecheckGoodsChange({ moduleId: this.pageId })
  499. .then((res) => {
  500. if (res.data > 0) {
  501. this.noStudent = false;
  502. }
  503. });
  504. await this.getDict();
  505. this.search();
  506. },
  507. activated() {
  508. if (this.$store.getters.modulePage) {
  509. this.$api
  510. .obtainCoursechapter(this.$store.getters.modulePage.id)
  511. .then((res) => {
  512. const FIND = this.tableData.findIndex((item) => {
  513. return item.chapterId == this.$store.getters.modulePage.id;
  514. });
  515. if (FIND !== -1) {
  516. res.data.sort = this.tableData[FIND].sort;
  517. this.tableData.splice(FIND, 1, res.data);
  518. }
  519. this.$store.dispatch("changemodulePage", null);
  520. });
  521. }
  522. },
  523. methods: {
  524. jumpChapter(v) {
  525. const jump = () => {
  526. this.$store.dispatch("changemodulePage", {
  527. name: "moduleManagementEdit",
  528. id: v.chapterId,
  529. });
  530. this.$router.push({
  531. path: "chapterEdit",
  532. query: {
  533. id: v.chapterId,
  534. },
  535. });
  536. };
  537. const statusPage = this.$store.state.tagsView.visitedViews.some(
  538. (item) => {
  539. return item.name == "ChapterEdit";
  540. }
  541. );
  542. if (statusPage) {
  543. this.$store
  544. .dispatch("tagsView/delCachedView", {
  545. name: "ChapterEdit",
  546. })
  547. .then((res) => {
  548. jump();
  549. });
  550. } else {
  551. jump();
  552. }
  553. },
  554. /**
  555. * 打开添加章组件
  556. */
  557. addChapter() {
  558. if (!this.newSujectApis.length) {
  559. this.$message.warning("请选择科目");
  560. return;
  561. }
  562. this.$refs.addChapter.openBoxs(this.newSujectApis);
  563. },
  564. /**
  565. * 添加章-返回数据
  566. */
  567. backData(v) {
  568. this.$api.inquireCourseListchapter({ chapterIds: v }).then((res) => {
  569. this.activeLists = res.rows;
  570. this.submitForm();
  571. });
  572. },
  573. handleCheckedCitiesChange() {
  574. let nid = this.newSujectOption.map((item) => {
  575. return item.newId;
  576. });
  577. this.checkAll = this.sujectArray.length === nid.length;
  578. this.isIndeterminate =
  579. this.sujectArray.length > 0 && this.sujectArray.length < nid.length;
  580. },
  581. setFunc(arr) {
  582. var arrays = [];
  583. for (let i = 0; i < arr.length; i++) {
  584. if (!arrays.includes(arr[i])) {
  585. arrays.push(arr[i]);
  586. }
  587. }
  588. return arrays;
  589. },
  590. handleCheckAllChange(val) {
  591. if (val) {
  592. let nid = this.newSujectOption.map((item) => {
  593. return item.newId;
  594. });
  595. let arrays = this.sujectArray.concat(nid);
  596. this.sujectArray = this.setFunc(arrays);
  597. this.isIndeterminate = false;
  598. } else {
  599. let nid = this.newSujectOption.map((item) => {
  600. return item.newId;
  601. });
  602. let newArr = [];
  603. this.sujectArray.forEach((item) => {
  604. if (!nid.includes(item)) {
  605. newArr.push(item);
  606. }
  607. });
  608. this.sujectArray = newArr;
  609. this.isIndeterminate = false;
  610. }
  611. },
  612. getMessage() {
  613. if (!this.courType) {
  614. this.$message.warning("请先选择业务层级");
  615. }
  616. },
  617. openBoxs() {
  618. var self = this;
  619. this.$api
  620. .inquireCourseListchapter({
  621. status: 1,
  622. pageNum: 1,
  623. pageSize: 10,
  624. publishStatus: 1,
  625. })
  626. .then((res) => {
  627. var aList = [];
  628. this.tableData.map((item) => {
  629. aList.push(item.chapterId);
  630. });
  631. this.disCheckList = aList;
  632. this.boxtableData = res.rows;
  633. this.total = res.total;
  634. this.dialogVisible = true;
  635. this.$nextTick(function () {
  636. self.$refs.multipleTable.clearSelection();
  637. });
  638. });
  639. },
  640. getInfosList() {
  641. this.$api
  642. .inquireCourseListmodulechapter(this.pageId)
  643. .then((result) => {
  644. // this.numberAll = result.total;
  645. // this.minTimeAll = result.timeTotal;
  646. this.tableData = result.data;
  647. });
  648. },
  649. init() {
  650. this.getInfos(2);
  651. },
  652. getInfos(int) {
  653. if (int === 1) {
  654. this.formData.pageNum = 1;
  655. }
  656. if (int === 2) {
  657. this.formData = {
  658. status: 1,
  659. pageSize: 10,
  660. pageNum: 1,
  661. publishStatus: 1,
  662. };
  663. }
  664. this.$api.inquireCourseListchapter(this.formData).then((res) => {
  665. this.boxtableData = res.rows;
  666. this.total = res.total;
  667. });
  668. },
  669. search() {
  670. this.$api
  671. .obtainCoursemodule(this.pageId)
  672. .then((res) => {
  673. this.bfImg = res.data.coverUrl;
  674. this.listData = res.data;
  675. this.$api
  676. .inquireCourseListmodulebusiness(this.pageId)
  677. .then((result) => {
  678. var arrays = [];
  679. result.data.map((item) => {
  680. arrays.push(item.businessId + "-" + item.subjectId);
  681. });
  682. this.sujectApis = arrays;
  683. this.getInfosList();
  684. });
  685. })
  686. .finally(() => {
  687. this.$modal.closeLoading();
  688. });
  689. },
  690. clearImgs() {
  691. this.listData.coverUrl = "";
  692. },
  693. changeTypes() {
  694. var self = this;
  695. var arrays = [];
  696. this.sujectApis.map((item, index) => {
  697. this.courTypeOptions.map((items) => {
  698. if (items.id === item.split("-").map(Number)[0]) {
  699. var obj = {
  700. educationTypeId: items.educationId,
  701. educationName: items.educationName,
  702. projectId: items.projectId,
  703. projectName: items.projectName,
  704. businessId: items.id,
  705. businessName: items.businessName,
  706. };
  707. self.sujectOption.map((i) => {
  708. if (
  709. i.id === item.split("-").map(Number)[1] &&
  710. i.courseArrays.indexOf(items.projectId) !== -1
  711. ) {
  712. obj.subjectName = i.subjectName;
  713. obj.subjectId = i.id;
  714. }
  715. });
  716. arrays.push(obj);
  717. }
  718. });
  719. });
  720. this.newSujectApis = arrays;
  721. },
  722. changeType() {
  723. this.changeHeight = !this.changeHeight;
  724. },
  725. submitSujectArray() {
  726. var self = this;
  727. this.sujectApis = this.sujectApis.filter((item, index) => {
  728. return item.split("-").map(Number)[0] !== Number(self.courType);
  729. });
  730. for (let i = 0; i < this.sujectArray.length; i++) {
  731. this.sujectApis.push(this.sujectArray[i]);
  732. }
  733. this.$refs.popovers.doClose();
  734. },
  735. showHandle() {
  736. var array = [];
  737. for (let i = 0; i < this.sujectApis.length; i++) {
  738. if (
  739. this.sujectApis[i].split("-").map(Number)[0] === Number(this.courType)
  740. ) {
  741. array.push(this.sujectApis[i]);
  742. }
  743. }
  744. this.sujectArray = array;
  745. if (!this.newSujectOption.length) {
  746. this.$message.warning("该业务层次暂无关联科目");
  747. this.$refs.popovers.doClose();
  748. return;
  749. }
  750. this.newSujectOption.map((item) => {
  751. item.newId = this.courType + "-" + item.id;
  752. });
  753. this.handleCheckedCitiesChange();
  754. },
  755. hideHandle() {},
  756. getDict() {
  757. return new Promise((resolve, reject) => {
  758. this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
  759. this.eduTypeOptions = res.rows;
  760. });
  761. this.$api.inquireCourseProjectType({ status: 1 }).then((res) => {
  762. this.projectTypeOptions = res.rows;
  763. });
  764. this.$api.inquirebusinessList({ status: 1 }).then((res) => {
  765. this.courTypeOptions = res.rows;
  766. this.newCourTypeOptions = res.rows;
  767. });
  768. this.$api.inquireCourseSubject({ status: 1 }).then((res) => {
  769. res.rows.map((item, index) => {
  770. var array = [];
  771. item.courseProjectTypes.map((items, indexs) => {
  772. array.push(items.id);
  773. });
  774. item.courseArrays = array;
  775. });
  776. this.sujectOption = res.rows;
  777. resolve();
  778. });
  779. });
  780. },
  781. changeEduType() {
  782. if (!(this.courType === undefined || this.courType === "")) {
  783. this.courType = "";
  784. }
  785. var arrays = [];
  786. this.courTypeOptions.map((item) => {
  787. if (item.educationId === this.eduType) {
  788. arrays.push(item);
  789. }
  790. });
  791. this.newCourTypeOptions = arrays;
  792. },
  793. changecourseType() {
  794. this.newCourTypeOptions.map((item, index) => {
  795. if (item.id === this.courType) {
  796. this.eduType = item.educationId;
  797. var array = [];
  798. this.sujectOption.map((items, indexs) => {
  799. if (items.courseArrays.indexOf(item.projectId) !== -1) {
  800. array.push(items);
  801. }
  802. });
  803. this.newSujectOption = array;
  804. }
  805. });
  806. var arrays = [];
  807. this.courTypeOptions.map((item) => {
  808. if (item.educationId === this.eduType) {
  809. arrays.push(item);
  810. }
  811. });
  812. this.newCourTypeOptions = arrays;
  813. this.$refs.popovers.doClose();
  814. },
  815. submit(formName) {
  816. this.$refs[formName].validate((valid) => {
  817. if (valid) {
  818. if (!this.newSujectApis.length) {
  819. this.$message.error("请选择适用业务层级");
  820. return;
  821. }
  822. // if (
  823. // this.listData.coverUrl === "" ||
  824. // this.listData.coverUrl === null ||
  825. // this.listData.coverUrl === undefined
  826. // ) {
  827. // this.$message.error("请上传节封面");
  828. // return false;
  829. // }
  830. for (let i = 0; i < this.tableData.length; i++) {
  831. if (!this.tableData[i].sort && this.tableData[i].sort !== 0) {
  832. this.$message.warning(`管理章第${i + 1}条请输入排序`);
  833. return;
  834. }
  835. }
  836. let arr = this.tableData.map((items) => {
  837. return items.sort;
  838. });
  839. if (new Set(arr).size != arr.length) {
  840. this.$message.warning("排序不允许有重复值");
  841. return;
  842. }
  843. this.rulesTableSumbit();
  844. } else {
  845. return false;
  846. }
  847. });
  848. },
  849. async rulesTableSumbit() {
  850. this.disabledBtn = true;
  851. var chapterIdList = [];
  852. this.tableData.map((item) => {
  853. chapterIdList.push({
  854. chapterId: item.chapterId,
  855. sort: Number(item.sort),
  856. });
  857. });
  858. var dataInfos = {
  859. status: 1,
  860. moduleId: this.pageId,
  861. businessList: this.newSujectApis,
  862. chapterIdList: chapterIdList,
  863. coverUrl: this.listData.coverUrl,
  864. moduleName: this.listData.moduleName,
  865. prefixName: this.listData.prefixName,
  866. publishStatus: this.listData.publishStatus,
  867. };
  868. this.$api
  869. .editCoursemodule(dataInfos)
  870. .then((res) => {
  871. this.$message.success("修改成功");
  872. setTimeout(() => {
  873. this.$store
  874. .dispatch("tagsView/exitView", this.$route)
  875. .then((res) => {
  876. this.$router.push({
  877. path: "moduleManagement",
  878. });
  879. });
  880. }, 500);
  881. })
  882. .catch(() => {
  883. this.disabledBtn = false;
  884. });
  885. },
  886. backPage() {
  887. this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
  888. this.$router.push({
  889. path: "moduleManagement",
  890. });
  891. });
  892. },
  893. closeType(index) {
  894. this.sujectApis.splice(index, 1);
  895. },
  896. getImgFile() {
  897. var self = this;
  898. var file = self.$refs.file.files[0];
  899. if (file === undefined) {
  900. self.$set(self.listData, "coverUrl", "");
  901. return;
  902. }
  903. if (file.size > 0.3 * 1024 * 1024) {
  904. self.$message.error("图片不得大于300kb");
  905. return;
  906. }
  907. var type = self.$refs.file.value.toLowerCase().split(".").splice(-1);
  908. if (
  909. type[0] != "jpg" &&
  910. type[0] != "png" &&
  911. type[0] != "jpeg" &&
  912. type[0] != "gif"
  913. ) {
  914. self.$message.error("上传格式需为:.jpg/.png/.jpeg/gif");
  915. self.$refs.file.value = "";
  916. return;
  917. }
  918. this.$upload.upload(file, 0).then((res) => {
  919. self.listData.coverUrl = res;
  920. });
  921. },
  922. handleSizeChange(v) {
  923. this.formData.pageSize = v;
  924. this.formData.pageNum = 1;
  925. this.getInfos();
  926. },
  927. handleCurrentChange(v) {
  928. this.formData.pageNum = v;
  929. this.getInfos();
  930. },
  931. selectAll(value) {
  932. this.activeLists = value;
  933. },
  934. select(value) {
  935. this.activeLists = value;
  936. },
  937. checkboxT(row, index) {
  938. if (this.disCheckList.indexOf(row.chapterId) !== -1) {
  939. return false;
  940. } else {
  941. return true;
  942. }
  943. },
  944. getRowKeys(row) {
  945. return row.chapterId;
  946. },
  947. submitForm() {
  948. if (this.activeLists.length === 0) {
  949. this.dialogVisible = false;
  950. return;
  951. }
  952. if (this.tableData.length) {
  953. let maxIndex = 0;
  954. this.tableData.forEach((item) => {
  955. if (item.sort > maxIndex) {
  956. maxIndex = item.sort;
  957. }
  958. });
  959. this.activeLists.forEach((item, index) => {
  960. item.sort = maxIndex + index + 1;
  961. });
  962. } else {
  963. this.activeLists.forEach((item, index) => {
  964. item.sort = index + 1;
  965. });
  966. }
  967. this.tableData = this.tableData.concat(this.activeLists);
  968. this.dialogVisible = false;
  969. this.$message.success("添加成功");
  970. },
  971. delList(item) {
  972. this.tableData.map((items, indexs) => {
  973. if (items.chapterId === item.chapterId) {
  974. this.tableData.splice(indexs, 1);
  975. this.$message.success("删除成功");
  976. }
  977. });
  978. },
  979. closedFunc(){
  980. this.activeLists = [];
  981. },
  982. },
  983. };
  984. </script>
  985. <style lang="less" scoped>
  986. .boxWidth {
  987. width: 800px;
  988. }
  989. .numInputs {
  990. width: 150px;
  991. }
  992. .checkboxSty {
  993. max-height: 210px;
  994. overflow: auto;
  995. display: flex;
  996. flex-direction: column;
  997. }
  998. .listBoxStys {
  999. flex-shrink: 0;
  1000. padding: 0px 10px;
  1001. border-radius: 8px;
  1002. border: 1px solid #eee;
  1003. margin-right: 10px;
  1004. margin-bottom: 6px;
  1005. }
  1006. .closeIcons {
  1007. color: red;
  1008. cursor: pointer;
  1009. margin-left: 6px;
  1010. }
  1011. .ach {
  1012. display: flex;
  1013. align-items: center;
  1014. overflow: hidden;
  1015. }
  1016. .clh {
  1017. display: flex;
  1018. align-items: center;
  1019. flex-wrap: wrap;
  1020. }
  1021. .imgBoxins {
  1022. width: 375px;
  1023. height: 220px;
  1024. text-align: center;
  1025. img {
  1026. height: 100%;
  1027. }
  1028. }
  1029. .iconStsz {
  1030. font-size: 40px;
  1031. color: #67c23a;
  1032. cursor: pointer;
  1033. }
  1034. .dis_plays {
  1035. display: flex;
  1036. align-items: center;
  1037. justify-content: space-between;
  1038. margin-bottom: 10px;
  1039. }
  1040. .comInputsty {
  1041. width: 50px;
  1042. height: 24px;
  1043. text-align: center;
  1044. border: none;
  1045. }
  1046. /deep/.el-button {
  1047. border-radius: 8px;
  1048. }
  1049. /deep/.el-dialog {
  1050. border-radius: 8px;
  1051. .el-dialog__header {
  1052. padding: 0;
  1053. .hearders {
  1054. height: 40px;
  1055. display: flex;
  1056. align-items: center;
  1057. justify-content: space-between;
  1058. padding: 0px 18px 0px 20px;
  1059. border-bottom: 1px solid #e2e2e2;
  1060. .leftTitle {
  1061. font-size: 14px;
  1062. font-weight: bold;
  1063. color: #2f4378;
  1064. }
  1065. .rightBoxs {
  1066. display: flex;
  1067. align-items: center;
  1068. img {
  1069. width: 14px;
  1070. height: 14px;
  1071. margin-left: 13px;
  1072. cursor: pointer;
  1073. }
  1074. }
  1075. }
  1076. }
  1077. .el-dialog__footer {
  1078. padding: 0;
  1079. .dialog-footer {
  1080. padding: 0px 40px;
  1081. height: 70px;
  1082. border-top: 1px solid #e2e2e2;
  1083. display: flex;
  1084. align-items: center;
  1085. justify-content: flex-end;
  1086. }
  1087. }
  1088. }
  1089. .imgBox {
  1090. width: 100%;
  1091. // height: 210px;
  1092. border: 1px solid #e2e2e2;
  1093. border-radius: 8px;
  1094. padding: 8px 8px 3px;
  1095. display: flex;
  1096. flex-direction: column;
  1097. align-items: center;
  1098. .imgLabel {
  1099. flex: 1;
  1100. width: 100%;
  1101. border: 1px dotted #e2e2e2;
  1102. color: #999;
  1103. font-size: 14px;
  1104. cursor: pointer;
  1105. border-radius: 8px;
  1106. .msPhoto {
  1107. display: flex;
  1108. justify-content: center;
  1109. align-items: center;
  1110. max-width: 100%;
  1111. max-height: 270px;
  1112. img {
  1113. max-width: 100%;
  1114. max-height: 270px;
  1115. }
  1116. }
  1117. .imgbbx {
  1118. display: flex;
  1119. flex-direction: column;
  1120. align-items: center;
  1121. justify-content: center;
  1122. width: 100%;
  1123. height: 100%;
  1124. i {
  1125. font-weight: bold;
  1126. margin: 14px 0;
  1127. font-size: 24px;
  1128. }
  1129. }
  1130. }
  1131. p {
  1132. margin: 5px 0px;
  1133. }
  1134. }
  1135. </style>