index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="admin-jiazheng-list">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">家政人员</text>
  6. <view class="nav-bar-icon-box">
  7. <text class="nav-bar-right-icon" @click="addJiazhengRenyuan">+</text>
  8. <uni-icons class="nav-bar-right-icon" type="search" size="18" color="#666"
  9. @click="toggle('top')"></uni-icons>
  10. </view>
  11. </view>
  12. <view class="jiazheng-search-box">
  13. <view @click.stop="clickAlltype" class="select-item-box">
  14. <text>{{data.leixing}}</text>
  15. <icon :class="allJtClass" />
  16. </view>
  17. <view class="jiazheng-search-right">
  18. <!-- 当前点击 增加 saixuan-active-->
  19. <view @click="updateTimeClick" :class="shaixuanStyleUpdate">
  20. <text>更新时间</text>
  21. <icon :class="updataJtClass" />
  22. </view>
  23. <view @click="luruTimeClick" :class="shaixuanStyleluru">
  24. <!-- class切换 saixuan-jt-default saixuan-jt-click-->
  25. <text>录入时间</text>
  26. <icon :class="luruJtClass" />
  27. </view>
  28. </view>
  29. </view>
  30. <view class="all-type-box" v-show="isOpen" @click="clickAlltype">
  31. <dataChecked :list="allType" mode="single" :defaultCount="99" :showAdd="false"
  32. @change="selectChangeSkill" />
  33. </view>
  34. <view>
  35. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  36. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  37. class="phone-scroll-view">
  38. <uni-list class="admin-list-box">
  39. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  40. <template v-slot:body>
  41. <view>
  42. <view>{{item.realName}}</view>
  43. <view @click="telephone(item)">打电话</view>
  44. </view>
  45. <view @click="lookUserInfo(item)">
  46. <image :src="item.icon ||defauleImg" mode=""></image>
  47. <view>
  48. <p> {{item.age}}岁|{{item.jingyan}}年经验</p>
  49. <p>{{item.jiguan}}</p>
  50. </view>
  51. <view>
  52. {{item.zhuangtai}}
  53. </view>
  54. </view>
  55. </template>
  56. </uni-list-item>
  57. <uni-load-more :status="data.state" @click="getMore(0)"
  58. :contentText="data.contentText"></uni-load-more>
  59. </uni-list>
  60. </scroll-view>
  61. </view>
  62. <view>
  63. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  64. @reset-search="dialogSearchReset"></search-dialog>
  65. </view>
  66. <customTabbarAdminVue :current-tab="1"></customTabbarAdminVue>
  67. </view>
  68. </template>
  69. <script setup>
  70. import {
  71. ref,
  72. reactive
  73. } from "vue";
  74. import {
  75. onLoad
  76. } from "@dcloudio/uni-app";
  77. import {
  78. getJiazhengList,
  79. getJiazhengLeixing
  80. } from "@/api/jiazheng.js"
  81. import dataChecked from './common/dataChecked.vue';
  82. import searchDialog from "./common/search.vue";
  83. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  84. const searchDialogRef = ref(null);
  85. let allType = ref([])
  86. let data = reactive({
  87. leixing: '全部类型',
  88. page: 0,
  89. size: 10,
  90. realName: '',
  91. sortRule: '', //排序规则(1降序,2升序
  92. sortRule: '', //排序类型(1更新时间,2录入时间)
  93. userName: '',
  94. list: [], // 考试列表
  95. loading: false,
  96. state: 'more',
  97. contentText: {
  98. contentdown: '查看更多',
  99. contentrefresh: '加载中',
  100. contentnomore: '没有更多'
  101. }
  102. })
  103. let isOpen = ref(false)
  104. let defauleImg = ref('@/static/images/my/user-default-img.png')
  105. const allJtClass = 'select-jt-default';
  106. let updataJtClass = ref('');
  107. let luruJtClass = ref('');
  108. let shaixuanStyleUpdate = ref('saixuan-item-box');
  109. let shaixuanStyleluru = ref('saixuan-item-box');
  110. const isOpenSelect = ref(false);
  111. const selectedOption = ref('');
  112. let isFirstClickUpdate = ref('true')
  113. let isFirstClickluru = ref('true')
  114. function updateTimeClick() {
  115. data.sortType = 1
  116. const isFirst = isFirstClickUpdate.value == 'true';
  117. const isSecond = isFirstClickUpdate.value == 'false';
  118. if (isFirst) {
  119. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  120. updataJtClass.value = 'saixuan-jt-default';
  121. isFirstClickUpdate.value = 'false';
  122. data.sortRule = 1
  123. } else if (isSecond) {
  124. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  125. updataJtClass.value = 'saixuan-jt-click';
  126. isFirstClickUpdate.value = 'empty';
  127. data.sortRule = 2
  128. } else {
  129. shaixuanStyleUpdate.value = 'saixuan-item-box';
  130. updataJtClass.value = '';
  131. isFirstClickUpdate.value = 'true';
  132. data.sortRule = 0
  133. }
  134. data.page = 0;
  135. refreshData()
  136. }
  137. function luruTimeClick() {
  138. data.sortType = 2
  139. const isFirst = isFirstClickluru.value == 'true';
  140. const isSecond = isFirstClickluru.value == 'false';
  141. if (isFirst) {
  142. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  143. luruJtClass.value = 'saixuan-jt-default';
  144. isFirstClickluru.value = 'false';
  145. data.sortRule = 1
  146. } else if (isSecond) {
  147. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  148. luruJtClass.value = 'saixuan-jt-click';
  149. isFirstClickluru.value = 'empty';
  150. data.sortRule = 2
  151. } else {
  152. shaixuanStyleluru.value = 'saixuan-item-box';
  153. luruJtClass.value = '';
  154. isFirstClickluru.value = 'true';
  155. data.sortRule = 0
  156. }
  157. data.page = 0;
  158. refreshData()
  159. }
  160. function dialogSearchBtn(name, searchData) {
  161. switch (name) {
  162. case '姓名':
  163. dialogSearchReset();
  164. data.realName = searchData.value;
  165. break;
  166. case '手机号':
  167. data.userName = searchData.value;
  168. break;
  169. }
  170. data.page = 0;
  171. refreshData();
  172. }
  173. function dialogSearchReset() {
  174. data.userName = '';
  175. data.realName = '';
  176. }
  177. const clickAlltype = (data) => {
  178. isOpen.value = !isOpen.value;
  179. }
  180. const toggle = (data, index) => {
  181. searchDialogRef.value.handleShow();
  182. }
  183. const addJiazhengRenyuan = () => {
  184. let pageInfo = {
  185. status: 'add'
  186. }
  187. uni.redirectTo({
  188. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  189. })
  190. }
  191. const lookUserInfo = (data) => {
  192. let pageInfo = {
  193. status: 'edit',
  194. id: data.id,
  195. userId: data.userId
  196. }
  197. uni.redirectTo({
  198. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  199. })
  200. }
  201. function goUpPage() {
  202. uni.redirectTo({
  203. url: `/pages/admin/ShouYe/shouye`
  204. })
  205. }
  206. function onRefresh() {
  207. data.page = 0;
  208. data.list = [];
  209. data.loading = true;
  210. refreshData();
  211. }
  212. function telephone(data) {
  213. console.log('data', data);
  214. uni.makePhoneCall({
  215. phoneNumber: '114' //仅为示例
  216. });
  217. }
  218. function selectChangeSkill(item) {
  219. data.leixing = item[0].name
  220. console.log('selectChangeSkill', item);
  221. data.page = 0;
  222. refreshData()
  223. }
  224. function refreshData() {
  225. const opt = {
  226. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  227. "page": 1,
  228. "realName": data.realName,
  229. "size": 10,
  230. "sortRule": data.sortRule,
  231. "sortType": data.sortType,
  232. "userName": data.userName
  233. }
  234. data.list = [];
  235. // 数学
  236. data.state = 'loading';
  237. data.page++;
  238. opt.page = data.page;
  239. getJiazhengList(opt).then(res => {
  240. data.list = data.list.concat(res.data.data);
  241. data.loading = false;
  242. if (res.data.total > data.list.length) {
  243. data.state = 'more';
  244. data.loading = false;
  245. } else {
  246. data.state = 'no-more';
  247. data.loading = false;
  248. }
  249. }).catch(err => {
  250. data.state = 'more';
  251. data.loading = false;
  252. })
  253. }
  254. function getMore() {
  255. const opt = {
  256. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  257. "page": 1,
  258. "realName": data.realName,
  259. "size": 10,
  260. "sortRule": data.sortRule,
  261. "sortType": data.sortType,
  262. "userName": data.userName
  263. }
  264. if (data.state == 'no-more') return;
  265. data.state = 'loading';
  266. data.page++;
  267. opt.page = data.page;
  268. getJiazhengList(opt).then(res => {
  269. data.list = data.list.concat(res.data.data);
  270. data.loading = false;
  271. if (res.data.total > data.list.length) {
  272. data.state = 'more';
  273. data.loading = false;
  274. } else {
  275. data.state = 'no-more';
  276. data.loading = false;
  277. }
  278. }).catch(err => {
  279. data.state = 'more';
  280. data.loading = false;
  281. })
  282. }
  283. function getLeixing() {
  284. let req = {}
  285. getJiazhengLeixing(req).then(res => {
  286. allType = dataConversionObject(res.data)
  287. console.log('allType', allType.value);
  288. })
  289. }
  290. function dataConversionObject(data) {
  291. let newList
  292. newList = data.map((name, index) => ({
  293. id: index,
  294. name: name
  295. }));
  296. return newList
  297. }
  298. onLoad(() => {
  299. getMore()
  300. getLeixing()
  301. })
  302. </script>