<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="purchaseTypeId"
|
class="form-item float_left"
|
>
|
<el-select
|
placeholder="请选择采购类型"
|
v-model="editConfig.infomation.purchaseTypeId"
|
clearable
|
style="width: calc(100% - 30px)"
|
>
|
<el-option
|
v-for="ele in plcBrandList"
|
:key="ele.name"
|
:label="ele.name"
|
:value="ele.ID"
|
></el-option>
|
</el-select>
|
<i
|
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
|
style="width: calc(100% - 40px)"
|
v-model="editConfig.infomation.supplierName"
|
:fetch-suggestions="
|
(queryString, callback) => {
|
querySearchAsync(queryString, callback, 'client');
|
}
|
"
|
value-key="name"
|
placeholder="请选择"
|
@select="handleSelectClient('client', $event)"
|
></el-autocomplete>
|
<div
|
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" 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
|
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
|
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
|
v-model="editConfig.infomation.phone"
|
placeholder="请填写"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="签约日期" prop="signingDate">
|
<el-date-picker
|
v-model="editConfig.infomation.signingDate"
|
style="width: 100%"
|
type="date"
|
clearable
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="交付日期" prop="deliveryDate">
|
<el-date-picker
|
v-model="editConfig.infomation.deliveryDate"
|
style="width: 100%"
|
type="date"
|
clearable
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="备注信息" prop="remark">
|
<el-input
|
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
|
:show-summary="showSummary"
|
:recalculateShow="false"
|
:product-table-list="productTableList"
|
@inputContent="inputContent"
|
@addProductClick="addProductClick"
|
@emptyProductClick="emptyProductClick"
|
@clearupProduct="clearupProduct"
|
/>
|
</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="请选择"
|
filterable
|
>
|
<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"
|
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
|
v-model="editConfig.infomation.priceAdjustmentType"
|
placeholder="请选择"
|
filterable
|
>
|
<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.priceAdjustment"
|
size="mini"
|
placeholder="请填写"
|
></el-input>
|
</el-form-item>
|
</div>
|
</div>
|
<div class="table-bottom-item">
|
<div class="table-bottom-l">合计</div>
|
<div class="table-bottom-r">{{ editConfig.infomation.realTotalPrice }}</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" size="small" @click="saveClick('form')"
|
>保存</el-button
|
>
|
<el-button size="small" @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 {
|
addPurchase,
|
updatePurchase,
|
savePurchaseType,
|
getPurchaseType,
|
} from "@/api/purchaseManage/purchase";
|
|
import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog";
|
export default {
|
name: "QuotationDialog",
|
components: { SelectSupplierDialog, CommonFormTableView,BomDialog },
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
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: "请填写",
|
trigger: "change",
|
},
|
{ validator: this.validatorNum, trigger: "change" },
|
],
|
priceAdjustment: [
|
{
|
required: false,
|
message: "请填写",
|
trigger: "change",
|
},
|
{ validator: this.validatorNumThree, trigger: "change" },
|
],
|
},
|
productTableList: {},
|
showSummary: {
|
show: true,
|
total: false,
|
sumProp: ["price", "total"],
|
titleProp: [
|
"编号",
|
"产品名称",
|
"产品编号",
|
"计量单位",
|
"规格型号",
|
"采购单价",
|
"描述",
|
],
|
mergeNumber: 4,
|
},
|
editSelectSupplierConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {},
|
},
|
supplierId: this.editCommonConfig.infomation.supplierId,
|
tableData: [],
|
productId: 1,
|
isNoProduct: true,
|
clientList: [],
|
plcBrandList:[],
|
editRow:{
|
isDefault:'pin'
|
}
|
};
|
},
|
created() {
|
this.setTableForm();
|
},
|
computed: {
|
},
|
watch:{
|
'editCommonConfig.visible':{
|
immediate:true,
|
handler:function(){
|
|
this.setTableForm();
|
}
|
}
|
},
|
methods: {
|
validatorNum(rule, value, callback) {
|
if (value) {
|
if (value == undefined || value == null) {
|
callback(new Error("请输入有效数字"));
|
} else {
|
var reg = /^\+?[0-9]\d*$/;
|
if (!reg.test(value)) {
|
callback(new Error("请填写不小于0的数字"));
|
} else {
|
callback();
|
}
|
}
|
} else {
|
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) {
|
console.log(val,'val')
|
getPurchaseType().then((res) => {
|
this.plcBrandList = res.data;
|
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')
|
savePurchaseType(data).then((res) => {
|
if (res.code == 200) {
|
this.$message({
|
message: "操作成功!",
|
type: "success",
|
});
|
this.$refs.editDialog.editDialogVisible = false;
|
this.handleGetBomKindDictList(true);
|
}
|
});
|
},
|
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();
|
console.log(params);
|
if (this.editConfig.title === "创建") {
|
addPurchase(params).then((res) => {
|
console.log(res);
|
this.editConfig.visible = false;
|
if (res.code === 200) {
|
this.$message.success("添加成功");
|
this.$parent.getData();
|
}
|
});
|
} 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));
|
let params = {
|
productList:this.tableData,
|
purchase:{
|
supplierId:this.supplierId||0,
|
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,
|
wholeDiscount:Number(data.wholeDiscount),
|
priceAdjustmentType:data.priceAdjustmentType,
|
priceAdjustment:Number(data.priceAdjustment),
|
realTotalPrice:data.realTotalPrice||'',
|
}
|
};
|
if(data.ID){
|
params.purchase.id=data.ID
|
}
|
return params;
|
},
|
handleClose() {
|
this.editConfig.visible = false;
|
},
|
// 选择客户相关方法
|
querySearchAsync(queryString, cb, value) {
|
var restaurants = [];
|
if (value === "client") {
|
restaurants = this.clientList;
|
}
|
var results = queryString
|
? restaurants.filter(this.createStateFilter(queryString))
|
: restaurants;
|
cb(results);
|
},
|
createStateFilter(queryString) {
|
return (state) => {
|
return (
|
state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
);
|
};
|
},
|
handleSelectClient(value, item) {
|
console.log(value);
|
if (value === "client") {
|
this.supplierId = item.id;
|
}
|
},
|
selClientClick() {
|
this.editSelectSupplierConfig.editVisible = true;
|
},
|
selClient(row) {
|
this.$set(this.editConfig.infomation,'supplierName',row.name)
|
this.editConfig.infomation.contact = row.contact;
|
this.editConfig.infomation.phone = row.phone;
|
this.supplierId = row.ID;
|
},
|
// 清除已选择用户
|
clearupClient(value) {
|
if (value == "client") {
|
this.$set(this.editConfig.infomation, "supplierName", "");
|
this.supplierId = null;
|
this.$forceUpdate();
|
}
|
},
|
setTableForm() {
|
if (
|
!this.editConfig.infomation.ID ||
|
this.editConfig.infomation.productList.length === 0
|
) {
|
this.tableData = [
|
{
|
productId: this.productId,
|
id: 0,
|
amount: 0,
|
desc: "",
|
name: "",
|
number: "",
|
price: 0,
|
total: 0,
|
},
|
];
|
} else {
|
this.tableData = this.editConfig.infomation.productList;
|
// this.tableData.map((item, index) => {
|
// item.productId = index + 1;
|
// });
|
}
|
this.productTableList = {
|
tableData: this.tableData,
|
tableColumn: [
|
{
|
label: "产品名称",
|
prop: "name",
|
min: 170,
|
productName: true,
|
isRequird: true,
|
},
|
{ label: "产品编号", prop: "number" },
|
{ label: "计量单位", prop: "unit" },
|
{ label: "规格型号", prop: "specifications" },
|
{ label: "数量", prop: "amount", inputNumber: true, isRequird: true },
|
{
|
label: "采购单价",
|
prop: "price",
|
inputFloat: true,
|
isRequird: true,
|
},
|
{ label: "价税合计", prop: "total", inputFloat: true },
|
{ label: "描述", prop: "remark", input: true },
|
],
|
};
|
this.handleGetBomKindDictList(true);
|
},
|
// 产品列表输入
|
inputContent(val, prop, row) {
|
this.productId = row.productId;
|
this.tableData.map((item) => {
|
if (item.productId === row.productId) {
|
item[prop] = val;
|
}
|
});
|
},
|
// 产品新增
|
addProductClick() {
|
this.productId++;
|
this.tableData.push({
|
productId: this.productId,
|
id: 0,
|
amount: 0,
|
desc: "",
|
name: "",
|
number: "",
|
price: 0,
|
total: 0,
|
});
|
this.showSummary.show = true;
|
},
|
// 产品清空
|
emptyProductClick() {
|
this.productId = 1;
|
this.tableData = [
|
{
|
productId: this.productId,
|
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;
|
},
|
},
|
};
|
</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>
|