Tenantbill.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="billall">
  3. <u-cell-group>
  4. <u-cell :title="mytitle" value="修改" :isLink="true" @click="floorchange">
  5. <u-icon slot="icon" size="40" name="map"></u-icon>
  6. </u-cell>
  7. </u-cell-group>
  8. <view class="topbill">
  9. <view class="topbilledit">
  10. <view class="changetime1">
  11. <picker mode="date" :value="myday" fields="month" @change="dateChange">
  12. <view class="selestDate">{{myday}}</view>
  13. </picker>
  14. </view>
  15. <view class="changetime2">
  16. <u-icon name="arrow-down-fill" color="#666666" size="20"></u-icon>
  17. </view>
  18. </view>
  19. <view class="topbilledit" @click="typechange">
  20. <view class="changetime1">
  21. {{mytype}}
  22. </view>
  23. <view class="changetime2">
  24. <u-icon name="arrow-down-fill" color="#666666" size="20"></u-icon>
  25. </view>
  26. </view>
  27. </view>
  28. <u-picker :show="showtype" :columns="columnstype" keyName="label" @confirm="confirmtype" @cancel='canceltype'>
  29. </u-picker>
  30. <!--
  31. <mx-date-picker :show="showPicker" type="range" :value="dayrange" :show-tips="true" :begin-text="'开始日期'" :end-text="'结束日期'" :show-seconds="true" @confirm="ed" @cancel="ec" /> -->
  32. <u-picker :show="showfloor" ref="uPicker" :loading="loading" @confirm="confirmfloor" @cancel='cancelfloor'
  33. :columns="columns" keyName="orgName" @change="changeHandler"></u-picker>
  34. <u-notify ref="uNotify" :show="showdct" message="服务器请求失败"></u-notify>
  35. </view>
  36. </template>
  37. <script>
  38. // import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue";
  39. export default {
  40. components: {
  41. // MxDatePicker
  42. },
  43. data() {
  44. const currentDate = this.getDate({
  45. format: 'yyyy-mm'
  46. })
  47. return {
  48. showtype: false,
  49. showdct: false,
  50. mytitle: '',
  51. alldata: [],
  52. showfloor: false,
  53. loading: false,
  54. columns: [],
  55. columnData: [],
  56. myday: '',
  57. mytype: '全部',
  58. showPicker: false,
  59. myday: currentDate,
  60. columnstype: [
  61. [{
  62. label: '全部',
  63. id: ''
  64. }, {
  65. label: '未结清',
  66. id: 0
  67. },
  68. {
  69. label: '已结清',
  70. id: 1
  71. }
  72. ]
  73. ],
  74. // dayrange: ['2019/01/01','2019/01/06'],
  75. }
  76. },
  77. //监听页面加载,其参数为上个页面传递的数据,参数类型为 Object(用于页面传参
  78. onLoad() {
  79. this.getfloor();
  80. },
  81. //监听页面初次渲染完成。注意如果渲染速度快,会在页面进入动画完成前触发
  82. onReady() {
  83. // 微信小程序需要用此写法
  84. },
  85. //监听页面隐藏
  86. onHide() {},
  87. //监听窗口尺寸变化
  88. onResize() {},
  89. //监听页面卸载
  90. onUnload() {},
  91. //监听用户下拉动作,一般用于下拉刷新
  92. onPullDownRefresh() {},
  93. methods: {
  94. canceltype() {
  95. this.showtype = false;
  96. },
  97. confirmtype(e) {
  98. // console.log('111111111111111111',e.value[0])
  99. this.showtype = false;
  100. this.mytype=e.value[0].label
  101. },
  102. typechange() {
  103. this.showtype = true;
  104. },
  105. dateChange(e) {
  106. this.myday = e.target.value;
  107. },
  108. getDate(type) {
  109. const date = new Date();
  110. let year = date.getFullYear();
  111. let month = date.getMonth() + 1;
  112. if (type === 'start') {
  113. year = year - 60;
  114. } else if (type === 'end') {
  115. year = year + 2;
  116. }
  117. month = month > 9 ? month : '0' + month;
  118. // day = day > 9 ? day : '0' + day;
  119. return `${year}-${month}`;
  120. },
  121. getfloor() {
  122. this.$api.get('/control/getOrgStructureTree/', {})
  123. .then(res => {
  124. if (res.data.code == 0) {
  125. this.mytitle = res.data.data[0].orgName;
  126. this.alldata = res.data.data[0].childrenList;
  127. //console.log('111111111111111111', res.data.data[0].childrenList)
  128. this.columns = [
  129. res.data.data[0].childrenList,
  130. res.data.data[0].childrenList[0].childrenList
  131. ]
  132. let allfloor = [];
  133. for (let i = 0; i < res.data.data[0].childrenList.length; i++) {
  134. allfloor.push(res.data.data[0].childrenList[i].childrenList)
  135. }
  136. // console.log('111111111111111111',allfloor)
  137. this.columnData = allfloor
  138. } else {
  139. this.showdct = true
  140. }
  141. })
  142. },
  143. floorchange() {
  144. this.showfloor = true;
  145. },
  146. changeHandler(e) {
  147. const {
  148. columnIndex,
  149. index,
  150. // 微信小程序无法将picker实例传出来,只能通过ref操作
  151. picker = this.$refs.uPicker
  152. } = e
  153. if (columnIndex === 0) {
  154. this.loading = true
  155. picker.setColumnValues(1, this.columnData[index])
  156. this.loading = false
  157. }
  158. },
  159. confirmfloor(e) {
  160. console.log('222222', e.value)
  161. this.mytitle = e.value[0].orgName + e.value[1].orgName;
  162. this.showfloor = false;
  163. },
  164. cancelfloor() {
  165. this.showfloor = false;
  166. },
  167. }
  168. }
  169. </script>
  170. <style>
  171. .billall {}
  172. .topbill {
  173. display: flex;
  174. justify-content: space-around;
  175. align-items: center;
  176. height: 100rpx;
  177. background-color: #e6e6e6;
  178. }
  179. .topbilledit {
  180. display: flex;
  181. justify-content: space-around;
  182. align-items: center;
  183. }
  184. .changetime1 {
  185. padding-right: 10rpx;
  186. }
  187. </style>