index.vue 30 KB

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