edit.vue 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281
  1. <template>
  2. <div>
  3. <div
  4. v-if="loading"
  5. v-loading="true"
  6. class="view-window"
  7. element-loading-text="Loading..."
  8. element-loading-background="rgba(0, 0, 0, 0.3)"
  9. ></div>
  10. <div class="flex fixed-button-area">
  11. <!-- <el-button @click="() => generatePDF()">generatePDF</el-button> -->
  12. <el-button
  13. type="info"
  14. @click="formVisible = !formVisible"
  15. >
  16. <el-icon
  17. size="18px"
  18. color="#fff"
  19. >
  20. <Switch />
  21. </el-icon>
  22. &nbsp;{{ formVisible ? 'Preview PDF' : 'Show Form' }}
  23. </el-button>
  24. <el-button
  25. type="primary"
  26. :disabled="!formVisible"
  27. @click="checkForm(mainForm)"
  28. >
  29. <el-icon
  30. size="20px"
  31. color="#fff"
  32. >
  33. <FolderAdd />
  34. </el-icon>
  35. &nbsp;Save & Attach
  36. </el-button>
  37. </div>
  38. <div
  39. v-show="formVisible"
  40. class="screen"
  41. >
  42. <div class="flex justify-between page-title-wrap">
  43. <div class="flex">
  44. <el-icon
  45. size="36px"
  46. :color="variables.mainColor"
  47. >
  48. <ShoppingCart />
  49. </el-icon>
  50. <div class="page-title">New Purchase Order</div>
  51. </div>
  52. </div>
  53. <el-form
  54. ref="mainForm"
  55. :model="form"
  56. :rules="formRule"
  57. label-width="120px"
  58. >
  59. <div class="flex items-start">
  60. <div class="layout-left">
  61. <el-form-item
  62. prop="Order_Type"
  63. label="Order Type"
  64. label-width="130px"
  65. >
  66. <el-radio-group v-model="form.Order_Type">
  67. <el-radio
  68. v-for="(item, index) in orderTypeList"
  69. :key="index"
  70. :label="item.label"
  71. :value="item.label"
  72. >
  73. {{ item.label }}
  74. </el-radio>
  75. </el-radio-group>
  76. </el-form-item>
  77. <el-form-item
  78. label="Artwork Link"
  79. prop="Artwork_Link"
  80. label-width="130px"
  81. >
  82. <el-input
  83. v-model="form.Artwork_Link"
  84. placeholder="Please input"
  85. type="textarea"
  86. :rows="3"
  87. ></el-input>
  88. </el-form-item>
  89. <el-form-item
  90. label="Currency"
  91. label-width="130px"
  92. >
  93. <el-select
  94. v-model="form.Currency"
  95. style="width: 100%"
  96. placeholder="please select currency"
  97. >
  98. <el-option
  99. v-for="(item, index) in currencyList"
  100. :key="index"
  101. :label="item.label"
  102. :value="item.label"
  103. />
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item
  107. v-if="recommandVendor.length"
  108. label="Suggest Supplier"
  109. label-width="130px"
  110. >
  111. <div class="flex flex-col items-start">
  112. <div
  113. v-for="(item, index) in recommandVendor"
  114. :key="index"
  115. class="btn-quick-vendor"
  116. :class="{ active: item.id === form.currentVendor }"
  117. @click="quickSelectSupplier(item)"
  118. >
  119. {{ item.name || '' }}
  120. </div>
  121. </div>
  122. </el-form-item>
  123. </div>
  124. <div class="layout-right flex-auto">
  125. <div style="position: absolute; right: 24px; top: 0">
  126. <el-form-item label="Template:">
  127. <el-select
  128. v-model="currentCompany"
  129. style="width: 150px"
  130. @change="onCompanyTemplateChange"
  131. >
  132. <el-option
  133. v-for="company in computedCompanyList"
  134. :key="company.id"
  135. :value="company.id"
  136. :label="company.label"
  137. ></el-option>
  138. </el-select>
  139. </el-form-item>
  140. </div>
  141. <div class="company-info">
  142. <div class="company-name">{{ computedCompany.name }}</div>
  143. <div class="flex justify-center">
  144. <div class="company-addr">
  145. 地址:&nbsp;{{ computedCompany.addr }}
  146. </div>
  147. <div class="company-phone">
  148. &nbsp;|&nbsp;电话:&nbsp;{{ computedCompany.phone }}
  149. </div>
  150. <div
  151. v-show="computedCompany.fax"
  152. class="company-fax"
  153. >
  154. &nbsp;|&nbsp;传真:&nbsp;{{ computedCompany.fax }}
  155. </div>
  156. </div>
  157. </div>
  158. <div class="pdf-title">采购合同</div>
  159. <div class="pdf-title-bg">
  160. <div class="left"></div>
  161. <div class="right"></div>
  162. </div>
  163. <div class="flex items-start justify-between form-area">
  164. <div class="form-area-left">
  165. <div class="">
  166. <span style="color: #f56c6c">*</span>
  167. 供应商(乙方) :
  168. </div>
  169. <div>{{ computedVendor.Primary_Contact_name }}</div>
  170. <el-form-item
  171. label-width="0"
  172. prop="currentVendor"
  173. >
  174. <el-select
  175. v-model="form.currentVendor"
  176. :remote-method="utils.debounce(getSupplierLists, 1000)"
  177. remote
  178. style="width: 100%"
  179. :loading="vendorLoading"
  180. filterable
  181. clearable
  182. >
  183. <el-option
  184. v-for="option in vendorList"
  185. :key="option.value"
  186. :value="option.value"
  187. :label="option.label"
  188. ></el-option>
  189. </el-select>
  190. </el-form-item>
  191. <div
  192. v-if="typeof computedCompany.taxReimbursement === 'undefined'"
  193. style="white-space: pre-wrap"
  194. >
  195. {{ computedVendor.PDF_display }}
  196. </div>
  197. <div
  198. v-else
  199. style="white-space: pre-wrap"
  200. >
  201. {{ computedVendor.PDF_display2 }}
  202. </div>
  203. </div>
  204. <div class="form-area-right">
  205. <el-form-item label="采购订单 #:">
  206. Generate once PO submitted
  207. </el-form-item>
  208. <el-form-item label="订单号 # :">
  209. <el-input
  210. v-model="form.Reference"
  211. disabled
  212. ></el-input>
  213. </el-form-item>
  214. <el-form-item
  215. label="日期:"
  216. prop="PO_Date"
  217. >
  218. <el-date-picker
  219. v-model="form.PO_Date"
  220. format="YYYY-MM-DD"
  221. value-format="YYYY-MM-DD"
  222. style="width: 100%"
  223. type="date"
  224. ></el-date-picker>
  225. </el-form-item>
  226. <el-form-item label="付款方式 :">
  227. <el-select
  228. v-model="form.Supplier_Payment_Terms"
  229. style="width: 100%"
  230. >
  231. <el-option
  232. v-for="(item, index) in supplierPaymentTermsLists"
  233. :key="index"
  234. :value="item.label"
  235. :label="item.label"
  236. ></el-option>
  237. </el-select>
  238. </el-form-item>
  239. <el-form-item label="参考 :">
  240. <el-input v-model="form.Title"></el-input>
  241. </el-form-item>
  242. <!-- 退税版没有这几项 -->
  243. <template
  244. v-if="typeof computedCompany.taxReimbursement === 'undefined'"
  245. >
  246. <el-form-item label="收货详情 :">
  247. <el-select
  248. v-model="form.field9"
  249. style="width: 100%"
  250. >
  251. <el-option
  252. v-for="(item, index) in addressList"
  253. :key="index"
  254. :value="item.label"
  255. :label="item.label"
  256. ></el-option>
  257. </el-select>
  258. </el-form-item>
  259. <el-form-item
  260. label="收件人 :"
  261. prop="field7"
  262. >
  263. <el-input v-model="form.field7"></el-input>
  264. </el-form-item>
  265. <el-form-item
  266. label="联系电话 :"
  267. prop="field8"
  268. >
  269. <el-input v-model="form.field8"></el-input>
  270. </el-form-item>
  271. </template>
  272. <el-form-item
  273. label="工厂交货日期 :"
  274. prop="field6"
  275. >
  276. <el-date-picker
  277. v-model="form.field6"
  278. style="width: 100%"
  279. format="YYYY-MM-DD"
  280. value-format="YYYY-MM-DD"
  281. ></el-date-picker>
  282. </el-form-item>
  283. <el-form-item label="送货备注 :">
  284. <el-input v-model="form.Delivery_Details"></el-input>
  285. </el-form-item>
  286. </div>
  287. </div>
  288. <div class="product-table-separator"></div>
  289. <div class="product-table">
  290. <table
  291. border="0"
  292. cellspacing="0"
  293. >
  294. <tr>
  295. <th class="product">品名</th>
  296. <th class="quantity">数量</th>
  297. <th class="rate">价格&nbsp;({{ currentCurrency.label }})</th>
  298. <th class="requirement">中文品目|要求</th>
  299. <th class="amount">金额</th>
  300. <th class="discount">折扣</th>
  301. <th class="warehouse">Warehouse</th>
  302. <th class="action">操作</th>
  303. </tr>
  304. <tr
  305. v-for="(product, index) in form.productList"
  306. :key="index"
  307. >
  308. <td class="product">
  309. <el-form-item
  310. label-width="0"
  311. :prop="'productList.' + index + '.id'"
  312. :rules="{
  313. required: true,
  314. message: '必填项',
  315. trigger: ['blur', 'change'],
  316. }"
  317. >
  318. <el-select-v2
  319. v-model="product.id"
  320. popper-class="product-select"
  321. style="width: 100%; margin-bottom: 4pt"
  322. :options="product.candidate"
  323. :loading="productLoading"
  324. :remote-method="
  325. (e: string) => getProductList(e, product)
  326. "
  327. remote
  328. filterable
  329. clearable
  330. @change="(e) => onProductSelect(e, product)"
  331. ></el-select-v2>
  332. </el-form-item>
  333. <el-input
  334. v-if="userInfo.Organization !== 'PrimePac'"
  335. v-model="product.desc"
  336. type="textarea"
  337. placeholder="Free text"
  338. ></el-input>
  339. </td>
  340. <td class="quantity">
  341. <el-form-item
  342. label-width="0"
  343. :prop="'productList.' + index + '.quantity'"
  344. :rules="{
  345. required: true,
  346. message: '必填项',
  347. trigger: ['blur', 'change'],
  348. }"
  349. >
  350. <el-input
  351. v-model="product.quantity"
  352. type="number"
  353. min="1"
  354. @change="(e) => onInputChange(e, product, 'quantity')"
  355. ></el-input>
  356. </el-form-item>
  357. </td>
  358. <td class="rate">
  359. <el-form-item
  360. label-width="0"
  361. :prop="'productList.' + index + '.rate'"
  362. :rules="{
  363. required: true,
  364. message: '必填项',
  365. trigger: ['blur', 'change'],
  366. }"
  367. >
  368. <el-input
  369. v-model="product.rate"
  370. type="number"
  371. @change="(e) => onInputChange(e, product, 'rate')"
  372. ></el-input>
  373. </el-form-item>
  374. </td>
  375. <td class="requirement">
  376. <el-input
  377. v-model="product.requirement"
  378. :rows="userInfo.Organization !== 'PrimePac' ? 4 : 5"
  379. type="textarea"
  380. placeholder="Free text"
  381. ></el-input>
  382. </td>
  383. <td class="amount">
  384. <el-input
  385. v-model="product.amount"
  386. type="number"
  387. disabled
  388. ></el-input>
  389. </td>
  390. <td class="discount">
  391. <el-input
  392. v-model="product.discount"
  393. type="number"
  394. @change="(e) => onInputChange(e, product, 'discount')"
  395. ></el-input>
  396. </td>
  397. <td class="">
  398. <el-form-item
  399. label-width="0"
  400. :prop="'productList.' + index + '.Warehouse'"
  401. :rules="{
  402. required: product.CF_Product_Type === 'Stock',
  403. message: '必填项',
  404. trigger: ['blur', 'change'],
  405. }"
  406. >
  407. <el-select
  408. v-model="product.Warehouse"
  409. clearable
  410. >
  411. <el-option
  412. v-for="v in warehouseList"
  413. :key="v"
  414. :label="v"
  415. :value="v"
  416. ></el-option>
  417. </el-select>
  418. </el-form-item>
  419. </td>
  420. <td class="action">
  421. <el-button
  422. size="small"
  423. type="danger"
  424. plain
  425. @click="form.productList.splice(index, 1)"
  426. >
  427. Delete
  428. </el-button>
  429. </td>
  430. </tr>
  431. </table>
  432. </div>
  433. <div>
  434. <el-button
  435. type="primary"
  436. size="small"
  437. plain
  438. @click="addRow"
  439. >
  440. Add Row
  441. </el-button>
  442. </div>
  443. <div class="flex justify-end">
  444. <div class="product-total-table">
  445. <div class="total-item">
  446. <div class="label">Sub Total</div>
  447. <div class="value">{{ toFixed(subTotal, 2) }}</div>
  448. </div>
  449. <div class="total-item">
  450. <div class="label">Total Discount</div>
  451. <div class="value">
  452. {{ toFixed(totalDiscount, 2) }}
  453. </div>
  454. </div>
  455. <div class="total-item">
  456. <div class="label">Adjustment</div>
  457. <div class="value">
  458. <el-input
  459. v-model="adjustment"
  460. style="width: 100%"
  461. type="number"
  462. ></el-input>
  463. </div>
  464. </div>
  465. <div class="total-item">
  466. <div class="label">Grand Total</div>
  467. <div class="value">
  468. {{ toFixed(grandTotal, 2) }}
  469. </div>
  470. </div>
  471. </div>
  472. </div>
  473. <div
  474. v-if="userInfo.Organization !== 'PrimePac'"
  475. class="note-form-area"
  476. >
  477. <div class="sub-form-title">注意事项:</div>
  478. <el-form-item label="印刷质量:">
  479. <el-input
  480. v-model="form.field12"
  481. type="textarea"
  482. :rows="3"
  483. ></el-input>
  484. </el-form-item>
  485. <el-form-item label="产品质量:">
  486. <el-input
  487. v-model="form.field13"
  488. type="textarea"
  489. :rows="3"
  490. ></el-input>
  491. </el-form-item>
  492. <el-form-item label="质量承诺:">
  493. <el-input
  494. v-model="form.field10"
  495. type="textarea"
  496. :rows="3"
  497. ></el-input>
  498. </el-form-item>
  499. <el-form-item label="箱子箱唛:">
  500. <el-input
  501. v-model="form.field11"
  502. type="textarea"
  503. :rows="3"
  504. ></el-input>
  505. </el-form-item>
  506. </div>
  507. <div class="sub-form-title">服务条款</div>
  508. <template v-if="currentCompany === 'PangeaTaxReimbursement'">
  509. <div class="rule-item flex">
  510. 一、合同价为含税价,税率为:
  511. <span style="color: #f56c6c">*</span>
  512. <el-form-item
  513. label-width="10"
  514. prop="field4"
  515. :rules="{
  516. required: true,
  517. message: '必填项',
  518. trigger: ['blur', 'change'],
  519. }"
  520. >
  521. <el-input
  522. v-model="form.field4"
  523. size="small"
  524. style="width: 120px"
  525. >
  526. <template #append>%</template>
  527. </el-input>
  528. </el-form-item>
  529. </div>
  530. <div class="rule-item flex">
  531. 二、运费条款:
  532. <span style="color: #f56c6c">*</span>
  533. <el-form-item label-width="10">
  534. <el-select
  535. v-model="form.field5"
  536. size="small"
  537. style="width: 110px"
  538. >
  539. <el-option
  540. v-for="(item, index) in field5_lists"
  541. :key="index"
  542. :label="item.label"
  543. :value="item.label"
  544. ></el-option>
  545. </el-select>
  546. </el-form-item>
  547. </div>
  548. </template>
  549. <template
  550. v-if="['PrimePacCommon', 'PrimePacSoft'].includes(currentCompany)"
  551. >
  552. <div class="rule-item">
  553. 一、本采购订单签署原件一式两份,双方各持一份。经双方代表签字或盖章即可生效,并具有同等法律效力。
  554. </div>
  555. <div class="rule-item flex nowrap">
  556. 二、以上价格已含所有产品的制作费、包装费;由
  557. <div class="attention flex nowrap">
  558. <span style="color: #f56c6c">*</span>
  559. <el-form-item label-width="10">
  560. <el-select
  561. v-model="form.field5"
  562. size="small"
  563. style="width: 110px"
  564. >
  565. <el-option
  566. v-for="(item, index) in field5_lists"
  567. :key="index"
  568. :label="item.label"
  569. :value="item.label"
  570. ></el-option>
  571. </el-select>
  572. </el-form-item>
  573. </div>
  574. 运费送货到广州甲方指定的卸货地点,不含税,运费届时实报实销。
  575. </div>
  576. <div class="rule-item">
  577. 三、印刷及工艺要求:乙方需按照甲方图稿或指定样品进行生产,颜色对照潘通色卡或指定样品。
  578. </div>
  579. <div class="rule-item">
  580. 四、付款形式:
  581. <span class="attention">{{ form.Supplier_Payment_Terms }}</span>
  582. 。甲方在乙方完成大货时,先寄大货样品给乙方确认,确认后付清剩余尾款。甲方通过银行转帐的方式付款,乙方账户信息如上。
  583. </div>
  584. <div class="rule-item">
  585. 五、出货标准:五层出口空白硬纸箱,箱内套防潮袋。如实际出货包装与合约要求不符,甲方有权拒收整批货物。
  586. </div>
  587. <div class="rule-item">
  588. 六、订货时间:自合同成立,甲方支付定金并确认图稿后算起。
  589. </div>
  590. <div class="rule-item">
  591. 七、交货期限:自确认图稿时间算起,乙方应于
  592. <span class="attention">{{ form.field6 }}</span>
  593. 前生产好产品,甲方确认并支付剩余款项后,乙方在约定时间内安排发出剩余产品到甲方收货地址。
  594. </div>
  595. </template>
  596. <div
  597. v-for="(item, index) in currentServiceRule"
  598. :key="index"
  599. class="rule-item"
  600. :class="[{ sub: typeof item === 'object' }]"
  601. v-html="typeof item === 'object' ? item.value : item"
  602. ></div>
  603. <template
  604. v-if="['PrimePacCommon', 'PrimePacSoft'].includes(currentCompany)"
  605. >
  606. <div class="sub-form-title">附录</div>
  607. <div
  608. v-for="(item, index) in appendixData"
  609. :key="index"
  610. class="rule-item"
  611. :class="[{ sub: typeof item === 'object' }]"
  612. v-html="typeof item === 'object' ? item.value : item"
  613. ></div>
  614. </template>
  615. <div
  616. v-if="currentCompany === 'PrimePacCommon'"
  617. class="flex items-stretch PrimePac-table"
  618. >
  619. <div class="flex flex-col items-stretch">
  620. <div class="column-item flex justify-center">制作要求</div>
  621. <div class="flex-auto column-item flex justify-center">
  622. 产品外观要求
  623. </div>
  624. </div>
  625. <div class="flex-auto flex flex-col items-stretch">
  626. <div
  627. v-for="(item, index) in PrimePacCommonRuleTableData"
  628. :key="index"
  629. class="flex items-stretch flex-auto"
  630. >
  631. <div class="column-item flex justify-center">
  632. {{ item.project }}
  633. </div>
  634. <div class="column-item flex-auto flex justify-center">
  635. {{ item.method }}
  636. </div>
  637. </div>
  638. </div>
  639. </div>
  640. <div
  641. v-if="currentCompany === 'PrimePacSoft'"
  642. class="flex flex-col items-stretch PrimePac-table"
  643. >
  644. <div class="flex items-stretch">
  645. <div class="flex flex-col items-stretch">
  646. <div class="column-item flex-auto flex justify-center">
  647. 制作要求
  648. </div>
  649. </div>
  650. <div class="flex-auto flex flex-col items-stretch">
  651. <div
  652. v-for="(item, index) in PrimePacSoftRuleTableData1"
  653. :key="index"
  654. class="flex items-stretch flex-auto"
  655. >
  656. <div class="column-item flex justify-center">
  657. {{ item.project }}
  658. </div>
  659. <div class="column-item flex-auto flex justify-center">
  660. {{ item.method }}
  661. </div>
  662. </div>
  663. </div>
  664. </div>
  665. <div class="flex items-stretch">
  666. <div class="flex flex-col items-stretch">
  667. <div class="column-item flex-auto flex justify-center">
  668. 产品技术要求
  669. </div>
  670. </div>
  671. <div class="flex-auto flex flex-col items-stretch">
  672. <div
  673. v-for="(item, index) in PrimePacSoftRuleTableData2"
  674. :key="index"
  675. class="flex items-stretch flex-auto"
  676. >
  677. <div class="column-item flex justify-center">
  678. {{ item.project }}
  679. </div>
  680. <div class="column-item flex-auto flex justify-center">
  681. {{ item.method }}
  682. </div>
  683. </div>
  684. </div>
  685. </div>
  686. </div>
  687. </div>
  688. </div>
  689. </el-form>
  690. <br />
  691. </div>
  692. <div
  693. class="print"
  694. :class="{ hidden: formVisible && !loading }"
  695. >
  696. <div class="pdf-wrap">
  697. <div
  698. id="pdfElement"
  699. ref="pdfElement"
  700. class="preview-area"
  701. >
  702. <div class="company-info">
  703. <div class="company-name">{{ computedCompany.name }}</div>
  704. <div class="flex justify-center">
  705. <div class="company-addr">
  706. 地址:&nbsp;{{ computedCompany.addr }}
  707. </div>
  708. <div class="company-phone">
  709. &nbsp;|&nbsp;电话:&nbsp;{{ computedCompany.phone }}
  710. </div>
  711. <div
  712. v-show="computedCompany.fax"
  713. class="company-fax"
  714. >
  715. &nbsp;|&nbsp;传真:&nbsp;{{ computedCompany.fax }}
  716. </div>
  717. </div>
  718. </div>
  719. <div>
  720. <table class="pdf-title-bg">
  721. <tr>
  722. <td class="left">
  723. <div>&nbsp;</div>
  724. </td>
  725. <td class="center">
  726. <div class="pdf-title">采购合同</div>
  727. </td>
  728. <td class="right">
  729. <div>&nbsp;</div>
  730. </td>
  731. </tr>
  732. </table>
  733. </div>
  734. <div class="form-area flex items-start">
  735. <div class="flex-auto">
  736. <div>供应商(乙方) :</div>
  737. <div
  738. v-if="computedVendor.Primary_Contact_name"
  739. class="column-vendor"
  740. >
  741. {{ computedVendor.Primary_Contact_name }}
  742. </div>
  743. <div class="column-vendor">
  744. {{ computedVendor.label }}
  745. </div>
  746. <div
  747. v-if="typeof computedCompany.taxReimbursement === 'undefined'"
  748. class="column-vendor"
  749. >
  750. {{ computedVendor.PDF_display }}
  751. </div>
  752. <div
  753. v-else
  754. class="column-vendor"
  755. >
  756. {{ computedVendor.PDF_display2 }}
  757. </div>
  758. </div>
  759. <div class="flex-auto">
  760. <div class="flex">
  761. <div class="column-form-label">采购订单 #:</div>
  762. <div class="column-form-value">
  763. {{ longPONumber || '' }}
  764. </div>
  765. </div>
  766. <div class="flex">
  767. <div class="column-form-label">订单号 # :</div>
  768. <div class="column-form-value">
  769. {{ form.Reference }}
  770. </div>
  771. </div>
  772. <div class="flex">
  773. <div class="column-form-label">日期 :</div>
  774. <div class="column-form-value">
  775. {{ form.PO_Date }}
  776. </div>
  777. </div>
  778. <div class="flex">
  779. <div class="column-form-label">付款方式 :</div>
  780. <div class="column-form-value">
  781. {{
  782. form.Supplier_Payment_Terms !== '-None-'
  783. ? form.Supplier_Payment_Terms
  784. : ''
  785. }}
  786. </div>
  787. </div>
  788. <div class="flex items-start">
  789. <div class="column-form-label">参考 :</div>
  790. <div class="column-form-value">
  791. {{ form.Title }}
  792. </div>
  793. </div>
  794. <template
  795. v-if="typeof computedCompany.taxReimbursement === 'undefined'"
  796. >
  797. <div class="flex items-start">
  798. <div class="column-form-label">收货详情 :</div>
  799. <div class="column-form-value">
  800. {{ form.field9 }}
  801. </div>
  802. </div>
  803. <div class="flex">
  804. <div class="column-form-label">收件人 :</div>
  805. <div class="column-form-value">
  806. {{ form.field7 }}
  807. </div>
  808. </div>
  809. <div class="flex">
  810. <div class="column-form-label">联系电话 :</div>
  811. <div class="column-form-value">
  812. {{ form.field8 }}
  813. </div>
  814. </div>
  815. </template>
  816. <div class="flex">
  817. <div class="column-form-label">工厂交货日期 :</div>
  818. <div class="column-form-value">
  819. {{ form.field6 }}
  820. </div>
  821. </div>
  822. <div class="flex">
  823. <div class="column-form-label">送货备注 :</div>
  824. <div class="column-form-value">
  825. {{ form.Delivery_Details }}
  826. </div>
  827. </div>
  828. </div>
  829. </div>
  830. <div class="product-table-separator"></div>
  831. <div class="product-table">
  832. <table
  833. border="0"
  834. cellspacing="0"
  835. >
  836. <tr>
  837. <th class="row-index">#</th>
  838. <th>品名</th>
  839. <th v-if="userInfo.Organization !== 'PrimePac'">
  840. 中文品目|要求
  841. </th>
  842. <th>数量</th>
  843. <th>价格&nbsp;({{ currentCurrency.label }})</th>
  844. <th>金额</th>
  845. </tr>
  846. <tr
  847. v-for="(product, index) in form.productList"
  848. :key="index"
  849. >
  850. <td class="row-index">{{ index + 1 }}.</td>
  851. <td>
  852. <div class="product-name">{{ product.name }}</div>
  853. <div
  854. v-if="userInfo.Organization !== 'PrimePac'"
  855. class="desc"
  856. >
  857. {{ product.desc }}
  858. </div>
  859. <div
  860. v-else
  861. class="desc"
  862. >
  863. {{ product.requirement }}
  864. </div>
  865. </td>
  866. <td v-if="userInfo.Organization !== 'PrimePac'">
  867. {{ product.requirement }}
  868. </td>
  869. <td>
  870. {{ product.quantity }}
  871. </td>
  872. <td>
  873. {{ currentCurrency.country
  874. }}{{ currentCurrency.symbol }}&nbsp;{{
  875. toFixed(Number(product.rate), computedDeci)
  876. }}
  877. </td>
  878. <td>
  879. {{ currentCurrency.country
  880. }}{{ currentCurrency.symbol }}&nbsp;{{
  881. toFixed(Number(product.amount), computedDeci)
  882. }}
  883. </td>
  884. </tr>
  885. </table>
  886. </div>
  887. <!-- <br /> -->
  888. <div class="flex justify-between items-start">
  889. <div
  890. v-if="userInfo.Organization !== 'PrimePac'"
  891. class="note-form-area"
  892. >
  893. <div class="sub-form-title">注意事项:</div>
  894. <div class="">
  895. <div class="label">印刷质量:</div>
  896. <div class="value">{{ form.field12 }}</div>
  897. </div>
  898. <div class="">
  899. <div class="label">产品质量:</div>
  900. <div class="value">{{ form.field13 }}</div>
  901. </div>
  902. <div class="">
  903. <div class="label">质量承诺:</div>
  904. <div class="value">{{ form.field10 }}</div>
  905. </div>
  906. <div class="">
  907. <div class="label">箱子箱唛:</div>
  908. <div class="value">{{ form.field11 }}</div>
  909. </div>
  910. </div>
  911. <div v-else></div>
  912. <div class="product-total-table">
  913. <div class="total-item flex">
  914. <div class="label">小计&nbsp;</div>
  915. <div class="value">
  916. {{ currentCurrency.country
  917. }}{{ currentCurrency.symbol }}&nbsp;{{
  918. toFixed(subTotal, computedDeci)
  919. }}
  920. </div>
  921. </div>
  922. <div class="total-item flex">
  923. <div class="label">合计&nbsp;</div>
  924. <div class="value">
  925. {{ currentCurrency.country
  926. }}{{ currentCurrency.symbol }}&nbsp;{{
  927. toFixed(grandTotal, computedDeci)
  928. }}
  929. </div>
  930. </div>
  931. </div>
  932. </div>
  933. <br />
  934. <div class="sub-form-title">服务条款</div>
  935. <template v-if="currentCompany === 'PangeaTaxReimbursement'">
  936. <div class="rule-item">
  937. 一、合同价为含税价,税率为: {{ form.field4 }} %
  938. </div>
  939. <div class="rule-item">二、运费条款: {{ form.field5 }}</div>
  940. </template>
  941. <template
  942. v-if="['PrimePacCommon', 'PrimePacSoft'].includes(currentCompany)"
  943. >
  944. <div class="rule-item">
  945. 一、本采购订单签署原件一式两份,双方各持一份。经双方代表签字或盖章即可生效,并具有同等法律效力。
  946. </div>
  947. <div class="rule-item flex nowrap">
  948. 二、以上价格已含所有产品的制作费、包装费;由
  949. <span class="attention">{{ form.field5 }}</span>
  950. 运费送货到广州甲方指定的卸货地点,不含税,运费届时实报实销。
  951. </div>
  952. <div class="rule-item">
  953. 三、印刷及工艺要求:乙方需按照甲方图稿或指定样品进行生产,颜色对照潘通色卡或指定样品。
  954. </div>
  955. <div class="rule-item">
  956. 四、付款形式:
  957. <span class="attention">{{ form.Supplier_Payment_Terms }}</span>
  958. 。甲方在乙方完成大货时,先寄大货样品给乙方确认,确认后付清剩余尾款。甲方通过银行转帐的方式付款,乙方账户信息如上。
  959. </div>
  960. <div class="rule-item">
  961. 五、出货标准:五层出口空白硬纸箱,箱内套防潮袋。如实际出货包装与合约要求不符,甲方有权拒收整批货物。
  962. </div>
  963. <div class="rule-item">
  964. 六、订货时间:自合同成立,甲方支付定金并确认图稿后算起。
  965. </div>
  966. <div class="rule-item">
  967. 七、交货期限:自确认图稿时间算起,乙方应于
  968. <span class="attention">{{ form.field6 }}</span>
  969. 前生产好产品,甲方确认并支付剩余款项后,乙方在约定时间内安排发出剩余产品到甲方收货地址。
  970. </div>
  971. </template>
  972. <div
  973. v-for="(item, index) in currentServiceRule"
  974. :key="index"
  975. class="rule-item"
  976. :class="[{ sub: typeof item === 'object' }]"
  977. v-html="typeof item === 'object' ? item.value : item"
  978. ></div>
  979. <template
  980. v-if="['PrimePacCommon', 'PrimePacSoft'].includes(currentCompany)"
  981. >
  982. <div class="sub-form-title">附录</div>
  983. <div
  984. v-for="(item, index) in appendixData"
  985. :key="index"
  986. class="rule-item"
  987. :class="[{ sub: typeof item === 'object' }]"
  988. v-html="typeof item === 'object' ? item.value : item"
  989. ></div>
  990. </template>
  991. <div
  992. v-if="currentCompany === 'PrimePacCommon'"
  993. class="flex items-stretch PrimePac-table"
  994. >
  995. <div class="flex flex-col items-stretch">
  996. <div class="column-item flex justify-center">制作要求</div>
  997. <div class="flex-auto column-item flex justify-center">
  998. 产品外观要求
  999. </div>
  1000. </div>
  1001. <div class="flex-auto flex flex-col items-stretch">
  1002. <div
  1003. v-for="(item, index) in PrimePacCommonRuleTableData"
  1004. :key="index"
  1005. class="flex items-stretch flex-auto"
  1006. >
  1007. <div class="column-item flex justify-center">
  1008. {{ item.project }}
  1009. </div>
  1010. <div class="column-item flex-auto flex justify-center">
  1011. {{ item.method }}
  1012. </div>
  1013. </div>
  1014. </div>
  1015. </div>
  1016. <div
  1017. v-if="currentCompany === 'PrimePacSoft'"
  1018. class="flex flex-col items-stretch PrimePac-table"
  1019. >
  1020. <div class="flex items-stretch">
  1021. <div class="flex flex-col items-stretch">
  1022. <div class="column-item flex-auto flex justify-center">
  1023. 制作要求
  1024. </div>
  1025. </div>
  1026. <div class="flex-auto flex flex-col items-stretch">
  1027. <div
  1028. v-for="(item, index) in PrimePacSoftRuleTableData1"
  1029. :key="index"
  1030. class="flex items-stretch flex-auto"
  1031. >
  1032. <div class="column-item flex justify-center">
  1033. {{ item.project }}
  1034. </div>
  1035. <div class="column-item flex-auto flex justify-center">
  1036. {{ item.method }}
  1037. </div>
  1038. </div>
  1039. </div>
  1040. </div>
  1041. <div class="flex items-stretch">
  1042. <div class="flex flex-col items-stretch">
  1043. <div class="column-item flex-auto flex justify-center">
  1044. 产品技术要求
  1045. </div>
  1046. </div>
  1047. <div class="flex-auto flex flex-col items-stretch">
  1048. <div
  1049. v-for="(item, index) in PrimePacSoftRuleTableData2"
  1050. :key="index"
  1051. class="flex items-stretch flex-auto"
  1052. >
  1053. <div class="column-item flex justify-center">
  1054. {{ item.project }}
  1055. </div>
  1056. <div class="column-item flex-auto flex justify-center">
  1057. {{ item.method }}
  1058. </div>
  1059. </div>
  1060. </div>
  1061. </div>
  1062. </div>
  1063. <br />
  1064. <div class="signature-area">
  1065. <div class="company-seal"></div>
  1066. <div
  1067. style="align-items: flex-end"
  1068. :class="{
  1069. flex: ['PrimePacCommon', 'PrimePacSoft'].includes(
  1070. currentCompany,
  1071. ),
  1072. between: ['PrimePacCommon', 'PrimePacSoft'].includes(
  1073. currentCompany,
  1074. ),
  1075. }"
  1076. >
  1077. <div class="first-party">
  1078. <div
  1079. class="flex"
  1080. style="align-items: flex-end"
  1081. >
  1082. <div v-show="!computedCompany.label.includes('Pangea')">
  1083. 甲方(盖章):
  1084. </div>
  1085. <div
  1086. class="sign-wrap"
  1087. :class="{
  1088. pangea: computedCompany.label.includes('Pangea'),
  1089. }"
  1090. >
  1091. <img
  1092. v-if="computedCompany.signPath"
  1093. :src="computedCompany.signPath"
  1094. />
  1095. </div>
  1096. </div>
  1097. <div class="">代表人: {{ userInfo.full_name }}</div>
  1098. <div class="">日期: {{ form.PO_Date }}</div>
  1099. </div>
  1100. <div class="second-party">
  1101. <div class="">乙方(盖章):</div>
  1102. </div>
  1103. </div>
  1104. </div>
  1105. </div>
  1106. </div>
  1107. <div
  1108. v-if="computedCompany.taxReimbursement && false"
  1109. class="pdf-wrap"
  1110. >
  1111. <div
  1112. ref="pdfElement2"
  1113. class="preview-area2"
  1114. >
  1115. <div class="supplier-name">
  1116. {{ computedVendor.Suppliers_Name || computedVendor.Vendor_Name }}
  1117. </div>
  1118. <div class="billing-addr">
  1119. {{ computedVendor.Billing_Address || '' }}
  1120. </div>
  1121. <div class="flex justify-around contact-info">
  1122. <div class="flex">
  1123. <div>Tel No.:</div>
  1124. <div>&nbsp;{{ computedVendor.Phone }}</div>
  1125. </div>
  1126. <div class="flex justify-center">
  1127. <div>E-mail:</div>
  1128. <div class="">&nbsp;{{ computedVendor.Email }}</div>
  1129. </div>
  1130. </div>
  1131. <div class="base-info-area">
  1132. <div class="flex">
  1133. <div class="flex items-start left">
  1134. <div class="base-info-label">TO:</div>
  1135. <div
  1136. v-if="currentCompany === 'AZYTaxReimbursement'"
  1137. class="base-info-value"
  1138. >
  1139. Azy Trading Pty Ltd
  1140. </div>
  1141. <div
  1142. v-else-if="currentCompany === 'FOTTaxReimbursement'"
  1143. class="base-info-value"
  1144. >
  1145. Fair Ocean Trading Australia Pty Ltd
  1146. </div>
  1147. </div>
  1148. <div class="right flex">
  1149. <div class="base-info-label">Date:</div>
  1150. <div class="base-info-value">{{ form.PO_Date }}</div>
  1151. </div>
  1152. </div>
  1153. <div class="flex items-start">
  1154. <div class="left flex items-start">
  1155. <div class="base-info-label">ADD:</div>
  1156. <div>
  1157. <div
  1158. v-if="currentCompany === 'AZYTaxReimbursement'"
  1159. class="base-info-value"
  1160. >
  1161. UNIT 12,21/F WAYSON COMM BLDG NO 28 CONNAUGHT RD WEST SHEUNG
  1162. WAN, HK
  1163. </div>
  1164. <div
  1165. v-else-if="currentCompany === 'FOTTaxReimbursement'"
  1166. class="base-info-value"
  1167. >
  1168. 15/10 Chilvers Road, Thornleigh, NSW 2120
  1169. </div>
  1170. </div>
  1171. </div>
  1172. <div class="right flex">
  1173. <div class="base-info-label">P/I. NO.</div>
  1174. <div class="base-info-value">{{ longPONumber }}</div>
  1175. </div>
  1176. </div>
  1177. <div class="flex items-start">
  1178. <div class="left flex">
  1179. <div class="base-info-label">ATTN:</div>
  1180. <div class="base-info-value">Accounts</div>
  1181. </div>
  1182. <div class="right flex">
  1183. <div class="base-info-label">Reference:</div>
  1184. <div class="base-info-value">{{ PONumber }}</div>
  1185. </div>
  1186. </div>
  1187. <div class="flex items-start">
  1188. <div class="flex left">
  1189. <template v-if="currentCompany === 'FOTTaxReimbursement'">
  1190. <div class="base-info-label">TEL NO:</div>
  1191. <div class="base-info-value">02 9008 1322</div>
  1192. </template>
  1193. <div v-else></div>
  1194. </div>
  1195. <div class="right flex">
  1196. <div class="base-info-label">Payment Term:</div>
  1197. <div class="base-info-value">
  1198. {{ computedVendor.Supplier_Payment_Terms }}
  1199. </div>
  1200. </div>
  1201. </div>
  1202. </div>
  1203. <div class="table-title">PROFORMA INVOICE</div>
  1204. <div class="product-table">
  1205. <table cellspacing="0">
  1206. <tr>
  1207. <th>ITEM</th>
  1208. <th>DESCRIPTION</th>
  1209. <th>QTY(pcs)</th>
  1210. <th>UNIT PRICE</th>
  1211. <th>TOPTAL VALUE</th>
  1212. </tr>
  1213. <tr
  1214. v-for="(product, index) in form.productList"
  1215. :key="index"
  1216. >
  1217. <td>
  1218. <div>{{ product.name }}</div>
  1219. </td>
  1220. <td>
  1221. <div class="desc">{{ product.desc }}</div>
  1222. </td>
  1223. <td>
  1224. {{ product.quantity }}
  1225. </td>
  1226. <td>
  1227. {{ currentCurrency.country
  1228. }}{{ currentCurrency.symbol }}&nbsp;{{
  1229. toFixed(Number(product.rate), computedDeci)
  1230. }}
  1231. </td>
  1232. <td>
  1233. {{ currentCurrency.country
  1234. }}{{ currentCurrency.symbol }}&nbsp;{{
  1235. toFixed(Number(product.amount), computedDeci)
  1236. }}
  1237. </td>
  1238. </tr>
  1239. </table>
  1240. <div class="flex justify-end">
  1241. <div
  1242. class="flex"
  1243. style="margin-top: 10pt"
  1244. >
  1245. <div style="margin: 0 100pt 0 0">TOTAL</div>
  1246. <div>
  1247. {{ currentCurrency.country
  1248. }}{{ currentCurrency.symbol }}&nbsp;{{ subTotal }}
  1249. </div>
  1250. </div>
  1251. </div>
  1252. </div>
  1253. <br />
  1254. <div class="bank-info-area">
  1255. <div class="flex">
  1256. <div>Bank Information</div>
  1257. <div></div>
  1258. </div>
  1259. <div class="flex">
  1260. <div class="bank-info-label">Beneficiary:</div>
  1261. <div class="bank-info-value">
  1262. {{ computedVendor.Suppliers_Name }}dd
  1263. </div>
  1264. </div>
  1265. <div class="flex">
  1266. <div class="bank-info-label">Bank:</div>
  1267. <div class="bank-info-value">
  1268. {{ computedVendor.Bank_Branch_Name }}
  1269. </div>
  1270. </div>
  1271. <div class="flex">
  1272. <div class="bank-info-label">Bank Add:</div>
  1273. <div class="bank-info-value">{{}}</div>
  1274. </div>
  1275. <div class="flex">
  1276. <div class="bank-info-label">A/C No.:</div>
  1277. <div class="bank-info-value">
  1278. {{ computedVendor.Bank_Account }}
  1279. </div>
  1280. </div>
  1281. <div class="flex">
  1282. <div class="bank-info-label">Bank Code:</div>
  1283. <div class="bank-info-value">{{}}</div>
  1284. </div>
  1285. <div class="flex">
  1286. <div class="bank-info-label">SWIFT CODE:</div>
  1287. <div class="bank-info-value">
  1288. {{ computedVendor.Swift_Code_IBAN }}
  1289. </div>
  1290. </div>
  1291. <div class="flex">
  1292. <div class="bank-info-label">Add:</div>
  1293. <div class="bank-info-value">{{}}</div>
  1294. </div>
  1295. </div>
  1296. <br />
  1297. <div class="flex justify-between items-start">
  1298. <div class="">
  1299. <div class="">BUYERS' SIGNATURE</div>
  1300. <div class="sign-wrap">
  1301. <img
  1302. v-if="computedCompany.signPath"
  1303. :src="computedCompany.signPath"
  1304. />
  1305. </div>
  1306. </div>
  1307. <div class="">
  1308. <div class="">SELLER'S SIGNATURE</div>
  1309. </div>
  1310. </div>
  1311. </div>
  1312. </div>
  1313. </div>
  1314. </div>
  1315. </template>
  1316. <script lang="ts" setup>
  1317. import { computed, defineComponent, ref, unref, watch } from 'vue'
  1318. import { useRoute } from 'vue-router'
  1319. import {
  1320. ElButton,
  1321. ElSelectV2,
  1322. ElSelect,
  1323. ElOption,
  1324. ElIcon,
  1325. ElInput,
  1326. ElForm,
  1327. ElFormItem,
  1328. ElDatePicker,
  1329. ElMessage,
  1330. ElNotification,
  1331. ElRadioGroup,
  1332. ElRadio,
  1333. ElMessageBox,
  1334. } from 'element-plus'
  1335. import type { FormInstance } from 'element-plus'
  1336. import { ShoppingCart, FolderAdd, Switch } from '@element-plus/icons-vue'
  1337. import request from '@/utils/axios'
  1338. import dayjs from 'dayjs'
  1339. import jspdf from 'jspdf'
  1340. import html2canvas from 'html2canvas'
  1341. import utils from '@/utils/index'
  1342. import variables from '@/assets/css/var.module.scss'
  1343. import {
  1344. ServiceTypeKeyEnum,
  1345. ISelectItem,
  1346. IProductItem,
  1347. IUser,
  1348. IVendorItem,
  1349. IRecommandVendor,
  1350. IForm,
  1351. } from '@/interface'
  1352. import {
  1353. currencyList,
  1354. orderTypeList,
  1355. formRule,
  1356. emptyProductItem,
  1357. PrimePacList,
  1358. companyList,
  1359. serviceRule,
  1360. appendixData,
  1361. warehouseList,
  1362. productBlackList,
  1363. PrimePacSoftRuleTableData2,
  1364. PrimePacSoftRuleTableData1,
  1365. PrimePacCommonRuleTableData,
  1366. } from './const'
  1367. defineComponent({
  1368. name: 'PurchaseOrderEdit',
  1369. })
  1370. computed(() => {
  1371. return variables
  1372. })
  1373. const formVisible = ref(true)
  1374. const loading = ref(false)
  1375. // 订单ID. 例如 5757019000000683001, 不是串号.
  1376. const POID = ref('')
  1377. // po 串号. 例如 PO2025
  1378. const PONumber = ref('')
  1379. // po 长串号. 例如 ZCPO2025
  1380. const longPONumber = ref('')
  1381. const mainForm = ref<FormInstance>()
  1382. const checkForm = function (formEl: FormInstance | undefined) {
  1383. if (!formEl) return
  1384. formEl.validate((valid, fields) => {
  1385. if (valid) {
  1386. submit()
  1387. } else {
  1388. console.log('check form has not pass!', fields)
  1389. ElMessage.error('请检查表单必填项')
  1390. }
  1391. })
  1392. }
  1393. const submit = () => {
  1394. loading.value = true
  1395. createPurchaseOrders()
  1396. .then(() => {
  1397. // console.log(res)
  1398. getPurchaseOrdersData()
  1399. .then(() => {
  1400. generatePDF()
  1401. .then(() => {
  1402. ElNotification({
  1403. duration: 0,
  1404. type: 'success',
  1405. title: '任务已成功处理',
  1406. message: '本页面将自动跳转',
  1407. })
  1408. const url =
  1409. import.meta.env.VITE_PO_PATH +
  1410. POID.value +
  1411. import.meta.env.VITE_PO_APPEND
  1412. setTimeout(() => {
  1413. window.location.replace(url)
  1414. }, 1000)
  1415. })
  1416. .finally(() => {
  1417. loading.value = false
  1418. })
  1419. })
  1420. .catch(() => {
  1421. // loading.value = false
  1422. const msg = '获取PO详情失败, 未能正确生成PDF'
  1423. console.log(msg)
  1424. ElNotification({ duration: 0, title: msg, type: 'error' })
  1425. })
  1426. })
  1427. .catch(() => {
  1428. // loading.value = false
  1429. const msg = '创建PO失败'
  1430. console.log(msg)
  1431. ElNotification({ duration: 0, title: msg, type: 'error' })
  1432. })
  1433. }
  1434. const pdfElement = ref()
  1435. const pdfElement2 = ref()
  1436. const generatePDF = (ele = pdfElement, isFirstTime = true) => {
  1437. const A4_WIDTH = 592.28
  1438. const A4_HEIGHT = 841.89
  1439. let imageWrapper = unref(ele) // 获取DOM
  1440. // let pageHeight = (imageWrapper.scrollWidth / A4_WIDTH) * A4_HEIGHT
  1441. let pageHeight = (imageWrapper.clientWidth / A4_WIDTH) * A4_HEIGHT
  1442. let lableListID = imageWrapper.querySelectorAll('#pdfElement > div')
  1443. // 进行分割操作,当dom内容已超出a4的高度,则将该dom前插入一个空dom,把他挤下去,分割
  1444. for (let i = 0; i < lableListID.length; i++) {
  1445. let multiple = Math.ceil(
  1446. (lableListID[i].offsetTop + lableListID[i].offsetHeight) / pageHeight,
  1447. )
  1448. if (isSplit(lableListID, i, multiple * pageHeight)) {
  1449. let divParent = lableListID[i].parentNode // 获取该div的父节点
  1450. let newNode = document.createElement('div')
  1451. newNode.className = 'empty-div'
  1452. newNode.style.background = '#fff'
  1453. let _H =
  1454. multiple * pageHeight -
  1455. (lableListID[i].offsetTop + lableListID[i].offsetHeight)
  1456. //留白
  1457. newNode.style.height = _H + 40 + 'px'
  1458. newNode.style.width = '100%'
  1459. let next = lableListID[i].nextSibling // 获取div的下一个兄弟节点
  1460. // 判断兄弟节点是否存在
  1461. if (next) {
  1462. // 存在则将新节点插入到div的下一个兄弟节点之前,即div之后
  1463. divParent.insertBefore(newNode, next)
  1464. } else {
  1465. // 不存在则直接添加到最后,appendChild默认添加到divParent的最后
  1466. divParent.appendChild(newNode)
  1467. }
  1468. }
  1469. }
  1470. return new Promise((resolve) => {
  1471. html2canvas(imageWrapper, {
  1472. allowTaint: true,
  1473. useCORS: true,
  1474. backgroundColor: '#fff', //一定要设背景颜色,否则有的浏览器就会变花~,比如Edge
  1475. scale: 3, // 缩放倍率调整清晰度
  1476. }).then((canvas) => {
  1477. let pdf = new jspdf('p', 'mm', 'a4') //A4纸,纵向
  1478. let ctx = canvas.getContext('2d'),
  1479. a4ContentWidth = 190,
  1480. a4ContentHeight = 277, //A4大小,210mm x 297mm,四边各保留10mm的边距,显示区域190x277
  1481. imgHeight = Math.floor(
  1482. (a4ContentHeight / a4ContentWidth) * canvas.width,
  1483. ), //按A4显示比例换算一页图像的像素高度
  1484. renderedHeight = 0
  1485. while (renderedHeight < canvas.height) {
  1486. let page = document.createElement('canvas')
  1487. page.width = canvas.width
  1488. page.height = Math.min(imgHeight, canvas.height - renderedHeight) //可能内容不足一页
  1489. //用getImageData剪裁指定区域,并画到前面创建的canvas对象中
  1490. // @ts-ignore: Object is possibly 'null'.
  1491. page
  1492. .getContext('2d')
  1493. .putImageData(
  1494. ctx!.getImageData(
  1495. 0,
  1496. renderedHeight,
  1497. canvas.width,
  1498. Math.min(imgHeight, canvas.height - renderedHeight),
  1499. ),
  1500. 0,
  1501. 0,
  1502. )
  1503. // document.body.appendChild(page)
  1504. pdf.addImage(
  1505. page.toDataURL('image/jpeg', 0.5),
  1506. 'JPEG',
  1507. 10,
  1508. 10,
  1509. a4ContentWidth,
  1510. Math.min(
  1511. a4ContentHeight,
  1512. a4ContentWidth * (page.height / page.width),
  1513. ),
  1514. ) //添加图像到页面,保留10mm边距
  1515. renderedHeight += imgHeight
  1516. if (renderedHeight < canvas.height) pdf.addPage() //如果后面还有内容,添加一个空页
  1517. }
  1518. const prefix =
  1519. `${PONumber.value}-${computedVendor.value.label}` +
  1520. (form.value.Title?.length ? `-${form.value.Title}` : '')
  1521. const fileName = isFirstTime ? prefix : prefix + '_2'
  1522. // sendPDF(pdf.output('datauristring'), fileName)
  1523. // .then(() => {
  1524. resolve(true)
  1525. // })
  1526. // 本地备份一下
  1527. pdf.save(fileName + '.pdf')
  1528. })
  1529. })
  1530. }
  1531. const isSplit = function (nodes: any, index: number, pageHeight: number) {
  1532. // 计算当前这块dom是否跨越了a4大小,以此分割
  1533. if (
  1534. nodes[index].offsetTop + nodes[index].offsetHeight < pageHeight &&
  1535. nodes[index + 1] &&
  1536. nodes[index + 1].offsetTop + nodes[index + 1].offsetHeight > pageHeight
  1537. ) {
  1538. return true
  1539. }
  1540. return false
  1541. }
  1542. // const sendPDF = function (file: string, filename = `attachment_file`) {
  1543. // const temp = file.split(',')
  1544. // // @ts-ignore: Object is possibly 'null'.
  1545. // const mimeType = temp[0].match(/:(.*?);/)[1]
  1546. // let extName = mimeType.split('/')[1]
  1547. // let bstr = window.atob(temp[1])
  1548. // let n = bstr.length
  1549. // let result = new Uint8Array(n)
  1550. // while (n--) {
  1551. // result[n] = bstr.charCodeAt(n)
  1552. // }
  1553. // const data = {
  1554. // id: POID.value,
  1555. // file: new File([result], `${filename}.${extName}`, { type: mimeType }),
  1556. // }
  1557. // return new Promise((resolve, reject) => {
  1558. // request
  1559. // .post('/Purchase_orders/uploadAttachmentFile', data, {
  1560. // headers: {
  1561. // 'Content-Type': 'multipart/form-data',
  1562. // },
  1563. // })
  1564. // .then((response) => {
  1565. // if (response.data.code !== 1) {
  1566. // const msg = '自动创建附件失败'
  1567. // ElNotification({ duration: 0, title: msg, type: 'error' })
  1568. // reject(msg)
  1569. // return
  1570. // }
  1571. // ElNotification({
  1572. // duration: 0,
  1573. // title: '自动创建 PDF 成功',
  1574. // type: 'success',
  1575. // })
  1576. // resolve(true)
  1577. // })
  1578. // .catch((e) => {
  1579. // reject(e)
  1580. // })
  1581. // })
  1582. // }
  1583. const createPurchaseOrders = function () {
  1584. const data = JSON.parse(JSON.stringify(unref(form)))
  1585. data.Status = 'Created'
  1586. data.Sub_Total = subTotal.value
  1587. data.Total_Taxes = 0
  1588. data.Total_Discount = totalDiscount.value
  1589. data.Adjustment = Number(adjustment.value)
  1590. data.Grand_Total = grandTotal.value
  1591. data.Subject = '这里不用填'
  1592. data.Created_By = {
  1593. id: userInfo.value.users_id || route.query.user,
  1594. name: userInfo.value.full_name || '',
  1595. }
  1596. data.Owner = {
  1597. id: userInfo.value.users_id || route.query.user,
  1598. name: userInfo.value.full_name || '',
  1599. email: userInfo.value.email || '',
  1600. }
  1601. data.Vendor_Name = {
  1602. id: computedVendor.value.value,
  1603. name: computedVendor.value.label,
  1604. }
  1605. data.Related_Sales_Order = {
  1606. id: form.value.saleOrderId,
  1607. name: form.value.Title,
  1608. }
  1609. data.Purchase_Items = data.productList.map((item: any) => {
  1610. return {
  1611. Warehouse: item.Warehouse || '',
  1612. Quantity: item.quantity,
  1613. Discount: item.discount || 0,
  1614. List_Price: item.rate,
  1615. Tax: 0,
  1616. total: item.amount,
  1617. total_after_discount: Number(item.amount) - Number(item.discount),
  1618. Net_Total: Number(item.amount) - Number(item.discount),
  1619. Description: item.desc,
  1620. Requirement: item.requirement,
  1621. line_tax: [],
  1622. // book: '',
  1623. // id: item.id,
  1624. product: {
  1625. // name: item.name,
  1626. id: item.id,
  1627. // Product_Code: item.Product_Code,
  1628. },
  1629. Product_Name: {
  1630. id: item.id,
  1631. },
  1632. // 这两个是crm有的, 但是文档没有
  1633. List_Price_Non_Currency: item.rate,
  1634. Price_Book_Name: '',
  1635. }
  1636. })
  1637. if (data.productList) delete data.productList
  1638. return new Promise((resolve, reject) => {
  1639. request
  1640. .post('/Purchase_orders/createPurchaseOrders', data, {})
  1641. .then((response) => {
  1642. if (response.data.code !== 1) return
  1643. const res = response.data.result
  1644. if (res.data && res.data.length && res.data[0].code === 'SUCCESS') {
  1645. POID.value = res.data[0].details?.id || ''
  1646. resolve(res.data[0].details?.id)
  1647. ElNotification({
  1648. duration: 0,
  1649. title: '创建 Purchase Order 成功',
  1650. type: 'success',
  1651. })
  1652. } else {
  1653. ElNotification({
  1654. duration: 0,
  1655. title: '未能成功创建PO, 请稍后重试或者联系管理员',
  1656. type: 'error',
  1657. })
  1658. }
  1659. reject('未能成功创建PO')
  1660. })
  1661. .catch((e) => {
  1662. reject(e)
  1663. })
  1664. })
  1665. }
  1666. const getPurchaseOrdersData = function () {
  1667. return new Promise((resolve, reject) => {
  1668. request
  1669. .post('/purchase_orders/getPurchaseOrdersData', {
  1670. id: POID.value,
  1671. })
  1672. .then((response) => {
  1673. if (response.data.code !== 1) {
  1674. reject(false)
  1675. return
  1676. }
  1677. const res = Array.isArray(response.data.result)
  1678. ? response.data.result[0]
  1679. : response.data.result
  1680. longPONumber.value = res.PO_Number || ''
  1681. PONumber.value = res.Purchase_Order_Number || ''
  1682. resolve(true)
  1683. })
  1684. .catch((e) => {
  1685. reject(e)
  1686. })
  1687. })
  1688. }
  1689. const currentCurrency = computed(() => {
  1690. const temp = currencyList.value.filter((i) => i.label === form.value.Currency)
  1691. // 2是人民币
  1692. return temp.length ? temp[0] : temp[2]
  1693. })
  1694. const form = ref<IForm>({
  1695. Order_Type: '',
  1696. Artwork_Link: '',
  1697. Currency: 'CNY',
  1698. // 订单号
  1699. saleOrderId: '',
  1700. Reference: '',
  1701. // 日期
  1702. PO_Date: '',
  1703. // 付款方式
  1704. Supplier_Payment_Terms: '-None-',
  1705. // 参考, so的job name
  1706. Title: '',
  1707. // 收货地址
  1708. field9: '广州市越秀区八旗二马路广东航运大厦1904室 邮编510110',
  1709. // 收件人
  1710. field7: '',
  1711. // 联系电话
  1712. field8: '18925020659',
  1713. // 工厂交货日期
  1714. field6: '',
  1715. productList: [
  1716. {
  1717. name: '',
  1718. id: '',
  1719. quantity: '',
  1720. rate: '',
  1721. requirement: '',
  1722. desc: '',
  1723. amount: 0,
  1724. discount: '',
  1725. candidate: [],
  1726. },
  1727. ] as IProductItem[],
  1728. // 印刷质量
  1729. field12: '',
  1730. // 产品质量
  1731. field13: '',
  1732. // 质量承诺
  1733. field10: '',
  1734. // 箱子箱唛
  1735. field11: '',
  1736. // 税率
  1737. field4: '0',
  1738. // 运费条款
  1739. field5: '供应商承担',
  1740. currentVendor: '',
  1741. Delivery_Details: '',
  1742. })
  1743. const addRow = function () {
  1744. form.value.productList.push(JSON.parse(JSON.stringify(emptyProductItem)))
  1745. }
  1746. const keyNeedCompute = ['quantity', 'rate']
  1747. const onInputChange = function (e: any, obj: IProductItem, key: string) {
  1748. if (typeof e === 'string') {
  1749. if (e.length) {
  1750. // 强制转换为数字类型
  1751. obj[key] = Math.round(utils.multiply(Number(e), 1000)) / 1000
  1752. // 计算每行的总额
  1753. if (keyNeedCompute.includes(key)) {
  1754. obj.amount = utils.multiply(Number(obj.quantity), Number(obj.rate))
  1755. }
  1756. } else {
  1757. // obj[key] = minValue
  1758. }
  1759. }
  1760. }
  1761. const onProductSelect = function (e: any, product: IProductItem) {
  1762. if (e) {
  1763. const temp = product.candidate.filter((i) => i.value === e)
  1764. if (temp.length) {
  1765. product.name = temp[0].label
  1766. product.Product_Code = temp[0].Product_Code // 没有传出去, 实际上没用, 在本页面处于废弃状态
  1767. }
  1768. getProductData(product.id).then((ctx) => {
  1769. product.requirement =
  1770. userInfo.value.Organization === 'PrimePac'
  1771. ? '产品名称:\n尺寸:\n材质:\n工艺:\n颜色:\n其他备注:'
  1772. : ctx.CF3 || ''
  1773. product.CF_Product_Type = ctx.CF_Product_Type || ''
  1774. })
  1775. } else {
  1776. product.name = ''
  1777. }
  1778. }
  1779. // 小计
  1780. const subTotal = computed(() => {
  1781. return form.value.productList.reduce((total, current) => {
  1782. total = total + Number(current.amount)
  1783. return total
  1784. }, 0)
  1785. })
  1786. // 总优惠额度
  1787. const totalDiscount = computed(() => {
  1788. return form.value.productList.reduce((total, current) => {
  1789. total = total + Number(current.discount)
  1790. return total
  1791. }, 0)
  1792. })
  1793. // 价格统计修正值
  1794. const adjustment = ref<number | string>('')
  1795. // 总计
  1796. const grandTotal = computed(() => {
  1797. return subTotal.value - totalDiscount.value + Number(adjustment.value)
  1798. })
  1799. const productLoading = ref(false)
  1800. const getProductList = utils.debounce(
  1801. (keyword: string, target: IProductItem) => {
  1802. const key = keyword.trim()
  1803. if (!key.length) return
  1804. productLoading.value = true
  1805. const data = {
  1806. value: key,
  1807. name: 'Products',
  1808. api_name: 'Product_Name',
  1809. contains: 'contains',
  1810. page: 1,
  1811. limit: 20,
  1812. }
  1813. getSearchData(data)
  1814. .then((response) => {
  1815. if (response.data.code !== 1) return
  1816. const res = response.data.result
  1817. target.candidate = res.data.map((item: any) => {
  1818. return {
  1819. ...item,
  1820. label: item.Product_Name,
  1821. value: item.products_id || item.id,
  1822. }
  1823. })
  1824. })
  1825. .finally(() => {
  1826. productLoading.value = false
  1827. })
  1828. },
  1829. 1000,
  1830. )
  1831. const toFixed = function (value: number, ratio = 2) {
  1832. let r = 100
  1833. if (ratio === 3) {
  1834. r = 1000
  1835. }
  1836. return utils.toFixed(value, r)
  1837. }
  1838. const vendorList = ref<IVendorItem[]>([])
  1839. const computedVendor = computed(() => {
  1840. const temp = vendorList.value.filter(
  1841. (i) => i.value === form.value.currentVendor,
  1842. )
  1843. return temp.length
  1844. ? temp[0]
  1845. : {
  1846. Primary_Contact_name: '',
  1847. PDF_display: '',
  1848. PDF_display2: '',
  1849. label: '',
  1850. value: '',
  1851. Payment_Terms: '',
  1852. High_Risk_Supplier: false
  1853. }
  1854. })
  1855. watch(computedVendor, () => {
  1856. if (
  1857. computedVendor.value.Payment_Terms &&
  1858. computedVendor.value.Payment_Terms.length
  1859. ) {
  1860. form.value.Supplier_Payment_Terms = computedVendor.value.Payment_Terms
  1861. }
  1862. })
  1863. const vendorLoading = ref(false)
  1864. const getSupplierLists = function (string: string) {
  1865. return new Promise((resolve, reject) => {
  1866. const keyword = string.trim() || ''
  1867. if (!keyword.length) {
  1868. reject('false')
  1869. return
  1870. }
  1871. const data = {
  1872. value: keyword,
  1873. name: 'Vendors',
  1874. api_name: 'Vendor_Name',
  1875. contains: 'contains',
  1876. page: 1,
  1877. limit: 100,
  1878. }
  1879. vendorLoading.value = true
  1880. getSearchData(data)
  1881. .then((response) => {
  1882. if (response.data.code !== 1) return false
  1883. const res = response.data.result || { data: [] }
  1884. vendorList.value = res.data
  1885. .filter((i: any) => !i.Hide_Record)
  1886. .map((i: any) => {
  1887. return {
  1888. ...i,
  1889. label: i.Suppliers_Name || i.Vendor_Name,
  1890. value: i.supplier_id || i.id,
  1891. Primary_Contact_name: i.Primary_Contact_name || '',
  1892. PDF_display: i.PDF_display || '',
  1893. PDF_display2: i.PDF_display2 || '',
  1894. }
  1895. })
  1896. if (
  1897. vendorList.value.length === 1 &&
  1898. vendorList.value[0].High_Risk_Supplier === true
  1899. ) {
  1900. ElMessageBox.alert(
  1901. '请注意该供应商在我们黑名单中。<br>Please note that this supplier is in our black list.',
  1902. 'Alert',
  1903. {
  1904. dangerouslyUseHTMLString: true,
  1905. },
  1906. )
  1907. }
  1908. vendorLoading.value = false
  1909. loading.value = false
  1910. resolve(true)
  1911. })
  1912. .catch((e) => reject(e))
  1913. })
  1914. }
  1915. const quickSelectSupplier = function (item: IRecommandVendor) {
  1916. form.value.currentVendor = item.id
  1917. loading.value = true
  1918. getSupplierLists(item.name)
  1919. }
  1920. const getSearchData = async function (p: any) {
  1921. return await request
  1922. .post('/common/getPublicLists', p, {
  1923. headers: { 'Content-Type': 'multipart/form-data' },
  1924. })
  1925. .then((response) => {
  1926. return response
  1927. })
  1928. }
  1929. const computedCompanyList = computed(() => {
  1930. return userInfo.value.Organization === 'PrimePac'
  1931. ? PrimePacList.value
  1932. : companyList.value
  1933. })
  1934. // 切换模版后的处理
  1935. const onCompanyTemplateChange = function () {
  1936. // 重置这两个字段
  1937. form.value.field5 = '供应商承担'
  1938. form.value.field4 = ''
  1939. if (typeof computedCompany.value.taxReimbursement === 'undefined') {
  1940. form.value.field7 = soOwner.value
  1941. form.value.field8 = '18925020659'
  1942. form.value.field9 = '广州市越秀区八旗二马路广东航运大厦1904室 邮编510110'
  1943. } else {
  1944. // 退税版没有这三个表单项, 直接重置值. 相应的, 非退税版要重新赋值.
  1945. form.value.field7 = ''
  1946. form.value.field8 = ''
  1947. form.value.field9 = ''
  1948. }
  1949. }
  1950. const currentServiceRule = computed(() => {
  1951. if (currentCompany.value === 'PrimePacSoft') {
  1952. return serviceRule.value['PrimePacCommon']
  1953. }
  1954. return serviceRule.value[currentCompany.value as ServiceTypeKeyEnum]
  1955. })
  1956. const currentCompany = ref('PC')
  1957. const computedCompany = computed(() => {
  1958. const result = computedCompanyList.value.filter(
  1959. (i) => i.id === currentCompany.value,
  1960. )
  1961. return result.length ? result[0] : computedCompanyList.value[0]
  1962. })
  1963. // 格式化输出价格的小数位数. 退税版需要显示三位小数, 其他只需要两位小数
  1964. const computedDeci = computed(() => {
  1965. return typeof computedCompany.value.taxReimbursement !== 'undefined' ? 3 : 2
  1966. })
  1967. // 候选 收货地址
  1968. let addressList = ref<ISelectItem[]>([])
  1969. // 候选 运费条款. 目前只有庞吉亚退税版用到, 其他模版默认供应商承担
  1970. let field5_lists = ref<ISelectItem[]>([])
  1971. let supplierPaymentTermsLists = ref<ISelectItem[]>([])
  1972. loading.value = true
  1973. // 获取下拉框非动态候选数据
  1974. const p1 = request
  1975. .post('/common/getfieldsData')
  1976. .then((response: any) => {
  1977. const res = response.data.result
  1978. orderTypeList.value = res.Order_Type_lists.map((i: string) => {
  1979. return {
  1980. label: i,
  1981. }
  1982. }).filter((i: any) => i.label !== '-None-')
  1983. addressList.value = res.field9_lists.map((i: any) => {
  1984. return {
  1985. label: i,
  1986. }
  1987. })
  1988. field5_lists.value = res.field5_lists
  1989. .filter((i: string) => !/^-?[Nn]one-?$/.test(i))
  1990. .map((i: any) => {
  1991. return {
  1992. label: i,
  1993. }
  1994. })
  1995. supplierPaymentTermsLists.value = res.Supplier_Payment_Terms_lists.map(
  1996. (i: any) => {
  1997. return {
  1998. label: i,
  1999. }
  2000. },
  2001. )
  2002. })
  2003. .catch((e) => {
  2004. console.log(e, '下拉框')
  2005. ElMessage.error('获取下拉框数据出错, 请联系管理员.')
  2006. })
  2007. const route = useRoute()
  2008. const soOwner = ref('')
  2009. // 获取销售订单详情
  2010. const p2 = request
  2011. .post('/common/getSalesOrdersData', { id: route.params.id })
  2012. .then((response) => {
  2013. return response
  2014. })
  2015. // 获取对 该so对应客户的标注 并弹窗提醒
  2016. const getAccountsData = async (id: string) =>
  2017. request.post('/common/getAccountsData', { id }).then((response) => {
  2018. const res = response.data
  2019. if (res.code !== 1) return
  2020. if (res.result.User_Notes && res.result.User_Notes.length) {
  2021. ElMessageBox.confirm(res.result.User_Notes, '', {
  2022. confirmButtonText: '将此备注添加到合同',
  2023. cancelButtonText: '已知悉',
  2024. type: 'warning',
  2025. showClose: false,
  2026. closeOnPressEscape: false,
  2027. closeOnClickModal: false,
  2028. autofocus: false,
  2029. })
  2030. .then(() => {
  2031. // 迭代3 需求. 固定填充一行.
  2032. form.value.productList.push(
  2033. Object.assign({}, emptyProductItem, {
  2034. requirement: res.result.User_Notes || '',
  2035. quantity: 1,
  2036. rate: 0,
  2037. id: '4791186000172849436',
  2038. name: 'User Notes',
  2039. CF_Product_Type: '',
  2040. candidate: [
  2041. {
  2042. label: 'User Notes',
  2043. value: '4791186000172849436',
  2044. },
  2045. ],
  2046. }),
  2047. )
  2048. })
  2049. .catch(() => {})
  2050. }
  2051. })
  2052. const getProductData = async (id: string) =>
  2053. request.post('/common/getProductsData', { id }).then((response) => {
  2054. const res = response.data
  2055. if (res.code !== 1) return
  2056. // 推荐供应商. 用来快速选择供应商的.
  2057. if (
  2058. Array.isArray(res.result.SUPPLIER_PRICING) &&
  2059. res.result.SUPPLIER_PRICING.length
  2060. ) {
  2061. for (const item of res.result.SUPPLIER_PRICING) {
  2062. if (
  2063. item.Supplier?.id &&
  2064. !computedRecommandVendorID.value.includes(item.Supplier.id)
  2065. ) {
  2066. console.log(item, 'item')
  2067. recommandVendor.value.push({
  2068. id: item.Supplier.id,
  2069. name: item.Supplier.name,
  2070. })
  2071. }
  2072. }
  2073. }
  2074. return res.result
  2075. })
  2076. const recommandVendor = ref<IRecommandVendor[]>([])
  2077. // 用来去重
  2078. const computedRecommandVendorID = computed(() =>
  2079. recommandVendor.value.map((i: any) => i.id),
  2080. )
  2081. // 根据url传递过来的用户ID获取的用户身份信息
  2082. const userInfo = ref({} as IUser)
  2083. const p3 = request
  2084. .post('/common/getUsersData', { id: route.query.user })
  2085. .then((response) => {
  2086. const res = response.data
  2087. if (res.code !== 1) return
  2088. if (res.result.users && res.result.users.length) {
  2089. userInfo.value = res.result.users[0]
  2090. } else if (res.result.id) {
  2091. userInfo.value = res.result || {}
  2092. } else if (Array.isArray(res.result) && res.result.length) {
  2093. userInfo.value = res.result[0] || {}
  2094. } else {
  2095. ElMessage.error('获取当前用户身份异常, 请联系管理员')
  2096. }
  2097. // 根据用户 ‘组织’ 切换模版默认选中项
  2098. if (userInfo.value.Organization === 'PrimePac') {
  2099. currentCompany.value = 'PrimePacCommon'
  2100. } else {
  2101. currentCompany.value = 'PC'
  2102. }
  2103. })
  2104. Promise.all([p1, p2, p3, getAccountsData])
  2105. .then((array: any[]) => {
  2106. // p2的数据处理逻辑从原本的p2then移动到这里处理.
  2107. // 因为要根据p3用户数据的Organization 来填充产品列表里面的 requirement, 这步处理必须放在p3后面, 而p2 p3是并发操作.
  2108. if (array[1].data.code !== 1) return
  2109. const res = array[1].data.result
  2110. if (res.Account_Name && res.Account_Name.id) {
  2111. getAccountsData(res.Account_Name.id)
  2112. }
  2113. form.value.field7 = res.Owner_name || res.Owner.name || ''
  2114. soOwner.value = res.Owner_name || res.Owner.name || ''
  2115. form.value.Title =
  2116. res.Contract_Title || res.Sales_Order_Title_Job_Name || ''
  2117. form.value.saleOrderId = res.sales_orders_id || res.id || ''
  2118. form.value.PO_Date = dayjs(new Date()).format('YYYY-MM-DD')
  2119. form.value.Reference = res.Reference || ''
  2120. form.value.Artwork_Link = res.Artwork_Link || ''
  2121. let temp = []
  2122. if (res.details) {
  2123. temp = res.details.filter(
  2124. (item: any) => !productBlackList.includes(item.product_id),
  2125. )
  2126. } else if (res.Product_Details) {
  2127. temp = res.Product_Details.filter(
  2128. (item: any) => !productBlackList.includes(item.product.id),
  2129. )
  2130. }
  2131. if (!temp.length) return
  2132. form.value.productList = []
  2133. recommandVendor.value = []
  2134. temp.forEach((item: any) => {
  2135. getProductData(item.product.id).then((ctx) => {
  2136. console.log(ctx, 'product ctx')
  2137. form.value.productList.push(
  2138. Object.assign({}, emptyProductItem, {
  2139. candidate: [
  2140. {
  2141. Product_Code: item.product_Product_Code,
  2142. label: item.product.name,
  2143. value: item.product.id,
  2144. },
  2145. ],
  2146. Product_Code: item.product.Product_Code,
  2147. id: item.product.id,
  2148. name: item.product.name,
  2149. label: item.product.name,
  2150. value: item.product.id,
  2151. desc: item.product_description || '',
  2152. quantity: Number(item.quantity),
  2153. requirement:
  2154. userInfo.value.Organization === 'PrimePac'
  2155. ? '产品名称:\n尺寸:\n材质:\n工艺:\n颜色:\n其他备注:'
  2156. : ctx.CF3 || '',
  2157. CF_Product_Type: ctx.CF_Product_Type,
  2158. }),
  2159. )
  2160. })
  2161. })
  2162. })
  2163. .finally(() => {
  2164. loading.value = false
  2165. })
  2166. </script>
  2167. <style lang="scss">
  2168. input[type='number'] {
  2169. -moz-appearance: textfield;
  2170. appearance: textfield;
  2171. &:hover {
  2172. -moz-appearance: textfield;
  2173. appearance: textfield;
  2174. &::-webkit-inner-spin-button,
  2175. &::-webkit-outer-spin-button {
  2176. -webkit-appearance: none;
  2177. margin: 0;
  2178. }
  2179. }
  2180. &::-webkit-inner-spin-button,
  2181. &::-webkit-outer-spin-button {
  2182. -webkit-appearance: none;
  2183. margin: 0;
  2184. }
  2185. }
  2186. .product-select {
  2187. .el-select-dropdown,
  2188. .el-select-dropdown__list {
  2189. min-width: 400px;
  2190. max-width: 500px;
  2191. }
  2192. }
  2193. </style>
  2194. <style lang="scss" scoped>
  2195. @import './style.scss';
  2196. </style>