2 changed files with 845 additions and 0 deletions
-
25src/api/partspare/partSparePurchaseImport.js
-
820src/views/modules/partspare/partSparePurchaseImport.vue
@ -0,0 +1,25 @@ |
|||
import { createAPI } from "@/utils/httpRequest.js"; |
|||
|
|||
// 备件采购订单导入记录查询
|
|||
export const queryPartSparePurchaseImportPage = data => |
|||
createAPI(`/pms/partspare/purchaseImport/queryPage`, "post", data); |
|||
|
|||
// 备件采购订单导入记录新增
|
|||
export const savePartSparePurchaseImport = data => |
|||
createAPI(`/pms/partspare/purchaseImport/save`, "post", data); |
|||
|
|||
// 备件采购订单导入记录修改
|
|||
export const updatePartSparePurchaseImport = data => |
|||
createAPI(`/pms/partspare/purchaseImport/update`, "post", data); |
|||
|
|||
// 备件采购订单导入记录删除
|
|||
export const deletePartSparePurchaseImport = data => |
|||
createAPI(`/pms/partspare/purchaseImport/delete`, "post", data); |
|||
|
|||
// Excel导入
|
|||
export const importPartSparePurchaseImportExcel = data => |
|||
createAPI(`/pms/partspare/purchaseImport/importExcel`, "post", data); |
|||
|
|||
// 下载导入模板
|
|||
export const downloadPartSparePurchaseImportTemplate = () => |
|||
createAPI(`/pms/partspare/purchaseImport/downloadTemplate`, "get", {}, "download"); |
|||
@ -0,0 +1,820 @@ |
|||
<template> |
|||
<div class="mod-config"> |
|||
<el-form :inline="true" label-position="top" :model="queryForm"> |
|||
<el-form-item label="BU"> |
|||
<el-select v-model="queryForm.buKey" clearable style="width: 160px" placeholder="请选择"> |
|||
<el-option |
|||
v-for="item in userBuList" |
|||
:key="item.site + '_' + item.buNo" |
|||
:label="item.buDesc" |
|||
:value="composeBuKey(item.site, item.buNo)" |
|||
></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="日期"> |
|||
<el-date-picker |
|||
style="width: 140px" |
|||
v-model="queryForm.orderDateStart" |
|||
type="date" |
|||
format="yyyy-MM-dd" |
|||
value-format="yyyy-MM-dd" |
|||
placeholder="开始日期" |
|||
></el-date-picker> |
|||
<span class="date-separator">-</span> |
|||
<el-date-picker |
|||
style="width: 170px" |
|||
v-model="queryForm.orderDateEnd" |
|||
type="date" |
|||
format="yyyy-MM-dd" |
|||
value-format="yyyy-MM-dd 23:59:59" |
|||
placeholder="结束日期" |
|||
></el-date-picker> |
|||
</el-form-item> |
|||
<el-form-item label="供应商"> |
|||
<el-input v-model="queryForm.supplierName" clearable style="width: 140px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="币种"> |
|||
<el-input v-model="queryForm.currencyType" clearable style="width: 100px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="订单编号"> |
|||
<el-input v-model="queryForm.orderNo" clearable style="width: 140px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="存货编码"> |
|||
<el-input v-model="queryForm.itemCode" clearable style="width: 130px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="存货名称"> |
|||
<el-input v-model="queryForm.itemName" clearable style="width: 150px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="项目目录(BU)"> |
|||
<el-input v-model="queryForm.projectBu" clearable style="width: 130px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="上游单据号"> |
|||
<el-input v-model="queryForm.requestNo" clearable style="width: 130px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="请购员"> |
|||
<el-input v-model="queryForm.requestBy" clearable style="width: 120px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="导入人"> |
|||
<el-input v-model="queryForm.importBy" clearable style="width: 120px"></el-input> |
|||
</el-form-item> |
|||
<!-- <el-form-item label="导入文件名"> |
|||
<el-input v-model="queryForm.sourceFileName" clearable style="width: 140px"></el-input> |
|||
</el-form-item>--> |
|||
</el-form> |
|||
|
|||
<el-form :inline="true" label-position="top" :model="queryForm"> |
|||
<el-form-item label="导入日期"> |
|||
<el-date-picker |
|||
style="width: 140px" |
|||
v-model="queryForm.importDateStart" |
|||
type="date" |
|||
format="yyyy-MM-dd" |
|||
value-format="yyyy-MM-dd" |
|||
placeholder="开始日期" |
|||
></el-date-picker> |
|||
<span class="date-separator">-</span> |
|||
<el-date-picker |
|||
style="width: 170px" |
|||
v-model="queryForm.importDateEnd" |
|||
type="date" |
|||
format="yyyy-MM-dd" |
|||
value-format="yyyy-MM-dd 23:59:59" |
|||
placeholder="结束日期" |
|||
></el-date-picker> |
|||
</el-form-item> |
|||
<el-form-item label="数量范围"> |
|||
<el-input v-model="queryForm.qtyStart" clearable style="width: 90px"></el-input> |
|||
<span class="date-separator">-</span> |
|||
<el-input v-model="queryForm.qtyEnd" clearable style="width: 90px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="本币价税合计范围"> |
|||
<el-input v-model="queryForm.localTotalAmountStart" clearable style="width: 100px"></el-input> |
|||
<span class="date-separator">-</span> |
|||
<el-input v-model="queryForm.localTotalAmountEnd" clearable style="width: 100px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label=" "> |
|||
<el-button type="primary" @click="handleQuery">查询</el-button> |
|||
<el-button type="default" @click="resetQuery">重置</el-button> |
|||
<!-- <el-button type="primary" @click="openAddDialog">新增</el-button>--> |
|||
<el-button type="primary" @click="openImportDialog">导入</el-button> |
|||
<!-- <el-button type="warning" @click="downloadTemplateFile">下载模板</el-button>--> |
|||
<el-button type="danger" :disabled="selectionData.length === 0" @click="deleteSelection">删除</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<el-table |
|||
:data="dataList" |
|||
border |
|||
show-summary |
|||
:summary-method="getSummaryRow" |
|||
:max-height="height" |
|||
v-loading="dataListLoading" |
|||
@selection-change="handleSelectionChange" |
|||
style="width: 100%" |
|||
> |
|||
<el-table-column type="selection" width="50" align="center"></el-table-column> |
|||
<el-table-column prop="orderDate" label="日期" width="110" align="center"></el-table-column> |
|||
<el-table-column prop="supplierName" label="供应商" min-width="180" show-overflow-tooltip></el-table-column> |
|||
<el-table-column prop="currencyType" label="币种" width="80" align="center"></el-table-column> |
|||
<el-table-column prop="orderNo" label="订单编号" min-width="150" show-overflow-tooltip></el-table-column> |
|||
<el-table-column prop="itemCode" label="存货编码" min-width="120" show-overflow-tooltip></el-table-column> |
|||
<el-table-column prop="itemName" label="存货名称" min-width="120" show-overflow-tooltip></el-table-column> |
|||
<el-table-column prop="qty" label="数量" width="80" align="right"> |
|||
<template slot-scope="scope"> |
|||
{{ formatNumber(scope.row.qty) }} |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="localUnitPrice" label="本币单价" width="80" align="right"> |
|||
<template slot-scope="scope"> |
|||
{{ formatNumber(scope.row.localUnitPrice) }} |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="localAmount" label="本币金额" width="80" align="right"> |
|||
<template slot-scope="scope"> |
|||
{{ formatNumber(scope.row.localAmount) }} |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="localTaxAmount" label="本币税额" width="80" align="right"> |
|||
<template slot-scope="scope"> |
|||
{{ formatNumber(scope.row.localTaxAmount) }} |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="localTotalAmount" label="本币价税合计" width="100" align="right"> |
|||
<template slot-scope="scope"> |
|||
{{ formatNumber(scope.row.localTotalAmount) }} |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="unitName" label="单位" width="60" align="center"></el-table-column> |
|||
<el-table-column prop="projectBu" label="项目目录(BU)" min-width="200" show-overflow-tooltip></el-table-column> |
|||
<el-table-column prop="requestNo" label="上游单据号" min-width="130" show-overflow-tooltip></el-table-column> |
|||
<el-table-column prop="requestBy" label="请购员" width="90" align="center"></el-table-column> |
|||
<el-table-column prop="importDate" label="导入日期" width="160" align="center"></el-table-column> |
|||
<el-table-column prop="importBy" label="导入人" width="100" align="center"></el-table-column> |
|||
<!-- <el-table-column prop="sourceFileName" label="导入文件名" min-width="160" show-overflow-tooltip></el-table-column> |
|||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip></el-table-column>--> |
|||
<el-table-column fixed="right" label="操作" width="140" align="center"> |
|||
<template slot-scope="scope"> |
|||
<el-link type="primary" @click="openEditDialog(scope.row)">修改</el-link> |
|||
<el-link type="danger" style="margin-left: 8px" @click="deleteByRow(scope.row)">删除</el-link> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<el-pagination |
|||
style="margin-top: 8px" |
|||
@size-change="sizeChangeHandle" |
|||
@current-change="currentChangeHandle" |
|||
:current-page="pageIndex" |
|||
:page-sizes="[20, 50, 100, 500]" |
|||
:page-size="pageSize" |
|||
:total="totalPage" |
|||
layout="total, sizes, prev, pager, next, jumper" |
|||
></el-pagination> |
|||
|
|||
<el-dialog |
|||
:title="formMode === 'add' ? '新增采购订单记录' : '修改采购订单记录'" |
|||
:close-on-click-modal="false" |
|||
v-drag |
|||
:visible.sync="formDialogVisible" |
|||
width="980px" |
|||
> |
|||
<el-form |
|||
ref="saveForm" |
|||
:model="formData" |
|||
:rules="formRules" |
|||
:inline="true" |
|||
label-position="top" |
|||
> |
|||
<el-form-item label="BU" prop="buKey"> |
|||
<el-select v-model="formData.buKey" clearable style="width: 220px" placeholder="请选择"> |
|||
<el-option |
|||
v-for="item in userBuList" |
|||
:key="item.site + '_' + item.buNo + '_form'" |
|||
:label="item.buDesc" |
|||
:value="composeBuKey(item.site, item.buNo)" |
|||
></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="日期" prop="orderDate"> |
|||
<el-date-picker |
|||
style="width: 160px" |
|||
v-model="formData.orderDate" |
|||
type="date" |
|||
format="yyyy-MM-dd" |
|||
value-format="yyyy-MM-dd" |
|||
placeholder="请选择" |
|||
></el-date-picker> |
|||
</el-form-item> |
|||
<el-form-item label="供应商" prop="supplierName"> |
|||
<el-input v-model="formData.supplierName" style="width: 220px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="币种" prop="currencyType"> |
|||
<el-input v-model="formData.currencyType" style="width: 120px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="订单编号" prop="orderNo"> |
|||
<el-input v-model="formData.orderNo" style="width: 180px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="存货编码" prop="itemCode"> |
|||
<el-input v-model="formData.itemCode" style="width: 160px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="存货名称" prop="itemName"> |
|||
<el-input v-model="formData.itemName" style="width: 220px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="数量"> |
|||
<el-input-number :controls="false" :step="0" :min="0" v-model="formData.qty" style="width: 140px"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="本币单价"> |
|||
<el-input-number :controls="false" :step="0" :min="0" v-model="formData.localUnitPrice" style="width: 140px"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="本币金额"> |
|||
<el-input-number :controls="false" :step="0" :min="0" v-model="formData.localAmount" style="width: 140px"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="本币税额"> |
|||
<el-input-number :controls="false" :step="0" :min="0" v-model="formData.localTaxAmount" style="width: 140px"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="本币价税合计"> |
|||
<el-input-number :controls="false" :step="0" :min="0" v-model="formData.localTotalAmount" style="width: 160px"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="单位"> |
|||
<el-input v-model="formData.unitName" style="width: 120px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="项目目录(BU)"> |
|||
<el-input v-model="formData.projectBu" style="width: 160px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="上游单据号"> |
|||
<el-input v-model="formData.requestNo" style="width: 160px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="请购员"> |
|||
<el-input v-model="formData.requestBy" style="width: 120px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="备注"> |
|||
<el-input v-model="formData.remark" style="width: 220px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="导入日期" v-if="formMode === 'edit'"> |
|||
<el-input :value="formData.importDate" disabled style="width: 180px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="导入人" v-if="formMode === 'edit'"> |
|||
<el-input :value="formData.importBy" disabled style="width: 120px"></el-input> |
|||
</el-form-item> |
|||
</el-form> |
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" :loading="formLoading" @click="saveFormData">保存</el-button> |
|||
<el-button @click="formDialogVisible = false">取消</el-button> |
|||
</span> |
|||
</el-dialog> |
|||
|
|||
<el-dialog |
|||
title="导入采购订单记录" |
|||
:close-on-click-modal="false" |
|||
v-drag |
|||
class="customer-dialog purchase-import-dialog" |
|||
:visible.sync="importDialogVisible" |
|||
width="430px" |
|||
style="height: 560px;" |
|||
append-to-body |
|||
@close="closeImportDialog" |
|||
> |
|||
<el-form :inline="true" label-position="top" label-width="80px" :model="importData"> |
|||
<el-form-item label="BU" required> |
|||
<el-select v-model="importData.buKey" clearable style="width: 295px" placeholder="请选择"> |
|||
<el-option |
|||
v-for="item in userBuList" |
|||
:key="item.site + '_' + item.buNo + '_import'" |
|||
:label="item.buDesc" |
|||
:value="composeBuKey(item.site, item.buNo)" |
|||
></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-row> |
|||
<el-col :span="24"> |
|||
<div class="upload-label">Excel文件</div> |
|||
<el-upload |
|||
class="customer-upload" |
|||
drag |
|||
action="javascript:void(0);" |
|||
ref="uploadFile" |
|||
:limit="1" |
|||
accept=".xlsx,.xls" |
|||
:before-upload="beforeUploadHandle" |
|||
:on-change="onImportFileChange" |
|||
:auto-upload="false" |
|||
style="text-align: left;" |
|||
> |
|||
<i class="el-icon-upload"></i> |
|||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
|||
<div class="el-upload__tip" slot="tip">只能上传xlsx/xls文件,首行为表头</div> |
|||
</el-upload> |
|||
</el-col> |
|||
</el-row> |
|||
</el-form> |
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" :loading="importLoading" :disabled="importLoading" @click="submitImport">保存</el-button> |
|||
<el-button type="primary" @click="importDialogVisible = false">关闭</el-button> |
|||
</span> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { getAllBuList } from "@/api/factory/site.js"; |
|||
import { |
|||
queryPartSparePurchaseImportPage, |
|||
savePartSparePurchaseImport, |
|||
updatePartSparePurchaseImport, |
|||
deletePartSparePurchaseImport, |
|||
importPartSparePurchaseImportExcel, |
|||
downloadPartSparePurchaseImportTemplate |
|||
} from "@/api/partspare/partSparePurchaseImport.js"; |
|||
|
|||
export default { |
|||
name: "partSparePurchaseImport", |
|||
data() { |
|||
return { |
|||
height: 200, |
|||
userBuList: [], |
|||
defaultBuNo: "03-RFID", |
|||
defaultBuKey: "", |
|||
queryForm: this.getDefaultQueryForm(), |
|||
dataList: [], |
|||
dataListLoading: false, |
|||
summaryData: { |
|||
totalQty: 0, |
|||
totalLocalTotalAmount: 0 |
|||
}, |
|||
selectionData: [], |
|||
pageIndex: 1, |
|||
pageSize: 50, |
|||
totalPage: 0, |
|||
formDialogVisible: false, |
|||
formLoading: false, |
|||
formMode: "add", |
|||
formData: this.getDefaultFormData(), |
|||
formRules: { |
|||
buKey: [{ required: true, message: "请选择BU", trigger: "change" }], |
|||
orderNo: [{ required: true, message: "请输入订单编号", trigger: "blur" }], |
|||
itemCode: [{ required: true, message: "请输入存货编码", trigger: "blur" }] |
|||
}, |
|||
importDialogVisible: false, |
|||
importLoading: false, |
|||
importData: { |
|||
buKey: "" |
|||
}, |
|||
importFileList: [] |
|||
}; |
|||
}, |
|||
created() { |
|||
this.$nextTick(() => { |
|||
this.height = window.innerHeight - 260; |
|||
}); |
|||
this.getBuList(); |
|||
}, |
|||
methods: { |
|||
getDefaultQueryForm() { |
|||
return { |
|||
buKey: "", |
|||
supplierName: "", |
|||
currencyType: "", |
|||
orderNo: "", |
|||
itemCode: "", |
|||
itemName: "", |
|||
projectBu: "", |
|||
requestNo: "", |
|||
requestBy: "", |
|||
importBy: "", |
|||
sourceFileName: "", |
|||
orderDateStart: null, |
|||
orderDateEnd: null, |
|||
importDateStart: null, |
|||
importDateEnd: null, |
|||
qtyStart: null, |
|||
qtyEnd: null, |
|||
localTotalAmountStart: null, |
|||
localTotalAmountEnd: null |
|||
}; |
|||
}, |
|||
getDefaultFormData() { |
|||
return { |
|||
id: null, |
|||
buKey: "", |
|||
orderDate: null, |
|||
supplierName: "", |
|||
currencyType: "", |
|||
orderNo: "", |
|||
itemCode: "", |
|||
itemName: "", |
|||
qty: null, |
|||
localUnitPrice: null, |
|||
localAmount: null, |
|||
localTaxAmount: null, |
|||
localTotalAmount: null, |
|||
unitName: "", |
|||
projectBu: "", |
|||
requestNo: "", |
|||
requestBy: "", |
|||
importDate: null, |
|||
importBy: "", |
|||
sourceFileName: "", |
|||
remark: "" |
|||
}; |
|||
}, |
|||
getBuList() { |
|||
const params = { |
|||
username: this.$store.state.user.name |
|||
}; |
|||
getAllBuList(params).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.userBuList = data.rows || []; |
|||
if (this.userBuList.length > 0) { |
|||
this.defaultBuKey = this.getDefaultBuKey(); |
|||
this.queryForm.buKey = this.defaultBuKey; |
|||
this.importData.buKey = this.defaultBuKey; |
|||
} |
|||
this.getDataList(); |
|||
} |
|||
}); |
|||
}, |
|||
getDefaultBuKey() { |
|||
const target = this.userBuList.find(item => |
|||
this.normalizeBuNo(item.site, item.buNo) === this.defaultBuNo |
|||
); |
|||
const defaultItem = target || this.userBuList[0]; |
|||
if (!defaultItem) { |
|||
return ""; |
|||
} |
|||
return this.composeBuKey(defaultItem.site, defaultItem.buNo); |
|||
}, |
|||
composeBuKey(site, buNo) { |
|||
return site + "_" + this.normalizeBuNo(site, buNo); |
|||
}, |
|||
normalizeBuNo(site, buNo) { |
|||
if (buNo === null || buNo === undefined) { |
|||
return ""; |
|||
} |
|||
const buText = String(buNo).trim(); |
|||
const siteText = site === null || site === undefined ? "" : String(site).trim(); |
|||
const prefix = siteText ? siteText + "_" : ""; |
|||
if (prefix && buText.indexOf(prefix) === 0) { |
|||
return buText.substring(prefix.length); |
|||
} |
|||
return buText; |
|||
}, |
|||
parseBuKey(buKey) { |
|||
if (!buKey || buKey.indexOf("_") < 0) { |
|||
return { site: "", buNo: "" }; |
|||
} |
|||
const splitIndex = buKey.indexOf("_"); |
|||
const site = buKey.substring(0, splitIndex); |
|||
const rawBuNo = buKey.substring(splitIndex + 1); |
|||
return { |
|||
site: site, |
|||
buNo: this.normalizeBuNo(site, rawBuNo) |
|||
}; |
|||
}, |
|||
handleQuery() { |
|||
this.pageIndex = 1; |
|||
this.getDataList(); |
|||
}, |
|||
resetQuery() { |
|||
const buKey = this.defaultBuKey || this.queryForm.buKey; |
|||
this.queryForm = this.getDefaultQueryForm(); |
|||
this.queryForm.buKey = buKey; |
|||
this.pageIndex = 1; |
|||
this.getDataList(); |
|||
}, |
|||
getDataList() { |
|||
const buData = this.parseBuKey(this.queryForm.buKey); |
|||
const params = { |
|||
...this.queryForm, |
|||
...buData, |
|||
page: this.pageIndex, |
|||
limit: this.pageSize |
|||
}; |
|||
params.qtyStart = this.parseNumberOrNull(params.qtyStart); |
|||
params.qtyEnd = this.parseNumberOrNull(params.qtyEnd); |
|||
params.localTotalAmountStart = this.parseNumberOrNull(params.localTotalAmountStart); |
|||
params.localTotalAmountEnd = this.parseNumberOrNull(params.localTotalAmountEnd); |
|||
delete params.buKey; |
|||
this.dataListLoading = true; |
|||
queryPartSparePurchaseImportPage(params).then(({ data }) => { |
|||
this.dataListLoading = false; |
|||
if (data && data.code === 0) { |
|||
this.dataList = data.page.list || []; |
|||
this.pageIndex = data.page.currPage; |
|||
this.pageSize = data.page.pageSize; |
|||
this.totalPage = data.page.totalCount; |
|||
this.summaryData = this.buildSummaryData(data.summary); |
|||
} else { |
|||
this.dataList = []; |
|||
this.totalPage = 0; |
|||
this.summaryData = this.getDefaultSummaryData(); |
|||
this.$message.error(data.msg || "查询失败"); |
|||
} |
|||
}).catch(() => { |
|||
this.dataListLoading = false; |
|||
this.summaryData = this.getDefaultSummaryData(); |
|||
this.$message.error("查询失败"); |
|||
}); |
|||
}, |
|||
getDefaultSummaryData() { |
|||
return { |
|||
totalQty: 0, |
|||
totalLocalTotalAmount: 0 |
|||
}; |
|||
}, |
|||
buildSummaryData(summary) { |
|||
return { |
|||
totalQty: this.parseNumberOrZero(summary && summary.totalQty), |
|||
totalLocalTotalAmount: this.parseNumberOrZero(summary && summary.totalLocalTotalAmount) |
|||
}; |
|||
}, |
|||
getSummaryRow({ columns }) { |
|||
return columns.map((column) => { |
|||
if (column.type === "selection") { |
|||
return ""; |
|||
} |
|||
if (column.property === "orderDate") { |
|||
return "总计"; |
|||
} |
|||
if (column.property === "qty") { |
|||
return this.formatNumber(this.summaryData.totalQty); |
|||
} |
|||
if (column.property === "localTotalAmount") { |
|||
return this.formatNumber(this.summaryData.totalLocalTotalAmount); |
|||
} |
|||
return ""; |
|||
}); |
|||
}, |
|||
sizeChangeHandle(val) { |
|||
this.pageSize = val; |
|||
this.pageIndex = 1; |
|||
this.getDataList(); |
|||
}, |
|||
currentChangeHandle(val) { |
|||
this.pageIndex = val; |
|||
this.getDataList(); |
|||
}, |
|||
handleSelectionChange(val) { |
|||
this.selectionData = val || []; |
|||
}, |
|||
openAddDialog() { |
|||
this.formMode = "add"; |
|||
this.formData = this.getDefaultFormData(); |
|||
this.formData.buKey = this.queryForm.buKey; |
|||
this.formDialogVisible = true; |
|||
this.$nextTick(() => { |
|||
if (this.$refs.saveForm) { |
|||
this.$refs.saveForm.clearValidate(); |
|||
} |
|||
}); |
|||
}, |
|||
openEditDialog(row) { |
|||
if (!row || row.id === null || row.id === undefined || row.id === "") { |
|||
this.$message.warning("当前记录ID无效,无法修改"); |
|||
return; |
|||
} |
|||
this.formMode = "edit"; |
|||
this.formData = { |
|||
...this.getDefaultFormData(), |
|||
...row, |
|||
buKey: this.composeBuKey(row.site, row.buNo) |
|||
}; |
|||
this.formDialogVisible = true; |
|||
this.$nextTick(() => { |
|||
if (this.$refs.saveForm) { |
|||
this.$refs.saveForm.clearValidate(); |
|||
} |
|||
}); |
|||
}, |
|||
saveFormData() { |
|||
this.$refs.saveForm.validate((valid) => { |
|||
if (!valid) { |
|||
return; |
|||
} |
|||
const buData = this.parseBuKey(this.formData.buKey); |
|||
if (!buData.site || !buData.buNo) { |
|||
this.$message.warning("请选择BU"); |
|||
return; |
|||
} |
|||
const params = { |
|||
...this.formData, |
|||
...buData |
|||
}; |
|||
if (this.formMode === "edit" && (params.id === null || params.id === undefined || params.id === "")) { |
|||
this.$message.warning("当前记录ID无效,无法修改"); |
|||
return; |
|||
} |
|||
if (this.formMode === "edit") { |
|||
params.id = String(params.id); |
|||
} |
|||
delete params.buKey; |
|||
const api = this.formMode === "add" ? savePartSparePurchaseImport : updatePartSparePurchaseImport; |
|||
this.formLoading = true; |
|||
api(params).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.$message.success(data.msg || "操作成功"); |
|||
this.formDialogVisible = false; |
|||
this.getDataList(); |
|||
} else { |
|||
this.$alert(data.msg || "操作失败", "错误", { confirmButtonText: "确定" }); |
|||
} |
|||
this.formLoading = false; |
|||
}).catch(() => { |
|||
this.formLoading = false; |
|||
this.$message.error("操作失败"); |
|||
}); |
|||
}); |
|||
}, |
|||
deleteSelection() { |
|||
if (this.selectionData.length === 0) { |
|||
this.$message.warning("请选择需要删除的数据"); |
|||
return; |
|||
} |
|||
this.$confirm(`确定删除选中的 ${this.selectionData.length} 条记录吗?`, "提示", { |
|||
confirmButtonText: "确定", |
|||
cancelButtonText: "取消", |
|||
type: "warning" |
|||
}).then(() => { |
|||
const ids = this.selectionData |
|||
.map(item => item.id) |
|||
.filter(id => id !== null && id !== undefined && id !== "") |
|||
.map(id => String(id)); |
|||
if (ids.length === 0) { |
|||
this.$message.warning("选中记录ID无效,无法删除"); |
|||
return; |
|||
} |
|||
deletePartSparePurchaseImport(ids).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.$message.success(data.msg || "删除成功"); |
|||
this.getDataList(); |
|||
} else { |
|||
this.$message.error(data.msg || "删除失败"); |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error("删除失败"); |
|||
}); |
|||
}).catch(() => {}); |
|||
}, |
|||
deleteByRow(row) { |
|||
if (!row || row.id === null || row.id === undefined || row.id === "") { |
|||
this.$message.warning("当前记录ID无效,无法删除"); |
|||
return; |
|||
} |
|||
this.$confirm("确定删除该记录吗?", "提示", { |
|||
confirmButtonText: "确定", |
|||
cancelButtonText: "取消", |
|||
type: "warning" |
|||
}).then(() => { |
|||
deletePartSparePurchaseImport([String(row.id)]).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.$message.success(data.msg || "删除成功"); |
|||
this.getDataList(); |
|||
} else { |
|||
this.$message.error(data.msg || "删除失败"); |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error("删除失败"); |
|||
}); |
|||
}).catch(() => {}); |
|||
}, |
|||
openImportDialog() { |
|||
this.importFileList = []; |
|||
this.importData.buKey = this.queryForm.buKey || this.defaultBuKey || this.importData.buKey; |
|||
this.importDialogVisible = true; |
|||
}, |
|||
closeImportDialog() { |
|||
this.importFileList = []; |
|||
if (this.$refs.uploadFile) { |
|||
this.$refs.uploadFile.clearFiles(); |
|||
} |
|||
}, |
|||
beforeUploadHandle(file) { |
|||
const ext = file.name.substring(file.name.lastIndexOf(".")).toLowerCase(); |
|||
if (!(ext === ".xlsx" || ext === ".xls")) { |
|||
this.$message.error("请选择Excel文件(.xlsx 或 .xls)"); |
|||
return false; |
|||
} |
|||
return true; |
|||
}, |
|||
onImportFileChange(file) { |
|||
this.importFileList = [file]; |
|||
}, |
|||
submitImport() { |
|||
const buData = this.parseBuKey(this.importData.buKey); |
|||
if (!buData.site || !buData.buNo) { |
|||
this.$message.warning("请选择BU"); |
|||
return; |
|||
} |
|||
if (this.importFileList.length === 0) { |
|||
this.$message.warning("请先选择导入文件"); |
|||
return; |
|||
} |
|||
const formData = new FormData(); |
|||
formData.append("file", this.importFileList[0].raw); |
|||
formData.append("site", buData.site); |
|||
formData.append("buNo", buData.buNo); |
|||
this.importLoading = true; |
|||
importPartSparePurchaseImportExcel(formData).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.$message.success((data.msg || "导入成功") + (data.count ? `,共 ${data.count} 条` : "")); |
|||
this.importDialogVisible = false; |
|||
this.getDataList(); |
|||
} else { |
|||
this.$alert(data.msg || "导入失败", "错误", { confirmButtonText: "确定" }); |
|||
} |
|||
this.importLoading = false; |
|||
}).catch(() => { |
|||
this.importLoading = false; |
|||
this.$message.error("导入失败"); |
|||
}); |
|||
}, |
|||
downloadTemplateFile() { |
|||
downloadPartSparePurchaseImportTemplate().then(({ data }) => { |
|||
const blob = new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }); |
|||
const fileName = "采购订单导入模板.xlsx"; |
|||
const link = document.createElement("a"); |
|||
link.download = fileName; |
|||
link.style.display = "none"; |
|||
link.href = URL.createObjectURL(blob); |
|||
document.body.appendChild(link); |
|||
link.click(); |
|||
URL.revokeObjectURL(link.href); |
|||
document.body.removeChild(link); |
|||
}).catch(() => { |
|||
this.$message.error("模板下载失败"); |
|||
}); |
|||
}, |
|||
formatNumber(value) { |
|||
if (value === null || value === undefined || value === "") { |
|||
return ""; |
|||
} |
|||
const number = Number(value); |
|||
if (isNaN(number)) { |
|||
return value; |
|||
} |
|||
return number.toFixed(4); |
|||
}, |
|||
parseNumberOrNull(value) { |
|||
if (value === null || value === undefined || value === "") { |
|||
return null; |
|||
} |
|||
const number = Number(value); |
|||
return isNaN(number) ? null : number; |
|||
}, |
|||
parseNumberOrZero(value) { |
|||
if (value === null || value === undefined || value === "") { |
|||
return 0; |
|||
} |
|||
const number = Number(value); |
|||
return isNaN(number) ? 0 : number; |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
|
|||
<style scoped> |
|||
.date-separator { |
|||
display: inline-block; |
|||
width: 16px; |
|||
text-align: center; |
|||
} |
|||
|
|||
/deep/ .el-table__footer-wrapper td { |
|||
font-weight: 600; |
|||
} |
|||
|
|||
/deep/ .el-table__footer-wrapper { |
|||
display: block !important; |
|||
visibility: visible !important; |
|||
} |
|||
|
|||
/deep/ .purchase-import-dialog .el-dialog { |
|||
margin-top: 3vh !important; |
|||
} |
|||
|
|||
/deep/ .purchase-import-dialog .el-dialog__body { |
|||
overflow-y: hidden; |
|||
} |
|||
|
|||
/deep/ .purchase-import-dialog .customer-upload .el-upload { |
|||
width: 100%; |
|||
} |
|||
|
|||
/deep/ .purchase-import-dialog .customer-upload .el-upload .el-upload-dragger { |
|||
width: 100%; |
|||
height: 180px; |
|||
} |
|||
|
|||
/deep/ .purchase-import-dialog .customer-upload .el-upload__text { |
|||
margin-top: 5px; |
|||
} |
|||
|
|||
/deep/ .purchase-import-dialog .customer-upload .el-upload__tip { |
|||
margin-top: 2px; |
|||
line-height: 16px; |
|||
} |
|||
|
|||
.upload-label { |
|||
font-size: 12px; |
|||
line-height: 20px; |
|||
} |
|||
</style> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue