homeConfigurationSlot.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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 === 'grading'" @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. export default {
  70. name: "homeConfigurationSlot",
  71. props: {
  72. homeConfig: {},
  73. },
  74. data() {
  75. return {
  76. gradingCount: 0, //分级管控未完成总数
  77. }
  78. },
  79. created() {
  80. },
  81. mounted() {
  82. this.initializeData();
  83. },
  84. methods: {
  85. //初始化
  86. initializeData() {
  87. let self = this;
  88. for (let i = 0; i < self.homeConfig.layout.length; i++) {
  89. //分级管控
  90. if (self.homeConfig.layout[i].route === 'grading') {
  91. self.getGrading();
  92. }
  93. }
  94. },
  95. //按钮点击事件
  96. buttonClick(item) {
  97. if (item.buttonType === 'page') {
  98. uni.navigateTo({
  99. url: item.routeUrl,
  100. });
  101. } else if (item.buttonType === 'button') {
  102. if (item.route === 'photoInspection') {
  103. this.outSubjectPhoto();
  104. }
  105. } else if (item.buttonType === 'none') {
  106. uni.showToast({
  107. title: '暂未开放',
  108. icon: "none",
  109. mask: true,
  110. duration: 2000
  111. });
  112. }
  113. },
  114. //获取拍照检查配置
  115. async outSubjectPhoto() {
  116. const {
  117. data
  118. } = await outSubjectPhoto();
  119. if (data.code == 200) {
  120. if (data.data == null) {
  121. //需要检查(重新填写)
  122. let obj = {
  123. sub: "实验室照片",
  124. subUrl: "",
  125. garbage: "垃圾桶清理后照片",
  126. garbageUrl: "",
  127. dangerous: "使用危险设备照片(选填)",
  128. dangerousUrl: "",
  129. sourceRisk: "危险源设备使用登记本照片(选填)",
  130. sourceRiskUrl: "",
  131. };
  132. uni.navigateTo({
  133. url: '/pages_student/workbench/photoInspection?newData=' + encodeURIComponent(JSON
  134. .stringify(obj)),
  135. });
  136. } else if (data.data == false) {
  137. //不需要检查
  138. uni.showToast({
  139. title: '暂无检查数据',
  140. icon: "none",
  141. mask: true,
  142. duration: 2000
  143. });
  144. } else {
  145. //需要检查(修改内容)
  146. let obj = {
  147. id: data.data.id,
  148. sub: "实验室照片",
  149. subUrl: data.data.subUrl,
  150. garbage: "垃圾桶清理后照片",
  151. garbageUrl: data.data.garbageUrl,
  152. dangerous: "使用危险设备照片(选填)",
  153. dangerousUrl: data.data.dangerousUrl,
  154. sourceRisk: "危险源设备使用登记本照片(选填)",
  155. sourceRiskUrl: data.data.sourceRiskUrl,
  156. };
  157. uni.navigateTo({
  158. url: '/pages_student/workbench/photoInspection?newData=' + encodeURIComponent(JSON
  159. .stringify(obj)),
  160. });
  161. }
  162. }
  163. },
  164. //获取分级管控未完成总数
  165. async getGrading() {
  166. const {
  167. data
  168. } = await gradingControl({})
  169. if (data.code == 200) {
  170. this.$set(this, 'gradingCount', data.data.length);
  171. }
  172. },
  173. //调用摄像头
  174. saoCode() {
  175. uni.scanCode({
  176. onlyFromCamera: true,
  177. success: function(res) {
  178. uni.navigateTo({
  179. url: '/pages_student/mine/codeSuccess?q=' + encodeURIComponent(JSON
  180. .stringify(res.result))
  181. });
  182. }
  183. });
  184. },
  185. },
  186. }
  187. </script>
  188. <style lang="stylus" scoped>
  189. .homeConfigurationSlot {
  190. margin: 0;
  191. padding: 0;
  192. .min-icon-button-box {
  193. display flex;
  194. justify-content: flex-start;
  195. flex-wrap: wrap;
  196. width: 710rpx;
  197. margin: 20rpx;
  198. background: #ffffff;
  199. border-radius: 20rpx;
  200. padding-bottom: 20rpx;
  201. .min-button-box {
  202. width: 176rpx;
  203. img {
  204. height: 75rpx;
  205. width: 75rpx;
  206. margin: 30rpx auto 10rpx;
  207. }
  208. view {
  209. text-align: center;
  210. font-size: 24rpx;
  211. }
  212. }
  213. }
  214. .big-icon-button-box {
  215. margin: 10rpx 0 0 20rpx;
  216. .imgBox {
  217. display: inline-block;
  218. width: 350rpx;
  219. height: 150rpx;
  220. margin: 10rpx 10rpx 0 0;
  221. }
  222. img {
  223. width: 350rpx;
  224. height: 150rpx;
  225. }
  226. }
  227. .three-big-icon-button-box {
  228. width: 710rpx;
  229. height: 354rpx;
  230. margin: 20rpx 20rpx 0;
  231. background: #ffffff;
  232. border-radius: 20rpx;
  233. position: relative;
  234. .imgBox:nth-child(1) {
  235. position: absolute;
  236. left: 13rpx;
  237. top: 20rpx;
  238. width: 310rpx;
  239. height: 150rpx;
  240. margin-bottom: 14rpx;
  241. img {
  242. width: 310rpx;
  243. height: 150rpx;
  244. }
  245. }
  246. .imgBox:nth-child(2) {
  247. position: absolute;
  248. left: 13rpx;
  249. top: 180rpx;
  250. width: 310rpx;
  251. height: 150rpx;
  252. img {
  253. width: 310rpx;
  254. height: 150rpx;
  255. }
  256. }
  257. .imgBox:nth-child(3) {
  258. position: absolute;
  259. right: 13rpx;
  260. top: 20rpx;
  261. width: 362rpx;
  262. height: 310rpx;
  263. // margin: 22rpx 13rpx 22rpx 0;
  264. img {
  265. width: 362rpx;
  266. height: 310rpx;
  267. }
  268. }
  269. }
  270. .grading {
  271. width: 712rpx;
  272. height: 80rpx;
  273. background: #FFFFFF;
  274. border-radius: 20rpx;
  275. margin: 20rpx 0 20rpx 20rpx;
  276. display: flex;
  277. justify-content: flex-start;
  278. align-items: center;
  279. .grading_l {
  280. width: 34rpx;
  281. height: 34rpx;
  282. margin-left: 16rpx;
  283. }
  284. .grading_c {
  285. font-size: 28rpx;
  286. font-family: PingFang SC;
  287. font-weight: 500;
  288. color: #333333;
  289. margin-left: 16rpx;
  290. }
  291. .grading_r {
  292. width: 504rpx;
  293. height: 80rpx;
  294. font-size: 26rpx;
  295. font-family: PingFang SC;
  296. font-weight: 500;
  297. color: #EE3A3A;
  298. display: flex;
  299. justify-content: flex-end;
  300. align-items: center;
  301. >img {
  302. width: 20rpx;
  303. height: 20rpx;
  304. margin-left: 20rpx;
  305. }
  306. }
  307. }
  308. }
  309. </style>