Browse Source
阶梯价格变更弹窗:回车 = 新增梯度
阶梯价格变更弹窗:回车 = 新增梯度
QC人员排程页:20 天卡片 + 日期箭头工具条 订单查询页验货明细:跳转按订单类型分流 物料页价格表弹窗:新增「维护价格表」master
6 changed files with 843 additions and 21 deletions
-
97src/views/modules/inspection/inspectionScheduleOverview.vue
-
18src/views/modules/order/com_inspectionDetailList.vue
-
8src/views/modules/qc/IQCResultEntry.vue
-
24src/views/modules/srmPart/partInfoList.vue
-
709src/views/modules/supplier/com_supplierPartTierChangeDialog.vue
-
8src/views/modules/supplier/supplierPartMoqPrice.vue
@ -0,0 +1,709 @@ |
|||
<template> |
|||
<div class="supplier-part-tier-change"> |
|||
<!-- |
|||
阶梯价格变更弹窗(与 supplierPartMoqPrice.vue 的「变更」弹窗功能一致): |
|||
维护 MOQ 三数量、在用状态、长宽高/毛净重、Remark/latest changes、阶梯价格与附件。 |
|||
供 partInfoList 价格表弹窗「维护价格表」按钮打开;打开时自行回查可供物料行与当前生效阶梯价。 |
|||
保存成功后向父组件抛 saved 事件,由调用方刷新自己的展示。 |
|||
--> |
|||
<el-dialog |
|||
title="阶梯价格变更" |
|||
:visible.sync="tierDialogVisible" |
|||
width="1000px" |
|||
:close-on-click-modal="false" |
|||
class="tier-change-dialog" |
|||
append-to-body |
|||
v-drag |
|||
@keyup.enter.native="onTierDialogEnter" |
|||
> |
|||
<el-form label-position="top" :model="tierForm"> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="5"> |
|||
<el-form-item label="供应商编号"> |
|||
<el-input v-model="tierForm.supplierCode" disabled /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="9"> |
|||
<el-form-item label="物料信息"> |
|||
<el-input :value="`${tierForm.partNo || ''} / ${tierForm.item || ''} / ${tierForm.sku || ''}`" disabled /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="4"> |
|||
<el-form-item label="价格日期" required> |
|||
<el-date-picker |
|||
v-model="tierForm.priceDate" |
|||
type="date" |
|||
value-format="yyyy-MM-dd" |
|||
format="yyyy-MM-dd" |
|||
placeholder="价格日期" |
|||
style="width: 100%" |
|||
@change="fetchAttachmentList" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label=" "> |
|||
<div class="tier-action-buttons"> |
|||
<el-button type="primary" class="customer-bun-min" @click="addTierRow">新增梯度</el-button> |
|||
<el-button type="primary" class="customer-bun-min" @click="setNoTier">无梯度</el-button> |
|||
</div> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
</el-form> |
|||
<div class="attachment-header"> |
|||
<span>维护MOQ</span> |
|||
</div> |
|||
<el-form label-position="top" :model="tierForm"> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="6"> |
|||
<el-form-item label="MOQ/COLOR" required> |
|||
<el-input-number v-model="tierForm.moqColor" :min="0" :controls="false" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="QTY/PO" required> |
|||
<el-input-number v-model="tierForm.moq" :min="0" :controls="false" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="QTY/CARTON" required> |
|||
<el-input-number v-model="tierForm.qtyCarton" :min="0" :controls="false" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="6"> |
|||
<el-form-item label="是否在用"> |
|||
<el-select v-model="tierForm.active" style="width: 100%"> |
|||
<el-option label="是" value="Y" /> |
|||
<el-option label="否" value="N" /> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="8"> |
|||
<el-form-item label="Length/MM"> |
|||
<el-input-number v-model="tierForm.length" :min="0" :controls="false" placeholder="可空" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-form-item label="Width/MM"> |
|||
<el-input-number v-model="tierForm.width" :min="0" :controls="false" placeholder="可空" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-form-item label="Height/MM"> |
|||
<el-input-number v-model="tierForm.height" :min="0" :controls="false" placeholder="可空" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="8"> |
|||
<el-form-item label="GW/G"> |
|||
<el-input-number v-model="tierForm.grossWeight" :min="0" :controls="false" placeholder="可空" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-form-item label="NW/G"> |
|||
<el-input-number v-model="tierForm.netWeight" :min="0" :controls="false" placeholder="可空" style="width: 100%" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-form-item label="Remark" class="optional-text" :style="calcTextareaFollowGapStyle(2)"> |
|||
<el-input |
|||
v-model="tierForm.remark" |
|||
type="textarea" |
|||
resize="none" |
|||
maxlength="200" |
|||
show-word-limit |
|||
:autosize="{ minRows: 2, maxRows: 2 }" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item label="latest changes" class="optional-text" :style="calcTextareaFollowGapStyle(2)"> |
|||
<el-input |
|||
v-model="tierForm.latestChanges" |
|||
type="textarea" |
|||
resize="none" |
|||
maxlength="200" |
|||
show-word-limit |
|||
:autosize="{ minRows: 2, maxRows: 2 }" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
</el-form> |
|||
<div class="rq"> |
|||
<el-table :height="300" :data="tierForm.tierPriceList" border stripe style="width: 100%; margin-top: 5px;"> |
|||
<el-table-column type="index" label="#" width="50" header-align="center" align="center" /> |
|||
<el-table-column label="开始数量" min-width="140" header-align="center" align="right"> |
|||
<template slot-scope="scope"> |
|||
<el-input-number v-model="scope.row.qtyStart" :step="0.0001" :min="0" :controls="false" style="width: 98%" /> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="结束数量" min-width="140" header-align="center" align="right"> |
|||
<template slot-scope="scope"> |
|||
<el-input-number v-model="scope.row.qtyEnd" :step="0.0001" :min="0" :controls="false" style="width: 98%" /> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="单价" min-width="150" header-align="center" align="right"> |
|||
<template slot-scope="scope"> |
|||
<el-input-number v-model="scope.row.unitPrice" :step="0.0001" :precision="4" :min="0" :controls="false" style="width: 98%" /> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="备注" min-width="220" header-align="center" align="left"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-model="scope.row.remark" /> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="操作" width="90" header-align="center" align="center" fixed="right"> |
|||
<template slot-scope="scope"> |
|||
<el-link style="cursor: pointer" @click="removeTierRow(scope.$index)">删除</el-link> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</div> |
|||
<div class="attachment-header"> |
|||
<span>附件</span> |
|||
<el-button type="primary" class="customer-bun-min" @click="openAttachmentUploadDialog">上传附件</el-button> |
|||
</div> |
|||
<el-table :data="attachmentList" border stripe :max-height="180" v-loading="attachmentLoading" style="width: 100%"> |
|||
<el-table-column prop="fileName" label="文件名" min-width="260" header-align="center" align="left" show-overflow-tooltip /> |
|||
<el-table-column prop="createdBy" label="上传人" min-width="120" header-align="center" align="center" /> |
|||
<el-table-column prop="createDate" label="上传时间" min-width="160" header-align="center" align="center" /> |
|||
<el-table-column label="操作" width="90" header-align="center" align="center" fixed="right"> |
|||
<template slot-scope="scope"> |
|||
<el-link style="cursor: pointer" @click="downloadAttachment(scope.row)">下载</el-link> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<div slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" :disabled="tierSaveLoading" @click="saveTierChange"> |
|||
{{ tierSaveLoading ? '保存中...' : '保存' }} |
|||
</el-button> |
|||
<el-button :disabled="tierSaveLoading" @click="tierDialogVisible = false">取消</el-button> |
|||
</div> |
|||
</el-dialog> |
|||
|
|||
<!-- 附件上传弹窗(与 supplierPartMoqPrice.vue 一致:OSS 上传后按 refIds 关联到本次价格版本) --> |
|||
<el-dialog |
|||
title="上传" |
|||
:visible.sync="attachmentUploadVisible" |
|||
v-drag |
|||
width="400px" |
|||
append-to-body |
|||
:close-on-click-modal="false" |
|||
> |
|||
<el-form ref="attachmentUploadForm" class="rq" label-width="80px" label-position="top"> |
|||
<el-row :gutter="10"> |
|||
<el-col :span="24"> |
|||
<el-form-item label=" " class="auto"> |
|||
<el-upload |
|||
drag |
|||
:file-list="attachmentFileList" |
|||
action="#" |
|||
ref="attachmentUploadRef" |
|||
:on-remove="onAttachmentFileRemove" |
|||
:on-change="onAttachmentFileChange" |
|||
multiple |
|||
:auto-upload="false" |
|||
> |
|||
<i class="el-icon-upload" /> |
|||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
|||
</el-upload> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="24"> |
|||
<el-form-item label="备注" class="auto" :style="calcTextareaFollowGapStyle(3)"> |
|||
<el-input |
|||
type="textarea" |
|||
v-model="attachmentRemark" |
|||
resize="none" |
|||
:autosize="{ minRows: 3, maxRows: 3 }" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
</el-form> |
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" :loading="attachmentUploadLoading" @click="submitAttachmentUpload">确认</el-button> |
|||
<el-button @click="attachmentUploadVisible = false">取消</el-button> |
|||
</span> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { |
|||
listSupplierPartMoq, |
|||
listCurrentTierPrice, |
|||
saveTierPrice, |
|||
saveSupplierPartMoq |
|||
} from '@/api/supplier/supplierPartMoqPrice' |
|||
import { |
|||
queryOssFilePlus, |
|||
ossUploadNoSaveOSSForYJY, |
|||
downLoadObjectFile |
|||
} from '@/api/oss/oss' |
|||
|
|||
export default { |
|||
name: 'SupplierPartTierChangeDialog', |
|||
data () { |
|||
return { |
|||
tierDialogVisible: false, |
|||
tierSaveLoading: false, |
|||
tierForm: { |
|||
site: '', |
|||
supplierCode: '', |
|||
supplierName: '', |
|||
partNo: '', |
|||
item: '', |
|||
sku: '', |
|||
partDesc: '', |
|||
priceDate: '', |
|||
moq: 0, |
|||
moqColor: 0, |
|||
qtyCarton: 0, |
|||
active: 'Y', |
|||
remark: '', |
|||
latestChanges: '', |
|||
length: null, |
|||
width: null, |
|||
height: null, |
|||
grossWeight: null, |
|||
netWeight: null, |
|||
tierPriceList: [] |
|||
}, |
|||
attachmentLoading: false, |
|||
attachmentList: [], |
|||
attachmentRefIds: [], |
|||
attachmentUploadVisible: false, |
|||
attachmentUploadLoading: false, |
|||
attachmentFileList: [], |
|||
attachmentRemark: '' |
|||
} |
|||
}, |
|||
methods: { |
|||
/** |
|||
* 打开弹窗:入参 { site, supplierCode, partNo, item, sku }。 |
|||
* 自行回查可供物料行(MOQ 等回显)与当前生效阶梯价; |
|||
* 可供物料行不存在时提示先建立供应商可供关系(后端保存 MOQ 也要求关系已存在)。 |
|||
*/ |
|||
open (payload) { |
|||
const site = String((payload && payload.site) || this.$store.state.user.site || '').trim() |
|||
const supplierCode = String((payload && payload.supplierCode) || '').trim() |
|||
const partNo = String((payload && payload.partNo) || '').trim() |
|||
if (!site || !supplierCode || !partNo) { |
|||
this.$message.warning('缺少供应商或物料编码,无法维护价格表') |
|||
return |
|||
} |
|||
Promise.all([ |
|||
listSupplierPartMoq({ site, partNo }), |
|||
listCurrentTierPrice({ site, supplierCode, partNo }) |
|||
]).then(([partRes, tierRes]) => { |
|||
const partData = partRes && partRes.data |
|||
const tierData = tierRes && tierRes.data |
|||
if (!(partData && partData.code === 0) || !(tierData && tierData.code === 0)) { |
|||
this.$message.error((partData && partData.msg) || (tierData && tierData.msg) || '获取供应商物料信息失败') |
|||
return |
|||
} |
|||
// listSupplierPart 的 supplierCode 条件按简称模糊匹配,故按 partNo 查询后前端精确匹配供应商+物料 |
|||
const matched = (partData.rows || []).find(row => |
|||
(row.partNo || '').trim().toUpperCase() === partNo.toUpperCase() && |
|||
(row.supplierCode || '').trim().toUpperCase() === supplierCode.toUpperCase() |
|||
) |
|||
if (!matched) { |
|||
this.$message.warning('该供应商+物料尚未建立可供关系,请先在物料保存时发起新品流程或到供应商物料MOQ页面新增') |
|||
return |
|||
} |
|||
this.tierForm = { |
|||
site, |
|||
supplierCode: matched.supplierCode, |
|||
supplierName: matched.supplierName || '', |
|||
partNo: matched.partNo, |
|||
item: matched.item || (payload && payload.item) || '', |
|||
sku: matched.sku || (payload && payload.sku) || '', |
|||
partDesc: matched.partDesc || '', |
|||
priceDate: this.getTodayDate(), |
|||
moq: this.normalizeNumberValue(matched.moq, 0), |
|||
moqColor: this.normalizeNumberValue(matched.moqColor, 0), |
|||
qtyCarton: this.normalizeNumberValue(matched.qtyCarton, 0), |
|||
active: matched.active || 'Y', |
|||
remark: matched.remark || '', |
|||
latestChanges: matched.latestChanges || '', |
|||
// 长宽高/毛净重可空,保留空值不回显为 0 |
|||
length: matched.length == null ? null : matched.length, |
|||
width: matched.width == null ? null : matched.width, |
|||
height: matched.height == null ? null : matched.height, |
|||
grossWeight: matched.grossWeight == null ? null : matched.grossWeight, |
|||
netWeight: matched.netWeight == null ? null : matched.netWeight, |
|||
tierPriceList: (tierData.rows || []).map(item => ({ |
|||
qtyStart: this.normalizeNumberValue(item.qtyStart, 0), |
|||
qtyEnd: this.normalizeNumberValue(item.qtyEnd, 0), |
|||
unitPrice: this.normalizeNumberValue(item.unitPrice, 0), |
|||
remark: item.remark || '' |
|||
})) |
|||
} |
|||
if (!this.tierForm.tierPriceList.length) { |
|||
this.tierForm.tierPriceList.push(this.buildEmptyTierRow()) |
|||
} |
|||
// 每次进入都按新版本处理:附件不继承历史,需重新上传 |
|||
this.attachmentRefIds = [] |
|||
this.attachmentList = [] |
|||
this.attachmentRemark = '' |
|||
this.attachmentFileList = [] |
|||
this.tierDialogVisible = true |
|||
}).catch(() => { |
|||
this.$message.error('获取供应商物料信息失败') |
|||
}) |
|||
}, |
|||
addTierRow () { |
|||
const rows = this.tierForm.tierPriceList |
|||
// 新增梯度前需判断上一条结束数量不等于 0:未填写有效结束数量时阻止新增 |
|||
if (rows.length) { |
|||
const lastQtyEnd = this.normalizeNumberValue(rows[rows.length - 1].qtyEnd, 0) |
|||
if (lastQtyEnd === 0) { |
|||
this.$message.warning('请先填写上一条梯度的结束数量') |
|||
return |
|||
} |
|||
// 新梯度的开始数量 = 上一条结束数量 + 1 |
|||
const newRow = this.buildEmptyTierRow() |
|||
newRow.qtyStart = lastQtyEnd + 1 |
|||
rows.push(newRow) |
|||
} else { |
|||
rows.push(this.buildEmptyTierRow()) |
|||
} |
|||
}, |
|||
// 弹窗内按回车等同于点击「新增梯度」;textarea 回车换行、下拉/日期选择的回车不触发 |
|||
onTierDialogEnter (e) { |
|||
const target = e.target |
|||
if (!target || target.tagName !== 'INPUT') return |
|||
if (target.closest('.el-select') || target.closest('.el-date-editor')) return |
|||
this.addTierRow() |
|||
}, |
|||
setNoTier () { |
|||
const rows = this.tierForm.tierPriceList || [] |
|||
// 无梯度:仅允许存在一条价格梯度,将其结束数量置为上不封顶(1000000) |
|||
if (rows.length !== 1) { |
|||
this.$message.warning('当前产品有价格梯度,请删除多余价格信息') |
|||
return |
|||
} |
|||
rows[0].qtyEnd = 1000000 |
|||
}, |
|||
removeTierRow (index) { |
|||
this.tierForm.tierPriceList.splice(index, 1) |
|||
if (!this.tierForm.tierPriceList.length) { |
|||
this.tierForm.tierPriceList.push(this.buildEmptyTierRow()) |
|||
} |
|||
}, |
|||
buildEmptyTierRow () { |
|||
return { |
|||
qtyStart: 0, |
|||
qtyEnd: 0, |
|||
unitPrice: 0, |
|||
remark: '' |
|||
} |
|||
}, |
|||
// 校验三个起订量:空值不允许,且不能小于 0 |
|||
validateQtyFields (form) { |
|||
const fields = [ |
|||
{ key: 'moqColor', label: 'MOQ/COLOR' }, |
|||
{ key: 'moq', label: 'QTY/PO' }, |
|||
{ key: 'qtyCarton', label: 'QTY/CARTON' } |
|||
] |
|||
for (let i = 0; i < fields.length; i++) { |
|||
const field = fields[i] |
|||
const value = form[field.key] |
|||
if (value === null || value === undefined || value === '') { |
|||
this.$message.warning(field.label + '不能为空') |
|||
return false |
|||
} |
|||
if (Number(value) < 0) { |
|||
this.$message.warning(field.label + '不能小于0') |
|||
return false |
|||
} |
|||
} |
|||
return true |
|||
}, |
|||
normalizeNumberValue (value, defaultValue = 0) { |
|||
if (value === null || value === undefined || value === '') return defaultValue |
|||
const num = Number(value) |
|||
if (Number.isNaN(num)) return defaultValue |
|||
return Object.is(num, -0) ? 0 : num |
|||
}, |
|||
validateTierRows () { |
|||
if (!this.tierForm.priceDate) { |
|||
this.$message.warning('价格日期不能为空') |
|||
return false |
|||
} |
|||
if (!this.tierForm.tierPriceList || !this.tierForm.tierPriceList.length) { |
|||
this.$message.warning('请至少维护一条阶梯价格') |
|||
return false |
|||
} |
|||
for (let i = 0; i < this.tierForm.tierPriceList.length; i++) { |
|||
const row = this.tierForm.tierPriceList[i] |
|||
if (row.qtyStart === null || row.qtyStart === undefined || row.qtyStart === '') { |
|||
this.$message.warning(`第${i + 1}行开始数量不能为空`) |
|||
return false |
|||
} |
|||
if (row.qtyEnd === null || row.qtyEnd === undefined || row.qtyEnd === '') { |
|||
this.$message.warning(`第${i + 1}行结束数量不能为空`) |
|||
return false |
|||
} |
|||
if (Number(row.qtyStart) > Number(row.qtyEnd)) { |
|||
this.$message.warning(`第${i + 1}行开始数量不能大于结束数量`) |
|||
return false |
|||
} |
|||
if (row.unitPrice === null || row.unitPrice === undefined || row.unitPrice === '') { |
|||
this.$message.warning(`第${i + 1}行单价不能为空`) |
|||
return false |
|||
} |
|||
} |
|||
const sortedRanges = this.tierForm.tierPriceList |
|||
.map((row, idx) => ({ rowNo: idx + 1, qtyStart: Number(row.qtyStart), qtyEnd: Number(row.qtyEnd) })) |
|||
.sort((a, b) => { |
|||
if (a.qtyStart !== b.qtyStart) return a.qtyStart - b.qtyStart |
|||
return a.qtyEnd - b.qtyEnd |
|||
}) |
|||
for (let i = 1; i < sortedRanges.length; i++) { |
|||
if (sortedRanges[i].qtyStart <= sortedRanges[i - 1].qtyEnd) { |
|||
this.$message.warning(`第${sortedRanges[i - 1].rowNo}行与第${sortedRanges[i].rowNo}行数量区间重叠`) |
|||
return false |
|||
} |
|||
} |
|||
return true |
|||
}, |
|||
saveTierChange () { |
|||
if (!this.validateTierRows()) { |
|||
return |
|||
} |
|||
// MOQ 与阶梯价一起提交,三个起订量需校验 |
|||
if (!this.validateQtyFields(this.tierForm)) { |
|||
return |
|||
} |
|||
this.tierSaveLoading = true |
|||
const priceInData = { |
|||
site: this.tierForm.site, |
|||
supplierCode: this.tierForm.supplierCode, |
|||
partNo: this.tierForm.partNo, |
|||
priceDate: this.tierForm.priceDate, |
|||
submitBy: this.$store.state.user.name, |
|||
attachmentRefs: this.buildAttachmentRefs(), |
|||
tierPriceList: this.tierForm.tierPriceList.map(item => ({ |
|||
qtyStart: item.qtyStart, |
|||
qtyEnd: item.qtyEnd, |
|||
// 与界面显示保持一致:单价固定按后四位小数提交(如 0.1 → 0.1000) |
|||
unitPrice: this.normalizeNumberValue(item.unitPrice, 0).toFixed(4), |
|||
remark: item.remark || '' |
|||
})) |
|||
} |
|||
const moqInData = { |
|||
site: this.tierForm.site, |
|||
supplierCode: this.tierForm.supplierCode, |
|||
partNo: this.tierForm.partNo, |
|||
moq: this.tierForm.moq, |
|||
moqColor: this.tierForm.moqColor, |
|||
qtyCarton: this.tierForm.qtyCarton, |
|||
active: this.tierForm.active, |
|||
remark: this.tierForm.remark || '', |
|||
latestChanges: this.tierForm.latestChanges || '', |
|||
length: this.tierForm.length == null ? null : this.tierForm.length, |
|||
width: this.tierForm.width == null ? null : this.tierForm.width, |
|||
height: this.tierForm.height == null ? null : this.tierForm.height, |
|||
grossWeight: this.tierForm.grossWeight == null ? null : this.tierForm.grossWeight, |
|||
netWeight: this.tierForm.netWeight == null ? null : this.tierForm.netWeight |
|||
} |
|||
Promise.all([saveTierPrice(priceInData), saveSupplierPartMoq(moqInData)]).then(([priceRes, moqRes]) => { |
|||
const priceData = priceRes && priceRes.data |
|||
const moqData = moqRes && moqRes.data |
|||
if (priceData && priceData.code === 0 && moqData && moqData.code === 0) { |
|||
this.$message.success('保存成功') |
|||
this.tierDialogVisible = false |
|||
// 通知调用方刷新自己的价格展示 |
|||
this.$emit('saved', { |
|||
site: this.tierForm.site, |
|||
supplierCode: this.tierForm.supplierCode, |
|||
partNo: this.tierForm.partNo |
|||
}) |
|||
} else { |
|||
this.$alert((priceData && priceData.msg) || (moqData && moqData.msg) || '保存失败', '错误', { confirmButtonText: '确定' }) |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error('保存失败') |
|||
}).finally(() => { |
|||
this.tierSaveLoading = false |
|||
}) |
|||
}, |
|||
getTodayDate () { |
|||
const date = new Date() |
|||
const pad = num => String(num).padStart(2, '0') |
|||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}` |
|||
}, |
|||
buildAttachmentQueryParams () { |
|||
return { |
|||
orderRef1: this.tierForm.site, |
|||
orderRef2: this.tierForm.supplierCode, |
|||
orderRef3: this.tierForm.partNo, |
|||
orderRef4: this.tierForm.priceDate || '', |
|||
orderReftype: 'SUPPLIER_PART_PRICE' |
|||
} |
|||
}, |
|||
fetchAttachmentList () { |
|||
if (!this.tierDialogVisible || !this.tierForm.supplierCode || !this.tierForm.partNo) { |
|||
this.attachmentList = [] |
|||
return |
|||
} |
|||
const refIdSet = new Set((this.attachmentRefIds || []).map(item => String(item))) |
|||
this.attachmentLoading = true |
|||
queryOssFilePlus(this.buildAttachmentQueryParams()).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
const allRows = data.rows || [] |
|||
this.attachmentList = refIdSet.size > 0 |
|||
? allRows.filter(item => refIdSet.has(String(item.id))) |
|||
: [] |
|||
} else { |
|||
this.attachmentList = [] |
|||
} |
|||
}).catch(() => { |
|||
this.attachmentList = [] |
|||
}).finally(() => { |
|||
this.attachmentLoading = false |
|||
}) |
|||
}, |
|||
openAttachmentUploadDialog () { |
|||
if (!this.tierForm.priceDate) { |
|||
this.$message.warning('请先选择价格日期') |
|||
return |
|||
} |
|||
this.attachmentUploadVisible = true |
|||
this.attachmentRemark = '' |
|||
this.attachmentFileList = [] |
|||
this.$nextTick(() => { |
|||
if (this.$refs.attachmentUploadRef) { |
|||
this.$refs.attachmentUploadRef.clearFiles() |
|||
} |
|||
}) |
|||
}, |
|||
onAttachmentFileChange (file, fileList) { |
|||
this.attachmentFileList = fileList |
|||
}, |
|||
onAttachmentFileRemove (file, fileList) { |
|||
this.attachmentFileList = fileList |
|||
}, |
|||
submitAttachmentUpload () { |
|||
if (!this.attachmentFileList || this.attachmentFileList.length === 0) { |
|||
this.$message.warning('请选择附件') |
|||
return |
|||
} |
|||
this.attachmentUploadLoading = true |
|||
const formData = new FormData() |
|||
for (let i = 0; i < this.attachmentFileList.length; i++) { |
|||
formData.append('file', this.attachmentFileList[i].raw) |
|||
} |
|||
const queryParams = this.buildAttachmentQueryParams() |
|||
formData.append('orderRef1', queryParams.orderRef1) |
|||
formData.append('orderRef2', queryParams.orderRef2) |
|||
formData.append('orderRef3', queryParams.orderRef3) |
|||
formData.append('orderRef4', queryParams.orderRef4) |
|||
formData.append('createdBy', this.$store.state.user.name) |
|||
formData.append('CAdditionalInfo', this.attachmentRemark || '') |
|||
formData.append('orderReftype', queryParams.orderReftype) |
|||
ossUploadNoSaveOSSForYJY(formData).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
const uploadedRows = data.rows || [] |
|||
const uploadedIds = uploadedRows |
|||
.map(item => item.id) |
|||
.filter(item => item !== null && item !== undefined && item !== '') |
|||
this.attachmentRefIds = this.mergeAttachmentIds(this.attachmentRefIds, uploadedIds) |
|||
this.$message.success('上传成功') |
|||
this.attachmentUploadVisible = false |
|||
this.fetchAttachmentList() |
|||
} else { |
|||
this.$alert((data && data.msg) || '上传失败', '错误', { confirmButtonText: '确定' }) |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error('上传失败') |
|||
}).finally(() => { |
|||
this.attachmentUploadLoading = false |
|||
}) |
|||
}, |
|||
downloadAttachment (row) { |
|||
downLoadObjectFile(row).then(({ data }) => { |
|||
const blob = new Blob([data], { type: 'application/octet-stream;charset=utf-8' }) |
|||
const linkNode = document.createElement('a') |
|||
linkNode.download = row.fileName || 'download' |
|||
linkNode.style.display = 'none' |
|||
linkNode.href = URL.createObjectURL(blob) |
|||
document.body.appendChild(linkNode) |
|||
linkNode.click() |
|||
URL.revokeObjectURL(linkNode.href) |
|||
document.body.removeChild(linkNode) |
|||
}).catch(() => { |
|||
this.$message.error('下载失败') |
|||
}) |
|||
}, |
|||
mergeAttachmentIds (sourceIds, appendIds) { |
|||
const merged = [...(sourceIds || []), ...(appendIds || [])].map(item => String(item)) |
|||
return [...new Set(merged)] |
|||
}, |
|||
calcTextareaFollowGapStyle (rows) { |
|||
const rowCount = Number(rows) || 1 |
|||
const followGap = rowCount > 1 ? (rowCount - 1) * 20 : 0 |
|||
return { marginBottom: `${followGap}px` } |
|||
}, |
|||
buildAttachmentRefs () { |
|||
return (this.attachmentRefIds || []).join(',') |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
.supplier-part-tier-change .attachment-header { |
|||
margin-top: 12px; |
|||
margin-bottom: 8px; |
|||
display: flex; |
|||
justify-content: space-between; |
|||
align-items: center; |
|||
} |
|||
|
|||
.supplier-part-tier-change .tier-action-buttons { |
|||
display: flex; |
|||
align-items: center; |
|||
gap: 8px; |
|||
flex-wrap: nowrap; |
|||
} |
|||
|
|||
.supplier-part-tier-change /deep/ .rq .el-input-number .el-input__inner { |
|||
text-align: right; |
|||
padding-right: 5px !important; |
|||
} |
|||
|
|||
.supplier-part-tier-change /deep/ .rq .el-input .el-input--medium { |
|||
line-height: 20px; |
|||
} |
|||
|
|||
.supplier-part-tier-change /deep/ .rq .el-input-number .el-input--medium { |
|||
line-height: 20px; |
|||
} |
|||
|
|||
.rq .auto /deep/ .el-form-item__content { |
|||
height: auto; |
|||
line-height: 1.5; |
|||
} |
|||
|
|||
.supplier-part-tier-change /deep/ .optional-text .el-form-item__content { |
|||
height: auto; |
|||
line-height: 1.5; |
|||
} |
|||
|
|||
/* 阶梯价格变更(维护MOQ)弹窗:内容不超时自适应,超过时弹窗内部滚动 */ |
|||
.supplier-part-tier-change /deep/ .tier-change-dialog .el-dialog__body { |
|||
max-height: 560px; |
|||
overflow-y: auto; |
|||
} |
|||
</style> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue