zhengwei 4 éve
szülő
commit
cd153b2cb6

+ 3 - 3
src/Mock/index.js

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

+ 57 - 21
src/components/Headside.vue

@@ -1,28 +1,25 @@
 <template>
   <div id="headside">
     <nav class="navbar user-info-navbar" role="navigation">
-      <i
-          :class="[{ 'el-icon-s-unfold left_hide_icon': left_panel_state }, { 'el-icon-s-fold left_show_icon': !left_panel_state }]"
+      <i :class="[{ 'el-icon-s-unfold left_hide_icon': left_panel_state }, { 'el-icon-s-fold left_show_icon': !left_panel_state }]"
           @click="left_hide"
-      ></i>
+      />
       <span class="title">
 				场馆管理系统
 			</span>
       <ul class="user-info-menu pull-right  list-unstyled">
-
         <span class="customer_serve logoutBtn" @click="logoutClick">
-					<i class="el-icon-switch-button"></i> 退出</span
-        >
+		  		<i class="el-icon-switch-button"/>
+          退出
+        </span>
+        <span v-if="canChange == 1">
+          <span class="customer_serve changeShopBtn" @click="changeShop">切换店铺</span>
+        </span>
+
+        <span class="el-dropdown-link customer_serve shopinfo">{{ ShopName }}</span>
         <span class="el-dropdown-link customer_serve">{{ user.name }}</span>
-        <span class="el-dropdown-link customer_serve shopinfo">
-					<span>{{ ShopName }}</span>
-					<span>{{ userLevelText }}</span>
-				</span>
-        <span class="customer_serve changeShopBtn" @click="changeShop">
-          切换店铺
-        </span
-        >
       </ul>
+
       <div class="tabs">
         <el-tabs v-model="editableTabsValue" type="card" editable @edit="handleTabsEdit" @tab-remove="remove">
           <el-tab-pane
