lessonManage.vue 21 KB

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