kehuList.vue 8.3 KB

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