zhengwei 4 éve
szülő
commit
17144e40c9

+ 76 - 7
src/Global.js

@@ -81,7 +81,7 @@ nonTfmtDatetoLength = function (datetime, length) {
 };
 
 /**
- * 获取时间字符串
+ * 获取当前时间字符串
  * @param mYear 几年后
  * @param mMonth 几个月后
  * @returns {string}
@@ -89,8 +89,8 @@ nonTfmtDatetoLength = function (datetime, length) {
 getDate = function (mYear, mMonth) {
     let date = new Date();
     let split = "-";
-    let year = date.getFullYear()+mYear;
-    let month = date.getMonth() + 1+mMonth;
+    let year = date.getFullYear() + mYear;
+    let month = date.getMonth() + 1 + mMonth;
     let strDate = date.getDate();
     if (month >= 1 && month <= 9) {
         month = "0" + month;
@@ -102,6 +102,58 @@ getDate = function (mYear, mMonth) {
     return thisData;
 };
 
+/**
+ * 获取当前时间字符串
+ * @param mDate 时间基准
+ * @param mYear 几年后
+ * @param mMonth 几个月后
+ * @param mDay 几天后
+ * @returns {string}
+ */
+getDate = function (mDate, mYear, mMonth, mDay) {
+    let date = new Date(mDate);
+    let split = "-";
+    let year = date.getFullYear() + mYear;
+    let month = date.getMonth() + 1 + mMonth;
+    let day = date.getDate() + mDay;
+    let hh = new Date().getHours();
+    let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
+    let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
+
+    //处理'日'越界
+    if (day < 1) {
+        month--;
+        day = new Date(year, month, 0).getDate() + day;
+    }
+    let monthDays = new Date(year, month, 0).getDate();//这个月本应该多少天
+    if (day > monthDays) {
+        day = day - monthDays;
+        month++;
+    }
+
+    //处理'月'越界
+    if (month < 1) {
+        year--;
+        month += 12;
+
+    }
+    if (month > 12) {
+        year++;
+        month -=12;
+    }
+
+    //10以下的月数和天数拼接0
+    if (month >= 1 && month <= 9) {
+        month = "0" + month;
+    }
+
+    if (day >= 0 && day <= 9) {
+        day = "0" + day;
+    }
+    let thisData = year + split + month + split + day;
+    return thisData;
+};
+
 // 校验内容长度
 globalValid = function (data, mins, maxs, text, that) {
     let thisVal = data;
@@ -218,7 +270,7 @@ endTypeOptions = function () {
         }, {
             value: 180,
             label: '半年'
-        },{
+        }, {
             value: 360,
             label: '一年'
         },
@@ -429,8 +481,25 @@ deepClone = function (obj) {
 };
 
 getSignStr = function (jsonStr) {
-
-
     return "123123123";
 }
-
+//课程类型
+courseOptions = function () {
+    let option = [];
+    option = [
+        {
+            value: 1,
+            label: '室内课'
+        }, {
+            value: 2,
+            label: '户外课'
+        }, {
+            value: 3,
+            label: '线上课'
+        }, {
+            value: 4,
+            label: '混合课'
+        },
+    ];
+    return option
+}

+ 3 - 3
src/Mock/index.js

@@ -231,10 +231,10 @@ let getNavListQuery = function () {
                         clmname: "课程表模板",
                         clmurl: "/lessonTableTemplate",
                     }, {
-                        clmid: "/lessonManage",
-                        clmcode: "lessonManage",
+                        clmid: "/lessonTableManage",
+                        clmcode: "lessonTableManage",
                         clmname: "课程表管理",
-                        clmurl: "/lessonManage",
+                        clmurl: "/lessonTableManage",
                     }, {
                         clmid: "/record",
                         clmcode: "record",

+ 6 - 6
src/api/Navs.js

@@ -52,9 +52,9 @@ let navs = [
 	},
 	{
 		clmid: "6",
-		clmcode: "lessonTable",
+		clmcode: "lessonTableTemple",
 		clmname: "课程表模板",
-		clmurl: "/lessonTable",
+		clmurl: "/lessonTableTemple",
 		prname: "",
 		show: 3,
 		grouplist: "2,5",
@@ -62,9 +62,9 @@ let navs = [
 	},
 	{
 		clmid: "7",
-		clmcode: "lessonManage",
+		clmcode: "lessonTableManage",
 		clmname: "课程表管理",
-		clmurl: "/lessonManage",
+		clmurl: "/lessonTableManage",
 		prname: "",
 		show: 3,
 		grouplist: "2,5",
@@ -282,9 +282,9 @@ let navs = [
 	},
 	{
 		clmid: "26",
-		clmcode: "lessonManage",
+		clmcode: "lessonTableManage",
 		clmname: "课程表管理",
-		clmurl: "/lessonManage",
+		clmurl: "/lessonTableManage",
 		prname: "",
 		show: 4,
 		grouplist: "2,5",

+ 2 - 3
src/components/preview.vue

@@ -20,15 +20,14 @@
             <div class="tableContext">
                 <div class="times">
                     <span v-for="time in previewDate.sttplanpreviewtimelist">{{time.begin_str}}-{{time.end_str}}</span>
-                    <span v-for="time in previewDate.SttPreviewTimeList">{{time.BeginStr}}-{{time.EndStr}}</span>
+                    <span v-for="time in previewDate.sttpreviewtimelist">{{time.begin_str}}-{{time.end_str}}</span>
                 </div>
-                <!--                1-->
                 <div class="rows" v-for="i in 7">
                     <em :style="{background:tab.class_color}" v-for="tab in previewDate.sttplanpreviewclasslist"
                         v-if="tab.week_day == i">
                         {{tab.class_name}}
                     </em>
-                    <em :style="{background:tab.class_color}" v-for="tab in previewDate.sttreviewclasslist"
+                    <em :style="{background:tab.class_color}" v-for="tab in previewDate.sttpreviewclasslist"
                         v-if="tab.week_day == i">
                         {{tab.class_name}}
                     </em>

+ 0 - 8
src/router/index.js

@@ -125,14 +125,6 @@ const routes = [
                     title: "系统设置",
                     // clmid: "22",
                 }
-            }, {
-                path: '/lessonManage',
-                name: 'lessonManage',
-                component: () => import('@/views/Class/LessonTableManage.vue'),
-                meta: {
-                    title: "课程表管理",
-                    // clmid: "5",
-                }
             }, {
                 path: '/coach',
                 name: 'coach',

+ 568 - 606
src/views/Class/LessonTableManage.vue

@@ -5,14 +5,14 @@
     </div>
     <div class="change">
       <el-button type="primary" @click="addLessonTable" size="mini">新增课程表</el-button>
-      <el-button type="" @click="copy"  size="mini">复制</el-button>
-      <el-button type="" @click="delList" size="mini">删除</el-button>
-      <el-button type="" @click="query" :disabled="serachBtnStatus" size="mini">刷新</el-button>
+      <el-button @click="copyLessonTable" size="mini">复制</el-button>
+      <el-button @click="deleteLessonTable" size="mini">删除</el-button>
+      <el-button @click="refreshQuery" :disabled="serachBtnStatus" size="mini">刷新</el-button>
     </div>
     <div class="table">
       <el-table :data="tableData" border is-horizontal-resize :default-sort="{prop: 'date', order: 'descending'}"
-        element-loading-background="rgba(0, 0, 0, 0.8)" class="" @selection-change="handleSelectionChange"
-        @current-change="clickChange">
+                element-loading-background="rgba(0, 0, 0, 0.8)" class="" @selection-change="handleSelectionChange"
+                @current-change="clickChange">
         >
         <el-table-column label="选择" width="55">
           <template slot-scope="scope">
@@ -21,7 +21,7 @@
         </el-table-column>
         <el-table-column label="序号" type="index" width="50" align="center">
           <template scope="scope">
-            <span>{{(start) + scope.$index + 1}}</span>
+            <span>{{ (start) + scope.$index + 1 }}</span>
           </template>
         </el-table-column>
         <el-table-column prop="data" label="日期">
@@ -45,75 +45,40 @@
         </el-table-column>
         <el-table-column prop="name" label="课程表名称" sortable>
         </el-table-column>
-        <el-table-column prop="created_at" label="最后编辑时间" :formatter="filterFmtDate" sortable>
+        <el-table-column prop="updated_at" label="最后编辑时间" :formatter="filterFmtDate" sortable>
         </el-table-column>
         <el-table-column prop="online" label="是否上线" width=120px sortable>
-          <!--                    上线状态	0:不上线 1:下线-->
+          <!--上线状态	0:不上线 1:下线-->
           <template slot-scope="scope">
-            <el-switch v-model="scope.row.online" :active-value="1" :inactive-value="0" active-color="#409EFF"
-              inactive-color="#D9D9D9" @change=changeWechat($event,scope.row)>
+            <el-switch :value="scope.row.online" :active-value="1" :inactive-value="0" active-color="#409EFF"
+                       inactive-color="#D9D9D9" @input=changeLessonOnline($event,scope.row)>
             </el-switch>
           </template>
         </el-table-column>
         <el-table-column prop="Status" label="操作">
           <template slot-scope="scope">
-            <el-button type="text" v-if="scope.row.diffweek >= 0" @click="editName(scope.row)">编辑名称
-            </el-button>
-            <el-button type="text" v-if="scope.row.diffweek >= 0" @click="goEdit(scope.row)">修改课程
-            </el-button>
-            <el-button type="text" @click="seeWeek(scope.row)">预览本周</el-button>
+            <el-button type="text" v-if="scope.row.diffweek >= 0" @click="editLessonName(scope.row)">编辑名称</el-button>
+            <el-button type="text" v-if="scope.row.diffweek >= 0" @click="editLessonDetail(scope.row)">修改课程</el-button>
+            <el-button type="text" @click="previewThisWeek(scope.row)">预览本周</el-button>
           </template>
         </el-table-column>
 
       </el-table>
       <br>
       <el-pagination background :total="pageination.total" :page-size="pageination.pageItem"
-        @current-change="pageChange"></el-pagination>
+                     @current-change="pageChange"></el-pagination>
     </div>
 
-    <el-dialog title="发布课程表" :visible.sync="dialogVisible" width="650px">
-      <div class="dialogTitle">
-        <span>{{ form.name }}</span>
-      </div>
+    <el-dialog title="复制课程表" :visible.sync="dialogCopyVisible" width="650px">
       <div>
         <span class="demonstration">选择发布日期(按周选取)</span>
         <br>
         <br>
-        <el-date-picker v-model="form.week" type="week" :picker-options="{'firstDayOfWeek': 1}" format="yyyy 第 WW 周"
-          placeholder="选择周">
-        </el-date-picker>
+        <el-input v-model="copyForm.name" style="width: 220px"/>
         <br>
         <br>
-        <span>
-          微信可见
-        </span>
-        <el-switch v-model="form.wechat" :active-value="1" :inactive-value="0" active-color="#409EFF"
-          inactive-color="#D9D9D9">
-        </el-switch>
-        <span>
-          微信可预约
-        </span>
-        <el-switch v-model="form.appoint" :active-value="1" :inactive-value="0" active-color="#409EFF"
-          inactive-color="#D9D9D9">
-        </el-switch>
-      </div>
-      <div class="dialogFooter">
-        <el-button type="primary" size="small" @click="public">确定</el-button>
-        <el-button @click="dialogVisible = false" size="small">取消</el-button>
-      </div>
-    </el-dialog>
-    <el-dialog title="复制课程表" :visible.sync="dialogCopyVisible" width="650px">
-      <div>
-        <span class="demonstration">选择发布日期(按周选取)</span>
-        <br>
-        <br>
-        <!--                todo 禁用当前周以前的选项  disabledDate(date) {
-           return date.getTime() <= Date.now()-86400000;
-         }
-        -->
-        <el-date-picker v-model="copyForm.week" type="week" :picker-options="{'firstDayOfWeek': 1}" format="yyyy 第 WW 周"
-          placeholder="选择周">
-        </el-date-picker>
+        <el-date-picker v-model="copyForm.begin_date" type="week" :picker-options="{'firstDayOfWeek': 1}"
+                        format="yyyy 第 WW 周" placeholder="选择周" style="width: 220px"/>
       </div>
       <div class="dialogFooter">
         <el-button type="primary" size="small" @click="confirmCopy">确定</el-button>
@@ -141,203 +106,109 @@
 </template>
 
 <script>
-  import Global from '../../Global.js'
-  import preview from '../../components/preview'
-
-  import {
-    StandardRequest
-  } from "@/grpc/base_pb";
-
-  let qs = require('qs');
-  export default {
-    data() {
-      return {
-        serachBtnStatus: false,
-        previewShow: false,
-        previewDate: {},
-        BigTitle: '',
-        smallTitle: '',
-        dialogVisible: false,
-        dialogCopyVisible: false,
-        dialogNameVisible: false,
-        dialogdata: [],
-        dialogValue: [],
-        start: 0,
-        draw: 1,
-        // panel 配置项目
-        multipleSelection: [],
-        pageination: {
-          pageItem: 100,
-          pageoptions: pageOptions(),
-          total: 100,
-          pageIndex: 1,
-        },
-        form: {
-          Id: '',
-          name: '',
-          week: '',
-          wechat: 1,
-          appoint: 1,
-        },
-        copyForm: {
-          stbId: '',
-          Id: '',
-          name: '',
-          week: '',
-          wechat: 1,
-          appoint: 1,
-        },
-        tableData: [],
-        tableRadio: [],
-      }
-    },
-    mounted() {
-      this.getTableQuery();
-    },
-    methods: {
-      clickChange(item) {
-        this.tableRadio = item
+import Global from '../../Global.js'
+import preview from '../../components/preview'
+
+import {
+  StandardRequest
+} from "@/grpc/base_pb";
+
+let qs = require('qs');
+export default {
+  data() {
+    return {
+      serachBtnStatus: false,
+      previewShow: false,
+      previewDate: {},
+      BigTitle: '',
+      smallTitle: '',
+      dialogVisible: false,
+      dialogCopyVisible: false,
+      dialogNameVisible: false,
+      dialogdata: [],
+      dialogValue: [],
+      start: 0,
+      draw: 1,
+      // panel 配置项目
+      multipleSelection: [],
+      pageination: {
+        pageItem: 100,
+        pageoptions: pageOptions(),
+        total: 100,
+        pageIndex: 1,
       },
-      // 编辑名称
-      editName(row) {
-        this.form.name = row.name;
-        this.form.stbId = row.StbId;
-        this.dialogNameVisible = true;
+      form: {
+        Id: '',
+        name: '',
+        week: '',
+        wechat: 1,
+        appoint: 1,
       },
-      // 预览本周
-      seeWeek(row) {
-        let that = this;
-        console.log(row);
-        let param = {
-          token: localStorage.token,
-          stbId: row.StbId,
-        };
-        let postdata = qs.stringify(param);
-        SchoolTimetablePreview(postdata).then(res => {
-          let json = res;
-          if (json.Code == 0) {
-            that.BigTitle = row.name;
-            that.smallTitle = row.begin_date + '至' + row.end_date;
-            that.previewDate = json.Rs;
-            // 前台排序
-            that.previewDate.SttPreviewClassList.sort((a, b) => a.ClassIndex - b.ClassIndex);//升序
-            that.previewShow = true;
-          } else {
-            that.$message.error(json.Memo + ' 错误码:' + json.Code);
-          }
-        })
+      copyForm: {
+        stb_id: '',
+        name: '',
+        begin_date: ''
       },
-      addLessonTable() {
-        this.$router.push({
-          path: '/lessonTableManageEdit', query: {
-            id: 0
-          }
-        });
-      },
-      // 删除
-      delList() {
-        let that = this;
-        if (this.tableRadio.length == 0) {
-          this.$message.error("请先选中一条记录");
-          return false
-        }
-        let row = that.tableRadio;
-
-        if (row.diffweek < 0) {
-          that.$message({
-            showClose: true,
-            message: '已过期的课程表不可删除',
-            type: 'error'
-          });
-          return false
+      tableData: [],
+      tableRadio: [],
+    }
+  },
+  mounted() {
+    this.getTableQuery();
+  },
+  methods: {
+    clickChange(item) {
+      this.tableRadio = item
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val;
+    },
+    //新增课程表
+    addLessonTable() {
+      this.$router.push({
+        path: '/lessonTableManageEdit', query: {
+          id: 0
         }
+      });
+    },
+    //复制课程表
+    copyLessonTable() {
+      let that = this;
+      if (this.tableRadio.length == 0) {
+        this.$message.error("请先选中一条记录");
+        return false
+      }
+      that.dialogCopyVisible = true;
+      that.copyForm.name = that.tableRadio.name;
+      that.copyForm.stb_id = that.tableRadio.stb_id;
+      that.copyForm.begin_date = that.tableRadio.begin_date;
+    },
+    //确认复制课程表
+    confirmCopy() {
+      let that = this;
 
-        let param = {
-          token: localStorage.token,
-          stbId: row.StbId,
-          status: 9,//0禁用1启用9删除
-        };
-        let postdata = qs.stringify(param);
-
-        this.$confirm('此操作将永久删除该课程表, 是否继续?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          STTBasicStatusEdit(postdata).then(res => {
-            let json = res;
-            if (json.Code == 0) {
-              that.$message({
-                showClose: true,
-                message: '选中的课程表已删除!',
-                type: 'success'
-              });
-              // 重载列表
-              that.getTableQuery();
-            } else {
-              that.$message.error(json.Memo + ' 错误码:' + json.Code);
-            }
-          });
-        }).catch(() => {
-          this.$message({
-            type: 'info',
-            message: '已取消删除'
-          });
-        });
-      },
-      // 提交名称修改
-      confirmName() {
-        let that = this;
-        if (!this.form.name) {
-          this.$message.error('名称不能为空');
-          return false
-        }
-        if (this.form.name.length < 3) {
-          this.$message.error('名称不能小于3个字符');
-          return false
-        }
-        if (this.form.name.length > 20) {
-          this.$message.error('名称不能大于20个字符');
-          return false
-        }
-        let param = {
-          token: localStorage.token,
-          stbId: this.form.stbId,
-          name: this.form.name,
-        };
-        let postdata = qs.stringify(param);
-        STTBasicEdit(postdata).then(res => {
-          let json = res;
-          if (json.Code == 0) {
-            that.$message({
-              showClose: true,
-              message: '名称修改成功!',
-              type: 'success'
-            });
-            this.getTableQuery();
-            this.dialogNameVisible = false;
-          } else {
-            that.$message.error(json.Memo + ' 错误码:' + json.Code);
-          }
-        })
-      },
-      confirmCopy() {
-        let that = this;
-        let row = this.copyForm;
+      if (!that.copyForm.begin_date) {
+        that.$message.error('没有选择发布周期');
+        return false
+      }
 
-        if (!row.week) {
-          that.$message.error('没有选择发布周期');
-          return false
-        }
-        let param = {
-          token: localStorage.token,
-          stbId: row.StbId,
-          incomingDate: nonTfmtDatetoLength(row.week, 10),//对应日期 字符串 年-月-日 格式,
-        };
-        let postdata = qs.stringify(param);
-        SchoolTimeTableCopy(postdata).then(res => {
-          let json = res;
-          if (json.Code == 0) {
+      const jsonStr = {
+        shopId: localStorage.shopId,
+        stbId: that.copyForm.stb_id,
+        name: that.copyForm.name,
+        incomingDate: nonTfmtDatetoLength(that.copyForm.begin_date, 10)//对应日期 字符串 年-月-日 格式,
+      };
+
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sTTBasicCopy(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
             that.$message({
               showClose: true,
               message: '课程复制成功!',
@@ -346,124 +217,42 @@
             this.dialogCopyVisible = false;
             this.getTableQuery();
           } else {
-            that.$message.error(json.Memo + ' 错误码:' + json.Code);
+            that.$message.error(res.memo + ',错误代码:' + res.code);
           }
-        })
-      },
-      copy() {
-        let that = this;
-        this.dialogCopyVisible = true;
-        if (this.tableRadio.length == 0) {
-          this.$message.error("请先选中一条记录");
-          return false
-        }
-        this.copyForm = that.tableRadio;
-      },
-      // 发布课程表
-      openLessonTable(row) {
-        this.dialogVisible = true;
-        this.form.name = row.name;
-        this.form.Id = row.Id;
-        this.form.week = '';
-      },
-      // 发布
-      public() {
-        let that = this;
-        if (!this.form.week) {
-          this.$message({
-            showClose: true,
-            message: '错了哦,发布周期不能空',
-            type: 'error'
-          });
-          return false
+        } else {
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
         }
+      });
+    },
+    // 删除
+    deleteLessonTable() {
+      let that = this;
+      if (this.tableRadio.length == 0) {
+        this.$message.error("请先选中一条记录");
+        return false
+      }
+      let row = that.tableRadio;
 
-        let param = {
-          token: localStorage.token,
-          detectorid: this.form.Id,
-          week: this.form.week,
-          wechat: this.form.wechat,
-          appoint: this.form.appoint,
-        };
-        let postdata = qs.stringify(param);
-        testSelect(postdata).then(res => {
-          let json = res;
-          if (json.Code == 0) {
-            that.$message({
-              showClose: true,
-              message: this.form.name + '已发布!',
-              type: 'success'
-            });
-            // 重载列表
-            that.getTableQuery();
-            this.dialogVisible = false;
-          } else {
-            that.$message.error(json.Memo + ' 错误码:' + json.Code);
-          }
-        });
-      },
-      // 取消发布
-      unpubilc(row) {
-        let that = this;
-        let param = {
-          token: localStorage.token,
-          detectorid: row.Id,
-          status: 4,//0禁用1启用9删除
-        };
-        let postdata = qs.stringify(param);
-        testSelect(postdata).then(res => {
-          let json = res;
-          if (json.Code == 0) {
-            that.$message({
-              showClose: true,
-              message: '选中的课程表已复制!',
-              type: 'success'
-            });
-            // 重载列表
-            that.getTableQuery();
-          } else {
-            that.$message.error(json.Memo + ' 错误码:' + json.Code);
-          }
-        });
-      },
-      // 编辑课程表
-      goEdit(row) {
-        // 参数???
-        this.$router.push({
-          path: '/editLessonManage', query: {
-            id: row.StbId,
-            name: row.name
-          }
+      if (row.diffweek < 0) {
+        that.$message({
+          showClose: true,
+          message: '已过期的课程表不可删除',
+          type: 'error'
         });
-      },
-      handleSelectionChange(val) {
-        this.multipleSelection = val;
-      },
-      // 查询按钮
-      query() {
-        let that = this;
-        that.serachBtnStatus = true;
-        let totalTime = 2
-        let clock = window.setInterval(() => {
-          totalTime--
-          if (totalTime < 0) {
-            totalTime = 2;
-            that.serachBtnStatus = false;
-          }
-        }, 1000)
-        this.getTableQuery();
-        this.$message.success('查询完毕');
-      },
-      // 页面数据查询
-      getTableQuery() {
-        let that = this;
-        that.loading = true;
+        return false
+      }
+
+      this.$confirm('此操作将永久删除该课程表, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
 
         const jsonStr = {
-          shopId: localStorage.shopId,
-          online: -99,// 0:不上线 1:上线 -99:全部
-          start: that.start,
-          tableMax: that.pageination.pageItem
+          stbId: row.stb_id,
+          status: 9,//9:删除
         };
 
         let paraRequest = new StandardRequest();
@@ -471,21 +260,18 @@
         paraRequest.setJsonstr(JSON.stringify(jsonStr));
         paraRequest.setSign(getSignStr(jsonStr));
         console.log(paraRequest);
-        that.client.sTTBasicQuery(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        that.client.sTTBasicStatusEdit(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
           if (err == null) {
             console.log(StandardReply.getJsonrst());
             let res = JSON.parse(StandardReply);
             if (res.code === 0) {
-              that.loading = false;
-              if (res.rs) {
-                that.allTableData = res.rs;
-                that.recordsTotal = res.rs.length;
-              } else {
-                that.allTableData = [];
-                that.recordsTotal = 0;
-              }
-              // 设置分页数据
-              that.setPaginations();
+              that.$message({
+                showClose: true,
+                message: '选中的课程表已删除!',
+                type: 'success'
+              });
+              // 重载列表
+              that.getTableQuery();
             } else {
               that.$message.error(res.memo + ',错误代码:' + res.code);
             }
@@ -495,70 +281,46 @@
             console.log(res);
           }
         });
-      },
-      // 设置分页数据
-      setPaginations() {
-        // 分页属性
-        let that = this;
-        that.pageination.total = that.recordsTotal;
-        // 默认分页
-        that.tableData = that.allTableData.filter((item, index) => {
-          return index < that.pageination.pageItem;
-        });
-      },
-      // 每页显示数量
-      handleSizeChange() {
-        let that = this;
-        that.tableData = that.allTableData.filter((item, index) => {
-          return index < that.pageination.pageItem;
+
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
         });
-        that.draw = that.pageination.pageItem;
-        that.getTableQuery();
-      },
-      // 翻页
-      pageChange(pageIndex) {
-        let that = this;
-        // 获取当前页
-        let index = that.pageination.pageItem * (pageIndex - 1);
-        // 数据总数
-        let nums = that.pageination.pageItem * pageIndex;
-        // 容器
-        let tables = [];
-        for (var i = index; i < nums; i++) {
-          if (that.allTableData[i]) {
-            tables.push(that.allTableData[i])
-          }
-          this.tableData = tables;
+      });
+    },
+    //刷新按钮
+    refreshQuery() {
+      let that = this;
+      that.serachBtnStatus = true;
+      let totalTime = 2
+      let clock = window.setInterval(() => {
+        totalTime--
+        if (totalTime < 0) {
+          totalTime = 2;
+          that.serachBtnStatus = false;
         }
-        that.start = index * that.draw;
-        // that.getTableQuery();
-      },
-      // 自动排序
-      sortChange(params) {
-        console.log(params)
-      },
-      // 过滤时间
-      filterFmtDate(value, row, column) {
-        let that = this;
-        return nonTfmtDate(column, 11);
-      },
-      // 过滤金额
-      filterMoney(value, row, column) {
-        let that = this;
-        return parseFloat(column).toFixed(2);
-      },
-      // 课程表上下线状态修改
-      changeWechat(e, row) {
-        let that = this;
-        let param = {
-          token: localStorage.token,
-          stbId: row.StbId,//
-          online: e,//
-        };
-        let postdata = qs.stringify(param);
-        STTBasicOfflineEdit(postdata).then(res => {
-          let json = res;
-          if (json.Code == 0) {
+      }, 1000)
+      this.getTableQuery();
+      this.$message.success('查询完毕');
+    },
+    //课程表上下线状态修改
+    changeLessonOnline(e, row) {
+      let that = this;
+      const jsonStr = {
+        stbId: row.stb_id,//
+        online: e,//0:不上线 1:下线
+      };
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sTTBasicOfflineEdit(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
             let text = parseInt(e) == 1 ? '上线' : '下线';
             that.$message({
               showClose: true,
@@ -568,199 +330,399 @@
             // 重载列表
             that.getTableQuery();
           } else {
-            that.$message.error(json.Memo + ' 错误码:' + json.Code);
-            row.online = 0;
+            that.$message.error(res.memo + ',错误代码:' + res.code);
           }
-        })
-      },
+        } else {
+          row.online = 0;
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
+        }
+      });
+    },
+    // 编辑名称
+    editLessonName(row) {
+      this.form.name = row.name;
+      this.form.stbId = row.stb_id;
+      this.dialogNameVisible = true;
     },
-    watch: {
-      $route(to) {
-        if (to.name == 'lessonManage') {
-          this.getTableQuery();
+    // 提交名称修改
+    confirmName() {
+      let that = this;
+      if (!this.form.name) {
+        this.$message.error('名称不能为空');
+        return false
+      }
+      if (this.form.name.length < 3) {
+        this.$message.error('名称不能小于3个字符');
+        return false
+      }
+      if (this.form.name.length > 20) {
+        this.$message.error('名称不能大于20个字符');
+        return false
+      }
+      const jsonStr = {
+        stbId: this.form.stbId,
+        name: this.form.name,
+      };
+
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sTTBasicEdit(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
+            that.$message({
+              showClose: true,
+              message: '名称修改成功!',
+              type: 'success'
+            });
+            this.getTableQuery();
+            this.dialogNameVisible = false;
+          } else {
+            that.$message.error(res.memo + ',错误代码:' + res.code);
+          }
+        } else {
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
         }
-      },
+      });
     },
-    components: {
-      preview
-    }
+    //修改课程表
+    editLessonDetail(row) {
+      console.log(row);
+      this.$router.push({
+        path: '/lessonTableManageEdit', query: {
+          id: row.stb_id,
+          name: row.name,
+          week: getDate(row.begin_date, 0, 0, 1)
+        }
+      });
+    },
+    // 预览本周
+    previewThisWeek(row) {
+      let that = this;
+      const jsonStr = {
+        stbId: row.stb_id
+      };
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sTTBasicPreview(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
+            that.BigTitle = row.name;
+            that.smallTitle = row.begin_date + '至' + row.end_date;
+            if (res.rs) {
+              that.previewDate = res.rs;
+              if (res.rs.sttpreviewclasslist) {
+                // 前台排序
+                that.previewDate.sttpreviewclasslist.sort((a, b) => a.class_index - b.class_index);//升序
+                that.previewShow = true;
+              }
+            } else {
+              that.$message.error('当前课程表为空');
+            }
+          } else {
+            that.$message.error(res.memo + ',错误代码:' + res.code);
+          }
+        } else {
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
+        }
+      });
+    },
+    // 页面数据查询
+    getTableQuery() {
+      let that = this;
+      that.loading = true;
+
+      const jsonStr = {
+        shopId: localStorage.shopId,
+        online: -99,// 0:不上线 1:上线 -99:全部
+        start: that.start,
+        tableMax: that.pageination.pageItem
+      };
+
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sTTBasicQuery(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
+            that.loading = false;
+            if (res.rs) {
+              that.allTableData = res.rs;
+              that.recordsTotal = res.rs.length;
+            } else {
+              that.allTableData = [];
+              that.recordsTotal = 0;
+            }
+            // 设置分页数据
+            that.setPaginations();
+          } else {
+            that.$message.error(res.memo + ',错误代码:' + res.code);
+          }
+        } else {
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
+        }
+      });
+    },
+    // 设置分页数据
+    setPaginations() {
+      // 分页属性
+      let that = this;
+      that.pageination.total = that.recordsTotal;
+      // 默认分页
+      that.tableData = that.allTableData.filter((item, index) => {
+        return index < that.pageination.pageItem;
+      });
+    },
+    // 每页显示数量
+    handleSizeChange() {
+      let that = this;
+      that.tableData = that.allTableData.filter((item, index) => {
+        return index < that.pageination.pageItem;
+      });
+      that.draw = that.pageination.pageItem;
+      that.getTableQuery();
+    },
+    // 翻页
+    pageChange(pageIndex) {
+      let that = this;
+      // 获取当前页
+      let index = that.pageination.pageItem * (pageIndex - 1);
+      // 数据总数
+      let nums = that.pageination.pageItem * pageIndex;
+      // 容器
+      let tables = [];
+      for (var i = index; i < nums; i++) {
+        if (that.allTableData[i]) {
+          tables.push(that.allTableData[i])
+        }
+        this.tableData = tables;
+      }
+      that.start = index * that.draw;
+      // that.getTableQuery();
+    },
+    // 自动排序
+    sortChange(params) {
+      console.log(params)
+    },
+    // 过滤时间
+    filterFmtDate(value, row, column) {
+      let that = this;
+      return nonTfmtDate(column, 11);
+    },
+    // 过滤金额
+    filterMoney(value, row, column) {
+      let that = this;
+      return parseFloat(column).toFixed(2);
+    },
+  },
+  watch: {
+    $route(to) {
+      if (to.name == 'lessonManage') {
+        this.getTableQuery();
+      }
+    },
+  },
+  components: {
+    preview
   }
+}
 </script>
 
 <style scoped>
-  @import "../../assets/css/panel.css";
-
-  .context {
-    /* height: 770px; */
-    overflow-y: scroll;
-    display: block;
-    margin: 0 auto;
-    background-color: #fff !important;
-    padding: 30px;
-    padding-bottom: 60px;
-  }
-
-  .panel-body {
-    padding: 20px;
-    background: #F0F2F5;
-  }
-
-  .change {
-    width: 100%;
-    overflow: hidden;
-    display: block;
-    margin: 0 auto;
-    padding-top: 10px;
-    padding-bottom: 10px;
-  }
-
-  .change button {
-    float: left;
-  }
-
-  .change button.pull-right {
-    float: right;
+@import "../../assets/css/panel.css";
+
+.context {
+  /* height: 770px; */
+  overflow-y: scroll;
+  display: block;
+  margin: 0 auto;
+  background-color: #fff !important;
+  padding: 30px;
+  padding-bottom: 60px;
+}
+
+.panel-body {
+  padding: 20px;
+  background: #F0F2F5;
+}
+
+.change {
+  width: 100%;
+  overflow: hidden;
+  display: block;
+  margin: 0 auto;
+  padding-top: 10px;
+  padding-bottom: 10px;
+}
+
+.change button {
+  float: left;
+}
+
+.change button.pull-right {
+  float: right;
+}
+
+.dialogTitle {
+  width: 100%;
+  overflow: hidden;
+  display: block;
+  margin: 0 auto;
+  color: #000000;
+  font-size: 18px;
+  text-align: center;
+}
+
+.dialogTitle span {
+  width: 169px;
+  height: 40px;
+  line-height: 40px;
+  text-align: center;
+  color: #fff;
+  background: #3799FF;
+  border-radius: 250px;
+  font-size: 18px;
+  overflow: hidden;
+  display: block;
+  margin: 0 auto;
+  margin-bottom: 30px;
+}
+
+.dialogTitle em {
+  float: none;
+  font-style: normal;
+  color: #3799FF;
+  margin: 0;
+}
+
+/deep/ .el-transfer-panel__item .el-checkbox__input {
+  left: 40px;
+}
+
+.dialogFooter {
+  width: 90%;
+  overflow: hidden;
+  display: block;
+  margin: 0 auto;
+  margin-top: 10px;
+}
+
+.dialogFooter button {
+  float: right;
+  margin-left: 10px;
+}
+
+.link {
+  color: #03B1FF;
+  text-decoration: underline;
+}
+
+.readyTime {
+  width: 90%;
+  height: 30px;
+  line-height: 30px;
+  overflow: hidden;
+  display: block;
+  margin: 0 auto;
+  border: 1px solid #FFC769;
+  border-radius: 4px;
+  background: #FFF0D6;
+  text-indent: 14px;
+}
+
+.CurTime {
+  width: 90%;
+  height: 27px;
+  line-height: 30px;
+  overflow: hidden;
+  display: block;
+  margin: 0 auto;
+  border: 1px solid #3799FF;
+  border-radius: 4px;
+  background: #D9ECFF;
+  padding: 3px 6px;
+  text-indent: 14px;
+}
+
+.runTime {
+  width: 90%;
+  /*height: 30px;*/
+  /*line-height: 30px;*/
+  /*overflow: hidden;*/
+  display: block;
+  margin: 0 auto;
+  border: 1px solid #3799FF;
+  border-radius: 4px;
+  background: #D9ECFF;
+  padding: 3px 6px;
+  text-indent: 14px;
+}
+
+.curIcon {
+  position: relative;
+  left: 4px;
+  /*top: -34px;*/
+  width: 24px;
+  height: 24px;
+  float: left;
+  background: url("../../assets/img/lessonTable/star.png") top center no-repeat;
+  background-size: 100% 100%;
+}
+
+.rowHeight {
+  width: 220px;
+  overflow: hidden;
+  display: block;
+  height: 35px;
+  float: left;
+  margin: 0;
+}
+
+/*ipad only*/
+@media only screen and (max-width: 1366px) {
+  .CurTime {
+    width: 98%;
+    font-size: 12px;
+    text-align: left;
+    text-indent: 3px;
+    padding-left: 0;
+    padding-right: 0;
   }
 
-  .dialogTitle {
+  .rowHeight {
     width: 100%;
-    overflow: hidden;
-    display: block;
-    margin: 0 auto;
-    color: #000000;
-    font-size: 18px;
-    text-align: center;
-  }
-
-  .dialogTitle span {
-    width: 169px;
-    height: 40px;
-    line-height: 40px;
-    text-align: center;
-    color: #fff;
-    background: #3799FF;
-    border-radius: 250px;
-    font-size: 18px;
-    overflow: hidden;
-    display: block;
-    margin: 0 auto;
-    margin-bottom: 30px;
-  }
-
-  .dialogTitle em {
-    float: none;
-    font-style: normal;
-    color: #3799FF;
-    margin: 0;
-  }
-
-  /deep/ .el-transfer-panel__item .el-checkbox__input {
-    left: 40px;
-  }
-
-  .dialogFooter {
-    width: 90%;
-    overflow: hidden;
-    display: block;
-    margin: 0 auto;
-    margin-top: 10px;
-  }
-
-  .dialogFooter button {
-    float: right;
-    margin-left: 10px;
-  }
-
-  .link {
-    color: #03B1FF;
-    text-decoration: underline;
   }
 
   .readyTime {
-    width: 90%;
-    height: 30px;
-    line-height: 30px;
-    overflow: hidden;
-    display: block;
-    margin: 0 auto;
-    border: 1px solid #FFC769;
-    border-radius: 4px;
-    background: #FFF0D6;
-    text-indent: 14px;
-  }
-
-  .CurTime {
-    width: 90%;
-    height: 27px;
-    line-height: 30px;
-    overflow: hidden;
-    display: block;
-    margin: 0 auto;
-    border: 1px solid #3799FF;
-    border-radius: 4px;
-    background: #D9ECFF;
-    padding: 3px 6px;
-    text-indent: 14px;
-  }
-
-  .runTime {
-    width: 90%;
-    /*height: 30px;*/
-    /*line-height: 30px;*/
-    /*overflow: hidden;*/
-    display: block;
-    margin: 0 auto;
-    border: 1px solid #3799FF;
-    border-radius: 4px;
-    background: #D9ECFF;
-    padding: 3px 6px;
-    text-indent: 14px;
+    width: 98%;
+    font-size: 12px;
+    text-align: left;
+    text-indent: 3px;
   }
 
   .curIcon {
-    position: relative;
-    left: 4px;
-    /*top: -34px;*/
-    width: 24px;
-    height: 24px;
-    float: left;
-    background: url("../../assets/img/lessonTable/star.png") top center no-repeat;
-    background-size: 100% 100%;
-  }
-
-  .rowHeight {
-    width: 220px;
-    overflow: hidden;
-    display: block;
-    height: 35px;
-    float: left;
-    margin: 0;
-  }
-
-  /*ipad only*/
-  @media only screen and (max-width: 1366px) {
-    .CurTime {
-      width: 98%;
-      font-size: 12px;
-      text-align: left;
-      text-indent: 3px;
-      padding-left: 0;
-      padding-right: 0;
-    }
-
-    .rowHeight {
-      width: 100%;
-    }
-
-    .readyTime {
-      width: 98%;
-      font-size: 12px;
-      text-align: left;
-      text-indent: 3px;
-    }
-
-    .curIcon {
-      left: 0
-    }
+    left: 0
   }
+}
 </style>

+ 1 - 1
src/views/SttPlan/LessonTableTemplateEdit.vue

@@ -342,7 +342,7 @@ export default {
           if (res.code === 0) {
             let id = that.$route.query.id;
             // 提交课程内容
-            that.LessonTableTemplateEdit(id);
+            that.LessonTemplateEdit(id);
           } else {
             that.$message.error(res.memo + ',错误代码:' + res.code);
           }