iview 的select元件擴充
效果如圖上圖
對iview的select進行擴充
程式碼如下
<Row>
<FormItem label="部門" prop="departments" style="position:relative;">
<!-- 修改 -->
<Select placeholder="請輸入部門" class="bandelete" v-if="!modal.isread" v-model="model.departments" ref="setQuery" filterable remote @on-change="deletedata" @on-clear="remoteMethod" :remote-method="remoteMethod" multiple transfer clearable>
<Option v-for="(option, index) in modal.perm" :value="option.code" :key="index">{{option.name}}</Option>
</Select>
<span v-if="modal.isread">{{newDepartmentsnamestring}}</span>
</FormItem>
<FormItem style="position:relative;margin-bottom:0px;" v-if="model.departments.length>0 && !modal.isread">
<!-- 修改 -->
<div slot="label">
<Tooltip :transfer="true" content="勾選後該部門就能檢視該類別下所有的名單" placement="bottom-start">
<span style="font-size: 12px;font-weight:bold">
<Icon class="ivu-icon ivu-icon-ios-information-circle" slot="icon" color="#A1A1A1" style="font-size:14px;cursor:pointer;"></Icon>
</span>
</Tooltip>
</div>
<div style="border:1px solid #dcdee2;padding:16px;" class="checkclass" >
<CheckboxGroup v-model="model.maindepartments" @on-change="getisall()">
<div v-for="(option, index) in savecoorddepartment" v-if="model.departments.includes(option.code)" style="width:50%;display:inline-block;position:relative;">
<Checkbox style="line-height: 19px;margin-right:-6px;" :key="index" :label="option.code">{{option.name}}</Checkbox>
<i class="ivu-icon ivu-icon-ios-close" style="font-size:19px;vertical-align:top;margin-right:4px;cursor:pointer;position:absolute;" @click="deletecurrent(option.code)"></i>
</div>
</CheckboxGroup>
</div>
</FormItem>
</Row>
deletedata:function(val){
let allselectdepartment = val;
let indepartment = [];
if(allselectdepartment.length>0){
let maindepartments = [...this.model.maindepartments];
if(maindepartments.length>0){
maindepartments.map(item=>{
if(allselectdepartment.includes(item)){
indepartment.push(item);
}
})
}
this.model.maindepartments = indepartment;
allselectdepartment.map(alitem=>{
let hasexict = this.savecoorddepartment.find(item=>{
return item.code == alitem
})
if(!hasexict){
let hasdepartment = this.modal.perm.find(item=>{
return item.code == alitem
})
if(hasdepartment){
this.savecoorddepartment.push(hasdepartment);
}
}
})
}else{
this.model.maindepartments = [];
this.savecoorddepartment = [];
}
},
deletecurrent:function(code){
let _this = this;
let maindepartments = _this.model.maindepartments;
let departments = [..._this.model.departments];
let newmaindepartments = [];
let newdepartments = [];
if(maindepartments.length>0){
maindepartments.map(item=>{
if(item != code){
newmaindepartments.push(item);
}
})
if(newmaindepartments.length>0){
_this.model.maindepartments = newmaindepartments;
}else{
_this.model.maindepartments = [];
}
}else{
_this.model.maindepartments = [];
}
if(departments.length>0){
departments.map(item=>{
if(item != code){
newdepartments.push(item);
}
})
if(newdepartments.length>0){
_this.model.departments = newdepartments;
}else{
_this.model.departments = [];
}
}else{
_this.model.departments = [];
}
}
獲取查詢資料列表的remoteMethod()方法我就不寫了
這裡還需注意,每次選完後,需要將所選的內容放入列表中,不然搜尋查詢後資料會自動過濾未查到資料
相關文章
- 擴充套件laravel config 元件套件Laravel元件
- iview Table元件使用render新增Select下拉框並進行雙向繫結View元件
- 開源 | FLUI : Flutter 的元件擴充套件集UIFlutter元件套件
- 為Unity元件編寫擴充套件Unity元件套件
- 【UniApp】-uni-app-擴充套件元件APP套件元件
- iview 元件無法使用View元件
- iView常用元件清空技巧View元件
- 基於Ardalis.GuardClauses守衛元件的擴充元件
- PHP 系統樹圖擴充套件元件PHP套件元件
- 擴充spring元件之自定義標籤Spring元件
- Jmeter——元件擴充套件,使其功能更全面JMeter元件套件
- [Dcat 擴充套件] dcat-distpicker 省市區三級聯動選擇元件擴充套件元件
- iView 釋出微信小程式 UI 元件庫 iView WeappView微信小程式UI元件APP
- WPF之花式控制元件功能擴充套件控制元件套件
- 基於 iView 的樹選擇器元件View元件
- Select 元件實現元件
- Vue.js 元件複用和擴充套件之道Vue.js元件套件
- EFCore之SQL擴充套件元件BeetleX.EFCore.ExtensionSQL套件元件
- WPF開源控制元件擴充套件庫 - MaterialDesignExtensions控制元件套件
- KubeSphere v4 擴充套件元件使用指南套件元件
- Mozilla Firefox將很快獲得包含Tor模式的擴充套件元件Firefox模式套件元件
- Mozilla Firefox 將很快獲得包含 Tor 模式的擴充套件元件Firefox模式套件元件
- .NET Core 3.0之建立基於Consul的Configuration擴充套件元件套件元件
- kotlin 擴充套件(擴充套件函式和擴充套件屬性)Kotlin套件函式
- Iview元件庫之tree的第二種實現View元件
- Kotlin的解析(擴充)Kotlin
- ?用Chrome擴充套件管理器, 管理你的擴充套件Chrome套件
- form-create-designer中怎麼擴充套件自定義元件ORM套件元件
- Element-ui 級聯選擇器元件功能擴充套件UI元件套件
- 關於使用iview中Table元件的一點小技巧View元件
- Iview元件庫之樹形控制元件增刪改功能View控制元件
- JavaScript操作select控制元件JavaScript控制元件
- Element外掛中Select元件的報錯元件
- 正則的擴充套件套件
- SRAM的容量擴充套件套件
- 【Kotlin】擴充套件屬性、擴充套件函式Kotlin套件函式
- PHP擴充套件開發就是一個自己的PHP擴充套件PHP套件
- 開箱即用的後臺擴充套件 Laravel + Vue,3 分鐘搭建。強大的自定義擴充套件,豐富的第三方元件套件LaravelVue元件