index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="page-wrap">
  3. <view class="pageTabs">
  4. <uni-segmented-control :current="tabIdx" :values="tabs" style-type="text" active-color="#007aff" @clickItem="changeTab" />
  5. </view>
  6. <view class="head">
  7. <uni-card padding="0" margin="5px 0">
  8. <uni-search-bar @confirm="search" v-model="keywords" @clear="search"></uni-search-bar>
  9. </uni-card>
  10. <view class="addbt" @click="handle('create')">
  11. <view class="word"><uni-icons type="plusempty" size="30" color="#fff"></uni-icons></view>
  12. </view>
  13. </view>
  14. <view class="pageMain">
  15. <uni-swipe-action class="item-action-box" v-if="tabIdx===0">
  16. <uni-card padding="10px 0" margin="5px 0" v-for="(item,idx) in items" :key="item.dlId">
  17. <uni-swipe-action-item class="item-action" :auto-close="true">
  18. <template v-slot:right>
  19. <view class="slot-button">
  20. <view class="bt edit" @click="handle({type:'edit',item})"><text class="slot-button-text">编辑</text></view>
  21. <view class="bt del" @click="handle({type:'del',item})"><text class="slot-button-text">删除</text></view>
  22. </view>
  23. </template>
  24. <view class="item" @click="handle({type:'detail',item})">
  25. <view class="title">
  26. <view class="name">{{item.dlName}}</view>
  27. <view class="camera" @click.stop="showCamera">
  28. <uni-icons v-if='item.cameraNum>0' type="videocam-filled" size="20" color="#007aff" ></uni-icons>
  29. </view>
  30. </view>
  31. <view class="item-row space-between">
  32. <uni-tag :text="item.disasterLevelTitle" custom-style="background-color: #ecf5ff; border-color: #d9ecff; color: #409eff;"></uni-tag>
  33. <uni-tag :text="item.disasterCatTitle" type="warning"></uni-tag>
  34. </view>
  35. <view class="bottom">
  36. <view class="item-row space-between">
  37. <view class="icon-item">
  38. <uni-icons type="person-filled" size="15" color="#999"></uni-icons>
  39. <text class="word">{{item.dlPeopleNum}}</text>
  40. </view>
  41. <view class="icon-item">
  42. <uni-icons type="home-filled" size="15" color="#999"></uni-icons>
  43. <text class="word">{{item.dlHouseNum}}</text>
  44. </view>
  45. </view>
  46. <view class="icon-item">
  47. <image class="icon" src="/static/images/admin_icon.png" mode="widthFix"></image>
  48. <text class="word">{{item.groupName}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </uni-swipe-action-item>
  53. </uni-card>
  54. </uni-swipe-action>
  55. <uni-swipe-action class="item-action-box" v-if="tabIdx===1">
  56. <uni-card padding="10px 0" margin="5px 0" v-for="(item,idx) in items" :key="item.rdId">
  57. <uni-swipe-action-item class="item-action" :auto-close="true">
  58. <template v-slot:right>
  59. <view class="slot-button">
  60. <view class="bt edit" @click="handle({type:'edit',item})"><text class="slot-button-text">编辑</text></view>
  61. <view class="bt del" @click="handle({type:'del',item})"><text class="slot-button-text">删除</text></view>
  62. </view>
  63. </template>
  64. <view class="item" @click="handle({type:'detail',item})">
  65. <view class="title">
  66. <view class="name">{{item.rdName}}</view>
  67. <view class="camera" @click.stop="showCamera">
  68. <uni-icons v-if='item.cameraNum>0' type="videocam-filled" size="20" color="#007aff" ></uni-icons>
  69. </view>
  70. </view>
  71. <view class="item-row space-between">
  72. <view class="icon-item">
  73. <uni-icons type="location-filled" size="15" color="#999"></uni-icons>
  74. <text class="word">{{item.rdAddress}}</text>
  75. </view>
  76. </view>
  77. <view class="bottom">
  78. <view class="item-row space-between">
  79. <view class="icon-item">
  80. <uni-icons type="person-filled" size="15" color="#999"></uni-icons>
  81. <text class="word">{{item.respName}}</text>
  82. </view>
  83. <view class="icon-item">
  84. <uni-icons type="phone-filled" size="15" color="#999"></uni-icons>
  85. <text class="word">{{item.respPhone}}</text>
  86. </view>
  87. </view>
  88. <view class="icon-item">
  89. <image class="icon" src="/static/images/admin_icon.png" mode="widthFix"></image>
  90. <text class="word">{{item.groupName}}</text>
  91. </view>
  92. </view>
  93. </view>
  94. </uni-swipe-action-item>
  95. </uni-card>
  96. </uni-swipe-action>
  97. </view>
  98. <CreateDisaster ref="disaster" @success="getData"></CreateDisaster>
  99. <CreateReservoir ref="reservoir" @success="getData"></CreateReservoir>
  100. <Detail ref="detail" :type="tabIdx===0?'dl':'rd'" ></Detail>
  101. </view>
  102. </template>
  103. <script>
  104. import disasterApi from '@/api/disaster.js'
  105. import CreateDisaster from './components/CreateDisaster.vue'
  106. import CreateReservoir from './components/CreateReservoir.vue'
  107. import Detail from './components/Detail.vue'
  108. export default {
  109. components:{
  110. CreateDisaster,
  111. CreateReservoir,
  112. Detail
  113. },
  114. data() {
  115. return {
  116. tabIdx:0,
  117. tabs:['地质灾害点','水库淤堤坝'],
  118. items:[],
  119. keywords: ""
  120. }
  121. },
  122. onShow() {
  123. this.getData();
  124. this.init()
  125. },
  126. methods: {
  127. changeTab({currentIndex}){
  128. if (this.tabIdx !== currentIndex) {
  129. this.tabIdx = currentIndex
  130. this.getData()
  131. }
  132. },
  133. init(){
  134. if(!uni.getStorageSync('disasterLevels')){
  135. disasterApi.getDisasterLevelByList().then((res)=>{
  136. uni.setStorageSync('disasterLevels',res.data)
  137. })
  138. disasterApi.getDisasterCatByList().then((res)=>{
  139. uni.setStorageSync('disasterCats',res.data)
  140. })
  141. }
  142. },
  143. search(){
  144. this.getData()
  145. },
  146. getData(){
  147. const getDataList=this.tabIdx===0?disasterApi.getDisasterLocationByList:disasterApi.getReservoirDamByPage
  148. getDataList({keywords:this.keywords}).then((res)=>{
  149. this.items=res.data
  150. })
  151. },
  152. showCamera(item){
  153. },
  154. handle({type,item}){
  155. if(type==='detail'){
  156. this.$refs.detail.show(item)
  157. }else if(type==='del'){
  158. const deleteById=this.tabIdx===0?disasterApi.deleteDisasterLocationById:disasterApi.deleteReservoirDamById;
  159. const id=this.tabIdx===0?item.dlId:item.rdId
  160. uni.showModal({
  161. title: '提示',
  162. content: '是否确定删除',
  163. success: function (res) {
  164. if (res.confirm) {
  165. deleteBoundById(id).then(()=>{
  166. uni.showToast({
  167. title:'删除成功!',
  168. icon:'none'
  169. })
  170. self.getData()
  171. })
  172. }
  173. }
  174. });
  175. }else{
  176. if(this.tabIdx===0){
  177. this.$refs.disaster.show(type,item)
  178. }else{
  179. this.$refs.reservoir.show(type,item)
  180. }
  181. }
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .page-wrap{
  188. padding:0 20rpx;
  189. .pageTabs{
  190. background-color: #fff;
  191. }
  192. .head{
  193. margin-top: 20rpx;
  194. .handle{
  195. display: inline-block;
  196. // background-color: #007aff;
  197. color: #777777;
  198. text-align: center;
  199. padding:16rpx 20rpx;
  200. border-radius: 30rpx;
  201. // border: 1px solid #007aff;
  202. font-size: 28rpx;
  203. line-height: 1;
  204. box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  205. }
  206. .addbt{
  207. width: 100rpx;
  208. height: 100rpx;
  209. border-radius: 50%;
  210. color: #fff;
  211. background-color: rgba(64,158,255,0.6);
  212. box-shadow:0 0 10rpx rgba(0,0,0,0.6);
  213. position: fixed;
  214. right: 10rpx;
  215. bottom: 20%;
  216. z-index: 99;
  217. text-align: center;
  218. display: flex;
  219. justify-content: center;
  220. align-items: center;
  221. .word{
  222. width: 80rpx;
  223. height: 80rpx;
  224. border-radius: 50%;
  225. margin: 5rpx auto;
  226. font-size: 28rpx;
  227. letter-spacing: 2px;
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. }
  232. }
  233. }
  234. .pageMain{
  235. margin-top: 20rpx;
  236. background-color: #f5f5f5;
  237. padding-bottom: 50rpx;
  238. .slot-button{
  239. width: 400rpx;
  240. height: 100%;
  241. display: flex;
  242. flex-direction: row;
  243. justify-content: center;
  244. align-items: center;
  245. color: #fff;
  246. padding-left: 10px;
  247. .bt{
  248. width: 50%;
  249. height: 100%;
  250. font-size: 30rpx;
  251. box-sizing: border-box;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. &.edit{
  256. background-color:#007aff;
  257. }
  258. &.del{
  259. background-color:#F56C6C;
  260. }
  261. &.detail{
  262. background-color: #e6a23c;
  263. }
  264. }
  265. }
  266. .item{
  267. color: #666;
  268. .title{
  269. display: flex;
  270. justify-content: space-between;
  271. align-items: center;
  272. .name{
  273. font-size: 32rpx;
  274. color: #222222;
  275. line-height: 1;
  276. padding-bottom: 10rpx;
  277. text-overflow: ellipsis;
  278. overflow: hidden;
  279. white-space: nowrap;
  280. flex: 1;
  281. }
  282. .camera{
  283. width: 100rpx;
  284. text-align: right;
  285. flex-shrink: 0;
  286. }
  287. }
  288. image{
  289. &.icon{
  290. width: 30rpx;
  291. height: 30rpx;
  292. display: block;
  293. }
  294. }
  295. .item-row{
  296. display: flex;
  297. align-items: center;
  298. padding-top: 14rpx;
  299. &.space-between{
  300. justify-content: space-between;
  301. }
  302. }
  303. .icon-item{
  304. display: flex;
  305. align-items: center;
  306. .word{
  307. margin-left: 8rpx;
  308. font-size: 24rpx;
  309. }
  310. }
  311. }
  312. }
  313. }
  314. </style>