addDialogNew.vue 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756
  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. { required: true, message: '请选择付款条件', trigger: 'change' }
  1068. ],
  1069. };
  1070. }
  1071. },
  1072. created() {
  1073. console.log(this);
  1074. this.getGroupAll();
  1075. this.getEnterprisePage();
  1076. this.changePersonel();
  1077. //交易方式//1 先票后款 2 先款后票
  1078. parameterGetByCode({
  1079. code: 'eom_contract_add_transactionMode'
  1080. }).then((res) => {
  1081. this.defaultTransactionMode = +res.value;
  1082. });
  1083. //批次号是否必填//0否 1是
  1084. parameterGetByCode({
  1085. code: 'eom_purchaseOrder_batchNo'
  1086. }).then((res) => {
  1087. this.isBatchNo = res.value;
  1088. });
  1089. // 是否生成收款计划单默认配置//0否 1是
  1090. parameterGetByCode({
  1091. code: 'sale_order_gen_receipt_plan'
  1092. }).then((res) => {
  1093. this.isGenReceiptPlan = res.value;
  1094. console.log('isGenReceiptPlan', this.isGenReceiptPlan);
  1095. });
  1096. },
  1097. watch: {
  1098. // 监听订单类型变化,缓存带料清单与产出清单数据,切换回支持类型时恢复
  1099. 'form.sourceType'(newVal, oldVal) {
  1100. const wasInOrder = this.orderSourceType.includes(oldVal);
  1101. const isInOrder = this.orderSourceType.includes(newVal);
  1102. // 从支持类型切到不支持类型:缓存当前数据
  1103. if (wasInOrder && !isInOrder) {
  1104. this.cacheDetailList();
  1105. }
  1106. // 从不支持类型切回支持类型:从缓存恢复数据
  1107. if (!wasInOrder && isInOrder) {
  1108. this.restoreCachedDetailList();
  1109. }
  1110. }
  1111. },
  1112. methods: {
  1113. changeReceiveTerms(row, index) {
  1114. console.log('changeReceiveTerms~~~', row)
  1115. this.form.paymentConditionId = row.id;
  1116. this.form.paymentConditionName = row.name;
  1117. console.log('changeReceiveTerms!!!', this.form)
  1118. this.$forceUpdate()
  1119. },
  1120. handlePaymentConditionBtn() {
  1121. this.$refs.receiveTermsDialogRef.open();
  1122. },
  1123. generatePlanChange(val) {
  1124. console.log(val)
  1125. if(val == 0) {
  1126. } else {
  1127. this.issueNumberChange(this.form.issueNumber);
  1128. // this.$refs.paymentCollectionPlanRef?.setDiscountAmount(
  1129. // this.form.payAmount
  1130. // );
  1131. }
  1132. },
  1133. stockShow() {
  1134. this.$refs.selectStockLedgerDialogRef.open('', -1);
  1135. },
  1136. orderListShow() {
  1137. if (!this.form.partbName) {
  1138. this.$message.warning('请先选择供应商');
  1139. return;
  1140. }
  1141. this.$refs.orderListDialogRef.open();
  1142. },
  1143. async changeHistoryOrder(item) {
  1144. console.log('item~~~~', item)
  1145. const data = await getpurchaseorderDetail(item.id);
  1146. console.log('data~~~~', data);
  1147. [
  1148. 'id',
  1149. 'orderId',
  1150. 'createTime',
  1151. 'createUserId',
  1152. 'createUserName',
  1153. 'createDept',
  1154. 'orderNo',
  1155. 'orderStatus',
  1156. 'outboundStatus',
  1157. 'payStatus',
  1158. 'preOrderNo',
  1159. 'progress',
  1160. 'processInstanceId',
  1161. 'orderBomList'
  1162. ].forEach((key) => {
  1163. delete data[key];
  1164. data.productList.forEach((item) => {
  1165. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1166. delete item[key];
  1167. }
  1168. });
  1169. data.rawList.forEach((item) => {
  1170. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1171. delete item[key];
  1172. }
  1173. });
  1174. data.outputList.forEach((item) => {
  1175. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1176. delete item[key];
  1177. }
  1178. });
  1179. data.receiptPaymentList.forEach((item) => {
  1180. if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
  1181. delete item[key];
  1182. }
  1183. });
  1184. });
  1185. this.form = data;
  1186. if (data) {
  1187. // data.relationType = +data.relationType;
  1188. this.$nextTick(() => {
  1189. this.$store.commit('order/setAllcountAmount', data.totalAmount);
  1190. this.$refs.inventoryTable &&
  1191. this.$refs.inventoryTable.putTableValue(data.productList);
  1192. this.$refs.rawDetailListRef &&
  1193. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1194. this.$refs.outputDetailListRef &&
  1195. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1196. this.getLinkInfo(data.partaId);
  1197. this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
  1198. this.getrequireUser(data.requireDeptId);
  1199. if(data.purchaseDeptId) {
  1200. this.getPurchaseUser(data.purchaseDeptId);
  1201. }
  1202. this.$store.commit('order/setContractId', data.contractId);
  1203. });
  1204. }
  1205. },
  1206. setIssueNumber(len) {
  1207. this.form.issueNumber = len;
  1208. // 分期付款下手工增删行后,同步回填新行的计划付款日期
  1209. if (this.isInstallment) {
  1210. this.$nextTick(() => {
  1211. this.setInstallmentDeadLine();
  1212. });
  1213. }
  1214. },
  1215. getSupplierData(data) {
  1216. console.log('data~~~', data);
  1217. if(!this.form.partbName) {
  1218. getSupplierInfo(data[data.length - 1].productId).then((res) => {
  1219. console.log('res~~~', res);
  1220. this.changeParent(res.data);
  1221. })
  1222. }
  1223. },
  1224. //选择退货单
  1225. handleReturnBtn(e) {
  1226. // this.$refs.returnListRef.open();
  1227. if (e.target.nodeName == 'I') {
  1228. this.$set(this.form, 'relationCode', '');
  1229. this.$set(this.form, 'relationId', '');
  1230. return;
  1231. }
  1232. this.returnOrderDialogFlag = true;
  1233. },
  1234. //退货单
  1235. async changeReturn(row) {
  1236. // console.log('data~~~', row);
  1237. // this.form = Object.assign({}, this.form, {
  1238. // relationCode: row.returnNo,
  1239. // relationId: row.id
  1240. // });
  1241. // this.$set(this.form, 'relationName', data.requirementName);
  1242. this.$set(this.form, 'relationId', row.id);
  1243. this.$set(this.form, 'relationName', row.returnNo);
  1244. this.getReturnOrderDetail(row);
  1245. },
  1246. async getReturnOrderDetail(row) {
  1247. console.log('row', row.orderNo);
  1248. const id = row.orderIds.split(',')[0];
  1249. const res = await getSaleOrderDetail(id);
  1250. console.log('res~~~~', res);
  1251. if (row.partaId) {
  1252. await this.changeParent({ id: row.partaId }, true);
  1253. }
  1254. if (res) {
  1255. let {
  1256. // partaAddress,
  1257. // partaEmail,
  1258. // partaFax,
  1259. // partaId,
  1260. // partaLinkId,
  1261. // partaLinkName,
  1262. // partaName,
  1263. // partaTel,
  1264. partbAddress,
  1265. partbEmail,
  1266. partbFax,
  1267. partbId,
  1268. partbLinkId,
  1269. partbLinkName,
  1270. partbName,
  1271. partbTel,
  1272. totalPrice,
  1273. discountTotalPrice,
  1274. // partaUnifiedSocialCreditCode,
  1275. partbUnifiedSocialCreditCode,
  1276. settlementMode,
  1277. settlementModeName,
  1278. pricingWay,
  1279. productList,
  1280. typedetailList,
  1281. totalAmount,
  1282. payAmount
  1283. } = res;
  1284. this.form = Object.assign({}, this.form, {
  1285. partaAddress: partbAddress,
  1286. partaEmail: partbEmail,
  1287. partaFax: partbFax,
  1288. partaId: partbId,
  1289. partaLinkId: partbLinkId,
  1290. partaLinkName: partbLinkName,
  1291. partaName: partbName,
  1292. partaTel: partbTel,
  1293. // partbAddress,
  1294. // partbEmail,
  1295. // partbFax,
  1296. // partbId,
  1297. // partbLinkId,
  1298. // partbLinkName,
  1299. // partbName,
  1300. // partbTel,
  1301. totalPrice,
  1302. discountTotalPrice,
  1303. partaUnifiedSocialCreditCode: partbUnifiedSocialCreditCode,
  1304. settlementMode,
  1305. settlementModeName,
  1306. pricingWay,
  1307. productList,
  1308. typedetailList,
  1309. // totalAmount,
  1310. payAmount
  1311. });
  1312. this.$nextTick(() => {
  1313. this.$store.commit('order/setAllcountAmount', totalAmount);
  1314. this.$refs.inventoryTable &&
  1315. this.$refs.inventoryTable.putTableValue(res.productList);
  1316. this.getLinkInfo(row.partaId);
  1317. });
  1318. }
  1319. },
  1320. // 销售处理退货
  1321. handleReturnDealBtn(e) {
  1322. if (e.target.nodeName == 'I') {
  1323. this.$set(this.form, 'relationCode', '');
  1324. this.$set(this.form, 'relationId', '');
  1325. return;
  1326. }
  1327. this.returnOrderDealDialogFlag = true;
  1328. },
  1329. async changeReturnDeal(row) {
  1330. this.$set(this.form, 'relationId', row.id);
  1331. this.$set(this.form, 'relationName', row.returnNo);
  1332. this.getReturnOrderDetail(row);
  1333. },
  1334. //选择采购退货单
  1335. handlePurchaseReturnOrder() {
  1336. this.purchaseReturnOrderDialogFlag = true;
  1337. },
  1338. //采购退货单回调
  1339. getPReturnOrderInfo(row) {
  1340. console.log('params~~~~', row);
  1341. this.$set(this.form, 'relationId', row.id);
  1342. this.$set(this.form, 'relationName', row.returnNo);
  1343. this.getReturnPurchaseDetail(row);
  1344. },
  1345. async getReturnPurchaseDetail(row) {
  1346. this.businessId = row.orderId;
  1347. this.loading = true;
  1348. const data = await getpurchaseorderDetail(row.orderId);
  1349. this.loading = false;
  1350. // this.form = data;
  1351. if (data) {
  1352. let {
  1353. partaAddress,
  1354. partaEmail,
  1355. partaFax,
  1356. partaId,
  1357. partaLinkId,
  1358. partaLinkName,
  1359. partaName,
  1360. partaTel,
  1361. partbAddress,
  1362. partbEmail,
  1363. partbFax,
  1364. partbId,
  1365. partbLinkId,
  1366. partbLinkName,
  1367. partbName,
  1368. partbTel,
  1369. totalPrice,
  1370. discountTotalPrice,
  1371. partaUnifiedSocialCreditCode,
  1372. partbUnifiedSocialCreditCode,
  1373. settlementMode,
  1374. settlementModeName,
  1375. pricingWay,
  1376. productList,
  1377. typedetailList,
  1378. totalAmount,
  1379. payAmount
  1380. } = data;
  1381. this.form = Object.assign({}, this.form, {
  1382. partaAddress,
  1383. partaEmail,
  1384. partaFax,
  1385. partaId,
  1386. partaLinkId,
  1387. partaLinkName,
  1388. partaName,
  1389. partaTel,
  1390. partbAddress,
  1391. partbEmail,
  1392. partbFax,
  1393. partbId,
  1394. partbLinkId,
  1395. partbLinkName,
  1396. partbName,
  1397. partbTel,
  1398. totalPrice,
  1399. discountTotalPrice,
  1400. partaUnifiedSocialCreditCode,
  1401. partbUnifiedSocialCreditCode,
  1402. settlementMode,
  1403. settlementModeName,
  1404. pricingWay,
  1405. productList,
  1406. typedetailList,
  1407. totalAmount,
  1408. payAmount
  1409. });
  1410. this.$nextTick(() => {
  1411. this.$store.commit('order/setAllcountAmount', totalAmount);
  1412. this.$refs.inventoryTable &&
  1413. this.$refs.inventoryTable.putTableValue(data.productList);
  1414. this.$refs.rawDetailListRef &&
  1415. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1416. this.$refs.outputDetailListRef &&
  1417. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1418. this.getLinkInfo(data.partaId);
  1419. this.getrequireUser(this.form.requireDeptId);
  1420. // this.$store.commit('order/setContractId', data.contractId);
  1421. });
  1422. }
  1423. },
  1424. //选择项目弹框
  1425. handleProjectBtn() {
  1426. if (this.clearing) return;
  1427. let item = {
  1428. id: this.form.projectId
  1429. };
  1430. this.$refs.selectProjectRef.open(item);
  1431. },
  1432. //选择项目回调
  1433. async changeProject(obj) {
  1434. this.projectData = obj;
  1435. this.form = Object.assign({}, this.form, {
  1436. projectName: obj.name,
  1437. // projectId: obj.id,
  1438. // projectCode: obj.code,
  1439. });
  1440. },
  1441. // 选择负责人部门
  1442. change_principalDep(id) {
  1443. const info = this.groupData.find((e) => e.id == id);
  1444. this.form.requireDeptName = info.name;
  1445. // this.form.requireUserId = '';
  1446. // this.form.requireUserName = '';
  1447. this.$set(this.form, 'requireUserId', '');
  1448. this.$set(this.form, 'requireUserName', '');
  1449. // 根据部门获取人员
  1450. this.getrequireUser(id);
  1451. },
  1452. // 选择采购部门
  1453. changePurchaseDep(id) {
  1454. const info = this.groupData.find((e) => e.id == id);
  1455. this.form.purchaseDeptName = info.name;
  1456. this.$set(this.form, 'purchaseUserId', '');
  1457. this.$set(this.form, 'purchaseUserName', '');
  1458. this.getPurchaseUser(id);
  1459. },
  1460. getPurchaseUser(groupId) {
  1461. console.log('groupId~~~~', groupId);
  1462. if (groupId) {
  1463. this.$refs.purchaseDirectorRef.getList({ groupId });
  1464. }
  1465. },
  1466. //选择采购需求
  1467. handPurchaseNeed() {
  1468. this.$refs.purchaseNeedList.open(
  1469. this.form.relationCode,
  1470. this.form.sourceType
  1471. );
  1472. },
  1473. //选择采购需求回调
  1474. async changePurchaseNeedList(data) {
  1475. this.form.relationId = data.id;
  1476. this.form.relationCode = data.requirementCode;
  1477. this.form.relationName = data.requirementName;
  1478. this.$set(this.form, 'relationName', data.requirementName);
  1479. this.$set(this.form, 'relationId', data.id);
  1480. this.$set(this.form, 'relationCode', data.requirementCode);
  1481. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  1482. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  1483. this.$set(this.form, 'requireUserId', data.requireUserId);
  1484. this.$set(this.form, 'requireUserName', data.requireUserName);
  1485. this.getrequireUser(data.requireDeptId);
  1486. let info = await getProductsBySource({
  1487. relationId: this.form.relationId,
  1488. relationType: this.form.relationType
  1489. });
  1490. info.productList.forEach((item) => {
  1491. item['deliveryDeadline'] = item.expectReceiveDate;
  1492. });
  1493. let form = {
  1494. contractVO: {
  1495. ...this.form
  1496. },
  1497. productList: info.productList || []
  1498. };
  1499. this.$refs.inventoryTable &&
  1500. this.$refs.inventoryTable.putTableValue(form.productList);
  1501. },
  1502. //选择采购计划
  1503. handPurchasePlan() {
  1504. this.$refs.inquiryManageRef.open(
  1505. this.form.planCode,
  1506. this.form.sourceType
  1507. );
  1508. },
  1509. //选择采购计划回调
  1510. async changeInquiryManageList(data) {
  1511. this.form.purchasePlanId = data.id;
  1512. this.form.purchasePlanNo = data.planCode;
  1513. this.form.purchasePlanName = data.planName;
  1514. this.form.relationId = data.id;
  1515. this.form.relationCode = data.planCode;
  1516. this.form.relationName = data.planName;
  1517. this.form.requireDeptId = data.requireDeptId;
  1518. this.form.requireDeptName = data.requireDeptName;
  1519. this.form.requireUserId = data.requireUserId;
  1520. this.form.requireUserName = data.requireUserName;
  1521. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  1522. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  1523. this.$set(this.form, 'requireUserId', data.requireUserId);
  1524. this.$set(this.form, 'requireUserName', data.requireUserName);
  1525. this.getrequireUser(data.requireDeptId);
  1526. // let cusInfo = {}
  1527. this.$set(this.form, 'purchasePlanName', data.planName);
  1528. this.$set(this.form, 'purchasePlanId', data.id);
  1529. this.$set(this.form, 'purchasePlanNo', data.planCode);
  1530. this.$set(this.form, 'relationName', data.planName);
  1531. this.$set(this.form, 'relationId', data.id);
  1532. this.$set(this.form, 'relationCode', data.planCode);
  1533. const res = await getplanDetail(data.id);
  1534. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  1535. let info = await getProductsBySource({
  1536. relationId: this.form.relationId,
  1537. relationType: this.form.relationType
  1538. });
  1539. info['rawDetailList'] = info.rawList;
  1540. info['outputDetailList'] = info.outputList;
  1541. info.productList.forEach((item) => {
  1542. item['deliveryDeadline'] = item.expectReceiveDate;
  1543. });
  1544. let supplierList = res.detailList
  1545. .filter((item) => item.supplierId)
  1546. .map((item) => {
  1547. return {
  1548. supplierId: item.supplierId,
  1549. supplierName: item.supplierName
  1550. };
  1551. });
  1552. if (supplierList?.length > 0) {
  1553. this.supplierList = Array.from(
  1554. new Set(supplierList.map((obj) => JSON.stringify(obj)))
  1555. ).map((str) => JSON.parse(str));
  1556. this.$nextTick(() => {
  1557. this.putTableValue(info);
  1558. });
  1559. if (
  1560. this.supplierList.length == 1 &&
  1561. this.supplierList[0]?.supplierId
  1562. ) {
  1563. await this.changeParent({ id: this.supplierList[0]?.supplierId });
  1564. } else {
  1565. this.supplierListShow = true;
  1566. }
  1567. } else {
  1568. this.putTableValue(info);
  1569. }
  1570. // let form = {
  1571. // contractVO: {
  1572. // ...this.form
  1573. // },
  1574. // productList: info.productList || []
  1575. // }
  1576. // const codeList = form.productList.map((item) => item.productCode);
  1577. // let inventoryTotalList = await getInventoryTotalAPI(codeList);
  1578. // form.productList.forEach((item) => {
  1579. // let find =
  1580. // inventoryTotalList.find((key) => key.code == item.productCode) || {};
  1581. // item.availableCountBase = find.availableCountBase;
  1582. // });
  1583. // this.$refs.inventoryTable &&
  1584. // this.$refs.inventoryTable.putTableValue(form.productList);
  1585. },
  1586. //选择核价单
  1587. handInquiry(e) {
  1588. this.$refs.inquiryListRef.open(this.form.sourceType);
  1589. },
  1590. //选择采购核价回调
  1591. async changeInquiryList(data) {
  1592. console.log(data, 'data=======');
  1593. this.form.relationId = data.id;
  1594. this.form.relationCode = data.inquiryCode;
  1595. this.form.relationName = data.inquiryName;
  1596. this.winnerSuppleIds = data.winnerSuppleIds;
  1597. this.$set(this.form, 'relationName', data.inquiryName);
  1598. this.$set(this.form, 'relationId', data.id);
  1599. this.$set(this.form, 'relationCode', data.inquiryCode);
  1600. const res = await getpurchaseinquiry(data.id);
  1601. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  1602. this.$set(this.form, 'requireDeptId', res.requireDeptId);
  1603. this.$set(this.form, 'requireDeptName', res.requireDeptName);
  1604. this.$set(this.form, 'requireUserId', res.requireUserId);
  1605. this.$set(this.form, 'requireUserName', res.requireUserName);
  1606. this.getrequireUser(res.requireDeptId);
  1607. let info = await getProductsBySource({
  1608. relationId: this.form.relationId,
  1609. relationType: this.form.relationType,
  1610. supplierId: this.winnerSuppleIds
  1611. });
  1612. info['rawDetailList'] = info.rawList;
  1613. info['outputDetailList'] = info.outputList;
  1614. info.productList.forEach((item) => {
  1615. item['discountSinglePrice'] = item.singlePrice;
  1616. item['discountTotalPrice'] = item.totalPrice;
  1617. });
  1618. if (info.productList.length > 1) {
  1619. this.$refs.planTableListRef.open(info);
  1620. } else {
  1621. this.$nextTick(() => {
  1622. this.putTableValue(info);
  1623. });
  1624. }
  1625. this.form = {
  1626. ...this.form,
  1627. partbId: info.partbId,
  1628. partbName: info.partbName,
  1629. partbAddress: info.partaAddress,
  1630. partbLinkId: info.partaAddress,
  1631. partbLinkName: info.partbLinkName,
  1632. partbEmail: info.partbEmail,
  1633. partbTel: info.partbTel
  1634. };
  1635. await this.getLinkInfo(info.partbId);
  1636. this.$nextTick(() => {
  1637. let firstLink =
  1638. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1639. this.form = Object.assign({}, this.form, {
  1640. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  1641. partbLinkName:
  1642. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  1643. partbTel:
  1644. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1645. });
  1646. this.setProductInfo();
  1647. });
  1648. await this.changeParent({ id: info.partbId });
  1649. },
  1650. async putTableValue({ productList, rawDetailList, outputDetailList }) {
  1651. let totalPrice = 0;
  1652. productList.forEach((item) => {
  1653. totalPrice += item.totalPrice ? (+item.totalPrice) : 0;
  1654. });
  1655. this.$store.commit('order/setAllcountAmount', totalPrice);
  1656. this.$set(this.form, 'totalPrice', totalPrice);
  1657. if (this.form.relationType == 3) {
  1658. this.$set(this.form, 'payAmount', totalPrice);
  1659. this.discountInput();
  1660. }
  1661. this.$refs.inventoryTable &&
  1662. this.$refs.inventoryTable.putTableValue(productList);
  1663. this.$refs.rawDetailListRef &&
  1664. this.$refs.rawDetailListRef.putTableValue(rawDetailList); //原料
  1665. this.$refs.outputDetailListRef &&
  1666. this.$refs.outputDetailListRef.putTableValue(outputDetailList);
  1667. },
  1668. getrequireUser(groupId) {
  1669. if (groupId) {
  1670. this.$refs.directorRef.getList({ groupId });
  1671. }
  1672. },
  1673. salesmanChange(val, info) {
  1674. this.$set(this.form, 'requireUserId', val);
  1675. this.$set(this.form, 'requireUserName', info.name);
  1676. // this.form.requireUserName = info.name;
  1677. },
  1678. purchaseUserChange(val, info) {
  1679. this.$set(this.form, 'purchaseUserId', val);
  1680. this.$set(this.form, 'purchaseUserName', info.name);
  1681. },
  1682. // 获取公司数据
  1683. getGroupAll() {
  1684. listOrganizations().then((list) => {
  1685. this.groupData = list;
  1686. this.groupTreeData = this.$util.toTreeData({
  1687. data: list,
  1688. idField: 'id',
  1689. parentIdField: 'parentId'
  1690. });
  1691. });
  1692. },
  1693. discountInput() {
  1694. this.$refs.inventoryTable.discountInputByOrder(this.form.payAmount);
  1695. this.$refs.paymentCollectionPlanRef?.setDiscountAmount(this.form.payAmount);
  1696. },
  1697. //产品清单修改单价或者数量重置优惠金额
  1698. orderDiscountAmount(val = 0) {
  1699. console.log('orderDiscountAmount~~~~', val);
  1700. this.form.payAmount = val;
  1701. this.$refs.paymentCollectionPlanRef.setDiscountAmount(val);
  1702. //this.form.payAmount = undefined
  1703. },
  1704. //选择合同获取合同的详情
  1705. async getDetailData(id) {
  1706. this.loading = true;
  1707. const data = await getDetail(id);
  1708. let info = await getProductsBySource({
  1709. relationId: this.form.relationId,
  1710. relationType: this.form.relationType
  1711. });
  1712. this.loading = false;
  1713. if (data) {
  1714. // if (data.contractVO.sourceType == 3 && data.contractVO.sourceId) {
  1715. // //获取需求部门
  1716. // const res = await getplanDetail(data.contractVO.sourceId);
  1717. // this.$nextTick(() => {
  1718. // this.form.requireDeptId = res.requireDeptId;
  1719. // this.form.requireDeptName = res.requireDeptName;
  1720. // this.form.requireUserId = res.requireUserId;
  1721. // this.form.requireUserName = res.requireUserName;
  1722. // });
  1723. // }
  1724. this.$set(this.form, 'requireDeptId', data.contractVO?.requireDeptId);
  1725. this.$set(
  1726. this.form,
  1727. 'requireDeptName',
  1728. data.contractVO?.requireDeptName
  1729. );
  1730. this.$set(this.form, 'requireUserId', data.contractVO?.requireUserId);
  1731. // this.$set(this.form, 'businessDeptId', data.contractVO?.businessDeptId);
  1732. // this.$set(this.form, 'businessDeptName', data.contractVO?.businessDeptName);
  1733. // this.$set(this.form, 'businessUserId', data.contractVO?.businessUserId);
  1734. // this.$set(this.form, 'businessUserName', data.contractVO?.businessUserName);
  1735. this.$set(
  1736. this.form,
  1737. 'requireUserName',
  1738. data.contractVO?.requireUserName
  1739. );
  1740. console.log('data.contractVO~~~~', data.contractVO);
  1741. this.getrequireUser(data.contractVO?.requireDeptId);
  1742. this.getPurchaseUser(data.contractVO?.businessDeptId);
  1743. this.$nextTick(() => {
  1744. let { contractVO } = data;
  1745. // this.form=contractVOform.receiveAddress
  1746. let {
  1747. partaAddress,
  1748. partaEmail,
  1749. partaFax,
  1750. partaId,
  1751. partaLinkId,
  1752. partaLinkName,
  1753. partaName,
  1754. partaTel,
  1755. partbAddress,
  1756. partbEmail,
  1757. partbFax,
  1758. partbId,
  1759. partbLinkId,
  1760. partbLinkName,
  1761. partbName,
  1762. partbTel,
  1763. totalPrice,
  1764. discountTotalPrice,
  1765. partaUnifiedSocialCreditCode,
  1766. partbUnifiedSocialCreditCode,
  1767. settlementMode,
  1768. settlementModeName,
  1769. pricingWay,
  1770. isFirstProcess,
  1771. requireSourceType,
  1772. requireSourceTypeName,
  1773. businessDeptId,
  1774. businessDeptName,
  1775. businessUserId,
  1776. businessUserName,
  1777. transactionMode,
  1778. startSettlementDate,
  1779. receiptDate,
  1780. issueNumber,
  1781. endSettlementDate,
  1782. deliveryMode,
  1783. } = contractVO;
  1784. this.form = Object.assign({}, this.form, {
  1785. partaAddress,
  1786. partaEmail,
  1787. partaFax,
  1788. partaId,
  1789. partaLinkId,
  1790. partaLinkName,
  1791. partaName,
  1792. partaTel,
  1793. partbAddress,
  1794. partbEmail,
  1795. partbFax,
  1796. partbId,
  1797. partbLinkId,
  1798. partbLinkName,
  1799. partbName,
  1800. partbTel,
  1801. totalPrice,
  1802. settlementMode,
  1803. settlementModeName,
  1804. discountTotalPrice,
  1805. partaUnifiedSocialCreditCode,
  1806. partbUnifiedSocialCreditCode,
  1807. pricingWay,
  1808. totalAmount: totalPrice,
  1809. payAmount: discountTotalPrice,
  1810. receiveAddress: partaAddress,
  1811. isFirstProcess,
  1812. sourceType: requireSourceType || '1',
  1813. sourceTypeName: requireSourceTypeName,
  1814. purchaseDeptId: businessDeptId,
  1815. purchaseDeptName: businessDeptName,
  1816. purchaseUserId: businessUserId,
  1817. purchaseUserName: businessUserName,
  1818. transactionMode,
  1819. startSettlementDate,
  1820. receiptDate,
  1821. issueNumber,
  1822. endSettlementDate,
  1823. deliveryMode,
  1824. settlementDate: startSettlementDate ? [startSettlementDate, endSettlementDate] : [],
  1825. });
  1826. this.getLinkInfo(partaId);
  1827. // info.productList = info.productList.map((item) => {
  1828. // item['purchaseCount'] = item.contractCount;
  1829. // item['purchaseUnit'] = item.contractUnit;
  1830. // item['purchaseUnitId'] = item.contractUnitId;
  1831. // return item;
  1832. // });
  1833. if (info.productList.length > 1) {
  1834. console.log('info.productList~~~~', info.productList);
  1835. this.$refs.planTableListRef.contractOpen(
  1836. info.productList,
  1837. contractVO.contractStartDate
  1838. );
  1839. } else {
  1840. this.contractSuccess({
  1841. productList: info.productList,
  1842. contractStartDate: contractVO.contractStartDate
  1843. });
  1844. }
  1845. const receiptData = {
  1846. receiptPaymentList: data.receiptPaymentList,
  1847. payAmount: discountTotalPrice
  1848. }
  1849. this.$refs.paymentCollectionPlanRef &&
  1850. this.$refs.paymentCollectionPlanRef.putTableValue(receiptData);
  1851. this.$refs.rawDetailListRef &&
  1852. this.$refs.rawDetailListRef.putTableValue(contractVO.rawList); //原料
  1853. this.$refs.outputDetailListRef &&
  1854. this.$refs.outputDetailListRef.putTableValue(
  1855. contractVO.outputList
  1856. );
  1857. this.$store.commit('order/setAllcountAmount', totalPrice);
  1858. });
  1859. }
  1860. },
  1861. contractSuccess({ productList, contractStartDate }) {
  1862. console.log('productList~~~contractSuccess', productList);
  1863. this.$nextTick(() => {
  1864. this.$refs.inventoryTable &&
  1865. this.$refs.inventoryTable.putTableValue(
  1866. productList,
  1867. contractStartDate
  1868. );
  1869. });
  1870. },
  1871. //获取订单详情
  1872. async getpurchaseorderDetail(id) {
  1873. this.businessId = id;
  1874. this.loading = true;
  1875. const data = await getpurchaseorderDetail(id);
  1876. this.loading = false;
  1877. data.settlementDate = data.startSettlementDate ? [data.startSettlementDate, data.endSettlementDate] : [];
  1878. this.form = data;
  1879. console.log('data~~~~~~~000', data);
  1880. if (data) {
  1881. this.$nextTick(() => {
  1882. this.$store.commit('order/setAllcountAmount', data.totalAmount);
  1883. this.$refs.inventoryTable &&
  1884. this.$refs.inventoryTable.putTableValue(data.productList);
  1885. this.$refs.rawDetailListRef &&
  1886. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1887. this.$refs.outputDetailListRef &&
  1888. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1889. this.getLinkInfo(data.partaId);
  1890. this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
  1891. this.getrequireUser(this.form.requireDeptId);
  1892. if(data.purchaseDeptId) {
  1893. this.getPurchaseUser(data.purchaseDeptId);
  1894. }
  1895. this.$store.commit('order/setContractId', data.contractId);
  1896. });
  1897. }
  1898. },
  1899. //更新联系人数据
  1900. async getLinkInfo(contactId) {
  1901. const data = await getcontactlink({ contactId });
  1902. if (data && data?.length) {
  1903. this.linkNameOptions = data;
  1904. }
  1905. },
  1906. sourceTypeChange() {
  1907. // 当sourceType改变时,只重置relationType,保留各清单数据
  1908. this.form.relationType = '';
  1909. },
  1910. // 实时同步带料清单数据到缓存
  1911. rawDataChange(val) {
  1912. this.rawDetailListCache = val || [];
  1913. },
  1914. // 实时同步产出清单数据到缓存
  1915. outputDataChange(val) {
  1916. this.outputDetailListCache = val || [];
  1917. },
  1918. /**
  1919. * 切换订单类型时缓存带料清单与产出清单的数据
  1920. * 由于 tab 上的 v-if 会销毁子组件,所以提前把数据保存到父组件
  1921. */
  1922. cacheDetailList() {
  1923. if (this.$refs.rawDetailListRef) {
  1924. this.rawDetailListCache =
  1925. this.$refs.rawDetailListRef.getTableValue() || [];
  1926. }
  1927. if (this.$refs.outputDetailListRef) {
  1928. this.outputDetailListCache =
  1929. this.$refs.outputDetailListRef.getTableValue() || [];
  1930. }
  1931. },
  1932. /**
  1933. * 当订单类型切回到支持带料/产出清单的类型时,从缓存恢复数据
  1934. */
  1935. restoreCachedDetailList() {
  1936. this.$nextTick(() => {
  1937. if (this.$refs.rawDetailListRef) {
  1938. this.$refs.rawDetailListRef.putTableValue(
  1939. this.rawDetailListCache || []
  1940. );
  1941. }
  1942. if (this.$refs.outputDetailListRef) {
  1943. this.$refs.outputDetailListRef.putTableValue(
  1944. this.outputDetailListCache || []
  1945. );
  1946. }
  1947. });
  1948. },
  1949. handleChangeRelationType(val) {
  1950. // if(this.showReturnRelation) {
  1951. // this.form.relationType = val;
  1952. // }
  1953. this.valueChange();
  1954. },
  1955. valueChange() {
  1956. this.form.purchasePlanId = '';
  1957. this.form.purchasePlanNo = '';
  1958. this.form.purchasePlanName = '';
  1959. this.form.relationId = '';
  1960. this.form.relationCode = '';
  1961. this.form.relationName = '';
  1962. this.$nextTick(() => {
  1963. this.$refs.inventoryTable &&
  1964. this.$refs.inventoryTable.putTableValue([]);
  1965. });
  1966. },
  1967. //选择下拉框
  1968. onchangeLink(selectedOptions) {
  1969. const option = this.linkNameOptions.find(
  1970. (opt) => opt.id === selectedOptions
  1971. );
  1972. this.form = Object.assign({}, this.form, {
  1973. partbEmail: option?.email,
  1974. partbLinkName: option?.linkName || '',
  1975. partbTel: option?.mobilePhone || option?.phone || '',
  1976. partbLinkId: option?.id
  1977. });
  1978. },
  1979. handHead() {
  1980. let item = {
  1981. id: this.form.partaLinkId
  1982. };
  1983. this.$refs.headRef.open(item);
  1984. },
  1985. //选择供采购方人回调
  1986. changePersonel(obj) {
  1987. if (!obj) {
  1988. obj = this.$store.getters.user.info;
  1989. obj.id = obj.userId;
  1990. }
  1991. this.$set(this.form, 'partaLinkId', obj.id);
  1992. this.$set(this.form, 'partaLinkName', obj.name);
  1993. this.$set(this.form, 'partaTel', obj.phone);
  1994. this.$set(this.form, 'partaEmail', obj.email);
  1995. },
  1996. //选择供应商回调
  1997. async changeParent(obj) {
  1998. if (!obj.id) {
  1999. return;
  2000. }
  2001. const { base, other } = await contactDetail(obj.id);
  2002. this.form = Object.assign({}, this.form, {
  2003. partbId: base.id,
  2004. partbName: base.name,
  2005. partbAddress: other.addressName
  2006. ? other.addressName + other.address
  2007. : base.addressName + other.address,
  2008. partbLinkId: '',
  2009. partbLinkName: '',
  2010. partbEmail: '',
  2011. partbTel: '',
  2012. supplierMark: base.serialNo,
  2013. partbUnifiedSocialCreditCode: base.unifiedSocialCreditCode
  2014. });
  2015. await this.getLinkInfo(obj.id);
  2016. // this.form.productList=productList
  2017. this.$nextTick(() => {
  2018. let firstLink =
  2019. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  2020. this.form = Object.assign({}, this.form, {
  2021. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  2022. partbLinkName:
  2023. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  2024. partbTel:
  2025. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  2026. });
  2027. this.setProductInfo();
  2028. });
  2029. },
  2030. setProductInfo() {
  2031. this.$refs.inventoryTable.setCustomerMark(this.form.supplierMark);
  2032. },
  2033. //选择合同回调
  2034. async changeContract(obj) {
  2035. this.form = Object.assign({}, this.form, {
  2036. contractId: obj.id,
  2037. contractName: obj.contractName,
  2038. contractNo: obj.contractNo,
  2039. relationId: obj.id,
  2040. relationName: obj.contractName,
  2041. relationCode: obj.contractNo,
  2042. contractStartDate: obj.contractStartDate,
  2043. });
  2044. await this.getPlanInfo(this.form.contractId);
  2045. await this.getDetailData(obj.id);
  2046. // //采购询价表
  2047. // if(obj.sourceType==2){
  2048. // obj.sourceId && this.getPurchaseinquiry(obj.sourceId);
  2049. // }
  2050. // //采购计划
  2051. // if(obj.sourceType==3){
  2052. // obj.sourceId && this.getPlanInfo(this.form.contractId);
  2053. // }
  2054. this.$store.commit('order/setContractId', obj.id);
  2055. //获取合同采购计划
  2056. },
  2057. async getPlanInfo(id) {
  2058. let res = await getPurchasePlanByContractIdAPI(id);
  2059. if (!res.data?.id) return;
  2060. this.form = Object.assign({}, this.form, {
  2061. purchasePlanId: res.data?.id,
  2062. purchasePlanName: res.data?.planName,
  2063. purchasePlanNo: res.data?.planCode,
  2064. sourceType: res.data?.sourceType,
  2065. sourceTypeName: res.data?.sourceTypeName
  2066. });
  2067. },
  2068. //选择合同弹框
  2069. handleContractBtn() {
  2070. if (this.clearing) return;
  2071. let item = {
  2072. id: this.form.contractId
  2073. };
  2074. this.$refs.selectContractRef.open(item, this.form.sourceType);
  2075. },
  2076. //清除合同
  2077. clearContrcat() {
  2078. this.clearing = true;
  2079. this.isFlag = false;
  2080. let {
  2081. sourceType,
  2082. sourceTypeName,
  2083. requireDeptId,
  2084. requireDeptName,
  2085. requireUserId,
  2086. requireUserName,
  2087. settlementMode,
  2088. settlementModeName,
  2089. id,
  2090. projectName,
  2091. saleType,
  2092. saleTypeName,
  2093. deliveryDate,
  2094. orderFiles,
  2095. remark
  2096. } = this.form;
  2097. this.form = Object.assign({}, copyObj(this.formDef), {
  2098. id,
  2099. projectName,
  2100. saleType,
  2101. saleTypeName,
  2102. deliveryDate,
  2103. orderFiles,
  2104. remark,
  2105. sourceType,
  2106. sourceTypeName,
  2107. requireDeptId,
  2108. requireDeptName,
  2109. requireUserId,
  2110. requireUserName,
  2111. settlementMode,
  2112. settlementModeName
  2113. });
  2114. this.$store.commit('order/setContractId', '');
  2115. this.$store.commit('order/setAllcountAmount', 0);
  2116. this.$refs.inventoryTable.putTableValue([]);
  2117. this.$refs.rawDetailListRef &&
  2118. this.$refs.rawDetailListRef.putTableValue([]);
  2119. this.$refs.outputDetailListRef &&
  2120. this.$refs.outputDetailListRef.putTableValue([]);
  2121. setTimeout(() => {
  2122. this.clearing = false;
  2123. }, 500);
  2124. },
  2125. handParent() {
  2126. if (this.form.contractId) {
  2127. return this.$message.error('选择了合同不能更改供应商名称');
  2128. }
  2129. let item = {
  2130. id: this.form.contactId
  2131. };
  2132. this.$refs.parentRef.open(item);
  2133. },
  2134. //通过合同获取订单类型
  2135. async getPurchaseinquiry(sourceId) {
  2136. let data = await getPurchaseinquiryAPI(sourceId);
  2137. this.isFlag = !!data.sourceType;
  2138. this.form = Object.assign({}, this.form, {
  2139. sourceType: data.sourceType,
  2140. sourceTypeName: data.sourceTypeName
  2141. });
  2142. },
  2143. //打开新增编辑弹框
  2144. async open(type, row, contactCategoryId) {
  2145. this.title = type === 'add' ? '新增' : '修改';
  2146. this.activeName = '1';
  2147. this.row = row;
  2148. // 打开弹框前先清空缓存,避免残留上次数据
  2149. this.rawDetailListCache = [];
  2150. this.outputDetailListCache = [];
  2151. this.visible = true;
  2152. if (this.enterprisePage.length == 0) {
  2153. await this.getEnterprisePage();
  2154. }
  2155. if (type == 'add') {
  2156. // console.log('enterprisePage~~~~~', this.enterprisePage);
  2157. this.form.transactionMode = this.defaultTransactionMode;
  2158. this.isUpdate = false;
  2159. if (this.enterprisePage.length > 0) {
  2160. this.form.partaName = this.enterprisePage[0]?.name;
  2161. this.form.partaUnifiedSocialCreditCode =
  2162. this.enterprisePage[0]?.unifiedSocialCreditCode;
  2163. this.form.partaFax = this.enterprisePage[0]?.fax;
  2164. this.form.partaAddress = this.enterprisePage[0]?.address;
  2165. this.form.purchaseDeptId = this.enterprisePage[0]?.groupId || '';
  2166. this.form.purchaseDeptName = this.enterprisePage[0]?.name || '';
  2167. this.form.purchaseUserId = this.$store.state.user.info?.id || '';
  2168. this.form.purchaseUserName = this.$store.state.user.info?.name || '';
  2169. this.$nextTick(() => {
  2170. this.issueNumberChange(this.form.issueNumber);
  2171. if(this.form.purchaseDeptId) {
  2172. this.getPurchaseUser(this.form.purchaseDeptId);
  2173. }
  2174. })
  2175. }
  2176. this.form.contractStartDate = formatDate(new Date(), 'yyyy-MM-dd');
  2177. this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
  2178. } else {
  2179. this.isUpdate = true;
  2180. await this.getpurchaseorderDetail(row.id);
  2181. }
  2182. },
  2183. getEnterprisePage() {
  2184. enterprisePage({
  2185. pageNum: 1,
  2186. size: 100
  2187. }).then((res) => {
  2188. this.enterprisePage = [];
  2189. this.enterprisePage.push(...res.list);
  2190. });
  2191. },
  2192. getEnterprise() {
  2193. let data = this.enterprisePage.find(
  2194. (item) => item.name == this.form.quoteName
  2195. );
  2196. this.form.partaName = data.name;
  2197. this.form.partaUnifiedSocialCreditCode = data.unifiedSocialCreditCode;
  2198. this.form.partaFax = data.fax;
  2199. this.form.partaAddress = data.address;
  2200. },
  2201. //从合同页面新增订单
  2202. contractOpen(row) {
  2203. this.title = '新增';
  2204. this.visible = true;
  2205. this.isUpdate = false;
  2206. this.form.relationType = 4;
  2207. this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
  2208. this.changeContract(row);
  2209. },
  2210. handleGoodsList() {
  2211. console.log(11111);
  2212. this.supplierGoodsListDialogFlag = true;
  2213. this.$nextTick(() => {
  2214. this.$refs.supplierGoodsListDialogRef.open(this.form.partbId);
  2215. });
  2216. },
  2217. changeValue(val = []) {
  2218. this.$refs.inventoryTable &&
  2219. this.$refs.inventoryTable.getGoodsListData(val);
  2220. },
  2221. // 交易方式改变
  2222. transactionModeChange(v) {
  2223. },
  2224. // 配送方式改变
  2225. deliveryModeChange(v) {
  2226. },
  2227. // 结算方式改变
  2228. settlementModeChange(v) {
  2229. console.log('v~~~', v.dictCode);
  2230. this.form.settlementModeName = v.dictValue;
  2231. // this.$set(this.form, 'issueNumber', 1);
  2232. this.$set(this.form, 'settlementDate', []);
  2233. this.$set(this.form, 'receiptDate', 1);
  2234. if (v.dictCode == 3) {
  2235. this.$set(this.form, 'issueNumber', 2);
  2236. } else {
  2237. this.$set(this.form, 'issueNumber', 1);
  2238. }
  2239. this.$refs.paymentCollectionPlanRef.defaultList(v.dictCode, this.form.issueNumber);
  2240. },
  2241. // settlementModeChange(info) {
  2242. // this.form.settlementModeName = info.dictValue;
  2243. // },
  2244. ifChiefChange(value, idx) {
  2245. if (value === 1) {
  2246. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  2247. this.tableLinkData[idx].ifChief = 1;
  2248. }
  2249. },
  2250. getValidate() {
  2251. if (!this.form.paymentConditionName) {
  2252. this.$message.error('付款条件不能为空');
  2253. }
  2254. const arr = [
  2255. new Promise((resolve, reject) => {
  2256. this.$refs.form.validate((valid) => {
  2257. if (!valid) {
  2258. reject(false);
  2259. } else {
  2260. resolve(true);
  2261. }
  2262. });
  2263. }),
  2264. new Promise((resolve, reject) => {
  2265. this.$refs.inventoryTable.validateForm((valid) => {
  2266. if (!valid) {
  2267. reject(false);
  2268. } else {
  2269. resolve(true);
  2270. }
  2271. });
  2272. }),
  2273. ]
  2274. if(this.form.isGeneratePaymentPlan != 0) {
  2275. arr.push(new Promise((resolve, reject) => {
  2276. this.$refs.paymentCollectionPlanRef.validateForm((valid) => {
  2277. if (!valid) {
  2278. reject(false);
  2279. } else {
  2280. resolve(true);
  2281. }
  2282. });
  2283. }))
  2284. }
  2285. return Promise.all(arr);
  2286. },
  2287. async save(type) {
  2288. let is = false;
  2289. try {
  2290. await this.getValidate();
  2291. // 表单验证通过,执行保存操作
  2292. this.loading = true;
  2293. let isTemporary = [];
  2294. if (!this.isUpdate) {
  2295. delete this.form.id;
  2296. }
  2297. // if (!this.form.contractId) { //如果来源是合同 金额不变这个逻辑有问题 先注释
  2298. this.form.totalAmount = this.allcountAmount;
  2299. // }
  2300. const rawDetailList =
  2301. (this.$refs.rawDetailListRef &&
  2302. this.$refs.rawDetailListRef.getTableValue()) ||
  2303. [];
  2304. const outputDetailList =
  2305. (this.$refs.outputDetailListRef &&
  2306. this.$refs.outputDetailListRef.getTableValue()) ||
  2307. [];
  2308. const tabList =
  2309. (this.$refs.inventoryTable &&
  2310. this.$refs.inventoryTable.getTableValue()) ||
  2311. [];
  2312. tabList.forEach((v, i) => {
  2313. if (!v.productCode) {
  2314. isTemporary.push(v.productName);
  2315. }
  2316. tabList.forEach((v2, j) => {
  2317. if (
  2318. v.productCode == v2.productCode &&
  2319. v.taskId == v2.taskId &&
  2320. v.batchNo == v2.batchNo &&
  2321. v.colorKey == v2.colorKey &&
  2322. v.provenance?.join() == v2.provenance?.join() &&
  2323. v.modelKey == v2.modelKey &&
  2324. v.goodsLevel == v2.goodsLevel &&
  2325. i != j
  2326. ) {
  2327. is = true;
  2328. }
  2329. });
  2330. });
  2331. if (isTemporary.length > 0) {
  2332. this.$message.error(
  2333. isTemporary.toString() +
  2334. '是临时产品,无法创建订单,请先去主数据维护!'
  2335. );
  2336. return;
  2337. }
  2338. // if (is) {
  2339. // this.$message.error('同产品,工序、批次号、颜色不能完全一致!');
  2340. // return;
  2341. // }
  2342. let productList = [
  2343. ...tabList,
  2344. ...rawDetailList.map((item) => {
  2345. item.singlePrice = item.singlePrice || 0;
  2346. item.discountSinglePrice = item.discountSinglePrice || 0;
  2347. item.totalPrice = item.totalPrice || 0;
  2348. item.discountTotalPrice = item.discountTotalPrice || 0;
  2349. return item;
  2350. }),
  2351. ...outputDetailList.map((item) => {
  2352. item.singlePrice = item.singlePrice || 0;
  2353. item.discountSinglePrice = item.discountSinglePrice || 0;
  2354. item.discountTotalPrice = item.discountTotalPrice || 0;
  2355. item.totalPrice = item.totalPrice || 0;
  2356. return item;
  2357. })
  2358. ];
  2359. console.log('提交数据~~~', this.form);
  2360. let commitData = Object.assign({}, this.form, {
  2361. productList,
  2362. // purchaseTypeName: this.getDictValue(
  2363. // '采购订单类型',
  2364. // this.form.purchaseType
  2365. // ),
  2366. sourceTypeName: this.requirementSourceType.find(
  2367. (val) => val.value == this.form.sourceType
  2368. )?.label,
  2369. receiptPaymentList: this.form.isGeneratePaymentPlan == 0 ? [] :
  2370. this.$refs?.paymentCollectionPlanRef?.getTableValue() || [],
  2371. endSettlementDate: this.form.settlementDate?.length ? this.form.settlementDate[1] : '',
  2372. startSettlementDate: this.form.settlementDate?.length ? this.form.settlementDate[0] : ''
  2373. });
  2374. if(this.form.isGeneratePaymentPlan != 0) {
  2375. const ratioSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + +cur.ratio, 0);
  2376. // if(+ratioSum != 100){
  2377. // this.$message.error('比例合计必须为100%');
  2378. // return;
  2379. // }
  2380. if(+ratioSum > 100){
  2381. this.$message.error('比例合计不能超过100%');
  2382. return;
  2383. }
  2384. }
  2385. // 使用万分之一进行计算,避免浮点数精度问题(对应4位小数)
  2386. // let receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
  2387. // const payAmount = +commitData.payAmount;
  2388. // if(+ratioSum == 100) {
  2389. // // 使用万分之一进行计算,避免浮点数精度问题
  2390. // const difference = Math.round((payAmount - receiptPaymentListSum) * 10000) / 10000;
  2391. // if (Math.abs(difference) >= 0.0001 && commitData.receiptPaymentList.length > 0) {
  2392. // const lastIndex = commitData.receiptPaymentList.length - 1;
  2393. // // 使用万分之一进行计算,避免浮点数精度问题
  2394. // const newPrice = Math.round((+commitData.receiptPaymentList[lastIndex].price + difference) * 10000) / 10000;
  2395. // commitData.receiptPaymentList[lastIndex].price = formatPrice(newPrice);
  2396. // receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
  2397. // }
  2398. // }
  2399. // if(Math.abs(+receiptPaymentListSum - payAmount) > 0.0001){
  2400. // this.$message.error('计划收款金额合计与优惠后金额不一致');
  2401. // return;
  2402. // }
  2403. // console.log('提交数据', commitData);
  2404. if (this.isUpdate) {
  2405. try {
  2406. // 更新前先拉取最新编辑数据,确保基于最新版本提交
  2407. await getByIdForEdit(this.form.id || this.businessId);
  2408. const res = await UpdateInformation(commitData);
  2409. this.loading = false;
  2410. this.$message.success('修改成功');
  2411. updateRelationStatus([this.form.partbId]);
  2412. if (this.form.contractId) {
  2413. updateContractStatus([this.form.contractId]);
  2414. }
  2415. if (type === 'sub') {
  2416. this.sub(res);
  2417. return;
  2418. }
  2419. this.cancel();
  2420. this.$emit('done');
  2421. } catch (e) {
  2422. this.loading = false;
  2423. }
  2424. } else {
  2425. addInformation(commitData)
  2426. .then((res) => {
  2427. this.loading = false;
  2428. this.$message.success('新增成功');
  2429. updateRelationStatus([this.form.partbId]);
  2430. if (type === 'sub') {
  2431. this.sub(res);
  2432. return;
  2433. }
  2434. this.cancel();
  2435. this.$emit('done');
  2436. })
  2437. .catch((e) => {
  2438. //this.loading = false;
  2439. });
  2440. }
  2441. } catch (error) {
  2442. console.log(error);
  2443. // 表单验证未通过,不执行保存操作
  2444. }
  2445. },
  2446. async sub(res) {
  2447. const data = await getpurchaseorderDetail(this.businessId || res);
  2448. this.processSubmitDialogFlag = true;
  2449. this.$nextTick(() => {
  2450. let params = {
  2451. businessId: data.id,
  2452. businessKey: 'purchase_order_approve',
  2453. formCreateUserId: data.createUserId,
  2454. variables: {
  2455. businessCode: data.orderNo,
  2456. businessName: data.partaName,
  2457. businessType: data.sourceTypeName
  2458. }
  2459. // callBackMethodType : '1',
  2460. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  2461. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  2462. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  2463. // miniHandle : '',
  2464. // miniView : '',
  2465. };
  2466. this.$refs.processSubmitDialogRef.init(params);
  2467. });
  2468. // submit({
  2469. // businessId: this.businessId || res
  2470. // }).then((res) => {
  2471. // this.cancel();
  2472. // this.$emit('done');
  2473. // });
  2474. },
  2475. reload() {
  2476. this.cancel();
  2477. this.$emit('done');
  2478. },
  2479. cancel() {
  2480. // 先清空带料清单与产出清单的缓存,避免 nextTick 异步导致关闭事件再次触发时缓存残留
  2481. this.rawDetailListCache = [];
  2482. this.outputDetailListCache = [];
  2483. this.$nextTick(() => {
  2484. this.isFlag = false;
  2485. // 关闭后,销毁所有的表单数据
  2486. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  2487. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  2488. this.$store.commit('order/clearUserData');
  2489. this.form = copyObj(this.formDef);
  2490. this.visible = false;
  2491. });
  2492. },
  2493. //查找合同分类对应name
  2494. findNameById(tree, targetId) {
  2495. for (let i = 0; i < tree.length; i++) {
  2496. const node = tree[i];
  2497. if (node.id === targetId) {
  2498. return node.name;
  2499. }
  2500. if (node.children && node.children.length > 0) {
  2501. const name = this.findNameById(node.children, targetId);
  2502. if (name) {
  2503. return name;
  2504. }
  2505. }
  2506. }
  2507. return null;
  2508. },
  2509. // 日期范围变化
  2510. settlementDateChange(val) {
  2511. // console.log(val);
  2512. // 分期付款:期数由用户自行填写,这里只把计划付款日期回填到已有的付款计划行
  2513. if (this.isInstallment) {
  2514. this.setInstallmentDeadLine();
  2515. return;
  2516. }
  2517. let dateRange = [];
  2518. if(this.form.settlementMode == 1) {
  2519. // // this.transformDays(val)
  2520. dateRange = this.transformDaysFun(val);
  2521. }
  2522. if(this.form.settlementMode == 2) {
  2523. // // this.transformMonth(val)
  2524. dateRange = this.transformMonthFun(val, this.form.receiptDate);
  2525. }
  2526. console.log('dateRange~~~', dateRange);
  2527. this.$set(this.form, 'issueNumber', dateRange.length);
  2528. // this.setDefaultList(dateRange)
  2529. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
  2530. },
  2531. // 收款日变化
  2532. receiptDateChange(v) {
  2533. // this.transformMonth(this.form.settlementDate)
  2534. if (this.isInstallment) {
  2535. this.setInstallmentDeadLine();
  2536. return;
  2537. }
  2538. if(this.form.settlementDate.length > 0 && this.form.issueNumber) {
  2539. const dateRange = this.transformMonthFun(this.form.settlementDate, v);
  2540. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
  2541. }
  2542. },
  2543. // 分期付款:按「结算月份范围 + 收款日期」给付款计划回填计划付款日期
  2544. // 结算月份范围/收款日期均非必填,未填时不做任何赋值;只覆盖 deadLine,不影响用户已填的比例/款项名称/金额/说明
  2545. setInstallmentDeadLine() {
  2546. const { settlementDate, receiptDate } = this.form;
  2547. if (!settlementDate || settlementDate.length < 2) return;
  2548. const day = parseInt(receiptDate, 10);
  2549. if (!day || day < 1 || day > 31) return;
  2550. const dateRange = this.transformMonthFun(settlementDate, day);
  2551. this.$refs.paymentCollectionPlanRef?.setDeadLineList(dateRange);
  2552. },
  2553. // 期数变化
  2554. issueNumberChange(v) {
  2555. let dateRange = [];
  2556. if(this.form.settlementMode == 1) {
  2557. dateRange = this.transformDaysFun(this.form.settlementDate, v);
  2558. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v, dateRange);
  2559. } else if(this.form.settlementMode == 2) {
  2560. dateRange = this.transformMonthFun(this.form.settlementDate, v);
  2561. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v, dateRange);
  2562. } else if (this.isInstallment) {
  2563. // 先按期数重建行,再回填计划付款日期
  2564. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v);
  2565. this.$nextTick(() => {
  2566. this.setInstallmentDeadLine();
  2567. });
  2568. } else {
  2569. this.$refs.paymentCollectionPlanRef?.defaultList(this.form.settlementMode, v);
  2570. }
  2571. },
  2572. transformDaysFun(date) {
  2573. const startDate = new Date(date[0]);
  2574. const endDate = new Date(date[1]);
  2575. // 计算毫秒差并转换为天数,使用Math.ceil确保结果为整数
  2576. const days = Math.ceil((endDate - startDate) / (1000 * 60 * 60 * 24)) + 1;
  2577. console.log('包含两头的天数:', days);
  2578. // 生成包括头尾在内的所有日期
  2579. const allDates = [];
  2580. const current = new Date(startDate);
  2581. // 遍历从开始日期到结束日期的所有天数
  2582. while (current <= endDate) {
  2583. // 格式化日期为YYYY-MM-dd
  2584. const year = current.getFullYear();
  2585. const month = current.getMonth() + 1; // 月份从0开始,需要+1
  2586. const day = current.getDate();
  2587. const formattedMonth = String(month).padStart(2, '0');
  2588. const formattedDay = String(day).padStart(2, '0');
  2589. const formattedDateStr = `${year}-${formattedMonth}-${formattedDay}`;
  2590. allDates.push(formattedDateStr);
  2591. // 移动到下一天
  2592. current.setDate(current.getDate() + 1);
  2593. }
  2594. return allDates;
  2595. },
  2596. transformMonthFun(date, day) {
  2597. // 处理月份数据(转换为Date对象)
  2598. const parseMonthDate = (dateStr) => {
  2599. return dateStr instanceof Date ? dateStr : new Date(dateStr + '-01');
  2600. };
  2601. const start = parseMonthDate(date[0]);
  2602. const end = parseMonthDate(date[1]);
  2603. // 先生成所有月份的日期数组
  2604. const allMonthDates = [];
  2605. const currentDate = new Date(start);
  2606. // 遍历从开始月份到结束月份的所有月份
  2607. while (currentDate <= end) {
  2608. const year = currentDate.getFullYear();
  2609. const month = currentDate.getMonth() + 1; // 月份从0开始,需要+1
  2610. const receiptDate = day;
  2611. // 格式化日期为YYYY-MM-dd
  2612. const formattedMonth = String(month).padStart(2, '0');
  2613. const formattedDate = String(receiptDate).padStart(2, '0');
  2614. const deadLine = receiptDate ? `${year}-${formattedMonth}-${formattedDate}` : '';
  2615. allMonthDates.push(deadLine);
  2616. // 使用Date对象的setMonth方法正确移动到下一个月(自动处理年份变化)
  2617. currentDate.setMonth(currentDate.getMonth() + 1);
  2618. }
  2619. return allMonthDates;
  2620. },
  2621. }
  2622. };
  2623. </script>
  2624. <style scoped lang="scss">
  2625. .TotalAmount {
  2626. font-size: 16px;
  2627. padding-right: 30px;
  2628. }
  2629. </style>