kehuList.vue 8.0 KB

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