Update机构和系统配置代码
This commit is contained in:
@@ -1,78 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-modal
|
|
||||||
:confirmLoading="confirmLoading"
|
|
||||||
:visible="visible"
|
|
||||||
@cancel="onCancel"
|
|
||||||
@ok="onOk"
|
|
||||||
class="yo-modal-form"
|
|
||||||
title="新增参数"
|
|
||||||
>
|
|
||||||
<FormBody ref="form-body" />
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import FormBody from './form';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
FormBody,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
confirmLoading: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
formBody() {
|
|
||||||
return this.$refs['form-body'];
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 从外部调用打开本窗口
|
|
||||||
*/
|
|
||||||
onOpen() {
|
|
||||||
this.visible = true;
|
|
||||||
this.$nextTick(async () => {
|
|
||||||
await this.formBody.onInit();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 点击保存时的操作
|
|
||||||
*/
|
|
||||||
onOk() {
|
|
||||||
this.$refs['form-body'].onValidate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
this.confirmLoading = true;
|
|
||||||
this.$api
|
|
||||||
.sysConfigAdd(this.$refs['form-body'].form)
|
|
||||||
.then(({ success }) => {
|
|
||||||
this.confirmLoading = false;
|
|
||||||
if (success) {
|
|
||||||
this.$message.success('添加成功');
|
|
||||||
this.onCancel();
|
|
||||||
this.$emit('ok');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.confirmLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 关闭窗口时的操作
|
|
||||||
*/
|
|
||||||
onCancel() {
|
|
||||||
this.$refs['form-body'].onResetFields();
|
|
||||||
this.visible = false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-modal
|
|
||||||
:confirmLoading="confirmLoading"
|
|
||||||
:visible="visible"
|
|
||||||
@cancel="onCancel"
|
|
||||||
@ok="onOk"
|
|
||||||
title="编辑用户"
|
|
||||||
>
|
|
||||||
<FormBody ref="form-body" />
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import FormBody from './form';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
FormBody,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
|
|
||||||
confirmLoading: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 从外部调用打开本窗口,并填充外部传入的数据
|
|
||||||
*/
|
|
||||||
onOpen(record) {
|
|
||||||
this.visible = true;
|
|
||||||
this.$nextTick(async () => {
|
|
||||||
this.$refs['form-body'].onFillData(record);
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 点击保存时的操作
|
|
||||||
*/
|
|
||||||
onOk() {
|
|
||||||
this.$refs['form-body'].onValidate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
this.confirmLoading = true;
|
|
||||||
this.$api
|
|
||||||
.sysConfigEdit(this.$refs['form-body'].form)
|
|
||||||
.then(({ success }) => {
|
|
||||||
if (success) {
|
|
||||||
this.$message.success('编辑成功');
|
|
||||||
this.onCancel();
|
|
||||||
this.$emit('ok');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.confirmLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 关闭窗口时的操作
|
|
||||||
*/
|
|
||||||
onCancel() {
|
|
||||||
this.$refs['form-body'].onResetFields();
|
|
||||||
this.visible = false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -1,7 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!--
|
||||||
|
普通编辑窗体
|
||||||
|
v 1.2
|
||||||
|
2021-04-30
|
||||||
|
Lufthafen
|
||||||
|
-->
|
||||||
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
|
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
|
||||||
<div class="yo-form-group">
|
<a-spin :spinning="loading">
|
||||||
<a-form-model-item label="角色名" prop="name">
|
<a-icon slot="indicator" spin type="loading" />
|
||||||
|
<div class="yo-form-group">
|
||||||
|
<!-- 表单控件 -->
|
||||||
|
<!-- ... -->
|
||||||
|
<a-form-model-item label="角色名" prop="name">
|
||||||
<a-input placeholder="请输入角色名" v-model="form.name" />
|
<a-input placeholder="请输入角色名" v-model="form.name" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<a-form-model-item label="唯一编码" prop="code" :disabled="editDisabled">
|
<a-form-model-item label="唯一编码" prop="code" :disabled="editDisabled">
|
||||||
@@ -33,35 +43,56 @@
|
|||||||
<a-form-model-item label="备注" prop="remark">
|
<a-form-model-item label="备注" prop="remark">
|
||||||
<a-input placeholder="请输入备注" v-model="form.remark" />
|
<a-input placeholder="请输入备注" v-model="form.remark" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
</div>
|
</div>
|
||||||
|
</a-spin>
|
||||||
</a-form-model>
|
</a-form-model>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
/* 表单内容默认值 */
|
||||||
|
const defaultForm = {
|
||||||
|
// editDisabled:false,
|
||||||
|
/* ... */
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editDisabled:false,
|
/** 表单数据 */
|
||||||
groupCode:[],
|
form: {},
|
||||||
form: {
|
/** 验证格式 */
|
||||||
active: "N",
|
|
||||||
},
|
|
||||||
rules: {
|
rules: {
|
||||||
name: [{ required: true, message: "请输入应用名称" }],
|
name: [{ required: true, message: "请输入应用名称" }],
|
||||||
code: [{ required: true, message: "请输入唯一编码" }],
|
code: [{ required: true, message: "请输入唯一编码" }],
|
||||||
sysFlag: [{ required: true, message: "请选择参数类型" }],
|
sysFlag: [{ required: true, message: "请选择参数类型" }],
|
||||||
groupCode: [{ required: true, message: "请选择所属分类" }],
|
groupCode: [{ required: true, message: "请选择所属分类" }],
|
||||||
value: [{ required: true, message: "请输入参数值" }],
|
value: [{ required: true, message: "请输入参数值" }],
|
||||||
|
/* ... */
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 加载异步数据状态 */
|
||||||
|
loading: false,
|
||||||
|
editDisabled:false,
|
||||||
|
groupCode:[],
|
||||||
|
/** 其他成员属性 */
|
||||||
|
/* ... */
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
* 必要的方法
|
* 必要的方法
|
||||||
* 在打开编辑页时允许填充数据
|
* 在打开编辑页时允许填充数据
|
||||||
*/
|
*/
|
||||||
onFillData(record) {
|
onFillData(params) {
|
||||||
this.form = this.$_.cloneDeep(record);
|
/** 将默认数据覆盖到form */
|
||||||
if(record.sysFlag == 'Y')
|
this.form = this.$_.cloneDeep({
|
||||||
|
...defaultForm,
|
||||||
|
...params.record,
|
||||||
|
/** 在此处添加其他默认数据转换 */
|
||||||
|
/* ... */
|
||||||
|
});
|
||||||
|
|
||||||
|
if(this.form.sysFlag == 'Y')
|
||||||
{
|
{
|
||||||
this.editDisabled = true
|
this.editDisabled = true
|
||||||
}else
|
}else
|
||||||
@@ -70,12 +101,26 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async onInit() {
|
/**
|
||||||
this.loading = true;
|
* 必要方法
|
||||||
this.groupCode = await this.onLoadgroupCodeData();
|
* 验证表单并获取表单数据
|
||||||
this.loading = false;
|
*/
|
||||||
},
|
onGetData() {
|
||||||
|
return new Promise((reslove, reject) => {
|
||||||
|
this.$refs.form.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
const record = this.$_.cloneDeep(this.form);
|
||||||
|
|
||||||
|
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
|
||||||
|
/* ... */
|
||||||
|
|
||||||
|
reslove(record);
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 必要的方法
|
* 必要的方法
|
||||||
@@ -85,28 +130,42 @@ export default {
|
|||||||
this.$refs.form.validate(callback);
|
this.$refs.form.validate(callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 获取所属分类字典表的内容
|
|
||||||
*/
|
|
||||||
|
|
||||||
onLoadgroupCodeData() {
|
|
||||||
return this.$api.sysDictTypeDropDown({ code: 'consts_type' }).then(({ data }) => {
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 必要的方法
|
* 必要的方法
|
||||||
* 在外部窗口关闭或重置时对表单验证进行初始化
|
* 在外部窗口关闭或重置时对表单验证进行初始化
|
||||||
*/
|
*/
|
||||||
onResetFields() {
|
onResetFields() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.form = {};
|
|
||||||
this.$refs.form.resetFields();
|
this.$refs.form.resetFields();
|
||||||
|
|
||||||
|
/** 在这里可以初始化当前组件中其他属性 */
|
||||||
|
/* ... */
|
||||||
}, 300);
|
}, 300);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 加载当前表单中所需要的异步数据
|
||||||
|
*/
|
||||||
|
async onInit(params) {
|
||||||
|
this.loading = true;
|
||||||
|
/** 可以在这里await获取一些异步数据 */
|
||||||
|
this.groupCode = await this.onLoadgroupCodeData();
|
||||||
|
/* ... */
|
||||||
|
this.loading = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 当前组件的其他方法 */
|
||||||
|
/* ... */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 获取所属分类字典表的内容
|
||||||
|
*/
|
||||||
|
onLoadgroupCodeData() {
|
||||||
|
return this.$api.sysDictTypeDropDown({ code: 'consts_type' }).then(({ data }) => {
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -1,29 +1,36 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!--
|
||||||
|
普通查询表格
|
||||||
|
v 1.2
|
||||||
|
2021-04-30
|
||||||
|
Lufthafen
|
||||||
|
-->
|
||||||
<container>
|
<container>
|
||||||
<br />
|
<br />
|
||||||
<a-card :bordered="false">
|
<a-card :bordered="false">
|
||||||
<Auth auth="sysConfig:page">
|
<yo-table
|
||||||
<div class="yo-query-bar">
|
:columns="columns"
|
||||||
<a-form-model :model="query" layout="inline">
|
:load-data="loadData"
|
||||||
<a-form-model-item label="参数名称">
|
@query="onQuery"
|
||||||
<a-input placeholder="请输入参数名称" v-model="query.name" />
|
@resetQuery="onResetQuery"
|
||||||
</a-form-model-item>
|
ref="table"
|
||||||
<a-form-model-item label="唯一编码">
|
>
|
||||||
<a-input placeholder="请输入唯一编码" v-model="query.code" />
|
<Auth auth="sysConfig:page" slot="query">
|
||||||
</a-form-model-item>
|
<!-- 此处添加查询表单控件 -->
|
||||||
<a-form-model-item>
|
<!-- ... -->
|
||||||
<a-button-group>
|
<a-form-model-item label="参数名称">
|
||||||
<a-button @click="onQuery" type="primary">查询</a-button>
|
<a-input placeholder="请输入参数名称" v-model="query.name" />
|
||||||
<a-button @click="() => {(query = {}), onQuery();}">重置</a-button>
|
</a-form-model-item>
|
||||||
</a-button-group>
|
<a-form-model-item label="唯一编码">
|
||||||
</a-form-model-item>
|
<a-input placeholder="请输入唯一编码" v-model="query.code" />
|
||||||
</a-form-model>
|
</a-form-model-item>
|
||||||
</div>
|
|
||||||
</Auth>
|
|
||||||
<yo-table :columns="columns" :load-data="loadData" ref="table">
|
|
||||||
<Auth auth="sysConfig:add" slot="operator">
|
|
||||||
<a-button @click="onOpen('add-form')" icon="plus">新增职位</a-button>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
|
<Auth auth="sysConfig:add" slot="operator">
|
||||||
|
<a-button @click="onOpen('add-form')" icon="plus">新增配置</a-button>
|
||||||
|
</Auth>
|
||||||
|
<!-- 格式化字段内容 -->
|
||||||
|
<!-- ... -->
|
||||||
|
<!-- 添加操作控件 -->
|
||||||
<span slot="action" slot-scope="text, record">
|
<span slot="action" slot-scope="text, record">
|
||||||
<yo-table-actions>
|
<yo-table-actions>
|
||||||
<Auth auth="sysConfig:edit">
|
<Auth auth="sysConfig:edit">
|
||||||
@@ -34,26 +41,50 @@
|
|||||||
<a>删除</a>
|
<a>删除</a>
|
||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
</Auth>
|
</Auth>
|
||||||
|
<!-- 可在此处添加其他操作控件 -->
|
||||||
|
<!-- ... -->
|
||||||
</yo-table-actions>
|
</yo-table-actions>
|
||||||
</span>
|
</span>
|
||||||
</yo-table>
|
</yo-table>
|
||||||
</a-card>
|
</a-card>
|
||||||
<br />
|
|
||||||
<edit-form @ok="onReloadData" ref="edit-form" />
|
<!-- 新增表单 -->
|
||||||
<add-form @ok="onReloadData" ref="add-form" />
|
<yo-modal-form :action="$api[api.add]" :title="'新增' + name" @ok="onReloadData" ref="add-form">
|
||||||
|
<form-body />
|
||||||
|
</yo-modal-form>
|
||||||
|
|
||||||
|
<!-- 编辑表单 -->
|
||||||
|
<yo-modal-form :action="$api[api.edit]" :title="'编辑' + name" @ok="onReloadData" ref="edit-form">
|
||||||
|
<form-body />
|
||||||
|
</yo-modal-form>
|
||||||
</container>
|
</container>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import AddForm from './addForm';
|
import FormBody from './form';
|
||||||
import editForm from './editForm';
|
|
||||||
|
/* 在此管理整个页面需要的接口名称 */
|
||||||
|
const api = {
|
||||||
|
page: 'sysConfigPage',
|
||||||
|
add: 'sysConfigAdd',
|
||||||
|
edit: 'sysConfigEdit',
|
||||||
|
delete: 'sysConfigDelete',
|
||||||
|
/* ... */
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
AddForm,
|
FormBody,
|
||||||
editForm,
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
api,
|
||||||
|
|
||||||
|
name: '配置',
|
||||||
|
|
||||||
|
/* 查询条件 */
|
||||||
query: {},
|
query: {},
|
||||||
|
|
||||||
|
/* 表格字段 */
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: '参数名称',
|
title: '参数名称',
|
||||||
@@ -81,18 +112,26 @@ export default {
|
|||||||
sorter: true,
|
sorter: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/* 字典编码储存格式 */
|
||||||
|
// codes: {
|
||||||
|
// code1: [],
|
||||||
|
// code2: [],
|
||||||
|
// },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
const flag = this.$auth({ sysConfig: [['edit'], ['delete']] });
|
/** 按需加载字典编码 */
|
||||||
|
//this.onLoadCodes();
|
||||||
|
|
||||||
|
/** 根据权限添加操作列 */
|
||||||
|
const flag = this.$auth(/* ... */);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.columns.push({
|
this.columns.push({
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: '200px',
|
width: '150px',
|
||||||
dataIndex: 'action',
|
dataIndex: 'action',
|
||||||
scopedSlots: {
|
scopedSlots: { customRender: 'action' },
|
||||||
customRender: 'action',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -102,14 +141,12 @@ export default {
|
|||||||
* 传给yo-table以示意数据接口及其参数和返回的数据结构
|
* 传给yo-table以示意数据接口及其参数和返回的数据结构
|
||||||
*/
|
*/
|
||||||
loadData(params) {
|
loadData(params) {
|
||||||
return this.$api
|
return this.$api[api.page]({
|
||||||
.sysConfigPage({
|
...params,
|
||||||
...params,
|
...this.query,
|
||||||
...this.query,
|
}).then((res) => {
|
||||||
})
|
return res.data;
|
||||||
.then((res) => {
|
});
|
||||||
return res.data;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,6 +157,16 @@ export default {
|
|||||||
this.$refs.table.onReloadData(true);
|
this.$refs.table.onReloadData(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有查询功能时的必要方法
|
||||||
|
* 重置查询条件
|
||||||
|
*/
|
||||||
|
onResetQuery() {
|
||||||
|
/** 在这里重置查询条件时,可对特殊的字段做保留处理 */
|
||||||
|
this.query = {};
|
||||||
|
this.onQuery();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 必要方法
|
* 必要方法
|
||||||
* 重新列表数据
|
* 重新列表数据
|
||||||
@@ -129,26 +176,72 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 有编辑新增功能的必要方法
|
* 必要方法
|
||||||
|
* 加载字典数据
|
||||||
|
* 如果不需要获取相应的字典数据,此方法内容可空
|
||||||
|
*/
|
||||||
|
//onLoadCodes() {
|
||||||
|
// this.$api
|
||||||
|
// .$queue([
|
||||||
|
// this.$api.sysDictTypeDropDownAwait({ code: 'code1' }),
|
||||||
|
// this.$api.sysDictTypeDropDownAwait({ code: 'code2' }),
|
||||||
|
// /* ... */
|
||||||
|
// ])
|
||||||
|
// .then(([code1, code2]) => {
|
||||||
|
// this.codes.code1 = code1.data;
|
||||||
|
// this.codes.code2 = 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) {
|
onOpen(formName, record) {
|
||||||
this.$refs[formName].onOpen(record);
|
this.$refs[formName].onOpen({
|
||||||
|
record,
|
||||||
|
/* 按需添加其他参数 */
|
||||||
|
/* ... */
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 可以用做一系列操作的公共回调,此方法中会重新加载当前列表
|
||||||
|
*/
|
||||||
onResult(success, successMessage) {
|
onResult(success, successMessage) {
|
||||||
if (success) {
|
if (success) {
|
||||||
this.$message.success(successMessage);
|
this.$message.success(successMessage);
|
||||||
this.onReloadData();
|
this.onReloadData();
|
||||||
}
|
}
|
||||||
this.$refs.table.onLoaded();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 删除时调用
|
||||||
|
*/
|
||||||
onDelete(record) {
|
onDelete(record) {
|
||||||
this.$refs.table.onLoading();
|
this.$refs.table.onLoading();
|
||||||
this.$api.sysConfigDelete(record).then(({ success, message }) => {
|
this.$api[api.delete](record)
|
||||||
this.onResult(success, '删除成功');
|
.then(({ success }) => {
|
||||||
});
|
this.onResult(success, '删除成功');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.$refs.table.onLoaded();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-modal
|
|
||||||
:confirmLoading="confirmLoading"
|
|
||||||
:visible="visible"
|
|
||||||
@cancel="onCancel"
|
|
||||||
@ok="onOk"
|
|
||||||
class="yo-modal-form"
|
|
||||||
title="新增机构"
|
|
||||||
>
|
|
||||||
<FormBody ref="form-body" />
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import FormBody from './form';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
FormBody,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
|
|
||||||
confirmLoading: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
formBody() {
|
|
||||||
return this.$refs['form-body'];
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 从外部调用打开本窗口
|
|
||||||
*/
|
|
||||||
onOpen(record, orgId) {
|
|
||||||
this.visible = true;
|
|
||||||
this.$nextTick(async () => {
|
|
||||||
await this.formBody.onInit();
|
|
||||||
|
|
||||||
// 获取外部选中的部门id
|
|
||||||
this.formBody.onFillData(record, orgId);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 点击保存时的操作
|
|
||||||
*/
|
|
||||||
onOk() {
|
|
||||||
this.$refs['form-body'].onValidate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
this.confirmLoading = true;
|
|
||||||
this.$api
|
|
||||||
.sysOrgAdd(this.$refs['form-body'].onGetData())
|
|
||||||
.then(({ success }) => {
|
|
||||||
if (success) {
|
|
||||||
this.$message.success('新增成功');
|
|
||||||
this.onCancel();
|
|
||||||
this.$emit('ok');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.confirmLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 关闭窗口时的操作
|
|
||||||
*/
|
|
||||||
onCancel() {
|
|
||||||
this.$refs['form-body'].onResetFields();
|
|
||||||
this.visible = false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-modal
|
|
||||||
:confirmLoading="confirmLoading"
|
|
||||||
:visible="visible"
|
|
||||||
@cancel="onCancel"
|
|
||||||
@ok="onOk"
|
|
||||||
class="yo-modal-form"
|
|
||||||
title="编辑机构"
|
|
||||||
>
|
|
||||||
<FormBody ref="form-body" />
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import FormBody from './form';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
FormBody,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
|
|
||||||
confirmLoading: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 从外部调用打开本窗口,并填充外部传入的数据
|
|
||||||
*/
|
|
||||||
onOpen(record) {
|
|
||||||
this.visible = true;
|
|
||||||
this.$nextTick(async () => {
|
|
||||||
await this.$refs['form-body'].onInit();
|
|
||||||
this.$refs['form-body'].onFillData(record);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 点击保存时的操作
|
|
||||||
*/
|
|
||||||
onOk() {
|
|
||||||
this.$refs['form-body'].onValidate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
this.confirmLoading = true;
|
|
||||||
this.$api
|
|
||||||
.sysOrgEdit(this.$refs['form-body'].onGetData())
|
|
||||||
.then(({ success }) => {
|
|
||||||
if (success) {
|
|
||||||
this.$message.success('编辑成功');
|
|
||||||
this.onCancel();
|
|
||||||
this.$emit('ok');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.confirmLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 关闭窗口时的操作
|
|
||||||
*/
|
|
||||||
onCancel() {
|
|
||||||
this.$refs['form-body'].onResetFields();
|
|
||||||
this.visible = false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!--
|
||||||
|
普通编辑窗体
|
||||||
|
v 1.2
|
||||||
|
2021-04-30
|
||||||
|
Lufthafen
|
||||||
|
-->
|
||||||
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
|
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
|
||||||
<a-spin :spinning="loading">
|
<a-spin :spinning="loading">
|
||||||
<a-icon slot="indicator" spin type="loading" />
|
<a-icon slot="indicator" spin type="loading" />
|
||||||
<div class="yo-form-group">
|
<div class="yo-form-group">
|
||||||
<a-form-model-item label="机构名称" prop="name">
|
<!-- 表单控件 -->
|
||||||
|
<!-- ... -->
|
||||||
|
<a-form-model-item label="机构名称" prop="name">
|
||||||
<a-input placeholder="请输入机构名称" v-model="form.name" />
|
<a-input placeholder="请输入机构名称" v-model="form.name" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<a-form-model-item label="唯一编码" prop="code">
|
<a-form-model-item label="唯一编码" prop="code">
|
||||||
@@ -46,45 +54,55 @@
|
|||||||
<script>
|
<script>
|
||||||
import { EMPTY_ID } from '@/util/global';
|
import { EMPTY_ID } from '@/util/global';
|
||||||
|
|
||||||
|
/* 表单内容默认值 */
|
||||||
|
const defaultForm = {
|
||||||
|
/* ... */
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
/** 表单数据 */
|
||||||
form: {
|
form: {
|
||||||
pid: undefined,
|
pid: undefined,
|
||||||
sort: 100,
|
sort: 100,
|
||||||
},
|
},
|
||||||
|
/** 验证格式 */
|
||||||
rules: {
|
rules: {
|
||||||
name: [{ required: true, message: '请输入机构名称' }],
|
name: [{ required: true, message: '请输入机构名称' }],
|
||||||
code: [{ required: true, message: '请输入唯一编码' }],
|
code: [{ required: true, message: '请输入唯一编码' }],
|
||||||
pid: [{ required: true, message: '请选择上级机构' }],
|
pid: [{ required: true, message: '请选择上级机构' }],
|
||||||
areaCode: [{ required: true, message: '请选择所属区域' }],
|
areaCode: [{ required: true, message: '请选择所属区域' }],
|
||||||
|
/* ... */
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 加载异步数据状态 */
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
||||||
orgData: [],
|
orgData: [],
|
||||||
areaData: [],
|
areaData: [],
|
||||||
|
/** 其他成员属性 */
|
||||||
|
/* ... */
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
* 必要的方法
|
* 必要的方法
|
||||||
* 在打开编辑页时允许填充数据
|
* 在打开编辑页时允许填充数据
|
||||||
*/
|
*/
|
||||||
onFillData(record, orgId) {
|
onFillData(params,orgId) {
|
||||||
if (orgId) {
|
if(orgId){
|
||||||
this.form.pid = orgId;
|
this.form.pid = orgId;
|
||||||
} else if (record) {
|
}else if(params){
|
||||||
// 从字符串areaCode查找到整个层级
|
// 从字符串areaCode查找到整个层级
|
||||||
const areaCode = [];
|
const areaCode = [];
|
||||||
const findCode = (data, level) => {
|
const findCode = (data, level) => {
|
||||||
level = level || 0;
|
level = level || 0;
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
const item = data[i];
|
const item = data[i];
|
||||||
|
|
||||||
areaCode[level] = item.code;
|
areaCode[level] = item.code;
|
||||||
|
|
||||||
if (item.code === record.areaCode) {
|
if (item.code === params.areaCode) {
|
||||||
areaCode.length = level + 1;
|
areaCode.length = level + 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -98,21 +116,41 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (record.areaCode) {
|
if (params.areaCode) {
|
||||||
findCode(this.areaData);
|
findCode(this.areaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.form = this.$_.cloneDeep({
|
/** 将默认数据覆盖到form */
|
||||||
...record,
|
this.form = this.$_.cloneDeep({
|
||||||
areaCode,
|
...defaultForm,
|
||||||
});
|
...params,
|
||||||
|
areaCode,
|
||||||
|
/** 在此处添加其他默认数据转换 */
|
||||||
|
/* ... */
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 验证表单并获取表单数据
|
||||||
|
*/
|
||||||
onGetData() {
|
onGetData() {
|
||||||
const submitForm = this.$_.cloneDeep(this.form);
|
return new Promise((reslove, reject) => {
|
||||||
submitForm.areaCode = submitForm.areaCode[submitForm.areaCode.length - 1];
|
|
||||||
return submitForm;
|
this.$refs.form.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
const record = this.$_.cloneDeep(this.form);
|
||||||
|
record.areaCode = record.areaCode[record.areaCode.length - 1];
|
||||||
|
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
|
||||||
|
/* ... */
|
||||||
|
|
||||||
|
reslove(record);
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,16 +168,27 @@ export default {
|
|||||||
onResetFields() {
|
onResetFields() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$refs.form.resetFields();
|
this.$refs.form.resetFields();
|
||||||
|
|
||||||
|
/** 在这里可以初始化当前组件中其他属性 */
|
||||||
|
/* ... */
|
||||||
}, 300);
|
}, 300);
|
||||||
},
|
},
|
||||||
|
|
||||||
async onInit() {
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 加载当前表单中所需要的异步数据
|
||||||
|
*/
|
||||||
|
async onInit(params) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
/** 可以在这里await获取一些异步数据 */
|
||||||
await this.onLoadOrgData();
|
await this.onLoadOrgData();
|
||||||
await this.onLoadAreaData();
|
await this.onLoadAreaData();
|
||||||
|
/* ... */
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 当前组件的其他方法 */
|
||||||
|
/* ... */
|
||||||
onLoadOrgData() {
|
onLoadOrgData() {
|
||||||
return this.$api.getOrgTree().then(({ data }) => {
|
return this.$api.getOrgTree().then(({ data }) => {
|
||||||
this.orgData = [
|
this.orgData = [
|
||||||
@@ -154,7 +203,6 @@ export default {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoadAreaData() {
|
onLoadAreaData() {
|
||||||
return this.$api.getAreaTree().then(({ data }) => {
|
return this.$api.getAreaTree().then(({ data }) => {
|
||||||
// 为了防止出现空的层级选择,删除所有空children节点
|
// 为了防止出现空的层级选择,删除所有空children节点
|
||||||
|
|||||||
@@ -1,67 +1,96 @@
|
|||||||
<template>
|
<template>
|
||||||
<yo-tree-layout
|
<!--
|
||||||
|
普通查询表格
|
||||||
|
v 1.2
|
||||||
|
2021-04-30
|
||||||
|
Lufthafen
|
||||||
|
-->
|
||||||
|
<yo-tree-layout
|
||||||
:load-data="loadTreeData"
|
:load-data="loadTreeData"
|
||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
default-expanded-keys
|
default-expanded-keys
|
||||||
ref="tree-layout"
|
ref="tree-layout"
|
||||||
>
|
>
|
||||||
<container>
|
<container>
|
||||||
<a-card :bordered="false">
|
<br />
|
||||||
<Auth auth="sysOrg:page">
|
<a-card :bordered="false">
|
||||||
<div class="yo-query-bar">
|
<yo-table
|
||||||
<a-form-model :model="query" layout="inline">
|
:columns="columns"
|
||||||
<a-form-model-item label="机构名称">
|
:load-data="loadData"
|
||||||
<a-input allow-clear placeholder="请输入机构名称" v-model="query.name" />
|
@query="onQuery"
|
||||||
</a-form-model-item>
|
@resetQuery="onResetQuery"
|
||||||
<a-form-model-item>
|
ref="table"
|
||||||
<a-button-group>
|
>
|
||||||
<a-button @click="onQuery" type="primary">查询</a-button>
|
<Auth auth="sysOrg:page" slot="query">
|
||||||
<a-button @click="onReset">重置</a-button>
|
<!-- 此处添加查询表单控件 -->
|
||||||
</a-button-group>
|
<!-- ... -->
|
||||||
</a-form-model-item>
|
<a-form-model-item label="机构名称">
|
||||||
</a-form-model>
|
<a-input allow-clear placeholder="请输入机构名称" v-model="query.name" />
|
||||||
</div>
|
</a-form-model-item>
|
||||||
|
|
||||||
<yo-table :columns="columns" :load-data="loadData" ref="table">
|
|
||||||
<Auth auth="sysOrg:add" slot="operator">
|
|
||||||
<a-button @click="onOpen('add-form')" icon="plus">新增机构</a-button>
|
|
||||||
</Auth>
|
|
||||||
<span slot="action" slot-scope="text, record">
|
|
||||||
<yo-table-actions>
|
|
||||||
<Auth auth="sysOrg:edit">
|
|
||||||
<a @click="onOpen('edit-form', record)">编辑</a>
|
|
||||||
</Auth>
|
|
||||||
<Auth auth="sysOrg:delete">
|
|
||||||
<a-popconfirm @confirm="onDelete(record)" placement="topRight" title="是否确认删除">
|
|
||||||
<a>删除</a>
|
|
||||||
</a-popconfirm>
|
|
||||||
</Auth>
|
|
||||||
</yo-table-actions>
|
|
||||||
</span>
|
|
||||||
</yo-table>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
</a-card>
|
<Auth auth="sysOrg:add" slot="operator">
|
||||||
</container>
|
<a-button @click="onOpen('add-form')" icon="plus">新增机构</a-button>
|
||||||
<add-form @ok="onReloadData" ref="add-form" />
|
</Auth>
|
||||||
<edit-form @ok="onReloadData" ref="edit-form" />
|
<!-- 格式化字段内容 -->
|
||||||
</yo-tree-layout>
|
<!-- ... -->
|
||||||
|
<!-- 添加操作控件 -->
|
||||||
|
<span slot="action" slot-scope="text, record">
|
||||||
|
<yo-table-actions>
|
||||||
|
<Auth auth="sysOrg:edit">
|
||||||
|
<a @click="onOpen('edit-form', record)">编辑</a>
|
||||||
|
</Auth>
|
||||||
|
<Auth auth="sysOrg:delete">
|
||||||
|
<a-popconfirm @confirm="onDelete(record)" placement="topRight" title="是否确认删除">
|
||||||
|
<a>删除</a>
|
||||||
|
</a-popconfirm>
|
||||||
|
</Auth>
|
||||||
|
<!-- 可在此处添加其他操作控件 -->
|
||||||
|
<!-- ... -->
|
||||||
|
</yo-table-actions>
|
||||||
|
</span>
|
||||||
|
</yo-table>
|
||||||
|
</a-card>
|
||||||
|
|
||||||
|
<!-- 新增表单 -->
|
||||||
|
<yo-modal-form :action="$api[api.add]" :title="'新增' + name" @ok="onReloadData" ref="add-form">
|
||||||
|
<form-body />
|
||||||
|
</yo-modal-form>
|
||||||
|
|
||||||
|
<!-- 编辑表单 -->
|
||||||
|
<yo-modal-form :action="$api[api.edit]" :title="'编辑' + name" @ok="onReloadData" ref="edit-form">
|
||||||
|
<form-body />
|
||||||
|
</yo-modal-form>
|
||||||
|
</container>
|
||||||
|
</yo-tree-layout>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import FormBody from './form';
|
||||||
import YoTreeLayout from '@/components/yoTreeLayout';
|
import YoTreeLayout from '@/components/yoTreeLayout';
|
||||||
|
|
||||||
import AddForm from './addForm';
|
/* 在此管理整个页面需要的接口名称 */
|
||||||
import EditForm from './editForm';
|
const api = {
|
||||||
|
page: 'getOrgPage',
|
||||||
|
add: 'sysOrgAdd',
|
||||||
|
edit: 'sysOrgEdit',
|
||||||
|
delete: 'sysOrgDelete',
|
||||||
|
/* ... */
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
FormBody,
|
||||||
YoTreeLayout,
|
YoTreeLayout,
|
||||||
AddForm,
|
|
||||||
EditForm,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
api,
|
||||||
|
|
||||||
|
name: '机构',
|
||||||
|
|
||||||
|
/* 查询条件 */
|
||||||
query: {},
|
query: {},
|
||||||
|
|
||||||
|
/* 表格字段 */
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: '机构名称',
|
title: '机构名称',
|
||||||
@@ -87,14 +116,20 @@ export default {
|
|||||||
sorter: true,
|
sorter: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/* 字典编码储存格式 */
|
||||||
|
// codes: {
|
||||||
|
// code1: [],
|
||||||
|
// code2: [],
|
||||||
|
// },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
const flag = this.$auth({
|
/** 按需加载字典编码 */
|
||||||
sysOrg: [['edit'], ['delete']],
|
//this.onLoadCodes();
|
||||||
});
|
|
||||||
|
|
||||||
|
/** 根据权限添加操作列 */
|
||||||
|
const flag = this.$auth(/* ... */);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.columns.push({
|
this.columns.push({
|
||||||
title: '操作',
|
title: '操作',
|
||||||
@@ -104,8 +139,121 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* 必要的方法
|
||||||
|
* 传给yo-table以示意数据接口及其参数和返回的数据结构
|
||||||
|
*/
|
||||||
|
loadData(params) {
|
||||||
|
return this.$api[api.page]({
|
||||||
|
...params,
|
||||||
|
...this.query,
|
||||||
|
}).then((res) => {
|
||||||
|
return res.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有查询功能时的必要方法
|
||||||
|
* 加载数据时初始化分页信息
|
||||||
|
*/
|
||||||
|
onQuery() {
|
||||||
|
this.$refs.table.onReloadData(true);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有查询功能时的必要方法
|
||||||
|
* 重置查询条件
|
||||||
|
*/
|
||||||
|
onResetQuery() {
|
||||||
|
/** 在这里重置查询条件时,可对特殊的字段做保留处理 */
|
||||||
|
Object.keys(this.query).forEach((p) => {
|
||||||
|
if (p !== 'pid') {
|
||||||
|
this.query[p] = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.onQuery();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 重新列表数据
|
||||||
|
*/
|
||||||
|
onReloadData() {
|
||||||
|
this.$refs.table.onReloadData();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 加载字典数据
|
||||||
|
* 如果不需要获取相应的字典数据,此方法内容可空
|
||||||
|
*/
|
||||||
|
//onLoadCodes() {
|
||||||
|
// this.$api
|
||||||
|
// .$queue([
|
||||||
|
// this.$api.sysDictTypeDropDownAwait({ code: 'code1' }),
|
||||||
|
// this.$api.sysDictTypeDropDownAwait({ code: 'code2' }),
|
||||||
|
// /* ... */
|
||||||
|
// ])
|
||||||
|
// .then(([code1, code2]) => {
|
||||||
|
// this.codes.code1 = code1.data;
|
||||||
|
// this.codes.code2 = 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,
|
||||||
|
/* 按需添加其他参数 */
|
||||||
|
/* ... */
|
||||||
|
|
||||||
|
this.query['pid']
|
||||||
|
);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 可以用做一系列操作的公共回调,此方法中会重新加载当前列表
|
||||||
|
*/
|
||||||
|
onResult(success, successMessage) {
|
||||||
|
if (success) {
|
||||||
|
this.$message.success(successMessage);
|
||||||
|
this.onReloadData();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 必要方法
|
||||||
|
* 删除时调用
|
||||||
|
*/
|
||||||
|
onDelete(record) {
|
||||||
|
this.$refs.table.onLoading();
|
||||||
|
this.$api[api.delete](record)
|
||||||
|
.then(({ success }) => {
|
||||||
|
this.onResult(success, '删除成功');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.$refs.table.onLoaded();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 树形选择界面必要的方法
|
* 树形选择界面必要的方法
|
||||||
* 传给yo-table-layout以示意数据接口
|
* 传给yo-table-layout以示意数据接口
|
||||||
@@ -122,67 +270,6 @@ export default {
|
|||||||
};
|
};
|
||||||
this.onQuery();
|
this.onQuery();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要的方法
|
|
||||||
* 传给yo-table以示意数据接口及其参数和返回的数据结构
|
|
||||||
*/
|
|
||||||
loadData(params) {
|
|
||||||
return this.$api
|
|
||||||
.getOrgPage({
|
|
||||||
...params,
|
|
||||||
...this.query,
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
return res.data;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 有查询功能时的必要方法
|
|
||||||
* 加载数据时初始化分页信息
|
|
||||||
*/
|
|
||||||
onQuery() {
|
|
||||||
this.$refs.table.onReloadData(true);
|
|
||||||
},
|
|
||||||
|
|
||||||
onReset() {
|
|
||||||
Object.keys(this.query).forEach((p) => {
|
|
||||||
if (p !== 'pid') {
|
|
||||||
this.query[p] = undefined;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.onQuery();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 必要方法
|
|
||||||
* 重新列表数据
|
|
||||||
*/
|
|
||||||
onReloadData() {
|
|
||||||
this.$refs.table.onReloadData();
|
|
||||||
this.$refs['tree-layout'].onReloadData();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 有编辑新增功能的必要方法
|
|
||||||
* 从列表页调用窗口的打开方法
|
|
||||||
*/
|
|
||||||
onOpen(formName, record) {
|
|
||||||
this.$refs[formName].onOpen(record, this.query['pid']);
|
|
||||||
},
|
|
||||||
|
|
||||||
onDelete(record) {
|
|
||||||
this.$api.sysOrgDelete(record).then(({ success }) => {
|
|
||||||
if (success) {
|
|
||||||
this.$message.success('删除成功');
|
|
||||||
this.onReloadData();
|
|
||||||
if (this.query['pid'] == record.id) {
|
|
||||||
delete this.query.pid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user