addDialogNew.vue 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454
  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. console.log('提交数据~~~', this.form);
  2110. let commitData = Object.assign({}, this.form, {
  2111. productList,
  2112. // purchaseTypeName: this.getDictValue(
  2113. // '采购订单类型',
  2114. // this.form.purchaseType
  2115. // ),
  2116. sourceTypeName: this.requirementSourceType.find(
  2117. (val) => val.value == this.form.sourceType
  2118. )?.label,
  2119. receiptPaymentList: this.$refs?.paymentCollectionPlanRef?.getTableValue() || [],
  2120. endSettlementDate: this.form.settlementDate.length ?this.form.settlementDate[1] : '',
  2121. startSettlementDate: this.form.settlementDate.length ? this.form.settlementDate[0] : ''
  2122. });
  2123. const ratioSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + +cur.ratio, 0);
  2124. if(+ratioSum != 100){
  2125. this.$message.error('比例合计必须为100%');
  2126. return;
  2127. }
  2128. // 使用万分之一进行计算,避免浮点数精度问题(对应4位小数)
  2129. let receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
  2130. const payAmount = +commitData.payAmount;
  2131. if(+ratioSum == 100) {
  2132. // 使用万分之一进行计算,避免浮点数精度问题
  2133. const difference = Math.round((payAmount - receiptPaymentListSum) * 10000) / 10000;
  2134. if (Math.abs(difference) >= 0.0001 && commitData.receiptPaymentList.length > 0) {
  2135. const lastIndex = commitData.receiptPaymentList.length - 1;
  2136. // 使用万分之一进行计算,避免浮点数精度问题
  2137. const newPrice = Math.round((+commitData.receiptPaymentList[lastIndex].price + difference) * 10000) / 10000;
  2138. commitData.receiptPaymentList[lastIndex].price = formatPrice(newPrice);
  2139. receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 10000), 0) / 10000;
  2140. }
  2141. }
  2142. if(Math.abs(+receiptPaymentListSum - payAmount) > 0.0001){
  2143. this.$message.error('计划收款金额合计与优惠后金额不一致');
  2144. return;
  2145. }
  2146. console.log('提交数据', commitData);
  2147. if (this.isUpdate) {
  2148. UpdateInformation(commitData)
  2149. .then((res) => {
  2150. this.loading = false;
  2151. this.$message.success('修改成功');
  2152. updateRelationStatus([this.form.partbId]);
  2153. if (this.form.contractId) {
  2154. updateContractStatus([this.form.contractId]);
  2155. }
  2156. if (type === 'sub') {
  2157. this.sub(res);
  2158. return;
  2159. }
  2160. this.cancel();
  2161. this.$emit('done');
  2162. })
  2163. .catch((e) => {
  2164. //this.loading = false;
  2165. });
  2166. } else {
  2167. addInformation(commitData)
  2168. .then((res) => {
  2169. this.loading = false;
  2170. this.$message.success('新增成功');
  2171. updateRelationStatus([this.form.partbId]);
  2172. if (type === 'sub') {
  2173. this.sub(res);
  2174. return;
  2175. }
  2176. this.cancel();
  2177. this.$emit('done');
  2178. })
  2179. .catch((e) => {
  2180. //this.loading = false;
  2181. });
  2182. }
  2183. } catch (error) {
  2184. console.log(error);
  2185. // 表单验证未通过,不执行保存操作
  2186. }
  2187. },
  2188. async sub(res) {
  2189. const data = await getpurchaseorderDetail(this.businessId || res);
  2190. this.processSubmitDialogFlag = true;
  2191. this.$nextTick(() => {
  2192. let params = {
  2193. businessId: data.id,
  2194. businessKey: 'purchase_order_approve',
  2195. formCreateUserId: data.createUserId,
  2196. variables: {
  2197. businessCode: data.orderNo,
  2198. businessName: data.partaName,
  2199. businessType: data.sourceTypeName
  2200. }
  2201. // callBackMethodType : '1',
  2202. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  2203. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  2204. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  2205. // miniHandle : '',
  2206. // miniView : '',
  2207. };
  2208. this.$refs.processSubmitDialogRef.init(params);
  2209. });
  2210. // submit({
  2211. // businessId: this.businessId || res
  2212. // }).then((res) => {
  2213. // this.cancel();
  2214. // this.$emit('done');
  2215. // });
  2216. },
  2217. reload() {
  2218. this.cancel();
  2219. this.$emit('done');
  2220. },
  2221. cancel() {
  2222. this.$nextTick(() => {
  2223. this.isFlag = false;
  2224. // 关闭后,销毁所有的表单数据
  2225. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  2226. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  2227. this.$store.commit('order/clearUserData');
  2228. this.form = copyObj(this.formDef);
  2229. this.visible = false;
  2230. });
  2231. },
  2232. //查找合同分类对应name
  2233. findNameById(tree, targetId) {
  2234. for (let i = 0; i < tree.length; i++) {
  2235. const node = tree[i];
  2236. if (node.id === targetId) {
  2237. return node.name;
  2238. }
  2239. if (node.children && node.children.length > 0) {
  2240. const name = this.findNameById(node.children, targetId);
  2241. if (name) {
  2242. return name;
  2243. }
  2244. }
  2245. }
  2246. return null;
  2247. },
  2248. // 日期范围变化
  2249. settlementDateChange(val) {
  2250. // console.log(val);
  2251. let dateRange = [];
  2252. if(this.form.settlementMode == 1) {
  2253. // // this.transformDays(val)
  2254. dateRange = this.transformDaysFun(val);
  2255. }
  2256. if(this.form.settlementMode == 2) {
  2257. // // this.transformMonth(val)
  2258. dateRange = this.transformMonthFun(val, this.form.receiptDate);
  2259. }
  2260. console.log('dateRange~~~', dateRange);
  2261. this.$set(this.form, 'issueNumber', dateRange.length);
  2262. // this.setDefaultList(dateRange)
  2263. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
  2264. },
  2265. // 收款日变化
  2266. receiptDateChange(v) {
  2267. // this.transformMonth(this.form.settlementDate)
  2268. if(this.form.settlementDate.length > 0 && this.form.issueNumber) {
  2269. const dateRange = this.transformMonthFun(this.form.settlementDate, v);
  2270. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
  2271. }
  2272. },
  2273. // 期数变化
  2274. issueNumberChange(v) {
  2275. let dateRange = [];
  2276. if(this.form.settlementMode == 1) {
  2277. dateRange = this.transformDaysFun(this.form.settlementDate, v);
  2278. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, v, dateRange);
  2279. } else if(this.form.settlementMode == 2) {
  2280. dateRange = this.transformMonthFun(this.form.settlementDate, v);
  2281. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, v, dateRange);
  2282. } else {
  2283. this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, v);
  2284. }
  2285. },
  2286. transformDaysFun(date) {
  2287. const startDate = new Date(date[0]);
  2288. const endDate = new Date(date[1]);
  2289. // 计算毫秒差并转换为天数,使用Math.ceil确保结果为整数
  2290. const days = Math.ceil((endDate - startDate) / (1000 * 60 * 60 * 24)) + 1;
  2291. console.log('包含两头的天数:', days);
  2292. // 生成包括头尾在内的所有日期
  2293. const allDates = [];
  2294. const current = new Date(startDate);
  2295. // 遍历从开始日期到结束日期的所有天数
  2296. while (current <= endDate) {
  2297. // 格式化日期为YYYY-MM-dd
  2298. const year = current.getFullYear();
  2299. const month = current.getMonth() + 1; // 月份从0开始,需要+1
  2300. const day = current.getDate();
  2301. const formattedMonth = String(month).padStart(2, '0');
  2302. const formattedDay = String(day).padStart(2, '0');
  2303. const formattedDateStr = `${year}-${formattedMonth}-${formattedDay}`;
  2304. allDates.push(formattedDateStr);
  2305. // 移动到下一天
  2306. current.setDate(current.getDate() + 1);
  2307. }
  2308. return allDates;
  2309. },
  2310. transformMonthFun(date, day) {
  2311. // 处理月份数据(转换为Date对象)
  2312. const parseMonthDate = (dateStr) => {
  2313. return dateStr instanceof Date ? dateStr : new Date(dateStr + '-01');
  2314. };
  2315. const start = parseMonthDate(date[0]);
  2316. const end = parseMonthDate(date[1]);
  2317. // 先生成所有月份的日期数组
  2318. const allMonthDates = [];
  2319. const currentDate = new Date(start);
  2320. // 遍历从开始月份到结束月份的所有月份
  2321. while (currentDate <= end) {
  2322. const year = currentDate.getFullYear();
  2323. const month = currentDate.getMonth() + 1; // 月份从0开始,需要+1
  2324. const receiptDate = day;
  2325. // 格式化日期为YYYY-MM-dd
  2326. const formattedMonth = String(month).padStart(2, '0');
  2327. const formattedDate = String(receiptDate).padStart(2, '0');
  2328. const deadLine = receiptDate ? `${year}-${formattedMonth}-${formattedDate}` : '';
  2329. allMonthDates.push(deadLine);
  2330. // 使用Date对象的setMonth方法正确移动到下一个月(自动处理年份变化)
  2331. currentDate.setMonth(currentDate.getMonth() + 1);
  2332. }
  2333. return allMonthDates;
  2334. },
  2335. }
  2336. };
  2337. </script>
  2338. <style scoped lang="scss">
  2339. .TotalAmount {
  2340. font-size: 16px;
  2341. padding-right: 30px;
  2342. }
  2343. </style>