fix org对seed的错误应用

This commit is contained in:
2021-05-09 13:04:52 +08:00
parent 982b79bbb0
commit 57e1a4231d
7 changed files with 91 additions and 403 deletions

View File

@@ -95,6 +95,8 @@
box-shadow: 0 0 0 2px @white;
}
&--name {
font-weight: bolder;
position: absolute;
left: 32px + @padding-sm * 2;

View File

@@ -1,71 +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() {
this.visible = true;
},
/**
* 必要的方法
* 点击保存时的操作
*/
onOk() {
this.$refs['form-body'].onValidate((valid) => {
if (valid) {
this.confirmLoading = true;
this.$api
.sysAppAdd(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>

View File

@@ -1,74 +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(() => {
this.$refs['form-body'].onFillData(record);
});
},
/**
* 必要的方法
* 点击保存时的操作
*/
onOk() {
this.$refs['form-body'].onValidate((valid) => {
if (valid) {
this.confirmLoading = true;
this.$api
.sysAppEdit(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>

View File

@@ -1,84 +0,0 @@
<template>
<a-drawer
:confirmLoading="confirmLoading"
:visible="visible"
:width="800"
@close="onClose"
@ok="onOk"
class="yo-drawer-form"
title="新增菜单"
>
<FormBody ref="form-body" />
<div class="ant-drawer-footer">
<a-button @click="onClose">取消</a-button>
<a-button :loading="confirmLoading" @click="onOk" type="primary">确定</a-button>
</div>
</a-drawer>
</template>
<script>
import FormBody from './form';
export default {
components: {
FormBody,
},
data() {
return {
visible: false,
confirmLoading: false,
};
},
computed: {
formBody() {
return this.$refs['form-body'];
},
},
methods: {
/**
* 必要的方法
* 从外部调用打开本窗口
*/
async onOpen(record) {
this.visible = true;
this.$nextTick(async () => {
await this.formBody.onInit(record, true);
});
},
/**
* 必要的方法
* 点击保存时的操作
*/
onOk() {
this.formBody.onGetData().then((data) => {
this.confirmLoading = true;
this.$api
.sysMenuAdd(data)
.then(({ success }) => {
if (success) {
this.$message.success('新增成功');
this.onClose();
this.$emit('ok');
}
})
.finally(() => {
this.confirmLoading = false;
});
});
},
/**
* 必要的方法
* 关闭窗口时的操作
*/
onClose() {
this.formBody.onResetFields();
this.visible = false;
},
},
};
</script>

View File

@@ -1,83 +0,0 @@
<template>
<a-drawer
:confirmLoading="confirmLoading"
:visible="visible"
:width="800"
@close="onClose"
class="yo-drawer-form"
title="编辑应用"
>
<FormBody ref="form-body" />
<div class="ant-drawer-footer">
<a-button @click="onClose">取消</a-button>
<a-button :loading="confirmLoading" @click="onOk" type="primary">确定</a-button>
</div>
</a-drawer>
</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) {
this.visible = true;
this.$nextTick(async () => {
await this.formBody.onInit(record);
this.formBody.onFillData(record);
});
},
/**
* 必要的方法
* 点击保存时的操作
*/
onOk() {
this.formBody.onGetData().then((data) => {
this.confirmLoading = true;
this.$api
.sysMenuEdit(data)
.then(({ success }) => {
if (success) {
this.$message.success('编辑成功');
this.onClose();
this.$emit('ok');
}
})
.finally(() => {
this.confirmLoading = false;
});
});
},
/**
* 必要的方法
* 关闭窗口时的操作
*/
onClose() {
this.formBody.onResetFields();
this.visible = false;
},
},
};
</script>

View File

@@ -57,16 +57,15 @@ import { EMPTY_ID } from '@/util/global';
/* 表单内容默认值 */
const defaultForm = {
/* ... */
pid: undefined,
sort: 100,
};
export default {
data() {
return {
/** 表单数据 */
form: {
pid: undefined,
sort: 100,
},
form: {},
/** 验证格式 */
rules: {
name: [{ required: true, message: '请输入机构名称' }],
@@ -90,10 +89,7 @@ export default {
* 必要的方法
* 在打开编辑页时允许填充数据
*/
onFillData(params,orgId) {
if(orgId){
this.form.pid = orgId;
}else if(params){
onFillData(params) {
// 从字符串areaCode查找到整个层级
const areaCode = [];
const findCode = (data, level) => {
@@ -102,7 +98,7 @@ export default {
const item = data[i];
areaCode[level] = item.code;
if (item.code === params.areaCode) {
if (item.code === params.record.areaCode) {
areaCode.length = level + 1;
return true;
}
@@ -116,19 +112,19 @@ export default {
}
};
if (params.areaCode) {
if (params.record && params.record.areaCode) {
findCode(this.areaData);
}
/** 将默认数据覆盖到form */
this.form = this.$_.cloneDeep({
...defaultForm,
...params,
areaCode,
pid: params.orgId,
...params.record,
/** 在此处添加其他默认数据转换 */
/* ... */
areaCode,
});
}
},
/**
@@ -137,7 +133,6 @@ export default {
*/
onGetData() {
return new Promise((reslove, reject) => {
this.$refs.form.validate((valid) => {
if (valid) {
const record = this.$_.cloneDeep(this.form);

View File

@@ -57,7 +57,12 @@
</yo-modal-form>
<!-- 编辑表单 -->
<yo-modal-form :action="$api[api.edit]" :title="'编辑' + name" @ok="onReloadData" ref="edit-form">
<yo-modal-form
:action="$api[api.edit]"
:title="'编辑' + name"
@ok="onReloadData"
ref="edit-form"
>
<form-body />
</yo-modal-form>
</container>
@@ -219,14 +224,12 @@ export default {
* 从列表页调用窗口的打开方法
*/
onOpen(formName, record) {
this.$refs[formName].onOpen(
this.$refs[formName].onOpen({
record,
/* 按需添加其他参数 */
/* ... */
this.query['pid']
);
orgId: this.query['pid'],
});
},
/**
* 必要方法