index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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. dialogSearchReset();
  307. data.userName = searchData.value;
  308. break;
  309. }
  310. data.page = 0;
  311. refreshData();
  312. }
  313. function dialogSearchReset() {
  314. data.userName = '';
  315. data.realName = '';
  316. }
  317. const clickAlltype = (data) => {
  318. isOpen.value = !isOpen.value;
  319. }
  320. const toggle = (data, index) => {
  321. searchDialogRef.value.handleShow();
  322. }
  323. const addJiazhengRenyuan = () => {
  324. let pageInfo = {
  325. status: 'add'
  326. }
  327. uni.redirectTo({
  328. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  329. })
  330. }
  331. const lookUserInfo = (data) => {
  332. let pageInfo = {
  333. status: 'edit',
  334. id: data.id,
  335. userId: data.userId,
  336. isZijiazheng: isZijiazhengFlag.value,
  337. from: from.value,
  338. endDate: endDate.value,
  339. startDate: startDate.value,
  340. jzId: jzId.value,
  341. userIdList: userIdList.value ? userIdList.value : "",
  342. listIds: listIds.value ? listIds.value : "",
  343. }
  344. uni.redirectTo({
  345. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  346. })
  347. }
  348. function goUpPage() {
  349. if (from.value == 'zijiazhenggongsi') {
  350. const originalParams =
  351. `isZijiazheng=true&userIdList=${userIdList.value}&startDate=${startDate.value}&endDate=${endDate.value}&jzId=${jzId.value}&from=zijiazhenggongsi`
  352. uni.redirectTo({
  353. url: `/pages/admin/zijiazheng/index?${originalParams}`
  354. })
  355. } else if (from.value == 'banzhengshuliang') {
  356. const originalParams =
  357. `isZijiazheng=true&userIdList=${userIdList.value}&startDate=${startDate.value}&endDate=${endDate.value}&jzId=${jzId.value}&listIds=${listIds.value}&from=zijiazhenggongsi`
  358. uni.redirectTo({
  359. url: `/pages/admin/zijiazheng/banzhengshuliang?${originalParams}`
  360. })
  361. } else if (from.value == 'yibanzhengshuliang') {
  362. const originalParams =
  363. `isZijiazheng=true&userIdList=${userIdList.value}&startDate=${startDate.value}&endDate=${endDate.value}&jzId=${jzId.value}&listIds=${listIds.value}&from=zijiazhenggongsi`
  364. uni.redirectTo({
  365. url: `/pages/admin/zijiazheng/yibanzhengshuliang?${originalParams}`
  366. })
  367. } else {
  368. uni.redirectTo({
  369. url: `/pages/admin/ShouYe/shouye`
  370. })
  371. }
  372. }
  373. function onRefresh() {
  374. data.page = 0;
  375. data.list = [];
  376. data.loading = true;
  377. refreshData();
  378. }
  379. function telephone(data) {
  380. console.log('data', data);
  381. if (data.userName) {
  382. uni.makePhoneCall({
  383. phoneNumber: data.userName
  384. });
  385. } else {
  386. uni.showToast({
  387. title: `无电话号`,
  388. icon: 'none',
  389. duration: 2000
  390. })
  391. return false
  392. }
  393. }
  394. function kechengBind(data) {
  395. uni.redirectTo({
  396. url: `/pages/admin/Jiazheng/kechengBind?id=` + data.id
  397. })
  398. }
  399. function selectChangeSkill(item) {
  400. if (item.length > 0) {
  401. data.zyId = item[0].id
  402. data.zyName = item[0].name
  403. console.log('selectChangeSkill', item);
  404. data.page = 0;
  405. refreshData()
  406. }
  407. }
  408. const convertToArray = (str) => str.split(',').map(item => item.trim());
  409. function refreshData() {
  410. const opt = {
  411. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  412. "page": 1,
  413. "realName": data.realName,
  414. "size": 10,
  415. "sortRule": data.sortRule,
  416. "sortType": data.sortType,
  417. "userName": data.userName,
  418. "jingdu": data.jingdu,
  419. "weidu": data.weidu,
  420. "jzId": jzId.value,
  421. "userIdList": userIdList.value ? convertToArray(userIdList.value) : []
  422. }
  423. data.list = [];
  424. // 数学
  425. data.state = 'loading';
  426. data.page++;
  427. opt.page = data.page;
  428. getJiazhengList(opt).then(res => {
  429. data.list = data.list.concat(res.data.data);
  430. data.list = data.list.map(item => {
  431. const newItem = {
  432. ...item
  433. };
  434. if (item.zyNames == '') {
  435. newItem.zyNames = []
  436. } else {
  437. newItem.zyNames = item.zyNames.split(',');
  438. }
  439. return newItem;
  440. })
  441. data.loading = false;
  442. if (res.data.total > data.list.length) {
  443. data.state = 'more';
  444. data.loading = false;
  445. } else {
  446. data.state = 'no-more';
  447. data.loading = false;
  448. }
  449. }).catch(err => {
  450. data.state = 'more';
  451. data.loading = false;
  452. })
  453. }
  454. function getMore() {
  455. const opt = {
  456. "zyId": data.zyId == '全部职业' ? '' : data.zyId,
  457. "page": 1,
  458. "realName": data.realName,
  459. "size": 10,
  460. "sortRule": data.sortRule,
  461. "sortType": data.sortType,
  462. "userName": data.userName,
  463. "jingdu": data.jingdu,
  464. "weidu": data.weidu,
  465. "jzId": jzId.value,
  466. "userIdList": userIdList.value ? convertToArray(userIdList.value) : []
  467. }
  468. if (data.state == 'no-more') return;
  469. data.state = 'loading';
  470. data.page++;
  471. opt.page = data.page;
  472. getJiazhengList(opt).then(res => {
  473. data.list = data.list.concat(res.data.data);
  474. data.list = data.list.map(item => {
  475. const newItem = {
  476. ...item
  477. };
  478. // if(item.zyNames ==''){
  479. // newItem.zyNames = []
  480. // }else{
  481. // newItem.zyNames = item.zyNames.split(',');
  482. // }
  483. // 处理 zyNames 字段
  484. if (typeof newItem.zyNames !== 'string') {
  485. newItem.zyNames = [];
  486. } else {
  487. newItem.zyNames = newItem.zyNames.trim() == '' ? [] : newItem.zyNames.split(',');
  488. }
  489. return newItem;
  490. })
  491. console.log('data.list', data.list);
  492. data.loading = false;
  493. if (res.data.total > data.list.length) {
  494. data.state = 'more';
  495. data.loading = false;
  496. } else {
  497. data.state = 'no-more';
  498. data.loading = false;
  499. }
  500. }).catch(err => {
  501. data.state = 'more';
  502. data.loading = false;
  503. })
  504. }
  505. function getLeixing() {
  506. let req = {}
  507. getJiazhengZhiyeAll(req).then(res => {
  508. res.data.unshift({
  509. id: '',
  510. name: '全部职业'
  511. });
  512. allType = res.data
  513. // allType = dataConversionObject(res.data)
  514. console.log('allType', allType);
  515. })
  516. }
  517. function dataConversionObject(data) {
  518. let newList
  519. newList = data.map((name, index) => ({
  520. id: index,
  521. name: name
  522. }));
  523. return newList
  524. }
  525. function getCurrentWeizhi() {
  526. console.log('1231231');
  527. uni.getLocation({
  528. type: 'wgs84',
  529. success: function(res) {
  530. console.log('res', res)
  531. data.jingdu = res.longitude
  532. data.weidu = res.latitude
  533. data.weizhiFlag = true
  534. console.log('当前位置的经度:' + res.longitude);
  535. console.log('当前位置的纬度:' + res.latitude);
  536. }
  537. });
  538. }
  539. onLoad((options) => {
  540. if (options && options.isZijiazheng == 'true') {
  541. isZijiazhengFlag.value = 'true'
  542. userIdList.value = options.userIdList
  543. listIds.value = options.listIds
  544. startDate.value = options.startDate
  545. endDate.value = options.endDate
  546. from.value = options.from
  547. jzId.value = options.jzId
  548. console.log('userIdList.value', userIdList.value);
  549. }
  550. getMore()
  551. getLeixing()
  552. getCurrentWeizhi()
  553. })
  554. </script>