index.vue 4.8 KB

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