index.vue 29 KB

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