這是一個重置密碼的彈窗,iview3的彈窗關閉和校驗會有衝突,我採用了自定義的寫法。html
<Modal v-model="modalPassword" :loading=true :mask-closable="false" @on-cancel="handleReset('resetPassword')"> <div slot="header"> <span>重置密碼</span> </div> <Form :model="resetPassword" ref="resetPassword" :rules="ruleValidate" :label-width="120"> <FormItem label="新密碼" prop="Firstpassword"> <Input v-model="resetPassword.Firstpassword"></Input> </FormItem> <FormItem label="確認密碼" prop="Secondpassword"> <Input v-model="resetPassword.Secondpassword"></Input> </FormItem> </Form> <div slot="footer"> <Button @click="handleReset('resetPassword')">取消</Button> <Button type="primary" @click="passwordOk">肯定重置</Button> </div> </Modal>
data() {
const pwdCheckValidate = (rule, value, callback) => {
let vm = this; if (value == '') { return callback(new Error('確認密碼不能爲空')); } else if (value != vm.resetPassword.Firstpassword) { return callback(new Error('兩次密碼不一致')); } else { callback(); } }; return { resetPassword:{}, ruleValidate:{ Firstpassword: [ { required: true, message: '新密碼不能爲空', trigger: 'blur' }, { type: 'string', pattern: /(?![0-9A-Z]+$)(?![0-9a-z]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/, message: '密碼由8-20位大小寫字母數字組成', trigger: 'blur' } ], Secondpassword: [ { required: true, trigger: 'blur', validator: pwdCheckValidate }, { type: 'string', pattern: /(?![0-9A-Z]+$)(?![0-9a-z]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/, message: '密碼由8-20位大小寫字母數字組成', trigger: 'blur' } ] } } }
注意:數據庫
handleReset(name) {
let vm = this;
if (this.$refs[name] !== undefined) { this.$refs[name].resetFields(); } }
加一個if判斷就能夠了api
緣由數組
<FormItem label="菜單名稱"> <CheckboxGroup v-model="addRole.list" v-for="(item,index) in menuArr" :key="index"> <Checkbox :label="item.menuName"></Checkbox> </CheckboxGroup> </FormItem>
注意markdown
靜態頁面iview
<checkbox-group v-model="pageItem.stu_batch"> <Checkbox label="1">綜合院校</Checkbox> <Checkbox label="2">提早批招生</Checkbox> <Checkbox label="3">無批次招生</Checkbox> <Checkbox label="4">第一批次招生</Checkbox> <Checkbox label="5">第二批次招生A</Checkbox> <Checkbox label="6">第二批次招生B</Checkbox> <Checkbox label="7">第三批次招生A</Checkbox> <Checkbox label="8">第三批次招生B</Checkbox> </checkbox-group>
//渲染頁面的數據ui
pageItem:{ stu_batch:[],//定義爲數組(官方api爲數組) }
與後臺交互的對象(須要與前面pageItem進行賦值)this
pageItemAddAndUpd: { stu_batch:"",//由於我這邊後臺接收的爲字符串 }
//這裏賦值須要進行判斷(由於若是是返回時空值沒有填數據的話須要進行判斷)spa
if(response.data.datalist[0].stu_batch==""||response.data.datalist[0].stu_batch==null){ this.pageItem.stu_batch = []; }else{ this.pageItem.stu_batch = JSON.parse(response.data.datalist[0].stu_batch); }
//這裏是保存操做code
this.pageItemAddAndUpd.stu_batch = JSON.stringify(this.pageItem.stu_batch)//須要將數組轉化成字符串進行後臺保存
父元素加個overflow: auto;就能夠了
setTimeout(_ => { vm.$Modal.confirm({ title: '登陸信息', content: '數據庫未發現該序列號' }); }, 500);
第二個彈窗加個延遲
h('Button', { props: { type: 'error', size: 'small' }, style: { marginRight: '5px', display: (params.row.isValid === 0 && this.type === 'tableRole') ? "inline-block" : "none" }, on: { click: () => { this.addRole.roleId = params.row.roleId; this.dataDelete.push(params.row); this.modalDelete = true; } } }, '刪除')
樣式中display判斷一下