addDialogNew.vue 82 KB

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