index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="page-wrap">
  3. <view class="search-wrap">
  4. <uni-search-bar class="search" @confirm="search" v-model="keywords" @clear="search"></uni-search-bar>
  5. <uni-data-select class="select" v-model="reportingTypeId" :localdata="types" placeholder="请选择类别" @change="search"></uni-data-select>
  6. </view>
  7. <view class="addbt" @click="handle({type:'add'})">
  8. <view class="word">事件上报</view>
  9. </view>
  10. <view class="pageMain">
  11. <uni-swipe-action class="item-action-box">
  12. <uni-card padding="10px 0" margin="5px 0" v-for="item in items" :key="item.reportingId">
  13. <uni-swipe-action-item class="item-action" :auto-close="true">
  14. <template v-slot:right>
  15. <view class="slot-button">
  16. <view class="bt edit" @click="handle({type:'edit',item})"><text class="slot-button-text">编辑</text></view>
  17. <view class="bt del" @click="handle({type:'del',item})"><text class="slot-button-text">删除</text></view>
  18. </view>
  19. </template>
  20. <view class="item" @click="handle({type:'detail',item})">
  21. <view class="title">
  22. <view class="name">{{item.reportingSubject}}</view>
  23. </view>
  24. <view class="tagbox">
  25. <uni-tag :text="item.reportingTypeTitle" custom-style="background-color: #ecf5ff; border-color: #d9ecff; color: #409eff;"></uni-tag>
  26. </view>
  27. <view class="icon-item">
  28. <image class="icon" src="/static/images/time.png" mode="widthFix"></image>
  29. <text class="word">{{item.reportingTime}}</text>
  30. </view>
  31. <view class="icon-item">
  32. <image class="icon" src="/static/images/admin_icon.png" mode="widthFix"></image>
  33. <text class="word">{{item.reportingGroupName}}</text>
  34. </view>
  35. </view>
  36. </uni-swipe-action-item>
  37. </uni-card>
  38. </uni-swipe-action>
  39. </view>
  40. <Detail ref="detail"></Detail>
  41. <Edit ref="edit" @success="search"></Edit>
  42. <Report ref="report" @success="search"></Report>
  43. </view>
  44. </template>
  45. <script>
  46. import reportingApi from '@/api/reporting.js'
  47. import Report from './components/Report.vue'
  48. import Detail from './components/Detail.vue'
  49. import Edit from './components/Edit.vue'
  50. export default {
  51. components:{
  52. Report,
  53. Detail,
  54. Edit
  55. },
  56. computed:{
  57. types(){
  58. return this.reportingTypes.map(item=>{
  59. return{
  60. ...item,
  61. value:item.reportingTypeId,
  62. text:item.reportingTypeTitle
  63. }
  64. })
  65. }
  66. },
  67. data() {
  68. return {
  69. items:[],
  70. reportingTypes:uni.getStorageSync('reportingTypes')||[],
  71. page:1,
  72. limit:10,
  73. total:0,
  74. keywords:"" ,
  75. reportingTypeId:undefined
  76. }
  77. },
  78. onShow() {
  79. this.init()
  80. this.getData()
  81. },
  82. methods: {
  83. init(){
  84. if(!uni.getStorageSync('reportingTypes')){
  85. reportingApi.getTypeByList().then((res)=>{
  86. uni.setStorageSync('reportingTypes',res.data)
  87. this.reportingTypes=res.data
  88. })
  89. }
  90. },
  91. search(){
  92. this.resetFilter()
  93. this.getData()
  94. },
  95. getData(){
  96. const items=JSON.parse(JSON.stringify(this.items))
  97. let params={
  98. page:this.page,
  99. limit:this.limit,
  100. keywords:this.keywords,
  101. }
  102. if(this.reportingTypeId){params.reportingTypeId=this.reportingTypeId}
  103. reportingApi.getByPage(params).then((res)=>{
  104. this.items=items.concat(res.data)
  105. this.total=res.total
  106. })
  107. },
  108. handle({type,item}){
  109. const self=this;
  110. if(type==='del'){
  111. uni.showModal({
  112. title: '提示',
  113. content: '是否确定删除',
  114. success: function (res) {
  115. if (res.confirm) {
  116. reportingApi.deleteById(item.reportingId).then(()=>{
  117. uni.showToast({
  118. title:'删除成功!',
  119. icon:'none'
  120. })
  121. self.resetFilter()
  122. self.getData()
  123. })
  124. }
  125. }
  126. });
  127. }else{
  128. if(type==='detail'){
  129. this.$refs.detail.show(item)
  130. }
  131. if(type==='edit'){
  132. this.$refs.edit.show({type:"edit",item})
  133. }
  134. if(type==='add'){
  135. this.$refs.report.show()
  136. }
  137. }
  138. },
  139. resetFilter(){
  140. this.page = 1
  141. this.limit = 10
  142. this.total = 0
  143. this.items=[]
  144. }
  145. },
  146. onReachBottom() {
  147. if(this.total>this.limit*this.page){
  148. this.page++
  149. this.getData()
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .page-wrap{
  156. padding:0 20rpx;
  157. .search-wrap{
  158. margin: 5px 0;
  159. padding: 0 5px;
  160. box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.08);
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. flex-wrap: wrap;
  165. background-color: #fff;
  166. .search{
  167. flex: 1;
  168. }
  169. .select{
  170. width: 240rpx;
  171. margin-top: 10rpx;
  172. flex-shrink: 0;
  173. margin-left: 10rpx;
  174. }
  175. }
  176. .addbt{
  177. width: 100rpx;
  178. height: 100rpx;
  179. border-radius: 50%;
  180. color: #fff;
  181. background-color: rgba(64,158,255,0.7);
  182. box-shadow:0 0 10rpx rgba(0,0,0,0.4);
  183. position: fixed;
  184. right: 10rpx;
  185. bottom: 20%;
  186. z-index: 99;
  187. text-align: center;
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. .word{
  192. width: 80rpx;
  193. height: 80rpx;
  194. border-radius: 50%;
  195. margin: 5rpx auto;
  196. font-size: 28rpx;
  197. letter-spacing: 2px;
  198. }
  199. }
  200. .pageMain{
  201. margin-top: 20rpx;
  202. background-color: #f5f5f5;
  203. padding-bottom: 50rpx;
  204. .item{
  205. .title{
  206. display: flex;
  207. justify-content: space-between;
  208. align-items: center;
  209. .name{
  210. font-size: 36rpx;
  211. color: #222222;
  212. font-weight: 500;
  213. }
  214. .num{
  215. font-size: 32rpx;
  216. color: #424242;
  217. }
  218. }
  219. .tagbox{
  220. font-size: 24rpx;
  221. color: #666666;
  222. padding: 14rpx 0;
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. }
  227. .location{
  228. display: flex;
  229. align-items: center;
  230. }
  231. .bottom{
  232. .time{
  233. font-size: 24rpx;
  234. color: #666666;
  235. }
  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. .slot-button{
  262. width: 400rpx;
  263. height: 100%;
  264. display: flex;
  265. flex-direction: row;
  266. justify-content: center;
  267. align-items: center;
  268. color: #fff;
  269. padding-left: 10px;
  270. .bt{
  271. width: 50%;
  272. height: 100%;
  273. font-size: 30rpx;
  274. box-sizing: border-box;
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. &.edit{
  279. background-color:#007aff;
  280. }
  281. &.del{
  282. background-color:#F56C6C;
  283. }
  284. &.detail{
  285. background-color: #e6a23c;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. </style>