addDialog.vue 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659
  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="12">
  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"
  32. clearable
  33. >
  34. <el-option
  35. v-for="item in requirementSourceType"
  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="relationType">
  44. <el-select
  45. v-model="form.relationType"
  46. filterable
  47. clearable
  48. style="width: 100%"
  49. @change="handleChangeRelationType"
  50. >
  51. <el-option :value="1" label="采购需求单"></el-option>
  52. <el-option :value="2" label="采购计划单"></el-option>
  53. <el-option :value="3" label="采购核价单"></el-option>
  54. <el-option :value="4" label="采购合同"></el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item
  58. prop="outsourceScene"
  59. label="委外场景"
  60. v-if="
  61. orderSourceType.includes(form.sourceType) && form.outsourceScene
  62. "
  63. >
  64. <el-select
  65. v-model="form.outsourceScene"
  66. disabled
  67. style="width: 100%"
  68. >
  69. <el-option
  70. :value="item.value"
  71. :label="item.label"
  72. v-for="item in outsourceSceneList"
  73. :key="item.value"
  74. >
  75. </el-option>
  76. </el-select>
  77. </el-form-item>
  78. <el-form-item
  79. v-if="form.relationType == 1"
  80. label="采购需求单"
  81. prop="relationName"
  82. >
  83. <el-input
  84. @click.native="handPurchaseNeed"
  85. v-model="form.relationName"
  86. placeholder="请选择"
  87. ></el-input>
  88. </el-form-item>
  89. <el-form-item
  90. v-if="form.relationType == 2"
  91. label="采购计划单"
  92. prop="relationName"
  93. >
  94. <el-input
  95. @click.native="handPurchasePlan"
  96. v-model="form.relationName"
  97. placeholder="请选择"
  98. ></el-input>
  99. </el-form-item>
  100. <el-form-item
  101. v-if="form.relationType == 3"
  102. label="采购核价单"
  103. prop="relationName"
  104. >
  105. <el-input
  106. @click.native="handInquiry"
  107. v-model="form.relationName"
  108. placeholder="请选择"
  109. ></el-input>
  110. </el-form-item>
  111. <el-form-item
  112. v-if="form.relationType == 4"
  113. label="选择合同"
  114. prop="contractName"
  115. >
  116. <el-input
  117. clearable
  118. v-model="form.contractName"
  119. @click.native="handleContractBtn"
  120. @clear="clearContrcat"
  121. placeholder="请输入"
  122. />
  123. </el-form-item>
  124. <el-form-item label="需求部门" prop="requireDeptId">
  125. <ele-tree-select
  126. clearable
  127. :data="groupTreeData"
  128. v-model="form.requireDeptId"
  129. valueKey="id"
  130. labelKey="name"
  131. placeholder="请选择"
  132. @change="change_principalDep"
  133. default-expand-all
  134. />
  135. </el-form-item>
  136. <el-form-item prop="orderFiles" label="附件">
  137. <fileMain v-model="form.orderFiles"></fileMain>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="12">
  141. <el-form-item label="项目名称" prop="projectName">
  142. <el-input
  143. clearable
  144. v-model="form.projectName"
  145. placeholder="请输入"
  146. />
  147. </el-form-item>
  148. <el-form-item label="结算方式" prop="settlementMode">
  149. <DictSelection
  150. dictName="结算方式"
  151. clearable
  152. @itemChange="settlementModeChange"
  153. v-model="form.settlementMode"
  154. >
  155. </DictSelection>
  156. </el-form-item>
  157. <el-form-item label="需求人" prop="requireUserId">
  158. <personSelect
  159. ref="directorRef"
  160. v-model="form.requireUserId"
  161. @selfChange="salesmanChange"
  162. :init="false"
  163. />
  164. </el-form-item>
  165. </el-col>
  166. </el-row>
  167. <headerTitle title="基本信息"></headerTitle>
  168. <el-row>
  169. <el-col :span="12">
  170. <el-form-item label="采购方名称" prop="partaName">
  171. <el-select
  172. style="width: 100%"
  173. v-model="form.partaName"
  174. placeholder="请选择"
  175. @change="getEnterprise()"
  176. >
  177. <el-option
  178. v-for="item in enterprisePage"
  179. :key="item.id"
  180. :label="item.name"
  181. :value="item.name"
  182. >
  183. </el-option>
  184. </el-select>
  185. </el-form-item>
  186. <el-form-item
  187. label="采购方统一社会信用代码"
  188. class="form_item_label"
  189. prop="partaUnifiedSocialCreditCode"
  190. >
  191. <el-input
  192. clearable
  193. v-model="form.partaUnifiedSocialCreditCode"
  194. placeholder="请输入"
  195. />
  196. </el-form-item>
  197. <el-form-item label="采购方联系人" prop="partaLinkName">
  198. <el-input
  199. clearable
  200. v-model="form.partaLinkName"
  201. @click.native="handHead"
  202. placeholder="请输入"
  203. />
  204. </el-form-item>
  205. <el-form-item label="采购方电话" prop="partaTel">
  206. <el-input
  207. clearable
  208. :maxlength="20"
  209. v-model="form.partaTel"
  210. placeholder="请输入"
  211. />
  212. </el-form-item>
  213. <el-form-item label="采购方传真" prop="partaFax">
  214. <el-input clearable v-model="form.partaFax" placeholder="请输入" />
  215. </el-form-item>
  216. <el-form-item label=" 采购方Email" prop="partaEmail">
  217. <el-input
  218. clearable
  219. v-model="form.partaEmail"
  220. placeholder="请输入"
  221. />
  222. </el-form-item>
  223. <el-form-item label="采购方地址" prop="partaAddress">
  224. <el-input
  225. clearable
  226. v-model="form.partaAddress"
  227. placeholder="请输入"
  228. />
  229. </el-form-item>
  230. </el-col>
  231. <el-col :span="12">
  232. <el-form-item label="供应商名称" prop="partbName">
  233. <el-row>
  234. <el-col :span="form.partbName ? 19 : 24">
  235. <el-input
  236. clearable
  237. v-model="form.partbName"
  238. @click.native="handParent"
  239. :disabled="!!form.contractId"
  240. placeholder="请选择"
  241. >
  242. </el-input>
  243. </el-col>
  244. <el-col :span="5">
  245. <el-button
  246. v-if="form.partbName"
  247. style="color: #fff; background: #1890ff"
  248. @click.native="handleGoodsList"
  249. >供货列表
  250. </el-button>
  251. </el-col>
  252. </el-row>
  253. </el-form-item>
  254. <el-form-item
  255. label="供应商统一社会信用代码"
  256. prop="partbUnifiedSocialCreditCode"
  257. class="form_item_label"
  258. >
  259. <el-input
  260. clearable
  261. v-model="form.partbUnifiedSocialCreditCode"
  262. placeholder="请输入"
  263. />
  264. </el-form-item>
  265. <el-form-item label="供应商联系人" prop="partbLinkName">
  266. <el-select
  267. style="width: 100%"
  268. v-model="form.partbLinkName"
  269. placeholder="请选择"
  270. @change="onchangeLink"
  271. >
  272. <el-option
  273. v-for="item in linkNameOptions"
  274. :key="item.id"
  275. :label="item.linkName"
  276. :value="item.id"
  277. >
  278. </el-option>
  279. </el-select>
  280. </el-form-item>
  281. <el-form-item prop="partbTel" label="供应商联系电话">
  282. <el-input clearable v-model="form.partbTel" placeholder="请输入" />
  283. </el-form-item>
  284. <el-form-item prop="partbFax" label="供应商传真">
  285. <el-input clearable v-model="form.partbFax" placeholder="请输入" />
  286. </el-form-item>
  287. <el-form-item label="供应商Email" prop="partbEmail">
  288. <el-input
  289. clearable
  290. v-model="form.partbEmail"
  291. placeholder="请输入"
  292. />
  293. </el-form-item>
  294. <el-form-item label="供应商地址" prop="partbAddress">
  295. <el-input
  296. clearable
  297. v-model="form.partbAddress"
  298. placeholder="请输入"
  299. />
  300. </el-form-item>
  301. </el-col>
  302. </el-row>
  303. <!-- <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle> -->
  304. <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
  305. <el-tab-pane label="物品清单" name="1">
  306. <inventoryTable
  307. ref="inventoryTable"
  308. @orderDiscountAmount="orderDiscountAmount"
  309. :pricingWay="form.pricingWay"
  310. :supplierMark="form.supplierMark"
  311. :is-show-supplier-mark="true"
  312. :isContractId="
  313. !!form.contractId && !OutValidate.includes(form.sourceType)
  314. "
  315. >
  316. </inventoryTable>
  317. </el-tab-pane>
  318. <el-tab-pane
  319. label="带料清单"
  320. name="2"
  321. v-if="orderSourceType.includes(form.sourceType)"
  322. >
  323. <inventoryTable
  324. ref="rawDetailListRef"
  325. :detailType="1"
  326. :pricingWay="form.pricingWay"
  327. :supplierMark="form.supplierMark"
  328. :is-show-supplier-mark="true"
  329. :isContractId="
  330. !!form.contractId && !OutValidate.includes(form.sourceType)
  331. "
  332. ></inventoryTable>
  333. </el-tab-pane>
  334. <el-tab-pane
  335. label="产出清单"
  336. name="3"
  337. v-if="orderSourceType.includes(form.sourceType)"
  338. >
  339. <inventoryTable
  340. ref="outputDetailListRef"
  341. :detailType="2"
  342. :pricingWay="form.pricingWay"
  343. :supplierMark="form.supplierMark"
  344. :is-show-supplier-mark="true"
  345. :isContractId="
  346. !!form.contractId && !OutValidate.includes(form.sourceType)
  347. "
  348. ></inventoryTable>
  349. </el-tab-pane>
  350. </el-tabs>
  351. <el-row style="margin-top: 20px">
  352. <el-col :span="12">
  353. <el-form-item label="总金额" prop="totalAmount">
  354. {{ allcountAmount || 0 }}元
  355. </el-form-item>
  356. <el-form-item label="备注" prop="remark">
  357. <el-input
  358. clearable
  359. type="textarea"
  360. v-model="form.remark"
  361. placeholder="请输入"
  362. />
  363. </el-form-item>
  364. </el-col>
  365. <el-col :span="12">
  366. <el-form-item label="优惠后总金额" prop="payAmount">
  367. <el-input
  368. clearable
  369. v-model="form.payAmount"
  370. :disabled="
  371. (!!form.contractId && !OutValidate.includes(form.sourceType)) ||
  372. !allcountAmount
  373. "
  374. type="number"
  375. @blur="discountInput"
  376. placeholder="请输入"
  377. >
  378. <template slot="append">元</template>
  379. </el-input>
  380. </el-form-item>
  381. </el-col>
  382. </el-row>
  383. </el-form>
  384. <div slot="footer" class="footer">
  385. <el-button type="primary" @click="save" v-click-once>保存</el-button>
  386. <el-button type="primary" @click="save('sub')" v-click-once
  387. >提交</el-button
  388. >
  389. <el-button @click="cancel">返回</el-button>
  390. </div>
  391. <parentList
  392. ref="parentRef"
  393. @changeParent="changeParent"
  394. :classType="2"
  395. ></parentList>
  396. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  397. <contractListDialog
  398. :hasGeneratedOrder="
  399. this.OutValidate.includes(this.form.sourceType) ? 3 : 0
  400. "
  401. ref="selectContractRef"
  402. @changeParent="changeContract"
  403. :type="2"
  404. :sourceType="form.sourceType"
  405. ></contractListDialog>
  406. <inquiryManageList
  407. ref="inquiryManageRef"
  408. @changeInquiryManageList="changeInquiryManageList"
  409. ></inquiryManageList>
  410. <process-submit-dialog
  411. :isNotNeedProcess="false"
  412. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  413. v-if="processSubmitDialogFlag"
  414. ref="processSubmitDialogRef"
  415. @reload="reload"
  416. ></process-submit-dialog>
  417. <purchaseNeedList
  418. ref="purchaseNeedList"
  419. @changeParent="changePurchaseNeedList"
  420. ></purchaseNeedList>
  421. <inquiryList
  422. ref="inquiryListRef"
  423. @changeParent="changeInquiryList"
  424. ></inquiryList>
  425. <supplier-goods-list-dialog
  426. @changeParent="changeValue"
  427. :supplier-goods-list-dialog-flag.sync="supplierGoodsListDialogFlag"
  428. v-if="supplierGoodsListDialogFlag"
  429. ref="supplierGoodsListDialogRef"
  430. ></supplier-goods-list-dialog>
  431. <planTableList
  432. ref="planTableListRef"
  433. @success="putTableValue"
  434. @contractSuccess="contractSuccess"
  435. ></planTableList>
  436. <ele-modal
  437. custom-class="ele-dialog-form long-dialog-form"
  438. :visible.sync="supplierListShow"
  439. title="选择供应商"
  440. :close-on-click-modal="false"
  441. width="600px"
  442. append-to-body
  443. >
  444. <el-select style="width: 100%" v-model="supplierId" placeholder="请选择">
  445. <el-option
  446. v-for="item in supplierList"
  447. :key="item.supplierId"
  448. :label="item.supplierName"
  449. :value="item.supplierId"
  450. >
  451. </el-option>
  452. </el-select>
  453. <div slot="footer" class="footer">
  454. <el-button
  455. type="primary"
  456. @click="
  457. changeParent({ id: supplierId });
  458. supplierListShow = false;
  459. "
  460. >确认</el-button
  461. >
  462. <el-button @click="supplierListShow = false">返回</el-button>
  463. </div>
  464. </ele-modal>
  465. </ele-modal>
  466. </template>
  467. <script>
  468. import { emailReg, telReg } from 'ele-admin';
  469. import inventoryTable from './inventoryTable.vue';
  470. import planTableList from './planTableList.vue';
  471. import fileUpload from '@/components/upload/fileUpload';
  472. import dictMixins from '@/mixins/dictMixins';
  473. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  474. import personSelect from '@/components/CommomSelect/person-select.vue';
  475. import parentList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  476. import {
  477. enterprisePage,
  478. getDetail,
  479. updateContractStatus
  480. } from '@/api/contractManage/contractBook';
  481. import supplierGoodsListDialog from '@/views/purchasingManage/purchaseOrder/components/supplierGoodsListDialog.vue';
  482. import {
  483. addInformation,
  484. getProductsBySource,
  485. getPurchaseinquiryAPI,
  486. getpurchaseorderDetail,
  487. getPurchasePlanByContractIdAPI,
  488. UpdateInformation
  489. } from '@/api/purchasingManage/purchaseOrder';
  490. import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
  491. import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
  492. import { getcontactlink } from '@/api/saleManage/businessFollow';
  493. import headList from '@/BIZComponents/user-select/user-select.vue';
  494. import contractListDialog from '@/views/saleManage/saleOrder/components/contractListDialog.vue';
  495. import { listOrganizations } from '@/api/system/organization';
  496. import { copyObj } from '@/utils/util';
  497. import inquiryManageList from '@/views/purchasingManage/inquiryManage/components/inquiryManage-list.vue';
  498. // import fileMain from '@/components/addDoc/index.vue';
  499. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  500. import purchaseNeedList from '@/views/purchasingManage/purchasePlanManage/components/purchaseNeed-list.vue';
  501. import inquiryList from './inquiryList.vue';
  502. import {
  503. contactDetail,
  504. updateRelationStatus
  505. } from '@/api/saleManage/contact';
  506. import {
  507. requirementSourceType,
  508. acceptUnpackoptions,
  509. orderSourceType,
  510. outsourceSceneList
  511. } from '@/enum/dict.js';
  512. export default {
  513. mixins: [dictMixins],
  514. props: {
  515. isRequired: {
  516. type: Boolean,
  517. default: true
  518. }
  519. },
  520. components: {
  521. inquiryList,
  522. purchaseNeedList,
  523. processSubmitDialog,
  524. // fileMain,
  525. inquiryManageList,
  526. fileUpload,
  527. headList,
  528. contractListDialog,
  529. inventoryTable,
  530. deptSelect,
  531. parentList,
  532. personSelect,
  533. supplierGoodsListDialog,
  534. planTableList
  535. },
  536. data() {
  537. let formDef = {
  538. id: '',
  539. contractId: '',
  540. relationType: '',
  541. relationName: '',
  542. orderFiles: [],
  543. contractName: '',
  544. deliveryDate: '',
  545. payAmount: '',
  546. projectName: '',
  547. projectId: '',
  548. receiveAddress: '',
  549. sourceType: '',
  550. sourceTypeName: '',
  551. pricingWay: 1,
  552. remark: '',
  553. saleType: '',
  554. saleTypeName: '',
  555. totalAmount: '',
  556. settlementMode: '4',
  557. settlementModeName: '分期付款',
  558. partaUnifiedSocialCreditCode: '',
  559. partbUnifiedSocialCreditCode: '',
  560. partaAddress: '',
  561. partaEmail: '',
  562. partaFax: '',
  563. partaId: '',
  564. partaLinkId: '',
  565. partaLinkName: '',
  566. partaName: '',
  567. partaTel: '',
  568. partbAddress: '',
  569. partbEmail: '',
  570. partbFax: '',
  571. partbId: '',
  572. partbLinkId: '',
  573. partbLinkName: '',
  574. partbName: '',
  575. partbTel: '',
  576. purchasePlanId: '',
  577. purchasePlanNo: '',
  578. purchasePlanName: '',
  579. isFirstProcess: 0
  580. };
  581. return {
  582. supplierListShow: false,
  583. supplierList: [],
  584. supplierId: '',
  585. orderSourceType,
  586. outsourceSceneList,
  587. requirementSourceType,
  588. processList: [
  589. {
  590. label: '是',
  591. value: 1
  592. },
  593. {
  594. label: '否',
  595. value: 0
  596. }
  597. ],
  598. isFlag: false, //订单类型是否不可修改
  599. clearing: false, //是否清除合同
  600. payWayOptions: [],
  601. delDetailIds: [],
  602. linkNameOptions: [],
  603. acceptUnpackoptions,
  604. visible: false,
  605. fullscreen: false,
  606. processSubmitDialogFlag: false,
  607. supplierGoodsListDialogFlag: false,
  608. title: '',
  609. row: {},
  610. activeName: '1',
  611. pricingWayList: [
  612. { id: 1, name: '按数量计价' },
  613. { id: 2, name: '按重量计价' }
  614. ],
  615. formDef,
  616. form: copyObj(formDef),
  617. enterprisePage: [],
  618. tableBankData: [],
  619. tableLinkData: [],
  620. // 组织机构树形结构数据
  621. groupTreeData: [],
  622. groupData: [],
  623. OutValidate: ['3', '4'],
  624. // 提交状态
  625. loading: false,
  626. // 是否是修改
  627. isUpdate: false,
  628. businessId: '',
  629. winnerSuppleIds: ''
  630. };
  631. },
  632. computed: {
  633. allcountAmount() {
  634. return this.$store.state.order.allcountAmount;
  635. },
  636. rules() {
  637. let isRequired = this.isRequired;
  638. // console.log(this.isRequired);
  639. return {
  640. deliveryDate: [
  641. { required: true, message: '请选择交货日期', trigger: 'change' }
  642. ],
  643. purchasePlanName: [
  644. {
  645. required: this.OutValidate.includes(this.form.sourceType),
  646. message: '请选择采购计划单',
  647. trigger: ['change', 'blur']
  648. }
  649. ],
  650. relationName: [
  651. {
  652. required: true,
  653. message: '请选择',
  654. trigger: ['change', 'blur']
  655. }
  656. ],
  657. contractName: [
  658. {
  659. required: true,
  660. message: '请选择合同',
  661. trigger: ['change', 'blur']
  662. }
  663. ],
  664. // purchaseType: [
  665. // {required: true, message: '请选择采购订单类型', trigger: 'change'}
  666. // ],
  667. settlementMode: [
  668. { required: true, message: '请选择结算方式', trigger: 'change' }
  669. ],
  670. partaName: [
  671. {
  672. required: true,
  673. message: '请选择供应商名称',
  674. trigger: 'change'
  675. }
  676. ],
  677. partaLinkName: [
  678. {
  679. required: isRequired,
  680. message: '请选择供应商联系人',
  681. trigger: 'change'
  682. }
  683. ],
  684. acceptUnpack: [
  685. { required: true, message: '请选择是否接受', trigger: 'change' }
  686. ],
  687. sourceType: [
  688. { required: true, message: '请选择订单类型', trigger: 'change' }
  689. ],
  690. payAmount: [{ required: true, message: '请输入', trigger: 'blur' }],
  691. partbAddress: [
  692. { required: true, message: '请输入', trigger: 'blur' }
  693. ],
  694. partaTel: [
  695. {
  696. required: isRequired,
  697. pattern: telReg,
  698. message: '请输入供应商联系电话',
  699. trigger: 'blur'
  700. }
  701. ],
  702. partbName: [
  703. { required: true, message: '请输入供采购方名称', trigger: 'change' }
  704. ],
  705. partbLinkName: [
  706. {
  707. required: isRequired,
  708. message: '请输入供采购方联系人',
  709. trigger: 'change'
  710. }
  711. ],
  712. partbTel: [
  713. {
  714. required: isRequired,
  715. pattern: telReg,
  716. message: '请输入供采购方联系电话',
  717. trigger: 'blur'
  718. }
  719. ],
  720. partaEmail: [
  721. { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
  722. ]
  723. };
  724. }
  725. },
  726. created() {
  727. console.log(this);
  728. this.getGroupAll();
  729. this.getEnterprisePage();
  730. this.changePersonel();
  731. },
  732. methods: {
  733. // 选择负责人部门
  734. change_principalDep(id) {
  735. const info = this.groupData.find((e) => e.id == id);
  736. this.form.requireDeptName = info.name;
  737. // this.form.requireUserId = '';
  738. // this.form.requireUserName = '';
  739. this.$set(this.form, 'requireUserId', '');
  740. this.$set(this.form, 'requireUserName', '');
  741. // 根据部门获取人员
  742. this.getrequireUser(id);
  743. },
  744. //选择采购需求
  745. handPurchaseNeed() {
  746. this.$refs.purchaseNeedList.open(
  747. this.form.relationCode,
  748. this.form.sourceType
  749. );
  750. },
  751. //选择采购需求回调
  752. async changePurchaseNeedList(data) {
  753. this.form.relationId = data.id;
  754. this.form.relationCode = data.requirementCode;
  755. this.form.relationName = data.requirementName;
  756. this.$set(this.form, 'relationName', data.requirementName);
  757. this.$set(this.form, 'relationId', data.id);
  758. this.$set(this.form, 'relationCode', data.requirementCode);
  759. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  760. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  761. this.$set(this.form, 'requireUserId', data.requireUserId);
  762. this.$set(this.form, 'requireUserName', data.requireUserName);
  763. this.getrequireUser(data.requireDeptId);
  764. let info = await getProductsBySource({
  765. relationId: this.form.relationId,
  766. relationType: this.form.relationType
  767. });
  768. let form = {
  769. contractVO: {
  770. ...this.form
  771. },
  772. productList: info.productList || []
  773. };
  774. this.$refs.inventoryTable &&
  775. this.$refs.inventoryTable.putTableValue(form.productList);
  776. },
  777. //选择采购计划
  778. handPurchasePlan() {
  779. this.$refs.inquiryManageRef.open(
  780. this.form.planCode,
  781. this.form.sourceType
  782. );
  783. },
  784. //选择采购计划回调
  785. async changeInquiryManageList(data) {
  786. this.form.purchasePlanId = data.id;
  787. this.form.purchasePlanNo = data.planCode;
  788. this.form.purchasePlanName = data.planName;
  789. this.form.relationId = data.id;
  790. this.form.relationCode = data.planCode;
  791. this.form.relationName = data.planName;
  792. this.form.requireDeptId = data.requireDeptId;
  793. this.form.requireDeptName = data.requireDeptName;
  794. this.form.requireUserId = data.requireUserId;
  795. this.form.requireUserName = data.requireUserName;
  796. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  797. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  798. this.$set(this.form, 'requireUserId', data.requireUserId);
  799. this.$set(this.form, 'requireUserName', data.requireUserName);
  800. this.getrequireUser(data.requireDeptId);
  801. // let cusInfo = {}
  802. this.$set(this.form, 'purchasePlanName', data.planName);
  803. this.$set(this.form, 'purchasePlanId', data.id);
  804. this.$set(this.form, 'purchasePlanNo', data.planCode);
  805. this.$set(this.form, 'relationName', data.planName);
  806. this.$set(this.form, 'relationId', data.id);
  807. this.$set(this.form, 'relationCode', data.planCode);
  808. const res = await getplanDetail(data.id);
  809. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  810. let info = await getProductsBySource({
  811. relationId: this.form.relationId,
  812. relationType: this.form.relationType
  813. });
  814. info['rawDetailList'] = info.rawList;
  815. info['outputDetailList'] = info.outputList;
  816. // if (info.productList.length > 1) {
  817. // this.$refs.planTableListRef.open(info);
  818. // } else {
  819. // }
  820. let supplierList = res.detailList
  821. .filter((item) => item.supplierId)
  822. .map((item) => {
  823. return {
  824. supplierId: item.supplierId,
  825. supplierName: item.supplierName
  826. };
  827. });
  828. if (supplierList?.length > 0) {
  829. this.supplierList = Array.from(
  830. new Set(supplierList.map((obj) => JSON.stringify(obj)))
  831. ).map((str) => JSON.parse(str));
  832. this.$nextTick(() => {
  833. this.putTableValue(info);
  834. });
  835. if (
  836. this.supplierList.length == 1 &&
  837. this.supplierList[0]?.supplierId
  838. ) {
  839. await this.changeParent({ id: this.supplierList[0]?.supplierId });
  840. } else {
  841. this.supplierListShow = true;
  842. }
  843. }else{
  844. this.putTableValue(info);
  845. }
  846. // let form = {
  847. // contractVO: {
  848. // ...this.form
  849. // },
  850. // productList: info.productList || []
  851. // }
  852. // const codeList = form.productList.map((item) => item.productCode);
  853. // let inventoryTotalList = await getInventoryTotalAPI(codeList);
  854. // form.productList.forEach((item) => {
  855. // let find =
  856. // inventoryTotalList.find((key) => key.code == item.productCode) || {};
  857. // item.availableCountBase = find.availableCountBase;
  858. // });
  859. // this.$refs.inventoryTable &&
  860. // this.$refs.inventoryTable.putTableValue(form.productList);
  861. },
  862. //选择核价单
  863. handInquiry(e) {
  864. this.$refs.inquiryListRef.open(this.form.sourceType);
  865. },
  866. //选择采购核价回调
  867. async changeInquiryList(data) {
  868. console.log(data, '=======');
  869. this.form.relationId = data.id;
  870. this.form.relationCode = data.inquiryCode;
  871. this.form.relationName = data.inquiryName;
  872. this.winnerSuppleIds = data.winnerSuppleIds;
  873. this.$set(this.form, 'relationName', data.inquiryName);
  874. this.$set(this.form, 'relationId', data.id);
  875. this.$set(this.form, 'relationCode', data.inquiryCode);
  876. const res = await getpurchaseinquiry(data.id);
  877. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  878. let info = await getProductsBySource({
  879. relationId: this.form.relationId,
  880. relationType: this.form.relationType,
  881. supplierId: this.winnerSuppleIds
  882. });
  883. info['rawDetailList'] = info.rawList;
  884. info['outputDetailList'] = info.outputList;
  885. info.productList.forEach((item) => {
  886. item['discountSinglePrice'] = item.singlePrice;
  887. item['discountTotalPrice'] = item.totalPrice;
  888. });
  889. if (info.productList.length > 1) {
  890. this.$refs.planTableListRef.open(info);
  891. } else {
  892. this.$nextTick(() => {
  893. this.putTableValue(info);
  894. });
  895. }
  896. this.form = {
  897. ...this.form,
  898. partbId: info.partbId,
  899. partbName: info.partbName,
  900. partbAddress: info.partaAddress,
  901. partbLinkId: info.partaAddress,
  902. partbLinkName: info.partbLinkName,
  903. partbEmail: info.partbEmail,
  904. partbTel: info.partbTel
  905. };
  906. await this.getLinkInfo(info.partbId);
  907. this.$nextTick(() => {
  908. let firstLink =
  909. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  910. this.form = Object.assign({}, this.form, {
  911. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  912. partbLinkName:
  913. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  914. partbTel:
  915. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  916. });
  917. this.setProductInfo();
  918. });
  919. await this.changeParent({ id: info.partbId });
  920. },
  921. async putTableValue({ productList, rawDetailList, outputDetailList }) {
  922. let totalPrice = 0;
  923. productList.forEach((item) => {
  924. totalPrice += item.totalPrice;
  925. });
  926. this.$store.commit('order/setAllcountAmount', totalPrice);
  927. this.$set(this.form, 'totalPrice', totalPrice);
  928. if (this.form.relationType == 3) {
  929. this.$set(this.form, 'payAmount', totalPrice);
  930. }
  931. this.$refs.inventoryTable &&
  932. this.$refs.inventoryTable.putTableValue(productList);
  933. this.$refs.rawDetailListRef &&
  934. this.$refs.rawDetailListRef.putTableValue(rawDetailList); //原料
  935. this.$refs.outputDetailListRef &&
  936. this.$refs.outputDetailListRef.putTableValue(outputDetailList);
  937. },
  938. getrequireUser(groupId) {
  939. if (groupId) {
  940. this.$refs.directorRef.getList({ groupId });
  941. }
  942. },
  943. salesmanChange(val, info) {
  944. this.$set(this.form, 'requireUserId', val);
  945. this.$set(this.form, 'requireUserName', info.name);
  946. // this.form.requireUserName = info.name;
  947. },
  948. // 获取公司数据
  949. getGroupAll() {
  950. listOrganizations().then((list) => {
  951. this.groupData = list;
  952. this.groupTreeData = this.$util.toTreeData({
  953. data: list,
  954. idField: 'id',
  955. parentIdField: 'parentId'
  956. });
  957. });
  958. },
  959. discountInput() {
  960. this.$refs.inventoryTable.discountInputByOrder(this.form.payAmount);
  961. },
  962. //产品清单修改单价或者数量重置优惠金额
  963. orderDiscountAmount(val = 0) {
  964. this.form.payAmount = val;
  965. //this.form.payAmount = undefined
  966. },
  967. //选择合同获取合同的详情
  968. async getDetailData(id) {
  969. this.loading = true;
  970. const data = await getDetail(id);
  971. let info = await getProductsBySource({
  972. relationId: this.form.relationId,
  973. relationType: this.form.relationType
  974. });
  975. this.loading = false;
  976. if (data) {
  977. // if (data.contractVO.sourceType == 3 && data.contractVO.sourceId) {
  978. // //获取需求部门
  979. // const res = await getplanDetail(data.contractVO.sourceId);
  980. // this.$nextTick(() => {
  981. // this.form.requireDeptId = res.requireDeptId;
  982. // this.form.requireDeptName = res.requireDeptName;
  983. // this.form.requireUserId = res.requireUserId;
  984. // this.form.requireUserName = res.requireUserName;
  985. // });
  986. // }
  987. this.$set(this.form, 'requireDeptId', data.contractVO?.requireDeptId);
  988. this.$set(
  989. this.form,
  990. 'requireDeptName',
  991. data.contractVO?.requireDeptName
  992. );
  993. this.$set(this.form, 'requireUserId', data.contractVO?.requireUserId);
  994. this.$set(
  995. this.form,
  996. 'requireUserName',
  997. data.contractVO?.requireUserName
  998. );
  999. this.getrequireUser(data.contractVO?.requireDeptId);
  1000. this.$nextTick(() => {
  1001. let { contractVO } = data;
  1002. // this.form=contractVOform.receiveAddress
  1003. let {
  1004. partaAddress,
  1005. partaEmail,
  1006. partaFax,
  1007. partaId,
  1008. partaLinkId,
  1009. partaLinkName,
  1010. partaName,
  1011. partaTel,
  1012. partbAddress,
  1013. partbEmail,
  1014. partbFax,
  1015. partbId,
  1016. partbLinkId,
  1017. partbLinkName,
  1018. partbName,
  1019. partbTel,
  1020. totalPrice,
  1021. discountTotalPrice,
  1022. partaUnifiedSocialCreditCode,
  1023. partbUnifiedSocialCreditCode,
  1024. settlementMode,
  1025. settlementModeName,
  1026. pricingWay,
  1027. isFirstProcess,
  1028. requireSourceType,
  1029. requireSourceTypeName
  1030. } = contractVO;
  1031. this.form = Object.assign({}, this.form, {
  1032. partaAddress,
  1033. partaEmail,
  1034. partaFax,
  1035. partaId,
  1036. partaLinkId,
  1037. partaLinkName,
  1038. partaName,
  1039. partaTel,
  1040. partbAddress,
  1041. partbEmail,
  1042. partbFax,
  1043. partbId,
  1044. partbLinkId,
  1045. partbLinkName,
  1046. partbName,
  1047. partbTel,
  1048. totalPrice,
  1049. settlementMode,
  1050. settlementModeName,
  1051. discountTotalPrice,
  1052. partaUnifiedSocialCreditCode,
  1053. partbUnifiedSocialCreditCode,
  1054. pricingWay,
  1055. totalAmount: totalPrice,
  1056. payAmount: discountTotalPrice,
  1057. receiveAddress: partaAddress,
  1058. isFirstProcess,
  1059. sourceType: requireSourceType || '1',
  1060. sourceTypeName: requireSourceTypeName
  1061. });
  1062. this.getLinkInfo(partaId);
  1063. if (info.productList.length > 1) {
  1064. this.$refs.planTableListRef.contractOpen(
  1065. info.productList,
  1066. contractVO.contractStartDate
  1067. );
  1068. } else {
  1069. this.contractSuccess({
  1070. productList: info.productList,
  1071. contractStartDate: contractVO.contractStartDate
  1072. });
  1073. }
  1074. this.$refs.rawDetailListRef &&
  1075. this.$refs.rawDetailListRef.putTableValue(contractVO.rawList); //原料
  1076. this.$refs.outputDetailListRef &&
  1077. this.$refs.outputDetailListRef.putTableValue(
  1078. contractVO.outputList
  1079. );
  1080. this.$store.commit('order/setAllcountAmount', totalPrice);
  1081. });
  1082. }
  1083. },
  1084. contractSuccess({ productList, contractStartDate }) {
  1085. this.$nextTick(() => {
  1086. this.$refs.inventoryTable &&
  1087. this.$refs.inventoryTable.putTableValue(
  1088. productList,
  1089. contractStartDate
  1090. );
  1091. });
  1092. },
  1093. //获取订单详情
  1094. async getpurchaseorderDetail(id) {
  1095. this.businessId = id;
  1096. this.loading = true;
  1097. const data = await getpurchaseorderDetail(id);
  1098. this.loading = false;
  1099. if (data) {
  1100. this.$nextTick(() => {
  1101. this.form = data;
  1102. this.$store.commit('order/setAllcountAmount', data.totalAmount);
  1103. this.$refs.inventoryTable &&
  1104. this.$refs.inventoryTable.putTableValue(data.productList);
  1105. this.$refs.rawDetailListRef &&
  1106. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1107. this.$refs.outputDetailListRef &&
  1108. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1109. this.getLinkInfo(data.partaId);
  1110. this.getrequireUser(this.form.requireDeptId);
  1111. this.$store.commit('order/setContractId', data.contractId);
  1112. });
  1113. }
  1114. },
  1115. //更新联系人数据
  1116. async getLinkInfo(contactId) {
  1117. const data = await getcontactlink({ contactId });
  1118. if (data && data?.length) {
  1119. this.linkNameOptions = data;
  1120. }
  1121. },
  1122. sourceTypeChange() {
  1123. this.valueChange();
  1124. },
  1125. handleChangeRelationType(val) {
  1126. this.valueChange();
  1127. },
  1128. valueChange() {
  1129. this.form.purchasePlanId = '';
  1130. this.form.purchasePlanNo = '';
  1131. this.form.purchasePlanName = '';
  1132. this.form.relationId = '';
  1133. this.form.relationCode = '';
  1134. this.form.relationName = '';
  1135. this.$nextTick(() => {
  1136. this.$refs.inventoryTable &&
  1137. this.$refs.inventoryTable.putTableValue([]);
  1138. });
  1139. },
  1140. //选择下拉框
  1141. onchangeLink(selectedOptions) {
  1142. const option = this.linkNameOptions.find(
  1143. (opt) => opt.id === selectedOptions
  1144. );
  1145. this.form = Object.assign({}, this.form, {
  1146. partbEmail: option?.email,
  1147. partbLinkName: option?.linkName || '',
  1148. partbTel: option?.mobilePhone || option?.phone || '',
  1149. partbLinkId: option?.id
  1150. });
  1151. },
  1152. handHead() {
  1153. let item = {
  1154. id: this.form.partaLinkId
  1155. };
  1156. this.$refs.headRef.open(item);
  1157. },
  1158. //选择供采购方人回调
  1159. changePersonel(obj) {
  1160. if (!obj) {
  1161. obj = this.$store.getters.user.info;
  1162. obj.id = obj.userId;
  1163. }
  1164. this.$set(this.form, 'partaLinkId', obj.id);
  1165. this.$set(this.form, 'partaLinkName', obj.name);
  1166. this.$set(this.form, 'partaTel', obj.phone);
  1167. this.$set(this.form, 'partaEmail', obj.email);
  1168. },
  1169. //选择供应商回调
  1170. async changeParent(obj) {
  1171. if (!obj.id) {
  1172. return;
  1173. }
  1174. const { base, other } = await contactDetail(obj.id);
  1175. this.form = Object.assign({}, this.form, {
  1176. partbId: base.id,
  1177. partbName: base.name,
  1178. partbAddress: other.addressName
  1179. ? other.addressName + other.address
  1180. : base.addressName + other.address,
  1181. partbLinkId: '',
  1182. partbLinkName: '',
  1183. partbEmail: '',
  1184. partbTel: '',
  1185. supplierMark: base.serialNo,
  1186. partbUnifiedSocialCreditCode: base.unifiedSocialCreditCode
  1187. });
  1188. await this.getLinkInfo(obj.id);
  1189. // this.form.productList=productList
  1190. this.$nextTick(() => {
  1191. let firstLink =
  1192. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1193. this.form = Object.assign({}, this.form, {
  1194. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  1195. partbLinkName:
  1196. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  1197. partbTel:
  1198. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1199. });
  1200. this.setProductInfo();
  1201. });
  1202. },
  1203. setProductInfo() {
  1204. this.$refs.inventoryTable.setCustomerMark(this.form.supplierMark);
  1205. },
  1206. //选择合同回调
  1207. async changeContract(obj) {
  1208. this.form = Object.assign({}, this.form, {
  1209. contractId: obj.id,
  1210. contractName: obj.contractName,
  1211. contractNo: obj.contractNo,
  1212. relationId: obj.id,
  1213. relationName: obj.contractName,
  1214. relationCode: obj.contractNo
  1215. });
  1216. await this.getPlanInfo(this.form.contractId);
  1217. await this.getDetailData(obj.id);
  1218. // //采购询价表
  1219. // if(obj.sourceType==2){
  1220. // obj.sourceId && this.getPurchaseinquiry(obj.sourceId);
  1221. // }
  1222. // //采购计划
  1223. // if(obj.sourceType==3){
  1224. // obj.sourceId && this.getPlanInfo(this.form.contractId);
  1225. // }
  1226. this.$store.commit('order/setContractId', obj.id);
  1227. //获取合同采购计划
  1228. },
  1229. async getPlanInfo(id) {
  1230. let res = await getPurchasePlanByContractIdAPI(id);
  1231. if (!res.data?.id) return;
  1232. this.form = Object.assign({}, this.form, {
  1233. purchasePlanId: res.data?.id,
  1234. purchasePlanName: res.data?.planName,
  1235. purchasePlanNo: res.data?.planCode,
  1236. sourceType: res.data?.sourceType,
  1237. sourceTypeName: res.data?.sourceTypeName
  1238. });
  1239. },
  1240. //选择合同弹框
  1241. handleContractBtn() {
  1242. if (this.clearing) return;
  1243. let item = {
  1244. id: this.form.contractId
  1245. };
  1246. this.$refs.selectContractRef.open(item, this.form.sourceType);
  1247. },
  1248. //清除合同
  1249. clearContrcat() {
  1250. this.clearing = true;
  1251. this.isFlag = false;
  1252. let {
  1253. sourceType,
  1254. sourceTypeName,
  1255. requireDeptId,
  1256. requireDeptName,
  1257. requireUserId,
  1258. requireUserName,
  1259. settlementMode,
  1260. settlementModeName,
  1261. id,
  1262. projectName,
  1263. saleType,
  1264. saleTypeName,
  1265. deliveryDate,
  1266. orderFiles,
  1267. remark
  1268. } = this.form;
  1269. this.form = Object.assign({}, copyObj(this.formDef), {
  1270. id,
  1271. projectName,
  1272. saleType,
  1273. saleTypeName,
  1274. deliveryDate,
  1275. orderFiles,
  1276. remark,
  1277. sourceType,
  1278. sourceTypeName,
  1279. requireDeptId,
  1280. requireDeptName,
  1281. requireUserId,
  1282. requireUserName,
  1283. settlementMode,
  1284. settlementModeName
  1285. });
  1286. this.$store.commit('order/setContractId', '');
  1287. this.$store.commit('order/setAllcountAmount', 0);
  1288. this.$refs.inventoryTable.putTableValue([]);
  1289. this.$refs.rawDetailListRef &&
  1290. this.$refs.rawDetailListRef.putTableValue([]);
  1291. this.$refs.outputDetailListRef &&
  1292. this.$refs.outputDetailListRef.putTableValue([]);
  1293. setTimeout(() => {
  1294. this.clearing = false;
  1295. }, 500);
  1296. },
  1297. handParent() {
  1298. if (this.form.contractId) {
  1299. return this.$message.error('选择了合同不能更改供应商名称');
  1300. }
  1301. let item = {
  1302. id: this.form.contactId
  1303. };
  1304. this.$refs.parentRef.open(item);
  1305. },
  1306. //通过合同获取订单类型
  1307. async getPurchaseinquiry(sourceId) {
  1308. let data = await getPurchaseinquiryAPI(sourceId);
  1309. this.isFlag = !!data.sourceType;
  1310. this.form = Object.assign({}, this.form, {
  1311. sourceType: data.sourceType,
  1312. sourceTypeName: data.sourceTypeName
  1313. });
  1314. },
  1315. //打开新增编辑弹框
  1316. async open(type, row, contactCategoryId) {
  1317. this.title = type === 'add' ? '新增' : '修改';
  1318. this.activeName = '1';
  1319. this.row = row;
  1320. this.visible = true;
  1321. if (this.enterprisePage.length == 0) {
  1322. await this.getEnterprisePage();
  1323. }
  1324. if (type == 'add') {
  1325. this.isUpdate = false;
  1326. if (this.enterprisePage.length > 0) {
  1327. this.form.partaName = this.enterprisePage[0]?.name;
  1328. this.form.partaUnifiedSocialCreditCode =
  1329. this.enterprisePage[0]?.unifiedSocialCreditCode;
  1330. this.form.partaFax = this.enterprisePage[0]?.fax;
  1331. this.form.partaAddress = this.enterprisePage[0]?.address;
  1332. }
  1333. } else {
  1334. this.isUpdate = true;
  1335. await this.getpurchaseorderDetail(row.id);
  1336. }
  1337. },
  1338. getEnterprisePage() {
  1339. enterprisePage({
  1340. pageNum: 1,
  1341. size: 100
  1342. }).then((res) => {
  1343. this.enterprisePage = [];
  1344. this.enterprisePage.push(...res.list);
  1345. });
  1346. },
  1347. getEnterprise() {
  1348. let data = this.enterprisePage.find(
  1349. (item) => item.name == this.form.quoteName
  1350. );
  1351. this.form.partaName = data.name;
  1352. this.form.partaUnifiedSocialCreditCode = data.unifiedSocialCreditCode;
  1353. this.form.partaFax = data.fax;
  1354. this.form.partaAddress = data.address;
  1355. },
  1356. //从合同页面新增订单
  1357. contractOpen(row) {
  1358. this.title = '新增';
  1359. this.visible = true;
  1360. this.isUpdate = false;
  1361. this.form.relationType = 4;
  1362. this.changeContract(row);
  1363. },
  1364. handleGoodsList() {
  1365. console.log(11111);
  1366. this.supplierGoodsListDialogFlag = true;
  1367. this.$nextTick(() => {
  1368. this.$refs.supplierGoodsListDialogRef.open(this.form.partbId);
  1369. });
  1370. },
  1371. changeValue(val = []) {
  1372. this.$refs.inventoryTable &&
  1373. this.$refs.inventoryTable.getGoodsListData(val);
  1374. },
  1375. settlementModeChange(info) {
  1376. this.form.settlementModeName = info.dictValue;
  1377. },
  1378. ifChiefChange(value, idx) {
  1379. if (value === 1) {
  1380. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  1381. this.tableLinkData[idx].ifChief = 1;
  1382. }
  1383. },
  1384. getValidate() {
  1385. return Promise.all([
  1386. new Promise((resolve, reject) => {
  1387. this.$refs.form.validate((valid) => {
  1388. if (!valid) {
  1389. reject(false);
  1390. } else {
  1391. resolve(true);
  1392. }
  1393. });
  1394. }),
  1395. new Promise((resolve, reject) => {
  1396. this.$refs.inventoryTable.validateForm((valid) => {
  1397. if (!valid) {
  1398. reject(false);
  1399. } else {
  1400. resolve(true);
  1401. }
  1402. });
  1403. })
  1404. ]);
  1405. },
  1406. async save(type) {
  1407. let is = false;
  1408. try {
  1409. await this.getValidate();
  1410. // 表单验证通过,执行保存操作
  1411. this.loading = true;
  1412. let isTemporary = [];
  1413. if (!this.isUpdate) {
  1414. delete this.form.id;
  1415. }
  1416. if (!this.form.contractId) {
  1417. this.form.totalAmount = this.allcountAmount;
  1418. }
  1419. const rawDetailList =
  1420. (this.$refs.rawDetailListRef &&
  1421. this.$refs.rawDetailListRef.getTableValue()) ||
  1422. [];
  1423. const outputDetailList =
  1424. (this.$refs.outputDetailListRef &&
  1425. this.$refs.outputDetailListRef.getTableValue()) ||
  1426. [];
  1427. const tabList =
  1428. (this.$refs.inventoryTable &&
  1429. this.$refs.inventoryTable.getTableValue()) ||
  1430. [];
  1431. tabList.forEach((v, i) => {
  1432. if (!v.productCode) {
  1433. isTemporary.push(v.productName);
  1434. }
  1435. // tabList.forEach((v2, j) => {
  1436. // if (
  1437. // v.productCode == v2.productCode &&
  1438. // v.taskId == v2.taskId &&
  1439. // v.batchNo == v2.batchNo &&
  1440. // i != j
  1441. // ) {
  1442. // is = true;
  1443. // }
  1444. // });
  1445. });
  1446. if (isTemporary.length > 0) {
  1447. this.$message.error(
  1448. isTemporary.toString() +
  1449. '是临时产品,无法创建订单,请先去主数据维护!'
  1450. );
  1451. return;
  1452. }
  1453. // if (is) {
  1454. // this.$message.error('同产品,工序、批次号不能完全一致!');
  1455. // return;
  1456. // }
  1457. let productList = [
  1458. ...tabList,
  1459. ...rawDetailList.map((item) => {
  1460. item.singlePrice = item.singlePrice || 0;
  1461. item.discountSinglePrice = item.discountSinglePrice || 0;
  1462. item.totalPrice = item.totalPrice || 0;
  1463. item.discountTotalPrice = item.discountTotalPrice || 0;
  1464. return item;
  1465. }),
  1466. ...outputDetailList.map((item) => {
  1467. item.singlePrice = item.singlePrice || 0;
  1468. item.discountSinglePrice = item.discountSinglePrice || 0;
  1469. item.discountTotalPrice = item.discountTotalPrice || 0;
  1470. item.totalPrice = item.totalPrice || 0;
  1471. return item;
  1472. })
  1473. ];
  1474. let commitData = Object.assign({}, this.form, {
  1475. productList,
  1476. // purchaseTypeName: this.getDictValue(
  1477. // '采购订单类型',
  1478. // this.form.purchaseType
  1479. // ),
  1480. sourceTypeName: this.requirementSourceType.find(
  1481. (val) => val.value == this.form.sourceType
  1482. )?.label
  1483. });
  1484. if (this.isUpdate) {
  1485. UpdateInformation(commitData)
  1486. .then((res) => {
  1487. this.loading = false;
  1488. this.$message.success('修改成功');
  1489. updateRelationStatus([this.form.partbId]);
  1490. if (this.form.contractId) {
  1491. updateContractStatus([this.form.contractId]);
  1492. }
  1493. if (type === 'sub') {
  1494. this.sub(res);
  1495. return;
  1496. }
  1497. this.cancel();
  1498. this.$emit('done');
  1499. })
  1500. .catch((e) => {
  1501. //this.loading = false;
  1502. });
  1503. } else {
  1504. addInformation(commitData)
  1505. .then((res) => {
  1506. this.loading = false;
  1507. this.$message.success('新增成功');
  1508. updateRelationStatus([this.form.partbId]);
  1509. if (type === 'sub') {
  1510. this.sub(res);
  1511. return;
  1512. }
  1513. this.cancel();
  1514. this.$emit('done');
  1515. })
  1516. .catch((e) => {
  1517. //this.loading = false;
  1518. });
  1519. }
  1520. } catch (error) {
  1521. console.log(error);
  1522. // 表单验证未通过,不执行保存操作
  1523. }
  1524. },
  1525. async sub(res) {
  1526. const data = await getpurchaseorderDetail(this.businessId || res);
  1527. this.processSubmitDialogFlag = true;
  1528. this.$nextTick(() => {
  1529. let params = {
  1530. businessId: data.id,
  1531. businessKey: 'purchase_order_approve',
  1532. formCreateUserId: data.createUserId,
  1533. variables: {
  1534. businessCode: data.orderNo,
  1535. businessName: data.partaName,
  1536. businessType: data.sourceTypeName
  1537. }
  1538. // callBackMethodType : '1',
  1539. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  1540. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  1541. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  1542. // miniHandle : '',
  1543. // miniView : '',
  1544. };
  1545. this.$refs.processSubmitDialogRef.init(params);
  1546. });
  1547. // submit({
  1548. // businessId: this.businessId || res
  1549. // }).then((res) => {
  1550. // this.cancel();
  1551. // this.$emit('done');
  1552. // });
  1553. },
  1554. reload() {
  1555. this.cancel();
  1556. this.$emit('done');
  1557. },
  1558. cancel() {
  1559. this.$nextTick(() => {
  1560. this.isFlag = false;
  1561. // 关闭后,销毁所有的表单数据
  1562. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  1563. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  1564. this.$store.commit('order/clearUserData');
  1565. this.form = copyObj(this.formDef);
  1566. this.visible = false;
  1567. });
  1568. },
  1569. //查找合同分类对应name
  1570. findNameById(tree, targetId) {
  1571. for (let i = 0; i < tree.length; i++) {
  1572. const node = tree[i];
  1573. if (node.id === targetId) {
  1574. return node.name;
  1575. }
  1576. if (node.children && node.children.length > 0) {
  1577. const name = this.findNameById(node.children, targetId);
  1578. if (name) {
  1579. return name;
  1580. }
  1581. }
  1582. }
  1583. return null;
  1584. }
  1585. }
  1586. };
  1587. </script>
  1588. <style scoped lang="scss">
  1589. .TotalAmount {
  1590. font-size: 16px;
  1591. padding-right: 30px;
  1592. }
  1593. </style>