index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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. <uni-icons class="nav-bar-right-icon bar-ml10" type="search" size="20" @click="toggle('top')"></uni-icons>
  7. </view>
  8. <view class="jiazheng-search-box">
  9. <view @click.stop="clickAlltype" class="select-item-box">
  10. <text class="select-text">{{data.zyName}}</text>
  11. <icon :class="allJtClass" />
  12. </view>
  13. <view class="jiazheng-search-right">
  14. <!-- 当前点击 增加 saixuan-active-->
  15. <view @click="updateTimeClick" :class="shaixuanStyleUpdate">
  16. <text>更新时间</text>
  17. <icon :class="updataJtClass" />
  18. </view>
  19. <view @click="luruTimeClick" :class="shaixuanStyleluru">
  20. <!-- class切换 saixuan-jt-default saixuan-jt-click-->
  21. <text>录入时间</text>
  22. <icon :class="luruJtClass" />
  23. </view>
  24. <view @click="juliClick" :class="shaixuanStylejuli">
  25. <!-- class切换 saixuan-jt-default saixuan-jt-click-->
  26. <text :class="data.weizhiFlag?'':'saixuan-disabled'">距离排序</text>
  27. <icon :class="juliJtClass" />
  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 class="jz-new-btn-box">
  36. <button type="default" class="phone-green-btn" @click="addJiazhengRenyuan">新增人员</button>
  37. </view>
  38. <view>
  39. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  40. :refresher-threshold="50" @scrolltolower="onScrolltolower" refresher-background="transparent"
  41. @refresherrefresh="onRefresh" class="jz-scroll-view">
  42. <uni-list class="admin-list-box">
  43. <uni-list-item v-for="item in data.list" class="jz-list-item-box">
  44. <template v-slot:body>
  45. <view class="card-head-row">
  46. <view class="head-name">{{item.realName}}</view>
  47. <button type="default" class="phone-green-btn bz-bind-btn"
  48. @click.stop="kechengBind(item)">课程绑定</button>
  49. <button type="default" class="phone-green-btn bz-tel-btn"
  50. @click.stop="telephone(item)">打电话</button>
  51. <share :id="item.id" ref="shareRef">分享</share>
  52. </view>
  53. <view @click="lookUserInfo(item)" class="card-body-row">
  54. <view class="card-img-box">
  55. <img :src="item.icon" v-if="item.icon">
  56. <icon class="phone-default-userImg" v-else></icon>
  57. </view>
  58. <view class="body-content-row">
  59. <view class="content-text-row">
  60. <view> {{item.age}}岁<text v-if="item.jingyan"> | {{item.jingyan}}经验</text>
  61. </view>
  62. <view class="text-status">{{item.zhuangtai}}</view>
  63. </view>
  64. <view class="content-text-row">
  65. {{item.jiguanShengName === item.jiguanShiName ? item.jiguanShengName : `${item.jiguanShengName} ${item.jiguanShiName}`}}人
  66. </view>
  67. <view v-if="item.zyNames.length>0" class="content-lx-box">
  68. <view class="content-lx-item" v-for="item2 in item.zyNames" :key="item2">
  69. {{item2}}
  70. </view>
  71. </view>
  72. <!-- <view class="content-text-row">{{item.jiguan}}</view> -->
  73. </view>
  74. </view>
  75. </template>
  76. </uni-list-item>
  77. <uni-load-more :status="data.state" @click="getMore(0)"
  78. :contentText="data.contentText"></uni-load-more>
  79. </uni-list>
  80. </scroll-view>
  81. </view>
  82. <view>
  83. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  84. @reset-search="dialogSearchReset"></search-dialog>
  85. </view>
  86. <customTabbarAdminVue :current-tab="1"></customTabbarAdminVue>
  87. </view>
  88. </template>
  89. <script setup>
  90. import {
  91. ref,
  92. reactive
  93. } from "vue";
  94. import {
  95. onLoad
  96. } from "@dcloudio/uni-app";
  97. import {
  98. getJiazhengList,
  99. getJiazhengJineng,
  100. getJiazhengZhiyeAll,
  101. getJiazhengLeixing
  102. } from "@/api/jiazheng.js"
  103. import dataChecked from './common/dataChecked.vue';
  104. import searchDialog from "./common/search.vue";
  105. import share from "./common/share.vue";
  106. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  107. const searchDialogRef = ref(null);
  108. const shareRef = ref(null);
  109. let allType = ref([])
  110. let data = reactive({
  111. zyId: '',
  112. zyName: '全部职业',
  113. page: 0,
  114. size: 10,
  115. realName: '',
  116. sortRule: '', //排序规则(1降序,2升序
  117. sortRule: '', //排序类型(1更新时间,2录入时间)
  118. userName: '',
  119. weidu: '',
  120. jingdu: '',
  121. weizhiFlag: false,
  122. id: '',
  123. list: [], // 考试列表
  124. loading: false,
  125. state: 'more',
  126. contentText: {
  127. contentdown: '查看更多',
  128. contentrefresh: '加载中',
  129. contentnomore: '没有更多'
  130. }
  131. })
  132. let isOpen = ref(false)
  133. let defauleImg = ref('@/static/images/my/user-default-img.png')
  134. const allJtClass = 'select-jt-default';
  135. let updataJtClass = ref('');
  136. let luruJtClass = ref('');
  137. let juliJtClass = ref('');
  138. let shaixuanStyleUpdate = ref('saixuan-item-box');
  139. let shaixuanStyleluru = ref('saixuan-item-box');
  140. let shaixuanStylejuli = ref('saixuan-item-box');
  141. const isOpenSelect = ref(false);
  142. const selectedOption = ref('');
  143. let isFirstClickUpdate = ref('true')
  144. let isFirstClickluru = ref('true')
  145. let isFirstClickjuli = ref('true')
  146. function updateTimeClick() {
  147. data.sortType = 1
  148. const isFirst = isFirstClickUpdate.value == 'true';
  149. const isSecond = isFirstClickUpdate.value == 'false';
  150. if (isFirst) {
  151. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  152. updataJtClass.value = 'saixuan-jt-default';
  153. isFirstClickUpdate.value = 'false';
  154. data.sortRule = 1
  155. } else if (isSecond) {
  156. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  157. updataJtClass.value = 'saixuan-jt-click';
  158. isFirstClickUpdate.value = 'empty';
  159. data.sortRule = 2
  160. } else {
  161. shaixuanStyleUpdate.value = 'saixuan-item-box';
  162. updataJtClass.value = '';
  163. isFirstClickUpdate.value = 'true';
  164. data.sortRule = 0
  165. }
  166. data.page = 0;
  167. refreshData()
  168. }
  169. function onScrolltolower() {
  170. getMore()
  171. }
  172. function luruTimeClick() {
  173. data.sortType = 2
  174. const isFirst = isFirstClickluru.value == 'true';
  175. const isSecond = isFirstClickluru.value == 'false';
  176. if (isFirst) {
  177. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  178. luruJtClass.value = 'saixuan-jt-default';
  179. isFirstClickluru.value = 'false';
  180. data.sortRule = 1
  181. } else if (isSecond) {
  182. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  183. luruJtClass.value = 'saixuan-jt-click';
  184. isFirstClickluru.value = 'empty';
  185. data.sortRule = 2
  186. } else {
  187. shaixuanStyleluru.value = 'saixuan-item-box';
  188. luruJtClass.value = '';
  189. isFirstClickluru.value = 'true';
  190. data.sortRule = 0
  191. }
  192. data.page = 0;
  193. refreshData()
  194. }
  195. function juliClick() {
  196. if (!data.weizhiFlag) {
  197. uni.showToast({
  198. title: `当前位置经纬度获取失败,请重新进入该页面!`,
  199. icon: 'none',
  200. duration: 2000
  201. })
  202. return false
  203. }
  204. data.sortType = 3
  205. const isFirst = isFirstClickjuli.value == 'true';
  206. const isSecond = isFirstClickjuli.value == 'false';
  207. if (isFirst) {
  208. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  209. juliJtClass.value = 'saixuan-jt-default';
  210. isFirstClickjuli.value = 'false';
  211. data.sortRule = 1
  212. } else if (isSecond) {
  213. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  214. juliJtClass.value = 'saixuan-jt-click';
  215. isFirstClickjuli.value = 'empty';
  216. data.sortRule = 2
  217. } else {
  218. shaixuanStylejuli.value = 'saixuan-item-box';
  219. juliJtClass.value = '';
  220. isFirstClickjuli.value = 'true';
  221. data.sortRule = 0
  222. }
  223. data.page = 0;
  224. refreshData()
  225. }
  226. function dialogSearchBtn(name, searchData) {
  227. switch (name) {
  228. case '姓名':
  229. dialogSearchReset();
  230. data.realName = searchData.value;
  231. break;
  232. case '手机号':
  233. data.userName = searchData.value;
  234. break;
  235. }
  236. data.page = 0;
  237. refreshData();
  238. }
  239. function dialogSearchReset() {
  240. data.userName = '';
  241. data.realName = '';
  242. }
  243. const clickAlltype = (data) => {
  244. isOpen.value = !isOpen.value;
  245. }
  246. const toggle = (data, index) => {
  247. searchDialogRef.value.handleShow();
  248. }
  249. const addJiazhengRenyuan = () => {
  250. let pageInfo = {
  251. status: 'add'
  252. }
  253. uni.redirectTo({
  254. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  255. })
  256. }
  257. const lookUserInfo = (data) => {
  258. let pageInfo = {
  259. status: 'edit',
  260. id: data.id,
  261. userId: data.userId
  262. }
  263. uni.redirectTo({
  264. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  265. })
  266. }
  267. function goUpPage() {
  268. uni.redirectTo({
  269. url: `/pages/admin/ShouYe/shouye`
  270. })
  271. }
  272. function onRefresh() {
  273. data.page = 0;
  274. data.list = [];
  275. data.loading = true;
  276. refreshData();
  277. }
  278. function telephone(data) {
  279. console.log('data', data);
  280. if (data.userName) {
  281. uni.makePhoneCall({
  282. phoneNumber: data.userName
  283. });
  284. } else {
  285. uni.showToast({
  286. title: `无电话号`,
  287. icon: 'none',
  288. duration: 2000
  289. })
  290. return false
  291. }
  292. }
  293. function kechengBind(data) {
  294. uni.redirectTo({
  295. url: `/pages/admin/Jiazheng/kechengBind?id=` + data.id
  296. })
  297. }
  298. function selectChangeSkill(item) {
  299. if (item.length > 0) {
  300. data.zyId = item[0].id
  301. data.zyName = item[0].name
  302. console.log('selectChangeSkill', item);
  303. data.page = 0;
  304. refreshData()
  305. }
  306. }
  307. function refreshData() {
  308. const opt = {
  309. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  310. "page": 1,
  311. "realName": data.realName,
  312. "size": 10,
  313. "sortRule": data.sortRule,
  314. "sortType": data.sortType,
  315. "userName": data.userName,
  316. "jingdu": data.jingdu,
  317. "weidu": data.weidu
  318. }
  319. data.list = [];
  320. // 数学
  321. data.state = 'loading';
  322. data.page++;
  323. opt.page = data.page;
  324. getJiazhengList(opt).then(res => {
  325. data.list = data.list.concat(res.data.data);
  326. data.list = data.list.map(item => {
  327. const newItem = {
  328. ...item
  329. };
  330. if (item.zyNames == '') {
  331. newItem.zyNames = []
  332. } else {
  333. newItem.zyNames = item.zyNames.split(',');
  334. }
  335. return newItem;
  336. })
  337. data.loading = false;
  338. if (res.data.total > data.list.length) {
  339. data.state = 'more';
  340. data.loading = false;
  341. } else {
  342. data.state = 'no-more';
  343. data.loading = false;
  344. }
  345. }).catch(err => {
  346. data.state = 'more';
  347. data.loading = false;
  348. })
  349. }
  350. function getMore() {
  351. const opt = {
  352. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  353. "page": 1,
  354. "realName": data.realName,
  355. "size": 10,
  356. "sortRule": data.sortRule,
  357. "sortType": data.sortType,
  358. "userName": data.userName,
  359. "jingdu": data.jingdu,
  360. "weidu": data.weidu
  361. }
  362. if (data.state == 'no-more') return;
  363. data.state = 'loading';
  364. data.page++;
  365. opt.page = data.page;
  366. getJiazhengList(opt).then(res => {
  367. data.list = data.list.concat(res.data.data);
  368. data.list = data.list.map(item => {
  369. const newItem = {
  370. ...item
  371. };
  372. // if(item.zyNames ==''){
  373. // newItem.zyNames = []
  374. // }else{
  375. // newItem.zyNames = item.zyNames.split(',');
  376. // }
  377. // 处理 zyNames 字段
  378. if (typeof newItem.zyNames !== 'string') {
  379. newItem.zyNames = [];
  380. } else {
  381. newItem.zyNames = newItem.zyNames.trim() == '' ? [] : newItem.zyNames.split(',');
  382. }
  383. return newItem;
  384. })
  385. console.log('data.list', data.list);
  386. data.loading = false;
  387. if (res.data.total > data.list.length) {
  388. data.state = 'more';
  389. data.loading = false;
  390. } else {
  391. data.state = 'no-more';
  392. data.loading = false;
  393. }
  394. }).catch(err => {
  395. data.state = 'more';
  396. data.loading = false;
  397. })
  398. }
  399. function getLeixing() {
  400. let req = {}
  401. getJiazhengZhiyeAll(req).then(res => {
  402. res.data.unshift({
  403. id: '',
  404. name: '全部职业'
  405. });
  406. allType = res.data
  407. // allType = dataConversionObject(res.data)
  408. console.log('allType', allType);
  409. })
  410. }
  411. function dataConversionObject(data) {
  412. let newList
  413. newList = data.map((name, index) => ({
  414. id: index,
  415. name: name
  416. }));
  417. return newList
  418. }
  419. function getCurrentWeizhi() {
  420. console.log('1231231');
  421. uni.getLocation({
  422. type: 'wgs84',
  423. success: function(res) {
  424. console.log('res', res)
  425. data.jingdu = res.longitude
  426. data.weidu = res.latitude
  427. data.weizhiFlag = true
  428. console.log('当前位置的经度:' + res.longitude);
  429. console.log('当前位置的纬度:' + res.latitude);
  430. }
  431. });
  432. }
  433. onLoad(() => {
  434. getMore()
  435. getLeixing()
  436. getCurrentWeizhi()
  437. })
  438. </script>