homeConfigurationSlot.vue 11 KB

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