homeConfigurationSlot.vue 10 KB

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