index.vue 38 KB

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