feat: 代码过滤逻辑 修改
This commit is contained in:
@ -1478,6 +1478,7 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
||||
icon: button?.icon,
|
||||
tooltip: button?.name,
|
||||
onClick: handleView.bind(null, record),
|
||||
code: button.code
|
||||
});
|
||||
}
|
||||
if (['edit', 'copyData', 'delete'].includes(button.code)) {
|
||||
@ -1507,18 +1508,6 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
||||
act.onClick = handleStartwork.bind(null, record);
|
||||
}
|
||||
actionsList.unshift(act);
|
||||
${
|
||||
hasFlowRecordButton
|
||||
? `if (hasFlowRecord) {
|
||||
actionsList.splice(1, 0, {
|
||||
tooltip: '查看流转记录',
|
||||
icon: 'liuzhuanxinxi|svg',
|
||||
onClick: handleFlowRecord.bind(null, record),
|
||||
});
|
||||
}`
|
||||
: ''
|
||||
}
|
||||
|
||||
} else {
|
||||
actionsList.unshift({
|
||||
icon: 'faqishenpi|svg',
|
||||
@ -1537,12 +1526,7 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
||||
}
|
||||
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 === '删除')
|
||||
}
|
||||
let conditions = item.code !== 'view'
|
||||
return conditions
|
||||
})
|
||||
return result
|
||||
@ -1556,6 +1540,7 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
||||
tooltip: button?.name,
|
||||
color: button.code === 'delete' ? 'error' : undefined,
|
||||
onClick: btnEvent[button.code].bind(null, record),
|
||||
code: button?.code
|
||||
};
|
||||
} else {
|
||||
if (button.code === 'view') {
|
||||
@ -1563,13 +1548,21 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
||||
icon: button?.icon,
|
||||
tooltip: button?.name,
|
||||
onClick: btnEvent[button.code].bind(null, record),
|
||||
code: button?.code
|
||||
};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
});
|
||||
return actionsList;
|
||||
return filterAction(actionsList, record);
|
||||
}
|
||||
function filterAction(list, record) {
|
||||
const result = list.filter((item)=> {
|
||||
let conditions = item.code === 'view' || item.code === 'delete'
|
||||
return conditions
|
||||
})
|
||||
return result
|
||||
}`
|
||||
}
|
||||
${
|
||||
|
||||
@ -8,18 +8,18 @@
|
||||
</slot>
|
||||
关闭
|
||||
</a-button>
|
||||
<a-button v-for="item in buttonList" type="primary" @click="btnEventHandle(item.code)">
|
||||
<a-button style="margin-right: 10px" type="primary" @click="editForm" v-if="mode === 'view' && type === 'readonly'">
|
||||
<slot name="icon">
|
||||
<check-circle-outlined />
|
||||
<edit-outlined />
|
||||
</slot>
|
||||
{{ item.name }}
|
||||
编辑
|
||||
</a-button>
|
||||
<!-- <a-button v-if="mode != 'read'" type="primary" @click="handleSubmit">
|
||||
<a-button type="primary" @click="handleSubmit" v-else>
|
||||
<slot name="icon">
|
||||
<check-circle-outlined />
|
||||
</slot>
|
||||
确认
|
||||
</a-button> -->
|
||||
保存
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
<component :is="dynamicComponent" ref="formRef" :fromPage="FromPageType.MENU" @form-mounted="onFormMounted" />
|
||||
@ -32,31 +32,10 @@ import { FromPageType } from '/@/enums/workflowEnum';
|
||||
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { CheckCircleOutlined, StopOutlined, CloseOutlined } from '@ant-design/icons-vue';
|
||||
import { CheckCircleOutlined, StopOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons-vue';
|
||||
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
||||
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 formType = ref('2'); // 0 新建 1 修改 2 查看
|
||||
const formRef = ref();
|
||||
@ -87,34 +66,15 @@ if (hash.indexOf('createForm') > 0) {
|
||||
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({
|
||||
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) {
|
||||
formProps.value = _formProps;
|
||||
@ -187,10 +147,6 @@ async function saveModal() {
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.page-bg-wrap {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.top-toolbar {
|
||||
min-height: 44px;
|
||||
margin-bottom: 12px;
|
||||
|
||||
Reference in New Issue
Block a user