Browse Source

价格表

master
常熟吴彦祖 3 weeks ago
parent
commit
2f8d0ee7be
  1. 28
      src/api/initialImport.js
  2. 14
      src/api/supplier/priceSheetReport.js
  3. 62
      src/views/modules/srmSupplier/supplierList.vue
  4. 364
      src/views/modules/supplier/priceSheetReport.vue
  5. 71
      src/views/modules/sys/initialImport.vue

28
src/api/initialImport.js

@ -27,3 +27,31 @@ export const saveSupplierPrice = data => http({
data: http.adornData(data), data: http.adornData(data),
timeout: 600000 timeout: 600000
}) })
export const downloadPartSkuTemplate = () => http({
url: http.adornUrl('/sys/initialImport/partSku/template'),
method: 'get',
responseType: 'blob'
})
export const previewPartSku = (file, site) => {
const formData = new FormData()
formData.append('file', file)
formData.append('site', site)
return http({
url: http.adornUrl('/sys/initialImport/partSku/preview'),
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
},
timeout: 120000
})
}
export const savePartSku = data => http({
url: http.adornUrl('/sys/initialImport/partSku/save'),
method: 'post',
data: http.adornData(data),
timeout: 600000
})

14
src/api/supplier/priceSheetReport.js

@ -0,0 +1,14 @@
import { createAPI } from '@/utils/httpRequest.js'
export const getPriceListPage = data => createAPI('/supplier/priceSheetReport/priceListPage', 'post', data)
export const getHandlingChargePage = data => createAPI('/supplier/priceSheetReport/handlingChargePage', 'post', data)
export const getPaymentTermsPage = data => createAPI('/supplier/priceSheetReport/paymentTermsPage', 'post', data)
export const exportPriceSheetReport = data => createAPI(
'/supplier/priceSheetReport/export',
'post',
data,
{ responseType: 'blob', timeout: 600000 }
)

62
src/views/modules/srmSupplier/supplierList.vue

