feat: 代码过滤逻辑 修改

This commit is contained in:
GAOANG
2024-04-24 18:19:12 +08:00
parent a2ce42f862
commit 60458f1dc8
2 changed files with 19 additions and 70 deletions

View File

@ -1478,6 +1478,7 @@ ${hasTemplatePrint ? ' reactive ' : ''}
icon: button?.icon, icon: button?.icon,
tooltip: button?.name, tooltip: button?.name,
onClick: handleView.bind(null, record), onClick: handleView.bind(null, record),
code: button.code
}); });
} }
if (['edit', 'copyData', 'delete'].includes(button.code)) { if (['edit', 'copyData', 'delete'].includes(button.code)) {
@ -1507,18 +1508,6 @@ ${hasTemplatePrint ? ' reactive ' : ''}
act.onClick = handleStartwork.bind(null, record); act.onClick = handleStartwork.bind(null, record);
} }
actionsList.unshift(act); actionsList.unshift(act);
${
hasFlowRecordButton
? `if (hasFlowRecord) {
actionsList.splice(1, 0, {
tooltip: '查看流转记录',
icon: 'liuzhuanxinxi|svg',
onClick: handleFlowRecord.bind(null, record),
});
}`
: ''
}
} else { } else {
actionsList.unshift({ actionsList.unshift({
icon: 'faqishenpi|svg', icon: 'faqishenpi|svg',
@ -1537,12 +1526,7 @@ ${hasTemplatePrint ? ' reactive ' : ''}
} }
function filterAction(list, record) { function filterAction(list, record) {
const result = list.filter((item)=> { const result = list.filter((item)=> {
let conditions = item.tooltip !== '查看流转记录' let conditions = item.code !== 'view'
if (record.workflowData.enabled) {
conditions = conditions && item.tooltip !== '查看'
} else {
conditions = conditions && (item.tooltip === '查看' || item.tooltip === '删除')
}
return conditions return conditions
}) })
return result return result
@ -1556,6 +1540,7 @@ ${hasTemplatePrint ? ' reactive ' : ''}
tooltip: button?.name, tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined, color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record), onClick: btnEvent[button.code].bind(null, record),
code: button?.code
}; };
} else { } else {
if (button.code === 'view') { if (button.code === 'view') {
@ -1563,13 +1548,21 @@ ${hasTemplatePrint ? ' reactive ' : ''}
icon: button?.icon, icon: button?.icon,
tooltip: button?.name, tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record), onClick: btnEvent[button.code].bind(null, record),
code: button?.code
}; };
} else { } else {
return {}; 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
}` }`
} }
${ ${

View File

@ -8,18 +8,18 @@
</slot> </slot>
关闭 关闭
</a-button> </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"> <slot name="icon">
<check-circle-outlined /> <edit-outlined />
</slot> </slot>
{{ item.name }} 编辑
</a-button> </a-button>
<!-- <a-button v-if="mode != 'read'" type="primary" @click="handleSubmit"> <a-button type="primary" @click="handleSubmit" v-else>
<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" />
@ -32,31 +32,10 @@ import { FromPageType } from '/@/enums/workflowEnum';
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive } 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, EditOutlined } 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'; 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();
@ -87,34 +66,15 @@ if (hash.indexOf('createForm') > 0) {
mode.value = 'view'; mode.value = 'view';
} }
const type = ref('readonly') 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() { function editForm() {
type.value = 'edit' type.value = 'edit'
setFormType() setFormType()
} }
function deleteForm() {
}
function onFormMounted(_formProps) { function onFormMounted(_formProps) {
formProps.value = _formProps; formProps.value = _formProps;
@ -187,10 +147,6 @@ async function saveModal() {
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.page-bg-wrap {
background-color: #fff;
}
.top-toolbar { .top-toolbar {
min-height: 44px; min-height: 44px;
margin-bottom: 12px; margin-bottom: 12px;