| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733 |
- <template>
- <div class="context">
- <div class="panel">
- <h5>课程表管理</h5>
- </div>
- <div class="change">
- <el-button type="primary" @click="addLessonTable">新增课程表</el-button>
- <el-button type="" @click="copy">复制</el-button>
- <el-button type="" @click="delList">删除</el-button>
- <el-button type="" @click="query">查询</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"
- >
- <el-table-column
- type="selection"
- width="55">
- </el-table-column>
- <el-table-column
- type="index"
- label="序号"
- width="50">
- </el-table-column>
- <el-table-column
- prop="Name"
- label="日期"
- >
- <template slot-scope="scope">
- <div class="rowHeight">
- <!-- 未上线-->
- <span class="readyTime" v-if="scope.row.Diffweek < 0">
- {{scope.row.BeginDate}} - {{scope.row.EndDate}}
- </span>
- <!-- 已上线-->
- <span class="CurTime" v-if="scope.row.Diffweek >= 0">
- {{scope.row.BeginDate}} - {{scope.row.EndDate}}
- </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>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- prop="Name"
- label="课程表名称"
- sortable
- >
- </el-table-column>
- <el-table-column
- prop="CreateColumn.CreatedAt"
- label="最后编辑时间"
- :formatter="filterFmtDate"
- sortable
- >
- </el-table-column>
- <el-table-column
- prop="Online"
- label="是否上线"
- >
- <!-- 上线状态 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>
- </template>
- </el-table-column>
- <el-table-column
- prop="Status"
- label="操作"
- >
- <template slot-scope="scope">
- <el-button type="text" @click="editName(scope.row)">编辑名称</el-button>
- <el-button type="text" @click="goEdit(scope.row)">修改课程</el-button>
- <el-button type="text" @click="seeWeek(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>
- </div>
- <el-dialog title="发布课程表" :visible.sync="dialogVisible" width="640px">
- <div class="dialogTitle">
- <span>{{form.name}}</span>
- </div>
- <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>
- <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="640px">
- <div>
- <span class="demonstration">选择发布日期(按周选取)</span>
- <br>
- <br>
- <el-date-picker
- v-model="copyForm.week"
- type="week"
- :picker-options="{'firstDayOfWeek': 1}"
- format="yyyy 第 WW 周"
- placeholder="选择周">
- </el-date-picker>
- </div>
- <div class="dialogFooter">
- <el-button type="primary" size="small" @click="confirmCopy">确定</el-button>
- <el-button @click="dialogCopyVisible = false" size="small">取消</el-button>
- </div>
- </el-dialog>
- <el-dialog title="编辑名称" :visible.sync="dialogNameVisible" width="640px">
- <el-form ref="form" :model="form" label-width="160px">
- <el-form-item label="课程表名称">
- <el-input v-model="form.name"></el-input>
- </el-form-item>
- </el-form>
- <div class="dialogFooter">
- <el-button type="primary" size="small" @click="confirmName">确定</el-button>
- <el-button @click="dialogNameVisible = false" size="small">取消</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import Global from '../Global.js'
- import {
- STTBasicListQuery,
- STTBasicOfflineEdit,
- STTBasicStatusEdit,
- SchoolTimeTableCopy,
- STTBasicEdit,
- testSelect
- } from "../api/getApiRes";
- let qs = require('qs');
- export default {
- data() {
- return {
- dialogVisible: false,
- dialogCopyVisible: false,
- dialogNameVisible: false,
- dialogdata: [],
- dialogValue: [],
- // 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: []
- }
- },
- mounted() {
- this.getTableQuery();
- },
- methods: {
- // 编辑名称
- editName(row) {
- this.form.name = row.Name;
- this.form.stbId = row.StbId;
- this.dialogNameVisible = true;
- },
- // 预览本周
- seeWeek() {
- console.log(123);
- },
- addLessonTable() {
- this.$router.push({
- path: '/editLessonManage', query: {
- id: 0
- }
- });
- },
- // 删除
- delList() {
- let that = this;
- // checkNum
- if (!this.multipleSelection.length) {
- that.$message({
- showClose: true,
- message: '错了哦,需要先选中至少一条记录',
- type: 'error'
- });
- return false
- }
- if (this.multipleSelection.length != 1) {
- that.$message({
- showClose: true,
- message: '错了哦,只能选中一条记录',
- type: 'error'
- });
- return false
- }
- let row = that.multipleSelection[0];
- 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);
- }
- });
- }).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);
- }
- })
- },
- confirmCopy() {
- let that = this;
- let row = this.copyForm;
- 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) {
- that.$message({
- showClose: true,
- message: '课程复制成功!',
- type: 'success'
- });
- this.dialogCopyVisible = false;
- this.getTableQuery();
- } else {
- that.$message.error(json.Memo);
- }
- })
- },
- copy() {
- let that = this;
- // checkNum
- if (!this.multipleSelection.length) {
- that.$message({
- showClose: true,
- message: '错了哦,需要先选中至少一条记录',
- type: 'error'
- });
- return false
- }
- if (this.multipleSelection.length != 1) {
- that.$message({
- showClose: true,
- message: '错了哦,只能选中一条记录',
- type: 'error'
- });
- return false
- }
- this.dialogCopyVisible = true;
- this.copyForm = that.multipleSelection[0];
- },
- // 发布课程表
- 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
- }
- 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);
- }
- });
- },
- // 取消发布
- 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);
- }
- });
- },
- // 编辑课程表
- goEdit(row) {
- // 参数???
- this.$router.push({
- path: '/editLessonManage', query: {
- id: row.StbId,
- name: row.Name
- }
- });
- },
- handleSelectionChange(val) {
- this.multipleSelection = val;
- },
- // 查询按钮
- query() {
- this.getTableQuery();
- this.$message.success('查询完毕');
- },
- // 页面数据查询
- getTableQuery() {
- let that = this;
- that.loading = true;
- let param = {
- token: localStorage.token,
- start: 1,//
- tableMax: 9999,//
- };
- 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;
- } else {
- that.allTableData = [];
- that.recordsTotal = 0;
- }
- // 设置分页数据
- that.setPaginations();
- } else {
- that.$message.error(json.Memo);
- }
- })
- },
- // 设置分页数据
- 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);
- },
- // 课程表上下线状态修改
- 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) {
- that.$message({
- showClose: true,
- message: '当前课程表已' + json.Memo,
- type: 'success'
- });
- // 重载列表
- that.getTableQuery();
- } else {
- that.$message.error(json.Memo);
- row.Online = 0;
- }
- })
- },
- },
- }
- </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;
- }
- .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;
- }
- </style>
|