<template>
|
<div class="add-quotation">
|
<el-dialog
|
:title="editCommonConfig.title + '采购单'"
|
:visible.sync="editConfig.visible"
|
width="50%"
|
:before-close="handleClose"
|
append-to-body
|
custom-class="iframe-dialog"
|
>
|
<el-form
|
ref="form"
|
:model="editConfig.infomation"
|
:rules="rules"
|
label-position="right"
|
label-width="130px"
|
size="mini"
|
style="height: 60vh; overflow-x: hidden"
|
>
|
<!-- 信息 -->
|
<div class="basic-info">
|
<!-- 基本信息 -->
|
<div class="basic-info-title">基本信息</div>
|
<div class="basic-info-view">
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="采购单号" prop="number">
|
<!-- <el-input v-model="editConfig.infomation.number"></el-input> -->
|
<el-input
|
style="width: 85%"
|
v-if="
|
editConfig.title == '编辑' ||
|
editConfig.title == '查看' ||
|
(editConfig.title == '新建' && codenumer && (explain != '' || isIdDisabled))
|
"
|
:disabled="editConfig.title != '新建'"
|
v-model="editConfig.infomation.number"
|
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-col>
|
<el-col :span="12">
|
<el-form-item label="采购类型" prop="purchaseTypeId" class="float_left" style="width: 100%">
|
<el-select
|
:disabled="editConfig.isDisabled"
|
placeholder="请选择采购类型"
|
v-model="editConfig.infomation.purchaseTypeId"
|
clearable
|
style="width: calc(100% - 30px)"
|
>
|
<el-option
|
v-for="ele in plcBrandList"
|
:key="ele.purchaseTypeId"
|
:label="ele.name"
|
:value="ele.id"
|
></el-option>
|
</el-select>
|
<i
|
v-if="!editConfig.isDisabled"
|
class="el-icon-setting margin_left_10px cursor_pointer"
|
style="font-size: 20px; color: #333"
|
@click="handleShow"
|
></i>
|
</el-form-item>
|
</el-col>
|
|
<el-col :span="12">
|
<el-form-item label="供应商名称" prop="supplierName">
|
<div class="custom-name">
|
<el-autocomplete
|
:disabled="editConfig.isDisabled"
|
style="width: calc(100% - 40px)"
|
v-model="editConfig.infomation.supplierName"
|
:fetch-suggestions="
|
(queryString, callback) => {
|
querySearchAsync(queryString, callback, 'supplier')
|
}
|
"
|
value-key="name"
|
placeholder="请选择"
|
@select="handleSelectClient('client', $event)"
|
></el-autocomplete>
|
<div v-if="!editConfig.isDisabled" class="common-select-btn" @click="selClientClick('client')">
|
<i class="el-icon-circle-plus-outline" title="选择"></i>
|
</div>
|
<div
|
v-if="editConfig.infomation.supplierName && editConfig.infomation.supplierName.length > 0"
|
class="common-select-btn"
|
@click="clearupClient('client')"
|
>
|
<i class="el-icon-remove-outline" v-if="!editConfig.isDisabled" title="清除"></i>
|
</div>
|
</div>
|
</el-form-item>
|
</el-col>
|
<!-- <el-col :span="12">
|
<el-form-item label="单据来源" prop="orderSource">
|
<el-input v-model="editConfig.infomation.orderSource" disabled placeholder="请填写"></el-input>
|
</el-form-item>
|
</el-col> -->
|
<el-col :span="12">
|
<el-form-item label="采购单名称" prop="name">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.name"
|
placeholder="请填写"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="供应商联系人" prop="contact">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.contact"
|
placeholder="请填写"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="联系电话" prop="phone">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.phone"
|
placeholder="请填写"
|
maxlength="11"
|
show-word-limit
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="签约日期" prop="signingDate">
|
<el-date-picker
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.signingDate"
|
style="width: 100%"
|
type="date"
|
clearable
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd"
|
:picker-options="pickerOptionsBefore"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="交付日期" prop="deliveryDate">
|
<el-date-picker
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.deliveryDate"
|
style="width: 100%"
|
type="date"
|
clearable
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd"
|
:picker-options="pickerOptions"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="收货仓库" prop="warehouse">
|
<el-select
|
placeholder="请选择收货仓库"
|
v-model="editConfig.infomation.warehouse"
|
clearable
|
style="width: calc(100% - 0px)"
|
:disabled="editConfig.isDisabled"
|
>
|
<el-option
|
v-for="(ele, index) in receiveWhouseList"
|
:key="index"
|
:label="ele.name"
|
:value="ele.name"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="地址" prop="warehouseAddress">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.warehouseAddress"
|
placeholder="请填写"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="接收人" prop="principal">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.principal"
|
placeholder="请填写"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="来源单据" prop="sourceOrder">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.sourceOrder"
|
placeholder="请填写"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="备注信息" prop="remark">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
type="textarea"
|
:autosize="{ minRows: 3, maxRows: 4 }"
|
maxlength="500"
|
clearable
|
v-model="editConfig.infomation.remark"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
<!-- 产品管理 -->
|
<div class="basic-info-title" style="display: flex">产品信息</div>
|
<div class="product-view">
|
<CommonFormTableView
|
ref="tableRef"
|
:detailEnter="editCommonConfig.detailEnter"
|
:show-summary="showSummary"
|
:recalculateShow="false"
|
:addTypeIdMultiple="true"
|
:product-table-list="productTableList"
|
sign="purchase"
|
@inputContent="inputContent"
|
@getSummaries="getSummaries"
|
@addProductClick="addProductClick"
|
@getSelectArray="getSelectArray"
|
@emptyProductClick="emptyProductClick"
|
@clearupProduct="clearupProduct"
|
@rowClick="rowClick"
|
@handleProduct="handleProduct"
|
/>
|
</div>
|
<div class="table-bottom">
|
<div class="table-bottom-item">
|
<div class="table-bottom-l">
|
<el-form-item label="整单折扣" prop="member_id">
|
<el-select
|
v-model="editConfig.infomation.wholeDiscountType"
|
placeholder="请选择"
|
:disabled="editConfig.isDisabled"
|
filterable
|
@change="getTotal"
|
>
|
<el-option label="百分比降价" :value="1"></el-option>
|
<el-option label="直接降价" :value="2"></el-option>
|
</el-select>
|
</el-form-item>
|
</div>
|
<div class="table-bottom-r">
|
<el-form-item label="" prop="member_id">
|
<el-input
|
v-model="editConfig.infomation.wholeDiscount"
|
size="mini"
|
:disabled="editConfig.isDisabled"
|
@change="getTotal"
|
placeholder="请填写"
|
></el-input>
|
</el-form-item>
|
</div>
|
</div>
|
<div class="table-bottom-item">
|
<div class="table-bottom-l">
|
<el-form-item label="调整" prop="member_id">
|
<el-select
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.priceAdjustmentType"
|
placeholder="请选择"
|
filterable
|
@change="getTotal"
|
>
|
<el-option label="增加" :value="1"></el-option>
|
<el-option label="减少" :value="2"></el-option>
|
</el-select>
|
</el-form-item>
|
</div>
|
<div class="table-bottom-r">
|
<el-form-item label="" prop="member_id">
|
<el-input
|
:disabled="editConfig.isDisabled"
|
v-model="editConfig.infomation.priceAdjustment"
|
size="mini"
|
@change="getTotal"
|
placeholder="请填写"
|
></el-input>
|
</el-form-item>
|
</div>
|
</div>
|
<div class="table-bottom-item">
|
<div class="table-bottom-l">合计</div>
|
<div class="table-bottom-r">{{ total }}</div>
|
</div>
|
</div>
|
</div>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<!-- <el-button type="primary" size="small" @click="editConfig.visible = false">保并提交审批</el-button> -->
|
<el-button type="primary" v-if="this.editConfig.title != '查看'" size="small" @click="saveClick('form')"
|
>保存</el-button
|
>
|
<el-button size="small" v-if="this.editConfig.title != '查看'" @click="editConfig.visible = false"
|
>取消</el-button
|
>
|
</div>
|
<!-- 选择供应商名称-->
|
<SelectSupplierDialog
|
v-if="editSelectSupplierConfig.editVisible"
|
:edit-common-config="editSelectSupplierConfig"
|
@selClient="selClient"
|
/>
|
</el-dialog>
|
<BomDialog
|
ref="editDialog"
|
@sucessSet="handleGetBomKindDictList"
|
@handleConfirmSave="handleConfirmSave"
|
:editRow="editRow"
|
:workList="plcBrandList"
|
title="采购类型"
|
></BomDialog>
|
</div>
|
</template>
|
|
<script>
|
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
|
import BomDialog from "@/components/makepager/BomDialog"
|
import { getProductListTwo } from "@/api/productManage/product"
|
import {
|
addPurchase,
|
updatePurchase,
|
savePurchaseType,
|
getPurchaseType,
|
getWarehouseInfo
|
} from "@/api/purchaseManage/purchase"
|
import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog"
|
// import { formToJSON } from "axios";
|
import codeMixin from "@/components/mixin/codeMixin"
|
|
export default {
|
name: "QuotationDialog",
|
components: { SelectSupplierDialog, CommonFormTableView, BomDialog },
|
mixins: [codeMixin],
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
detailEnter: true,
|
visible: false,
|
title: "新建",
|
infomation: {}
|
}
|
}
|
}
|
},
|
data() {
|
return {
|
editConfig: this.editCommonConfig,
|
rules: {
|
purchaseTypeId: [{ required: true, message: "请选择", trigger: "change" }],
|
supplierName: [{ required: true, message: "请选择供应商名称", trigger: "change" }],
|
phone: [
|
{
|
required: false,
|
message: "请填写",
|
trigger: "change"
|
},
|
{ validator: this.validatorPhone, trigger: "change" }
|
],
|
wholeDiscount: [
|
{
|
required: false,
|
message: "请填写0-100的数字",
|
trigger: "change"
|
},
|
{ validator: this.validatorNum, trigger: "change" }
|
],
|
priceAdjustment: [
|
{
|
required: false,
|
message: "请填写",
|
trigger: "change"
|
},
|
{ validator: this.validatorNumThree, trigger: "change" }
|
],
|
number: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }],
|
warehouse: [{ required: true, message: "请选择收货仓库", trigger: "change" }],
|
signingDate: [{ required: true, message: "请选择签约日期", trigger: "change" }],
|
deliveryDate: [{ required: true, message: "请选择交付日期", trigger: "change" }],
|
},
|
productTableList: {},
|
showSummary: {
|
show: true,
|
total: false,
|
sumProp: ["price", "total"],
|
multiply: ["amount", "price"],
|
titleProp: ["编号", "产品名称", "产品编号", "计量单位", "规格", "型号", "采购单价", "描述"],
|
mergeNumber: 4,
|
totalName: "小计"
|
},
|
editSelectSupplierConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {}
|
},
|
supplierId: this.editCommonConfig.infomation.supplierId,
|
tableData: [],
|
productIndex: 0,
|
productId: "",
|
isNoProduct: true,
|
clientList: [],
|
plcBrandList: [],
|
editRow: {
|
isDefault: "pin"
|
},
|
total: 0,
|
totalTwo: 0,
|
productListIdx: 0,
|
lacks: [],
|
pickerOptions: {
|
disabledDate(time) {
|
return time.getTime() < Date.now() - 8.64e7
|
}
|
},
|
pickerOptionsBefore: {
|
disabledDate(time) {
|
return time.getTime() > Date.now()
|
}
|
},
|
receiveWhouseList: [] // 收货仓库列表
|
}
|
},
|
created() {
|
this.handleGetBomKindDictList()
|
this.getWarehouseInfo()
|
this.$store.dispatch("getSupplier")
|
this.formInfo()
|
},
|
computed: {
|
supplierList() {
|
return this.$store.state.getSupplierName.supplierList
|
}
|
},
|
watch: {
|
"editCommonConfig.visible": {
|
immediate: true,
|
handler: function () {
|
this.handleGetBomKindDictList(true)
|
}
|
}
|
},
|
methods: {
|
formInfo() {
|
this.objCode.type = "采购单编码"
|
this.objCode.codeStandID = ""
|
if (this.editConfig.infomation.codeStandardID) {
|
this.objCode.codeStandID = this.editConfig.infomation.codeStandardID
|
}
|
this.getRCodeStandardList()
|
},
|
validatorNum(rule, value, callback) {
|
if (this.editConfig.infomation.wholeDiscountType == 1) {
|
if (value == undefined || value == null || (!value && value != 0)) {
|
callback(new Error("请输入有效数字"))
|
} else {
|
var reg = /^\+?[0-9]\d*$/
|
if (!reg.test(value)) {
|
callback(new Error("请填写0-100的数字"))
|
} else {
|
if (Number(value) > 100) {
|
callback(new Error("请填写0-100的数字"))
|
} else {
|
callback()
|
}
|
}
|
}
|
} else {
|
this.validatorNumThree(rule, value, callback)
|
}
|
},
|
validatorNumThree(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)) {
|
callback(new Error("请填写2位小数的数字"))
|
} else {
|
callback()
|
}
|
}
|
} else {
|
callback()
|
}
|
},
|
// PLC配置设置
|
handleShow() {
|
this.handleGetBomKindDictList()
|
this.$refs.editDialog.editDialogVisible = true
|
},
|
// PLC配置
|
handleGetBomKindDictList(val) {
|
getPurchaseType().then((res) => {
|
this.plcBrandList = res.data
|
this.setTableForm()
|
if (val) {
|
for (let i in this.plcBrandList) {
|
if (this.plcBrandList[i][this.editRow.isDefault]) {
|
this.editConfig.infomation.purchaseTypeId = this.editConfig.infomation.purchaseTypeId
|
? this.editConfig.infomation.purchaseTypeId
|
: this.plcBrandList[i].id
|
this.$set(this.editConfig.infomation, "purchaseTypeId", this.editConfig.infomation.purchaseTypeId)
|
break
|
}
|
}
|
}
|
})
|
},
|
handleConfirmSave(data) {
|
console.log(data, "data")
|
data.forEach((ele) => {
|
delete ele.created_at
|
})
|
|
savePurchaseType(data).then(
|
(res) => {
|
if (res.code === 200) {
|
this.$message({
|
message: "操作成功!",
|
type: "success"
|
})
|
this.$refs.editDialog.editDialogVisible = false
|
this.handleGetBomKindDictList(true)
|
}
|
},
|
(err) => {
|
console.error(err)
|
this.$message({
|
message: "操作失败!",
|
type: "warning"
|
})
|
}
|
)
|
},
|
validatorPhone(rule, value, callback) {
|
if (value) {
|
if (value == undefined || value == null) {
|
callback(new Error("请输入"))
|
} else {
|
if (value.length != 11) {
|
callback(new Error("长度在11个字符!"))
|
} else {
|
var reg = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
|
if (!reg.test(value)) {
|
callback(new Error("请填写正确的联系电话!"))
|
} else {
|
callback()
|
}
|
}
|
}
|
} else {
|
callback()
|
}
|
},
|
// 保存
|
saveClick(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
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.$message.error("产品名称不能为空")
|
} else {
|
const params = this.saveParams()
|
//新建
|
if (this.editConfig.title === "新建") {
|
this.lacks = []
|
this.tableData.forEach((item) => {
|
if (this.productTableList.tableProductList.map((obj) => obj.number).includes(item.number)) {
|
console.log(`${item.name} 在数组中存在`)
|
} else {
|
this.lacks.push(item.name)
|
}
|
})
|
if (this.lacks.length > 0) {
|
this.$confirm(`当前供应商不能提供您选择的产品:${this.lacks}, 是否继续创建采购单?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
console.log("确定创建")
|
//创建采购单
|
addPurchase(params).then((res) => {
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message.success("创建成功")
|
this.$parent.getData()
|
}
|
})
|
})
|
.catch(() => {
|
console.log("取消创建")
|
})
|
} else {
|
addPurchase(params).then((res) => {
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message.success("创建成功")
|
this.$parent.getData()
|
} else {
|
this.$message.error(res.msg)
|
}
|
})
|
}
|
} else {
|
// 编辑
|
getProductListTwo({
|
supplierId: this.editConfig.infomation.supplierId,
|
page: 1,
|
pageSize: 100
|
}).then((res) => {
|
if (res.code === 200) {
|
this.lacks = []
|
// 编辑前先看看当前供应商对应的产品列表
|
this.productTableList.tableProductList = res.data.list
|
//当前产品是否在当前供应商下存在
|
this.tableData.forEach((item) => {
|
if (this.productTableList.tableProductList.map((obj) => obj.number).includes(item.number)) {
|
console.log(`${item.name} 在数组中存在`)
|
} else {
|
this.lacks.push(item.name)
|
}
|
})
|
// 不存在的产品信息
|
if (this.lacks.length > 0) {
|
this.$confirm(`当前供应商不能提供您选择的产品:${this.lacks}, 是否继续更新采购单?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
console.log("确定更新")
|
//更新采购单
|
updatePurchase(params).then((res) => {
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message.success("更新成功")
|
this.$parent.getData()
|
}
|
})
|
})
|
.catch(() => {
|
console.log("取消更新")
|
})
|
} else {
|
updatePurchase(params).then((res) => {
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message.success("更新成功")
|
this.$parent.getData()
|
}
|
})
|
}
|
}
|
})
|
}
|
}
|
} else {
|
console.log("error submit")
|
return false
|
}
|
})
|
},
|
saveParams() {
|
let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
|
|
if (this.editConfig.infomation.wholeDiscountType == 2 && this.editConfig.infomation.wholeDiscount) {
|
if (Number(this.editConfig.infomation.wholeDiscount) > Number(this.totalTwo)) {
|
this.$message.error("直接降价不能超过价税合计的总和!")
|
return true
|
}
|
}
|
let params = {
|
productList: this.tableData,
|
purchase: {
|
number: data.number || "",
|
supplierId: data.supplierId,
|
signingDate: data.signingDate || "",
|
remark: data.remark,
|
orderSource: data.orderSource || "",
|
purchaseTypeId: data.purchaseTypeId || 0,
|
phone: data.phone || "",
|
name: data.name || "",
|
deliveryDate: data.deliveryDate || "",
|
contact: data.contact,
|
wholeDiscountType: data.wholeDiscountType ? data.wholeDiscountType : 0,
|
wholeDiscount: data.wholeDiscount ? Number(data.wholeDiscount) : 0,
|
priceAdjustmentType: data.priceAdjustmentType ? data.priceAdjustmentType : 0,
|
priceAdjustment: data.priceAdjustment ? Number(data.priceAdjustment) : 0,
|
realTotalPrice: this.total ? Number(this.total) : 0,
|
totalPrice: this.totalTwo ? Number(this.totalTwo) : 0,
|
status: data.status,
|
quantity: data.quantity, // 采购数量
|
warehouse: data.warehouse || "", // 收货仓库
|
warehouseAddress: data.warehouseAddress || "", // 收货仓库地址
|
principal: data.principal || "", // 仓库负责人
|
sourceOrder: data.sourceOrder || "" // 来源单据
|
}
|
}
|
if (data.id) {
|
params.purchase.id = data.id
|
}
|
return params
|
},
|
handleClose() {
|
this.editConfig.visible = false
|
},
|
// 选择客户相关方法
|
querySearchAsync(queryString, cb, value) {
|
this.productTableList.tableProductList = []
|
var restaurants = []
|
if (value === "supplier") {
|
restaurants = this.supplierList
|
}
|
var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants
|
cb(results)
|
},
|
createStateFilter(queryString) {
|
return (state) => {
|
return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
}
|
},
|
// 选择供应商
|
async handleSelectClient(value, item) {
|
this.$refs.tableRef.supplierId=item.id
|
this.productTableList.supplierId = item.id
|
if (value === "client") {
|
this.supplierId = item.id
|
this.editConfig.infomation.supplierId = item.id
|
}
|
await getProductListTwo({
|
supplierId: item.id,
|
page: 1,
|
pageSize: 100
|
}).then((res) => {
|
if (res.code === 200) {
|
this.productTableList.tableProductList = res.data.list
|
this.$refs.tableRef.productList=res.data.list
|
console.log(this.productTableList.tableProductList, "pop")
|
}
|
})
|
},
|
selClientClick() {
|
this.editSelectSupplierConfig.editVisible = true
|
},
|
async selClient(row) {
|
this.$refs.tableRef.supplierId=row.id
|
await getProductListTwo({
|
supplierId: row.id,
|
page: 1,
|
pageSize: 100
|
}).then((res) => {
|
if (res.code === 200) {
|
this.$refs.tableRef.productList=res.data.list
|
this.productTableList.tableProductList = res.data.list
|
}
|
})
|
this.$set(this.editConfig.infomation, "supplierName", row.name)
|
this.editConfig.infomation.contact = row.contact
|
this.editConfig.infomation.phone = row.phone
|
this.editConfig.infomation.supplierId = row.id
|
},
|
// 清除已选择用户
|
async clearupClient(value) {
|
if (value == "client") {
|
this.$refs.tableRef.supplierId=null
|
this.$set(this.editConfig.infomation, "supplierName", "")
|
this.supplierId = null
|
this.$forceUpdate()
|
await getProductListTwo({
|
page: 1,
|
pageSize: 100
|
}).then((res) => {
|
if (res.code === 200) {
|
this.productTableList.tableProductList = res.data.list
|
this.$refs.tableRef.productList=res.data.list
|
console.log(this.productTableList.tableProductList, "pop")
|
}
|
})
|
}
|
},
|
setTableForm() {
|
if (!this.editConfig.infomation.id || this.editConfig.infomation.productList.length === 0) {
|
this.tableData = [
|
{
|
purchaseId: 0,
|
productId: Number(this.productId),
|
productIndex: this.productIndex,
|
amount: 1,
|
name: "",
|
number: "",
|
price: 0,
|
total: 0,
|
remark: "",
|
unit: "",
|
purchasePrice: "",
|
deliveryTime: "",
|
shippingDuration: "",
|
specifications: "",
|
modelNumber: ""
|
}
|
]
|
} else {
|
this.tableData = this.editConfig.infomation.productList
|
// this.tableData.map((item, index) => {
|
// item.productId = index + 1;
|
// });
|
}
|
this.productTableList = {
|
tableProductList: [],
|
supplierId: undefined,
|
tableData: this.tableData,
|
disabled: this.editConfig.isDisabled,
|
isReturn: true,
|
tableColumn: [
|
{
|
label: "产品名称",
|
prop: "name",
|
min: 180,
|
productName: true,
|
isRequird: true,
|
disabled: this.editConfig.isDisabled
|
},
|
{ label: "产品编号", prop: "number", min: 150 },
|
{ label: "计量单位", prop: "unit" },
|
{ label: "规格", prop: "specifications" },
|
{ label: "型号", prop: "modelNumber" },
|
{ label: "数量", prop: "amount", inputNumber: true, disabled: this.editConfig.isDisabled },
|
{
|
label: "采购单价",
|
prop: "purchasePrice",
|
inputFloat: true,
|
isRequird: true,
|
disabled: this.editConfig.isDisabled
|
},
|
{ label: "价税合计", prop: "total", inputFloat: true, disabled: this.editConfig.isDisabled, multiply: true },
|
{ label: "描述", prop: "remark", input: true, disabled: this.editConfig.isDisabled }
|
]
|
}
|
this.toal = this.editConfig.infomation.realTotalPrice
|
},
|
// 产品列表输入
|
inputContent(val, prop, row) {
|
let num = 0
|
this.tableData.map((item) => {
|
num += item.amount
|
if (item.number === row.number) {
|
item[prop] = val
|
}
|
})
|
if (prop === "amount") {
|
this.editConfig.infomation.quantity = num
|
}
|
},
|
getSummaries(total) {
|
this.totalTwo = JSON.parse(JSON.stringify(total))
|
this.total = total
|
this.getTotal()
|
},
|
getTotal() {
|
let prie = 0
|
if (this.editConfig.infomation.priceAdjustmentType == 1) {
|
prie = Number(this.editConfig.infomation.priceAdjustment)
|
} else if (this.editConfig.infomation.priceAdjustmentType == 2) {
|
prie = -1 * Number(this.editConfig.infomation.priceAdjustment)
|
} else {
|
prie = 0
|
}
|
let t = 0
|
if (this.editConfig.infomation.wholeDiscountType == 1) {
|
t = (this.totalTwo * Number(this.editConfig.infomation.wholeDiscount)) / 100
|
} else if (this.editConfig.infomation.wholeDiscountType == 2) {
|
t = Number(this.editConfig.infomation.wholeDiscount)
|
} else {
|
t = 0
|
}
|
this.total = this.totalTwo - t + Number(prie)
|
},
|
// 产品新增
|
addProductClick() {
|
// this.productIndex++
|
// this.tableData.push({
|
// productIndex: this.productIndex,
|
// productId: "",
|
// id: 0,
|
// amount: 0,
|
// desc: "",
|
// name: "",
|
// number: "",
|
// price: 0,
|
// total: 0
|
// })
|
// this.showSummary.show = true
|
},
|
// 新增方式修改
|
getSelectArray(val, index) {
|
console.log(val, "ddd99999")
|
if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
|
this.tableData = []
|
}
|
if (index < this.tableData.length) {
|
this.tableData.splice(index, 1)
|
val.map((item, ind) => {
|
this.tableData.splice(index + ind, 0, item)
|
})
|
} else {
|
this.tableData = this.tableData.concat(val)
|
}
|
this.productTableList.tableData = this.tableData
|
this.showSummary.show = true
|
},
|
// 产品清空
|
emptyProductClick() {
|
this.productIndex = 1
|
this.tableData = [
|
{
|
productId: "",
|
productIndex: this.productIndex,
|
id: 0,
|
amount: "0",
|
desc: "",
|
name: "",
|
number: "",
|
price: 0,
|
total: 0
|
}
|
]
|
this.productTableList.tableData = this.tableData
|
},
|
clearupProduct(data) {
|
this.tableData = data
|
this.productTableList.tableData = this.tableData
|
},
|
//选择行
|
rowClick(row) {
|
console.log(row, "xuanze")
|
this.productListIdx = row.productIndex
|
},
|
//选中产品
|
handleProduct(item) {
|
this.tableData[this.productListIdx].productId = Number(item.id)
|
console.log(item, "选中产品", this.tableData)
|
},
|
// 获取收货仓库列表
|
async getWarehouseInfo() {
|
await getWarehouseInfo().then((res) => {
|
console.log(res)
|
this.receiveWhouseList = res.data.info
|
})
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
.table-bottom {
|
width: 500px;
|
float: right;
|
margin-right: 20px;
|
margin-top: 10px;
|
height: auto;
|
line-height: 30px;
|
font-size: 14px;
|
font-weight: 700;
|
margin-bottom: 20px;
|
color: #333;
|
.table-bottom-item {
|
width: 100%;
|
text-align: right;
|
.table-bottom-l {
|
width: 250px;
|
float: left;
|
}
|
.table-bottom-r {
|
width: calc(100% - 250px);
|
float: right;
|
}
|
}
|
}
|
::v-deep {
|
.iframe-dialog .el-dialog__body {
|
.basic-info {
|
overflow: hidden;
|
.basic-info-title {
|
background-color: #f4f8fe;
|
padding-left: 10px;
|
font-size: 15px;
|
font-weight: bold;
|
color: #666;
|
height: 42px;
|
line-height: 42px;
|
}
|
.basic-info-view {
|
margin-top: 10px;
|
padding-right: 40px;
|
.custom-name,
|
.common-select {
|
display: flex;
|
.common-select-sel {
|
width: 270px;
|
}
|
.common-select-btn {
|
margin-left: 5px;
|
font-size: 16px;
|
cursor: pointer;
|
}
|
}
|
}
|
.annex-view {
|
display: flex;
|
color: #6166d3;
|
.setFormat {
|
margin-left: 10px;
|
}
|
}
|
}
|
.unflod-collapse {
|
display: flex;
|
height: 30px;
|
justify-content: center;
|
align-items: center;
|
color: #6166d3;
|
}
|
.dialog-footer {
|
background-color: #f5f5f5;
|
height: 55px;
|
line-height: 55px;
|
}
|
}
|
}
|
</style>
|