addDialogNew.vue 80 KB

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