homeConfigurationSlot.vue 7.8 KB

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