index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 设备号管理
  7. </h2>
  8. <div class="m-core">
  9. <save-form
  10. :inline="true"
  11. :model="searchForm"
  12. ref="searchForm"
  13. @submit="search"
  14. @reset="onReSet"
  15. >
  16. <el-form-item prop="search">
  17. <el-input
  18. v-model.trim="searchForm.search"
  19. clearable
  20. @keyup.enter.native="search"
  21. placeholder="姓名、编号、手机号"
  22. ></el-input>
  23. </el-form-item>
  24. <el-form-item prop="deviceNum">
  25. <el-input
  26. v-model.trim="searchForm.deviceNum"
  27. @keyup.enter.native="deviceNum"
  28. clearable
  29. placeholder="设备号"
  30. ></el-input>
  31. </el-form-item>
  32. <el-form-item prop="timer">
  33. <el-date-picker
  34. v-model.trim="searchForm.timer"
  35. type="daterange"
  36. value-format="yyyy-MM-dd"
  37. range-separator="至"
  38. start-placeholder="绑定开始日期"
  39. end-placeholder="绑定结束日期"
  40. :picker-options="{
  41. firstDayOfWeek: 1,
  42. }"
  43. >
  44. </el-date-picker>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button native-type="submit" type="primary">搜索</el-button>
  48. <el-button native-type="reset" type="danger">重置</el-button>
  49. </el-form-item>
  50. </save-form>
  51. <div class="tableWrap">
  52. <el-table
  53. style="width: 100%"
  54. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  55. :data="tableList"
  56. >
  57. <el-table-column align="center" prop="studentId" label="用户编号">
  58. <template slot-scope="scope">
  59. <div>
  60. <copy-text>{{ scope.row.userId }}</copy-text>
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column align="center" prop="studentId" label="用户姓名">
  65. <template slot-scope="scope">
  66. <div>
  67. <copy-text>{{ scope.row.user.realName }}</copy-text>
  68. </div>
  69. </template>
  70. </el-table-column>
  71. <el-table-column align="center" prop="studentId" label="手机号码">
  72. <template slot-scope="scope">
  73. <div>
  74. <copy-text>{{ scope.row.user.phone }}</copy-text>
  75. </div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column align="center" prop="studentId" label="设备号" width="280px">
  79. <template slot-scope="scope">
  80. <div>
  81. <copy-text>{{ scope.row.deviceNum }}</copy-text>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column align="center" prop="studentId" label="绑定时间">
  86. <template slot-scope="scope">
  87. <div>
  88. {{ scope.row.bindTime }}
  89. </div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column align="center" prop="studentId" label="操作">
  93. <template slot-scope="scope">
  94. <div>
  95. <auth auths="userDevice/unbind">
  96. <el-button type="text" @click="unbind(scope.row)"
  97. >解除限制</el-button
  98. >
  99. </auth>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <pagination
  105. sync
  106. :total.sync="rules.total"
  107. :page.sync="rules.page"
  108. :limit.sync="rules.limit"
  109. :page-sizes="rules.page_size"
  110. @pagination="getList"
  111. />
  112. </div>
  113. </div>
  114. </div>
  115. </template>
  116. <script>
  117. import pagination from "@/components/Pagination/index";
  118. import { getUserDevice, unbindUserDevice } from "./api";
  119. import { getTimes } from "@/utils";
  120. export default {
  121. components: { pagination },
  122. data() {
  123. return {
  124. searchForm: {
  125. search: null,
  126. deviceNum: null,
  127. timer: [],
  128. },
  129. tableList: [],
  130. organList: [],
  131. rules: {
  132. // 分页规则
  133. limit: 10, // 限制显示条数
  134. page: 1, // 当前页
  135. total: 0, // 总条数
  136. page_size: [10, 20, 40, 50], // 选择限制显示条数
  137. },
  138. };
  139. },
  140. //生命周期 - 创建完成(可以访问当前this实例)
  141. created() {},
  142. //生命周期 - 挂载完成(可以访问DOM元素)
  143. mounted() {
  144. // 获取分部
  145. this.init();
  146. },
  147. methods: {
  148. init() {
  149. this.getList();
  150. },
  151. async getList() {
  152. const { timer, ...rest } = this.searchForm;
  153. let obj = {
  154. ...rest,
  155. page: this.rules.page,
  156. rows: this.rules.limit,
  157. ...getTimes(timer, ["bindStartTime", "bindEndTime"], "YYYY-MM-DD"),
  158. };
  159. try {
  160. const res = await getUserDevice(obj);
  161. this.tableList = res.data.rows;
  162. this.rules.total = res.data.total;
  163. } catch (e) {
  164. console.log(e);
  165. }
  166. },
  167. search() {
  168. this.rules.page = 1;
  169. this.getList();
  170. },
  171. onReSet() {
  172. this.$refs["searchForm"].resetFields();
  173. this.search();
  174. },
  175. unbind(row) {
  176. this.$confirm(
  177. "请确认是否解除绑定,解除后该设备号可重新绑定账号",
  178. "提示",
  179. {
  180. confirmButtonText: "确定",
  181. cancelButtonText: "取消",
  182. type: "warning",
  183. }
  184. )
  185. .then(async () => {
  186. try {
  187. const res = await unbindUserDevice({ id: row.id });
  188. this.$message.success("解除绑定成功");
  189. this.getList();
  190. } catch (e) {
  191. console.log(e);
  192. }
  193. })
  194. .catch(() => {});
  195. },
  196. },
  197. };
  198. </script>
  199. <style lang='scss' scoped>
  200. </style>