homeConfigurationSlot.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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 === 'gradingControl'" @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. if (item.route === 'gradingControl') {//分級管控
  138. uni.navigateTo({
  139. url: item.routeUrl,
  140. });
  141. }
  142. //学生端------------------------
  143. if (item.route === 'integralExchange') {//积分兑换
  144. uni.navigateTo({
  145. url: item.routeUrl,
  146. });
  147. //this.saoCode(item.routeUrl)
  148. }
  149. if (item.route === 'accessApplication') {//准入申请
  150. uni.navigateTo({
  151. url: item.routeUrl,
  152. });
  153. }
  154. if (item.route === 'studentGasBottle') {//气瓶管理
  155. uni.navigateTo({
  156. url: item.routeUrl,
  157. });
  158. }
  159. }else if (item.buttonType === 'button') {
  160. if (item.route === 'photoInspection') {
  161. this.outSubjectPhoto();
  162. }
  163. } else if (item.buttonType === 'none') {
  164. uni.showToast({
  165. title: '暂未开放',
  166. icon: "none",
  167. mask: true,
  168. duration: 2000
  169. });
  170. }
  171. },
  172. //获取用户身份标识"adminGentle": false, 管理员身份 "rectifyGentle": false, 院级管理员collegeGentle 整改身份"applyGentle": false 检查者身份
  173. async getGentleIdentifier(routeUrl){
  174. let self = this;
  175. const {data} = await getGentleIdentifier();
  176. if(data.code==200){
  177. let pageType = null
  178. // 如果是管理员 检查者和整改者
  179. let list=[];
  180. if(data.data.adminGentle || data.data.collegeGentle){//校级管理员
  181. list.push({name:'管理员',pageType:1})
  182. }
  183. if(data.data.applyGentle ||data.data.myApplyGentle){
  184. list.push({name:'检查者',pageType:2})
  185. }
  186. if(data.data.rectifyGentle){
  187. list.push({name:'整改者',pageType:3})
  188. }
  189. if(!data.data.adminGentle && !data.data.applyGentle && !data.data.myApplyGentle && !data.data.rectifyGentle && !data.data.collegeGentle){
  190. }
  191. uni.setStorageSync('gentleIdentifier',list)
  192. uni.setStorageSync('gentleIdentifierData',data.data)
  193. if(list.length>0){
  194. uni.navigateTo({
  195. url: routeUrl,
  196. });
  197. }else{
  198. uni.showToast({
  199. title: '没有相关权限',
  200. icon:"none",
  201. mask:true,
  202. duration: 2000
  203. });
  204. }
  205. }
  206. },
  207. //获取拍照检查配置
  208. async outSubjectPhoto(routeUrl) {
  209. const {
  210. data
  211. } = await outSubjectPhoto();
  212. if (data.code == 200) {
  213. if (data.data == null) {
  214. //需要检查(重新填写)
  215. let obj = {
  216. sub: "实验室照片",
  217. subUrl: "",
  218. garbage: "垃圾桶清理后照片",
  219. garbageUrl: "",
  220. dangerous: "使用危险设备照片(选填)",
  221. dangerousUrl: "",
  222. sourceRisk: "危险源设备使用登记本照片(选填)",
  223. sourceRiskUrl: "",
  224. };
  225. uni.navigateTo({
  226. url: routeUrl+'?newData=' + encodeURIComponent(JSON.stringify(obj)),
  227. });
  228. } else if (data.data == false) {
  229. //不需要检查
  230. uni.showToast({
  231. title: '暂无检查数据',
  232. icon: "none",
  233. mask: true,
  234. duration: 2000
  235. });
  236. } else {
  237. //需要检查(修改内容)
  238. let obj = {
  239. id: data.data.id,
  240. sub: "实验室照片",
  241. subUrl: data.data.subUrl,
  242. garbage: "垃圾桶清理后照片",
  243. garbageUrl: data.data.garbageUrl,
  244. dangerous: "使用危险设备照片(选填)",
  245. dangerousUrl: data.data.dangerousUrl,
  246. sourceRisk: "危险源设备使用登记本照片(选填)",
  247. sourceRiskUrl: data.data.sourceRiskUrl,
  248. };
  249. uni.navigateTo({
  250. url: routeUrl+'?newData=' + encodeURIComponent(JSON.stringify(obj)),
  251. });
  252. }
  253. }
  254. },
  255. //获取分级管控未完成总数
  256. async getGrading() {
  257. const {
  258. data
  259. } = await gradingControl({})
  260. if (data.code == 200) {
  261. this.$set(this, 'gradingCount', data.data.length);
  262. }
  263. },
  264. //调用摄像头
  265. saoCode(routeUrl) {
  266. uni.scanCode({
  267. onlyFromCamera: true,
  268. success: function(res) {
  269. uni.navigateTo({
  270. url: routeUrl+'?q=' + encodeURIComponent(JSON
  271. .stringify(res.result))
  272. });
  273. }
  274. });
  275. },
  276. },
  277. }
  278. </script>
  279. <style lang="stylus" scoped>
  280. .homeConfigurationSlot {
  281. margin: 0;
  282. padding: 0;
  283. .min-icon-button-box {
  284. display flex;
  285. justify-content: flex-start;
  286. flex-wrap: wrap;
  287. width: 710rpx;
  288. margin: 20rpx;
  289. background: #ffffff;
  290. border-radius: 20rpx;
  291. padding-bottom: 20rpx;
  292. .min-button-box {
  293. width: 176rpx;
  294. img {
  295. height: 75rpx;
  296. width: 75rpx;
  297. margin: 30rpx auto 10rpx;
  298. }
  299. view {
  300. text-align: center;
  301. font-size: 24rpx;
  302. }
  303. }
  304. }
  305. .big-icon-button-box {
  306. margin: 10rpx 0 0 20rpx;
  307. .imgBox {
  308. display: inline-block;
  309. width: 350rpx;
  310. height: 150rpx;
  311. margin: 10rpx 10rpx 0 0;
  312. }
  313. img {
  314. width: 350rpx;
  315. height: 150rpx;
  316. }
  317. }
  318. .three-big-icon-button-box {
  319. width: 710rpx;
  320. height: 354rpx;
  321. margin: 20rpx 20rpx 0;
  322. background: #ffffff;
  323. border-radius: 20rpx;
  324. position: relative;
  325. .imgBox:nth-child(1) {
  326. position: absolute;
  327. left: 13rpx;
  328. top: 20rpx;
  329. width: 310rpx;
  330. height: 150rpx;
  331. margin-bottom: 14rpx;
  332. img {
  333. width: 310rpx;
  334. height: 150rpx;
  335. }
  336. }
  337. .imgBox:nth-child(2) {
  338. position: absolute;
  339. left: 13rpx;
  340. top: 180rpx;
  341. width: 310rpx;
  342. height: 150rpx;
  343. img {
  344. width: 310rpx;
  345. height: 150rpx;
  346. }
  347. }
  348. .imgBox:nth-child(3) {
  349. position: absolute;
  350. right: 13rpx;
  351. top: 20rpx;
  352. width: 362rpx;
  353. height: 310rpx;
  354. // margin: 22rpx 13rpx 22rpx 0;
  355. img {
  356. width: 362rpx;
  357. height: 310rpx;
  358. }
  359. }
  360. }
  361. .grading {
  362. width: 712rpx;
  363. height: 80rpx;
  364. background: #FFFFFF;
  365. border-radius: 20rpx;
  366. margin: 20rpx 0 20rpx 20rpx;
  367. display: flex;
  368. justify-content: flex-start;
  369. align-items: center;
  370. .grading_l {
  371. width: 34rpx;
  372. height: 34rpx;
  373. margin-left: 16rpx;
  374. }
  375. .grading_c {
  376. font-size: 28rpx;
  377. font-family: PingFang SC;
  378. font-weight: 500;
  379. color: #333333;
  380. margin-left: 16rpx;
  381. }
  382. .grading_r {
  383. width: 504rpx;
  384. height: 80rpx;
  385. font-size: 26rpx;
  386. font-family: PingFang SC;
  387. font-weight: 500;
  388. color: #EE3A3A;
  389. display: flex;
  390. justify-content: flex-end;
  391. align-items: center;
  392. >img {
  393. width: 20rpx;
  394. height: 20rpx;
  395. margin-left: 20rpx;
  396. }
  397. }
  398. }
  399. }
  400. </style>