@@ -47,7 +44,7 @@ export default {
   data() {
     return {
       user: {
-        name: "admin",
+        name: '',
       },
       time: "8:30-17:30",
       tel: "0000-0079-000",
@@ -56,13 +53,14 @@ export default {
       newnumState: false,
       left_panel_state: true,
       screen_full: false,
-      ShopName: "",
+      ShopName: localStorage.shopName,
       userLevelText: "",
       current: globalcurrentWeek(),
       // tabs
       editableTabsValue: '',
       editableTabs: [],
-      tabIndex: 2
+      tabIndex: 2,
+      canChange:0
     };
   },
   props: ['tableTabs'],
@@ -79,6 +77,10 @@ export default {
   },
   mounted() {
     this.left_hide();//默认展开侧边栏
+    this.name = localStorage.shopName;
+    this.user.name = localStorage.userName;
+    this.canChange = localStorage.canChange;
+    console.log(localStorage.canChange);
     // this.getManagerSelfQuery();// TODO 待重构
   },
   methods: {
@@ -135,7 +137,7 @@ export default {
         } else {
           if (json.Code == 1010) {
             that.$message.error(json.Memo + " 错误码:" + json.Code);
-            that.$router.push({path: "/login", query: {status : 1}});
+            that.$router.push({path: "/login", query: {status: 1}});
             return false;
           } else {
             that.$message.error(json.Memo + " 错误码:" + json.Code);
@@ -174,7 +176,7 @@ export default {
           })
           .then(() => {
             let that = this;
-            that.$router.push({path: "/login", query: {status: 1}});
+            that.$router.push({path: "/login", query: {status: 10010}});
             that.$message({
               showClose: true,
               message: "当前用户已退出登陆!",
@@ -194,7 +196,7 @@ export default {
           })
           .then(() => {
             let that = this;
-            that.$router.push({path: "/login", query: {status: 1}});
+            that.$router.push({path: "/login", query: {status: 10011}});
             let param = {
               token: localStorage.token,
             };
@@ -290,7 +292,6 @@ li {
   }
 }
 
-
 .customer_serve {
   float: right;
   margin-right: 20px;
@@ -301,6 +302,15 @@ li {
 }
 
 .logoutBtn {
+  width: 80px;
+  height: 20px;
+  text-align: center;
+  line-height: 20px;
+  margin-top: 10px;
+  padding: 0;
+  border-radius: 250px;
+  color: white;
+  background-color: #e30000;
   cursor: pointer;
 }
 
@@ -467,5 +477,31 @@ li {
     text-align: right;
     line-height: 45px;
   }
+
+  .logoutBtn {
+    width: 80px;
+    height: 20px;
+    text-align: center;
+    line-height: 20px;
+    margin-top: 10px;
+    padding: 0;
+    border-radius: 250px;
+    color: white;
+    background-color: #e30000;
+    cursor: pointer;
+  }
+  .changeShopBtn {
+    width: 80px;
+    height: 20px;
+    text-align: center;
+    line-height: 20px;
+    margin-top: 10px;
+    padding: 0;
+    border-radius: 250px;
+    color: white;
+    background-color: #E38F00;
+    cursor: pointer;
+  }
+
 }
 </style>

+ 5 - 5
src/components/preview.vue

@@ -24,15 +24,15 @@
                 </div>
                 <!--                1-->
                 <div class="rows" v-for="i in 7">
-                    <em :style="{background:tab.ClassColor}" v-for="tab in previewDate.sttplanpreviewclasslist"
+                    <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.ClassColor}" v-for="tab in previewDate.SttPreviewClassList"
-                        v-if="tab.WeekDay == i">
-                        {{tab.ClassName}}
+                    <em :style="{background:tab.class_color}" v-for="tab in previewDate.sttreviewclasslist"
+                        v-if="tab.week_day == i">
+                        {{tab.class_name}}
                     </em>
-                </div><!--                2-->
+                </div>
             </div>
         </div>
     </div>

+ 18 - 10
src/router/index.js

@@ -54,29 +54,37 @@ const routes = [
                     // clmid: "3",
                 }
             }, {
-                path: '/lessonTemplate',
-                name: 'lessonTemplate',
-                component: () => import('@/views/Class/LessonTemplate.vue'),
+                path: '/lessonTableTemplate',
+                name: 'lessonTableTemplate',
+                component: () => import('@/views/Class/LessonTableTemplate.vue'),
                 meta: {
                     title: "课程表模板",
                     // clmid: "4",
                 }
             }, {
-                path: '/lessonTemplateEdit',
-                name: 'lessonTemplateEdit',
-                component: () => import('@/views/SttPlan/LessonTemplateEdit.vue'),
+                path: '/lessonTableTemplateEdit',
+                name: 'lessonTableTemplateEdit',
+                component: () => import('@/views/SttPlan/LessonTableTemplateEdit.vue'),
                 meta: {
                     title: "编辑课程表模板",
                     // clmid: "4",
                 }
             }, {
-                path: '/lessonManage',
-                name: 'lessonManage',
-                component: () => import('@/views/SchoolTimeTable/LessonManage.vue'),
+                path: '/lessonTableManage',
+                name: 'lessonTableManage',
+                component: () => import('@/views/Class/LessonTableManage.vue'),
                 meta: {
                     title: "课程表管理",
                     // clmid: "5",
                 }
+            }, {
+                path: '/lessonTableManageEdit',
+                name: 'lessonTableManageEdit',
+                component: () => import('@/views/SchoolTimeTable/LessonTableManageEdit.vue'),
+                meta: {
+                    title: "编辑课程表",
+                    // clmid: "5",
+                }
             }, {
                 path: '/adminManage',
                 name: 'AdminManage',
@@ -120,7 +128,7 @@ const routes = [
             }, {
                 path: '/lessonManage',
                 name: 'lessonManage',
-                component: () => import('@/views/Class/lessonManage.vue'),
+                component: () => import('@/views/Class/LessonTableManage.vue'),
                 meta: {
                     title: "课程表管理",
                     // clmid: "5",

+ 26 - 53
src/views/Auth/Login.vue

@@ -95,15 +95,20 @@ export default {
     }
   },
   mounted() {
+    let that = this;
     this.overtime = new Date();
     this.getGenVerifyPic();
     // 如果是手动退出用户
-    if (this.$route.query.status === 1) {
+    if (that.$route.query.status == 10010) {
       // 刷新验证图
-      this.changeValImg();
+      that.changeValImg();
       // 重置倒计时
-      this.overtime = new Date();
-      console.log(1212121222);
+      that.overtime = new Date();
+      console.log(localStorage.token);
+    }
+    // 如果是切换店铺
+    if (that.$route.query.status == 10011) {
+      this.checkUserShopList();
     }
     // checkScreen
     if (document.body.clientWidth < 1024) {
@@ -216,20 +221,24 @@ export default {
                 if (res.length === 1) {
                   localStorage.shopId = res[0].getShopuuid();
                   localStorage.shopName = res[0].getName();
+                  localStorage.userName = res[0].getContacts();
+                  localStorage.canChange = 0;
+
                   console.log(localStorage.shopId);
-                  if(res[0].getStatus(0) === 1){
+                  if (res[0].getStatus(0) === 1) {
                     that.$router.push({path: '/'});
-                  }else{
-                    that.$message.error( '该商家当前状态异常' + res[0].getStatus());
+                  } else {
+                    that.$message.error('该商家当前状态异常' + res[0].getStatus());
                   }
                 }
                 // //账号下有多家店铺
                 if (res.length > 1) {
                   that.selectShop = true;
+                  localStorage.canChange = 1;
                   let jsonObjList = [];
                   res.forEach((item, i) => {
-                    console.log(i,item.getShopuuid());
-                    let jsonObj = {shopId: "",name: "", addr: "", contacts: "",status:1};
+                    console.log(i, item.getShopuuid());
+                    let jsonObj = {shopId: "", name: "", addr: "", contacts: "", status: 1};
                     jsonObj.shopId = item.getShopuuid();
                     jsonObj.name = item.getName();
                     jsonObj.addr = item.getAddr();
@@ -251,9 +260,14 @@ export default {
     //提交选中行事件
     enterShop() {
       let that = this;
-      console.log(this.currentRow);
-      localStorage.shopId = this.currentRow.shopId;
-      localStorage.shopName = this.currentRow.name;
+      if (that.currentRow == null || that.currentRow.length == 0) {
+        this.$message.error("请先选中商家");
+        return false
+      }
+      console.log(that.currentRow);
+      localStorage.shopId = that.currentRow.shopId;
+      localStorage.shopName = that.currentRow.name;
+      localStorage.userName = that.currentRow.contacts;
       if (this.currentRow.status === 1) {
         that.$router.push({path: '/'});
       } else {
@@ -269,47 +283,6 @@ export default {
         let res = response.toObject()
         console.log(res);
       });
-
-      // let param = {
-      //   token: localStorage.token,
-      // };
-
-      // let postdata = qs.stringify(param);
-      // console.log(postdata);
-
-      // ManagerSelfQuery(postdata).then(res => {
-      //   let json = res;
-      //   if (json.Code == 0) {
-      //     that.userLevelText = json.Rs.Role.Name;
-      //     // 1 会员 2 系统 3 店铺 4 教练
-      //     that.userLevel = json.Rs.Role.Id;
-      //     localStorage.shopId = json.Rs.ShopId;
-      //     localStorage.ShopId = json.Rs.ShopId;
-      //
-      //     switch (parseInt(that.userLevel)) {
-      //       case 1:
-      //         that.$router.push({path: '/'});
-      //         break;
-      //       case 2:
-      //         that.$router.push({path: '/shopManage'});
-      //         break;
-      //       case 3:
-      //         that.$router.push({path: '/'});
-      //         break;
-      //       case 4:
-      //         that.$router.push({path: '/'});
-      //         break;
-      //
-      //     }
-      //   } else {
-      //     if (json.Code == 1010) {
-      //       that.$message.error(json.Memo + ' 错误码:' + json.Code);
-      //       that.$router.push({path: '/login', query: {status: 1}});
-      //       return false
-      //     }
-      //     that.$message.error(json.Memo + ' 错误码:' + json.Code);
-      //   }
-      // })
     }
   },
 }

+ 66 - 60
src/views/Class/lessonManage.vue → src/views/Class/LessonTableManage.vue

@@ -4,9 +4,9 @@
       <h5>课程表管理</h5>
     </div>
     <div class="change">
-      <el-button type="primary" @click="addLessonTable" v-if="userLevel != 4" size="mini">新增课程表</el-button>
-      <el-button type="" @click="copy" v-if="userLevel != 4" size="mini">复制</el-button>
-      <el-button type="" @click="delList" v-if="userLevel != 4" size="mini">删除</el-button>
+      <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>
     </div>
     <div class="table">
@@ -24,42 +24,42 @@
             <span>{{(start) + scope.$index + 1}}</span>
           </template>
         </el-table-column>
-        <el-table-column prop="Name" label="日期">
+        <el-table-column prop="data" label="日期">
           <template slot-scope="scope">
             <div class="rowHeight">
-              <!--                            已过期-->
-              <span class="readyTime" v-if="scope.row.Diffweek < 0">
-                {{ scope.row.BeginDate }} - {{ scope.row.EndDate }}
+              <!--已过期-->
+              <span class="readyTime" v-if="scope.row.diffweek < 0">
+                {{ scope.row.begin_date }} 至 {{ scope.row.end_date }}
               </span>
-              <!--                            已上线-->
-              <span class="CurTime" v-if="scope.row.Diffweek >= 0">
-                {{ scope.row.BeginDate }} - {{ scope.row.EndDate }}
+              <!--已上线-->
+              <span class="CurTime" v-if="scope.row.diffweek >= 0">
+                {{ scope.row.begin_date }} 至 {{ scope.row.end_date }}
               </span>
-              <!--                            当前进行-->
-              <i class="curIcon" v-if="scope.row.Status == 1 && scope.row.Diffweek == 0"></i>
-              <span class="runTime" v-if="scope.row.Status == 2 ">
-                {{ scope.row.BeginDate }} - {{ scope.row.EndDate }}
+              <!--当前进行-->
+              <span v-if="scope.row.diffweek == 0">
+              <i class="curIcon"/>
+              <span class="runTime">{{ scope.row.begin_date }} 至 {{ scope.row.end_date }}</span>
               </span>
             </div>
           </template>
         </el-table-column>
-        <el-table-column prop="Name" label="课程表名称" sortable>
+        <el-table-column prop="name" label="课程表名称" sortable>
         </el-table-column>
-        <el-table-column prop="CreateColumn.CreatedAt" label="最后编辑时间" :formatter="filterFmtDate" sortable>
+        <el-table-column prop="created_at" label="最后编辑时间" :formatter="filterFmtDate" sortable>
         </el-table-column>
-        <el-table-column prop="Online" label="是否上线" width=120px sortable v-if="userLevel != 4">
+        <el-table-column prop="online" label="是否上线" width=120px sortable>
           <!--                    上线状态	0:不上线 1:下线-->
           <template slot-scope="scope">
-            <el-switch v-model="scope.row.Online" :active-value="1" :inactive-value="0" active-color="#409EFF"
+            <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>
           </template>
         </el-table-column>
         <el-table-column prop="Status" label="操作">
           <template slot-scope="scope">
-            <el-button type="text" v-if="scope.row.Diffweek >= 0 && userLevel != 4" @click="editName(scope.row)">编辑名称
+            <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  && userLevel != 4" @click="goEdit(scope.row)">修改课程
+            <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>
           </template>
@@ -143,16 +143,10 @@
 <script>
   import Global from '../../Global.js'
   import preview from '../../components/preview'
+
   import {
-    STTBasicListQuery,
-    STTBasicOfflineEdit,
-    STTBasicStatusEdit,
-    SchoolTimeTableCopy,
-    STTBasicEdit,
-    testSelect,
-    SttPlanPreview,
-    SchoolTimetablePreview,
-  } from "../../api/getApiRes";
+    StandardRequest
+  } from "@/grpc/base_pb";
 
   let qs = require('qs');
   export default {
@@ -195,7 +189,6 @@
         },
         tableData: [],
         tableRadio: [],
-        userLevel: localStorage.userLevel
       }
     },
     mounted() {
@@ -207,7 +200,7 @@
       },
       // 编辑名称
       editName(row) {
-        this.form.name = row.Name;
+        this.form.name = row.name;
         this.form.stbId = row.StbId;
         this.dialogNameVisible = true;
       },
@@ -223,8 +216,8 @@
         SchoolTimetablePreview(postdata).then(res => {
           let json = res;
           if (json.Code == 0) {
-            that.BigTitle = row.Name;
-            that.smallTitle = row.BeginDate + '至' + row.EndDate;
+            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);//升序
@@ -236,7 +229,7 @@
       },
       addLessonTable() {
         this.$router.push({
-          path: '/editLessonManage', query: {
+          path: '/lessonTableManageEdit', query: {
             id: 0
           }
         });
@@ -250,7 +243,7 @@
         }
         let row = that.tableRadio;
 
-        if (row.Diffweek < 0) {
+        if (row.diffweek < 0) {
           that.$message({
             showClose: true,
             message: '已过期的课程表不可删除',
@@ -439,7 +432,7 @@
         this.$router.push({
           path: '/editLessonManage', query: {
             id: row.StbId,
-            name: row.Name
+            name: row.name
           }
         });
       },
@@ -465,30 +458,43 @@
       getTableQuery() {
         let that = this;
         that.loading = true;
-        let param = {
-          token: localStorage.token,
-          start: 1,//
-          tableMax: 9999,//
+
+        const jsonStr = {
+          shopId: localStorage.shopId,
+          online: -99,// 0:不上线 1:上线 -99:全部
+          start: that.start,
+          tableMax: that.pageination.pageItem
         };
-        let postdata = qs.stringify(param);
-        STTBasicListQuery(postdata).then(res => {
-          let json = res;
-          if (json.Code == 0) {
-            that.loading = false;
-            if (json.Rs) {
-              that.allTableData = json.Rs;
-              that.recordsTotal = json.Rs.length;
+
+        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.allTableData = [];
-              that.recordsTotal = 0;
+              that.$message.error(res.memo + ',错误代码:' + res.code);
             }
-
-            // 设置分页数据
-            that.setPaginations();
           } else {
-            that.$message.error(json.Memo + ' 错误码:' + json.Code);
+            let res = err;
+            that.$message.error(res.message + ',错误代码:' + res.code);
+            console.log(res);
           }
-        })
+        });
       },
       // 设置分页数据
       setPaginations() {
@@ -563,7 +569,7 @@
             that.getTableQuery();
           } else {
             that.$message.error(json.Memo + ' 错误码:' + json.Code);
-            row.Online = 0;
+            row.online = 0;
           }
         })
       },
@@ -699,9 +705,9 @@
 
   .runTime {
     width: 90%;
-    height: 30px;
-    line-height: 30px;
-    overflow: hidden;
+    /*height: 30px;*/
+    /*line-height: 30px;*/
+    /*overflow: hidden;*/
     display: block;
     margin: 0 auto;
     border: 1px solid #3799FF;
@@ -714,7 +720,7 @@
   .curIcon {
     position: relative;
     left: 4px;
-    top: -34px;
+    /*top: -34px;*/
     width: 24px;
     height: 24px;
     float: left;

+ 0 - 816
src/views/SchoolTimeTable/LessonManage.vue

@@ -1,816 +0,0 @@
-<template>
-    <div class="context">
-        <div class="panel">
-            <h5>{{ pageTitle }}</h5>
-        </div>
-        <div class="panel-body">
-            <div class="panel_control">
-                <el-row :gutter="20">
-                    <el-col :span="5">
-                        <em>
-                            <span style="color: red">*</span> 课程表名称:
-                        </em>
-                        <el-input
-                            v-model="panel.name"
-                            placeholder="请输入课程表名称"
-                            :disabled="panel.inputState"
-                        ></el-input>
-                    </el-col>
-                    <el-col :span="5" v-if="!panel.inputState">
-                        <em>
-                            <span style="color: red">*</span> 课程表时间:
-                        </em>
-                        <el-date-picker
-                            v-model="panel.week"
-                            type="week"
-                            :picker-options="{ 'firstDayOfWeek': 1 }"
-                            format="yyyy 第 WW 周"
-                            placeholder="选择周"
-                        ></el-date-picker>
-                    </el-col>
-                    <!--        todo-->
-                    <!--        <el-button class="seeTemp">预览课程表</el-button>-->
-                    <el-button
-                        type="default"
-                        class="seeTemp"
-                        @click="$router.push('/lessonManage')"
-                    >返回课程表</el-button>
-                </el-row>
-            </div>
-        </div>
-        <br />
-        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
-            <el-tab-pane label="星期一" name="1"></el-tab-pane>
-            <el-tab-pane label="星期二" name="2"></el-tab-pane>
-            <el-tab-pane label="星期三" name="3"></el-tab-pane>
-            <el-tab-pane label="星期四" name="4"></el-tab-pane>
-            <el-tab-pane label="星期五" name="5"></el-tab-pane>
-            <el-tab-pane label="星期六" name="6"></el-tab-pane>
-            <el-tab-pane label="星期天" name="7"></el-tab-pane>
-        </el-tabs>
-
-        <!--        todo 读取后台保存状态,新保存后不跳走-->
-        <div class="table">
-            <el-table
-                v-for="tab in tabs"
-                :data="tab.tableData"
-                v-if="tab.days == activeName"
-                border
-                is-horizontal-resize
-                :default-sort="{ prop: 'date', order: 'descending' }"
-                element-loading-background="rgba(0, 0, 0, 0.8)"
-                class
-                @selection-change="handleSelectionChange"
-            >
-                >
-                <el-table-column prop="timeScope" label="时间" width="230px" align="center">
-                    <template slot-scope="scope">
-                        <el-time-picker
-                            is-range
-                            v-model="scope.row.timeLong"
-                            range-separator="至"
-                            start-placeholder="开始时间"
-                            end-placeholder="结束时间"
-                            placeholder="选择时间范围"
-                            :readonly="scope.row.Locking == 1"
-                        ></el-time-picker>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="ClassId" label="课程" align="center">
-                    <!--                    locking是1的不可编辑课程和时间-->
-                    <template slot-scope="scope">
-                        <el-select
-                            v-model="scope.row.ClassId"
-                            @change="getRowTop(scope.row)"
-                            :disabled="scope.row.Locking == 1"
-                        >
-                            <el-option
-                                v-for="item in panel.options"
-                                :key="item.value"
-                                :label="item.label"
-                                :value="item.value"
-                            ></el-option>
-                        </el-select>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="OrderToplimit" label="预约名额" align="center">
-                    <template slot-scope="scope">
-                        <el-input-number
-                            v-model="scope.row.OrderToplimit"
-                            :min="1"
-                            :max="9999"
-                            label
-                        ></el-input-number>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="ConsumeHour" label="消耗课时" align="center">
-                    <template slot-scope="scope">
-                        <el-input-number v-model="scope.row.ConsumeHour" :min="0" :max="9999" label></el-input-number>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="WxVisible" label="微信可见" width="80px">
-                    <template slot-scope="scope">
-                        <el-switch
-                            v-model="scope.row.WxVisible"
-                            :active-value="1"
-                            :inactive-value="0"
-                            active-color="#409EFF"
-                            inactive-color="#D9D9D9"
-                            @change="changeWechat($event, scope.row)"
-                        ></el-switch>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="WxOrder" label="微信预约" width="80px">
-                    <template slot-scope="scope">
-                        <el-switch
-                            v-model="scope.row.WxOrder"
-                            :active-value="1"
-                            :inactive-value="0"
-                            active-color="#409EFF"
-                            inactive-color="#D9D9D9"
-                            @change="changeWechatOrder($event, scope.row.ClassSelf)"
-                        ></el-switch>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="Status" label="操作" width="70px" align="center">
-                    <template slot-scope="scope">
-                        <el-button
-                            type="text"
-                            class="red"
-                            @click="delRow(scope)"
-                            v-if="scope.row.Locking != 1"
-                        >删除</el-button>
-                        <el-button
-                            type="text"
-                            class="gary"
-                            @click="delRow(scope)"
-                            v-if="scope.row.Locking == 1"
-                        >删除</el-button>
-                    </template>
-                </el-table-column>
-            </el-table>
-            <div class="rowBottom">
-                <el-button type="default" @click="$router.push('/lessonManage')">返回课程表</el-button>
-                <!--                ID为0是新建,不为0是修改-->
-                <el-button
-                    type="primary"
-                    class="pull-right"
-                    @click="confirmLessonTable"
-                    v-if="this.$route.query.id == 0"
-                    :disabled="serachBtnStatus"
-                >提交</el-button>
-                <el-button
-                    type="primary"
-                    class="pull-right"
-                    @click="confirmEditLessonTable"
-                    v-if="this.$route.query.id != 0"
-                    :disabled="serachBtnStatus"
-                >提交</el-button>
-                <el-button type="primary" class="pull-right" @click="addRow">新增课表</el-button>
-            </div>
-            <div>
-                <br />
-                <em class="red wrning">*所有操作提交后生效</em>
-            </div>
-        </div>
-        <br />
-        <el-dialog title="增删课程会员" :visible.sync="dialogVisible">
-            <div class="dialogTitle">
-                <span>基础功能</span>
-            </div>
-            <div>
-                <el-transfer filterable v-model="dialogValue" :data="dialogdata"></el-transfer>
-            </div>
-            <div class="dialogFooter">
-                <el-button type="primary" size="small">确定</el-button>
-                <el-button @click="dialogVisible = false" size="small">取消</el-button>
-            </div>
-        </el-dialog>
-    </div>
-</template>
-
-<script>
-import Global from '../../Global.js'
-import {
-    SttPlanBasicAdd,
-    SttPlanDetailListQuery,
-    SttPlanDetailBatchSave,
-    STTBasicAdd,
-    SttPlanBasicEdit,
-    STTDetailListQuery,
-    STTDetailBatchSave,
-    STTBasicEdit,
-    testTable,
-    testTableLong,
-    testSelect,
-    ClassListQuery,
-    STTDetailAllowDelCheck,
-    ClassDetailOne
-} from "../../api/getApiRes";
-
-let qs = require('qs');
-export default {
-    data() {
-        return {
-            pageTitle: '新增课程表',
-            dialogVisible: false,
-            dialogdata: [],
-            dialogValue: [],
-            temId: '',
-            activeName: '1',
-            tableData: [],
-            // panel 配置项目
-            panel: {
-                inputState: false,
-                name: '',
-                usercode: '',
-                username: '',
-                compname: '',
-                keyword: '',
-                USERCODE: '',
-                week: '',
-                taskstatus: 99,
-                draw: 1,
-                start: 0,
-                recordsTotal: 0,
-                tableData: [],
-                allTableData: [],
-                limit: '10',
-                multipleSort: false,
-                loading: false,
-                fileList: [],
-                multipleSelection: [],
-                detectedmac: '',
-                options: [],
-                time1: globalBt(),
-            },
-            multipleSelection: [],
-            pageination: {
-                pageItem: 10,
-                pageoptions: pageOptions(),
-                total: 100,
-                pageIndex: 1,
-            },
-            testRow: {
-                timeLong: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 23, 59)],
-                BeginStr: '08:30',
-                EndStr: '23:59',
-                ClassId: '',
-                OrderToplimit: 1,
-                ConsumeHour: 1,
-                WxOrder: 1,
-                WxVisible: 0,
-            },
-            tabs: [
-                {
-                    tableData: [], days: '1'
-                },
-                {
-                    tableData: [], days: '2'
-                },
-                {
-                    tableData: [], days: '3'
-                },
-                {
-                    tableData: [], days: '4'
-                },
-                {
-                    tableData: [], days: '5'
-                },
-                {
-                    tableData: [], days: '6'
-                },
-                {
-                    tableData: [], days: '7'
-                },
-            ],
-            serachBtnStatus: false,
-        }
-    },
-    mounted() {
-        // 加载课程选项
-        this.panelSelect();
-        if (parseInt(this.$route.query.id) == 0) {
-            //  深拷贝赋初始值
-            this.pageTitle = '新增课程表'
-            this.deepValue();
-            this.panel.name = '';
-            this.panel.week = '';
-            this.panel.inputState = false
-        } else {
-            // 读取赋值
-            this.pageTitle = '编辑课程表'
-            this.getTableQuery();
-            this.panel.inputState = true
-        }
-    },
-    methods: {
-        // 加载选项
-        panelSelect() {
-            let that = this;
-            let param = {
-                token: localStorage.token,
-                vipType: '',
-                start: 1,
-                expDay: 0,
-                tableMax: 9999,
-            };
-            let postdata = qs.stringify(param);
-            ClassListQuery(postdata).then(res => {
-                let json = res;
-                if (json.Code == 0) {
-                    // that.dialogdata = json.Rs;
-                    if (json.Rs == null) return false
-                    that.panel.options = turnClassResToOption(json.Rs)
-                    console.log(that.panel.options);
-                } else {
-                    that.$message.error(json.Memo + ' 错误码:' + json.Code);
-                }
-            })
-        },
-        // 选择课程后,获取当前课程的建议上课人数和课时消耗
-        getRowTop(row) {
-            let that = this;
-            console.log(row);
-            let param = {
-                token: localStorage.token,
-                classId: row.ClassId,
-            };
-            let postdata = qs.stringify(param);
-            ClassDetailOne(postdata).then(res => {
-                let json = res;
-                if (json.Code == 0) {
-                    row.OrderToplimit = json.Rs.TopLimit;
-                    row.ConsumeHour = json.Rs.ConsumeHour;
-                    // row.WxOrder = json.Rs.WxOrder; //不支持联动
-                    row.WxVisible = json.Rs.WxVisible;
-                } else {
-                    that.$message.error(json.Memo + ' 错误码:' + json.Code);
-                }
-            })
-        },
-        confirmEditLessonTable() {
-            let id = this.$route.query.id
-            // 提交课程内容,不再修改课程名称和时间的信息
-            this.EditLessonTable(id);
-        },
-        // 删除
-        delRow(scope) {
-            if (!scope.row.StdId) {
-                let delIndex = parseInt(scope.$index)
-                let curIndex = parseInt(this.activeName) - 1;
-                this.tabs[curIndex].tableData.splice(delIndex, 1)
-            } else {
-                this.checkCannotDel(scope)
-            }
-        },
-        // 检测课表中课程可否删除
-        checkCannotDel(scope) {
-            let that = this;
-            let param = {
-                token: localStorage.token,
-                stdId: scope.row.StdId,
-            };
-            let postdata = qs.stringify(param);
-            STTDetailAllowDelCheck(postdata).then(res => {
-                let json = res;
-                if (json.Code == 0) {
-                    let delIndex = parseInt(scope.$index)
-                    let curIndex = parseInt(this.activeName) - 1;
-                    this.tabs[curIndex].tableData.splice(delIndex, 1)
-                } else {
-                    that.$message.error(json.Memo + ' 错误码:' + json.Code);
-                }
-            })
-        },
-        // 提交课程
-        confirmLessonTable() {
-            if (!this.panel.name) {
-                this.$message.error('名称不能为空');
-                return false
-            }
-            if (this.panel.name.length < 3) {
-                this.$message.error('名称不能小于3个字符');
-                return false
-            }
-            if (this.panel.name.length > 20) {
-                this.$message.error('名称不能大于20个字符');
-                return false
-            }
-            if (!this.checkData()) {
-                return false
-            }
-
-            let that = this;
-
-            that.serachBtnStatus = true;
-            let totalTime = 2
-            let clock = window.setInterval(() => {
-                totalTime--
-                if (totalTime < 0) {
-                    totalTime = 2;
-                    that.serachBtnStatus = false;
-                }
-            }, 1000)
-
-
-            let param = {
-                token: localStorage.token,
-                name: this.panel.name,
-                incomingDate: nonTfmtDatetoLength(this.panel.week, 10),//对应日期 字符串 年-月-日 格式,
-            };
-            let postdata = qs.stringify(param);
-            STTBasicAdd(postdata).then(res => {
-                let json = res;
-                if (json.Code == 0) {
-                    that.panel.tabId = json.Id;
-                    // 提交课程内容
-                    that.EditLessonTable(json.Id);
-                } else {
-                    that.$message.error(json.Memo + ' 错误码:' + json.Code);
-                }
-            })
-        },
-        // 保存课程
-        EditLessonTable(planId) {
-            let that = this;
-            // 校验提交的数据
-            if (!this.checkData()) {
-                return false
-            }
-            // 提交数据
-            let planRs = [];
-            let thisRow = {};
-            for (let i = 0; i < this.tabs.length; i++) {
-                for (let j = 0; j < this.tabs[i].tableData.length; j++) {
-                    thisRow = this.tabs[i].tableData[j];
-                    thisRow.LessonIndex = parseInt(j + 1);
-                    if (planId) {
-                        thisRow.StbId = parseInt(planId);
-                    } else {
-                        thisRow.StbId = parseInt(this.$route.query.id);
-                    }
-                    thisRow.WeekDay = parseInt(i + 1);
-                    thisRow.BeginStr = getHoursAndMin(thisRow.timeLong[0]);
-                    thisRow.EndStr = getHoursAndMin(thisRow.timeLong[1]);
-                    thisRow.StdId = thisRow.StdId ? thisRow.StdId : 0;
-                    this.$delete(thisRow, 'Base');
-                    this.$delete(thisRow, 'SpdId');
-                    planRs.push(thisRow);
-                }
-            }
-
-            let res = JSON.stringify(planRs);
-            // 如果传入0就用url里的,如果非0就用传入的
-            // let uploadPlanId = planId == 0 ? this.$route.query.id : planId;
-            let param = {
-                token: localStorage.token,
-                stbId: planId,
-                stbRs: res,
-            };
-            let postdata = qs.stringify(param);
-            STTDetailBatchSave(postdata).then(res => {
-                let json = res;
-                if (json.Code == 0) {
-                    that.$message({
-                        showClose: true,
-                        message: '课程已上传成功!',
-                        type: 'success'
-                    });
-                    this.$router.push({
-                        path: '/lessonManage'
-                    });
-                    // 提交后清掉内存里的课表
-                    this.clearTableRAM();
-                    // this.getTableQuery();
-                } else {
-                    this.$router.push({
-                        path: '/lessonManage'
-                    });
-                    // 提交后清掉内存里的课表
-                    this.clearTableRAM();
-                    that.$message.error(json.Memo + ' 错误码:' + json.Code);
-                }
-            })
-        },
-        clearTableRAM() {
-            this.tabs = [
-                {
-                    tableData: [], days: '1'
-                },
-                {
-                    tableData: [], days: '2'
-                },
-                {
-                    tableData: [], days: '3'
-                },
-                {
-                    tableData: [], days: '4'
-                },
-                {
-                    tableData: [], days: '5'
-                },
-                {
-                    tableData: [], days: '6'
-                },
-                {
-                    tableData: [], days: '7'
-                },
-            ];
-
-        },
-        checkData() {
-            let res = true
-            for (let i = 0; i < this.tabs.length; i++) {
-                for (let j = 0; j < this.tabs[i].tableData.length; j++) {
-                    if (!this.tabs[i].tableData[j].ClassId) {
-                        let days = numberToWeekdays(i + 1);
-                        let lessonIndex = j + 1;
-                        this.$message.error(days + '第' + lessonIndex + '节课有课程未选择,请选择后再提交')
-                        res = false
-                        break;
-                    }
-                }
-            }
-            return res
-        },
-        // 检查数据
-        checkData2() {
-            // todo
-            let tableDate = this.tabs;
-            tableDate.map(function(item) {
-                console.log(item);
-            })
-        },
-        // 新增一行
-        addRow() {
-            // 读取当前周几
-            let index = parseInt(this.activeName) - 1;
-            let rows = this.testRow;
-            let res = this.deepClone(rows);
-            this.tabs[index].tableData.push(res);
-        },
-        //  深拷贝赋初始值
-        deepValue() {
-            let that = this;
-            let valus = [
-                this.testRow
-            ];
-            this.tabs.map(function(item) {
-                let res = that.deepClone(valus);
-                item.tableData = res;
-            })
-        },
-        deepClone(obj) {
-            let _obj = JSON.stringify(obj),
-                objClone = JSON.parse(_obj);
-            return objClone
-        },
-        handleClick() {
-        },
-        changeWechat(e, row) {
-            // if(parseInt(e) == 0){
-            //     this.$message.success('当前课程微信已不可见');
-            // }else{
-            //     this.$message.success('当前课程微信不可见');
-            // }
-        },
-        changeWechatOrder(e, row) {
-            // if(parseInt(e) == 0){
-            //     this.$message.success('当前课程微信已不可预约');
-            // }else{
-            //     this.$message.success('当前课程微信可预约');
-            // }
-        },
-        // 增删会员课程
-        lessonStudenChange() {
-            this.dialogVisible = true
-        },
-        handleSelectionChange(val) {
-            this.multipleSelection = val;
-        },
-        // 页面数据查询
-        getTableQuery() {
-            let that = this;
-            that.loading = true;
-            let param = {
-                token: localStorage.token,
-                stbId: this.$route.query.id,//
-            };
-            // 只能读取,不能修改
-            this.panel.name = this.$route.query.name;
-
-
-            let postdata = qs.stringify(param);
-            STTDetailListQuery(postdata).then(res => {
-                let json = res;
-                let Rs = json.Rs
-                let bt = '';
-                let et = '';
-                if (json.Code == 0) {
-                    that.loading = false;
-                    // 清掉上次的记录
-                    for (let i = 0; i < that.tabs.length; i++) {
-                        that.tabs[i].tableData = []
-                    }
-                    if (Rs) {
-                        // 遍历分配
-                        Rs.map(function(item) {
-                            for (let i = 0; i < 7; i++) {
-                                if (item.WeekDay == i + 1) {
-                                    bt = new Date(2016, 9, 10, item.BeginStr.substr(0, 2), item.BeginStr.substr(3, 2));
-                                    et = new Date(2016, 9, 10, item.EndStr.substr(0, 2), item.EndStr.substr(3, 2));
-                                    item.timeLong = [bt, et];
-                                    that.tabs[i].tableData.push(item);
-
-                                }
-                            }
-                        })
-                    } else {
-                        that.allTableData = [];
-                        that.recordsTotal = 0;
-                    }
-                } else {
-                    that.$message.error(json.Memo + ' 错误码:' + json.Code);
-                }
-            })
-        },
-    },
-    watch: {
-        $route(to) {
-            if (to.name == 'EditLessonManage') {
-                this.temId = this.$route.query.id;
-                this.panelSelect();
-                if (parseInt(this.temId) == 0) {
-                    this.pageTitle = '新增课程表'
-                    this.deepValue();
-                    this.panel.name = '';
-                    this.panel.week = '';
-                    this.panel.inputState = false
-                } else {
-                    this.pageTitle = '编辑课程表'
-                    this.getTableQuery();
-                    this.panel.inputState = true
-                }
-            }
-        },
-    },
-}
-</script>
-
-<style scoped>
-@import "../../assets/css/panel.css";
-
-em {
-    font-style: normal;
-}
-
-.context {
-    overflow: hidden;
-    /* height: 770px; */
-
-    overflow-y: scroll;
-    display: block;
-    margin: 0 auto;
-    background-color: #fff !important;
-    min-height: 100%;
-    padding: 30px;
-    padding-bottom: 10px;
-}
-
-.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;
-}
-
-/deep/ .panel_control .el-input {
-    width: 200px;
-    float: left;
-}
-
-.panel_control em {
-    float: left;
-    font-size: 14px;
-    color: #545454;
-    line-height: 45px;
-    margin-right: 10px;
-}
-
-.seeTemp {
-    /*position: relative;*/
-    float: right;
-    bottom: 0px;
-    z-index: 222;
-}
-
-.table {
-    position: relative;
-    /*top: -50px;*/
-    top: 0px;
-}
-
-.el-range-editor.el-input__inner {
-    width: 220px;
-    padding: 3px 6px;
-}
-
-.rowBottom {
-    width: 100%;
-    overflow: hidden;
-    display: block;
-    margin: 0 auto;
-    margin-top: 10px;
-}
-
-.rowBottom button {
-    float: left;
-    margin-right: 10px;
-}
-
-.wrning {
-    float: right;
-    font-size: 12px;
-}
-
-.rowBottom button.pull-right {
-    float: right;
-}
-
-.gary {
-    color: #8c939d;
-}
-@media (min-width: 320px) and (max-width: 1366px) {
-    /deep/ .el-range-editor.el-input__inner {
-        width: 180px;
-    }
-    /deep/ .el-input-number {
-        width: 140px;
-    }
-}
-</style>

+ 781 - 0
src/views/SchoolTimeTable/LessonTableManageEdit.vue

@@ -0,0 +1,781 @@
+<template>
+  <div class="context">
+    <div class="panel">
+      <h5>{{ pageTitle }}</h5>
+    </div>
+    <div class="panel-body">
+      <div class="panel_control">
+        <el-row :gutter="20">
+          <el-col :span="5">
+            <em>
+              <span style="color: red">*</span> 课程表名称:
+            </em>
+            <el-input v-model="panel.name" placeholder="请输入课程表名称" :disabled="panel.inputState"/>
+          </el-col>
+          <el-col :span="5" v-if="!panel.inputState">
+            <em>
+              <span style="color: red">*</span> 课程表时间:
+            </em>
+            <el-date-picker
+                v-model="panel.week" type="week" :picker-options="{ 'firstDayOfWeek': 1 }"
+                format="yyyy 第 WW 周" placeholder="选择周"/>
+          </el-col>
+          <el-button type="default" class="seeTemp" @click="$router.push('/lessonManage')">返回课程表</el-button>
+        </el-row>
+      </div>
+    </div>
+    <br/>
+    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
+      <el-tab-pane label="星期一" name="1"></el-tab-pane>
+      <el-tab-pane label="星期二" name="2"></el-tab-pane>
+      <el-tab-pane label="星期三" name="3"></el-tab-pane>
+      <el-tab-pane label="星期四" name="4"></el-tab-pane>
+      <el-tab-pane label="星期五" name="5"></el-tab-pane>
+      <el-tab-pane label="星期六" name="6"></el-tab-pane>
+      <el-tab-pane label="星期天" name="7"></el-tab-pane>
+    </el-tabs>
+
+    <!--todo 读取后台保存状态,新保存后不跳走-->
+    <div class="table">
+      <el-table v-for="tab in tabs" :data="tab.tableData" v-if="tab.days == activeName" border
+                is-horizontal-resize :default-sort="{ prop: 'date', order: 'descending' }"
+                element-loading-background="rgba(0, 0, 0, 0.8)" class
+                @selection-change="handleSelectionChange">
+        <el-table-column prop="timeScope" label="时间" width="230px" align="center">
+          <template slot-scope="scope">
+            <el-time-picker is-range v-model="scope.row.timeLong" range-separator="至" start-placeholder="开始时间"
+                            end-placeholder="结束时间" placeholder="选择时间范围" :readonly="scope.row.Locking == 1"
+            ></el-time-picker>
+          </template>
+        </el-table-column>
+        <el-table-column prop="ClassId" label="课程" align="center">
+          <!--locking是1的不可编辑课程和时间-->
+          <template slot-scope="scope">
+            <el-select v-model="scope.row.ClassId" @change="getRowTop(scope.row)" :disabled="scope.row.Locking == 1">
+              <el-option v-for="item in panel.options" :key="item.value" :label="item.label" :value="item.value"/>
+            </el-select>
+          </template>
+        </el-table-column>
+        <el-table-column prop="OrderToplimit" label="预约名额" align="center">
+          <template slot-scope="scope">
+            <el-input-number v-model="scope.row.OrderToplimit" :min="1" :max="9999" label/>
+          </template>
+        </el-table-column>
+        <el-table-column prop="ConsumeHour" label="消耗课时" align="center">
+          <template slot-scope="scope">
+            <el-input-number v-model="scope.row.ConsumeHour" :min="0" :max="9999" label/>
+          </template>
+        </el-table-column>
+        <el-table-column prop="Status" label="操作" width="150px" align="center">
+          <template slot-scope="scope">
+            <el-button type="text" class="gary" @click="lessonRowEdit(scope)">编辑</el-button>
+            <el-button type="text" class="red" @click="delRow(scope)">删除</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="rowBottom">
+        <el-button type="default" @click="$router.push('/lessonManage')">返回课程表</el-button>
+        <!--ID为0是新建,不为0是修改-->
+        <el-button type="primary" class="pull-right" @click="confirmLessonTable"
+                   v-if="this.$route.query.id == 0" :disabled="searchBtnStatus">提交
+        </el-button>
+        <el-button type="primary" class="pull-right" @click="confirmEditLessonTable"
+                   v-if="this.$route.query.id != 0" :disabled="searchBtnStatus">提交
+        </el-button>
+        <el-button type="primary" class="pull-right" @click="addRow">新增课表</el-button>
+      </div>
+      <div>
+        <br/>
+        <em class="red wrning">*所有操作提交后生效</em>
+      </div>
+    </div>
+    <br/>
+    <el-dialog title="课程编辑" :visible.sync="dialogLessonVisable" width="720px">
+
+      <el-form ref="form" :model="form" label-width="145px">
+        <div style="float:left;" align="left">
+          <h4>预约设置</h4>
+          <hr/>
+          <div style="margin-left: -40px">
+            <el-form-item label="微信可见" style="float: left;">
+              <el-switch
+                  v-model="form.wxVisible"
+                  :active-value="1"
+                  :inactive-value="0"
+                  active-color="#409EFF"
+                  inactive-color="#D9D9D9"
+                  style="z-index: 1">
+              </el-switch>
+            </el-form-item>
+
+            <el-form-item label="是否拼课" style="float: left;">
+              <el-switch
+                  v-model="form.isClassGroup"
+                  :active-value="1"
+                  :inactive-value="0"
+                  active-color="#409EFF"
+                  inactive-color="#D9D9D9"
+                  style="z-index: 1">
+              </el-switch>
+            </el-form-item>
+
+            <el-form-item label="开放预约">
+              <el-switch
+                  v-model="form.wxOrder"
+                  :active-value="1"
+                  :inactive-value="0"
+                  active-color="#409EFF"
+                  inactive-color="#D9D9D9"
+                  style="z-index: 1">
+              </el-switch>
+            </el-form-item>
+
+            <el-form-item label="拼课截止时间" :required="true">
+              <el-date-picker v-model="form.lastLesson" type="date" placeholder="选择日期">
+              </el-date-picker>
+            </el-form-item>
+          </div>
+        </div>
+        <div style="float:right;">
+          <h4 align="left">课程设置</h4>
+          <hr/>
+          <div style="margin-left: -30px">
+            <el-form-item label="心率课" style="float: left">
+              <el-switch
+                  v-model="form.isHr"
+                  :active-value="1"
+                  :inactive-value="0"
+                  active-color="#409EFF"
+                  inactive-color="#D9D9D9"
+                  style="z-index: 1">
+              </el-switch>
+            </el-form-item>
+            <el-form-item label="评分课" style="float: left">
+              <el-switch
+                  v-model="form.isScore"
+                  :active-value="1"
+                  :inactive-value="0"
+                  active-color="#409EFF"
+                  inactive-color="#D9D9D9"
+                  style="z-index: 1">
+              </el-switch>
+            </el-form-item>
+            <el-form-item label="最小人数">
+              <el-input-number v-model="form.orderMiniLimit" :min="0" :max="99999" label="(天)"></el-input-number>
+            </el-form-item>
+            <el-form-item label="课程类型" :required="true">
+              <el-select v-model="form.courseType" type="date" placeholder="选择日期">
+              </el-select>
+            </el-form-item>
+          </div>
+        </div>
+      </el-form>
+      <div class="dialogFooter" >
+        <el-button type="primary" size="small">确定</el-button>
+        <el-button @click="dialogLessonVisable = false" size="small">取消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import Global from '../../Global.js'
+import {
+  STTBasicAdd,
+  STTDetailListQuery,
+  STTDetailBatchSave,
+  ClassListQuery,
+  STTDetailAllowDelCheck,
+  ClassDetailOne
+} from "../../api/getApiRes";
+
+let qs = require('qs');
+export default {
+  data() {
+    return {
+      pageTitle: '新增课程表',
+      dialogLessonVisable: false,
+      dialogdata: [],
+      dialogValue: [],
+      temId: '',
+      activeName: '1',
+      tableData: [],
+      // panel 配置项目
+      panel: {
+        inputState: false,
+        name: '',
+        usercode: '',
+        username: '',
+        compname: '',
+        keyword: '',
+        USERCODE: '',
+        week: '',
+        taskstatus: 99,
+        draw: 1,
+        start: 0,
+        recordsTotal: 0,
+        tableData: [],
+        allTableData: [],
+        limit: '10',
+        multipleSort: false,
+        loading: false,
+        fileList: [],
+        multipleSelection: [],
+        detectedmac: '',
+        options: [],
+        time1: globalBt(),
+      },
+      multipleSelection: [],
+      pageination: {
+        pageItem: 10,
+        pageoptions: pageOptions(),
+        total: 100,
+        pageIndex: 1,
+      },
+      testRow: {
+        timeLong: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 23, 59)],
+        BeginStr: '08:30',
+        EndStr: '23:59',
+        ClassId: '',
+        OrderToplimit: 1,
+        ConsumeHour: 1,
+        WxOrder: 1,
+        WxVisible: 0,
+      },
+      tabs: [
+        {
+          tableData: [], days: '1'
+        },
+        {
+          tableData: [], days: '2'
+        },
+        {
+          tableData: [], days: '3'
+        },
+        {
+          tableData: [], days: '4'
+        },
+        {
+          tableData: [], days: '5'
+        },
+        {
+          tableData: [], days: '6'
+        },
+        {
+          tableData: [], days: '7'
+        },
+      ],
+      form: {
+        wxVisible: 0,
+        isClassGroup: 0,
+        wxOrder: 0,
+        orderMiniLimit: 0,
+        lastLesson: 0,
+        isHr: 0,
+        courseType: 0
+      },
+      searchBtnStatus: false,
+    }
+  },
+  mounted() {
+    // 加载课程选项
+    this.panelSelect();
+    if (parseInt(this.$route.query.id) == 0) {
+      //  深拷贝赋初始值
+      this.pageTitle = '新增课程表'
+      this.deepValue();
+      this.panel.name = '';
+      this.panel.week = '';
+      this.panel.inputState = false
+    } else {
+      // 读取赋值
+      this.pageTitle = '编辑课程表'
+      this.getTableQuery();
+      this.panel.inputState = true
+    }
+  },
+  methods: {
+    // 加载选项
+    panelSelect() {
+      let that = this;
+      let param = {
+        token: localStorage.token,
+        vipType: '',
+        start: 1,
+        expDay: 0,
+        tableMax: 9999,
+      };
+      let postdata = qs.stringify(param);
+      ClassListQuery(postdata).then(res => {
+        let json = res;
+        if (json.Code == 0) {
+          // that.dialogdata = json.Rs;
+          if (json.Rs == null) return false
+          that.panel.options = turnClassResToOption(json.Rs)
+          console.log(that.panel.options);
+        } else {
+          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+        }
+      })
+    },
+    // 选择课程后,获取当前课程的建议上课人数和课时消耗
+    getRowTop(row) {
+      let that = this;
+      console.log(row);
+      let param = {
+        token: localStorage.token,
+        classId: row.ClassId,
+      };
+      let postdata = qs.stringify(param);
+      ClassDetailOne(postdata).then(res => {
+        let json = res;
+        if (json.Code == 0) {
+          row.OrderToplimit = json.Rs.TopLimit;
+          row.ConsumeHour = json.Rs.ConsumeHour;
+          // row.WxOrder = json.Rs.WxOrder; //不支持联动
+          row.WxVisible = json.Rs.WxVisible;
+        } else {
+          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+        }
+      })
+    },
+    confirmEditLessonTable() {
+      let id = this.$route.query.id
+      // 提交课程内容,不再修改课程名称和时间的信息
+      this.EditLessonTable(id);
+    },
+    // 删除
+    delRow(scope) {
+      if (!scope.row.StdId) {
+        let delIndex = parseInt(scope.$index)
+        let curIndex = parseInt(this.activeName) - 1;
+        this.tabs[curIndex].tableData.splice(delIndex, 1)
+      } else {
+        this.checkCannotDel(scope)
+      }
+    },
+    // 检测课表中课程可否删除
+    checkCannotDel(scope) {
+      let that = this;
+      let param = {
+        token: localStorage.token,
+        stdId: scope.row.StdId,
+      };
+      let postdata = qs.stringify(param);
+      STTDetailAllowDelCheck(postdata).then(res => {
+        let json = res;
+        if (json.Code == 0) {
+          let delIndex = parseInt(scope.$index)
+          let curIndex = parseInt(this.activeName) - 1;
+          this.tabs[curIndex].tableData.splice(delIndex, 1)
+        } else {
+          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+        }
+      })
+    },
+    // 提交课程
+    confirmLessonTable() {
+      if (!this.panel.name) {
+        this.$message.error('名称不能为空');
+        return false
+      }
+      if (this.panel.name.length < 3) {
+        this.$message.error('名称不能小于3个字符');
+        return false
+      }
+      if (this.panel.name.length > 20) {
+        this.$message.error('名称不能大于20个字符');
+        return false
+      }
+      if (!this.checkData()) {
+        return false
+      }
+
+      let that = this;
+
+      that.serachBtnStatus = true;
+      let totalTime = 2
+      let clock = window.setInterval(() => {
+        totalTime--
+        if (totalTime < 0) {
+          totalTime = 2;
+          that.serachBtnStatus = false;
+        }
+      }, 1000)
+
+
+      let param = {
+        token: localStorage.token,
+        name: this.panel.name,
+        incomingDate: nonTfmtDatetoLength(this.panel.week, 10),//对应日期 字符串 年-月-日 格式,
+      };
+      let postdata = qs.stringify(param);
+      STTBasicAdd(postdata).then(res => {
+        let json = res;
+        if (json.Code == 0) {
+          that.panel.tabId = json.Id;
+          // 提交课程内容
+          that.EditLessonTable(json.Id);
+        } else {
+          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+        }
+      })
+    },
+    // 保存课程
+    EditLessonTable(planId) {
+      let that = this;
+      // 校验提交的数据
+      if (!this.checkData()) {
+        return false
+      }
+      // 提交数据
+      let planRs = [];
+      let thisRow = {};
+      for (let i = 0; i < this.tabs.length; i++) {
+        for (let j = 0; j < this.tabs[i].tableData.length; j++) {
+          thisRow = this.tabs[i].tableData[j];
+          thisRow.LessonIndex = parseInt(j + 1);
+          if (planId) {
+            thisRow.StbId = parseInt(planId);
+          } else {
+            thisRow.StbId = parseInt(this.$route.query.id);
+          }
+          thisRow.WeekDay = parseInt(i + 1);
+          thisRow.BeginStr = getHoursAndMin(thisRow.timeLong[0]);
+          thisRow.EndStr = getHoursAndMin(thisRow.timeLong[1]);
+          thisRow.StdId = thisRow.StdId ? thisRow.StdId : 0;
+          this.$delete(thisRow, 'Base');
+          this.$delete(thisRow, 'SpdId');
+          planRs.push(thisRow);
+        }
+      }
+
+      let res = JSON.stringify(planRs);
+      // 如果传入0就用url里的,如果非0就用传入的
+      // let uploadPlanId = planId == 0 ? this.$route.query.id : planId;
+      let param = {
+        token: localStorage.token,
+        stbId: planId,
+        stbRs: res,
+      };
+      let postdata = qs.stringify(param);
+      STTDetailBatchSave(postdata).then(res => {
+        let json = res;
+        if (json.Code == 0) {
+          that.$message({
+            showClose: true,
+            message: '课程已上传成功!',
+            type: 'success'
+          });
+          this.$router.push({
+            path: '/lessonManage'
+          });
+          // 提交后清掉内存里的课表
+          this.clearTableRAM();
+          // this.getTableQuery();
+        } else {
+          this.$router.push({
+            path: '/lessonManage'
+          });
+          // 提交后清掉内存里的课表
+          this.clearTableRAM();
+          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+        }
+      })
+    },
+    clearTableRAM() {
+      this.tabs = [
+        {
+          tableData: [], days: '1'
+        },
+        {
+          tableData: [], days: '2'
+        },
+        {
+          tableData: [], days: '3'
+        },
+        {
+          tableData: [], days: '4'
+        },
+        {
+          tableData: [], days: '5'
+        },
+        {
+          tableData: [], days: '6'
+        },
+        {
+          tableData: [], days: '7'
+        },
+      ];
+
+    },
+    checkData() {
+      let res = true
+      for (let i = 0; i < this.tabs.length; i++) {
+        for (let j = 0; j < this.tabs[i].tableData.length; j++) {
+          if (!this.tabs[i].tableData[j].ClassId) {
+            let days = numberToWeekdays(i + 1);
+            let lessonIndex = j + 1;
+            this.$message.error(days + '第' + lessonIndex + '节课有课程未选择,请选择后再提交')
+            res = false
+            break;
+          }
+        }
+      }
+      return res
+    },
+    // 检查数据
+    checkData2() {
+      // todo
+      let tableDate = this.tabs;
+      tableDate.map(function (item) {
+        console.log(item);
+      })
+    },
+    // 新增一行
+    addRow() {
+      // 读取当前周几
+      let index = parseInt(this.activeName) - 1;
+      let rows = this.testRow;
+      let res = this.deepClone(rows);
+      this.tabs[index].tableData.push(res);
+    },
+    //  深拷贝赋初始值
+    deepValue() {
+      let that = this;
+      let valus = [
+        this.testRow
+      ];
+      this.tabs.map(function (item) {
+        let res = that.deepClone(valus);
+        item.tableData = res;
+      })
+    },
+    deepClone(obj) {
+      let _obj = JSON.stringify(obj),
+          objClone = JSON.parse(_obj);
+      return objClone
+    },
+    handleClick() {
+    },
+    changeWechat(e, row) {
+      // if(parseInt(e) == 0){
+      //     this.$message.success('当前课程微信已不可见');
+      // }else{
+      //     this.$message.success('当前课程微信不可见');
+      // }
+    },
+    changeWechatOrder(e, row) {
+      // if(parseInt(e) == 0){
+      //     this.$message.success('当前课程微信已不可预约');
+      // }else{
+      //     this.$message.success('当前课程微信可预约');
+      // }
+    },
+    // 编辑课表行
+    lessonRowEdit() {
+      this.dialogLessonVisable = true
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val;
+    },
+    // 页面数据查询
+    getTableQuery() {
+      let that = this;
+      that.loading = true;
+      let param = {
+        token: localStorage.token,
+        stbId: this.$route.query.id,//
+      };
+      // 只能读取,不能修改
+      this.panel.name = this.$route.query.name;
+
+
+      let postdata = qs.stringify(param);
+      STTDetailListQuery(postdata).then(res => {
+        let json = res;
+        let Rs = json.Rs
+        let bt = '';
+        let et = '';
+        if (json.Code == 0) {
+          that.loading = false;
+          // 清掉上次的记录
+          for (let i = 0; i < that.tabs.length; i++) {
+            that.tabs[i].tableData = []
+          }
+          if (Rs) {
+            // 遍历分配
+            Rs.map(function (item) {
+              for (let i = 0; i < 7; i++) {
+                if (item.WeekDay == i + 1) {
+                  bt = new Date(2016, 9, 10, item.BeginStr.substr(0, 2), item.BeginStr.substr(3, 2));
+                  et = new Date(2016, 9, 10, item.EndStr.substr(0, 2), item.EndStr.substr(3, 2));
+                  item.timeLong = [bt, et];
+                  that.tabs[i].tableData.push(item);
+
+                }
+              }
+            })
+          } else {
+            that.allTableData = [];
+            that.recordsTotal = 0;
+          }
+        } else {
+          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+        }
+      })
+    },
+  },
+  watch: {
+    $route(to) {
+      if (to.name == 'EditLessonManage') {
+        this.temId = this.$route.query.id;
+        this.panelSelect();
+        if (parseInt(this.temId) == 0) {
+          this.pageTitle = '新增课程表'
+          this.deepValue();
+          this.panel.name = '';
+          this.panel.week = '';
+          this.panel.inputState = false
+        } else {
+          this.pageTitle = '编辑课程表'
+          this.getTableQuery();
+          this.panel.inputState = true
+        }
+      }
+    },
+  },
+}
+</script>
+
+<style scoped>
+@import "../../assets/css/panel.css";
+
+em {
+  font-style: normal;
+}
+
+.context {
+  overflow: hidden;
+  /* height: 770px; */
+
+  overflow-y: scroll;
+  display: block;
+  margin: 0 auto;
+  background-color: #fff !important;
+  min-height: 100%;
+  padding: 30px;
+  padding-bottom: 10px;
+}
+
+.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;
+}
+
+.dialogLessonVisable .pull-left {
+  width: 40%;
+  float: left;
+}
+
+
+/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 {
+  margin-top: 20px;
+}
+
+/deep/ .panel_control .el-input {
+  width: 200px;
+  float: left;
+}
+
+.panel_control em {
+  float: left;
+  font-size: 14px;
+  color: #545454;
+  line-height: 45px;
+  margin-right: 10px;
+}
+
+.seeTemp {
+  /*position: relative;*/
+  float: right;
+  bottom: 0px;
+  z-index: 222;
+}
+
+.table {
+  position: relative;
+  /*top: -50px;*/
+  top: 0px;
+}
+
+.el-range-editor.el-input__inner {
+  width: 220px;
+  padding: 3px 6px;
+}
+
+.rowBottom {
+  width: 100%;
+  overflow: hidden;
+  display: block;
+  margin: 0 auto;
+  margin-top: 10px;
+}
+
+.rowBottom button {
+  float: left;
+  margin-right: 10px;
+}
+
+.wrning {
+  float: right;
+  font-size: 12px;
+}
+
+.rowBottom button.pull-right {
+  float: right;
+}
+
+.gary {
+  color: #8c939d;
+}
+
+@media (min-width: 320px) and (max-width: 1366px) {
+  /deep/ .el-range-editor.el-input__inner {
+    width: 180px;
+  }
+
+  /deep/ .el-input-number {
+    width: 140px;
+  }
+}
+</style>

+ 153 - 146
src/views/SttPlan/LessonTemplateEdit.vue → src/views/SttPlan/LessonTableTemplateEdit.vue

@@ -10,10 +10,9 @@
             <em> <span style="color: red">*</span>课程表模板名称:</em>
             <el-input v-model="panel.name" placeholder="请输入课程表模板名称"></el-input>
           </el-col>
-          <!--                    默认不通用-->
-          <!--        todo-->
-          <!--        <el-button class="seeTemp" @click.native="seeWeekTemp">预览模板</el-button>-->
-          <el-button type="default" class="seeTemp" @click="$router.push('/lessonTemplate')">返回课程表模板</el-button>
+          <!--默认不通用-->
+          <!--<el-button class="seeTemp" @click.native="seeWeekTemp">预览模板</el-button>-->
+          <el-button type="default" class="seeTemp" @click="$router.push('/lessonTableTemplate')">返回课程表模板</el-button>
         </el-row>
       </div>
     </div>
@@ -40,7 +39,6 @@
           class=""
           @selection-change="handleSelectionChange"
       >
-        >
         <el-table-column
             prop="timeScope"
             label="时间"
@@ -65,7 +63,7 @@
             align="center"
         >
           <template slot-scope="scope">
-            <el-select v-model="scope.row.class_id" @change="getRowTop(scope.row)">
+            <el-select v-model="scope.row.class_id" @change="getLessonTopMember(scope.row)">
               <el-option
                   v-for="item in panel.options"
                   :key="item.value"
@@ -76,21 +74,21 @@
           </template>
         </el-table-column>
         <el-table-column
-            prop="TopLimit"
+            prop="top_limit"
             label="预约名额"
             align="center"
         >
           <template slot-scope="scope">
-            <el-input-number v-model="scope.row.TopLimit" :min="1" :max="9999" label=""></el-input-number>
+            <el-input-number v-model="scope.row.top_limit" :min="1" :max="9999" label=""></el-input-number>
           </template>
         </el-table-column>
         <el-table-column
-            prop="ConsumeHour"
+            prop="consume_hour"
             label="消耗课时"
             align="center"
         >
           <template slot-scope="scope">
-            <el-input-number v-model="scope.row.ConsumeHour" :min="0" :max="9999"
+            <el-input-number v-model="scope.row.consume_hour" :min="0" :max="9999"
                              label=""></el-input-number>
           </template>
         </el-table-column>
@@ -106,12 +104,12 @@
         </el-table-column>
       </el-table>
       <div class="rowBottom">
-        <el-button type="default" @click="$router.push('/lessonTemplate')">返回课程表模板</el-button>
+        <el-button type="default" @click="$router.push('/lessonTableTemplate')">返回课程表模板</el-button>
         <!--ID为0是新建,不为0是修改-->
-        <el-button type="primary" class="pull-right" @click="confirmLessonTable"
+        <el-button type="primary" class="pull-right" @click="confirmLessonTemplateAdd"
                    v-if="this.$route.query.id == 0" :disabled="serachBtnStatus">提交
         </el-button>
-        <el-button type="primary" class="pull-right" @click="confirmEditLessonTable"
+        <el-button type="primary" class="pull-right" @click="confirmLessonTableEdit"
                    v-if="this.$route.query.id != 0" :disabled="serachBtnStatus">提交
         </el-button>
         <el-button type="primary" class="pull-right" @click="addRow">新增课程</el-button>
@@ -124,21 +122,6 @@
       </div>
     </div>
     <br>
-
-
-    <el-dialog title="增删课程会员" :visible.sync="dialogVisible">
-      <div class="dialogTitle">
-        <span>基础功能</span>
-      </div>
-      <div>
-        <el-transfer filterable v-model="dialogValue" :data="dialogdata"></el-transfer>
-      </div>
-      <div class="dialogFooter">
-        <el-button type="primary" size="small">确定</el-button>
-        <el-button @click="dialogVisible = false" size="small">取消</el-button>
-      </div>
-    </el-dialog>
-
     <el-dialog title="预览" :visible.sync="previewShow" width="1200px">
       <preview :preview-date="previewDate" :big-title="BigTitle" :small-title="smallTitle"></preview>
       <div class="dialogFooter">
@@ -155,13 +138,6 @@ import preview from '@/components/preview.vue'
 import {
   StandardRequest
 } from "@/grpc/base_pb";
-import {
-  SttPlanBasicAdd,
-  SttPlanDetailBatchSave,
-  SttPlanBasicEdit,
-  ClassDetailOne,
-  ClassListQuery,
-} from "../../api/getApiRes";
 
 let qs = require('qs');
 export default {
@@ -210,11 +186,11 @@ export default {
       },
       testRow: {
         timeLong: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 23, 59)],
-        BeginStr: '08:30',
-        EndStr: '23:59',
-        ClassId: '',
-        TopLimit: 1,
-        ConsumeHour: 0,
+        begin_str: '08:30',
+        end_str: '23:59',
+        class_id: '',
+        top_limit: 1,
+        consume_hour: 0,
       },
       tabs: [
         {
@@ -244,19 +220,14 @@ export default {
     }
   },
   mounted() {
-    console.log('加载课程选项');
-
     // 加载课程选项
     this.panelSelect();
-    if (this.$route.query.id === 0) {
+    if (this.$route.query.id == 0) {
+      this.panel.name = '';
       this.pageTitle = '新增课程表模板'
-      //  深拷贝赋初始值
       this.deepValue();
-      this.panel.name = '';
     } else {
-      console.log(this.$route.query.id);
       this.pageTitle = '编辑课程表模板'
-      // 读取赋值
       this.getTableQuery();
     }
   },
@@ -297,27 +268,36 @@ export default {
       });
     },
     // 选择课程后,获取当前课程的建议上课人数和课时消耗
-    getRowTop(row) {
+    getLessonTopMember(row) {
       let that = this;
-      console.log(row);
-      let param = {
-        token: localStorage.token,
-        classId: row.class_id,
+      const jsonStr = {
+        shopId: localStorage.shopId,
+        classId: row.class_id
       };
-      let postdata = qs.stringify(param);
-      ClassDetailOne(postdata).then(res => {
-        let json = res;
-        if (json.Code == 0) {
-          row.TopLimit = json.Rs.TopLimit;
-          row.ConsumeHour = json.Rs.ConsumeHour;
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.classSimpleQuery(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
+            row.top_limit = res.rs[0].top_limit;
+            row.consume_hour = res.rs[0].consume_hour;
+          } else {
+            that.$message.error(res.memo + ',错误代码:' + res.code);
+          }
         } else {
-          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
         }
-      })
+      });
     },
-    confirmEditLessonTable() {
+    confirmLessonTableEdit() {
       let that = this;
-
       // 按钮倒计时
       that.serachBtnStatus = true;
       let totalTime = 2;
@@ -341,25 +321,36 @@ export default {
         this.$message.error('模板名称不能大于20个字符');
         return false
       }
+      //检查每天的课程是否都提交了
       if (!this.checkData()) {
         return false
       }
-      let param = {
-        token: localStorage.token,
+      const jsonStr = {
         planId: this.$route.query.id,
         planName: this.panel.name
       };
-      let postdata = qs.stringify(param);
-      SttPlanBasicEdit(postdata).then(res => {
-        let json = res;
-        if (json.Code == 0) {
-          let id = that.$route.query.id;
-          // 提交课程内容
-          that.LessonTemplateEdit(id);
+
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sttPlanBasicEdit(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
+            let id = that.$route.query.id;
+            // 提交课程内容
+            that.LessonTableTemplateEdit(id);
+          } else {
+            that.$message.error(res.memo + ',错误代码:' + res.code);
+          }
         } else {
-          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
         }
-      })
+      });
     },
     // 删除
     delRow(scope) {
@@ -367,8 +358,8 @@ export default {
       let curIndex = parseInt(this.activeName) - 1;
       this.tabs[curIndex].tableData.splice(delIndex, 1)
     },
-    // 提交课程模板
-    confirmLessonTable() {
+    // 提交新增课程模板
+    confirmLessonTemplateAdd() {
       if (!this.panel.name) {
         this.$message.error('模板名称不能为空');
         return false
@@ -385,21 +376,34 @@ export default {
         return false
       }
       let that = this;
-      let param = {
-        token: localStorage.token,
-        planName: this.panel.name,
+
+      const jsonStr = {
+        shopId: localStorage.shopId,
+        planName: this.panel.name
       };
-      let postdata = qs.stringify(param);
-      SttPlanBasicAdd(postdata).then(res => {
-        let json = res;
-        if (json.Code == 0) {
-          that.panel.tabId = json.Id;
-          // 提交课程内容
-          that.LessonTemplateEdit(json.Id);
+
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sttPlanBasicAdd(paraRequest, {"Token": localStorage.token}, (err, StandardReply) => {
+        if (err == null) {
+          console.log(StandardReply.getJsonrst());
+          let res = JSON.parse(StandardReply);
+          if (res.code === 0) {
+            that.panel.tabId = res.newid;
+            // 提交课程内容
+            that.LessonTableTemplateEdit(res.newid);
+          } else {
+            that.$message.error(res.memo + ',错误代码:' + res.code);
+          }
         } else {
-          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
         }
-      })
+      });
     },
     // 数据组装
     DataAssembly() {
@@ -407,15 +411,15 @@ export default {
       for (let i = 0; i < this.tabs.length; i++) {
         for (let j = 0; j < this.tabs[i].tableData.length; j++) {
           thisRow = this.tabs[i].tableData[j];
-          thisRow.lessonIndex = parseInt(j);
+          thisRow.lesson_index = parseInt(j);
           if (planId) {
-            thisRow.PlanId = parseInt(planId);
+            thisRow.plan_id = parseInt(planId);
           } else {
-            thisRow.PlanId = parseInt(this.$route.query.id);
+            thisRow.plan_id = parseInt(this.$route.query.id);
           }
-          thisRow.WeekDay = parseInt(i + 1);
-          thisRow.BeginStr = getHoursAndMin(thisRow.timeLong[0]);
-          thisRow.EndStr = getHoursAndMin(thisRow.timeLong[1]);
+          thisRow.week_day = parseInt(i + 1);
+          thisRow.begin_str = getHoursAndMin(thisRow.timeLong[0]);
+          thisRow.end_str = getHoursAndMin(thisRow.timeLong[1]);
           this.$delete(thisRow, 'Base');
           this.$delete(thisRow, 'SpdId');
           this.DataAssemblyRs.push(thisRow)
@@ -423,65 +427,71 @@ export default {
       }
     },
     // 修改课程模板
-    EditLessonTable(planId) {
+    LessonTemplateEdit(planId) {
       let that = this;
-      // 提交数据
-
       let planRs = [];
       let thisRow = {};
+
       for (let i = 0; i < this.tabs.length; i++) {
         for (let j = 0; j < this.tabs[i].tableData.length; j++) {
           thisRow = this.tabs[i].tableData[j];
-          thisRow.lessonIndex = parseInt(j);
+          console.log(i,'--',j);
+          console.log(thisRow);
+          thisRow.lesson_index = parseInt(j);
           if (planId) {
-            thisRow.PlanId = parseInt(planId);
+            thisRow.plan_id = parseInt(planId);
           } else {
-            thisRow.PlanId = parseInt(this.$route.query.id);
+            thisRow.plan_id = parseInt(this.$route.query.id);
           }
-          thisRow.WeekDay = parseInt(i + 1);
-          thisRow.BeginStr = getHoursAndMin(thisRow.timeLong[0]);
-          thisRow.EndStr = getHoursAndMin(thisRow.timeLong[1]);
+          thisRow.week_day = parseInt(i + 1);
+          thisRow.begin_str = getHoursAndMin(thisRow.timeLong[0]);
+          thisRow.end_str = getHoursAndMin(thisRow.timeLong[1]);
           this.$delete(thisRow, 'Base');
           this.$delete(thisRow, 'SpdId');
           planRs.push(thisRow)
         }
       }
 
-      let res = JSON.stringify(planRs);
-      // 如果传入0就用url里的,如果非0就用传入的
-      // let uploadPlanId = planId == 0 ? this.$route.query.id : planId;
-      let param = {
-        token: localStorage.token,
-        // planId: this.$route.query.id,
+      const jsonStr = {
         planId: planId,
-        planRs: res,
+        planRs: planRs,
       };
-      let postdata = qs.stringify(param);
-      // 得等数组装完才能校验
-      SttPlanDetailBatchSave(postdata).then(res => {
-        let json = res;
-        if (json.Code == 0) {
-          that.$message({
-            showClose: true,
-            message: '课程模板已上传成功!',
-            type: 'success'
-          });
-          this.$router.push({
-            path: '/lessonTemplateEdit'
-          });
-          // 提交后清掉内存里的课表
-          this.clearTableRAM();
-
-          // this.getTableQuery();
+
+      let paraRequest = new StandardRequest();
+      paraRequest.setShopid(localStorage.shopId);
+      paraRequest.setJsonstr(JSON.stringify(jsonStr));
+      paraRequest.setSign(getSignStr(jsonStr));
+      console.log(paraRequest);
+      that.client.sttPlanDetailBatchSave(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.$router.push({
+              path: '/lessonTableTemplate'
+            });
+            // 提交后清掉内存里的课表
+            this.clearTableRAM();
+            // this.getTableQuery();
+          } else {
+            // this.$router.push({
+            //   path: '/lessonTable'
+            // });
+            // 提交后清掉内存里的课表
+            // this.clearTableRAM();
+            that.$message.error(res.memo + ',错误代码:' + res.code);
+          }
         } else {
-          // this.$router.push({
-          //   path: '/lessonTable'
-          // });
-          // 提交后清掉内存里的课表
-          // this.clearTableRAM();
-          that.$message.error(json.Memo + ' 错误码:' + json.Code);
+          let res = err;
+          that.$message.error(res.message + ',错误代码:' + res.code);
+          console.log(res);
         }
-      })
+      });
     },
     clearTableRAM() {
       this.tabs = [
@@ -514,10 +524,10 @@ export default {
       let res = true;
       for (let i = 0; i < this.tabs.length; i++) {
         for (let j = 0; j < this.tabs[i].tableData.length; j++) {
-          if (!this.tabs[i].tableData[j].ClassId) {
+          if (!this.tabs[i].tableData[j].class_id) {
             let days = numberToWeekdays(i + 1);
-            let lessonIndex = j + 1;
-            this.$message.error(days + '第' + lessonIndex + '节课有课程未选择,请选择后再提交');
+            let lesson_index = j + 1;
+            this.$message.error(days + '第' + lesson_index + '节课有课程未选择,请选择后再提交');
             res = false;
             break;
           }
@@ -526,15 +536,14 @@ export default {
       return res
     },
     checkData2() {
-      // 目前报错规则:StbId  WeekDay ClassId 不能为空为 0 BeginStr EndStr 必须是5位数字符串
+      // 目前报错规则:StbId  week_day class_id 不能为空为 0 begin_str end_str 必须是5位数字符串
       let that = this;
       this.DataAssembly();
       let tableDate = this.DataAssemblyRs;
-      console.log(123);
       tableDate.map(function (item) {
-        if (!item.ClassId) {
-          let days = numberToWeekdays(item.WeekDay);
-          let lessonIndex = parseInt(item.lessonIndex + 1);
+        if (!item.class_id) {
+          let days = numberToWeekdays(item.week_day);
+          let lessonIndex = parseInt(item.lesson_index + 1);
           that.$message.error(days + '第' + lessonIndex + '节课有课程未选择,请选择后再提交');
           return false
         } else {
@@ -550,12 +559,11 @@ export default {
       let res = this.deepClone(rows);
       this.tabs[index].tableData.push(res);
     },
-    //  深拷贝赋初始值
+    //深拷贝赋初始值
     deepValue() {
       let that = this;
       let value = [
         this.testRow
-        // {BeginStr: '08:30', EndStr: '09:30', ClassId: 0, TopLimit: 0, ConsumeHour: 0},
       ];
       this.tabs.map(function (item) {
         let res = that.deepClone(value);
@@ -601,7 +609,6 @@ export default {
             let bt = '';
             let et = '';
             that.loading = false;
-
             if (res.rs) {
               // 遍历分配
               res.rs.map(function (item) {
@@ -634,12 +641,12 @@ export default {
     // 去重
     unique(arr) {
       const res = new Map();
-      return arr.filter((arr) => !res.has(arr.EndStr) && res.set(arr.EndStr, 1))
+      return arr.filter((arr) => !res.has(arr.end_str) && res.set(arr.end_str, 1))
     }
   },
   watch: {
     $route(to) {
-      if (to.name == 'lessonTemplateEdit') {
+      if (to.name == 'lessonTableTemplateEdit') {
         this.temId = this.$route.query.id;
         this.panelSelect();
         if (parseInt(this.temId) == 0) {