chemicalsConfig.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="public-config-page">
  3. <el-form class="public-form-box scrollbar-box" :model="form" ref="form" :inline="true" :rules="rules" label-width="160px">
  4. <div class="form-max-box">
  5. <el-form-item label="使用身份配置" prop="userType">
  6. <el-checkbox-group v-model="form.userType">
  7. <el-checkbox style="margin:4px 87px 0 20px;" label="11">教职工</el-checkbox>
  8. <el-checkbox label="22">学生</el-checkbox>
  9. </el-checkbox-group>
  10. </el-form-item>
  11. </div>
  12. <div class="form-max-box">
  13. <el-form-item label="扩展配置" prop="expandType">
  14. <el-checkbox-group v-model="form.expandType">
  15. <el-checkbox style="margin:4px 30px 0 20px;" label="11">化学品柜智能锁</el-checkbox>
  16. <el-checkbox label="22">气瓶标签</el-checkbox>
  17. </el-checkbox-group>
  18. </el-form-item>
  19. </div>
  20. </el-form>
  21. <div class="sub_btn">
  22. <p class="null-p"></p>
  23. <p class="inquire-button-one" @click="submitForm">保存</p>
  24. <p class="null-p"></p>
  25. </div>
  26. <!--查看图片-->
  27. <el-dialog title="查看" :visible.sync="imgOpen" width="1200px" append-to-body>
  28. <div class="scrollbar-box" style="width:1160px;margin:0 auto;max-height:700px;overflow-y: scroll">
  29. <img :src="imgUrl" style="display:block;max-width:1160px;margin:0 auto">
  30. </div>
  31. </el-dialog>
  32. </div>
  33. </template>
  34. <script>
  35. import { getToken } from "@/utils/auth";
  36. import { getLogoInfo,updateLogoInfo } from "@/api/system/publicConfig";
  37. import store from '@/store'
  38. export default {
  39. name: "publicConfig",
  40. data() {
  41. return {
  42. uploadImgUrl: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/base/upload", // 上传的图片服务器地址
  43. headers: {
  44. Authorization: "Bearer " + getToken(),
  45. },
  46. form:{
  47. userType:[],
  48. expandType:[]
  49. },
  50. rules: {
  51. userType: [
  52. { required: true, message: "请配置使用身份", trigger: "blur" }
  53. ],
  54. smartLock: [
  55. { required: true, message: "请配置智能锁", trigger: "blur" }
  56. ],
  57. airBottle: [
  58. { required: true, message: "请配置气瓶标签", trigger: "blur" }
  59. ],
  60. expandType: [
  61. { required: true, message: "请配置扩展配置", trigger: "blur" }
  62. ]
  63. },
  64. imgUrl:"",
  65. imgOpen:false,
  66. };
  67. },
  68. created() {
  69. },
  70. mounted(){
  71. this.getLogoInfo();
  72. },
  73. methods: {
  74. /** 提交按钮 */
  75. submitForm: function() {
  76. let self = this;
  77. this.$refs["form"].validate(valid => {
  78. if (valid) {
  79. let obj = {
  80. }
  81. //判断使用身份配置
  82. if(self.form.userType[1]){
  83. obj.userType = '-1';
  84. }else{
  85. if(self.form.userType[0] == '11'){
  86. obj.userType = '11';
  87. }else if(self.form.userType[0] == '22'){
  88. obj.userType = '22';
  89. }
  90. }
  91. //判断扩展配置(智能锁配置/气瓶标签配置)
  92. let oneType = 0;
  93. let twoType = 0;
  94. for(let i=0;i<self.form.expandType.length;i++){
  95. if(self.form.expandType[i] == '11'){
  96. obj.smartLock = 1;
  97. oneType++
  98. }else if(self.form.expandType[i] == '22'){
  99. obj.airBottle = 1;
  100. twoType++
  101. }
  102. }
  103. if(oneType==0){
  104. obj.smartLock = 0;
  105. }
  106. if(twoType==0){
  107. obj.airBottle = 0;
  108. }
  109. updateLogoInfo(obj).then(response => {
  110. this.msgSuccess(response.msg);
  111. this.getLogoInfo();
  112. });
  113. }
  114. });
  115. },
  116. //查看图片
  117. lookImg(url){
  118. this.imgUrl = url;
  119. this.imgOpen = true;
  120. },
  121. //获取数据
  122. getLogoInfo(){
  123. getLogoInfo().then(response => {
  124. //判断使用身份配置
  125. let listOne = [];
  126. if(response.data.userType == -1){
  127. listOne.push('11')
  128. listOne.push('22')
  129. }else if(response.data.userType == 11){
  130. listOne.push('11')
  131. }else if(response.data.userType == 22){
  132. listOne.push('22')
  133. }
  134. this.$set(response.data,'userType',listOne);
  135. //判断扩展配置
  136. let listTwo = [];
  137. if(response.data.smartLock == 1){
  138. listTwo.push('11')
  139. }
  140. if(response.data.airBottle == 1){
  141. listTwo.push('22')
  142. }
  143. this.$set(response.data,'expandType',listTwo);
  144. this.$set(this,'form',response.data)
  145. });
  146. },
  147. },
  148. };
  149. </script>
  150. <style scoped lang="scss">
  151. .public-config-page{
  152. flex:1;
  153. display: flex;
  154. flex-direction: column;
  155. overflow: hidden;
  156. .public-form-box{
  157. flex:1;
  158. overflow-y: scroll;
  159. overflow-x: hidden;
  160. }
  161. /*底部按钮弹框*/
  162. .sub_btn{
  163. display: flex;
  164. background: #fff;
  165. height: 112px;
  166. .null-p{
  167. flex:1;
  168. }
  169. .inquire-button-one{
  170. cursor:pointer;
  171. display: inline-block;
  172. text-align: center;
  173. width: 70px;
  174. height: 40px;
  175. border-radius: 6px;
  176. border: 1px solid #0045af;
  177. color:#ffffff;
  178. background:#0045af;
  179. margin:36px 10px 0 0;
  180. }
  181. }
  182. *{
  183. margin:0;
  184. }
  185. .title-box{
  186. border-bottom:1px solid #dedede;
  187. p{
  188. margin-left:40px;
  189. color:#0045af;
  190. line-height:60px;
  191. }
  192. }
  193. .form-max-box{
  194. margin-top:20px;
  195. }
  196. }
  197. </style>