car.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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.searchList=[]
  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.building.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. submit(){
  164. if (this.$isEmpty(this.form.name)) {
  165. this.$u.toast('请输入楼栋名')
  166. return
  167. }
  168. if (this.$isEmpty(this.form.residentialId) || this.$isEmpty(this.form.residentialName)) {
  169. this.$u.toast('请选择所属小区')
  170. return
  171. }
  172. if (!this.$isEmpty(this.form.personTel)) {
  173. if (!this.$verify.phone(this.form.personTel)&&!this.$verify.landline(this.form.personTel)) {
  174. this.$u.toast('请输入正确的联系方式')
  175. return
  176. }
  177. }
  178. console.log(this.form);
  179. if (this.$isEmpty(this.form.id)) {
  180. console.log('我是新增');
  181. this.$api.building.add(this.form).then(res=>{
  182. if (res.code==200) {
  183. this.popupShow=false
  184. this.$u.toast('添加成功')
  185. this.mescroll.resetUpScroll()
  186. }
  187. })
  188. }else{
  189. let {createAccountId,createDate,floorNumber,roomNumber,status,unitNumber,personNumber,...params}=this.form
  190. console.log(params);
  191. this.$api.building.update(params).then(res=>{
  192. if (res.data==true) {
  193. this.popupShow=false
  194. this.$u.toast('修改成功')
  195. this.mescroll.resetUpScroll()
  196. }
  197. })
  198. }
  199. },
  200. //获取小区列表
  201. getResidentailList(params){
  202. let list = [];
  203. this.$api.residential.page(params).then(res=>{
  204. let list=[]
  205. res.list.forEach(item=>{
  206. let obj={
  207. label:item.name,
  208. value:item.id
  209. }
  210. list.push(obj)
  211. })
  212. this.residentialList = list;
  213. })
  214. },
  215. /**
  216. * 获取筛选的条件数
  217. */
  218. getFilterCount(){
  219. let n=0
  220. console.log(this.areaValue);
  221. if (!this.$isEmpty(this.areaValue)) {
  222. //地区
  223. n++
  224. }
  225. if (!this.$isEmpty(this.params.name)) {
  226. //楼栋
  227. n++
  228. }
  229. this.filterCount=n
  230. },
  231. /**
  232. * 下拉回调
  233. */
  234. downCallback(){
  235. setTimeout(()=>{
  236. this.mescroll.resetUpScroll()
  237. },1500)
  238. },
  239. /**
  240. * 上拉回调
  241. * @param {Object} mescroll
  242. */
  243. upCallback(mescroll) {
  244. let params=this.params
  245. params.current=mescroll.num
  246. params.size=mescroll.size
  247. this.getFilterCount()
  248. try{
  249. if(params.personName == null || params.personPhone == null){
  250. console.log(params)
  251. this.$api.carManage.page(params).then(res=>{
  252. let data=res.data.records
  253. let length=data.length
  254. let total=res.data.total
  255. mescroll.endBySize(length, total);
  256. if(mescroll.num == 1) this.list = [];
  257. this.list=this.list.concat(data);
  258. })
  259. }else{
  260. console.log(222)
  261. this.$api.carManage.pageBycondition(params).then(res=>{
  262. let data=res.data.records
  263. let length=data.length
  264. let total=res.data.total
  265. mescroll.endBySize(length, total);
  266. if(mescroll.num == 1) this.list = [];
  267. this.list=this.list.concat(data);
  268. })
  269. }
  270. }catch(e){
  271. mescroll.endErr();
  272. }
  273. },
  274. /**
  275. * 重置
  276. */
  277. reset(){
  278. //查询数据列表的参数
  279. this.params={}
  280. this.data=['','']
  281. //地区
  282. this.areaValue=''
  283. //小区列表
  284. this.residentialList=[]
  285. //小区关键字
  286. this.keyword=''
  287. //数据列表
  288. this.list=[],
  289. this.getResidentailList()
  290. this.mescroll.resetUpScroll()
  291. },
  292. /**
  293. * 点击选择小区,重新获取楼栋列表
  294. */
  295. residentailConfirm(res){
  296. if (this.operaType==0) {
  297. // 筛选楼栋列表的选择小区
  298. this.params.residentialId =res.value
  299. this.data[1] = res.label
  300. this.residentialShow = false
  301. this.mescroll.resetUpScroll()
  302. }else if(this.operaType==1){
  303. // 添加操作的选择小区
  304. this.form.residentialName=res.label
  305. this.form.residentialId=res.value
  306. this.residentialShow=false
  307. this.operaType=0
  308. }
  309. },
  310. /**
  311. * 顶部菜单选择
  312. * @param {Object} index 菜单下标
  313. */
  314. showDown(index){
  315. if (index==0) {
  316. //地区
  317. this.regionShow=true
  318. return
  319. }
  320. if(index==1){
  321. //小区
  322. this.residentialShow = true;
  323. return;
  324. }
  325. },
  326. /**
  327. * 确认筛选
  328. */
  329. filterConfirm(){
  330. this.mescroll.resetUpScroll()
  331. },
  332. /**
  333. * 地区确认回调
  334. * @param {Object} object
  335. */
  336. regionConfirm(object){
  337. this.data[0]= object.area.label;
  338. this.areaValue = object.area.value;
  339. let params = {
  340. isSelect: true,
  341. regionArea: this.areaValue
  342. };
  343. this.getFilterCount()
  344. this.getResidentailList(params);
  345. },
  346. }
  347. }
  348. </script>
  349. <style>
  350. </style>