addPage.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="addPage">
  3. <div class="title-box">
  4. <p>门禁授权申请</p>
  5. <!--<p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>-->
  6. </div>
  7. <el-form ref="form" :model="form" :rules="addRules" label-width="200px">
  8. <el-form-item label="实验室:" prop="subjectId" class="selsectbox"
  9. style="display: inline-block">
  10. <el-select
  11. style="width:500px;"
  12. @change="userChange"
  13. v-model="form.subjectId"
  14. filterable
  15. placeholder="搜索选择实验室"
  16. remote
  17. :remote-method="userSelectList"
  18. :loading="loading">
  19. <el-option
  20. v-for="item in optionsUser"
  21. :key="item.id"
  22. :label="item.name"
  23. :value="item.id">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="管理员:" prop="safeUserId"
  28. style="display: inline-block">
  29. <el-select
  30. style="width:500px;"
  31. v-model="form.safeUserId"
  32. placeholder="请选择管理员"
  33. remote
  34. :loading="loading">
  35. <el-option
  36. v-for="item in optionsUserOne"
  37. :key="item.safeUserId"
  38. :label="item.safeUserName"
  39. :value="item.safeUserId">
  40. </el-option>
  41. </el-select>
  42. </el-form-item>
  43. <!--<el-form-item label="共同申请人:" prop="userId2" class="selsectbox"-->
  44. <!--style="display: inline-block">-->
  45. <!--<el-select-->
  46. <!--style="width:500px;"-->
  47. <!--@change="userChangeOne"-->
  48. <!--v-model="form.userId2"-->
  49. <!--filterable-->
  50. <!--placeholder="搜索选择共同申请人"-->
  51. <!--remote-->
  52. <!--:remote-method="userSelectListOne"-->
  53. <!--:loading="loading">-->
  54. <!--<el-option-->
  55. <!--v-for="item in optionsUserOne"-->
  56. <!--:key="item.userId"-->
  57. <!--:label="item.nickName"-->
  58. <!--:value="item.userId">-->
  59. <!--{{item.nickName}}-{{item.userName}}-->
  60. <!--</el-option>-->
  61. <!--</el-select>-->
  62. <!--</el-form-item>-->
  63. <el-form-item label="位置:" prop="laboratoryId">
  64. <p style="line-height:40px;color:#333;">{{text?text:'请选择实验室'}}</p>
  65. </el-form-item>
  66. <!--<el-form-item label="安全责任人:" prop="laboratoryId">-->
  67. <!--&lt;!&ndash;<p style="line-height:40px;">{{name?name:'请选择实验室'}}</p>&ndash;&gt;-->
  68. <!--<p style="line-height:40px;color:#333;" v-if="!nameList[0]">请选择实验室</p>-->
  69. <!--<p style="line-height:40px;color:#333;" v-if="nameList[0]"><span v-for="(item,index) in nameList">{{index!=0?','+item:item}}</span></p>-->
  70. <!--</el-form-item>-->
  71. </el-form>
  72. <div class="bottom-button-box">
  73. <p class="reset-button-one" @click="backPage">取消</p>
  74. <p class="inquire-button-one" @click="upData">提交</p>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import { subjectList,selectUserListByName } from "@/api/laboratory/approval";
  80. import { subjectVo,openDoorApply,subjectRelationList } from "@/api/laboratory/subject";
  81. export default {
  82. name: "addPage",
  83. data(){
  84. return{
  85. loading:false,
  86. form:{},
  87. addRules:{
  88. subjectId: [
  89. { required: true, message: "请选择实验室", trigger: "blur" }
  90. ],
  91. userId2: [
  92. { required: true, message: "请选择共同申请人", trigger: "blur" },
  93. ],
  94. safeUserId: [
  95. { required: true, message: "请选择管理员", trigger: "blur" },
  96. ],
  97. },
  98. optionsUser:[],
  99. optionsUserOne:[],
  100. subjectOptions:[],
  101. text:"",
  102. nameList:"",
  103. newObj:{},
  104. }
  105. },
  106. created() {
  107. },
  108. mounted(){
  109. },
  110. methods:{
  111. //实验室获取
  112. userSelectList(query){
  113. if (query !== '' && query.length>1) {
  114. this.loading = true;
  115. let obj = {
  116. name : query
  117. };
  118. subjectList(obj).then(response => {
  119. this.optionsUser = response.data;
  120. this.loading = false;
  121. });
  122. } else {
  123. this.optionsUser = [];
  124. }
  125. },
  126. //人员获取
  127. userSelectListOne(query){
  128. if (query !== '' && query.length>1) {
  129. this.loading = true;
  130. let obj = {
  131. nickName : query,
  132. userType : 22
  133. };
  134. selectUserListByName(obj).then(response => {
  135. this.optionsUserOne = response.data;
  136. this.loading = false;
  137. });
  138. } else {
  139. this.optionsUserOne = [];
  140. }
  141. },
  142. //实验室选中
  143. userChange(data){
  144. let self = this;
  145. subjectVo(data,0).then(response => {
  146. this.text = response.data.deptName + '-' + response.data.buildName + '-' + response.data.floorName +'-'+ response.data.roomName
  147. let list = response.data.safeUserNames.split(',');
  148. this.$set(this,'nameList',list);
  149. this.$set(this.newObj,'position',response.data.buildName + '-' + response.data.floorName +'-'+ response.data.roomName);
  150. this.$set(this.newObj,'college',response.data.deptName);
  151. this.$set(this.newObj,'subjectName',response.data.name);
  152. this.$set(this.newObj,'subjectId',response.data.id);
  153. // this.$set(this.newObj,'safeUserName',response.data.safeUserName);
  154. // this.$set(this.newObj,'safeUserId',response.data.safeUserId);
  155. // this.$set(this.newObj,'safeUserPhone',response.data.safeUserPhone);
  156. subjectRelationList({subjectId:response.data.id}).then(response => {
  157. this.$set(this,'optionsUserOne',response.rows);
  158. })
  159. });
  160. },
  161. //人员选中
  162. userChangeOne(data){
  163. this.$set(this.newObj,'userId2',data);
  164. },
  165. upData(){
  166. let self = this;
  167. this.$refs["form"].validate(valid => {
  168. if (valid) {
  169. this.$confirm('确认要提交吗?', "警告", {
  170. confirmButtonText: "确定",
  171. cancelButtonText: "取消",
  172. type: "warning"
  173. }).then(() => {
  174. for(let i=0;i<self.optionsUserOne.length;i++){
  175. if(self.form.safeUserId == self.optionsUserOne[i].safeUserId){
  176. self.newObj.safeUserId = self.optionsUserOne[i].safeUserId;
  177. self.newObj.safeUserName = self.optionsUserOne[i].safeUserName;
  178. self.newObj.safeUserPhone = self.optionsUserOne[i].safeUserPhone;
  179. }
  180. }
  181. openDoorApply(self.newObj).then(response => {
  182. self.msgSuccess(response.msg);
  183. self.$parent.goPageButton(3);
  184. });
  185. }).catch(function() {
  186. // 取消
  187. });
  188. }
  189. });
  190. },
  191. //返回
  192. backPage(){
  193. this.$parent.goPageButton(1);
  194. },
  195. }
  196. }
  197. </script>
  198. <style scoped lang="scss">
  199. .addPage{
  200. flex:1;
  201. display: flex;
  202. flex-direction: column;
  203. overflow: hidden;
  204. p{
  205. margin:0;
  206. padding:0;
  207. }
  208. .title-box{
  209. display: flex;
  210. height:90px;
  211. border-bottom: 1px solid #D8D8D8;
  212. margin-bottom:40px;
  213. p:nth-child(1){
  214. flex:1;
  215. font-size:16px;
  216. line-height:90px;
  217. margin-left:18px;
  218. color:#0045AF;
  219. }
  220. p:nth-child(2){
  221. margin:25px 25px 0 0;
  222. }
  223. }
  224. .bottom-button-box{
  225. display: flex;
  226. margin:200px auto 40px;
  227. p:nth-child(1){
  228. margin-right:20px;
  229. width:90px;
  230. }
  231. p:nth-child(2){
  232. width:90px;
  233. }
  234. }
  235. }
  236. </style>
  237. <style>
  238. /*//替换左边默认图标*/
  239. .selsectbox .el-select .el-input .el-select__caret:after {
  240. background: url(../../../../assets/ZDimages/icon_001.png) no-repeat center center; /*引入icon*/
  241. transform:rotate(180deg);
  242. background-size: 20px 20px; /*这个是图片的大小,在这里不能直接设置width height,设置宽高其实是select的宽高,图片可能会失真只设置宽度 高度auto也行*/
  243. padding: 0 0 0 26px; /*需要设置padding 把placeholder向右移*/
  244. box-sizing: border-box;
  245. font-size: 14px;
  246. }
  247. </style>