homeConfigurationSlot.vue 11 KB

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