coach.vue 22 KB

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