增加租户界面、单据优化

This commit is contained in:
季圣华
2021-06-01 23:33:36 +08:00
parent 15245791c8
commit 6d7cbe7612
19 changed files with 279 additions and 26 deletions

View File

@@ -0,0 +1,99 @@
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :md="6" :sm="12">
<a-form-item label="登录名称">
<a-input placeholder="输入登录名称模糊查询" v-model="queryParam.loginName"></a-input>
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery">查询</a-button>
<a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!-- 操作按钮区域 -->
<div class="table-operator" style="border-top: 5px">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
</div>
<!-- table区域-begin -->
<div>
<a-table
ref="table"
bordered
size="middle"
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
</span>
</a-table>
</div>
<!-- table区域-end -->
<tenant-modal ref="modalForm" @ok="modalFormOk"></tenant-modal>
</a-card>
</template>
<script>
import TenantModal from './modules/TenantModal'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import JInput from '@/components/jeecg/JInput'
export default {
name: "TenantList",
mixins: [JeecgListMixin],
components: {
TenantModal,
JInput
},
data() {
return {
queryParam: {
loginName: ""
},
columns: [
{
title: '#',
dataIndex: '',
key:'rowIndex',
width:40,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
{ title: '登录名称', dataIndex: 'loginName', width: 100, align: "center"},
{ title: '用户数量限制', dataIndex: 'userNumLimit', width: 100, align: "center"},
{ title: '单据数量限制', dataIndex: 'billsNumLimit', width: 100, align: "center"},
{ title: '创建时间', dataIndex: 'createTimeStr', width: 100, align: "center"},
{
title: '操作',
dataIndex: 'action',
scopedSlots: {customRender: 'action'},
align: "center",
width: 100
}
],
url: {
list: "/tenant/list"
},
}
},
created () {
},
methods: {
}
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>

View File

@@ -0,0 +1,129 @@
<template>
<a-modal
:title="title"
:width="600"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭"
wrapClassName="ant-modal-cust-warp"
style="top:15%;height: 70%;overflow-y: hidden">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="登录名称">
<a-input placeholder="请输入登录名称" v-decorator.trim="[ 'loginName', validatorRules.loginName]" :readOnly="!!model.id"
suffix="初始密码123456" />
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="用户数量限制">
<a-input-number style="width:50%" placeholder="请输入用户数量限制" v-decorator.trim="[ 'userNumLimit' ]" />
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据数量限制">
<a-input-number style="width:50%" placeholder="请输入单据数量限制" v-decorator.trim="[ 'billsNumLimit' ]" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import pick from 'lodash.pick'
import {registerUser,editTenant,checkTenant } from '@/api/api'
export default {
name: "TenantModal",
data () {
return {
title:"操作",
visible: false,
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules:{
loginName:{
rules: [
{ required: true, message: '请输入登录名称!' },
{ min: 2, max: 30, message: '长度在 2 30 个字符', trigger: 'blur' },
{ validator: this.validateLoginName}
]
}
},
}
},
created () {
},
methods: {
add () {
this.edit({});
},
edit (record) {
this.form.resetFields();
this.model = Object.assign({}, record);
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'loginName', 'userNumLimit', 'billsNumLimit'))
});
},
close () {
this.$emit('close');
this.visible = false;
},
handleOk () {
const that = this;
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true;
let formData = Object.assign(this.model, values);
let obj;
if(!this.model.id){
formData.password = '123456'
obj=registerUser(formData);
}else{
obj=editTenant(formData);
}
obj.then((res)=>{
if(res.code === 200){
that.$emit('ok');
}else{
that.$message.warning(res.data.message);
}
}).finally(() => {
that.confirmLoading = false;
that.close();
})
}
})
},
handleCancel () {
this.close()
},
validateLoginName(rule, value, callback){
let params = {
name: value,
id: this.model.id?this.model.id:0
};
checkTenant(params).then((res)=>{
if(res && res.code===200) {
if(!res.data.status){
callback();
} else {
callback("登录名称已经存在");
}
} else {
callback(res.data);
}
});
}
}
}
</script>
<style scoped>
</style>