feat: 表单按钮状态修改
This commit is contained in:
@ -497,3 +497,37 @@ export function changeSchemaDisabled(schemas) {
|
|||||||
});
|
});
|
||||||
return schemas;
|
return schemas;
|
||||||
}
|
}
|
||||||
|
// 辅助设置表单可以编辑
|
||||||
|
export function changeSchemaEnable(schemas) {
|
||||||
|
const layoutComponents = ['tab', 'grid', 'card'];
|
||||||
|
schemas?.map((info) => {
|
||||||
|
if (layoutComponents.includes(info.type!)) {
|
||||||
|
info.children?.map((childInfo) => {
|
||||||
|
childInfo.list.map((com) => {
|
||||||
|
if (layoutComponents.includes(com.type)) {
|
||||||
|
changeSchemaDisabled(childInfo.list);
|
||||||
|
} else {
|
||||||
|
com.dynamicDisabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (info.type == 'table-layout') {
|
||||||
|
info.children?.map((childInfo) => {
|
||||||
|
childInfo.list.map((com) => {
|
||||||
|
com.children.map((el) => {
|
||||||
|
if (layoutComponents.includes(el.type) || el.type == 'table-layout') {
|
||||||
|
changeSchemaDisabled(com.children);
|
||||||
|
} else {
|
||||||
|
el.dynamicDisabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (info.type == 'one-for-one') {
|
||||||
|
changeSchemaDisabled(info.componentProps.childSchemas);
|
||||||
|
} else {
|
||||||
|
info.dynamicDisabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return schemas;
|
||||||
|
}
|
||||||
@ -1533,7 +1533,19 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
|||||||
actionsList = actionsList.concat(editAndDelBtn);
|
actionsList = actionsList.concat(editAndDelBtn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return actionsList;
|
return filterAction(actionsList, record);
|
||||||
|
}
|
||||||
|
function filterAction(list, record) {
|
||||||
|
const result = list.filter((item)=> {
|
||||||
|
let conditions = item.tooltip !== '查看流转记录'
|
||||||
|
if (record.workflowData.enabled) {
|
||||||
|
conditions = conditions && item.tooltip !== '查看'
|
||||||
|
} else {
|
||||||
|
conditions = conditions && (item.tooltip === '查看' || item.tooltip === '删除')
|
||||||
|
}
|
||||||
|
return conditions
|
||||||
|
})
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
: `
|
: `
|
||||||
|
|||||||
@ -8,12 +8,18 @@
|
|||||||
</slot>
|
</slot>
|
||||||
关闭
|
关闭
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button v-if="mode != 'view'" type="primary" @click="handleSubmit">
|
<a-button v-for="item in buttonList" type="primary" @click="btnEventHandle(item.code)">
|
||||||
|
<slot name="icon">
|
||||||
|
<check-circle-outlined />
|
||||||
|
</slot>
|
||||||
|
{{ item.name }}
|
||||||
|
</a-button>
|
||||||
|
<!-- <a-button v-if="mode != 'read'" type="primary" @click="handleSubmit">
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<check-circle-outlined />
|
<check-circle-outlined />
|
||||||
</slot>
|
</slot>
|
||||||
确认
|
确认
|
||||||
</a-button>
|
</a-button> -->
|
||||||
</a-space>
|
</a-space>
|
||||||
</div>
|
</div>
|
||||||
<component :is="dynamicComponent" ref="formRef" :fromPage="FromPageType.MENU" @form-mounted="onFormMounted" />
|
<component :is="dynamicComponent" ref="formRef" :fromPage="FromPageType.MENU" @form-mounted="onFormMounted" />
|
||||||
@ -23,13 +29,34 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { FromPageType } from '/@/enums/workflowEnum';
|
import { FromPageType } from '/@/enums/workflowEnum';
|
||||||
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent } from 'vue';
|
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive } from 'vue';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { CheckCircleOutlined, StopOutlined, CloseOutlined } from '@ant-design/icons-vue';
|
import { CheckCircleOutlined, StopOutlined, CloseOutlined } from '@ant-design/icons-vue';
|
||||||
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
||||||
import useEventBus from '/@/hooks/event/useEventBus';
|
import useEventBus from '/@/hooks/event/useEventBus';
|
||||||
|
import { edit } from '../generator/order/api';
|
||||||
|
|
||||||
|
// const buttonList = reactive([])
|
||||||
|
const allButtonList = [
|
||||||
|
{
|
||||||
|
"isUse": true,
|
||||||
|
"name": "编辑",
|
||||||
|
"code": "edit",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isUse": true,
|
||||||
|
"name": "确认",
|
||||||
|
"code": "submit",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
const btnEvent = {
|
||||||
|
edit: editForm,
|
||||||
|
submit: handleSubmit,
|
||||||
|
delete: deleteForm
|
||||||
|
}
|
||||||
const dynamicComponent = ref(null);
|
const dynamicComponent = ref(null);
|
||||||
const formType = ref('2'); // 0 新建 1 修改 2 查看
|
const formType = ref('2'); // 0 新建 1 修改 2 查看
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
@ -59,11 +86,36 @@ if (hash.indexOf('createForm') > 0) {
|
|||||||
} else if (hash.indexOf('viewForm') > 0) {
|
} else if (hash.indexOf('viewForm') > 0) {
|
||||||
mode.value = 'view';
|
mode.value = 'view';
|
||||||
}
|
}
|
||||||
|
const type = ref('readonly')
|
||||||
|
const buttonList = computed(() => {
|
||||||
|
let buttonArr = []
|
||||||
|
if (mode.value === 'create') {
|
||||||
|
buttonArr = allButtonList.filter(item => item.name === '确认')
|
||||||
|
} else {
|
||||||
|
if (type.value === 'readonly') {
|
||||||
|
buttonArr = allButtonList.filter(item => item.name !== '确认')
|
||||||
|
} else {
|
||||||
|
buttonArr = allButtonList.filter(item => item.name !== '编辑')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buttonArr;
|
||||||
|
});
|
||||||
|
|
||||||
dynamicComponent.value = defineAsyncComponent({
|
dynamicComponent.value = defineAsyncComponent({
|
||||||
loader: () => import(`./../../views/${pathArr[0]}/${pathArr[1]}/components/Form.vue`)
|
loader: () => import(`./../../views/${pathArr[0]}/${pathArr[1]}/components/Form.vue`)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function btnEventHandle(code) {
|
||||||
|
btnEvent[code]()
|
||||||
|
|
||||||
|
}
|
||||||
|
function editForm() {
|
||||||
|
type.value = 'edit'
|
||||||
|
setFormType()
|
||||||
|
}
|
||||||
|
function deleteForm() {
|
||||||
|
}
|
||||||
|
|
||||||
function onFormMounted(_formProps) {
|
function onFormMounted(_formProps) {
|
||||||
formProps.value = _formProps;
|
formProps.value = _formProps;
|
||||||
setFormType();
|
setFormType();
|
||||||
@ -76,7 +128,11 @@ async function setFormType() {
|
|||||||
}
|
}
|
||||||
await nextTick();
|
await nextTick();
|
||||||
if (_mode === 'view') {
|
if (_mode === 'view') {
|
||||||
await formRef.value.setDisabledForm();
|
if (type.value === 'readonly') {
|
||||||
|
await formRef.value.setDisabledForm();
|
||||||
|
} else {
|
||||||
|
await formRef.value.setEnabledForm();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await formRef.value.setFormDataFromId(formId.value);
|
await formRef.value.setFormDataFromId(formId.value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user