comList.vue 8.4 KB

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