|
|
@@ -2,55 +2,66 @@
|
|
|
<div class="p-2">
|
|
|
<!--查询区域-->
|
|
|
<div class="jeecg-basic-table-form-container">
|
|
|
- <a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
|
|
+ <a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="{ style: 'width: 160px' }" :wrapper-col="wrapperCol">
|
|
|
<a-row :gutter="24">
|
|
|
- <a-col :lg="6">
|
|
|
- <a-form-item name="status">
|
|
|
- <template #label><span title="状态">状态</span></template>
|
|
|
- <j-select-multiple placeholder="请选择状态" v-model:value="queryParam.status" dictCode="yes_or_no" allow-clear />
|
|
|
+
|
|
|
+ <a-col :lg="8">
|
|
|
+ <a-form-item name="annual">
|
|
|
+ <template #label><span title="年度">年度(Annual)</span></template>
|
|
|
+ <a-date-picker
|
|
|
+ v-model:value="queryParam.annual"
|
|
|
+ picker="year"
|
|
|
+ value-format="YYYY"
|
|
|
+ format="YYYY"
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder="请选择年度"
|
|
|
+ allow-clear
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
- <a-col :lg="6">
|
|
|
+ <a-col :lg="8">
|
|
|
+ <a-form-item name="supplierId">
|
|
|
+ <template #label><span title="供应商">供应商(Supplier)</span></template>
|
|
|
+ <a-select
|
|
|
+ v-model:value="queryParam.supplierId"
|
|
|
+ :options="supplierOptions"
|
|
|
+ show-search
|
|
|
+ optionFilterProp="label"
|
|
|
+ placeholder="请选择供应商"
|
|
|
+ allow-clear
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :lg="8">
|
|
|
+ <a-form-item name="title">
|
|
|
+ <template #label><span title="标题">标题(Title)</span></template>
|
|
|
+ <a-input placeholder="请输入标题" v-model:value="queryParam.title" allow-clear ></a-input>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :lg="8">
|
|
|
<a-form-item name="materialCode">
|
|
|
- <template #label><span title="物料编码">物料编码</span></template>
|
|
|
+ <template #label><span title="物料编码">物料编码(Material Code)</span></template>
|
|
|
<a-input placeholder="请输入物料编码" v-model:value="queryParam.materialCode" allow-clear ></a-input>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
- <template v-if="toggleSearchStatus">
|
|
|
- <a-col :lg="6">
|
|
|
+
|
|
|
+ <a-col :lg="8">
|
|
|
<a-form-item name="materialName">
|
|
|
- <template #label><span title="物料名称">物料名称</span></template>
|
|
|
+ <template #label><span title="物料名称">物料名称(Material Name)</span></template>
|
|
|
<a-input placeholder="请输入物料名称" v-model:value="queryParam.materialName" allow-clear ></a-input>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
- <a-col :lg="6">
|
|
|
+ <a-col :lg="8">
|
|
|
<a-form-item name="sparePartNumber">
|
|
|
- <template #label><span title="备件号">备件号</span></template>
|
|
|
+ <template #label><span title="备件号">备件号(SparePartNumber)</span></template>
|
|
|
<a-input placeholder="请输入备件号" v-model:value="queryParam.sparePartNumber" allow-clear ></a-input>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
- <a-col :lg="6">
|
|
|
- <a-form-item name="annual">
|
|
|
- <template #label><span title="年度">年度</span></template>
|
|
|
- <a-input placeholder="请输入年度" v-model:value="queryParam.annual" allow-clear ></a-input>
|
|
|
- </a-form-item>
|
|
|
- </a-col>
|
|
|
- <a-col :lg="6">
|
|
|
- <a-form-item name="supplierName">
|
|
|
- <template #label><span title="供应商名称">供应商名</span></template>
|
|
|
- <a-input placeholder="请输入供应商名称" v-model:value="queryParam.supplierName" allow-clear ></a-input>
|
|
|
- </a-form-item>
|
|
|
- </a-col>
|
|
|
- <a-col :lg="6">
|
|
|
- <a-form-item name="title">
|
|
|
- <template #label><span title="标题">标题</span></template>
|
|
|
- <a-input placeholder="请输入标题" v-model:value="queryParam.title" allow-clear ></a-input>
|
|
|
- </a-form-item>
|
|
|
- </a-col>
|
|
|
+ <template v-if="toggleSearchStatus">
|
|
|
</template>
|
|
|
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
|
|
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
|
|
- <a-col :lg="6">
|
|
|
+ <a-col :lg="8">
|
|
|
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
|
|
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
|
|
|
<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
|
|
|
@@ -69,7 +80,7 @@
|
|
|
<template #tableTitle>
|
|
|
<a-button type="primary" v-auth="'otherCode:pur_suggested_price:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
|
|
<a-button type="primary" v-auth="'otherCode:pur_suggested_price:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
|
|
- <j-upload-button type="primary" v-auth="'otherCode:pur_suggested_price:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
|
|
+ <a-button type="primary" v-auth="'otherCode:pur_suggested_price:importExcel'" preIcon="ant-design:import-outlined" @click="openImportModal">导入</a-button>
|
|
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
|
|
<template #overlay>
|
|
|
<a-menu>
|
|
|
@@ -95,11 +106,59 @@
|
|
|
</BasicTable>
|
|
|
<!-- 表单区域 -->
|
|
|
<PurSuggestedPriceModal ref="registerModal" @success="handleSuccess"></PurSuggestedPriceModal>
|
|
|
+ <a-modal
|
|
|
+ title="导入供应商指导价"
|
|
|
+ :visible="importVisible"
|
|
|
+ :confirm-loading="importSubmitting"
|
|
|
+ @ok="submitImport"
|
|
|
+ @cancel="closeImportModal"
|
|
|
+ destroyOnClose
|
|
|
+ >
|
|
|
+ <a-form-item label="年度" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }" required>
|
|
|
+ <a-date-picker
|
|
|
+ v-model:value="importForm.annual"
|
|
|
+ picker="year"
|
|
|
+ value-format="YYYY"
|
|
|
+ format="YYYY"
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder="请选择年度"
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form :model="importForm" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
|
|
|
+ <a-form-item label="供应商" required>
|
|
|
+ <a-select
|
|
|
+ v-model:value="importForm.supplierId"
|
|
|
+ :options="supplierOptions"
|
|
|
+ show-search
|
|
|
+ optionFilterProp="label"
|
|
|
+ placeholder="请选择供应商"
|
|
|
+ allow-clear
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="单位" required :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
|
|
|
+ <JDictSelectTag v-model:value="importForm.unit" dictCode="currency" placeholder="请选择单位" />
|
|
|
+ </a-form-item>
|
|
|
+
|
|
|
+ <a-form-item label="是否覆盖" required>
|
|
|
+ <a-switch
|
|
|
+ :checked="importForm.overwrite === 1"
|
|
|
+ checked-children="是"
|
|
|
+ un-checked-children="否"
|
|
|
+ @change="(checked) => (importForm.overwrite = checked ? 1 : 0)"
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="导入文件" required>
|
|
|
+ <a-upload :beforeUpload="beforeImportFile" :fileList="importFileList" :maxCount="1" @remove="removeImportFile">
|
|
|
+ <a-button preIcon="ant-design:upload-outlined">选择文件</a-button>
|
|
|
+ </a-upload>
|
|
|
+ </a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </a-modal>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" name="otherCode-purSuggestedPrice" setup>
|
|
|
- import { ref, reactive } from 'vue';
|
|
|
+ import { ref, reactive, onMounted } from 'vue';
|
|
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
|
|
import { useListPage } from '/@/hooks/system/useListPage';
|
|
|
import { columns, superQuerySchema } from './PurSuggestedPrice.data';
|
|
|
@@ -109,6 +168,9 @@
|
|
|
import { useUserStore } from '/@/store/modules/user';
|
|
|
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
|
|
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import { defHttp } from '/@/utils/http/axios';
|
|
|
+ import { useGlobSetting } from '/@/hooks/setting';
|
|
|
|
|
|
const formRef = ref();
|
|
|
const queryParam = reactive<any>({});
|
|
|
@@ -116,7 +178,9 @@
|
|
|
const registerModal = ref();
|
|
|
const userStore = useUserStore();
|
|
|
//注册table数据
|
|
|
- const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
|
|
+ const { createMessage, createWarningModal } = useMessage();
|
|
|
+ const glob = useGlobSetting();
|
|
|
+ const { prefixCls, tableContext, onExportXls } = useListPage({
|
|
|
tableProps: {
|
|
|
title: '供应商指导价',
|
|
|
api: list,
|
|
|
@@ -124,17 +188,32 @@
|
|
|
canResize:false,
|
|
|
useSearchForm: false,
|
|
|
actionColumn: {
|
|
|
- width: 120,
|
|
|
+ width: 130,
|
|
|
fixed: 'right',
|
|
|
},
|
|
|
beforeFetch: async (params) => {
|
|
|
- return Object.assign(params, queryParam);
|
|
|
+ // 覆盖 useListPage 默认 createTime 倒序
|
|
|
+ delete params.column;
|
|
|
+ delete params.order;
|
|
|
+ const query = { ...queryParam };
|
|
|
+ if (query.supplierId) {
|
|
|
+ query.supplier = query.supplierId;
|
|
|
+ delete query.supplierId;
|
|
|
+ }
|
|
|
+ return Object.assign(params, query);
|
|
|
},
|
|
|
},
|
|
|
exportConfig: {
|
|
|
name: "供应商指导价",
|
|
|
url: getExportUrl,
|
|
|
- params: queryParam,
|
|
|
+ params: () => {
|
|
|
+ const query = { ...queryParam };
|
|
|
+ if (query.supplierId) {
|
|
|
+ query.supplier = query.supplierId;
|
|
|
+ delete query.supplierId;
|
|
|
+ }
|
|
|
+ return query;
|
|
|
+ },
|
|
|
},
|
|
|
importConfig: {
|
|
|
url: getImportUrl,
|
|
|
@@ -152,10 +231,25 @@
|
|
|
xs: 24,
|
|
|
sm: 20,
|
|
|
});
|
|
|
+ const importVisible = ref(false);
|
|
|
+ const importSubmitting = ref(false);
|
|
|
+ const importFileList = ref<any[]>([]);
|
|
|
+ const supplierOptions = ref<any[]>([]);
|
|
|
+ const importForm = reactive<any>({
|
|
|
+ supplierId: '',
|
|
|
+ unit: '',
|
|
|
+ annual: '',
|
|
|
+ overwrite: 0,
|
|
|
+ });
|
|
|
|
|
|
// 高级查询配置
|
|
|
const superQueryConfig = reactive(superQuerySchema);
|
|
|
|
|
|
+ // 加载供应商选项
|
|
|
+ onMounted(() => {
|
|
|
+ loadSupplierOptions();
|
|
|
+ });
|
|
|
+
|
|
|
/**
|
|
|
* 高级查询事件
|
|
|
*/
|
|
|
@@ -260,7 +354,101 @@
|
|
|
//刷新数据
|
|
|
reload();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ function openImportModal() {
|
|
|
+ importVisible.value = true;
|
|
|
+ loadSupplierOptions();
|
|
|
+ }
|
|
|
+
|
|
|
+ function closeImportModal() {
|
|
|
+ importVisible.value = false;
|
|
|
+ importSubmitting.value = false;
|
|
|
+ importFileList.value = [];
|
|
|
+ importForm.supplierId = '';
|
|
|
+ importForm.unit = '';
|
|
|
+ importForm.annual = '';
|
|
|
+ importForm.overwrite = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ function beforeImportFile(file) {
|
|
|
+ importFileList.value = [file];
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ function removeImportFile() {
|
|
|
+ importFileList.value = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ async function loadSupplierOptions() {
|
|
|
+ if (supplierOptions.value.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const res: any = await defHttp.get(
|
|
|
+ { url: '/cuspCode/cuspSupplierProfile/list', params: { pageSize: -1, status: 1 } },
|
|
|
+ { isTransformResponse: false }
|
|
|
+ );
|
|
|
+ const records = res?.result?.records || [];
|
|
|
+ supplierOptions.value = records.map((item) => ({
|
|
|
+ label: item.name || item.supplierName,
|
|
|
+ value: item.id,
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ async function submitImport() {
|
|
|
+ if (!importForm.supplierId) {
|
|
|
+ createMessage.warning('请选择供应商');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!importForm.unit) {
|
|
|
+ createMessage.warning('请选择单位');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!importForm.annual) {
|
|
|
+ createMessage.warning('请填写年度');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!importFileList.value.length) {
|
|
|
+ createMessage.warning('请选择导入文件');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ importSubmitting.value = true;
|
|
|
+ try {
|
|
|
+ const file = importFileList.value[0];
|
|
|
+ const fileInfo: any = await defHttp.uploadFile(
|
|
|
+ { url: getImportUrl },
|
|
|
+ {
|
|
|
+ file,
|
|
|
+ data: {
|
|
|
+ supplier: importForm.supplierId,
|
|
|
+ unit: importForm.unit,
|
|
|
+ annual: importForm.annual,
|
|
|
+ overwrite: importForm.overwrite,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { isReturnResponse: true }
|
|
|
+ );
|
|
|
+ if (fileInfo?.code === 201) {
|
|
|
+ const {
|
|
|
+ message,
|
|
|
+ result: { msg, fileUrl, fileName },
|
|
|
+ } = fileInfo;
|
|
|
+ const href = glob.uploadUrl + fileUrl;
|
|
|
+ createWarningModal({
|
|
|
+ title: message,
|
|
|
+ centered: false,
|
|
|
+ content: `<div><span>${msg}</span><br/><span>具体详情请<a href=${href} download=${fileName}> 点击下载 </a></span></div>`,
|
|
|
+ });
|
|
|
+ } else if (fileInfo?.code === 500 || fileInfo?.code === 510) {
|
|
|
+ createMessage.error(fileInfo?.message || `${file.name} 导入失败`);
|
|
|
+ } else {
|
|
|
+ createMessage.success(fileInfo?.message || `${file.name} 文件上传成功`);
|
|
|
+ }
|
|
|
+ handleSuccess();
|
|
|
+ closeImportModal();
|
|
|
+ } finally {
|
|
|
+ importSubmitting.value = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|