3 个回答
✓ 已被采纳
  • 后台组织json数据如下:
[
 {time: '',activity: '早读', monday: '', tuesday: '', Wednesday: '', Thursday: '', Friday: ''},
 {time: '',activity: '...', monday: '', tuesday: '', Wednesday: '', Thursday: '', Friday: ''},
 ...
]
  • html确定基本的表结构
  • 摸板引擎解析每条json记录,如果activity属性值不为空字符串,则设置td标签colspan="5";否则,生成6个td标签,按时间段,星期一,...,星期五分别赋值

保证数据完整性的一种结构:

{
  "classId" : "1",
  "className" : "五年级一班",
  "semesterId" : "1",
  "semester" : "2015年第一学期",
  "courses" : [
    {
      "day" : "monday",
      "course" : [
        {
          "startTime" : "7:40",
          "endTime" : "8:00",
          "subject" : "早读",
          "teacher" : "-"
        },
        {
          "startTime" : "8:00",
          "endTime" : "8:45",
          "subject" : "数学",
          "teacher" : "张红"
        },
        {
          "startTime" : "8:55",
          "endTime" : "9:40",
          "subject" : "语言E",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "9:40",
          "endTime" : "10:10",
          "subject" : "课堂操",
          "teacher" : "-"
        },
        {
          "startTime" : "10:00",
          "endTime" : "10:45",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "10:45",
          "endTime" : "11:05",
          "subject" : "眼保健操",
          "teacher" : "-"
        },
        {
          "startTime" : "11:05",
          "endTime" : "11:50",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "11:50",
          "endTime" : "14:00",
          "subject" : "午休",
          "teacher" : "-"
        },
        {
          "startTime" : "14:00",
          "endTime" : "14:45",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "14:55",
          "endTime" : "15:40",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "15:50",
          "endTime" : "16:35",
          "subject" : "语文",
          "teacher" : "李晓军"
        }
      ]
    },
    {
      "day" : "tuesday",
      "course" : [
        {
          "startTime" : "7:40",
          "endTime" : "8:00",
          "subject" : "早读",
          "teacher" : "-"
        },
        {
          "startTime" : "8:00",
          "endTime" : "8:45",
          "subject" : "数学",
          "teacher" : "张红"
        },
        {
          "startTime" : "8:55",
          "endTime" : "9:40",
          "subject" : "语言E",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "9:40",
          "endTime" : "10:10",
          "subject" : "课堂操",
          "teacher" : "-"
        },
        {
          "startTime" : "10:00",
          "endTime" : "10:45",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "10:45",
          "endTime" : "11:05",
          "subject" : "眼保健操",
          "teacher" : "-"
        },
        {
          "startTime" : "11:05",
          "endTime" : "11:50",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "11:50",
          "endTime" : "14:00",
          "subject" : "午休",
          "teacher" : "-"
        },
        {
          "startTime" : "14:00",
          "endTime" : "14:45",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "14:55",
          "endTime" : "15:40",
          "subject" : "语文",
          "teacher" : "李晓军"
        },
        {
          "startTime" : "15:50",
          "endTime" : "16:35",
          "subject" : "语文",
          "teacher" : "李晓军"
        }
      ]
    }
  ]
}

后来想想,若我们想要标注出不同的课程类型的话,可以给每一节课再加一个标识:

type

比如:

    {
          "startTime" : "7:40",
          "endTime" : "8:00",
          "subject" : "早读",
          "teacher" : "-",
          "type" : "common"
    },
  • 应该将没门课程作为一个对象。
  • 周一到周五是固定的,时间段也是固定。可以将它们做为一种类型。
  • 早读也相当于一门课程,不过这门课程是每日课程,因此应该和其他课程标识出来
[
    {name: '早读', teacher: '张红', number:0, time:'7:40-8:00',week: 1,  dailyCourse:true},
    {name: '数学', teacher: '张红', number:1, time:'8:10-8:50', week: 1,  dailyCourse:false},
    ...
]
  • 多添加了一个time字段,为的时以后课程会更改时间,也不用修改界面了。
宣传栏