homeConfigurationSlot.vue 10 KB

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