InspectionListFilter.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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, getFetchDataList, 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. building:{
  145. hosId: loginUserStore.loginUser.user.currentHospital.id,
  146. }
  147. };
  148. getFetchDataList("simple/data", "building", postData)
  149. .then((res) => {
  150. uni.hideLoading();
  151. let list = res.list || [];
  152. pageData.areaList = [{ id: 0, buildingName: '全部' }, ...list];
  153. console.log(444,pageData.areaList )
  154. });
  155. }
  156. // 获取故障现象列表
  157. function getInspectionFormList(){
  158. uni.showLoading({
  159. title: "加载中",
  160. mask: true,
  161. });
  162. let postData = {
  163. idx: 0,
  164. sum: 9999,
  165. account: loginUserStore.loginUser.user.account,
  166. inspectionForm: {
  167. status: {value: "1"},
  168. },
  169. }
  170. api_inspectionForm(postData).then(res => {
  171. uni.hideLoading();
  172. if(res.status == 200){
  173. let list = res.list || [];
  174. pageData.inspectionFormList = [{ id:0, name: '全部' }, ...list];
  175. }else{
  176. uni.showToast({
  177. icon: 'none',
  178. title: res.msg || '请求数据失败!'
  179. });
  180. }
  181. })
  182. }
  183. // 页面路由跳转
  184. function clickPageRouter(type){
  185. pageData.pageRouter = type;
  186. switch(type){
  187. case 'area':
  188. getAreaList();
  189. break;
  190. case 'inspectionForm':
  191. getInspectionFormList();
  192. break;
  193. }
  194. }
  195. // 显示登记时间
  196. function changeIsShowDate(type){
  197. isShowDate.value = true;
  198. }
  199. onLoad((option) => {
  200. searchData.area = evt.area;
  201. searchData.inspectionForm = evt.inspectionForm;
  202. searchData.acceptDate = evt.acceptDate;
  203. })
  204. </script>
  205. <style lang="scss" scoped>
  206. .mask{
  207. position: fixed;
  208. left: 0;
  209. top: 0;
  210. right: 0;
  211. bottom: 0;
  212. background-color: rgba(0, 0, 0, 0.4);
  213. z-index: 999;
  214. }
  215. .line{
  216. content: '';
  217. position: fixed;
  218. top: 0;
  219. left: 0;
  220. z-index: 9999;
  221. height: 8rpx;
  222. width: 100%;
  223. background-color: #EBEBEB;
  224. }
  225. .container{
  226. position: fixed;
  227. left: 125rpx;
  228. top: 0;
  229. right: 0;
  230. bottom: 0;
  231. z-index: 9999;
  232. background-color: #F7F7F7;
  233. display: flex;
  234. flex-direction: column;
  235. justify-content: space-between;
  236. .container_form{
  237. height: 100%;
  238. display: flex;
  239. flex-direction: column;
  240. flex: 1;
  241. min-height: 0;
  242. }
  243. .hospital{
  244. display: flex;
  245. justify-content: space-between;
  246. align-items: center;
  247. padding: 32rpx 24rpx 24rpx;
  248. background-color: #fff;
  249. .name{
  250. font-size: 30rpx;
  251. flex-shrink: 0;
  252. margin-right: 24rpx;
  253. }
  254. .value{
  255. font-size: 26rpx;
  256. color: #5DAAB6;
  257. }
  258. }
  259. .areas{
  260. flex: 1;
  261. min-height: 0;
  262. margin-top: 16rpx;
  263. background-color: #fff;
  264. .areas_item{
  265. padding: 24rpx;
  266. border-bottom: 1rpx solid #DEDEDE;
  267. }
  268. }
  269. .categorys{
  270. flex: 1;
  271. min-height: 0;
  272. margin-top: 16rpx;
  273. background-color: #fff;
  274. .categorys_item{
  275. padding: 24rpx;
  276. border-bottom: 1rpx solid #DEDEDE;
  277. }
  278. }
  279. .tabs{
  280. margin-top: 16rpx;
  281. background-color: #FBFBFB;
  282. display: flex;
  283. flex-wrap: wrap;
  284. justify-content: space-between;
  285. gap: 16rpx 0;
  286. padding: 24rpx 16rpx;
  287. .tab{
  288. width: 180rpx;
  289. height: 60rpx;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. background-color: #F7F7F7;
  294. font-size: 28rpx;
  295. position: relative;
  296. .newicon-xuanzejiaobiao{
  297. opacity: 0;
  298. position: absolute;
  299. right: 0;
  300. bottom: 0;
  301. font-size: 38rpx;
  302. color: #53B9BB;
  303. }
  304. &.active{
  305. background-color: rgba(149, 220, 231, 0.30);
  306. .newicon-xuanzejiaobiao{
  307. opacity: 1;
  308. }
  309. }
  310. }
  311. }
  312. .area,
  313. .category,
  314. .acceptDate{
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. padding: 24rpx;
  319. background-color: #fff;
  320. margin-top: 24rpx;
  321. .name{
  322. font-size: 28rpx;
  323. flex-shrink: 0;
  324. margin-right: 24rpx;
  325. }
  326. }
  327. .container_foot{
  328. .clear{
  329. padding: 24rpx;
  330. font-size: 28rpx;
  331. background-color: #fff;
  332. margin: 0 16rpx;
  333. display: flex;
  334. align-items: center;
  335. justify-content: center;
  336. }
  337. .foot_btns{
  338. margin-top: 24rpx;
  339. display: flex;
  340. border-top: 1rpx solid #BFBFBF;
  341. .cancel{
  342. flex: 1;
  343. background-color: #fff;
  344. font-size: 32rpx;
  345. padding: 24rpx;
  346. display: flex;
  347. justify-content: center;
  348. }
  349. .confirm{
  350. flex: 1;
  351. font-size: 32rpx;
  352. padding: 24rpx;
  353. background-color: $uni-primary;
  354. display: flex;
  355. justify-content: center;
  356. color: #fff;
  357. }
  358. }
  359. }
  360. }
  361. </style>