car.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view>
  3. <!-- 详情 -->
  4. <u-popup v-model="popupShow" mode="center" width="650" :closeable="true" border-radius="10">
  5. <view style="padding: 60rpx 40rpx 10rpx;">
  6. <u-form label-width="150" :model="form">
  7. <u-form-item label="所属小区" :required="true">
  8. <u-input type="select" disabled @click="operaType=1;residentialShow=true" v-model="form.residentialName" />
  9. </u-form-item>
  10. <u-form-item label="车主姓名" ><u-input v-model="form.personName" /></u-form-item>
  11. <u-form-item label="车主电话" ><u-input v-model="form.personTel" /></u-form-item>
  12. </u-form>
  13. <view @click="submit" class="flex cu-btn bg-blue" style="margin: 60rpx 0 10rpx;padding: 40rpx;">
  14. 提交
  15. </view>
  16. </view>
  17. </u-popup>
  18. <!-- 筛选标签条 -->
  19. <view class="cu-bar bg-white flex justify-around" style="z-index: 100;width: 100%;position: fixed;top: -2rpx;">
  20. <view class="u-line-1" @click="showDown(index)" v-for="(item,index) in filterMenu" :key="index" style="width: 24%;text-align: center;height: 100%;">
  21. {{data[index]==""? item:data[index]}}
  22. <u-icon name="arrow-down-fill" size="20" style="padding-left: 10rpx;"></u-icon>
  23. </view>
  24. <view class="u-line-1" @click="filterShow=true" style="width: 26%;position: relative;text-align: center;height: 100%;">
  25. 筛选
  26. <text class="cuIcon-filter padding-left-10" ></text>
  27. <u-badge :offset="[2, 20]" size="mini" type="error" :count="filterCount"></u-badge>
  28. </view>
  29. </view>
  30. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  31. <view style="margin-top: 110rpx;">
  32. <card @delItem="delItem" @edit="edit" :list="list"></card>
  33. </view>
  34. </mescroll-body>
  35. <!-- 地区选择器 -->
  36. <u-picker @confirm="regionConfirm" mode="region" v-model="regionShow"></u-picker>
  37. <!-- 小区 -->
  38. <u-popup border-radius="60" height="60%" mode="bottom" v-model="residentialShow">
  39. <view class="fixed cu-bar search bg-white">
  40. <view class="search-form round">
  41. <text class="cuIcon-search"></text>
  42. <u-input style="width: 90%;" v-model="keyword" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  43. </view>
  44. </view>
  45. <scroll-view v-if="!$isEmpty(residentialList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
  46. <view @click="residentailConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in residentialList" :key="index">
  47. <text>{{item.label}}</text>
  48. </view>
  49. <u-divider v-if="residentialList.length>=10" height="80">只显示十条数据</u-divider>
  50. </scroll-view>
  51. <u-empty v-else name="search"></u-empty>
  52. </u-popup>
  53. <!-- 筛选 -->
  54. <u-modal :show-cancel-button="true" cancel-text="重置" @cancel="reset" @confirm="filterConfirm" title="筛选" :mask-close-able="true" v-model="filterShow" >
  55. <view class="slot-content" style="margin: 20rpx;">
  56. <u-form label-width="150" :model="params" ref="uForm">
  57. <u-form-item :border-bottom="false" label="车主姓名"><u-input placeholder="请输入车主姓名" v-model="params.personName" /></u-form-item>
  58. <u-form-item :border-bottom="false" label="车主号码"><u-input placeholder="请输入车主号码" v-model="params.personPhone" /></u-form-item>
  59. </u-form>
  60. </view>
  61. </u-modal>
  62. <!-- 添加按钮 -->
  63. <add-btn @click.native="add"></add-btn>
  64. <!-- 通知alert -->
  65. <u-toast ref="uToast" />
  66. </view>
  67. </template>
  68. <script>
  69. import card from "./card.vue"
  70. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  71. let that;
  72. export default {
  73. components:{
  74. card
  75. },
  76. mixins:[MescrollMixin],
  77. data() {
  78. return {
  79. //新增修改详情弹窗
  80. popupShow:false,
  81. form:{},
  82. operaType:0,
  83. //顶部菜单栏
  84. filterMenu: ["所属地区","所属小区"],
  85. data:['','',''],
  86. //地区
  87. regionShow:false,
  88. areaValue:'',
  89. //小区
  90. residentialShow:false,
  91. residentialList:[],
  92. //筛选
  93. filterShow:false,
  94. filterCount:0,
  95. //参数
  96. params:{},
  97. //小区关键字
  98. keyword:'',
  99. list: [],
  100. downOption: {
  101. use: true,
  102. auto: false
  103. },
  104. upOption: {
  105. page: {
  106. page: 0,
  107. size: 10
  108. },
  109. noMoreSize: 5,
  110. empty: {
  111. tip: '暂无相关数据'
  112. }
  113. },
  114. }
  115. },
  116. onLoad(){
  117. that=this
  118. this.getResidentailList({isSelect:true})
  119. },
  120. watch:{
  121. keyword(){
  122. let that=this
  123. //节流函数
  124. if (this.timer){
  125. clearTimeout(this.timer)//阻止setTimeout函数的执行
  126. }
  127. this.timer = setTimeout(() => {
  128. that.residentialList=[]
  129. let params = {
  130. isSelect: true,
  131. regionArea: that.areaValue,
  132. name: that.keyword
  133. }
  134. this.getResidentailList(params)
  135. }, 500)
  136. }
  137. },
  138. methods: {
  139. //添加车辆
  140. add(){
  141. uni.navigateTo({
  142. url:"./add"
  143. })
  144. },
  145. edit(item){
  146. let {orgId,orgPosition,...form}=item
  147. this.form=form
  148. this.popupShow=true
  149. console.log(this.form);
  150. },
  151. delItem(item){
  152. this.$dialog.showModal('确定要删除此记录吗?').then(res=>{
  153. this.$api.carManage.del({id:item.id}).then(res=>{
  154. if (res.data==true) {
  155. this.$u.toast('删除成功')
  156. this.mescroll.resetUpScroll()
  157. }else{
  158. this.$u.toast('删除失败')
  159. }
  160. })
  161. })
  162. },
  163. /**
  164. * 获取筛选的条件数
  165. */
  166. getFilterCount(){
  167. let n=0
  168. console.log(this.areaValue);
  169. if (!this.$isEmpty(this.areaValue)) {
  170. //地区
  171. n++
  172. }
  173. if (!this.$isEmpty(this.params.name)) {
  174. //楼栋
  175. n++
  176. }
  177. this.filterCount=n
  178. },
  179. /**
  180. * 下拉回调
  181. */
  182. downCallback(){
  183. setTimeout(()=>{
  184. this.mescroll.resetUpScroll()
  185. },1500)
  186. },
  187. /**
  188. * 上拉回调
  189. * @param {Object} mescroll
  190. */
  191. upCallback(mescroll) {
  192. let params=this.params
  193. params.current=mescroll.num
  194. params.size=mescroll.size
  195. this.getFilterCount()
  196. try{
  197. if(params.personName == null || params.personPhone == null){
  198. console.log(params)
  199. this.$api.carManage.page(params).then(res=>{
  200. let data=res.data.records
  201. let length=data.length
  202. let total=res.data.total
  203. mescroll.endBySize(length, total);
  204. if(mescroll.num == 1) this.list = [];
  205. this.list=this.list.concat(data);
  206. })
  207. }else{
  208. console.log(222)
  209. this.$api.carManage.page(params).then(res=>{
  210. let data=res.data.records
  211. let length=data.length
  212. let total=res.data.total
  213. mescroll.endBySize(length, total);
  214. if(mescroll.num == 1) this.list = [];
  215. this.list=this.list.concat(data);
  216. })
  217. }
  218. }catch(e){
  219. mescroll.endErr();
  220. }
  221. },
  222. /**
  223. * 重置
  224. */
  225. reset(){
  226. //查询数据列表的参数
  227. this.params={}
  228. this.data=['','']
  229. //地区
  230. this.areaValue=''
  231. //小区列表
  232. this.residentialList=[]
  233. //小区关键字
  234. this.keyword=''
  235. //数据列表
  236. this.list=[],
  237. this.getResidentailList()
  238. this.mescroll.resetUpScroll()
  239. },
  240. /**
  241. * 顶部菜单选择
  242. * @param {Object} index 菜单下标
  243. */
  244. showDown(index){
  245. if (index==0) {
  246. //地区
  247. this.regionShow=true
  248. return
  249. }
  250. if(index==1){
  251. //小区
  252. this.residentialShow = true;
  253. return;
  254. }
  255. },
  256. /**
  257. * 确认筛选
  258. */
  259. filterConfirm(){
  260. this.mescroll.resetUpScroll()
  261. },
  262. /**
  263. * 地区确认回调
  264. * @param {Object} object
  265. */
  266. regionConfirm(object){
  267. this.data[0]= object.area.label;
  268. this.areaValue = object.area.value;
  269. let params = {
  270. isSelect: true,
  271. regionArea: this.areaValue
  272. };
  273. // this.getFilterCount()
  274. this.getResidentailList(params);
  275. },
  276. /**
  277. * 获取小区列表
  278. * @param {Object} params
  279. */
  280. getResidentailList(params){
  281. console.log(params)
  282. let list = [];
  283. this.$api.residential.page(params).then(res=>{
  284. console.log(res)
  285. let list=[]
  286. res.list.forEach(item=>{
  287. let obj={
  288. label:item.name,
  289. value:item.id
  290. }
  291. list.push(obj)
  292. })
  293. this.residentialList = list;
  294. console.log(list)
  295. })
  296. },
  297. /**
  298. * 点击选择小区刷新列表
  299. */
  300. residentailConfirm(res){
  301. //筛选标题
  302. this.params.residentialId =res.value
  303. this.data[1] = res.label
  304. this.residentialShow = false
  305. //获取楼栋列表
  306. let params={
  307. residentialId:this.params.residentialId
  308. }
  309. this.mescroll.resetUpScroll()
  310. },
  311. }
  312. }
  313. </script>
  314. <style>
  315. </style>