index.vue 31 KB

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