index.vue 36 KB

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