InspectionListFilter.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <view class="container" @touchmove.stop.prevent v-if="pageData.pageRouter === 'default'">
  3. <view class="container_form">
  4. <view class="category" @click="clickPageRouter('inspectionForm')">
  5. <text class="name">巡检单</text>
  6. <text class="value ellipsis">{{searchData.inspectionForm ? searchData.inspectionForm.name : ''}}</text>
  7. </view>
  8. <view class="area" @click="clickPageRouter('area')">
  9. <text class="name">楼栋</text>
  10. <text class="value ellipsis">{{searchData.area ? searchData.area.buildingName : ''}}</text>
  11. </view>
  12. <view class="acceptDate" @click="changeIsShowDate()">
  13. <text class="name">登记时间</text>
  14. <text class="value ellipsis" v-if="searchData.acceptDate.length">{{searchData.acceptDate[0] || ''}}至{{searchData.acceptDate[1] || ''}}</text>
  15. <text class="value ellipsis" v-else>全部</text>
  16. </view>
  17. </view>
  18. <view class="container_foot">
  19. <view class="clear" @click="clear">清除选项</view>
  20. <view class="foot_btns">
  21. <view class="cancel" @click="cancel">取消</view>
  22. <view class="confirm" @click="confirm">确认</view>
  23. </view>
  24. </view>
  25. <PyhRdtpicker
  26. :show="isShowDate"
  27. :start="start"
  28. :end="end"
  29. @showchange="showDatechange"
  30. :value="searchData.acceptDate"
  31. @change="bindDateChange"
  32. :themeColor="primaryColor"
  33. ></PyhRdtpicker>
  34. </view>
  35. <view class="container" @touchmove.stop.prevent v-else-if="pageData.pageRouter === 'area'">
  36. <view class="container_form">
  37. <view class="hospital">
  38. <text class="name">楼栋</text>
  39. </view>
  40. <scroll-view scroll-y class="areas">
  41. <view class="areas_item" v-for="area in pageData.areaList" :key="area.id" @click="clickArea(area)">{{area.buildingName}}</view>
  42. </scroll-view>
  43. </view>
  44. <view class="container_foot">
  45. <view class="foot_btns">
  46. <view class="cancel" @click="clickPageRouter('default')">取消</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="container" @touchmove.stop.prevent v-else-if="pageData.pageRouter === 'inspectionForm'">
  51. <view class="container_form">
  52. <view class="hospital">
  53. <text class="name">巡检单</text>
  54. </view>
  55. <scroll-view scroll-y class="categorys">
  56. <view class="categorys_item" v-for="item in pageData.inspectionFormList" :key="item.id" @click="clickInspectionForm(item)">{{item.name}}</view>
  57. </scroll-view>
  58. </view>
  59. <view class="container_foot">
  60. <view class="foot_btns">
  61. <view class="cancel" @click="clickPageRouter('default')">取消</view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="mask" @touchmove.stop.prevent></view>
  66. <view class="line" @touchmove.stop.prevent></view>
  67. </template>
  68. <script setup>
  69. import PyhRdtpicker from '@/components/PyhRdtpicker/PyhRdtpicker.vue';
  70. import { defineEmits, ref, reactive, defineProps } from 'vue'
  71. import { startOfYear, endOfYear, format, add } from 'date-fns'
  72. import { onLoad } from '@dcloudio/uni-app'
  73. import { useLoginUserStore } from '@/stores/loginUser'
  74. import { api_building, api_inspectionForm } from "@/http/api.js"
  75. import { defaultColor } from '@/static/js/theme.js'
  76. const emit = defineEmits(['cancelEmit', 'confirmEmit']);
  77. const { evt } = defineProps({
  78. evt: {
  79. type: Object,
  80. required: true,
  81. },
  82. });
  83. const loginUserStore = useLoginUserStore();
  84. // 主题颜色
  85. const primaryColor = ref(defaultColor)
  86. // 登记时间
  87. const isShowDate = ref(false)
  88. const start = ref(format(startOfYear(add(new Date(), { years: -5})), 'yyyy-MM-dd'));
  89. const end = ref(format(endOfYear(add(new Date(), { years: 0})), 'yyyy-MM-dd'));
  90. // 页面数据
  91. const pageData = reactive({
  92. pageRouter: 'default',
  93. areaList: [],
  94. inspectionFormList: [],
  95. });
  96. const searchData = reactive({
  97. area: {id: 0, buildingName: '全部'},
  98. inspectionForm: {id: 0, name: '全部'},
  99. acceptDate: [],
  100. })
  101. // 显示登记时间
  102. function showDatechange(){
  103. isShowDate.value = !isShowDate.value;
  104. }
  105. // 登记时间确定
  106. function bindDateChange(e){
  107. console.log(e);
  108. searchData.acceptDate = e;
  109. }
  110. // 点击区域
  111. function clickArea(area){
  112. pageData.pageRouter = 'default';
  113. searchData.area = area;
  114. }
  115. // 点击故障现象
  116. function clickInspectionForm(inspectionForm){
  117. pageData.pageRouter = 'default';
  118. searchData.inspectionForm = inspectionForm;
  119. }
  120. // 清空
  121. function clear(){
  122. searchData.area = {id: 0, buildingName: '全部'};
  123. searchData.inspectionForm = {id: 0, name: '全部'};
  124. searchData.acceptDate = [];
  125. console.log(searchData.acceptDate)
  126. }
  127. // 取消
  128. function cancel(){
  129. emit('cancelEmit')
  130. }
  131. // 确认
  132. function confirm(){
  133. emit('confirmEmit', searchData);
  134. }
  135. // 获取楼栋列表
  136. function getAreaList(){
  137. uni.showLoading({
  138. title: "加载中",
  139. mask: true,
  140. });
  141. let postData = {
  142. idx: 0,
  143. sum: 9999,
  144. account: loginUserStore.loginUser.user.account,
  145. building: {},
  146. }
  147. api_building(postData).then(res => {
  148. uni.hideLoading();
  149. if(res.status == 200){
  150. let list = res.list || [];
  151. pageData.areaList = [{ id: 0, buildingName: '全部' }, ...list];
  152. }else{
  153. uni.showToast({
  154. icon: 'none',
  155. title: res.msg || '请求数据失败!'
  156. });
  157. }
  158. })
  159. }
  160. // 获取故障现象列表
  161. function getInspectionFormList(){
  162. uni.showLoading({
  163. title: "加载中",
  164. mask: true,
  165. });
  166. let postData = {
  167. idx: 0,
  168. sum: 9999,
  169. account: loginUserStore.loginUser.user.account,
  170. inspectionForm: {
  171. status: {value: "1"},
  172. },
  173. }
  174. api_inspectionForm(postData).then(res => {
  175. uni.hideLoading();
  176. if(res.status == 200){
  177. let list = res.list || [];
  178. pageData.inspectionFormList = [{ id:0, name: '全部' }, ...list];
  179. }else{
  180. uni.showToast({
  181. icon: 'none',
  182. title: res.msg || '请求数据失败!'
  183. });
  184. }
  185. })
  186. }
  187. // 页面路由跳转
  188. function clickPageRouter(type){
  189. pageData.pageRouter = type;
  190. switch(type){
  191. case 'area':
  192. getAreaList();
  193. break;
  194. case 'inspectionForm':
  195. getInspectionFormList();
  196. break;
  197. }
  198. }
  199. // 显示登记时间
  200. function changeIsShowDate(type){
  201. isShowDate.value = true;
  202. }
  203. onLoad((option) => {
  204. searchData.area = evt.area;
  205. searchData.inspectionForm = evt.inspectionForm;
  206. searchData.acceptDate = evt.acceptDate;
  207. })
  208. </script>
  209. <style lang="scss" scoped>
  210. .mask{
  211. position: fixed;
  212. left: 0;
  213. top: 0;
  214. right: 0;
  215. bottom: 0;
  216. background-color: rgba(0, 0, 0, 0.4);
  217. z-index: 999;
  218. }
  219. .line{
  220. content: '';
  221. position: fixed;
  222. top: 0;
  223. left: 0;
  224. z-index: 9999;
  225. height: 8rpx;
  226. width: 100%;
  227. background-color: #EBEBEB;
  228. }
  229. .container{
  230. position: fixed;
  231. left: 125rpx;
  232. top: 0;
  233. right: 0;
  234. bottom: 0;
  235. z-index: 9999;
  236. background-color: #F7F7F7;
  237. display: flex;
  238. flex-direction: column;
  239. justify-content: space-between;
  240. .container_form{
  241. height: 100%;
  242. display: flex;
  243. flex-direction: column;
  244. flex: 1;
  245. min-height: 0;
  246. }
  247. .hospital{
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. padding: 32rpx 24rpx 24rpx;
  252. background-color: #fff;
  253. .name{
  254. font-size: 30rpx;
  255. flex-shrink: 0;
  256. margin-right: 24rpx;
  257. }
  258. .value{
  259. font-size: 26rpx;
  260. color: #5DAAB6;
  261. }
  262. }
  263. .areas{
  264. flex: 1;
  265. min-height: 0;
  266. margin-top: 16rpx;
  267. background-color: #fff;
  268. .areas_item{
  269. padding: 24rpx;
  270. border-bottom: 1rpx solid #DEDEDE;
  271. }
  272. }
  273. .categorys{
  274. flex: 1;
  275. min-height: 0;
  276. margin-top: 16rpx;
  277. background-color: #fff;
  278. .categorys_item{
  279. padding: 24rpx;
  280. border-bottom: 1rpx solid #DEDEDE;
  281. }
  282. }
  283. .tabs{
  284. margin-top: 16rpx;
  285. background-color: #FBFBFB;
  286. display: flex;
  287. flex-wrap: wrap;
  288. justify-content: space-between;
  289. gap: 16rpx 0;
  290. padding: 24rpx 16rpx;
  291. .tab{
  292. width: 180rpx;
  293. height: 60rpx;
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. background-color: #F7F7F7;
  298. font-size: 28rpx;
  299. position: relative;
  300. .newicon-xuanzejiaobiao{
  301. opacity: 0;
  302. position: absolute;
  303. right: 0;
  304. bottom: 0;
  305. font-size: 38rpx;
  306. color: #53B9BB;
  307. }
  308. &.active{
  309. background-color: rgba(149, 220, 231, 0.30);
  310. .newicon-xuanzejiaobiao{
  311. opacity: 1;
  312. }
  313. }
  314. }
  315. }
  316. .area,
  317. .category,
  318. .acceptDate{
  319. display: flex;
  320. justify-content: space-between;
  321. align-items: center;
  322. padding: 24rpx;
  323. background-color: #fff;
  324. margin-top: 24rpx;
  325. .name{
  326. font-size: 28rpx;
  327. flex-shrink: 0;
  328. margin-right: 24rpx;
  329. }
  330. }
  331. .container_foot{
  332. .clear{
  333. padding: 24rpx;
  334. font-size: 28rpx;
  335. background-color: #fff;
  336. margin: 0 16rpx;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. }
  341. .foot_btns{
  342. margin-top: 24rpx;
  343. display: flex;
  344. border-top: 1rpx solid #BFBFBF;
  345. .cancel{
  346. flex: 1;
  347. background-color: #fff;
  348. font-size: 32rpx;
  349. padding: 24rpx;
  350. display: flex;
  351. justify-content: center;
  352. }
  353. .confirm{
  354. flex: 1;
  355. font-size: 32rpx;
  356. padding: 24rpx;
  357. background-color: $uni-primary;
  358. display: flex;
  359. justify-content: center;
  360. color: #fff;
  361. }
  362. }
  363. }
  364. }
  365. </style>