index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 :inverted="true" :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 :text="formatDangerStatus(item.status)" :type="item.status>0?'primary':'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 industryApi from '@/api/industry.js'
  61. import dangerApi from '@/api/danger.js'
  62. import Create from './components/Create.vue'
  63. import Detail from './components/Detail.vue'
  64. export default {
  65. components:{
  66. Create,
  67. Detail
  68. },
  69. data() {
  70. return {
  71. items:[],
  72. page:1,
  73. limit:10,
  74. total:0,
  75. keywords: ""
  76. }
  77. },
  78. onShow() {
  79. this.getData();
  80. this.init()
  81. },
  82. methods: {
  83. init(){
  84. if(!uni.getStorageSync('dangerCats')){
  85. industryApi.getByList().then((res)=>{
  86. uni.setStorageSync('entCats',res.data)
  87. })
  88. dangerApi.getCatByList().then((res)=>{
  89. uni.setStorageSync('dangerCats',res.data)
  90. })
  91. }
  92. },
  93. search(){
  94. this.resetFilter();
  95. this.getData()
  96. },
  97. getData(){
  98. dangerApi.getByPage({
  99. page:this.page,
  100. limit:this.limit,
  101. keywords:this.keywords
  102. }).then((res)=>{
  103. this.items=this.items.concat(res.data)
  104. })
  105. },
  106. handle({type,item}){
  107. const self=this;
  108. if(type==='detail'){
  109. this.$refs.detail.show(item)
  110. }else if(type==='del'){
  111. uni.showModal({
  112. title: '提示',
  113. content: '是否确定删除',
  114. success: function (res) {
  115. if (res.confirm) {
  116. dangerApi.deleteById(item.dangerId).then(()=>{
  117. uni.showToast({
  118. title:'删除成功!',
  119. icon:'none'
  120. })
  121. self.search()
  122. })
  123. }
  124. }
  125. });
  126. }else{
  127. this.$refs.danger.show({type,item})
  128. }
  129. },
  130. formatDangerLevel(val){
  131. let dangerLevelOptions=['末知','重大','较大','一般','较小'];
  132. return dangerLevelOptions[val]
  133. },
  134. formatDangerStatus(val){
  135. let status=['未整改','已整改'];
  136. return status[val]
  137. },
  138. resetFilter(){
  139. this.page = 1
  140. this.limit = 10
  141. this.total = 0
  142. this.items=[]
  143. }
  144. },
  145. onReachBottom() {
  146. if(this.total>this.size*this.page){
  147. this.page++
  148. this.getData()
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .page-wrap{
  155. padding:0 20rpx;
  156. .pageTabs{
  157. background-color: #fff;
  158. }
  159. .head{
  160. margin-top: 20rpx;
  161. .handle{
  162. display: inline-block;
  163. // background-color: #007aff;
  164. color: #777777;
  165. text-align: center;
  166. padding:16rpx 20rpx;
  167. border-radius: 30rpx;
  168. // border: 1px solid #007aff;
  169. font-size: 28rpx;
  170. line-height: 1;
  171. box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  172. }
  173. .addbt{
  174. width: 100rpx;
  175. height: 100rpx;
  176. border-radius: 50%;
  177. color: #fff;
  178. background-color: rgba(64,158,255,0.6);
  179. box-shadow:0 0 10rpx rgba(0,0,0,0.6);
  180. position: fixed;
  181. right: 10rpx;
  182. bottom: 20%;
  183. z-index: 99;
  184. text-align: center;
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. .word{
  189. width: 80rpx;
  190. height: 80rpx;
  191. border-radius: 50%;
  192. margin: 5rpx auto;
  193. font-size: 28rpx;
  194. letter-spacing: 2px;
  195. display: flex;
  196. justify-content: center;
  197. align-items: center;
  198. }
  199. }
  200. }
  201. .pageMain{
  202. margin-top: 20rpx;
  203. background-color: #f5f5f5;
  204. padding-bottom: 50rpx;
  205. .slot-button{
  206. width: 400rpx;
  207. height: 100%;
  208. display: flex;
  209. flex-direction: row;
  210. justify-content: center;
  211. align-items: center;
  212. color: #fff;
  213. padding-left: 10px;
  214. .bt{
  215. width: 50%;
  216. height: 100%;
  217. font-size: 30rpx;
  218. box-sizing: border-box;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. &.edit{
  223. background-color:#007aff;
  224. }
  225. &.del{
  226. background-color:#F56C6C;
  227. }
  228. &.detail{
  229. background-color: #e6a23c;
  230. }
  231. }
  232. }
  233. .item{
  234. color: #666;
  235. .name{
  236. font-size: 32rpx;
  237. color: #222222;
  238. line-height: 1;
  239. padding-bottom: 10rpx;
  240. }
  241. image{
  242. &.icon{
  243. width: 30rpx;
  244. height: 30rpx;
  245. display: block;
  246. }
  247. }
  248. .item-row{
  249. display: flex;
  250. align-items: center;
  251. padding-top: 14rpx;
  252. &.space-between{
  253. justify-content: space-between;
  254. }
  255. }
  256. .icon-item{
  257. display: flex;
  258. align-items: center;
  259. .word{
  260. margin-left: 8rpx;
  261. font-size: 24rpx;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>