IncidentListFilter.vue 11 KB

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