buildList.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true" backUrl="/pages/index/index">
  4. <block slot="content">楼宇列表</block>
  5. </cu-custom>
  6. <view :style="[{top:CustomBar + 'px'}]">
  7. <view class="search-box">
  8. <view class="choose-box">
  9. <jp-picker v-model="parkId" rangeKey="label" rangeValue="value"
  10. :range="parkList" empty="选择园区">
  11. </jp-picker>
  12. </view>
  13. <view class="input-box">
  14. <input type="text" placeholder="请输入楼宇名称" v-model="curWord" confirm-type="search"
  15. ></input>
  16. </view>
  17. <text class="cuIcon-search color-white" @click="doSearch"></text>
  18. </view>
  19. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
  20. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  21. v-for="(item, index) in dataList" :key="index" @touchstart="ListTouchStart"
  22. @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  23. <view class="item-box" @click="gotoBuildInfo(item.id)">
  24. <view class="item-title">
  25. <view>
  26. <text class="line-zs"></text>{{item.buildingName}}(<text class="subtitle">{{item.parkName}}</text>)
  27. </view>
  28. <view class="btn-box" v-if="stype == 5">
  29. <view class="edit-botton" @click.stop="edit(item.id)">修改</view>
  30. <view class="del-botton" @click.stop="del(item.id)">删除</view>
  31. </view>
  32. </view>
  33. <view class="item-line">
  34. <view class="item-name">楼宇总面积:</view>
  35. <view class="item-content">{{item.buildingArea}}㎡</view>
  36. </view>
  37. <view class="item-line">
  38. <view class="item-name">楼宇企业数:</view>
  39. <view class="item-content">{{item.reserve3}}</view>
  40. </view>
  41. <view class="item-line">
  42. <view class="item-name">楼宇联系人:</view>
  43. <view class="item-content">{{item.buildingContacts.substring(0,5)}}({{item.reserve2}})</view>
  44. </view>
  45. </view>
  46. </view>
  47. </mescroll-body>
  48. <uni-fab :pattern=" {
  49. color: '#7A7E83',
  50. backgroundColor: '#fff',
  51. selectedColor: '#007AFF',
  52. buttonColor: '#007AFF'
  53. }" horizontal="right" vertical="bottom" @fabClick="add" v-if="stype == 5"></uni-fab>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import uniFab from '@/components/uni-fab/uni-fab.vue';
  59. import loginService from '@/api/auth/loginService.js'
  60. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  61. import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
  62. export default {
  63. mixins: [MescrollMixin, MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
  64. onShow(option) {
  65. this.$auth.checkLogin()
  66. },
  67. components: {
  68. uniFab
  69. },
  70. data() {
  71. return {
  72. searchForm: {},
  73. curWord: "", //当前搜索关键词
  74. dataList: [], // 数据列表
  75. modalName: null,
  76. tablePage: {
  77. total: 0,
  78. currentPage: 1,
  79. pageSize: 10,
  80. orders: []
  81. },
  82. loading: false,
  83. parkList: [],
  84. parkId: '',
  85. stype: '', // 企业 => 3 楼宇 => 2 园区 => 1 zfadmin => 4 admin=> 5
  86. }
  87. },
  88. created() {
  89. this.stype = uni.getStorageSync('stype')
  90. this.getParkList()
  91. },
  92. methods: {
  93. // 新增
  94. add() {
  95. uni.navigateTo({
  96. url: '/pages/buildEdit/buildEdit'
  97. })
  98. },
  99. getParkList() {
  100. loginService.parkList({
  101. current: 1,
  102. size: 1000000,
  103. }).then(({
  104. data
  105. }) => {
  106. this.parkList = data.records.map((item) => {
  107. return {
  108. label: item.parkName,
  109. value: item.id
  110. }
  111. })
  112. console.log(this.parkList, '=============>')
  113. }).catch(e => {
  114. console.log(e)
  115. })
  116. },
  117. // 修改
  118. edit(id) {
  119. uni.navigateTo({
  120. url: '/pages/buildEdit/buildEdit?id=' + id
  121. })
  122. },
  123. gotoBuildInfo(id) {
  124. uni.navigateTo({
  125. url: `/pages/buildEdit/buildEdit?id=${id}&ischeck=1`
  126. })
  127. },
  128. // 删除
  129. del(id) {
  130. uni.showModal({
  131. title: '提示',
  132. content: '您确认要删除数据吗',
  133. showCancel: true,
  134. success: (res) => {
  135. if (res.confirm) {
  136. loginService.delete(id).then(({
  137. data
  138. }) => {
  139. uni.showToast({
  140. title: data,
  141. icon: "success"
  142. })
  143. this.doSearch()
  144. })
  145. }
  146. }
  147. });
  148. },
  149. /*获取数据列表 */
  150. upCallback(page) {
  151. this.loading = true
  152. loginService.list({
  153. current: page.num,
  154. size: page.size,
  155. buildingName: this.curWord,
  156. }).then(({
  157. data
  158. }) => {
  159. let curPageData = data.records
  160. this.mescroll.endBySize(curPageData.length, data.total);
  161. //如果是第一页需手动制空列表
  162. if (page.num == 1) {
  163. this.dataList = [];
  164. }
  165. //追加新数据
  166. this.dataList = this.dataList.concat(curPageData);
  167. }).catch(e => {
  168. //联网失败, 结束加载
  169. this.mescroll.endErr();
  170. })
  171. },
  172. // 输入监听
  173. inputWord(e) {
  174. },
  175. // 搜索
  176. doSearch(word) {
  177. this.dataList = []; // 先清空列表,显示加载进度
  178. this.mescroll.resetUpScroll();
  179. },
  180. // ListTouch触摸开始
  181. ListTouchStart(e) {
  182. this.listTouchStart = e.touches[0].pageX
  183. },
  184. // ListTouch计算方向
  185. ListTouchMove(e) {
  186. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > -60 ? 'right' : 'left'
  187. },
  188. // ListTouch计算滚动
  189. ListTouchEnd(e) {
  190. if (this.listTouchDirection == 'left') {
  191. this.modalName = e.currentTarget.dataset.target
  192. } else {
  193. this.modalName = null
  194. }
  195. this.listTouchDirection = null
  196. }
  197. }
  198. }
  199. </script>
  200. <style>
  201. .ellipsis-description {
  202. font-size: 12px;
  203. line-height: $line-height-base;
  204. display: -webkit-box;
  205. /*作为弹性伸缩盒子模型显示*/
  206. -webkit-line-clamp: 1;
  207. /*显示的行数;如果要设置2行加...则设置为2*/
  208. overflow: hidden;
  209. /*超出的文本隐藏*/
  210. text-overflow: ellipsis;
  211. /* 溢出用省略号*/
  212. -webkit-box-orient: vertical;
  213. /*伸缩盒子的子元素排列:从上到下*/
  214. }
  215. .item-box{
  216. width: 710rpx;
  217. margin-left: 20rpx;
  218. background: #FFFFFF;
  219. box-shadow: 0px 1px 3px 0px rgba(9,2,4,0.1);
  220. border-radius: 10px;
  221. padding-top: 20rpx;
  222. padding-left: 38rpx;
  223. padding-right: 10rpx;
  224. margin-top: 20rpx;
  225. }
  226. .item-title{
  227. position: relative;
  228. display: flex;
  229. justify-content: space-between;
  230. font-size: 30rpx;
  231. color: #333;
  232. font-weight: bold;
  233. align-items: center;
  234. }
  235. .item-line{
  236. display: flex;
  237. height: 48rpx;
  238. margin-top: 20rpx;
  239. }
  240. .subtitle{
  241. color: #E5880E;
  242. }
  243. .item-name{
  244. font-size: 30rpx;
  245. color: #333;
  246. }
  247. .item-content{
  248. color: #1497EF;
  249. font-size: 30rpx;
  250. }
  251. .btn-box{
  252. display: flex;
  253. }
  254. .line-zs{
  255. width: 2rpx;
  256. height: 30rpx;
  257. background: #36A7F3;
  258. }
  259. .edit-botton{
  260. width: 100rpx;
  261. height: 48rpx;
  262. line-height: 48rpx;
  263. color: #fff;
  264. font-size: 28rpx;
  265. margin-right: 20rpx;
  266. border-radius: 10rpx;
  267. background: #5A9EE9;
  268. text-align: center;
  269. }
  270. .del-botton{
  271. width: 100rpx;
  272. height: 48rpx;
  273. line-height: 48rpx;
  274. color: #fff;
  275. font-size: 28rpx;
  276. margin-right: 20rpx;
  277. border-radius: 10rpx;
  278. background: #F27C85;
  279. text-align: center;
  280. }
  281. .color-white{
  282. color: #fff;
  283. font-size: 40rpx;
  284. line-height: 60rpx;
  285. }
  286. .search-box{
  287. background: #36A7F3;
  288. display: flex;
  289. padding-left: 20rpx;
  290. padding-right: 20rpx;
  291. padding-bottom: 10rpx;
  292. }
  293. .input-box{
  294. margin-left: 20rpx;
  295. background: #fff;
  296. height: 60rpx;
  297. width: 420rpx;
  298. display: flex;
  299. align-items: center;
  300. border-radius: 30rpx;
  301. padding-left: 10rpx;
  302. margin-right: 20rpx;
  303. }
  304. .choose-box{
  305. background: #fff;
  306. width: 200rpx;
  307. border-radius: 30rpx;
  308. height: 60rpx;
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. }
  313. .cu-bar .search-form {
  314. background-color: white;
  315. }
  316. </style>