relevancePhone.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <template>
  2. <div class="context">
  3. <el-page-header @back="goBack" content="关联手机号"></el-page-header>
  4. <div class="panel">
  5. <br>
  6. <h5> {{regionName}}</h5>
  7. </div>
  8. <div class="change">
  9. <el-button @click="addMember" type="primary">新增手机号</el-button>
  10. <el-button @click="editList">编辑手机号</el-button>
  11. </div>
  12. <div class="table">
  13. <el-table
  14. :data="tableData"
  15. border
  16. is-horizontal-resize
  17. :default-sort="{prop: 'date', order: 'descending'}"
  18. element-loading-background="rgba(0, 0, 0, 0.8)"
  19. class=""
  20. @selection-change="handleSelectionChange" @current-change="clickChange"
  21. >
  22. <el-table-column label="选择" width="55">
  23. <template slot-scope="scope">
  24. <el-radio v-model="tableRadio" :label="scope.row"><i></i></el-radio>
  25. </template>
  26. </el-table-column>
  27. <el-table-column
  28. type="index"
  29. label="序号"
  30. align="center"
  31. width="50">
  32. </el-table-column>
  33. <el-table-column
  34. prop="UserName"
  35. label="主账号用户名"
  36. >
  37. </el-table-column>
  38. <el-table-column
  39. prop="UserPhone"
  40. label="手机号"
  41. >
  42. </el-table-column>
  43. <el-table-column
  44. prop="Status"
  45. label="状态"
  46. >
  47. <!--1:启用 8:暂停 9:删除-->
  48. <template slot-scope="scope">
  49. <span v-if="scope.row.Status == 1" style="color: yellowgreen">启用</span>
  50. <span v-if="scope.row.Status == 8" style="color: yellow">暂停</span>
  51. <span v-if="scope.row.Status == 9" style="color: red">删除</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column
  55. prop="Memo"
  56. label="备注"
  57. >
  58. </el-table-column>
  59. <el-table-column
  60. prop="UserPhone"
  61. label="操作">
  62. <template slot-scope="scope">
  63. <el-button type="danger" size="mini"
  64. @click="pauseRowDel(scope.row)">
  65. 删除
  66. </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.memo" placeholder="姓名或家庭关系"></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. testTable,
  104. ShopManagerStatusEdit,
  105. VipUserAssociatedPhoneSimpleQuery,
  106. VipUserAssociatedPhoneAdd,
  107. EditShopVenueEquip,
  108. VipUserAssociatedPhoneEdit,
  109. VipUserAssociatedPhoneDel,
  110. VipUserAssociatedPhoneStatusEdit
  111. } from "../api/getApiRes";
  112. let qs = require('qs');
  113. export default {
  114. data() {
  115. return {
  116. regionName: '',
  117. dialogVisible: false,
  118. dialogMemberVisible: false,
  119. dialogTitle: '新增手机号',
  120. // panel 配置项目
  121. multipleSelection: [],
  122. tableRadio: [],
  123. pageination: {
  124. pageItem: 100,
  125. pageoptions: pageOptions(),
  126. total: 100,
  127. pageIndex: 1,
  128. },
  129. form: {
  130. phone: '',
  131. memo: '',
  132. eqId: '',
  133. eqSn: '',
  134. name: '',
  135. version: '',
  136. userCode: '',
  137. shopId: '',
  138. pId: '',
  139. btnType: 0,
  140. equipType: 1,
  141. },
  142. options: [
  143. {value: 1, label: 'TVBox'},
  144. {value: 2, label: 'BLEHub'},
  145. ],
  146. shops: [],
  147. tableData: [],
  148. serachBtnStatus: false,
  149. }
  150. },
  151. mounted() {
  152. this.regionName = this.$route.query.name;
  153. this.getTableQuery();
  154. },
  155. methods: {
  156. goBack() {
  157. this.$router.push({
  158. path: '/member', query: {}
  159. });
  160. },
  161. // 删除
  162. pauseRowDel(row) {
  163. let that = this;
  164. let param = {
  165. token: localStorage.token,
  166. userId: this.$route.query.userId,
  167. pId: row.PId,
  168. };
  169. let postdata = qs.stringify(param);
  170. this.$confirm('此操作将永久删除该手机号, 是否继续?', '提示', {
  171. confirmButtonText: '确定',
  172. cancelButtonText: '取消',
  173. type: 'warning'
  174. }).then(() => {
  175. VipUserAssociatedPhoneDel(postdata).then(res => {
  176. let json = res;
  177. if (json.Code == 0) {
  178. that.$message({
  179. showClose: true,
  180. message: '选中的手机号已删除!',
  181. type: 'success'
  182. });
  183. // 重载列表
  184. that.getTableQuery();
  185. } else {
  186. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  187. }
  188. });
  189. }).catch(() => {
  190. this.$message({
  191. type: 'info',
  192. message: '已取消删除'
  193. });
  194. });
  195. },
  196. clearForm() {
  197. // clear
  198. this.form.name = '';
  199. this.form.phone = '';
  200. this.form.memo = '';
  201. this.form.userCode = '';
  202. this.form.shopId = '';
  203. this.form.eqSn = '';
  204. this.form.version = '';
  205. this.form.pId = '';
  206. this.form.equipType = 1;
  207. },
  208. handleSelectionChange(val) {
  209. this.multipleSelection = val;
  210. },
  211. // 新增手机号
  212. addMember() {
  213. this.clearForm();
  214. this.dialogMemberVisible = true;
  215. this.form.btnType = 0;
  216. this.dialogTitle = '新增手机号'
  217. },
  218. clickChange(item) {
  219. this.tableRadio = item
  220. },
  221. // 删除
  222. delList() {
  223. let that = this;
  224. if (this.tableRadio.length == 0) {
  225. this.$message.error("请先选中一条记录");
  226. return false
  227. }
  228. let userId = this.tableRadio.Id;
  229. let param = {
  230. key: localStorage.ServiceKey,
  231. shopId: localStorage.ServiceId,
  232. svId: this.$route.query.svId,
  233. eqId: this.tableRadio.EqId,
  234. status: 9,//1:启用 8:暂停 9:删除
  235. };
  236. let postdata = qs.stringify(param);
  237. this.$confirm('此操作将永久删除该手机号, 是否继续?', '提示', {
  238. confirmButtonText: '确定',
  239. cancelButtonText: '取消',
  240. type: 'warning'
  241. }).then(() => {
  242. VipUserAssociatedPhoneStatusEdit(postdata).then(res => {
  243. let json = res;
  244. if (json.Code == 0) {
  245. that.$message({
  246. showClose: true,
  247. message: '选中的手机号已删除!',
  248. type: 'success'
  249. });
  250. // 重载列表
  251. that.getTableQuery();
  252. } else {
  253. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  254. }
  255. });
  256. }).catch(() => {
  257. this.$message({
  258. type: 'info',
  259. message: '已取消删除'
  260. });
  261. });
  262. },
  263. // 编辑
  264. editList() {
  265. let that = this;
  266. this.clearForm();
  267. if (this.tableRadio.length == 0) {
  268. this.$message.error("请先选中一条记录");
  269. return false
  270. }
  271. let row = this.tableRadio;
  272. this.form.shopid = row.ShopId;
  273. this.form.userId = row.Id;
  274. this.form.name = row.Name;
  275. this.form.phone = row.UserPhone;
  276. this.form.userCode = row.Usercode;
  277. this.form.pId = row.PId;
  278. this.form.password = '';
  279. this.form.eqId = row.EqId;
  280. this.form.equipType = row.EquipType;
  281. this.form.memo = row.Memo;
  282. this.form.adminType = row.AdminType;
  283. this.dialogVisible = true;
  284. this.dialogTitle = '编辑手机号';
  285. this.form.btnType = 1;
  286. this.dialogMemberVisible = true
  287. },
  288. // 确认提交新增手机号
  289. confirmMember() {
  290. let that = this;
  291. if (!that.form.phone) {
  292. this.$message.error('错了哦,手机号码不能为空');
  293. return false
  294. }
  295. if (!globalCheckPhone(that.form.phone)) {
  296. this.$message.error('错了哦,手机号格式不正确');
  297. return false
  298. }
  299. if (that.form.memo) {
  300. if (that.form.memo.length > 200) {
  301. this.$message.error('错了哦,备注字数超过200个字');
  302. return false
  303. }
  304. }
  305. let param = {
  306. token: localStorage.token,
  307. userId: this.$route.query.userId,
  308. phone: this.form.phone,
  309. memo: this.form.memo,
  310. };
  311. let postdata = qs.stringify(param);
  312. VipUserAssociatedPhoneAdd(postdata).then(res => {
  313. let json = res;
  314. if (json.Code == 0) {
  315. // 关闭弹窗
  316. that.dialogMemberVisible = false;
  317. // 重载列表
  318. that.getTableQuery();
  319. that.$message({
  320. showClose: true,
  321. message: '所属设备添加成功!',
  322. type: 'success'
  323. });
  324. } else {
  325. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  326. }
  327. })
  328. },
  329. confirmEditMember() {
  330. let that = this;
  331. console.log(that.form.version.length);
  332. // checkNum
  333. if (!that.form.phone) {
  334. this.$message.error('错了哦,手机号码不能为空');
  335. return false
  336. }
  337. if (!globalCheckPhone(that.form.phone)) {
  338. this.$message.error('错了哦,手机号格式不正确');
  339. return false
  340. }
  341. if (that.form.memo) {
  342. if (that.form.memo.length > 200) {
  343. this.$message.error('错了哦,备注字数超过200个字');
  344. return false
  345. }
  346. }
  347. let param = {
  348. token: localStorage.token,
  349. userId: this.$route.query.userId,
  350. phone: this.form.phone,
  351. memo: this.form.memo,
  352. pId: this.form.pId,
  353. };
  354. let postdata = qs.stringify(param);
  355. VipUserAssociatedPhoneEdit(postdata).then(res => {
  356. let json = res;
  357. if (json.Code == 0) {
  358. // 关闭弹窗
  359. that.dialogMemberVisible = false;
  360. // 重载列表
  361. that.getTableQuery();
  362. that.$message({
  363. showClose: true,
  364. message: '手机号信息编辑成功!',
  365. type: 'success'
  366. });
  367. } else {
  368. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  369. }
  370. })
  371. },
  372. // 查询按钮
  373. query() {
  374. // 按钮倒计时
  375. let that = this;
  376. that.serachBtnStatus = true;
  377. let totalTime = 2;
  378. let clock = window.setInterval(() => {
  379. totalTime--;
  380. if (totalTime < 0) {
  381. totalTime = 2;
  382. that.serachBtnStatus = false;
  383. }
  384. }, 1000);
  385. this.getTableQuery();
  386. this.$message.success('查询完毕');
  387. },
  388. // 页面数据查询
  389. getTableQuery() {
  390. let that = this;
  391. that.loading = true;
  392. let param = {
  393. token: localStorage.token,
  394. userId: this.$route.query.userId,
  395. };
  396. let postdata = qs.stringify(param);
  397. VipUserAssociatedPhoneSimpleQuery(postdata).then(res => {
  398. let json = res;
  399. if (json.Code == 0) {
  400. that.loading = false;
  401. if (json.Rs) {
  402. that.allTableData = json.Rs;
  403. that.recordsTotal = json.Rs.length;
  404. } else {
  405. that.allTableData = [];
  406. that.recordsTotal = 0;
  407. }
  408. // 设置分页数据
  409. that.setPaginations();
  410. } else {
  411. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  412. }
  413. })
  414. },
  415. // 设置分页数据
  416. setPaginations() {
  417. // 分页属性
  418. let that = this;
  419. that.pageination.total = that.recordsTotal;
  420. // 默认分页
  421. that.tableData = that.allTableData.filter((item, index) => {
  422. return index < that.pageination.pageItem;
  423. });
  424. },
  425. // 每页显示数量
  426. handleSizeChange() {
  427. let that = this;
  428. that.tableData = that.allTableData.filter((item, index) => {
  429. return index < that.pageination.pageItem;
  430. });
  431. that.draw = that.pageination.pageItem;
  432. that.getTableQuery();
  433. },
  434. // 翻页
  435. pageChange(pageIndex) {
  436. let that = this;
  437. // 获取当前页
  438. let index = that.pageination.pageItem * (pageIndex - 1);
  439. // 数据总数
  440. let nums = that.pageination.pageItem * pageIndex;
  441. // 容器
  442. let tables = [];
  443. for (var i = index; i < nums; i++) {
  444. if (that.allTableData[i]) {
  445. tables.push(that.allTableData[i])
  446. }
  447. this.tableData = tables;
  448. }
  449. that.start = index * that.draw;
  450. // that.getTableQuery();
  451. },
  452. // 自动排序
  453. sortChange(params) {
  454. console.log(params)
  455. },
  456. // 过滤时间
  457. filterFmtDate(value, row, column) {
  458. let that = this;
  459. return nonTfmtDate(column, 11);
  460. },
  461. // 暂停
  462. pause(row) {
  463. let that = this;
  464. console.log(row);
  465. this.$confirm('是否暂停设备' + row.EqSn + '?', '暂停操作', {
  466. confirmButtonText: '确定',
  467. cancelButtonText: '取消',
  468. type: 'warning'
  469. }).then(() => {
  470. let param = {
  471. key: localStorage.ServiceKey,
  472. shopId: localStorage.ServiceId,
  473. svId: this.$route.query.svId,
  474. eqId: row.EqId,
  475. status: 8,//1:启用 8:暂停 9:删除
  476. };
  477. let postdata = qs.stringify(param);
  478. VipUserAssociatedPhoneStatusEdit(postdata).then(res => {
  479. let json = res;
  480. if (json.Code == 0) {
  481. that.$message({
  482. showClose: true,
  483. message: row.EqSn + '暂停成功!',
  484. type: 'success'
  485. });
  486. // table 重载
  487. that.getTableQuery();
  488. } else {
  489. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  490. }
  491. })
  492. }).catch(() => {
  493. this.$message({
  494. type: 'info',
  495. message: '已取消暂停'
  496. });
  497. });
  498. },
  499. // 开启
  500. run(row) {
  501. let that = this;
  502. this.$confirm('是否开启设备' + row.EqSn + '?', '开启操作', {
  503. confirmButtonText: '确定',
  504. cancelButtonText: '取消',
  505. type: 'warning'
  506. }).then(() => {
  507. let param = {
  508. key: localStorage.ServiceKey,
  509. shopId: localStorage.ServiceId,
  510. svId: this.$route.query.svId,
  511. eqId: row.EqId,
  512. status: 1,//1:启用 8:暂停 9:删除
  513. };
  514. let postdata = qs.stringify(param);
  515. VipUserAssociatedPhoneStatusEdit(postdata).then(res => {
  516. let json = res;
  517. if (json.Code == 0) {
  518. that.$message({
  519. showClose: true,
  520. message: row.EqSn + '开启成功!',
  521. type: 'success'
  522. });
  523. // table 重载
  524. that.getTableQuery();
  525. } else {
  526. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  527. }
  528. })
  529. }).catch(() => {
  530. this.$message({
  531. type: 'info',
  532. message: '已取消开启'
  533. });
  534. });
  535. },
  536. },
  537. watch: {
  538. $route(to) {
  539. if (to.name == 'relevancePhone') {
  540. this.getTableQuery();
  541. }
  542. },
  543. },
  544. }
  545. </script>
  546. <style scoped>
  547. @import "../assets/css/panel.css";
  548. .context {
  549. height: 770px;
  550. overflow-y: scroll;
  551. display: block;
  552. margin: 0 auto;
  553. background-color: #fff !important;
  554. padding: 30px;
  555. padding-bottom: 60px;
  556. }
  557. .panel-body {
  558. padding: 20px;
  559. background: #F0F2F5;
  560. }
  561. .change {
  562. width: 100%;
  563. overflow: hidden;
  564. display: block;
  565. margin: 0 auto;
  566. padding-top: 10px;
  567. padding-bottom: 10px;
  568. }
  569. .change button {
  570. float: left;
  571. }
  572. .change button.pull-right {
  573. float: right;
  574. }
  575. .dialogTitle {
  576. width: 100%;
  577. overflow: hidden;
  578. display: block;
  579. margin: 0 auto;
  580. color: #000000;
  581. font-size: 18px;
  582. text-align: center;
  583. }
  584. .dialogTitle em {
  585. float: none;
  586. font-style: normal;
  587. color: #3799FF;
  588. margin: 0;
  589. }
  590. /deep/ .el-transfer-panel__item .el-checkbox__input {
  591. left: 40px;
  592. }
  593. .dialogFooter {
  594. width: 90%;
  595. overflow: hidden;
  596. display: block;
  597. margin: 0 auto;
  598. margin-top: 10px;
  599. }
  600. .dialogFooter button {
  601. float: right;
  602. margin-left: 10px;
  603. }
  604. /deep/ .el-date-editor .el-range__icon {
  605. line-height: 22px;
  606. }
  607. .panel /deep/ .el-date-editor .el-range-separator {
  608. line-height: 22px;
  609. }
  610. /deep/ .el-select {
  611. width: 100%;
  612. }
  613. .panel h5 {
  614. font-size: 24px;
  615. }
  616. /*ipad only*/
  617. @media only screen and (max-width: 1366px) {
  618. .panel /deep/ .el-date-editor--daterange {
  619. width: 100%;
  620. }
  621. }
  622. </style>