Tenantbill.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. <!-- 列表 -->
  29. <t-table>
  30. <t-tr>
  31. <t-th>序号</t-th>
  32. <t-th>姓名</t-th>
  33. <t-th>年龄</t-th>
  34. <t-th>爱好</t-th>
  35. <t-th>操作</t-th>
  36. </t-tr>
  37. <t-tr v-for="item in tableList" :key="item.id">
  38. <t-td>{{ item.id + 1 }}</t-td>
  39. <t-td>{{ item.name }}</t-td>
  40. <t-td>{{ item.age }}</t-td>
  41. <t-td>{{ item.hobby }}</t-td>
  42. <t-td align="left"> <u-button @click="edit(item)" size="small" type="primary" :plain="true" text="编辑"></u-button></t-td>
  43. </t-tr>
  44. </t-table>
  45. <u-picker :show="showtype" :columns="columnstype" keyName="label" @confirm="confirmtype" @cancel='canceltype'>
  46. </u-picker>
  47. <!--
  48. <mx-date-picker :show="showPicker" type="range" :value="dayrange" :show-tips="true" :begin-text="'开始日期'" :end-text="'结束日期'" :show-seconds="true" @confirm="ed" @cancel="ec" /> -->
  49. <u-picker :show="showfloor" ref="uPicker" :loading="loading" @confirm="confirmfloor" @cancel='cancelfloor'
  50. :columns="columns" keyName="orgName" @change="changeHandler"></u-picker>
  51. <u-notify ref="uNotify" :show="showdct" message="服务器请求失败"></u-notify>
  52. </view>
  53. </template>
  54. <script>
  55. // import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue";
  56. import tTable from '@/components/t-table/t-table.vue';
  57. import tTh from '@/components/t-table/t-th.vue';
  58. import tTr from '@/components/t-table/t-tr.vue';
  59. import tTd from '@/components/t-table/t-td.vue';
  60. export default {
  61. components: {
  62. // MxDatePicker
  63. tTable,
  64. tTh,
  65. tTr,
  66. tTd
  67. },
  68. data() {
  69. const currentDate = this.getDate({
  70. format: 'yyyy-mm'
  71. })
  72. return {
  73. tableList: [{
  74. id: 0,
  75. name: '张三',
  76. age: '19',
  77. hobby: '游泳'
  78. },
  79. {
  80. id: 1,
  81. name: '李四',
  82. age: '21',
  83. hobby: '绘画'
  84. },
  85. {
  86. id: 2,
  87. name: '王二',
  88. age: '29',
  89. hobby: '滑板'
  90. },
  91. {
  92. id: 3,
  93. name: '码字',
  94. age: '20',
  95. hobby: '蹦极'
  96. }
  97. ],
  98. showtype: false,
  99. showdct: false,
  100. mytitle: '',
  101. alldata: [],
  102. showfloor: false,
  103. loading: false,
  104. columns: [],
  105. columnData: [],
  106. myday: '',
  107. mytype: '全部',
  108. showPicker: false,
  109. myday: currentDate,
  110. columnstype: [
  111. [{
  112. label: '全部',
  113. id: ''
  114. }, {
  115. label: '未结清',
  116. id: 0
  117. },
  118. {
  119. label: '已结清',
  120. id: 1
  121. }
  122. ]
  123. ],
  124. }
  125. },
  126. //监听页面加载,其参数为上个页面传递的数据,参数类型为 Object(用于页面传参
  127. onLoad() {
  128. this.getfloor();
  129. },
  130. //监听页面初次渲染完成。注意如果渲染速度快,会在页面进入动画完成前触发
  131. onReady() {
  132. // 微信小程序需要用此写法
  133. },
  134. //监听页面隐藏
  135. onHide() {},
  136. //监听窗口尺寸变化
  137. onResize() {},
  138. //监听页面卸载
  139. onUnload() {},
  140. //监听用户下拉动作,一般用于下拉刷新
  141. onPullDownRefresh() {},
  142. methods: {
  143. edit(item) {
  144. console.log('111111111111111111', item)
  145. },
  146. canceltype() {
  147. this.showtype = false;
  148. },
  149. confirmtype(e) {
  150. // console.log('111111111111111111',e.value[0])
  151. this.showtype = false;
  152. this.mytype = e.value[0].label
  153. },
  154. typechange() {
  155. this.showtype = true;
  156. },
  157. dateChange(e) {
  158. this.myday = e.target.value;
  159. },
  160. getDate(type) {
  161. const date = new Date();
  162. let year = date.getFullYear();
  163. let month = date.getMonth() + 1;
  164. if (type === 'start') {
  165. year = year - 60;
  166. } else if (type === 'end') {
  167. year = year + 2;
  168. }
  169. month = month > 9 ? month : '0' + month;
  170. // day = day > 9 ? day : '0' + day;
  171. return `${year}-${month}`;
  172. },
  173. getfloor() {
  174. this.$api.get('/control/getOrgStructureTree/', {})
  175. .then(res => {
  176. if (res.data.code == 0) {
  177. this.mytitle = res.data.data[0].orgName;
  178. this.alldata = res.data.data[0].childrenList;
  179. //console.log('111111111111111111', res.data.data[0].childrenList)
  180. this.columns = [
  181. res.data.data[0].childrenList,
  182. res.data.data[0].childrenList[0].childrenList
  183. ]
  184. let allfloor = [];
  185. for (let i = 0; i < res.data.data[0].childrenList.length; i++) {
  186. allfloor.push(res.data.data[0].childrenList[i].childrenList)
  187. }
  188. // console.log('111111111111111111',allfloor)
  189. this.columnData = allfloor
  190. } else {
  191. this.showdct = true
  192. }
  193. })
  194. },
  195. floorchange() {
  196. this.showfloor = true;
  197. },
  198. changeHandler(e) {
  199. const {
  200. columnIndex,
  201. index,
  202. // 微信小程序无法将picker实例传出来,只能通过ref操作
  203. picker = this.$refs.uPicker
  204. } = e
  205. if (columnIndex === 0) {
  206. this.loading = true
  207. picker.setColumnValues(1, this.columnData[index])
  208. this.loading = false
  209. }
  210. },
  211. confirmfloor(e) {
  212. console.log('222222', e.value)
  213. this.mytitle = e.value[0].orgName + e.value[1].orgName;
  214. this.showfloor = false;
  215. },
  216. cancelfloor() {
  217. this.showfloor = false;
  218. },
  219. }
  220. }
  221. </script>
  222. <style>
  223. .billall {}
  224. .topbill {
  225. display: flex;
  226. justify-content: space-around;
  227. align-items: center;
  228. height: 100rpx;
  229. background-color: #e6e6e6;
  230. }
  231. .topbilledit {
  232. display: flex;
  233. justify-content: space-around;
  234. align-items: center;
  235. }
  236. .changetime1 {
  237. padding-right: 10rpx;
  238. }
  239. </style>