index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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 v-if="isZijiazhengFlag !='true'" 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 v-if="isZijiazhengFlag !='true'" 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 v-if="isZijiazhengFlag !='true'" 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 isZijiazhengFlag = ref('false')
  134. let defauleImg = ref('@/static/images/my/user-default-img.png')
  135. const allJtClass = 'select-jt-default';
  136. let updataJtClass = ref('');
  137. let luruJtClass = ref('');
  138. let juliJtClass = ref('');
  139. let shaixuanStyleUpdate = ref('saixuan-item-box');
  140. let shaixuanStyleluru = ref('saixuan-item-box');
  141. let shaixuanStylejuli = ref('saixuan-item-box');
  142. const isOpenSelect = ref(false);
  143. const selectedOption = ref('');
  144. let isFirstClickUpdate = ref('true')
  145. let isFirstClickluru = ref('true')
  146. let isFirstClickjuli = ref('true')
  147. let userIdList = ref(null)
  148. let startDate = ref(null)
  149. let endDate = ref(null)
  150. let from = ref(null)
  151. let zjId = ref(null)
  152. function updateTimeClick() {
  153. data.sortType = 1
  154. const isFirst = isFirstClickUpdate.value == 'true';
  155. const isSecond = isFirstClickUpdate.value == 'false';
  156. if (isFirst) {
  157. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  158. updataJtClass.value = 'saixuan-jt-default';
  159. isFirstClickUpdate.value = 'false';
  160. data.sortRule = 1
  161. } else if (isSecond) {
  162. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  163. updataJtClass.value = 'saixuan-jt-click';
  164. isFirstClickUpdate.value = 'empty';
  165. data.sortRule = 2
  166. } else {
  167. shaixuanStyleUpdate.value = 'saixuan-item-box';
  168. updataJtClass.value = '';
  169. isFirstClickUpdate.value = 'true';
  170. data.sortRule = 0
  171. }
  172. data.page = 0;
  173. refreshData()
  174. }
  175. function onScrolltolower() {
  176. getMore()
  177. }
  178. function luruTimeClick() {
  179. data.sortType = 2
  180. const isFirst = isFirstClickluru.value == 'true';
  181. const isSecond = isFirstClickluru.value == 'false';
  182. if (isFirst) {
  183. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  184. luruJtClass.value = 'saixuan-jt-default';
  185. isFirstClickluru.value = 'false';
  186. data.sortRule = 1
  187. } else if (isSecond) {
  188. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  189. luruJtClass.value = 'saixuan-jt-click';
  190. isFirstClickluru.value = 'empty';
  191. data.sortRule = 2
  192. } else {
  193. shaixuanStyleluru.value = 'saixuan-item-box';
  194. luruJtClass.value = '';
  195. isFirstClickluru.value = 'true';
  196. data.sortRule = 0
  197. }
  198. data.page = 0;
  199. refreshData()
  200. }
  201. function juliClick() {
  202. if (!data.weizhiFlag) {
  203. uni.showToast({
  204. title: `当前位置经纬度获取失败,请重新进入该页面!`,
  205. icon: 'none',
  206. duration: 2000
  207. })
  208. return false
  209. }
  210. data.sortType = 3
  211. const isFirst = isFirstClickjuli.value == 'true';
  212. const isSecond = isFirstClickjuli.value == 'false';
  213. if (isFirst) {
  214. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  215. juliJtClass.value = 'saixuan-jt-default';
  216. isFirstClickjuli.value = 'false';
  217. data.sortRule = 1
  218. } else if (isSecond) {
  219. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  220. juliJtClass.value = 'saixuan-jt-click';
  221. isFirstClickjuli.value = 'empty';
  222. data.sortRule = 2
  223. } else {
  224. shaixuanStylejuli.value = 'saixuan-item-box';
  225. juliJtClass.value = '';
  226. isFirstClickjuli.value = 'true';
  227. data.sortRule = 0
  228. }
  229. data.page = 0;
  230. refreshData()
  231. }
  232. function dialogSearchBtn(name, searchData) {
  233. switch (name) {
  234. case '姓名':
  235. dialogSearchReset();
  236. data.realName = searchData.value;
  237. break;
  238. case '手机号':
  239. data.userName = searchData.value;
  240. break;
  241. }
  242. data.page = 0;
  243. refreshData();
  244. }
  245. function dialogSearchReset() {
  246. data.userName = '';
  247. data.realName = '';
  248. }
  249. const clickAlltype = (data) => {
  250. isOpen.value = !isOpen.value;
  251. }
  252. const toggle = (data, index) => {
  253. searchDialogRef.value.handleShow();
  254. }
  255. const addJiazhengRenyuan = () => {
  256. let pageInfo = {
  257. status: 'add'
  258. }
  259. uni.redirectTo({
  260. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  261. })
  262. }
  263. const lookUserInfo = (data) => {
  264. let pageInfo = {
  265. status: 'edit',
  266. id: data.id,
  267. userId: data.userId,
  268. isZijiazheng: isZijiazhengFlag.value,
  269. userIdList: userIdList.value ? userIdList.value : "",
  270. }
  271. uni.redirectTo({
  272. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  273. })
  274. }
  275. function goUpPage() {
  276. if (from.value == 'zijiazhenggongsi') {
  277. const originalParams =
  278. `isZijiazheng=true&userIdList=${userIdList.value}&startDate=${startDate.value}&endDate=${endDate.value}&zjId=${zjId.value}&from=zijiazhenggongsi`
  279. uni.redirectTo({
  280. url: `/pages/admin/zijiazheng/index?${originalParams}`
  281. })
  282. } else {
  283. uni.redirectTo({
  284. url: `/pages/admin/ShouYe/shouye`
  285. })
  286. }
  287. }
  288. function onRefresh() {
  289. data.page = 0;
  290. data.list = [];
  291. data.loading = true;
  292. refreshData();
  293. }
  294. function telephone(data) {
  295. console.log('data', data);
  296. if (data.userName) {
  297. uni.makePhoneCall({
  298. phoneNumber: data.userName
  299. });
  300. } else {
  301. uni.showToast({
  302. title: `无电话号`,
  303. icon: 'none',
  304. duration: 2000
  305. })
  306. return false
  307. }
  308. }
  309. function kechengBind(data) {
  310. uni.redirectTo({
  311. url: `/pages/admin/Jiazheng/kechengBind?id=` + data.id
  312. })
  313. }
  314. function selectChangeSkill(item) {
  315. if (item.length > 0) {
  316. data.zyId = item[0].id
  317. data.zyName = item[0].name
  318. console.log('selectChangeSkill', item);
  319. data.page = 0;
  320. refreshData()
  321. }
  322. }
  323. const convertToArray = (str) => str.split(',').map(item => item.trim());
  324. function refreshData() {
  325. const opt = {
  326. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  327. "page": 1,
  328. "realName": data.realName,
  329. "size": 10,
  330. "sortRule": data.sortRule,
  331. "sortType": data.sortType,
  332. "userName": data.userName,
  333. "jingdu": data.jingdu,
  334. "weidu": data.weidu,
  335. "userIdList": userIdList.value ? convertToArray(userIdList.value) : []
  336. }
  337. data.list = [];
  338. // 数学
  339. data.state = 'loading';
  340. data.page++;
  341. opt.page = data.page;
  342. getJiazhengList(opt).then(res => {
  343. data.list = data.list.concat(res.data.data);
  344. data.list = data.list.map(item => {
  345. const newItem = {
  346. ...item
  347. };
  348. if (item.zyNames == '') {
  349. newItem.zyNames = []
  350. } else {
  351. newItem.zyNames = item.zyNames.split(',');
  352. }
  353. return newItem;
  354. })
  355. data.loading = false;
  356. if (res.data.total > data.list.length) {
  357. data.state = 'more';
  358. data.loading = false;
  359. } else {
  360. data.state = 'no-more';
  361. data.loading = false;
  362. }
  363. }).catch(err => {
  364. data.state = 'more';
  365. data.loading = false;
  366. })
  367. }
  368. function getMore() {
  369. const opt = {
  370. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  371. "page": 1,
  372. "realName": data.realName,
  373. "size": 10,
  374. "sortRule": data.sortRule,
  375. "sortType": data.sortType,
  376. "userName": data.userName,
  377. "jingdu": data.jingdu,
  378. "weidu": data.weidu,
  379. "userIdList": userIdList.value ? convertToArray(userIdList.value) : []
  380. }
  381. if (data.state == 'no-more') return;
  382. data.state = 'loading';
  383. data.page++;
  384. opt.page = data.page;
  385. getJiazhengList(opt).then(res => {
  386. data.list = data.list.concat(res.data.data);
  387. data.list = data.list.map(item => {
  388. const newItem = {
  389. ...item
  390. };
  391. // if(item.zyNames ==''){
  392. // newItem.zyNames = []
  393. // }else{
  394. // newItem.zyNames = item.zyNames.split(',');
  395. // }
  396. // 处理 zyNames 字段
  397. if (typeof newItem.zyNames !== 'string') {
  398. newItem.zyNames = [];
  399. } else {
  400. newItem.zyNames = newItem.zyNames.trim() == '' ? [] : newItem.zyNames.split(',');
  401. }
  402. return newItem;
  403. })
  404. console.log('data.list', data.list);
  405. data.loading = false;
  406. if (res.data.total > data.list.length) {
  407. data.state = 'more';
  408. data.loading = false;
  409. } else {
  410. data.state = 'no-more';
  411. data.loading = false;
  412. }
  413. }).catch(err => {
  414. data.state = 'more';
  415. data.loading = false;
  416. })
  417. }
  418. function getLeixing() {
  419. let req = {}
  420. getJiazhengZhiyeAll(req).then(res => {
  421. res.data.unshift({
  422. id: '',
  423. name: '全部职业'
  424. });
  425. allType = res.data
  426. // allType = dataConversionObject(res.data)
  427. console.log('allType', allType);
  428. })
  429. }
  430. function dataConversionObject(data) {
  431. let newList
  432. newList = data.map((name, index) => ({
  433. id: index,
  434. name: name
  435. }));
  436. return newList
  437. }
  438. function getCurrentWeizhi() {
  439. console.log('1231231');
  440. uni.getLocation({
  441. type: 'wgs84',
  442. success: function(res) {
  443. console.log('res', res)
  444. data.jingdu = res.longitude
  445. data.weidu = res.latitude
  446. data.weizhiFlag = true
  447. console.log('当前位置的经度:' + res.longitude);
  448. console.log('当前位置的纬度:' + res.latitude);
  449. }
  450. });
  451. }
  452. onLoad((options) => {
  453. if (options && options.isZijiazheng == 'true') {
  454. isZijiazhengFlag.value = 'true'
  455. userIdList.value = options.userIdList
  456. startDate.value = options.startDate
  457. endDate.value = options.endDate
  458. from.value = options.from
  459. zjId.value = options.zjId
  460. console.log('userIdList.value', userIdList.value);
  461. }
  462. getMore()
  463. getLeixing()
  464. getCurrentWeizhi()
  465. })
  466. </script>