addDialogNew.vue 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. v-if="visible"
  6. :visible.sync="visible"
  7. :title="title"
  8. :close-on-click-modal="false"
  9. width="70%"
  10. @close="cancel"
  11. :maxable="true"
  12. :resizable="true"
  13. append-to-body
  14. >
  15. <el-form
  16. ref="form"
  17. :model="form"
  18. :rules="rules"
  19. class="el-form-box"
  20. label-width="120px"
  21. >
  22. <headerTitle title="订单信息"></headerTitle>
  23. <el-row>
  24. <el-col :span="8">
  25. <el-form-item label="订单类型" prop="sourceType">
  26. <el-select
  27. v-model="form.sourceType"
  28. placeholder="请选择"
  29. style="width: 100%"
  30. @change="sourceTypeChange"
  31. :disabled="isFlag || (isUpdate && form.sourceType === '8')"
  32. clearable
  33. >
  34. <el-option
  35. v-for="item in filterList"
  36. :key="item.value"
  37. :label="item.label"
  38. :value="item.value"
  39. >
  40. </el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="需求部门" prop="requireDeptId">
  44. <ele-tree-select
  45. clearable
  46. :data="groupTreeData"
  47. v-model="form.requireDeptId"
  48. valueKey="id"
  49. labelKey="name"
  50. placeholder="请选择"
  51. @change="change_principalDep"
  52. default-expand-all
  53. />
  54. </el-form-item>
  55. <el-form-item label="采购部门" prop="purchaseDeptId">
  56. <ele-tree-select
  57. clearable
  58. :data="groupTreeData"
  59. v-model="form.purchaseDeptId"
  60. valueKey="id"
  61. labelKey="name"
  62. placeholder="请选择"
  63. @change="changePurchaseDep"
  64. default-expand-all
  65. />
  66. </el-form-item>
  67. <el-form-item label="来源类型" prop="relationType">
  68. <el-select
  69. v-model="form.relationType"
  70. filterable
  71. clearable
  72. style="width: 100%"
  73. :disabled="(isUpdate && form.sourceType === '8')"
  74. @change="handleChangeRelationType"
  75. >
  76. <el-option v-if="!showReturnRelation" :value="1" label="采购需求单"></el-option>
  77. <el-option v-if="!showReturnRelation" :value="2" label="采购计划单"></el-option>
  78. <el-option v-if="!showReturnRelation" :value="3" label="采购核价单"></el-option>
  79. <el-option v-if="!showReturnRelation" :value="4" label="采购合同"></el-option>
  80. <el-option v-if="!showReturnRelation" :value="5" label="售后服务"></el-option>
  81. <el-option v-if="showReturnRelation" :value="6" label="销售退货单"></el-option>
  82. <el-option v-if="showReturnRelation" :value="7" label="销售退货处理单"></el-option>
  83. <el-option v-if="showReturnRelation" :value="8" label="采购退货单"></el-option>
  84. </el-select>
  85. </el-form-item>
  86. <el-form-item
  87. prop="outsourceScene"
  88. label="委外场景"
  89. v-if="
  90. orderSourceType.includes(form.sourceType) && form.outsourceScene
  91. "
  92. >
  93. <el-select
  94. v-model="form.outsourceScene"
  95. disabled
  96. style="width: 100%"
  97. >
  98. <el-option
  99. :value="item.value"
  100. :label="item.label"
  101. v-for="item in outsourceSceneList"
  102. :key="item.value"
  103. >
  104. </el-option>
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item
  108. v-if="form.relationType == 1"
  109. label="采购需求单"
  110. prop="relationName"
  111. >
  112. <el-input
  113. @click.native="handPurchaseNeed"
  114. v-model="form.relationName"
  115. placeholder="请选择"
  116. ></el-input>
  117. </el-form-item>
  118. <el-form-item
  119. v-if="form.relationType == 2"
  120. label="采购计划单"
  121. prop="relationName"
  122. >
  123. <el-input
  124. @click.native="handPurchasePlan"
  125. v-model="form.relationName"
  126. placeholder="请选择"
  127. ></el-input>
  128. </el-form-item>
  129. <el-form-item
  130. v-if="form.relationType == 3"
  131. label="采购核价单"
  132. prop="relationName"
  133. >
  134. <el-input
  135. @click.native="handInquiry"
  136. v-model="form.relationName"
  137. placeholder="请选择"
  138. ></el-input>
  139. </el-form-item>
  140. <el-form-item
  141. v-if="form.relationType == 4"
  142. label="选择合同"
  143. prop="contractName"
  144. >
  145. <el-input
  146. clearable
  147. v-model="form.contractName"
  148. @click.native="handleContractBtn"
  149. @clear="clearContrcat"
  150. placeholder="请输入"
  151. />
  152. </el-form-item>
  153. <el-form-item
  154. v-if="form.relationType == 6"
  155. label="销售退货单"
  156. prop="relationName"
  157. >
  158. <el-input
  159. clearable
  160. v-model="form.relationName"
  161. @click.native="handleReturnBtn"
  162. @clear="clearContrcat"
  163. placeholder="请输入"
  164. />
  165. </el-form-item>
  166. <el-form-item
  167. v-if="form.relationType == 7"
  168. label="销售退货处理单"
  169. prop="relationName"
  170. >
  171. <el-input
  172. clearable
  173. v-model="form.relationName"
  174. :disabled="(isUpdate && form.sourceType === '8')"
  175. @click.native="handleReturnDealBtn"
  176. @clear="clearContrcat"
  177. placeholder="请输入"
  178. />
  179. </el-form-item>
  180. <el-form-item
  181. v-if="form.relationType == 8"
  182. label="采购退货单"
  183. prop="relationName"
  184. >
  185. <el-input
  186. clearable
  187. v-model="form.relationName"
  188. @click.native="handlePurchaseReturnOrder"
  189. @clear="clearContrcat"
  190. placeholder="请输入"
  191. />
  192. </el-form-item>
  193. </el-col>
  194. <el-col :span="8">
  195. <!-- <el-form-item label="项目名称" prop="projectName">
  196. <el-input
  197. clearable
  198. v-model="form.projectName"
  199. placeholder="请输入"
  200. />
  201. </el-form-item> -->
  202. <el-form-item label="项目名称" prop="projectName">
  203. <el-input
  204. clearable
  205. v-model="form.projectName"
  206. placeholder="请输入"
  207. style="width: calc(100% - 80px)"
  208. />
  209. <el-button
  210. style="margin-left: 5px"
  211. size="small"
  212. type="primary"
  213. @click.native="handleProjectBtn"
  214. >选择
  215. </el-button>
  216. </el-form-item>
  217. <el-form-item label="需求人" prop="requireUserId">
  218. <personSelect
  219. ref="directorRef"
  220. v-model="form.requireUserId"
  221. @selfChange="salesmanChange"
  222. :init="false"
  223. />
  224. </el-form-item>
  225. <el-form-item label="采购员" prop="purchaseUserId">
  226. <personSelect
  227. ref="purchaseDirectorRef"
  228. v-model="form.purchaseUserId"
  229. @selfChange="purchaseUserChange"
  230. :init="false"
  231. />
  232. </el-form-item>
  233. <el-form-item label="签订日期" prop="contractStartDate">
  234. <el-date-picker
  235. v-model="form.contractStartDate"
  236. type="date"
  237. value-format="yyyy-MM-dd"
  238. format="yyyy-MM-dd"
  239. :clearable="false"
  240. placeholder="选择日期"
  241. style="width: 100%"
  242. >
  243. </el-date-picker>
  244. </el-form-item>
  245. <el-form-item label="付款条件" prop="paymentConditionName">
  246. <el-input
  247. clearable
  248. readonly
  249. v-model="form.paymentConditionName"
  250. @click.native="handlePaymentConditionBtn"
  251. placeholder="请输入"
  252. />
  253. </el-form-item>
  254. <el-form-item prop="orderFiles" label="附件">
  255. <fileMain v-model="form.orderFiles"></fileMain>
  256. </el-form-item>
  257. </el-col>
  258. <el-col :span="8">
  259. <el-form-item label="生成付款计划表" prop="isGeneratePaymentPlan">
  260. <el-radio-group v-model="form.isGeneratePaymentPlan" @change="generatePlanChange">
  261. <el-radio :label="1">是</el-radio>
  262. <el-radio :label="0">否</el-radio>
  263. </el-radio-group>
  264. </el-form-item>
  265. <el-form-item label="交易方式" prop="transactionMode">
  266. <el-select
  267. v-model="form.transactionMode"
  268. placeholder="请选择"
  269. @change="transactionModeChange"
  270. style="width: 100%"
  271. >
  272. <el-option
  273. v-for="item in transactionMethodsOp"
  274. :key="item.value"
  275. :label="item.label"
  276. :value="item.value"
  277. >
  278. </el-option>
  279. </el-select>
  280. </el-form-item>
  281. <el-form-item label="收货模式" prop="deliveryMode">
  282. <el-select
  283. v-model="form.deliveryMode"
  284. placeholder="请选择"
  285. disabled
  286. @change="deliveryModeChange"
  287. style="width: 100%"
  288. >
  289. <el-option
  290. v-for="item in shippingModePurchaseOp"
  291. :key="item.value"
  292. :label="item.label"
  293. :value="item.value"
  294. >
  295. </el-option>
  296. </el-select>
  297. </el-form-item>
  298. <el-form-item label="结算方式" prop="settlementMode">
  299. <DictSelection
  300. dictName="结算方式"
  301. clearable
  302. @itemChange="settlementModeChange"
  303. v-model="form.settlementMode"
  304. >
  305. </DictSelection>
  306. </el-form-item>
  307. <el-form-item v-if="form.settlementMode == 1" label="结算日期范围" prop="settlementDate">
  308. <!-- <el-date-picker
  309. v-model="form.contractStartDate"
  310. @change="setDeliveryDays"
  311. type="date"
  312. placeholder="选择日期"
  313. style="width: 100%"
  314. >
  315. </el-date-picker> -->
  316. <el-date-picker
  317. style="width: 100%"
  318. v-model="form.settlementDate"
  319. :clearable="false"
  320. type="daterange"
  321. value-format="yyyy-MM-dd"
  322. range-separator="至"
  323. start-placeholder="开始日期"
  324. end-placeholder="结束日期"
  325. @change="settlementDateChange">
  326. </el-date-picker>
  327. </el-form-item>
  328. <el-form-item v-if="form.settlementMode == 2 || isInstallment" label="结算月份范围" prop="settlementDate">
  329. <!-- <el-date-picker
  330. v-model="form.contractEndDate"
  331. type="date"
  332. placeholder="选择日期"
  333. style="width: 100%"
  334. >
  335. </el-date-picker> -->
  336. <el-date-picker
  337. v-model="form.settlementDate"
  338. type="monthrange"
  339. :clearable="isInstallment"
  340. range-separator="至"
  341. start-placeholder="开始月份"
  342. end-placeholder="结束月份"
  343. value-format="yyyy-MM"
  344. style="width: 100%"
  345. @change="settlementDateChange"
  346. >
  347. </el-date-picker>
  348. </el-form-item>
  349. <el-form-item v-if="form.settlementMode == 2 || isInstallment" label="收款日期" prop="receiptDate">
  350. <el-input type="number" :min="1" :max="31" placeholder="请输入" v-model="form.receiptDate" @input="receiptDateChange">
  351. <template slot="prepend">每月</template>
  352. <template slot="append">日</template>
  353. </el-input>
  354. </el-form-item>
  355. <el-form-item
  356. v-if="form.isGeneratePaymentPlan != 0"
  357. label="期数"
  358. prop="issueNumber"
  359. >
  360. <el-input type="number" :min="1" v-model="form.issueNumber" @input="issueNumberChange">
  361. <template slot="append">
  362. <span>期</span>
  363. </template>
  364. </el-input>
  365. </el-form-item>
  366. </el-col>
  367. </el-row>
  368. <headerTitle title="基本信息"></headerTitle>
  369. <el-row>
  370. <el-col :span="12">
  371. <el-form-item label="采购方名称" prop="partaName">
  372. <el-select
  373. style="width: 100%"
  374. v-model="form.partaName"
  375. placeholder="请选择"
  376. @change="getEnterprise()"
  377. >
  378. <el-option
  379. v-for="item in enterprisePage"
  380. :key="item.id"
  381. :label="item.name"
  382. :value="item.name"
  383. >
  384. </el-option>
  385. </el-select>
  386. </el-form-item>
  387. <el-form-item
  388. label="采购方统一社会信用代码"
  389. class="form_item_label"
  390. prop="partaUnifiedSocialCreditCode"
  391. >
  392. <el-input
  393. clearable
  394. v-model="form.partaUnifiedSocialCreditCode"
  395. placeholder="请输入"
  396. />
  397. </el-form-item>
  398. <el-form-item label="采购方联系人" prop="partaLinkName">
  399. <el-input
  400. clearable
  401. v-model="form.partaLinkName"
  402. @click.native="handHead"
  403. placeholder="请输入"
  404. />
  405. </el-form-item>
  406. <el-form-item label="采购方电话" prop="partaTel">
  407. <el-input
  408. clearable
  409. :maxlength="20"
  410. v-model="form.partaTel"
  411. placeholder="请输入"
  412. />
  413. </el-form-item>
  414. <el-form-item label="采购方传真" prop="partaFax">
  415. <el-input clearable v-model="form.partaFax" placeholder="请输入" />
  416. </el-form-item>
  417. <el-form-item label=" 采购方Email" prop="partaEmail">
  418. <el-input
  419. clearable
  420. v-model="form.partaEmail"
  421. placeholder="请输入"
  422. />
  423. </el-form-item>
  424. <el-form-item label="采购方地址" prop="partaAddress">
  425. <el-input
  426. clearable
  427. v-model="form.partaAddress"
  428. placeholder="请输入"
  429. />
  430. </el-form-item>
  431. </el-col>
  432. <el-col :span="12">
  433. <el-form-item label="供应商名称" prop="partbName">
  434. <el-row>
  435. <el-col :span="form.partbName ? 19 : 24">
  436. <el-input
  437. clearable
  438. v-model="form.partbName"
  439. @click.native="handParent"
  440. :disabled="!!form.contractId"
  441. placeholder="请选择"
  442. >
  443. </el-input>
  444. </el-col>
  445. <el-col :span="5">
  446. <el-button
  447. v-if="form.partbName"
  448. style="color: #fff; background: #1890ff"
  449. @click.native="handleGoodsList"
  450. >供货列表
  451. </el-button>
  452. </el-col>
  453. </el-row>
  454. </el-form-item>
  455. <el-form-item
  456. label="供应商统一社会信用代码"
  457. prop="partbUnifiedSocialCreditCode"
  458. class="form_item_label"
  459. >
  460. <el-input
  461. clearable
  462. v-model="form.partbUnifiedSocialCreditCode"
  463. placeholder="请输入"
  464. />
  465. </el-form-item>
  466. <el-form-item label="供应商联系人" prop="partbLinkName">
  467. <el-select
  468. style="width: 100%"
  469. v-model="form.partbLinkName"
  470. placeholder="请选择"
  471. @change="onchangeLink"
  472. >
  473. <el-option
  474. v-for="item in linkNameOptions"
  475. :key="item.id"
  476. :label="item.linkName"
  477. :value="item.id"
  478. >
  479. </el-option>
  480. </el-select>
  481. </el-form-item>
  482. <el-form-item prop="partbTel" label="供应商联系电话">
  483. <el-input clearable v-model="form.partbTel" placeholder="请输入" />
  484. </el-form-item>
  485. <el-form-item prop="partbFax" label="供应商传真">
  486. <el-input clearable v-model="form.partbFax" placeholder="请输入" />
  487. </el-form-item>
  488. <el-form-item label="供应商Email" prop="partbEmail">
  489. <el-input
  490. clearable
  491. v-model="form.partbEmail"
  492. placeholder="请输入"
  493. />
  494. </el-form-item>
  495. <el-form-item label="供应商地址" prop="partbAddress">
  496. <el-input
  497. clearable
  498. v-model="form.partbAddress"
  499. placeholder="请输入"
  500. />
  501. </el-form-item>
  502. </el-col>
  503. </el-row>
  504. <!-- <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle> -->
  505. <headerTitle
  506. title="物品清单"
  507. style="margin-top: 30px"
  508. >
  509. <el-button
  510. type="primary"
  511. size="mini"
  512. style="margin-bottom: 5px"
  513. @click="stockShow"
  514. >库存台账</el-button>
  515. <el-button
  516. type="primary"
  517. size="mini"
  518. style="margin-bottom: 5px"
  519. @click="orderListShow"
  520. v-if="!form.id"
  521. >历史记录</el-button
  522. ></headerTitle
  523. >
  524. <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
  525. <el-tab-pane label="物品清单" name="1">
  526. <inventoryTable
  527. ref="inventoryTable"
  528. @orderDiscountAmount="orderDiscountAmount"
  529. :pricingWay="form.pricingWay"
  530. :supplierMark="form.supplierMark"
  531. :is-show-supplier-mark="true"
  532. :isContractId="
  533. !!form.contractId && !OutValidate.includes(form.sourceType)
  534. "
  535. :isBatchNo="isBatchNo == 1"
  536. :showSaleCount="true"
  537. @getProductData="getSupplierData"
  538. >
  539. </inventoryTable>
  540. </el-tab-pane>
  541. <el-tab-pane
  542. label="带料清单"
  543. name="2"
  544. v-if="orderSourceType.includes(form.sourceType)"
  545. >
  546. <inventoryTable
  547. ref="rawDetailListRef"
  548. :detailType="1"
  549. :pricingWay="form.pricingWay"
  550. :supplierMark="form.supplierMark"
  551. :is-show-supplier-mark="true"
  552. cacheKeyUrl="eos-purchasingManage-purchaseOrder-inventoryTable1"
  553. :isContractId="
  554. !!form.contractId && !OutValidate.includes(form.sourceType)
  555. "
  556. @dataChange="rawDataChange"
  557. ></inventoryTable>
  558. </el-tab-pane>
  559. <el-tab-pane
  560. label="产出清单"
  561. name="3"
  562. v-if="orderSourceType.includes(form.sourceType)"
  563. >
  564. <inventoryTable
  565. ref="outputDetailListRef"
  566. :detailType="2"
  567. :pricingWay="form.pricingWay"
  568. :supplierMark="form.supplierMark"
  569. cacheKeyUrl="eos-purchasingManage-purchaseOrder-inventoryTable2"
  570. :is-show-supplier-mark="true"
  571. :isContractId="
  572. !!form.contractId && !OutValidate.includes(form.sourceType)
  573. "
  574. @dataChange="outputDataChange"
  575. ></inventoryTable>
  576. </el-tab-pane>
  577. </el-tabs>
  578. <el-row style="margin-top: 20px">
  579. <el-col :span="12">
  580. <el-form-item label="总金额" prop="totalAmount">
  581. {{ allcountAmount || 0 }}元
  582. </el-form-item>
  583. <el-form-item label="备注" prop="remark">
  584. <el-input
  585. clearable
  586. type="textarea"
  587. v-model="form.remark"
  588. placeholder="请输入"
  589. />
  590. </el-form-item>
  591. </el-col>
  592. <el-col :span="12">
  593. <el-form-item label="优惠后总金额" prop="payAmount">
  594. <el-input
  595. clearable
  596. v-model="form.payAmount"
  597. :disabled="
  598. (!!form.contractId && !OutValidate.includes(form.sourceType)) ||
  599. !allcountAmount
  600. "
  601. type="number"
  602. @blur="discountInput"
  603. placeholder="请输入"
  604. >
  605. <template slot="append">元</template>
  606. </el-input>
  607. </el-form-item>
  608. </el-col>
  609. </el-row>
  610. <div v-if="form.isGeneratePaymentPlan != 0">
  611. <headerTitle
  612. title="付款计划"
  613. style="margin-top: 30px"
  614. ></headerTitle>
  615. <PaymentCollectionPlan
  616. ref="paymentCollectionPlanRef"
  617. menu="purchase"
  618. :info="form"
  619. @getIssueNumber="setIssueNumber"
  620. ></PaymentCollectionPlan>
  621. </div>
  622. </el-form>
  623. <div slot="footer" class="footer">
  624. <el-button type="primary" @click="save" v-click-once>保存</el-button>
  625. <el-button type="primary" @click="save('sub')" v-click-once
  626. >提交</el-button
  627. >
  628. <el-button @click="cancel">返回</el-button>
  629. </div>
  630. <selectStockLedgerDialog ref="selectStockLedgerDialogRef" :isSupplier="true" :isView="true" :cacheKeyUrl="cacheKeyUrl+'saleOrderss'"></selectStockLedgerDialog>
  631. <parentList
  632. ref="parentRef"
  633. @changeParent="changeParent"
  634. :classType="2"
  635. ></parentList>
  636. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  637. <contractListDialog
  638. :hasGeneratedOrder="
  639. this.OutValidate.includes(this.form.sourceType) ? 3 : 0
  640. "
  641. ref="selectContractRef"
  642. @changeParent="changeContract"
  643. :type="2"
  644. :sourceType="form.sourceType"
  645. ></contractListDialog>
  646. <inquiryManageList
  647. ref="inquiryManageRef"
  648. @changeInquiryManageList="changeInquiryManageList"
  649. ></inquiryManageList>
  650. <process-submit-dialog
  651. :isNotNeedProcess="true"
  652. api-fun-name="purchaseorderStatusAPI"
  653. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  654. v-if="processSubmitDialogFlag"
  655. ref="processSubmitDialogRef"
  656. @reload="reload"
  657. ></process-submit-dialog>
  658. <purchaseNeedList
  659. ref="purchaseNeedList"
  660. @changeParent="changePurchaseNeedList"
  661. ></purchaseNeedList>
  662. <inquiryList
  663. ref="inquiryListRef"
  664. @changeParent="changeInquiryList"
  665. ></inquiryList>
  666. <supplier-goods-list-dialog
  667. @changeParent="changeValue"
  668. :supplier-goods-list-dialog-flag.sync="supplierGoodsListDialogFlag"
  669. v-if="supplierGoodsListDialogFlag"
  670. ref="supplierGoodsListDialogRef"
  671. ></supplier-goods-list-dialog>
  672. <planTableList
  673. ref="planTableListRef"
  674. @success="putTableValue"
  675. @contractSuccess="contractSuccess"
  676. ></planTableList>
  677. <projectListDialog
  678. ref="selectProjectRef"
  679. @changeParent="changeProject"
  680. ></projectListDialog>
  681. <!-- 销售退货 -->
  682. <return-order-dialog
  683. :returnOrderDialogFlag.sync="returnOrderDialogFlag"
  684. returnSourceType=""
  685. hasHandleReceipt=""
  686. types=""
  687. v-if="returnOrderDialogFlag"
  688. @changeParent="changeReturn"
  689. >
  690. </return-order-dialog>
  691. <!-- 销售处理退货 -->
  692. <returnOrderDealDialog
  693. :returnOrderDealDialogFlag.sync="returnOrderDealDialogFlag"
  694. v-if="returnOrderDealDialogFlag"
  695. @changeParent="changeReturnDeal"
  696. >
  697. </returnOrderDealDialog>
  698. <!-- 采购退货 -->
  699. <purchase-return-order-dialog
  700. :purchaseReturnOrderDialogFlag.sync="purchaseReturnOrderDialogFlag"
  701. v-if="purchaseReturnOrderDialogFlag"
  702. @changeParent="getPReturnOrderInfo"
  703. ref="returnOrderDialogRef"
  704. ></purchase-return-order-dialog>
  705. <!-- 采购订单 -->
  706. <orderListDialog
  707. ref="orderListDialogRef"
  708. :isMy="true"
  709. :contactData="{
  710. id: form.partbId
  711. }"
  712. @changeParent="changeHistoryOrder"
  713. ></orderListDialog>
  714. <!-- 付款条件 -->
  715. <receiveTermsDialog ref="receiveTermsDialogRef" conditionType="terms" @changeParent="changeReceiveTerms"></receiveTermsDialog>
  716. <ele-modal
  717. custom-class="ele-dialog-form long-dialog-form"
  718. :visible.sync="supplierListShow"
  719. title="选择供应商"
  720. :close-on-click-modal="false"
  721. width="600px"
  722. append-to-body
  723. >
  724. <el-select style="width: 100%" v-model="supplierId" placeholder="请选择">
  725. <el-option
  726. v-for="item in supplierList"
  727. :key="item.supplierId"
  728. :label="item.supplierName"
  729. :value="item.supplierId"
  730. >
  731. </el-option>
  732. </el-select>
  733. <div slot="footer" class="footer">
  734. <el-button
  735. type="primary"
  736. @click="
  737. changeParent({ id: supplierId });
  738. supplierListShow = false;
  739. "
  740. >确认</el-button
  741. >
  742. <el-button @click="supplierListShow = false">返回</el-button>
  743. </div>
  744. </ele-modal>
  745. </ele-modal>
  746. </template>
  747. <script>
  748. import { emailReg, telReg } from 'ele-admin';
  749. import inventoryTable from './inventoryTableNew.vue';
  750. import planTableList from './planTableList.vue';
  751. import fileUpload from '@/components/upload/fileUpload';
  752. import dictMixins from '@/mixins/dictMixins';
  753. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  754. import personSelect from '@/components/CommomSelect/person-select.vue';
  755. import parentList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  756. import {
  757. enterprisePage,
  758. getDetail,
  759. updateContractStatus
  760. } from '@/api/contractManage/contractBook';
  761. import supplierGoodsListDialog from '@/views/purchasingManage/purchaseOrder/components/supplierGoodsListDialog.vue';
  762. import {
  763. addInformation,
  764. getProductsBySource,
  765. getPurchaseinquiryAPI,
  766. getpurchaseorderDetail,
  767. getPurchasePlanByContractIdAPI,
  768. UpdateInformation,
  769. getSupplierInfo,
  770. getByIdForEdit
  771. } from '@/api/purchasingManage/purchaseOrder';
  772. import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
  773. import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
  774. import { getcontactlink } from '@/api/saleManage/businessFollow';
  775. import headList from '@/BIZComponents/user-select/user-select.vue';
  776. import contractListDialog from '@/views/saleManage/saleOrder/components/contractListDialog.vue';
  777. import { listOrganizations } from '@/api/system/organization';
  778. import { copyObj } from '@/utils/util';
  779. import inquiryManageList from '@/views/purchasingManage/inquiryManage/components/inquiryManage-list.vue';
  780. // import fileMain from '@/components/addDoc/index.vue';
  781. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  782. import purchaseNeedList from '@/views/purchasingManage/purchasePlanManage/components/purchaseNeed-list.vue';
  783. import inquiryList from './inquiryList.vue';
  784. import projectListDialog from '@/views/saleManage/saleOrder/components/projectListDialog.vue'
  785. import {
  786. contactDetail,
  787. updateRelationStatus
  788. } from '@/api/saleManage/contact';
  789. import {
  790. requirementSourceType,
  791. acceptUnpackoptions,
  792. orderSourceType,
  793. outsourceSceneList
  794. } from '@/enum/dict.js';
  795. import returnOrderDialog from '@/views/saleManage/saleOrder/customerReturnOrder/returnOrderDialog.vue';
  796. import {
  797. getSaleOrderDetail,
  798. } from '@/api/saleManage/saleorder';
  799. import returnOrderDealDialog from './returnOrderDealDialog.vue';
  800. import purchaseReturnOrderDialog from '@/views/transportManager/shipManage/dispatchManage/components/purchaseReturnOrderDialog.vue';
  801. import PaymentCollectionPlan from '@/BIZComponents/paymentCollectionPlan/Index.vue'
  802. import { shippingModePurchaseOp, transactionMethodsOp } from '@/enum/dict.js';
  803. import { formatDate } from '@/utils/dateUtils';
  804. import { formatPrice } from '@/BIZComponents/setProduct.js';
  805. import { parameterGetByCode } from '@/api/main/index.js';
  806. import orderListDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/orderListDialog.vue';
  807. import receiveTermsDialog from '@/views/financialManage/advanceReceipt/components/receiveTermsDialog.vue'
  808. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  809. export default {
  810. mixins: [dictMixins],
  811. props: {
  812. isRequired: {
  813. type: Boolean,
  814. default: true
  815. }
  816. },
  817. components: {
  818. inquiryList,
  819. purchaseNeedList,
  820. processSubmitDialog,
  821. // fileMain,
  822. inquiryManageList,
  823. fileUpload,
  824. headList,
  825. contractListDialog,
  826. inventoryTable,
  827. deptSelect,
  828. parentList,
  829. personSelect,
  830. supplierGoodsListDialog,
  831. planTableList,
  832. projectListDialog,
  833. returnOrderDialog,
  834. returnOrderDealDialog,
  835. purchaseReturnOrderDialog,
  836. PaymentCollectionPlan,
  837. orderListDialog,
  838. receiveTermsDialog,
  839. selectStockLedgerDialog
  840. },
  841. data() {
  842. let formDef = {
  843. id: '',
  844. contractId: '',
  845. relationType: '',
  846. relationName: '',
  847. orderFiles: [],
  848. contractName: '',
  849. deliveryDate: '',
  850. payAmount: '',
  851. projectName: '',
  852. projectId: '',
  853. receiveAddress: '',
  854. sourceType: '',
  855. sourceTypeName: '',
  856. pricingWay: 1,
  857. remark: '',
  858. saleType: '',
  859. saleTypeName: '',
  860. totalAmount: '',
  861. isGeneratePaymentPlan: 0,
  862. settlementMode: '4',
  863. settlementModeName: '分期付款',
  864. partaUnifiedSocialCreditCode: '',
  865. partbUnifiedSocialCreditCode: '',
  866. partaAddress: '',
  867. partaEmail: '',
  868. partaFax: '',
  869. partaId: '',
  870. partaLinkId: '',
  871. partaLinkName: '',
  872. partaName: '',
  873. partaTel: '',
  874. partbAddress: '',
  875. partbEmail: '',
  876. partbFax: '',
  877. partbId: '',
  878. partbLinkId: '',
  879. partbLinkName: '',
  880. partbName: '',
  881. partbTel: '',
  882. purchasePlanId: '',
  883. purchasePlanNo: '',
  884. purchasePlanName: '',
  885. isFirstProcess: 0,
  886. purchaseDeptId: '',
  887. purchaseDeptName: '',
  888. purchaseUserId: '',
  889. purchaseUserName: '',
  890. issueNumber: 1,
  891. transactionMode: 1,
  892. deliveryMode: 1,
  893. settlementDate: [],
  894. endSettlementDate: '',
  895. startSettlementDate: '',
  896. receiptDate: 1,
  897. contractStartDate:''
  898. };
  899. return {
  900. purchaseReturnOrderDialogFlag: false,
  901. returnOrderDealDialogFlag: false,
  902. returnOrderDialogFlag: false,
  903. supplierListShow: false,
  904. supplierList: [],
  905. supplierId: '',
  906. orderSourceType,
  907. outsourceSceneList,
  908. requirementSourceType,
  909. processList: [
  910. {
  911. label: '是',
  912. value: 1
  913. },
  914. {
  915. label: '否',
  916. value: 0
  917. }
  918. ],
  919. isFlag: false, //订单类型是否不可修改
  920. clearing: false, //是否清除合同
  921. payWayOptions: [],
  922. delDetailIds: [],
  923. linkNameOptions: [],
  924. acceptUnpackoptions,
  925. visible: false,
  926. fullscreen: false,
  927. processSubmitDialogFlag: false,
  928. supplierGoodsListDialogFlag: false,
  929. title: '',
  930. row: {},
  931. activeName: '1',
  932. pricingWayList: [
  933. { id: 1, name: '按数量计价' },
  934. { id: 2, name: '按重量计价' }
  935. ],
  936. formDef,
  937. form: copyObj(formDef),
  938. enterprisePage: [],
  939. tableBankData: [],
  940. tableLinkData: [],
  941. // 组织机构树形结构数据
  942. groupTreeData: [],
  943. groupData: [],
  944. OutValidate: ['3', '4'],
  945. // 切换订单类型时缓存带料清单与产出清单的数据,避免因 tab 销毁而丢失
  946. rawDetailListCache: [],
  947. outputDetailListCache: [],
  948. // 记录上一次订单类型是否在 orderSourceType 中,用于判断是否需要恢复缓存
  949. prevSourceTypeInOrder: false,
  950. // 提交状态
  951. loading: false,
  952. // 是否是修改
  953. isUpdate: false,
  954. businessId: '',
  955. winnerSuppleIds: '',
  956. shippingModePurchaseOp,
  957. transactionMethodsOp,
  958. defaultTransactionMode: 1,
  959. isBatchNo: 0,
  960. isGenReceiptPlan: 1
  961. };
  962. },
  963. computed: {
  964. allcountAmount() {
  965. return this.$store.state.order.allcountAmount;
  966. },
  967. showReturnRelation() {
  968. return ['8','9'].includes(this.form.sourceType);
  969. },
  970. filterList() {
  971. return this.isUpdate ? this.requirementSourceType : this.requirementSourceType.filter(item => item.value !== '8');
  972. },
  973. // 结算方式是否为「分期付款」
  974. isInstallment() {
  975. const mode = this.form.settlementMode;
  976. if (mode === '' || mode === null || mode === undefined) return false;
  977. return mode == 4 || this.form.settlementModeName === '分期付款';
  978. },
  979. rules() {
  980. let isRequired = true;
  981. // console.log(this.isRequired);
  982. return {
  983. deliveryDate: [
  984. { required: true, message: '请选择交货日期', trigger: 'change' }
  985. ],
  986. isGeneratePaymentPlan: [
  987. { required: true, message: '请选择是否生成付款计划表', trigger: 'change' }
  988. ],
  989. purchasePlanName: [
  990. {
  991. required: this.OutValidate.includes(this.form.sourceType),
  992. message: '请选择采购计划单',
  993. trigger: ['change', 'blur']
  994. }
  995. ],
  996. relationName: [
  997. {
  998. required: true,
  999. message: '请选择',
  1000. trigger: ['change', 'blur']
  1001. }
  1002. ],
  1003. contractName: [
  1004. {
  1005. required: true,
  1006. message: '请选择合同',
  1007. trigger: ['change', 'blur']
  1008. }
  1009. ],
  1010. // purchaseType: [
  1011. // {required: true, message: '请选择采购订单类型', trigger: 'change'}
  1012. // ],
  1013. settlementMode: [
  1014. { required: true, message: '请选择结算方式', trigger: 'change' }
  1015. ],
  1016. partaName: [
  1017. {
  1018. required: true,
  1019. message: '请选择供应商名称',
  1020. trigger: 'change'
  1021. }
  1022. ],
  1023. partaLinkName: [
  1024. {
  1025. required: isRequired,
  1026. message: '请输入采购方联系人',
  1027. trigger: ['change', 'blur']
  1028. }
  1029. ],
  1030. acceptUnpack: [
  1031. { required: true, message: '请选择是否接受', trigger: 'change' }
  1032. ],
  1033. sourceType: [
  1034. { required: true, message: '请选择订单类型', trigger: 'change' }
  1035. ],
  1036. payAmount: [{ required: true, message: '请输入', trigger: 'blur' }],
  1037. // partbAddress: [
  1038. // { required: true, message: '请输入', trigger: 'blur' }
  1039. // ],
  1040. partaTel: [
  1041. {
  1042. required: isRequired,
  1043. pattern: isRequired ? telReg : null,
  1044. message: '请输入采购方电话',
  1045. trigger: 'blur'
  1046. }
  1047. ],
  1048. partbName: [
  1049. { required: true, message: '请输入供采购方名称', trigger: 'change' }
  1050. ],
  1051. partbLinkName: [
  1052. {
  1053. required: isRequired,
  1054. message: '请输入供应商联系人',
  1055. trigger: 'change'
  1056. }
  1057. ],
  1058. partbTel: [
  1059. {
  1060. required: isRequired,
  1061. pattern: isRequired ? telReg : null,
  1062. message: '请输入供应商联系电话',
  1063. trigger: 'blur'
  1064. }
  1065. ],
  1066. paymentConditionName: [
  1067. {
  1068. // 仅当「生成付款计划表 = 是」时付款条件才必填;选否则不再校验
  1069. required: true,
  1070. message: '请选择付款条件',
  1071. trigger: 'change'
  1072. }
  1073. ],
  1074. };
  1075. }
  1076. },
  1077. created() {
  1078. console.log(this);
  1079. this.getGroupAll();
  1080. this.getEnterprisePage();
  1081. this.changePersonel();
  1082. //交易方式//1 先票后款 2 先款后票
  1083. parameterGetByCode({
  1084. code: 'eom_contract_add_transactionMode'
  1085. }).then((res) => {
  1086. this.defaultTransactionMode = +res.value;
  1087. });
  1088. //批次号是否必填//0否 1是
  1089. parameterGetByCode({
  1090. code: 'eom_purchaseOrder_batchNo'
  1091. }).then((res) => {
  1092. this.isBatchNo = res.value;
  1093. });
  1094. // 是否生成收款计划单默认配置//0否 1是
  1095. parameterGetByCode({
  1096. code: 'sale_order_gen_receipt_plan'
  1097. }).then((res) => {
  1098. this.isGenReceiptPlan = res.value;
  1099. console.log('isGenReceiptPlan', this.isGenReceiptPlan);
  1100. });
  1101. },
  1102. watch: {
  1103. // 监听订单类型变化,缓存带料清单与产出清单数据,切换回支持类型时恢复
  1104. 'form.sourceType'(newVal, oldVal) {
  1105. const wasInOrder = this.orderSourceType.includes(oldVal);
  1106. const isInOrder = this.orderSourceType.includes(newVal);
  1107. // 从支持类型切到不支持类型:缓存当前数据
  1108. if (wasInOrder && !isInOrder) {
  1109. this.cacheDetailList();
  1110. }
  1111. // 从不支持类型切回支持类型:从缓存恢复数据
  1112. if (!wasInOrder && isInOrder) {
  1113. this.restoreCachedDetailList();
  1114. }
  1115. }
  1116. },
  1117. methods: {
  1118. changeReceiveTerms(row, index) {
  1119. console.log('changeReceiveTerms~~~', row)
  1120. this.form.paymentConditionId = row.id;
  1121. this.form.paymentConditionName = row.name;
  1122. console.log('changeReceiveTerms!!!', this.form)
  1123. this.$forceUpdate()
  1124. },
  1125. handlePaymentConditionBtn() {
  1126. this.$refs.receiveTermsDialogRef.open();
  1127. },
  1128. generatePlanChange(val) {
  1129. console.log(val)
  1130. if(val == 0) {
  1131. // this.$refs.form?.clearValidate(['paymentConditionName']);
  1132. } else {
  1133. this.issueNumberChange(this.form.issueNumber);
  1134. // this.$refs.paymentCollectionPlanRef?.setDiscountAmount(
  1135. // this.form.payAmount
  1136. // );
  1137. }
  1138. },
  1139. stockShow() {
  1140. this.$refs.selectStockLedgerDialogRef.open('', -1);
  1141. },
  1142. orderListShow() {
  1143. if (!this.form.partbName) {
  1144. this.$message.warning('请先选择供应商');
  1145. return;
  1146. }
  1147. this.$refs.orderListDialogRef.open();
  1148. },
  1149. async changeHistoryOrder(item) {
  1150. console.log('item~~~~', item)
  1151. const data = await getpurchaseorderDetail(item.id);
  1152. console.log('data~~~~', data);
  1153. [
  1154. 'id',
  1155. 'orderId',
  1156. 'createTime',
  1157. 'createUserId',
  1158. 'createUserName',
  1159. 'createDept',
  1160. 'orderNo',
  1161. 'orderStatus',
  1162. 'outboundStatus',
  1163. 'payStatus',
  1164. 'preOrderNo',
  1165. 'progress',
  1166. 'processInstanceId',
  1167. 'orderBomList'
  1168. ].forEach((key) => {
  1169. delete data[key];
  1170. data.productList.forEach((item) => {
  1171. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1172. delete item[key];
  1173. }
  1174. });
  1175. data.rawList.forEach((item) => {
  1176. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1177. delete item[key];
  1178. }
  1179. });
  1180. data.outputList.forEach((item) => {
  1181. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1182. delete item[key];
  1183. }
  1184. });
  1185. data.receiptPaymentList.forEach((item) => {
  1186. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1187. delete item[key];
  1188. }
  1189. });
  1190. });
  1191. this.form = data;
  1192. if (data) {
  1193. // data.relationType = +data.relationType;
  1194. this.$nextTick(() => {
  1195. this.$store.commit('order/setAllcountAmount', data.totalAmount);
  1196. this.$refs.inventoryTable &&
  1197. this.$refs.inventoryTable.putTableValue(data.productList);
  1198. this.$refs.rawDetailListRef &&
  1199. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1200. this.$refs.outputDetailListRef &&
  1201. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1202. this.getLinkInfo(data.partaId);
  1203. this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
  1204. this.getrequireUser(data.requireDeptId);
  1205. if(data.purchaseDeptId) {
  1206. this.getPurchaseUser(data.purchaseDeptId);
  1207. }
  1208. this.$store.commit('order/setContractId', data.contractId);
  1209. });
  1210. }
  1211. },
  1212. setIssueNumber(len) {
  1213. this.form.issueNumber = len;
  1214. // 分期付款下手工增删行后,同步回填新行的计划付款日期
  1215. if (this.isInstallment) {
  1216. this.$nextTick(() => {
  1217. this.setInstallmentDeadLine();
  1218. });
  1219. }
  1220. },
  1221. getSupplierData(data) {
  1222. console.log('data~~~', data);
  1223. if(!this.form.partbName) {
  1224. getSupplierInfo(data[data.length - 1].productId).then((res) => {
  1225. console.log('res~~~', res);
  1226. this.changeParent(res.data);
  1227. })
  1228. }
  1229. },
  1230. //选择退货单
  1231. handleReturnBtn(e) {
  1232. // this.$refs.returnListRef.open();
  1233. if (e.target.nodeName == 'I') {
  1234. this.$set(this.form, 'relationCode', '');
  1235. this.$set(this.form, 'relationId', '');
  1236. return;
  1237. }
  1238. this.returnOrderDialogFlag = true;
  1239. },
  1240. //退货单
  1241. async changeReturn(row) {
  1242. // console.log('data~~~', row);
  1243. // this.form = Object.assign({}, this.form, {
  1244. // relationCode: row.returnNo,
  1245. // relationId: row.id
  1246. // });
  1247. // this.$set(this.form, 'relationName', data.requirementName);
  1248. this.$set(this.form, 'relationId', row.id);
  1249. this.$set(this.form, 'relationName', row.returnNo);
  1250. this.getReturnOrderDetail(row);
  1251. },
  1252. async getReturnOrderDetail(row) {
  1253. console.log('row', row.orderNo);
  1254. const id = row.orderIds.split(',')[0];
  1255. const res = await getSaleOrderDetail(id);
  1256. console.log('res~~~~', res);
  1257. if (row.partaId) {
  1258. await this.changeParent({ id: row.partaId }, true);
  1259. }
  1260. if (res) {
  1261. let {
  1262. // partaAddress,
  1263. // partaEmail,
  1264. // partaFax,
  1265. // partaId,
  1266. // partaLinkId,
  1267. // partaLinkName,
  1268. // partaName,
  1269. // partaTel,
  1270. partbAddress,
  1271. partbEmail,
  1272. partbFax,
  1273. partbId,
  1274. partbLinkId,
  1275. partbLinkName,
  1276. partbName,
  1277. partbTel,
  1278. totalPrice,
  1279. discountTotalPrice,
  1280. // partaUnifiedSocialCreditCode,
  1281. partbUnifiedSocialCreditCode,
  1282. settlementMode,
  1283. settlementModeName,
  1284. pricingWay,
  1285. productList,
  1286. typedetailList,
  1287. totalAmount,
  1288. payAmount
  1289. } = res;
  1290. this.form = Object.assign({}, this.form, {
  1291. partaAddress: partbAddress,
  1292. partaEmail: partbEmail,
  1293. partaFax: partbFax,
  1294. partaId: partbId,
  1295. partaLinkId: partbLinkId,
  1296. partaLinkName: partbLinkName,
  1297. partaName: partbName,
  1298. partaTel: partbTel,
  1299. // partbAddress,
  1300. // partbEmail,
  1301. // partbFax,
  1302. // partbId,
  1303. // partbLinkId,
  1304. // partbLinkName,
  1305. // partbName,
  1306. // partbTel,
  1307. totalPrice,
  1308. discountTotalPrice,
  1309. partaUnifiedSocialCreditCode: partbUnifiedSocialCreditCode,
  1310. settlementMode,
  1311. settlementModeName,
  1312. pricingWay,
  1313. productList,
  1314. typedetailList,
  1315. // totalAmount,
  1316. payAmount
  1317. });
  1318. this.$nextTick(() => {
  1319. this.$store.commit('order/setAllcountAmount', totalAmount);
  1320. this.$refs.inventoryTable &&
  1321. this.$refs.inventoryTable.putTableValue(res.productList);
  1322. this.getLinkInfo(row.partaId);
  1323. });
  1324. }
  1325. },
  1326. // 销售处理退货
  1327. handleReturnDealBtn(e) {
  1328. if (e.target.nodeName == 'I') {
  1329. this.$set(this.form, 'relationCode', '');
  1330. this.$set(this.form, 'relationId', '');
  1331. return;
  1332. }
  1333. this.returnOrderDealDialogFlag = true;
  1334. },
  1335. async changeReturnDeal(row) {
  1336. this.$set(this.form, 'relationId', row.id);
  1337. this.$set(this.form, 'relationName', row.returnNo);
  1338. this.getReturnOrderDetail(row);
  1339. },
  1340. //选择采购退货单
  1341. handlePurchaseReturnOrder() {
  1342. this.purchaseReturnOrderDialogFlag = true;
  1343. },
  1344. //采购退货单回调
  1345. getPReturnOrderInfo(row) {
  1346. console.log('params~~~~', row);
  1347. this.$set(this.form, 'relationId', row.id);
  1348. this.$set(this.form, 'relationName', row.returnNo);
  1349. this.getReturnPurchaseDetail(row);
  1350. },
  1351. async getReturnPurchaseDetail(row) {
  1352. this.businessId = row.orderId;
  1353. this.loading = true;
  1354. const data = await getpurchaseorderDetail(row.orderId);
  1355. this.loading = false;
  1356. // this.form = data;
  1357. if (data) {
  1358. let {
  1359. partaAddress,
  1360. partaEmail,
  1361. partaFax,
  1362. partaId,
  1363. partaLinkId,
  1364. partaLinkName,
  1365. partaName,
  1366. partaTel,
  1367. partbAddress,
  1368. partbEmail,
  1369. partbFax,
  1370. partbId,
  1371. partbLinkId,
  1372. partbLinkName,
  1373. partbName,
  1374. partbTel,
  1375. totalPrice,
  1376. discountTotalPrice,
  1377. partaUnifiedSocialCreditCode,
  1378. partbUnifiedSocialCreditCode,
  1379. settlementMode,
  1380. settlementModeName,
  1381. pricingWay,
  1382. productList,
  1383. typedetailList,
  1384. totalAmount,
  1385. payAmount
  1386. } = data;
  1387. this.form = Object.assign({}, this.form, {
  1388. partaAddress,
  1389. partaEmail,
  1390. partaFax,
  1391. partaId,
  1392. partaLinkId,
  1393. partaLinkName,
  1394. partaName,
  1395. partaTel,
  1396. partbAddress,
  1397. partbEmail,
  1398. partbFax,
  1399. partbId,
  1400. partbLinkId,
  1401. partbLinkName,
  1402. partbName,
  1403. partbTel,
  1404. totalPrice,
  1405. discountTotalPrice,
  1406. partaUnifiedSocialCreditCode,
  1407. partbUnifiedSocialCreditCode,
  1408. settlementMode,
  1409. settlementModeName,
  1410. pricingWay,
  1411. productList,
  1412. typedetailList,
  1413. totalAmount,
  1414. payAmount
  1415. });
  1416. this.$nextTick(() => {
  1417. this.$store.commit('order/setAllcountAmount', totalAmount);
  1418. this.$refs.inventoryTable &&
  1419. this.$refs.inventoryTable.putTableValue(data.productList);
  1420. this.$refs.rawDetailListRef &&
  1421. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1422. this.$refs.outputDetailListRef &&
  1423. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1424. this.getLinkInfo(data.partaId);
  1425. this.getrequireUser(this.form.requireDeptId);
  1426. // this.$store.commit('order/setContractId', data.contractId);
  1427. });
  1428. }
  1429. },
  1430. //选择项目弹框
  1431. handleProjectBtn() {
  1432. if (this.clearing) return;
  1433. let item = {
  1434. id: this.form.projectId
  1435. };
  1436. this.$refs.selectProjectRef.open(item);
  1437. },
  1438. //选择项目回调
  1439. async changeProject(obj) {
  1440. this.projectData = obj;
  1441. this.form = Object.assign({}, this.form, {
  1442. projectName: obj.name,
  1443. // projectId: obj.id,
  1444. // projectCode: obj.code,
  1445. });
  1446. },
  1447. // 选择负责人部门
  1448. change_principalDep(id) {
  1449. const info = this.groupData.find((e) => e.id == id);
  1450. this.form.requireDeptName = info.name;
  1451. // this.form.requireUserId = '';
  1452. // this.form.requireUserName = '';
  1453. this.$set(this.form, 'requireUserId', '');
  1454. this.$set(this.form, 'requireUserName', '');
  1455. // 根据部门获取人员
  1456. this.getrequireUser(id);
  1457. },
  1458. // 选择采购部门
  1459. changePurchaseDep(id) {
  1460. const info = this.groupData.find((e) => e.id == id);
  1461. this.form.purchaseDeptName = info.name;
  1462. this.$set(this.form, 'purchaseUserId', '');
  1463. this.$set(this.form, 'purchaseUserName', '');
  1464. this.getPurchaseUser(id);
  1465. },
  1466. getPurchaseUser(groupId) {
  1467. console.log('groupId~~~~', groupId);
  1468. if (groupId) {
  1469. this.$refs.purchaseDirectorRef.getList({ groupId });
  1470. }
  1471. },
  1472. //选择采购需求
  1473. handPurchaseNeed() {
  1474. this.$refs.purchaseNeedList.open(
  1475. this.form.relationCode,
  1476. this.form.sourceType
  1477. );
  1478. },
  1479. //选择采购需求回调
  1480. async changePurchaseNeedList(data) {
  1481. this.form.relationId = data.id;
  1482. this.form.relationCode = data.requirementCode;
  1483. this.form.relationName = data.requirementName;
  1484. this.$set(this.form, 'relationName', data.requirementName);
  1485. this.$set(this.form, 'relationId', data.id);
  1486. this.$set(this.form, 'relationCode', data.requirementCode);
  1487. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  1488. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  1489. this.$set(this.form, 'requireUserId', data.requireUserId);
  1490. this.$set(this.form, 'requireUserName', data.requireUserName);
  1491. this.getrequireUser(data.requireDeptId);
  1492. let info = await getProductsBySource({
  1493. relationId: this.form.relationId,
  1494. relationType: this.form.relationType
  1495. });
  1496. info.productList.forEach((item) => {
  1497. item['deliveryDeadline'] = item.expectReceiveDate;
  1498. });
  1499. let form = {
  1500. contractVO: {
  1501. ...this.form
  1502. },
  1503. productList: info.productList || []
  1504. };
  1505. this.$refs.inventoryTable &&
  1506. this.$refs.inventoryTable.putTableValue(form.productList);
  1507. },
  1508. //选择采购计划
  1509. handPurchasePlan() {
  1510. this.$refs.inquiryManageRef.open(
  1511. this.form.planCode,
  1512. this.form.sourceType
  1513. );
  1514. },
  1515. //选择采购计划回调
  1516. async changeInquiryManageList(data) {
  1517. this.form.purchasePlanId = data.id;
  1518. this.form.purchasePlanNo = data.planCode;
  1519. this.form.purchasePlanName = data.planName;
  1520. this.form.relationId = data.id;
  1521. this.form.relationCode = data.planCode;
  1522. this.form.relationName = data.planName;
  1523. this.form.requireDeptId = data.requireDeptId;
  1524. this.form.requireDeptName = data.requireDeptName;
  1525. this.form.requireUserId = data.requireUserId;
  1526. this.form.requireUserName = data.requireUserName;
  1527. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  1528. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  1529. this.$set(this.form, 'requireUserId', data.requireUserId);
  1530. this.$set(this.form, 'requireUserName', data.requireUserName);
  1531. this.getrequireUser(data.requireDeptId);
  1532. // let cusInfo = {}
  1533. this.$set(this.form, 'purchasePlanName', data.planName);
  1534. this.$set(this.form, 'purchasePlanId', data.id);
  1535. this.$set(this.form, 'purchasePlanNo', data.planCode);
  1536. this.$set(this.form, 'relationName', data.planName);
  1537. this.$set(this.form, 'relationId', data.id);
  1538. this.$set(this.form, 'relationCode', data.planCode);
  1539. const res = await getplanDetail(data.id);
  1540. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  1541. let info = await getProductsBySource({
  1542. relationId: this.form.relationId,
  1543. relationType: this.form.relationType
  1544. });
  1545. info['rawDetailList'] = info.rawList;
  1546. info['outputDetailList'] = info.outputList;
  1547. info.productList.forEach((item) => {
  1548. item['deliveryDeadline'] = item.expectReceiveDate;
  1549. });
  1550. let supplierList = res.detailList
  1551. .filter((item) => item.supplierId)
  1552. .map((item) => {
  1553. return {
  1554. supplierId: item.supplierId,
  1555. supplierName: item.supplierName
  1556. };
  1557. });
  1558. if (supplierList?.length > 0) {
  1559. this.supplierList = Array.from(
  1560. new Set(supplierList.map((obj) => JSON.stringify(obj)))
  1561. ).map((str) => JSON.parse(str));
  1562. this.$nextTick(() => {
  1563. this.putTableValue(info);
  1564. });
  1565. if (
  1566. this.supplierList.length == 1 &&
  1567. this.supplierList[0]?.supplierId
  1568. ) {
  1569. await this.changeParent({ id: this.supplierList[0]?.supplierId });
  1570. } else {
  1571. this.supplierListShow = true;
  1572. }
  1573. } else {
  1574. this.putTableValue(info);
  1575. }
  1576. // let form = {
  1577. // contractVO: {
  1578. // ...this.form
  1579. // },
  1580. // productList: info.productList || []
  1581. // }
  1582. // const codeList = form.productList.map((item) => item.productCode);
  1583. // let inventoryTotalList = await getInventoryTotalAPI(codeList);
  1584. // form.productList.forEach((item) => {
  1585. // let find =
  1586. // inventoryTotalList.find((key) => key.code == item.productCode) || {};
  1587. // item.availableCountBase = find.availableCountBase;
  1588. // });
  1589. // this.$refs.inventoryTable &&
  1590. // this.$refs.inventoryTable.putTableValue(form.productList);
  1591. },
  1592. //选择核价单
  1593. handInquiry(e) {
  1594. this.$refs.inquiryListRef.open(this.form.sourceType);
  1595. },
  1596. //选择采购核价回调
  1597. async changeInquiryList(data) {
  1598. console.log(data, 'data=======');
  1599. this.form.relationId = data.id;
  1600. this.form.relationCode = data.inquiryCode;
  1601. this.form.relationName = data.inquiryName;
  1602. this.winnerSuppleIds = data.winnerSuppleIds;
  1603. this.$set(this.form, 'relationName', data.inquiryName);
  1604. this.$set(this.form, 'relationId', data.id);
  1605. this.$set(this.form, 'relationCode', data.inquiryCode);
  1606. const res = await getpurchaseinquiry(data.id);
  1607. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  1608. this.$set(this.form, 'requireDeptId', res.requireDeptId);
  1609. this.$set(this.form, 'requireDeptName', res.requireDeptName);
  1610. this.$set(this.form, 'requireUserId', res.requireUserId);
  1611. this.$set(this.form, 'requireUserName', res.requireUserName);
  1612. this.getrequireUser(res.requireDeptId);
  1613. let info = await getProductsBySource({
  1614. relationId: this.form.relationId,
  1615. relationType: this.form.relationType,
  1616. supplierId: this.winnerSuppleIds
  1617. });
  1618. info['rawDetailList'] = info.rawList;
  1619. info['outputDetailList'] = info.outputList;
  1620. info.productList.forEach((item) => {
  1621. item['discountSinglePrice'] = item.singlePrice;
  1622. item['discountTotalPrice'] = item.totalPrice;
  1623. });
  1624. if (info.productList.length > 1) {
  1625. this.$refs.planTableListRef.open(info);
  1626. } else {
  1627. this.$nextTick(() => {
  1628. this.putTableValue(info);
  1629. });
  1630. }
  1631. this.form = {
  1632. ...this.form,
  1633. partbId: info.partbId,
  1634. partbName: info.partbName,
  1635. partbAddress: info.partaAddress,
  1636. partbLinkId: info.partaAddress,
  1637. partbLinkName: info.partbLinkName,
  1638. partbEmail: info.partbEmail,
  1639. partbTel: info.partbTel
  1640. };
  1641. await this.getLinkInfo(info.partbId);
  1642. this.$nextTick(() => {
  1643. let firstLink =
  1644. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1645. this.form = Object.assign({}, this.form, {
  1646. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  1647. partbLinkName:
  1648. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  1649. partbTel:
  1650. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1651. });
  1652. this.setProductInfo();
  1653. });
  1654. await this.changeParent({ id: info.partbId });
  1655. },
  1656. async putTableValue({ productList, rawDetailList, outputDetailList }) {
  1657. let totalPrice = 0;
  1658. productList.forEach((item) => {
  1659. totalPrice += item.totalPrice ? (+item.totalPrice) : 0;
  1660. });
  1661. this.$store.commit('order/setAllcountAmount', totalPrice);
  1662. this.$set(this.form, 'totalPrice', totalPrice);
  1663. if (this.form.relationType == 3) {
  1664. this.$set(this.form, 'payAmount', totalPrice);
  1665. this.discountInput();
  1666. }
  1667. this.$refs.inventoryTable &&
  1668. this.$refs.inventoryTable.putTableValue(productList);
  1669. this.$refs.rawDetailListRef &&
  1670. this.$refs.rawDetailListRef.putTableValue(rawDetailList); //原料
  1671. this.$refs.outputDetailListRef &&
  1672. this.$refs.outputDetailListRef.putTableValue(outputDetailList);
  1673. },
  1674. getrequireUser(groupId) {
  1675. if (groupId) {
  1676. this.$refs.directorRef.getList({ groupId });
  1677. }
  1678. },
  1679. salesmanChange(val, info) {
  1680. this.$set(this.form, 'requireUserId', val);
  1681. this.$set(this.form, 'requireUserName', info.name);
  1682. // this.form.requireUserName = info.name;
  1683. },
  1684. purchaseUserChange(val, info) {
  1685. this.$set(this.form, 'purchaseUserId', val);
  1686. this.$set(this.form, 'purchaseUserName', info.name);
  1687. },
  1688. // 获取公司数据
  1689. getGroupAll() {
  1690. listOrganizations().then((list) => {
  1691. this.groupData = list;
  1692. this.groupTreeData = this.$util.toTreeData({
  1693. data: list,
  1694. idField: 'id',
  1695. parentIdField: 'parentId'
  1696. });
  1697. });
  1698. },
  1699. discountInput() {
  1700. this.$refs.inventoryTable.discountInputByOrder(this.form.payAmount);
  1701. this.$refs.paymentCollectionPlanRef?.setDiscountAmount(this.form.payAmount);
  1702. },
  1703. //产品清单修改单价或者数量重置优惠金额
  1704. orderDiscountAmount(val = 0) {
  1705. console.log('orderDiscountAmount~~~~', val);
  1706. this.form.payAmount = val;
  1707. this.$refs.paymentCollectionPlanRef.setDiscountAmount(val);
  1708. //this.form.payAmount = undefined
  1709. },
  1710. //选择合同获取合同的详情
  1711. async getDetailData(id) {
  1712. this.loading = true;
  1713. const data = await getDetail(id);
  1714. let info = await getProductsBySource({
  1715. relationId: this.form.relationId,
  1716. relationType: this.form.relationType
  1717. });
  1718. this.loading = false;
  1719. if (data) {
  1720. // if (data.contractVO.sourceType == 3 && data.contractVO.sourceId) {
  1721. // //获取需求部门
  1722. // const res = await getplanDetail(data.contractVO.sourceId);
  1723. // this.$nextTick(() => {
  1724. // this.form.requireDeptId = res.requireDeptId;
  1725. // this.form.requireDeptName = res.requireDeptName;
  1726. // this.form.requireUserId = res.requireUserId;
  1727. // this.form.requireUserName = res.requireUserName;
  1728. // });
  1729. // }
  1730. this.$set(this.form, 'requireDeptId', data.contractVO?.requireDeptId);
  1731. this.$set(
  1732. this.form,
  1733. 'requireDeptName',
  1734. data.contractVO?.requireDeptName
  1735. );
  1736. this.$set(this.form, 'requireUserId', data.contractVO?.requireUserId);
  1737. // this.$set(this.form, 'businessDeptId', data.contractVO?.businessDeptId);
  1738. // this.$set(this.form, 'businessDeptName', data.contractVO?.businessDeptName);
  1739. // this.$set(this.form, 'businessUserId', data.contractVO?.businessUserId);
  1740. // this.$set(this.form, 'businessUserName', data.contractVO?.businessUserName);
  1741. this.$set(
  1742. this.form,
  1743. 'requireUserName',
  1744. data.contractVO?.requireUserName
  1745. );
  1746. console.log('data.contractVO~~~~', data.contractVO);
  1747. this.getrequireUser(data.contractVO?.requireDeptId);
  1748. this.getPurchaseUser(data.contractVO?.businessDeptId);
  1749. this.$nextTick(() => {
  1750. let { contractVO } = data;
  1751. // this.form=contractVOform.receiveAddress
  1752. let {
  1753. partaAddress,
  1754. partaEmail,
  1755. partaFax,
  1756. partaId,
  1757. partaLinkId,
  1758. partaLinkName,
  1759. partaName,
  1760. partaTel,
  1761. partbAddress,
  1762. partbEmail,
  1763. partbFax,
  1764. partbId,
  1765. partbLinkId,
  1766. partbLinkName,
  1767. partbName,
  1768. partbTel,
  1769. totalPrice,
  1770. discountTotalPrice,
  1771. partaUnifiedSocialCreditCode,
  1772. partbUnifiedSocialCreditCode,
  1773. settlementMode,
  1774. settlementModeName,
  1775. pricingWay,
  1776. isFirstProcess,
  1777. requireSourceType,
  1778. requireSourceTypeName,
  1779. businessDeptId,
  1780. businessDeptName,
  1781. businessUserId,
  1782. businessUserName,
  1783. transactionMode,
  1784. startSettlementDate,
  1785. receiptDate,
  1786. issueNumber,
  1787. endSettlementDate,
  1788. deliveryMode,
  1789. } = contractVO;
  1790. this.form = Object.assign({}, this.form, {
  1791. partaAddress,
  1792. partaEmail,
  1793. partaFax,
  1794. partaId,
  1795. partaLinkId,
  1796. partaLinkName,
  1797. partaName,
  1798. partaTel,
  1799. partbAddress,
  1800. partbEmail,
  1801. partbFax,
  1802. partbId,
  1803. partbLinkId,
  1804. partbLinkName,
  1805. partbName,
  1806. partbTel,
  1807. totalPrice,
  1808. settlementMode,
  1809. settlementModeName,
  1810. discountTotalPrice,
  1811. partaUnifiedSocialCreditCode,
  1812. partbUnifiedSocialCreditCode,
  1813. pricingWay,
  1814. totalAmount: totalPrice,
  1815. payAmount: discountTotalPrice,
  1816. receiveAddress: partaAddress,
  1817. isFirstProcess,
  1818. sourceType: requireSourceType || '1',
  1819. sourceTypeName: requireSourceTypeName,
  1820. purchaseDeptId: businessDeptId,
  1821. purchaseDeptName: businessDeptName,
  1822. purchaseUserId: businessUserId,
  1823. purchaseUserName: businessUserName,
  1824. transactionMode,
  1825. startSettlementDate,
  1826. receiptDate,
  1827. issueNumber,
  1828. endSettlementDate,
  1829. deliveryMode,
  1830. settlementDate: startSettlementDate ? [startSettlementDate, endSettlementDate] : [],
  1831. });
  1832. this.getLinkInfo(partaId);
  1833. // info.productList = info.productList.map((item) => {
  1834. // item['purchaseCount'] = item.contractCount;
  1835. // item['purchaseUnit'] = item.contractUnit;
  1836. // item['purchaseUnitId'] = item.contractUnitId;
  1837. // return item;
  1838. // });
  1839. if (info.productList.length > 1) {
  1840. console.log('info.productList~~~~', info.productList);
  1841. this.$refs.planTableListRef.contractOpen(
  1842. info.productList,
  1843. contractVO.contractStartDate
  1844. );
  1845. } else {
  1846. this.contractSuccess({
  1847. productList: info.productList,
  1848. contractStartDate: contractVO.contractStartDate
  1849. });
  1850. }
  1851. const receiptData = {
  1852. receiptPaymentList: data.receiptPaymentList,
  1853. payAmount: discountTotalPrice
  1854. }
  1855. this.$refs.paymentCollectionPlanRef &&
  1856. this.$refs.paymentCollectionPlanRef.putTableValue(receiptData);
  1857. this.$refs.rawDetailListRef &&
  1858. this.$refs.rawDetailListRef.putTableValue(contractVO.rawList); //原料
  1859. this.$refs.outputDetailListRef &&
  1860. this.$refs.outputDetailListRef.putTableValue(
  1861. contractVO.outputList
  1862. );
  1863. this.$store.commit('order/setAllcountAmount', totalPrice);
  1864. });
  1865. }
  1866. },
  1867. contractSuccess({ productList, contractStartDate }) {
  1868. console.log('productList~~~contractSuccess', productList);
  1869. this.$nextTick(() => {
  1870. this.$refs.inventoryTable &&
  1871. this.$refs.inventoryTable.putTableValue(
  1872. productList,
  1873. contractStartDate
  1874. );
  1875. });
  1876. },
  1877. //获取订单详情
  1878. async getpurchaseorderDetail(id, isEdit = false) {
  1879. this.businessId = id;
  1880. this.loading = true;
  1881. const data = isEdit
  1882. ? await getByIdForEdit(id)
  1883. : await getpurchaseorderDetail(id);
  1884. this.loading = false;
  1885. data.settlementDate = data.startSettlementDate ? [data.startSettlementDate, data.endSettlementDate] : [];
  1886. this.form = data;
  1887. console.log('data~~~~~~~000', data);
  1888. if (data) {
  1889. this.$nextTick(() => {
  1890. this.$store.commit('order/setAllcountAmount', data.totalAmount);
  1891. this.$refs.inventoryTable &&
  1892. this.$refs.inventoryTable.putTableValue(data.productList);
  1893. this.$refs.rawDetailListRef &&
  1894. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1895. this.$refs.outputDetailListRef &&
  1896. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1897. this.getLinkInfo(data.partaId);
  1898. this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
  1899. this.getrequireUser(this.form.requireDeptId);
  1900. if(data.purchaseDeptId) {
  1901. this.getPurchaseUser(data.purchaseDeptId);
  1902. }
  1903. this.$store.commit('order/setContractId', data.contractId);
  1904. });
  1905. }
  1906. },
  1907. //更新联系人数据
  1908. async getLinkInfo(contactId) {
  1909. const data = await getcontactlink({ contactId });
  1910. if (data && data?.length) {
  1911. this.linkNameOptions = data;
  1912. }
  1913. },
  1914. sourceTypeChange() {
  1915. // 当sourceType改变时,只重置relationType,保留各清单数据
  1916. this.form.relationType = '';
  1917. },
  1918. // 实时同步带料清单数据到缓存
  1919. rawDataChange(val) {
  1920. this.rawDetailListCache = val || [];
  1921. },
  1922. // 实时同步产出清单数据到缓存
  1923. outputDataChange(val) {
  1924. this.outputDetailListCache = val || [];
  1925. },
  1926. /**
  1927. * 切换订单类型时缓存带料清单与产出清单的数据
  1928. * 由于 tab 上的 v-if 会销毁子组件,所以提前把数据保存到父组件
  1929. */
  1930. cacheDetailList() {
  1931. if (this.$refs.rawDetailListRef) {
  1932. this.rawDetailListCache =
  1933. this.$refs.rawDetailListRef.getTableValue() || [];
  1934. }
  1935. if (this.$refs.outputDetailListRef) {
  1936. this.outputDetailListCache =
  1937. this.$refs.outputDetailListRef.getTableValue() || [];
  1938. }
  1939. },
  1940. /**
  1941. * 当订单类型切回到支持带料/产出清单的类型时,从缓存恢复数据
  1942. */
  1943. restoreCachedDetailList() {
  1944. this.$nextTick(() => {
  1945. if (this.$refs.rawDetailListRef) {
  1946. this.$refs.rawDetailListRef.putTableValue(
  1947. this.rawDetailListCache || []
  1948. );
  1949. }
  1950. if (this.$refs.outputDetailListRef) {
  1951. this.$refs.outputDetailListRef.putTableValue(
  1952. this.outputDetailListCache || []
  1953. );
  1954. }
  1955. });
  1956. },
  1957. handleChangeRelationType(val) {
  1958. // if(this.showReturnRelation) {
  1959. // this.form.relationType = val;
  1960. // }
  1961. this.valueChange();
  1962. },
  1963. valueChange() {
  1964. this.form.purchasePlanId = '';
  1965. this.form.purchasePlanNo = '';
  1966. this.form.purchasePlanName = '';
  1967. this.form.relationId = '';
  1968. this.form.relationCode = '';
  1969. this.form.relationName = '';
  1970. this.$nextTick(() => {
  1971. this.$refs.inventoryTable &&
  1972. this.$refs.inventoryTable.putTableValue([]);
  1973. });
  1974. },
  1975. //选择下拉框
  1976. onchangeLink(selectedOptions) {
  1977. const option = this.linkNameOptions.find(
  1978. (opt) => opt.id === selectedOptions
  1979. );
  1980. this.form = Object.assign({}, this.form, {
  1981. partbEmail: option?.email,
  1982. partbLinkName: option?.linkName || '',
  1983. partbTel: option?.mobilePhone || option?.phone || '',
  1984. partbLinkId: option?.id
  1985. });
  1986. },
  1987. handHead() {
  1988. let item = {
  1989. id: this.form.partaLinkId
  1990. };
  1991. this.$refs.headRef.open(item);
  1992. },
  1993. //选择供采购方人回调
  1994. changePersonel(obj) {
  1995. if (!obj) {
  1996. obj = this.$store.getters.user.info;
  1997. obj.id = obj.userId;
  1998. }
  1999. this.$set(this.form, 'partaLinkId', obj.id);
  2000. this.$set(this.form, 'partaLinkName', obj.name);
  2001. this.$set(this.form, 'partaTel', obj.phone);
  2002. this.$set(this.form, 'partaEmail', obj.email);
  2003. },
  2004. //选择供应商回调
  2005. async changeParent(obj) {
  2006. if (!obj.id) {
  2007. return;
  2008. }
  2009. const { base, other } = await contactDetail(obj.id);
  2010. this.form = Object.assign({}, this.form, {
  2011. partbId: base.id,
  2012. partbName: base.name,
  2013. partbAddress: other.addressName
  2014. ? other.addressName + other.address
  2015. : base.addressName + other.address,
  2016. partbLinkId: '',
  2017. partbLinkName: '',
  2018. partbEmail: '',
  2019. partbTel: '',
  2020. supplierMark: base.serialNo,
  2021. partbUnifiedSocialCreditCode: base.unifiedSocialCreditCode
  2022. });
  2023. await this.getLinkInfo(obj.id);
  2024. // this.form.productList=productList
  2025. this.$nextTick(() => {
  2026. let firstLink =
  2027. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  2028. this.form = Object.assign({}, this.form, {
  2029. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  2030. partbLinkName:
  2031. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  2032. partbTel:
  2033. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  2034. });
  2035. this.setProductInfo();
  2036. });
  2037. },
  2038. setProductInfo() {
  2039. this.$refs.inventoryTable.setCustomerMark(this.form.supplierMark);
  2040. },
  2041. //选择合同回调
  2042. async changeContract(obj) {
  2043. this.form = Object.assign({}, this.form, {
  2044. contractId: obj.id,
  2045. contractName: obj.contractName,
  2046. contractNo: obj.contractNo,
  2047. relationId: obj.id,
  2048. relationName: obj.contractName,
  2049. relationCode: obj.contractNo,
  2050. contractStartDate: obj.contractStartDate,
  2051. });
  2052. await this.getPlanInfo(this.form.contractId);
  2053. await this.getDetailData(obj.id);
  2054. // //采购询价表
  2055. // if(obj.sourceType==2){
  2056. // obj.sourceId && this.getPurchaseinquiry(obj.sourceId);
  2057. // }
  2058. // //采购计划
  2059. // if(obj.sourceType==3){
  2060. // obj.sourceId && this.getPlanInfo(this.form.contractId);
  2061. // }
  2062. this.$store.commit('order/setContractId', obj.id);
  2063. //获取合同采购计划
  2064. },
  2065. async getPlanInfo(id) {
  2066. let res = await getPurchasePlanByContractIdAPI(id);
  2067. if (!res.data?.id) return;
  2068. this.form = Object.assign({}, this.form, {
  2069. purchasePlanId: res.data?.id,
  2070. purchasePlanName: res.data?.planName,
  2071. purchasePlanNo: res.data?.planCode,
  2072. sourceType: res.data?.sourceType,
  2073. sourceTypeName: res.data?.sourceTypeName
  2074. });
  2075. },
  2076. //选择合同弹框
  2077. handleContractBtn() {
  2078. if (this.clearing) return;
  2079. let item = {
  2080. id: this.form.contractId
  2081. };
  2082. this.$refs.selectContractRef.open(item, this.form.sourceType);
  2083. },
  2084. //清除合同
  2085. clearContrcat() {
  2086. this.clearing = true;
  2087. this.isFlag = false;
  2088. let {
  2089. sourceType,
  2090. sourceTypeName,
  2091. requireDeptId,
  2092. requireDeptName,
  2093. requireUserId,
  2094. requireUserName,
  2095. settlementMode,
  2096. settlementModeName,
  2097. id,
  2098. projectName,
  2099. saleType,
  2100. saleTypeName,
  2101. deliveryDate,
  2102. orderFiles,
  2103. remark
  2104. } = this.form;
  2105. this.form = Object.assign({}, copyObj(this.formDef), {
  2106. id,
  2107. projectName,
  2108. saleType,
  2109. saleTypeName,
  2110. deliveryDate,
  2111. orderFiles,
  2112. remark,
  2113. sourceType,
  2114. sourceTypeName,
  2115. requireDeptId,
  2116. requireDeptName,
  2117. requireUserId,
  2118. requireUserName,
  2119. settlementMode,
  2120. settlementModeName
  2121. });
  2122. this.$store.commit('order/setContractId', '');
  2123. this.$store.commit('order/setAllcountAmount', 0);
  2124. this.$refs.inventoryTable.putTableValue([]);
  2125. this.$refs.rawDetailListRef &&
  2126. this.$refs.rawDetailListRef.putTableValue([]);
  2127. this.$refs.outputDetailListRef &&
  2128. this.$refs.outputDetailListRef.putTableValue([]);
  2129. setTimeout(() => {
  2130. this.clearing = false;
  2131. }, 500);
  2132. },
  2133. handParent() {
  2134. if (this.form.contractId) {
  2135. return this.$message.error('选择了合同不能更改供应商名称');
  2136. }
  2137. let item = {
  2138. id: this.form.contactId
  2139. };
  2140. this.$refs.parentRef.open(item);
  2141. },
  2142. //通过合同获取订单类型
  2143. async getPurchaseinquiry(sourceId) {
  2144. let data = await getPurchaseinquiryAPI(sourceId);
  2145. this.isFlag = !!data.sourceType;
  2146. this.form = Object.assign({}, this.form, {
  2147. sourceType: data.sourceType,
  2148. sourceTypeName: data.sourceTypeName
  2149. });
  2150. },
  2151. //打开新增编辑弹框
  2152. async open(type, row, contactCategoryId) {
  2153. this.title = type === 'add' ? '新增' : '修改';
  2154. this.activeName = '1';
  2155. this.row = row;
  2156. // 打开弹框前先清空缓存,避免残留上次数据
  2157. this.rawDetailListCache = [];
  2158. this.outputDetailListCache = [];
  2159. this.visible = true;
  2160. if (this.enterprisePage.length == 0) {
  2161. await this.getEnterprisePage();
  2162. }
  2163. if (type == 'add') {
  2164. // console.log('enterprisePage~~~~~', this.enterprisePage);
  2165. this.form.transactionMode = this.defaultTransactionMode;
  2166. this.isUpdate = false;
  2167. if (this.enterprisePage.length > 0) {
  2168. this.form.partaName = this.enterprisePage[0]?.name;
  2169. this.form.partaUnifiedSocialCreditCode =
  2170. this.enterprisePage[0]?.unifiedSocialCreditCode;
  2171. this.form.partaFax = this.enterprisePage[0]?.fax;
  2172. this.form.partaAddress = this.enterprisePage[0]?.address;
  2173. this.form.purchaseDeptId = this.enterprisePage[0]?.groupId || '';
  2174. this.form.purchaseDeptName = this.enterprisePage[0]?.name || '';
  2175. this.form.purchaseUserId = this.$store.state.user.info?.id || '';
  2176. this.form.purchaseUserName = this.$store.state.user.info?.name || '';
  2177. this.$nextTick(() => {
  2178. this.issueNumberChange(this.form.issueNumber);
  2179. if(this.form.purchaseDeptId) {
  2180. this.getPurchaseUser(this.form.purchaseDeptId);
  2181. }
  2182. })
  2183. }
  2184. this.form.contractStartDate = formatDate(new Date(), 'yyyy-MM-dd');
  2185. this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
  2186. } else {
  2187. this.isUpdate = true;
  2188. await this.getpurchaseorderDetail(row.id, true);
  2189. }
  2190. },
  2191. getEnterprisePage() {
  2192. enterprisePage({
  2193. pageNum: 1,
  2194. size: 100
  2195. }).then((res) => {
  2196. this.enterprisePage = [];
  2197. this.enterprisePage.push(...res.list);
  2198. });
  2199. },
  2200. getEnterprise() {
  2201. let data = this.enterprisePage.find(
  2202. (item) => item.name == this.form.quoteName
  2203. );
  2204. this.form.partaName = data.name;
  2205. this.form.partaUnifiedSocialCreditCode = data.unifiedSocialCreditCode;
  2206. this.form.partaFax = data.fax;
  2207. this.form.partaAddress = data.address;
  2208. },
  2209. //从合同页面新增订单
  2210. contractOpen(row) {
  2211. this.title = '新增';
  2212. this.visible = true;
  2213. this.isUpdate = false;
  2214. this.form.relationType = 4;
  2215. this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
  2216. this.changeContract(row);
  2217. },
  2218. handleGoodsList() {
  2219. console.log(11111);
  2220. this.supplierGoodsListDialogFlag = true;
  2221. this.$nextTick(() => {
  2222. this.$refs.supplierGoodsListDialogRef.open(this.form.partbId);
  2223. });
  2224. },
  2225. changeValue(val = []) {
  2226. this.$refs.inventoryTable &&
  2227. this.$refs.inventoryTable.getGoodsListData(val);
  2228. },
  2229. // 交易方式改变
  2230. transactionModeChange(v) {
  2231. },
  2232. // 配送方式改变
  2233. deliveryModeChange(v) {
  2234. },
  2235. // 结算方式改变
  2236. settlementModeChange(v) {
  2237. console.log('v~~~', v.dictCode);
  2238. this.form.settlementModeName = v.dictValue;
  2239. // this.$set(this.form, 'issueNumber', 1);
  2240. this.$set(this.form, 'settlementDate', []);
  2241. this.$set(this.form, 'receiptDate', 1);
  2242. if (v.dictCode == 3) {
  2243. this.$set(this.form, 'issueNumber', 2);
  2244. } else {
  2245. this.$set(this.form, 'issueNumber', 1);
  2246. }
  2247. this.$refs.paymentCollectionPlanRef.defaultList(v.dictCode, this.form.issueNumber);
  2248. },
  2249. // settlementModeChange(info) {
  2250. // this.form.settlementModeName = info.dictValue;
  2251. // },
  2252. ifChiefChange(value, idx) {
  2253. if (value === 1) {
  2254. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  2255. this.tableLinkData[idx].ifChief = 1;
  2256. }
  2257. },
  2258. getValidate() {
  2259. if (!this.form.paymentConditionName) {
  2260. this.$message.error('付款条件不能为空');
  2261. }
  2262. const arr = [
  2263. new Promise((resolve, reject) => {
  2264. this.$refs.form.validate((valid) => {
  2265. if (!valid) {
  2266. reject(false);
  2267. } else {
  2268. resolve(true);
  2269. }
  2270. });
  2271. }),
  2272. new Promise((resolve, reject) => {
  2273. this.$refs.inventoryTable.validateForm((valid) => {
  2274. if (!valid) {
  2275. reject(false);
  2276. } else {
  2277. resolve(true);
  2278. }
  2279. });
  2280. }),
  2281. ]
  2282. if(this.form.isGeneratePaymentPlan != 0) {
  2283. arr.push(new Promise((resolve, reject) => {
  2284. this.$refs.paymentCollectionPlanRef.validateForm((valid) => {
  2285. if (!valid) {
  2286. reject(false);
  2287. } else {
  2288. resolve(true);
  2289. }
  2290. });
  2291. }))
  2292. }
  2293. return Promise.all(arr);
  2294. },
  2295. async save(type) {
  2296. let is = false;
  2297. try {
  2298. await this.getValidate();
  2299. // 表单验证通过,执行保存操作
  2300. this.loading = true;
  2301. let isTemporary = [];
  2302. if (!this.isUpdate) {
  2303. delete this.form.id;
  2304. }
  2305. // if (!this.form.contractId) { //如果来源是合同 金额不变这个逻辑有问题 先注释
  2306. this.form.totalAmount = this.allcountAmount;
  2307. // }
  2308. const rawDetailList =
  2309. (this.$refs.rawDetailListRef &&
  2310. this.$refs.rawDetailListRef.getTableValue()) ||
  2311. [];
  2312. const outputDetailList =
  2313. (this.$refs.outputDetailListRef &&
  2314. this.$refs.outputDetailListRef.getTableValue()) ||
  2315. [];
  2316. const tabList =
  2317. (this.$refs.inventoryTable &&
  2318. this.$refs.inventoryTable.getTableValue()) ||
  2319. [];
  2320. tabList.forEach((v, i) => {
  2321. if (!v.productCode) {
  2322. isTemporary.push(v.productName);
  2323. }
  2324. tabList.forEach((v2, j) => {
  2325. if (
  2326. v.productCode == v2.productCode &&
  2327. v.taskId == v2.taskId &&
  2328. v.batchNo == v2.batchNo &&
  2329. v.colorKey == v2.colorKey &&
  2330. v.provenance?.join() == v2.provenance?.join() &&
  2331. v.modelKey == v2.modelKey &&
  2332. v.goodsLevel == v2.goodsLevel &&
  2333. i != j
  2334. ) {
  2335. is = true;
  2336. }
  2337. });
  2338. });
  2339. if (isTemporary.length > 0) {
  2340. this.$message.error(
  2341. isTemporary.toString() +
  2342. '是临时产品,无法创建订单,请先去主数据维护!'
  2343. );
  2344. return;
  2345. }
  2346. // if (is) {
  2347. // this.$message.error('同产品,工序、批次号、颜色不能完全一致!');
  2348. // return;
  2349. // }
  2350. let productList = [
  2351. ...tabList,
  2352. ...rawDetailList.map((item) => {
  2353. item.singlePrice = item.singlePrice || 0;
  2354. item.discountSinglePrice = item.discountSinglePrice || 0;
  2355. item.totalPrice = item.totalPrice || 0;
  2356. item.discountTotalPrice = item.discountTotalPrice || 0;
  2357. return item;
  2358. }),
  2359. ...outputDetailList.map((item) => {
  2360. item.singlePrice = item.singlePrice || 0;
  2361. item.discountSinglePrice = item.discountSinglePrice || 0;
  2362. item.discountTotalPrice = item.discountTotalPrice || 0;
  2363. item.totalPrice = item.totalPrice || 0;
  2364. return item;
  2365. })
  2366. ];
  2367. console.log('提交数据~~~', this.form);
  2368. let commitData = Object.assign({}, this.form, {
  2369. productList,
  2370. // purchaseTypeName: this.getDictValue(
  2371. // '采购订单类型',
  2372. // this.form.purchaseType
  2373. // ),
  2374. sourceTypeName: this.requirementSourceType.find(
  2375. (val) => val.value == this.form.sourceType
  2376. )?.label,
  2377. receiptPaymentList: this.form.isGeneratePaymentPlan == 0 ? [] :
  2378. this.$refs?.paymentCollectionPlanRef?.getTableValue() || [],
  2379. endSettlementDate: this.form.settlementDate?.length ? this.form.settlementDate[1] : '',
  2380. startSettlementDate: this.form.settlementDate?.length ? this.form.settlementDate[0] : ''
  2381. });
  2382. if(this.form.isGeneratePaymentPlan != 0) {
  2383. const ratioSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + +cur.ratio, 0);
  2384. // if(+ratioSum != 100){
  2385. // this.$message.error('比例合计必须为100%');
  2386. // return;
  2387. // }
  2388. if(+ratioSum > 100){
  2389. this.$message.error('比例合计不能超过100%');
  2390. return;
  2391. }
  2392. }
  2393. // 使用万分之一进行计算,避免浮点数精度问题(对应4位小数)
  2394. // let receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
  2395. // const payAmount = +commitData.payAmount;
  2396. // if(+ratioSum == 100) {
  2397. // // 使用万分之一进行计算,避免浮点数精度问题
  2398. // const difference = Math.round((payAmount - receiptPaymentListSum) * 10000) / 10000;
  2399. // if (Math.abs(difference) >= 0.0001 && commitData.receiptPaymentList.length > 0) {
  2400. // const lastIndex = commitData.receiptPaymentList.length - 1;
  2401. // // 使用万分之一进行计算,避免浮点数精度问题
  2402. // const newPrice = Math.round((+commitData.receiptPaymentList[lastIndex].price + difference) * 10000) / 10000;
  2403. // commitData.receiptPaymentList[lastIndex].price = formatPrice(newPrice);
  2404. // receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
  2405. // }
  2406. // }
  2407. // if(Math.abs(+receiptPaymentListSum - payAmount) > 0.0001){
  2408. // this.$message.error('计划收款金额合计与优惠后金额不一致');
  2409. // return;
  2410. // }
  2411. // console.log('提交数据', commitData);
  2412. if (this.isUpdate) {
  2413. try {
  2414. const res = await UpdateInformation(commitData);
  2415. this.loading = false;
  2416. this.$message.success('修改成功');
  2417. updateRelationStatus([this.form.partbId]);
  2418. if (this.form.contractId) {
  2419. updateContractStatus([this.form.contractId]);
  2420. }
  2421. if (type === 'sub') {
  2422. this.sub(res);
  2423. return;
  2424. }
  2425. this.cancel();
  2426. this.$emit('done');
  2427. } catch (e) {
  2428. this.loading = false;
  2429. }
  2430. } else {
  2431. addInformation(commitData)
  2432. .then((res) => {
  2433. this.loading = false;
  2434. this.$message.success('新增成功');
  2435. updateRelationStatus([this.form.partbId]);
  2436. if (type === 'sub') {
  2437. this.sub(res);
  2438. return;
  2439. }
  2440. this.cancel();
  2441. this.$emit('done');
  2442. })
  2443. .catch((e) => {
  2444. //this.loading = false;
  2445. });
  2446. }
  2447. } catch (error) {
  2448. console.log(error);
  2449. // 表单验证未通过,不执行保存操作
  2450. }
  2451. },
  2452. async sub(res) {
  2453. const data = await getpurchaseorderDetail(this.businessId || res);
  2454. this.processSubmitDialogFlag = true;
  2455. this.$nextTick(() => {
  2456. let params = {
  2457. businessId: data.id,
  2458. businessKey: 'purchase_order_approve',
  2459. formCreateUserId: data.createUserId,
  2460. variables: {
  2461. businessCode: data.orderNo,
  2462. businessName: data.partaName,
  2463. businessType: data.sourceTypeName
  2464. }
  2465. // callBackMethodType : '1',
  2466. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  2467. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  2468. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  2469. // miniHandle : '',
  2470. // miniView : '',
  2471. };
  2472. this.$refs.processSubmitDialogRef.init(params);
  2473. });
  2474. // submit({
  2475. // businessId: this.businessId || res
  2476. // }).then((res) => {
  2477. // this.cancel();
  2478. // this.$emit('done');
  2479. // });
  2480. },
  2481. reload() {
  2482. this.cancel();
  2483. this.$emit('done');
  2484. },
  2485. cancel() {
  2486. // 先清空带料清单与产出清单的缓存,避免 nextTick 异步导致关闭事件再次触发时缓存残留
  2487. this.rawDetailListCache = [];
  2488. this.outputDetailListCache = [];
  2489. this.$nextTick(() => {
  2490. this.isFlag = false;
  2491. // 关闭后,销毁所有的表单数据
  2492. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  2493. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  2494. this.$store.commit('order/clearUserData');
  2495. this.form = copyObj(this.formDef);
  2496. this.visible = false;
  2497. });
  2498. },
  2499. //查找合同分类对应name
  2500. findNameById(tree, targetId) {
  2501. for (let i = 0; i < tree.length; i++) {
  2502. const node = tree[i];
  2503. if (node.id === targetId) {
  2504. return node.name;
  2505. }
  2506. if (node.children && node.children.length > 0) {
  2507. const name = this.findNameById(node.children, targetId);
  2508. if (name) {
  2509. return name;
  2510. }
  2511. }
  2512. }
  2513. return null;
  2514. },
  2515. // 日期范围变化
  2516. settlementDateChange(val) {
  2517. // console.log(val);
  2518. // 分期付款:期数由用户自行填写,这里只把计划付款日期回填到已有的付款计划行
  2519. if (this.isInstallment) {
  2520. this.setInstallmentDeadLine();
  2521. return;
  2522. }
  2523. let dateRange = [];
  2524. if(this.form.settlementMode == 1) {
  2525. // // this.transformDays(val)
  2526. dateRange = this.transformDaysFun(val);
  2527. }
  2528. if(this.form.settlementMode == 2) {
  2529. // // this.transformMonth(val)
  2530. dateRange = this.transformMonthFun(val, this.form.receiptDate);
  2531. }
  2532. console.log('dateRange~~~', dateRange);
  2533. this.$set(this.form, 'issueNumber', dateRange.length);
  2534. // this.setDefaultList(dateRange)
  2535. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
  2536. },
  2537. // 收款日变化
  2538. receiptDateChange(v) {
  2539. // this.transformMonth(this.form.settlementDate)
  2540. if (this.isInstallment) {
  2541. this.setInstallmentDeadLine();
  2542. return;
  2543. }
  2544. if(this.form.settlementDate.length > 0 && this.form.issueNumber) {
  2545. const dateRange = this.transformMonthFun(this.form.settlementDate, v);
  2546. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
  2547. }
  2548. },
  2549. // 分期付款:按「结算月份范围 + 收款日期」给付款计划回填计划付款日期
  2550. // 结算月份范围/收款日期均非必填,未填时不做任何赋值;只覆盖 deadLine,不影响用户已填的比例/款项名称/金额/说明
  2551. setInstallmentDeadLine() {
  2552. const { settlementDate, receiptDate } = this.form;
  2553. if (!settlementDate || settlementDate.length < 2) return;
  2554. const day = parseInt(receiptDate, 10);
  2555. if (!day || day < 1 || day > 31) return;
  2556. const dateRange = this.transformMonthFun(settlementDate, day);
  2557. this.$refs.paymentCollectionPlanRef?.setDeadLineList(dateRange);
  2558. },
  2559. // 期数变化
  2560. issueNumberChange(v) {
  2561. let dateRange = [];
  2562. if(this.form.settlementMode == 1) {
  2563. dateRange = this.transformDaysFun(this.form.settlementDate, v);
  2564. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v, dateRange);
  2565. } else if(this.form.settlementMode == 2) {
  2566. dateRange = this.transformMonthFun(this.form.settlementDate, v);
  2567. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v, dateRange);
  2568. } else if (this.isInstallment) {
  2569. // 先按期数重建行,再回填计划付款日期
  2570. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v);
  2571. this.$nextTick(() => {
  2572. this.setInstallmentDeadLine();
  2573. });
  2574. } else {
  2575. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v);
  2576. }
  2577. },
  2578. transformDaysFun(date) {
  2579. const startDate = new Date(date[0]);
  2580. const endDate = new Date(date[1]);
  2581. // 计算毫秒差并转换为天数,使用Math.ceil确保结果为整数
  2582. const days = Math.ceil((endDate - startDate) / (1000 * 60 * 60 * 24)) + 1;
  2583. console.log('包含两头的天数:', days);
  2584. // 生成包括头尾在内的所有日期
  2585. const allDates = [];
  2586. const current = new Date(startDate);
  2587. // 遍历从开始日期到结束日期的所有天数
  2588. while (current <= endDate) {
  2589. // 格式化日期为YYYY-MM-dd
  2590. const year = current.getFullYear();
  2591. const month = current.getMonth() + 1; // 月份从0开始,需要+1
  2592. const day = current.getDate();
  2593. const formattedMonth = String(month).padStart(2, '0');
  2594. const formattedDay = String(day).padStart(2, '0');
  2595. const formattedDateStr = `${year}-${formattedMonth}-${formattedDay}`;
  2596. allDates.push(formattedDateStr);
  2597. // 移动到下一天
  2598. current.setDate(current.getDate() + 1);
  2599. }
  2600. return allDates;
  2601. },
  2602. transformMonthFun(date, day) {
  2603. // 处理月份数据(转换为Date对象)
  2604. const parseMonthDate = (dateStr) => {
  2605. return dateStr instanceof Date ? dateStr : new Date(dateStr + '-01');
  2606. };
  2607. const start = parseMonthDate(date[0]);
  2608. const end = parseMonthDate(date[1]);
  2609. // 先生成所有月份的日期数组
  2610. const allMonthDates = [];
  2611. const currentDate = new Date(start);
  2612. // 遍历从开始月份到结束月份的所有月份
  2613. while (currentDate <= end) {
  2614. const year = currentDate.getFullYear();
  2615. const month = currentDate.getMonth() + 1; // 月份从0开始,需要+1
  2616. const receiptDate = day;
  2617. // 格式化日期为YYYY-MM-dd
  2618. const formattedMonth = String(month).padStart(2, '0');
  2619. const formattedDate = String(receiptDate).padStart(2, '0');
  2620. const deadLine = receiptDate ? `${year}-${formattedMonth}-${formattedDate}` : '';
  2621. allMonthDates.push(deadLine);
  2622. // 使用Date对象的setMonth方法正确移动到下一个月(自动处理年份变化)
  2623. currentDate.setMonth(currentDate.getMonth() + 1);
  2624. }
  2625. return allMonthDates;
  2626. },
  2627. }
  2628. };
  2629. </script>
  2630. <style scoped lang="scss">
  2631. .TotalAmount {
  2632. font-size: 16px;
  2633. padding-right: 30px;
  2634. }
  2635. </style>