index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="protection_list">
  3. <nav-bar></nav-bar>
  4. <van-search v-model="search.key" placeholder="请输入搜索关键词" />
  5. <van-dropdown-menu>
  6. <van-dropdown-item :title="selectedOrgName" @open="onItemClick" />
  7. <van-dropdown-item v-model="search.status" :options="statusOptions" />
  8. <van-dropdown-item v-model="search.hour" :options="hourOptions" />
  9. </van-dropdown-menu>
  10. <!-- <div>
  11. <van-picker show-toolbar title="选择" :columns="statusOptions"/>
  12. </div> -->
  13. <van-popup v-model="showOrg" round position="bottom">
  14. <van-cascader
  15. v-model="search.orgId"
  16. title="选择机构"
  17. :options="options"
  18. @close="showOrg = false"
  19. @change="changeTree"
  20. @finish="onFinish"
  21. :field-names="fieldNames"
  22. />
  23. </van-popup>
  24. <div class="container">
  25. <k-list :list="list" :params="search" :auto="false" ref="list">
  26. <template slot-scope="{ data }">
  27. <item :data="data" :statusOptions="statusOptions"></item>
  28. </template>
  29. </k-list>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import NavBar from '@/components/NavBar'
  35. // import Calendar from '@/components/Calendar';
  36. import { mapGetters } from 'vuex'
  37. import { deptTreeList } from '@/api/public'
  38. import { list } from '@/api/protection.js'
  39. import KList from '@/components/list/index.vue'
  40. import Item from './components/item.vue'
  41. export default {
  42. components: { NavBar, KList, Item },
  43. data() {
  44. return {
  45. options: [],
  46. search: {
  47. orgId: this.orgId,
  48. status: null,
  49. hour: null,
  50. key: null,
  51. updateTime: [],
  52. pageNum: 1,
  53. pageSize: 10
  54. },
  55. showOrg: false,
  56. selectedOrgName:null,
  57. statusOptions: [
  58. { value: null, text: '防区状态' },
  59. { value: '0', text: '撤防' },
  60. { value: '1', text: '布防' },
  61. { value: '2', text: '未知' }
  62. ],
  63. hourOptions: [
  64. { value: null, text: '上报时间' },
  65. { value: 1, text: '1小时内' },
  66. { value: 2, text: '2小时内' },
  67. { value: 3, text: '3小时内' },
  68. { value: 4, text: '4小时内' },
  69. { value: 8, text: '8小时内' },
  70. { value: 12, text: '12小时内' },
  71. { value: 24, text: '24小时内' },
  72. { value: 48, text: '48小时内' }
  73. ],
  74. // orgOptions: [
  75. // {
  76. // value: null,
  77. // text: ''
  78. // }
  79. // ],
  80. fieldNames: {
  81. text: 'name',
  82. value: 'id',
  83. children: 'children'
  84. }
  85. }
  86. },
  87. watch: {
  88. 'search.hour': {
  89. handler(v) {
  90. if (v) {
  91. this.search.updateTime = []
  92. this.search.updateTime[0] = (new Date().valueOf() - v * 60 * 60 * 1000).toLocaleString()
  93. this.search.updateTime[1] = new Date(2099, 1).toLocaleString()
  94. } else {
  95. this.search.updateTime = []
  96. }
  97. }
  98. }
  99. },
  100. created() {},
  101. mounted() {
  102. this.getTreeList()
  103. this.search.orgId = this.orgId
  104. // this.orgOptions[0].value = this.orgId
  105. // this.orgOptions[0].text = this.orgName
  106. this.selectedOrgName=this.orgName
  107. },
  108. computed: {
  109. ...mapGetters(['orgName', 'orgId'])
  110. },
  111. methods: {
  112. list,
  113. //获取机构树
  114. getTreeList() {
  115. deptTreeList(this.orgId).then(res => {
  116. this.options = res.data
  117. // this.orgInfo.orgId = this.orgId;
  118. // this.orgInfo.orgName = this.orgName;
  119. // console.log(res,'3333')
  120. })
  121. },
  122. onItemClick() {
  123. this.showOrg = true
  124. },
  125. //改变机构后将重新发起请求
  126. changeTree({ selectedOptions }) {
  127. // console.log(selectedOptions,'aaaaaa')
  128. // this.search.orgId = selectedOptions[selectedOptions.length-1].id;
  129. let option = selectedOptions[selectedOptions.length - 1]
  130. this.search.orgId = option.id
  131. this.selectedOrgName = option.name
  132. },
  133. onFinish({ selectedOptions }) {
  134. this.showOrg = false
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .protection_list {
  141. background-color: #fff;
  142. display: block;
  143. .container {
  144. // overflow: auto;
  145. // height: calc(100vh - 11rem);
  146. .k-content-repair {
  147. display: flex;
  148. flex-direction: column;
  149. justify-content: space-between;
  150. flex: 1;
  151. }
  152. }
  153. }
  154. // .form-box {
  155. // height: calc(100vh - 180px);
  156. // padding: 0 30px 50px 30px;
  157. // overflow: auto;
  158. // }
  159. // .radio-box {
  160. // height: 100px;
  161. // padding: 30px;
  162. // }
  163. // .org-name {
  164. // font-size: 30px;
  165. // line-height: 80px;
  166. // height: 80px;
  167. // text-align: center;
  168. // }
  169. </style>