index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="content">
  3. <u-navbar title="首页" title-color="#ffffff" :background="{backgroundColor: mainColor}" :is-back="false" :border-bottom="false"></u-navbar>
  4. <view class="index-bg"></view>
  5. <u-card :show-foot="false" padding="0px" margin="20rpx 20rpx" borderRadius="20" box-shadow="0 0 4px rgba(0, 0, 0, 0.2)"
  6. class="card-box">
  7. <view slot="head" style="padding: 12px 0;">
  8. <u-cell-group :border="false">
  9. <u-cell-item :border-bottom="false" :arrow="false" :title-style="{...filterStyle, fontWeight: 'bold'}">
  10. <view slot="title">
  11. <u-icon name="home-fill"></u-icon>
  12. {{tenantForm.label}}
  13. </view>
  14. </u-cell-item>
  15. <u-cell-item :border-bottom="false" :arrow="false" :title-style="filterStyle" @click="assetsShow = true">
  16. <view slot="title">
  17. {{assetsForm.label}}
  18. <u-icon :name="assetsShow ? 'arrow-up' : 'arrow-down'"></u-icon>
  19. </view>
  20. </u-cell-item>
  21. </u-cell-group>
  22. </view>
  23. <view slot="body">
  24. <u-grid :col="3" :border="false">
  25. <u-grid-item @click="goToRectifyInfo">
  26. <view class="handle-image" style="background: #a2db99;">
  27. <u-image :src="sectionIcon1" mode="aspectFit" width="80rpx" height="80rpx"></u-image>
  28. </view>
  29. <view class="handle-text">隐患整改清单</view>
  30. </u-grid-item>
  31. <u-grid-item @click="goToAdviseForm">
  32. <view class="handle-image" style="background: #feab27;">
  33. <u-image :src="sectionIcon2" mode="aspectFit" width="80rpx" height="80rpx"></u-image>
  34. </view>
  35. <view class="handle-text">建议反馈</view>
  36. </u-grid-item>
  37. <u-grid-item @click="goToHistoryList">
  38. <view class="handle-image" style="background: #5b78bb;">
  39. <u-image :src="sectionIcon3" mode="aspectFit" width="80rpx" height="80rpx"></u-image>
  40. </view>
  41. <view class="handle-text">历史清单</view>
  42. </u-grid-item>
  43. </u-grid>
  44. </view>
  45. </u-card>
  46. <u-action-sheet :list="assetsList" v-model="assetsShow" @click="setAssets"></u-action-sheet>
  47. <u-top-tips ref="uTips" :navbar-height="statusBarHeight + navbarHeight"></u-top-tips>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. mapGetters
  53. } from 'vuex'
  54. const NET = require('@/utils/request')
  55. const API = require('@/config/api')
  56. export default {
  57. computed: {
  58. ...mapGetters([
  59. 'mainColor',
  60. 'handleCustomStyle',
  61. ])
  62. },
  63. data() {
  64. return {
  65. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  66. navbarHeight: 44,
  67. sectionIcon1: API.getServerImg + '4.png',
  68. sectionIcon2: API.getServerImg + '3.png',
  69. sectionIcon3: API.getServerImg + '5.png',
  70. filterStyle: {
  71. fontSize: '13px',
  72. color: '#333333'
  73. },
  74. tenantForm: {
  75. areaId: '',
  76. label: '',
  77. value: ''
  78. },
  79. assetsShow: false,
  80. assetsForm: {
  81. label: '',
  82. value: '',
  83. tenantId: ''
  84. },
  85. assetsList: []
  86. }
  87. },
  88. onLoad() {
  89. if (uni.getStorageSync('userData')) {
  90. this.initialize()
  91. }
  92. },
  93. onShow() {
  94. if (!uni.getStorageSync('token')) {
  95. uni.navigateTo({
  96. url: '/pages/login/index'
  97. });
  98. }
  99. },
  100. methods: {
  101. // 获取初始化数据
  102. initialize() {
  103. NET.request(API.getTenantDetail + uni.getStorageSync('userData').userId, {}, 'GET').then(res => {
  104. this.tenantForm = {
  105. areaId: res.data.areaId,
  106. label: res.data.tenantName,
  107. value: res.data.tenantId
  108. }
  109. this.assetsList = res.data.assetList.map(site => {
  110. return {
  111. text: site.assetName,
  112. value: site.assetId,
  113. tenantId: site.tenantId,
  114. }
  115. })
  116. this.setAssets(0)
  117. }).catch(error => {
  118. this.$refs.uTips.show({
  119. title: error.message,
  120. type: 'warning',
  121. })
  122. })
  123. },
  124. // 选择资产
  125. setAssets(index) {
  126. this.assetsForm.label = this.assetsList[index].text
  127. this.assetsForm.value = this.assetsList[index].value
  128. this.assetsForm.tenantId = this.assetsList[index].tenantId
  129. },
  130. // 跳转隐患整改清单
  131. goToRectifyInfo() {
  132. NET.request(API.getHistoryList, {
  133. assetId: this.assetsForm.value,
  134. tenantId: this.tenantForm.value,
  135. pageIndex: 1,
  136. pageSize: 1,
  137. }, 'GET').then(res => {
  138. if (res.data.records.length) {
  139. uni.navigateTo({
  140. url: '/pagesHandle/rectifyInfo?taskId=' + res.data.records[0].taskId + '&tenantId=' + this.assetsForm.tenantId +
  141. '&assetId=' + this.assetsForm.value + '&signState=' + res.data.records[0].signState
  142. });
  143. } else {
  144. this.$refs.uTips.show({
  145. title: '暂无隐患整改清单',
  146. type: 'warning',
  147. })
  148. }
  149. }).catch(error => {
  150. this.$refs.uTips.show({
  151. title: error.message,
  152. type: 'warning',
  153. })
  154. })
  155. },
  156. // 跳转建议反馈
  157. goToAdviseForm() {
  158. uni.navigateTo({
  159. url: '/pagesHandle/adviseForm?areaId=' + this.tenantForm.areaId + '&tenantId=' + this.tenantForm.value +
  160. '&tenantName=' + this.tenantForm.label + '&assetId=' + this.assetsForm.value + '&assetName=' + this.assetsForm.label
  161. });
  162. },
  163. // 跳转历史清单
  164. goToHistoryList() {
  165. uni.navigateTo({
  166. url: '/pagesHandle/historyList?tenantId=' + this.assetsForm.tenantId + '&assetId=' + this.assetsForm.value
  167. });
  168. },
  169. },
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. @import "@/static/css/themes.scss";
  174. .content {
  175. width: 100%;
  176. height: 100vh;
  177. float: left;
  178. background-color: $pageBgColor;
  179. position: relative;
  180. .index-bg {
  181. width: 100%;
  182. height: 50px;
  183. background-color: $mainColor;
  184. position: absolute;
  185. }
  186. .handle-image {
  187. width: 60px;
  188. height: 60px;
  189. border-radius: 8px;
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. }
  194. .handle-text {
  195. line-height: 40px;
  196. font-size: 12px;
  197. padding-bottom: 2px;
  198. }
  199. /deep/.u-cell {
  200. padding: 8rpx 32rpx;
  201. }
  202. /deep/.u-icon {
  203. margin: 0 3px;
  204. font-size: 14px;
  205. color: $mainColor;
  206. }
  207. }
  208. </style>