lessonManage.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <h5>课程表管理</h5>
  5. </div>
  6. <div class="change">
  7. <el-button type="primary" @click="addLessonTable">新增课程表</el-button>
  8. <el-button type="" @click="copy">复制</el-button>
  9. <el-button type="" @click="delList">删除</el-button>
  10. <el-button type="" @click="query">查询</el-button>
  11. </div>
  12. <div class="table">
  13. <el-table
  14. :data="tableData"
  15. border
  16. is-horizontal-resize
  17. :default-sort="{prop: 'date', order: 'descending'}"
  18. element-loading-background="rgba(0, 0, 0, 0.8)"
  19. class=""
  20. @selection-change="handleSelectionChange"
  21. >
  22. <el-table-column
  23. type="selection"
  24. width="55">
  25. </el-table-column>
  26. <el-table-column
  27. type="index"
  28. label="序号"
  29. width="50">
  30. </el-table-column>
  31. <el-table-column
  32. prop="Name"
  33. label="日期"
  34. >
  35. <template slot-scope="scope">
  36. <div class="rowHeight">
  37. <!-- 未上线-->
  38. <span class="readyTime" v-if="scope.row.Diffweek < 0">
  39. {{scope.row.BeginDate}} - {{scope.row.EndDate}}
  40. </span>
  41. <!-- 已上线-->
  42. <span class="CurTime" v-if="scope.row.Diffweek >= 0">
  43. {{scope.row.BeginDate}} - {{scope.row.EndDate}}
  44. </span>
  45. <!-- 当前进行-->
  46. <i class="curIcon" v-if="scope.row.Status == 1 && scope.row.Diffweek == 0"></i>
  47. <span class="runTime" v-if="scope.row.Status == 2 ">
  48. {{scope.row.BeginDate}} - {{scope.row.EndDate}}
  49. </span>
  50. </div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. prop="Name"
  55. label="课程表名称"
  56. sortable
  57. >
  58. </el-table-column>
  59. <el-table-column
  60. prop="CreateColumn.CreatedAt"
  61. label="最后编辑时间"
  62. :formatter="filterFmtDate"
  63. sortable
  64. >
  65. </el-table-column>
  66. <el-table-column
  67. prop="Online"
  68. label="是否上线"
  69. >
  70. <!-- 上线状态 0:不上线 1:下线-->
  71. <template slot-scope="scope">
  72. <el-switch
  73. v-model="scope.row.Online"
  74. :active-value="1"
  75. :inactive-value="0"
  76. active-color="#409EFF"
  77. inactive-color="#D9D9D9"
  78. @change=changeWechat($event,scope.row)
  79. >
  80. </el-switch>
  81. </template>
  82. </el-table-column>
  83. <el-table-column
  84. prop="Status"
  85. label="操作"
  86. >
  87. <template slot-scope="scope">
  88. <el-button type="text" @click="editName(scope.row)">编辑名称</el-button>
  89. <el-button type="text" @click="goEdit(scope.row)">修改课程</el-button>
  90. <el-button type="text" @click="seeWeek(scope.row)">预览本周</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <br>
  95. <el-pagination
  96. background
  97. :total="pageination.total"
  98. :page-size="pageination.pageItem"
  99. @current-change="pageChange"
  100. ></el-pagination>
  101. </div>
  102. <el-dialog title="发布课程表" :visible.sync="dialogVisible" width="640px">
  103. <div class="dialogTitle">
  104. <span>{{form.name}}</span>
  105. </div>
  106. <div>
  107. <span class="demonstration">选择发布日期(按周选取)</span>
  108. <br>
  109. <br>
  110. <el-date-picker
  111. v-model="form.week"
  112. type="week"
  113. :picker-options="{'firstDayOfWeek': 1}"
  114. format="yyyy 第 WW 周"
  115. placeholder="选择周">
  116. </el-date-picker>
  117. <br>
  118. <br>
  119. <span>
  120. 微信可见
  121. </span>
  122. <el-switch
  123. v-model="form.wechat"
  124. :active-value="1"
  125. :inactive-value="0"
  126. active-color="#409EFF"
  127. inactive-color="#D9D9D9">
  128. </el-switch>
  129. <span>
  130. 微信可预约
  131. </span>
  132. <el-switch
  133. v-model="form.appoint"
  134. :active-value="1"
  135. :inactive-value="0"
  136. active-color="#409EFF"
  137. inactive-color="#D9D9D9">
  138. </el-switch>
  139. </div>
  140. <div class="dialogFooter">
  141. <el-button type="primary" size="small" @click="public">确定</el-button>
  142. <el-button @click="dialogVisible = false" size="small">取消</el-button>
  143. </div>
  144. </el-dialog>
  145. <el-dialog title="复制课程表" :visible.sync="dialogCopyVisible" width="640px">
  146. <div>
  147. <span class="demonstration">选择发布日期(按周选取)</span>
  148. <br>
  149. <br>
  150. <el-date-picker
  151. v-model="copyForm.week"
  152. type="week"
  153. :picker-options="{'firstDayOfWeek': 1}"
  154. format="yyyy 第 WW 周"
  155. placeholder="选择周">
  156. </el-date-picker>
  157. </div>
  158. <div class="dialogFooter">
  159. <el-button type="primary" size="small" @click="confirmCopy">确定</el-button>
  160. <el-button @click="dialogCopyVisible = false" size="small">取消</el-button>
  161. </div>
  162. </el-dialog>
  163. <el-dialog title="编辑名称" :visible.sync="dialogNameVisible" width="640px">
  164. <el-form ref="form" :model="form" label-width="160px">
  165. <el-form-item label="课程表名称">
  166. <el-input v-model="form.name"></el-input>
  167. </el-form-item>
  168. </el-form>
  169. <div class="dialogFooter">
  170. <el-button type="primary" size="small" @click="confirmName">确定</el-button>
  171. <el-button @click="dialogNameVisible = false" size="small">取消</el-button>
  172. </div>
  173. </el-dialog>
  174. </div>
  175. </template>
  176. <script>
  177. import Global from '../Global.js'
  178. import {
  179. STTBasicListQuery,
  180. STTBasicOfflineEdit,
  181. STTBasicStatusEdit,
  182. SchoolTimeTableCopy,
  183. STTBasicEdit,
  184. testSelect
  185. } from "../api/getApiRes";
  186. let qs = require('qs');
  187. export default {
  188. data() {
  189. return {
  190. dialogVisible: false,
  191. dialogCopyVisible: false,
  192. dialogNameVisible: false,
  193. dialogdata: [],
  194. dialogValue: [],
  195. // panel 配置项目
  196. multipleSelection: [],
  197. pageination: {
  198. pageItem: 100,
  199. pageoptions: pageOptions(),
  200. total: 100,
  201. pageIndex: 1,
  202. },
  203. form: {
  204. Id: '',
  205. name: '',
  206. week: '',
  207. wechat: 1,
  208. appoint: 1,
  209. },
  210. copyForm: {
  211. stbId: '',
  212. Id: '',
  213. name: '',
  214. week: '',
  215. wechat: 1,
  216. appoint: 1,
  217. },
  218. tableData: []
  219. }
  220. },
  221. mounted() {
  222. this.getTableQuery();
  223. },
  224. methods: {
  225. // 编辑名称
  226. editName(row) {
  227. this.form.name = row.Name;
  228. this.form.stbId = row.StbId;
  229. this.dialogNameVisible = true;
  230. },
  231. // 预览本周
  232. seeWeek() {
  233. console.log(123);
  234. },
  235. addLessonTable() {
  236. this.$router.push({
  237. path: '/editLessonManage', query: {
  238. id: 0
  239. }
  240. });
  241. },
  242. // 删除
  243. delList() {
  244. let that = this;
  245. // checkNum
  246. if (!this.multipleSelection.length) {
  247. that.$message({
  248. showClose: true,
  249. message: '错了哦,需要先选中至少一条记录',
  250. type: 'error'
  251. });
  252. return false
  253. }
  254. if (this.multipleSelection.length != 1) {
  255. that.$message({
  256. showClose: true,
  257. message: '错了哦,只能选中一条记录',
  258. type: 'error'
  259. });
  260. return false
  261. }
  262. let row = that.multipleSelection[0];
  263. let param = {
  264. token: localStorage.token,
  265. stbId: row.StbId,
  266. status: 9,//0禁用1启用9删除
  267. };
  268. let postdata = qs.stringify(param);
  269. this.$confirm('此操作将永久删除该课程表, 是否继续?', '提示', {
  270. confirmButtonText: '确定',
  271. cancelButtonText: '取消',
  272. type: 'warning'
  273. }).then(() => {
  274. STTBasicStatusEdit(postdata).then(res => {
  275. let json = res;
  276. if (json.Code == 0) {
  277. that.$message({
  278. showClose: true,
  279. message: '选中的课程表已删除!',
  280. type: 'success'
  281. });
  282. // 重载列表
  283. that.getTableQuery();
  284. } else {
  285. that.$message.error(json.Memo);
  286. }
  287. });
  288. }).catch(() => {
  289. this.$message({
  290. type: 'info',
  291. message: '已取消删除'
  292. });
  293. });
  294. },
  295. // 提交名称修改
  296. confirmName() {
  297. let that = this;
  298. if (!this.form.name) {
  299. this.$message.error('名称不能为空');
  300. return false
  301. }
  302. if (this.form.name.length < 3) {
  303. this.$message.error('名称不能小于3个字符');
  304. return false
  305. }
  306. if (this.form.name.length > 20) {
  307. this.$message.error('名称不能大于20个字符');
  308. return false
  309. }
  310. let param = {
  311. token: localStorage.token,
  312. stbId: this.form.stbId,
  313. name: this.form.name,
  314. };
  315. let postdata = qs.stringify(param);
  316. STTBasicEdit(postdata).then(res => {
  317. let json = res;
  318. if (json.Code == 0) {
  319. that.$message({
  320. showClose: true,
  321. message: '名称修改成功!',
  322. type: 'success'
  323. });
  324. this.getTableQuery();
  325. this.dialogNameVisible = false;
  326. } else {
  327. that.$message.error(json.Memo);
  328. }
  329. })
  330. },
  331. confirmCopy() {
  332. let that = this;
  333. let row = this.copyForm;
  334. if (!row.week) {
  335. that.$message.error('没有选择发布周期');
  336. return false
  337. }
  338. let param = {
  339. token: localStorage.token,
  340. stbId: row.StbId,
  341. incomingDate: nonTfmtDatetoLength(row.week, 10),//对应日期 字符串 年-月-日 格式,
  342. };
  343. let postdata = qs.stringify(param);
  344. SchoolTimeTableCopy(postdata).then(res => {
  345. let json = res;
  346. if (json.Code == 0) {
  347. that.$message({
  348. showClose: true,
  349. message: '课程复制成功!',
  350. type: 'success'
  351. });
  352. this.dialogCopyVisible = false;
  353. this.getTableQuery();
  354. } else {
  355. that.$message.error(json.Memo);
  356. }
  357. })
  358. },
  359. copy() {
  360. let that = this;
  361. // checkNum
  362. if (!this.multipleSelection.length) {
  363. that.$message({
  364. showClose: true,
  365. message: '错了哦,需要先选中至少一条记录',
  366. type: 'error'
  367. });
  368. return false
  369. }
  370. if (this.multipleSelection.length != 1) {
  371. that.$message({
  372. showClose: true,
  373. message: '错了哦,只能选中一条记录',
  374. type: 'error'
  375. });
  376. return false
  377. }
  378. this.dialogCopyVisible = true;
  379. this.copyForm = that.multipleSelection[0];
  380. },
  381. // 发布课程表
  382. openLessonTable(row) {
  383. this.dialogVisible = true;
  384. this.form.name = row.name;
  385. this.form.Id = row.Id;
  386. this.form.week = '';
  387. },
  388. // 发布
  389. public() {
  390. let that = this;
  391. if (!this.form.week) {
  392. this.$message({
  393. showClose: true,
  394. message: '错了哦,发布周期不能空',
  395. type: 'error'
  396. });
  397. return false
  398. }
  399. let param = {
  400. token: localStorage.token,
  401. detectorid: this.form.Id,
  402. week: this.form.week,
  403. wechat: this.form.wechat,
  404. appoint: this.form.appoint,
  405. };
  406. let postdata = qs.stringify(param);
  407. testSelect(postdata).then(res => {
  408. let json = res;
  409. if (json.Code == 0) {
  410. that.$message({
  411. showClose: true,
  412. message: this.form.name + '已发布!',
  413. type: 'success'
  414. });
  415. // 重载列表
  416. that.getTableQuery();
  417. this.dialogVisible = false;
  418. } else {
  419. that.$message.error(json.Memo);
  420. }
  421. });
  422. },
  423. // 取消发布
  424. unpubilc(row) {
  425. let that = this;
  426. let param = {
  427. token: localStorage.token,
  428. detectorid: row.Id,
  429. status: 4,//0禁用1启用9删除
  430. };
  431. let postdata = qs.stringify(param);
  432. testSelect(postdata).then(res => {
  433. let json = res;
  434. if (json.Code == 0) {
  435. that.$message({
  436. showClose: true,
  437. message: '选中的课程表已复制!',
  438. type: 'success'
  439. });
  440. // 重载列表
  441. that.getTableQuery();
  442. } else {
  443. that.$message.error(json.Memo);
  444. }
  445. });
  446. },
  447. // 编辑课程表
  448. goEdit(row) {
  449. // 参数???
  450. this.$router.push({
  451. path: '/editLessonManage', query: {
  452. id: row.StbId,
  453. name: row.Name
  454. }
  455. });
  456. },
  457. handleSelectionChange(val) {
  458. this.multipleSelection = val;
  459. },
  460. // 查询按钮
  461. query() {
  462. this.getTableQuery();
  463. this.$message.success('查询完毕');
  464. },
  465. // 页面数据查询
  466. getTableQuery() {
  467. let that = this;
  468. that.loading = true;
  469. let param = {
  470. token: localStorage.token,
  471. start: 1,//
  472. tableMax: 9999,//
  473. };
  474. let postdata = qs.stringify(param);
  475. STTBasicListQuery(postdata).then(res => {
  476. let json = res;
  477. if (json.Code == 0) {
  478. that.loading = false;
  479. if (json.Rs) {
  480. that.allTableData = json.Rs;
  481. that.recordsTotal = json.Rs.length;
  482. } else {
  483. that.allTableData = [];
  484. that.recordsTotal = 0;
  485. }
  486. // 设置分页数据
  487. that.setPaginations();
  488. } else {
  489. that.$message.error(json.Memo);
  490. }
  491. })
  492. },
  493. // 设置分页数据
  494. setPaginations() {
  495. // 分页属性
  496. let that = this;
  497. that.pageination.total = that.recordsTotal;
  498. // 默认分页
  499. that.tableData = that.allTableData.filter((item, index) => {
  500. return index < that.pageination.pageItem;
  501. });
  502. },
  503. // 每页显示数量
  504. handleSizeChange() {
  505. let that = this;
  506. that.tableData = that.allTableData.filter((item, index) => {
  507. return index < that.pageination.pageItem;
  508. });
  509. that.draw = that.pageination.pageItem;
  510. that.getTableQuery();
  511. },
  512. // 翻页
  513. pageChange(pageIndex) {
  514. let that = this;
  515. // 获取当前页
  516. let index = that.pageination.pageItem * (pageIndex - 1);
  517. // 数据总数
  518. let nums = that.pageination.pageItem * pageIndex;
  519. // 容器
  520. let tables = [];
  521. for (var i = index; i < nums; i++) {
  522. if (that.allTableData[i]) {
  523. tables.push(that.allTableData[i])
  524. }
  525. this.tableData = tables;
  526. }
  527. that.start = index * that.draw;
  528. that.getTableQuery();
  529. },
  530. // 自动排序
  531. sortChange(params) {
  532. console.log(params)
  533. },
  534. // 过滤时间
  535. filterFmtDate(value, row, column) {
  536. let that = this;
  537. return nonTfmtDate(column, 11);
  538. },
  539. // 过滤金额
  540. filterMoney(value, row, column) {
  541. let that = this;
  542. return parseFloat(column).toFixed(2);
  543. },
  544. // 课程表上下线状态修改
  545. changeWechat(e, row) {
  546. let that = this;
  547. let param = {
  548. token: localStorage.token,
  549. stbId: row.StbId,//
  550. online: e,//
  551. };
  552. let postdata = qs.stringify(param);
  553. STTBasicOfflineEdit(postdata).then(res => {
  554. let json = res;
  555. if (json.Code == 0) {
  556. that.$message({
  557. showClose: true,
  558. message: '当前课程表已' + json.Memo,
  559. type: 'success'
  560. });
  561. // 重载列表
  562. that.getTableQuery();
  563. } else {
  564. that.$message.error(json.Memo);
  565. row.Online = 0;
  566. }
  567. })
  568. },
  569. },
  570. }
  571. </script>
  572. <style scoped>
  573. @import "../assets/css/panel.css";
  574. .context { height: 770px;
  575. overflow-y: scroll;
  576. display: block;
  577. margin: 0 auto;
  578. background-color: #fff !important;
  579. padding: 30px;
  580. padding-bottom: 60px;
  581. }
  582. .panel-body {
  583. padding: 20px;
  584. background: #F0F2F5;
  585. }
  586. .change {
  587. width: 100%;
  588. overflow: hidden;
  589. display: block;
  590. margin: 0 auto;
  591. padding-top: 10px;
  592. padding-bottom: 10px;
  593. }
  594. .change button {
  595. float: left;
  596. }
  597. .change button.pull-right {
  598. float: right;
  599. }
  600. .dialogTitle {
  601. width: 100%;
  602. overflow: hidden;
  603. display: block;
  604. margin: 0 auto;
  605. color: #000000;
  606. font-size: 18px;
  607. text-align: center;
  608. }
  609. .dialogTitle span {
  610. width: 169px;
  611. height: 40px;
  612. line-height: 40px;
  613. text-align: center;
  614. color: #fff;
  615. background: #3799FF;
  616. border-radius: 250px;
  617. font-size: 18px;
  618. overflow: hidden;
  619. display: block;
  620. margin: 0 auto;
  621. margin-bottom: 30px;
  622. }
  623. .dialogTitle em {
  624. float: none;
  625. font-style: normal;
  626. color: #3799FF;
  627. margin: 0;
  628. }
  629. /deep/ .el-transfer-panel__item .el-checkbox__input {
  630. left: 40px;
  631. }
  632. .dialogFooter {
  633. width: 90%;
  634. overflow: hidden;
  635. display: block;
  636. margin: 0 auto;
  637. margin-top: 10px;
  638. }
  639. .dialogFooter button {
  640. float: right;
  641. margin-left: 10px;
  642. }
  643. .link {
  644. color: #03B1FF;
  645. text-decoration: underline;
  646. }
  647. .readyTime {
  648. width: 90%;
  649. height: 30px;
  650. line-height: 30px;
  651. overflow: hidden;
  652. display: block;
  653. margin: 0 auto;
  654. border: 1px solid #FFC769;
  655. border-radius: 4px;
  656. background: #FFF0D6;
  657. text-indent: 14px;
  658. }
  659. .CurTime {
  660. width: 90%;
  661. height: 27px;
  662. line-height: 30px;
  663. overflow: hidden;
  664. display: block;
  665. margin: 0 auto;
  666. border: 1px solid #3799FF;
  667. border-radius: 4px;
  668. background: #D9ECFF;
  669. padding: 3px 6px;
  670. text-indent: 14px;
  671. }
  672. .runTime {
  673. width: 90%;
  674. height: 30px;
  675. line-height: 30px;
  676. overflow: hidden;
  677. display: block;
  678. margin: 0 auto;
  679. border: 1px solid #3799FF;
  680. border-radius: 4px;
  681. background: #D9ECFF;
  682. padding: 3px 6px;
  683. text-indent: 14px;
  684. }
  685. .curIcon {
  686. position: relative;
  687. left: 4px;
  688. top: -34px;
  689. width: 24px;
  690. height: 24px;
  691. float: left;
  692. background: url("../assets/img/lessonTable/star.png") top center no-repeat;
  693. background-size: 100% 100%;
  694. }
  695. .rowHeight {
  696. width: 220px;
  697. overflow: hidden;
  698. display: block;
  699. height: 35px;
  700. float: left;
  701. margin: 0;
  702. }
  703. </style>