index.vue 8.8 KB

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