index.vue 8.3 KB

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