index.vue 16 KB

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