index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="客户端" width="280px">
  86. <template slot-scope="scope">
  87. <div>
  88. {{ scope.row.clientId|clientTypeFilter }}
  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. {{ scope.row.bindTime }}
  96. </div>
  97. </template>
  98. </el-table-column>
  99. <el-table-column align="center" prop="studentId" label="操作">
  100. <template slot-scope="scope">
  101. <div>
  102. <auth auths="userDevice/unbind">
  103. <el-button type="text" @click="unbind(scope.row)"
  104. >解除限制</el-button
  105. >
  106. </auth>
  107. </div>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <pagination
  112. sync
  113. :total.sync="rules.total"
  114. :page.sync="rules.page"
  115. :limit.sync="rules.limit"
  116. :page-sizes="rules.page_size"
  117. @pagination="getList"
  118. />
  119. </div>
  120. </div>
  121. </div>
  122. </template>
  123. <script>
  124. import pagination from "@/components/Pagination/index";
  125. import { getUserDevice, unbindUserDevice } from "./api";
  126. import { getTimes } from "@/utils";
  127. export default {
  128. components: { pagination },
  129. data() {
  130. return {
  131. searchForm: {
  132. search: null,
  133. deviceNum: null,
  134. timer: [],
  135. },
  136. tableList: [],
  137. organList: [],
  138. rules: {
  139. // 分页规则
  140. limit: 10, // 限制显示条数
  141. page: 1, // 当前页
  142. total: 0, // 总条数
  143. page_size: [10, 20, 40, 50], // 选择限制显示条数
  144. },
  145. };
  146. },
  147. //生命周期 - 创建完成(可以访问当前this实例)
  148. created() {},
  149. //生命周期 - 挂载完成(可以访问DOM元素)
  150. mounted() {
  151. // 获取分部
  152. this.init();
  153. },
  154. methods: {
  155. init() {
  156. this.getList();
  157. },
  158. async getList() {
  159. const { timer, ...rest } = this.searchForm;
  160. let obj = {
  161. ...rest,
  162. page: this.rules.page,
  163. rows: this.rules.limit,
  164. ...getTimes(timer, ["bindStartTime", "bindEndTime"], "YYYY-MM-DD"),
  165. };
  166. try {
  167. const res = await getUserDevice(obj);
  168. this.tableList = res.data.rows;
  169. this.rules.total = res.data.total;
  170. } catch (e) {
  171. console.log(e);
  172. }
  173. },
  174. search() {
  175. this.rules.page = 1;
  176. this.getList();
  177. },
  178. onReSet() {
  179. this.$refs["searchForm"].resetFields();
  180. this.search();
  181. },
  182. unbind(row) {
  183. this.$confirm(
  184. "请确认是否解除绑定,解除后该设备号可重新绑定账号",
  185. "提示",
  186. {
  187. confirmButtonText: "确定",
  188. cancelButtonText: "取消",
  189. type: "warning",
  190. }
  191. )
  192. .then(async () => {
  193. try {
  194. const res = await unbindUserDevice({ id: row.id });
  195. this.$message.success("解除绑定成功");
  196. this.getList();
  197. } catch (e) {
  198. console.log(e);
  199. }
  200. })
  201. .catch(() => {});
  202. },
  203. },
  204. };
  205. </script>
  206. <style lang='scss' scoped>
  207. </style>