采购计量列表样式调整

This commit is contained in:
‘huanghaiixia’
2026-01-20 17:55:58 +08:00
parent 3d97ce852e
commit b0e03cecc0
3 changed files with 622 additions and 109 deletions

View File

@ -39,7 +39,8 @@ export const columns: BasicColumn[] = [
title: '计划日期', title: '计划日期',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
width: 100, width: 120,
ellipsis: true,
sorter: true, sorter: true,
}, },
@ -48,7 +49,7 @@ export const columns: BasicColumn[] = [
title: '计量日期', title: '计量日期',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
width: 100, width: 120,
sorter: true, sorter: true,
}, },
{ {
@ -56,7 +57,8 @@ export const columns: BasicColumn[] = [
title: '客户', title: '客户',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
ellipsis: true,
width: 200,
sorter: true, sorter: true,
}, },
{ {
@ -64,7 +66,8 @@ export const columns: BasicColumn[] = [
title: '下载点', title: '下载点',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
ellipsis: true,
width: 200,
sorter: true, sorter: true,
}, },
{ {
@ -72,7 +75,8 @@ export const columns: BasicColumn[] = [
title: '供应商', title: '供应商',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
ellipsis: true,
width: 200,
sorter: true, sorter: true,
}, },
@ -81,7 +85,8 @@ export const columns: BasicColumn[] = [
title: '上载点', title: '上载点',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
ellipsis: true,
width: 200,
sorter: true, sorter: true,
}, },
@ -170,7 +175,8 @@ export const columns: BasicColumn[] = [
title: '销售合同', title: '销售合同',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
ellipsis: true,
width: 200,
sorter: true, sorter: true,
}, },
{ {
@ -178,7 +184,8 @@ export const columns: BasicColumn[] = [
title: '采购合同', title: '采购合同',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
ellipsis: true,
width: 200,
sorter: true, sorter: true,
}, },
@ -187,7 +194,7 @@ export const columns: BasicColumn[] = [
title: '附件', title: '附件',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
width: 200,
sorter: true, sorter: true,
}, },
@ -205,7 +212,8 @@ export const columns: BasicColumn[] = [
title: '备注', title: '备注',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
ellipsis: true,
width: 200,
sorter: true, sorter: true,
}, },
]; ];

View File

