ActionGroups.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <h5>动作分组</h5>
  5. <div class="likeTab">
  6. <el-button @click="goType('ratingManage')" size="mini" type="primary">动作分组</el-button>
  7. <el-button @click="goType('actionExercise')" size="mini" type>锻炼动作</el-button>
  8. <el-button @click="goType('bodyNode')" size="mini" type>身体节点</el-button>
  9. </div>
  10. <div class="panel-body">
  11. <div class="panel_control">
  12. <el-row :gutter="1">
  13. <el-col :span="6" align="center">
  14. <em>分组名称:</em>
  15. <el-input v-model="panel.str" placeholder="请输入名称" type="text" style="width: 150px"/>
  16. </el-col>
  17. <el-col :span="3">
  18. <em>状态:</em>
  19. <!--status-->
  20. <el-select v-model="panel.status" placeholder="请选择">
  21. <el-option
  22. v-for="item in panel.statusOptions"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </el-col>
  29. <el-col :span="2">
  30. <el-button size type="primary" @click="query" plain>查询</el-button>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="change">
  37. <el-button @click="addActionGroup" size="mini" type="primary">新增动作分组</el-button>
  38. <el-button @click="editActionGroup" size="mini">编辑动作分组</el-button>
  39. <el-button @click="deleteActionGroup" size="mini" type="danger">删除动作分组</el-button>
  40. </div>
  41. <div class="table">
  42. <el-table :data="tableData" border is-horizontal-resize
  43. :default-sort="{ prop: 'date', order: 'descending' }" element-loading-background="rgba(0, 0, 0, 0.8)"
  44. class @selection-change="handleSelectionChange" @current-change="clickChange">
  45. >
  46. <el-table-column label="选择" width="55">
  47. <template slot-scope="scope">
  48. <el-radio v-model="tableRadio" :label="scope.row">
  49. <i></i>
  50. </el-radio>
  51. </template>
  52. </el-table-column>
  53. <el-table-column type="index" label="序号" align="center" width="60"/>
  54. <el-table-column prop="AgName" label="动作分组名称" align="center" sortable/>
  55. <el-table-column prop="Memo" label="备注" align="center" sortable/>
  56. <el-table-column prop="id" label="操作">
  57. <template slot-scope="scope">
  58. <el-button type="primary" size="mini" @click="manageActionGroup(scope.row)">管理</el-button>
  59. <el-popover
  60. placement="left"
  61. title="动作分组明细"
  62. width="450"
  63. trigger="click"
  64. content="这是一段内容,这是一段内容,这是一段内容,这是一段内容。">
  65. <el-table :data="form.groupAcData">
  66. <el-table-column property="EaName" label="动作名称"></el-table-column>
  67. </el-table>
  68. <el-button slot="reference" type="info" size="mini" @click="getAcGroupDetail(scope.row)"
  69. style="margin-left: 10px;margin-right: 10px">查看
  70. </el-button>
  71. </el-popover>
  72. <el-button type="success" v-if="scope.row.Status == 8" size="mini" @click="enableRow(scope.row,1)">
  73. 启用
  74. </el-button>
  75. <el-button type="warning" v-if="scope.row.Status == 1" size="mini" @click="enableRow(scope.row,8)">
  76. 禁用
  77. </el-button>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <br/>
  82. <el-pagination background :total="pagination.total" :page-size="pagination.pageItem"
  83. @current-change="pageChange"
  84. :current-page.sync="cur_page"
  85. ></el-pagination>
  86. </div>
  87. <el-dialog :title="dialogTitle" :visible.sync="addActionGroupVisible" width="650px">
  88. <div class="dialogContent">
  89. <div class>
  90. <el-form ref="form" :model="form" label-width="160px">
  91. <el-form-item label="动作名称" :required="true">
  92. <el-input v-model="form.name"/>
  93. </el-form-item>
  94. <el-form-item label="备注">
  95. <el-input v-model="form.memo"/>
  96. </el-form-item>
  97. </el-form>
  98. </div>
  99. </div>
  100. <div class="dialogFooter">
  101. <el-button type="primary" size="small" v-if="form.btnType == 0" @click="confirmAddActionGroup">确定</el-button>
  102. <el-button type="primary" size="small" v-if="form.btnType == 1" @click="confirmEditActionGroup">确定</el-button>
  103. <el-button size="small" @click="addActionGroupVisible = false">取消</el-button>
  104. </div>
  105. </el-dialog>
  106. <el-dialog :title="dialogTitle" :visible.sync="manageActionGroupVisible" width="650px">
  107. <div class="dialogContent">
  108. <div class>
  109. <el-transfer filterable v-model="form.dialogValue" :data="form.dialogData" :titles="['全部动作','已绑动作']">
  110. </el-transfer>
  111. </div>
  112. </div>
  113. <div class="dialogFooter">
  114. <el-button type="primary" size="small" @click="confirmManageActionGroup">确定</el-button>
  115. <el-button size="small" @click="manageActionGroupVisible = false">取消</el-button>
  116. </div>
  117. </el-dialog>
  118. </div>
  119. </template>
  120. <script>
  121. import Global from '../Global.js'
  122. import {
  123. ActionGroupStatusEdit,
  124. ActionGroupEdit,
  125. ActionGroupQuery,
  126. ActionGroupAdd,
  127. ClassListQuery,
  128. ExerciseActionQuery,
  129. AGDetailEdit,
  130. AGDetailQuery
  131. } from "../api/getApiRes";
  132. let qs = require('qs');
  133. export default {
  134. data() {
  135. return {
  136. activeName: 'comm',
  137. dialogVisible: false,//其他dialog
  138. addActionGroupVisible: false,//新增动作分组弹窗
  139. manageActionGroupVisible: false,//管理动作分组弹窗
  140. dialogTitle: '新增心率设备',
  141. BtnGetAllPower: false,
  142. tableRadio: [],
  143. cur_page: 1,
  144. // panel 配置项目
  145. panel: {
  146. str: '',
  147. status: "",
  148. draw: 1,
  149. start: 0,
  150. recordsTotal: 0,
  151. tableData: [],
  152. allTableData: [],
  153. loading: false,
  154. statusOptions: [
  155. {value: "", label: '全部'},
  156. {value: 1, label: '启用'},
  157. {value: 8, label: '禁用'},
  158. ]
  159. },
  160. multipleSelection: [],
  161. pagination: {
  162. pageItem: 10,
  163. pageOptions: pageOptions(),
  164. total: 100,
  165. pageIndex: 1,
  166. },
  167. form: {
  168. agId: '',
  169. agName: '',
  170. name: '',
  171. memo: '',
  172. btnType: 0,//0新建,1编辑编辑
  173. groupAcData: [],
  174. dialogData: [],//穿梭待选
  175. dialogValue: [],//穿梭已选
  176. },
  177. tableData: []
  178. }
  179. },
  180. mounted() {
  181. this.getTableQuery();
  182. this.getAllActions();
  183. },
  184. methods: {
  185. //顶部菜单项切换
  186. goType(url) {
  187. this.$router.push({path: '/' + url});
  188. },
  189. //tableData中的行点击事件
  190. clickChange(item) {
  191. this.tableRadio = item
  192. },
  193. //tableData中的行选择事件
  194. handleSelectionChange(val) {
  195. this.multipleSelection = val;
  196. },
  197. //动作分组动作管理
  198. manageActionGroup(row) {
  199. let that = this;
  200. that.allDialogClose();
  201. that.manageActionGroupVisible = true;
  202. that.dialogTitle = '分组动作管理'
  203. that.form.agId = row.AgId;
  204. that.form.agName = row.AgName;
  205. that.getAcGroupDetail(row);
  206. },
  207. // 关闭所有弹窗
  208. allDialogClose() {
  209. this.dialogVisible = false;
  210. this.addActionGroupVisible = false;
  211. this.manageActionGroupVisible = false;
  212. },
  213. //清除弹窗输入项
  214. clearForm() {
  215. this.form.name = '';
  216. this.form.memo = "";
  217. this.form.agId = '';
  218. },
  219. // 新增动作
  220. addActionGroup() {
  221. this.clearForm();
  222. this.addActionGroupVisible = true;
  223. this.form.btnType = 0;
  224. this.dialogTitle = '新增动作分组'
  225. },
  226. //确认提交新动作
  227. confirmAddActionGroup() {
  228. let that = this;
  229. if (!that.form.name) {
  230. this.$message.error('错了哦,动作分组名称不能为空');
  231. return false
  232. }
  233. if (that.form.name.length > 20) {
  234. this.$message.error('动作分组名称过长,请重新编辑');
  235. return false
  236. }
  237. let param = {
  238. token: localStorage.token,
  239. shopId: localStorage.shopId,
  240. agName: that.form.name,
  241. memo: that.form.memo
  242. };
  243. let postdata = qs.stringify(param);
  244. ActionGroupAdd(postdata).then(res => {
  245. let json = res;
  246. if (json.Code == 0) {
  247. // 关闭弹窗
  248. that.addActionGroupVisible = false;
  249. // 重载列表
  250. that.getTableQuery();
  251. that.$message({
  252. showClose: true,
  253. message: '动作分组添加成功!',
  254. type: 'success'
  255. });
  256. } else {
  257. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  258. }
  259. })
  260. },
  261. //编辑动作分组
  262. editActionGroup() {
  263. let that = this;
  264. this.clearForm();
  265. if (this.tableRadio.length == 0) {
  266. this.$message.error("请先选中一条记录");
  267. return false
  268. }
  269. this.dialogVisible = true;
  270. this.addActionGroupVisible = true
  271. this.dialogTitle = '编辑动作分组';
  272. let row = this.tableRadio;
  273. this.form.shopid = row.ShopId;
  274. this.form.agId = row.AgId;
  275. this.form.name = row.AgName;
  276. this.form.memo = row.Memo;
  277. this.form.btnType = 1;
  278. },
  279. //提交编辑动作分组
  280. confirmEditActionGroup() {
  281. let that = this;
  282. if (!that.form.name) {
  283. this.$message.error('错了哦,动作分组名称不能为空');
  284. return false
  285. }
  286. if (that.form.name.length > 20) {
  287. this.$message.error('动作分组名称过长,请重新编辑');
  288. return false
  289. }
  290. let param = {
  291. token: localStorage.token,
  292. shopId: localStorage.shopId,
  293. agId: that.form.agId,
  294. agName: that.form.name,
  295. memo: that.form.memo
  296. };
  297. let postdata = qs.stringify(param);
  298. ActionGroupEdit(postdata).then(res => {
  299. let json = res;
  300. if (json.Code == 0) {
  301. // 关闭弹窗
  302. that.addActionGroupVisible = false;
  303. // 重载列表
  304. that.getTableQuery();
  305. that.$message({
  306. showClose: true,
  307. message: '动作分组编辑信息编辑成功!',
  308. type: 'success'
  309. });
  310. } else {
  311. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  312. }
  313. })
  314. },
  315. //删除动作分组
  316. deleteActionGroup() {
  317. let that = this;
  318. let row = this.tableRadio;
  319. let param = {
  320. token: localStorage.token,
  321. shopId: localStorage.ShopId,
  322. agId: row.AgId,
  323. agName: row.AgName,
  324. status: 9 //1:启用,8:禁用,9:删除
  325. };
  326. let postdata = qs.stringify(param);
  327. this.$confirm('此操作将永久删除该动作分组, 是否继续?', '提示', {
  328. confirmButtonText: '确定',
  329. cancelButtonText: '取消',
  330. type: 'warning'
  331. }).then(() => {
  332. ActionGroupStatusEdit(postdata).then(res => {
  333. let json = res;
  334. if (json.Code == 0) {
  335. // table 重载
  336. that.getTableQuery();
  337. that.$message({
  338. showClose: true,
  339. message: '删除成功',
  340. type: 'success'
  341. });
  342. } else {
  343. that.$message.error(json.Memo);
  344. }
  345. })
  346. }).catch(() => {
  347. this.$message({
  348. type: 'info',
  349. message: '已取消删除'
  350. });
  351. });
  352. },
  353. //编辑动作组动作
  354. confirmManageActionGroup() {
  355. let that = this;
  356. if (!that.form.dialogValue) {
  357. this.$message.error('错了哦,请至少选定一个动作');
  358. return false
  359. }
  360. console.log(that.form.dialogValue.toString());
  361. let param = {
  362. token: localStorage.token,
  363. agId: that.form.agId,
  364. agName: that.form.agName,
  365. ecList: that.form.dialogValue.toString()
  366. };
  367. let postdata = qs.stringify(param);
  368. AGDetailEdit(postdata).then(res => {
  369. let json = res;
  370. if (json.Code == 0) {
  371. that.$message({
  372. showClose: true,
  373. message: '执行成功!',
  374. type: 'success'
  375. });
  376. that.manageActionGroupVisible = false;
  377. // table 重载
  378. that.getTableQuery();
  379. } else {
  380. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  381. }
  382. })
  383. },
  384. //设置行状态
  385. enableRow(row, status) {
  386. let that = this;
  387. let param = {
  388. token: localStorage.token,
  389. agId: row.AgId,
  390. agName: row.AgName,
  391. status: status,//1:启用 8:暂停 9:删除
  392. };
  393. let postdata = qs.stringify(param);
  394. ActionGroupStatusEdit(postdata).then(res => {
  395. let json = res;
  396. if (json.Code == 0) {
  397. that.$message({
  398. showClose: true,
  399. message: '执行成功!',
  400. type: 'success'
  401. });
  402. // table 重载
  403. that.getTableQuery();
  404. } else {
  405. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  406. }
  407. })
  408. },
  409. //查看动作分组详情
  410. getAcGroupDetail(row) {
  411. let that = this;
  412. that.form.groupAcData = [];
  413. that.form.dialogValue = [];
  414. let param = {
  415. token: localStorage.token,
  416. shopId: localStorage.shopId,
  417. agId: row.AgId,
  418. };
  419. let postdata = qs.stringify(param);
  420. AGDetailQuery(postdata).then(res => {
  421. let json = res;
  422. if (json.Code == 0) {
  423. if (json.Rs != '') {
  424. that.form.groupAcData = json.Rs;
  425. for (let temp in that.form.groupAcData) {
  426. console.log(that.form.groupAcData[temp].EaId);
  427. that.form.dialogValue.push(that.form.groupAcData[temp].EaId)
  428. }
  429. } else {
  430. that.form.groupAcData = [];
  431. }
  432. } else {
  433. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  434. }
  435. })
  436. },
  437. //获取当前所有动作
  438. getAllActions() {
  439. let that = this;
  440. let param = {
  441. token: localStorage.token,
  442. shopId: localStorage.shopId,
  443. agId: 0,
  444. };
  445. let postdata = qs.stringify(param);
  446. ExerciseActionQuery(postdata).then(res => {
  447. let json = res;
  448. if (json.Code == 0) {
  449. if (json.Rs != '') {
  450. that.form.dialogData = turnActionsResToOption(json.Rs);
  451. } else {
  452. that.form.dialogData = [];
  453. }
  454. } else {
  455. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  456. }
  457. })
  458. },
  459. // 查询按钮
  460. query() {
  461. let that = this;
  462. that.start = 0;
  463. that.cur_page = 1;
  464. this.getTableQuery();
  465. this.$message.success('查询完毕');
  466. },
  467. // 页面数据查询
  468. getTableQuery() {
  469. let that = this;
  470. that.loading = true;
  471. let param = {
  472. token: localStorage.token,
  473. shopId: localStorage.shopId,
  474. agName: that.panel.str,
  475. status: that.panel.status,
  476. };
  477. let postdata = qs.stringify(param);
  478. ActionGroupQuery(postdata).then(res => {
  479. let json = res;
  480. if (json.Code == 0) {
  481. that.loading = false;
  482. if (json.Rs) {
  483. that.allTableData = json.Rs;
  484. that.recordsTotal = json.Rs.length;
  485. } else {
  486. that.allTableData = [];
  487. that.recordsTotal = 0;
  488. }
  489. // 设置分页数据
  490. that.setPaginations();
  491. } else {
  492. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  493. }
  494. })
  495. },
  496. // 设置分页数据
  497. setPaginations() {
  498. // 分页属性
  499. let that = this;
  500. that.pagination.total = that.recordsTotal;
  501. // 默认分页
  502. that.tableData = that.allTableData.filter((item, index) => {
  503. return index < that.pagination.pageItem;
  504. });
  505. },
  506. // 每页显示数量
  507. handleSizeChange() {
  508. let that = this;
  509. that.tableData = that.allTableData.filter((item, index) => {
  510. return index < that.pagination.pageItem;
  511. });
  512. that.draw = that.pagination.pageItem;
  513. // that.getTableQuery();
  514. },
  515. // 翻页
  516. pageChange(pageIndex) {
  517. let that = this;
  518. // 获取当前页
  519. let index = that.pagination.pageItem * (pageIndex - 1);
  520. // 数据总数
  521. let nums = that.pagination.pageItem * pageIndex;
  522. // 容器
  523. let tables = [];
  524. for (var i = index; i < nums; i++) {
  525. if (that.allTableData[i]) {
  526. tables.push(that.allTableData[i])
  527. }
  528. this.tableData = tables;
  529. }
  530. that.start = index * that.draw;
  531. // that.getTableQuery();
  532. },
  533. // 自动排序
  534. sortChange(params) {
  535. console.log(params)
  536. },
  537. // 过滤时间
  538. filterFmtDate(value, row, column) {
  539. let that = this;
  540. if (column == 0) {
  541. return '未获得'
  542. } else {
  543. return nonTfmtDatetoLength(new Date(column * 1000), 16);
  544. }
  545. },
  546. },
  547. }
  548. </script>
  549. <style scoped>
  550. @import "../assets/css/panel.css";
  551. .context {
  552. /* height: 770px; */
  553. overflow-y: scroll;
  554. display: block;
  555. margin: 0 auto;
  556. background-color: #fff !important;
  557. padding: 30px;
  558. }
  559. .panel-body {
  560. padding: 20px;
  561. background: #f0f2f5;
  562. }
  563. .change {
  564. width: 100%;
  565. overflow: hidden;
  566. display: block;
  567. margin: 0 auto;
  568. padding-top: 10px;
  569. padding-bottom: 10px;
  570. }
  571. .change button {
  572. float: left;
  573. }
  574. .change button.pull-right {
  575. float: right;
  576. }
  577. .likeTab {
  578. width: 100%;
  579. overflow: hidden;
  580. display: block;
  581. margin: 0 auto;
  582. padding-top: 10px;
  583. padding-bottom: 0;
  584. border-bottom: 1px solid #ccc;
  585. margin-bottom: 10px;
  586. }
  587. .likeTab button {
  588. float: left;
  589. border-radius: 0;
  590. }
  591. .likeTab button.pull-right {
  592. float: right;
  593. }
  594. .dialogTitle {
  595. width: 100%;
  596. overflow: hidden;
  597. display: block;
  598. margin: 0 auto;
  599. color: #000000;
  600. font-size: 18px;
  601. text-align: center;
  602. }
  603. .dialogTitle em {
  604. float: none;
  605. font-style: normal;
  606. color: #3799ff;
  607. margin: 0;
  608. }
  609. /deep/ .el-transfer-panel__item .el-checkbox__input {
  610. left: 40px;
  611. }
  612. .dialogFooter {
  613. width: 90%;
  614. overflow: hidden;
  615. display: block;
  616. margin: 0 auto;
  617. margin-top: 10px;
  618. }
  619. .dialogFooter button {
  620. float: right;
  621. margin-left: 10px;
  622. }
  623. .dialogContent {
  624. width: 100%;
  625. overflow: hidden;
  626. display: block;
  627. margin: 0 auto;
  628. }
  629. .dialogContent .pull-left {
  630. width: 30%;
  631. float: left;
  632. }
  633. .dialogContent .pull-right {
  634. width: 70%;
  635. float: right;
  636. }
  637. .panel_control /deep/ .el-input {
  638. width: 90px;
  639. float: left;
  640. }
  641. .panel-body em {
  642. /*float: left;*/
  643. line-height: 40px;
  644. margin-right: 10px;
  645. }
  646. </style>