@ -67,6 +67,9 @@
<span v-else-if="item.columnProp === 'status'" :class="getStatusClass(scope.row.status)"> <span v-else-if="item.columnProp === 'status'" :class="getStatusClass(scope.row.status)">
{{ scope.row.status }} {{ scope.row.status }}
</span> </span>
<span v-else-if="item.columnProp === 'minShipAccount' || item.columnProp === 'handlingCharge'">
{{ formatSupplierNumberDisplay(scope.row[item.columnProp]) }}
</span>
<span v-else>{{ scope.row[item.columnProp] }}</span> <span v-else>{{ scope.row[item.columnProp] }}</span>
</span> </span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
@ -153,7 +156,7 @@
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist> <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
<!-- 供应商编辑对话框 --> <!-- 供应商编辑对话框 -->
<el-dialog :title="isAdd ? '新增供应商' : '编辑供应商'" :visible.sync="supplierDialogVisible" width="600px" top="3vh" :close-on-click-modal="false" class="supplier-dialog">
<el-dialog :title="isAdd ? '新增供应商' : '编辑供应商'" :visible.sync="supplierDialogVisible" width="600px" top="3vh" :close-on-click-modal="false" v-drag class="supplier-dialog">
<div class="dialog-content"> <div class="dialog-content">
<el-form <el-form
:model="currentSupplier" :model="currentSupplier"
@ -271,9 +274,15 @@
<el-input v-model="currentSupplier.deliveryTerm" style="width: 130px"></el-input> <el-input v-model="currentSupplier.deliveryTerm" style="width: 130px"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6">
<!-- 最低出货金额排在手续费前一格;新增/编辑均可填写,默认 0,不强制固定小数位 - rqrq -->
<el-form-item label="最低出货金额">
<el-input v-model="currentSupplier.minShipAccount" type="number"></el-input>
</el-form-item>
</el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="手续费"> <el-form-item label="手续费">
<el-input v-model="currentSupplier.handlingCharge"></el-input>
<el-input v-model="currentSupplier.handlingCharge" type="number"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -713,7 +722,25 @@ export default {
{ {
userId: this.$store.state.user.name, userId: this.$store.state.user.name,
functionId: this.functionId, functionId: this.functionId,
serialNumber: '811001Table1DeliveryTerm',
serialNumber: '811001Table1MinShipAccount',
tableId: '811001Table1',
tableName: '供应商信息',
columnProp: 'minShipAccount',
headerAlign: 'center',
align: 'center',
columnLabel: '最低出货金额',
columnWidth: '120',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: '811001Table1HandlingCharge',
tableId: '811001Table1', tableId: '811001Table1',
tableName: '供应商信息', tableName: '供应商信息',
columnProp: 'handlingCharge', columnProp: 'handlingCharge',
@ -1253,7 +1280,8 @@ export default {
taxCode:'', taxCode:'',
paymentTerm:'', paymentTerm:'',
deliveryTerm:'', deliveryTerm:'',
handlingCharge:'',
minShipAccount: 0,
handlingCharge: 0,
contract:'', contract:'',
phoneNo: '', phoneNo: '',
phoneNo2:'', phoneNo2:'',
@ -1324,6 +1352,21 @@ export default {
'status-inactive': status === 'Inactive' 'status-inactive': status === 'Inactive'
} }
}, },
/**
* 查询列表数值去尾零。
* 业务意图:最低出货金额/手续费按“去尾零”展示,整数显示为 1 而不是 1.000。
* 边界:空值显示空;非数字原样返回。
*/
formatSupplierNumberDisplay (value) {
if (value === null || value === undefined || value === '') {
return ''
}
const num = Number(value)
if (!Number.isFinite(num)) {
return String(value)
}
return String(num)
},
loadMainOrReminder () { loadMainOrReminder () {
const raw = this.$route.query.docExpireSupplierIds const raw = this.$route.query.docExpireSupplierIds
if (raw !== undefined && raw !== null && String(raw).trim() !== '') { if (raw !== undefined && raw !== null && String(raw).trim() !== '') {
@ -1651,6 +1694,8 @@ export default {
taxCode:'', taxCode:'',
paymentTerm:'', paymentTerm:'',
deliveryTerm:'', deliveryTerm:'',
minShipAccount: 0,
handlingCharge: 0,
contract:'', contract:'',
phoneNo: '', phoneNo: '',
phoneNo2:'', phoneNo2:'',
@ -1687,7 +1732,14 @@ export default {
// 列表展示使用 user_display,编辑回填需恢复为账号 // 列表展示使用 user_display,编辑回填需恢复为账号
buyer: this.currentRow.buyerAccount || this.currentRow.buyer || '', buyer: this.currentRow.buyerAccount || this.currentRow.buyer || '',
sourcingStaff: this.currentRow.sourcingStaffAccount || this.currentRow.sourcingStaff || '', sourcingStaff: this.currentRow.sourcingStaffAccount || this.currentRow.sourcingStaff || '',
planner: this.currentRow.plannerAccount || this.currentRow.planner || ''
planner: this.currentRow.plannerAccount || this.currentRow.planner || '',
// 价格字段空值按 0 回填,避免编辑框出现 null - rqrq
minShipAccount: this.currentRow.minShipAccount === null || this.currentRow.minShipAccount === undefined || this.currentRow.minShipAccount === ''
? 0
: this.currentRow.minShipAccount,
handlingCharge: this.currentRow.handlingCharge === null || this.currentRow.handlingCharge === undefined || this.currentRow.handlingCharge === ''
? 0
: this.currentRow.handlingCharge
} }
this.loadSupplierDocTypeOptions() this.loadSupplierDocTypeOptions()
this.supplierDialogVisible = true this.supplierDialogVisible = true

364
src/views/modules/supplier/priceSheetReport.vue

@ -0,0 +1,364 @@
<template>
<div ref="pageRoot" class="customer-css price-sheet-report">
<el-form :inline="true" label-position="top" class="pi-search-form">
<el-form-item label="ITEM">
<el-input
v-model="searchData.item"
clearable
style="width: 160px"
@keyup.enter.native="handleSearch"
/>
</el-form-item>
<el-form-item label="ShortNPC">
<el-input
v-model="searchData.shortNpc"
clearable
style="width: 160px"
@keyup.enter.native="handleSearch"
/>
</el-form-item>
<el-form-item label="SKU">
<el-input
v-model="searchData.sku"
clearable
style="width: 160px"
@keyup.enter.native="handleSearch"
/>
</el-form-item>
<el-form-item label="物料一级分类">
<el-input
v-model="searchData.category"
clearable
style="width: 180px"
@keyup.enter.native="handleSearch"
/>
</el-form-item>
<el-form-item label=" ">
<el-button
type="primary"
icon="el-icon-search"
class="customer-bun-min"
:loading="activeLoading"
@click="handleSearch">
查询
</el-button>
<el-button
icon="el-icon-refresh-left"
class="customer-bun-min"
:disabled="activeLoading"
@click="handleReset">
重置
</el-button>
<el-button
type="success"
icon="el-icon-download"
class="customer-bun-min"
:loading="exportLoading"
@click="handleExport">
导出
</el-button>
</el-form-item>
</el-form>
<el-tabs v-model="activeTab" type="border-card" @tab-click="handleTabClick">
<el-tab-pane label="price list" name="priceList">
<el-table
ref="priceListTable"
v-loading="tabState.priceList.loading"
:data="tabState.priceList.rows"
:height="tableHeight"
border
stripe
style="width: 100%">
<el-table-column prop="rawCode" label="RAW CODE" min-width="140" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="sku" label="SKU" min-width="120" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="supplier" label="SUPPLIER" min-width="130" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="moqColor" label="MOQ/COLOR" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="qtyPo" label="QTY/PO" min-width="110" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="startDate" label="START DATE" min-width="120" header-align="center" align="center" />
<el-table-column prop="tierQty1" label="Tier_QTY_1" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="tierQty2" label="Tier_QTY_2" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="tierQty3" label="Tier_QTY_3" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="tierQty4" label="Tier_QTY_4" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="tierQty5" label="Tier_QTY_5" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="tierQty6" label="Tier_QTY_6" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="tierQty7" label="Tier_QTY_7" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="tierQty8" label="Tier_QTY_8" min-width="120" header-align="center" align="right" :formatter="formatNumberCell" />
<el-table-column prop="priceTier1" label="Price_Tier_1" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="priceTier2" label="Price_Tier_2" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="priceTier3" label="Price_Tier_3" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="priceTier4" label="Price_Tier_4" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="priceTier5" label="Price_Tier_5" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="priceTier6" label="Price_Tier_6" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="priceTier7" label="Price_Tier_7" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="priceTier8" label="Price_Tier_8" min-width="125" header-align="center" align="right" :formatter="formatDollarCell" />
<el-table-column prop="fsc" label="FSC" min-width="120" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="fscClaim" label="FSC claim" min-width="150" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="leadFreePellet" label="Lead free Pellet" min-width="160" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="awareDpp" label="AWARE DPP" min-width="140" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="coo" label="COO" min-width="120" header-align="center" align="left" show-overflow-tooltip />
</el-table>
<report-pagination ref="priceListPagination" tab-name="priceList" :state="tabState.priceList" @size-change="handleSizeChange" @page-change="handlePageChange" />
</el-tab-pane>
<el-tab-pane label="handling charge" name="handlingCharge">
<el-table
ref="handlingChargeTable"
v-loading="tabState.handlingCharge.loading"
:data="tabState.handlingCharge.rows"
:height="tableHeight"
border
stripe
style="width: 100%">
<el-table-column prop="supplier" label="" min-width="180" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="comments" label="COMMENTS" min-width="300" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="handlingCharge" label="HANDLING CHARGE" min-width="180" header-align="center" align="right" />
</el-table>
<report-pagination ref="handlingChargePagination" tab-name="handlingCharge" :state="tabState.handlingCharge" @size-change="handleSizeChange" @page-change="handlePageChange" />
</el-tab-pane>
<el-tab-pane label="active payment terms" name="paymentTerms">
<el-table
ref="paymentTermsTable"
v-loading="tabState.paymentTerms.loading"
:data="tabState.paymentTerms.rows"
:height="tableHeight"
border
stripe
style="width: 100%">
<el-table-column prop="rowNo" label="No" width="90" header-align="center" align="center" />
<el-table-column prop="supplier" label="Supplier" min-width="180" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="paymentTerms" label="Payment Terms" min-width="320" header-align="center" align="left" show-overflow-tooltip />
<el-table-column prop="telexReleaseStatus" label="Telex Release status" min-width="200" header-align="center" align="left" />
</el-table>
<report-pagination ref="paymentTermsPagination" tab-name="paymentTerms" :state="tabState.paymentTerms" @size-change="handleSizeChange" @page-change="handlePageChange" />
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import {
exportPriceSheetReport,
getHandlingChargePage,
getPaymentTermsPage,
getPriceListPage
} from '@/api/supplier/priceSheetReport'
const ReportPagination = {
name: 'ReportPagination',
props: {
tabName: { type: String, required: true },
state: { type: Object, required: true }
},
render (h) {
return h('el-pagination', {
class: 'report-pagination',
props: {
currentPage: this.state.page,
pageSizes: [20, 50, 100, 200, 500],
pageSize: this.state.limit,
total: this.state.total,
layout: 'total, sizes, prev, pager, next, jumper'
},
on: {
'size-change': value => this.$emit('size-change', this.tabName, value),
'current-change': value => this.$emit('page-change', this.tabName, value)
}
})
}
}
const createTabState = () => ({
rows: [],
page: 1,
limit: 50,
total: 0,
loading: false,
loaded: false
})
export default {
name: 'PriceSheetReport',
components: { ReportPagination },
data () {
return {
searchData: {
item: '',
shortNpc: '',
sku: '',
category: ''
},
activeTab: 'priceList',
exportLoading: false,
tableHeight: 520,
tabState: {
priceList: createTabState(),
handlingCharge: createTabState(),
paymentTerms: createTabState()
}
}
},
computed: {
activeLoading () {
return this.tabState[this.activeTab].loading
}
},
mounted () {
this.$nextTick(this.updateTableHeight)
window.addEventListener('resize', this.updateTableHeight)
this.loadTab('priceList')
},
activated () {
this.$nextTick(this.updateTableHeight)
},
beforeDestroy () {
window.removeEventListener('resize', this.updateTableHeight)
},
methods: {
updateTableHeight () {
this.$nextTick(() => {
const table = this.$refs[`${this.activeTab}Table`]
const pagination = this.$refs[`${this.activeTab}Pagination`]
if (!table || !table.$el || !pagination || !pagination.$el) return
const pageRoot = this.$refs.pageRoot
const container = pageRoot.parentElement
const paginationStyle = window.getComputedStyle(pagination.$el)
const pageStyle = window.getComputedStyle(pageRoot)
const tabsContent = pagination.$el.closest('.el-tabs__content')
const tabsContentStyle = tabsContent ? window.getComputedStyle(tabsContent) : null
const containerBottom = Math.min(
document.documentElement.clientHeight,
container.getBoundingClientRect().bottom
)
const reservedHeight = pagination.$el.getBoundingClientRect().height +
parseFloat(paginationStyle.marginTop || 0) +
parseFloat(paginationStyle.marginBottom || 0) +
parseFloat(pageStyle.paddingBottom || 0) +
(tabsContentStyle ? parseFloat(tabsContentStyle.paddingBottom || 0) : 0) + 2
this.tableHeight = Math.max(
280,
Math.floor(containerBottom - table.$el.getBoundingClientRect().top - reservedHeight)
)
this.$nextTick(() => table.doLayout())
})
},
buildQuery (tabName) {
const state = tabName ? this.tabState[tabName] : null
return {
site: this.$store.state.user.site,
item: (this.searchData.item || '').trim(),
shortNpc: (this.searchData.shortNpc || '').trim(),
sku: (this.searchData.sku || '').trim(),
category: (this.searchData.category || '').trim(),
page: state ? state.page : 1,
limit: state ? state.limit : 50
}
},
requestForTab (tabName) {
if (tabName === 'handlingCharge') return getHandlingChargePage
if (tabName === 'paymentTerms') return getPaymentTermsPage
return getPriceListPage
},
loadTab (tabName) {
const state = this.tabState[tabName]
state.loading = true
this.requestForTab(tabName)(this.buildQuery(tabName)).then(({ data }) => {
if (data && data.code === 0) {
const page = data.page || {}
state.rows = Array.isArray(page.list) ? page.list : []
state.page = Number(page.currPage || state.page)
state.limit = Number(page.pageSize || state.limit)
state.total = Number(page.totalCount || 0)
state.loaded = true
} else {
state.rows = []
state.total = 0
this.$message.error((data && data.msg) || '查询失败')
}
}).catch(() => {
state.rows = []
state.total = 0
this.$message.error('查询失败')
}).finally(() => {
state.loading = false
})
},
handleSearch () {
Object.keys(this.tabState).forEach(tabName => {
this.tabState[tabName].page = 1
this.tabState[tabName].loaded = false
})
this.loadTab(this.activeTab)
},
handleReset () {
this.searchData = {
item: '',
shortNpc: '',
sku: '',
category: ''
}
this.handleSearch()
},
handleTabClick () {
this.updateTableHeight()
if (!this.tabState[this.activeTab].loaded) {
this.loadTab(this.activeTab)
}
},
handleSizeChange (tabName, value) {
const state = this.tabState[tabName]
state.limit = value
state.page = 1
this.loadTab(tabName)
},
handlePageChange (tabName, value) {
this.tabState[tabName].page = value
this.loadTab(tabName)
},
handleExport () {
this.exportLoading = true
exportPriceSheetReport(this.buildQuery()).then(response => {
const blob = new Blob([response.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '价格单报表.xlsx'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
}).catch(() => {
this.$message.error('导出失败')
}).finally(() => {
this.exportLoading = false
})
},
formatNumberCell (row, column, value) {
return value === null || value === undefined || value === '' ? '' : value
},
formatDollarCell (row, column, value) {
return value === null || value === undefined || value === '' ? '' : `$${value}`
}
}
}
</script>
<style scoped>
.price-sheet-report {
padding: 12px 16px;
}
.price-sheet-report /deep/ .el-tabs__content {
padding: 10px 12px 8px;
}
.report-pagination {
margin-top: 8px;
text-align: right;
}
</style>

71
src/views/modules/sys/initialImport.vue

@ -23,10 +23,10 @@
</el-table> </el-table>
</div> </div>
<el-dialog <el-dialog
title="供应商价格期初导入"
:title="dialogTitle"
v-drag v-drag
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="94%"
:width="dialogWidth"
top="5vh" top="5vh"
:show-close="!saving" :show-close="!saving"
:close-on-click-modal="false" :close-on-click-modal="false"
@ -43,7 +43,7 @@
下载导入模板 下载导入模板
</el-button> </el-button>
<el-upload <el-upload
ref="supplierPriceUpload"
ref="initialImportUpload"
action="#" action="#"
accept=".xls,.xlsx" accept=".xls,.xlsx"
:auto-upload="false" :auto-upload="false"
@ -71,9 +71,9 @@
size="mini" size="mini"
empty-text="请选择Excel文件进行预览" empty-text="请选择Excel文件进行预览"
:row-class-name="previewRowClassName" :row-class-name="previewRowClassName"
class="supplier-price-preview">
class="initial-import-preview">
<el-table-column <el-table-column
v-for="column in columns"
v-for="column in activeColumns"
:key="column.prop" :key="column.prop"
:prop="column.prop" :prop="column.prop"
:label="column.label" :label="column.label"
@ -99,8 +99,11 @@
<script> <script>
import { import {
downloadPartSkuTemplate,
downloadSupplierPriceTemplate, downloadSupplierPriceTemplate,
previewPartSku,
previewSupplierPrice, previewSupplierPrice,
savePartSku,
saveSupplierPrice saveSupplierPrice
} from '@/api/initialImport' } from '@/api/initialImport'
@ -113,8 +116,14 @@ export default {
type: 'supplierPrice', type: 'supplierPrice',
name: '供应商价格期初导入', name: '供应商价格期初导入',
description: '导入供应商物料的MOQ、阶梯数量和阶梯价格。' description: '导入供应商物料的MOQ、阶梯数量和阶梯价格。'
},
{
type: 'partSku',
name: '物料SKU导入',
description: '按Item更新物料SKU,不存在的SKU会自动新增。'
} }
], ],
activeImportType: '',
dialogVisible: false, dialogVisible: false,
previewLoading: false, previewLoading: false,
saving: false, saving: false,
@ -123,7 +132,7 @@ export default {
previewRows: [], previewRows: [],
missingItems: [], missingItems: [],
missingSuppliers: [], missingSuppliers: [],
columns: [
supplierPriceColumns: [
{ prop: 'rawCode', label: 'RAW CODE', width: 120, align: 'center' }, { prop: 'rawCode', label: 'RAW CODE', width: 120, align: 'center' },
{ prop: 'supplier', label: 'Short_NPC', width: 100, align: 'center' }, { prop: 'supplier', label: 'Short_NPC', width: 100, align: 'center' },
{ prop: 'moqColor', label: 'MOQ/COLOR', width: 80, align: 'center' }, { prop: 'moqColor', label: 'MOQ/COLOR', width: 80, align: 'center' },
@ -144,14 +153,31 @@ export default {
{ prop: 'priceTier6', label: 'Price_Tier_6', width: 90, align: 'center' }, { prop: 'priceTier6', label: 'Price_Tier_6', width: 90, align: 'center' },
{ prop: 'priceTier7', label: 'Price_Tier_7', width: 90, align: 'center' }, { prop: 'priceTier7', label: 'Price_Tier_7', width: 90, align: 'center' },
{ prop: 'priceTier8', label: 'Price_Tier_8', width: 90, align: 'center' } { prop: 'priceTier8', label: 'Price_Tier_8', width: 90, align: 'center' }
],
partSkuColumns: [
{ prop: 'item', label: 'ITEM', width: 220, align: 'left' },
{ prop: 'sku', label: 'SKU', width: 220, align: 'left' }
] ]
} }
}, },
computed: {
activeColumns () {
return this.activeImportType === 'partSku' ? this.partSkuColumns : this.supplierPriceColumns
},
dialogTitle () {
return this.activeImportType === 'partSku' ? '物料SKU导入' : '供应商价格期初导入'
},
dialogWidth () {
return this.activeImportType === 'partSku' ? '680px' : '94%'
}
},
methods: { methods: {
openImportDialog (type) { openImportDialog (type) {
if (type !== 'supplierPrice') {
if (type !== 'supplierPrice' && type !== 'partSku') {
return return
} }
this.resetDialog()
this.activeImportType = type
this.dialogVisible = true this.dialogVisible = true
}, },
handleFileChange (file) { handleFileChange (file) {
@ -170,7 +196,8 @@ export default {
this.missingItems = [] this.missingItems = []
this.missingSuppliers = [] this.missingSuppliers = []
this.previewLoading = true this.previewLoading = true
previewSupplierPrice(rawFile, site).then(({ data }) => {
const previewRequest = this.activeImportType === 'partSku' ? previewPartSku : previewSupplierPrice
previewRequest(rawFile, site).then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.previewRows = data.data || [] this.previewRows = data.data || []
this.missingItems = data.missingItems || [] this.missingItems = data.missingItems || []
@ -200,14 +227,20 @@ export default {
}, },
handleDownloadTemplate () { handleDownloadTemplate () {
this.templateDownloading = true this.templateDownloading = true
downloadSupplierPriceTemplate().then(response => {
const downloadRequest = this.activeImportType === 'partSku'
? downloadPartSkuTemplate
: downloadSupplierPriceTemplate
const downloadFileName = this.activeImportType === 'partSku'
? '物料SKU期初导入模板.xlsx'
: '供应商价格期初导入模板.xlsx'
downloadRequest().then(response => {
const blob = new Blob([response.data], { const blob = new Blob([response.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
}) })
const url = window.URL.createObjectURL(blob) const url = window.URL.createObjectURL(blob)
const link = document.createElement('a') const link = document.createElement('a')
link.href = url link.href = url
link.download = '供应商价格期初导入模板.xlsx'
link.download = downloadFileName
document.body.appendChild(link) document.body.appendChild(link)
link.click() link.click()
document.body.removeChild(link) document.body.removeChild(link)
@ -231,7 +264,7 @@ export default {
const invalidCount = this.previewRows.filter(row => row && row.valid === false).length const invalidCount = this.previewRows.filter(row => row && row.valid === false).length
if (invalidCount > 0) { if (invalidCount > 0) {
this.$confirm( this.$confirm(
`存在${invalidCount}行淡黄色数据。如果继续保存,不存在的数据行将跳过,是否继续?`,
`存在${invalidCount}行淡黄色数据。如果继续保存,无效数据行将跳过,是否继续?`,
'数据校验提示', '数据校验提示',
{ {
confirmButtonText: '继续保存', confirmButtonText: '继续保存',
@ -247,7 +280,8 @@ export default {
}, },
performSave (site) { performSave (site) {
this.saving = true this.saving = true
saveSupplierPrice({
const saveRequest = this.activeImportType === 'partSku' ? savePartSku : saveSupplierPrice
saveRequest({
site, site,
rows: this.previewRows rows: this.previewRows
}).then(({ data }) => { }).then(({ data }) => {
@ -277,7 +311,7 @@ export default {
if (this.missingItems.length) { if (this.missingItems.length) {
messages.push(`以下Item不存在:${this.missingItems.join('、')}`) messages.push(`以下Item不存在:${this.missingItems.join('、')}`)
} }
if (this.missingSuppliers.length) {
if (this.activeImportType === 'supplierPrice' && this.missingSuppliers.length) {
messages.push(`以下供应商简称不存在:${this.missingSuppliers.join('、')}`) messages.push(`以下供应商简称不存在:${this.missingSuppliers.join('、')}`)
} }
const content = this.$createElement( const content = this.$createElement(
@ -300,11 +334,12 @@ export default {
}, },
clearSelectedFile () { clearSelectedFile () {
this.fileName = '' this.fileName = ''
if (this.$refs.supplierPriceUpload) {
this.$refs.supplierPriceUpload.clearFiles()
if (this.$refs.initialImportUpload) {
this.$refs.initialImportUpload.clearFiles()
} }
}, },
resetDialog () { resetDialog () {
this.activeImportType = ''
this.previewLoading = false this.previewLoading = false
this.saving = false this.saving = false
this.templateDownloading = false this.templateDownloading = false
@ -364,15 +399,15 @@ export default {
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
} }
.supplier-price-preview {
.initial-import-preview {
width: 100%; width: 100%;
} }
.supplier-price-preview /deep/ .initial-import-warning-row > td {
.initial-import-preview /deep/ .initial-import-warning-row > td {
background-color: #fff7d6 !important; background-color: #fff7d6 !important;
} }
.supplier-price-preview /deep/ .initial-import-warning-row:hover > td {
.initial-import-preview /deep/ .initial-import-warning-row:hover > td {
background-color: #fff0b3 !important; background-color: #fff0b3 !important;
} }

Loading…
Cancel
Save