Jelajahi Sumber

修改样式 添加

ajun 5 tahun lalu
induk
melakukan
9819d93067

+ 7 - 6
resources/views/maintenance/demand/_create.blade.php

@@ -1,7 +1,8 @@
+@auth
 <div id="demand-div">
     <div class="container-fluid position-absolute" style="z-index:300;top: 100px;">
-        <form class="d-flex float-right">
-            <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown"
+        <div class="d-flex float-right">
+            <button class="btn-circle btn-outline-primary" type="button" id="dropdownMenu2" data-toggle="dropdown" style="width: 45px;height: 45px"
                     aria-haspopup="true" aria-expanded="false">
                 提出问题
             </button>
@@ -9,7 +10,7 @@
                 <button class="dropdown-item" type="button" @click="showAddDemand()">提出问题</button>
                 <a href={{url('maintenance/demand/')}} class="dropdown-item">问题列表</a>
             </div>
-        </form>
+        </div>
     </div>
 
 
@@ -22,7 +23,6 @@
                         <span aria-hidden="true">&times;</span>
                     </button>
                 </div>
-
                 <div class="modal-body">
                     <div class="form-group row">
                         <label for="add-demand-auth" class="col-sm-2 col-form-label text-right">问题可见权限</label>
@@ -31,9 +31,9 @@
                                     v-model="addDemand.authority_id"
                                     :class="demandErrors.authority_id?'is-invalid':''"
                                     @focus="demandErrors.authority_id!==null ? demandErrors.authority_id=null:''">
-                                <option value=""></option>
+                                <option v-for="(authority,index) in authoritiesFilter" :value="authority.id">@{{ authority.name }}</option>
                             </select>
-                            <input type="text" class="form-control col-sm-3 ml-1" @input="filterAuth($e)"
+                            <input type="text" class="form-control col-sm-3 ml-1" id="add-demand-auth-filter" @input="filterAuth($event)"
                                    placeholder="输入权限进行删选">
                             <div class="invalid-feedback" v-if="demandErrors.authority_id">
                                 @{{ demandErrors.authority_id[0] }}
@@ -94,3 +94,4 @@
         </div>
     </div>
 </div>
+@endauth

+ 25 - 2
resources/views/maintenance/demand/_createjs.blade.php

@@ -1,3 +1,4 @@
+@auth
 <script>
     new Vue({
         el: "#demand-div",
@@ -10,6 +11,7 @@
         },
         created() {
             this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
+            this.getAuthority();
         },
         mounted() {
 
@@ -17,20 +19,28 @@
         methods: {
             /** 筛选 */
             filterAuth($e) {
-                let value = $($e).val();
+                let value = $($e.target).val();
                 let authorities = JSON.parse(JSON.stringify(this.authorities));
                 if (value === null) {
                     this.authoritiesFilter = authorities;
                     return;
                 }
                 this.authoritiesFilter = authorities.filter(function (item) {
-                    return item.includes(value);
+                    return item['name'].includes(value);
                 });
+                if(this.authoritiesFilter.length > 0)
+                    this.addDemand.authority_id = this.authoritiesFilter[0]['id'];
             },
             /** 创建 */
             showAddDemand() {
                 this.addDemand = {};
+                this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
+                $('#add-demand-auth-filter').val('');
                 $('#add-demand').modal('show')
+                if(this.authoritiesFilter.length === 0){
+                    if(this.authorities.length !==0)this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
+                    else this.getAuthority();
+                }
             },
             /** 创建 */
             createDemand() {
@@ -59,6 +69,19 @@
                     window.tempTip.show(err);
                 });
             },
+            getAuthority(){
+                let url = '{{url('apiLocal/authority/get')}}';
+                window.axios.get(url).then(res=>{
+                    if(res.data.success){
+                        this.authorities = res.data.data;
+                        this.authoritiesFilter = res.data.data;
+                        this.$forceUpdate();
+                    }
+                }).catch(err=>{
+                    window.tempTip.show(err);
+                });
+            },
         }
     });
 </script>
+@endauth