admissionConfiguration.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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="subjectData.xxpCardInfoId">
  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="subjectData.xxpCardInfoId">
  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. },
  77. verifyWayList:[],
  78. // 表单校验
  79. rules: {
  80. authType: [
  81. { required: true, message: "请选择考勤方式", trigger: "blur" },
  82. ],
  83. authPwd: [
  84. { required: true, message: "考勤密码最少8位 最多16位,必须同时包含字母和数字", trigger: "blur" },
  85. { pattern:/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/, message: "考勤密码最少8位 最多16位,必须同时包含字母和数字", trigger: "blur" }
  86. ],
  87. }
  88. }
  89. },
  90. created() {
  91. },
  92. mounted(){
  93. this.subjectmaterial();
  94. this.getSignTypeList();
  95. },
  96. methods:{
  97. /** 查询门禁授权类型 */
  98. getSignTypeList(){
  99. getSignTypeList().then(response => {
  100. if(response.code==200){
  101. this.verifyWayList=response.rows
  102. }
  103. });
  104. },
  105. //获取当前实验室准入配置
  106. subjectId(){
  107. let self = this;
  108. listTemplate({subjectId:this.subjectData.id}).then( response => {
  109. for(let i=0;i<response.data.listStudent.length;i++){
  110. for(let o=0;o<self.listStudent.length;o++){
  111. if(response.data.listStudent[i].id == self.listStudent[o].id){
  112. self.listStudent[o].checkType = true;
  113. }
  114. }
  115. }
  116. for(let i=0;i<response.data.listTeacher.length;i++){
  117. for(let o=0;o<self.listTeacher.length;o++){
  118. if(response.data.listTeacher[i].id == self.listTeacher[o].id){
  119. self.listTeacher[o].checkType = true;
  120. }
  121. }
  122. }
  123. if(!response.data.listStudent[0] && !response.data.listTeacher[0]){
  124. this.newUpDataType = true;
  125. }else{
  126. this.newUpDataType = false;
  127. }
  128. this.form.name=this.subjectData.name
  129. });
  130. },
  131. //提交接口
  132. upDataButton(){
  133. this.$refs["form"].validate(valid => {
  134. if (valid) {
  135. let self = this;
  136. let num = 0;
  137. let newData = {
  138. labSubjectList:[],
  139. studentList:[],
  140. teacherList:[],
  141. };
  142. newData.labSubjectList.push({id:this.subjectData.id});
  143. newData.authType=this.form.authType
  144. newData.authPwd=this.form.authPwd
  145. for(let i=0;i<self.listStudent.length;i++){
  146. if(self.listStudent[i].checkType){
  147. let obj = {
  148. materialId:self.listStudent[i].id,
  149. materialType:self.listStudent[i].materialSuit
  150. };
  151. newData.studentList.push(obj);
  152. num++
  153. }
  154. }
  155. for(let i=0;i<self.listTeacher.length;i++){
  156. if(self.listTeacher[i].checkType){
  157. let obj = {
  158. materialId:self.listTeacher[i].id,
  159. materialType:self.listTeacher[i].materialSuit
  160. };
  161. newData.teacherList.push(obj);
  162. num++
  163. }
  164. }
  165. if(num == 0){
  166. this.msgError("请选择准入条件");
  167. return
  168. }
  169. addlist(newData).then( response => {
  170. this.msgSuccess(this.newUpDataType?"提交成功":"修改成功");
  171. this.$parent.clickPage(1);
  172. });
  173. }
  174. });
  175. },
  176. //点击事件
  177. forListClick(item){
  178. item.checkType = !item.checkType;
  179. },
  180. //获取准入模板
  181. subjectmaterial(){
  182. this.loading = true;
  183. subjectmaterial({subjectId:this.subjectData.id}).then( response => {
  184. for(let i=0;i<response.data.listStudent.length;i++){
  185. response.data.listStudent[i].checkType = false;
  186. }
  187. for(let i=0;i<response.data.listTeacher.length;i++){
  188. response.data.listTeacher[i].checkType = false;
  189. }
  190. this.$set(this,'listStudent',response.data.listStudent);
  191. this.$set(this,'listTeacher',response.data.listTeacher);
  192. this.form.authType=response.data.cardInfo.authType+'';
  193. this.form.authPwd=response.data.cardInfo.authPwd;
  194. this.subjectId();
  195. });
  196. },
  197. //返回按钮
  198. backPage(){
  199. this.$parent.clickPage(1);
  200. },
  201. }
  202. }
  203. </script>
  204. <style lang="scss" scoped>
  205. .admissionConfiguration{
  206. flex:1;
  207. overflow-y: scroll;
  208. position: relative;
  209. display: flex;
  210. flex-direction: column;
  211. border-radius:10px!important;
  212. margin:5px 20px 20px 10px!important;
  213. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  214. .form-item{
  215. display: inline-block;
  216. margin-top: 40px;
  217. }
  218. .basics{
  219. display: flex;
  220. justify-content: flex-start;
  221. align-items: center;
  222. .tip{
  223. width: 14px;
  224. height: 14px;
  225. margin-left: 14px;
  226. }
  227. }
  228. .top-title-box{
  229. display: flex;
  230. border-bottom:1px solid #E0E0E0;
  231. margin:0 20px;
  232. p{
  233. margin:20px 0;
  234. line-height: 40px;
  235. }
  236. .title-p{
  237. font-size:18px;
  238. flex:1;
  239. color:#0045AF;
  240. }
  241. .right-icon{
  242. width:40px;
  243. text-align: center;
  244. }
  245. .right-icon:hover{
  246. cursor: pointer;
  247. background: rgba(0,0,0,0.1);
  248. -webkit-border-radius: 50%;
  249. -moz-border-radius: 50%;
  250. border-radius: 50%;
  251. }
  252. }
  253. .name-box{
  254. margin:32px 0 0 35px;
  255. font-size:16px;
  256. p{
  257. margin:0;
  258. }
  259. }
  260. .max-for-box{
  261. .for-box{
  262. display: inline-block;
  263. width:400px;
  264. height:60px;
  265. margin:32px 0 0 40px;
  266. cursor: pointer;
  267. border-radius:10px;
  268. overflow: hidden;
  269. position: relative;
  270. div{
  271. display: flex;
  272. line-height:60px;
  273. span:nth-child(1){
  274. margin:0 18px 0 18px;
  275. font-size:16px;
  276. color:#333;
  277. overflow:hidden;
  278. text-overflow:ellipsis;
  279. white-space:nowrap;
  280. }
  281. span:nth-child(2){
  282. font-size:14px;
  283. color:#999999;
  284. overflow:hidden;
  285. text-overflow:ellipsis;
  286. white-space:nowrap;
  287. }
  288. }
  289. .position-img{
  290. position: absolute;
  291. right:0;
  292. bottom:0;
  293. }
  294. }
  295. .for-border-one{
  296. border:1px solid #E0E0E0;
  297. }
  298. .for-border-two{
  299. border:1px solid #349cfb;
  300. }
  301. }
  302. .button-p{
  303. width:80px;
  304. margin:40px auto;
  305. }
  306. }
  307. </style>