Commit 78d4ff44 by 宋春膨

feat(scjh): 添加生产计划下发任务功能

- 在按钮配置中添加下发任务按钮,支持非默认按钮类型显示
- 实现下发任务的确认弹窗功能,包含提示信息和确认取消操作
- 集成axios请求实现生产计划批量下发功能
- 添加用户token认证头确保接口调用权限
- 优化代码格式化和组件结构布局
- 重构按钮事件配置和操作列数据处理逻辑
parent 00c6f0f1
<template> <template>
<ResizePageWrapper :hasLeft="false">
<template #resizeRight>
<ResizePageWrapper :hasLeft="false"> <BasicTable
@register="registerTable"
isMenuTable
<template #resizeRight> ref="tableRef"
<BasicTable @register="registerTable" isMenuTable ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }"
>
>
<template #toolbar> <template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code"> <template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" type="primary" @click="buttonClick(button.code)"> <a-button v-if="button.isDefault" type="primary" @click="buttonClick(button.code)">
...@@ -17,105 +14,72 @@ ...@@ -17,105 +14,72 @@
{{ button.name }} {{ button.name }}
</a-button> </a-button>
<CustomButtonModal v-else-if="button.buttonType == 'modal'" :info="button" /> <CustomButtonModal v-else-if="button.buttonType == 'modal'" :info="button" />
<a-button v-else :type="button.buttonType === 'danger' ? 'default' : button.buttonType || 'primary'" :danger="button.buttonType === 'danger'" > <a-button
v-else
:type="button.buttonType === 'danger' ? 'default' : button.buttonType || 'primary'"
:danger="button.buttonType === 'danger'" @click="buttonClick(button.code)"
>
<template #icon><Icon :icon="button.icon" /></template> <template #icon><Icon :icon="button.icon" /></template>
{{ button.name }} {{ button.name }}
</a-button> </a-button>
</template> </template>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'"> <template v-if="column.dataIndex === 'action'">
<TableAction
<TableAction
:actions="getLessActions(record)" :actions="getLessActions(record)"
:dropDownActions="getMoreActions(record)" :dropDownActions="getMoreActions(record)"
/> />
</template> </template>
<template v-else-if="column.dataIndex && column?.listStyle"> <template v-else-if="column.dataIndex && column?.listStyle">
<span :style="executeListStyle(getValue(record, column, 'style'), column?.listStyle)">{{ <span :style="executeListStyle(getValue(record, column, 'style'), column?.listStyle)">{{
getValue(record, column, 'value') getValue(record, column, 'value')
}}</span> }}</span>
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
</template> </template>
<ScjhModal @register="registerModal" @success="handleFormSuccess" @cancel="handleFormCancel"/>
</ResizePageWrapper>
<ScjhModal @register="registerModal" @success="handleFormSuccess" @cancel="handleFormCancel" />
</ResizePageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed,provide,Ref, createVNode, import { ref, computed, provide, Ref, createVNode } from 'vue';
} from 'vue';
import { Modal } from 'ant-design-vue'; import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table'; import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getMesProductionPlanPage, deleteMesProductionPlan} from '/@/api/scgl/scjh'; import { getMesProductionPlanPage, deleteMesProductionPlan } from '/@/api/scgl/scjh';
import { ResizePageWrapper } from '/@/components/Page'; import { ResizePageWrapper } from '/@/components/Page';
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 { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue'; import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { executeListStyle, getValue } from '/@/hooks/web/useListStyle';//列表样式配置 import { executeListStyle, getValue } from '/@/hooks/web/useListStyle'; //列表样式配置
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import ScjhModal from './components/ScjhModal.vue'; import ScjhModal from './components/ScjhModal.vue';
import { searchFormSchema, columns } from './components/config';
import { searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index'; import Icon from '/@/components/Icon/index';
const listSpliceNum = ref(3); //操作列最先展示几个
const listSpliceNum = ref(3); //操作列最先展示几个
import { useConcurrentLock } from '/@/hooks/web/useConcurrentLock'; import { useConcurrentLock } from '/@/hooks/web/useConcurrentLock';
import axios from 'axios';
import { useUserStore } from '/@/store/modules/user';
const pageParamsInfo = ref<any>({}); const pageParamsInfo = ref<any>({});
const { enableLockeData,handleOpenFormEnableLockeData, handleCloseFormEnableLocke, handleHasEnableLocke } = const {
useConcurrentLock(); enableLockeData,
handleOpenFormEnableLockeData,
handleCloseFormEnableLocke,
handleHasEnableLocke,
} = useConcurrentLock();
const { notification } = useMessage(); const { notification } = useMessage();
const { t } = useI18n(); const { t } = useI18n();
...@@ -124,18 +88,58 @@ ...@@ -124,18 +88,58 @@
const filterColumns = filterColumnAuth(columns); const filterColumns = filterColumnAuth(columns);
const tableRef = ref(); const tableRef = ref();
//展示在列表内的按钮 //展示在列表内的按钮
const actionButtons = ref<string[]>(["view","edit","delete"]); const actionButtons = ref<string[]>(['view', 'edit', 'delete']);
const buttonConfigs = computed(()=>{ const buttonConfigs = computed(() => {
const list = [{"buttonId":"2004396569122545664","name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true,"isUse":true},{"buttonId":"2004396569122545665","name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"isUse":true},{"buttonId":"2004396569122545666","name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true,"isEnableLock":true},{"buttonId":"2004471125057142784","name":"下发任务","code":"xiafa","icon":"ant-design:export-outlined","isDefault":false,"isUse":true,"setting":[],"showType":"top","buttonType":"primary"},{"buttonId":"2004396569122545667","name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true,"isUse":true}] const list = [
{
buttonId: '2004396569122545664',
name: '查看',
code: 'view',
icon: 'ant-design:eye-outlined',
isDefault: true,
isUse: true,
},
{
buttonId: '2004396569122545665',
name: '新增',
code: 'add',
icon: 'ant-design:plus-outlined',
isDefault: true,
isUse: true,
},
{
buttonId: '2004396569122545666',
name: '编辑',
code: 'edit',
icon: 'ant-design:form-outlined',
isDefault: true,
isUse: true,
isEnableLock: true,
},
{
buttonId: '2004471125057142784',
name: '下发任务',
code: 'xiafa',
icon: 'ant-design:export-outlined',
isDefault: false,
isUse: true,
setting: [],
showType: 'top',
buttonType: 'primary',
},
{
buttonId: '2004396569122545667',
name: '删除',
code: 'delete',
icon: 'ant-design:delete-outlined',
isDefault: true,
isUse: true,
},
];
return filterButtonAuth(list); return filterButtonAuth(list);
}) });
const tableButtonConfig = computed(() => { const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code)); return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
...@@ -145,29 +149,19 @@ ...@@ -145,29 +149,19 @@
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code)); return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
}); });
const btnEvent = {view : handleView,add : handleAdd,edit : handleEdit,delete : handleDelete,} const btnEvent = { view: handleView, add: handleAdd, edit: handleEdit, delete: handleDelete };
const { currentRoute } = useRouter(); const { currentRoute } = useRouter();
const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string); const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string);
provide<Ref<string>>('currentFormId', formIdComputedRef); provide<Ref<string>>('currentFormId', formIdComputedRef);
const selectedKeys = ref<string[]>([]); const selectedKeys = ref<string[]>([]);
const selectedRowsData = ref<any[]>([]); const selectedRowsData = ref<any[]>([]);
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerTable, { reload }] = useTable({
const [registerTable, { reload, }] = useTable({
title: 'Scjh列表', title: 'Scjh列表',
api: getMesProductionPlanPage, api: getMesProductionPlanPage,
rowKey: 'id', rowKey: 'id',
...@@ -181,25 +175,18 @@ ...@@ -181,25 +175,18 @@
fieldMapToTime: [], fieldMapToTime: [],
showResetButton: false, showResetButton: false,
}, },
bordered:false, bordered: false,
beforeFetch: (params) => { beforeFetch: (params) => {
pageParamsInfo.value = {...params, FormId: formIdComputedRef.value,PK: 'id' } pageParamsInfo.value = { ...params, FormId: formIdComputedRef.value, PK: 'id' };
return pageParamsInfo.value; return pageParamsInfo.value;
}, },
afterFetch: (res) => { afterFetch: (res) => {
selectedKeys.value = []; selectedKeys.value = [];
selectedRowsData.value = []; selectedRowsData.value = [];
}, },
useSearchForm: true, useSearchForm: true,
showTableSetting: true, showTableSetting: true,
striped: false, striped: false,
actionColumn: { actionColumn: {
width: 195, width: 195,
...@@ -211,60 +198,68 @@ ...@@ -211,60 +198,68 @@
size: false, size: false,
}, },
customRow, customRow,
isAdvancedQuery: false, isAdvancedQuery: false,
querySelectOption: JSON.stringify(searchFormSchema), querySelectOption: JSON.stringify(searchFormSchema),
objectId: formIdComputedRef.value, ////系统表单formId,自定义表单releaseId的id值 objectId: formIdComputedRef.value, ////系统表单formId,自定义表单releaseId的id值
}); });
function buttonClick(code) { function buttonClick(code) {
const store = useUserStore()
const ids = selectedRowsData.value.map((x) => x.id)
if (code === 'xiafa') {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认下发任务?',
okText: '确认',
cancelText: '取消',
onOk() {
axios
.post('http://localhost:8053/scgl/scjh/issue', { ids } , {headers: { Authorization: 'Bearer '+store.getToken } })
.then((res) => {
if (res.data === '下发成功') {
notification.success({
message: '提示信息',
description: res.data,
});
}
});
},
});
}
btnEvent[code](); btnEvent[code]();
} }
function handleAdd() { function handleAdd() {
openModal(true, { isUpdate: false });
}
openModal(true, { isUpdate: false, });
}
async function handleEdit(record: Recordable) { async function handleEdit(record: Recordable) {
let field = 'id'; let field = 'id';
try { try {
let hasIn = handleHasEnableLocke(buttonConfigs.value, 'edit'); let hasIn = handleHasEnableLocke(buttonConfigs.value, 'edit');
if (hasIn) { if (hasIn) {
let res = await handleOpenFormEnableLockeData( let res = await handleOpenFormEnableLockeData(record[field], formIdComputedRef.value);
record[field],
formIdComputedRef.value,
);
if (res !== null) { if (res !== null) {
return; return;
} }
} }
let info = { let info = {
id: record[field], id: record[field],
isUpdate: true, isUpdate: true,
};
};
openModal(true, info);
openModal(true, info); } catch (error) {}
} catch (error) {}
} }
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
deleteList([record.id]); deleteList([record.id]);
} }
function deleteList(ids) { function deleteList(ids) {
Modal.confirm({ Modal.confirm({
title: '提示信息', title: '提示信息',
...@@ -284,19 +279,14 @@ ...@@ -284,19 +279,14 @@
onCancel() {}, onCancel() {},
}); });
} }
function onSelectChange(selectedRowKeys: [], selectedRows) { function onSelectChange(selectedRowKeys: [], selectedRows) {
selectedKeys.value = selectedRowKeys; selectedKeys.value = selectedRowKeys;
selectedRowsData.value = selectedRows; selectedRowsData.value = selectedRows;
} }
function customRow(record: Recordable) { function customRow(record: Recordable) {
return { return {
onClick: () => { onClick: () => {
let selectedRowKeys = [...selectedKeys.value]; let selectedRowKeys = [...selectedKeys.value];
if (selectedRowKeys.indexOf(record.id) >= 0) { if (selectedRowKeys.indexOf(record.id) >= 0) {
...@@ -308,24 +298,20 @@ ...@@ -308,24 +298,20 @@
selectedKeys.value = selectedRowKeys; selectedKeys.value = selectedRowKeys;
}, },
ondblclick: () => { ondblclick: () => {
if (record.isCanEdit && hasPermission("scjh:edit")) { if (record.isCanEdit && hasPermission('scjh:edit')) {
handleEdit(record); handleEdit(record);
} }
}, },
}; };
} }
function handleSuccess() { function handleSuccess() {
selectedKeys.value = [];
selectedRowsData.value = [];
selectedKeys.value = [];
selectedRowsData.value = [];
reload(); reload();
} }
function handleFormSuccess() {
function handleFormSuccess() {
handleSuccess(); handleSuccess();
handleCloseFormEnableLocke(buttonConfigs.value, 'edit'); handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
} }
...@@ -333,19 +319,15 @@ ...@@ -333,19 +319,15 @@
handleCloseFormEnableLocke(buttonConfigs.value, 'edit'); handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
} }
function handleView(record: Recordable) { function handleView(record: Recordable) {
let info={ let info = {
isView: true, isView: true,
id: record.id, id: record.id,
} };
openModal(true, info); openModal(true, info);
} }
function getLessActions(record: Recordable) { function getLessActions(record: Recordable) {
let list = getActions(record); let list = getActions(record);
return list.slice(0, listSpliceNum.value); return list.slice(0, listSpliceNum.value);
...@@ -354,16 +336,16 @@ ...@@ -354,16 +336,16 @@
let list = getActions(record); let list = getActions(record);
return list.slice(listSpliceNum.value); return list.slice(listSpliceNum.value);
} }
function getActions(record: Recordable):ActionItem[] { function getActions(record: Recordable): ActionItem[] {
record.isCanEdit = false; record.isCanEdit = false;
let actionsList: ActionItem[] = []; let actionsList: ActionItem[] = [];
actionButtonConfig.value?.map((button) => { actionButtonConfig.value?.map((button) => {
if (!record?.workflowData?.processId) { if (!record?.workflowData?.processId) {
record.isCanEdit = true; record.isCanEdit = true;
actionsList.push({ actionsList.push({
...button, ...button,
auth: `scjh:${button.code}`, auth: `scjh:${button.code}`,
label: button?.name, label: button?.name,
color: button.code === 'delete' ? 'error' : undefined, color: button.code === 'delete' ? 'error' : undefined,
...@@ -372,34 +354,26 @@ ...@@ -372,34 +354,26 @@
} else { } else {
if (!['edit', 'delete'].includes(button.code)) { if (!['edit', 'delete'].includes(button.code)) {
actionsList.push({ actionsList.push({
auth: `scjh:${button.code}`, auth: `scjh:${button.code}`,
label: button?.name, label: button?.name,
onClick: btnEvent[button.code]?.bind(null, record), onClick: btnEvent[button.code]?.bind(null, record),
}); });
} }
} }
}); });
return actionsList; return actionsList;
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.ant-table-selection-col) { :deep(.ant-table-selection-col) {
width: 50px; width: 50px;
} }
.show{ .show {
display: flex; display: flex;
} }
.hide{ .hide {
display: none !important; display: none !important;
} }
</style>
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment