IncidentListFilter.vue 13 KB

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