IncidentListFilter.vue 9.8 KB

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