| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761 |
- <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="70%"
- @close="cancel"
- :maxable="true"
- :resizable="true"
- append-to-body
- >
- <el-form
- ref="form"
- :model="form"
- :rules="rules"
- class="el-form-box"
- label-width="120px"
- >
- <headerTitle title="订单信息"></headerTitle>
- <el-row>
- <el-col :span="8">
- <el-form-item label="订单类型" prop="sourceType">
- <el-select
- v-model="form.sourceType"
- placeholder="请选择"
- style="width: 100%"
- @change="sourceTypeChange"
- :disabled="isFlag || (isUpdate && form.sourceType === '8')"
- clearable
- >
- <el-option
- v-for="item in filterList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="需求部门" prop="requireDeptId">
- <ele-tree-select
- clearable
- :data="groupTreeData"
- v-model="form.requireDeptId"
- valueKey="id"
- labelKey="name"
- placeholder="请选择"
- @change="change_principalDep"
- default-expand-all
- />
- </el-form-item>
- <el-form-item label="采购部门" prop="purchaseDeptId">
- <ele-tree-select
- clearable
- :data="groupTreeData"
- v-model="form.purchaseDeptId"
- valueKey="id"
- labelKey="name"
- placeholder="请选择"
- @change="changePurchaseDep"
- default-expand-all
- />
- </el-form-item>
- <el-form-item label="来源类型" prop="relationType">
- <el-select
- v-model="form.relationType"
- filterable
- clearable
- style="width: 100%"
- :disabled="(isUpdate && form.sourceType === '8')"
- @change="handleChangeRelationType"
- >
- <el-option v-if="!showReturnRelation" :value="1" label="采购需求单"></el-option>
- <el-option v-if="!showReturnRelation" :value="2" label="采购计划单"></el-option>
- <el-option v-if="!showReturnRelation" :value="3" label="采购核价单"></el-option>
- <el-option v-if="!showReturnRelation" :value="4" label="采购合同"></el-option>
- <el-option v-if="!showReturnRelation" :value="5" label="售后服务"></el-option>
- <el-option v-if="showReturnRelation" :value="6" label="销售退货单"></el-option>
- <el-option v-if="showReturnRelation" :value="7" label="销售退货处理单"></el-option>
- <el-option v-if="showReturnRelation" :value="8" label="采购退货单"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- prop="outsourceScene"
- label="委外场景"
- v-if="
- orderSourceType.includes(form.sourceType) && form.outsourceScene
- "
- >
- <el-select
- v-model="form.outsourceScene"
- disabled
- style="width: 100%"
- >
- <el-option
- :value="item.value"
- :label="item.label"
- v-for="item in outsourceSceneList"
- :key="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- v-if="form.relationType == 1"
- label="采购需求单"
- prop="relationName"
- >
- <el-input
- @click.native="handPurchaseNeed"
- v-model="form.relationName"
- placeholder="请选择"
- ></el-input>
- </el-form-item>
- <el-form-item
- v-if="form.relationType == 2"
- label="采购计划单"
- prop="relationName"
- >
- <el-input
- @click.native="handPurchasePlan"
- v-model="form.relationName"
- placeholder="请选择"
- ></el-input>
- </el-form-item>
- <el-form-item
- v-if="form.relationType == 3"
- label="采购核价单"
- prop="relationName"
- >
- <el-input
- @click.native="handInquiry"
- v-model="form.relationName"
- placeholder="请选择"
- ></el-input>
- </el-form-item>
- <el-form-item
- v-if="form.relationType == 4"
- label="选择合同"
- prop="contractName"
- >
- <el-input
- clearable
- v-model="form.contractName"
- @click.native="handleContractBtn"
- @clear="clearContrcat"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- v-if="form.relationType == 6"
- label="销售退货单"
- prop="relationName"
- >
- <el-input
- clearable
- v-model="form.relationName"
- @click.native="handleReturnBtn"
- @clear="clearContrcat"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- v-if="form.relationType == 7"
- label="销售退货处理单"
- prop="relationName"
- >
- <el-input
- clearable
- v-model="form.relationName"
- :disabled="(isUpdate && form.sourceType === '8')"
- @click.native="handleReturnDealBtn"
- @clear="clearContrcat"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- v-if="form.relationType == 8"
- label="采购退货单"
- prop="relationName"
- >
- <el-input
- clearable
- v-model="form.relationName"
- @click.native="handlePurchaseReturnOrder"
- @clear="clearContrcat"
- placeholder="请输入"
- />
- </el-form-item>
-
- </el-col>
- <el-col :span="8">
- <!-- <el-form-item label="项目名称" prop="projectName">
- <el-input
- clearable
- v-model="form.projectName"
- placeholder="请输入"
- />
- </el-form-item> -->
- <el-form-item label="项目名称" prop="projectName">
- <el-input
- clearable
- v-model="form.projectName"
- placeholder="请输入"
- style="width: calc(100% - 80px)"
- />
- <el-button
- style="margin-left: 5px"
- size="small"
- type="primary"
- @click.native="handleProjectBtn"
- >选择
- </el-button>
- </el-form-item>
-
- <el-form-item label="需求人" prop="requireUserId">
- <personSelect
- ref="directorRef"
- v-model="form.requireUserId"
- @selfChange="salesmanChange"
- :init="false"
- />
- </el-form-item>
- <el-form-item label="采购员" prop="purchaseUserId">
- <personSelect
- ref="purchaseDirectorRef"
- v-model="form.purchaseUserId"
- @selfChange="purchaseUserChange"
- :init="false"
- />
- </el-form-item>
- <el-form-item label="签订日期" prop="contractStartDate">
- <el-date-picker
- v-model="form.contractStartDate"
- type="date"
- value-format="yyyy-MM-dd"
- format="yyyy-MM-dd"
- :clearable="false"
- placeholder="选择日期"
- style="width: 100%"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item label="付款条件" prop="paymentConditionName">
- <el-input
- clearable
- readonly
- v-model="form.paymentConditionName"
- @click.native="handlePaymentConditionBtn"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item prop="orderFiles" label="附件">
- <fileMain v-model="form.orderFiles"></fileMain>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="生成付款计划表" prop="isGeneratePaymentPlan">
- <el-radio-group v-model="form.isGeneratePaymentPlan" @change="generatePlanChange">
- <el-radio :label="1">是</el-radio>
- <el-radio :label="0">否</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="交易方式" prop="transactionMode">
- <el-select
- v-model="form.transactionMode"
- placeholder="请选择"
- @change="transactionModeChange"
- style="width: 100%"
- >
- <el-option
- v-for="item in transactionMethodsOp"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="收货模式" prop="deliveryMode">
- <el-select
- v-model="form.deliveryMode"
- placeholder="请选择"
- disabled
- @change="deliveryModeChange"
- style="width: 100%"
- >
- <el-option
- v-for="item in shippingModePurchaseOp"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="结算方式" prop="settlementMode">
- <DictSelection
- dictName="结算方式"
- clearable
- @itemChange="settlementModeChange"
- v-model="form.settlementMode"
- >
- </DictSelection>
- </el-form-item>
- <el-form-item v-if="form.settlementMode == 1" label="结算日期范围" prop="settlementDate">
- <!-- <el-date-picker
- v-model="form.contractStartDate"
- @change="setDeliveryDays"
- type="date"
- placeholder="选择日期"
- style="width: 100%"
- >
- </el-date-picker> -->
- <el-date-picker
- style="width: 100%"
- v-model="form.settlementDate"
- :clearable="false"
- type="daterange"
- value-format="yyyy-MM-dd"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- @change="settlementDateChange">
- </el-date-picker>
- </el-form-item>
- <el-form-item v-if="form.settlementMode == 2 || isInstallment" label="结算月份范围" prop="settlementDate">
- <!-- <el-date-picker
- v-model="form.contractEndDate"
- type="date"
- placeholder="选择日期"
- style="width: 100%"
- >
- </el-date-picker> -->
- <el-date-picker
- v-model="form.settlementDate"
- type="monthrange"
- :clearable="isInstallment"
- range-separator="至"
- start-placeholder="开始月份"
- end-placeholder="结束月份"
- value-format="yyyy-MM"
- style="width: 100%"
- @change="settlementDateChange"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item v-if="form.settlementMode == 2 || isInstallment" label="收款日期" prop="receiptDate">
- <el-input type="number" :min="1" :max="31" placeholder="请输入" v-model="form.receiptDate" @input="receiptDateChange">
- <template slot="prepend">每月</template>
- <template slot="append">日</template>
- </el-input>
- </el-form-item>
- <el-form-item
- v-if="form.isGeneratePaymentPlan != 0"
- label="期数"
- prop="issueNumber"
- >
- <el-input type="number" :min="1" v-model="form.issueNumber" @input="issueNumberChange">
- <template slot="append">
- <span>期</span>
- </template>
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle title="基本信息"></headerTitle>
- <el-row>
- <el-col :span="12">
- <el-form-item label="采购方名称" prop="partaName">
- <el-select
- style="width: 100%"
- v-model="form.partaName"
- 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="采购方统一社会信用代码"
- class="form_item_label"
- prop="partaUnifiedSocialCreditCode"
- >
- <el-input
- clearable
- v-model="form.partaUnifiedSocialCreditCode"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="采购方联系人" prop="partaLinkName">
- <el-input
- clearable
- v-model="form.partaLinkName"
- @click.native="handHead"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="采购方电话" prop="partaTel">
- <el-input
- clearable
- :maxlength="20"
- v-model="form.partaTel"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="采购方传真" prop="partaFax">
- <el-input clearable v-model="form.partaFax" placeholder="请输入" />
- </el-form-item>
- <el-form-item label=" 采购方Email" prop="partaEmail">
- <el-input
- clearable
- v-model="form.partaEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="采购方地址" prop="partaAddress">
- <el-input
- clearable
- v-model="form.partaAddress"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="供应商名称" prop="partbName">
- <el-row>
- <el-col :span="form.partbName ? 19 : 24">
- <el-input
- clearable
- v-model="form.partbName"
- @click.native="handParent"
- :disabled="!!form.contractId"
- placeholder="请选择"
- >
- </el-input>
- </el-col>
- <el-col :span="5">
- <el-button
- v-if="form.partbName"
- style="color: #fff; background: #1890ff"
- @click.native="handleGoodsList"
- >供货列表
- </el-button>
- </el-col>
- </el-row>
- </el-form-item>
- <el-form-item
- label="供应商统一社会信用代码"
- prop="partbUnifiedSocialCreditCode"
- class="form_item_label"
- >
- <el-input
- clearable
- v-model="form.partbUnifiedSocialCreditCode"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="供应商联系人" prop="partbLinkName">
- <el-select
- style="width: 100%"
- v-model="form.partbLinkName"
- placeholder="请选择"
- @change="onchangeLink"
- >
- <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 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">
- <el-input
- clearable
- v-model="form.partbEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="供应商地址" prop="partbAddress">
- <el-input
- clearable
- v-model="form.partbAddress"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <!-- <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle> -->
- <headerTitle
- title="物品清单"
- style="margin-top: 30px"
- >
- <el-button
- type="primary"
- size="mini"
- style="margin-bottom: 5px"
- @click="stockShow"
- >库存台账</el-button>
- <el-button
- type="primary"
- size="mini"
- style="margin-bottom: 5px"
- @click="orderListShow"
- v-if="!form.id"
- >历史记录</el-button
- ></headerTitle
- >
- <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
- <el-tab-pane label="物品清单" name="1">
- <inventoryTable
- ref="inventoryTable"
- @orderDiscountAmount="orderDiscountAmount"
- :pricingWay="form.pricingWay"
- :supplierMark="form.supplierMark"
- :is-show-supplier-mark="true"
- :isContractId="
- !!form.contractId && !OutValidate.includes(form.sourceType)
- "
- :isBatchNo="isBatchNo == 1"
- :showSaleCount="true"
- @getProductData="getSupplierData"
- >
- </inventoryTable>
- </el-tab-pane>
- <el-tab-pane
- label="带料清单"
- name="2"
- v-if="orderSourceType.includes(form.sourceType)"
- >
- <inventoryTable
- ref="rawDetailListRef"
- :detailType="1"
- :pricingWay="form.pricingWay"
- :supplierMark="form.supplierMark"
- :is-show-supplier-mark="true"
- cacheKeyUrl="eos-purchasingManage-purchaseOrder-inventoryTable1"
- :isContractId="
- !!form.contractId && !OutValidate.includes(form.sourceType)
- "
- @dataChange="rawDataChange"
- ></inventoryTable>
- </el-tab-pane>
- <el-tab-pane
- label="产出清单"
- name="3"
- v-if="orderSourceType.includes(form.sourceType)"
- >
- <inventoryTable
- ref="outputDetailListRef"
- :detailType="2"
- :pricingWay="form.pricingWay"
- :supplierMark="form.supplierMark"
- cacheKeyUrl="eos-purchasingManage-purchaseOrder-inventoryTable2"
- :is-show-supplier-mark="true"
- :isContractId="
- !!form.contractId && !OutValidate.includes(form.sourceType)
- "
- @dataChange="outputDataChange"
- ></inventoryTable>
- </el-tab-pane>
- </el-tabs>
- <el-row style="margin-top: 20px">
- <el-col :span="12">
- <el-form-item label="总金额" prop="totalAmount">
- {{ allcountAmount || 0 }}元
- </el-form-item>
- <el-form-item label="备注" prop="remark">
- <el-input
- clearable
- type="textarea"
- v-model="form.remark"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="优惠后总金额" prop="payAmount">
- <el-input
- clearable
- v-model="form.payAmount"
- :disabled="
- (!!form.contractId && !OutValidate.includes(form.sourceType)) ||
- !allcountAmount
- "
- type="number"
- @blur="discountInput"
- placeholder="请输入"
- >
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <div v-if="form.isGeneratePaymentPlan != 0">
- <headerTitle
- title="付款计划"
- style="margin-top: 30px"
- ></headerTitle>
- <PaymentCollectionPlan
- ref="paymentCollectionPlanRef"
- menu="purchase"
- :info="form"
- @getIssueNumber="setIssueNumber"
- ></PaymentCollectionPlan>
- </div>
- </el-form>
- <div slot="footer" class="footer">
- <el-button type="primary" @click="save" v-click-once>保存</el-button>
- <el-button type="primary" @click="save('sub')" v-click-once
- >提交</el-button
- >
- <el-button @click="cancel">返回</el-button>
- </div>
- <selectStockLedgerDialog ref="selectStockLedgerDialogRef" :isSupplier="true" :isView="true" :cacheKeyUrl="cacheKeyUrl+'saleOrderss'"></selectStockLedgerDialog>
- <parentList
- ref="parentRef"
- @changeParent="changeParent"
- :classType="2"
- ></parentList>
- <head-list ref="headRef" @changeParent="changePersonel"></head-list>
- <contractListDialog
- :hasGeneratedOrder="
- this.OutValidate.includes(this.form.sourceType) ? 3 : 0
- "
- ref="selectContractRef"
- @changeParent="changeContract"
- :type="2"
- :sourceType="form.sourceType"
- ></contractListDialog>
- <inquiryManageList
- ref="inquiryManageRef"
- @changeInquiryManageList="changeInquiryManageList"
- ></inquiryManageList>
- <process-submit-dialog
- :isNotNeedProcess="true"
- api-fun-name="purchaseorderStatusAPI"
- :processSubmitDialogFlag.sync="processSubmitDialogFlag"
- v-if="processSubmitDialogFlag"
- ref="processSubmitDialogRef"
- @reload="reload"
- ></process-submit-dialog>
- <purchaseNeedList
- ref="purchaseNeedList"
- @changeParent="changePurchaseNeedList"
- ></purchaseNeedList>
- <inquiryList
- ref="inquiryListRef"
- @changeParent="changeInquiryList"
- ></inquiryList>
- <supplier-goods-list-dialog
- @changeParent="changeValue"
- :supplier-goods-list-dialog-flag.sync="supplierGoodsListDialogFlag"
- v-if="supplierGoodsListDialogFlag"
- ref="supplierGoodsListDialogRef"
- ></supplier-goods-list-dialog>
- <planTableList
- ref="planTableListRef"
- @success="putTableValue"
- @contractSuccess="contractSuccess"
- ></planTableList>
- <projectListDialog
- ref="selectProjectRef"
- @changeParent="changeProject"
- ></projectListDialog>
- <!-- 销售退货 -->
- <return-order-dialog
- :returnOrderDialogFlag.sync="returnOrderDialogFlag"
- returnSourceType=""
- hasHandleReceipt=""
- types=""
- v-if="returnOrderDialogFlag"
- @changeParent="changeReturn"
- >
- </return-order-dialog>
- <!-- 销售处理退货 -->
- <returnOrderDealDialog
- :returnOrderDealDialogFlag.sync="returnOrderDealDialogFlag"
- v-if="returnOrderDealDialogFlag"
- @changeParent="changeReturnDeal"
- >
- </returnOrderDealDialog>
- <!-- 采购退货 -->
- <purchase-return-order-dialog
- :purchaseReturnOrderDialogFlag.sync="purchaseReturnOrderDialogFlag"
- v-if="purchaseReturnOrderDialogFlag"
- @changeParent="getPReturnOrderInfo"
- ref="returnOrderDialogRef"
- ></purchase-return-order-dialog>
- <!-- 采购订单 -->
- <orderListDialog
- ref="orderListDialogRef"
- :isMy="true"
- :contactData="{
- id: form.partbId
- }"
- @changeParent="changeHistoryOrder"
- ></orderListDialog>
- <!-- 付款条件 -->
- <receiveTermsDialog ref="receiveTermsDialogRef" conditionType="terms" @changeParent="changeReceiveTerms"></receiveTermsDialog>
- <ele-modal
- custom-class="ele-dialog-form long-dialog-form"
- :visible.sync="supplierListShow"
- title="选择供应商"
- :close-on-click-modal="false"
- width="600px"
- append-to-body
- >
- <el-select style="width: 100%" v-model="supplierId" placeholder="请选择">
- <el-option
- v-for="item in supplierList"
- :key="item.supplierId"
- :label="item.supplierName"
- :value="item.supplierId"
- >
- </el-option>
- </el-select>
- <div slot="footer" class="footer">
- <el-button
- type="primary"
- @click="
- changeParent({ id: supplierId });
- supplierListShow = false;
- "
- >确认</el-button
- >
- <el-button @click="supplierListShow = false">返回</el-button>
- </div>
- </ele-modal>
- </ele-modal>
- </template>
- <script>
- import { emailReg, telReg } from 'ele-admin';
- import inventoryTable from './inventoryTableNew.vue';
- import planTableList from './planTableList.vue';
- import fileUpload from '@/components/upload/fileUpload';
- 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/purchasingManage/supplierManage/components/parentList.vue';
- import {
- enterprisePage,
- getDetail,
- updateContractStatus
- } from '@/api/contractManage/contractBook';
- import supplierGoodsListDialog from '@/views/purchasingManage/purchaseOrder/components/supplierGoodsListDialog.vue';
- import {
- addInformation,
- getProductsBySource,
- getPurchaseinquiryAPI,
- getpurchaseorderDetail,
- getPurchasePlanByContractIdAPI,
- UpdateInformation,
- getSupplierInfo,
- getByIdForEdit
- } from '@/api/purchasingManage/purchaseOrder';
- import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
- import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
- import { getcontactlink } from '@/api/saleManage/businessFollow';
- import headList from '@/BIZComponents/user-select/user-select.vue';
- import contractListDialog from '@/views/saleManage/saleOrder/components/contractListDialog.vue';
- import { listOrganizations } from '@/api/system/organization';
- import { copyObj } from '@/utils/util';
- import inquiryManageList from '@/views/purchasingManage/inquiryManage/components/inquiryManage-list.vue';
- // import fileMain from '@/components/addDoc/index.vue';
- import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
- import purchaseNeedList from '@/views/purchasingManage/purchasePlanManage/components/purchaseNeed-list.vue';
- import inquiryList from './inquiryList.vue';
- import projectListDialog from '@/views/saleManage/saleOrder/components/projectListDialog.vue'
- import {
- contactDetail,
- updateRelationStatus
- } from '@/api/saleManage/contact';
- import {
- requirementSourceType,
- acceptUnpackoptions,
- orderSourceType,
- outsourceSceneList
- } from '@/enum/dict.js';
- import returnOrderDialog from '@/views/saleManage/saleOrder/customerReturnOrder/returnOrderDialog.vue';
- import {
- getSaleOrderDetail,
- } from '@/api/saleManage/saleorder';
- import returnOrderDealDialog from './returnOrderDealDialog.vue';
- import purchaseReturnOrderDialog from '@/views/transportManager/shipManage/dispatchManage/components/purchaseReturnOrderDialog.vue';
- import PaymentCollectionPlan from '@/BIZComponents/paymentCollectionPlan/Index.vue'
- import { shippingModePurchaseOp, transactionMethodsOp } from '@/enum/dict.js';
- import { formatDate } from '@/utils/dateUtils';
- import { formatPrice } from '@/BIZComponents/setProduct.js';
- import { parameterGetByCode } from '@/api/main/index.js';
- import orderListDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/orderListDialog.vue';
- import receiveTermsDialog from '@/views/financialManage/advanceReceipt/components/receiveTermsDialog.vue'
- import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
- export default {
- mixins: [dictMixins],
- props: {
- isRequired: {
- type: Boolean,
- default: true
- }
- },
- components: {
- inquiryList,
- purchaseNeedList,
- processSubmitDialog,
- // fileMain,
- inquiryManageList,
- fileUpload,
- headList,
- contractListDialog,
- inventoryTable,
- deptSelect,
- parentList,
- personSelect,
- supplierGoodsListDialog,
- planTableList,
- projectListDialog,
- returnOrderDialog,
- returnOrderDealDialog,
- purchaseReturnOrderDialog,
- PaymentCollectionPlan,
- orderListDialog,
- receiveTermsDialog,
- selectStockLedgerDialog
- },
- data() {
- let formDef = {
- id: '',
- contractId: '',
- relationType: '',
- relationName: '',
- orderFiles: [],
- contractName: '',
- deliveryDate: '',
- payAmount: '',
- projectName: '',
- projectId: '',
- receiveAddress: '',
- sourceType: '',
- sourceTypeName: '',
- pricingWay: 1,
- remark: '',
- saleType: '',
- saleTypeName: '',
- totalAmount: '',
- isGeneratePaymentPlan: 0,
- settlementMode: '4',
- settlementModeName: '分期付款',
- partaUnifiedSocialCreditCode: '',
- partbUnifiedSocialCreditCode: '',
- partaAddress: '',
- partaEmail: '',
- partaFax: '',
- partaId: '',
- partaLinkId: '',
- partaLinkName: '',
- partaName: '',
- partaTel: '',
- partbAddress: '',
- partbEmail: '',
- partbFax: '',
- partbId: '',
- partbLinkId: '',
- partbLinkName: '',
- partbName: '',
- partbTel: '',
- purchasePlanId: '',
- purchasePlanNo: '',
- purchasePlanName: '',
- isFirstProcess: 0,
- purchaseDeptId: '',
- purchaseDeptName: '',
- purchaseUserId: '',
- purchaseUserName: '',
- issueNumber: 1,
- transactionMode: 1,
- deliveryMode: 1,
- settlementDate: [],
- endSettlementDate: '',
- startSettlementDate: '',
- receiptDate: 1,
- contractStartDate:''
- };
- return {
- purchaseReturnOrderDialogFlag: false,
- returnOrderDealDialogFlag: false,
- returnOrderDialogFlag: false,
- supplierListShow: false,
- supplierList: [],
- supplierId: '',
- orderSourceType,
- outsourceSceneList,
- requirementSourceType,
- processList: [
- {
- label: '是',
- value: 1
- },
- {
- label: '否',
- value: 0
- }
- ],
- isFlag: false, //订单类型是否不可修改
- clearing: false, //是否清除合同
- payWayOptions: [],
- delDetailIds: [],
- linkNameOptions: [],
- acceptUnpackoptions,
- visible: false,
- fullscreen: false,
- processSubmitDialogFlag: false,
- supplierGoodsListDialogFlag: false,
- title: '',
- row: {},
- activeName: '1',
- pricingWayList: [
- { id: 1, name: '按数量计价' },
- { id: 2, name: '按重量计价' }
- ],
- formDef,
- form: copyObj(formDef),
- enterprisePage: [],
- tableBankData: [],
- tableLinkData: [],
- // 组织机构树形结构数据
- groupTreeData: [],
- groupData: [],
- OutValidate: ['3', '4'],
- // 切换订单类型时缓存带料清单与产出清单的数据,避免因 tab 销毁而丢失
- rawDetailListCache: [],
- outputDetailListCache: [],
- // 记录上一次订单类型是否在 orderSourceType 中,用于判断是否需要恢复缓存
- prevSourceTypeInOrder: false,
- // 提交状态
- loading: false,
- // 是否是修改
- isUpdate: false,
- businessId: '',
- winnerSuppleIds: '',
- shippingModePurchaseOp,
- transactionMethodsOp,
- defaultTransactionMode: 1,
- isBatchNo: 0,
- isGenReceiptPlan: 1
- };
- },
- computed: {
- allcountAmount() {
- return this.$store.state.order.allcountAmount;
- },
- showReturnRelation() {
- return ['8','9'].includes(this.form.sourceType);
- },
- filterList() {
- return this.isUpdate ? this.requirementSourceType : this.requirementSourceType.filter(item => item.value !== '8');
- },
- // 结算方式是否为「分期付款」
- isInstallment() {
- const mode = this.form.settlementMode;
- if (mode === '' || mode === null || mode === undefined) return false;
- return mode == 4 || this.form.settlementModeName === '分期付款';
- },
- rules() {
- let isRequired = true;
- // console.log(this.isRequired);
- return {
- deliveryDate: [
- { required: true, message: '请选择交货日期', trigger: 'change' }
- ],
- isGeneratePaymentPlan: [
- { required: true, message: '请选择是否生成付款计划表', trigger: 'change' }
- ],
- purchasePlanName: [
- {
- required: this.OutValidate.includes(this.form.sourceType),
- message: '请选择采购计划单',
- trigger: ['change', 'blur']
- }
- ],
- relationName: [
- {
- required: true,
- message: '请选择',
- trigger: ['change', 'blur']
- }
- ],
- contractName: [
- {
- required: true,
- message: '请选择合同',
- trigger: ['change', 'blur']
- }
- ],
- // purchaseType: [
- // {required: true, message: '请选择采购订单类型', trigger: 'change'}
- // ],
- settlementMode: [
- { required: true, message: '请选择结算方式', trigger: 'change' }
- ],
- partaName: [
- {
- required: true,
- message: '请选择供应商名称',
- trigger: 'change'
- }
- ],
- partaLinkName: [
- {
- required: isRequired,
- message: '请输入采购方联系人',
- trigger: ['change', 'blur']
- }
- ],
- acceptUnpack: [
- { required: true, message: '请选择是否接受', trigger: 'change' }
- ],
- sourceType: [
- { required: true, message: '请选择订单类型', trigger: 'change' }
- ],
- payAmount: [{ required: true, message: '请输入', trigger: 'blur' }],
- // partbAddress: [
- // { required: true, message: '请输入', trigger: 'blur' }
- // ],
- partaTel: [
- {
- required: isRequired,
- pattern: isRequired ? telReg : null,
- message: '请输入采购方电话',
- trigger: 'blur'
- }
- ],
- partbName: [
- { required: true, message: '请输入供采购方名称', trigger: 'change' }
- ],
- partbLinkName: [
- {
- required: isRequired,
- message: '请输入供应商联系人',
- trigger: 'change'
- }
- ],
- partbTel: [
- {
- required: isRequired,
- pattern: isRequired ? telReg : null,
- message: '请输入供应商联系电话',
- trigger: 'blur'
- }
- ],
- paymentConditionName: [
- {
- // 仅当「生成付款计划表 = 是」时付款条件才必填;选否则不再校验
- required: this.form.isGeneratePaymentPlan !== 0,
- message: '请选择付款条件',
- trigger: 'change'
- }
- ],
-
- };
- }
- },
- created() {
- console.log(this);
- this.getGroupAll();
- this.getEnterprisePage();
- this.changePersonel();
- //交易方式//1 先票后款 2 先款后票
- parameterGetByCode({
- code: 'eom_contract_add_transactionMode'
- }).then((res) => {
- this.defaultTransactionMode = +res.value;
- });
- //批次号是否必填//0否 1是
- parameterGetByCode({
- code: 'eom_purchaseOrder_batchNo'
- }).then((res) => {
- this.isBatchNo = res.value;
- });
- // 是否生成收款计划单默认配置//0否 1是
- parameterGetByCode({
- code: 'sale_order_gen_receipt_plan'
- }).then((res) => {
- this.isGenReceiptPlan = res.value;
- console.log('isGenReceiptPlan', this.isGenReceiptPlan);
- });
- },
- watch: {
- // 监听订单类型变化,缓存带料清单与产出清单数据,切换回支持类型时恢复
- 'form.sourceType'(newVal, oldVal) {
- const wasInOrder = this.orderSourceType.includes(oldVal);
- const isInOrder = this.orderSourceType.includes(newVal);
- // 从支持类型切到不支持类型:缓存当前数据
- if (wasInOrder && !isInOrder) {
- this.cacheDetailList();
- }
- // 从不支持类型切回支持类型:从缓存恢复数据
- if (!wasInOrder && isInOrder) {
- this.restoreCachedDetailList();
- }
- }
- },
- methods: {
- changeReceiveTerms(row, index) {
- console.log('changeReceiveTerms~~~', row)
- this.form.paymentConditionId = row.id;
- this.form.paymentConditionName = row.name;
- console.log('changeReceiveTerms!!!', this.form)
- this.$forceUpdate()
- },
- handlePaymentConditionBtn() {
- this.$refs.receiveTermsDialogRef.open();
- },
- generatePlanChange(val) {
- console.log(val)
- if(val == 0) {
- this.$refs.form?.clearValidate(['paymentConditionName']);
- } else {
- this.issueNumberChange(this.form.issueNumber);
- // this.$refs.paymentCollectionPlanRef?.setDiscountAmount(
- // this.form.payAmount
- // );
- }
- },
- stockShow() {
- this.$refs.selectStockLedgerDialogRef.open('', -1);
- },
- orderListShow() {
- if (!this.form.partbName) {
- this.$message.warning('请先选择供应商');
- return;
- }
- this.$refs.orderListDialogRef.open();
- },
- async changeHistoryOrder(item) {
- console.log('item~~~~', item)
- const data = await getpurchaseorderDetail(item.id);
- console.log('data~~~~', data);
- [
- 'id',
- 'orderId',
- 'createTime',
- 'createUserId',
- 'createUserName',
- 'createDept',
- 'orderNo',
- 'orderStatus',
- 'outboundStatus',
- 'payStatus',
- 'preOrderNo',
- 'progress',
- 'processInstanceId',
- 'orderBomList'
- ].forEach((key) => {
- delete data[key];
- data.productList.forEach((item) => {
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
- delete item[key];
- }
- });
- data.rawList.forEach((item) => {
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
- delete item[key];
- }
- });
- data.outputList.forEach((item) => {
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
- delete item[key];
- }
- });
- data.receiptPaymentList.forEach((item) => {
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
- delete item[key];
- }
- });
- });
- this.form = data;
- if (data) {
- // data.relationType = +data.relationType;
- this.$nextTick(() => {
- this.$store.commit('order/setAllcountAmount', data.totalAmount);
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(data.productList);
- this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
- this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
- this.getLinkInfo(data.partaId);
-
- this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
- this.getrequireUser(data.requireDeptId);
- if(data.purchaseDeptId) {
- this.getPurchaseUser(data.purchaseDeptId);
- }
- this.$store.commit('order/setContractId', data.contractId);
- });
- }
- },
- setIssueNumber(len) {
- this.form.issueNumber = len;
- // 分期付款下手工增删行后,同步回填新行的计划付款日期
- if (this.isInstallment) {
- this.$nextTick(() => {
- this.setInstallmentDeadLine();
- });
- }
- },
- getSupplierData(data) {
- console.log('data~~~', data);
- if(!this.form.partbName) {
- getSupplierInfo(data[data.length - 1].productId).then((res) => {
- console.log('res~~~', res);
- this.changeParent(res.data);
- })
- }
- },
- //选择退货单
- handleReturnBtn(e) {
- // this.$refs.returnListRef.open();
- if (e.target.nodeName == 'I') {
- this.$set(this.form, 'relationCode', '');
- this.$set(this.form, 'relationId', '');
- return;
- }
- this.returnOrderDialogFlag = true;
- },
- //退货单
- async changeReturn(row) {
- // console.log('data~~~', row);
- // this.form = Object.assign({}, this.form, {
- // relationCode: row.returnNo,
- // relationId: row.id
- // });
- // this.$set(this.form, 'relationName', data.requirementName);
- this.$set(this.form, 'relationId', row.id);
- this.$set(this.form, 'relationName', row.returnNo);
- this.getReturnOrderDetail(row);
- },
- async getReturnOrderDetail(row) {
- console.log('row', row.orderNo);
- const id = row.orderIds.split(',')[0];
- const res = await getSaleOrderDetail(id);
- console.log('res~~~~', res);
- if (row.partaId) {
- await this.changeParent({ id: row.partaId }, true);
- }
- if (res) {
- let {
- // partaAddress,
- // partaEmail,
- // partaFax,
- // partaId,
- // partaLinkId,
- // partaLinkName,
- // partaName,
- // partaTel,
- partbAddress,
- partbEmail,
- partbFax,
- partbId,
- partbLinkId,
- partbLinkName,
- partbName,
- partbTel,
- totalPrice,
- discountTotalPrice,
- // partaUnifiedSocialCreditCode,
- partbUnifiedSocialCreditCode,
- settlementMode,
- settlementModeName,
- pricingWay,
- productList,
- typedetailList,
- totalAmount,
- payAmount
- } = res;
- this.form = Object.assign({}, this.form, {
- partaAddress: partbAddress,
- partaEmail: partbEmail,
- partaFax: partbFax,
- partaId: partbId,
- partaLinkId: partbLinkId,
- partaLinkName: partbLinkName,
- partaName: partbName,
- partaTel: partbTel,
- // partbAddress,
- // partbEmail,
- // partbFax,
- // partbId,
- // partbLinkId,
- // partbLinkName,
- // partbName,
- // partbTel,
- totalPrice,
- discountTotalPrice,
- partaUnifiedSocialCreditCode: partbUnifiedSocialCreditCode,
- settlementMode,
- settlementModeName,
- pricingWay,
- productList,
- typedetailList,
- // totalAmount,
- payAmount
- });
- this.$nextTick(() => {
- this.$store.commit('order/setAllcountAmount', totalAmount);
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(res.productList);
- this.getLinkInfo(row.partaId);
- });
- }
- },
- // 销售处理退货
- handleReturnDealBtn(e) {
- if (e.target.nodeName == 'I') {
- this.$set(this.form, 'relationCode', '');
- this.$set(this.form, 'relationId', '');
- return;
- }
- this.returnOrderDealDialogFlag = true;
- },
- async changeReturnDeal(row) {
- this.$set(this.form, 'relationId', row.id);
- this.$set(this.form, 'relationName', row.returnNo);
- this.getReturnOrderDetail(row);
- },
- //选择采购退货单
- handlePurchaseReturnOrder() {
- this.purchaseReturnOrderDialogFlag = true;
- },
- //采购退货单回调
- getPReturnOrderInfo(row) {
- console.log('params~~~~', row);
- this.$set(this.form, 'relationId', row.id);
- this.$set(this.form, 'relationName', row.returnNo);
- this.getReturnPurchaseDetail(row);
- },
- async getReturnPurchaseDetail(row) {
- this.businessId = row.orderId;
- this.loading = true;
- const data = await getpurchaseorderDetail(row.orderId);
- this.loading = false;
- // this.form = data;
-
- if (data) {
- let {
- partaAddress,
- partaEmail,
- partaFax,
- partaId,
- partaLinkId,
- partaLinkName,
- partaName,
- partaTel,
- partbAddress,
- partbEmail,
- partbFax,
- partbId,
- partbLinkId,
- partbLinkName,
- partbName,
- partbTel,
- totalPrice,
- discountTotalPrice,
- partaUnifiedSocialCreditCode,
- partbUnifiedSocialCreditCode,
- settlementMode,
- settlementModeName,
- pricingWay,
- productList,
- typedetailList,
- totalAmount,
- payAmount
- } = data;
- this.form = Object.assign({}, this.form, {
- partaAddress,
- partaEmail,
- partaFax,
- partaId,
- partaLinkId,
- partaLinkName,
- partaName,
- partaTel,
- partbAddress,
- partbEmail,
- partbFax,
- partbId,
- partbLinkId,
- partbLinkName,
- partbName,
- partbTel,
- totalPrice,
- discountTotalPrice,
- partaUnifiedSocialCreditCode,
- partbUnifiedSocialCreditCode,
- settlementMode,
- settlementModeName,
- pricingWay,
- productList,
- typedetailList,
- totalAmount,
- payAmount
- });
- this.$nextTick(() => {
- this.$store.commit('order/setAllcountAmount', totalAmount);
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(data.productList);
- this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
- this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
- this.getLinkInfo(data.partaId);
- this.getrequireUser(this.form.requireDeptId);
- // this.$store.commit('order/setContractId', data.contractId);
- });
- }
- },
- //选择项目弹框
- handleProjectBtn() {
- if (this.clearing) return;
- let item = {
- id: this.form.projectId
- };
- this.$refs.selectProjectRef.open(item);
- },
- //选择项目回调
- async changeProject(obj) {
- this.projectData = obj;
- this.form = Object.assign({}, this.form, {
- projectName: obj.name,
- // projectId: obj.id,
- // projectCode: obj.code,
- });
- },
- // 选择负责人部门
- change_principalDep(id) {
- const info = this.groupData.find((e) => e.id == id);
- this.form.requireDeptName = info.name;
- // this.form.requireUserId = '';
- // this.form.requireUserName = '';
- this.$set(this.form, 'requireUserId', '');
- this.$set(this.form, 'requireUserName', '');
- // 根据部门获取人员
- this.getrequireUser(id);
- },
- // 选择采购部门
- changePurchaseDep(id) {
- const info = this.groupData.find((e) => e.id == id);
- this.form.purchaseDeptName = info.name;
- this.$set(this.form, 'purchaseUserId', '');
- this.$set(this.form, 'purchaseUserName', '');
- this.getPurchaseUser(id);
- },
- getPurchaseUser(groupId) {
- console.log('groupId~~~~', groupId);
- if (groupId) {
- this.$refs.purchaseDirectorRef.getList({ groupId });
- }
- },
- //选择采购需求
- handPurchaseNeed() {
- this.$refs.purchaseNeedList.open(
- this.form.relationCode,
- this.form.sourceType
- );
- },
- //选择采购需求回调
- async changePurchaseNeedList(data) {
- this.form.relationId = data.id;
- this.form.relationCode = data.requirementCode;
- this.form.relationName = data.requirementName;
- this.$set(this.form, 'relationName', data.requirementName);
- this.$set(this.form, 'relationId', data.id);
- this.$set(this.form, 'relationCode', data.requirementCode);
- this.$set(this.form, 'requireDeptId', data.requireDeptId);
- this.$set(this.form, 'requireDeptName', data.requireDeptName);
- this.$set(this.form, 'requireUserId', data.requireUserId);
- this.$set(this.form, 'requireUserName', data.requireUserName);
- this.getrequireUser(data.requireDeptId);
- let info = await getProductsBySource({
- relationId: this.form.relationId,
- relationType: this.form.relationType
- });
- info.productList.forEach((item) => {
- item['deliveryDeadline'] = item.expectReceiveDate;
- });
- let form = {
- contractVO: {
- ...this.form
- },
- productList: info.productList || []
- };
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(form.productList);
- },
- //选择采购计划
- handPurchasePlan() {
- this.$refs.inquiryManageRef.open(
- this.form.planCode,
- this.form.sourceType
- );
- },
- //选择采购计划回调
- async changeInquiryManageList(data) {
- this.form.purchasePlanId = data.id;
- this.form.purchasePlanNo = data.planCode;
- this.form.purchasePlanName = data.planName;
- this.form.relationId = data.id;
- this.form.relationCode = data.planCode;
- this.form.relationName = data.planName;
- this.form.requireDeptId = data.requireDeptId;
- this.form.requireDeptName = data.requireDeptName;
- this.form.requireUserId = data.requireUserId;
- this.form.requireUserName = data.requireUserName;
- this.$set(this.form, 'requireDeptId', data.requireDeptId);
- this.$set(this.form, 'requireDeptName', data.requireDeptName);
- this.$set(this.form, 'requireUserId', data.requireUserId);
- this.$set(this.form, 'requireUserName', data.requireUserName);
- this.getrequireUser(data.requireDeptId);
- // let cusInfo = {}
- this.$set(this.form, 'purchasePlanName', data.planName);
- this.$set(this.form, 'purchasePlanId', data.id);
- this.$set(this.form, 'purchasePlanNo', data.planCode);
- this.$set(this.form, 'relationName', data.planName);
- this.$set(this.form, 'relationId', data.id);
- this.$set(this.form, 'relationCode', data.planCode);
- const res = await getplanDetail(data.id);
- this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
- let info = await getProductsBySource({
- relationId: this.form.relationId,
- relationType: this.form.relationType
- });
- info['rawDetailList'] = info.rawList;
- info['outputDetailList'] = info.outputList;
- info.productList.forEach((item) => {
- item['deliveryDeadline'] = item.expectReceiveDate;
- });
- let supplierList = res.detailList
- .filter((item) => item.supplierId)
- .map((item) => {
- return {
- supplierId: item.supplierId,
- supplierName: item.supplierName
- };
- });
- if (supplierList?.length > 0) {
- this.supplierList = Array.from(
- new Set(supplierList.map((obj) => JSON.stringify(obj)))
- ).map((str) => JSON.parse(str));
- this.$nextTick(() => {
- this.putTableValue(info);
- });
- if (
- this.supplierList.length == 1 &&
- this.supplierList[0]?.supplierId
- ) {
- await this.changeParent({ id: this.supplierList[0]?.supplierId });
- } else {
- this.supplierListShow = true;
- }
- } else {
- this.putTableValue(info);
- }
- // let form = {
- // contractVO: {
- // ...this.form
- // },
- // productList: info.productList || []
- // }
- // const codeList = form.productList.map((item) => item.productCode);
- // let inventoryTotalList = await getInventoryTotalAPI(codeList);
- // form.productList.forEach((item) => {
- // let find =
- // inventoryTotalList.find((key) => key.code == item.productCode) || {};
- // item.availableCountBase = find.availableCountBase;
- // });
- // this.$refs.inventoryTable &&
- // this.$refs.inventoryTable.putTableValue(form.productList);
- },
- //选择核价单
- handInquiry(e) {
- this.$refs.inquiryListRef.open(this.form.sourceType);
- },
- //选择采购核价回调
- async changeInquiryList(data) {
- console.log(data, 'data=======');
- this.form.relationId = data.id;
- this.form.relationCode = data.inquiryCode;
- this.form.relationName = data.inquiryName;
- this.winnerSuppleIds = data.winnerSuppleIds;
- this.$set(this.form, 'relationName', data.inquiryName);
- this.$set(this.form, 'relationId', data.id);
- this.$set(this.form, 'relationCode', data.inquiryCode);
- const res = await getpurchaseinquiry(data.id);
- this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
- this.$set(this.form, 'requireDeptId', res.requireDeptId);
- this.$set(this.form, 'requireDeptName', res.requireDeptName);
- this.$set(this.form, 'requireUserId', res.requireUserId);
- this.$set(this.form, 'requireUserName', res.requireUserName);
- this.getrequireUser(res.requireDeptId);
- let info = await getProductsBySource({
- relationId: this.form.relationId,
- relationType: this.form.relationType,
- supplierId: this.winnerSuppleIds
- });
- info['rawDetailList'] = info.rawList;
- info['outputDetailList'] = info.outputList;
- info.productList.forEach((item) => {
- item['discountSinglePrice'] = item.singlePrice;
- item['discountTotalPrice'] = item.totalPrice;
- });
- if (info.productList.length > 1) {
- this.$refs.planTableListRef.open(info);
- } else {
- this.$nextTick(() => {
- this.putTableValue(info);
- });
- }
- this.form = {
- ...this.form,
- partbId: info.partbId,
- partbName: info.partbName,
- partbAddress: info.partaAddress,
- partbLinkId: info.partaAddress,
- partbLinkName: info.partbLinkName,
- partbEmail: info.partbEmail,
- partbTel: info.partbTel
- };
- await this.getLinkInfo(info.partbId);
- this.$nextTick(() => {
- let firstLink =
- this.linkNameOptions.find((item) => item.ifChief == 1) || {};
- this.form = Object.assign({}, this.form, {
- partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
- partbLinkName:
- firstLink.linkName || this.linkNameOptions[0]?.linkName,
- partbTel:
- firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
- });
- this.setProductInfo();
- });
- await this.changeParent({ id: info.partbId });
- },
- async putTableValue({ productList, rawDetailList, outputDetailList }) {
- let totalPrice = 0;
- productList.forEach((item) => {
- totalPrice += item.totalPrice ? (+item.totalPrice) : 0;
- });
- this.$store.commit('order/setAllcountAmount', totalPrice);
- this.$set(this.form, 'totalPrice', totalPrice);
- if (this.form.relationType == 3) {
- this.$set(this.form, 'payAmount', totalPrice);
- this.discountInput();
- }
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(productList);
- this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.putTableValue(rawDetailList); //原料
- this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.putTableValue(outputDetailList);
- },
- getrequireUser(groupId) {
- if (groupId) {
- this.$refs.directorRef.getList({ groupId });
- }
- },
- salesmanChange(val, info) {
- this.$set(this.form, 'requireUserId', val);
- this.$set(this.form, 'requireUserName', info.name);
- // this.form.requireUserName = info.name;
- },
- purchaseUserChange(val, info) {
- this.$set(this.form, 'purchaseUserId', val);
- this.$set(this.form, 'purchaseUserName', info.name);
- },
- // 获取公司数据
- getGroupAll() {
- listOrganizations().then((list) => {
- this.groupData = list;
- this.groupTreeData = this.$util.toTreeData({
- data: list,
- idField: 'id',
- parentIdField: 'parentId'
- });
- });
- },
- discountInput() {
- this.$refs.inventoryTable.discountInputByOrder(this.form.payAmount);
- this.$refs.paymentCollectionPlanRef?.setDiscountAmount(this.form.payAmount);
- },
- //产品清单修改单价或者数量重置优惠金额
- orderDiscountAmount(val = 0) {
- console.log('orderDiscountAmount~~~~', val);
- this.form.payAmount = val;
- this.$refs.paymentCollectionPlanRef.setDiscountAmount(val);
- //this.form.payAmount = undefined
- },
- //选择合同获取合同的详情
- async getDetailData(id) {
- this.loading = true;
- const data = await getDetail(id);
- let info = await getProductsBySource({
- relationId: this.form.relationId,
- relationType: this.form.relationType
- });
- this.loading = false;
- if (data) {
- // if (data.contractVO.sourceType == 3 && data.contractVO.sourceId) {
- // //获取需求部门
- // const res = await getplanDetail(data.contractVO.sourceId);
- // this.$nextTick(() => {
- // this.form.requireDeptId = res.requireDeptId;
- // this.form.requireDeptName = res.requireDeptName;
- // this.form.requireUserId = res.requireUserId;
- // this.form.requireUserName = res.requireUserName;
- // });
- // }
- this.$set(this.form, 'requireDeptId', data.contractVO?.requireDeptId);
- this.$set(
- this.form,
- 'requireDeptName',
- data.contractVO?.requireDeptName
- );
- this.$set(this.form, 'requireUserId', data.contractVO?.requireUserId);
- // this.$set(this.form, 'businessDeptId', data.contractVO?.businessDeptId);
- // this.$set(this.form, 'businessDeptName', data.contractVO?.businessDeptName);
- // this.$set(this.form, 'businessUserId', data.contractVO?.businessUserId);
- // this.$set(this.form, 'businessUserName', data.contractVO?.businessUserName);
- this.$set(
- this.form,
- 'requireUserName',
- data.contractVO?.requireUserName
- );
- console.log('data.contractVO~~~~', data.contractVO);
- this.getrequireUser(data.contractVO?.requireDeptId);
- this.getPurchaseUser(data.contractVO?.businessDeptId);
- this.$nextTick(() => {
- let { contractVO } = data;
- // this.form=contractVOform.receiveAddress
- let {
- partaAddress,
- partaEmail,
- partaFax,
- partaId,
- partaLinkId,
- partaLinkName,
- partaName,
- partaTel,
- partbAddress,
- partbEmail,
- partbFax,
- partbId,
- partbLinkId,
- partbLinkName,
- partbName,
- partbTel,
- totalPrice,
- discountTotalPrice,
- partaUnifiedSocialCreditCode,
- partbUnifiedSocialCreditCode,
- settlementMode,
- settlementModeName,
- pricingWay,
- isFirstProcess,
- requireSourceType,
- requireSourceTypeName,
- businessDeptId,
- businessDeptName,
- businessUserId,
- businessUserName,
- transactionMode,
- startSettlementDate,
- receiptDate,
- issueNumber,
- endSettlementDate,
- deliveryMode,
- } = contractVO;
- this.form = Object.assign({}, this.form, {
- partaAddress,
- partaEmail,
- partaFax,
- partaId,
- partaLinkId,
- partaLinkName,
- partaName,
- partaTel,
- partbAddress,
- partbEmail,
- partbFax,
- partbId,
- partbLinkId,
- partbLinkName,
- partbName,
- partbTel,
- totalPrice,
- settlementMode,
- settlementModeName,
- discountTotalPrice,
- partaUnifiedSocialCreditCode,
- partbUnifiedSocialCreditCode,
- pricingWay,
- totalAmount: totalPrice,
- payAmount: discountTotalPrice,
- receiveAddress: partaAddress,
- isFirstProcess,
- sourceType: requireSourceType || '1',
- sourceTypeName: requireSourceTypeName,
- purchaseDeptId: businessDeptId,
- purchaseDeptName: businessDeptName,
- purchaseUserId: businessUserId,
- purchaseUserName: businessUserName,
- transactionMode,
- startSettlementDate,
- receiptDate,
- issueNumber,
- endSettlementDate,
- deliveryMode,
- settlementDate: startSettlementDate ? [startSettlementDate, endSettlementDate] : [],
- });
- this.getLinkInfo(partaId);
- // info.productList = info.productList.map((item) => {
- // item['purchaseCount'] = item.contractCount;
- // item['purchaseUnit'] = item.contractUnit;
- // item['purchaseUnitId'] = item.contractUnitId;
- // return item;
- // });
- if (info.productList.length > 1) {
- console.log('info.productList~~~~', info.productList);
- this.$refs.planTableListRef.contractOpen(
- info.productList,
- contractVO.contractStartDate
- );
- } else {
- this.contractSuccess({
- productList: info.productList,
- contractStartDate: contractVO.contractStartDate
- });
- }
- const receiptData = {
- receiptPaymentList: data.receiptPaymentList,
- payAmount: discountTotalPrice
- }
- this.$refs.paymentCollectionPlanRef &&
- this.$refs.paymentCollectionPlanRef.putTableValue(receiptData);
- this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.putTableValue(contractVO.rawList); //原料
- this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.putTableValue(
- contractVO.outputList
- );
- this.$store.commit('order/setAllcountAmount', totalPrice);
- });
- }
- },
- contractSuccess({ productList, contractStartDate }) {
- console.log('productList~~~contractSuccess', productList);
- this.$nextTick(() => {
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(
- productList,
- contractStartDate
- );
- });
- },
- //获取订单详情
- async getpurchaseorderDetail(id, isEdit = false) {
- this.businessId = id;
- this.loading = true;
- const data = isEdit
- ? await getByIdForEdit(id)
- : await getpurchaseorderDetail(id);
- this.loading = false;
- data.settlementDate = data.startSettlementDate ? [data.startSettlementDate, data.endSettlementDate] : [];
- this.form = data;
- console.log('data~~~~~~~000', data);
- if (data) {
- this.$nextTick(() => {
- this.$store.commit('order/setAllcountAmount', data.totalAmount);
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(data.productList);
- this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
- this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
- this.getLinkInfo(data.partaId);
-
- this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
- this.getrequireUser(this.form.requireDeptId);
- if(data.purchaseDeptId) {
- this.getPurchaseUser(data.purchaseDeptId);
- }
- this.$store.commit('order/setContractId', data.contractId);
- });
- }
- },
- //更新联系人数据
- async getLinkInfo(contactId) {
- const data = await getcontactlink({ contactId });
- if (data && data?.length) {
- this.linkNameOptions = data;
- }
- },
- sourceTypeChange() {
- // 当sourceType改变时,只重置relationType,保留各清单数据
- this.form.relationType = '';
- },
- // 实时同步带料清单数据到缓存
- rawDataChange(val) {
- this.rawDetailListCache = val || [];
- },
- // 实时同步产出清单数据到缓存
- outputDataChange(val) {
- this.outputDetailListCache = val || [];
- },
- /**
- * 切换订单类型时缓存带料清单与产出清单的数据
- * 由于 tab 上的 v-if 会销毁子组件,所以提前把数据保存到父组件
- */
- cacheDetailList() {
- if (this.$refs.rawDetailListRef) {
- this.rawDetailListCache =
- this.$refs.rawDetailListRef.getTableValue() || [];
- }
- if (this.$refs.outputDetailListRef) {
- this.outputDetailListCache =
- this.$refs.outputDetailListRef.getTableValue() || [];
- }
- },
- /**
- * 当订单类型切回到支持带料/产出清单的类型时,从缓存恢复数据
- */
- restoreCachedDetailList() {
- this.$nextTick(() => {
- if (this.$refs.rawDetailListRef) {
- this.$refs.rawDetailListRef.putTableValue(
- this.rawDetailListCache || []
- );
- }
- if (this.$refs.outputDetailListRef) {
- this.$refs.outputDetailListRef.putTableValue(
- this.outputDetailListCache || []
- );
- }
- });
- },
- handleChangeRelationType(val) {
- // if(this.showReturnRelation) {
- // this.form.relationType = val;
- // }
- this.valueChange();
- },
- valueChange() {
- this.form.purchasePlanId = '';
- this.form.purchasePlanNo = '';
- this.form.purchasePlanName = '';
- this.form.relationId = '';
- this.form.relationCode = '';
- this.form.relationName = '';
- this.$nextTick(() => {
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue([]);
- });
- },
- //选择下拉框
- onchangeLink(selectedOptions) {
- 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
- });
- },
- handHead() {
- let item = {
- id: this.form.partaLinkId
- };
- this.$refs.headRef.open(item);
- },
- //选择供采购方人回调
- changePersonel(obj) {
- if (!obj) {
- obj = this.$store.getters.user.info;
- obj.id = obj.userId;
- }
- 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);
- },
- //选择供应商回调
- async changeParent(obj) {
- if (!obj.id) {
- return;
- }
- const { base, other } = await contactDetail(obj.id);
- this.form = Object.assign({}, this.form, {
- partbId: base.id,
- partbName: base.name,
- partbAddress: other.addressName
- ? other.addressName + other.address
- : base.addressName + other.address,
- partbLinkId: '',
- partbLinkName: '',
- partbEmail: '',
- partbTel: '',
- supplierMark: base.serialNo,
- partbUnifiedSocialCreditCode: base.unifiedSocialCreditCode
- });
- await this.getLinkInfo(obj.id);
- // this.form.productList=productList
- this.$nextTick(() => {
- let firstLink =
- this.linkNameOptions.find((item) => item.ifChief == 1) || {};
- this.form = Object.assign({}, this.form, {
- partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
- partbLinkName:
- firstLink.linkName || this.linkNameOptions[0]?.linkName,
- partbTel:
- firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
- });
- this.setProductInfo();
- });
- },
- setProductInfo() {
- this.$refs.inventoryTable.setCustomerMark(this.form.supplierMark);
- },
- //选择合同回调
- async changeContract(obj) {
- this.form = Object.assign({}, this.form, {
- contractId: obj.id,
- contractName: obj.contractName,
- contractNo: obj.contractNo,
- relationId: obj.id,
- relationName: obj.contractName,
- relationCode: obj.contractNo,
- contractStartDate: obj.contractStartDate,
- });
- await this.getPlanInfo(this.form.contractId);
- await this.getDetailData(obj.id);
- // //采购询价表
- // if(obj.sourceType==2){
- // obj.sourceId && this.getPurchaseinquiry(obj.sourceId);
- // }
- // //采购计划
- // if(obj.sourceType==3){
- // obj.sourceId && this.getPlanInfo(this.form.contractId);
- // }
- this.$store.commit('order/setContractId', obj.id);
- //获取合同采购计划
- },
- async getPlanInfo(id) {
- let res = await getPurchasePlanByContractIdAPI(id);
- if (!res.data?.id) return;
- this.form = Object.assign({}, this.form, {
- purchasePlanId: res.data?.id,
- purchasePlanName: res.data?.planName,
- purchasePlanNo: res.data?.planCode,
- sourceType: res.data?.sourceType,
- sourceTypeName: res.data?.sourceTypeName
- });
- },
- //选择合同弹框
- handleContractBtn() {
- if (this.clearing) return;
- let item = {
- id: this.form.contractId
- };
- this.$refs.selectContractRef.open(item, this.form.sourceType);
- },
- //清除合同
- clearContrcat() {
- this.clearing = true;
- this.isFlag = false;
- let {
- sourceType,
- sourceTypeName,
- requireDeptId,
- requireDeptName,
- requireUserId,
- requireUserName,
- settlementMode,
- settlementModeName,
- id,
- projectName,
- saleType,
- saleTypeName,
- deliveryDate,
- orderFiles,
- remark
- } = this.form;
- this.form = Object.assign({}, copyObj(this.formDef), {
- id,
- projectName,
- saleType,
- saleTypeName,
- deliveryDate,
- orderFiles,
- remark,
- sourceType,
- sourceTypeName,
- requireDeptId,
- requireDeptName,
- requireUserId,
- requireUserName,
- settlementMode,
- settlementModeName
- });
- this.$store.commit('order/setContractId', '');
- this.$store.commit('order/setAllcountAmount', 0);
- this.$refs.inventoryTable.putTableValue([]);
- this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.putTableValue([]);
- this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.putTableValue([]);
- setTimeout(() => {
- this.clearing = false;
- }, 500);
- },
- handParent() {
- if (this.form.contractId) {
- return this.$message.error('选择了合同不能更改供应商名称');
- }
- let item = {
- id: this.form.contactId
- };
- this.$refs.parentRef.open(item);
- },
- //通过合同获取订单类型
- async getPurchaseinquiry(sourceId) {
- let data = await getPurchaseinquiryAPI(sourceId);
- this.isFlag = !!data.sourceType;
- this.form = Object.assign({}, this.form, {
- sourceType: data.sourceType,
- sourceTypeName: data.sourceTypeName
- });
- },
- //打开新增编辑弹框
- async open(type, row, contactCategoryId) {
- this.title = type === 'add' ? '新增' : '修改';
- this.activeName = '1';
- this.row = row;
- // 打开弹框前先清空缓存,避免残留上次数据
- this.rawDetailListCache = [];
- this.outputDetailListCache = [];
- this.visible = true;
- if (this.enterprisePage.length == 0) {
- await this.getEnterprisePage();
- }
- if (type == 'add') {
- // console.log('enterprisePage~~~~~', this.enterprisePage);
- this.form.transactionMode = this.defaultTransactionMode;
- this.isUpdate = false;
- if (this.enterprisePage.length > 0) {
- this.form.partaName = this.enterprisePage[0]?.name;
- this.form.partaUnifiedSocialCreditCode =
- this.enterprisePage[0]?.unifiedSocialCreditCode;
- this.form.partaFax = this.enterprisePage[0]?.fax;
- this.form.partaAddress = this.enterprisePage[0]?.address;
- this.form.purchaseDeptId = this.enterprisePage[0]?.groupId || '';
- this.form.purchaseDeptName = this.enterprisePage[0]?.name || '';
- this.form.purchaseUserId = this.$store.state.user.info?.id || '';
- this.form.purchaseUserName = this.$store.state.user.info?.name || '';
- this.$nextTick(() => {
- this.issueNumberChange(this.form.issueNumber);
- if(this.form.purchaseDeptId) {
- this.getPurchaseUser(this.form.purchaseDeptId);
- }
- })
- }
- this.form.contractStartDate = formatDate(new Date(), 'yyyy-MM-dd');
- this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
- } else {
- this.isUpdate = true;
- await this.getpurchaseorderDetail(row.id, true);
- }
- },
- 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.partaName = data.name;
- this.form.partaUnifiedSocialCreditCode = data.unifiedSocialCreditCode;
- this.form.partaFax = data.fax;
- this.form.partaAddress = data.address;
- },
- //从合同页面新增订单
- contractOpen(row) {
- this.title = '新增';
- this.visible = true;
- this.isUpdate = false;
- this.form.relationType = 4;
- this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
- this.changeContract(row);
- },
- handleGoodsList() {
- console.log(11111);
- this.supplierGoodsListDialogFlag = true;
- this.$nextTick(() => {
- this.$refs.supplierGoodsListDialogRef.open(this.form.partbId);
- });
- },
- changeValue(val = []) {
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.getGoodsListData(val);
- },
- // 交易方式改变
- transactionModeChange(v) {
- },
- // 配送方式改变
- deliveryModeChange(v) {
- },
- // 结算方式改变
- settlementModeChange(v) {
- console.log('v~~~', v.dictCode);
- this.form.settlementModeName = v.dictValue;
- // this.$set(this.form, 'issueNumber', 1);
- this.$set(this.form, 'settlementDate', []);
- this.$set(this.form, 'receiptDate', 1);
- if (v.dictCode == 3) {
- this.$set(this.form, 'issueNumber', 2);
- } else {
- this.$set(this.form, 'issueNumber', 1);
- }
- this.$refs.paymentCollectionPlanRef.defaultList(v.dictCode, this.form.issueNumber);
- },
- // settlementModeChange(info) {
- // this.form.settlementModeName = info.dictValue;
- // },
- ifChiefChange(value, idx) {
- if (value === 1) {
- this.tableLinkData.forEach((e) => (e.ifChief = 0));
- this.tableLinkData[idx].ifChief = 1;
- }
- },
- getValidate() {
- if (this.form.isGeneratePaymentPlan !== 0 && !this.form.paymentConditionName) {
- this.$message.error('付款条件不能为空');
- }
- const arr = [
- 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);
- }
- });
- }),
- ]
- if(this.form.isGeneratePaymentPlan != 0) {
- arr.push(new Promise((resolve, reject) => {
- this.$refs.paymentCollectionPlanRef.validateForm((valid) => {
- if (!valid) {
- reject(false);
- } else {
- resolve(true);
- }
- });
- }))
- }
- return Promise.all(arr);
- },
- async save(type) {
- let is = false;
- try {
- await this.getValidate();
- // 表单验证通过,执行保存操作
- this.loading = true;
- let isTemporary = [];
- if (!this.isUpdate) {
- delete this.form.id;
- }
- // if (!this.form.contractId) { //如果来源是合同 金额不变这个逻辑有问题 先注释
- this.form.totalAmount = this.allcountAmount;
- // }
- const rawDetailList =
- (this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.getTableValue()) ||
- [];
- const outputDetailList =
- (this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.getTableValue()) ||
- [];
- const tabList =
- (this.$refs.inventoryTable &&
- this.$refs.inventoryTable.getTableValue()) ||
- [];
- tabList.forEach((v, i) => {
- if (!v.productCode) {
- isTemporary.push(v.productName);
- }
- tabList.forEach((v2, j) => {
- if (
- v.productCode == v2.productCode &&
- v.taskId == v2.taskId &&
- v.batchNo == v2.batchNo &&
- v.colorKey == v2.colorKey &&
- v.provenance?.join() == v2.provenance?.join() &&
- v.modelKey == v2.modelKey &&
- v.goodsLevel == v2.goodsLevel &&
- i != j
- ) {
- is = true;
- }
- });
- });
- if (isTemporary.length > 0) {
- this.$message.error(
- isTemporary.toString() +
- '是临时产品,无法创建订单,请先去主数据维护!'
- );
- return;
- }
- // if (is) {
- // this.$message.error('同产品,工序、批次号、颜色不能完全一致!');
- // return;
- // }
- let productList = [
- ...tabList,
- ...rawDetailList.map((item) => {
- item.singlePrice = item.singlePrice || 0;
- item.discountSinglePrice = item.discountSinglePrice || 0;
- item.totalPrice = item.totalPrice || 0;
- item.discountTotalPrice = item.discountTotalPrice || 0;
- return item;
- }),
- ...outputDetailList.map((item) => {
- item.singlePrice = item.singlePrice || 0;
- item.discountSinglePrice = item.discountSinglePrice || 0;
- item.discountTotalPrice = item.discountTotalPrice || 0;
- item.totalPrice = item.totalPrice || 0;
- return item;
- })
- ];
- console.log('提交数据~~~', this.form);
- let commitData = Object.assign({}, this.form, {
- productList,
- // purchaseTypeName: this.getDictValue(
- // '采购订单类型',
- // this.form.purchaseType
- // ),
- sourceTypeName: this.requirementSourceType.find(
- (val) => val.value == this.form.sourceType
- )?.label,
- receiptPaymentList: this.form.isGeneratePaymentPlan == 0 ? [] :
- this.$refs?.paymentCollectionPlanRef?.getTableValue() || [],
- endSettlementDate: this.form.settlementDate?.length ? this.form.settlementDate[1] : '',
- startSettlementDate: this.form.settlementDate?.length ? this.form.settlementDate[0] : ''
- });
- if(this.form.isGeneratePaymentPlan != 0) {
- const ratioSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + +cur.ratio, 0);
- // if(+ratioSum != 100){
- // this.$message.error('比例合计必须为100%');
- // return;
- // }
- if(+ratioSum > 100){
- this.$message.error('比例合计不能超过100%');
- return;
- }
- }
-
- // 使用万分之一进行计算,避免浮点数精度问题(对应4位小数)
- // let receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
- // const payAmount = +commitData.payAmount;
-
- // if(+ratioSum == 100) {
- // // 使用万分之一进行计算,避免浮点数精度问题
- // const difference = Math.round((payAmount - receiptPaymentListSum) * 10000) / 10000;
- // if (Math.abs(difference) >= 0.0001 && commitData.receiptPaymentList.length > 0) {
- // const lastIndex = commitData.receiptPaymentList.length - 1;
- // // 使用万分之一进行计算,避免浮点数精度问题
- // const newPrice = Math.round((+commitData.receiptPaymentList[lastIndex].price + difference) * 10000) / 10000;
- // commitData.receiptPaymentList[lastIndex].price = formatPrice(newPrice);
- // receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
- // }
- // }
- // if(Math.abs(+receiptPaymentListSum - payAmount) > 0.0001){
- // this.$message.error('计划收款金额合计与优惠后金额不一致');
- // return;
- // }
- // console.log('提交数据', commitData);
- if (this.isUpdate) {
- try {
- const res = await UpdateInformation(commitData);
- this.loading = false;
- this.$message.success('修改成功');
- updateRelationStatus([this.form.partbId]);
- if (this.form.contractId) {
- updateContractStatus([this.form.contractId]);
- }
- if (type === 'sub') {
- this.sub(res);
- return;
- }
- this.cancel();
- this.$emit('done');
- } catch (e) {
- this.loading = false;
- }
- } else {
- addInformation(commitData)
- .then((res) => {
- this.loading = false;
- this.$message.success('新增成功');
- updateRelationStatus([this.form.partbId]);
- if (type === 'sub') {
- this.sub(res);
- return;
- }
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- //this.loading = false;
- });
- }
- } catch (error) {
- console.log(error);
- // 表单验证未通过,不执行保存操作
- }
- },
- async sub(res) {
- const data = await getpurchaseorderDetail(this.businessId || res);
- this.processSubmitDialogFlag = true;
- this.$nextTick(() => {
- let params = {
- businessId: data.id,
- businessKey: 'purchase_order_approve',
- formCreateUserId: data.createUserId,
- variables: {
- businessCode: data.orderNo,
- businessName: data.partaName,
- businessType: data.sourceTypeName
- }
- // callBackMethodType : '1',
- // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
- // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
- // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
- // miniHandle : '',
- // miniView : '',
- };
- this.$refs.processSubmitDialogRef.init(params);
- });
- // submit({
- // businessId: this.businessId || res
- // }).then((res) => {
- // this.cancel();
- // this.$emit('done');
- // });
- },
- reload() {
- this.cancel();
- this.$emit('done');
- },
- cancel() {
- // 先清空带料清单与产出清单的缓存,避免 nextTick 异步导致关闭事件再次触发时缓存残留
- this.rawDetailListCache = [];
- this.outputDetailListCache = [];
- this.$nextTick(() => {
- this.isFlag = false;
- // 关闭后,销毁所有的表单数据
- this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
- this.$refs['formRef'] && this.$refs['formRef'].resetFields();
- this.$store.commit('order/clearUserData');
- this.form = copyObj(this.formDef);
- 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;
- },
- // 日期范围变化
- settlementDateChange(val) {
- // console.log(val);
- // 分期付款:期数由用户自行填写,这里只把计划付款日期回填到已有的付款计划行
- if (this.isInstallment) {
- this.setInstallmentDeadLine();
- return;
- }
- let dateRange = [];
- if(this.form.settlementMode == 1) {
- // // this.transformDays(val)
- dateRange = this.transformDaysFun(val);
- }
- if(this.form.settlementMode == 2) {
- // // this.transformMonth(val)
- dateRange = this.transformMonthFun(val, this.form.receiptDate);
- }
- console.log('dateRange~~~', dateRange);
- this.$set(this.form, 'issueNumber', dateRange.length);
- // this.setDefaultList(dateRange)
- this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
- },
- // 收款日变化
- receiptDateChange(v) {
- // this.transformMonth(this.form.settlementDate)
- if (this.isInstallment) {
- this.setInstallmentDeadLine();
- return;
- }
- if(this.form.settlementDate.length > 0 && this.form.issueNumber) {
- const dateRange = this.transformMonthFun(this.form.settlementDate, v);
- this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
- }
- },
- // 分期付款:按「结算月份范围 + 收款日期」给付款计划回填计划付款日期
- // 结算月份范围/收款日期均非必填,未填时不做任何赋值;只覆盖 deadLine,不影响用户已填的比例/款项名称/金额/说明
- setInstallmentDeadLine() {
- const { settlementDate, receiptDate } = this.form;
- if (!settlementDate || settlementDate.length < 2) return;
- const day = parseInt(receiptDate, 10);
- if (!day || day < 1 || day > 31) return;
- const dateRange = this.transformMonthFun(settlementDate, day);
- this.$refs.paymentCollectionPlanRef?.setDeadLineList(dateRange);
- },
- // 期数变化
- issueNumberChange(v) {
- let dateRange = [];
- if(this.form.settlementMode == 1) {
- dateRange = this.transformDaysFun(this.form.settlementDate, v);
- this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v, dateRange);
- } else if(this.form.settlementMode == 2) {
- dateRange = this.transformMonthFun(this.form.settlementDate, v);
- this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v, dateRange);
- } else if (this.isInstallment) {
- // 先按期数重建行,再回填计划付款日期
- this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v);
- this.$nextTick(() => {
- this.setInstallmentDeadLine();
- });
- } else {
- this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v);
- }
- },
- transformDaysFun(date) {
- const startDate = new Date(date[0]);
- const endDate = new Date(date[1]);
- // 计算毫秒差并转换为天数,使用Math.ceil确保结果为整数
- const days = Math.ceil((endDate - startDate) / (1000 * 60 * 60 * 24)) + 1;
- console.log('包含两头的天数:', days);
- // 生成包括头尾在内的所有日期
- const allDates = [];
- const current = new Date(startDate);
-
- // 遍历从开始日期到结束日期的所有天数
- while (current <= endDate) {
- // 格式化日期为YYYY-MM-dd
- const year = current.getFullYear();
- const month = current.getMonth() + 1; // 月份从0开始,需要+1
- const day = current.getDate();
-
- const formattedMonth = String(month).padStart(2, '0');
- const formattedDay = String(day).padStart(2, '0');
- const formattedDateStr = `${year}-${formattedMonth}-${formattedDay}`;
-
- allDates.push(formattedDateStr);
-
- // 移动到下一天
- current.setDate(current.getDate() + 1);
- }
- return allDates;
- },
- transformMonthFun(date, day) {
- // 处理月份数据(转换为Date对象)
- const parseMonthDate = (dateStr) => {
- return dateStr instanceof Date ? dateStr : new Date(dateStr + '-01');
- };
-
- const start = parseMonthDate(date[0]);
- const end = parseMonthDate(date[1]);
-
- // 先生成所有月份的日期数组
- const allMonthDates = [];
- const currentDate = new Date(start);
-
- // 遍历从开始月份到结束月份的所有月份
- while (currentDate <= end) {
- const year = currentDate.getFullYear();
- const month = currentDate.getMonth() + 1; // 月份从0开始,需要+1
- const receiptDate = day;
-
- // 格式化日期为YYYY-MM-dd
- const formattedMonth = String(month).padStart(2, '0');
- const formattedDate = String(receiptDate).padStart(2, '0');
- const deadLine = receiptDate ? `${year}-${formattedMonth}-${formattedDate}` : '';
-
- allMonthDates.push(deadLine);
-
- // 使用Date对象的setMonth方法正确移动到下一个月(自动处理年份变化)
- currentDate.setMonth(currentDate.getMonth() + 1);
- }
- return allMonthDates;
- },
- }
- };
- </script>
- <style scoped lang="scss">
- .TotalAmount {
- font-size: 16px;
- padding-right: 30px;
- }
- </style>
|