index.vue 8.1 KB

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