LessonTable.vue 21 KB

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