list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="phone-list-page phone-banzheng-page">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">子账号管理</text>
  6. <uni-icons class="nav-bar-right-icon" type="search" size="22" color="#666" @click="searchBtn"></uni-icons>
  7. </view>
  8. <view class="banzheng-search-box">
  9. <view class="select-item-box">
  10. </view>
  11. <view class="filter-btn" @click="handleAddZizhanghao">新增</view>
  12. </view>
  13. <!-- 课程列表 -->
  14. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  15. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  16. class="phone-scroll-saixuan-view">
  17. <uni-list>
  18. <uni-list-item v-for="item in data.list" class="banzheng-list-item-box">
  19. <template v-slot:body>
  20. <view>
  21. <view class="banzheng-list-card-box">
  22. <view>家政公司: {{item.jzName}}</view>
  23. <view>姓名:{{item.realName}}</view>
  24. <view>手机:{{item.userName}}</view>
  25. </view>
  26. <view>
  27. <button @click="handleEditor(item)">编辑</button>
  28. <button @click="handleDelete(item)">删除</button>
  29. <button @click="handleReset(item)">重置密码</button>
  30. </view>
  31. </view>
  32. </template>
  33. </uni-list-item>
  34. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  35. </uni-list>
  36. </scroll-view>
  37. <!-- 页面底端 -->
  38. <customTabbarClientVue></customTabbarClientVue>
  39. <!-- 搜索 -->
  40. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  41. @reset-search="dialogSearchReset"></search-dialog>
  42. <!-- 删除子账号 -->
  43. <common-dialog ref="commonDialogRef" :title="deleteTitle" :content="deleteConcent"
  44. @confirm-btn="deleteQuerenBtn"></common-dialog>
  45. <!-- 新增子账号 -->
  46. <addUserDlVue ref="addUserRef" title="新增" @confirm-btn="onAddSuccess"></addUserDlVue>
  47. <!-- 更新子账号 -->
  48. <editorUserDlVue ref="editorUserRef" title="编辑" @confirm-btn="onUpdateSuccess"></editorUserDlVue>
  49. <!-- 更新密码 -->
  50. <resetPasswordVue ref="resetPasswordRef"></resetPasswordVue>
  51. </view>
  52. </template>
  53. <script setup>
  54. import searchDialog from "@/pages/admin/banzheng/search.vue";
  55. import commonDialog from '@/components/dialog/commonDialog.vue';
  56. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  57. import addUserDlVue from "./components/addUserDl.vue";
  58. import editorUserDlVue from "./components/editorUserDl.vue";
  59. import resetPasswordVue from "./components/resetPassword.vue";
  60. import {
  61. reactive,
  62. ref
  63. } from "vue";
  64. import {
  65. onLoad
  66. } from "@dcloudio/uni-app"
  67. import {
  68. getUserGuanliList,
  69. getUserGuanliDelete
  70. } from "@/api/zizhanghao.js"
  71. const data = reactive({
  72. list: [], // 办证列表
  73. loading: false,
  74. page: 0,
  75. size: 10,
  76. state: 'more',
  77. contentText: {
  78. contentdown: '查看更多',
  79. contentrefresh: '加载中',
  80. contentnomore: '没有更多'
  81. },
  82. userName: '', // 手机号
  83. realName: '', // 姓名
  84. })
  85. const deleteTitle = ref('删除')
  86. const deleteConcent = ref('你确定要执行这个操作吗')
  87. const deletUserId = ref(null)
  88. const addUserRef = ref(null)
  89. const editorUserRef = ref(null)
  90. const commonDialogRef = ref(null)
  91. const resetPasswordRef = ref(null)
  92. const searchDialogRef = ref(null)
  93. function goUpPage() {
  94. uni.redirectTo({
  95. url: '/pages/admin/ShouYe/shouye'
  96. })
  97. }
  98. function onScrolltolower() {
  99. getMore()
  100. }
  101. function handleEditor(item) {
  102. editorUserRef.value.handleShow(item.userId);
  103. }
  104. function handleDelete(item) {
  105. deletUserId.value = item.userId;
  106. commonDialogRef.value.handleShow();
  107. }
  108. function handleReset(item) {
  109. resetPasswordRef.value.handleShow(item.userId)
  110. }
  111. function onAddSuccess() {
  112. data.page = 0;
  113. refreshData();
  114. }
  115. function onUpdateSuccess() {
  116. data.page = 0;
  117. refreshData();
  118. }
  119. function handleAddZizhanghao() {
  120. addUserRef.value.handleShow()
  121. }
  122. function searchBtn() {
  123. searchDialogRef.value.handleShow();
  124. }
  125. function refreshData() {
  126. const opt = {
  127. realName: data.realName, // 姓名
  128. userName: data.userName, // 手机号
  129. page: 1,
  130. size: 10, // 固定查询10条
  131. }
  132. data.list = [];
  133. // 数学
  134. data.state = 'loading';
  135. data.page++;
  136. opt.page = data.page;
  137. getUserGuanliList(opt).then(res => {
  138. data.list = data.list.concat(res.data.data);
  139. data.loading = false;
  140. if (res.data.total > data.list.length) {
  141. data.state = 'more';
  142. data.loading = false;
  143. } else {
  144. data.state = 'no-more';
  145. data.loading = false;
  146. }
  147. }).catch(err => {
  148. data.state = 'more';
  149. data.loading = false;
  150. })
  151. }
  152. function getMore() {
  153. const opt = {
  154. realName: data.realName, // 姓名
  155. userName: data.userName, // 手机号
  156. page: 1,
  157. size: 10, // 固定查询10条
  158. }
  159. if (data.state == 'no-more') return;
  160. data.state = 'loading';
  161. data.page++;
  162. opt.page = data.page;
  163. getUserGuanliList(opt).then(res => {
  164. data.list = data.list.concat(res.data.data);
  165. data.loading = false;
  166. if (res.data.total > data.list.length) {
  167. data.state = 'more';
  168. data.loading = false;
  169. } else {
  170. data.state = 'no-more';
  171. data.loading = false;
  172. }
  173. }).catch(err => {
  174. data.state = 'more';
  175. data.loading = false;
  176. })
  177. }
  178. function onRefresh() {
  179. data.page = 0;
  180. data.list = [];
  181. data.loading = true;
  182. refreshData();
  183. }
  184. function dialogSearchBtn(name, searchData) {
  185. switch (name) {
  186. case '姓名':
  187. dialogSearchReset();
  188. data.realName = searchData.value;
  189. break;
  190. case '手机号':
  191. data.userName = searchData.value;
  192. break;
  193. }
  194. data.page = 0;
  195. refreshData();
  196. }
  197. function dialogSearchReset() {
  198. data.userName = '';
  199. data.realName = '';
  200. }
  201. function deleteQuerenBtn() {
  202. getUserGuanliDelete({
  203. userId: deletUserId.value
  204. }).then(res => {
  205. if (res.code == 0) {
  206. uni.showToast({
  207. title: '成功'
  208. })
  209. data.page = 0;
  210. refreshData();
  211. } else {
  212. uni.showToast({
  213. title: '失败'
  214. })
  215. }
  216. })
  217. }
  218. onLoad(() => {
  219. getMore()
  220. })
  221. </script>
  222. <style>
  223. </style>