coach.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <h5>教练管理</h5>
  5. <div class="panel-body">
  6. <div class="panel_control">
  7. <el-row :gutter="20">
  8. <el-col :span="4">
  9. <em>姓名:</em>
  10. <el-input v-model="panel.name" placeholder="请输入姓名"></el-input>
  11. </el-col>
  12. <el-col :span="4">
  13. <em>手机号:</em>
  14. <el-input v-model="panel.phone" placeholder="请输入手机号"></el-input>
  15. </el-col>
  16. <el-col :span="4">
  17. <el-button size="" type="primary" @click="query" plain>查询</el-button>
  18. </el-col>
  19. </el-row>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="change">
  24. <el-button @click="addMember" type="primary">新增教练</el-button>
  25. <el-button @click="delList">删除教练</el-button>
  26. </div>
  27. <div class="table">
  28. <el-table
  29. :data="tableData"
  30. border
  31. is-horizontal-resize
  32. :default-sort="{prop: 'date', order: 'descending'}"
  33. element-loading-background="rgba(0, 0, 0, 0.8)"
  34. class=""
  35. @selection-change="handleSelectionChange"
  36. >
  37. <el-table-column
  38. type="selection"
  39. width="55">
  40. </el-table-column>
  41. <el-table-column
  42. type="index"
  43. label="序号"
  44. width="50">
  45. </el-table-column>
  46. <el-table-column
  47. prop="Name"
  48. label="教练"
  49. >
  50. </el-table-column>
  51. <el-table-column
  52. prop="Phone"
  53. label="手机号"
  54. sortable
  55. >
  56. </el-table-column>
  57. <el-table-column
  58. prop="TeacherId"
  59. label="操作"
  60. >
  61. <template slot-scope="scope">
  62. <el-button type="text" @click="editMember(scope.row)">编辑</el-button>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <br>
  67. <el-pagination
  68. background
  69. :total="pageination.total"
  70. :page-size="pageination.pageItem"
  71. @current-change="pageChange"
  72. ></el-pagination>
  73. </div>
  74. <el-dialog :title="dialogTitle" :visible.sync="dialogMemberVisible" width="480px">
  75. <div class="dialogContent">
  76. <div class="">
  77. <el-form ref="form" :model="form" label-width="160px">
  78. <el-form-item label="手机号">
  79. <el-input v-model="form.phone"></el-input>
  80. </el-form-item>
  81. <el-form-item label="姓名">
  82. <el-input v-model="form.name"></el-input>
  83. </el-form-item>
  84. </el-form>
  85. </div>
  86. </div>
  87. <div class="dialogFooter">
  88. <el-button type="primary" size="small" v-if="form.btnType == 0" @click="confirmMember">确定</el-button>
  89. <el-button type="primary" size="small" v-if="form.btnType == 1" @click="confirmEditMember">确定
  90. </el-button>
  91. <el-button size="small" @click="dialogMemberVisible = false">取消</el-button>
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. import Global from '../Global.js'
  98. import {
  99. TeacherListQuery,
  100. TeacherAdd,
  101. TeacherEdit,
  102. TeacherStatusEdit,
  103. testTable,
  104. testSelect
  105. } from "../api/getApiRes";
  106. let qs = require('qs');
  107. export default {
  108. data() {
  109. return {
  110. dialogVisible: false,//其他dialog
  111. dialogMemberVisible: false,//新增教练dialog
  112. dialogLesson: false,//课时调整
  113. dialogGift: false,//赠送课时调整
  114. dialogExpTime: false,//有效期调整
  115. dialogLessonTable: false,//教练课程
  116. dialogTitle: '新增教练',
  117. dialogValue: [],
  118. // panel 配置项目
  119. panel: {
  120. name: '',
  121. phone: '',
  122. compname: '',
  123. keyword: '',
  124. USERCODE: '',
  125. endType: '',
  126. taskstatus: 99,
  127. draw: 1,
  128. start: 0,
  129. recordsTotal: 0,
  130. tableData: [],
  131. allTableData: [],
  132. limit: '10',
  133. multipleSort: false,
  134. loading: false,
  135. fileList: [],
  136. multipleSelection: [],
  137. detectedmac: '',
  138. options: [
  139. {value: 99, label: '全部'},
  140. {value: 1, label: '进行中'},
  141. {value: 2, label: '已完成'},
  142. ],
  143. endTypeOptions: [
  144. {value: 99, label: '全部'},
  145. {value: 30, label: '近一个月'},
  146. {value: 7, label: '近一周'},
  147. {value: 1, label: '当日'},
  148. ],
  149. time1: globalBt(),
  150. },
  151. multipleSelection: [],
  152. pageination: {
  153. pageItem: 100,
  154. pageoptions: pageOptions(),
  155. total: 100,
  156. pageIndex: 1,
  157. },
  158. form: {
  159. name: '',
  160. userCode: '',
  161. shopId: '',
  162. teacherId: 0,
  163. memberType: 1,
  164. lesson: 1,
  165. gift: 1,
  166. btnType: 0,//0新建,1编辑编辑
  167. memo: '',
  168. phone: '',
  169. expTime: '',
  170. dialogdata: [],//穿梭待选
  171. dialogValue: [],//穿梭已选
  172. },
  173. memberTypes: [
  174. {value: 1, label: '年教练'},
  175. {value: 2, label: '充值教练'},
  176. ],
  177. tableData: []
  178. }
  179. },
  180. mounted() {
  181. this.getTableQuery();
  182. },
  183. methods: {
  184. // 编辑
  185. editMember(row) {
  186. this.clearForm();
  187. this.form.name = row.Name;
  188. this.form.phone = row.Phone;
  189. this.form.shopId = row.ShopId;
  190. this.form.teacherId = row.TeacherId;
  191. this.form.btnType = 1;
  192. this.dialogMemberVisible = true
  193. this.dialogTitle = '编辑教练'
  194. },
  195. // 禁用
  196. pauseRow(row) {
  197. let that = this;
  198. this.$confirm('是否禁用用户' + row.name + '?', '禁用操作', {
  199. confirmButtonText: '确定',
  200. cancelButtonText: '取消',
  201. type: 'warning'
  202. }).then(() => {
  203. let param = {
  204. token: localStorage.token,
  205. Id: row.Id,
  206. status: 0,
  207. };
  208. let postdata = qs.stringify(param);
  209. testTable(postdata).then(res => {
  210. let json = res;
  211. if (json.Code == 0) {
  212. that.$message({
  213. showClose: true,
  214. message: row.name + '禁用成功!',
  215. type: 'success'
  216. });
  217. // table 重载
  218. that.getTableQuery();
  219. } else {
  220. that.$message.error(json.Memo);
  221. }
  222. })
  223. }).catch(() => {
  224. this.$message({
  225. type: 'info',
  226. message: '已取消禁用'
  227. });
  228. });
  229. },
  230. // 启用
  231. runRow(row) {
  232. let that = this;
  233. this.$confirm('是否启用用户' + row.name + '?', '启用操作', {
  234. confirmButtonText: '确定',
  235. cancelButtonText: '取消',
  236. type: 'warning'
  237. }).then(() => {
  238. let param = {
  239. token: localStorage.token,
  240. Id: row.Id,
  241. status: 1,
  242. };
  243. let postdata = qs.stringify(param);
  244. testTable(postdata).then(res => {
  245. let json = res;
  246. if (json.Code == 0) {
  247. that.$message({
  248. showClose: true,
  249. message: row.name + '启用成功!',
  250. type: 'success'
  251. });
  252. // table 重载
  253. that.getTableQuery();
  254. } else {
  255. that.$message.error(json.Memo);
  256. }
  257. })
  258. }).catch(() => {
  259. this.$message({
  260. type: 'info',
  261. message: '已取消启用'
  262. });
  263. });
  264. },
  265. // 关闭所有
  266. allDialogClose() {
  267. this.dialogVisible = false;
  268. this.dialogGift = false;
  269. this.dialogLesson = false;
  270. this.dialogExpTime = false;
  271. this.dialogLessonTable = false;
  272. },
  273. // 确认提交新增教练
  274. confirmMember() {
  275. let that = this;
  276. // checkNum
  277. if (!that.form.phone) {
  278. this.$message.error('错了哦,手机号不能为空');
  279. return false
  280. }
  281. if (!globalCheckPhone(that.form.phone)) {
  282. this.$message.error('错了哦,手机号格式不正确');
  283. return false
  284. }
  285. if (!that.form.name) {
  286. this.$message.error('错了哦,教练名不能为空');
  287. return false
  288. }
  289. if (that.form.name.length > 8) {
  290. this.$message.error('错了哦,教练名字数超过8个字');
  291. return false
  292. }
  293. let param = {
  294. token: localStorage.token,
  295. shopId: localStorage.shopId,
  296. name: that.form.name,
  297. phone: that.form.phone,
  298. };
  299. let postdata = qs.stringify(param);
  300. TeacherAdd(postdata).then(res => {
  301. let json = res;
  302. if (json.Code == 0) {
  303. // 关闭弹窗
  304. that.dialogMemberVisible = false;
  305. // 重载列表
  306. that.getTableQuery();
  307. that.$message({
  308. showClose: true,
  309. message: '教练添加成功!',
  310. type: 'success'
  311. });
  312. } else {
  313. that.$message.error(json.Memo);
  314. }
  315. })
  316. },
  317. confirmEditMember() {
  318. let that = this;
  319. // checkNum
  320. if (!that.form.phone) {
  321. this.$message.error('错了哦,手机号不能为空');
  322. return false
  323. }
  324. if (!globalCheckPhone(that.form.phone)) {
  325. this.$message.error('错了哦,手机号格式不正确');
  326. return false
  327. }
  328. if (!that.form.name) {
  329. this.$message.error('错了哦,教练名不能为空');
  330. return false
  331. }
  332. if (that.form.name.length > 8) {
  333. this.$message.error('错了哦,教练名字数超过8个字');
  334. return false
  335. }
  336. let param = {
  337. token: localStorage.token,
  338. shopId: localStorage.shopId,
  339. teacherId: that.form.teacherId,
  340. name: that.form.name,
  341. phone: that.form.phone,
  342. };
  343. let postdata = qs.stringify(param);
  344. TeacherEdit(postdata).then(res => {
  345. let json = res;
  346. if (json.Code == 0) {
  347. // 关闭弹窗
  348. that.dialogMemberVisible = false;
  349. // 重载列表
  350. that.getTableQuery();
  351. that.$message({
  352. showClose: true,
  353. message: '教练信息编辑成功!',
  354. type: 'success'
  355. });
  356. } else {
  357. that.$message.error(json.Memo);
  358. }
  359. })
  360. },
  361. // 确认提交课时
  362. confirmLesson() {
  363. let that = this;
  364. // checkNum
  365. let param = {
  366. token: localStorage.token,
  367. userCode: that.form.userCode,
  368. lesson: that.form.lesson,
  369. };
  370. let postdata = qs.stringify(param);
  371. testSelect(postdata).then(res => {
  372. let json = res;
  373. if (json.Code == 0) {
  374. // 关闭弹窗
  375. that.dialogVisible = false;
  376. // 重载列表
  377. that.getTableQuery();
  378. that.$message({
  379. showClose: true,
  380. message: '课时调整成功!',
  381. type: 'success'
  382. });
  383. } else {
  384. that.$message.error(json.Memo);
  385. }
  386. })
  387. },
  388. // 新增教练
  389. addMember() {
  390. this.clearForm();
  391. this.dialogMemberVisible = true
  392. this.btnType = 0;
  393. this.dialogTitle = '新增教练'
  394. },
  395. // 删除
  396. delList() {
  397. let that = this;
  398. // checkNum
  399. if (!this.multipleSelection.length) {
  400. that.$message({
  401. showClose: true,
  402. message: '错了哦,需要先选中至少一条记录',
  403. type: 'error'
  404. });
  405. return false
  406. }
  407. if (this.multipleSelection.length != 1) {
  408. that.$message({
  409. showClose: true,
  410. message: '错了哦,只能选中一条记录',
  411. type: 'error'
  412. });
  413. return false
  414. }
  415. let TeacherId = that.multipleSelection[0].TeacherId;
  416. let param = {
  417. token: localStorage.token,
  418. teacherId: TeacherId,
  419. status: 9,//0禁用1启用9删除
  420. };
  421. let postdata = qs.stringify(param);
  422. this.$confirm('此操作将永久删除该教练, 是否继续?', '提示', {
  423. confirmButtonText: '确定',
  424. cancelButtonText: '取消',
  425. type: 'warning'
  426. }).then(() => {
  427. TeacherStatusEdit(postdata).then(res => {
  428. let json = res;
  429. if (json.Code == 0) {
  430. that.$message({
  431. showClose: true,
  432. message: '选中的教练已删除!',
  433. type: 'success'
  434. });
  435. // 重载列表
  436. that.getTableQuery();
  437. } else {
  438. that.$message.error(json.Memo);
  439. }
  440. });
  441. }).catch(() => {
  442. this.$message({
  443. type: 'info',
  444. message: '已取消删除'
  445. });
  446. });
  447. },
  448. handleSelectionChange(val) {
  449. this.multipleSelection = val;
  450. },
  451. // 查询按钮
  452. query() {
  453. this.getTableQuery();
  454. this.$message.success('查询完毕');
  455. },
  456. clearForm() {
  457. // clear
  458. this.form.name = '';
  459. this.form.phone = '';
  460. this.form.userCode = '';
  461. this.form.shopId = '';
  462. },
  463. // 页面数据查询
  464. getTableQuery() {
  465. let that = this;
  466. that.loading = true;
  467. let param = {
  468. token: localStorage.token,
  469. name: this.panel.name,//
  470. phone: this.panel.phone,//
  471. };
  472. let postdata = qs.stringify(param);
  473. TeacherListQuery(postdata).then(res => {
  474. let json = res;
  475. if (json.Code == 0) {
  476. that.loading = false;
  477. if (json.Rs) {
  478. that.allTableData = json.Rs;
  479. that.recordsTotal = json.Rs.length;
  480. } else {
  481. that.allTableData = [];
  482. that.recordsTotal = 0;
  483. }
  484. // 设置分页数据
  485. that.setPaginations();
  486. } else {
  487. that.$message.error(json.Memo);
  488. }
  489. })
  490. },
  491. // 设置分页数据
  492. setPaginations() {
  493. // 分页属性
  494. let that = this;
  495. that.pageination.total = that.recordsTotal;
  496. // 默认分页
  497. that.tableData = that.allTableData.filter((item, index) => {
  498. return index < that.pageination.pageItem;
  499. });
  500. },
  501. // 每页显示数量
  502. handleSizeChange() {
  503. let that = this;
  504. that.tableData = that.allTableData.filter((item, index) => {
  505. return index < that.pageination.pageItem;
  506. });
  507. that.draw = that.pageination.pageItem;
  508. that.getTableQuery();
  509. },
  510. // 翻页
  511. pageChange(pageIndex) {
  512. let that = this;
  513. // 获取当前页
  514. let index = that.pageination.pageItem * (pageIndex - 1);
  515. // 数据总数
  516. let nums = that.pageination.pageItem * pageIndex;
  517. // 容器
  518. let tables = [];
  519. for (var i = index; i < nums; i++) {
  520. if (that.allTableData[i]) {
  521. tables.push(that.allTableData[i])
  522. }
  523. this.tableData = tables;
  524. }
  525. that.start = index * that.draw;
  526. that.getTableQuery();
  527. },
  528. // 自动排序
  529. sortChange(params) {
  530. console.log(params)
  531. },
  532. },
  533. }
  534. </script>
  535. <style scoped>
  536. @import "../assets/css/panel.css";
  537. .context { height: 770px;
  538. overflow-y: scroll;
  539. display: block;
  540. margin: 0 auto;
  541. background-color: #fff !important;
  542. padding: 30px;
  543. }
  544. .panel-body {
  545. padding: 20px;
  546. background: #F0F2F5;
  547. }
  548. .change {
  549. width: 100%;
  550. overflow: hidden;
  551. display: block;
  552. margin: 0 auto;
  553. padding-top: 10px;
  554. padding-bottom: 10px;
  555. }
  556. .change button {
  557. float: left;
  558. }
  559. .change button.pull-right {
  560. float: right;
  561. }
  562. .dialogTitle {
  563. width: 100%;
  564. overflow: hidden;
  565. display: block;
  566. margin: 0 auto;
  567. color: #000000;
  568. font-size: 18px;
  569. text-align: center;
  570. }
  571. .dialogTitle em {
  572. float: none;
  573. font-style: normal;
  574. color: #3799FF;
  575. margin: 0;
  576. }
  577. /deep/ .el-transfer-panel__item .el-checkbox__input {
  578. left: 40px;
  579. }
  580. .dialogFooter {
  581. width: 90%;
  582. overflow: hidden;
  583. display: block;
  584. margin: 0 auto;
  585. margin-top: 10px;
  586. }
  587. .dialogFooter button {
  588. float: right;
  589. margin-left: 10px;
  590. }
  591. .dialogContent {
  592. width: 100%;
  593. overflow: hidden;
  594. display: block;
  595. margin: 0 auto;
  596. }
  597. .dialogContent .pull-left {
  598. width: 30%;
  599. float: left;
  600. }
  601. .dialogContent .pull-right {
  602. width: 70%;
  603. float: right;
  604. }
  605. </style>