index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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="list-new-btn-box">
  36. <button type="default" class="phone-green-btn" @click="addJiazhengRenyuan">新增人员</button>
  37. </view>
  38. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  39. :refresher-threshold="50" @scrolltolower="onScrolltolower" refresher-background="transparent"
  40. @refresherrefresh="onRefresh" class="jz-scroll-view">
  41. <uni-list class="admin-list-box">
  42. <uni-list-item v-for="item in data.list" class="jz-list-item-box">
  43. <template v-slot:body>
  44. <view v-if="isZijiazhengFlag !='true'" class="card-head-row">
  45. <view class="head-name">{{item.realName}}</view>
  46. <button type="default" class="phone-green-btn bz-bind-btn"
  47. @click.stop="kechengBind(item)">课程绑定</button>
  48. <button type="default" class="phone-green-btn bz-tel-btn"
  49. @click.stop="telephone(item)">打电话</button>
  50. <button type="default" class="phone-white-btn bz-tel-btn"
  51. @click.stop="getUUid(item)">分享</button>
  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. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  83. @reset-search="dialogSearchReset"></search-dialog>
  84. </view>
  85. <customTabbarAdminVue :current-tab="1"></customTabbarAdminVue>
  86. <share-popup ref="sharePopupRef" :title="shareTitle" :desc="shareDesc"
  87. :link=jianliUrl type="0" :image="shareImage" @success="onShareSuccess"/>
  88. </view>
  89. </template>
  90. <script setup>
  91. import {
  92. ref,
  93. reactive
  94. } from "vue";
  95. import {
  96. onLoad
  97. } from "@dcloudio/uni-app";
  98. import {
  99. getJiazhengList,
  100. getJiazhengJineng,
  101. getJiazhengZhiyeAll,
  102. getJiazhengLeixing,
  103. jiazhengShare
  104. } from "@/api/jiazheng.js"
  105. import SharePopup from '@/components/sharePopUp/index.vue'
  106. import config from "../../../config"
  107. import dataChecked from './common/dataChecked.vue';
  108. import searchDialog from "./common/search.vue";
  109. import share from "./common/share.vue";
  110. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  111. const searchDialogRef = ref(null);
  112. const shareRef = ref(null);
  113. let allType = ref([])
  114. let data = reactive({
  115. zyId: '',
  116. zyName: '全部职业',
  117. page: 0,
  118. size: 10,
  119. realName: '',
  120. sortRule: '', //排序规则(1降序,2升序
  121. sortRule: '', //排序类型(1更新时间,2录入时间)
  122. userName: '',
  123. weidu: '',
  124. jingdu: '',
  125. weizhiFlag: false,
  126. id: '',
  127. list: [], // 考试列表
  128. loading: false,
  129. state: 'more',
  130. contentText: {
  131. contentdown: '查看更多',
  132. contentrefresh: '加载中',
  133. contentnomore: '没有更多'
  134. }
  135. })
  136. let isOpen = ref(false)
  137. let jianliUrl = ref('')
  138. let sharePopupRef = ref(null)
  139. let uuid = ref('')
  140. let isZijiazhengFlag = ref('false')
  141. let defauleImg = ref('@/static/images/my/user-default-img.png')
  142. const allJtClass = 'select-jt-default';
  143. let updataJtClass = ref('');
  144. let luruJtClass = ref('');
  145. let juliJtClass = ref('');
  146. let shaixuanStyleUpdate = ref('saixuan-item-box');
  147. let shaixuanStyleluru = ref('saixuan-item-box');
  148. let shaixuanStylejuli = ref('saixuan-item-box');
  149. const isOpenSelect = ref(false);
  150. const selectedOption = ref('');
  151. let isFirstClickUpdate = ref('true')
  152. let isFirstClickluru = ref('true')
  153. let isFirstClickjuli = ref('true')
  154. let userIdList = ref(null)
  155. let listIds = ref(null)
  156. let startDate = ref(null)
  157. let endDate = ref(null)
  158. let from = ref(null)
  159. let jzId = ref(null)
  160. let shareTitle = ref('简历')
  161. let shareDesc = ref('请点击查看简历详情')
  162. let shareImage = ref('')
  163. function updateTimeClick() {
  164. data.sortType = 1
  165. const isFirst = isFirstClickUpdate.value == 'true';
  166. const isSecond = isFirstClickUpdate.value == 'false';
  167. if (isFirst) {
  168. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  169. updataJtClass.value = 'saixuan-jt-default';
  170. isFirstClickUpdate.value = 'false';
  171. data.sortRule = 1
  172. } else if (isSecond) {
  173. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  174. updataJtClass.value = 'saixuan-jt-click';
  175. isFirstClickUpdate.value = 'empty';
  176. data.sortRule = 2
  177. } else {
  178. shaixuanStyleUpdate.value = 'saixuan-item-box';
  179. updataJtClass.value = '';
  180. isFirstClickUpdate.value = 'true';
  181. data.sortRule = 0
  182. }
  183. data.page = 0;
  184. refreshData()
  185. }
  186. function onScrolltolower() {
  187. getMore()
  188. }
  189. function onShareSuccess(e){
  190. console.log('分享成功', e.scene)
  191. }
  192. function generateShareTitle(data) {
  193. console.log(data,'data');
  194. // 1. 姓名 [姓名]
  195. const name = (data.realName && data.realName.trim()) || '未知';
  196. const namePart = name ? `[${name}] - ` : '';
  197. // 2. 职业(取 zyNames 第一个)
  198. const jobPart = Array.isArray(data.zyNames) && data.zyNames.length > 0
  199. ? ''+data.zyNames.join(',')
  200. : '';
  201. /* // 3. 籍贯(省+市,如果相同只显示省)
  202. const province = data.jiguanShengName;
  203. const city = data.jiguanShiName;
  204. const originPart = province === city ? `,${province}人` : `,${province}${city}人`; */
  205. // 4. 经验
  206. // const experience = data.jingyan ? `,${data.jingyan}年经验` : '';
  207. // 5. 机构名 【机构】
  208. const agency= (data.jzName && data.jzName.trim()) || '';
  209. const agencyPart = agency ? `[${agency}] - ` : '';
  210. // 拼接最终 title ${originPart}${experience}
  211. return `${namePart}${agencyPart}${jobPart}`;
  212. }
  213. function getUUid(data){
  214. // 使用封装的方法生成标题
  215. shareTitle.value = generateShareTitle(data);
  216. shareDesc.value = data.jingli ? data.jingli : '请点击查看简历详情';
  217. shareImage.value = data.icon;
  218. jiazhengShare({
  219. id: data.id
  220. }).then(res => {
  221. if (res.code == 0) {
  222. uuid.value = res.data
  223. jianliUrl.value = `${config.jianliUrl}?uuid=${uuid.value}`
  224. sharePopupRef.value.open()
  225. }
  226. }).catch(err => {
  227. uni.showToast({
  228. title: '获得uuid失败',
  229. icon: 'none'
  230. })
  231. })
  232. }
  233. function luruTimeClick() {
  234. data.sortType = 2
  235. const isFirst = isFirstClickluru.value == 'true';
  236. const isSecond = isFirstClickluru.value == 'false';
  237. if (isFirst) {
  238. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  239. luruJtClass.value = 'saixuan-jt-default';
  240. isFirstClickluru.value = 'false';
  241. data.sortRule = 1
  242. } else if (isSecond) {
  243. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  244. luruJtClass.value = 'saixuan-jt-click';
  245. isFirstClickluru.value = 'empty';
  246. data.sortRule = 2
  247. } else {
  248. shaixuanStyleluru.value = 'saixuan-item-box';
  249. luruJtClass.value = '';
  250. isFirstClickluru.value = 'true';
  251. data.sortRule = 0
  252. }
  253. data.page = 0;
  254. refreshData()
  255. }
  256. function juliClick() {
  257. if (!data.weizhiFlag) {
  258. uni.showToast({
  259. title: `当前位置经纬度获取失败,请重新进入该页面!`,
  260. icon: 'none',
  261. duration: 2000
  262. })
  263. return false
  264. }
  265. data.sortType = 3
  266. const isFirst = isFirstClickjuli.value == 'true';
  267. const isSecond = isFirstClickjuli.value == 'false';
  268. if (isFirst) {
  269. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  270. juliJtClass.value = 'saixuan-jt-default';
  271. isFirstClickjuli.value = 'false';
  272. data.sortRule = 1
  273. } else if (isSecond) {
  274. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  275. juliJtClass.value = 'saixuan-jt-click';
  276. isFirstClickjuli.value = 'empty';
  277. data.sortRule = 2
  278. } else {
  279. shaixuanStylejuli.value = 'saixuan-item-box';
  280. juliJtClass.value = '';
  281. isFirstClickjuli.value = 'true';
  282. data.sortRule = 0
  283. }
  284. data.page = 0;
  285. refreshData()
  286. }
  287. function dialogSearchBtn(name, searchData) {
  288. switch (name) {
  289. case '姓名':
  290. dialogSearchReset();
  291. data.realName = searchData.value;
  292. break;
  293. case '手机号':
  294. data.userName = searchData.value;
  295. break;
  296. }
  297. data.page = 0;
  298. refreshData();
  299. }
  300. function dialogSearchReset() {
  301. data.userName = '';
  302. data.realName = '';
  303. }
  304. const clickAlltype = (data) => {
  305. isOpen.value = !isOpen.value;
  306. }
  307. const toggle = (data, index) => {
  308. searchDialogRef.value.handleShow();
  309. }
  310. const addJiazhengRenyuan = () => {
  311. let pageInfo = {
  312. status: 'add'
  313. }
  314. uni.redirectTo({
  315. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  316. })
  317. }
  318. const lookUserInfo = (data) => {
  319. let pageInfo = {
  320. status: 'edit',
  321. id: data.id,
  322. userId: data.userId,
  323. isZijiazheng: isZijiazhengFlag.value,
  324. from: from.value,
  325. endDate: endDate.value,
  326. startDate: startDate.value,
  327. jzId: jzId.value,
  328. userIdList: userIdList.value ? userIdList.value : "",
  329. listIds: listIds.value ? listIds.value : "",
  330. }
  331. uni.redirectTo({
  332. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  333. })
  334. }
  335. function goUpPage() {
  336. if (from.value == 'zijiazhenggongsi') {
  337. const originalParams =
  338. `isZijiazheng=true&userIdList=${userIdList.value}&startDate=${startDate.value}&endDate=${endDate.value}&jzId=${jzId.value}&from=zijiazhenggongsi`
  339. uni.redirectTo({
  340. url: `/pages/admin/zijiazheng/index?${originalParams}`
  341. })
  342. } else if (from.value == 'banzhengshuliang') {
  343. const originalParams =
  344. `isZijiazheng=true&userIdList=${userIdList.value}&startDate=${startDate.value}&endDate=${endDate.value}&jzId=${jzId.value}&listIds=${listIds.value}&from=zijiazhenggongsi`
  345. uni.redirectTo({
  346. url: `/pages/admin/zijiazheng/banzhengshuliang?${originalParams}`
  347. })
  348. } else if (from.value == 'yibanzhengshuliang') {
  349. const originalParams =
  350. `isZijiazheng=true&userIdList=${userIdList.value}&startDate=${startDate.value}&endDate=${endDate.value}&jzId=${jzId.value}&listIds=${listIds.value}&from=zijiazhenggongsi`
  351. uni.redirectTo({
  352. url: `/pages/admin/zijiazheng/yibanzhengshuliang?${originalParams}`
  353. })
  354. } else {
  355. uni.redirectTo({
  356. url: `/pages/admin/ShouYe/shouye`
  357. })
  358. }
  359. }
  360. function onRefresh() {
  361. data.page = 0;
  362. data.list = [];
  363. data.loading = true;
  364. refreshData();
  365. }
  366. function telephone(data) {
  367. console.log('data', data);
  368. if (data.userName) {
  369. uni.makePhoneCall({
  370. phoneNumber: data.userName
  371. });
  372. } else {
  373. uni.showToast({
  374. title: `无电话号`,
  375. icon: 'none',
  376. duration: 2000
  377. })
  378. return false
  379. }
  380. }
  381. function kechengBind(data) {
  382. uni.redirectTo({
  383. url: `/pages/admin/Jiazheng/kechengBind?id=` + data.id
  384. })
  385. }
  386. function selectChangeSkill(item) {
  387. if (item.length > 0) {
  388. data.zyId = item[0].id
  389. data.zyName = item[0].name
  390. console.log('selectChangeSkill', item);
  391. data.page = 0;
  392. refreshData()
  393. }
  394. }
  395. const convertToArray = (str) => str.split(',').map(item => item.trim());
  396. function refreshData() {
  397. const opt = {
  398. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  399. "page": 1,
  400. "realName": data.realName,
  401. "size": 10,
  402. "sortRule": data.sortRule,
  403. "sortType": data.sortType,
  404. "userName": data.userName,
  405. "jingdu": data.jingdu,
  406. "weidu": data.weidu,
  407. "jzId": jzId.value,
  408. "userIdList": userIdList.value ? convertToArray(userIdList.value) : []
  409. }
  410. data.list = [];
  411. // 数学
  412. data.state = 'loading';
  413. data.page++;
  414. opt.page = data.page;
  415. getJiazhengList(opt).then(res => {
  416. data.list = data.list.concat(res.data.data);
  417. data.list = data.list.map(item => {
  418. const newItem = {
  419. ...item
  420. };
  421. if (item.zyNames == '') {
  422. newItem.zyNames = []
  423. } else {
  424. newItem.zyNames = item.zyNames.split(',');
  425. }
  426. return newItem;
  427. })
  428. data.loading = false;
  429. if (res.data.total > data.list.length) {
  430. data.state = 'more';
  431. data.loading = false;
  432. } else {
  433. data.state = 'no-more';
  434. data.loading = false;
  435. }
  436. }).catch(err => {
  437. data.state = 'more';
  438. data.loading = false;
  439. })
  440. }
  441. function getMore() {
  442. const opt = {
  443. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  444. "page": 1,
  445. "realName": data.realName,
  446. "size": 10,
  447. "sortRule": data.sortRule,
  448. "sortType": data.sortType,
  449. "userName": data.userName,
  450. "jingdu": data.jingdu,
  451. "weidu": data.weidu,
  452. "jzId": jzId.value,
  453. "userIdList": userIdList.value ? convertToArray(userIdList.value) : []
  454. }
  455. if (data.state == 'no-more') return;
  456. data.state = 'loading';
  457. data.page++;
  458. opt.page = data.page;
  459. getJiazhengList(opt).then(res => {
  460. data.list = data.list.concat(res.data.data);
  461. data.list = data.list.map(item => {
  462. const newItem = {
  463. ...item
  464. };
  465. // if(item.zyNames ==''){
  466. // newItem.zyNames = []
  467. // }else{
  468. // newItem.zyNames = item.zyNames.split(',');
  469. // }
  470. // 处理 zyNames 字段
  471. if (typeof newItem.zyNames !== 'string') {
  472. newItem.zyNames = [];
  473. } else {
  474. newItem.zyNames = newItem.zyNames.trim() == '' ? [] : newItem.zyNames.split(',');
  475. }
  476. return newItem;
  477. })
  478. console.log('data.list', data.list);
  479. data.loading = false;
  480. if (res.data.total > data.list.length) {
  481. data.state = 'more';
  482. data.loading = false;
  483. } else {
  484. data.state = 'no-more';
  485. data.loading = false;
  486. }
  487. }).catch(err => {
  488. data.state = 'more';
  489. data.loading = false;
  490. })
  491. }
  492. function getLeixing() {
  493. let req = {}
  494. getJiazhengZhiyeAll(req).then(res => {
  495. res.data.unshift({
  496. id: '',
  497. name: '全部职业'
  498. });
  499. allType = res.data
  500. // allType = dataConversionObject(res.data)
  501. console.log('allType', allType);
  502. })
  503. }
  504. function dataConversionObject(data) {
  505. let newList
  506. newList = data.map((name, index) => ({
  507. id: index,
  508. name: name
  509. }));
  510. return newList
  511. }
  512. function getCurrentWeizhi() {
  513. console.log('1231231');
  514. uni.getLocation({
  515. type: 'wgs84',
  516. success: function(res) {
  517. console.log('res', res)
  518. data.jingdu = res.longitude
  519. data.weidu = res.latitude
  520. data.weizhiFlag = true
  521. console.log('当前位置的经度:' + res.longitude);
  522. console.log('当前位置的纬度:' + res.latitude);
  523. }
  524. });
  525. }
  526. onLoad((options) => {
  527. if (options && options.isZijiazheng == 'true') {
  528. isZijiazhengFlag.value = 'true'
  529. userIdList.value = options.userIdList
  530. listIds.value = options.listIds
  531. startDate.value = options.startDate
  532. endDate.value = options.endDate
  533. from.value = options.from
  534. jzId.value = options.jzId
  535. console.log('userIdList.value', userIdList.value);
  536. }
  537. getMore()
  538. getLeixing()
  539. getCurrentWeizhi()
  540. })
  541. </script>