index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. <view class="nav-bar-icon-box">
  7. <uni-icons class="nav-bar-right-icon" type="plusempty" size="18" color="#666" @click="addJiazhengRenyuan"></uni-icons>
  8. <uni-icons class="nav-bar-right-icon" type="search" size="18" color="#666"
  9. @click="toggle('top')"></uni-icons>
  10. </view>
  11. </view>
  12. <view class="jiazheng-search-box">
  13. <view @click.stop="clickAlltype" class="select-item-box">
  14. <text>{{data.leixing}}</text>
  15. <icon :class="allJtClass" />
  16. </view>
  17. <view class="jiazheng-search-right">
  18. <!-- 当前点击 增加 saixuan-active-->
  19. <view @click="updateTimeClick" :class="shaixuanStyleUpdate">
  20. <text>更新时间</text>
  21. <icon :class="updataJtClass" />
  22. </view>
  23. <view @click="luruTimeClick" :class="shaixuanStyleluru">
  24. <!-- class切换 saixuan-jt-default saixuan-jt-click-->
  25. <text>录入时间</text>
  26. <icon :class="luruJtClass" />
  27. </view>
  28. </view>
  29. </view>
  30. <view class="all-type-box" v-show="isOpen" @click="clickAlltype">
  31. <dataChecked :list="allType" mode="single" :defaultCount="99" :showAdd="false"
  32. @change="selectChangeSkill" />
  33. </view>
  34. <view>
  35. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  36. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  37. class="jz-scroll-view">
  38. <uni-list class="admin-list-box">
  39. <uni-list-item v-for="item in data.list" class="jz-list-item-box">
  40. <template v-slot:body>
  41. <view class="card-head-row">
  42. <view class="head-name">{{item.realName}}</view>
  43. <button type="default" class="phone-green-btn bz-tel-btn" @click.stop="telephone(item)">打电话</button>
  44. </view>
  45. <view @click="lookUserInfo(item)" class="card-body-row">
  46. <view class="card-img-box">
  47. <img :src="item.icon" v-if="item.icon">
  48. <icon class="phone-default-userImg" v-else></icon>
  49. </view>
  50. <view class="body-content-row">
  51. <view class="content-text-row">
  52. <view> {{item.age}}岁<text v-if="item.jingyan"> | {{item.jingyan}}年经验</text></view>
  53. <view class="text-status">{{item.zhuangtai}}</view>
  54. </view>
  55. <view class="content-text-row">{{item.jiguan}}</view>
  56. </view>
  57. </view>
  58. </template>
  59. </uni-list-item>
  60. <uni-load-more :status="data.state" @click="getMore(0)"
  61. :contentText="data.contentText"></uni-load-more>
  62. </uni-list>
  63. </scroll-view>
  64. </view>
  65. <view>
  66. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  67. @reset-search="dialogSearchReset"></search-dialog>
  68. </view>
  69. <customTabbarAdminVue :current-tab="1"></customTabbarAdminVue>
  70. </view>
  71. </template>
  72. <script setup>
  73. import {
  74. ref,
  75. reactive
  76. } from "vue";
  77. import {
  78. onLoad
  79. } from "@dcloudio/uni-app";
  80. import {
  81. getJiazhengList,
  82. getJiazhengLeixing
  83. } from "@/api/jiazheng.js"
  84. import dataChecked from './common/dataChecked.vue';
  85. import searchDialog from "./common/search.vue";
  86. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  87. const searchDialogRef = ref(null);
  88. let allType = ref([])
  89. let data = reactive({
  90. leixing: '全部类型',
  91. page: 0,
  92. size: 10,
  93. realName: '',
  94. sortRule: '', //排序规则(1降序,2升序
  95. sortRule: '', //排序类型(1更新时间,2录入时间)
  96. userName: '',
  97. list: [], // 考试列表
  98. loading: false,
  99. state: 'more',
  100. contentText: {
  101. contentdown: '查看更多',
  102. contentrefresh: '加载中',
  103. contentnomore: '没有更多'
  104. }
  105. })
  106. let isOpen = ref(false)
  107. let defauleImg = ref('@/static/images/my/user-default-img.png')
  108. const allJtClass = 'select-jt-default';
  109. let updataJtClass = ref('');
  110. let luruJtClass = ref('');
  111. let shaixuanStyleUpdate = ref('saixuan-item-box');
  112. let shaixuanStyleluru = ref('saixuan-item-box');
  113. const isOpenSelect = ref(false);
  114. const selectedOption = ref('');
  115. let isFirstClickUpdate = ref('true')
  116. let isFirstClickluru = ref('true')
  117. function updateTimeClick() {
  118. data.sortType = 1
  119. const isFirst = isFirstClickUpdate.value == 'true';
  120. const isSecond = isFirstClickUpdate.value == 'false';
  121. if (isFirst) {
  122. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  123. updataJtClass.value = 'saixuan-jt-default';
  124. isFirstClickUpdate.value = 'false';
  125. data.sortRule = 1
  126. } else if (isSecond) {
  127. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  128. updataJtClass.value = 'saixuan-jt-click';
  129. isFirstClickUpdate.value = 'empty';
  130. data.sortRule = 2
  131. } else {
  132. shaixuanStyleUpdate.value = 'saixuan-item-box';
  133. updataJtClass.value = '';
  134. isFirstClickUpdate.value = 'true';
  135. data.sortRule = 0
  136. }
  137. data.page = 0;
  138. refreshData()
  139. }
  140. function luruTimeClick() {
  141. data.sortType = 2
  142. const isFirst = isFirstClickluru.value == 'true';
  143. const isSecond = isFirstClickluru.value == 'false';
  144. if (isFirst) {
  145. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  146. luruJtClass.value = 'saixuan-jt-default';
  147. isFirstClickluru.value = 'false';
  148. data.sortRule = 1
  149. } else if (isSecond) {
  150. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  151. luruJtClass.value = 'saixuan-jt-click';
  152. isFirstClickluru.value = 'empty';
  153. data.sortRule = 2
  154. } else {
  155. shaixuanStyleluru.value = 'saixuan-item-box';
  156. luruJtClass.value = '';
  157. isFirstClickluru.value = 'true';
  158. data.sortRule = 0
  159. }
  160. data.page = 0;
  161. refreshData()
  162. }
  163. function dialogSearchBtn(name, searchData) {
  164. switch (name) {
  165. case '姓名':
  166. dialogSearchReset();
  167. data.realName = searchData.value;
  168. break;
  169. case '手机号':
  170. data.userName = searchData.value;
  171. break;
  172. }
  173. data.page = 0;
  174. refreshData();
  175. }
  176. function dialogSearchReset() {
  177. data.userName = '';
  178. data.realName = '';
  179. }
  180. const clickAlltype = (data) => {
  181. isOpen.value = !isOpen.value;
  182. }
  183. const toggle = (data, index) => {
  184. searchDialogRef.value.handleShow();
  185. }
  186. const addJiazhengRenyuan = () => {
  187. let pageInfo = {
  188. status: 'add'
  189. }
  190. uni.redirectTo({
  191. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  192. })
  193. }
  194. const lookUserInfo = (data) => {
  195. let pageInfo = {
  196. status: 'edit',
  197. id: data.id,
  198. userId: data.userId
  199. }
  200. uni.redirectTo({
  201. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  202. })
  203. }
  204. function goUpPage() {
  205. uni.redirectTo({
  206. url: `/pages/admin/ShouYe/shouye`
  207. })
  208. }
  209. function onRefresh() {
  210. data.page = 0;
  211. data.list = [];
  212. data.loading = true;
  213. refreshData();
  214. }
  215. function telephone(data) {
  216. console.log('data', data);
  217. uni.makePhoneCall({
  218. phoneNumber: '114' //仅为示例
  219. });
  220. }
  221. function selectChangeSkill(item) {
  222. data.leixing = item[0].name
  223. console.log('selectChangeSkill', item);
  224. data.page = 0;
  225. refreshData()
  226. }
  227. function refreshData() {
  228. const opt = {
  229. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  230. "page": 1,
  231. "realName": data.realName,
  232. "size": 10,
  233. "sortRule": data.sortRule,
  234. "sortType": data.sortType,
  235. "userName": data.userName
  236. }
  237. data.list = [];
  238. // 数学
  239. data.state = 'loading';
  240. data.page++;
  241. opt.page = data.page;
  242. getJiazhengList(opt).then(res => {
  243. data.list = data.list.concat(res.data.data);
  244. data.loading = false;
  245. if (res.data.total > data.list.length) {
  246. data.state = 'more';
  247. data.loading = false;
  248. } else {
  249. data.state = 'no-more';
  250. data.loading = false;
  251. }
  252. }).catch(err => {
  253. data.state = 'more';
  254. data.loading = false;
  255. })
  256. }
  257. function getMore() {
  258. const opt = {
  259. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  260. "page": 1,
  261. "realName": data.realName,
  262. "size": 10,
  263. "sortRule": data.sortRule,
  264. "sortType": data.sortType,
  265. "userName": data.userName
  266. }
  267. if (data.state == 'no-more') return;
  268. data.state = 'loading';
  269. data.page++;
  270. opt.page = data.page;
  271. getJiazhengList(opt).then(res => {
  272. data.list = data.list.concat(res.data.data);
  273. data.loading = false;
  274. if (res.data.total > data.list.length) {
  275. data.state = 'more';
  276. data.loading = false;
  277. } else {
  278. data.state = 'no-more';
  279. data.loading = false;
  280. }
  281. }).catch(err => {
  282. data.state = 'more';
  283. data.loading = false;
  284. })
  285. }
  286. function getLeixing() {
  287. let req = {}
  288. getJiazhengLeixing(req).then(res => {
  289. allType = dataConversionObject(res.data)
  290. console.log('allType', allType.value);
  291. })
  292. }
  293. function dataConversionObject(data) {
  294. let newList
  295. newList = data.map((name, index) => ({
  296. id: index,
  297. name: name
  298. }));
  299. return newList
  300. }
  301. onLoad(() => {
  302. getMore()
  303. getLeixing()
  304. })
  305. </script>