index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="page-wrap">
  3. <view class="head">
  4. <uni-card padding="0" margin="5px 0">
  5. <uni-search-bar @confirm="search" v-model="keywords" @clear="search"></uni-search-bar>
  6. </uni-card>
  7. <view class="addbt" @click="handle({type:'add'})">
  8. <view class="word"><uni-icons type="plusempty" size="30" color="#fff"></uni-icons></view>
  9. </view>
  10. </view>
  11. <view class="pageMain">
  12. <uni-swipe-action class="item-action-box">
  13. <uni-card padding="10px 0" margin="5px 0" v-for="(item,idx) in items" :key="item.entId">
  14. <uni-swipe-action-item class="item-action" :auto-close="true">
  15. <template v-slot:right>
  16. <view class="slot-button">
  17. <view class="bt edit" @click="handle({type:'edit',item})"><text class="slot-button-text">编辑</text></view>
  18. <view class="bt del" @click="handle({type:'del',item})"><text class="slot-button-text">删除</text></view>
  19. </view>
  20. </template>
  21. <view class="item" @click="handle({type:'detail',item})">
  22. <view class="title">
  23. <view class="name">{{item.dangerTitle}}</view>
  24. </view>
  25. <view class="item-row space-between">
  26. <uni-tag :text="item.dangerCatTitle" custom-style="background-color: #ecf5ff; border-color: #d9ecff; color: #409eff;"></uni-tag>
  27. <uni-tag :text="formatDangerLevel(item.dangerLevel)" type="success"></uni-tag>
  28. </view>
  29. <view class="item-row space-between">
  30. <view class="icon-item">
  31. <uni-icons type="location-filled" size="16" color="#999"></uni-icons>
  32. <text class="word">{{item.dangerLocation||'--'}}</text>
  33. </view>
  34. <uni-tag :inverted="true" :text="formatDangerStatus(item.status)" :type="item.status>0?'error':'warning'"></uni-tag>
  35. </view>
  36. <view class="bottom">
  37. <view class="icon-item">
  38. <image class="icon" src="/static/images/qiye.png" mode="widthFix"></image>
  39. <text class="word">{{item.entName}}</text>
  40. </view>
  41. <view class="icon-item">
  42. <image class="icon" src="/static/images/time.png" mode="widthFix"></image>
  43. <text class="word">{{item.submitTime}}</text>
  44. </view>
  45. <view class="icon-item">
  46. <image class="icon" src="/static/images/admin_icon.png" mode="widthFix"></image>
  47. <text class="word">{{item.groupName}}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </uni-swipe-action-item>
  52. </uni-card>
  53. </uni-swipe-action>
  54. </view>
  55. <Create ref="danger" @success="search"></Create>
  56. <Detail ref="detail"></Detail>
  57. </view>
  58. </template>
  59. <script>
  60. import dangerApi from '@/api/danger.js'
  61. import Create from './components/Create.vue'
  62. import Detail from './components/Detail.vue'
  63. export default {
  64. components:{
  65. Create,
  66. Detail
  67. },
  68. data() {
  69. return {
  70. items:[],
  71. page:1,
  72. limit:10,
  73. total:0,
  74. keywords: ""
  75. }
  76. },
  77. onShow() {
  78. this.getData();
  79. this.init()
  80. },
  81. methods: {
  82. init(){
  83. // if(!uni.getStorageSync('entCats')){
  84. // dangerApi.getCatByList().then((res)=>{
  85. // uni.setStorageSync('entCats',res.data)
  86. // })
  87. // }
  88. },
  89. search(){
  90. this.resetFilter();
  91. this.getData()
  92. },
  93. getData(){
  94. dangerApi.getByPage({
  95. page:this.page,
  96. limit:this.limit,
  97. keywords:this.keywords
  98. }).then((res)=>{
  99. this.items=this.items.concat(res.data)
  100. })
  101. },
  102. handle({type,item}){
  103. const self=this;
  104. if(type==='detail'){
  105. this.$refs.detail.show(item)
  106. }else if(type==='del'){
  107. uni.showModal({
  108. title: '提示',
  109. content: '是否确定删除',
  110. success: function (res) {
  111. if (res.confirm) {
  112. industryApi.deleteById(item.entId).then(()=>{
  113. uni.showToast({
  114. title:'删除成功!',
  115. icon:'none'
  116. })
  117. self.search()
  118. })
  119. }
  120. }
  121. });
  122. }else{
  123. this.$refs.industry.show({type,item})
  124. }
  125. },
  126. formatDangerLevel(val){
  127. let dangerLevelOptions=['末知','重大','较大','一般','较小'];
  128. return dangerLevelOptions[val]
  129. },
  130. formatDangerStatus(val){
  131. let status=['未整改','已整改'];
  132. return status[val]
  133. },
  134. resetFilter(){
  135. this.page = 1
  136. this.limit = 10
  137. this.total = 0
  138. this.items=[]
  139. }
  140. },
  141. onReachBottom() {
  142. if(this.total>this.size*this.page){
  143. this.page++
  144. this.getData()
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .page-wrap{
  151. padding:0 20rpx;
  152. .pageTabs{
  153. background-color: #fff;
  154. }
  155. .head{
  156. margin-top: 20rpx;
  157. .handle{
  158. display: inline-block;
  159. // background-color: #007aff;
  160. color: #777777;
  161. text-align: center;
  162. padding:16rpx 20rpx;
  163. border-radius: 30rpx;
  164. // border: 1px solid #007aff;
  165. font-size: 28rpx;
  166. line-height: 1;
  167. box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  168. }
  169. .addbt{
  170. width: 100rpx;
  171. height: 100rpx;
  172. border-radius: 50%;
  173. color: #fff;
  174. background-color: rgba(64,158,255,0.6);
  175. box-shadow:0 0 10rpx rgba(0,0,0,0.6);
  176. position: fixed;
  177. right: 10rpx;
  178. bottom: 20%;
  179. z-index: 99;
  180. text-align: center;
  181. display: flex;
  182. justify-content: center;
  183. align-items: center;
  184. .word{
  185. width: 80rpx;
  186. height: 80rpx;
  187. border-radius: 50%;
  188. margin: 5rpx auto;
  189. font-size: 28rpx;
  190. letter-spacing: 2px;
  191. display: flex;
  192. justify-content: center;
  193. align-items: center;
  194. }
  195. }
  196. }
  197. .pageMain{
  198. margin-top: 20rpx;
  199. background-color: #f5f5f5;
  200. padding-bottom: 50rpx;
  201. .slot-button{
  202. width: 400rpx;
  203. height: 100%;
  204. display: flex;
  205. flex-direction: row;
  206. justify-content: center;
  207. align-items: center;
  208. color: #fff;
  209. padding-left: 10px;
  210. .bt{
  211. width: 50%;
  212. height: 100%;
  213. font-size: 30rpx;
  214. box-sizing: border-box;
  215. display: flex;
  216. justify-content: center;
  217. align-items: center;
  218. &.edit{
  219. background-color:#007aff;
  220. }
  221. &.del{
  222. background-color:#F56C6C;
  223. }
  224. &.detail{
  225. background-color: #e6a23c;
  226. }
  227. }
  228. }
  229. .item{
  230. color: #666;
  231. .name{
  232. font-size: 32rpx;
  233. color: #222222;
  234. line-height: 1;
  235. padding-bottom: 10rpx;
  236. }
  237. image{
  238. &.icon{
  239. width: 30rpx;
  240. height: 30rpx;
  241. display: block;
  242. }
  243. }
  244. .item-row{
  245. display: flex;
  246. align-items: center;
  247. padding-top: 14rpx;
  248. &.space-between{
  249. justify-content: space-between;
  250. }
  251. }
  252. .icon-item{
  253. display: flex;
  254. align-items: center;
  255. .word{
  256. margin-left: 8rpx;
  257. font-size: 24rpx;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </style>