rentBill.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <van-nav-bar title="租户账单" safe-area-inset-top>
  3. <template #left>
  4. <van-icon
  5. :name="require('@/assets/arrow-left.svg')"
  6. size="24"
  7. @click="backPath"
  8. />
  9. </template>
  10. </van-nav-bar>
  11. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  12. <div class="page_info">
  13. <van-row align="center" class="position_pannel">
  14. <van-col>
  15. <van-image
  16. :src="require('@/assets/position.svg')"
  17. width="16"
  18. height="16"
  19. fit="contain"
  20. />
  21. <van-col>{{ name }}</van-col>
  22. <van-image
  23. :src="require('@/assets/arrow-right.svg')"
  24. width="24"
  25. height="24"
  26. fit="contain"
  27. />
  28. </van-col>
  29. <van-col
  30. @click="
  31. $route.push({ path: '/userInfo', query: { type: 'account' } })
  32. "
  33. >
  34. <van-image
  35. :src="require('@/assets/user.svg')"
  36. width="16"
  37. height="16"
  38. fit="contain"
  39. />
  40. </van-col>
  41. </van-row>
  42. <div class="drop_down">
  43. <van-dropdown-menu active-color="#1989fa">
  44. <van-dropdown-item
  45. v-model="dataForm.cycle"
  46. @change="handelChange('cycle', cycle)"
  47. :title="cycleTitle"
  48. :options="cycleList"
  49. />
  50. <van-dropdown-item
  51. v-model="dataForm.status"
  52. @change="handelChange('status', dataForm.status)"
  53. :title="statusTitle"
  54. :options="statusList"
  55. />
  56. </van-dropdown-menu>
  57. </div>
  58. <van-row align="center" class="list_total">
  59. <van-col>共有</van-col>
  60. <v-count-up
  61. :end-val="dataList.length"
  62. class="count_up"
  63. options="{ separator: ',' }"
  64. />
  65. <van-col>条记录</van-col>
  66. </van-row>
  67. <div class="info_list">
  68. <van-list
  69. v-model:loading="loading"
  70. :finished="finished"
  71. :error="error"
  72. error-text="请求失败,点击重新加载"
  73. finished-text="没有更多了"
  74. @load="onLoad"
  75. >
  76. <div
  77. v-for="item in dataList"
  78. :key="item.id"
  79. class="list_item"
  80. @click="toPath('/rentBillDetail', item)"
  81. >
  82. <van-row
  83. align="center"
  84. class="reduce_type"
  85. :style="{
  86. 'background-color': `${
  87. rentStatus_filter(item.status)['color']
  88. }`,
  89. }"
  90. >
  91. <van-col>{{
  92. `${rentStatus_filter(item.status)["label"]}`
  93. }}</van-col>
  94. </van-row>
  95. <van-row class="header">
  96. <van-col>{{ item.name }}</van-col>
  97. </van-row>
  98. <van-row>
  99. <van-col>本期金额:</van-col>
  100. <van-col style="color: #fa5555"
  101. >¥{{
  102. (parseInt(item.feeTotal * 100) / 100).toFixed(2)
  103. }}</van-col
  104. >
  105. </van-row>
  106. <van-row>
  107. <van-col>欠费天数:</van-col>
  108. <van-col>{{}}</van-col>
  109. </van-row>
  110. <van-row>
  111. <van-col>账户余额:¥</van-col>
  112. <van-col>{{
  113. (parseInt(item.balance * 100) / 100).toFixed(2)
  114. }}</van-col>
  115. </van-row>
  116. <van-row>
  117. <van-col>联系电话:</van-col>
  118. <van-col>{{ item.tel }}</van-col>
  119. </van-row>
  120. <div class="list_btn" v-if="item.status == 0">
  121. <van-button
  122. plain
  123. type="primary"
  124. size="small"
  125. @click="handleClick([parseInt(item.id)])"
  126. >催费</van-button
  127. >
  128. </div>
  129. </div>
  130. </van-list>
  131. </div>
  132. </div>
  133. </van-pull-refresh>
  134. </template>
  135. <script>
  136. import Api from "../utils/api";
  137. import { isEmpty } from "@/utils/index.js";
  138. import VCountUp from "./CountUp";
  139. export default {
  140. components: {
  141. "v-count-up": VCountUp,
  142. },
  143. data() {
  144. return {
  145. name: "电商园四期-B座",
  146. cycleTitle: "计费周期",
  147. statusTitle: "是否结清",
  148. statusList: [
  149. { text: "未结清", value: 0 },
  150. { text: "已结清", value: 1 },
  151. ],
  152. cycleList: [],
  153. dataForm: {
  154. cycle: "2022-08",
  155. status: "",
  156. page: 1,
  157. limit: 10,
  158. },
  159. dataList: [],
  160. loading: false,
  161. refreshing: false,
  162. finished: false,
  163. };
  164. },
  165. methods: {
  166. rentStatus_filter(val) {
  167. if (isEmpty(val)) {
  168. return {};
  169. }
  170. if (val == 0) {
  171. return { label: "未结清", color: "#FA5555" };
  172. }
  173. if (val == 1) {
  174. return { label: "已结清", color: "#09C700" };
  175. }
  176. },
  177. onLoad() {
  178. setTimeout(async () => {
  179. if (this.refreshing) {
  180. this.dataList = [];
  181. this.refreshing = false;
  182. }
  183. await this.getDataList();
  184. this.dataForm.page++; // 分页数加一
  185. }, 100);
  186. },
  187. onRefresh() {
  188. // 清空列表数据
  189. this.finished = false;
  190. // 重新加载数据
  191. // 将 loading 设置为 true,表示处于加载状态
  192. this.loading = true;
  193. this.dataForm.page = 1; // 分页数赋值为1
  194. this.onLoad();
  195. },
  196. // 获取列表数据方法
  197. getDataList() {
  198. Api.rentBillList(this.dataForm).then((res) => {
  199. if (res.code == 0) {
  200. if (res.data) {
  201. if (res.data.list.length == 0) {
  202. // 判断获取数据条数若等于0
  203. this.dataList = []; // 清空数组
  204. this.finished = true; // 停止加载
  205. }
  206. // 若数据条数不等于0
  207. this.dataList.push(...res.data.list); // 将数据放入list中
  208. this.loading = false; // 加载状态结束
  209. // 如果list长度大于等于总数据条数,数据全部加载完成
  210. if (this.dataList.length >= res.data.total) {
  211. this.finished = true; // 结束加载状态
  212. }
  213. } else {
  214. // 判断获取数据条数若等于0
  215. this.dataList = []; // 清空数组
  216. this.finished = true; // 停止加载
  217. }
  218. } else {
  219. this.loading = false; // 加载状态结束
  220. this.finished = true; // 停止加载
  221. }
  222. });
  223. },
  224. handleClick(ids) {
  225. Api.lackFeeInfoPay(ids).then((res) => {
  226. if (res.code == 0) {
  227. this.$toast.success("催费成功");
  228. this.onRefresh();
  229. } else {
  230. this.$toast.fail("催费失败");
  231. }
  232. });
  233. },
  234. // change事件可以拿到的是value
  235. handelChange(type, val) {
  236. if (type == "cycle") {
  237. // 这里打印出来的值就是我们想要的text
  238. this.cycleTitle = this.cycleList.filter(
  239. (item) => item.value === val
  240. )[0].text;
  241. }
  242. if (type == "status") {
  243. // 这里打印出来的值就是我们想要的text
  244. this.statusTitle = this.statusList.filter(
  245. (item) => item.value === val
  246. )[0].text;
  247. }
  248. this.getDataList();
  249. },
  250. toPath(path, val) {
  251. this.$router.push({
  252. path: path,
  253. query: {
  254. tenantId: val.id,
  255. tenantName: val.name,
  256. costCycle: this.dataForm.cycle,
  257. },
  258. });
  259. },
  260. backPath() {
  261. this.$router.back();
  262. },
  263. },
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. .page_info {
  268. height: 100%;
  269. .position_pannel {
  270. display: flex;
  271. align-items: center;
  272. justify-content: space-between;
  273. padding: 10px 16px;
  274. background: #5c8fff;
  275. box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.04);
  276. .van-col {
  277. height: 24px;
  278. font-size: 16px;
  279. color: #ffffff;
  280. line-height: 24px;
  281. text-indent: 4px;
  282. text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.04);
  283. display: flex;
  284. align-items: center;
  285. letter-spacing: 2px;
  286. }
  287. }
  288. .drop_down {
  289. /deep/ {
  290. --van-gray-4: #999999;
  291. --van-dropdown-menu-title-text-color: #0c1935;
  292. }
  293. }
  294. .list_total {
  295. padding: 0 16px;
  296. margin: 8px 0;
  297. display: flex;
  298. text-align: left;
  299. .van-col {
  300. height: 16px;
  301. font-size: 12px;
  302. font-weight: 400;
  303. color: #999999;
  304. line-height: 16px;
  305. }
  306. .count_up {
  307. font-size: 16px;
  308. font-weight: 500;
  309. color: #fa5555;
  310. margin: 0 2px;
  311. }
  312. }
  313. .info_list {
  314. padding: 0 16px;
  315. .list_item {
  316. background: #ffffff;
  317. box-shadow: 0px 0px 10px 0px rgba(153, 153, 153, 0.15);
  318. border-radius: 4px;
  319. margin-bottom: 12px;
  320. padding: 12px 16px;
  321. display: flex;
  322. flex-direction: column;
  323. align-items: flex-start;
  324. position: relative;
  325. &:nth-last-child(1) {
  326. margin-bottom: 0;
  327. }
  328. .van-col {
  329. height: 18px;
  330. font-size: 14px;
  331. color: #999999;
  332. line-height: 18px;
  333. margin-bottom: 4px;
  334. &:nth-last-child(1) {
  335. margin-bottom: 0;
  336. }
  337. }
  338. .header {
  339. .van-col {
  340. height: 22px;
  341. font-size: 16px;
  342. color: #0c1935;
  343. line-height: 22px;
  344. margin-bottom: 8px;
  345. }
  346. }
  347. .reduce_type {
  348. position: absolute;
  349. top: 0;
  350. right: 0;
  351. height: 24px;
  352. padding: 0 12px;
  353. border-radius: 0px 4px 0px 10px;
  354. .van-col {
  355. font-size: 12px;
  356. font-weight: 400;
  357. color: #ffffff;
  358. line-height: 16px;
  359. }
  360. }
  361. .list_btn {
  362. position: absolute;
  363. bottom: 15px;
  364. right: 12px;
  365. .van-button {
  366. &:nth-child(2) {
  367. margin: 0 12px;
  368. }
  369. }
  370. }
  371. }
  372. }
  373. }
  374. </style>