index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div class="allPage" v-loading="loading">
  3. <homePage
  4. ref="homePageRef"
  5. @cutPage="cutPage"
  6. :page="page"
  7. v-if="page == 1"
  8. :baseMessageLoading="baseMessageLoading"
  9. :classList="classList"
  10. :tid="tid"
  11. :bmData="bmData"
  12. ></homePage>
  13. <bindFrom ref="bindFromRef" @cutPage="cutPage" :page="page" v-if="page == 2"></bindFrom>
  14. <classInfo
  15. ref="classInfoRef"
  16. @cutPage="cutPage"
  17. :page="page"
  18. :tid="tid"
  19. v-if="page == 3"
  20. v-loading="baseMessageLoading"
  21. :bmData="bmData"
  22. :imageList="imageList"
  23. ></classInfo>
  24. <stencilled ref="stencilledRef" @cutPage="cutPage" :page="page" v-if="page == 5"></stencilled>
  25. <editTel ref="editTelRef" @cutPage="cutPage" :page="page" v-if="page == 6"></editTel>
  26. <addTel ref="addTelRef" @cutPage="cutPage" :page="page" v-if="page == 7"></addTel>
  27. <outcome
  28. ref="outcomeRef"
  29. @cutPage="cutPage"
  30. :page="page"
  31. v-show="page == 8"
  32. :loading="[currencyLoading, scienceLoading, extendLoading]"
  33. :dataList="dataList"
  34. />
  35. </div>
  36. </template>
  37. <script>
  38. import homePage from './homePage'
  39. import bindFrom from './bindFrom'
  40. import classInfo from './classInfo'
  41. import stencilled from './stencilled'
  42. import editTel from './editTel'
  43. import addTel from './addTel'
  44. import outcome from './outcome.vue'
  45. import { updateObsRequest, getCourseListRequest, getObsRequest, delClassRequest,delObsRequest } from '@/api/classObserve'
  46. export default {
  47. components: { homePage, bindFrom, classInfo, stencilled, editTel, addTel, outcome },
  48. data() {
  49. return {
  50. userId: this.$store.state.user.id,
  51. page: 1,
  52. loading: false,
  53. currencyLoading: true,
  54. baseMessageLoading: true,
  55. scienceLoading: true,
  56. extendLoading: true,
  57. classList: [],
  58. bmData: {
  59. id: '',
  60. tId: '',
  61. tIndex: 0,
  62. jsonData: {
  63. activity_methods: '',
  64. activity_structure: '',
  65. classroom_resources: '',
  66. courseName: '',
  67. name: '',
  68. studentNum: 0,
  69. subject: '',
  70. textbook: ''
  71. }
  72. },
  73. imageList: {},
  74. dataList: [],
  75. tid: ''
  76. }
  77. },
  78. methods: {
  79. cutPage(val) {
  80. this.page = val
  81. },
  82. // 获取课堂列表
  83. getCourseList() {
  84. this.loading = true
  85. return new Promise((resolve, reject) => {
  86. getCourseListRequest({
  87. userid: this.userId
  88. })
  89. .then(res => {
  90. let _data = res.FunctionResponse.result
  91. let _result = []
  92. try {
  93. _result = _data ? JSON.parse(_data) : []
  94. } catch (error) {
  95. _result = []
  96. }
  97. if (_result.length <= 0) {
  98. this.loading = false
  99. resolve()
  100. return
  101. }
  102. let _optionData = _result.map(item => {
  103. item.jsonData = item.jsonData ? JSON.parse(item.jsonData) : {}
  104. return {
  105. label: item.jsonData.courseName ? item.jsonData.courseName : `${item.tId}课堂`,
  106. value: item.tId,
  107. id: item.id,
  108. newLabel: item.jsonData.courseName ? item.jsonData.courseName : `${item.tId}课堂`,
  109. show: false,
  110. edit: false
  111. }
  112. })
  113. _optionData = _optionData.filter(i => i.label != '' && i.tId != '')
  114. this.classList = _optionData
  115. this.loading = false
  116. if (this.classList.length > 0) {
  117. this.changeTid(this.classList[0].value)
  118. }
  119. resolve()
  120. })
  121. .catch(e => {
  122. console.log(e)
  123. resolve()
  124. this.$message.error('获取课堂列表失败')
  125. })
  126. })
  127. },
  128. // 切换课堂
  129. changeTid(newTid) {
  130. if (this.tid == newTid) return
  131. let _flag = this.tid !== newTid
  132. this.tid = newTid
  133. if (_flag) {
  134. this.getData()
  135. }
  136. },
  137. //编辑课堂名称
  138. editClassName(item) {
  139. let _index = this.classList.findIndex(i => i.id == item.id)
  140. if (_index != -1) {
  141. if (this.tid == item.value) {
  142. //是现在预览的课堂
  143. this.$refs.homePageRef.historyListLoading = true
  144. this.bmData.jsonData.courseName = item.newLabel
  145. this.saveData(this.bmData).then(_ => {
  146. this.$refs.homePageRef.historyListLoading = false
  147. this.classList[_index].label = item.newLabel
  148. this.classList[_index].edit = false
  149. this.classList[_index].show = false
  150. this.loading = false
  151. this.$toast.success('修改成功')
  152. })
  153. } else {
  154. this.$refs.homePageRef.historyListLoading = true
  155. getObsRequest({ tid: item.value, type: 0 })
  156. .then(res => {
  157. let _data = res.FunctionResponse.result
  158. _data = JSON.parse(_data)
  159. let _bmData = _data.find(i => i.tIndex == 0)
  160. _bmData.jsonData = JSON.parse(_bmData.jsonData)
  161. _bmData.jsonData.courseName = item.newLabel
  162. this.saveData(_bmData).then(_ => {
  163. this.classList[_index].label = item.newLabel
  164. this.classList[_index].edit = false
  165. this.classList[_index].show = false
  166. this.loading = false
  167. this.$refs.homePageRef.historyListLoading = false
  168. this.$toast.success('修改成功')
  169. })
  170. })
  171. .catch(e => {
  172. console.log(e)
  173. this.$toast.fail('修改失败')
  174. })
  175. }
  176. }
  177. },
  178. //删除课堂
  179. delClass(item) {
  180. this.$refs.homePageRef.historyListLoading = true
  181. delClassRequest({ tid: item.id }).then(_ => {
  182. this.$toast.success('删除成功')
  183. this.getCourseList().then(_ => {
  184. if (this.tid == item.value || (this.tid == '' && this.classList.length > 0)) {
  185. this.changeTid(this.classList[0].value)
  186. }
  187. this.$refs.homePageRef.historyListLoading = false
  188. })
  189. })
  190. },
  191. //保存分析数据
  192. saveData(params) {
  193. return new Promise((resolve, reject) => {
  194. updateObsRequest({
  195. id: params.id,
  196. json_data: JSON.stringify(params.jsonData)
  197. })
  198. .then(res => {
  199. resolve()
  200. })
  201. .catch(e => {
  202. this.$message.error('保存失败')
  203. resolve()
  204. })
  205. })
  206. },
  207. //获取通用分析与基本信息
  208. getCurrencyAndBaseMessageData() {
  209. return new Promise(resolve => {
  210. if (!this.tid) return
  211. this.loading = true
  212. this.currencyLoading = true
  213. this.baseMessageLoading = true
  214. getObsRequest({ tid: this.tid, type: '0' })
  215. .then(res => {
  216. let _data = res.FunctionResponse.result.length ? JSON.parse(res.FunctionResponse.result) : []
  217. let _bmData = _data.find(i => i.tIndex == 0)
  218. // 基础信息
  219. _bmData.jsonData = JSON.parse(_bmData.jsonData)
  220. _bmData.jsonData.time? "":_bmData.jsonData.time = "";
  221. // 图片
  222. let _imageList = _data.find(i => i.tIndex == 1)
  223. _imageList.jsonData = JSON.parse(_imageList.jsonData)
  224. if (!_imageList.jsonData.videoList) {
  225. _imageList.jsonData.videoList = []
  226. }
  227. if (!_imageList.jsonData.NephogramList) {
  228. _imageList.jsonData.NephogramList = []
  229. }
  230. let currency = []
  231. for (let i = 2; i < _data.length; i++) {
  232. let _currency = _data[i]
  233. _currency.jsonData = JSON.parse(_currency.jsonData)
  234. currency.push(_currency)
  235. }
  236. // 赋值
  237. this.dataList.push(...currency)
  238. this.bmData = _bmData
  239. this.imageList = _imageList
  240. this.baseMessageLoading = false
  241. this.currencyLoading = false
  242. this.loading = false
  243. resolve()
  244. })
  245. .catch(e => {
  246. console.log(e)
  247. this.$toast.fail('获取通用分析失败')
  248. resolve()
  249. })
  250. })
  251. },
  252. //获取学科分析
  253. getScienceData() {
  254. return new Promise(resolve => {
  255. if (!this.tid) return
  256. this.scienceLoading = true
  257. getObsRequest({ tid: this.tid, type: '1' })
  258. .then(res => {
  259. let _data = res.FunctionResponse.result.length ? JSON.parse(res.FunctionResponse.result) : []
  260. if (_data.length == 0) {
  261. return (this.scienceLoading = false)
  262. }
  263. let science = []
  264. for (let i = 0; i < _data.length; i++) {
  265. let _science = _data[i]
  266. _science.jsonData = JSON.parse(_science.jsonData)
  267. science.push(_science)
  268. }
  269. this.dataList.push(...science)
  270. this.scienceLoading = false
  271. resolve()
  272. })
  273. .catch(e => {
  274. console.log(e)
  275. this.$toast.fail('获取科学分析失败')
  276. resolve()
  277. })
  278. })
  279. },
  280. //获取扩展分析
  281. getExtendData() {
  282. return new Promise(resolve => {
  283. if (!this.tid) return
  284. this.extendLoading = true;
  285. getObsRequest({tid:this.tid,type:"2"}).then(res=>{
  286. let _data = res.FunctionResponse.result.length
  287. ? JSON.parse(res.FunctionResponse.result)
  288. : [];
  289. if (_data.length == 0) {
  290. return (this.extendLoading = false);
  291. }
  292. let extent = [];
  293. for (let i = 0; i < _data.length; i++) {
  294. let _extent = _data[i];
  295. _extent.jsonData = JSON.parse(_extent.jsonData);
  296. extent.push(_extent);
  297. }
  298. this.dataList.push(...extent);
  299. this.extendLoading = false;
  300. resolve();
  301. }).catch((e) => {
  302. console.log(e);
  303. this.$toast("获取扩展分析失败")
  304. resolve();
  305. });
  306. })
  307. },
  308. //获取全部的数据
  309. getData() {
  310. this.dataList = [];
  311. this.imageList = {};
  312. return new Promise(resolve => {
  313. Promise.all([this.getCurrencyAndBaseMessageData(),this.getScienceData(),this.getExtendData()]).then(_ => {
  314. console.log('所有分析获取完成')
  315. resolve();
  316. })
  317. })
  318. },
  319. //删除分析
  320. delAnalysis(item){
  321. if(!this.tid)return;
  322. this.currencyLoading = true;
  323. this.baseMessageLoading = true;
  324. this.scienceLoading = true;
  325. this.extendLoading = true;
  326. delObsRequest({
  327. id:item.id,
  328. type:item.Type,
  329. tid:this.tid
  330. }).then(res=>{
  331. this.dataList = this.dataList.filter(_item=>_item.id!=item.id);
  332. this.$toast.success('删除成功');
  333. this.currencyLoading = false;
  334. this.baseMessageLoading= false;
  335. this.scienceLoading= false;
  336. this.extendLoading= false;
  337. }).catch(e=>{
  338. this.$toast.fail('删除失败');
  339. this.currencyLoading = false;
  340. this.baseMessageLoading= false;
  341. this.scienceLoading= false;
  342. this.extendLoading= false;
  343. })
  344. },
  345. //修改分析
  346. editAnalysis(item){
  347. if(!this.tid)return;
  348. this.baseMessageLoading= true;
  349. this.scienceLoading= true;
  350. this.extendLoading= true;
  351. editObsRequest({
  352. id:item.id,
  353. type:item.Type,
  354. tid:this.tid
  355. }).then(res=>{
  356. })
  357. }
  358. },
  359. mounted() {
  360. this.getCourseList().then(_ => {
  361. // if(this.tid=="" && this.classList.length>0){
  362. // this.changeTid(this.classList[0].value);
  363. // }
  364. // this.getData()
  365. })
  366. // console.log(getClassList)
  367. }
  368. }
  369. </script>
  370. <style lang="scss" scoped>
  371. .allPage {
  372. height: 100vh;
  373. }
  374. </style>