index.vue 9.9 KB

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