<template>
|
<div class="add-contract-manage">
|
<el-dialog
|
:title="editCommonConfig.title + '合同管理'"
|
:visible.sync="editConfig.visible"
|
:width="dialogWidth"
|
:before-close="handleClose"
|
>
|
<el-form
|
ref="form"
|
:model="editConfig.infomation"
|
:rules="rules"
|
label-position="right"
|
label-width="168px"
|
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="client_name">
|
<div class="custom-name">
|
<el-autocomplete
|
v-model="editConfig.infomation.client_name"
|
:fetch-suggestions="
|
(queryString, callback) => {
|
querySearchAsync(queryString, callback, 'client')
|
}
|
"
|
value-key="name"
|
@select="handleSelectClient('client', $event)"
|
style="width: 100%"
|
></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" style="width: 100%"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="负责人" prop="memberId">
|
<el-select
|
v-model="editConfig.infomation.memberId"
|
placeholder="请选择"
|
size="mini"
|
style="width: 100%"
|
>
|
<el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="合同状态" prop="statusId">
|
<div class="common-select">
|
<el-select
|
v-model="editConfig.infomation.statusId"
|
placeholder="请选择"
|
class="common-select-sel"
|
size="mini"
|
style="width: 100%"
|
>
|
<el-option v-for="item in statusOptions" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
<!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
|
</div>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="销售报价单" prop="quotation_number">
|
<div class="custom-name">
|
<el-autocomplete
|
v-model="editConfig.infomation.quotation_number"
|
:fetch-suggestions="
|
(queryString, callback) => {
|
querySearchAsync(queryString, callback, 'quotation')
|
}
|
"
|
value-key="number"
|
@select="handleSelectClient('quotation', $event)"
|
style="width: 100%"
|
></el-autocomplete>
|
<div class="common-select-btn" @click="selClientClick('quotation')">
|
<i class="el-icon-circle-plus-outline" title="选择"></i>
|
</div>
|
<div
|
v-if="editConfig.infomation.quotation_number && editConfig.infomation.quotation_number.length > 0"
|
class="common-select-btn"
|
@click="clearupClient('quotation')"
|
>
|
<i class="el-icon-remove-outline" title="清除"></i>
|
</div>
|
</div>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
<!-- 附件信息 -->
|
<div v-if="isUnflod" class="basic-info-title">附件信息</div>
|
<div class="basic-info-view">
|
<el-row>
|
<el-col :span="12">
|
<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 class="setFormat" @click="setFormatClick">设置允许上传的文件格式</div>
|
</div>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
<!-- 展开收起 -->
|
<!-- <div v-if="editConfig.title === '新建'" class="unflod-collapse" @click="unflodCollapseClick">
|
<div>{{ unflodCollapseStr }}</div>
|
<div v-if="isUnflod"><i class="el-icon-arrow-up"></i></div>
|
<div v-else><i class="el-icon-arrow-down"></i></div>
|
</div> -->
|
<!-- 选择审批流程 -->
|
<!-- <div class="basic-info-title">选择审批流程</div>
|
<div class="basic-info-view">
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="审批流程" prop="approvalWorkflow">
|
<el-select
|
v-model="editConfig.infomation.approvalWorkflow"
|
placeholder="请选择"
|
size="mini"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in approvalWorkflowOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="20">
|
<el-form-item label="审批步骤" prop="approvalSteps">
|
<el-input v-model="editConfig.infomation.approvalSteps"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="20">
|
<el-form-item label="审批人" prop="approvalPerson">
|
<el-input v-model="editConfig.infomation.approvalPerson"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="20">
|
<el-form-item label="审批意见" prop="approvalOpinion">
|
<el-input v-model="editConfig.infomation.approvalOpinion" type="textarea" :rows="2"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</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"
|
/>
|
<!-- 报价单 -->
|
<SelectCommonDialog
|
v-if="editSelCommonConfig.editVisible"
|
:edit-common-config="editSelCommonConfig"
|
@selClient="selClient"
|
/>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { getAllData } from "@/api/client/client"
|
import { getAddContract, getUpdateContract } from "@/api/sales/contractManage"
|
import SelectClientDialog from "@/views/other/commonDialog/SelectClientDialog"
|
import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog"
|
export default {
|
name: "AddContractManageDialog",
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
}
|
}
|
}
|
},
|
components: { SelectClientDialog, SelectCommonDialog },
|
computed: {
|
clientList() {
|
return this.$store.state.getClientName.clientList
|
},
|
quotationList() {
|
return this.$store.state.getClientName.quotationList
|
}
|
},
|
data() {
|
return {
|
dialogWidth: "50%",
|
editConfig: this.editCommonConfig,
|
rules: {
|
number: [{ required: true, message: "请输入", trigger: "blur" }],
|
member_id: [{ required: true, message: "请选择", trigger: "change" }]
|
},
|
memberOptions: [],
|
statusOptions: [], // 合同状态
|
approvalWorkflowOptions: [], // 审批流程
|
unflodCollapseStr: "收起",
|
isUnflod: true,
|
editSelectClientConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {}
|
},
|
editSelCommonConfig: {
|
editVisible: false,
|
title: "",
|
infomation: {}
|
},
|
clientId: this.editCommonConfig.infomation.clientId,
|
quotationId: this.editCommonConfig.infomation.quotationId
|
}
|
},
|
created() {
|
this.$store.dispatch("geClient")
|
this.$store.dispatch("geQuotation")
|
this.getCommonData()
|
},
|
methods: {
|
getCommonData() {
|
getAllData()
|
.then((res) => {
|
this.memberOptions = res.data.member
|
this.statusOptions = res.data.serviceContractStatus
|
})
|
.catch((err) => {
|
console.log(err)
|
})
|
},
|
// 保存
|
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 === "新建") {
|
getAddContract(params).then((res) => {
|
console.log(res)
|
this.editConfig.visible = false
|
if (res.code === 200) {
|
this.$message.success("添加成功")
|
this.$parent.getData()
|
}
|
})
|
} else {
|
getUpdateContract(params).then((res) => {
|
console.log(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,
|
file: "",
|
member_id: data.memberId || 0,
|
number: data.number || "",
|
quotation_id: this.quotationId || 0,
|
status_id: data.statusId || 0
|
}
|
return params
|
},
|
handleClose() {
|
this.editConfig.visible = false
|
},
|
// 选择客户相关方法
|
querySearchAsync(queryString, cb, value) {
|
var restaurants = []
|
if (value === "client") {
|
restaurants = this.clientList
|
} else if (value === "quotation") {
|
restaurants = this.quotationList
|
}
|
var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants
|
cb(results)
|
},
|
createStateFilter(queryString, value) {
|
return (state) => {
|
if (value === "contract" || value === "quotation") {
|
return state.number.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
} else {
|
return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
}
|
}
|
},
|
handleSelectClient(value, item) {
|
console.log(item)
|
if (value === "client") {
|
this.editConfig.infomation.client_name = item.name
|
this.clientId = item.id
|
} else if (value === "quotation") {
|
this.editConfig.infomation.quotation_number = item.number
|
this.quotationId = item.id
|
}
|
},
|
selClientClick(value) {
|
console.log("aaaa")
|
if (value === "client") {
|
this.editSelectClientConfig.editVisible = true
|
} else if (value === "quotation") {
|
this.editSelCommonConfig.title = "报价单"
|
this.editSelCommonConfig.editVisible = true
|
this.editSelCommonConfig.tableInfomation = [...this.quotationList]
|
}
|
},
|
selClient(row, value) {
|
console.log("bbbb")
|
console.log(value)
|
if (value === "client") {
|
this.editConfig.infomation.client_name = row.name
|
this.clientId = row.id
|
} else if (value === "quotation") {
|
this.editConfig.infomation.quotation_number = row.number
|
this.quotationId = row.id
|
}
|
},
|
// 清除已选择用户
|
clearupClient(value) {
|
console.log(value)
|
if (value === "client") {
|
console.log("ss88888")
|
this.editConfig.infomation.client_name = ""
|
this.clientId = 0
|
} else if (value === "quotation") {
|
this.editConfig.infomation.quotation_number = ""
|
this.quotationId = 0
|
}
|
},
|
// 添加附件
|
addAnnexClick() {},
|
// 设置允许上传文件格式
|
setFormatClick() {},
|
// 展开收起
|
unflodCollapseClick() {
|
if (this.unflodCollapseStr === "收起") {
|
this.unflodCollapseStr = "展开更多栏目"
|
this.isUnflod = false
|
} else {
|
this.unflodCollapseStr = "收起"
|
this.isUnflod = true
|
}
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
.add-contract-manage {
|
.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;
|
}
|
}
|
.common-select {
|
.common-select-sel {
|
width: 270px;
|
}
|
}
|
}
|
.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>
|