homeConfigurationSlot.vue 11 KB

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