<template>
|
<div class="add-quotation">
|
<el-dialog
|
:title="editCommonConfig.title + '采购单'"
|
:visible.sync="editConfig.visible"
|
:width="dialogWidth"
|
: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="brand"
|
class="form-item float_left"
|
>
|
<el-select
|
placeholder="请选择采购类型"
|
v-model="editConfig.infomation.client_name"
|
clearable
|
style="width: calc(100% - 30px)"
|
>
|
<el-option
|
v-for="ele in plcBrandList"
|
: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: #333"
|
@click="handleShow"
|
></i>
|
</el-form-item>
|
</el-col>
|
|
<el-col :span="12">
|
<el-form-item label="供应商名称" prop="client_name">
|
<div class="custom-name">
|
<el-autocomplete
|
style="width: calc(100% - 40px)"
|
v-model="editConfig.infomation.client_name"
|
: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.client_name &&
|
editConfig.infomation.client_name.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="number">
|
<el-input
|
v-model="editConfig.infomation.number"
|
placeholder="请填写"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="采购单名称" prop="number">
|
<el-input
|
v-model="editConfig.infomation.number"
|
placeholder="请填写"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="供应商联系人" prop="number">
|
<el-input
|
v-model="editConfig.infomation.number"
|
placeholder="请填写"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="联系电话" prop="contact_phone">
|
<el-input
|
v-model="editConfig.infomation.contact_phone"
|
placeholder="请填写"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="签约日期" prop="validity_date">
|
<el-date-picker
|
v-model="editConfig.infomation.validity_date"
|
style="width: 100%"
|
type="date"
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="交付日期" prop="validity_date">
|
<el-date-picker
|
v-model="editConfig.infomation.validity_date"
|
style="width: 100%"
|
type="date"
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="备注信息" prop="member_id">
|
<el-input
|
type="textarea"
|
:autosize="{ minRows: 3, maxRows: 4 }"
|
maxlength="500"
|
clearable
|
v-model="editConfig.infomation.member_id"
|
></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"
|
@recalculateProductClick="recalculateProductClick"
|
@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.fieldName"
|
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.number"
|
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.fieldName"
|
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.number"
|
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">26000.00</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>
|
<!-- 选择客户 -->
|
<SelectClientDialog
|
v-if="editSelectClientConfig.editVisible"
|
:edit-common-config="editSelectClientConfig"
|
@selClient="selClient"
|
/>
|
</el-dialog>
|
<BomDialog
|
ref="editDialog"
|
@sucessSet="handleGetBomKindDictList"
|
@handleConfirmSave="handleConfirmSave"
|
:workList="plcBrandList"
|
title="采购类型"
|
></BomDialog>
|
</div>
|
</template>
|
|
<script>
|
import CommonFormTableView from "@/components/makepager/CommonFormTableView";
|
import BomDialog from "@/components/makepager/BomDialog";
|
import {
|
getAddQuotation,
|
getUpdateQuotation,
|
getAllData,
|
} from "@/api/purchaseManage/purchase";
|
// import {
|
// postGetUnitDictList,
|
// postGetSaveSUnitDict,
|
// } from "@/api/purchaseManage/purchase";
|
import SelectClientDialog from "@/views/purchaseManage/purchase/components/SelectClientDialog";
|
export default {
|
name: "QuotationDialog",
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
visible: false,
|
title: "创建",
|
infomation: {},
|
};
|
},
|
},
|
},
|
components: { SelectClientDialog, CommonFormTableView,BomDialog },
|
computed: {
|
searchCommonHeight() {
|
return this.$refs.searchCommonView.offsetHeight;
|
},
|
contactNamelist() {
|
return this.$store.state.getClientName.contactNamelist;
|
},
|
},
|
data() {
|
return {
|
dialogWidth: "50%",
|
editConfig: this.editCommonConfig,
|
rules: {
|
client_id: [{ required: true, message: "请输入", trigger: "blur" }],
|
number: [{ required: true, message: "请输入", trigger: "blur" }],
|
quotation_status_id: [
|
{ required: true, message: "请选择", trigger: "change" },
|
],
|
member_id: [
|
{ required: true, message: "请选择负责人", trigger: "change" },
|
],
|
contact_phone: [
|
{
|
required: true,
|
message: "请填写",
|
trigger: "change",
|
},
|
{ validator: this.validatorPhone, trigger: "change" },
|
],
|
},
|
memberOptions: [],
|
quotationStatusOptions: [{ id: 1, name: "不知道" }], // 报价单状态
|
currencyOptions: [{ id: 1, name: "人民币" }], // 币种
|
approvalWorkflowOptions: [], // 审批流程
|
productTableList: {},
|
showSummary: {
|
show: true,
|
total: false,
|
sumProp: ["Amount", "total"],
|
titleProp: [
|
"编号",
|
"产品名称",
|
"产品编号",
|
"计量单位",
|
"规格型号",
|
"采购单价",
|
"描述",
|
],
|
mergeNumber: 4,
|
},
|
editSelectClientConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {},
|
},
|
clientId: this.editCommonConfig.infomation.client_id,
|
contactId: this.editCommonConfig.infomation.contact_id,
|
saleChanceId: this.editCommonConfig.infomation.sale_chance_id,
|
tableData: [],
|
productId: 1,
|
isNoProduct: true,
|
clientList: [],
|
plcBrandList:[],
|
};
|
},
|
created() {
|
this.setTableForm();
|
this.getCommonData();
|
},
|
methods: {
|
// PLC配置设置
|
handleShow() {
|
// this.handleGetBomKindDictList();
|
this.$refs.editDialog.editDialogVisible = true;
|
},
|
// PLC配置
|
handleGetBomKindDictList(val) {
|
console.log(val,'val')
|
// postGetUnitDictList().then((res) => {
|
// this.plcBrandList = res.data;
|
// if (val) {
|
// for (let i in this.plcBrandList) {
|
// if (this.plcBrandList[i].isDefault) {
|
// this.form.unit = this.form.unit
|
// ? this.form.unit
|
// : this.plcBrandList[i].name;
|
// this.$set(this.form, "unit", this.form.unit);
|
// break;
|
// }
|
// }
|
// }
|
// });
|
},
|
handleConfirmSave(data) {
|
console.log(data,'data')
|
// postGetSaveSUnitDict({ data: data }).then((res) => {
|
// if (res.code == 200) {
|
// this.$message({
|
// message: "操作成功!",
|
// type: "success",
|
// });
|
// this.$refs.editDialog.editDialogVisible = false;
|
// this.handleGetBomKindDictList();
|
// }
|
// });
|
},
|
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();
|
}
|
},
|
getCommonData() {
|
getAllData()
|
.then((res) => {
|
this.memberOptions = res.data.member;
|
this.quotationStatusOptions = res.data.quotationStatus;
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
|
// 保存
|
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 === "创建") {
|
getAddQuotation(params).then((res) => {
|
console.log(res);
|
this.editConfig.visible = false;
|
if (res.code === 200) {
|
this.$message.success("添加成功");
|
this.$parent.getData();
|
}
|
});
|
} else {
|
getUpdateQuotation(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 = this.editConfig.infomation;
|
let params = {
|
id: this.editConfig.title === "创建" ? 0 : data.id,
|
client_id: this.clientId || 0,
|
conditions: data.conditions || "",
|
contact_id: this.contactId || 0,
|
file: data.file || "",
|
member_id: data.member_id || 0,
|
number: data.number || "",
|
quotation_status_id: data.quotation_status_id || 0,
|
sale_chance_id: this.saleChanceId || 0,
|
validity_date: data.validity_date || "",
|
products: this.tableData,
|
};
|
return params;
|
},
|
handleClose() {
|
this.editConfig.visible = false;
|
},
|
// 选择客户相关方法
|
querySearchAsync(queryString, cb, value) {
|
var restaurants = [];
|
if (value === "client") {
|
restaurants = this.clientList;
|
} else if (value === "contact") {
|
restaurants = this.contactNamelist;
|
}
|
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.clientId = item.id;
|
} else if (value === "chance") {
|
this.saleChanceId = item.id;
|
} else {
|
this.contactId = item.id;
|
}
|
},
|
selClientClick() {
|
this.editSelectClientConfig.editVisible = true;
|
},
|
selClient(row) {
|
this.editConfig.infomation.client_name = row.name;
|
this.clientId = row.id;
|
},
|
// 清除已选择用户
|
clearupClient(value) {
|
if (value == "client") {
|
this.editConfig.infomation.client_name = "";
|
this.$set(this.editConfig.infomation, "client_name", "");
|
this.clientId = null;
|
this.$forceUpdate();
|
}
|
},
|
// 添加附件
|
addAnnexClick() {},
|
// 设置允许上传文件格式
|
setFormatClick() {},
|
setTableForm() {
|
if (
|
this.editConfig.title === "创建" ||
|
this.editConfig.infomation.products.length === 0
|
) {
|
this.tableData = [
|
{
|
productId: this.productId,
|
id: 0,
|
amount: 0,
|
desc: "",
|
name: "",
|
number: "",
|
price: 0,
|
total: 0,
|
},
|
];
|
} else {
|
this.tableData = this.editConfig.infomation.products;
|
this.tableData.map((item, index) => {
|
item.productId = index + 1;
|
});
|
}
|
this.productTableList = {
|
tableData: this.tableData,
|
tableColumn: [
|
{ label: "编号", prop: "productId", width: 40 },
|
{
|
label: "产品名称",
|
prop: "name",
|
productName: true,
|
isRequird: true,
|
},
|
{ label: "产品编号", prop: "number" },
|
{ label: "计量单位", prop: "number" },
|
{ label: "规格型号", prop: "number" },
|
{ label: "数量", prop: "amount", inputNumber: true, isRequird: true },
|
{
|
label: "采购单价",
|
prop: "price",
|
inputFloat: true,
|
isRequird: true,
|
},
|
{ label: "价税合计", prop: "total", inputFloat: true },
|
{ label: "描述", prop: "name", input: 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;
|
},
|
// 产品重算
|
recalculateProductClick() {},
|
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>
|