index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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({type:'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">
  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">
  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" :cats="disasterCats" :levels="disasterLevels"></CreateDisaster>
  99. <CreateReservoir ref="reservoir" @success="getData" :cats="disasterCats" :levels="disasterLevels"></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. disasterLevels:[],
  121. disasterCats:[]
  122. }
  123. },
  124. onShow() {
  125. this.getData();
  126. this.init()
  127. },
  128. methods: {
  129. changeTab({currentIndex}){
  130. if (this.tabIdx !== currentIndex) {
  131. this.tabIdx = currentIndex
  132. this.getData()
  133. }
  134. },
  135. init(){
  136. if(!uni.getStorageSync('disasterLevels')){
  137. disasterApi.getDisasterLevelByList().then((res)=>{
  138. uni.setStorageSync('disasterLevels',res.data)
  139. this.disasterLevels=res.data
  140. })
  141. }else{
  142. this.disasterLevels=uni.getStorageSync('disasterLevels')
  143. }
  144. if(!uni.getStorageSync('disasterCats')){
  145. disasterApi.getDisasterCatByList().then((res)=>{
  146. uni.setStorageSync('disasterCats',res.data)
  147. this.disasterCats=res.data
  148. })
  149. }else{
  150. this.disasterCats=uni.getStorageSync('disasterCats')
  151. }
  152. },
  153. search(){
  154. this.getData()
  155. },
  156. getData(){
  157. const getDataList=this.tabIdx===0?disasterApi.getDisasterLocationByList:disasterApi.getReservoirDamByPage
  158. getDataList({keywords:this.keywords}).then((res)=>{
  159. this.items=res.data
  160. })
  161. },
  162. handle({type,item}){
  163. if(type==='detail'){
  164. this.$refs.detail.show(item)
  165. }else if(type==='del'){
  166. const deleteById=this.tabIdx===0?disasterApi.deleteDisasterLocationById:disasterApi.deleteReservoirDamById;
  167. const id=this.tabIdx===0?item.dlId:item.rdId
  168. uni.showModal({
  169. title: '提示',
  170. content: '是否确定删除',
  171. success: function (res) {
  172. if (res.confirm) {
  173. deleteBoundById(id).then(()=>{
  174. uni.showToast({
  175. title:'删除成功!',
  176. icon:'none'
  177. })
  178. self.getData()
  179. })
  180. }
  181. }
  182. });
  183. }else{
  184. if(this.tabIdx===0){
  185. this.$refs.disaster.show(type,item)
  186. }else{
  187. this.$refs.reservoir.show(type,item)
  188. }
  189. }
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .page-wrap{
  196. padding:0 20rpx;
  197. .pageTabs{
  198. background-color: #fff;
  199. }
  200. .head{
  201. margin-top: 20rpx;
  202. .handle{
  203. display: inline-block;
  204. // background-color: #007aff;
  205. color: #777777;
  206. text-align: center;
  207. padding:16rpx 20rpx;
  208. border-radius: 30rpx;
  209. // border: 1px solid #007aff;
  210. font-size: 28rpx;
  211. line-height: 1;
  212. box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  213. }
  214. .addbt{
  215. width: 100rpx;
  216. height: 100rpx;
  217. border-radius: 50%;
  218. color: #fff;
  219. background-color: rgba(64,158,255,0.6);
  220. box-shadow:0 0 10rpx rgba(0,0,0,0.6);
  221. position: fixed;
  222. right: 10rpx;
  223. bottom: 20%;
  224. z-index: 99;
  225. text-align: center;
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. .word{
  230. width: 80rpx;
  231. height: 80rpx;
  232. border-radius: 50%;
  233. margin: 5rpx auto;
  234. font-size: 28rpx;
  235. letter-spacing: 2px;
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. }
  240. }
  241. }
  242. .pageMain{
  243. margin-top: 20rpx;
  244. background-color: #f5f5f5;
  245. padding-bottom: 50rpx;
  246. .slot-button{
  247. width: 400rpx;
  248. height: 100%;
  249. display: flex;
  250. flex-direction: row;
  251. justify-content: center;
  252. align-items: center;
  253. color: #fff;
  254. padding-left: 10px;
  255. .bt{
  256. width: 50%;
  257. height: 100%;
  258. font-size: 30rpx;
  259. box-sizing: border-box;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. &.edit{
  264. background-color:#007aff;
  265. }
  266. &.del{
  267. background-color:#F56C6C;
  268. }
  269. &.detail{
  270. background-color: #e6a23c;
  271. }
  272. }
  273. }
  274. .item{
  275. color: #666;
  276. .title{
  277. display: flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. .name{
  281. font-size: 32rpx;
  282. color: #222222;
  283. line-height: 1;
  284. padding-bottom: 10rpx;
  285. text-overflow: ellipsis;
  286. overflow: hidden;
  287. white-space: nowrap;
  288. flex: 1;
  289. }
  290. .camera{
  291. width: 100rpx;
  292. text-align: right;
  293. flex-shrink: 0;
  294. }
  295. }
  296. image{
  297. &.icon{
  298. width: 30rpx;
  299. height: 30rpx;
  300. display: block;
  301. }
  302. }
  303. .item-row{
  304. display: flex;
  305. align-items: center;
  306. padding-top: 14rpx;
  307. &.space-between{
  308. justify-content: space-between;
  309. }
  310. }
  311. .icon-item{
  312. display: flex;
  313. align-items: center;
  314. .word{
  315. margin-left: 8rpx;
  316. font-size: 24rpx;
  317. }
  318. }
  319. }
  320. }
  321. }
  322. </style>