homeConfigurationSlot.vue 10 KB

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