index.vue 8.2 KB

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