a.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. router.route('/updateStudioWorkNew4').all((req, res, next) => { //学生
  2. if (req.body[0]) {
  3. let p = [req.body[0].cid];
  4. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_studio_course_detail2"); //執行存儲過程
  5. mysql.usselect(p, function(ret) {
  6. let _unitIndex = parseInt(req.body[0].unitIndex);
  7. let _chapters = JSON.parse(req.body[0].chapters);
  8. let _unitJson = JSON.parse(ret[0][0].chapters)
  9. if ((_unitJson.length - 1) < _unitIndex) {
  10. let _i = _unitIndex - (_unitJson.length - 1)
  11. for (let i = 0; i < _i; i++) {
  12. _unitJson.push({
  13. dyName: "", //单元标题
  14. chapterInfo: [{
  15. isread: false,
  16. chapterid: guid(),
  17. title: "",
  18. courseName: "",
  19. taskJson: [{
  20. task: "",
  21. taskDetail: "",
  22. chapterData: [],
  23. toolText: "",
  24. toolChoose: [{
  25. tool: [],
  26. toolDetail: "",
  27. toolType: 0,
  28. askCount: 1,
  29. askTitle: "",
  30. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  31. }, ],
  32. isShowTools: false,
  33. askCount: 1,
  34. isFold: 0,
  35. askTitle: "",
  36. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  37. checkJson: [{ checkCount: [], checkPerent: [] }],
  38. homeworkList: [],
  39. }, ],
  40. itemCount: 1,
  41. fileList1: [],
  42. video: [],
  43. testData: [],
  44. pData: [],
  45. templateArray: [],
  46. }, ],
  47. })
  48. }
  49. _unitJson[_unitIndex] = _chapters[_unitIndex]
  50. } else {
  51. _unitJson[_unitIndex] = _chapters[_unitIndex]
  52. }
  53. // console.log(_unitJson);
  54. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  55. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudioWorkNew4"); //執行存儲過程
  56. mysql.usselect(p2, function(ret) {
  57. res.end(JSON.stringify({ success: 1 }));
  58. });
  59. // res.end(JSON.stringify({ success: 1 }));
  60. });
  61. }
  62. });
  63. router.route('/updateStudioWorkNew2').all((req, res, next) => { //学生
  64. if (req.body[0]) {
  65. p = [req.body[0].cid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].evaId, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template, req.body[0].ateacher];
  66. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudioWorkNew2"); //執行存儲過程
  67. mysql.usselect(p, function(ret) {
  68. let course = req.body[0].courseType;
  69. let courseId = req.body[0].cid;
  70. let userid = req.body[0].uid;
  71. delStudioCourseTypeS(course, courseId, userid);
  72. res.end(JSON.stringify({ success: 1 }));
  73. });
  74. }
  75. });
  76. router.route('/addStudioCourseWorkNew2').all((req, res, next) => { //学生
  77. if (req.body[0]) {
  78. p = [req.body[0].uid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].evaId, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template, req.body[0].ateacher];
  79. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addStudioCourseWorkNew2"); //執行存儲過程
  80. mysql.usselect(p, function(ret) {
  81. let course = req.body[0].courseType;
  82. let courseId = ret[0][0].courseId;
  83. let userid = req.body[0].uid;
  84. delStudioCourseTypeS(course, courseId, userid);
  85. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  86. });
  87. }
  88. });
  89. //teacher 查询项目模板
  90. router.route('/getStudioTemplateTs').all((req, res, next) => {
  91. var json = queryString(req.url);
  92. getmysql(req, res, "getStudioTemplateTs", json['oid']);
  93. });
  94. //查看课程
  95. router.route('/select_studio_course_detail').all((req, res, next) => { //学生
  96. var json = queryString(req.url);
  97. getmysql(req, res, "select_studio_course_detail", json['cid']);
  98. });
  99. //查看课程
  100. router.route('/select_studio_course_detail2').all((req, res, next) => { //学生
  101. var json = queryString(req.url);
  102. getmysql(req, res, "select_studio_course_detail2", json['cid']);
  103. });
  104. //协同恢复删除的阶段
  105. router.route('/restoreStudioWork').all((req, res, next) => { //学生
  106. if (req.body[0]) {
  107. let p = [req.body[0].cid];
  108. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_studio_course_detail2"); //執行存儲過程
  109. mysql.usselect(p, function(ret) {
  110. let _chapid = req.body[0].chapid;
  111. // console.log(_chapid);
  112. let _chapters = JSON.parse(req.body[0].chapters);
  113. let _unitJson = JSON.parse(ret[0][0].chapters)
  114. let _unitJson2 = []
  115. let chpaindex;
  116. for (var i = 0; i < _chapters.length; i++) {
  117. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  118. chpaindex = i
  119. }
  120. }
  121. for (var i = 0; i < _unitJson.length; i++) {
  122. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  123. // console.log(1);
  124. // _unitJson.splice(i, -1)
  125. _unitJson2.push(_unitJson[i])
  126. // break;
  127. }
  128. }
  129. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  130. // console.log(_unitJson2);
  131. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  132. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudioWorkNew4"); //執行存儲過程
  133. mysql.usselect(p2, function(ret) {
  134. res.end(JSON.stringify({ success: 1 }));
  135. });
  136. // res.end(JSON.stringify({ success: 1 }));
  137. });
  138. }
  139. });
  140. //查询分类及所有子分类
  141. router.route('/selectAllTypeStudio').all((req, res, next) => {
  142. var json = queryString(req.url);
  143. getmysql(req, res, "selectAllTypeStudio", json['org'], json['oid']);
  144. });
  145. //上传文件
  146. router.route('/addStudioCourseWorksS').all((req, res, next) => {
  147. postmysql(req, res, "addStudioCourseWorksS");
  148. });
  149. //删除提交的作业
  150. router.route('/deleteStudioCourseWorkS').all((req, res, next) => {
  151. postmysql(req, res, "deleteStudioCourseWorkS");
  152. });
  153. router.route('/selectStudioCourseNew222').all((req, res, next) => {
  154. var json = queryString(req.url);
  155. getmysql(req, res, "selectStudioCourseNew222", json['type'], json['uid'], json['oid'], json['org'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typef'], json['typeE'], json['cu'], json['cn'], json['page'], json['pageSize']);
  156. });
  157. //删除课程
  158. router.route('/deleteStudioCourse').all((req, res, next) => {
  159. var json = queryString(req.url);
  160. getmysql(req, res, "deleteStudioCourse", json['cid']);
  161. });
  162. function delStudioCourseTypeS(course, courseId, userid) {
  163. let _courseId = courseId;
  164. var _userdata = [
  165. _courseId
  166. ];
  167. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_studioCourseTypeS");
  168. mysql.usselect(_userdata, function(ret) {
  169. // console.log(ret);
  170. addStudioCourseTypeS(userid, course, _courseId)
  171. });
  172. // setTimeout(() => {
  173. // }, 1000);
  174. }
  175. function addStudioCourseTypeS(userid, course, _courseId) {
  176. var _uid = userid;
  177. var _courses = _courseId
  178. var _tid = JSON.parse(course)
  179. for (let i = 0; i < _tid.length; i++) {
  180. if (_tid[i] == '') {
  181. continue;
  182. }
  183. var _userdata = [
  184. _courses,
  185. _tid[i],
  186. _uid,
  187. ];
  188. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_studioCourseTypeS");
  189. mysql.usselect(_userdata, function(ret) {
  190. // console.log(ret);
  191. });
  192. }
  193. }