| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756 |
- <template>
- <ele-modal
- custom-class="ele-dialog-form long-dialog-form"
- :centered="true"
- v-if="visible"
- :visible.sync="visible"
- :title="title"
- :close-on-click-modal="false"
- width="80%"
- @close="cancel"
- >
- <el-form ref="form" :model="form" :rules="rules" label-width="120px">
- <headerTitle title="基本信息"></headerTitle>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="询价方名称"
- prop="contactName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.contactName"
- @click.native="handParent"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="有无商机"
- prop="opportunityType"
- style="margin-bottom: 22px"
- >
- <el-select
- v-model="form.opportunityType"
- placeholder="请选择"
- style="width: 100%"
- @change="opportunityTypeChange"
- >
- <el-option
- v-for="item in opportunityTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="关联商机"
- prop="opportunityId"
- style="margin-bottom: 22px"
- :rules="[
- {
- required: form.opportunityType === 1 ? true : false,
- message: '请选择关联商机',
- trigger: 'change'
- }
- ]"
- >
- <el-select
- :disabled="form.opportunityType === 0"
- v-model="form.opportunityId"
- placeholder="请选择"
- style="width: 100%"
- @change="opportunityChange"
- >
- <el-option
- v-for="item in businessList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="询价方联系人"
- prop="contactLinkName"
- style="margin-bottom: 22px"
- >
- <el-select
- v-model="form.contactLinkName"
- style="width: 100%"
- placeholder="请选择"
- @change="onchangeLink"
- @focus="selectFocus"
- >
- <el-option
- v-for="item in linkNameOptions"
- :key="item.id"
- :label="item.linkName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="询价方电话"
- prop="contactTel"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- :maxlength="20"
- v-model="form.contactTel"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="询价方传真"
- prop="contactFax"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.contactFax"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label=" 询价方Email"
- prop="contactEmail"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.contactEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="询价方地址"
- prop="contactAddress"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.contactAddress"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="报价方名称"
- prop="quoteName"
- style="margin-bottom: 22px"
- >
- <el-input
- v-if="enterprisePage.length <= 1"
- clearable
- v-model="form.quoteName"
- placeholder="请输入"
- />
- <el-select
- v-if="enterprisePage.length > 1"
- style="width: 100%"
- v-model="form.quoteName"
- placeholder="请选择"
- @change="getEnterprise()"
- >
- <el-option
- v-for="item in enterprisePage"
- :key="item.id"
- :label="item.name"
- :value="item.name"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="报价方联系人"
- prop="quoteLinkName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.quoteLinkName"
- @click.native="handHead()"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item prop="quoteTel" label="报价方联系电话">
- <el-input clearable v-model="form.quoteTel" placeholder="请输入" />
- </el-form-item>
- <el-form-item prop="quoteFax" label="报价方传真">
- <el-input clearable v-model="form.quoteFax" placeholder="请输入" />
- </el-form-item>
- <el-form-item
- label="报价方Email"
- prop="quoteEmail"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.quoteEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="报价方地址"
- prop="quoteAddress"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.quoteAddress"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item prop="askFile" label="附件">
- <fileUpload
- v-model="form.askFile"
- module="main"
- :showLib="false"
- :limit="1"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle title="报价单产品清单"></headerTitle>
- <inventoryTable
- ref="inventoryTable"
- :isDeliveryDeadline="false"
- :isGuaranteePeriod="false"
- ></inventoryTable>
- <el-row style="margin-top: 20px">
- <el-col :span="6">
- <el-form-item prop="taxRate" label="税率">
- <el-input clearable v-model="form.taxRate" placeholder="请输入">
- <template slot="append">%</template>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item prop="deliveryDate" label="交货日期">
- <el-date-picker
- v-model="form.deliveryDate"
- value-format="yyyy-MM-dd"
- placeholder="请选择交货日期"
- type="date"
- style="width: 150px"
- class="filter-item"
- ></el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="结算方式"
- prop="settlementMode"
- style="margin-bottom: 22px"
- >
- <DictSelection
- dictName="结算方式"
- clearable
- v-model="form.settlementMode"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="是否接受拆单"
- prop="acceptUnpack"
- style="margin-bottom: 22px"
- >
- <el-select v-model="form.acceptUnpack" placeholder="请选择">
- <el-option
- v-for="item in acceptUnpackoptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer" class="footer">
- <el-button type="primary" @click="save">保存</el-button>
- <el-button type="primary" @click="save('sub')">提交</el-button>
- <el-button @click="cancel">返回</el-button>
- </div>
- <parentList
- ref="parentRef"
- classType="1"
- @changeParent="changeParent"
- ></parentList>
- <head-list ref="headRef" @changeParent="changePersonel"></head-list>
- </ele-modal>
- </template>
- <script>
- import { emailReg, phoneReg, numberReg } from 'ele-admin';
- import { acceptUnpackoptions } from '@/enum/dict';
- import inventoryTable from '@/views/contractManage/contractBook/components/inventoryTable.vue';
- import { categoryData } from 'element-china-category-data';
- import fileUpload from '@/components/upload/fileUpload';
- import { cityData } from 'ele-admin/packages/utils/regions';
- import dictMixins from '@/mixins/dictMixins';
- import deptSelect from '@/components/CommomSelect/dept-select.vue';
- import personSelect from '@/components/CommomSelect/person-select.vue';
- import parentList from '@/views/saleManage/contact/components/parentList.vue';
- import {
- getDetail,
- UpdateInformation,
- addInformation,
- submit
- } from '@/api/saleManage/quotation';
- import { getOpportunityDetail } from '@/api/saleManage/businessOpportunity';
- import { getTableList } from '@/api/saleManage/businessOpportunity';
- import { enterprisePage } from '@/api/contractManage/contractBook';
- import { getcontactlink } from '@/api/saleManage/businessFollow';
- import headList from '@/views/saleManage/businessOpportunity/components/headList.vue';
- import { copyObj } from '@/utils/util';
- import { contactDetail } from '@/api/saleManage/contact';
- export default {
- props: {
- categoryTreeList: Array
- },
- mixins: [dictMixins],
- components: {
- fileUpload,
- headList,
- inventoryTable,
- deptSelect,
- parentList,
- personSelect
- },
- data() {
- let formDef = {
- id: '',
- acceptUnpack: null,
- askFile: null,
- contactAddress: '',
- opportunityId: '',
- contactEmail: '',
- contactFax: '',
- contactId: '',
- contactLinkId: '',
- contactLinkName: '',
- contactName: '',
- contactTel: '',
- deliveryDate: '',
- settlementMode: '',
- settlementModeName: '',
- quoteAddress: '',
- quoteEmail: '',
- quoteFax: '',
- quoteLinkId: '',
- quoteLinkName: '',
- quoteName: '',
- quoteTel: '',
- taxRate: null,
- totalPrice: null,
- opportunityType: null
- };
- return {
- opportunityTypeList: [
- { label: '有', value: 1 },
- { label: '无', value: 0 }
- ],
- payWayOptions: [],
- delDetailIds: [],
- linkNameOptions: [],
- acceptUnpackoptions,
- visible: false,
- title: '',
- row: {},
- activeName: 'base',
- formDef,
- form: copyObj(formDef),
- // removeBankList: [],
- // removeLinkList: [],
- tableBankData: [],
- tableLinkData: [],
- businessList: [], //商机列表
- rules: {
- // opportunityId: [
- // { required: true, message: '请选择关联商机', trigger: 'change' }
- // ],
- contactName: [
- { required: true, message: '请选择客户', trigger: 'change' }
- ],
- name: [
- { required: true, message: '请输入客户名称', trigger: 'blur' }
- ],
- contactLinkName: [
- { required: true, message: '请选择联系人', trigger: 'change' }
- ],
- acceptUnpack: [
- { required: true, message: '请选择是否接受', trigger: 'change' }
- ],
- contactTel: [
- {
- required: true,
- pattern: numberReg,
- message: '请输入联系电话',
- trigger: 'blur'
- }
- ],
- deliveryDate: [
- { required: true, message: '请选择交货日期', trigger: 'change' }
- ],
- settlementMode: [
- { required: true, message: '请选择结算方式', trigger: 'change' }
- ],
- quoteLinkName: [
- { required: true, message: '请输入报价方联系人', trigger: 'change' }
- ],
- quoteName: [
- { required: true, message: '请输入报价方名称', trigger: 'blur' }
- ],
- quoteTel: [
- {
- required: true,
- pattern: numberReg,
- message: '请输入报价方联系电话',
- trigger: 'blur'
- }
- ],
- quoteEmail: [
- { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
- ],
- contactEmail: [
- { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
- ],
- taxRate: [
- { pattern: numberReg, message: '请输入数字', trigger: 'blur' }
- ]
- },
- businessId: '',
- options: {
- cityData,
- categoryData
- },
- // 提交状态
- loading: false,
- // 是否是修改
- isUpdate: false,
- // 组织机构树形结构数据
- groupTreeData: [],
- // 组织机构平铺数据
- groupData: [],
- enterprisePage: []
- };
- },
- created() {
- this.getEnterprisePage();
- },
- methods: {
- opportunityTypeChange() {
- if (this.form.opportunityType === 0) {
- this.form.opportunityId = '';
- }
- },
- //获取详情
- async getDetailData(id) {
- this.businessId = id;
- this.loading = true;
- const data = await getDetail(id);
- this.loading = false;
- if (data) {
- this.$nextTick(() => {
- this.form = data;
- if (data.askFile !== '') {
- this.$set(this.form, 'askFile', [data?.askFile]);
- }
- if(data.opportunityId){
- this.form.opportunityType=1
- }
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(data);
- this.getLinkInfo(data.contactId);
- this.getBusinessList(data.contactName);
- });
- }
- },
- opportunityChange(id) {
- getOpportunityDetail(id).then((res) => {
- if (res.productList.length > 0) {
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(res);
- }
- });
- },
- //更新联系人数据
- async getLinkInfo(contactId) {
- const data = await getcontactlink({ contactId });
- if (data && data?.length) {
- this.linkNameOptions = data;
- }
- },
- selectFocus() {
- if (this.linkNameOptions.length === 0) {
- return this.$message.error('请先选择名称');
- }
- },
- //获取客户的商机列表
- async getBusinessList(name) {
- if (!this.form.contactName)
- return this.$message.error('请先选择询价方名称');
- const data = await getTableList({
- pageNum: 1,
- size: 30,
- contactName: name,
- approvalStatus:2
- });
- console.log(data, '3333');
- this.businessList = data.list;
- },
- //选择下拉框
- onchangeLink(selectedOptions) {
- const option = this.linkNameOptions.find(
- (opt) => opt.id === selectedOptions
- );
- this.form = Object.assign({}, this.form, {
- contactEmail: option?.email,
- contactLinkName: option?.linkName || '',
- contactTel: option?.mobilePhone || option?.phone || '',
- contactLinkId: option?.id
- });
- },
- handHead() {
- let item = {
- id: this.form.quoteLinkId
- };
- this.$refs.headRef.open(item);
- },
- //选择报价方人回调
- changePersonel(obj, index) {
- this.$set(this.form, 'quoteLinkId', obj.id);
- this.$set(this.form, 'quoteLinkName', obj.name);
- this.$set(this.form, 'quoteTel', obj.phone);
- this.$set(this.form, 'quoteEmail', obj.email);
- },
- //选择客户回调
- changeParent(obj) {
- this.form = Object.assign({}, this.form, {
- contactId: obj.id,
- contactName: obj.name,
- contactAddress: obj.addressName + obj.address,
- contactLinkId: '',
- contactLinkName: '',
- contactEmail: '',
- contactTel: ''
- });
- this.getLinkInfo(obj.id);
- this.getBusinessList(obj.name);
- },
- handParent() {
- let item = {
- id: this.form.contactId
- };
- this.$refs.parentRef.open(item);
- },
- async open(type, row, contactCategoryId) {
- this.title = type === 'add' ? '新增' : '修改';
- this.row = row;
- this.visible = true;
- if (this.enterprisePage.length == 0) {
- await this.getEnterprisePage();
- }
- if (type == 'add') {
- let userInfo=this.$store.getters.user.info
- this.isUpdate = false;
- userInfo.id=userInfo.userId
- this.changePersonel(userInfo)
- if (this.enterprisePage.length > 0) {
- this.form.quoteName = this.enterprisePage[0].name;
- // this.form.quoteTel = this.enterprisePage[0].tel;
- this.form.quoteFax = this.enterprisePage[0].fax;
- this.form.quoteAddress = this.enterprisePage[0].address;
-
- }
- if (row.id) {
- this.form.opportunityId = row.id;
- await this.opportunityChange(row.id);
- let data = await contactDetail(row.contactId);
- this.form.opportunityType=1
- this.changeParent(data.base);
- }
- } else {
- this.isUpdate = true;
- this.getDetailData(row.id);
- }
- },
- getEnterprisePage() {
- enterprisePage({
- pageNum: 1,
- size: 100
- }).then((res) => {
- this.enterprisePage = [];
- this.enterprisePage.push(...res.list);
- });
- },
- getEnterprise() {
- let data = this.enterprisePage.find(
- (item) => item.name == this.form.quoteName
- );
- this.form.quoteName = data.name;
- // this.form.quoteTel = data.tel;
- this.form.quoteFax = data.fax;
- this.form.quoteAddress = data.address;
- },
- salesmanChange(val, info) {
- this.otherForm.salesmanName = info.name;
- },
-
- ifChiefChange(value, idx) {
- if (value === 1) {
- this.tableLinkData.forEach((e) => (e.ifChief = 0));
- this.tableLinkData[idx].ifChief = 1;
- }
- },
- getValidate() {
- return new Promise((resolve, reject) => {
- this.$refs.form.validate((valid) => {
- if (!valid) {
- reject(false);
- } else {
- resolve(true);
- }
- });
- });
- },
- getValidate() {
- return Promise.all([
- new Promise((resolve, reject) => {
- this.$refs.form.validate((valid) => {
- if (!valid) {
- reject(false);
- } else {
- resolve(true);
- }
- });
- }),
- new Promise((resolve, reject) => {
- this.$refs.inventoryTable.validateForm((valid) => {
- if (!valid) {
- reject(false);
- } else {
- resolve(true);
- }
- });
- })
- ]);
- },
- async save(type) {
- try {
- await this.getValidate();
- // 表单验证通过,执行保存操作
- this.loading = true;
- if (!this.isUpdate) {
- delete this.form.id;
- }
- let settlementModeName = this.getDictValue(
- '结算方式',
- this.form.settlementMode
- );
- if (this.form.askFile && this.form.askFile.length > 0) {
- this.form.askFile = this.form.askFile[0];
- } else {
- this.form.askFile = null;
- }
- let commitData = Object.assign({}, this.form, {
- settlementModeName,
- quoteProductList: this.$refs.inventoryTable.getTableValue(),
- totalPrice: this.$refs.inventoryTable.getTotalPrice()
- });
- if (this.isUpdate) {
- UpdateInformation(commitData)
- .then((res) => {
- this.loading = false;
- if (type === 'sub') {
- this.quotationSubmit(res);
- return;
- }
- this.$message.success('修改成功');
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- //this.loading = false;
- });
- } else {
- addInformation(commitData)
- .then((res) => {
- this.loading = false;
- if (type === 'sub') {
- this.quotationSubmit(res);
- return;
- }
- this.$message.success('新增成功');
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- //this.loading = false;
- });
- }
- } catch (error) {
- console.log(error);
- // 表单验证未通过,不执行保存操作
- }
- },
- quotationSubmit(res) {
- submit({
- businessId: this.businessId || res
- }).then((res) => {
- this.cancel();
- this.$emit('done');
- });
- },
- cancel() {
- this.$nextTick(() => {
- this.activeName = 'base';
- // 关闭后,销毁所有的表单数据
- this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
- this.$refs['formRef'] && this.$refs['formRef'].resetFields();
- this.form = copyObj(this.formDef);
- this.visible = false;
- });
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .TotalAmount {
- font-size: 16px;
- padding-right: 30px;
- }
- </style>
|