| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379 |
- <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="type"
- style="margin-bottom: 22px"
- >
- <!-- <DictSelection
- dictName="合同类型"
- clearable
- v-model="form.type"
- @itemChange="dictChange"
- :disabled="create"
- >
- </DictSelection> -->
- <el-select
- v-model="form.type"
- placeholder="请选择"
- style="width: 100%"
- @change="dictChange"
- >
- <el-option
- v-for="item in contractBookTypeList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="来源类型"
- style="margin-bottom: 22px"
- v-if="form.type"
- >
- <el-select
- v-model="form.sourceType"
- placeholder="请选择"
- style="width: 100%"
- clearable
- @change="sourceTypeChange(form.type)"
- >
- <el-option
- v-if="item.parentId == form.type"
- v-for="item in sourceTypeList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="核价单"
- prop="sourceName"
- style="margin-bottom: 22px"
- v-if="form.sourceType == 2"
- >
- <el-input
- clearable
- v-model="form.sourceName"
- @click.native="handInquiry"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="报价单"
- prop="sourceName"
- style="margin-bottom: 22px"
- v-if="form.sourceType == 1"
- >
- <el-input
- clearable
- v-model="form.sourceName"
- @click.native="handQuotation"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="采购计划"
- prop="sourceName"
- style="margin-bottom: 22px"
- v-if="form.sourceType == 3"
- >
- <el-input
- clearable
- v-model="form.sourceName"
- @click.native="handPlan"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="商机名称"
- prop="sourceName"
- style="margin-bottom: 22px"
- v-if="form.sourceType == 4"
- >
- <el-input
- clearable
- v-model="form.sourceName"
- @click.native="handOpportunity"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="合同名称"
- prop="contractName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.contractName"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="合同编号"
- prop="contractNumber"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.contractNumber"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item prop="contractFile" label="合同附件">
- <fileUpload
- v-model="form.contractFile"
- module="main"
- :showLib="false"
- :limit="10"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="合同分类"
- prop="categoryId"
- style="margin-bottom: 22px; width: 340px"
- >
- <!-- <ele-tree-select
- :data="categoryTreeList"
- v-model="form.categoryId"
- valueKey="id"
- labelKey="name"
- placeholder="请选择"
- default-expand-all
- /> -->
- <el-select
- v-model="form.categoryId"
- placeholder="请选择"
- style="width: 100%"
- >
- <el-option
- v-for="item in categoryList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="签订日期"
- prop="contractStartDate"
- style="margin-bottom: 22px"
- >
- <el-date-picker
- v-model="form.contractStartDate"
- @change="setDeliveryDays"
- type="date"
- placeholder="选择日期"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item
- label="结束日期"
- prop="contractEndDate"
- style="margin-bottom: 22px"
- >
- <el-date-picker
- v-model="form.contractEndDate"
- type="date"
- placeholder="选择日期"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item
- label="结算方式"
- prop="settlementMode"
- style="margin-bottom: 22px"
- >
- <!-- <el-select v-model="form.receiptPaymentType" placeholder="请选择">
- <el-option
- v-for="item in paymentTypeOptions"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select> -->
- <DictSelection
- dictName="结算方式"
- clearable
- v-model="form.settlementMode"
- style="width: 220px"
- >
- </DictSelection>
- </el-form-item>
- <el-form-item
- label="计价方式"
- prop="pricingWay"
- style="margin-bottom: 22px"
- >
- <el-radio-group v-model="form.pricingWay" @change="changePricingWay">
- <el-radio v-for="item in pricingWayList" :label="item.id">{{ item.name }}</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle title="基本信息"></headerTitle>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="甲方名称"
- prop="partaName"
- style="margin-bottom: 22px"
- >
- <template v-if="form.type == '2'">
- <el-input
- clearable
- v-model="form.partaName"
- placeholder="请输入"
- v-if="enterprisePage.length <= 1"
- />
- <el-select
- v-if="enterprisePage.length > 1"
- style="width: 100%"
- v-model="form.partaName"
- placeholder="请选择"
- @change="getEnterprise(1)"
- >
- <el-option
- v-for="item in enterprisePage"
- :key="item.id"
- :label="item.name"
- :value="item.name"
- >
- </el-option>
- </el-select>
- </template>
- <template v-else>
- <el-input
- clearable
- v-model="form.partaName"
- @click.native="handParent"
- placeholder="请选择"
- />
- </template>
- </el-form-item>
- <el-form-item
- label="甲方统一社会信用代码"
- prop="partaUnifiedSocialCreditCode"
- label-width="160px"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partaUnifiedSocialCreditCode"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="甲方联系人"
- prop="partaLinkName"
- style="margin-bottom: 22px"
- >
- <template v-if="form.type == '2'">
- <el-input
- clearable
- v-model="form.partaLinkName"
- @click.native="handHead"
- placeholder="请选择"
- />
- </template>
- <template v-else>
- <el-select
- v-model="form.partaLinkName"
- 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>
- </template>
- </el-form-item>
- <el-form-item
- label="甲方电话"
- prop="partaTel"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- :maxlength="20"
- v-model="form.partaTel"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="甲方传真"
- prop="partaFax"
- style="margin-bottom: 22px"
- >
- <el-input clearable v-model="form.partaFax" placeholder="请输入"/>
- </el-form-item>
- <el-form-item
- label=" 甲方Email"
- prop="partaEmail"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partaEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="甲方地址"
- prop="partaAddress"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partaAddress"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <template v-if="form.type == '2'">
- <el-form-item
- label="乙方名称"
- prop="partbName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbName"
- @click.native="handSupplier"
- placeholder="请输入"
- />
- </el-form-item>
- </template>
- <template v-else>
- <el-form-item
- label="乙方名称"
- prop="partbName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbName"
- placeholder="请输入"
- v-if="enterprisePage.length <= 1"
- />
- <el-select
- v-if="enterprisePage.length > 1"
- style="width: 100%"
- v-model="form.partbName"
- placeholder="请选择"
- @change="getEnterprise(1)"
- >
- <el-option
- v-for="item in enterprisePage"
- :key="item.id"
- :label="item.name"
- :value="item.name"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </template>
- <el-form-item
- label="乙方统一社会信用代码"
- prop="partbUnifiedSocialCreditCode"
- label-width="160px"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbUnifiedSocialCreditCode"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="乙方联系人"
- prop="partbLinkName"
- style="margin-bottom: 22px"
- >
- <template v-if="form.type == '2'">
- <el-select
- v-model="form.partbLinkName"
- 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>
- </template>
- <template v-else>
- <el-input
- clearable
- v-model="form.partbLinkName"
- @click.native="handHead"
- placeholder="请输入"
- />
- </template>
- </el-form-item>
- <el-form-item prop="partbTel" label="乙方联系电话">
- <el-input clearable v-model="form.partbTel" placeholder="请输入"/>
- </el-form-item>
- <el-form-item prop="partbFax" label="乙方传真">
- <el-input clearable v-model="form.partbFax" placeholder="请输入"/>
- </el-form-item>
- <el-form-item
- label="乙方Email"
- prop="partbEmail"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="乙方地址"
- prop="partbAddress"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbAddress"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle>
- <inventoryTable
- ref="inventoryTable"
- :contractStartDate="this.form.contractStartDate"
- :isCustomerMark="false"
- :isDiscountTotalPrice="true"
- :contractBookType="form.type"
- :pricingWay='form.pricingWay'
- ></inventoryTable>
- <headerTitle
- :title="form.type == '2' ? '付款方式' : '收款方式'"
- style="margin-top: 30px"
- ></headerTitle>
- <paymentList ref="paymentListTable"/>
- </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" @changeParent="changeParent"></parentList>
- <inquiryManageList
- ref="inquiryManageRef"
- @changeInquiryManageList="changeInquiryManageList"
- ></inquiryManageList>
- <inquiryList
- ref="inquiryListRef"
- @changeParent="changeInquiryList"
- ></inquiryList>
- <quotationList
- ref="quotationListRef"
- @changeParent="changeInquiryList"
- ></quotationList>
- <supplierList
- ref="supplierListRef"
- :classType="2"
- @changeParent="changeSupplier"
- ></supplierList>
- <head-list ref="headRef" @changeParent="changePersonel"></head-list>
- <!-- 商机 -->
- <opportunity-dialog :opportunityDialogFlag.sync="opportunityDialogFlag" v-if="opportunityDialogFlag"
- ref="opportunityDialogRef" @changeParent="getOpportunityDetail"></opportunity-dialog>
- </ele-modal>
- </template>
- <script>
- import {emailReg, phoneReg, numberReg} from 'ele-admin';
- import {acceptUnpackoptions} from '@/enum/dict';
- import inventoryTable from './inventoryTable.vue';
- import inquiryList from './inquiryList.vue';
- import quotationList from './quotationList.vue';
- import fileUpload from '@/components/upload/fileUpload';
- import dictMixins from '@/mixins/dictMixins';
- import parentList from '@/views/saleManage/contact/components/parentList.vue';
- import {
- getDetail,
- UpdateInformation,
- addInformation,
- submit
- } from '@/api/contractManage/contractBook';
- import {contactDetail} from '@/api/saleManage/contact';
- import {getDetail as getOpportunityInfo} from '@/api/saleManage/businessOpportunity';
- import {getcontactlink} from '@/api/saleManage/businessFollow';
- import headList from '@/views/saleManage/businessOpportunity/components/headList.vue';
- import supplierList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
- import paymentList from './paymentList.vue';
- import {copyObj} from '@/utils/util';
- import {enterprisePage} from '@/api/contractManage/contractBook';
- import inquiryManageList from "@/views/purchasingManage/inquiryManage/components/inquiryManage-list.vue";
- import {getplanDetail} from "@/api/purchasingManage/purchasePlanManage";
- import opportunityDialog from "@/views/financialManage/feeManage/feeApplication/opportunityDialog.vue";
- import {getOpportunityDetail} from "@/api/saleManage/businessOpportunity";
- export default {
- props: {
- categoryTreeList: Array
- },
- mixins: [dictMixins],
- components: {
- opportunityDialog,
- inquiryManageList,
- fileUpload,
- headList,
- paymentList,
- inventoryTable,
- supplierList,
- parentList,
- inquiryList,
- quotationList
- },
- data() {
- let formDef = {
- id: '',
- contractEndDate: '',
- contractFile: [],
- contractName: '',
- contractNumber: '',
- contractStartDate: '',
- opportunityId: '',
- categoryName: '',
- categoryId: '',
- sourceId: '',
- sourceType: '',
- sourceName: '',
- partaUnifiedSocialCreditCode: '',
- partbUnifiedSocialCreditCode: '',
- partaAddress: '',
- partaEmail: '',
- partaFax: '',
- partaId: '',
- partaLinkId: '',
- partaLinkName: '',
- partaName: '',
- partaTel: '',
- partbAddress: '',
- partbEmail: '',
- partbFax: '',
- partbId: '',
- partbLinkId: '',
- partbLinkName: '',
- partbName: '',
- partbTel: '',
- settlementModeName: '结算方式',
- settlementMode: '4',
- pricingWay: 1,
- totalPrice: null,
- type: '', //1=销售合同 2=采购合同
- typeName: ''
- };
- return {
- payWayOptions: [],
- delDetailIds: [],
- paymentTypeOptions: [
- {id: 1, name: '固定'},
- {id: 2, name: '分期'}
- ],
- pricingWayList: [
- {id: 1, name: '按数量计价'},
- {id: 2, name: '按重量计价'}
- ],
- contractBookTypeList: [],
- sourceTypeList: [
- {
- code: 1,
- name: '报价单',
- parentId: '1',
- },
- {
- code: 2,
- name: '核价单',
- parentId: '2',
- },
- {
- code: 3,
- name: '采购计划',
- parentId: '2',
- },
- {
- code: 4,
- name: '商机',
- parentId: '1',
- },
- ],
- categoryList: [],
- linkNameOptions: [],
- acceptUnpackoptions,
- visible: false,
- opportunityDialogFlag: false,
- title: '',
- row: {},
- activeName: 'base',
- formDef,
- form: copyObj(formDef),
- // removeBankList: [],
- // removeLinkList: [],
- tableBankData: [],
- tableLinkData: [],
- rules: {
- type: [
- {required: true, message: '请选择合同类型', trigger: 'change'}
- ],
- settlementMode: [
- {required: true, message: '请选择合结算方式', trigger: 'change'}
- ],
- categoryId: [
- {required: true, message: '请选择合同分类', trigger: 'change'}
- ],
- contractNumber: [
- {required: true, message: '请输入自带编号', trigger: 'change'}
- ],
- contractName: [
- {required: true, message: '请输入合同名称', trigger: 'blur'}
- ],
- partaName: [
- {required: true, message: '请选择甲方名称', trigger: 'change'}
- ],
- partaLinkName: [
- {required: true, message: '请选择甲方联系人', trigger: 'change'}
- ],
- acceptUnpack: [
- {required: true, message: '请选择是否接受', trigger: 'change'}
- ],
- partaTel: [
- {
- required: true,
- pattern: numberReg,
- message: '请输入甲方联系电话',
- trigger: 'blur'
- }
- ],
- deliveryDate: [
- {required: true, message: '请选择交货日期', trigger: 'change'}
- ],
- partbName: [
- {required: true, message: '请输入乙方名称', trigger: 'change'}
- ],
- partbLinkName: [
- {required: true, message: '请输入乙方联系人', trigger: 'change'}
- ],
- partbTel: [
- {
- required: true,
- pattern: numberReg,
- message: '请输入乙方联系电话',
- trigger: 'blur'
- }
- ],
- partaEmail: [
- {pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur'}
- ],
- contractStartDate: [
- {required: true, message: '请选择签订日期', trigger: 'change'}
- ],
- contractEndDate: [
- {validator: this.validateEndDate, trigger: 'blur'}
- ]
- },
- enterprise: {
- address: '',
- unifiedSocialCreditCode: '',
- tel: '',
- name: ''
- },
- // 提交状态
- loading: false,
- // 是否是修改
- isUpdate: false,
- enterprisePage: [],
- create: false,
- businessId: ''
- };
- },
- created() {
- enterprisePage({
- pageNum: 1,
- size: 200
- }).then((res) => {
- this.enterprisePage = [];
- this.enterprisePage.push(...res.list);
- this.getEnterprise();
- });
- },
- methods: {
- //开始日期验证
- validateStartDate(rule, value, callback) {
- if (this.form.contractEndDate && value > this.form.contractEndDate) {
- callback(new Error('开始日期不能大于结束日期'));
- } else {
- callback();
- }
- },
- //结束日期验证
- validateEndDate(rule, value, callback) {
- if (
- this.form.contractEndDate &&
- this.form.contractStartDate &&
- value < this.form.contractStartDate
- ) {
- callback(new Error('结束日期不能小于开始日期'));
- } else {
- callback();
- }
- },
- //选择供应商
- changeSupplier(obj) {
- this.form = Object.assign({}, this.form, {
- partbId: obj.id,
- partbName: obj.name,
- partbAddress: obj.addressName + obj.address,
- partbLinkId: '',
- partbLinkName: '',
- partbEmail: '',
- partbTel: ''
- });
- this.getLinkInfo(obj.id);
- },
- //获取详情
- async getDetailData(id) {
- this.businessId = id;
- this.loading = true;
- const data = await getDetail(id);
- this.loading = false;
- if (data) {
- this.$nextTick(() => {
- let {contractVO} = data;
- this.dictChange(contractVO.type, 'init');
- this.form = contractVO;
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(data);
- this.$refs.paymentListTable &&
- this.$refs.paymentListTable.putTableValue(
- data.receiptPaymentList
- );
- this.getLinkInfo(
- contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
- );
- });
- }
- },
- //签订日期 更新
- setDeliveryDays() {
- this.$refs.inventoryTable.setDeliveryDays('', '', '', true);
- },
- //更新联系人数据
- 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('请先选择名称');
- }
- },
- //选择合同类型
- dictChange(val, type) {
- this.categoryList = copyObj(
- this.contractBookTypeList.find((item) => item.code == val).children
- );
- if (type == 'init') {
- return;
- }
- let typeName = ''
- if (val) typeName = this.contractBookTypeList.find(item => item.code == val)?.name || ''
- this.form = Object.assign({}, this.form, {
- typeName: typeName || val.dictValue,
- contractName: '',
- sourceType: '',
- sourceId: '',
- sourceName: '',
- partaAddress: '',
- partaEmail: '',
- partaFax: '',
- partaId: '',
- partaLinkId: '',
- partaLinkName: '',
- partaName: '',
- partaTel: '',
- partbAddress: '',
- partbEmail: '',
- partbFax: '',
- partbId: '',
- partbLinkId: '',
- partbLinkName: '',
- partbName: '',
- partbTel: '',
- partaUnifiedSocialCreditCode: '',
- partbUnifiedSocialCreditCode: '',
- categoryName: '',
- categoryId: ''
- });
- this.getEnterprise();
- this.changePersonel();
- },
- //选择来源类型
- sourceTypeChange(val, type) {
- this.form = Object.assign({}, this.form, {
- contractName: '',
- sourceId: '',
- sourceName: '',
- partaAddress: '',
- partaEmail: '',
- partaFax: '',
- partaId: '',
- partaLinkId: '',
- partaLinkName: '',
- partaName: '',
- partaTel: '',
- partbAddress: '',
- partbEmail: '',
- partbFax: '',
- partbId: '',
- partbLinkId: '',
- partbLinkName: '',
- partbName: '',
- partbTel: '',
- partaUnifiedSocialCreditCode: '',
- partbUnifiedSocialCreditCode: '',
- // categoryName: '',
- // categoryId: ''
- });
- this.getEnterprise();
- this.changePersonel();
- },
- getEnterprise(type) {
- let key = this.form.type == '1' || !this.form.type ? 'partb' : 'parta';
- let keyArr = [
- key + 'Name',
- key + 'UnifiedSocialCreditCode',
- key + 'Fax',
- key + 'Address'
- ];
- if (type === 1) {
- let data = this.enterprisePage.find(
- (item) => item.name == this.form[keyArr[0]]
- );
- this.form[keyArr[0]] = data.name;
- this.form[keyArr[1]] = data.unifiedSocialCreditCode;
- this.form[keyArr[2]] = data.fax;
- this.form[keyArr[3]] = data.address;
- return;
- }
- if (this.enterprisePage.length > 0) {
- this.form[keyArr[0]] =
- this.form[keyArr[0]] || this.enterprisePage[0].name;
- this.form[keyArr[1]] =
- this.form[keyArr[1]] ||
- this.enterprisePage[0].unifiedSocialCreditCode;
- this.form[keyArr[2]] =
- this.form[keyArr[2]] || this.enterprisePage[0].fax;
- this.form[keyArr[3]] =
- this.form[keyArr[3]] || this.enterprisePage[0].address;
- }
- },
- //选择合同分类
- // treeChange(val) {
- // //这里eladmin组件有bug,要手动验证下
- // this.$set(this.form, 'categoryId', val);
- // this.$refs.form.validateField('categoryId');
- // },
- //选择下拉框
- onchangeLink(selectedOptions) {
- if (this.form.type == '2') {
- const option = this.linkNameOptions.find(
- (opt) => opt.id === selectedOptions
- );
- this.form = Object.assign({}, this.form, {
- partbEmail: option?.email,
- partbLinkName: option?.linkName || '',
- partbTel: option?.mobilePhone || option?.phone || '',
- partbLinkId: option?.id
- });
- } else {
- const option = this.linkNameOptions.find(
- (opt) => opt.id === selectedOptions
- );
- this.form = Object.assign({}, this.form, {
- partaEmail: option?.email,
- partaLinkName: option?.linkName || '',
- partaTel: option?.mobilePhone || option?.phone || '',
- partaLinkId: option?.id
- });
- }
- },
- handHead(title) {
- if (this.form.type == '2') {
- let item = {
- id: this.form.partaLinkId
- };
- this.$refs.headRef.open(item);
- } else {
- let item = {
- id: this.form.partbLinkId
- };
- this.$refs.headRef.open(item);
- }
- },
- //选择乙方人和采购合同下的甲方人回调
- changePersonel(obj, index, title) {
- if (!obj) {
- obj = this.$store.getters.user.info;
- obj.id = obj.userId;
- }
- if (this.form.type == '2') {
- this.$set(this.form, 'partaLinkId', obj.id);
- this.$set(this.form, 'partaLinkName', obj.name);
- this.$set(this.form, 'partaTel', obj.phone);
- this.$set(this.form, 'partaEmail', obj.email);
- } else {
- this.$set(this.form, 'partbLinkId', obj.id);
- this.$set(this.form, 'partbLinkName', obj.name);
- this.$set(this.form, 'partbTel', obj.phone);
- this.$set(this.form, 'partbEmail', obj.email);
- }
- },
- //选择客户回调
- changeParent(obj) {
- console.log(obj, 'obj');
- this.form = Object.assign({}, this.form, {
- partaId: obj.id,
- partaName: obj.name,
- partaAddress: obj.addressName + obj.address,
- partaLinkId: '',
- partaLinkName: '',
- partaEmail: '',
- partaTel: '',
- //contractName: obj.name,
- partaUnifiedSocialCreditCode: obj.unifiedSocialCreditCode
- });
- this.getLinkInfo(obj.id);
- },
- //选择采购合同的乙方
- handSupplier() {
- let item = {
- id: this.form.partbId
- };
- this.$refs.supplierListRef.open(item);
- },
- handParent() {
- let item = {
- id: this.form.contactId
- };
- this.$refs.parentRef.open(item);
- },
- async open(type, row, create = false) {
- this.title = type === 'add' ? '新增' : '修改';
- this.row = row;
- this.visible = true;
- this.create = create;
- this.contractBookTypeList = copyObj(this.categoryTreeList[0].children);
- if (type == 'add') {
- let userInfo = this.$store.getters.user.info;
- this.isUpdate = false;
- userInfo.id = userInfo.userId;
- this.changePersonel();
- this.form.contractStartDate = new Date()
- if (row?.contractVO?.type) {
- this.dictChange(row.contractVO.type, 'init');
- }
- this.$nextTick(() => {
- this.$refs.paymentListTable.defaultList()
- })
- if (create) {
- this.create = create;
- //核价单生成的合同
- this.$nextTick(() => {
- this.setValue(row);
- });
- }
- } else {
- this.isUpdate = true;
- this.getDetailData(row.id);
- }
- },
- //赋值
- setValue(row) {
- let {contractVO} = row;
- contractVO = {
- ...contractVO,
- categoryId: contractVO.categoryId || this.form.categoryId,
- categoryName: contractVO.categoryName || this.form.categoryName,
- contractStartDate: contractVO.contractStartDate || this.form.contractStartDate,
- contractEndDate: contractVO.contractEndDate || this.form.contractEndDate,
- pricingWay: 1,
- }
- this.form = contractVO;
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(row);
- this.$refs.paymentListTable &&
- this.$refs.paymentListTable.putTableValue(row.receiptPaymentList);
- this.getEnterprise();
- this.getLinkInfo(
- contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
- );
- },
- //切换计费方式重新算费用
- changePricingWay() {
- this.$refs.inventoryTable.getTotalPrice()
- },
- 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);
- }
- });
- }),
- new Promise((resolve, reject) => {
- this.$refs.paymentListTable.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 [totalPrice, discountTotalPrice] = this.$refs.inventoryTable.getPrice();
- this.form.totalPrice = totalPrice;
- this.form.discountTotalPrice = discountTotalPrice;
- if (this.form.categoryId) {
- this.form.categoryName = this.findNameById(
- this.categoryTreeList,
- this.form.categoryId
- );
- }
- this.form.settlementModeName = this.getDictValue(
- '结算方式',
- this.form.settlementMode
- );
- let commitData = Object.assign(
- {},
- {
- contract: this.form,
- productList: this.$refs.inventoryTable.getTableValue(),
- receiptPaymentList: this.$refs.paymentListTable.getTableValue()
- }
- );
- if (this.isUpdate) {
- UpdateInformation(commitData)
- .then((res) => {
- this.loading = false;
- this.$message.success('修改成功');
- if (type === 'sub') {
- this.contractBookSubmit(res);
- return;
- }
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- //this.loading = false;
- });
- } else {
- addInformation(commitData)
- .then((res) => {
- this.loading = false;
- this.$message.success('新增成功');
- if (type === 'sub') {
- this.contractBookSubmit(res);
- return;
- }
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- //this.loading = false;
- });
- }
- } catch (error) {
- console.log(error);
- // 表单验证未通过,不执行保存操作
- }
- },
- contractBookSubmit(res) {
- submit({
- businessId: this.businessId || res,
- businessType: this.form.type
- // productionSupervisorId
- }).then((res) => {
- this.cancel();
- this.$emit('done');
- });
- },
- handInquiry(e) {
- if (e.target.nodeName == "I") {
- this.$set(this.form, 'sourceName', '');
- this.$set(this.form, 'sourceId', '');
- return
- }
- this.$refs.inquiryListRef.open();
- },
- handQuotation(e) {
- if (e.target.nodeName == "I") {
- this.$set(this.form, 'sourceName', '');
- this.$set(this.form, 'sourceId', '');
- return
- }
- this.$refs.quotationListRef.open();
- },
- async changeInquiryList({data, sourceCode}) {
- this.setValue(data);
- this.$set(this.form, 'sourceName', sourceCode);
- this.$set(this.form, 'sourceId', data.id);
- let contactId = this.form.type == 2 ? data.contractVO.partbId : data.contractVO.partaId
- let {base} = await contactDetail(contactId)
- this.$set(this.form, 'contractName', base.simpleName);
- },
- //选择采购计划
- handPlan(e) {
- if (e.target.nodeName == "I") {
- this.$set(this.form, 'sourceName', '');
- this.$set(this.form, 'sourceId', '');
- return
- }
- this.$refs.inquiryManageRef.open();
- },
- //选择采购计划回调
- async changeInquiryManageList(data) {
- let info = await this.getPlanInfo(data.id)
- let cusInfo = {}
- // if (info.detailList.length) cusInfo = await this.getCusInfo(info.detailList[0]?.supplierId ?? '');
- this.$set(this.form, 'sourceName', data.planName);
- this.$set(this.form, 'sourceId', data.id);
- // this.$set(this.form, 'contractName', cusInfo?.base?.simpleName);
- let form = {
- contractVO: {
- ...this.form,
- // partbName: cusInfo.base.name,
- // partbId: cusInfo.base.id,
- // partbUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
- // partbAddress: cusInfo.base.addressName + cusInfo.base.address,
- // partbLinkName: cusInfo.linkList[0]?.linkName,
- // partbLinkId: cusInfo.linkList[0]?.id,
- // partbTel: cusInfo.linkList[0]?.mobilePhone,
- },
- productList: info.detailList || []
- }
- this.setValue(form);
- // await this.getLinkInfo(cusInfo.base.id)
- },
- //获取计划详情
- async getPlanInfo(id) {
- return Promise.resolve(await getplanDetail(id))
- },
- //获取客户详情
- async getCusInfo(id = '') {
- if (!id) return
- return Promise.resolve(await contactDetail(id))
- },
- //选择商机
- handOpportunity(e) {
- if (e.target.nodeName == "I") {
- this.$set(this.form, 'sourceName', '');
- this.$set(this.form, 'sourceId', '');
- return
- }
- this.opportunityDialogFlag = true
- this.$nextTick(() => {
- let item = {
- id: this.form.sourceId
- }
- this.$refs.opportunityDialogRef.init(item)
- })
- },
- //获取商机信息
- async getOpportunityDetail(row) {
- this.$set(this.form, 'sourceName', row.name);
- this.$set(this.form, 'sourceId', row.id);
- let cusInfo = await this.getCusInfo(row?.contactId ?? '');
- let info = await this.getOpportunityDetailData(row?.id ?? '');
- await this.getLinkInfo(cusInfo.base.id)
- let totalPrice = info.productList.reduce((num, cur) => {
- return num + Number(cur.totalPrice);
- }, 0)
- info.productList.forEach((item) => {
- item.discountSinglePrice = item.discountSinglePrice || item.singlePrice
- item.discountTotalPrice = item.discountTotalPrice || item.totalPrice
- })
- let discountTotalPrice = info.productList.reduce((num, cur) => {
- return num + Number(cur.discountTotalPrice);
- }, 0)
- let form = {
- contractVO: {
- ...this.form,
- partaName: cusInfo.base.name,
- partaId: cusInfo.base.id,
- partaUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
- partaAddress: cusInfo.base.addressName + cusInfo.base.address,
- partaLinkName: cusInfo.linkList[0]?.linkName,
- partaLinkId: cusInfo.linkList[0]?.id,
- partaTel: cusInfo.linkList[0]?.mobilePhone,
- totalPrice: totalPrice,
- discountTotalPrice: discountTotalPrice,
- },
- productList: info.productList || []
- }
- this.setValue(form);
- },
- //获取商机详情
- async getOpportunityDetailData(id) {
- return Promise.resolve(await getOpportunityInfo(id))
- },
- 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.$store.commit('concact/setDiscountAmount', 0);
- this.visible = false;
- });
- },
- //查找合同分类对应name
- findNameById(tree, targetId) {
- for (let i = 0; i < tree.length; i++) {
- const node = tree[i];
- if (node.id === targetId) {
- return node.name;
- }
- if (node.children && node.children.length > 0) {
- const name = this.findNameById(node.children, targetId);
- if (name) {
- return name;
- }
- }
- }
- return null;
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .TotalAmount {
- font-size: 16px;
- padding-right: 30px;
- }
- </style>
|