LessonTable.vue 21 KB

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