You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

2721 lines
102 KiB

<template>
<div class="customer-css" ref="pageRoot">
<!-- 查询时间和产品 -->
<el-form ref="searchForm" :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;" >
<el-row>
<el-col :span="24" style="">
<el-form-item :label="'产品编码:'">
<!-- <span style="cursor: pointer" slot="label" @click="getBaseList(520)"><a href="#">产品编码</a></span> -->
<el-input v-model="searchData.partNo" style="width: 130px"></el-input>
</el-form-item>
<el-form-item :label="'基准料号:'">
<el-input v-model="searchData.basePartNo" style="width: 130px"></el-input>
</el-form-item>
<!-- <el-form-item :label="'NPC货号:'">-->
<!-- <el-input v-model="searchData.npc" style="width: 130px"></el-input>-->
<!-- </el-form-item>-->
<el-form-item :label="'产品名称:'">
<el-input v-model="searchData.partDesc" style="width: 130px"></el-input>
</el-form-item>
<el-form-item :label="'Item:'">
<el-input v-model="searchData.item" style="width: 130px"></el-input>
</el-form-item>
<el-form-item :label="'SKU:'">
<el-input v-model="searchData.sku" style="width: 130px"></el-input>
</el-form-item>
<el-form-item>
<!-- 查询条件与验货申请页「供应商编码」一样可点标签开 Chooselist 520 选供应商;
选中后回填供应商简称(c_short_npc)展示,后端同一条件兼容按编码模糊查,输入框仍可手输回车查询 - rqrq -->
<span style="cursor: pointer" slot="label" @click="getBaseList(520, '', 'searchSupplier')"><a href="#">默认供应商:</a></span>
<el-input v-model="searchData.defaultSupplierNo" style="width: 130px" @keyup.enter.native="getMainData"></el-input>
</el-form-item>
<el-form-item :label="'一级分类:'">
<el-select v-model="searchData.category" clearable filterable style="width: 130px" @change="onSearchCategoryChange">
<el-option v-for="item in searchCategoryLevel1Options" :key="item.familyId"
:label="item.familyName" :value="item.familyId" />
</el-select>
</el-form-item>
<el-form-item :label="'二级分类:'">
<el-select v-model="searchData.categoryLevel2" clearable filterable style="width: 130px"
:disabled="!searchData.category" @change="onSearchCategoryLevel2Change">
<el-option v-for="item in searchCategoryLevel2Options" :key="item.familyId"
:label="item.familyName" :value="item.familyId" />
</el-select>
</el-form-item>
<el-form-item :label="'三级分类:'">
<el-select v-model="searchData.categoryLevel3" clearable filterable style="width: 130px"
:disabled="!searchData.categoryLevel2">
<el-option v-for="item in searchCategoryLevel3Options" :key="item.familyId"
:label="item.familyName" :value="item.familyId" />
</el-select>
</el-form-item>
<el-form-item :label="' '">
<el-button class="customer-bun-min" type="primary" @click="getMainData" style="">查询</el-button>
<el-button @click="addPart()" type="primary" style="margin-left: 2px">新增</el-button>
<!-- <el-button @click="openCopyDialog" type="primary" style="margin-left: 2px">复制</el-button>-->
<!-- 主表导出:风格与供应商列表一致,复用当前查询条件全量导出 - rqrq -->
<el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
<!-- 高级复制固定使用当前选中物料,保存后刷新主表及当前明细 - rqrq -->
<el-button @click="$refs.advancedCopyDialog.open(currentRow)" type="primary" style="margin-left: 2px">高级复制</el-button>
<!-- 按基准料号统一指定SKU - rqrq -->
<el-button @click="openSpecifySkuDialog" type="primary" style="margin-left: 2px">指定SKU</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-table
:height="height"
:data="mainDataList"
border
ref="mainTable"
highlight-current-row
@row-click="changeData"
v-loading="dataListLoading"
style="margin-top: 0px; width: 100%;">
<el-table-column
v-for="(item,index) in columnArray1" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed==''?false:item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden">{{
formatTableCell(item.columnProp, scope.row)
}}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
style="width: 100px; height: 100px"/></span>
</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column
fixed="right"
header-align="center"
align="center"
width="260"
label="操作">
<template slot-scope="scope">
<!-- <el-link style="cursor: pointer" v-if="scope.row.flowStatus === 'COMPLETED' || scope.row.flowStatus === 'TERMINATED'" @click="handleRestart(scope.row)">重新审批 |</el-link>
<el-link style="cursor: pointer" v-if="scope.row.flowStatus === 'RUNNING'" @click="openApproveDialog(scope.row)">审批 |</el-link> -->
<!-- <el-link style="cursor: pointer" v-if="scope.row.partStage === 'Created'" @click="startFormalApprove(scope.row)">转正 |</el-link>-->
<el-link style="cursor: pointer" @click="openCurrentRowPriceDialog(scope.row)">价格表 |</el-link>
<el-link style="cursor: pointer" @click="openChangeDefaultSupplier(scope.row)">变更默认供应商 |</el-link>
<el-link style="cursor: pointer" @click="editPart(scope.row)">编辑 |</el-link>
<el-link style="cursor: pointer" @click="deletePart(scope.row)">删除</el-link>
</template>
</el-table-column>
</el-table>
<!-- 分页插件 -->
<el-pagination ref="mainPagination" style="margin-top: 0px"
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<el-tabs ref="partTabs" v-model="activeName" style="margin-top: 0px; width: 99%;" @tab-click="tabClick" class="customer-tab" type="border-card">
<el-tab-pane label="基础信息" name="basicInfo" style="">
<basicInfo ref="basicInfo"></basicInfo>
</el-tab-pane>
<el-tab-pane label="规格参数" name="specParams" style="">
<specParams ref="specParams"></specParams>
</el-tab-pane>
<!-- <el-tab-pane label="关联供应商" name="suppliers" style="">-->
<!-- <suppliers ref="suppliers"></suppliers>-->
<!-- </el-tab-pane>-->
<!-- <el-tab-pane label="审批与放行" name="approval" style="">-->
<!-- <approval ref="approval"></approval>-->
<!-- </el-tab-pane>-->
<el-tab-pane label="附件" name="attachments" style="">
<attachments ref="attachments"></attachments>
</el-tab-pane>
</el-tabs>
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
<PartAdvancedCopyDialog ref="advancedCopyDialog" @copied="handleAdvancedCopyResult" />
<!--
供应商可供物料价格表弹窗(沿用 poOrder.vue 查看价格表实现)
用途:按默认供应商 + 物料编码查询当前生效阶梯价并展示
关联状态:
priceDialogVisible / priceDialogRows / priceDialogLoading
priceDialogPartNo / priceDialogSupplierNo
-->
<el-dialog
title="供应商可供物料价格表"
v-drag
:visible.sync="priceDialogVisible"
width="680px"
top="8vh"
append-to-body
:close-on-click-modal="false"
@closed="resetSupplierPartPriceDialog">
<div style="margin-bottom: 10px; color: #606266;">
<span>供应商:{{ priceDialogSupplierNo }}</span>
<span style="margin-left: 16px;">物料编码:{{ priceDialogPartNo }}</span>
</div>
<el-table
:data="priceDialogRows"
:height="360"
border
stripe
v-loading="priceDialogLoading"
empty-text="该供应商物料未维护价格表">
<el-table-column prop="qtyStart" label="数量起" min-width="100" header-align="center" align="center" />
<el-table-column label="数量止" min-width="100" header-align="center" align="center">
<template slot-scope="scope">{{ scope.row.qtyEnd === null || scope.row.qtyEnd === undefined || scope.row.qtyEnd === '' ? '∞' : scope.row.qtyEnd }}</template>
</el-table-column>
<el-table-column prop="unitPrice" label="单价" min-width="100" header-align="center" align="center" />
<el-table-column prop="priceDate" label="价格日期" min-width="120" header-align="center" align="center" />
<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>
<div class="dialog-content">
<el-form
:model="currentpart"
:rules="partRules"
ref="partForm"
label-position="top"
class="part-form">
<div class="form-section">
<el-row :gutter="24">
<el-col :span="6">
<el-form-item label="基准料号" prop="basePartNo" :required="isAdd">
<el-input v-model="currentpart.basePartNo" :disabled="!isAdd" @input="syncGeneratedPartNo" @blur="onBasePartNoBlur"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<!-- 后缀可不填,空值时产品编码直接使用基准料号 - rqrq -->
<el-form-item label="物料后缀" prop="partSuffix">
<el-input v-model="currentpart.partSuffix" :disabled="!isAdd" @input="syncGeneratedPartNo"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="产品编码" prop="partNo">
<el-input v-model="currentpart.partNo" disabled></el-input>
</el-form-item>
</el-col>
<!-- <el-col :span="6">-->
<!-- <el-form-item label="NPC货号" prop="npc">-->
<!-- <el-input v-model="currentpart.npc"></el-input>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
</el-row>
<el-row :gutter="24">
<el-col :span="6">
<el-form-item>
<span style="cursor: pointer" slot="label" @click="getBaseList(510)"><a href="#">计量单位</a></span>
<el-input v-model="currentpart.unit" ></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item prop="defaultSupplierNo" :required="isAdd">
<span style="cursor: pointer" slot="label" @click="getBaseList(520)"><a href="#">默认供应商</a></span>
<el-input v-model="currentpart.defaultSupplierNo" ></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="Item">
<el-input v-model="currentpart.item"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" v-if="showSkuInDialog && isAdd">
<el-form-item prop="sku">
<span style="cursor: pointer" slot="label" @click="getBaseList(508)"><a href="#">SKU</a></span>
<el-autocomplete
v-model="currentpart.sku"
:fetch-suggestions="querySkuSuggestions"
clearable
style="width: 100%"
placeholder="选择或输入SKU">
</el-autocomplete>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="6">
<el-form-item label="一级分类">
<el-select v-model="currentpart.category" clearable filterable style="width: 100%" @change="onPartCategoryChange">
<el-option v-for="item in categoryLevel1Options" :key="item.familyId"
:label="item.familyName" :value="item.familyId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="二级分类">
<el-select v-model="currentpart.categoryLevel2" clearable filterable style="width: 100%"
:disabled="!currentpart.category" @change="onPartCategoryLevel2Change">
<el-option v-for="item in categoryLevel2Options" :key="item.familyId"
:label="item.familyName" :value="item.familyId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="三级分类">
<el-select v-model="currentpart.categoryLevel3" clearable filterable style="width: 100%"
:disabled="!currentpart.categoryLevel2">
<el-option v-for="item in categoryLevel3Options" :key="item.familyId"
:label="item.familyName" :value="item.familyId" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="产品名称" prop="partDesc">
<el-input v-model="currentpart.partDesc"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="产品规格" prop="partSpec">
<el-input v-model="currentpart.partSpec" placeholder="无产品规格请保持N/A"></el-input>
</el-form-item>
</el-col>
</el-row>
</div>
<div class="form-section">
<el-row :gutter="24">
<el-col :span="6">
<el-form-item >
<span style="cursor: pointer" slot="label" @click="getBaseList(529)"><a href="#">采购员</a></span>
<el-input v-model="currentpart.buyerName" ></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item >
<span style="cursor: pointer" slot="label" @click="getBaseList(528)"><a href="#">sourcing专员</a></span>
<el-input v-model="currentpart.sourcingName" ></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="属性模板" prop="codeNo">
<el-select v-model="currentpart.codeNo" clearable filterable placeholder="请选择" style="width: 100%">
<el-option v-for="code in codeNoOptions" :key="code" :label="code" :value="code" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="是否在用">
<el-select v-model="currentpart.status" placeholder="请选择" >
<el-option label="在用" value="Y"></el-option>
<el-option label="禁用" value="N"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</div>
<div class="form-section">
<el-row :gutter="24">
<el-col :span="24">
<el-form-item label="备注">
<el-input v-model="currentpart.remark" type="textarea" :rows="2" resize="none" ></el-input>
</el-form-item>
</el-col>
</el-row>
</div>
</el-form>
</div>
<div slot="footer" class="dialog-footer" style="margin-top: 20px">
<el-button type="primary" @click="savePart()">保存</el-button>
<el-button @click="partDialogVisible = false">取消</el-button>
</div>
</el-dialog>
<el-dialog title="复制物料" :visible.sync="copyDialogVisible" width="520px" :close-on-click-modal="false" v-drag>
<el-form :model="copyForm" :rules="copyRules" ref="copyForm" label-position="top">
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="基准料号" prop="basePartNo">
<el-input v-model="copyForm.basePartNo"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料后缀" prop="partSuffix">
<el-input v-model="copyForm.partSuffix"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmCopyPart">确认</el-button>
<el-button @click="copyDialogVisible = false">取消</el-button>
</div>
</el-dialog>
<!-- 按基准料号统一指定SKU - rqrq -->
<el-dialog title="指定SKU" :visible.sync="specifySkuDialogVisible" width="460px" :close-on-click-modal="false" v-drag>
<el-form :model="specifySkuForm" label-position="top">
<el-form-item label="基准料号">
<el-input v-model="specifySkuForm.basePartNo" disabled></el-input>
</el-form-item>
<el-form-item>
<span style="cursor: pointer" slot="label" @click="openSpecifySkuPicker"><a href="#">SKU</a></span>
<el-input v-model="specifySkuForm.sku" placeholder="选择或输入SKU"></el-input>
</el-form-item>
<div style="color:#909399;font-size:12px;line-height:1.5">将把基准料号 {{ specifySkuForm.basePartNo }} 下所有物料的 SKU 统一修改为上述值。</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" :loading="specifySkuSaving" @click="confirmSpecifySku">确认</el-button>
<el-button @click="specifySkuDialogVisible = false">取消</el-button>
</div>
</el-dialog>
<el-dialog title="变更默认供应商" :visible.sync="changeSupplierDialogVisible" width="560px" :close-on-click-modal="false" v-drag>
<el-form :model="changeSupplierForm" label-position="top">
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="变更范围">
<el-select v-model="changeSupplierForm.changeMode" style="width: 100%">
<el-option label="按产品编码" value="PART_NO"></el-option>
<el-option label="按基准物料" value="BASE_PART"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="当前供应商编码">
<el-input v-model="changeSupplierForm.currentSupplierNo" disabled></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="24">
<el-form-item label="当前供应商描述">
<el-input v-model="changeSupplierForm.currentSupplierName" disabled></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="24">
<el-form-item>
<span style="cursor: pointer" slot="label" @click="getBaseList(520, '', 'changeSupplier')"><a href="#">目标供应商</a></span>
<el-input
v-model="changeSupplierForm.targetSupplierNo"
readonly
placeholder="请选择目标供应商"
@click.native="getBaseList(520, '', 'changeSupplier')">
<i slot="suffix" class="el-icon-search" style="cursor:pointer" @click.stop="getBaseList(520, '', 'changeSupplier')"></i>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" :loading="changeSupplierLoading" @click="confirmChangeDefaultSupplier">确认</el-button>
<el-button @click="changeSupplierDialogVisible = false">取消</el-button>
</div>
</el-dialog>
<!-- 审批对话框 - rqrq -->
<!-- <el-dialog
title="审批"
:visible.sync="approveDialogVisible"
width="550px"
:close-on-click-modal="false"
v-drag>
<el-form :model="approveData" label-position="top">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="是否特殊放行">
<el-select v-model="approveData.specialRelease" style="width: 100%">
<el-option label="否" value="N"></el-option>
<el-option label="是" value="Y"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="审批意见">
<el-input type="textarea" v-model="approveData.comment" :rows="3" placeholder="请输入审批意见"></el-input>
</el-form-item>
</el-form>
<el-footer style="height:40px;margin-top: 60px;text-align:center">
<el-button type="success" @click="submitApprove('APPROVED')" :loading="approveLoading">同意</el-button>
<el-button type="danger" @click="submitApprove('REJECTED')" :loading="approveLoading">驳回</el-button>
<el-button @click="approveDialogVisible = false" :disabled="approveLoading">取消</el-button>
</el-footer>
</el-dialog> -->
<!-- 新品流程确认三按钮弹窗:发起并审核 / 发起 / 取消 -->
<el-dialog
title="新品流程确认"
:visible.sync="newProductFlowDialogVisible"
width="440px"
:close-on-click-modal="false"
v-drag
append-to-body>
<div style="line-height: 1.6">供应商价格表中未找到该物料记录,是否产生供应商价格表(可供物料)并进入新品流程?</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmNewProductFlow(true)">发起并审核</el-button>
<el-button type="primary" plain @click="confirmNewProductFlow(false)">发起</el-button>
<el-button @click="cancelNewProductFlow">取消</el-button>
</div>
</el-dialog>
<!-- 新品登记审核弹窗:发起并审核后跳出,布局与 supplierPartNewProductAudit 页面的登记审核弹窗一致 -->
<el-dialog
title="登记审核"
:visible.sync="auditDialogVisible"
width="460px"
:close-on-click-modal="false"
v-drag
append-to-body>
<el-form :model="auditForm" class="rq" label-width="80px" label-position="top">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="部门" >
<el-select v-model="auditForm.deptType" disabled style="width: 100%">
<el-option label="采购部门" value="PURCHASE" />
<el-option label="质量部门" value="QUALITY" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="审核结论" required>
<el-select v-model="auditForm.auditResult" style="width: 100%">
<el-option label="同意" value="AGREE" />
<el-option label="不同意" value="REJECT" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="是否需要测试">
<el-checkbox v-model="auditForm.needTestFlag">需要测试</el-checkbox>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="审核人">
<el-input :value="currentLoginUser" disabled />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="审核意见" :style="calcTextareaFollowGapStyle(3)">
<el-input
v-model="auditForm.auditOpinion"
type="textarea"
resize="none"
:autosize="{ minRows: 3, maxRows: 3 }"
placeholder="可不填"
/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" :loading="auditSaveLoading" @click="submitPartNewProductAudit">确认</el-button>
<el-button :disabled="auditSaveLoading" @click="auditDialogVisible = false">取消</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
/* 组件 */
import {
searchPartList,
createPart,
updatePart,
copyPartByBase,
deletePart,
startPartFormalApprove,
changePartDefaultSupplier,
listSkuByBasePartNo,
updateSkuByBasePartNo,
checkSkuBasePartNo
} from '@/api/part/partInfo.js'
import { checkSupplierPartByItemSku, addSupplierPartMoq, listSupplierPartMoq } from '@/api/supplier/supplierPartMoqPrice'
import { listPoCurrentTierPrice } from '@/api/order/poOrder'
import { startNewProductAudit, listNewProductAuditRecord, submitNewProductAuditRecord } from '@/api/supplier/supplierPartNewProductAudit'
import excel from '@/utils/excel-util.js'
import { fetchSupplierDetail, resolveSupplierShortFieldsFromDetail } from '@/utils/supplierChooselistHelper'
import { getChooselistEam, getChooselistDataEam } from '@/api/chooselist/chooselist.js'
import Chooselist from '@/views/modules/common/Chooselist_eam'
import basicInfo from './com_part_BasicInfo'
import specParams from './com_part_SpecParams'
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,
restartFlowInstance
} from '@/api/workFlow/workFlow.js'
import { listPartFamilyByType } from '@/api/baseInformation/srmPartFamily.js'
import { refreshPropertiesModal as refreshPartPropertiesModal } from '@/api/part/partProperties.js'
export default {
watch: {
searchData: {
deep: true,
handler: function (newV, oldV) {
this.searchData.partNo = this.searchData.partNo.toUpperCase()
this.searchData.npc = this.searchData.npc.toUpperCase()
this.searchData.category = (this.searchData.category || '').toUpperCase()
this.searchData.categoryLevel2 = (this.searchData.categoryLevel2 || '').toUpperCase()
this.searchData.categoryLevel3 = (this.searchData.categoryLevel3 || '').toUpperCase()
this.searchData.unit = this.searchData.unit.toUpperCase()
this.searchData.codeNo = this.searchData.codeNo.toUpperCase()
this.searchData.partDesc = this.searchData.partDesc.toUpperCase()
this.searchData.partSpec = this.searchData.partSpec.toUpperCase()
this.searchData.basePartNo = (this.searchData.basePartNo || '').toUpperCase()
this.searchData.sku = (this.searchData.sku || '').toUpperCase()
this.searchData.item = (this.searchData.item || '').toUpperCase()
this.searchData.defaultSupplierNo = (this.searchData.defaultSupplierNo || '').toUpperCase()
}
},
currentpart: {
deep: true,
handler: function (newV, oldV) {
this.currentpart.partNo = this.currentpart.partNo.toUpperCase()
this.currentpart.npc = this.currentpart.npc.toUpperCase()
this.currentpart.category = (this.currentpart.category || '').toUpperCase()
this.currentpart.categoryLevel2 = (this.currentpart.categoryLevel2 || '').toUpperCase()
this.currentpart.categoryLevel3 = (this.currentpart.categoryLevel3 || '').toUpperCase()
this.currentpart.unit = this.currentpart.unit.toUpperCase()
this.currentpart.codeNo = (this.currentpart.codeNo || '').toUpperCase()
this.currentpart.partDesc = this.currentpart.partDesc.toUpperCase()
this.currentpart.partSpec = this.currentpart.partSpec.toUpperCase()
this.currentpart.basePartNo = (this.currentpart.basePartNo || '').toUpperCase()
this.currentpart.partSuffix = (this.currentpart.partSuffix || '').toUpperCase()
this.currentpart.sku = (this.currentpart.sku || '').toUpperCase()
this.currentpart.item = (this.currentpart.item || '').toUpperCase()
this.currentpart.defaultSupplierNo = (this.currentpart.defaultSupplierNo || '').toUpperCase()
if (this.isAdd) {
this.currentpart.partNo = this.generatePartNo(this.currentpart.basePartNo, this.currentpart.partSuffix)
}
}
}
},
computed: {
currentLoginUser () {
return this.$store.state.user.username || this.$store.state.user.name || ''
}
},
data () {
return {
functionId: this.$route.meta.menuId,
height: 200,
detailHeight: 320,
currentRow: {},
searchData: {
partNo: '',
basePartNo: '',
npc: '',
partDesc: '',
partSpec: '',
sku: '',
item: '',
defaultSupplierNo: '',
buyerName: '',
sourcingName: '',
category: '',
categoryLevel2: '',
categoryLevel3: '',
unit: '',
status: '',
codeNo: '',
createBy: '',
site: this.$store.state.user.site,
page: 1,
limit: 10
},
pageIndex: 1,
pageSize: 50,
totalPage: 0,
searchCategoryLevel1Options: [],
searchCategoryLevel2Options: [],
searchCategoryLevel3Options: [],
categoryLevel1Options: [],
categoryLevel2Options: [],
categoryLevel3Options: [],
// 属性模板下拉选项(来源与 Chooselist 527 同一数据源)
codeNoOptions: [],
tagNo: '',
mainDataList: [],
dataListLoading: false,
activeName: 'basicInfo',
// 审批对话框
approveDialogVisible: false,
approveLoading: false,
approveData: {
applyNo: '',
// nodeCode: '',
// nodeName: '',
// departmentName: '', // 审批部门 - rqrq
// assigneeName: '',
site: '',
orderType: '',
comment: '',
flowCode: '',
flowVersion: null
},
columnArray1: [
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTablePartNo',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'partNo',
headerAlign: 'center',
align: 'center',
columnLabel: '产品编码',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: true,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableBasePartNo',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'basePartNo',
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: 'partTableNpc',
// tableId: 'partTable',
// tableName: '产品信息',
// columnProp: 'npc',
// headerAlign: 'center',
// align: 'center',
// columnLabel: 'NPC货号',
// columnWidth: '100',
// columnHidden: false,
// columnImage: false,
// columnSortable: false,
// sortLv: 0,
// status: true,
// fixed: false
// },
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableItem',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'item',
headerAlign: 'center',
align: 'center',
columnLabel: 'Item',
columnWidth: '120',
columnHidden: false,
columnImage: false,
columnSortable: true,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableSku',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'sku',
headerAlign: 'center',
align: 'center',
columnLabel: 'SKU',
columnWidth: '120',
columnHidden: false,
columnImage: false,
columnSortable: true,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableDefaultSupplierNo',
tableId: 'partTable',
tableName: '产品信息',
// 默认供应商列改为展示供应商简称(后端未维护简称时回退供应商编码),导出共用该列配置 - rqrq
columnProp: 'defaultSupplierShortName',
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: 'partTablePartDesc',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'partDesc',
headerAlign: 'center',
align: 'left',
columnLabel: '产品名称',
columnWidth: '200',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTablepartSpec',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'partSpec',
headerAlign: 'center',
align: 'left',
columnLabel: '产品规格',
columnWidth: '150',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableBuyerName',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'buyerName',
headerAlign: 'center',
align: 'center',
columnLabel: '采购员',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableSourcingName',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'sourcingName',
headerAlign: 'center',
align: 'center',
columnLabel: 'sourcing专员',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableCategory',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'categoryName',
headerAlign: 'center',
align: 'center',
columnLabel: '一级分类',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableCategoryLevel2',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'categoryLevel2Name',
headerAlign: 'center',
align: 'center',
columnLabel: '二级分类',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableCategoryLevel3',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'categoryLevel3Name',
headerAlign: 'center',
align: 'center',
columnLabel: '三级分类',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableUnit',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'unit',
headerAlign: 'center',
align: 'center',
columnLabel: '计量单位',
columnWidth: '80',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTablePartStage',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'partStage',
headerAlign: 'center',
align: 'center',
columnLabel: '物料阶段',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableStatus',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'status',
headerAlign: 'center',
align: 'center',
columnLabel: '是否在用',
columnWidth: '80',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableCodeNo',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'codeNo',
headerAlign: 'center',
align: 'center',
columnLabel: '属性模板',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableCreateBy',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'createBy',
headerAlign: 'center',
align: 'center',
columnLabel: '创建人',
columnWidth: '100',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.functionId,
serialNumber: 'partTableCreateDate',
tableId: 'partTable',
tableName: '产品信息',
columnProp: 'createDate',
headerAlign: 'center',
align: 'center',
columnLabel: '创建时间',
columnWidth: '150',
columnHidden: false,
columnImage: false,
columnSortable: true,
sortLv: 0,
status: true,
fixed: false
}
// {
// userId: this.$store.state.user.name,
// functionId: this.functionId,
// serialNumber: 'partTableDepartmentName',
// tableId: 'partTable',
// tableName: '产品信息',
// columnProp: 'departmentName',
// headerAlign: 'center',
// align: 'center',
// columnLabel: '审批部门',
// columnWidth: '100',
// columnHidden: false,
// columnImage: false,
// columnSortable: false,
// sortLv: 0,
// status: true,
// fixed: false
// },
// {
// userId: this.$store.state.user.name,
// functionId: this.functionId,
// serialNumber: 'partTableApproverName',
// tableId: 'partTable',
// tableName: '产品信息',
// columnProp: 'assigneeName',
// headerAlign: 'center',
// align: 'center',
// columnLabel: '要求审批人',
// columnWidth: '100',
// columnHidden: false,
// columnImage: false,
// columnSortable: false,
// sortLv: 0,
// status: true,
// fixed: false
// },
// {
// userId: this.$store.state.user.name,
// functionId: this.functionId,
// serialNumber: 'partTableFlowStatus',
// tableId: 'partTable',
// tableName: '产品信息',
// columnProp: 'flowStatus',
// headerAlign: 'center',
// align: 'center',
// columnLabel: '审批状态',
// columnWidth: '100',
// columnHidden: false,
// columnImage: false,
// columnSortable: false,
// sortLv: 0,
// status: true,
// fixed: false
// }
],
exportName: '产品信息' + this.dayjs().format('YYYYMMDDHHmmss'),
// 供应商可供物料价格表弹窗状态 - rqrq
priceDialogVisible: false,
priceDialogLoading: false,
priceDialogRows: [],
priceDialogPartNo: '',
priceDialogSupplierNo: '',
// 产品对话框相关
partDialogVisible: false,
isAdd: true,
skuOptions: [],
currentpart: {
partNo: '',
basePartNo: '',
partSuffix: '',
npc: '',
partDesc: '',
partSpec: '',
sku: '',
item: '',
defaultSupplierNo: '',
buyerName: '',
sourcingName: '',
category: '',
categoryLevel2: '',
categoryLevel3: '',
unit: '',
status: 'Y',
codeNo: '',
createBy: '',
remark: '',
site: this.$store.state.user.site,
},
partRules: {
partSpec: [
{ required: true, message: ' ', trigger: 'blur' }
],
npc: [
{ required: true, message: ' ', trigger: 'blur' }
],
codeNo: [
{ required: true, message: ' ', trigger: 'blur' }
],
sku: [
{
validator: (rule, value, callback) => {
// 新增时单向强校验:填了 Item 就必须填 SKU;只填 SKU 时 Item 仍可留空
// 编辑态不强制,避免历史“有 Item 无 SKU”的数据无法保存
if (this.isAdd && String(this.currentpart.item || '').trim() && !String(value || '').trim()) {
callback(new Error('填写 Item 后必须填写 SKU'))
return
}
callback()
},
trigger: ['blur', 'change']
}
]
},
copyDialogVisible: false,
// 新品流程三按钮确认与登记审核弹窗
newProductFlowDialogVisible: false,
auditDialogVisible: false,
auditSaveLoading: false,
auditForm: {
id: null,
site: '',
supplierCode: '',
partNo: '',
auditRoundNo: null,
deptType: 'PURCHASE',
auditResult: '',
needTestFlag: false,
auditOpinion: ''
},
copyForm: {
basePartNo: '',
partSuffix: ''
},
// 编辑/新增弹窗中展示 SKU 字段(与“指定SKU”按钮批量维护并存),不需要时改为 false
showSkuInDialog: true,
// 指定SKU弹窗
specifySkuDialogVisible: false,
specifySkuSaving: false,
specifySkuForm: {
site: '',
basePartNo: '',
sku: ''
},
changeSupplierDialogVisible: false,
changeSupplierLoading: false,
changeSupplierForm: {
changeMode: 'PART_NO',
partNo: '',
basePartNo: '',
currentSupplierNo: '',
currentSupplierName: '',
targetSupplierNo: '',
targetSupplierName: ''
},
basePickScene: '',
copyRules: {
basePartNo: [
{ required: true, message: '请输入基准料号', trigger: 'blur' }
]
}
}
},
/* 组件 */
components: {
PartAdvancedCopyDialog,
SupplierPartTierChangeDialog,
Chooselist,
basicInfo,
specParams,
suppliers,
approval,
attachments
},
created() {
this.loadSearchCategoryLevel1()
this.getMainData()
},
mounted () {
this.handleResize()
window.addEventListener('resize', this.handleResize)
this.loadCodeNoOptions()
},
beforeDestroy () {
window.removeEventListener('resize', this.handleResize)
},
methods: {
getOuterHeight (el) {
if (!el) return 0
const rect = el.getBoundingClientRect()
const style = window.getComputedStyle(el)
return rect.height + (parseFloat(style.marginTop) || 0) + (parseFloat(style.marginBottom) || 0)
},
handleResize () {
this.$nextTick(() => {
const rootEl = this.$refs.pageRoot || this.$el
if (!rootEl) return
const searchFormEl = this.$refs.searchForm && this.$refs.searchForm.$el
? this.$refs.searchForm.$el
: this.$refs.searchForm
const paginationEl = this.$refs.mainPagination && this.$refs.mainPagination.$el
? this.$refs.mainPagination.$el
: this.$refs.mainPagination
const tabsEl = this.$refs.partTabs && this.$refs.partTabs.$el
? this.$refs.partTabs.$el
: this.$refs.partTabs
const tabsHeaderEl = tabsEl ? tabsEl.querySelector('.el-tabs__header') : null
const viewportBottomGap = 24
const pageTop = rootEl.getBoundingClientRect().top
const availableViewportHeight = window.innerHeight - pageTop - viewportBottomGap
const fixedBlockHeight = this.getOuterHeight(searchFormEl) + this.getOuterHeight(paginationEl) + this.getOuterHeight(tabsHeaderEl) + 22
const splitAvailable = availableViewportHeight - fixedBlockHeight
if (!Number.isFinite(splitAvailable) || splitAvailable <= 0) return
let mainTableHeight
let detailHeight
if (splitAvailable < 520) {
mainTableHeight = Math.max(180, Math.floor(splitAvailable * 0.45))
detailHeight = Math.max(220, splitAvailable - mainTableHeight)
} else {
mainTableHeight = Math.max(220, Math.floor(splitAvailable * 0.42))
detailHeight = splitAvailable - mainTableHeight
if (detailHeight < 320) {
detailHeight = 320
mainTableHeight = Math.max(200, splitAvailable - detailHeight)
}
}
this.height = mainTableHeight
this.detailHeight = detailHeight
this.applyCurrentTabHeight()
this.$nextTick(() => {
if (this.$refs.mainTable && this.$refs.mainTable.doLayout) {
this.$refs.mainTable.doLayout()
}
})
})
},
getBasicTabHeight () {
return Math.max(Number(this.height) - 20, 180)
},
getDetailTabHeight (offset = 0) {
return Math.max(Number(this.detailHeight) - Number(offset || 0), 220)
},
applyCurrentTabHeight () {
if (this.$refs.basicInfo && this.$refs.basicInfo.searchData) {
this.$refs.basicInfo.searchData.height = this.getBasicTabHeight()
}
if (this.$refs.specParams && this.$refs.specParams.setTableHeight) {
this.$refs.specParams.setTableHeight(this.getDetailTabHeight(70))
}
if (this.$refs.suppliers && this.$refs.suppliers.setTableHeight) {
this.$refs.suppliers.setTableHeight(this.getDetailTabHeight(90))
}
if (this.$refs.approval && this.$refs.approval.setTableHeight) {
this.$refs.approval.setTableHeight(this.getDetailTabHeight(30))
}
if (this.$refs.attachments && this.$refs.attachments.setTableHeight) {
this.$refs.attachments.setTableHeight(this.getDetailTabHeight(90))
}
},
formatPartStageDesc (partStage) {
if (partStage === 'Approved') {
return '正式物料'
}
if (partStage === 'Approving') {
return '转正审批中'
}
return '新增物料'
},
formatTableCell (columnProp, row) {
if (columnProp === 'partStage') {
return this.formatPartStageDesc(row.partStage)
}
if (columnProp === 'status') {
return row.status === 'Y' ? '在用' : row.status === 'N' ? '禁用' : row.status
}
if (columnProp === 'categoryName') {
return row.categoryName || row.category || ''
}
if (columnProp === 'categoryLevel2Name') {
return row.categoryLevel2Name || row.categoryLevel2 || ''
}
if (columnProp === 'categoryLevel3Name') {
return row.categoryLevel3Name || row.categoryLevel3 || ''
}
return row[columnProp]
},
// 新增和原有复制共用规则:后缀允许包含 '-',为空时直接使用基准料号 - rqrq
generatePartNo (basePartNo, partSuffix) {
const base = (basePartNo || '').trim().toUpperCase()
const suffix = (partSuffix || '').trim().toUpperCase()
if (!base) {
return ''
}
return suffix ? `${base}-${suffix}` : base
},
syncGeneratedPartNo () {
if (!this.isAdd) return
this.currentpart.partNo = this.generatePartNo(this.currentpart.basePartNo, this.currentpart.partSuffix)
},
// 基准料号失焦:查询该基准料号下已维护过的SKU,作为SKU联想建议(仍允许输入不存在的SKU)
onBasePartNoBlur () {
if (!this.isAdd) return
const basePartNo = (this.currentpart.basePartNo || '').trim().toUpperCase()
if (!basePartNo) {
this.skuOptions = []
return
}
const site = (this.$store.state.user.site || '').trim().toUpperCase()
// 当前SKU为空、或是上一次自动带出/联想列表中的值时,才允许被新的第一个覆盖,避免冲掉用户手动录入的自定义SKU
const prevOptions = this.skuOptions || []
const curSku = this.currentpart.sku
const canOverwrite = !curSku || prevOptions.indexOf(curSku) !== -1
listSkuByBasePartNo({ site, basePartNo }).then(({ data }) => {
const rows = (data && data.code === 0 && data.rows) ? data.rows : []
this.skuOptions = rows
// 默认选中第一个自动赋值给SKU输入框
if (rows.length && canOverwrite) {
this.currentpart.sku = rows[0]
// 程序赋值不触发输入框校验,重算一次避免旧的报错残留(未带出值时不主动校验,防止提前抛错)
if (this.showSkuInDialog && this.isAdd && this.$refs.partForm) {
this.$refs.partForm.validateField('sku')
}
}
}).catch(() => {
this.skuOptions = []
})
},
// SKU 联想:从已维护的 skuOptions 中前缀/包含匹配,无匹配时也允许直接录入
querySkuSuggestions (queryString, cb) {
const list = this.skuOptions || []
const kw = (queryString || '').trim().toUpperCase()
const results = kw ? list.filter(item => (item || '').toUpperCase().indexOf(kw) !== -1) : list
cb(results.map(item => ({ value: item })))
},
extractBasePartNo (partNo) {
const value = (partNo || '').trim().toUpperCase()
if (!value) return ''
const index = value.indexOf('-')
return index > 0 ? value.substring(0, index) : value
},
// 以已存基准料号为边界提取完整后缀;基准为空或与编码不匹配时留空,避免按首个 '-' 误拆 - rqrq。
extractPartSuffix (partNo, basePartNo) {
const value = (partNo || '').trim().toUpperCase()
const base = (basePartNo || '').trim().toUpperCase()
return base && value.indexOf(`${base}-`) === 0 ? value.substring(base.length + 1) : ''
},
openCopyDialog () {
const selectedBasePartNo = (this.currentRow && this.currentRow.basePartNo) ? this.currentRow.basePartNo : ''
this.copyForm = {
// 复制弹窗默认带出当前选中行基准料号 - rqrq
basePartNo: (selectedBasePartNo || '').trim().toUpperCase(),
partSuffix: ''
}
this.copyDialogVisible = true
this.$nextTick(() => {
if (this.$refs.copyForm) {
this.$refs.copyForm.clearValidate()
}
})
},
confirmCopyPart () {
this.$refs.copyForm.validate((valid) => {
if (!valid) return
const basePartNo = (this.copyForm.basePartNo || '').trim().toUpperCase()
const partSuffix = (this.copyForm.partSuffix || '').trim().toUpperCase()
// 后缀内的 '-' 属于编码内容,只校验拼接后的完整编码长度 - rqrq。
if (this.generatePartNo(basePartNo, partSuffix).length > 30) {
this.$message.warning('产品编码不能超过30个字符')
return
}
copyPartByBase({
site: this.$store.state.user.site,
basePartNo,
partSuffix
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success(`复制成功,新产品编码:${data.partNo || this.generatePartNo(basePartNo, partSuffix)}`)
this.copyDialogVisible = false
this.getMainData()
return
}
this.$message.error((data && data.msg) || '复制失败')
}).catch(error => {
this.$message.error('复制失败: ' + error.message)
})
})
},
// 打开“指定SKU”弹窗:默认带入当前选中行的基准料号与SKU
openSpecifySkuDialog () {
const row = this.currentRow
if (!row || !row.partNo) {
this.$message.warning('请先选择一条物料')
return
}
let basePartNo = (row.basePartNo || '').trim().toUpperCase()
if (!basePartNo) {
basePartNo = this.extractBasePartNo(row.partNo)
}
if (!basePartNo) {
this.$message.warning('未找到基准料号,无法指定SKU')
return
}
this.specifySkuForm = {
site: this.$store.state.user.site,
basePartNo: basePartNo,
sku: (row.sku || '').trim().toUpperCase()
}
this.specifySkuDialogVisible = true
},
// 指定SKU弹窗中的SKU选择器(Chooselist 508)
openSpecifySkuPicker () {
this.tagNo = 508
this.basePickScene = 'specifySku'
this.$nextTick(() => {
this.$refs.baseList.init(508, this.specifySkuForm.sku || '')
})
},
// 确认指定:按基准料号统一修改SKU
confirmSpecifySku () {
const sku = (this.specifySkuForm.sku || '').trim().toUpperCase()
if (!sku) {
this.$message.warning('请选择或输入SKU')
return
}
this.$confirm(`确认将基准料号 ${this.specifySkuForm.basePartNo} 下所有物料的SKU统一修改为 ${sku}?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 与新增弹窗同一套 SKU 与基准料号一一对应校验,冲突时不执行指定
this.doSkuBasePartNoCheck(this.specifySkuForm.site, sku, this.specifySkuForm.basePartNo, true).then(pass => {
if (!pass) return
this.execUpdateSkuByBasePartNo(sku)
})
}).catch(() => {})
},
// 执行按基准料号统一修改SKU并刷新列表
execUpdateSkuByBasePartNo (sku) {
this.specifySkuSaving = true
updateSkuByBasePartNo({
site: this.specifySkuForm.site,
basePartNo: this.specifySkuForm.basePartNo,
sku
}).then(({ data }) => {
this.specifySkuSaving = false
if (data && data.code === 0) {
const updatedCount = data.updatedCount || 0
this.$message.success(updatedCount > 0 ? `指定成功,共更新 ${updatedCount} 条物料` : '该基准料号下物料SKU已是最新,已同步SKU对照表')
this.specifySkuDialogVisible = false
this.getMainData()
} else {
this.$message.error((data && data.msg) || '指定SKU失败')
}
}).catch(error => {
this.specifySkuSaving = false
this.$message.error('指定SKU失败: ' + error.message)
})
},
// 查看当前物料价格表:按默认供应商 + 物料编码查当前生效阶梯价(同 poOrder.vue) - rqrq
openCurrentRowPriceDialog (row) {
if (!row || !row.partNo) {
this.$message.warning('请先选择一行数据')
return
}
const site = String(row.site || this.$store.state.user.site || '').trim()
const supplierCode = String(row.defaultSupplierNo || row.supplierNo || '').trim()
const partNo = String(row.partNo || '').trim()
if (!site || !supplierCode || !partNo) {
this.$message.warning('当前行缺少供应商或物料编码,无法查询价格')
return
}
this.loadSupplierPartPriceDialog({ site, supplierCode, partNo })
},
// 共用的阶梯价加载:拉取当前生效阶梯价并渲染到价格弹窗
loadSupplierPartPriceDialog ({ site, supplierCode, partNo }) {
this.priceDialogPartNo = partNo
this.priceDialogSupplierNo = supplierCode
this.priceDialogRows = []
this.priceDialogVisible = true
this.priceDialogLoading = true
listPoCurrentTierPrice({
site,
supplierCode,
partNo
}).then(({ data }) => {
if (data && data.code === 0) {
this.priceDialogRows = (data.rows || []).map(item => ({
qtyStart: (item.qtyStart === null || item.qtyStart === undefined) ? '' : item.qtyStart,
qtyEnd: (item.qtyEnd === null || item.qtyEnd === undefined) ? '' : item.qtyEnd,
unitPrice: (item.unitPrice === null || item.unitPrice === undefined) ? '' : item.unitPrice,
priceDate: item.priceDate || '',
remark: item.remark || ''
}))
return
}
this.priceDialogRows = []
this.$message.error((data && data.msg) || '获取供应商价格表失败')
}).catch(() => {
this.priceDialogRows = []
this.$message.error('获取供应商价格表失败')
}).finally(() => {
this.priceDialogLoading = false
})
},
resetSupplierPartPriceDialog () {
this.priceDialogLoading = false
this.priceDialogRows = []
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('请先选择物料')
return
}
this.changeSupplierForm = {
changeMode: 'PART_NO',
partNo: (row.partNo || '').trim().toUpperCase(),
basePartNo: (row.basePartNo || '').trim().toUpperCase(),
currentSupplierNo: (row.defaultSupplierNo || '').trim().toUpperCase(),
currentSupplierName: row.defaultSupplierName || '',
targetSupplierNo: '',
targetSupplierName: ''
}
this.changeSupplierDialogVisible = true
},
confirmChangeDefaultSupplier () {
const targetSupplierNo = (this.changeSupplierForm.targetSupplierNo || '').trim().toUpperCase()
const currentSupplierNo = (this.changeSupplierForm.currentSupplierNo || '').trim().toUpperCase()
if (!targetSupplierNo) {
this.$message.warning('目标供应商不能为空')
return
}
if (targetSupplierNo === currentSupplierNo) {
this.$message.warning('目标供应商不能与当前供应商相同')
return
}
const payload = {
site: this.$store.state.user.site,
partNo: this.changeSupplierForm.partNo,
changeMode: this.changeSupplierForm.changeMode,
targetSupplierNo
}
this.changeSupplierLoading = true
changePartDefaultSupplier(payload).then(({ data }) => {
if (data && data.code === 0) {
const updatedCount = data.updatedCount || 0
this.$message.success(`变更成功,影响 ${updatedCount} 条物料`)
this.changeSupplierDialogVisible = false
this.getMainData()
return
}
this.$message.error((data && data.msg) || '变更失败')
}).catch(error => {
this.$message.error('变更失败: ' + error.message)
}).finally(() => {
this.changeSupplierLoading = false
})
},
startFormalApprove (row) {
if (!row || !row.partNo) {
this.$message.warning('未找到有效产品编码')
return
}
// 新增物料阶段手动发起转正审批 - rqrq
this.$confirm('确认发起该物料的转正流程吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let inData = {
site: this.$store.state.user.site,
partNo: row.partNo
}
startPartFormalApprove(inData).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success(data.msg || '操作成功')
this.getMainData()
return
}
this.$message.error((data && data.msg) || '发起转正失败')
}).catch(error => {
this.$message.error('发起转正失败: ' + error.message)
})
}).catch(() => {})
},
fetchPartFamilyOptions (familyType, parentPartFamily) {
return listPartFamilyByType({
site: this.$store.state.user.site,
familyType,
parentPartFamily: parentPartFamily || '',
active: 'Y'
}).then(({ data }) => {
if (data && data.code === 0) {
return data.list || []
}
return []
}).catch(() => [])
},
loadSearchCategoryLevel1 () {
this.fetchPartFamilyOptions('level1').then(list => {
this.searchCategoryLevel1Options = list
})
},
onSearchCategoryChange () {
this.searchData.categoryLevel2 = ''
this.searchData.categoryLevel3 = ''
this.searchCategoryLevel2Options = []
this.searchCategoryLevel3Options = []
if (!this.searchData.category) return
this.fetchPartFamilyOptions('level2', this.searchData.category).then(list => {
this.searchCategoryLevel2Options = list
})
},
onSearchCategoryLevel2Change () {
this.searchData.categoryLevel3 = ''
this.searchCategoryLevel3Options = []
if (!this.searchData.categoryLevel2) return
this.fetchPartFamilyOptions('level3', this.searchData.categoryLevel2).then(list => {
this.searchCategoryLevel3Options = list
})
},
loadPartCategoryLevel1 () {
return this.fetchPartFamilyOptions('level1').then(list => {
this.categoryLevel1Options = list
})
},
loadPartCategoryLevel2 (keepValues) {
if (!this.currentpart.category) {
this.categoryLevel2Options = []
if (!keepValues) {
this.currentpart.categoryLevel2 = ''
this.currentpart.categoryLevel3 = ''
this.categoryLevel3Options = []
}
return Promise.resolve()
}
return this.fetchPartFamilyOptions('level2', this.currentpart.category).then(list => {
this.categoryLevel2Options = list
if (!keepValues) {
this.currentpart.categoryLevel2 = ''
this.currentpart.categoryLevel3 = ''
this.categoryLevel3Options = []
}
})
},
loadPartCategoryLevel3 (keepValues) {
if (!this.currentpart.categoryLevel2) {
this.categoryLevel3Options = []
if (!keepValues) {
this.currentpart.categoryLevel3 = ''
}
return Promise.resolve()
}
return this.fetchPartFamilyOptions('level3', this.currentpart.categoryLevel2).then(list => {
this.categoryLevel3Options = list
if (!keepValues) {
this.currentpart.categoryLevel3 = ''
}
})
},
onPartCategoryChange () {
this.loadPartCategoryLevel2(false)
},
onPartCategoryLevel2Change () {
this.loadPartCategoryLevel3(false)
},
initPartCategoryOptions (keepValues) {
return this.loadPartCategoryLevel1().then(() => {
return this.loadPartCategoryLevel2(keepValues).then(() => {
return this.loadPartCategoryLevel3(keepValues)
})
})
},
// 加载属性模板下拉选项:复用 Chooselist 527 的配置数据源,按当前站点过滤取全量 code_no
loadCodeNoOptions () {
const currentSite = (this.$store.state.user.site || '').trim()
getChooselistEam({ tagNo: 527 }).then(({ data }) => {
const config = data && data.data
if (!config || !config.sqlcode) {
this.codeNoOptions = []
return
}
let sql = config.sqlcode
if (currentSite) {
sql += " and site = '" + currentSite + "' "
}
getChooselistDataEam({ sqlcode: sql }).then(({ data: res }) => {
if (res.code === 0) {
const rows = res.baseListData || []
const codes = rows.map(r => r.code_no).filter(v => v !== null && v !== undefined && v !== '')
this.codeNoOptions = Array.from(new Set(codes))
} else {
this.codeNoOptions = []
}
})
})
},
getBaseList (val, type, scene) {
this.tagNo = val
this.basePickScene = scene || ''
this.$nextTick(() => {
let strVal = ''
let conSql = ''
if (this.tagNo === 510) {
strVal = this.currentpart.unit
}
if (val === 508) {
strVal = this.currentpart.sku
}
if (val === 529) {
strVal = this.currentpart.buyerName
}
if (val === 528) {
strVal = this.currentpart.sourcingName
}
if (val === 527) {
strVal = this.currentpart.codeNo
}
if (val === 520) {
strVal = this.currentpart.defaultSupplierNo
}
if (val === 520 && this.basePickScene === 'changeSupplier') {
strVal = this.changeSupplierForm.targetSupplierNo
}
// 查询条件场景:按站点过滤(与验货申请页一致);520 只按编码/全称匹配,而查询框里可能是回填的
// 简称,预填会把列表筛空,因此不预填,需要时可在弹窗内的条件框手动筛 - rqrq
if (val === 520 && this.basePickScene === 'searchSupplier') {
strVal = ''
conSql = " and site = '" + this.$store.state.user.site + "'"
}
this.$refs.baseList.init(val, strVal?strVal:'', conSql)
})
},
/* 列表方法的回调 */
getBaseData (val) {
if (this.tagNo === 510) {
this.currentpart.unit = val.UMID
}
if (this.tagNo === 508) {
if (this.basePickScene === 'specifySku') {
this.specifySkuForm.sku = val.sku || val.SKU || ''
// 选择SKU后直接执行指定并刷新页面
this.confirmSpecifySku()
} else {
this.currentpart.sku = val.sku
// 选择器回填为程序赋值,不会触发输入框 change/blur,此处主动重算 SKU 校验,避免旧的「必须填写 SKU」报错残留
if (this.showSkuInDialog && this.isAdd && this.$refs.partForm) {
this.$refs.partForm.validateField('sku')
}
}
}
if (this.tagNo === 529) {
this.currentpart.buyerName = val.UserName
}
if (this.tagNo === 528) {
this.currentpart.sourcingName = val.UserName
}
if (this.tagNo === 527) {
this.currentpart.codeNo = val.code_no
}
if (this.tagNo === 520) {
if (this.basePickScene === 'searchSupplier') {
// 查询条件按业务约定展示供应商简称:520 只返回编码与全称,需回查主数据取 c_short_npc;
// 先回填编码保证无简称时仍有可用筛选值,也不写 currentpart,避免把查询值带进新增/编辑表单 - rqrq
const supplierNo = (val.supplier_no || val.supplierNo || '').trim().toUpperCase()
this.searchData.defaultSupplierNo = supplierNo
if (supplierNo) {
fetchSupplierDetail(supplierNo, this.$store.state.user.site).then(detail => {
const { shortNpc } = resolveSupplierShortFieldsFromDetail(detail)
// 仅当期间用户没改动查询框时才把编码换成简称,避免异步回包覆盖手动输入
if (shortNpc && this.searchData.defaultSupplierNo === supplierNo) {
this.searchData.defaultSupplierNo = shortNpc
}
})
}
} else {
this.currentpart.defaultSupplierNo = val.supplier_no || ''
}
}
if (this.tagNo === 520 && this.basePickScene === 'changeSupplier') {
const supplierNo = val.supplier_no || ''
const supplierName = val.supplier_name || ''
this.changeSupplierForm.targetSupplierNo = (supplierNo || '').trim().toUpperCase()
this.changeSupplierForm.targetSupplierName = supplierName || ''
}
this.basePickScene = ''
},
getMainData () {
this.searchData.limit = this.pageSize
this.searchData.page = this.pageIndex
searchPartList(this.searchData).then(({data}) => {
if (data.code === 0) {
// 处理列表数据,确保可以正确显示嵌套属性
this.mainDataList = data.page.list.map(item => {
// 方式1:将嵌套属性提取到顶层
if (item.flowNodeInstanceData) {
item.departmentName = item.flowNodeInstanceData.departmentName;
item.assigneeName = item.flowNodeInstanceData.assigneeName;
} else {
item.departmentName = '';
item.assigneeName = '';
}
return item;
});
// this.mainDataList = data.page.list
this.pageIndex = data.page.currPage
this.pageSize = data.page.pageSize
this.totalPage = data.page.totalCount
// 判断是否全部存在数据
if (this.mainDataList.length > 0) {
// 设置选中行
this.$refs.mainTable.setCurrentRow(this.mainDataList[0])
this.changeData(this.mainDataList[0])
} else {
this.changeData(null)
}
}
this.dataListLoading = false
})
},
tabClick (tab, event) {
this.refreshCurrentTabTable()
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getMainData()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getMainData()
},
changeData (row) {
this.currentRow = JSON.parse(JSON.stringify(row))
this.refreshCurrentTabTable()
},
refreshCurrentTabTable () {
if (this.currentRow === '' || this.currentRow === null) {
this.currentRow = {site: '', partNo: ''}
}
if (this.activeName === 'basicInfo') {
this.refreshBasicInfo()
}
if (this.activeName === 'specParams') {
this.refreshSpecParams()
}
if (this.activeName === 'suppliers') {
this.refreshSuppliers()
}
if (this.activeName === 'approval') {
this.refreshApproval()
}
if (this.activeName === 'attachments') {
this.refreshAttachments()
}
},
/**
* 主表导出。
* 业务意图:与供应商列表导出风格保持一致。
* 规则:
* 1) 复用当前查询条件与主表列配置;
* 2) 分页改为 page=1、limit=-1,一次导出全部命中数据;
* 3) 产品阶段列按描述文案导出,避免只导出编码。
*/
async exportExcel () {
// 导出单独组参,避免把列表当前 pageSize 改成 -1。site 以前端查询条件为准。 - rqrq
const params = Object.assign({}, this.searchData, {
page: 1,
limit: -1,
site: this.searchData.site || this.$store.state.user.site
})
excel.exportTable({
url: '/part/searchPartList',
columnMapping: this.columnArray1, // 可以直接用table,不需要的列就剔除
mergeSetting: [], // 需要合并的列
params: params,
fileName: this.exportName + '.xlsx',
rowFetcher: res => res.data,
columnFormatter: [
{ columnProp: 'partStage', formatter: (val) => this.formatPartStageDesc(val) }
],
dropColumns: []// 需要剔除的列
})
},
refreshBasicInfo () {
let inData = {
site: this.currentRow.site,
partNo: this.currentRow.partNo,
partDesc: this.currentRow.partDesc,
height: this.getBasicTabHeight()
}
this.$refs.basicInfo.init(inData)
},
refreshSpecParams () {
let inData = {
site: this.currentRow.site,
partNo: this.currentRow.partNo,
codeNo: this.currentRow.codeNo,
functionType:"P",
height: this.getDetailTabHeight(70)
}
this.$refs.specParams.init(inData)
},
refreshSuppliers () {
let inData = {
site: this.currentRow.site,
partNo: this.currentRow.partNo,
height: this.getDetailTabHeight(90)
}
this.$refs.suppliers.init(inData)
},
refreshApproval () {
let inData = {
site: this.currentRow.site,
orderRef1: this.currentRow.partNo,
orderType: '产品资料',
height: this.getDetailTabHeight(30)
}
this.$refs.approval.init(inData)
},
refreshAttachments () {
let inData = {
orderRef1: this.currentRow.site,
orderRef2: this.currentRow.partNo,
orderRef3: this.currentRow.partDesc,
orderReftype: 'part',
height: this.getDetailTabHeight(90)
}
this.$refs.attachments.init(inData)
},
// 新增产品
addPart() {
this.isAdd = true
this.skuOptions = []
this.currentpart = {
partNo: '',
basePartNo: '',
partSuffix: '',
npc: '',
partDesc: '',
partSpec: 'N/A',
sku: '',
item: '',
defaultSupplierNo: '',
buyerName: '',
sourcingName: '',
category: '',
categoryLevel2: '',
categoryLevel3: '',
unit: '',
status: 'Y',
codeNo: '',
createBy: this.$store.state.user.name,
remark: '',
site: this.$store.state.user.site,
}
this.categoryLevel2Options = []
this.categoryLevel3Options = []
this.loadPartCategoryLevel1()
this.partDialogVisible = true
},
// 编辑产品
editPart(row) {
if (!row) {
this.$message.warning('请选择一个产品修改')
return
}
this.isAdd = false
this.skuOptions = []
this.currentpart = {...row}
// 编辑时按已存基准料号回显完整后缀,基准料号空值保持为空 - rqrq。
this.currentpart.partSuffix = this.extractPartSuffix(this.currentpart.partNo, this.currentpart.basePartNo)
this.initPartCategoryOptions(true).then(() => {
this.partDialogVisible = true
})
},
// 新增后自动刷新属性模板 - rqrq
autoRefreshPartPropertiesAfterCreate () {
const site = (this.$store.state.user.site || '').trim().toUpperCase()
const partNo = (this.currentpart.partNo || '').trim().toUpperCase()
const codeNo = (this.currentpart.codeNo || '').trim().toUpperCase()
if (!site || !partNo || !codeNo) {
return Promise.resolve(false)
}
// 新增料号成功后自动刷新属性模板,提前生成属性 - rqrq
return refreshPartPropertiesModal({
site,
partNo,
codeNo,
recordType: 'P'
}).then(({ data }) => {
if (data && data.code === 0) {
return true
}
this.$message.warning((data && data.msg) || '刷新属性模板失败')
return false
}).catch(error => {
this.$message.warning('刷新属性模板失败: ' + (error.message || error))
return false
})
},
// 保存产品
savePart() {
if (this.isAdd) {
const basePartNo = (this.currentpart.basePartNo || '').trim().toUpperCase()
const partSuffix = (this.currentpart.partSuffix || '').trim().toUpperCase()
// 基准料号必填,后缀允许留空;与高级复制的编码规则一致 - rqrq
if (!basePartNo) {
this.$message.warning('请填写基准料号')
return
}
// 与普通复制、高级复制一致,允许多段后缀并限制完整产品编码为30位 - rqrq。
if (this.generatePartNo(basePartNo, partSuffix).length > 30) {
this.$message.warning('产品编码不能超过30个字符')
return
}
if (!(this.currentpart.defaultSupplierNo || '').trim()) {
this.$message.warning('请填写默认供应商')
return
}
this.currentpart.defaultSupplierNo = (this.currentpart.defaultSupplierNo || '').trim().toUpperCase()
this.currentpart.basePartNo = basePartNo
this.currentpart.partSuffix = partSuffix
this.currentpart.partNo = this.generatePartNo(basePartNo, partSuffix)
}
this.$refs.partForm.validate((valid) => {
if (!valid) {
this.$message.warning('请填写必填字段')
return
}
// 新增时先校验 SKU 与基准料号的一一对应关系,通过后进入原有价格表校验及保存
this.ensureSkuBasePartNoConsistent().then(pass => {
if (pass) {
this.checkPriceAndSave()
}
})
})
},
/**
* 新增时校验 SKU 与基准料号互为一一对应(仅新增弹窗、两者均有值时触发):
* part_sku 无该 SKU → 放行,保存物料时自动新建;
* SKU 存在但基准料号为空 → 后端自动回填本次基准料号后放行;
* SKU 已对应其他基准料号 → 仍然拦截,提示去 SKU 管理页人工维护;
* 基准料号已对应其他 SKU → 询问是否统一修改该基准料号下的产品SKU(同“指定SKU”功能)。
*/
ensureSkuBasePartNoConsistent () {
const basePartNo = (this.currentpart.basePartNo || '').trim().toUpperCase()
const sku = (this.currentpart.sku || '').trim().toUpperCase()
// 编辑态不校验;SKU 或基准料号有一方未填时交给原有逻辑处理(保存时不写 part_sku 对应关系)
if (!this.isAdd || !basePartNo || !sku) {
return Promise.resolve(true)
}
return this.doSkuBasePartNoCheck(this.$store.state.user.site, sku, basePartNo, false)
},
/**
* 调用 part_sku 一致性校验接口:无记录放行、空基准料号后端自动回填、冲突按场景处理。
* 新增弹窗与“指定SKU”弹窗共用;skipNavigation=true 时冲突不跳转,留在当前弹窗。
* 统一返回 Promise<boolean>:true 可继续保存/指定,false 中止。
*/
doSkuBasePartNoCheck (site, sku, basePartNo, skipNavigation) {
return checkSkuBasePartNo({
site,
sku,
basePartNo
}).then(({ data }) => {
if (data && data.code === 0) {
if (data.conflict) {
// 冲突可能转为“统一修改该基准料号下的SKU”,按其结果决定是否继续
return this.promptSkuBasePartNoConflict(data, sku, skipNavigation, basePartNo)
}
return true
}
// 接口返回异常时中止保存/指定,避免写入不一致的对应关系
this.$message.error((data && data.msg) || 'SKU与基准料号一致性校验失败')
return false
}).catch(() => {
this.$message.error('SKU与基准料号一致性校验失败,请稍后重试')
return false
})
},
// 冲突处理:基准料号已对应其他SKU时走“统一修改该基准料号下的SKU”;方向A(SKU 已被其他基准料号占用)已放开,不再拦截
promptSkuBasePartNoConflict (data, sku, skipNavigation, basePartNo) {
// 基准料号已对应其他SKU:本次目标就是把它们统一成新SKU,不存在占用风险,直接按统一修改处理
if (data.conflictType === 'BASE_PART_NO') {
// “指定SKU”弹窗已二次确认过,直接放行到统一修改;新增弹窗需先询问用户
if (skipNavigation) {
return Promise.resolve(true)
}
return this.$confirm(
`当前基准料号的SKU为:${data.conflictSku},是否统一修改该基准料号下的产品SKU:${sku}?`,
'SKU与基准料号不一致',
{
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
}
).then(() => {
return this.unifySkuByBasePartNo(sku, basePartNo)
}).catch(() => {
this.$message.info('已取消统一修改,本次新增未保存,请调整SKU后再保存。')
return false
})
}
// 方向A 已放开:后端不再产生 conflictType='SKU',其余情况直接放行继续保存/指定 - rqrq
return Promise.resolve(true)
},
// 按基准料号统一修改SKU(后端按 part 表把该基准料号下所有物料 sku 统一),成功返回 true 继续保存
unifySkuByBasePartNo (sku, basePartNo) {
return updateSkuByBasePartNo({
site: this.$store.state.user.site,
basePartNo,
sku
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success(`已统一修改该基准料号下的SKU为 ${sku}`)
return true
}
this.$message.error((data && data.msg) || '统一修改SKU失败')
return false
}).catch(() => {
this.$message.error('统一修改SKU失败,请稍后重试')
return false
})
},
// 原有价格表校验:供应商编码、Item、SKU 三者都有值时校验价格表是否已存在该组合
checkPriceAndSave () {
const supplierCode = (this.currentpart.defaultSupplierNo || '').trim().toUpperCase()
const item = (this.currentpart.item || '').trim().toUpperCase()
const sku = (this.currentpart.sku || '').trim().toUpperCase()
// 供应商编码、Item、SKU 三者都有值时,校验价格表是否已存在该组合
if (supplierCode && item && sku) {
checkSupplierPartByItemSku({
site: this.$store.state.user.site,
supplierCode,
item,
sku
}).then(({ data }) => {
if (data && data.code === 0 && data.exists) {
// 价格表已存在该组合,正常保存
this.doSavePart(false)
} else {
// 组合不存在时再按 供应商+物料号 查价格表行:编辑改 Item 会查不到组合,
// 但行已存在(已在供/审核流程中),保存时后端会自动同步新 Item,不应重复弹新品流程确认
this.hasSupplierPartRow(supplierCode).then(exists => {
if (exists) {
this.doSavePart(false)
} else {
this.promptCreateSupplierPriceAndAudit()
}
})
}
}).catch(() => {
// 校验接口异常时不阻塞保存
this.doSavePart(false)
})
} else {
this.doSavePart(false)
}
},
/**
* 按 供应商+物料号 判断价格表(可供物料)行是否已存在。
* listSupplierPart 的 supplierCode 条件实际按简称模糊匹配,故仅按 partNo 查询后在前端精确匹配
*/
hasSupplierPartRow (supplierCode) {
const partNo = (this.currentpart.partNo || '').trim().toUpperCase()
if (!partNo) {
return Promise.resolve(false)
}
return listSupplierPartMoq({
site: this.$store.state.user.site,
partNo
}).then(({ data }) => {
if (!(data && data.code === 0)) {
return false
}
return (data.rows || []).some(row =>
(row.partNo || '').trim().toUpperCase() === partNo &&
(row.supplierCode || '').trim().toUpperCase() === supplierCode
)
}).catch(() => false)
},
/**
* 未查询到价格表记录时,弹出三按钮确认弹窗:
* 发起并审核→保存后产生价格表并发起审核,随后跳出登记审核弹窗;
* 发起→仅产生价格表并发起审核(不默认审核);取消→仅保存,不产生价格表也不进入新品流程
*/
promptCreateSupplierPriceAndAudit () {
this.newProductFlowDialogVisible = true
},
confirmNewProductFlow (withAudit) {
this.newProductFlowDialogVisible = false
this.doSavePart(true, withAudit)
},
cancelNewProductFlow () {
this.newProductFlowDialogVisible = false
// 取消:仅保存物料,不产生价格表也不进入新品流程
this.doSavePart(false)
},
/**
* 执行实际保存逻辑
* @param {boolean} needCreatePriceAndAudit 保存成功后是否产生价格表并发起新品审核
* @param {boolean} auditAfterStart 发起审核后是否跳出登记审核弹窗(发起并审核)
*/
doSavePart (needCreatePriceAndAudit, auditAfterStart) {
const apiCall = this.isAdd ? createPart(this.currentpart) : updatePart(this.currentpart)
apiCall.then(({data}) => {
if (data && data.code === 0) {
const finishSave = (refreshOk) => {
const successMsg = this.isAdd
? (refreshOk ? '新增产品成功,已刷新属性模板' : '新增产品成功')
: '修改产品成功'
this.$message.success(successMsg)
this.partDialogVisible = false
this.getMainData()
// 保存成功后,根据用户选择决定是否产生价格表并进入新品流程
if (needCreatePriceAndAudit) {
this.createSupplierPriceAndStartAudit(null, auditAfterStart)
}
}
// 新增后自动执行“刷新属性模板”按钮同等逻辑 - rqrq
if (this.isAdd) {
this.autoRefreshPartPropertiesAfterCreate().then((refreshOk) => {
finishSave(refreshOk)
})
return
}
finishSave(false)
} else {
this.$message.error(data.msg || '操作失败')
}
}).catch(error => {
this.$message.error('操作失败: ' + error.message)
})
},
/**
* 新增物料保存成功后:先产生供应商价格表(可供物料),再进入新品审核流程。
* 价格表已存在或创建失败时不阻断,继续尝试发起审核(审核接口会校验可供物料关系)。
* 注意:后端保存物料时已按 供应商+物料号 sync 过 SupplierforPart,这里先查重,已存在则跳过新增,
* 避免 addSupplierPart 撞重复校验报"供应商+物料已存在,请勿重复新增"
* 不传 payload 时默认取当前编辑弹窗的物料(普通新增/编辑保存链路),高级复制传目标物料信息复用同一逻辑
* @param {boolean} auditAfterStart 发起审核后是否跳出登记审核弹窗(发起并审核)
*/
createSupplierPriceAndStartAudit (payload, auditAfterStart) {
const site = this.$store.state.user.site
const supplierCode = ((payload && payload.supplierCode) || this.currentpart.defaultSupplierNo || '').trim().toUpperCase()
const partNo = ((payload && payload.partNo) || this.currentpart.partNo || '').trim().toUpperCase()
if (!supplierCode || !partNo) {
return
}
// listSupplierPart 的 supplierCode 条件实际按简称模糊匹配,故仅按 partNo 查询后在前端精确匹配供应商编码
listSupplierPartMoq({
site,
partNo
}).then(({ data }) => {
if (data && data.code === 0) {
const rows = data.rows || []
const exists = rows.some(row =>
(row.partNo || '').trim().toUpperCase() === partNo &&
(row.supplierCode || '').trim().toUpperCase() === supplierCode
)
if (exists) {
this.$message.info('供应商价格表(可供物料)已存在,跳过新增')
return
}
return addSupplierPartMoq({
site,
supplierCode,
partNo
}).then(({ data: addRes }) => {
if (addRes && addRes.code === 0) {
this.$message.success('已产生供应商价格表(可供物料)')
} else {
this.$message.warning((addRes && addRes.msg) || '产生供应商价格表失败')
}
}).catch(error => {
this.$message.warning('产生供应商价格表失败: ' + (error.message || error))
})
}
}).catch(() => {
// 查重接口异常时不阻断,按原逻辑直接尝试新增
return addSupplierPartMoq({
site,
supplierCode,
partNo
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success('已产生供应商价格表(可供物料)')
}
// 后端重复校验报"已存在"属正常情况(保存物料时已自动建立关系),不再弹出警告
}).catch(() => {})
}).then(() => {
// 无论价格表是否刚创建,都尝试发起新品审核
this.executeStartNewProductAudit(payload, auditAfterStart)
})
},
/**
* 调用开始审核接口,生成新品审核记录;同样支持 payload 传入,供高级复制链路复用
* auditAfterStart 为 true(发起并审核)时,开始审核成功后跳出登记审核弹窗
*/
executeStartNewProductAudit (payload, auditAfterStart) {
const supplierCode = ((payload && payload.supplierCode) || this.currentpart.defaultSupplierNo || '').trim().toUpperCase()
const partNo = ((payload && payload.partNo) || this.currentpart.partNo || '').trim().toUpperCase()
if (!supplierCode || !partNo) {
return
}
startNewProductAudit({
site: this.$store.state.user.site,
supplierCode,
partNo
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success('已创建新品审核记录')
if (auditAfterStart) {
this.openNewProductAuditDialog(supplierCode, partNo)
}
} else {
this.$message.warning((data && data.msg) || '开始审核失败')
}
}).catch(() => {
this.$message.warning('开始审核失败')
})
},
/**
* 发起并审核:查询该物料最新轮次待审核的采购部门记录,跳出登记审核弹窗选择同意/不同意
*/
openNewProductAuditDialog (supplierCode, partNo) {
listNewProductAuditRecord({
site: this.$store.state.user.site,
supplierCode,
partNo
}).then(({ data }) => {
if (data && data.code === 0) {
// 取最大轮次待登记的采购记录
const record = (data.rows || []).reduce((max, row) => {
if ((row.deptType || '').toUpperCase() !== 'PURCHASE' || (row.status || '').toUpperCase() !== 'PENDING') {
return max
}
return (!max || (row.auditRoundNo || 0) > (max.auditRoundNo || 0)) ? row : max
}, null)
if (!record) {
this.$message.warning('未找到待登记的采购部门审核记录,请到新品审核页面处理')
return
}
this.auditForm = {
id: record.id,
site: record.site,
supplierCode: record.supplierCode,
partNo: record.partNo,
auditRoundNo: record.auditRoundNo,
deptType: 'PURCHASE',
auditResult: '',
needTestFlag: false,
auditOpinion: ''
}
this.auditDialogVisible = true
} else {
this.$message.warning((data && data.msg) || '查询审核记录失败')
}
}).catch(() => {
this.$message.warning('查询审核记录失败')
})
},
// 登记审核弹窗提交:结论必选,同意后整轮完成判定由后端 applyRoundOutcome 处理
submitPartNewProductAudit () {
if (!this.auditForm.id) {
this.$message.warning('审核记录无效')
return
}
if (!this.auditForm.auditResult) {
this.$message.warning('请选择审核结论')
return
}
this.auditSaveLoading = true
submitNewProductAuditRecord({
id: this.auditForm.id,
site: this.auditForm.site,
supplierCode: this.auditForm.supplierCode,
partNo: this.auditForm.partNo,
auditRoundNo: this.auditForm.auditRoundNo,
deptType: this.auditForm.deptType,
auditResult: this.auditForm.auditResult,
needTest: this.auditForm.needTestFlag ? 'Y' : 'N',
auditOpinion: (this.auditForm.auditOpinion || '').trim()
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success('审核登记成功')
this.auditDialogVisible = false
this.getMainData()
} else {
this.$message.error((data && data.msg) || '审核登记失败')
}
}).catch(() => {
this.$message.error('审核登记失败')
}).finally(() => {
this.auditSaveLoading = false
})
},
// 审核意见文本域后表单项的跟随间距,与 supplierPartNewProductAudit 页面同口径
calcTextareaFollowGapStyle (rows) {
const rowCount = Number(rows) || 1
const followGap = rowCount > 1 ? (rowCount - 1) * 20 : 0
return { marginBottom: `${followGap}px` }
},
/**
* 高级复制成功后的回调:先刷新主表,再按弹窗内用户的新品流程选择执行——
* createPriceAndAudit 为 true(发起)/'audit'(发起并审核)时产生价格表并发起新品审核,'audit' 额外跳出登记审核弹窗,
* false 仅刷新;兼容旧 payload 结构:未携带该标志时回退为后端回填字段齐全即执行
*/
handleAdvancedCopyResult (payload) {
this.getMainData()
if (!payload) {
return
}
const supplierCode = (payload.supplierNo || '').trim().toUpperCase()
const item = (payload.item || '').trim().toUpperCase()
const sku = (payload.sku || '').trim().toUpperCase()
const flowChoice = payload.createPriceAndAudit
const shouldCreate = flowChoice === true || flowChoice === 'audit' ||
(typeof flowChoice !== 'boolean' && flowChoice !== 'audit' && !!(supplierCode && item && sku))
if (!shouldCreate) {
return
}
this.createSupplierPriceAndStartAudit({
supplierCode,
partNo: (payload.partNo || '').trim().toUpperCase()
}, flowChoice === 'audit')
},
// 删除产品
deletePart(row) {
this.$confirm('你确定删除该产品?', '确认删除', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deletePart({
id: row.id,
site: row.site,
partNo: row.partNo
}).then(({data}) => {
if (data && data.code === 0) {
this.$message.success('产品删除成功')
this.getMainData()
} else {
this.$message.error(data.msg || '删除失败')
}
}).catch(error => {
this.$message.error('删除失败: ' + error.message)
})
})
}
// 打开审批对话框
// openApproveDialog(row) {
// this.approveData = {
// applyNo: row.flowNodeInstanceData.applyNo,
// site: row.flowNodeInstanceData.site,
// orderType: row.flowNodeInstanceData.orderType,
// flowCode: row.flowNodeInstanceData.flowCode,
// flowVersion: row.flowNodeInstanceData.flowVersion,
// nodeCode: row.flowNodeInstanceData.nodeCode,
// comment: ''
// }
// this.approveDialogVisible = true
// },
// 提交审批
// submitApprove(action) {
// if (action === 'REJECTED' && !this.approveData.comment) {
// this.$message.warning('驳回时必须填写审批意见')
// return
// }
// this.approveLoading = true
// approveNodeInstance({
// applyNo: this.approveData.applyNo,
// nodeCode: this.approveData.nodeCode,
// site: this.approveData.site,
// orderType: this.approveData.orderType,
// specialRelease: this.approveData.specialRelease,
// action: action,
// comment: this.approveData.comment
// }).then(({ data }) => {
// if (data && data.code === 0) {
// this.$message.success(action === 'APPROVED' ? '审批通过成功' : '驳回成功')
// this.approveDialogVisible = false
// //刷新列表
// this.getMainData()
// } else {
// this.$message.error(data.msg || '操作失败')
// }
// }).finally(() => {
// this.approveLoading = false
// })
// },
// 重新审批 - rqrq
// handleRestart(row) {
// this.$confirm('确定要重新发起审批流程吗?', '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// restartFlowInstance({
// applyNo: row.applyNo,
// site: row.site,
// orderType: row.orderType
// }).then(({ data }) => {
// if (data && data.code === 0) {
// this.$message.success('重新审批成功')
// this.getMainData()
// } else {
// this.$message.error(data.msg || '操作失败')
// }
// })
// }).catch(() => {})
// }
}
}
</script>
<!--当前页面的标签样式-->
<style scoped lang="scss">
/deep/ .customer-tab .el-tabs__content {
padding: 5px !important;
}
/* 产品对话框整体样式 */
.part-dialog {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.part-dialog .el-dialog {
margin-top: 5vh !important;
margin-bottom: 5vh !important;
}
.part-dialog .el-dialog__header {
padding: 20px 25px 15px 25px;
border-bottom: 1px solid #E4E7ED;
}
.part-dialog .el-dialog__body {
padding: 25px 25px 25px 25px;
max-height: 75vh;
overflow-y: auto;
min-height: 400px;
}
.dialog-content {
width: 100%;
}
/* 产品表单样式 */
.part-form {
width: 100%;
}
.part-form .el-form-item {
margin-bottom: 1px;
}
.part-form .el-form-item__label {
font-weight: 500;
color: #303133;
line-height: 32px;
padding-right: 12px;
}
.part-form .el-form-item__content {
line-height: normal;
}
/* 表单分组样式 */
.form-section {
margin-bottom: 5px;
}
.form-section:last-child {
margin-bottom: 5px;
}
/* 输入框样式 */
.part-form .el-input,
.part-form .el-textarea,
.part-form .el-date-editor {
width: 100%;
}
/* 文本域样式优化 */
.part-form .el-textarea__inner {
resize: none;
font-family: inherit;
line-height: 1.5;
}
/* 对话框底部按钮居中 */
.dialog-footer-center {
text-align: center;
padding: 15px 0 5px 0;
border-top: 1px solid #E4E7ED;
margin-top: 15px;
}
.dialog-footer-center .el-button {
margin: 0 10px;
min-width: 90px;
height: 36px;
padding: 0 20px;
font-size: 14px;
}
/* 响应式调整 */
@media (max-width: 1200px) {
.part-dialog {
width: 95% !important;
}
.part-dialog .el-dialog__body {
padding: 20px 20px 15px 20px;
}
}
@media (max-width: 768px) {
.part-form .el-col {
margin-bottom: 20px;
}
.form-section {
margin-bottom: 35px;
}
.part-form .el-form-item__label {
line-height: 28px;
height: 28px;
}
}
</style>