homeConfigurationSlot.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <!--
  2. 首页按钮匹配组件
  3. <homeConfigurationSlot v-if="homeConfigData[0]" :homeConfig="homeConfigData[0]"></homeConfigurationSlot>
  4. <homeConfigurationSlot v-if="homeConfigData[1]" :homeConfig="homeConfigData[1]"></homeConfigurationSlot>
  5. <homeConfigurationSlot v-if="homeConfigData[2]" :homeConfig="homeConfigData[2]"></homeConfigurationSlot>
  6. <homeConfigurationSlot v-if="homeConfigData[3]" :homeConfig="homeConfigData[3]"></homeConfigurationSlot>
  7. import { homeConfigurationSlot } from '@/component/homeConfigurationSlot'
  8. import { getHomeConfig } from '@/utils/homeConfig.js'
  9. components: {
  10. homeConfigurationSlot,
  11. },
  12. homeConfigData: [],
  13. async systemAppletLayoutSelect() {
  14. const {data} = await systemAppletLayoutSelect({module:'home'})
  15. if(data.code == 200){
  16. let list = JSON.parse(JSON.stringify(data.data))
  17. for(let i=0;i<list.length;i++){
  18. list[i].layout = JSON.parse(list[i].layout);
  19. }
  20. this.$set(this,'homeConfigData',getHomeConfig(list));
  21. }
  22. },
  23. -->
  24. <template>
  25. <view class="homeConfigurationSlot">
  26. <!-- 小型按钮模块 -->
  27. <view class="min-icon-button-box" v-if="homeConfig.type == 'minBox'">
  28. <permissionsSlot v-for="(item,index) in homeConfig.layout" :key="index" :hasPermi="item.limits">
  29. <view class="min-button-box" @click="buttonClick(item)">
  30. <img :src="item.img">
  31. <view>{{item.name}}</view>
  32. </view>
  33. </permissionsSlot>
  34. </view>
  35. <!-- 大型按钮模块 -->
  36. <view class="big-icon-button-box" v-if="homeConfig.type == 'bigBox'">
  37. <permissionsSlot class="imgBox" v-for="(item,index) in homeConfig.layout" :key="index"
  38. :hasPermi="item.limits">
  39. <img :src="item.img" @click="buttonClick(item)">
  40. </permissionsSlot>
  41. </view>
  42. <!-- 三格按钮 -->
  43. <view class="three-big-icon-button-box" v-if="homeConfig.type == 'threeBox'">
  44. <permissionsSlot class="imgBox" v-for="(item,index) in homeConfig.layout" :key="index"
  45. :hasPermi="item.limits">
  46. <img v-if="index<3" :src="item.img" @click="buttonClick(item)">
  47. </permissionsSlot>
  48. </view>
  49. <!-- 条型按钮 -->
  50. <view v-if="homeConfig.type == 'stripBox'">
  51. <permissionsSlot v-for="(item,index) in homeConfig.layout" :key="index" :hasPermi="item.limits">
  52. <view class="grading">
  53. <img class="grading_l" :src="item.img" />
  54. <view class="grading_c">{{item.name}}</view>
  55. <view class="grading_r" v-if="item.route === 'grading'" @click="buttonClick(item)">
  56. {{gradingCount>0?gradingCount+'项工作待完成':''}}
  57. <img src="@/images/basicsModules/icon_wdwg_gd.png" />
  58. </view>
  59. </view>
  60. </permissionsSlot>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. outSubjectPhoto,
  67. gradingControl
  68. } from '@/api/basicsModules/index.js'
  69. import {} from '@/api/safetyExamine/index.js'
  70. export default {
  71. name: "homeConfigurationSlot",
  72. props: {
  73. homeConfig: {},
  74. },
  75. data() {
  76. return {
  77. gradingCount: 0, //分级管控未完成总数
  78. }
  79. },
  80. created() {
  81. },
  82. mounted() {
  83. this.initializeData();
  84. },
  85. methods: {
  86. //初始化
  87. initializeData() {
  88. let self = this;
  89. for (let i = 0; i < self.homeConfig.layout.length; i++) {
  90. //分级管控
  91. if (self.homeConfig.layout[i].route === 'grading') {
  92. self.getGrading();
  93. }
  94. }
  95. },
  96. //按钮点击事件
  97. buttonClick(item) {
  98. if (item.buttonType === 'page') {//随手拍
  99. if (item.route === 'snapshotManage') {//安全检查
  100. uni.navigateTo({
  101. url: item.routeUrl,
  102. });
  103. }
  104. if (item.route === 'safetyExamine') {//安全检查
  105. uni.navigateTo({
  106. url: item.routeUrl,
  107. });
  108. //this.getGentleIdentifier(item.routeUrl)
  109. }
  110. if (item.route === 'leaveInspection') {//离开检查
  111. uni.navigateTo({
  112. url: item.routeUrl,
  113. });
  114. //this.outSubjectPhoto(item.routeUrl);
  115. }
  116. if (item.route === 'accessQualification') {//准入审核
  117. uni.navigateTo({
  118. url: item.routeUrl,
  119. });
  120. //this.outSubjectPhoto(item.routeUrl);
  121. }
  122. if (item.route === 'gasBottle') {//气瓶管理
  123. uni.navigateTo({
  124. url: item.routeUrl,
  125. });
  126. }
  127. if (item.route === 'warningRecording') {//安全报警
  128. uni.navigateTo({
  129. url: item.routeUrl,
  130. });
  131. }
  132. if (item.route === 'emergencyEvacuation') {//应急处置
  133. uni.navigateTo({
  134. url: item.routeUrl,
  135. });
  136. }
  137. }else if (item.buttonType === 'button') {
  138. if (item.route === 'photoInspection') {
  139. this.outSubjectPhoto();
  140. }
  141. } else if (item.buttonType === 'none') {
  142. uni.showToast({
  143. title: '暂未开放',
  144. icon: "none",
  145. mask: true,
  146. duration: 2000
  147. });
  148. }
  149. },
  150. //获取用户身份标识"adminGentle": false, 管理员身份 "rectifyGentle": false, 院级管理员collegeGentle 整改身份"applyGentle": false 检查者身份
  151. async getGentleIdentifier(routeUrl){
  152. let self = this;
  153. const {data} = await getGentleIdentifier();
  154. if(data.code==200){
  155. let pageType = null
  156. // 如果是管理员 检查者和整改者
  157. let list=[];
  158. if(data.data.adminGentle || data.data.collegeGentle){//校级管理员
  159. list.push({name:'管理员',pageType:1})
  160. }
  161. if(data.data.applyGentle ||data.data.myApplyGentle){
  162. list.push({name:'检查者',pageType:2})
  163. }
  164. if(data.data.rectifyGentle){
  165. list.push({name:'整改者',pageType:3})
  166. }
  167. if(!data.data.adminGentle && !data.data.applyGentle && !data.data.myApplyGentle && !data.data.rectifyGentle && !data.data.collegeGentle){
  168. }
  169. uni.setStorageSync('gentleIdentifier',list)
  170. uni.setStorageSync('gentleIdentifierData',data.data)
  171. if(list.length>0){
  172. uni.navigateTo({
  173. url: routeUrl,
  174. });
  175. }else{
  176. uni.showToast({
  177. title: '没有相关权限',
  178. icon:"none",
  179. mask:true,
  180. duration: 2000
  181. });
  182. }
  183. }
  184. },
  185. //获取拍照检查配置
  186. async outSubjectPhoto(routeUrl) {
  187. const {
  188. data
  189. } = await outSubjectPhoto();
  190. if (data.code == 200) {
  191. if (data.data == null) {
  192. //需要检查(重新填写)
  193. let obj = {
  194. sub: "实验室照片",
  195. subUrl: "",
  196. garbage: "垃圾桶清理后照片",
  197. garbageUrl: "",
  198. dangerous: "使用危险设备照片(选填)",
  199. dangerousUrl: "",
  200. sourceRisk: "危险源设备使用登记本照片(选填)",
  201. sourceRiskUrl: "",
  202. };
  203. uni.navigateTo({
  204. url: routeUrl+'?newData=' + encodeURIComponent(JSON.stringify(obj)),
  205. });
  206. } else if (data.data == false) {
  207. //不需要检查
  208. uni.showToast({
  209. title: '暂无检查数据',
  210. icon: "none",
  211. mask: true,
  212. duration: 2000
  213. });
  214. } else {
  215. //需要检查(修改内容)
  216. let obj = {
  217. id: data.data.id,
  218. sub: "实验室照片",
  219. subUrl: data.data.subUrl,
  220. garbage: "垃圾桶清理后照片",
  221. garbageUrl: data.data.garbageUrl,
  222. dangerous: "使用危险设备照片(选填)",
  223. dangerousUrl: data.data.dangerousUrl,
  224. sourceRisk: "危险源设备使用登记本照片(选填)",
  225. sourceRiskUrl: data.data.sourceRiskUrl,
  226. };
  227. uni.navigateTo({
  228. url: routeUrl+'?newData=' + encodeURIComponent(JSON.stringify(obj)),
  229. });
  230. }
  231. }
  232. },
  233. //获取分级管控未完成总数
  234. async getGrading() {
  235. const {
  236. data
  237. } = await gradingControl({})
  238. if (data.code == 200) {
  239. this.$set(this, 'gradingCount', data.data.length);
  240. }
  241. },
  242. //调用摄像头
  243. saoCode() {
  244. uni.scanCode({
  245. onlyFromCamera: true,
  246. success: function(res) {
  247. uni.navigateTo({
  248. url: '/pages_student/mine/codeSuccess?q=' + encodeURIComponent(JSON
  249. .stringify(res.result))
  250. });
  251. }
  252. });
  253. },
  254. },
  255. }
  256. </script>
  257. <style lang="stylus" scoped>
  258. .homeConfigurationSlot {
  259. margin: 0;
  260. padding: 0;
  261. .min-icon-button-box {
  262. display flex;
  263. justify-content: flex-start;
  264. flex-wrap: wrap;
  265. width: 710rpx;
  266. margin: 20rpx;
  267. background: #ffffff;
  268. border-radius: 20rpx;
  269. padding-bottom: 20rpx;
  270. .min-button-box {
  271. width: 176rpx;
  272. img {
  273. height: 75rpx;
  274. width: 75rpx;
  275. margin: 30rpx auto 10rpx;
  276. }
  277. view {
  278. text-align: center;
  279. font-size: 24rpx;
  280. }
  281. }
  282. }
  283. .big-icon-button-box {
  284. margin: 10rpx 0 0 20rpx;
  285. .imgBox {
  286. display: inline-block;
  287. width: 350rpx;
  288. height: 150rpx;
  289. margin: 10rpx 10rpx 0 0;
  290. }
  291. img {
  292. width: 350rpx;
  293. height: 150rpx;
  294. }
  295. }
  296. .three-big-icon-button-box {
  297. width: 710rpx;
  298. height: 354rpx;
  299. margin: 20rpx 20rpx 0;
  300. background: #ffffff;
  301. border-radius: 20rpx;
  302. position: relative;
  303. .imgBox:nth-child(1) {
  304. position: absolute;
  305. left: 13rpx;
  306. top: 20rpx;
  307. width: 310rpx;
  308. height: 150rpx;
  309. margin-bottom: 14rpx;
  310. img {
  311. width: 310rpx;
  312. height: 150rpx;
  313. }
  314. }
  315. .imgBox:nth-child(2) {
  316. position: absolute;
  317. left: 13rpx;
  318. top: 180rpx;
  319. width: 310rpx;
  320. height: 150rpx;
  321. img {
  322. width: 310rpx;
  323. height: 150rpx;
  324. }
  325. }
  326. .imgBox:nth-child(3) {
  327. position: absolute;
  328. right: 13rpx;
  329. top: 20rpx;
  330. width: 362rpx;
  331. height: 310rpx;
  332. // margin: 22rpx 13rpx 22rpx 0;
  333. img {
  334. width: 362rpx;
  335. height: 310rpx;
  336. }
  337. }
  338. }
  339. .grading {
  340. width: 712rpx;
  341. height: 80rpx;
  342. background: #FFFFFF;
  343. border-radius: 20rpx;
  344. margin: 20rpx 0 20rpx 20rpx;
  345. display: flex;
  346. justify-content: flex-start;
  347. align-items: center;
  348. .grading_l {
  349. width: 34rpx;
  350. height: 34rpx;
  351. margin-left: 16rpx;
  352. }
  353. .grading_c {
  354. font-size: 28rpx;
  355. font-family: PingFang SC;
  356. font-weight: 500;
  357. color: #333333;
  358. margin-left: 16rpx;
  359. }
  360. .grading_r {
  361. width: 504rpx;
  362. height: 80rpx;
  363. font-size: 26rpx;
  364. font-family: PingFang SC;
  365. font-weight: 500;
  366. color: #EE3A3A;
  367. display: flex;
  368. justify-content: flex-end;
  369. align-items: center;
  370. >img {
  371. width: 20rpx;
  372. height: 20rpx;
  373. margin-left: 20rpx;
  374. }
  375. }
  376. }
  377. }
  378. </style>