<template>
|
<div class="add-common">
|
<el-dialog
|
:title="modalTitle + '产品'"
|
:visible.sync="editConfig.visible"
|
:width="dialogWidth"
|
:before-close="handleClose"
|
>
|
<!-- 头 -->
|
<div slot="title" class="dialog-header">
|
<span>{{ modalTitle + "产品" }}</span>
|
<div class="header_btns">
|
<span class="btn">
|
<i class="el-icon-printer"></i>
|
<span>打印</span>
|
</span>
|
<span class="btn" style="margin-left: 15px">
|
<i class="el-icon-s-tools"></i>
|
<span>动作</span>
|
</span>
|
<el-button v-if="showEdit" plain size="mini" style="margin-left: 15px" @click="editClick">编辑</el-button>
|
</div>
|
</div>
|
<!-- 内容 -->
|
<el-form
|
ref="form"
|
:model="editConfig.infomation"
|
:rules="rules"
|
label-position="right"
|
label-width="110px"
|
size="mini"
|
>
|
<!-- <div class="content-btn">
|
<el-button plain size="mini" disabled>标签打印</el-button>
|
<el-button plain size="mini" disabled>更新数量</el-button>
|
<el-button plain size="mini" disabled>执行补货</el-button>
|
</div> -->
|
<div class="basic-info">
|
<FormBtnsView
|
:add-product="addProduct"
|
@inOutBoundClick="inOutBoundClick"
|
@inLibraryClick="inLibraryClick"
|
:show-procure="showProcure"
|
:countObject="statisticsMap"
|
:show-sale="showSale"
|
@listingRulesClick="listingRulesClick"
|
@reorderRulesClick="reorderRulesClick"
|
/>
|
<div class="bottom">
|
<el-tabs v-model="activeName" type="card">
|
<el-tab-pane label="基本信息" name="first"></el-tab-pane>
|
<!-- <el-tab-pane label="销售" name="sale"></el-tab-pane>
|
<el-tab-pane label="采购" name="second"></el-tab-pane> -->
|
<el-tab-pane label="库存" name="third"></el-tab-pane>
|
<!-- <el-tab-pane label="会计" name="four"></el-tab-pane> -->
|
</el-tabs>
|
<!-- 基本信息 -->
|
<div v-if="activeName === 'first'">
|
<div class="purchase-view">
|
<div class="left">
|
<el-form-item label="产品名称" prop="name">
|
<el-input
|
v-model="editConfig.infomation.name"
|
placeholder=""
|
:disabled="!showFooter"
|
style="width: 85%"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="产品编码" prop="id">
|
<el-input
|
style="width: 85%"
|
v-if="
|
editConfig.title == '编辑' ||
|
(editConfig.title == '新建' && codenumer && (explain != '' || isIdDisabled))
|
"
|
:disabled="editConfig.title != '新建'"
|
v-model="editConfig.infomation.id"
|
placeholder="请输入编码"
|
>
|
</el-input>
|
<span v-else-if="editConfig.title == '新建'" style="color: #f56c6c; width: 85%"
|
>请优先配置编码规范 <el-button type="text" @click="numberClick"> 配置规范 </el-button></span
|
>
|
</el-form-item>
|
<el-form-item label="产品规格" prop="specs">
|
<el-input
|
style="width: 85%"
|
:disabled="!showFooter"
|
clearable
|
v-model="editConfig.infomation.specs"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="产品类型" prop="productType">
|
<el-select
|
v-model="editConfig.infomation.productType"
|
placeholder="请选择"
|
size="mini"
|
clearable
|
style="width: 85%"
|
:disabled="!showFooter"
|
>
|
<el-option v-for="item in productTypeOptions" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<!-- <el-form-item label="开票策略" prop="invoicingStrategy" >
|
<el-select
|
v-model="editConfig.infomation.invoicingStrategy"
|
placeholder="请选择"
|
size="mini"
|
style="width: 85%"
|
:disabled="!showFooter"
|
>
|
<el-option v-for="item in strategyOptions" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
<div class="font_size_13" style="color: gray">可储存的产品是您管理库存水平的实物项目。</div>
|
<div class="font_size_13" style="color: gray">您可以在发货前为其开具结算单。</div>
|
</el-form-item> -->
|
<el-form-item label="物料类型" prop="model">
|
<el-select
|
v-model="editConfig.infomation.model"
|
placeholder="请选择"
|
filterable
|
clearable
|
style="width: 85%"
|
:popper-append-to-body="false"
|
:disabled="!showFooter"
|
>
|
<el-option v-for="item in materialTypeList" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<!-- <el-form-item label="单位old" prop="unit">
|
<el-input
|
v-model="editConfig.infomation.unit"
|
placeholder="请输入"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item> -->
|
|
<el-form-item label="单位" prop="unit">
|
<el-select
|
:disabled="!showFooter"
|
v-model="editConfig.infomation.unit"
|
placeholder="单位"
|
filterable
|
@change="Gtechange"
|
style="width: calc(85% - 120px)"
|
>
|
<el-option
|
v-for="ele in unitList"
|
:key="ele.id"
|
:label="ele.name"
|
:value="ele.name"
|
></el-option>
|
</el-select>
|
<i
|
class="el-icon-setting margin_left_10px cursor_pointer"
|
style="font-size: 20px; color: gray"
|
@click="handleUnitShow"
|
></i>
|
<el-checkbox
|
class="margin_left_10px"
|
:disabled="editConfig.infomation.unit&&showFooter?false:true"
|
v-model="editConfig.infomation.moreUnit"
|
@change="moreUnitChange"
|
>启用多单位</el-checkbox
|
>
|
<!-- <span class="margin_left_10px cursor_pointer" @click="handleUnitMore">启用多单位</span> -->
|
</el-form-item>
|
|
<el-form-item label="产品标签" prop="productTagName">
|
<el-input
|
v-model="editConfig.infomation.productTagName"
|
placeholder="请输入"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="图片上传:" prop="imageUrl">
|
<IconCropper
|
:isView="isView"
|
:image-url="editConfig.infomation.imageSrc"
|
@getImageData="getImageData"
|
style="width: 85%"
|
/>
|
</el-form-item>
|
</div>
|
<div class="right">
|
<el-form-item label="销售价格" prop="salePrice">
|
<!-- <span>¥</span> -->
|
<el-input-number
|
v-model.trim="editConfig.infomation.salePrice"
|
placeholder="请输入"
|
:min="0"
|
:controls="false"
|
size="mini"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input-number>
|
</el-form-item>
|
<!-- <el-form-item label="销项税" prop="customerTaxes" >
|
<el-input-number
|
v-model="editConfig.infomation.customerTaxes"
|
placeholder="请输入"
|
:min="0"
|
:controls="false"
|
style="width: 85%; margin-right: 5px"
|
:disabled="!showFooter"
|
></el-input-number>
|
</el-form-item> -->
|
<el-form-item label="成本" prop="cost">
|
<!-- <span>¥</span> -->
|
<el-input-number
|
v-model.trim="editConfig.infomation.cost"
|
placeholder="请输入"
|
:min="0"
|
:controls="false"
|
size="mini"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input-number>
|
</el-form-item>
|
<el-form-item label="产品类别" prop="categoryId">
|
<el-select
|
v-model="editConfig.infomation.categoryId"
|
placeholder="请选择"
|
size="mini"
|
clearable
|
filterable
|
style="width: 85%"
|
:disabled="!showFooter"
|
>
|
<el-option
|
v-for="item in productCategoryOptions"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="产品型号" prop="type">
|
<el-input
|
style="width: 85%"
|
:disabled="!showFooter"
|
filterable
|
v-model="editConfig.infomation.type"
|
placeholder="请输入"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="采购类型" prop="purchaseTypeList">
|
<el-checkbox-group
|
v-model="editConfig.infomation.purchaseTypeList"
|
:disabled="!showFooter"
|
>
|
<el-checkbox v-for="item in bomPurchaseTypeList" :key="item.id" :label="item.id">{{ item.name }}</el-checkbox>
|
</el-checkbox-group>
|
</el-form-item>
|
<el-form-item label="内部编码" prop="internalReference">
|
<el-input
|
v-model.trim="editConfig.infomation.internalReference"
|
placeholder="请输入"
|
size="mini"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="条码" prop="barcode">
|
<el-input
|
v-model.trim="editConfig.infomation.barcode"
|
placeholder="请输入"
|
size="mini"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
</div>
|
</div>
|
<div class="all">
|
<!-- <div class="second-label">备注</div> -->
|
<el-form-item label="备注" prop="note">
|
<el-input
|
v-model.trim="editConfig.infomation.note"
|
placeholder="请输入"
|
size="mini"
|
type="textarea"
|
style="width: 95%"
|
:autosize="{ minRows: 4 }"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
</div>
|
</div>
|
<!-- 库存 -->
|
<div v-if="activeName === 'third'">
|
<div class="purchase-view">
|
<div class="all">
|
<div class="second-label">物流</div>
|
</div>
|
</div>
|
<div class="purchase-view">
|
<!-- <div class="left">
|
<div class="second-label">操作</div>
|
<el-form-item label="路线" prop="checkedRoute" >
|
<el-checkbox-group v-model="checkedRoute" :min="1" :max="2">
|
<el-checkbox v-for="city in route" :label="city" :key="city" class="list-item">{{
|
city.length > 20 ? city.substring(0, 20) + "..." : city
|
}}</el-checkbox>
|
</el-checkbox-group>
|
</el-form-item>
|
</div> -->
|
<div class="left">
|
<el-form-item label="负责人" prop="principal" label-width="80px">
|
<el-select
|
v-model="editConfig.infomation.principal"
|
placeholder="请选择"
|
size="mini"
|
style="width: 88%"
|
disabled
|
>
|
<el-option
|
v-for="(item, index) in memberOptions"
|
:key="index"
|
:label="item.userName"
|
:value="item.userName"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<!-- <el-form-item label="重量" prop="weight" label-width="80px">
|
<el-input-number
|
v-model="editConfig.infomation.weight"
|
placeholder="请输入"
|
:min="0"
|
:precision="2"
|
:controls="false"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input-number>
|
<span> kg</span>
|
</el-form-item> -->
|
<el-form-item label="毛重" prop="grossWeight" label-width="80px">
|
<el-col :span="15"
|
>
|
<el-input
|
v-model="editConfig.infomation.grossWeight"
|
placeholder="请输入"
|
:disabled="!showFooter"
|
></el-input>
|
</el-col>
|
<el-col :span="1"> </el-col>
|
<el-col :span="5">
|
<el-select
|
v-model="editConfig.infomation.grossUnit"
|
placeholder="单位"
|
filterable
|
:disabled="!showFooter"
|
style="width: 100%; float: right"
|
:popper-append-to-body="false"
|
>
|
<el-option
|
v-for="ele in grossUnitList"
|
:key="ele.id"
|
:label="ele.name"
|
:value="ele.name"
|
></el-option>
|
</el-select>
|
</el-col>
|
</el-form-item>
|
<el-form-item label="净重" prop="netWeight" label-width="80px">
|
<el-col :span="15"
|
>
|
<el-input
|
v-model="editConfig.infomation.netWeight"
|
:disabled="!showFooter"
|
placeholder="请输入"
|
></el-input>
|
</el-col>
|
<el-col :span="1"> </el-col>
|
<el-col :span="5">
|
<el-select
|
v-model="editConfig.infomation.netUnit"
|
placeholder="单位"
|
filterable
|
:disabled="!showFooter"
|
style="width: 100%; float: right"
|
:popper-append-to-body="false"
|
>
|
<el-option
|
v-for="ele in grossUnitList"
|
:key="ele.id"
|
:label="ele.name"
|
:value="ele.name"
|
></el-option>
|
</el-select>
|
</el-col>
|
</el-form-item>
|
<el-form-item label="体积" prop="volume" label-width="80px">
|
<el-input-number
|
v-model="editConfig.infomation.volume"
|
placeholder="请输入"
|
:min="0"
|
:precision="2"
|
:controls="false"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input-number>
|
<span> m³</span>
|
</el-form-item>
|
</div>
|
<div class="right">
|
<el-form-item label="制造前置时间" prop="makeAdvanceTime" label-width="130px">
|
<el-input-number
|
v-model="editConfig.infomation.makeAdvanceTime"
|
placeholder="请输入"
|
:min="0"
|
:precision="0"
|
:controls="false"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input-number>
|
<span> 天数</span>
|
</el-form-item>
|
<el-form-item label="生产订单准备天数" prop="orderAdvanceTime" label-width="130px">
|
<el-input-number
|
v-model="editConfig.infomation.orderAdvanceTime"
|
placeholder="请输入"
|
:min="0"
|
:precision="0"
|
:controls="false"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input-number>
|
<span> 天数</span>
|
</el-form-item>
|
<el-form-item label="客户前置时间" prop="deliveryAdvanceTime" label-width="130px">
|
<el-input-number
|
v-model="editConfig.infomation.deliveryAdvanceTime"
|
placeholder="请输入"
|
:min="0"
|
:precision="0"
|
:controls="false"
|
style="width: 85%"
|
:disabled="!showFooter"
|
></el-input-number>
|
<span> 天</span>
|
</el-form-item>
|
</div>
|
</div>
|
<!-- <div class="purchase-view">
|
<div class="left">
|
<div class="second-label">收货说明</div>
|
<el-form-item label="" prop="inStorageExplain" label-width="0px">
|
<el-input
|
v-model.trim="editConfig.infomation.inStorageExplain"
|
placeholder="此说明添加到收货订单中(例如,产品在仓库的存储位置)"
|
size="mini"
|
type="textarea"
|
style="width: 95%"
|
:autosize="{ minRows: 4 }"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
</div>
|
<div class="right">
|
<div class="second-label">出库单说明</div>
|
<el-form-item label="" prop="outStorageExplain" label-width="0px">
|
<el-input
|
v-model.trim="editConfig.infomation.outStorageExplain"
|
placeholder="此通知已添加到送货单中"
|
size="mini"
|
type="textarea"
|
style="width: 95%"
|
:autosize="{ minRows: 4 }"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
</div>
|
</div>
|
<div class="purchase-view">
|
<div class="left">
|
<div class="second-label">内部调拨说明</div>
|
<el-form-item label="" prop="internalTransferExplain" label-width="0px">
|
<el-input
|
v-model.trim="editConfig.infomation.internalTransferExplain"
|
placeholder="此说明添加到内部调拨订单中(例如,在仓库中何处提取产品)"
|
size="mini"
|
type="textarea"
|
style="width: 100%"
|
:autosize="{ minRows: 4 }"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
</div>
|
<div class="right"></div>
|
</div> -->
|
</div>
|
<!-- 下面不要删 二期或三期会用到 -->
|
<!-- 销售 -->
|
<!-- <div v-if="activeName === 'sale'">
|
<div class="purchase-view">
|
<div class="left">
|
<div class="second-label">{{ "加售&交叉销售" }}</div>
|
<el-form-item label="可选产品" prop="selectProduct" >
|
<el-select
|
v-model="editConfig.infomation.selectProduct"
|
multiple
|
placeholder="请选择"
|
size="mini"
|
style="width: 85%"
|
:disabled="!showFooter"
|
>
|
<el-option
|
v-for="item in selectProductOptions"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<div class="second-label">销售说明</div>
|
<el-form-item label="" prop="sellExplain" label-width="20px">
|
<el-input
|
v-model.trim="editConfig.infomation.sellExplain"
|
size="mini"
|
type="textarea"
|
style="width: 85%"
|
:autosize="{ minRows: 2 }"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
</div>
|
<div class="right"></div>
|
</div>
|
</div> -->
|
<!-- 采购 -->
|
<!-- <div v-if="activeName === 'second'">
|
<CommonFormTableView
|
:product-table-list="productTableList"
|
:detail-enter="!showFooter"
|
@inputContent="inputContent"
|
@addProductClick="addProductClick"
|
>
|
<template v-if="showFooter" slot="tableButton">
|
<el-table-column label="操作" width="60" fixed="right" align="center">
|
<template slot-scope="scope">
|
<div @click="handleDelClick(scope)">
|
<i class="el-icon-delete"></i>
|
</div>
|
</template>
|
</el-table-column>
|
</template>
|
</CommonFormTableView>
|
<div class="purchase-view">
|
<div class="left">
|
<div class="second-label">供应商账单</div>
|
<el-form-item label="进项税" prop="client_name" >
|
<el-select
|
v-model="editConfig.infomation.memberId"
|
multiple
|
placeholder="请选择"
|
size="mini"
|
style="width: 63%"
|
:disabled="!showFooter"
|
>
|
<el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="控制策略" prop="client_name" >
|
<el-radio-group v-model="editConfig.infomation.resource">
|
<el-radio label="订单数量"></el-radio>
|
<el-radio label="收到数量"></el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</div>
|
<div class="right">
|
<div class="second-label">采购说明</div>
|
<el-form-item label="" prop="name" label-width="0px">
|
<el-input
|
v-model.trim="editConfig.infomation.desc"
|
placeholder="本条备注被添加到采购订单"
|
size="mini"
|
type="textarea"
|
style="width: 100%"
|
:autosize="{ minRows: 4 }"
|
:disabled="!showFooter"
|
></el-input>
|
</el-form-item>
|
</div>
|
</div>
|
</div> -->
|
</div>
|
</div>
|
</el-form>
|
<!-- 尾 -->
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" size="small" @click="saveClick('form')" :disabled="!showFooter">保存</el-button>
|
<el-button size="small" @click="editConfig.visible = false">取消</el-button>
|
</div>
|
</el-dialog>
|
<BomDialog
|
ref="editDialog"
|
:editRow="editRow"
|
@handleConfirmSave="handleConfirmSave"
|
:workList="unitList"
|
title="计量单位"
|
></BomDialog>
|
<UnitMoreDialog
|
ref="unitMoreDialog"
|
@saveUnitMore="saveUnitMore"
|
@cancelUnitMore='cancelUnitMore'
|
:workList="unitList"
|
:unitRight='editConfig.infomation.unit'
|
:dataList="editConfig.infomation.moreUnitList"
|
title="启用多单位"
|
></UnitMoreDialog>
|
</div>
|
</template>
|
|
<script>
|
import IconCropper from "./IconCropper"
|
import { getProductCategoryList } from "@/api/product/productCategory"
|
import { getProductList, addProduct, updateProduct,saveUnitDict } from "@/api/product/product"
|
import { uploadFiles, getUserInfo, } from "@/api/common/other"
|
import codeMixin from "@/components/mixin/codeMixin"
|
import { getDataByType } from "@/api/data"
|
import BomDialog from "./components/bomDialog";
|
import {getUnitInfo, } from "@/api/basic/standard";
|
// import { postGetSaveSUnitDict } from "@/api/basic/standard";
|
import UnitMoreDialog from "./components/UnitMoreDialog";
|
|
export default {
|
mixins: [codeMixin],
|
name: "AddProductDialog",
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
visible: false,
|
title: "新建",
|
infomation: {},
|
autoEdit: false
|
}
|
}
|
}
|
},
|
components: {
|
IconCropper,
|
BomDialog,
|
UnitMoreDialog,
|
},
|
computed: {
|
modalTitle() {
|
if (this.editConfig.title === "编辑" && this.editConfig.autoEdit) {
|
return "编辑"
|
} else if (this.editConfig.title === "编辑") {
|
return !this.showEdit ? "编辑" : "查看"
|
} else {
|
return "新建"
|
}
|
}
|
},
|
data() {
|
return {
|
dialogWidth: "50%",
|
editConfig: this.editCommonConfig,
|
rules: {
|
name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
|
id: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }],
|
model: [{ required: true, message: "请选择物料类型", trigger: "change" }],
|
// salePrice: [{ required: true, message: "请输入销售价格", trigger: "blur" }],
|
unit: [{ required: true, message: "请输入单位", trigger: ["blur"] }],
|
// 采购类型
|
purchaseTypeList: [{ required: true, message: "请选择", trigger: "blur" }],
|
netWeight: [
|
{
|
required: false,
|
message: "请填写",
|
trigger: "change",
|
},
|
{
|
validator: this.validatorNumFour,
|
trigger: "blur",
|
},
|
],
|
grossWeight: [
|
{
|
required: false,
|
message: "请填写",
|
trigger: "change",
|
},
|
{
|
validator: this.validatorNumFour,
|
trigger: "blur",
|
},
|
],
|
},
|
memberOptions: [],
|
productCategoryOptions: [], // 产品类别
|
productTypeOptions: [
|
{ name: "能消耗", id: 1 },
|
{ name: "服务", id: 2 },
|
{ name: "可库存产品", id: 3 }
|
], // 产品类型
|
strategyOptions: [
|
{ name: "订购数量", id: 1 },
|
{ name: "交付数量", id: 2 }
|
], // 开票策略
|
selectProductOptions: [], // 可选产品
|
showButton: true,
|
activeName: "first",
|
productTableList: {},
|
tableData: [],
|
isNoProduct: false, // 添加明细行时是否有产品未选择
|
showEdit: false, // 是否显示编辑按钮
|
isDelClick: false, // 删除按钮是否可点击
|
showFooter: false, // 是否显示取消保存
|
imageSrc: "", // 图片地址
|
marketable: true, // 可销售
|
procurable: true, // 可采购
|
checkedRoute: [],
|
route: ["制造", "河池生产制造仓"],
|
addProduct: false,
|
showProcure: true,
|
showSale: true,
|
materialTypeList: [
|
{ name: "原材料", id: "原材料" },
|
{ name: "半成品", id: "半成品" },
|
{ name: "成品", id: "成品" },
|
{ name: "辅料", id: "辅料" },
|
{ name: "耗材", id: "耗材" },
|
{ name: "其他", id: "其他" }
|
],
|
statisticsMap: {
|
amount: this.editCommonConfig.infomation.amount ? this.editCommonConfig.infomation.amount : 0, // 在库
|
predictionAmount: this.editCommonConfig.infomation.predictionAmount
|
? this.editCommonConfig.infomation.predictionAmount
|
: 0, //预测
|
inputAmount: this.editCommonConfig.infomation.inputAmount ? this.editCommonConfig.infomation.inputAmount : 0, //进
|
outputAmount: this.editCommonConfig.infomation.outputAmount ? this.editCommonConfig.infomation.outputAmount : 0, //出
|
reorderRuleNum: this.editCommonConfig.infomation.reorderRuleNum
|
? this.editCommonConfig.infomation.reorderRuleNum
|
: 0, //重订货规则数量
|
minInventoryRule: this.editCommonConfig.infomation.minInventoryRule
|
? this.editCommonConfig.infomation.minInventoryRule
|
: 0, //最小重订货
|
maxInventoryRule: this.editCommonConfig.infomation.maxInventoryRule
|
? this.editCommonConfig.infomation.maxInventoryRule
|
: 0 //最大重订货
|
},
|
isView: false,
|
fileFormdata: null, // 上传图片入参
|
bomPurchaseTypeList: getDataByType("purchaseType"),
|
grossUnitList:getDataByType("grossUnit"),
|
unitList: [],
|
editRow:{
|
editDialogVisible:false,
|
BomTableData:[]
|
}
|
}
|
},
|
created() {
|
if (this.editConfig.title === "编辑" && !this.editConfig.autoEdit) {
|
this.isView = true
|
}
|
this.getProductCategoryList()
|
this.getProductList()
|
this.setTableForm()
|
this.setBottonView()
|
this.statisticsMap.inLibrary = this.editConfig?.infomation?.amount ?? 0
|
// 进出口的产品 数量 还没有
|
this.statisticsMap.enter = this.editConfig?.infomation?.amount ?? 0
|
this.statisticsMap.exit = this.editConfig?.infomation?.amount ?? 0
|
if (this.editConfig.autoEdit) {
|
this.editClick()
|
}
|
this.setOptionalFieldsToEmpty()
|
this.formInfo()
|
this.getUserInfo()
|
this.getUnitInfo()
|
},
|
methods: {
|
validatorNumFour(rule, value, callback) {
|
if (value != "") {
|
if (value == undefined || value == null) {
|
callback(new Error("请输入有效数字"));
|
} else {
|
let reg2 =
|
/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
|
if (!reg2.test(value) || value == 0) {
|
callback(new Error("请填写大于零的2位小数的数字"));
|
} else {
|
callback();
|
}
|
}
|
} else {
|
callback();
|
}
|
},
|
// 单位
|
handleUnitShow() {
|
this.editRow.editDialogVisible = true;
|
},
|
// 启用多单位
|
handleUnitMore(){
|
if(this.editConfig.infomation.unit){
|
this.$refs.unitMoreDialog.editDialogVisible = true;
|
}else{
|
this.$message.error('请先选择单位!')
|
}
|
},
|
saveUnitMore(list){
|
this.editConfig.infomation.moreUnit=true
|
this.editConfig.infomation.moreUnitList=list
|
},
|
cancelUnitMore(){
|
this.editConfig.infomation.moreUnit=false
|
},
|
// 启用多单位的开关
|
moreUnitChange(){
|
// let string=false;
|
if(this.editConfig.infomation.unit){
|
// if(this.editConfig.infomation.moreUnitList&&this.editConfig.infomation.moreUnitList.length>0){
|
// for(let i in this.editConfig.infomation.moreUnitList){
|
// if(this.editConfig.infomation.moreUnitList[i].unit&&this.editConfig.infomation.moreUnitList[i].amount){
|
// string=true;
|
// break;
|
// }
|
// }
|
// }
|
if(this.editConfig.infomation.moreUnit){
|
// this.editConfig.infomation.moreUnit=false
|
// this.$message.error('请先配置多单位!')
|
this.$refs.unitMoreDialog.editDialogVisible = true;
|
}
|
}else{
|
this.editConfig.infomation.moreUnit=false
|
this.$message.error('请先选择单位!')
|
}
|
|
},
|
handleConfirmSave(dataList) {
|
saveUnitDict({ data: dataList }).then((res) => {
|
if (res.code == 200) {
|
this.$message({
|
message: "操作成功!",
|
type: "success",
|
});
|
this.getUnitInfo()
|
}
|
});
|
this.editRow.editDialogVisible = false;
|
|
},
|
// 获取登录用户信息
|
getUserInfo() {
|
getUserInfo().then((res) => {
|
console.log(res)
|
if (res.code == 200) {
|
this.editConfig.infomation.principal = res.data.userName
|
this.memberOptions.push(res.data)
|
}
|
console.log(this.memberOptions)
|
})
|
},
|
formInfo() {
|
this.objCode.type = "物料编码"
|
this.objCode.codeStandID = ""
|
if (this.editConfig.infomation.codeStandardID) {
|
this.objCode.codeStandID = this.editConfig.infomation.codeStandardID
|
}
|
this.getRCodeStandardList()
|
},
|
/**
|
* 非必填项后端返回的是数字 0,表单需要空串才能视为未选择回显
|
*/
|
setOptionalFieldsToEmpty() {
|
let arr = ["productType", "categoryId"]
|
arr
|
.filter((filed) => this.editConfig.infomation[filed] === 0)
|
.forEach((filed) => {
|
this.editConfig.infomation[filed] = ""
|
})
|
},
|
/**
|
* 后端只接受数字形式, 保存时还得再转回去
|
*/
|
unsetFieldsToNumber() {
|
let arr = ["productType", "categoryId"]
|
arr
|
.filter((filed) => this.editConfig.infomation[filed] === "")
|
.forEach((filed) => {
|
this.editConfig.infomation[filed] = 0
|
})
|
},
|
// 获取产品类别
|
async getProductCategoryList() {
|
await getProductCategoryList({
|
keyWord: "",
|
page: 0,
|
pageSize: 0
|
}).then((res) => {
|
if (res.code === 200) {
|
this.productCategoryOptions = res.data
|
}
|
})
|
},
|
// 获取可选产品
|
async getProductList() {
|
await getProductList({
|
keyWord: "",
|
page: 1,
|
pageSize: 20
|
}).then((res) => {
|
if (res.code === 200) {
|
const list = res.data.map((item) => {
|
return {
|
id: item.id,
|
name: item.name
|
}
|
})
|
this.selectProductOptions = list || []
|
}
|
})
|
},
|
// 设置删除/打印/编辑是否显示
|
setBottonView() {
|
if (this.editConfig.title === "新建") {
|
this.showButton = false
|
this.showEdit = false
|
this.showFooter = true
|
this.addProduct = true
|
} else {
|
this.showEdit = true
|
this.showFooter = false
|
this.addProduct = false
|
}
|
},
|
// 关闭
|
handleClose() {
|
this.editConfig.visible = false
|
},
|
// 编辑
|
editClick() {
|
this.showEdit = false
|
this.showButton = false
|
this.showFooter = true
|
this.isView = false
|
this.setTableForm()
|
},
|
// 保存
|
saveClick(formName) {
|
console.log(this.editConfig.infomation)
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
console.log(this.fileFormdata == null)
|
let attachmentIDs = []
|
if (this.fileFormdata == null) {
|
if (this.editConfig.infomation.attachmentList?.length > 0) {
|
this.editConfig.infomation.attachmentList.forEach((ele) => {
|
attachmentIDs.push(ele.id)
|
})
|
} else {
|
attachmentIDs = []
|
}
|
this.saveEditRequest(attachmentIDs)
|
} else {
|
uploadFiles(this.fileFormdata).then((res) => {
|
if (res.code == 200) {
|
res.data.forEach((ele) => {
|
attachmentIDs.push(ele.id)
|
})
|
}
|
this.saveEditRequest(attachmentIDs)
|
})
|
}
|
}
|
})
|
},
|
// 保存/编辑接口请求
|
saveEditRequest(attachmentIDs) {
|
let requestUrl = this.editConfig.title === "新建" ? addProduct : updateProduct
|
this.unsetFieldsToNumber()
|
let params = {
|
...this.editConfig.infomation,
|
attachmentIDs
|
}
|
if (this.editConfig.title == "新建") {
|
params.codeStandardID = this.autoCodeObj.codeStandardID
|
params.autoIncr = this.autoCodeObj.maxAutoIncr
|
}
|
if(params.moreUnitList&¶ms.moreUnitList.length>0){
|
for(let i in params.moreUnitList){
|
params.moreUnitList[i].amount=Number(params.moreUnitList[i].amount)
|
}
|
}
|
requestUrl(params).then((res) => {
|
console.log(res)
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message.success(this.editConfig.title === "新建" ? "添加" : "编辑" + "成功!")
|
this.$parent.getData()
|
}
|
}, console.error)
|
},
|
// 删除
|
delClick() {},
|
setTableForm() {
|
this.productTableList = {
|
tableData: this.tableData,
|
tableColumn: [
|
{ label: "供应商", prop: "name", productName: true, isRequird: true },
|
// { label: "供应商名称", prop: "number", input: true },
|
// { label: "供应商产品代码", prop: "number", input: true },
|
{ label: "开始日期", prop: "amount", date: true },
|
{ label: "结束日期", prop: "price", date: true },
|
{ label: "公司", prop: "total", select: true },
|
{ label: "数量", prop: "total", inputFloat: true },
|
{ label: "价格", prop: "price", inputFloat: true },
|
{ label: "币种", prop: "total", select: true }
|
// { label: "交货提前时间", prop: "total", inputNumber: true }
|
]
|
}
|
},
|
// 产品列表输入
|
inputContent(val, prop, row) {
|
this.productId = row.productId
|
this.tableData.map((item) => {
|
if (item.productId === row.productId) {
|
item[prop] = val
|
}
|
})
|
},
|
// 产品新增
|
addProductClick() {
|
console.log(this.tableData)
|
for (let i = 0; i < this.tableData.length; i++) {
|
if (this.tableData[i].name.length === 0) {
|
this.isNoProduct = true
|
break
|
} else {
|
this.isNoProduct = false
|
}
|
}
|
if (!this.isNoProduct) {
|
this.productId++
|
this.tableData.push({
|
productId: this.productId,
|
id: 0,
|
amount: 0,
|
desc: "",
|
name: "",
|
number: "",
|
price: 0,
|
total: 0
|
})
|
}
|
},
|
// 产品删除
|
handleDelClick(scope) {
|
console.log(scope)
|
this.tableData.splice(scope.$index, 1)
|
},
|
// 上传图片
|
getImageData(formdata) {
|
this.fileFormdata = formdata
|
// console.log(formdata, "图片数据")
|
},
|
// 进出点击
|
inOutBoundClick(val) {
|
if (this.editConfig.title !== "新建") {
|
console.log(this.editConfig.infomation)
|
let url=''
|
if(val=='进'){
|
url='inboundOutboundDetail'
|
}else{
|
url='outboundDetail'
|
}
|
this.$router.push({
|
name:url,
|
params: {
|
name: this.editConfig.infomation.name,
|
id: this.editConfig.infomation.id
|
}
|
})
|
}
|
},
|
// 在库点击
|
inLibraryClick() {
|
if (this.editConfig.title !== "新建") {
|
console.log(this.editConfig.infomation)
|
this.$router.push({
|
name: "inventoryReport",
|
params: {
|
name: this.editConfig.infomation.name,
|
id: this.editConfig.infomation.id
|
}
|
})
|
}
|
},
|
// 上架规则
|
listingRulesClick() {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
this.$router.push({
|
path: "/warehouseManage/listingRules",
|
query: {
|
productName: this.editConfig.infomation.name,
|
productId: this.editConfig.title === "新建" ? "" : this.editConfig.infomation.id
|
}
|
})
|
}
|
})
|
},
|
// 重订购规则
|
reorderRulesClick() {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
this.$router.push({
|
path: "/productManage/reorderRules",
|
query: {
|
productName: this.editConfig.infomation.name,
|
productId: this.editConfig.title === "新建" ? "" : this.editConfig.infomation.id
|
}
|
})
|
}
|
})
|
},
|
// 可销售/可采购
|
checkboxChange(val, param) {
|
if (val === "采购") {
|
this.showProcure = param
|
} else if (val === "销售") {
|
this.showSale = param
|
}
|
},
|
Gtechange(){
|
this.$forceUpdate()
|
},
|
// 获取单位列表数据
|
async getUnitInfo(){
|
await getUnitInfo().then((res)=>{
|
if( this.editConfig.title==="新建"){
|
res.data.map((item)=>{
|
if(item.isDefault){
|
this.editConfig.infomation.unit=item.name
|
}
|
})
|
}
|
this.editRow.BomTableData = res.data;
|
this.unitList=res.data
|
})
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
.dialog-header {
|
display: flex;
|
align-items: center;
|
font-size: 14px;
|
color: #333;
|
.header_btns {
|
margin-left: auto;
|
margin-right: 60px;
|
.btn {
|
cursor: no-drop;
|
}
|
}
|
}
|
.content-btn {
|
height: 37px;
|
line-height: 37px;
|
padding-left: 20px;
|
border-bottom: 1px solid #e9e9e9;
|
}
|
.basic-info {
|
height: calc(100% - 80px);
|
overflow: auto;
|
margin: 10px;
|
// border: 1px solid #dcdfe6;
|
// box-shadow: inset 0 0 2px #dee2e6;
|
// -moz-box-shadow: inset 0 0 2px #dee2e6;
|
// -webkit-box-shadow: inset 0 0 2px #dee2e6;
|
.bottom {
|
margin-top: 10px;
|
}
|
.content-number {
|
display: flex;
|
justify-content: right;
|
height: 44px;
|
// border-bottom: 1px solid #e9e9e9;
|
font-size: 13px;
|
.sub-number {
|
width: 12.5%;
|
border-right: 1px solid #e9e9e9;
|
display: flex;
|
padding: 3px 9px;
|
.left {
|
margin-top: 3px;
|
font-size: 22px;
|
font-weight: 600;
|
}
|
.icon-view {
|
transform: rotate(270deg);
|
}
|
.right {
|
margin-left: 6px;
|
.right-label {
|
color: #495057;
|
}
|
.right-one {
|
height: 38px;
|
line-height: 38px;
|
}
|
}
|
}
|
}
|
.purchase-view {
|
display: flex;
|
.left {
|
width: 50%;
|
}
|
.right {
|
width: 50%;
|
}
|
.all {
|
width: 100%;
|
}
|
}
|
.second-label {
|
margin-left: 20px;
|
margin-right: 20px;
|
border-bottom: 1px solid #d9d9d9;
|
margin-bottom: 10px;
|
}
|
.list-item {
|
width: 100%;
|
}
|
.avatar-uploader .el-upload {
|
border: 1px dashed #d9d9d9;
|
border-radius: 6px;
|
cursor: pointer;
|
position: relative;
|
overflow: hidden;
|
}
|
.avatar-uploader .el-upload:hover {
|
border-color: #409eff;
|
}
|
.avatar-uploader-icon {
|
font-size: 28px;
|
color: #8c939d;
|
width: 178px;
|
height: 178px;
|
line-height: 178px;
|
text-align: center;
|
}
|
.avatar {
|
width: 178px;
|
height: 178px;
|
display: block;
|
}
|
}
|
::v-deep {
|
.el-dialog__headerbtn {
|
position: absolute;
|
top: 18px;
|
}
|
.el-button {
|
&:hover {
|
border: 1px solid #dcdfe6;
|
color: #333;
|
}
|
}
|
.el-tabs--card > .el-tabs__header {
|
border-bottom: none;
|
}
|
.el-tabs__item.is-active {
|
color: #fff;
|
background: #2a78fb;
|
}
|
.el-tabs__item {
|
height: 30px;
|
line-height: 30px;
|
font-size: 13px;
|
background: #f3f3f3;
|
}
|
.el-input__inner {
|
text-align: left;
|
}
|
}
|
</style>
|