index.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  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="适用业务层级" required>
  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 (!this.newSujectApis.length) {
  955. this.$message.error("请选择适用业务层级");
  956. return;
  957. }
  958. // if (
  959. // this.listData.coverUrl === "" ||
  960. // this.listData.coverUrl === null ||
  961. // this.listData.coverUrl === undefined
  962. // ) {
  963. // this.$message.error("请上传章封面");
  964. // return false;
  965. // }
  966. for (let i = 0; i < this.tableData.length; i++) {
  967. if (!this.tableData[i].sort && this.tableData[i].sort !== 0) {
  968. this.$message.warning(`管理节第${i + 1}条请输入排序`);
  969. return;
  970. }
  971. }
  972. let arr = this.tableData.map((items) => {
  973. return items.sort;
  974. });
  975. if (new Set(arr).size != arr.length) {
  976. this.$message.warning("排序不允许有重复值");
  977. return;
  978. }
  979. this.rulesTableSumbit();
  980. } else {
  981. return false;
  982. }
  983. });
  984. },
  985. async rulesTableSumbit() {
  986. this.disabledBtn = true;
  987. var sectionIdList = [];
  988. this.tableData.map((item) => {
  989. sectionIdList.push({
  990. sectionId: item.sectionId,
  991. sort: Number(item.sort),
  992. });
  993. });
  994. var dataInfos = {
  995. status: 1,
  996. businessList: this.newSujectApis,
  997. sectionIdList: sectionIdList,
  998. coverUrl: this.listData.coverUrl,
  999. name: this.listData.name,
  1000. prefixName: this.listData.prefixName,
  1001. publishStatus: this.listData.publishStatus,
  1002. };
  1003. this.$api
  1004. .addCoursechapter(dataInfos)
  1005. .then((res) => {
  1006. this.$methodsTools.cacheBusinessList(this.newSujectApis);
  1007. this.$message.success("新增成功");
  1008. setTimeout(() => {
  1009. this.$store
  1010. .dispatch("tagsView/exitView", this.$route)
  1011. .then((res) => {
  1012. this.$router.push({
  1013. path: "chapter",
  1014. });
  1015. });
  1016. }, 500);
  1017. })
  1018. .catch(() => {
  1019. this.disabledBtn = false;
  1020. });
  1021. },
  1022. backPage() {
  1023. this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
  1024. this.$router.push({
  1025. path: "chapter",
  1026. });
  1027. });
  1028. },
  1029. closeType(index) {
  1030. this.sujectApis.splice(index, 1);
  1031. },
  1032. getImgFile() {
  1033. var self = this;
  1034. var file = self.$refs.file.files[0];
  1035. if (file === undefined) {
  1036. self.$set(self.listData, "coverUrl", "");
  1037. return;
  1038. }
  1039. if (file.size > 0.3 * 1024 * 1024) {
  1040. self.$message.error("图片不得大于300kb");
  1041. return;
  1042. }
  1043. var type = self.$refs.file.value.toLowerCase().split(".").splice(-1);
  1044. if (
  1045. type[0] != "jpg" &&
  1046. type[0] != "png" &&
  1047. type[0] != "jpeg" &&
  1048. type[0] != "gif"
  1049. ) {
  1050. self.$message.error("上传格式需为:.jpg/.png/.jpeg/gif");
  1051. self.$refs.file.value = "";
  1052. return;
  1053. }
  1054. this.$upload.upload(file, 0).then((res) => {
  1055. self.listData.coverUrl = res;
  1056. });
  1057. },
  1058. handleSizeChange(v) {
  1059. this.formData.pageSize = v;
  1060. this.formData.pageNum = 1;
  1061. this.getInfos();
  1062. },
  1063. handleCurrentChange(v) {
  1064. this.formData.pageNum = v;
  1065. this.getInfos();
  1066. },
  1067. selectAll(value) {
  1068. this.activeLists = value;
  1069. },
  1070. select(value) {
  1071. this.activeLists = value;
  1072. },
  1073. checkboxT(row, index) {
  1074. if (this.disCheckList.indexOf(row.sectionId) !== -1) {
  1075. return false;
  1076. } else {
  1077. return true;
  1078. }
  1079. },
  1080. getRowKeys(row) {
  1081. return row.sectionId;
  1082. },
  1083. submitForm(int) {
  1084. if (this.activeLists.length === 0) {
  1085. this.dialogVisible = false;
  1086. return;
  1087. }
  1088. if (this.tableData.length) {
  1089. let maxIndex = 0;
  1090. this.tableData.forEach((item) => {
  1091. if (item.sort > maxIndex) {
  1092. maxIndex = item.sort;
  1093. }
  1094. });
  1095. this.activeLists.forEach((item, index) => {
  1096. item.sort = maxIndex + index + 1;
  1097. });
  1098. } else {
  1099. this.activeLists.forEach((item, index) => {
  1100. item.sort = index + 1;
  1101. });
  1102. }
  1103. this.tableData = this.tableData.concat(this.activeLists);
  1104. this.dialogVisible = false;
  1105. if (!int) {
  1106. this.$message({
  1107. type: "success",
  1108. message: `添加成功`,
  1109. customClass: "myMessageClass",
  1110. });
  1111. }
  1112. this.activeLists = [];
  1113. },
  1114. delList(item) {
  1115. this.tableData.map((items, indexs) => {
  1116. if (items.sectionId === item.sectionId) {
  1117. this.tableData.splice(indexs, 1);
  1118. this.$message.success("删除成功");
  1119. }
  1120. });
  1121. },
  1122. },
  1123. };
  1124. </script>
  1125. <style lang="less" scoped>
  1126. .swq {
  1127. text-align: center;
  1128. border-bottom: 1px solid #eee;
  1129. }
  1130. .dowmStys {
  1131. color: blue;
  1132. cursor: pointer;
  1133. }
  1134. .boxWidth {
  1135. width: 800px;
  1136. }
  1137. .numInputs {
  1138. width: 150px;
  1139. }
  1140. .checkboxSty {
  1141. max-height: 210px;
  1142. overflow: auto;
  1143. display: flex;
  1144. flex-direction: column;
  1145. }
  1146. .listBoxStys {
  1147. flex-shrink: 0;
  1148. padding: 0px 10px;
  1149. border-radius: 8px;
  1150. border: 1px solid #eee;
  1151. margin-right: 10px;
  1152. margin-bottom: 6px;
  1153. }
  1154. .closeIcons {
  1155. color: red;
  1156. cursor: pointer;
  1157. margin-left: 6px;
  1158. }
  1159. .ach {
  1160. display: flex;
  1161. align-items: center;
  1162. overflow: hidden;
  1163. }
  1164. .clh {
  1165. display: flex;
  1166. align-items: center;
  1167. flex-wrap: wrap;
  1168. }
  1169. .imgBoxins {
  1170. width: 375px;
  1171. height: 220px;
  1172. text-align: center;
  1173. img {
  1174. height: 100%;
  1175. }
  1176. }
  1177. .iconStsz {
  1178. font-size: 40px;
  1179. color: #67c23a;
  1180. cursor: pointer;
  1181. }
  1182. .dis_plays {
  1183. display: flex;
  1184. align-items: center;
  1185. justify-content: space-between;
  1186. margin-bottom: 10px;
  1187. }
  1188. .comInputsty {
  1189. width: 50px;
  1190. height: 24px;
  1191. text-align: center;
  1192. border: none;
  1193. }
  1194. /deep/.el-button {
  1195. border-radius: 8px;
  1196. }
  1197. /deep/.el-dialog {
  1198. border-radius: 8px;
  1199. .el-dialog__header {
  1200. padding: 0;
  1201. .hearders {
  1202. height: 40px;
  1203. display: flex;
  1204. align-items: center;
  1205. justify-content: space-between;
  1206. padding: 0px 18px 0px 20px;
  1207. border-bottom: 1px solid #e2e2e2;
  1208. .leftTitle {
  1209. font-size: 14px;
  1210. font-weight: bold;
  1211. color: #2f4378;
  1212. }
  1213. .rightBoxs {
  1214. display: flex;
  1215. align-items: center;
  1216. img {
  1217. width: 14px;
  1218. height: 14px;
  1219. margin-left: 13px;
  1220. cursor: pointer;
  1221. }
  1222. }
  1223. }
  1224. }
  1225. .el-dialog__footer {
  1226. padding: 0;
  1227. .dialog-footer {
  1228. padding: 0px 40px;
  1229. height: 70px;
  1230. border-top: 1px solid #e2e2e2;
  1231. display: flex;
  1232. align-items: center;
  1233. justify-content: flex-end;
  1234. }
  1235. }
  1236. }
  1237. .imgBox {
  1238. width: 100%;
  1239. // height: 210px;
  1240. border: 1px solid #e2e2e2;
  1241. border-radius: 8px;
  1242. padding: 8px 8px 3px;
  1243. display: flex;
  1244. flex-direction: column;
  1245. align-items: center;
  1246. .imgLabel {
  1247. flex: 1;
  1248. width: 100%;
  1249. border: 1px dotted #e2e2e2;
  1250. color: #999;
  1251. font-size: 14px;
  1252. cursor: pointer;
  1253. border-radius: 8px;
  1254. .msPhoto {
  1255. display: flex;
  1256. justify-content: center;
  1257. align-items: center;
  1258. max-width: 100%;
  1259. max-height: 270px;
  1260. img {
  1261. max-width: 100%;
  1262. max-height: 270px;
  1263. }
  1264. }
  1265. .imgbbx {
  1266. display: flex;
  1267. flex-direction: column;
  1268. align-items: center;
  1269. justify-content: center;
  1270. width: 100%;
  1271. height: 100%;
  1272. i {
  1273. font-weight: bold;
  1274. margin: 14px 0;
  1275. font-size: 24px;
  1276. }
  1277. }
  1278. }
  1279. p {
  1280. margin: 5px 0px;
  1281. }
  1282. }
  1283. </style>