Commit 4559c117 by 胡鑫

盈亏 生成单据

parent 6ea9755b
<template>
<ResizePageWrapper :hasLeft="false">
<ResizePageWrapper :hasLeft="false">
<template #resizeRight>
<BasicTable @register="registerTable" isMenuTable ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }"
>
<BasicTable @register="registerTable" isMenuTable ref="tableRef"
:row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }">
<template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" type="primary" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
<template #icon>
<Icon :icon="button.icon" />
</template>
{{ button.name }}
</a-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'" >
<template #icon><Icon :icon="button.icon" /></template>
<a-button v-else :type="button.buttonType === 'danger' ? 'default' : button.buttonType || 'primary'"
:danger="button.buttonType === 'danger'">
<template #icon>
<Icon :icon="button.icon" />
</template>
{{ button.name }}
</a-button>
</template>
......@@ -29,10 +32,7 @@
<template v-if="column.dataIndex === 'action'">
<TableAction
:actions="getLessActions(record)"
:dropDownActions="getMoreActions(record)"
/>
<TableAction :actions="getLessActions(record)" :dropDownActions="getMoreActions(record)" />
</template>
<template v-else-if="column.dataIndex && column?.listStyle">
......@@ -49,39 +49,41 @@
<KcykModal @register="registerModal" @success="handleFormSuccess" @cancel="handleFormCancel"/>
<KcykModal @register="registerModal" @success="handleFormSuccess" @cancel="handleFormCancel" />
</ResizePageWrapper>
</ResizePageWrapper>
</template>
<script lang="ts" setup>
import { ref, computed,provide,Ref,
import {
ref, computed, provide, Ref,
} from 'vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getMesWarehouseProfitandlossPage, deleteMesWarehouseProfitandloss} from '/@/api/ckgl/kcyk';
import { ResizePageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { executeListStyle, getValue } from '/@/hooks/web/useListStyle';//列表样式配置
import { useRouter } from 'vue-router';
import { getAppEnvConfig } from '/@/utils/env';
import { getToken } from '/@/utils/auth';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getMesWarehouseProfitandlossPage, deleteMesWarehouseProfitandloss } from '/@/api/ckgl/kcyk';
import { ResizePageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { executeListStyle, getValue } from '/@/hooks/web/useListStyle';//列表样式配置
import { useRouter } from 'vue-router';
import { useModal } from '/@/components/Modal';
import { useModal } from '/@/components/Modal';
import KcykModal from './components/KcykModal.vue';
import KcykModal from './components/KcykModal.vue';
......@@ -89,9 +91,9 @@
import { searchFormSchema, columns } from './components/config';
import { searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import Icon from '/@/components/Icon/index';
......@@ -102,70 +104,104 @@
const listSpliceNum = ref(3); //操作列最先展示几个
const listSpliceNum = ref(3); //操作列最先展示几个
import { useConcurrentLock } from '/@/hooks/web/useConcurrentLock';
import { useConcurrentLock } from '/@/hooks/web/useConcurrentLock';
import { log } from 'console';
const pageParamsInfo = ref<any>({});
const { enableLockeData,handleOpenFormEnableLockeData, handleCloseFormEnableLocke, handleHasEnableLocke } =
const pageParamsInfo = ref<any>({});
const { enableLockeData, handleOpenFormEnableLockeData, handleCloseFormEnableLocke, handleHasEnableLocke } =
useConcurrentLock();
const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth, hasPermission } = usePermission();
const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth, hasPermission } = usePermission();
const filterColumns = filterColumnAuth(columns);
const tableRef = ref();
const filterColumns = filterColumnAuth(columns);
const tableRef = ref();
//展示在列表内的按钮
const actionButtons = ref<string[]>(["create"]);
const buttonConfigs = computed(()=>{
const list = [{"buttonId":"2016441785685393408","name":"生成单据","code":"create","icon":"ant-design:download-outlined","isDefault":false,"isUse":true,"setting":[],"showType":"inline","buttonType":"primary"}]
//展示在列表内的按钮
const actionButtons = ref<string[]>(["create"]);
const buttonConfigs = computed(() => {
const list = [{ "buttonId": "2016441785685393408", "name": "生成单据", "code": "create", "icon": "ant-design:download-outlined", "isDefault": false, "isUse": true, "setting": [], "showType": "inline", "buttonType": "primary" }]
return filterButtonAuth(list);
})
})
const tableButtonConfig = computed(() => {
const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
});
});
const actionButtonConfig = computed(() => {
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
// 调用生成单据接口
const btnEvent = {
create: async (record) => {
try {
const response = await fetch(getAppEnvConfig().VITE_GLOB_API_URL + '/ckgl/kcyk/addslip', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${getToken()}`
},
body: JSON.stringify(record)
});
const btnEvent = {}
if (response.ok) {
notification.success({
message: '成功',
description: '生成单据成功'
});
// 刷新列表
reload();
} else {
const error = await response.json();
notification.error({
message: '失败',
description: error.message || '生成单据失败'
});
}
} catch (error) {
notification.error({
message: '错误',
description: '生成单据时发生错误'
});
console.error('生成单据失败:', error);
}
}
}
const { currentRoute } = useRouter();
const { currentRoute } = useRouter();
const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string);
provide<Ref<string>>('currentFormId', formIdComputedRef);
const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string);
provide<Ref<string>>('currentFormId', formIdComputedRef);
const selectedKeys = ref<string[]>([]);
const selectedRowsData = ref<any[]>([]);
const selectedKeys = ref<string[]>([]);
const selectedRowsData = ref<any[]>([]);
const [registerModal, { openModal }] = useModal();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, }] = useTable({
const [registerTable, { reload, }] = useTable({
title: 'Kcyk列表',
api: getMesWarehouseProfitandlossPage,
rowKey: 'id',
......@@ -179,9 +215,9 @@
fieldMapToTime: [],
showResetButton: false,
},
bordered:false,
bordered: false,
beforeFetch: (params) => {
pageParamsInfo.value = {...params, FormId: formIdComputedRef.value,PK: 'id' }
pageParamsInfo.value = { ...params, FormId: formIdComputedRef.value, PK: 'id' }
return pageParamsInfo.value;
},
afterFetch: (res) => {
......@@ -212,15 +248,15 @@
isAdvancedQuery: false,
querySelectOption: JSON.stringify(searchFormSchema),
objectId: formIdComputedRef.value, ////系统表单formId,自定义表单releaseId的id值
});
});
function buttonClick(code) {
function buttonClick(code) {
btnEvent[code]();
}
}
......@@ -232,12 +268,12 @@
function onSelectChange(selectedRowKeys: [], selectedRows) {
function onSelectChange(selectedRowKeys: [], selectedRows) {
selectedKeys.value = selectedRowKeys;
selectedRowsData.value = selectedRows;
}
}
function customRow(record: Recordable) {
function customRow(record: Recordable) {
console.log(record);
// 强制根据盈亏状态设置行背景色
let rowStyle = {};
......@@ -270,40 +306,40 @@
}
},
};
}
}
function handleSuccess() {
function handleSuccess() {
selectedKeys.value = [];
selectedRowsData.value = [];
reload();
}
}
function handleFormSuccess() {
function handleFormSuccess() {
handleSuccess();
handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
}
function handleFormCancel() {
}
function handleFormCancel() {
handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
}
}
function getLessActions(record: Recordable) {
function getLessActions(record: Recordable) {
let list = getActions(record);
return list.slice(0, listSpliceNum.value);
}
function getMoreActions(record: Recordable) {
}
function getMoreActions(record: Recordable) {
let list = getActions(record);
return list.slice(listSpliceNum.value);
}
function getActions(record: Recordable):ActionItem[] {
}
function getActions(record: Recordable): ActionItem[] {
record.isCanEdit = false;
let actionsList: ActionItem[] = [];
......@@ -330,25 +366,20 @@
}
});
return actionsList;
}
}
</script>
<style lang="less" scoped>
:deep(.ant-table-selection-col) {
:deep(.ant-table-selection-col) {
width: 50px;
}
}
.show{
.show {
display: flex;
}
}
.hide{
.hide {
display: none !important;
}
}
</style>
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