index.vue 17 KB

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