index.vue 27 KB

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