@ -17,27 +17,16 @@
</div> </div>
</div> </div>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex" class="PngMeasureSalesPurStyle"> <PageWrapper dense fixedHeight contentFullHeight contentClass="flex" class="PngMeasureSalesPurStyle">
<BasicTable @register="registerTable" ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }" @row-dbClick="dbClickRow"> <a-table :loading="loading" :columns="columns" :data-source="tableData" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }"
rowKey="id" :pagination="pagination" @row-dbClick="dbClickRow" :scroll="{x: 2000}">
<!-- <template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
<a-button v-else :type="button.type">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
</template>
</template> -->
<template #bodyCell="{ column, record, index }"> <template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'qtyMeaGj'"> <template v-if="column.dataIndex === 'qtyMeaGj'">
<a-input-number v-model:value="record.qtyMeaGj" v-if="statusCode==='N'|| statusCode==='JLZ'" @change="numChange(record)" :min="0" style="width: 100%" /> <a-input-number v-model:value="record.qtyMeaGj" v-if="statusCode==='N'|| statusCode==='JLZ'" @change="numChange(record, index)" :min="0" style="width: 100%" />
<div v-else>{{ record.qtyMeaGj }}</div> <div v-else>{{ record.qtyMeaGj }}</div>
</template> </template>
<template v-if="column.dataIndex === 'qtyMeaM3'"> <template v-if="column.dataIndex === 'qtyMeaM3'">
<a-input-number v-model:value="record.qtyMeaM3" v-if="statusCode==='N'|| statusCode==='JLZ'" @change="numChange(record)" :min="0" style="width: 100%" /> <a-input-number v-model:value="record.qtyMeaM3" v-if="statusCode==='N'|| statusCode==='JLZ'" @change="numChange(record, index)" :min="0" style="width: 100%" />
</template> </template>
<template v-if="column.dataIndex === 'lngFileUploadList'"> <template v-if="column.dataIndex === 'lngFileUploadList'">
<div> <div>
@ -45,7 +34,7 @@
:multiple="true" :dataDelete="true" :isShowTip="false" :isShowBtnIcon="false" @click="onUpload(index)" @change="uploadChange" :showDownloadIcon="false"/> :multiple="true" :dataDelete="true" :isShowTip="false" :isShowBtnIcon="false" @click="onUpload(index)" @change="uploadChange" :showDownloadIcon="false"/>
<div v-for="(item, idx) in record.lngFileUploadList"> <div v-for="(item, idx) in record.lngFileUploadList">
<a @click="handleDownload(item)">{{item.fileOrg}}</a> <a @click="handleDownload(item)">{{item.fileOrg}}</a>
<span @click="deleteFile(record, idx)" class="delIcon"><DeleteOutlined /></span> <span @click="deleteFile(record, idx, index)" class="delIcon"><DeleteOutlined /></span>
</div> </div>
</div> </div>
</template> </template>
@ -53,7 +42,7 @@
<TableAction :actions="getActions(record)" /> <TableAction :actions="getActions(record)" />
</template> </template>
</template> </template>
</BasicTable> </a-table>
<PngMeasureSalesPurModal @register="registerModal" @success="handleSuccess" /> <PngMeasureSalesPurModal @register="registerModal" @success="handleSuccess" />
<ImportModal @register="registerImportModal" importUrl="/dayPlan/pngMeasureSalesPur/import" @success="handleImportSuccess"/> <ImportModal @register="registerImportModal" importUrl="/dayPlan/pngMeasureSalesPur/import" @success="handleImportSuccess"/>
@ -94,6 +83,7 @@
import { downloadByUrl } from '/@/utils/file/download'; import { downloadByUrl } from '/@/utils/file/download';
import { DeleteOutlined } from '@ant-design/icons-vue'; import { DeleteOutlined } from '@ant-design/icons-vue';
import searchForm from './components/searchForm.vue' import searchForm from './components/searchForm.vue'
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus(); const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
@ -108,6 +98,29 @@
const customSearchFormSchema =ref(searchFormSchema); const customSearchFormSchema =ref(searchFormSchema);
const tableRef = ref(); const tableRef = ref();
const tableData = ref([])
const total = ref(0);
const currentPage = ref(1);
const pageSize = ref(10);
const loading = ref(false)
// 分页配置
const pagination = computed(() => ({
total: total.value,
current: currentPage.value,
pageSize: pageSize.value,
showQuickJumper: true,
showSizeChanger: true,
showTotal: (total: number) => `${total}条数据`,
pageSizeOptions: ["10", "20", "50", "80", "100"],
onShowSizeChange: (current, pageSize) => {
pageSize.value = pageSize;
loadData()
},
onChange: (current, size) => {
pageSize.value = size;
loadData()
},
}));
//所有按钮 //所有按钮
const buttons = ref([{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"保存","code":"save","icon":"ant-design:save-outlined","isDefault":true},{"isUse":true,"name":"保存并确认","code":"submit","icon":"ant-design:check-outlined","isDefault":true},{"isUse":true,"name":"取消确认","code":"cancel","icon":"ant-design:rollback-outlined","isDefault":true},{"isUse":true,"name":"驳回","code":"reject","icon":"ant-design:stop-outlined","isDefault":true},{"isUse":true,"name":"导出","code":"export","icon":"ant-design:export-outlined","isDefault":true},{"isUse":true,"name":"导入","code":"import","icon":"ant-design:import-outlined","isDefault":true},{"isUse":true,"name":"删除","code":"batchdelete","icon":"ant-design:delete-outlined","isDefault":true},{"isUse":true,"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true}]); const buttons = ref([{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"保存","code":"save","icon":"ant-design:save-outlined","isDefault":true},{"isUse":true,"name":"保存并确认","code":"submit","icon":"ant-design:check-outlined","isDefault":true},{"isUse":true,"name":"取消确认","code":"cancel","icon":"ant-design:rollback-outlined","isDefault":true},{"isUse":true,"name":"驳回","code":"reject","icon":"ant-design:stop-outlined","isDefault":true},{"isUse":true,"name":"导出","code":"export","icon":"ant-design:export-outlined","isDefault":true},{"isUse":true,"name":"导入","code":"import","icon":"ant-design:import-outlined","isDefault":true},{"isUse":true,"name":"删除","code":"batchdelete","icon":"ant-design:delete-outlined","isDefault":true},{"isUse":true,"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true}]);
//展示在列表内的按钮 //展示在列表内的按钮
@ -144,37 +157,24 @@
const columnName = 'PngMeasureSalesPur'; const columnName = 'PngMeasureSalesPur';
const formName='管道气采购计量'; const formName='管道气采购计量';
const [registerTable, { reload, clearSelectedRowKeys, getDataSource, updateTableDataRecord }] = useTable({
title: '' || (formName + '列表'), const loadData = async () => {
api: getLngPngMeasureSalesPurPage, loading.value = true;
rowKey: 'id', try {
columns: customConfigColums, const res = await getLngPngMeasureSalesPurPage({
formConfig: { limit: currentPage.value,
schemas: [], size: pageSize.value,
showResetButton: false, page: currentPage.value,
showSubmitButton: false ...formState.value,
}, });
beforeFetch: (params) => { tableData.value = res.list;
return { ...params, FormId: formIdComputedRef.value, PK: 'id',page: params.limit, ...formState.value}; total.value = res.total || res.length || 0;
}, } catch (error) {
afterFetch: (res) => { console.error('获取列表失败:', error);
tableRef.value.setToolBarWidth(); } finally {
loading.value = false;
}, }
useSearchForm: true, };
showTableSetting: true,
striped: false,
rowSelection: {
type: 'checkbox',
onChange: onSelectChange
},
tableSetting: {
size: false,
setting: false,
},
customRow,
});
const isExpend = ref(false) const isExpend = ref(false)
const formState = ref({}) const formState = ref({})
const toggle = (val)=> { const toggle = (val)=> {
@ -182,34 +182,31 @@
} }
const onSearch = (val)=> { const onSearch = (val)=> {
formState.value = val formState.value = val
reload() handleSuccess()
} }
const onReset = (val)=> { const onReset = (val)=> {
formState.value ={ page: 1,size: 10} formState.value ={ page: 1,size: 10}
reload() handleSuccess()
} }
const onUpload = (index) => { const onUpload = (index) => {
curIdx.value = index curIdx.value = index
} }
const uploadChange = (val) => { const uploadChange = (val) => {
let data = getDataSource() tableData.value[curIdx.value].lngFileUploadList = val
let record = data[curIdx.value]
record.lngFileUploadList = val
updateTableDataRecord(record.id, record)
} }
const deleteFile = (record, idx) => { const deleteFile = (record, idx, index) => {
record.lngFileUploadList.splice(idx, 1) record.lngFileUploadList.splice(idx, 1)
updateTableDataRecord(record.id, record) tableData.value[index] = record
} }
const handleDownload = (info) => { const handleDownload = (info) => {
const url = parseDownloadUrl(info.response ? info.response.data.fileUrl : info.fileUrl); const url = parseDownloadUrl(info.response ? info.response.data.fileUrl : info.fileUrl);
const fileName = info.response ? info.response.data.fileOrg : info.fileOrg; const fileName = info.response ? info.response.data.fileOrg : info.fileOrg;
downloadByUrl({ url, fileName: fileName}); downloadByUrl({ url, fileName: fileName});
}; };
const numChange = (record) => { const numChange = (record, index) => {
record.rateM3Gj = Number(record.qtyMeaGj) ? (Number(record.qtyMeaM3) || 0 ) / Number(record.qtyMeaGj) : '0' record.rateM3Gj = Number(record.qtyMeaGj) ? (Number(record.qtyMeaM3) || 0 ) / Number(record.qtyMeaGj) : '0'
record.rateM3Gj = record.rateM3Gj.toFixed(6) record.rateM3Gj = record.rateM3Gj.toFixed(6)
updateTableDataRecord(record.id, record) tableData.value[index] = record
} }
function handleAdd() { function handleAdd() {
@ -238,7 +235,6 @@
message: 'Tip', message: 'Tip',
description: t('已驳回!'), description: t('已驳回!'),
}); });
clearSelectedRowKeys()
} }
async function handleCancel() { async function handleCancel() {
@ -255,7 +251,6 @@
message: 'Tip', message: 'Tip',
description: t('取消成功!'), description: t('取消成功!'),
}); });
clearSelectedRowKeys()
} }
async function handleSubmit() { async function handleSubmit() {
if (!selectedRowsData.value.length) { if (!selectedRowsData.value.length) {
@ -271,7 +266,6 @@
message: 'Tip', message: 'Tip',
description: t('确认成功!'), description: t('确认成功!'),
}); });
clearSelectedRowKeys()
} }
async function handleSave() { async function handleSave() {
if (!selectedRowsData.value.length) { if (!selectedRowsData.value.length) {
@ -287,7 +281,6 @@
message: 'Tip', message: 'Tip',
description: t('保存成功!'), description: t('保存成功!'),
}); });
clearSelectedRowKeys()
} }
function dbClickRow(record) { function dbClickRow(record) {
@ -381,28 +374,13 @@
selectedRowsData.value = selectedRows; selectedRowsData.value = selectedRows;
} }
function customRow(record: Recordable) {
return {
onClick: () => {
let selectedRowKeys = [...selectedKeys.value];
if (selectedRowKeys.indexOf(record.id) >= 0) {
let index = selectedRowKeys.indexOf(record.id);
selectedRowKeys.splice(index, 1);
} else {
selectedRowKeys.push(record.id);
}
selectedKeys.value = selectedRowKeys;
},
};
}
function handleRefresh() { function handleRefresh() {
reload(); loadData();
} }
function handleSuccess() { function handleSuccess() {
selectedKeys.value = [];
selectedKeys.value = []; selectedRowsData.value = [];
selectedRowsData.value = []; loadData();
reload();
} }
async function handleExport() { async function handleExport() {
const res = await exportLngPngMeasureSalesPur({ isTemplate: false }); const res = await exportLngPngMeasureSalesPur({ isTemplate: false });
@ -420,7 +398,7 @@
}); });
} }
function handleImportSuccess(){ function handleImportSuccess(){
reload() loadData()
} }
onMounted(() => { onMounted(() => {
@ -430,9 +408,8 @@
} else { } else {
bus.on(FORM_LIST_MODIFIED, handleRefresh); bus.on(FORM_LIST_MODIFIED, handleRefresh);
} }
loadData()
// 合并渲染覆盖配置中的列表配置,包括展示字段配置、搜索字段配置、按钮配置
mergeCustomListRenderConfig();
}); });
onUnmounted(() => { onUnmounted(() => {
if (schemaIdComputedRef.value) { if (schemaIdComputedRef.value) {
@ -466,20 +443,8 @@
}); });
return actionsList; return actionsList;
} }
async function mergeCustomListRenderConfig(){
if (formConfig.useCustomConfig) {
let formId=currentRoute.value.meta.formId;
//1.合并展示字段配置
let cols= await mergeColumns(customConfigColums.value,formId);
customConfigColums.value=cols;
//2.合并搜索字段配置
let sFormSchema= await mergeSearchFormSchema(customSearchFormSchema.value,formId);
customSearchFormSchema.value=sFormSchema;
//3.合并按钮配置
let btns= await mergeButtons(buttons.value,formId);
buttons.value=btns;
}
};
</script> </script>
<style lang="less"> <style lang="less">
.PngMeasureSalesPurStyle .cusSearchForm .advanceRow> div:nth-of-type(3){ .PngMeasureSalesPurStyle .cusSearchForm .advanceRow> div:nth-of-type(3){

View File

@ -0,0 +1,540 @@
<template>
<div class="pd">
<div>
<template v-for="button in tableButtonConfig" :key="button.code" >
<a-button class="pr" v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
<a-button class="pr" v-else :type="button.type">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
</template>
</div>
<div :class="isExpend ? 'formStyle' : ''">
<searchForm @toggle="toggle" @search="onSearch" @reset="onReset"></searchForm>
</div>
</div>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex" class="PngMeasureSalesPurStyle">
<BasicTable @register="registerTable" ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }" @row-dbClick="dbClickRow">
<!-- <template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
<a-button v-else :type="button.type">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
</template>
</template> -->
<template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'qtyMeaGj'">
<a-input-number v-model:value="record.qtyMeaGj" v-if="statusCode==='N'|| statusCode==='JLZ'" @change="numChange(record)" :min="0" style="width: 100%" />
<div v-else>{{ record.qtyMeaGj }}</div>
</template>
<template v-if="column.dataIndex === 'qtyMeaM3'">
<a-input-number v-model:value="record.qtyMeaM3" v-if="statusCode==='N'|| statusCode==='JLZ'" @change="numChange(record)" :min="0" style="width: 100%" />
</template>
<template v-if="column.dataIndex === 'lngFileUploadList'">
<div>
<Upload :file-list="record.lngFileUploadList" :showUploadList="false" v-model:value="tableId" v-model:tableName="tableName" v-model:columnName="columnName"
:multiple="true" :dataDelete="true" :isShowTip="false" :isShowBtnIcon="false" @click="onUpload(index)" @change="uploadChange" :showDownloadIcon="false"/>
<div v-for="(item, idx) in record.lngFileUploadList">
<a @click="handleDownload(item)">{{item.fileOrg}}</a>
<span @click="deleteFile(record, idx)" class="delIcon"><DeleteOutlined /></span>
</div>
</div>
</template>
<template v-if="column.dataIndex === 'action'">
<TableAction :actions="getActions(record)" />
</template>
</template>
</BasicTable>
<PngMeasureSalesPurModal @register="registerModal" @success="handleSuccess" />
<ImportModal @register="registerImportModal" importUrl="/dayPlan/pngMeasureSalesPur/import" @success="handleImportSuccess"/>
<DataLog :logId="logId" :logPath="logPath" v-model:visible="modalVisible"/>
</PageWrapper>
</template>
<script lang="ts" setup>
const modalVisible = ref(false);
const logId = ref('')
const logPath = ref('/dayPlan/pngMeasureSalesPur/datalog');
import { DataLog } from '/@/components/pcitc';
import { ref, computed, onMounted, onUnmounted, createVNode, } from 'vue';
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngPngMeasureSalesPurPage, deleteLngPngMeasureSalesPur, exportLngPngMeasureSalesPur, addLngPngMeasureSalesPur, updateLngPngMeasureSalesPur,
cancelLngPngMeasureSalesPur, rejectLngPngMeasureSalesPur
} from '/@/api/dayPlan/PngMeasureSalesPur';
import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { useRouter } from 'vue-router';
import { setIndexFlowStatus } from '/@/utils/flow/index'
import { useModal } from '/@/components/Modal';
import PngMeasureSalesPurModal from './components/PngMeasureSalesPurModal.vue';
import { ImportModal } from '/@/components/Import';
import { downloadByData } from '/@/utils/file/download';
import {formConfig, searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
import Upload from '/@/components/Form/src/components/Upload.vue';
import { parseDownloadUrl} from '/@/api/system/file';
import { downloadByUrl } from '/@/utils/file/download';
import { DeleteOutlined } from '@ant-design/icons-vue';
import searchForm from './components/searchForm.vue'
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth } = usePermission();
const { mergeColumns,mergeSearchFormSchema,mergeButtons } = useFormConfig();
const filterColumns = cloneDeep(filterColumnAuth(columns));
const customConfigColums =ref(filterColumns);
const customSearchFormSchema =ref(searchFormSchema);
const tableRef = ref();
//所有按钮
const buttons = ref([{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"保存","code":"save","icon":"ant-design:save-outlined","isDefault":true},{"isUse":true,"name":"保存并确认","code":"submit","icon":"ant-design:check-outlined","isDefault":true},{"isUse":true,"name":"取消确认","code":"cancel","icon":"ant-design:rollback-outlined","isDefault":true},{"isUse":true,"name":"驳回","code":"reject","icon":"ant-design:stop-outlined","isDefault":true},{"isUse":true,"name":"导出","code":"export","icon":"ant-design:export-outlined","isDefault":true},{"isUse":true,"name":"导入","code":"import","icon":"ant-design:import-outlined","isDefault":true},{"isUse":true,"name":"删除","code":"batchdelete","icon":"ant-design:delete-outlined","isDefault":true},{"isUse":true,"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true}]);
//展示在列表内的按钮
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete', 'startwork','flowRecord']);
const buttonConfigs = computed(()=>{
return filterButtonAuth(buttons.value);
})
const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
});
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
const btnEvent = {add : handleAdd, refresh : handleRefresh,batchdelete : handleBatchdelete,import : handleImport,export : handleExport,
save: handleSave, submit: handleSubmit, cancel: handleCancel, reject: handleReject}
const { currentRoute } = useRouter();
const router = useRouter();
const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId
const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId
const selectedKeys = ref<string[]>([]);
const selectedRowsData = ref<any[]>([]);
const curIdx = ref()
const [registerModal, { openModal }] = useModal();
const [registerImportModal, { openModal: openImportModal }] = useModal();
const tableId = '';
const tableName = 'PngMeasureSalesPur';
const columnName = 'PngMeasureSalesPur';
const formName='管道气采购计量';
const [registerTable, { reload, clearSelectedRowKeys, getDataSource, updateTableDataRecord }] = useTable({
title: '' || (formName + '列表'),
api: getLngPngMeasureSalesPurPage,
rowKey: 'id',
immediate: false,
columns: customConfigColums,
formConfig: {
schemas: [],
showResetButton: false,
showSubmitButton: false
},
beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id',page: params.limit, ...formState.value};
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
striped: false,
rowSelection: {
type: 'checkbox',
onChange: onSelectChange
},
tableSetting: {
size: false,
setting: false,
},
customRow,
});
const isExpend = ref(false)
const formState = ref({})
const toggle = (val)=> {
isExpend.value = val
}
const onSearch = (val)=> {
formState.value = val
reload()
}
const onReset = (val)=> {
formState.value ={ page: 1,size: 10}
reload()
}
const onUpload = (index) => {
curIdx.value = index
}
const uploadChange = (val) => {
let data = getDataSource()
let record = data[curIdx.value]
record.lngFileUploadList = val
updateTableDataRecord(record.id, record)
}
const deleteFile = (record, idx) => {
record.lngFileUploadList.splice(idx, 1)
updateTableDataRecord(record.id, record)
}
const handleDownload = (info) => {
const url = parseDownloadUrl(info.response ? info.response.data.fileUrl : info.fileUrl);
const fileName = info.response ? info.response.data.fileOrg : info.fileOrg;
downloadByUrl({ url, fileName: fileName});
};
const numChange = (record) => {
record.rateM3Gj = Number(record.qtyMeaGj) ? (Number(record.qtyMeaM3) || 0 ) / Number(record.qtyMeaGj) : '0'
record.rateM3Gj = record.rateM3Gj.toFixed(6)
updateTableDataRecord(record.id, record)
}
function handleAdd() {
router.push({
path: '/dayPlan/PngMeasureSalesPur/createForm',
query: {
formPath: 'dayPlan/PngMeasureSalesPur',
formName: formName,
formId:currentRoute.value.meta.formId,
type:'add'
}
});
}
async function handleReject() {
if (!selectedRowsData.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要驳回的数据'),
});
return;
}
await rejectLngPngMeasureSalesPur(selectedRowsData.value)
handleSuccess();
notification.success({
message: 'Tip',
description: t('已驳回!'),
});
clearSelectedRowKeys()
}
async function handleCancel() {
if (!selectedRowsData.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要取消的数据'),
});
return;
}
await cancelLngPngMeasureSalesPur(selectedRowsData.value)
handleSuccess();
notification.success({
message: 'Tip',
description: t('取消成功!'),
});
clearSelectedRowKeys()
}
async function handleSubmit() {
if (!selectedRowsData.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要确认的数据'),
});
return;
}
await updateLngPngMeasureSalesPur(selectedRowsData.value)
handleSuccess();
notification.success({
message: 'Tip',
description: t('确认成功!'),
});
clearSelectedRowKeys()
}
async function handleSave() {
if (!selectedRowsData.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要保存的数据'),
});
return;
}
await addLngPngMeasureSalesPur(selectedRowsData.value)
handleSuccess();
notification.success({
message: 'Tip',
description: t('保存成功!'),
});
clearSelectedRowKeys()
}
function dbClickRow(record) {
if (!actionButtonConfig?.value.some(element => element.code == 'view')) {
return;
}
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else if (schemaId && !taskIds && processId) {
router.push({
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
query: {
readonly: 1,
taskId: '',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else {
router.push({
path: '/form/PngMeasureSalesPur/' + record.id + '/viewForm',
query: {
formPath: 'dayPlan/PngMeasureSalesPur',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleDatalog (record: Recordable) {
modalVisible.value = true
logId.value = record.id
}
function handleBatchdelete() {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要删除的数据'),
});
return;
}
//与工作流相关的数据不能进行批量删除
const cantDelete = selectedRowsData.value.filter((x) => {
return (
(x.workflowData?.enabled && x.workflowData?.status) ||
(!x.workflowData?.enabled && !!x.workflowData?.processId)
);
});
if (cantDelete.length) {
notification.warning({
message: 'Tip',
description: t('含有不能删除的数据'),
});
return;
}
deleteList(selectedKeys.value);
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteLngPngMeasureSalesPur(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
});
}
function onSelectChange(selectedRowKeys: [], selectedRows) {
selectedKeys.value = selectedRowKeys;
selectedRowsData.value = selectedRows;
}
function customRow(record: Recordable) {
return {
onClick: () => {
let selectedRowKeys = [...selectedKeys.value];
if (selectedRowKeys.indexOf(record.id) >= 0) {
let index = selectedRowKeys.indexOf(record.id);
selectedRowKeys.splice(index, 1);
} else {
selectedRowKeys.push(record.id);
}
selectedKeys.value = selectedRowKeys;
},
};
}
function handleRefresh() {
reload();
}
function handleSuccess() {
selectedKeys.value = [];
selectedRowsData.value = [];
reload();
}
async function handleExport() {
const res = await exportLngPngMeasureSalesPur({ isTemplate: false });
downloadByData(
res.data,
'PngMeasureSalesPur.xlsx',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
);
}
function handleImport() {
openImportModal(true, {
title: '快速导入',
downLoadUrl:'/dayPlan/pngMeasureSalesPur/export',
});
}
function handleImportSuccess(){
reload()
}
onMounted(() => {
if (schemaIdComputedRef.value) {
bus.on(FLOW_PROCESSED, handleRefresh);
bus.on(CREATE_FLOW, handleRefresh);
} else {
bus.on(FORM_LIST_MODIFIED, handleRefresh);
}
// 合并渲染覆盖配置中的列表配置,包括展示字段配置、搜索字段配置、按钮配置
mergeCustomListRenderConfig();
});
onUnmounted(() => {
if (schemaIdComputedRef.value) {
bus.off(FLOW_PROCESSED, handleRefresh);
bus.off(CREATE_FLOW, handleRefresh);
} else {
bus.off(FORM_LIST_MODIFIED, handleRefresh);
}
});
function getActions(record: Recordable):ActionItem[] {
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
if (!record.workflowData?.processId) {
return {
icon: button?.icon,
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record),
};
} else {
if (button.code === 'view') {
return {
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
};
} else {
return {};
}
}
});
return actionsList;
}
async function mergeCustomListRenderConfig(){
if (formConfig.useCustomConfig) {
let formId=currentRoute.value.meta.formId;
//1.合并展示字段配置
let cols= await mergeColumns(customConfigColums.value,formId);
customConfigColums.value=cols;
//2.合并搜索字段配置
let sFormSchema= await mergeSearchFormSchema(customSearchFormSchema.value,formId);
customSearchFormSchema.value=sFormSchema;
//3.合并按钮配置
let btns= await mergeButtons(buttons.value,formId);
buttons.value=btns;
}
};
</script>
<style lang="less">
.PngMeasureSalesPurStyle .cusSearchForm .advanceRow> div:nth-of-type(3){
display: none;
}
.PngMeasureSalesPurStyle .cusSearchForm .advanceRow> div:nth-of-type(2){
display: none;
}
.PngMeasureSalesPurStyle .w-full .advanceRow> div:nth-of-type(4){
display: none;
}
</style>
<style lang="less" scoped>
:deep(.ant-table-selection-col) {
width: 50px;
}
.show{
display: flex;
}
.hide{
display: none !important;
}
.delIcon {
margin-left: 10px;
cursor: pointer;
margin-bottom: 5px;
}
.pd {
padding: 6px 4px 0px 8px;
position: relative;
}
.pr {
margin-right: 4px;
margin-bottom: 8px;
}
.pr:nth-child(1) {
margin-left: 4px;
}
.formStyle {
position: absolute;
max-height: 400px;
z-index: 6;
background: #fff;
border: 1px solid rgba(204, 204, 204, 0.47);
box-shadow: 1px 2px 10px #ccc;
top: 0;
left: 0;
right: 0;
padding: 12px 0 8px 15px;
align-items: self-start !important;
justify-content: space-between;
margin: 2px 4px 12px 8px;
}
:deep(.ant-table-title) {
display: none !important;
}
</style>