index.vue 9.6 KB

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