Browse Source

阶梯价格变更弹窗:回车 = 新增梯度

QC人员排程页:20 天卡片 + 日期箭头工具条
订单查询页验货明细:跳转按订单类型分流
物料页价格表弹窗:新增「维护价格表」
master
qiankanghui 3 hours ago
parent
commit
3a8d90bff7
  1. 97
      src/views/modules/inspection/inspectionScheduleOverview.vue
  2. 18
      src/views/modules/order/com_inspectionDetailList.vue
  3. 8
      src/views/modules/qc/IQCResultEntry.vue
  4. 24
      src/views/modules/srmPart/partInfoList.vue
  5. 709
      src/views/modules/supplier/com_supplierPartTierChangeDialog.vue
  6. 8
      src/views/modules/supplier/supplierPartMoqPrice.vue

97
src/views/modules/inspection/inspectionScheduleOverview.vue

@ -3,19 +3,23 @@
<el-tabs v-model="activeTab" type="border-card" class="customer-tab" @tab-click="handleTabClick">
<!-- 页签一:所有QC人员排程情况 -->
<el-tab-pane label="QC排程情况" name="schedule">
<el-form :inline="true" size="small" class="all-qc-query-form">
<el-form-item label="起始日期">
<!-- 起始日期工具条:可选择日期 + 前后滚动(布局参照“我的待办”页面) -->
<div class="schedule-toolbar">
<span class="start-date-label">起始日期</span>
<div class="schedule-toolbar-row">
<el-button icon="el-icon-arrow-left" size="small" title="前一天" class="shift-btn shift-btn--left" @click="shiftStartDate(-1)" />
<el-date-picker
v-model="allQcQuery.startDate"
type="date"
size="small"
value-format="yyyy-MM-dd"
placeholder="请选择起始日期"
style="width: 150px;" />
</el-form-item>
<el-form-item label=" ">
<el-button type="primary" size="small" @click="queryAllQcSchedule">查询</el-button>
</el-form-item>
</el-form>
style="width: 150px;"
@change="handleStartDateChange" />
<el-button icon="el-icon-arrow-right" size="small" title="后一天" class="shift-btn shift-btn--right" @click="shiftStartDate(1)" />
<el-button size="small" type="text" @click="backToToday">回到今天</el-button>
</div>
</div>
<div class="all-qc-schedule-container" v-loading="allQcLoading">
<div class="schedule-days-grid">
<div v-for="day in allScheduleDays" :key="day.date" class="schedule-day-card">
@ -288,15 +292,30 @@ export default {
this.qcList = []
})
},
queryAllQcSchedule () {
if (!this.allQcQuery.startDate) {
// 起始日期前后滚动:每次移动 1 天并刷新查询显示
shiftStartDate (offsetDays) {
const base = this.parseDateString(this.allQcQuery.startDate) || new Date()
const next = new Date(base)
next.setDate(base.getDate() + offsetDays)
this.allQcQuery.startDate = this.formatDate(next)
this.loadAllQcSchedule()
},
// 手动选择起始日期后刷新查询
handleStartDateChange (val) {
if (!val) {
// 清空时回退到今天
this.allQcQuery.startDate = this.getTodayDateString()
}
this.loadAllQcSchedule()
},
// 回到今天并刷新
backToToday () {
this.allQcQuery.startDate = this.getTodayDateString()
this.loadAllQcSchedule()
},
loadAllQcSchedule () {
if (!this.qcList || this.qcList.length === 0) {
this.allScheduleDays = this.generateNextDays(10, this.allQcQuery.startDate)
this.allScheduleDays = this.generateNextDays(20, this.allQcQuery.startDate)
this.$message.warning('暂无QC人员数据')
return
}
@ -306,7 +325,7 @@ export default {
const promises = this.qcList.map(qc => {
return getScheduleView(qc.userName, startDate, this.$store.state.user.site).then(({ data }) => {
if (data.code === 0) {
const days = this.generateNextDays(10, startDate)
const days = this.generateNextDays(20, startDate)
const tasksByDate = {}
;(data.list || []).forEach(task => {
const taskStartDate = new Date(task.planStartDate)
@ -338,15 +357,15 @@ export default {
}))
return { userName: qc.userName, qcName: qc.qcName, scheduleDays }
}
return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(10, startDate) }
return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(20, startDate) }
}).catch(() => {
return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(10, startDate) }
return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(20, startDate) }
})
})
Promise.all(promises).then(results => {
const daysMap = {}
const baseDays = this.generateNextDays(10, startDate)
const baseDays = this.generateNextDays(20, startDate)
baseDays.forEach(day => {
daysMap[day.date] = {
date: day.date,
@ -539,9 +558,53 @@ export default {
}
/* ===== 页签一:所有QC排程 ===== */
.all-qc-query-form {
.schedule-toolbar {
display: flex;
flex-direction: column;
align-items: flex-start;
margin-bottom: 12px;
padding: 0 4px;
margin-bottom: 6px;
.start-date-label {
margin-bottom: 6px;
font-size: 14px;
color: #606266;
white-space: nowrap;
}
.schedule-toolbar-row {
display: flex;
align-items: center;
}
.shift-btn {
padding: 6px 10px;
color: #606266;
}
.shift-btn:hover {
color: #409eff;
background: #ecf5ff;
}
.shift-btn--left {
margin-right: 6px;
}
.shift-btn--right {
margin-left: 6px;
margin-right: 12px;
}
// 隐藏日期框内的前缀日历图标(保留右侧清空按钮),并收紧左侧内边距
// 注意:vue-loader 13 只认 /deep/,::v-deep 不生效
/deep/ .el-date-editor .el-input__icon.el-icon-date {
display: none;
}
/deep/ .el-date-editor .el-date-editor--date__inner {
padding-left: 15px;
}
}
.all-qc-schedule-container {

18
src/views/modules/order/com_inspectionDetailList.vue

@ -226,6 +226,22 @@ export default {
this.searchTable()
},
// 跳转目标路由名:按订单类型区分「采购单验货」/「打样单验货」(与 myInspectionList / mySampleInspectionList 一致),
// 两个路由由 sys_menu 动态注册,菜单还没配或本次登录前未注册时路由并不存在
// (vue-router 3.0 对不存在的 name 只静默告警、不会真的跳),故先做存在性探测,探不到就退回原「验货任务」页
resolveIqcEntryRouteName (orderType) {
const target = orderType === 'Sample' ? 'qc-IQCResultSampleEntry' : 'qc-IQCResultPoEntry'
try {
const matched = this.$router.match({ name: target })
if (matched && matched.matched && matched.matched.length > 0) {
return target
}
} catch (e) {
// 探测异常按原路由处理
}
return 'qc-IQCResultEntry'
},
jumpToInspection(row) {
const inspectionNo = row && row.inspectNo ? String(row.inspectNo).trim() : ''
if (!inspectionNo) {
@ -233,7 +249,7 @@ export default {
return
}
this.$router.push({
name: 'qc-IQCResultEntry',
name: this.resolveIqcEntryRouteName(row.orderType),
query: {
inspectionNo,
jumpMode: 'single'

8
src/views/modules/qc/IQCResultEntry.vue

@ -2754,11 +2754,13 @@
// 派生窗口(采购单验货 / 打样单验货 / 验货审核)的数据范围硬约束:
// 查询与导出两个出口都要调用,否则导出会绕过页面过滤把他人单子、打样单一并导出
applyPageScopeParams (queryParams) {
applyPageScopeParams (queryParams, options = {}) {
if (this.orderScope) {
queryParams.orderType = this.orderScope
}
if (this.qcOnly) {
// 精确单号跳转(如订单查询页验货明细「跳转」)是查看指定单据,不按登录 QC 隔离,
// 否则单据指派给其它 QC 时跳转过来会查不到;常规列表查询与导出仍按 qcOnly 隔离
if (this.qcOnly && !options.skipQcOnly) {
queryParams.qcOperatorAccount = this.searchData.userName || this.$store.state.user.name
}
if (this.auditMode) {
@ -2787,7 +2789,7 @@
this.searchData.page = this.pageIndex
queryParams = this.searchData
}
this.applyPageScopeParams(queryParams)
this.applyPageScopeParams(queryParams, { skipQcOnly: useTemporaryInspectionNo })
qcIQCInspectionSearch(queryParams).then(({data}) => {
if (data.code === 0) {
if (useTemporaryInspectionNo) {

24
src/views/modules/srmPart/partInfoList.vue

@ -177,10 +177,14 @@
<el-table-column prop="remark" label="备注" min-width="160" header-align="center" align="left" show-overflow-tooltip />
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="openTierChangeFromPriceDialog">维护价格表</el-button>
<el-button @click="priceDialogVisible = false">关闭</el-button>
</div>
</el-dialog>
<!-- 阶梯价格变更弹窗:与 supplierPartMoqPrice 页面「变更」弹窗功能一致,保存后刷新上方价格展示 -->
<SupplierPartTierChangeDialog ref="tierChangeDialog" @saved="handleTierChangeSaved" />
<!-- 产品编辑对话框 -->
<!-- 默认弹窗可拖动,特殊需求除外 - rqrq -->
<el-dialog :title="isAdd ? '新增产品' : '编辑产品'" :visible.sync="partDialogVisible" width="720px" top="3vh" :close-on-click-modal="false" class="part-dialog" v-drag>
@ -551,6 +555,7 @@ import suppliers from './com_part_Suppliers'
import approval from './com_part_Approval'
import attachments from './com_part_Attachments'
import PartAdvancedCopyDialog from './PartAdvancedCopyDialog'
import SupplierPartTierChangeDialog from '@/views/modules/supplier/com_supplierPartTierChangeDialog'
import {
approveNodeInstance,
@ -1174,6 +1179,7 @@ export default {
/* 组件 */
components: {
PartAdvancedCopyDialog,
SupplierPartTierChangeDialog,
Chooselist,
basicInfo,
specParams,
@ -1523,6 +1529,24 @@ export default {
this.priceDialogPartNo = ''
this.priceDialogSupplierNo = ''
},
// 价格表弹窗内「维护价格表」:打开与 supplierPartMoqPrice「变更」一致的阶梯价格变更弹窗
openTierChangeFromPriceDialog () {
if (!this.priceDialogSupplierNo || !this.priceDialogPartNo) {
this.$message.warning('缺少供应商或物料编码,无法维护价格表')
return
}
this.$refs.tierChangeDialog.open({
site: this.$store.state.user.site,
supplierCode: this.priceDialogSupplierNo,
partNo: this.priceDialogPartNo
})
},
// 阶梯价格变更保存成功后刷新价格表弹窗的当前生效阶梯价
handleTierChangeSaved ({ site, supplierCode, partNo }) {
if (this.priceDialogVisible) {
this.loadSupplierPartPriceDialog({ site, supplierCode, partNo })
}
},
openChangeDefaultSupplier (row) {
if (!row || !row.partNo) {
this.$message.warning('请先选择物料')

709
src/views/modules/supplier/com_supplierPartTierChangeDialog.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>

8
src/views/modules/supplier/supplierPartMoqPrice.vue

@ -316,6 +316,7 @@
:close-on-click-modal="false"
class="tier-change-dialog"
v-drag
@keyup.enter.native="onTierDialogEnter"
>
<el-form label-position="top" :model="tierForm">
<el-row :gutter="20">
@ -1104,6 +1105,13 @@ export default {
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)

Loading…
Cancel
Save