update .gitignore
This commit is contained in:
@@ -1,363 +1,363 @@
|
||||
<template>
|
||||
<!--
|
||||
普通编辑窗体
|
||||
v 1.2
|
||||
2021-04-30
|
||||
Lufthafen
|
||||
-->
|
||||
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
|
||||
<a-spin :spinning="loading">
|
||||
<a-icon slot="indicator" spin type="loading" />
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="10">
|
||||
<h3 class="h3">基本信息</h3>
|
||||
<div class="yo-form-group">
|
||||
<a-form-model-item label="账号" prop="account">
|
||||
<a-input placeholder="请输入账号" v-model="form.account" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="姓名" prop="name">
|
||||
<a-input placeholder="请输入姓名" v-model="form.name" />
|
||||
</a-form-model-item>
|
||||
<template v-if="mode == 'add'">
|
||||
<a-form-model-item label="密码" prop="password">
|
||||
<a-input-password placeholder="请输入密码" v-model="form.password" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="确认密码" prop="confirm">
|
||||
<a-input-password placeholder="请确认密码" v-model="form.confirm" />
|
||||
</a-form-model-item>
|
||||
</template>
|
||||
<a-form-model-item label="昵称">
|
||||
<a-input placeholder="请输入昵称" v-model="form.nickName" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="生日">
|
||||
<a-date-picker
|
||||
@change="(date) => form.birthday = date ? $moment(date).format('YYYY-MM-DD') : null"
|
||||
class="w-100-p"
|
||||
placeholder="请选择生日"
|
||||
v-model="form.birthday"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="性别" prop="sex">
|
||||
<a-radio-group v-model="form.sex">
|
||||
<a-radio-button :value="0">
|
||||
<a-icon class="mr-xxs" type="stop" />
|
||||
<span>保密</span>
|
||||
</a-radio-button>
|
||||
<a-radio-button :value="1">
|
||||
<a-icon :style="{ color: '#1890ff' }" class="mr-xxs" type="man" />
|
||||
<span>男</span>
|
||||
</a-radio-button>
|
||||
<a-radio-button :value="2">
|
||||
<a-icon :style="{ color: '#eb2f96' }" class="mr-xxs" type="woman" />
|
||||
<span>女</span>
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="邮箱" prop="email">
|
||||
<a-input placeholder="请输入邮箱" v-model="form.email" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="手机号" prop="phone">
|
||||
<a-input placeholder="请输入手机号" v-model="form.phone" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="电话" prop="tel">
|
||||
<a-input placeholder="请输入电话" v-model="form.tel" />
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
<a-col :span="14" v-if="form.sysEmpParam">
|
||||
<h3 class="h3">员工信息</h3>
|
||||
<div class="yo-form-group">
|
||||
<a-form-model-item label="所属组织机构" prop="sysEmpParam.orgId">
|
||||
<a-tree-select
|
||||
:dropdown-style="{ maxHeight: '300px', overflow: 'auto' }"
|
||||
:tree-data="orgData"
|
||||
placeholder="请选择所属组织机构"
|
||||
tree-default-expand-all
|
||||
v-model="form.sysEmpParam.orgId"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="工号">
|
||||
<a-input placeholder="请输入工号" v-model="form.sysEmpParam.jobNum" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="职位信息" prop="sysEmpParam.posIdList">
|
||||
<a-select mode="multiple" placeholder="请选择职位信息" v-model="form.sysEmpParam.posIdList">
|
||||
<a-select-option
|
||||
:key="i"
|
||||
:value="item.id"
|
||||
v-for="(item, i) in posData"
|
||||
>{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
<h4 class="h4">附加信息</h4>
|
||||
<div class="pl-md pr-md">
|
||||
<a-table
|
||||
:columns="extColumns"
|
||||
:data-source="form.sysEmpParam.extIds"
|
||||
:pagination="false"
|
||||
size="small"
|
||||
>
|
||||
<template slot="footer">
|
||||
<a-button @click="onAddExtData" block icon="plus" type="dashed">新增一项</a-button>
|
||||
</template>
|
||||
<template slot="orgId" slot-scope="text, record">
|
||||
<a-tree-select
|
||||
:default-value="text"
|
||||
:dropdown-style="{ maxHeight: '300px', overflow: 'auto' }"
|
||||
:tree-data="orgData"
|
||||
@change="value => onChangeExtData(value, record, 'orgId')"
|
||||
placeholder="请选择附加组织机构"
|
||||
tree-default-expand-all
|
||||
/>
|
||||
</template>
|
||||
<template slot="posId" slot-scope="text, record">
|
||||
<a-select
|
||||
:default-value="text"
|
||||
@change="value => onChangeExtData(value, record, 'posId')"
|
||||
placeholder="请选择附加职位信息"
|
||||
>
|
||||
<a-select-option
|
||||
:key="i"
|
||||
:value="item.id"
|
||||
v-for="(item, i) in posData"
|
||||
>{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
<template slot="action" slot-scope="text, record">
|
||||
<a-button @click="onRemoveExtData(record)" size="small" type="danger">删除</a-button>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-spin>
|
||||
</a-form-model>
|
||||
</template>
|
||||
<script>
|
||||
const validateToNextPassword = (rule, value, callback) => {
|
||||
callback();
|
||||
};
|
||||
const compareToFirstPassword = (rule, value, callback) => {
|
||||
callback();
|
||||
};
|
||||
|
||||
/* 表单内容默认值 */
|
||||
const defaultForm = {
|
||||
/* ... */
|
||||
sex: 0,
|
||||
sysEmpParam: {},
|
||||
};
|
||||
|
||||
export default {
|
||||
props: {
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'edit',
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
/** 表单数据 */
|
||||
form: {},
|
||||
/** 验证格式 */
|
||||
rules: {
|
||||
/* ... */
|
||||
account: [{ required: true, min: 5, message: '请输入至少五个字符的账号', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
password: [
|
||||
{ required: true, min: 5, message: '请输入至少五个字符的密码', trigger: 'blur' },
|
||||
{ validator: validateToNextPassword, trigger: 'blur' },
|
||||
],
|
||||
confirm: [
|
||||
{ required: true, message: '请确认密码', trigger: 'blur' },
|
||||
{ validator: compareToFirstPassword, trigger: 'blur' },
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
pattern: /^((13[0-9])|(14[5,7])|(15[^4,\\D])|(17[0,1,3,6-8])|(18[0-9])|(19[8,9])|(166))[0-9]{8}$/,
|
||||
message: '手机号格式不正确',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
email: [
|
||||
{ pattern: /^\w{3,}(\.\w+)*@[A-z0-9]+(\.[A-z]{2,5}){1,2}$/, message: '邮箱格式不正确', trigger: 'blur' },
|
||||
],
|
||||
'sysEmpParam.orgId': [{ required: true, message: '请选择所属组织机构' }],
|
||||
'sysEmpParam.posIdList': [{ required: true, message: '请选择职位信息' }],
|
||||
},
|
||||
|
||||
/** 加载异步数据状态 */
|
||||
loading: false,
|
||||
|
||||
/** 其他成员属性 */
|
||||
/* ... */
|
||||
orgData: [],
|
||||
posData: [],
|
||||
|
||||
extColumns: [
|
||||
{
|
||||
title: '附属机构',
|
||||
dataIndex: 'orgId',
|
||||
width: '45%',
|
||||
scopedSlots: { customRender: 'orgId' },
|
||||
},
|
||||
{
|
||||
title: '附属岗位',
|
||||
dataIndex: 'posId',
|
||||
width: '45%',
|
||||
scopedSlots: { customRender: 'posId' },
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: '70px',
|
||||
scopedSlots: { customRender: 'action' },
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 必要的方法
|
||||
* 在打开编辑页时允许填充数据
|
||||
*/
|
||||
onFillData(params) {
|
||||
const form = this.$_.cloneDeep(params.record || {});
|
||||
// 日期特殊处理
|
||||
if (form.birthday) {
|
||||
form.birthday = this.$moment(form.birthday).format('YYYY-MM-DD');
|
||||
}
|
||||
// 提交的时候是"param",而获取下来却是"info",在这里转换一下
|
||||
if (form.sysEmpInfo) {
|
||||
form.sysEmpParam = form.sysEmpInfo;
|
||||
delete form.sysEmpInfo;
|
||||
} else if (!form.sysEmpParam) {
|
||||
form.sysEmpParam = {
|
||||
extIds: [],
|
||||
};
|
||||
}
|
||||
// 转换职位信息列表
|
||||
if (form.sysEmpParam.positions) {
|
||||
form.sysEmpParam.posIdList = form.sysEmpParam.positions.map((p) => p.posId);
|
||||
}
|
||||
// 附加信息
|
||||
if (form.sysEmpParam.extOrgPos) {
|
||||
form.sysEmpParam.extIds = form.sysEmpParam.extOrgPos.map((p, i) => {
|
||||
return {
|
||||
key: i,
|
||||
orgId: p.orgId,
|
||||
posId: p.posId,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (params.orgId) {
|
||||
form.sysEmpParam.orgId = orgId;
|
||||
}
|
||||
|
||||
/** 将默认数据覆盖到form */
|
||||
this.form = this.$_.cloneDeep({
|
||||
...defaultForm,
|
||||
...form,
|
||||
/** 在此处添加其他默认数据转换 */
|
||||
/* ... */
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 验证表单并获取表单数据
|
||||
*/
|
||||
onGetData() {
|
||||
return new Promise((reslove, reject) => {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const record = this.$_.cloneDeep(this.form);
|
||||
|
||||
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
|
||||
/* ... */
|
||||
|
||||
reslove(record);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要的方法
|
||||
* 在外部窗口进行保存时调用表单验证
|
||||
*/
|
||||
onValidate(callback) {
|
||||
this.$refs.form.validate(callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要的方法
|
||||
* 在外部窗口关闭或重置时对表单验证进行初始化
|
||||
*/
|
||||
onResetFields() {
|
||||
setTimeout(() => {
|
||||
this.$refs.form.resetFields();
|
||||
|
||||
/** 在这里可以初始化当前组件中其他属性 */
|
||||
/* ... */
|
||||
this.form = {
|
||||
...defaultForm,
|
||||
};
|
||||
}, 300);
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 加载当前表单中所需要的异步数据
|
||||
*/
|
||||
async onInit(params) {
|
||||
this.loading = true;
|
||||
/** 可以在这里await获取一些异步数据 */
|
||||
/* ... */
|
||||
this.orgData = await this.onLoadOrgData();
|
||||
this.posData = await this.onLoadPosData();
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
/** 当前组件的其他方法 */
|
||||
/* ... */
|
||||
|
||||
onLoadOrgData() {
|
||||
return this.$api.getOrgTree().then(({ data }) => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
onLoadPosData() {
|
||||
return this.$api.sysPosList().then(({ data }) => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
onAddExtData() {
|
||||
this.form.sysEmpParam.extIds.push({
|
||||
key: this.form.sysEmpParam.extIds.length,
|
||||
orgId: undefined,
|
||||
posId: undefined,
|
||||
});
|
||||
},
|
||||
|
||||
onRemoveExtData(record) {
|
||||
const ext = this.form.sysEmpParam.extIds,
|
||||
remove = ext.find((p) => p.key === record.key),
|
||||
index = ext.indexOf(remove);
|
||||
|
||||
ext.splice(index, 1);
|
||||
},
|
||||
|
||||
onChangeExtData(value, record, type) {
|
||||
record[type] = value;
|
||||
},
|
||||
},
|
||||
};
|
||||
<template>
|
||||
<!--
|
||||
普通编辑窗体
|
||||
v 1.2
|
||||
2021-04-30
|
||||
Lufthafen
|
||||
-->
|
||||
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
|
||||
<a-spin :spinning="loading">
|
||||
<a-icon slot="indicator" spin type="loading" />
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="10">
|
||||
<h3 class="h3">基本信息</h3>
|
||||
<div class="yo-form-group">
|
||||
<a-form-model-item label="账号" prop="account">
|
||||
<a-input placeholder="请输入账号" v-model="form.account" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="姓名" prop="name">
|
||||
<a-input placeholder="请输入姓名" v-model="form.name" />
|
||||
</a-form-model-item>
|
||||
<template v-if="mode == 'add'">
|
||||
<a-form-model-item label="密码" prop="password">
|
||||
<a-input-password placeholder="请输入密码" v-model="form.password" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="确认密码" prop="confirm">
|
||||
<a-input-password placeholder="请确认密码" v-model="form.confirm" />
|
||||
</a-form-model-item>
|
||||
</template>
|
||||
<a-form-model-item label="昵称">
|
||||
<a-input placeholder="请输入昵称" v-model="form.nickName" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="生日">
|
||||
<a-date-picker
|
||||
@change="(date) => form.birthday = date ? $moment(date).format('YYYY-MM-DD') : null"
|
||||
class="w-100-p"
|
||||
placeholder="请选择生日"
|
||||
v-model="form.birthday"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="性别" prop="sex">
|
||||
<a-radio-group v-model="form.sex">
|
||||
<a-radio-button :value="0">
|
||||
<a-icon class="mr-xxs" type="stop" />
|
||||
<span>保密</span>
|
||||
</a-radio-button>
|
||||
<a-radio-button :value="1">
|
||||
<a-icon :style="{ color: '#1890ff' }" class="mr-xxs" type="man" />
|
||||
<span>男</span>
|
||||
</a-radio-button>
|
||||
<a-radio-button :value="2">
|
||||
<a-icon :style="{ color: '#eb2f96' }" class="mr-xxs" type="woman" />
|
||||
<span>女</span>
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="邮箱" prop="email">
|
||||
<a-input placeholder="请输入邮箱" v-model="form.email" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="手机号" prop="phone">
|
||||
<a-input placeholder="请输入手机号" v-model="form.phone" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="电话" prop="tel">
|
||||
<a-input placeholder="请输入电话" v-model="form.tel" />
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
<a-col :span="14" v-if="form.sysEmpParam">
|
||||
<h3 class="h3">员工信息</h3>
|
||||
<div class="yo-form-group">
|
||||
<a-form-model-item label="所属组织机构" prop="sysEmpParam.orgId">
|
||||
<a-tree-select
|
||||
:dropdown-style="{ maxHeight: '300px', overflow: 'auto' }"
|
||||
:tree-data="orgData"
|
||||
placeholder="请选择所属组织机构"
|
||||
tree-default-expand-all
|
||||
v-model="form.sysEmpParam.orgId"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="工号">
|
||||
<a-input placeholder="请输入工号" v-model="form.sysEmpParam.jobNum" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="职位信息" prop="sysEmpParam.posIdList">
|
||||
<a-select mode="multiple" placeholder="请选择职位信息" v-model="form.sysEmpParam.posIdList">
|
||||
<a-select-option
|
||||
:key="i"
|
||||
:value="item.id"
|
||||
v-for="(item, i) in posData"
|
||||
>{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
<h4 class="h4">附加信息</h4>
|
||||
<div class="pl-md pr-md">
|
||||
<a-table
|
||||
:columns="extColumns"
|
||||
:data-source="form.sysEmpParam.extIds"
|
||||
:pagination="false"
|
||||
size="small"
|
||||
>
|
||||
<template slot="footer">
|
||||
<a-button @click="onAddExtData" block icon="plus" type="dashed">新增一项</a-button>
|
||||
</template>
|
||||
<template slot="orgId" slot-scope="text, record">
|
||||
<a-tree-select
|
||||
:default-value="text"
|
||||
:dropdown-style="{ maxHeight: '300px', overflow: 'auto' }"
|
||||
:tree-data="orgData"
|
||||
@change="value => onChangeExtData(value, record, 'orgId')"
|
||||
placeholder="请选择附加组织机构"
|
||||
tree-default-expand-all
|
||||
/>
|
||||
</template>
|
||||
<template slot="posId" slot-scope="text, record">
|
||||
<a-select
|
||||
:default-value="text"
|
||||
@change="value => onChangeExtData(value, record, 'posId')"
|
||||
placeholder="请选择附加职位信息"
|
||||
>
|
||||
<a-select-option
|
||||
:key="i"
|
||||
:value="item.id"
|
||||
v-for="(item, i) in posData"
|
||||
>{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
<template slot="action" slot-scope="text, record">
|
||||
<a-button @click="onRemoveExtData(record)" size="small" type="danger">删除</a-button>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-spin>
|
||||
</a-form-model>
|
||||
</template>
|
||||
<script>
|
||||
const validateToNextPassword = (rule, value, callback) => {
|
||||
callback();
|
||||
};
|
||||
const compareToFirstPassword = (rule, value, callback) => {
|
||||
callback();
|
||||
};
|
||||
|
||||
/* 表单内容默认值 */
|
||||
const defaultForm = {
|
||||
/* ... */
|
||||
sex: 0,
|
||||
sysEmpParam: {},
|
||||
};
|
||||
|
||||
export default {
|
||||
props: {
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'edit',
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
/** 表单数据 */
|
||||
form: {},
|
||||
/** 验证格式 */
|
||||
rules: {
|
||||
/* ... */
|
||||
account: [{ required: true, min: 5, message: '请输入至少五个字符的账号', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
password: [
|
||||
{ required: true, min: 5, message: '请输入至少五个字符的密码', trigger: 'blur' },
|
||||
{ validator: validateToNextPassword, trigger: 'blur' },
|
||||
],
|
||||
confirm: [
|
||||
{ required: true, message: '请确认密码', trigger: 'blur' },
|
||||
{ validator: compareToFirstPassword, trigger: 'blur' },
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
pattern: /^((13[0-9])|(14[5,7])|(15[^4,\\D])|(17[0,1,3,6-8])|(18[0-9])|(19[8,9])|(166))[0-9]{8}$/,
|
||||
message: '手机号格式不正确',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
email: [
|
||||
{ pattern: /^\w{3,}(\.\w+)*@[A-z0-9]+(\.[A-z]{2,5}){1,2}$/, message: '邮箱格式不正确', trigger: 'blur' },
|
||||
],
|
||||
'sysEmpParam.orgId': [{ required: true, message: '请选择所属组织机构' }],
|
||||
'sysEmpParam.posIdList': [{ required: true, message: '请选择职位信息' }],
|
||||
},
|
||||
|
||||
/** 加载异步数据状态 */
|
||||
loading: false,
|
||||
|
||||
/** 其他成员属性 */
|
||||
/* ... */
|
||||
orgData: [],
|
||||
posData: [],
|
||||
|
||||
extColumns: [
|
||||
{
|
||||
title: '附属机构',
|
||||
dataIndex: 'orgId',
|
||||
width: '45%',
|
||||
scopedSlots: { customRender: 'orgId' },
|
||||
},
|
||||
{
|
||||
title: '附属岗位',
|
||||
dataIndex: 'posId',
|
||||
width: '45%',
|
||||
scopedSlots: { customRender: 'posId' },
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: '70px',
|
||||
scopedSlots: { customRender: 'action' },
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 必要的方法
|
||||
* 在打开编辑页时允许填充数据
|
||||
*/
|
||||
onFillData(params) {
|
||||
const form = this.$_.cloneDeep(params.record || {});
|
||||
// 日期特殊处理
|
||||
if (form.birthday) {
|
||||
form.birthday = this.$moment(form.birthday).format('YYYY-MM-DD');
|
||||
}
|
||||
// 提交的时候是"param",而获取下来却是"info",在这里转换一下
|
||||
if (form.sysEmpInfo) {
|
||||
form.sysEmpParam = form.sysEmpInfo;
|
||||
delete form.sysEmpInfo;
|
||||
} else if (!form.sysEmpParam) {
|
||||
form.sysEmpParam = {
|
||||
extIds: [],
|
||||
};
|
||||
}
|
||||
// 转换职位信息列表
|
||||
if (form.sysEmpParam.positions) {
|
||||
form.sysEmpParam.posIdList = form.sysEmpParam.positions.map((p) => p.posId);
|
||||
}
|
||||
// 附加信息
|
||||
if (form.sysEmpParam.extOrgPos) {
|
||||
form.sysEmpParam.extIds = form.sysEmpParam.extOrgPos.map((p, i) => {
|
||||
return {
|
||||
key: i,
|
||||
orgId: p.orgId,
|
||||
posId: p.posId,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (params.orgId) {
|
||||
form.sysEmpParam.orgId = orgId;
|
||||
}
|
||||
|
||||
/** 将默认数据覆盖到form */
|
||||
this.form = this.$_.cloneDeep({
|
||||
...defaultForm,
|
||||
...form,
|
||||
/** 在此处添加其他默认数据转换 */
|
||||
/* ... */
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 验证表单并获取表单数据
|
||||
*/
|
||||
onGetData() {
|
||||
return new Promise((reslove, reject) => {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const record = this.$_.cloneDeep(this.form);
|
||||
|
||||
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
|
||||
/* ... */
|
||||
|
||||
reslove(record);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要的方法
|
||||
* 在外部窗口进行保存时调用表单验证
|
||||
*/
|
||||
onValidate(callback) {
|
||||
this.$refs.form.validate(callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要的方法
|
||||
* 在外部窗口关闭或重置时对表单验证进行初始化
|
||||
*/
|
||||
onResetFields() {
|
||||
setTimeout(() => {
|
||||
this.$refs.form.resetFields();
|
||||
|
||||
/** 在这里可以初始化当前组件中其他属性 */
|
||||
/* ... */
|
||||
this.form = {
|
||||
...defaultForm,
|
||||
};
|
||||
}, 300);
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 加载当前表单中所需要的异步数据
|
||||
*/
|
||||
async onInit(params) {
|
||||
this.loading = true;
|
||||
/** 可以在这里await获取一些异步数据 */
|
||||
/* ... */
|
||||
this.orgData = await this.onLoadOrgData();
|
||||
this.posData = await this.onLoadPosData();
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
/** 当前组件的其他方法 */
|
||||
/* ... */
|
||||
|
||||
onLoadOrgData() {
|
||||
return this.$api.getOrgTree().then(({ data }) => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
onLoadPosData() {
|
||||
return this.$api.sysPosList().then(({ data }) => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
onAddExtData() {
|
||||
this.form.sysEmpParam.extIds.push({
|
||||
key: this.form.sysEmpParam.extIds.length,
|
||||
orgId: undefined,
|
||||
posId: undefined,
|
||||
});
|
||||
},
|
||||
|
||||
onRemoveExtData(record) {
|
||||
const ext = this.form.sysEmpParam.extIds,
|
||||
remove = ext.find((p) => p.key === record.key),
|
||||
index = ext.indexOf(remove);
|
||||
|
||||
ext.splice(index, 1);
|
||||
},
|
||||
|
||||
onChangeExtData(value, record, type) {
|
||||
record[type] = value;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,384 +1,384 @@
|
||||
<template>
|
||||
<!--
|
||||
普通树查询表格
|
||||
v 1.2
|
||||
2021-04-30
|
||||
Lufthafen
|
||||
-->
|
||||
<yo-tree-layout
|
||||
:load-data="loadTreeData"
|
||||
@select="onSelect"
|
||||
default-expanded-keys
|
||||
ref="tree-layout"
|
||||
>
|
||||
<container>
|
||||
<a-card :bordered="false">
|
||||
<Auth auth="sysUser:page">
|
||||
<div class="yo-query-bar">
|
||||
<a-form-model :model="query" @submit.native.prevent layout="inline">
|
||||
<a-form-model-item label="关键词">
|
||||
<a-input allow-clear placeholder="请输入姓名、账号、手机号" v-model="query.searchValue" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="状态">
|
||||
<a-select
|
||||
:style="{ width: '170px' }"
|
||||
allow-clear
|
||||
placeholder="请选择状态"
|
||||
v-model="query.searchStatus"
|
||||
>
|
||||
<a-select-option
|
||||
:key="i"
|
||||
:value="item.code"
|
||||
v-for="(item, i) in codes.common_status"
|
||||
>{{ item.value }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item>
|
||||
<a-button-group>
|
||||
<a-button @click="onQuery" html-type="submit" type="primary">查询</a-button>
|
||||
<a-button @click="onReset">重置</a-button>
|
||||
</a-button-group>
|
||||
</a-form-model-item>
|
||||
</a-form-model>
|
||||
</div>
|
||||
</Auth>
|
||||
|
||||
<yo-list :load-data="loadData" item-layout="horizontal" ref="list" size="large">
|
||||
<Auth auth="sysUser:add" slot="operator">
|
||||
<a-button @click="onOpen('add-form')" icon="plus">新增用户</a-button>
|
||||
</Auth>
|
||||
<a-list-item key="record.id" slot="renderItem" slot-scope="record">
|
||||
<Auth auth="sysUser:edit" slot="actions">
|
||||
<a @click="onOpen('edit-form', record)">编辑</a>
|
||||
</Auth>
|
||||
<Auth auth="sysUser:delete" slot="actions">
|
||||
<a-popconfirm @confirm="onDelete(record)" placement="topRight" title="是否确认删除">
|
||||
<a>删除</a>
|
||||
</a-popconfirm>
|
||||
</Auth>
|
||||
<Auth :auth="{ sysUser: [['grantRole'], ['grantData']] }" slot="actions">
|
||||
<a-dropdown placement="bottomRight">
|
||||
<a class="ant-dropdown-link">
|
||||
授权
|
||||
<a-icon type="down" />
|
||||
</a>
|
||||
<a-menu slot="overlay">
|
||||
<Auth auth="sysUser:grantRole">
|
||||
<a-menu-item>
|
||||
<a @click="onOpen('role-form', record)">授权角色</a>
|
||||
</a-menu-item>
|
||||
</Auth>
|
||||
<Auth auth="sysUser:grantData">
|
||||
<a-menu-item>
|
||||
<a @click="onOpen('data-form', record)">授权额外数据</a>
|
||||
</a-menu-item>
|
||||
</Auth>
|
||||
</a-menu>
|
||||
</a-dropdown>
|
||||
</Auth>
|
||||
<a-list-item-meta>
|
||||
<div slot="title">{{ record.nickName || record.name }}</div>
|
||||
<div slot="description">{{ record.account }}</div>
|
||||
<yo-image
|
||||
:id="record.avatar"
|
||||
:size="48"
|
||||
icon="user"
|
||||
shape="square"
|
||||
slot="avatar"
|
||||
type="avatar"
|
||||
/>
|
||||
</a-list-item-meta>
|
||||
<div class="yo-list-content--h">
|
||||
<div class="yo-list-content--h--item">
|
||||
<span>性别</span>
|
||||
<p>{{ bindCodeValue(record.sex, 'sex') }}</p>
|
||||
</div>
|
||||
<div class="yo-list-content--h--item">
|
||||
<span>手机</span>
|
||||
<p>{{ record.phone || '未设置' }}</p>
|
||||
</div>
|
||||
<div class="yo-list-content--h--item">
|
||||
<span>邮箱</span>
|
||||
<p>{{ record.email || '未设置' }}</p>
|
||||
</div>
|
||||
<Auth auth="sysUser:changeStatus">
|
||||
<div class="yo-list-content--h--item text-center">
|
||||
<a-switch
|
||||
:checked="!record.status"
|
||||
:checked-children="bindCodeValue(0, 'common_status')"
|
||||
:loading="record.statusChanging"
|
||||
:un-checked-children="bindCodeValue(1, 'common_status')"
|
||||
@change="(checked) => onSetUserStatus(record, checked)"
|
||||
/>
|
||||
</div>
|
||||
</Auth>
|
||||
</div>
|
||||
</a-list-item>
|
||||
</yo-list>
|
||||
</a-card>
|
||||
</container>
|
||||
|
||||
<!-- 新增表单 -->
|
||||
<yo-modal-form
|
||||
:action="$api[api.add]"
|
||||
:title="'新增' + name"
|
||||
:width="1024"
|
||||
@ok="onReloadData"
|
||||
ref="add-form"
|
||||
>
|
||||
<form-body mode="add" />
|
||||
</yo-modal-form>
|
||||
|
||||
<!-- 编辑表单 -->
|
||||
<yo-modal-form
|
||||
:action="$api[api.edit]"
|
||||
:title="'编辑' + name"
|
||||
:width="1024"
|
||||
@ok="onReloadData"
|
||||
ref="edit-form"
|
||||
>
|
||||
<form-body mode="edit" />
|
||||
</yo-modal-form>
|
||||
|
||||
<role-form @ok="onReloadData" ref="role-form" />
|
||||
<data-form @ok="onReloadData" ref="data-form" />
|
||||
</yo-tree-layout>
|
||||
</template>
|
||||
<script>
|
||||
/* 需要引用YoTreeLayout组件 */
|
||||
import YoTreeLayout from '@/components/yoTreeLayout';
|
||||
import YoList from '@/components/yoList';
|
||||
import FormBody from './form';
|
||||
|
||||
import RoleForm from './roleForm';
|
||||
import DataForm from './dataForm';
|
||||
|
||||
/* 在此管理整个页面需要的接口名称 */
|
||||
const api = {
|
||||
tree: 'getOrgTree',
|
||||
page: 'getUserPage',
|
||||
add: 'sysUserAdd',
|
||||
edit: 'sysUserEdit',
|
||||
delete: 'sysUserDelete',
|
||||
/* ... */
|
||||
};
|
||||
|
||||
export default {
|
||||
components: {
|
||||
YoTreeLayout,
|
||||
YoList,
|
||||
FormBody,
|
||||
RoleForm,
|
||||
DataForm,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
api,
|
||||
|
||||
name: '用户',
|
||||
|
||||
/* 查询条件 */
|
||||
query: {},
|
||||
|
||||
/* 表格字段 */
|
||||
columns: [],
|
||||
|
||||
/* 字典编码储存格式 */
|
||||
codes: {
|
||||
sex: [],
|
||||
common_status: [],
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
this.onLoadCodes();
|
||||
|
||||
/** 根据权限添加操作列 */
|
||||
const flag = this.$auth({
|
||||
sysUser: [['edit'], ['delete'], ['grantRole'], ['grantData']],
|
||||
});
|
||||
if (flag) {
|
||||
this.columns.push({
|
||||
title: '操作',
|
||||
width: '150px',
|
||||
dataIndex: 'action',
|
||||
scopedSlots: { customRender: 'action' },
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 树形选择界面必要的方法
|
||||
* 传给yo-table-layout以示意数据接口
|
||||
*/
|
||||
loadTreeData() {
|
||||
return this.$api[api.tree]().then((res) => {
|
||||
return res.data;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 树形选择界面必要的方法
|
||||
* 选择树节点事件
|
||||
*/
|
||||
onSelect([id]) {
|
||||
/** 在选择事件中可以对右侧表格添加父节点id的查询条件 */
|
||||
this.query = {
|
||||
'sysEmpParam.orgId': id,
|
||||
};
|
||||
this.onQuery();
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要的方法
|
||||
* 传给yo-table以示意数据接口及其参数和返回的数据结构
|
||||
*/
|
||||
loadData(params) {
|
||||
return this.$api[api.page]({
|
||||
...params,
|
||||
...this.query,
|
||||
}).then((res) => {
|
||||
return res.data;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 有查询功能时的必要方法
|
||||
* 加载数据时初始化分页信息
|
||||
*/
|
||||
onQuery() {
|
||||
this.$refs.list.onReloadData(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 重新列表数据
|
||||
*/
|
||||
onReset() {
|
||||
/* 与普通查询页不同的是,这里的父节点参数不应该在重置后被清空 */
|
||||
Object.keys(this.query).forEach((p) => {
|
||||
if (p !== 'pid') {
|
||||
this.query[p] = undefined;
|
||||
}
|
||||
});
|
||||
this.onQuery();
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 重新列表数据
|
||||
*/
|
||||
onReloadData() {
|
||||
this.$refs.list.onReloadData();
|
||||
this.$refs['tree-layout'].onReloadData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 加载字典数据
|
||||
* 如果不需要获取相应的字典数据,此方法内容可空
|
||||
*/
|
||||
onLoadCodes() {
|
||||
this.$api
|
||||
.$queue([
|
||||
this.$api.sysDictTypeDropDownAwait({ code: 'sex' }),
|
||||
this.$api.sysDictTypeDropDownAwait({ code: 'common_status' }),
|
||||
/* ... */
|
||||
])
|
||||
.then(([code1, code2]) => {
|
||||
this.codes.sex = code1.data;
|
||||
this.codes.common_status = code2.data;
|
||||
/* ... */
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 绑定数据字典值
|
||||
*/
|
||||
bindCodeValue(code, name) {
|
||||
const c = this.codes[name].find((p) => p.code == code);
|
||||
if (c) {
|
||||
return c.value;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* 有编辑新增功能的必要方法
|
||||
* 从列表页调用窗口的打开方法
|
||||
*/
|
||||
onOpen(formName, record) {
|
||||
this.$refs[formName].onOpen({
|
||||
record,
|
||||
orgId: this.query['sysEmpParam.orgId'],
|
||||
/* 按需添加其他参数 */
|
||||
/* ... */
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 可以用做一系列操作的公共回调,此方法中会重新加载当前列表
|
||||
*/
|
||||
onResult(success, successMessage) {
|
||||
if (success) {
|
||||
this.$message.success(successMessage);
|
||||
this.onReloadData();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 删除时调用
|
||||
*/
|
||||
onDelete(record) {
|
||||
this.$refs.list.onLoading();
|
||||
this.$api[api.delete](record)
|
||||
.then(({ success }) => {
|
||||
this.onResult(success, '删除成功');
|
||||
})
|
||||
.finally(() => {
|
||||
this.$refs.list.onLoaded();
|
||||
});
|
||||
},
|
||||
|
||||
onSetUserStatus(record, checked) {
|
||||
this.$set(record, 'statusChanging', true);
|
||||
this.$api
|
||||
.sysUserChangeStatus({
|
||||
id: record.id,
|
||||
status: +!checked,
|
||||
})
|
||||
.then(({ success, message }) => {
|
||||
if (success) {
|
||||
this.$message.success('操作成功');
|
||||
this.onReloadData();
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
record.statusChanging = false;
|
||||
});
|
||||
},
|
||||
|
||||
onResetPassword(record) {
|
||||
this.$api
|
||||
.sysUserResetPwd({
|
||||
id: record.id,
|
||||
})
|
||||
.then(({ success, message }) => {
|
||||
if (success) {
|
||||
this.$message.success('重置成功');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
<template>
|
||||
<!--
|
||||
普通树查询表格
|
||||
v 1.2
|
||||
2021-04-30
|
||||
Lufthafen
|
||||
-->
|
||||
<yo-tree-layout
|
||||
:load-data="loadTreeData"
|
||||
@select="onSelect"
|
||||
default-expanded-keys
|
||||
ref="tree-layout"
|
||||
>
|
||||
<container>
|
||||
<a-card :bordered="false">
|
||||
<Auth auth="sysUser:page">
|
||||
<div class="yo-query-bar">
|
||||
<a-form-model :model="query" @submit.native.prevent layout="inline">
|
||||
<a-form-model-item label="关键词">
|
||||
<a-input allow-clear placeholder="请输入姓名、账号、手机号" v-model="query.searchValue" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="状态">
|
||||
<a-select
|
||||
:style="{ width: '170px' }"
|
||||
allow-clear
|
||||
placeholder="请选择状态"
|
||||
v-model="query.searchStatus"
|
||||
>
|
||||
<a-select-option
|
||||
:key="i"
|
||||
:value="item.code"
|
||||
v-for="(item, i) in codes.common_status"
|
||||
>{{ item.value }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item>
|
||||
<a-button-group>
|
||||
<a-button @click="onQuery" html-type="submit" type="primary">查询</a-button>
|
||||
<a-button @click="onReset">重置</a-button>
|
||||
</a-button-group>
|
||||
</a-form-model-item>
|
||||
</a-form-model>
|
||||
</div>
|
||||
</Auth>
|
||||
|
||||
<yo-list :load-data="loadData" item-layout="horizontal" ref="list" size="large">
|
||||
<Auth auth="sysUser:add" slot="operator">
|
||||
<a-button @click="onOpen('add-form')" icon="plus">新增用户</a-button>
|
||||
</Auth>
|
||||
<a-list-item key="record.id" slot="renderItem" slot-scope="record">
|
||||
<Auth auth="sysUser:edit" slot="actions">
|
||||
<a @click="onOpen('edit-form', record)">编辑</a>
|
||||
</Auth>
|
||||
<Auth auth="sysUser:delete" slot="actions">
|
||||
<a-popconfirm @confirm="onDelete(record)" placement="topRight" title="是否确认删除">
|
||||
<a>删除</a>
|
||||
</a-popconfirm>
|
||||
</Auth>
|
||||
<Auth :auth="{ sysUser: [['grantRole'], ['grantData']] }" slot="actions">
|
||||
<a-dropdown placement="bottomRight">
|
||||
<a class="ant-dropdown-link">
|
||||
授权
|
||||
<a-icon type="down" />
|
||||
</a>
|
||||
<a-menu slot="overlay">
|
||||
<Auth auth="sysUser:grantRole">
|
||||
<a-menu-item>
|
||||
<a @click="onOpen('role-form', record)">授权角色</a>
|
||||
</a-menu-item>
|
||||
</Auth>
|
||||
<Auth auth="sysUser:grantData">
|
||||
<a-menu-item>
|
||||
<a @click="onOpen('data-form', record)">授权额外数据</a>
|
||||
</a-menu-item>
|
||||
</Auth>
|
||||
</a-menu>
|
||||
</a-dropdown>
|
||||
</Auth>
|
||||
<a-list-item-meta>
|
||||
<div slot="title">{{ record.nickName || record.name }}</div>
|
||||
<div slot="description">{{ record.account }}</div>
|
||||
<yo-image
|
||||
:id="record.avatar"
|
||||
:size="48"
|
||||
icon="user"
|
||||
shape="square"
|
||||
slot="avatar"
|
||||
type="avatar"
|
||||
/>
|
||||
</a-list-item-meta>
|
||||
<div class="yo-list-content--h">
|
||||
<div class="yo-list-content--h--item">
|
||||
<span>性别</span>
|
||||
<p>{{ bindCodeValue(record.sex, 'sex') }}</p>
|
||||
</div>
|
||||
<div class="yo-list-content--h--item">
|
||||
<span>手机</span>
|
||||
<p>{{ record.phone || '未设置' }}</p>
|
||||
</div>
|
||||
<div class="yo-list-content--h--item">
|
||||
<span>邮箱</span>
|
||||
<p>{{ record.email || '未设置' }}</p>
|
||||
</div>
|
||||
<Auth auth="sysUser:changeStatus">
|
||||
<div class="yo-list-content--h--item text-center">
|
||||
<a-switch
|
||||
:checked="!record.status"
|
||||
:checked-children="bindCodeValue(0, 'common_status')"
|
||||
:loading="record.statusChanging"
|
||||
:un-checked-children="bindCodeValue(1, 'common_status')"
|
||||
@change="(checked) => onSetUserStatus(record, checked)"
|
||||
/>
|
||||
</div>
|
||||
</Auth>
|
||||
</div>
|
||||
</a-list-item>
|
||||
</yo-list>
|
||||
</a-card>
|
||||
</container>
|
||||
|
||||
<!-- 新增表单 -->
|
||||
<yo-modal-form
|
||||
:action="$api[api.add]"
|
||||
:title="'新增' + name"
|
||||
:width="1024"
|
||||
@ok="onReloadData"
|
||||
ref="add-form"
|
||||
>
|
||||
<form-body mode="add" />
|
||||
</yo-modal-form>
|
||||
|
||||
<!-- 编辑表单 -->
|
||||
<yo-modal-form
|
||||
:action="$api[api.edit]"
|
||||
:title="'编辑' + name"
|
||||
:width="1024"
|
||||
@ok="onReloadData"
|
||||
ref="edit-form"
|
||||
>
|
||||
<form-body mode="edit" />
|
||||
</yo-modal-form>
|
||||
|
||||
<role-form @ok="onReloadData" ref="role-form" />
|
||||
<data-form @ok="onReloadData" ref="data-form" />
|
||||
</yo-tree-layout>
|
||||
</template>
|
||||
<script>
|
||||
/* 需要引用YoTreeLayout组件 */
|
||||
import YoTreeLayout from '@/components/yoTreeLayout';
|
||||
import YoList from '@/components/yoList';
|
||||
import FormBody from './form';
|
||||
|
||||
import RoleForm from './roleForm';
|
||||
import DataForm from './dataForm';
|
||||
|
||||
/* 在此管理整个页面需要的接口名称 */
|
||||
const api = {
|
||||
tree: 'getOrgTree',
|
||||
page: 'getUserPage',
|
||||
add: 'sysUserAdd',
|
||||
edit: 'sysUserEdit',
|
||||
delete: 'sysUserDelete',
|
||||
/* ... */
|
||||
};
|
||||
|
||||
export default {
|
||||
components: {
|
||||
YoTreeLayout,
|
||||
YoList,
|
||||
FormBody,
|
||||
RoleForm,
|
||||
DataForm,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
api,
|
||||
|
||||
name: '用户',
|
||||
|
||||
/* 查询条件 */
|
||||
query: {},
|
||||
|
||||
/* 表格字段 */
|
||||
columns: [],
|
||||
|
||||
/* 字典编码储存格式 */
|
||||
codes: {
|
||||
sex: [],
|
||||
common_status: [],
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
this.onLoadCodes();
|
||||
|
||||
/** 根据权限添加操作列 */
|
||||
const flag = this.$auth({
|
||||
sysUser: [['edit'], ['delete'], ['grantRole'], ['grantData']],
|
||||
});
|
||||
if (flag) {
|
||||
this.columns.push({
|
||||
title: '操作',
|
||||
width: '150px',
|
||||
dataIndex: 'action',
|
||||
scopedSlots: { customRender: 'action' },
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 树形选择界面必要的方法
|
||||
* 传给yo-table-layout以示意数据接口
|
||||
*/
|
||||
loadTreeData() {
|
||||
return this.$api[api.tree]().then((res) => {
|
||||
return res.data;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 树形选择界面必要的方法
|
||||
* 选择树节点事件
|
||||
*/
|
||||
onSelect([id]) {
|
||||
/** 在选择事件中可以对右侧表格添加父节点id的查询条件 */
|
||||
this.query = {
|
||||
'sysEmpParam.orgId': id,
|
||||
};
|
||||
this.onQuery();
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要的方法
|
||||
* 传给yo-table以示意数据接口及其参数和返回的数据结构
|
||||
*/
|
||||
loadData(params) {
|
||||
return this.$api[api.page]({
|
||||
...params,
|
||||
...this.query,
|
||||
}).then((res) => {
|
||||
return res.data;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 有查询功能时的必要方法
|
||||
* 加载数据时初始化分页信息
|
||||
*/
|
||||
onQuery() {
|
||||
this.$refs.list.onReloadData(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 重新列表数据
|
||||
*/
|
||||
onReset() {
|
||||
/* 与普通查询页不同的是,这里的父节点参数不应该在重置后被清空 */
|
||||
Object.keys(this.query).forEach((p) => {
|
||||
if (p !== 'pid') {
|
||||
this.query[p] = undefined;
|
||||
}
|
||||
});
|
||||
this.onQuery();
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 重新列表数据
|
||||
*/
|
||||
onReloadData() {
|
||||
this.$refs.list.onReloadData();
|
||||
this.$refs['tree-layout'].onReloadData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 加载字典数据
|
||||
* 如果不需要获取相应的字典数据,此方法内容可空
|
||||
*/
|
||||
onLoadCodes() {
|
||||
this.$api
|
||||
.$queue([
|
||||
this.$api.sysDictTypeDropDownAwait({ code: 'sex' }),
|
||||
this.$api.sysDictTypeDropDownAwait({ code: 'common_status' }),
|
||||
/* ... */
|
||||
])
|
||||
.then(([code1, code2]) => {
|
||||
this.codes.sex = code1.data;
|
||||
this.codes.common_status = code2.data;
|
||||
/* ... */
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 绑定数据字典值
|
||||
*/
|
||||
bindCodeValue(code, name) {
|
||||
const c = this.codes[name].find((p) => p.code == code);
|
||||
if (c) {
|
||||
return c.value;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* 有编辑新增功能的必要方法
|
||||
* 从列表页调用窗口的打开方法
|
||||
*/
|
||||
onOpen(formName, record) {
|
||||
this.$refs[formName].onOpen({
|
||||
record,
|
||||
orgId: this.query['sysEmpParam.orgId'],
|
||||
/* 按需添加其他参数 */
|
||||
/* ... */
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 可以用做一系列操作的公共回调,此方法中会重新加载当前列表
|
||||
*/
|
||||
onResult(success, successMessage) {
|
||||
if (success) {
|
||||
this.$message.success(successMessage);
|
||||
this.onReloadData();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 必要方法
|
||||
* 删除时调用
|
||||
*/
|
||||
onDelete(record) {
|
||||
this.$refs.list.onLoading();
|
||||
this.$api[api.delete](record)
|
||||
.then(({ success }) => {
|
||||
this.onResult(success, '删除成功');
|
||||
})
|
||||
.finally(() => {
|
||||
this.$refs.list.onLoaded();
|
||||
});
|
||||
},
|
||||
|
||||
onSetUserStatus(record, checked) {
|
||||
this.$set(record, 'statusChanging', true);
|
||||
this.$api
|
||||
.sysUserChangeStatus({
|
||||
id: record.id,
|
||||
status: +!checked,
|
||||
})
|
||||
.then(({ success, message }) => {
|
||||
if (success) {
|
||||
this.$message.success('操作成功');
|
||||
this.onReloadData();
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
record.statusChanging = false;
|
||||
});
|
||||
},
|
||||
|
||||
onResetPassword(record) {
|
||||
this.$api
|
||||
.sysUserResetPwd({
|
||||
id: record.id,
|
||||
})
|
||||
.then(({ success, message }) => {
|
||||
if (success) {
|
||||
this.$message.success('重置成功');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user