kehuList.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="admin-kehu-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 class="jiazheng-search-box">
  9. <view class="jiazheng-search-right">
  10. <view @click="updateTimeClick" :class="shaixuanStyleUpdate">
  11. <text>更新时间</text>
  12. <icon :class="updataJtClass" />
  13. </view>
  14. <view @click="luruTimeClick" :class="shaixuanStyleluru">
  15. <text>录入时间</text>
  16. <icon :class="luruJtClass" />
  17. </view>
  18. </view>
  19. </view>
  20. <view class="list-new-btn-box">
  21. <button type="default" class="phone-green-btn" @click="addKehu">新增客户</button>
  22. </view>
  23. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  24. :refresher-threshold="50" @scrolltolower="onScrolltolower" refresher-background="transparent"
  25. @refresherrefresh="onRefresh">
  26. <uni-list class="kh-scroll-view">
  27. <uni-list-item v-for="item in data.list" class="ht-list-item-box">
  28. <template v-slot:body>
  29. <view class="kh-card-box">
  30. <view class="card-head-row">
  31. <view class="del-btn-box" @click.stop="delBtn(item)"><icon class="del-btn"></icon></view>
  32. <button type="default" class="phone-green-btn ht-head-btn"
  33. @click.stop="htBtn(item)">合同</button>
  34. <button type="default" class="phone-green-btn ht-head-btn"
  35. @click.stop="telBtn(item)">打电话</button>
  36. <button type="default" class="phone-white-btn ht-head-btn"
  37. @click.stop="editorBtn(item)">编辑</button>
  38. </view>
  39. <view class="card-body-row">
  40. <view class="body-row"><icon class="user-icon"></icon>{{item.realName}}</view>
  41. <view class="body-row"><icon class="tel-icon"></icon>{{item.userName}}</view>
  42. <!-- v-if="item.idcard" -->
  43. <view class="body-row" ><icon class="idcard-icon"></icon>{{ item.idcard ? item.idcard : '----' }}</view>
  44. <view class="body-row" v-if="item.createTime"><icon class="data-icon"></icon>录入时间:{{item.createTime}}</view>
  45. <view class="body-row" v-if="item.updateTime"><icon class="data-icon"></icon>更新时间:{{item.updateTime}}</view>
  46. </view>
  47. </view>
  48. </template>
  49. </uni-list-item>
  50. <uni-load-more :status="data.state" @click="getMore(0)"
  51. :contentText="data.contentText"></uni-load-more>
  52. </uni-list>
  53. </scroll-view>
  54. <!-- 查询组件 -->
  55. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  56. @reset-search="dialogSearchReset"></search-dialog>
  57. <!-- 删除子账号 -->
  58. <common-dialog ref="commonDialogRef" :title="deleteTitle" :content="deleteConcent"
  59. @confirm-btn="deleteQuerenBtn"></common-dialog>
  60. <!-- 页面底端 -->
  61. <customTabbarClientVue></customTabbarClientVue>
  62. </view>
  63. </template>
  64. <script setup>
  65. import {ref,reactive} from "vue";
  66. import {onLoad} from "@dcloudio/uni-app";
  67. import * as khApi from "@/api/kehu.js"
  68. import searchDialog from "./components/search.vue";
  69. import commonDialog from '@/components/dialog/commonDialog.vue';
  70. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  71. const searchDialogRef = ref(null);
  72. // 排序
  73. let updataJtClass = ref('');
  74. let luruJtClass = ref('');
  75. let shaixuanStyleUpdate = ref('saixuan-item-box');
  76. let shaixuanStyleluru = ref('saixuan-item-box');
  77. let isFirstClickUpdate = ref('true')
  78. let isFirstClickluru = ref('true')
  79. const data = reactive({
  80. khTel: '',
  81. khRealName: '',
  82. list: [], // 列表
  83. loading: false,
  84. page: 0,
  85. size: 10,
  86. sortRule: '', //排序规则(1降序,2升序
  87. sortType: '', //排序类型(1更新时间,2录入时间)
  88. state: 'more',
  89. contentText: {
  90. contentdown: '查看更多',
  91. contentrefresh: '加载中',
  92. contentnomore: '没有更多'
  93. }
  94. })
  95. // 删除
  96. const commonDialogRef = ref(null)
  97. const deleteTitle = ref('删除')
  98. const deleteConcent = ref('你确定要执行这个操作吗')
  99. const deletKhId = ref(null)
  100. // 返回
  101. function goUpPage() {
  102. uni.redirectTo({
  103. url: `/pages/admin/ShouYe/shouye`
  104. })
  105. }
  106. /********** 查询 **********/
  107. function toggle() {
  108. searchDialogRef.value.handleShow();
  109. }
  110. function dialogSearchBtn(opt, searchInput) {
  111. if (opt == 2) {
  112. data.khRealName = searchInput
  113. data.khTel = '';
  114. } else {
  115. data.khRealName = '';
  116. data.khTel = searchInput
  117. }
  118. onRefresh()
  119. }
  120. function dialogSearchReset() {
  121. data.khTel = '';
  122. data.khRealName = '';
  123. }
  124. /********** 排序 **********/
  125. function updateTimeClick() {
  126. data.sortType = 1
  127. const isFirst = isFirstClickUpdate.value == 'true';
  128. const isSecond = isFirstClickUpdate.value == 'false';
  129. if (isFirst) {
  130. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  131. updataJtClass.value = 'saixuan-jt-default';
  132. isFirstClickUpdate.value = 'false';
  133. data.sortRule = 1
  134. } else if (isSecond) {
  135. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  136. updataJtClass.value = 'saixuan-jt-click';
  137. isFirstClickUpdate.value = 'empty';
  138. data.sortRule = 2
  139. } else {
  140. shaixuanStyleUpdate.value = 'saixuan-item-box';
  141. updataJtClass.value = '';
  142. isFirstClickUpdate.value = 'true';
  143. data.sortRule = 0
  144. }
  145. data.page = 0;
  146. refreshData()
  147. }
  148. function luruTimeClick() {
  149. data.sortType = 2
  150. const isFirst = isFirstClickluru.value == 'true';
  151. const isSecond = isFirstClickluru.value == 'false';
  152. if (isFirst) {
  153. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  154. luruJtClass.value = 'saixuan-jt-default';
  155. isFirstClickluru.value = 'false';
  156. data.sortRule = 1
  157. } else if (isSecond) {
  158. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  159. luruJtClass.value = 'saixuan-jt-click';
  160. isFirstClickluru.value = 'empty';
  161. data.sortRule = 2
  162. } else {
  163. shaixuanStyleluru.value = 'saixuan-item-box';
  164. luruJtClass.value = '';
  165. isFirstClickluru.value = 'true';
  166. data.sortRule = 0
  167. }
  168. data.page = 0;
  169. refreshData()
  170. }
  171. /********** 新增 **********/
  172. function addKehu(){
  173. uni.redirectTo({
  174. url: '/pages/admin/kehu/kehuInfo'
  175. })
  176. }
  177. /********** 查询 **********/
  178. function onScrolltolower() {
  179. getMore()
  180. }
  181. function onRefresh() {
  182. if (data.loading) return;
  183. data.page = 0;
  184. data.list = [];
  185. data.loading = true;
  186. refreshData();
  187. }
  188. function refreshData() {
  189. const opt = {
  190. sortType:data.sortType,
  191. sortRule:data.sortRule,
  192. userName: data.khTel,
  193. realName: data.khRealName,
  194. page: data.page,
  195. size: data.size,
  196. status: data.status
  197. }
  198. data.list = [];
  199. // 数学
  200. data.state = 'loading';
  201. data.page++;
  202. opt.page = data.page;
  203. khApi.getKehuList(opt).then(res => {
  204. data.list = data.list.concat(res.data.data);
  205. data.loading = false;
  206. if (res.data.total > data.list.length) {
  207. data.state = 'more';
  208. } else {
  209. data.state = 'no-more';
  210. }
  211. }).catch(err => {
  212. data.state = 'more';
  213. }).finally(() => {
  214. data.loading = false;
  215. })
  216. }
  217. function getMore() {
  218. const opt = {
  219. sortType:data.sortType,
  220. sortRule:data.sortRule,
  221. userName: data.khTel,
  222. realName: data.khRealName,
  223. page: data.page,
  224. size: data.size,
  225. status: data.status
  226. }
  227. if (data.state == 'no-more') return;
  228. data.state = 'loading';
  229. data.page++;
  230. opt.page = data.page;
  231. khApi.getKehuList(opt).then(res => {
  232. data.list = data.list.concat(res.data.data);
  233. data.loading = false;
  234. if (res.data.total > data.list.length) {
  235. data.state = 'more';
  236. } else {
  237. data.state = 'no-more';
  238. }
  239. }).catch(err => {
  240. data.state = 'more';
  241. }).finally(() => {
  242. data.loading = false;
  243. })
  244. }
  245. // 删除
  246. function delBtn(item) {
  247. deletKhId.value = item.id;
  248. commonDialogRef.value.handleShow();
  249. }
  250. function deleteQuerenBtn() {
  251. khApi.getKehuDelete({
  252. ids: [deletKhId.value]
  253. }).then(res => {
  254. if (res.code == 0) {
  255. uni.showToast({
  256. title: '成功'
  257. })
  258. data.page = 0;
  259. refreshData();
  260. } else {
  261. uni.showToast({
  262. title: '失败'
  263. })
  264. }
  265. })
  266. }
  267. // 合同
  268. function htBtn(data){
  269. uni.navigateTo({
  270. url: `/pages/admin/Hetong/sanfangHetong?khName=${data.realName}&from=kehu`
  271. })
  272. }
  273. // 打电话
  274. function telBtn(data) {
  275. console.log('打电话data', data);
  276. if (data.userName) {
  277. uni.makePhoneCall({
  278. phoneNumber: data.userName
  279. });
  280. } else {
  281. uni.showToast({
  282. title: `无电话号`,
  283. icon: 'none',
  284. duration: 2000
  285. })
  286. return false
  287. }
  288. }
  289. // 编辑
  290. function editorBtn(data){
  291. uni.redirectTo({
  292. url: `/pages/admin/kehu/kehuInfo?id=${data.id}&userId=${data.userId}`
  293. })
  294. }
  295. onLoad((options) => {
  296. getMore()
  297. })
  298. </script>
  299. <style>
  300. </style>