<template>
|
<div class="add-common">
|
<el-dialog
|
:title="addCommonConfig.title + '供应商'"
|
:visible.sync="editConfig.visible"
|
:width="dialogWidth"
|
:before-close="handleClose"
|
:close-on-click-modal="false"
|
append-to-body
|
custom-class="iframe-dialog"
|
>
|
<el-form
|
ref="form"
|
:model="editConfig.infomation"
|
:rules="rules"
|
label-position="right"
|
label-width="308px"
|
size="mini"
|
>
|
<!-- 信息 -->
|
<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-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="供应商名称" prop="supplier_name">
|
<el-input v-model="editConfig.infomation.name"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="供应商类型" prop="supplierType_id">
|
<div class="custom-name">
|
<el-select
|
v-model="editConfig.infomation.supplierType_id"
|
placeholder="请选择供应商类型"
|
class="common-select-sel"
|
size="mini"
|
>
|
<el-option v-for="item in supplierTypeOptions" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
<div class="common-select-btn" @click="setSupplierType"><i class="el-icon-setting"></i></div>
|
</div>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="所属行业" prop="industry_id">
|
<div class="custom-name">
|
<el-select
|
v-model="editConfig.infomation.industry_id"
|
placeholder="请选择供应商行业"
|
class="common-select-sel"
|
size="mini"
|
>
|
<el-option v-for="item in industryOptions" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
<div class="common-select-btn" @click="setIndustry"><i class="el-icon-setting"></i></div>
|
</div>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="联系人" prop="contact_name">
|
<el-input v-model="editConfig.infomation.contact_name"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="联系电话" prop="phone">
|
<el-input
|
v-model="editConfig.infomation.phone"
|
maxlength="11"
|
show-word-limit
|
oninput="value=value.replace(/[^\d]/g,'')"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="销售负责人" prop="sale_member">
|
<el-input v-model="editConfig.infomation.sale_member" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="邮箱" prop="email">
|
<el-input v-model="editConfig.infomation.email"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="详细地址" prop="address_detail">
|
<el-input
|
type="textarea"
|
:autosize="{ minRows: 2 }"
|
placeholder="请输入内容"
|
v-model="editConfig.infomation.address_detail"
|
disabled
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="网址" prop="webUrl">
|
<el-input v-model="editConfig.infomation.webUrl" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
<!-- 入驻信息 -->
|
<div class="basic-info-title">入驻信息</div>
|
<div class="basic-info-view">
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="户名" prop="account_name">
|
<el-input v-model="editConfig.infomation.account_name" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="开户行" prop="account_name">
|
<el-input v-model="editConfig.infomation.account_name" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="账号" prop="account_name">
|
<el-input v-model="editConfig.infomation.account_name" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="附件" prop="">
|
<template slot="label">
|
<div style="display: flex; float: right">
|
<div style="font-size: 16px">
|
<i class="el-icon-warning-outline" title="最多上传20个附件,最大限制5MB"></i>
|
</div>
|
<span style="margin-left: 5px">合同附件</span>
|
</div>
|
</template>
|
<div class="annex-view">
|
<div @click="addAnnexClick">
|
<div style="display: flex; float: right">
|
<div style="font-size: 16px"><i class="el-icon-paperclip"></i></div>
|
<span>添加附件</span>
|
</div>
|
</div>
|
</div>
|
<div class="file-content">
|
<div>文件名称</div>
|
<div>
|
<el-button type="text">预览</el-button>
|
<el-button type="text">下载</el-button>
|
<el-button type="text">删除</el-button>
|
</div>
|
</div>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
</div>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" size="small" @click="saveClick('form')">保 存</el-button>
|
<el-button size="small" @click="editConfig.visible = false">取 消</el-button>
|
</div>
|
</el-dialog>
|
<!-- 编辑下拉框 -->
|
<EditDropdownDialog v-if="editDropdownConfig.editVisible" :edit-dropdown-config="editDropdownConfig" />
|
</div>
|
</template>
|
|
<script>
|
import { getAddContact, getUpdateContact } from "@/api/client/contacts"
|
import EditDropdownDialog from "@/views/other/commonDialog/EditDropdownDialog"
|
export default {
|
name: "AddSupplierDialog",
|
props: {
|
addCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
}
|
}
|
}
|
},
|
components: { EditDropdownDialog },
|
computed: {},
|
data() {
|
return {
|
dialogWidth: "80%",
|
editConfig: this.addCommonConfig,
|
rules: {
|
supplier_name: [{ required: true, message: "请输入", trigger: "blur" }],
|
member_id: [{ required: true, message: "请选择", trigger: "change" }],
|
phone: [
|
{ required: false, message: "", trigger: "blur" },
|
{ len: 11, message: "长度在11个字符", trigger: "blur" },
|
{
|
pattern: /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/,
|
message: "请输入正确的手机号",
|
trigger: "blur"
|
}
|
],
|
email: [
|
{ required: false, message: "", trigger: "blur" },
|
{
|
pattern: /^[a-zA-Z0-9_\\.]+@[a-zA-Z0-9-]+[\\.a-zA-Z]+$/,
|
message: "请输入正确的邮箱格式",
|
trigger: "blur"
|
}
|
]
|
},
|
supplierTypeOptions: [], // 供应商类型
|
industryOptions: [], // 所属行业
|
memberOptions: [],
|
editDropdownConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {}
|
}
|
}
|
},
|
created() {
|
if (this.editConfig.title !== "新建" && this.editConfig.infomation.province_id !== 0) {
|
this.getCityList(this.editConfig.infomation.province_id, "edit")
|
}
|
},
|
methods: {
|
handleClose() {
|
this.editConfig.visible = false
|
},
|
// 保存
|
saveClick(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
console.log(this.editConfig.infomation)
|
const params = this.saveParams()
|
console.log(params)
|
if (this.editConfig.title === "新建") {
|
getAddContact(params)
|
.then((res) => {
|
console.log(res)
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message({
|
message: "添加成功",
|
type: "success"
|
})
|
this.$parent.getData()
|
}
|
})
|
.catch((err) => {
|
console.log(err)
|
})
|
} else {
|
getUpdateContact(params)
|
.then((res) => {
|
console.log(res)
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message({
|
message: "编辑成功",
|
type: "success"
|
})
|
this.$parent.getData()
|
}
|
})
|
.catch((err) => {
|
console.log(err)
|
})
|
}
|
} else {
|
console.log("error submit")
|
return false
|
}
|
})
|
},
|
saveParams() {
|
let data = this.editConfig.infomation
|
let params = {
|
id: this.editConfig.title === "新建" ? 0 : data.id,
|
birthday: data.birthday || "",
|
city_id: data.city_id || 0,
|
client_id: this.clientId || 0,
|
country_id: data.country_id || 0,
|
desc: data.desc || "",
|
email: data.email || "",
|
is_first: data.is_first || false,
|
member_id: data.member_id || 0,
|
name: data.name || "",
|
number: data.number || "",
|
phone: data.phone || "",
|
position: data.position || "",
|
province_id: data.province_id || 0,
|
region_id: data.region_id || 0,
|
wechat: data.wechat || ""
|
}
|
return params
|
},
|
// 添加附件
|
addAnnexClick() {},
|
// 设置供应商类型
|
setSupplierType() {
|
this.editDropdownConfig.editVisible = true
|
this.editDropdownConfig.title = "供应商类型"
|
},
|
// 设置所属行业
|
setIndustry() {
|
this.editDropdownConfig.editVisible = true
|
this.editDropdownConfig.title = "所属行业"
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
::v-deep {
|
.iframe-dialog .el-dialog__body {
|
.basic-info {
|
.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-btn {
|
margin-left: 5px;
|
font-size: 18px;
|
cursor: pointer;
|
}
|
}
|
.common-select {
|
.common-select-sel {
|
width: 270px;
|
}
|
}
|
}
|
.annex-view {
|
display: flex;
|
color: #6166d3;
|
.setFormat {
|
margin-left: 10px;
|
}
|
}
|
.file-content {
|
display: flex;
|
}
|
}
|
.dialog-footer {
|
background-color: #f5f5f5;
|
height: 55px;
|
line-height: 55px;
|
}
|
}
|
}
|
</style>
|