batchCreationClassDialog.vue 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819
  1. <template>
  2. <div class="batchCreationClassDialog">
  3. <el-dialog
  4. :visible.sync="show"
  5. width="100%"
  6. height="100%"
  7. fullscreen
  8. :modal="false"
  9. :close-on-click-modal="true"
  10. :show-close="false"
  11. >
  12. <div class="box">
  13. <div class="b_back">
  14. <div class="b_b_left" @click="close()">
  15. <img src="../../../../assets/icon/classroomObservation/right.svg" />
  16. <span>返回</span>
  17. </div>
  18. <div class="b_b_right">
  19. <el-button type="primary" size="small" @click="uploadFile"
  20. >上传文件</el-button
  21. >
  22. </div>
  23. </div>
  24. <div class="b_head">
  25. <span>已上传的课堂实录</span>
  26. </div>
  27. <div class="b_nav">
  28. <div class="b_n_left">
  29. <span
  30. :class="{ b_n_l_active: selectStatus == item.value }"
  31. v-for="item in statusList"
  32. :key="item.value"
  33. @click="changeStatus(item.value)"
  34. >{{ item.label }}</span
  35. >
  36. </div>
  37. <div class="b_n_right">
  38. <span @click="test">总计{{ dataList.length }}个</span>
  39. </div>
  40. </div>
  41. <div class="b_bottom">
  42. <div class="b_b_operation">
  43. <div class="b_b_o_left">
  44. <span
  45. >当前进度 {{ progress }}/{{
  46. dataList.filter(
  47. i =>
  48. selectStatus == "99" ||
  49. statusList
  50. .find(i => i.value == selectStatus)
  51. .allow.includes(i.status)
  52. ).length
  53. }}</span
  54. >
  55. </div>
  56. <div class="b_b_o_right">
  57. <div>
  58. <el-checkbox v-model="selectAll" :indeterminate="indeterminate"
  59. >全选</el-checkbox
  60. >
  61. </div>
  62. <span>
  63. <span @click="exportDoc" style="color:#409EFF"
  64. >批量导出doc</span
  65. >
  66. </span>
  67. <span>
  68. <span @click="regenerateTheReport" style="color:#409EFF"
  69. >批量重新生成报告</span
  70. >
  71. </span>
  72. <span>
  73. <span @click="delSelectBtn" style="color: red;">删除</span>
  74. <!-- <img
  75. @click="delSelectBtn"
  76. src="../../../../assets/icon/classroomObservation/del2.svg"
  77. /> -->
  78. </span>
  79. </div>
  80. </div>
  81. <div class="b_b_list">
  82. <batchClassCard
  83. v-for="item in dataList"
  84. :data="item"
  85. :isSelect="selectList.includes(item.id)"
  86. :key="item.id"
  87. v-show="
  88. selectStatus === '99' ||
  89. statusList
  90. .find(i => i.value === selectStatus)
  91. .allow.includes(item.status)
  92. "
  93. @changeChecked="changeCardChecked"
  94. @editBaseMessage="editBaseMessage"
  95. @changeData="changeData"
  96. @taskBtn="taskBtn"
  97. @goToEdit="goToEdit"
  98. />
  99. </div>
  100. </div>
  101. </div>
  102. <uploadFileToCreateClassDialog
  103. ref="uploadFileToCreateClassDialogRef"
  104. @success="uploadFileSuccess"
  105. />
  106. <editBaseMessageDialog
  107. ref="editBaseMessageDialogRef"
  108. @success="editBaseMessageSuccess"
  109. />
  110. </el-dialog>
  111. <!-- 录音转文字 -->
  112. <iframe
  113. allow="camera *; microphone *;display-capture;midi;encrypted-media;"
  114. src="https://beta.cloud.cocorobo.cn/browser/public/index.html"
  115. ref="iframeRef"
  116. v-show="false"
  117. ></iframe>
  118. </div>
  119. </template>
  120. <script>
  121. import batchClassCard from "../newComponents/batchClassCard.vue";
  122. import uploadFileToCreateClassDialog from "./uploadFileToCreateClassDialog.vue";
  123. import editBaseMessageDialog from "./editBaseMessageDialog.vue";
  124. import { v4 as uuidv4 } from "uuid";
  125. import { toolMixin } from "../tools/mixin";
  126. import JSZip from "jszip";
  127. export default {
  128. mixins: [toolMixin],
  129. components: {
  130. batchClassCard,
  131. uploadFileToCreateClassDialog,
  132. editBaseMessageDialog
  133. },
  134. data() {
  135. return {
  136. statusList: [
  137. { label: "全部", value: "99", allow: [] },
  138. { label: "已完成", value: "2", allow: ["2"] },
  139. { label: "处理中", value: "1", allow: ["1"] },
  140. { label: "等待处理", value: "0", allow: ["0"] },
  141. { label: "待开始", value: "3", allow: ["3"] }
  142. ],
  143. userId: this.$route.query["userid"],
  144. selectStatus: "99",
  145. show: false,
  146. selectList: [],
  147. dataList: [],
  148. nowDoTaskId: [],
  149. dialogTagDataList: []
  150. };
  151. },
  152. computed: {
  153. selectAll: {
  154. get() {
  155. let _result = false;
  156. let _data = this.dataList.filter(
  157. i =>
  158. this.selectStatus === "99" ||
  159. this.statusList
  160. .find(i2 => i2.value === this.selectStatus)
  161. .allow.includes(i.status)
  162. );
  163. if (_data.length > 0 && _data.length === this.selectList.length) {
  164. _result = true;
  165. }
  166. return _result;
  167. },
  168. set(value) {
  169. if (value) {
  170. this.selectList = this.dataList
  171. .filter(
  172. i =>
  173. this.selectStatus === "99" ||
  174. this.statusList
  175. .find(i2 => i2.value === this.selectStatus)
  176. .allow.includes(i.status)
  177. )
  178. .map(i => i.id);
  179. this.$forceUpdate();
  180. } else {
  181. this.selectList = [];
  182. }
  183. }
  184. },
  185. indeterminate() {
  186. let _result = false;
  187. let _data = this.dataList.filter(
  188. i =>
  189. this.selectStatus === "99" ||
  190. this.statusList
  191. .find(i2 => i2.value === this.selectStatus)
  192. .allow.includes(i.status)
  193. );
  194. if (_data.length > this.selectList.length && this.selectList.length > 0) {
  195. _result = true;
  196. }
  197. return _result;
  198. },
  199. progress() {
  200. return this.dataList.filter(
  201. i =>
  202. i.status == "2" &&
  203. (this.selectStatus == "99" ||
  204. this.statusList
  205. .find(i2 => i2.value == this.selectStatus)
  206. .allow.includes(i.status))
  207. ).length;
  208. }
  209. },
  210. methods: {
  211. open() {
  212. this.show = true;
  213. },
  214. close() {
  215. this.show = false;
  216. },
  217. init() {},
  218. changeStatus(newValue) {
  219. this.selectStatus = newValue;
  220. this.selectList = [];
  221. },
  222. uploadFile() {
  223. this.$refs.uploadFileToCreateClassDialogRef.open();
  224. },
  225. //批量上传文件成功
  226. async uploadFileSuccess(data) {
  227. this.$refs.uploadFileToCreateClassDialogRef.close();
  228. let { fileList, automaticCoding, analysisTemplate } = data;
  229. this.loading = true;
  230. let fileDataList = fileList.map(i => i.successData);
  231. let _tempData = await this.getTemplateData(analysisTemplate[1]);
  232. let _analysisList = JSON.parse(_tempData.tips);
  233. let tagList = _analysisList.find(i => i.isOtherData);
  234. if (!tagList) {
  235. tagList = [
  236. { value: 0, name: "通用课堂分析", loading: false },
  237. { value: 1, name: "学科课堂分析", loading: false },
  238. { value: 2, name: "扩展分析", loading: false }
  239. ];
  240. } else {
  241. tagList = tagList.dialogTagList;
  242. }
  243. let batch = uuidv4();
  244. _analysisList = _analysisList.filter(
  245. i => !i.isOtherData && i.jsonData.name != "词频词汇分析"
  246. );
  247. _analysisList.forEach(i => {
  248. if (i.jsonData.spectrogramData) {
  249. delete i.jsonData.spectrogramData;
  250. }
  251. });
  252. let promiseList = [];
  253. fileDataList.forEach(i => {
  254. let data = {
  255. id: uuidv4(),
  256. create_at: "2025-05-07 16.05.03",
  257. remarks: "",
  258. batch: batch,
  259. status: "0",
  260. createId: "",
  261. jsonData: {
  262. file_ids: "",
  263. baseMessage: {
  264. courseName: i.name,
  265. teacherName: "老师",
  266. time: this.getFileLastUpdateTime(i.fileObj),
  267. grade: "小学五年级",
  268. subject: "科学",
  269. textbook: "教科版",
  270. studentNum: 45,
  271. imageList: {
  272. fileList: [],
  273. fileList1: [],
  274. fileList2: [],
  275. fileList3: [],
  276. name: "课堂记录",
  277. NephogramList: [],
  278. videoList: []
  279. }
  280. },
  281. tagList: tagList,
  282. steps: [],
  283. analysisList: _analysisList,
  284. fileData: i,
  285. automaticCoding: automaticCoding
  286. }
  287. };
  288. if (i.type == "text/plain") {
  289. data.jsonData.steps = [
  290. {
  291. type: "uploadFile",
  292. text: "上传文件",
  293. status: "1"
  294. },
  295. {
  296. type: "transcription",
  297. text: "文本转录",
  298. status: "0",
  299. progress: "0"
  300. }
  301. ];
  302. if (data.jsonData.automaticCoding) {
  303. data.jsonData.steps.push({
  304. type: "automaticCoding",
  305. text: "自动编码"
  306. });
  307. }
  308. data.jsonData.steps.push(
  309. ...[
  310. {
  311. type: "getFileIds",
  312. text: "获取文件fileid",
  313. status: "0"
  314. },
  315. {
  316. type: "getWordCloudMap",
  317. text: "获取词云图",
  318. status: "0"
  319. },
  320. {
  321. type: "generateReport",
  322. text: "生成报告",
  323. status: "0",
  324. progress: "0",
  325. num: _analysisList.length,
  326. successNum: 0
  327. },
  328. {
  329. type: "createClass",
  330. text: "创建课堂",
  331. status: "0",
  332. progress: "0"
  333. }
  334. ]
  335. );
  336. } else if (
  337. ["audio/wav", "audio/x-m4a", "audio/mpeg"].includes(i.type)
  338. ) {
  339. data.jsonData.baseMessage.imageList.fileList = [
  340. {
  341. name: i.name,
  342. status: "success",
  343. url: i.url,
  344. uid: "1"
  345. }
  346. ];
  347. data.jsonData.steps = [
  348. {
  349. type: "uploadFile",
  350. text: "上传文件",
  351. status: "1"
  352. },
  353. {
  354. type: "transcription",
  355. text: "文本转录",
  356. status: "0",
  357. progress: "0"
  358. }
  359. ];
  360. if (data.jsonData.automaticCoding) {
  361. data.jsonData.steps.push({
  362. type: "automaticCoding",
  363. text: "自动编码",
  364. status: "0",
  365. progress: "0"
  366. });
  367. }
  368. data.jsonData.steps.push(
  369. ...[
  370. {
  371. type: "getFileIds",
  372. text: "获取文件fileid",
  373. status: "0"
  374. },
  375. {
  376. type: "getWordCloudMap",
  377. text: "获取词云图",
  378. status: "0"
  379. },
  380. {
  381. type: "generateReport",
  382. text: "生成报告",
  383. status: "0",
  384. progress: "0",
  385. num: _analysisList.length,
  386. successNum: 0
  387. },
  388. {
  389. type: "createClass",
  390. text: "创建课堂",
  391. status: "0",
  392. progress: "0"
  393. }
  394. ]
  395. );
  396. } else if (i.type == "video/mp4") {
  397. data.jsonData.baseMessage.imageList.videoList = [
  398. {
  399. name: i.name,
  400. status: "success",
  401. url: i.url,
  402. uid: "1"
  403. }
  404. ];
  405. data.jsonData.steps = [
  406. {
  407. type: "uploadFile",
  408. text: "上传文件",
  409. status: "1"
  410. },
  411. {
  412. type: "getVideoVoice",
  413. text: "视频提取音频",
  414. status: "0",
  415. progress: "0"
  416. },
  417. {
  418. type: "transcription",
  419. text: "文本转录",
  420. status: "0",
  421. progress: "0"
  422. }
  423. ];
  424. if (data.jsonData.automaticCoding) {
  425. data.jsonData.steps.push({
  426. type: "automaticCoding",
  427. text: "自动编码",
  428. status: "0",
  429. progress: "0"
  430. });
  431. }
  432. data.jsonData.steps.push(
  433. ...[
  434. {
  435. type: "getFileIds",
  436. text: "获取文件fileid",
  437. status: "0"
  438. },
  439. {
  440. type: "getWordCloudMap",
  441. text: "获取词云图",
  442. status: "0"
  443. },
  444. {
  445. type: "generateReport",
  446. text: "生成报告",
  447. status: "0",
  448. progress: "0",
  449. num: _analysisList.length,
  450. successNum: 0
  451. },
  452. {
  453. type: "createClass",
  454. text: "创建课堂",
  455. status: "0",
  456. progress: "0"
  457. }
  458. ]
  459. );
  460. }
  461. promiseList.push(
  462. new Promise((resolve, reject) => {
  463. // 本地保存fileObj
  464. const fileObj = data.jsonData.fileData.fileObj;
  465. delete data.jsonData.fileData.fileObj;
  466. const params = [
  467. {
  468. remarks: data.remarks,
  469. status: "3",
  470. json: JSON.stringify(data.jsonData),
  471. batch: data.batch,
  472. createId: data.createId,
  473. userId: this.userId
  474. }
  475. ];
  476. console.log(params);
  477. this.ajax
  478. .post(this.$store.state.api + "insert_classroomTask", params)
  479. .then(res => {
  480. const _data = res.data[0][0];
  481. if (_data.id) {
  482. data.jsonData.fileData.fileObj = fileObj;
  483. data.id = _data.id;
  484. this.dataList.unshift(data);
  485. }
  486. resolve();
  487. })
  488. .catch(err => {
  489. console.error(err);
  490. reject(err);
  491. });
  492. })
  493. );
  494. });
  495. console.log(promiseList);
  496. Promise.all(promiseList)
  497. .then(res => {
  498. this.$message.success("创建成功");
  499. if (!this.dataList.find(i => i.status == 1)) {
  500. this.startTask(this.dataList.find(i => i.status === "0").id);
  501. }
  502. })
  503. .catch(err => {
  504. console.log("创建出错", err);
  505. });
  506. },
  507. //获取模板的数据
  508. getTemplateData(tid) {
  509. return new Promise(resolve => {
  510. let params = {
  511. uid: this.userId,
  512. cid: tid,
  513. st: 0
  514. };
  515. this.ajax
  516. .get(this.$store.state.api + "selectClassroomTemplateDetail", params)
  517. .then(res => {
  518. let _data = res.data[0][0];
  519. resolve(_data);
  520. });
  521. });
  522. },
  523. changeCardChecked({ type = 0, id }) {
  524. if (type === 0 && !this.selectList.includes(id)) {
  525. this.selectList.push(id);
  526. } else if (type === 1 && this.selectList.push(id)) {
  527. this.selectList = this.selectList.filter(i => i != id);
  528. }
  529. },
  530. //修改课堂的baseMessage按钮
  531. editBaseMessage(id) {
  532. let _data = this.dataList.find(i => i.id === id);
  533. if (_data) {
  534. this.$refs.editBaseMessageDialogRef.open({
  535. editId: _data.id,
  536. message: _data.jsonData.baseMessage
  537. });
  538. } else {
  539. this.$message.error("未查询到该数据");
  540. }
  541. },
  542. //修改课堂的baseMessage
  543. editBaseMessageSuccess({ editId, message }) {
  544. if (editId) {
  545. let _editorBarData = null;
  546. let _transcriptionData = null;
  547. if (
  548. this.dataList.find(i => i.id === editId).jsonData.baseMessage
  549. .editorBarData
  550. ) {
  551. _editorBarData = this.dataList.find(i => i.id === editId).jsonData
  552. .baseMessage.editorBarData;
  553. }
  554. if (
  555. this.dataList.find(i => i.id === editId).jsonData.baseMessage
  556. .transcriptionData
  557. ) {
  558. _transcriptionData = this.dataList.find(i => i.id === editId).jsonData
  559. .baseMessage.transcriptionData;
  560. }
  561. this.dataList.find(i => i.id === editId).jsonData.baseMessage = message;
  562. if (_editorBarData) {
  563. this.dataList.find(
  564. i => i.id === editId
  565. ).jsonData.baseMessage.editorBarData = _editorBarData;
  566. }
  567. if (_transcriptionData) {
  568. this.dataList.find(
  569. i => i.id === editId
  570. ).jsonData.baseMessage.transcriptionData = _transcriptionData;
  571. }
  572. this.$forceUpdate();
  573. this.$refs.editBaseMessageDialogRef.close();
  574. this.updateTask(editId);
  575. }
  576. },
  577. // 删除选择的数据
  578. delSelectBtn() {
  579. let _delList = this.dataList.filter(
  580. i =>
  581. this.selectList.includes(i.id) &&
  582. (this.selectStatus === "99" ||
  583. this.statusList
  584. .find(i2 => i2.value === this.selectStatus)
  585. .allow.includes(i.status))
  586. );
  587. if (_delList.length <= 0) return this.$message.info("请先选择列表");
  588. this.$confirm("您确定要删除选中的数据吗?", "提示", {
  589. confirmButtonText: "确定",
  590. cancelButtonText: "取消",
  591. type: "warning"
  592. })
  593. .then(() => {
  594. // 确定删除
  595. let params = [
  596. {
  597. idList: _delList.map(i => i.id).join(","),
  598. userId: this.userId
  599. }
  600. ];
  601. this.ajax
  602. .post(this.$store.state.api + "delete_classroomTask", params)
  603. .then(res => {
  604. if (res.data > 0) {
  605. this.$message.success("删除成功");
  606. this.dataList = this.dataList.filter(
  607. i => !_delList.find(del => del.id === i.id)
  608. );
  609. this.selectList = [];
  610. }
  611. })
  612. .catch(err => {
  613. console.log(err);
  614. this.$message.error("删除失败");
  615. });
  616. })
  617. .catch(() => {
  618. // 取消删除
  619. });
  620. },
  621. //获取任务列表
  622. getTaskList() {
  623. let params = {
  624. userId: this.userId
  625. };
  626. this.ajax
  627. .get(this.$store.state.api + "select_classroomTask", params)
  628. .then(res => {
  629. let _data = res.data[0];
  630. if (_data.length > 0) {
  631. _data.forEach(i => (i.jsonData = JSON.parse(i.jsonData)));
  632. this.dataList = _data;
  633. }
  634. });
  635. },
  636. //获取所有的模块分析
  637. getDialogTagDataList() {
  638. let params = {
  639. uid: this.userId
  640. };
  641. this.ajax
  642. .get(this.$store.state.api + "select_smodel", params)
  643. .then(res => {
  644. let _result = res.data[0];
  645. this.dialogTagDataList = _result;
  646. })
  647. .catch(e => {
  648. console.log(e);
  649. this.$message.error("获取模块分析列表失败");
  650. });
  651. },
  652. updateTask(id) {
  653. return new Promise((resolve, reject) => {
  654. let _data = this.dataList.find(i => i.id === id);
  655. if (_data) {
  656. const dataCopy = JSON.parse(JSON.stringify(_data));
  657. if (dataCopy.jsonData.fileData.fileObj) {
  658. delete dataCopy.jsonData.fileData.fileObj;
  659. }
  660. if (
  661. dataCopy.jsonData.baseMessage.editorBarData &&
  662. dataCopy.jsonData.baseMessage.editorBarData.content
  663. ) {
  664. delete dataCopy.jsonData.baseMessage.editorBarData.content;
  665. }
  666. if (
  667. dataCopy.jsonData.baseMessage.editorBarData &&
  668. dataCopy.jsonData.baseMessage.editorBarData.tableList
  669. ) {
  670. delete dataCopy.jsonData.baseMessage.editorBarData.tableList;
  671. }
  672. if (dataCopy.jsonData.errorMessage) {
  673. delete dataCopy.jsonData.errorMessage;
  674. }
  675. console.log("dataCopy", dataCopy);
  676. let params = [
  677. {
  678. id: dataCopy.id,
  679. userId: this.userId,
  680. remarks: dataCopy.remarks,
  681. status: ["0", "1"].includes(dataCopy.status)
  682. ? "3"
  683. : dataCopy.status,
  684. json: JSON.stringify(dataCopy.jsonData),
  685. createId: dataCopy.createId,
  686. batch: dataCopy.batch
  687. }
  688. ];
  689. this.ajax
  690. .post(this.$store.state.api + "update_classroomTask", params)
  691. .then(res => {
  692. if (res.data == 1) {
  693. console.log("修改任务成功");
  694. resolve();
  695. } else {
  696. reject();
  697. this.$message.error("修改任务失败");
  698. }
  699. })
  700. .catch(err => {
  701. console.log(err);
  702. this.$message.error("修改任务失败");
  703. reject();
  704. });
  705. }
  706. });
  707. },
  708. changeData({ field, data }) {
  709. let _index = this.dataList.findIndex(i => i.id === data.id);
  710. if (_index != -1) {
  711. if (this.dataList[_index][field] != data[field]) {
  712. this.dataList[_index][field] = data[field];
  713. this.updateTask(this.dataList[_index].id);
  714. }
  715. }
  716. },
  717. taskBtn(obj) {
  718. let { type, id } = obj;
  719. if (type === "startTask" && id) {
  720. // this.startTask(id);
  721. if (
  722. this.dataList.some(i => i.status === "1") &&
  723. this.dataList.find(i => i.id === id).status === "0"
  724. ) {
  725. this.$confirm(
  726. "您确定要开始该任务嘛?其他已开始的任务会暂停。",
  727. "提示",
  728. {
  729. confirmButtonText: "确定",
  730. cancelButtonText: "取消",
  731. type: "warning"
  732. }
  733. )
  734. .then(() => {
  735. this.startTask(id);
  736. })
  737. .catch(() => {
  738. console.log("不暂停");
  739. });
  740. } else {
  741. this.startTask(id);
  742. }
  743. } else if (type === "stopTask" && id) {
  744. this.$confirm("您确定要停止该任务吗?", "提示", {
  745. confirmButtonText: "确定",
  746. cancelButtonText: "取消",
  747. type: "warning"
  748. })
  749. .then(() => {
  750. this.stopTask(id);
  751. })
  752. .catch(() => {
  753. console.log("不暂停");
  754. });
  755. } else if (type === "pauseTask" && id) {
  756. this.$confirm("您确定要暂停该任务吗?", "提示", {
  757. confirmButtonText: "确定",
  758. cancelButtonText: "取消",
  759. type: "warning"
  760. })
  761. .then(() => {
  762. this.pauseTask(id);
  763. })
  764. .catch(() => {
  765. console.log("不暂停");
  766. });
  767. } else if (type === "regenerateTheReport" && id) {
  768. this.$confirm("您确定要重新生成任报告吗?。", "提示", {
  769. confirmButtonText: "确定",
  770. cancelButtonText: "取消",
  771. type: "warning"
  772. })
  773. .then(() => {
  774. this.dataList.find(i => i.id === id).status = "0";
  775. this.dataList
  776. .find(i => i.id === id)
  777. .jsonData.steps.find(i => i.type == "generateReport").status =
  778. "0";
  779. this.dataList.find(i => i.id === id).jsonData.steps.find(i => i.type == "generateReport").successNum = 0;
  780. this.dataList
  781. .find(i => i.id === id)
  782. .jsonData.steps.find(i => i.type == "createClass").status =
  783. "0";
  784. if (!this.dataList.some(i => i.status == "1")) {
  785. this.startTask(id);
  786. }
  787. })
  788. .catch(() => {
  789. console.log("不暂停");
  790. });
  791. }
  792. },
  793. async startTask(id) {
  794. let _isStartTaskIndex = this.dataList.findIndex(i => i.status === "1");
  795. let _needStartTaskIndex = this.dataList.findIndex(i => i.id === id);
  796. if (_isStartTaskIndex === -1) {
  797. //没有任务在进行,直接开始处理
  798. this.dataList[_needStartTaskIndex].status = "1"; //处理中
  799. } else if (
  800. this.dataList[_needStartTaskIndex].status === "3" &&
  801. _isStartTaskIndex !== -1
  802. ) {
  803. //有任务在进行,且这个任务是从待开始状态到开始状态,等待处理
  804. this.dataList[_needStartTaskIndex].status = "0";
  805. } else if (
  806. _isStartTaskIndex !== -1 &&
  807. this.dataList[_needStartTaskIndex].status === "0"
  808. ) {
  809. //有任务在进行,且这个任务是从等待状态到开始状态,停止现任务,开始新任务
  810. this.nowDoTaskId = this.nowDoTaskId.filter(
  811. i => i !== this.dataList[_isStartTaskIndex].id
  812. );
  813. this.dataList[_isStartTaskIndex].status = "0"; //
  814. this.dataList[_needStartTaskIndex].status = "1"; //处理中
  815. }
  816. if (
  817. !this.nowDoTaskId.includes(this.dataList.find(i => i.status === "1").id)
  818. ) {
  819. let _startData = JSON.parse(
  820. JSON.stringify(this.dataList.find(i => i.status === "1"))
  821. );
  822. if (
  823. this.dataList.find(i => i.id === _startData.id).jsonData.fileData
  824. .fileObj
  825. ) {
  826. _startData.jsonData.fileData.fileObj = this.dataList.find(
  827. i => i.id === _startData.id
  828. ).jsonData.fileData.fileObj;
  829. }
  830. this.nowDoTaskId.push(_startData.id);
  831. let _stepList = _startData.jsonData.steps;
  832. for (let i = 0; i < _stepList.length; i++) {
  833. //按顺序处理任务
  834. let _step = _stepList[i];
  835. console.log(_step);
  836. if (!this.nowDoTaskId.includes(_startData.id)){
  837. if (
  838. this.dataList.find(i => i.id === _startData.id).status == "1"
  839. ) {
  840. this.dataList.find(i => i.id === _startData.id).status = "0";
  841. if (this.dataList.find(i => i.status == "0")) {
  842. let id = this.dataList.find(i => i.status == "0").id;
  843. this.startTask(id);
  844. }
  845. }
  846. break;
  847. };
  848. if (_step.status == "1") {
  849. if (_step.type == "createClass") {
  850. if (
  851. this.dataList.find(i => i.id === _startData.id).status == "1"
  852. ) {
  853. this.dataList.find(i => i.id === _startData.id).status = "2";
  854. this.updateTask(_startData.id);
  855. if (this.dataList.find(i => i.status == "0")) {
  856. let id = this.dataList.find(i => i.status == "0").id;
  857. this.startTask(id);
  858. }
  859. }
  860. break;
  861. } else {
  862. continue;
  863. }
  864. }
  865. if (_step.type === "uploadFile") continue;
  866. if (_step.type === "getVideoVoice") {
  867. //视频提取音频
  868. _stepList[i].status = "2";
  869. _stepList[i].startTime =
  870. new Date().toLocaleDateString().replaceAll("/", "-") +
  871. " " +
  872. new Date().toLocaleTimeString();
  873. this.dataList.find(
  874. i => i.id === _startData.id
  875. ).jsonData.steps = _stepList;
  876. this.$forceUpdate()
  877. let _fileData = _startData.jsonData.fileData;
  878. let audioFile = await this.getVideoToVoiceAndUploadMixin(_fileData);
  879. if (audioFile.data == 3) {
  880. this.dataList.find(
  881. i => i.id === _startData.id
  882. ).jsonData.errorMessage = {
  883. content: "视频提取音频失败",
  884. err: audioFile.err
  885. };
  886. this.dataList.find(i => i.id === _startData.id).status = "3";
  887. if (this.dataList.find(i => i.status == "0")) {
  888. let id = this.dataList.find(i => i.status == "0").id;
  889. this.startTask(id);
  890. }
  891. break;
  892. }
  893. if (!this.nowDoTaskId.includes(_startData.id)) break;
  894. _startData.jsonData.fileData.videoUrl = _fileData.url;
  895. _startData.jsonData.fileData.fileObj = audioFile.fileObj;
  896. _startData.jsonData.fileData.url = audioFile.audioUrl.Location;
  897. _startData.jsonData.baseMessage.imageList.fileList = [
  898. {
  899. name: _fileData.name,
  900. status: "success",
  901. url: audioFile.Location,
  902. uid: "1"
  903. }
  904. ];
  905. _stepList[i].status = "1";
  906. this.dataList.find(i => i.id === _startData.id).jsonData =
  907. _startData.jsonData;
  908. this.updateTask(_startData.id);
  909. _startData.jsonData = JSON.parse(
  910. JSON.stringify(
  911. this.dataList.find(i => i.id === _startData.id).jsonData
  912. )
  913. );
  914. _startData.jsonData.fileData.fileObj = audioFile.fileObj; //防止文件因为json失效
  915. console.log("data👉", JSON.parse(JSON.stringify(_startData)));
  916. console.log(`${_startData.id}:已完成视频转音频`);
  917. } else if (_step.type === "transcription") {
  918. //文本转录
  919. const fileData = _startData.jsonData.fileData;
  920. if (fileData.type === "text/plain") {
  921. //txt文件
  922. _stepList[i].status = "2";
  923. _stepList[i].startTime =
  924. new Date().toLocaleDateString().replaceAll("/", "-") +
  925. " " +
  926. new Date().toLocaleTimeString();
  927. this.dataList.find(
  928. i => i.id === _startData.id
  929. ).jsonData.steps = _stepList;
  930. this.$forceUpdate()
  931. let { editorBarData } = await this.getTextContentMixin(fileData);
  932. if (!this.nowDoTaskId.includes(_startData.id)) break;
  933. this.dataList.find(
  934. i => i.id === _startData.id
  935. ).jsonData.baseMessage.editorBarData = editorBarData;
  936. _stepList[i].status = "1";
  937. this.dataList.find(
  938. i => i.id === _startData.id
  939. ).jsonData.steps = _stepList;
  940. this.updateTask(_startData.id);
  941. _startData.jsonData = JSON.parse(
  942. JSON.stringify(
  943. this.dataList.find(i => i.id === _startData.id).jsonData
  944. )
  945. );
  946. console.log(`${_startData.id}:已获取转录文稿(txt)`);
  947. console.log("data👉", JSON.parse(JSON.stringify(_startData)));
  948. } else if (
  949. ["video/mp4", "audio/wav", "audio/x-m4a", "audio/mpeg"].includes(
  950. fileData.type
  951. )
  952. ) {
  953. //mp4与wav文件
  954. _stepList[i].status = "2";
  955. _stepList[i].startTime =
  956. new Date().toLocaleDateString().replaceAll("/", "-") +
  957. " " +
  958. new Date().toLocaleTimeString();
  959. this.dataList.find(
  960. i => i.id === _startData.id
  961. ).jsonData.steps = _stepList;
  962. this.$forceUpdate()
  963. let _file = _startData.jsonData.fileData.fileObj;
  964. if (!_file && JSON.stringify(_file) != "{}") {
  965. let fileBody = await this.getFileBody(
  966. _startData.jsonData.fileData.url
  967. );
  968. let _type = _startData.jsonData.fileData.type.split("/")[1];
  969. if (_type == "x-m4a") {
  970. _type = "m4a";
  971. } else if (_type == "mpeg") {
  972. _type = "mp3";
  973. }
  974. _file = new File([fileBody.data], `audio.${_type}`, {
  975. type: _startData.jsonData.fileData.type
  976. });
  977. }
  978. // 只对m4a文件进行转wav,mp3文件不再转码
  979. if (_file.type === "audio/x-m4a") {
  980. let _data = await this.audioToWavMixin(_file);
  981. if (_data !== 1) {
  982. _file = _data.data;
  983. } else {
  984. console.log("报错👉", _data);
  985. if (this.dataList.find(i => i.status == "0")) {
  986. let id = this.dataList.find(i => i.status == "0").id;
  987. this.startTask(id);
  988. }
  989. break;
  990. }
  991. }
  992. console.log("转录文件", _file);
  993. let {
  994. transcriptionContent,
  995. editorBarData,
  996. data
  997. } = await this.wavAudioToTextAndObjMixin(_file);
  998. if (data === 1) {
  999. //转录失败,直接退出
  1000. if (this.dataList.find(i => i.status == "0")) {
  1001. let id = this.dataList.find(i => i.status == "0").id;
  1002. this.startTask(id);
  1003. }
  1004. break;
  1005. }
  1006. this.dataList.find(
  1007. i => i.id === _startData.id
  1008. ).jsonData.baseMessage.transcriptionData = transcriptionContent;
  1009. this.dataList.find(
  1010. i => i.id === _startData.id
  1011. ).jsonData.baseMessage.editorBarData = editorBarData;
  1012. _stepList[i].status = "1";
  1013. this.dataList.find(
  1014. i => i.id === _startData.id
  1015. ).jsonData.steps = _stepList;
  1016. this.updateTask(_startData.id);
  1017. _startData.jsonData = JSON.parse(
  1018. JSON.stringify(
  1019. this.dataList.find(i => i.id === _startData.id).jsonData
  1020. )
  1021. );
  1022. console.log(`${_startData.id}:已获取转录文稿(mp4/wav)`);
  1023. }
  1024. } else if (_step.type === "automaticCoding") {
  1025. if (_startData.jsonData.automaticCoding) {
  1026. const fileData = _startData.jsonData.fileData;
  1027. _stepList[i].status = "2";
  1028. _stepList[i].startTime =
  1029. new Date().toLocaleDateString().replaceAll("/", "-") +
  1030. " " +
  1031. new Date().toLocaleTimeString();
  1032. this.dataList.find(
  1033. i => i.id === _startData.id
  1034. ).jsonData.steps = _stepList;
  1035. this.$forceUpdate()
  1036. //选择了字段编码
  1037. let _content =
  1038. _startData.jsonData.baseMessage.editorBarData.content;
  1039. let _tableList =
  1040. _startData.jsonData.baseMessage.editorBarData.table;
  1041. if (!_content) {
  1042. _content = await this.getFile(
  1043. _startData.jsonData.baseMessage.editorBarData.url
  1044. );
  1045. _content = _content.data;
  1046. this.dataList.find(
  1047. i => i.id === _startData.id
  1048. ).jsonData.baseMessage.editorBarData.content = _content;
  1049. }
  1050. if (!_tableList) {
  1051. let _result = [];
  1052. let _data = _content;
  1053. let _div = document.createElement("div");
  1054. _div.innerHTML = _data;
  1055. let _tableRows = _div.querySelectorAll(`table tbody tr`);
  1056. _tableRows.forEach((i, index) => {
  1057. if (index == 0) return;
  1058. let obj = {
  1059. index: i.cells[0].textContent,
  1060. startTime: i.cells[1].textContent,
  1061. endTime: i.cells[2].textContent,
  1062. value: i.cells[3].textContent,
  1063. time: i.cells[4].textContent,
  1064. role: i.cells[5] ? i.cells[5].textContent : "",
  1065. code: i.cells[6] ? i.cells[6].textContent : ""
  1066. };
  1067. _result.push(obj);
  1068. });
  1069. _tableList = _result;
  1070. }
  1071. let editorBarData = "";
  1072. if (fileData.type == "text/plain") {
  1073. let _result = await this.automaticCodingForTextMixin({
  1074. tableList: _tableList
  1075. });
  1076. editorBarData = _result.editorBarData;
  1077. } else {
  1078. let _result = await this.automaticCodingMixin({
  1079. tableList: _tableList
  1080. });
  1081. editorBarData = _result.editorBarData;
  1082. }
  1083. if (!this.nowDoTaskId.includes(_startData.id)) break;
  1084. _stepList[i].status = "1";
  1085. this.dataList.find(i => i.id === _startData.id).jsonData =
  1086. _startData.jsonData;
  1087. this.dataList.find(
  1088. i => i.id === _startData.id
  1089. ).jsonData.baseMessage.editorBarData = editorBarData;
  1090. this.dataList.find(
  1091. i => i.id === _startData.id
  1092. ).jsonData.steps = _stepList;
  1093. this.updateTask(_startData.id);
  1094. _startData.jsonData = JSON.parse(
  1095. JSON.stringify(
  1096. this.dataList.find(i => i.id === _startData.id).jsonData
  1097. )
  1098. );
  1099. console.log("data👉", JSON.parse(JSON.stringify(_startData)));
  1100. console.log(`${_startData.id}:已获完成自动编码`);
  1101. // }
  1102. } else {
  1103. _stepList[i].status = "1";
  1104. this.dataList.find(
  1105. i => i.id === _startData.id
  1106. ).jsonData.steps = _stepList;
  1107. this.updateTask(_startData.id);
  1108. _startData.jsonData = JSON.parse(
  1109. JSON.stringify(
  1110. this.dataList.find(i => i.id === _startData.id).jsonData
  1111. )
  1112. );
  1113. }
  1114. } else if (_step.type === "getFileIds") {
  1115. //文件获取fileId
  1116. _stepList[i].status = "2";
  1117. _stepList[i].startTime =
  1118. new Date().toLocaleDateString().replaceAll("/", "-") +
  1119. " " +
  1120. new Date().toLocaleTimeString();
  1121. this.dataList.find(
  1122. i => i.id === _startData.id
  1123. ).jsonData.steps = _stepList;
  1124. this.$forceUpdate()
  1125. let _fileData = _startData.jsonData.baseMessage.editorBarData;
  1126. let { fileId } = await this.getFileIdMixin(_fileData.url);
  1127. if (!this.nowDoTaskId.includes(_startData.id)) break;
  1128. this.dataList.find(
  1129. i => i.id === _startData.id
  1130. ).jsonData.file_ids = fileId;
  1131. _stepList[i].status = "1";
  1132. this.dataList.find(
  1133. i => i.id === _startData.id
  1134. ).jsonData.steps = _stepList;
  1135. this.updateTask(_startData.id);
  1136. _startData.jsonData = JSON.parse(
  1137. JSON.stringify(
  1138. this.dataList.find(i => i.id === _startData.id).jsonData
  1139. )
  1140. );
  1141. console.log("data👉", JSON.parse(JSON.stringify(_startData)));
  1142. console.log(`${_startData.id}:已获取fileId`);
  1143. } else if (_step.type == "getWordCloudMap") {
  1144. //文件获取fileId
  1145. _stepList[i].status = "2";
  1146. _stepList[i].startTime =
  1147. new Date().toLocaleDateString().replaceAll("/", "-") +
  1148. " " +
  1149. new Date().toLocaleTimeString();
  1150. this.dataList.find(
  1151. i => i.id === _startData.id
  1152. ).jsonData.steps = _stepList;
  1153. this.$forceUpdate()
  1154. let _fileData = _startData.jsonData.baseMessage.editorBarData;
  1155. let _content = await this.getFile(_fileData.url);
  1156. let _result = await this.getWordCloudMapMixin(_content.data);
  1157. this.dataList
  1158. .find(i => i.id === _startData.id)
  1159. .jsonData.baseMessage.imageList.NephogramList.push(_result);
  1160. _stepList[i].status = "1";
  1161. this.dataList.find(
  1162. i => i.id === _startData.id
  1163. ).jsonData.steps = _stepList;
  1164. this.updateTask(_startData.id);
  1165. _startData.jsonData = JSON.parse(
  1166. JSON.stringify(
  1167. this.dataList.find(i => i.id === _startData.id).jsonData
  1168. )
  1169. );
  1170. } else if (_step.type === "generateReport") {
  1171. //生成报告
  1172. _stepList[i].status = "2";
  1173. _stepList[i].successNum = 0;
  1174. _stepList[i].startTime =
  1175. new Date().toLocaleDateString().replaceAll("/", "-") +
  1176. " " +
  1177. new Date().toLocaleTimeString();
  1178. this.dataList.find(
  1179. i => i.id === _startData.id
  1180. ).jsonData.steps = _stepList;
  1181. let _i = i;
  1182. this.$forceUpdate()
  1183. let _analysisList = _startData.jsonData.analysisList;
  1184. let promises = [];
  1185. let _content =
  1186. _startData.jsonData.baseMessage.editorBarData.content;
  1187. if (!_content) {
  1188. _content = await this.getFile(
  1189. _startData.jsonData.baseMessage.editorBarData.url
  1190. );
  1191. _content = _content.data;
  1192. _startData.jsonData.baseMessage.editorBarData.content = _content;
  1193. }
  1194. console.log(_analysisList.length)
  1195. promises = _analysisList.map((i, index) => {
  1196. return new Promise(async resolve => {
  1197. _startData.jsonData.analysisList[index].status = "default"; //默认状态
  1198. let _num = 0;
  1199. let _maxNum = 5;
  1200. const getAnalysis = async () => {
  1201. if (
  1202. ["tryAgainMax", "noAgentData"].includes(
  1203. _startData.jsonData.analysisList[index].status
  1204. )
  1205. ) {
  1206. return resolve();
  1207. }
  1208. if (_num >= _maxNum) {
  1209. _startData.jsonData.analysisList[index].status =
  1210. "tryAgainMax"; //超过尝试次数
  1211. return resolve();
  1212. }
  1213. _num += 1;
  1214. let _assistantData =
  1215. this.dialogTagDataList.find(
  1216. i2 => i2.id == i.jsonData.mId
  1217. ) ||
  1218. this.dialogTagDataList.find(
  1219. i2 => i2.name == i.jsonData.name
  1220. );
  1221. if (!_assistantData) {
  1222. _startData.jsonData.analysisList[index].status =
  1223. "noAgentData"; //无对应的智能体
  1224. return resolve();
  1225. }
  1226. let data = await this.getAnalysisMixin({
  1227. fileId: _startData.jsonData.file_ids,
  1228. content: _content,
  1229. analysisData: i.jsonData,
  1230. assistantData: _assistantData,
  1231. baseMessage: _startData.jsonData.baseMessage
  1232. });
  1233. console.log("👉xxx",data,index)
  1234. if (!this.nowDoTaskId.includes(_startData.id)) return resolve();
  1235. if (data.data == 1) {
  1236. if (_num < _maxNum) {
  1237. //重试
  1238. getAnalysis();
  1239. }
  1240. } else {
  1241. _startData.jsonData.analysisList[index].status = "success";
  1242. _startData.jsonData.analysisList[index].jsonData =
  1243. data.data;
  1244. _stepList[_i].successNum += 1;
  1245. this.dataList.find(i2 => i2.id === _startData.id).jsonData.steps[_i].successNum = _stepList[_i].successNum;
  1246. this.$forceUpdate();
  1247. resolve();
  1248. // this.updateTask(_startData.id);
  1249. // _startData.jsonData = JSON.parse(
  1250. // JSON.stringify(
  1251. // this.dataList.find(i => i.id === _startData.id).jsonData
  1252. // )
  1253. // );
  1254. }
  1255. };
  1256. getAnalysis();
  1257. });
  1258. });
  1259. await Promise.all(promises).then(() => {
  1260. console.log(`${_startData.id}:已完成分析获取`);
  1261. if (!this.nowDoTaskId.includes(_startData.id)) return;
  1262. console.log("data👉", JSON.parse(JSON.stringify(_startData)));
  1263. console.log(_startData.jsonData.analysisList);
  1264. _stepList[i].status = "1";
  1265. this.dataList.find(
  1266. i => i.id === _startData.id
  1267. ).jsonData.steps = _stepList;
  1268. this.dataList.find(i => i.id === _startData.id).jsonData =
  1269. _startData.jsonData;
  1270. this.updateTask(_startData.id);
  1271. _startData.jsonData = JSON.parse(
  1272. JSON.stringify(
  1273. this.dataList.find(i => i.id === _startData.id).jsonData
  1274. )
  1275. );
  1276. if (
  1277. this.dataList
  1278. .find(i => i.id === _startData.id)
  1279. .jsonData.steps.find(i => i.type === "createClass").status ===
  1280. "1"
  1281. ) {
  1282. this.dataList.find(i => i.id === _startData.id).status = "2";
  1283. if (this.dataList.find(i => i.status == "0")) {
  1284. let id = this.dataList.find(i => i.status == "0").id;
  1285. this.startTask(id);
  1286. }
  1287. }
  1288. });
  1289. if (!this.nowDoTaskId.includes(_startData.id)) break;
  1290. } else if (_step.type === "createClass") {
  1291. //创建课堂
  1292. _stepList[i].status = "2";
  1293. _stepList[i].startTime =
  1294. new Date().toLocaleDateString().replaceAll("/", "-") +
  1295. " " +
  1296. new Date().toLocaleTimeString();
  1297. this.dataList.find(
  1298. i => i.id === _startData.id
  1299. ).jsonData.steps = _stepList;
  1300. this.$forceUpdate()
  1301. // 判断是否已经创建了课堂 已经创建了就删除原有课堂
  1302. if(_startData.jsonData.createId){
  1303. let delCourse = await this.deleteClassMixin(_startData.jsonData.createId)
  1304. if(delCourse==1){
  1305. console.log("删除课堂成功")
  1306. }else{
  1307. console.log("删除课堂失败")
  1308. }
  1309. }
  1310. //创建课堂 赋值好fileid 替换创建后课堂的基础数据 继续下一个任务
  1311. let newOption = await this.createClassMixin(_startData.jsonData);
  1312. if ([1, 2, 3].includes(newOption.data)) {
  1313. this.dataList.find(
  1314. i => i.id === _startData.id
  1315. ).jsonData.errorMessage = {
  1316. content: "创建课堂失败",
  1317. err: data.err
  1318. };
  1319. this.dataList.find(i => i.id === _startData.id).status = "3";
  1320. break;
  1321. }
  1322. if (!this.nowDoTaskId.includes(_startData.id)) break;
  1323. this.$emit("addNewCourseOption", newOption.data);
  1324. this.dataList.find(i => i.id === _startData.id).jsonData.createId =
  1325. newOption.tid;
  1326. _stepList[i].status = "1";
  1327. this.dataList.find(
  1328. i => i.id === _startData.id
  1329. ).jsonData.steps = _stepList;
  1330. this.dataList.find(i => i.id === _startData.id).status = "2";
  1331. this.updateTask(_startData.id);
  1332. _startData.jsonData = JSON.parse(
  1333. JSON.stringify(
  1334. this.dataList.find(i => i.id === _startData.id).jsonData
  1335. )
  1336. );
  1337. console.log(`${_startData.id}:已创建课堂`);
  1338. // 查看是否有需要开启的任务
  1339. if (this.dataList.find(i => i.status == "0")) {
  1340. let id = this.dataList.find(i => i.status == "0").id;
  1341. this.startTask(id);
  1342. }
  1343. break;
  1344. }
  1345. console.log(this.dataList.find(i => i.id === _startData.id));
  1346. if (this.dataList.find(i => i.id === _startData.id).status == "1") {
  1347. this.dataList.find(i => i.id === _startData.id).status = "0";
  1348. if (this.dataList.find(i => i.status == "0")) {
  1349. let id = this.dataList.find(i => i.status == "0").id;
  1350. this.startTask(id);
  1351. }
  1352. }
  1353. }
  1354. }
  1355. },
  1356. // 暂停任务
  1357. pauseTask(id) {
  1358. let _waitTask = this.dataList.find(i => i.status === "0");
  1359. if (_waitTask) {
  1360. //暂停这个任务,
  1361. this.dataList.find(i => i.id === id).status = "0";
  1362. this.nowDoTaskId = this.nowDoTaskId.filter(i => i !== id);
  1363. // 开始另一个任务
  1364. this.startTask(_waitTask.id);
  1365. } else {
  1366. //没有任务了,所以改为待开始(停止)
  1367. this.dataList.find(i => i.id === id).status = "3";
  1368. }
  1369. },
  1370. //停止任务
  1371. stopTask(id) {
  1372. let stopTask = this.dataList.find(i => i.id === id);
  1373. if (stopTask.status === "0") {
  1374. this.dataList.find(i => i.id === id).status = "3";
  1375. }
  1376. if (stopTask.status === "1") {
  1377. this.dataList.find(i => i.id === id).status = "3";
  1378. this.nowDoTaskId = this.nowDoTaskId.filter(i => i !== id);
  1379. }
  1380. if (
  1381. stopTask.jsonData.steps.find(i => i.type == "createClass").status == 1
  1382. ) {
  1383. this.dataList.find(i => i.id === id).status = "2";
  1384. this.nowDoTaskId = this.nowDoTaskId.filter(i => i !== id);
  1385. }
  1386. console.log(stopTask);
  1387. let _waitTask = this.dataList.find(i => i.status === "0");
  1388. console.log(_waitTask);
  1389. if (_waitTask) {
  1390. // 开始另一个任务
  1391. this.startTask(_waitTask.id);
  1392. }
  1393. // let _waitTask = this.dataList.find(i => i.status === "0" && i.id===id);
  1394. // if (_waitTask) {
  1395. // //停止这个任务,
  1396. // this.dataList.find(i => i.id === id).status = "3";
  1397. // this.nowDoTaskId = this.nowDoTaskId.filter(i=>i!==id);
  1398. // // 开始另一个任务
  1399. // this.startTask(_waitTask.id);
  1400. // } else {
  1401. // //只停止这个任务
  1402. // this.dataList.find(i => i.id === id).status = "3";
  1403. // }
  1404. },
  1405. goToEdit(id) {
  1406. let _data = this.dataList.find(i => i.id === id);
  1407. if (_data) {
  1408. let createId = _data.jsonData.createId;
  1409. this.$emit("changeClass", createId);
  1410. this.close();
  1411. }
  1412. },
  1413. test() {
  1414. this.testMixin();
  1415. },
  1416. async exportDoc() {
  1417. let _exportList = this.dataList.filter(
  1418. i =>
  1419. this.selectList.includes(i.id) &&
  1420. (this.selectStatus === "99" ||
  1421. this.statusList
  1422. .find(i2 => i2.value === this.selectStatus)
  1423. .allow.includes(i.status)) &&
  1424. i.status == "2"
  1425. );
  1426. if (_exportList.length <= 0)
  1427. return this.$message.info("请先选择已经完成的任务列表");
  1428. let promise = [];
  1429. let _notify = this.$notify.info({
  1430. title: "提示",
  1431. message: "正在批量导出word中,请稍等...",
  1432. duration: 0,
  1433. showClose: false
  1434. });
  1435. let _copyExportData = JSON.parse(JSON.stringify(_exportList));
  1436. let fileList = [];
  1437. for (let i = 0; i < _copyExportData.length; i++) {
  1438. // _copyExportData[i].jsonData.baseMessage.courseName =
  1439. // _copyExportData[i].jsonData.baseMessage.courseName + "_" + i;
  1440. fileList.push(await this.getDocFnPromise(_copyExportData[i]));
  1441. }
  1442. if (fileList.length == 1) {
  1443. saveAs(fileList[0], `${fileList[0].name}`);
  1444. this.$message.success("导出报告成功");
  1445. } else if (fileList.length > 1) {
  1446. const zip = new JSZip();
  1447. fileList.forEach((i, index) => {
  1448. let fileName = i.name;
  1449. if (
  1450. fileList
  1451. .map(i => i.name)
  1452. .filter((fi, findex) => findex !== index)
  1453. .includes(fileName)
  1454. )
  1455. fileName =
  1456. fileName.replace(/\.[^/.]+$/, "") +
  1457. `(${index}).` +
  1458. fileName.replace(/^.*\./, "");
  1459. // let fileName = i.name;
  1460. // let fileNames = fileList.map(file => file.name);
  1461. // let count = 1;
  1462. // while (fileNames.includes(fileName)) {
  1463. // let nameWithoutExtension = fileName.replace(/\.[^/.]+$/, "");
  1464. // let extension = fileName.replace(nameWithoutExtension, "");
  1465. // fileName = `${nameWithoutExtension}(${count})${extension}`;
  1466. // count++;
  1467. // }
  1468. zip.file(fileName, i, { binary: true });
  1469. });
  1470. zip.generateAsync({ type: "blob" }).then(content => {
  1471. // 生成二进制流
  1472. saveAs(content, `课堂观察报告.zip`); // 利用file-saver保存文件 自定义文件名
  1473. });
  1474. this.$message.success("导出报告成功");
  1475. }
  1476. _notify.close();
  1477. // _exportList.forEach((i, index) => {
  1478. // i.jsonData.baseMessage.courseName =
  1479. // i.jsonData.baseMessage.courseName + "_" + index;
  1480. // promise.push(this.getDocFnPromise(i));
  1481. // });
  1482. // Promise.all(promise)
  1483. // .then(res => {
  1484. // _notify.close();
  1485. // console.log(res);
  1486. // if (res.length == 1) {
  1487. // saveAs(res[0], `${res[0].name}`);
  1488. // this.$message.success("导出报告成功");
  1489. // } else if (res.length > 1) {
  1490. // const zip = new JSZip();
  1491. // res.forEach(i => {
  1492. // zip.file(`${i.name}`, i, { binary: true });
  1493. // });
  1494. // zip.generateAsync({ type: "blob" }).then(content => {
  1495. // // 生成二进制流
  1496. // saveAs(content, `课堂观察报告.zip`); // 利用file-saver保存文件 自定义文件名
  1497. // });
  1498. // this.$message.success("导出报告成功");
  1499. // }
  1500. // })
  1501. // .catch(err => {
  1502. // console.log("err", err);
  1503. // });
  1504. },
  1505. async regenerateTheReport() {
  1506. let _generateList = this.dataList.filter(
  1507. i =>
  1508. this.selectList.includes(i.id) &&
  1509. (this.selectStatus === "99" ||
  1510. this.statusList
  1511. .find(i2 => i2.value === this.selectStatus)
  1512. .allow.includes(i.status)) &&
  1513. i.status == "2"
  1514. );
  1515. if (_generateList.length <= 0)
  1516. return this.$message.info("请先选择已经完成的任务列表");
  1517. this.$confirm("确认要重新生成课堂观察报告吗?", "提示", {
  1518. confirmButtonText: "确定",
  1519. cancelButtonText: "取消",
  1520. type: "warning"
  1521. }).then(() => {
  1522. _generateList.forEach(i => {
  1523. this.dataList.find(i2 => i2.id == i.id).status = "0";
  1524. this.dataList
  1525. .find(i2 => i2.id === i.id)
  1526. .jsonData.steps.find(i2 => i2.type == "generateReport").status =
  1527. "0";
  1528. });
  1529. this.dataList.find(i => i.id === id).jsonData.steps.find(i => i.type == "generateReport").successNum = 0;
  1530. if (!this.dataList.some(i => i.status == "1")) {
  1531. this.startTask(_generateList[0].id);
  1532. }
  1533. });
  1534. }
  1535. },
  1536. mounted() {
  1537. this.getTaskList();
  1538. this.getDialogTagDataList();
  1539. }
  1540. };
  1541. </script>
  1542. <style scoped>
  1543. .batchCreationClassDialog {
  1544. width: 100vw;
  1545. height: 100vh;
  1546. }
  1547. .batchCreationClassDialog >>> .el-dialog__header,
  1548. .batchCreationClassDialog >>> .el-dialog__footer {
  1549. display: none; /* 隐藏头部和底部 */
  1550. }
  1551. .batchCreationClassDialog >>> .el-dialog__body {
  1552. padding: 0;
  1553. margin: 0;
  1554. height: 100vh;
  1555. width: 100vw;
  1556. overflow: auto;
  1557. display: flex;
  1558. justify-content: center;
  1559. }
  1560. .box {
  1561. width: 70%;
  1562. min-width: 500px;
  1563. height: 100%;
  1564. box-sizing: border-box;
  1565. border-left: solid 1px #e1e1e1;
  1566. border-right: solid 1px #e1e1e1;
  1567. padding: 0 40px;
  1568. }
  1569. .b_back {
  1570. height: 50px;
  1571. width: 100%;
  1572. display: flex;
  1573. align-items: center;
  1574. justify-content: space-between;
  1575. margin-top: 20px;
  1576. }
  1577. .b_b_left {
  1578. display: flex;
  1579. align-items: center;
  1580. cursor: pointer;
  1581. }
  1582. .b_b_left > img {
  1583. width: 25px;
  1584. height: 25px;
  1585. transform: rotate(180deg);
  1586. }
  1587. .b_b_left > span {
  1588. font-size: 16px;
  1589. font-weight: bold;
  1590. margin-left: 5px;
  1591. }
  1592. .b_head {
  1593. width: 100%;
  1594. height: 50px;
  1595. margin: 20px 0 0px 0;
  1596. box-sizing: border-box;
  1597. }
  1598. .b_head > span {
  1599. font-size: 18px;
  1600. font-weight: bold;
  1601. color: #000;
  1602. }
  1603. .b_nav {
  1604. width: 100%;
  1605. height: 50px;
  1606. display: flex;
  1607. align-items: center;
  1608. justify-content: space-between;
  1609. box-sizing: border-box;
  1610. border-bottom: solid 1px rgba(150, 155, 163, 1);
  1611. }
  1612. .b_n_left {
  1613. flex: 1;
  1614. /* width: calc(100% - 60px); */
  1615. height: 100%;
  1616. display: flex;
  1617. align-items: center;
  1618. overflow-y: hidden;
  1619. }
  1620. .b_n_left > span {
  1621. height: 100%;
  1622. padding: 0 20px;
  1623. display: flex;
  1624. align-items: center;
  1625. justify-content: center;
  1626. position: relative;
  1627. cursor: pointer;
  1628. transition: 0.3s;
  1629. font-size: 16px;
  1630. white-space: nowrap;
  1631. }
  1632. .b_n_left > span:hover {
  1633. color: rgba(5, 96, 253, 1);
  1634. }
  1635. .b_n_left > .b_n_l_active {
  1636. color: rgba(5, 96, 253, 1);
  1637. }
  1638. .b_n_left > .b_n_l_active::after {
  1639. content: "";
  1640. position: absolute;
  1641. width: 70%;
  1642. height: 4px;
  1643. border-radius: 4px;
  1644. bottom: -1px;
  1645. left: 50%;
  1646. transform: translateX(-50%);
  1647. background-color: rgba(5, 96, 253, 1);
  1648. }
  1649. .b_n_right {
  1650. width: auto;
  1651. height: 100%;
  1652. display: flex;
  1653. align-items: center;
  1654. justify-content: flex-end;
  1655. color: rgba(150, 155, 163, 1);
  1656. font-size: 16px;
  1657. white-space: nowrap;
  1658. }
  1659. .b_bottom {
  1660. width: 100%;
  1661. height: auto;
  1662. min-height: calc(100% - 210px);
  1663. /* height: calc(100% - 200px); */
  1664. }
  1665. .b_b_operation {
  1666. width: 100%;
  1667. height: 40px;
  1668. display: flex;
  1669. align-items: center;
  1670. justify-content: space-between;
  1671. margin-top: 10px;
  1672. }
  1673. .b_b_o_left {
  1674. width: calc(100% - 100px);
  1675. height: 100%;
  1676. display: flex;
  1677. align-items: center;
  1678. font-size: 16px;
  1679. }
  1680. .b_b_o_right {
  1681. width: fit-content;
  1682. height: 100%;
  1683. display: flex;
  1684. align-items: center;
  1685. justify-content: space-between;
  1686. }
  1687. .b_b_o_right > div {
  1688. margin-right: 10px;
  1689. font-size: 16px;
  1690. }
  1691. .b_b_o_right > div >>> .el-checkbox {
  1692. display: flex;
  1693. align-items: center;
  1694. }
  1695. .b_b_o_right > span {
  1696. width: fit-content;
  1697. height: 20px;
  1698. cursor: pointer;
  1699. display: flex;
  1700. align-items: center;
  1701. margin: 0 10px;
  1702. white-space: nowrap;
  1703. }
  1704. .b_b_o_right > span > img {
  1705. width: 100%;
  1706. height: 100%;
  1707. }
  1708. .b_b_list {
  1709. width: 100%;
  1710. height: auto;
  1711. padding-bottom: 40px;
  1712. }
  1713. </style>