IncidentListFilter.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view class="container" @touchstart.stop 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" @touchstart.stop 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" @touchstart.stop 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" @touchstart.stop></view>
  59. <view class="line" @touchstart.stop></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. searchData.selected = evt.selected;
  207. searchData.area = evt.area;
  208. searchData.category = evt.category;
  209. })
  210. </script>
  211. <style lang="scss" scoped>
  212. .mask{
  213. position: fixed;
  214. left: 0;
  215. top: 0;
  216. right: 0;
  217. bottom: 0;
  218. background-color: rgba(0, 0, 0, 0.4);
  219. z-index: 999;
  220. }
  221. .line{
  222. content: '';
  223. position: fixed;
  224. top: 0;
  225. left: 0;
  226. z-index: 9999;
  227. height: 8rpx;
  228. width: 100%;
  229. background-color: #EBEBEB;
  230. }
  231. .container{
  232. position: fixed;
  233. left: 150rpx;
  234. top: 0;
  235. right: 0;
  236. bottom: 0;
  237. z-index: 9999;
  238. background-color: #F7F7F7;
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: space-between;
  242. .container_form{
  243. height: 100%;
  244. display: flex;
  245. flex-direction: column;
  246. flex: 1;
  247. min-height: 0;
  248. }
  249. .hospital{
  250. display: flex;
  251. justify-content: space-between;
  252. align-items: center;
  253. padding: 32rpx 24rpx 24rpx;
  254. background-color: #fff;
  255. .name{
  256. font-size: 30rpx;
  257. flex-shrink: 0;
  258. margin-right: 24rpx;
  259. }
  260. .value{
  261. font-size: 26rpx;
  262. color: #5DAAB6;
  263. }
  264. }
  265. .areas{
  266. flex: 1;
  267. min-height: 0;
  268. margin-top: 16rpx;
  269. background-color: #fff;
  270. .areas_item{
  271. padding: 24rpx;
  272. border-bottom: 1rpx solid #DEDEDE;
  273. }
  274. }
  275. .categorys{
  276. flex: 1;
  277. min-height: 0;
  278. margin-top: 16rpx;
  279. background-color: #fff;
  280. .categorys_item{
  281. padding: 24rpx;
  282. border-bottom: 1rpx solid #DEDEDE;
  283. }
  284. }
  285. .tabs{
  286. margin-top: 16rpx;
  287. background-color: #FBFBFB;
  288. display: flex;
  289. flex-wrap: wrap;
  290. justify-content: space-between;
  291. gap: 16rpx 0;
  292. padding: 24rpx 16rpx;
  293. .tab{
  294. width: 180rpx;
  295. height: 60rpx;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. background-color: #F7F7F7;
  300. font-size: 28rpx;
  301. position: relative;
  302. .newicon-xuanzejiaobiao{
  303. opacity: 0;
  304. position: absolute;
  305. right: 0;
  306. bottom: 0;
  307. font-size: 38rpx;
  308. color: #53B9BB;
  309. }
  310. &.active{
  311. background-color: rgba(149, 220, 231, 0.30);
  312. .newicon-xuanzejiaobiao{
  313. opacity: 1;
  314. }
  315. }
  316. }
  317. }
  318. .area,
  319. .category{
  320. display: flex;
  321. justify-content: space-between;
  322. align-items: center;
  323. padding: 24rpx;
  324. background-color: #fff;
  325. margin-top: 24rpx;
  326. .name{
  327. font-size: 28rpx;
  328. flex-shrink: 0;
  329. margin-right: 24rpx;
  330. }
  331. }
  332. .container_foot{
  333. .clear{
  334. padding: 24rpx;
  335. font-size: 28rpx;
  336. background-color: #fff;
  337. margin: 0 16rpx;
  338. display: flex;
  339. align-items: center;
  340. justify-content: center;
  341. }
  342. .foot_btns{
  343. margin-top: 24rpx;
  344. display: flex;
  345. border-top: 1rpx solid #BFBFBF;
  346. .cancel{
  347. flex: 1;
  348. background-color: #fff;
  349. font-size: 32rpx;
  350. padding: 24rpx;
  351. display: flex;
  352. justify-content: center;
  353. }
  354. .confirm{
  355. flex: 1;
  356. font-size: 32rpx;
  357. padding: 24rpx;
  358. background-color: $uni-primary;
  359. display: flex;
  360. justify-content: center;
  361. color: #fff;
  362. }
  363. }
  364. }
  365. }
  366. </style>