给文本框增加回车跳转下一个的事件

This commit is contained in:
季圣华
2021-10-29 00:27:11 +08:00
parent deead4b32b
commit 8f30705c79
17 changed files with 216 additions and 159 deletions

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="accountModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="名称">
<a-input placeholder="请输入名称" v-decorator.trim="[ 'name', validatorRules.name]" />
</a-form-item>
@@ -38,6 +38,7 @@
<script>
import pick from 'lodash.pick'
import {addAccount,editAccount,checkAccount } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "AccountModal",
data () {
@@ -84,6 +85,7 @@
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'name', 'serialNo', 'initialAmount', 'currentAmount', 'remark'))
autoJumpNextInput('accountModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="customerModal">
<a-col :span="24/2">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="名称">
<a-input placeholder="请输入名称" v-decorator.trim="[ 'supplier', validatorRules.supplier]" />
@@ -93,6 +93,7 @@
<script>
import pick from 'lodash.pick'
import {addSupplier,editSupplier,checkSupplier } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "CustomerModal",
data () {
@@ -136,6 +137,7 @@
this.form.setFieldsValue(pick(this.model,'supplier', 'contacts', 'telephone', 'email', 'telephone',
'phoneNum', 'fax', 'beginNeedGet', 'beginNeedPay', 'allNeedGet', 'allNeedPay', 'taxNum', 'taxRate',
'bankName', 'accountNumber', 'address', 'description'))
autoJumpNextInput('customerModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="depotModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="仓库名称">
<a-input placeholder="请输入仓库名称" v-decorator.trim="[ 'name', validatorRules.name]" />
</a-form-item>
@@ -48,6 +48,7 @@
<script>
import pick from 'lodash.pick'
import {addDepot,editDepot,checkDepot,getUserList } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "DepotModal",
data () {
@@ -91,6 +92,7 @@
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,
'name', 'address', 'warehousing', 'truckage', 'principal', 'sort', 'remark'))
autoJumpNextInput('depotModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="functionModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="编号">
<a-input placeholder="请输入编号" v-decorator.trim="[ 'number', validatorRules.number]" />
</a-form-item>
@@ -50,6 +50,7 @@
<script>
import pick from 'lodash.pick'
import {addFunction,editFunction,checkFunction } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
import JSelectMultiple from '@/components/jeecg/JSelectMultiple'
export default {
name: "FunctionModal",
@@ -123,6 +124,7 @@
}
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'number', 'name', 'parentNumber', 'url', 'component', 'sort', 'pushBtn', 'icon', 'enabled'))
autoJumpNextInput('functionModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="inOutItemModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="名称">
<a-input placeholder="请输入名称" v-decorator.trim="[ 'name', validatorRules.name]" />
</a-form-item>
@@ -35,6 +35,7 @@
<script>
import pick from 'lodash.pick'
import {addInOutItem,editInOutItem,checkInOutItem } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "InOutItemModal",
data () {
@@ -80,6 +81,7 @@
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'name', 'type', 'remark'))
autoJumpNextInput('inOutItemModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="memberModal">
<a-col :span="24/2">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="名称">
<a-input placeholder="请输入名称" v-decorator.trim="[ 'supplier', validatorRules.supplier]" />
@@ -53,6 +53,7 @@
<script>
import pick from 'lodash.pick'
import {addSupplier,editSupplier,checkSupplier } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "MemberModal",
data () {
@@ -95,6 +96,7 @@
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'supplier', 'contacts', 'telephone', 'email', 'telephone',
'phoneNum', 'description'))
autoJumpNextInput('memberModal')
});
},
close () {

View File

@@ -11,7 +11,7 @@
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="organizationModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="名称">
<a-input placeholder="请输入名称" v-decorator="['orgAbr', validatorRules.orgAbr ]"/>
</a-form-item>
@@ -38,6 +38,7 @@
<script>
import { httpAction } from '@/api/manage'
import { queryOrganizationTreeList, checkOrganization } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
import pick from 'lodash.pick'
import ATextarea from 'ant-design-vue/es/input/TextArea'
export default {
@@ -107,6 +108,7 @@
this.loadTreeData();
this.$nextTick(() => {
this.form.setFieldsValue(pick(record, 'orgAbr', 'orgNo', 'parentId', 'sort', 'remark'))
autoJumpNextInput('organizationModal')
});
},
close () {

View File

@@ -1,142 +1,143 @@
<template>
<a-modal
title="重新设定密码"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleSubmit"
@cancel="handleCancel"
cancelText="关闭"
style="top:20px;"
>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item label="用户账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入用户账号" v-decorator="[ 'username', {}]" :readOnly="true"/>
</a-form-item>
<a-form-item label="登陆密码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
<a-input type="password" placeholder="请输入登陆密码" v-decorator="[ 'password', validatorRules.password]" />
</a-form-item>
<a-form-item label="确认密码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
<a-input type="password" @blur="handleConfirmBlur" placeholder="请重新输入登陆密码" v-decorator="[ 'confirmpassword', validatorRules.confirmpassword]"/>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import {changePassword} from '@/api/api'
export default {
name: "PasswordModal",
data () {
return {
visible: false,
confirmLoading: false,
confirmDirty: false,
validatorRules:{
password:{
rules: [{
required: true,
pattern:/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
message: '密码由8位数字、大小写字母和特殊符号组成!'
}, {
validator: this.validateToNextPassword,
}],
},
confirmpassword:{
rules: [{
required: true, message: '请重新输入登陆密码!',
}, {
validator: this.compareToFirstPassword,
}],
},
},
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
form:this.$form.createForm(this)
}
},
created () {
console.log("created");
},
methods: {
show (username) {
this.form.resetFields();
this.visible = true;
this.model.username = username;
this.$nextTick(() => {
this.form.setFieldsValue({username:username});
});
},
close () {
this.$emit('close');
this.visible = false;
this.disableSubmit = false;
this.selectedRole = [];
},
handleSubmit () {
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true;
let formData = Object.assign(this.model, values);
changePassword(formData).then((res)=>{
if(res.success){
this.$message.success(res.message);
this.$emit('ok');
}else{
this.$message.warning(res.message);
}
}).finally(() => {
this.confirmLoading = false;
this.close();
});
}
})
},
handleCancel () {
this.close()
},
validateToNextPassword (rule, value, callback) {
const form = this.form;
const confirmpassword=form.getFieldValue('confirmpassword');
console.log("confirmpassword==>",confirmpassword);
if (value && confirmpassword && value !== confirmpassword) {
callback('两次输入的密码不一样!');
}
if (value && this.confirmDirty) {
form.validateFields(['confirm'], { force: true })
}
callback();
},
compareToFirstPassword (rule, value, callback) {
const form = this.form;
if (value && value !== form.getFieldValue('password')) {
callback('两次输入的密码不一样!');
} else {
callback()
}
},
handleConfirmBlur (e) {
const value = e.target.value
this.confirmDirty = this.confirmDirty || !!value
}
}
}
<template>
<a-modal
title="重新设定密码"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleSubmit"
@cancel="handleCancel"
cancelText="关闭"
style="top:20px;"
>
<a-spin :spinning="confirmLoading">
<a-form :form="form" id="passwordModal">
<a-form-item label="用户账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入用户账号" v-decorator="[ 'username', {}]" :readOnly="true"/>
</a-form-item>
<a-form-item label="登陆密码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
<a-input type="password" placeholder="请输入登陆密码" v-decorator="[ 'password', validatorRules.password]" />
</a-form-item>
<a-form-item label="确认密码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
<a-input type="password" @blur="handleConfirmBlur" placeholder="请重新输入登陆密码" v-decorator="[ 'confirmpassword', validatorRules.confirmpassword]"/>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import {changePassword} from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "PasswordModal",
data () {
return {
visible: false,
confirmLoading: false,
confirmDirty: false,
validatorRules:{
password:{
rules: [{
required: true,
pattern:/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
message: '密码由8位数字、大小写字母和特殊符号组成!'
}, {
validator: this.validateToNextPassword,
}],
},
confirmpassword:{
rules: [{
required: true, message: '请重新输入登陆密码!',
}, {
validator: this.compareToFirstPassword,
}],
},
},
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
form:this.$form.createForm(this)
}
},
created () {
console.log("created");
},
methods: {
show (username) {
this.form.resetFields();
this.visible = true;
this.model.username = username;
this.$nextTick(() => {
this.form.setFieldsValue({username:username});
autoJumpNextInput('passwordModal')
});
},
close () {
this.$emit('close');
this.visible = false;
this.disableSubmit = false;
this.selectedRole = [];
},
handleSubmit () {
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true;
let formData = Object.assign(this.model, values);
changePassword(formData).then((res)=>{
if(res.success){
this.$message.success(res.message);
this.$emit('ok');
}else{
this.$message.warning(res.message);
}
}).finally(() => {
this.confirmLoading = false;
this.close();
});
}
})
},
handleCancel () {
this.close()
},
validateToNextPassword (rule, value, callback) {
const form = this.form;
const confirmpassword=form.getFieldValue('confirmpassword');
console.log("confirmpassword==>",confirmpassword);
if (value && confirmpassword && value !== confirmpassword) {
callback('两次输入的密码不一样!');
}
if (value && this.confirmDirty) {
form.validateFields(['confirm'], { force: true })
}
callback();
},
compareToFirstPassword (rule, value, callback) {
const form = this.form;
if (value && value !== form.getFieldValue('password')) {
callback('两次输入的密码不一样!');
} else {
callback()
}
},
handleConfirmBlur (e) {
const value = e.target.value
this.confirmDirty = this.confirmDirty || !!value
}
}
}
</script>

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="personModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="姓名">
<a-input placeholder="请输入姓名" v-decorator.trim="[ 'name', validatorRules.name]" />
</a-form-item>
@@ -33,6 +33,7 @@
<script>
import pick from 'lodash.pick'
import {addPerson,editPerson,checkPerson } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "PersonModal",
data () {
@@ -78,6 +79,7 @@
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'name', 'type', 'description'))
autoJumpNextInput('personModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="roleModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="角色名称">
<a-input placeholder="请输入角色名称" v-decorator.trim="[ 'name', validatorRules.name]" />
</a-form-item>
@@ -36,6 +36,7 @@
<script>
import pick from 'lodash.pick'
import {addRole,editRole,checkRole } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "RoleModal",
data () {
@@ -87,6 +88,7 @@
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'name', 'type', 'description'))
autoJumpNextInput('roleModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="systemConfigModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="公司名称">
<a-input placeholder="请输入公司名称" v-decorator.trim="[ 'companyName', validatorRules.companyName]" />
</a-form-item>
@@ -53,6 +53,7 @@
<script>
import pick from 'lodash.pick'
import {addSystemConfig,editSystemConfig,checkSystemConfig } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "SystemConfigModal",
data () {
@@ -110,6 +111,7 @@
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'companyName', 'companyContacts', 'companyAddress',
'companyTel', 'companyFax', 'companyPostCode', 'depotFlag', 'customerFlag', 'minusStockFlag'))
autoJumpNextInput('systemConfigModal')
});
if(record.id) {
if (record.depotFlag != null) {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="unitModal">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="基本单位">
<a-input placeholder="请输入基本单位(小单位)" v-decorator.trim="[ 'basicUnit', validatorRules.basicUnit]" />
</a-form-item>
@@ -36,6 +36,7 @@
<script>
import pick from 'lodash.pick'
import {addUnit,editUnit,checkUnit } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "UnitModal",
data () {
@@ -85,6 +86,7 @@
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'basicUnit','otherUnit','ratio'))
autoJumpNextInput('unitModal')
});
},
close () {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="userModal">
<a-form-item label="登录名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入登录名称" v-decorator.trim="[ 'loginName', validatorRules.loginName]" :readOnly="!!model.id"
suffix="初始密码123456" />
@@ -64,6 +64,7 @@
import {addUser,editUser,queryOrganizationTreeList,roleAllList} from '@/api/api'
import { disabledAuthFilter } from "@/utils/authFilter"
import {duplicateCheck } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
import JImageUpload from '../../../components/jeecg/JImageUpload'
export default {
name: "UserModal",
@@ -133,6 +134,7 @@
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'loginName','username','roleId','orgaId','position',
'phonenum','email','userBlngOrgaDsplSeq','description'))
autoJumpNextInput('userModal')
});
},
close() {

View File

@@ -15,7 +15,7 @@
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form :form="form" id="vendorModal">
<a-col :span="24/2">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="名称">
<a-input placeholder="请输入名称" v-decorator.trim="[ 'supplier', validatorRules.supplier]" />
@@ -93,6 +93,7 @@
<script>
import pick from 'lodash.pick'
import {addSupplier,editSupplier,checkSupplier } from '@/api/api'
import {autoJumpNextInput} from "@/utils/util"
export default {
name: "VendorModal",
data () {
@@ -136,6 +137,7 @@
this.form.setFieldsValue(pick(this.model,'supplier', 'contacts', 'telephone', 'email', 'telephone',
'phoneNum', 'fax', 'beginNeedGet', 'beginNeedPay', 'allNeedGet', 'allNeedPay', 'taxNum', 'taxRate',
'bankName', 'accountNumber', 'address', 'description'))
autoJumpNextInput('vendorModal')
});
},
close () {