admissionConfiguration.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!--实验室准入配置-->
  2. <template>
  3. <div class="admissionConfiguration scrollbar-box">
  4. <div class="top-title-box">
  5. <p class="title-p">基本信息</p>
  6. <p class="right-button reset-button-one" @click="backPage">返回</p>
  7. <!--<p class="el-icon-close right-icon color_one" @click="backPage"></p>-->
  8. </div>
  9. <div class="basics">
  10. <el-form ref="form" :model="form" label-width="120px" :rules="rules">
  11. <el-form-item label="适用实验室:" prop="name" class="form-item">
  12. <el-input
  13. style="width:320px;"
  14. maxlength="30"
  15. v-model="form.name"
  16. placeholder=""
  17. clearable
  18. size="small"
  19. disabled
  20. />
  21. </el-form-item>
  22. <el-form-item label="考勤方式" prop="authType" class="form-item" v-if="form.isSignId">
  23. <el-select v-model="form.authType" clearable >
  24. <el-option
  25. v-for="item in verifyWayList"
  26. :key="item.dictValue"
  27. :label="item.dictLabel"
  28. :value="item.dictValue">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="考勤密码:" prop="authPwd" class="form-item" v-if="form.isSignId">
  33. <el-input
  34. maxlength="16"
  35. v-model="form.authPwd"
  36. placeholder=""
  37. clearable
  38. size="small"
  39. />
  40. </el-form-item>
  41. </el-form>
  42. </div>
  43. <div class="top-title-box">
  44. <p class="title-p">准入信息配置</p>
  45. </div>
  46. <div class="max-for-box">
  47. <div class="for-box" v-for="(item,index) in listStudent" :key="index" :class="item.checkType?'for-border-two':'for-border-one'" @click="forListClick(item)">
  48. <div><span>{{item.materialName}}</span><span>{{item.materialDescribe}}</span></div>
  49. <img class="position-img" v-if="item.checkType" src="@/assets/ZDimages/icon_30.png" alt="">
  50. </div>
  51. </div>
  52. <p class="inquire-button-one button-p" @click="upDataButton">{{newUpDataType?'提交':'修改'}}</p>
  53. </div>
  54. </template>
  55. <script>
  56. import { listTemplate, subjectmaterial, addlist } from "@/api/laboratory/admissionConfiguration";
  57. import {
  58. getSignTypeList
  59. } from '@/api/laboratory/subject'
  60. import { infoConfigAdd, infoConfigPut } from '@/api/laboratory/safetyInfo'
  61. export default {
  62. name: "admissionConfiguration",
  63. props:{
  64. subjectData:{},
  65. },
  66. data() {
  67. return {
  68. //学生模板
  69. listStudent:[],
  70. //老师模板
  71. listTeacher:[],
  72. newUpDataType:false,
  73. form:{
  74. authType:'2',
  75. authPwd:'',
  76. isSignId:'',
  77. },
  78. verifyWayList:[],
  79. // 表单校验
  80. rules: {
  81. authType: [
  82. { required: true, message: "请选择考勤方式", trigger: "blur" },
  83. ],
  84. authPwd: [
  85. { required: true, message: "考勤密码最少8位 最多16位,必须同时包含字母和数字", trigger: "blur" },
  86. { pattern:/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/, message: "考勤密码最少8位 最多16位,必须同时包含字母和数字", trigger: "blur" }
  87. ],
  88. }
  89. }
  90. },
  91. created() {
  92. },
  93. mounted(){
  94. this.subjectmaterial();
  95. this.getSignTypeList();
  96. },
  97. methods:{
  98. /** 查询门禁授权类型 */
  99. getSignTypeList(){
  100. getSignTypeList().then(response => {
  101. if(response.code==200){
  102. this.verifyWayList=response.rows
  103. }
  104. });
  105. },
  106. //获取当前实验室准入配置
  107. subjectId(){
  108. let self = this;
  109. listTemplate({subjectId:this.subjectData.id}).then( response => {
  110. for(let i=0;i<response.data.listStudent.length;i++){
  111. for(let o=0;o<self.listStudent.length;o++){
  112. if(response.data.listStudent[i].id == self.listStudent[o].id){
  113. self.listStudent[o].checkType = true;
  114. }
  115. }
  116. }
  117. for(let i=0;i<response.data.listTeacher.length;i++){
  118. for(let o=0;o<self.listTeacher.length;o++){
  119. if(response.data.listTeacher[i].id == self.listTeacher[o].id){
  120. self.listTeacher[o].checkType = true;
  121. }
  122. }
  123. }
  124. if(!response.data.listStudent[0] && !response.data.listTeacher[0]){
  125. this.newUpDataType = true;
  126. }else{
  127. this.newUpDataType = false;
  128. }
  129. this.form.name=this.subjectData.name
  130. });
  131. },
  132. //提交接口
  133. upDataButton(){
  134. this.$refs["form"].validate(valid => {
  135. if (valid) {
  136. let self = this;
  137. let num = 0;
  138. let newData = {
  139. labSubjectList:[],
  140. studentList:[],
  141. teacherList:[],
  142. };
  143. newData.labSubjectList.push({id:this.subjectData.id});
  144. newData.authType=this.form.authType
  145. newData.authPwd=this.form.authPwd
  146. for(let i=0;i<self.listStudent.length;i++){
  147. if(self.listStudent[i].checkType){
  148. let obj = {
  149. materialId:self.listStudent[i].id,
  150. materialType:self.listStudent[i].materialSuit
  151. };
  152. newData.studentList.push(obj);
  153. num++
  154. }
  155. }
  156. for(let i=0;i<self.listTeacher.length;i++){
  157. if(self.listTeacher[i].checkType){
  158. let obj = {
  159. materialId:self.listTeacher[i].id,
  160. materialType:self.listTeacher[i].materialSuit
  161. };
  162. newData.teacherList.push(obj);
  163. num++
  164. }
  165. }
  166. if(num == 0){
  167. this.msgError("请选择准入条件");
  168. return
  169. }
  170. addlist(newData).then( response => {
  171. this.msgSuccess(this.newUpDataType?"提交成功":"修改成功");
  172. this.$parent.clickPage(1);
  173. });
  174. }
  175. });
  176. },
  177. //点击事件
  178. forListClick(item){
  179. item.checkType = !item.checkType;
  180. },
  181. //获取准入模板
  182. subjectmaterial(){
  183. this.loading = true;
  184. subjectmaterial({subjectId:this.subjectData.id}).then( response => {
  185. for(let i=0;i<response.data.listStudent.length;i++){
  186. response.data.listStudent[i].checkType = false;
  187. }
  188. for(let i=0;i<response.data.listTeacher.length;i++){
  189. response.data.listTeacher[i].checkType = false;
  190. }
  191. this.$set(this,'listStudent',response.data.listStudent);
  192. this.$set(this,'listTeacher',response.data.listTeacher);
  193. this.$set(this.form,'isSignId',response.data.cardInfo.id);
  194. this.form.authType=response.data.cardInfo.authType+'';
  195. this.form.authPwd=response.data.cardInfo.authPwd;
  196. this.subjectId();
  197. });
  198. },
  199. //返回按钮
  200. backPage(){
  201. this.$parent.clickPage(1);
  202. },
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. .admissionConfiguration{
  208. flex:1;
  209. overflow-y: scroll;
  210. position: relative;
  211. display: flex;
  212. flex-direction: column;
  213. border-radius:10px!important;
  214. margin:5px 20px 20px 10px!important;
  215. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  216. .form-item{
  217. display: inline-block;
  218. margin-top: 40px;
  219. }
  220. .basics{
  221. display: flex;
  222. justify-content: flex-start;
  223. align-items: center;
  224. .tip{
  225. width: 14px;
  226. height: 14px;
  227. margin-left: 14px;
  228. }
  229. }
  230. .top-title-box{
  231. display: flex;
  232. border-bottom:1px solid #E0E0E0;
  233. margin:0 20px;
  234. p{
  235. margin:20px 0;
  236. line-height: 40px;
  237. }
  238. .title-p{
  239. font-size:18px;
  240. flex:1;
  241. color:#0045AF;
  242. }
  243. .right-icon{
  244. width:40px;
  245. text-align: center;
  246. }
  247. .right-icon:hover{
  248. cursor: pointer;
  249. background: rgba(0,0,0,0.1);
  250. -webkit-border-radius: 50%;
  251. -moz-border-radius: 50%;
  252. border-radius: 50%;
  253. }
  254. }
  255. .name-box{
  256. margin:32px 0 0 35px;
  257. font-size:16px;
  258. p{
  259. margin:0;
  260. }
  261. }
  262. .max-for-box{
  263. .for-box{
  264. display: inline-block;
  265. width:400px;
  266. height:60px;
  267. margin:32px 0 0 40px;
  268. cursor: pointer;
  269. border-radius:10px;
  270. overflow: hidden;
  271. position: relative;
  272. div{
  273. display: flex;
  274. line-height:60px;
  275. span:nth-child(1){
  276. margin:0 18px 0 18px;
  277. font-size:16px;
  278. color:#333;
  279. overflow:hidden;
  280. text-overflow:ellipsis;
  281. white-space:nowrap;
  282. }
  283. span:nth-child(2){
  284. font-size:14px;
  285. color:#999999;
  286. overflow:hidden;
  287. text-overflow:ellipsis;
  288. white-space:nowrap;
  289. }
  290. }
  291. .position-img{
  292. position: absolute;
  293. right:0;
  294. bottom:0;
  295. }
  296. }
  297. .for-border-one{
  298. border:1px solid #E0E0E0;
  299. }
  300. .for-border-two{
  301. border:1px solid #349cfb;
  302. }
  303. }
  304. .button-p{
  305. width:80px;
  306. margin:40px auto;
  307. }
  308. }
  309. </style>