index.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270
  1. <template>
  2. <div class="page-wecom-approval">
  3. <div
  4. v-if="loading"
  5. v-loading="true"
  6. style="
  7. width: 100vw;
  8. height: 100vh;
  9. z-index: 999;
  10. position: fixed;
  11. top: 0;
  12. left: 0;
  13. "
  14. class=""
  15. element-loading-text="Loading..."
  16. element-loading-background="rgba(0, 0, 0, 0.3)"
  17. ></div>
  18. <div class="main-content">
  19. <div
  20. class="flex"
  21. style="max-width: 800px; margin: 0 auto"
  22. >
  23. <div class="logo-area">
  24. <img
  25. :src="getLogoPath()"
  26. alt=""
  27. />
  28. </div>
  29. <div class="page-title">货物运输申请</div>
  30. <!-- <el-button @click="redirectToCRM">test</el-button> -->
  31. </div>
  32. <el-form
  33. ref="mainForm"
  34. style="max-width: 800px; margin: 0 auto"
  35. :model="form"
  36. :rules="rules"
  37. label-width="150px"
  38. label-position="left"
  39. >
  40. <el-form-item
  41. label="申请人"
  42. prop="name"
  43. >
  44. <el-input
  45. v-model="form.creator_userid"
  46. disabled
  47. style="display: none"
  48. ></el-input>
  49. <div style="font-weight: bold">{{ firstName }}</div>
  50. </el-form-item>
  51. <el-form-item
  52. prop="so_ref"
  53. label="SO Reference"
  54. >
  55. <el-input
  56. v-model="form.so_ref"
  57. style="display: none"
  58. disabled
  59. ></el-input>
  60. <div class="">{{ form.so_ref }}</div>
  61. </el-form-item>
  62. <el-form-item
  63. prop="job_name"
  64. label="Job Name"
  65. >
  66. <el-input
  67. v-model="form.job_name"
  68. style="display: none"
  69. disabled
  70. ></el-input>
  71. <div class="">{{ form.job_name }}</div>
  72. </el-form-item>
  73. <el-form-item
  74. prop="location"
  75. label="Location"
  76. >
  77. <el-radio-group v-model="form.location">
  78. <el-radio
  79. v-for="item in locationList"
  80. :key="item.key"
  81. :label="item.value[0].text"
  82. :value="item.key"
  83. ></el-radio>
  84. </el-radio-group>
  85. </el-form-item>
  86. <el-form-item
  87. prop="yunshu"
  88. label="运输方式"
  89. >
  90. <el-radio-group v-model="form.yunshu">
  91. <el-radio
  92. v-for="item in yunshuList"
  93. :key="item.key"
  94. :label="item.value[0].text"
  95. :value="item.key"
  96. ></el-radio>
  97. </el-radio-group>
  98. </el-form-item>
  99. <el-form-item
  100. v-if="form.yunshu === 'option-1718767952637'"
  101. label="Cbm"
  102. prop="cbm"
  103. >
  104. <el-input
  105. v-model="form.cbm"
  106. placeholder="如选择海运,请填写方数"
  107. type="number"
  108. ></el-input>
  109. </el-form-item>
  110. <el-form-item
  111. prop="huoyun"
  112. label="货运方式"
  113. >
  114. <el-radio-group v-model="form.huoyun">
  115. <el-radio
  116. v-for="item in huoyunList"
  117. :key="item.key"
  118. :label="item.value[0].text"
  119. :value="item.key"
  120. ></el-radio>
  121. </el-radio-group>
  122. </el-form-item>
  123. <el-form-item
  124. v-if="form.huoyun === 'option-1718768018003'"
  125. label="货代名称"
  126. prop="huodai"
  127. >
  128. <el-select v-model="form.huodai">
  129. <el-option
  130. v-for="item in huodaiList"
  131. :key="item.key"
  132. :label="item.value[0].text"
  133. :value="item.key"
  134. ></el-option>
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item
  138. prop="trans"
  139. label="中转方式"
  140. >
  141. <el-radio-group v-model="form.trans">
  142. <el-radio
  143. v-for="item in transList"
  144. :key="item.key"
  145. :label="item.value[0].text"
  146. :value="item.key"
  147. ></el-radio>
  148. </el-radio-group>
  149. </el-form-item>
  150. <el-form-item
  151. prop="number"
  152. label="箱数"
  153. >
  154. <el-input v-model="form.number"></el-input>
  155. </el-form-item>
  156. <el-form-item
  157. prop="weight"
  158. label="重量"
  159. >
  160. <el-input v-model="form.weight">
  161. <template #append>kg</template>
  162. </el-input>
  163. </el-form-item>
  164. <el-form-item label="地址">
  165. <div class="addr-input-group">
  166. <el-input
  167. v-model="form.ATTN"
  168. placeholder="ATTN"
  169. ></el-input>
  170. <el-input
  171. v-model="form.Phone"
  172. placeholder="Phone"
  173. ></el-input>
  174. <el-input
  175. v-model="form.Shipping_Unit_Building_Name"
  176. placeholder="Shipping_Unit/Building_Name"
  177. type="textarea"
  178. rows="1"
  179. ></el-input>
  180. <el-input
  181. v-model="form.Shipping_Street"
  182. placeholder="Shipping_Street"
  183. ></el-input>
  184. <el-input
  185. v-model="form.Shipping_City"
  186. placeholder="Shipping_City"
  187. ></el-input>
  188. <el-input
  189. v-model="form.Shipping_State"
  190. placeholder="Shipping_State"
  191. ></el-input>
  192. <el-input
  193. v-model="form.Shipping_Code"
  194. placeholder="Shipping_Code"
  195. ></el-input>
  196. <el-input
  197. v-model="form.Shipping_Country"
  198. placeholder="Shipping_Country"
  199. ></el-input>
  200. </div>
  201. </el-form-item>
  202. <el-form-item
  203. prop="comment"
  204. label="装箱备注"
  205. >
  206. <el-input
  207. v-model="form.comment"
  208. placeholder="任何补充,请在此处填写"
  209. type="textarea"
  210. :rows="3"
  211. ></el-input>
  212. </el-form-item>
  213. <el-form-item
  214. prop="file"
  215. label="附件"
  216. >
  217. <div>
  218. <label for="fileInput">
  219. <el-tooltip
  220. :content="'企业微信限制了传\'图片\'最大只能上传10MB, 传\'文件\'类型最大只能上传20MB, 上传数量上限为6. 企微可能随时会调整, 建议别传太大的文件.'"
  221. >
  222. <div class="el-button el-button-primary">添加附件</div>
  223. </el-tooltip>
  224. </label>
  225. <br />
  226. <div style="color: #999">
  227. Artwork/Agreement/合同/其他附件, 请Attach
  228. </div>
  229. <div class="">
  230. <div
  231. v-for="(file, i) in form.files"
  232. :key="i"
  233. class="flex"
  234. >
  235. <div style="color: #333; margin-right: 24px">
  236. {{ file.name }}
  237. </div>
  238. <el-button
  239. size="small"
  240. type="danger"
  241. @click="deleteFile(i)"
  242. >
  243. Delete
  244. </el-button>
  245. </div>
  246. </div>
  247. </div>
  248. </el-form-item>
  249. <el-form-item label="价格">
  250. <el-table :data="form.price">
  251. <el-table-column
  252. label="货代价格"
  253. prop=""
  254. >
  255. <template #default="scope">
  256. <el-input
  257. v-model="scope.row.pa"
  258. placeholder="请填写我们支付给货代总金额或者每公斤单价"
  259. ></el-input>
  260. </template>
  261. </el-table-column>
  262. <el-table-column
  263. width="220"
  264. label="发票单价(AUD/USD)"
  265. prop=""
  266. >
  267. <template #default="scope">
  268. <el-input
  269. v-model="scope.row.pb"
  270. placeholder="请填写申报发票上的单价"
  271. ></el-input>
  272. </template>
  273. </el-table-column>
  274. <el-table-column
  275. width="100"
  276. label="操作"
  277. >
  278. <template #default="scope">
  279. <el-button
  280. type="danger"
  281. size="small"
  282. @click="deletePriceRow(scope.row, scope.$index)"
  283. >
  284. Delete
  285. </el-button>
  286. </template>
  287. </el-table-column>
  288. </el-table>
  289. <el-button
  290. size="small"
  291. @click="addPriceRow"
  292. >
  293. Add row
  294. </el-button>
  295. </el-form-item>
  296. <br />
  297. <el-form-item>
  298. <template #label>
  299. <div>
  300. <div class="">货物</div>
  301. <el-button
  302. type="danger"
  303. size="small"
  304. @click="resetGoods"
  305. >
  306. Reset
  307. </el-button>
  308. <el-button
  309. style="margin: 8px 0 0 0"
  310. type="primary"
  311. size="small"
  312. @click="autoFillNumber"
  313. >
  314. Dispatch All
  315. </el-button>
  316. </div>
  317. </template>
  318. <el-table :data="form.goods">
  319. <el-table-column label="品名">
  320. <template #default="scope">
  321. <el-input
  322. v-model="scope.row.name"
  323. disabled
  324. ></el-input>
  325. <el-input
  326. v-model="scope.row.desc"
  327. type="textarea"
  328. row="3"
  329. disabled
  330. style="margin-top: 8px"
  331. ></el-input>
  332. </template>
  333. </el-table-column>
  334. <el-table-column
  335. width="120"
  336. label="剩余数量"
  337. prop="quantity"
  338. >
  339. <template #default="scope">
  340. <el-input
  341. v-model="scope.row.quantity"
  342. type="number"
  343. disabled
  344. min="0"
  345. ></el-input>
  346. </template>
  347. </el-table-column>
  348. <el-table-column
  349. width="120"
  350. label="发货数量"
  351. prop="number"
  352. >
  353. <template #default="scope">
  354. <el-form-item
  355. label=""
  356. label-width="0"
  357. :prop="'goods.' + scope.$index + '.number'"
  358. :rules="{
  359. required: true,
  360. message: '必填项',
  361. trigger: ['blur', 'change'],
  362. }"
  363. >
  364. <el-input
  365. v-model="scope.row.number"
  366. type="number"
  367. min="0"
  368. @change="(e) => limitNumber(e, scope.row, 'number')"
  369. ></el-input>
  370. </el-form-item>
  371. </template>
  372. </el-table-column>
  373. <el-table-column
  374. label="操作"
  375. width="100"
  376. >
  377. <template #default="scope">
  378. <el-button
  379. type="danger"
  380. size="small"
  381. @click="deleteGoodRow(scope.row, scope.$index)"
  382. >
  383. Delete
  384. </el-button>
  385. </template>
  386. </el-table-column>
  387. </el-table>
  388. </el-form-item>
  389. <el-form-item>
  390. <div class="flex">
  391. <el-button
  392. size="large"
  393. type="primary"
  394. :disabled="submited"
  395. :loading="loading"
  396. @click="checkForm(mainForm)"
  397. >
  398. 提交
  399. </el-button>
  400. </div>
  401. </el-form-item>
  402. </el-form>
  403. <div class="copyright">
  404. Copyright of Promocollection - Version 1.0 Released on 01/07/2024
  405. </div>
  406. </div>
  407. <input
  408. id="fileInput"
  409. type="file"
  410. multiple
  411. style="display: none"
  412. @change="processFile"
  413. />
  414. </div>
  415. </template>
  416. <script lang="ts">
  417. export default defineComponent({
  418. name: 'WecomApproval',
  419. })
  420. </script>
  421. <script lang="ts" setup>
  422. import { defineComponent, ref } from 'vue'
  423. import { useRoute } from 'vue-router'
  424. import {
  425. ElButton,
  426. ElForm,
  427. ElFormItem,
  428. ElInput,
  429. ElRadio,
  430. ElRadioGroup,
  431. ElTable,
  432. ElTableColumn,
  433. ElSelect,
  434. ElOption,
  435. ElMessage,
  436. ElTooltip,
  437. ElNotification,
  438. } from 'element-plus'
  439. import type { FormRules, FormInstance } from 'element-plus'
  440. import request from '@/utils/axios'
  441. const loading = ref(false)
  442. const mainForm = ref<FormInstance>()
  443. const form = ref({
  444. creator_userid: '',
  445. so_ref: '',
  446. job_name: '',
  447. location: '',
  448. yunshu: '',
  449. cbm: '',
  450. huoyun: '',
  451. huodai: '',
  452. trans: '',
  453. number: '',
  454. weight: '',
  455. ATTN: '',
  456. Phone: '',
  457. Shipping_Unit_Building_Name: '',
  458. Shipping_Street: '',
  459. Shipping_City: '',
  460. Shipping_State: '',
  461. Shipping_Code: '',
  462. Shipping_Country: '',
  463. comment: '',
  464. archer: '',
  465. price: [{ pa: '', pb: '' }],
  466. goods: [] as any[],
  467. files: [] as { file_id: string; name: string }[], // 附件
  468. useField: '',
  469. })
  470. const rules = ref<FormRules>({
  471. creator_userid: [{ required: true, message: '必填项', trigger: 'blur' }],
  472. so_ref: [{ required: true, message: '必填项', trigger: 'blur' }],
  473. job_name: [{ required: true, message: '必填项', trigger: 'blur' }],
  474. location: [{ required: true, message: '必填项', trigger: 'blur' }],
  475. yunshu: [{ required: true, message: '必填项', trigger: 'blur' }],
  476. cbm: [{ required: true, message: '必填项', trigger: 'blur' }],
  477. huoyun: [{ required: true, message: '必填项', trigger: 'blur' }],
  478. huodai: [{ required: true, message: '必填项', trigger: 'blur' }],
  479. trans: [{ required: true, message: '必填项', trigger: 'blur' }],
  480. })
  481. const locationList = [
  482. {
  483. key: 'option-1718767763003',
  484. value: [
  485. {
  486. text: 'AU',
  487. lang: 'zh_CN',
  488. },
  489. ],
  490. },
  491. {
  492. key: 'option-1718767763004',
  493. value: [
  494. {
  495. text: 'NZ',
  496. lang: 'zh_CN',
  497. },
  498. ],
  499. },
  500. {
  501. key: 'option-1718767776803',
  502. value: [
  503. {
  504. text: 'Other(请在地址栏填写其他国家)',
  505. lang: 'zh_CN',
  506. },
  507. ],
  508. },
  509. ]
  510. const yunshuList = [
  511. {
  512. key: 'option-1718767905143',
  513. value: [
  514. {
  515. text: '其他空运',
  516. lang: 'zh_CN',
  517. },
  518. ],
  519. },
  520. {
  521. key: 'option-1718767938758',
  522. value: [
  523. {
  524. text: 'DHL空运',
  525. lang: 'zh_CN',
  526. },
  527. ],
  528. },
  529. {
  530. key: 'option-1718767944843',
  531. value: [
  532. {
  533. text: 'TNT空运',
  534. lang: 'zh_CN',
  535. },
  536. ],
  537. },
  538. {
  539. key: 'option-1718767905144',
  540. value: [
  541. {
  542. text: 'FedEx空运',
  543. lang: 'zh_CN',
  544. },
  545. ],
  546. },
  547. {
  548. key: 'option-1718767952637',
  549. value: [
  550. {
  551. text: '海运',
  552. lang: 'zh_CN',
  553. },
  554. ],
  555. },
  556. ]
  557. const huoyunList = [
  558. {
  559. key: 'option-1718767971282',
  560. value: [
  561. {
  562. text: '自送AUE',
  563. lang: 'zh_CN',
  564. },
  565. ],
  566. },
  567. {
  568. key: 'option-1718767971283',
  569. value: [
  570. {
  571. text: '自送浚捷',
  572. lang: 'zh_CN',
  573. },
  574. ],
  575. },
  576. {
  577. key: 'option-1718768010827',
  578. value: [
  579. {
  580. text: 'Logistics直发客户',
  581. lang: 'zh_CN',
  582. },
  583. ],
  584. },
  585. {
  586. key: 'option-1718768018003',
  587. value: [
  588. {
  589. text: '货代',
  590. lang: 'zh_CN',
  591. },
  592. ],
  593. },
  594. ]
  595. const huodaiList = [
  596. {
  597. key: 'option-1718768061055',
  598. value: [
  599. {
  600. text: '腾信',
  601. lang: 'zh_CN',
  602. },
  603. ],
  604. },
  605. {
  606. key: 'option-1718768061056',
  607. value: [
  608. {
  609. text: 'BWW',
  610. lang: 'zh_CN',
  611. },
  612. ],
  613. },
  614. {
  615. key: 'option-1718768085759',
  616. value: [
  617. {
  618. text: '天汇',
  619. lang: 'zh_CN',
  620. },
  621. ],
  622. },
  623. {
  624. key: 'option-1718768093097',
  625. value: [
  626. {
  627. text: '耀辉',
  628. lang: 'zh_CN',
  629. },
  630. ],
  631. },
  632. {
  633. key: 'option-1718768107857',
  634. value: [
  635. {
  636. text: '聂先生',
  637. lang: 'zh_CN',
  638. },
  639. ],
  640. },
  641. {
  642. key: 'option-1718768114817',
  643. value: [
  644. {
  645. text: '项先生',
  646. lang: 'zh_CN',
  647. },
  648. ],
  649. },
  650. {
  651. key: 'option-1718768125847',
  652. value: [
  653. {
  654. text: '鑫发',
  655. lang: 'zh_CN',
  656. },
  657. ],
  658. },
  659. {
  660. key: 'option-1718768131503',
  661. value: [
  662. {
  663. text: '茗佳',
  664. lang: 'zh_CN',
  665. },
  666. ],
  667. },
  668. {
  669. key: 'option-1723103324115',
  670. value: [
  671. {
  672. text: '其他货代(请与物流部沟通)',
  673. lang: 'zh_CN',
  674. },
  675. ],
  676. },
  677. ]
  678. const transList = [
  679. {
  680. key: 'option-1718768200256',
  681. value: [
  682. {
  683. text: '直送NZ',
  684. lang: 'zh_CN',
  685. },
  686. ],
  687. },
  688. {
  689. key: 'option-1718768200257',
  690. value: [
  691. {
  692. text: '直送客户',
  693. lang: 'zh_CN',
  694. },
  695. ],
  696. },
  697. {
  698. key: 'option-1718768224239',
  699. value: [
  700. {
  701. text: 'to AUWH',
  702. lang: 'zh_CN',
  703. },
  704. ],
  705. },
  706. ]
  707. const addPriceRow = () =>
  708. form.value.price.push({
  709. pa: '',
  710. pb: '',
  711. })
  712. const deletePriceRow = function (row: any, index: number) {
  713. form.value.price.splice(index, 1)
  714. }
  715. const deleteGoodRow = function (row: any, index: number) {
  716. form.value.goods.splice(index, 1)
  717. }
  718. const deleteFile = function (index: number) {
  719. form.value.files.splice(index, 1)
  720. }
  721. const route = useRoute()
  722. const soData = ref(
  723. {} as {
  724. Contract_Title: string
  725. Reference: string
  726. Pkg_details: any[]
  727. Product_Details: any[]
  728. },
  729. )
  730. const resetGoods = function () {
  731. if (
  732. Array.isArray(soData.value.Pkg_details) &&
  733. soData.value.Pkg_details.length
  734. ) {
  735. form.value.useField = 'Pkg_details'
  736. form.value.goods = soData.value.Pkg_details.map((i: any) => {
  737. return {
  738. id: i.Product_Line_Id,
  739. name: i.Product?.name || '',
  740. desc: i.Description || '',
  741. quantity: i.Quantity || 0,
  742. number: '',
  743. }
  744. })
  745. } else if (Array.isArray(soData.value.Product_Details)) {
  746. form.value.useField = 'Product_Details'
  747. form.value.goods = soData.value.Product_Details.map((i: any) => {
  748. console.log('iii')
  749. return {
  750. id: i.id,
  751. name: i.product.name || '',
  752. desc: i.product_description || '',
  753. quantity: i.quantity || 0,
  754. number: '',
  755. }
  756. })
  757. } else {
  758. form.value.goods = []
  759. }
  760. }
  761. const autoFillNumber = function () {
  762. form.value.goods.forEach((i) => {
  763. i.number = i.quantity
  764. })
  765. }
  766. const firstName = ref('')
  767. request
  768. .post('/common/getSalesOrdersData', {
  769. id: route.params.id,
  770. })
  771. .then((res) => {
  772. const d = res.data.result
  773. if (res.status === 200 && res.data.code === 1) {
  774. soData.value = d
  775. if (d.Package_not_complate === true) {
  776. ElNotification({
  777. duration: 0,
  778. type: 'error',
  779. title: '出错啦!',
  780. message: 'Please confirm current package before a create a new one',
  781. })
  782. return false
  783. }
  784. firstName.value = (route.query.firstName as string) || ''
  785. form.value.creator_userid = (route.query.userName as string) || ''
  786. form.value.job_name = d.Contract_Title
  787. form.value.so_ref = d.Reference
  788. form.value.ATTN = d.ATTN || ''
  789. form.value.Phone = d.Phone || ''
  790. form.value.Shipping_Unit_Building_Name =
  791. d.Shipping_Unit_Building_Name || ''
  792. form.value.Shipping_Street = d.Shipping_Street || ''
  793. form.value.Shipping_City = d.Shipping_City || ''
  794. form.value.Shipping_State = d.Shipping_State || ''
  795. form.value.Shipping_Code = d.Shipping_Code || ''
  796. form.value.Shipping_Country = d.Shipping_Country || ''
  797. }
  798. resetGoods()
  799. })
  800. const limitNumber = function (e: any, obj: any, key: string) {
  801. if (e) {
  802. obj[key] = Math.round(Number(e))
  803. }
  804. }
  805. const resetFileInput = function () {
  806. const input = document.getElementById('fileInput') as HTMLInputElement
  807. if (input) {
  808. input.value = ''
  809. }
  810. }
  811. const processFile = async function (event: any) {
  812. if (loading.value) {
  813. console.log('重复 change')
  814. // 如果正在上传, 无视重复选择文件动作
  815. resetFileInput()
  816. return
  817. }
  818. const files = event.target.files || event.dataTransfer.files
  819. loading.value = true
  820. Promise.all(
  821. Array.from(files).map((file: any) => {
  822. const fileForm = new FormData()
  823. fileForm.append('file', file)
  824. return request
  825. .post('/Shipping_tracking/uploadStraightFile', fileForm, {
  826. headers: {
  827. 'Content-Type': 'multipart/form-data',
  828. },
  829. })
  830. .then((res) => {
  831. const d = res.data
  832. if (![1, 200].includes(d.result.code)) {
  833. ElMessage.error(d.result?.message?.errmsg || 'error')
  834. } else {
  835. ElMessage.success(file.name + '上传成功')
  836. form.value.files.push({
  837. file_id: d.result.message.media_id || '',
  838. name: file.name,
  839. })
  840. }
  841. })
  842. }),
  843. ).finally(() => {
  844. loading.value = false
  845. // 处理上传完文件, 重置文件输入框内容
  846. resetFileInput()
  847. })
  848. }
  849. const checkForm = function (formEl: FormInstance | undefined) {
  850. if (!formEl) return
  851. formEl.validate((valid, fields) => {
  852. if (valid) {
  853. submit()
  854. } else {
  855. ElMessage.error('请检查表单必填项')
  856. }
  857. })
  858. }
  859. const submited = ref(false)
  860. const submit = function () {
  861. // 接口
  862. const d: any = {
  863. creator_userid: form.value.creator_userid,
  864. template_id: '3TmmDAekrafuPCvjxB9TqYwrmk5uj6XGoxseaD1J', // 申请模版 的id
  865. use_template_approver: 1, // 使用此模板在管理后台设置的审批流程
  866. apply_data: {
  867. contents: [
  868. {
  869. control: 'Text',
  870. id: 'Text-1718767851650',
  871. value: {
  872. text: form.value.so_ref,
  873. },
  874. },
  875. {
  876. control: 'Text',
  877. id: 'Text-1718767876049',
  878. value: {
  879. text: form.value.job_name,
  880. },
  881. },
  882. {
  883. control: 'Selector',
  884. id: 'Selector-1718767763003',
  885. value: {
  886. selector: {
  887. type: 'single',
  888. options: [
  889. {
  890. key: form.value.location,
  891. },
  892. ],
  893. },
  894. },
  895. },
  896. {
  897. // 运输方式
  898. control: 'Selector',
  899. id: 'Selector-1718767905142',
  900. value: {
  901. selector: {
  902. type: 'single',
  903. options: [
  904. {
  905. key: form.value.yunshu,
  906. },
  907. ],
  908. },
  909. },
  910. },
  911. {
  912. // 货运
  913. control: 'Selector',
  914. id: 'Selector-1718767971281',
  915. value: {
  916. selector: {
  917. type: 'single',
  918. options: [
  919. {
  920. key: form.value.huoyun,
  921. },
  922. ],
  923. },
  924. },
  925. },
  926. {
  927. // 中转
  928. control: 'Selector',
  929. id: 'Selector-1718768200256',
  930. value: {
  931. selector: {
  932. type: 'single',
  933. options: [
  934. {
  935. key: form.value.trans,
  936. },
  937. ],
  938. },
  939. },
  940. },
  941. {
  942. control: 'Number',
  943. id: 'Number-1718768439507',
  944. value: {
  945. new_number: form.value.number,
  946. },
  947. },
  948. {
  949. control: 'Number',
  950. id: 'Number-1718768458174',
  951. value: {
  952. new_number: form.value.weight,
  953. },
  954. },
  955. {
  956. // 地址
  957. control: 'Textarea',
  958. id: 'Textarea-1718769752197',
  959. value: {
  960. text: (
  961. (form.value.ATTN ? `ATTN ${form.value.ATTN}; ` : '') +
  962. (form.value.Phone ? `Phone ${form.value.Phone}` : '') +
  963. '\n' +
  964. form.value.Shipping_Unit_Building_Name +
  965. ', ' +
  966. form.value.Shipping_Street +
  967. ', ' +
  968. form.value.Shipping_City +
  969. ', ' +
  970. form.value.Shipping_State +
  971. ', ' +
  972. form.value.Shipping_Code +
  973. ', ' +
  974. form.value.Shipping_Country
  975. )
  976. .trim()
  977. .replace('null', ''),
  978. },
  979. },
  980. {
  981. // 装箱备注
  982. control: 'Textarea',
  983. id: 'Textarea-1718769807829',
  984. value: {
  985. text: form.value.comment,
  986. },
  987. },
  988. ] as any[],
  989. },
  990. summary_list: [
  991. {
  992. summary_info: [
  993. {
  994. text: locationList.filter((i) => i.key === form.value.location)[0]
  995. .value[0].text,
  996. lang: 'zh_CN',
  997. },
  998. ],
  999. },
  1000. {
  1001. summary_info: [
  1002. {
  1003. text: form.value.so_ref,
  1004. lang: 'zh_CN',
  1005. },
  1006. ],
  1007. },
  1008. {
  1009. summary_info: [
  1010. {
  1011. text: form.value.job_name,
  1012. lang: 'zh_CN',
  1013. },
  1014. ],
  1015. },
  1016. ],
  1017. }
  1018. if (form.value.yunshu === 'option-1718767952637') {
  1019. d.apply_data.contents.push({
  1020. control: 'Number',
  1021. id: 'Number-1718768530132',
  1022. value: {
  1023. new_number: form.value.cbm,
  1024. },
  1025. })
  1026. }
  1027. if (form.value.huoyun === 'option-1718768018003') {
  1028. d.apply_data.contents.push({
  1029. control: 'Selector',
  1030. id: 'Selector-1718768061055',
  1031. value: {
  1032. selector: {
  1033. type: 'single',
  1034. options: [
  1035. {
  1036. key: form.value.huodai,
  1037. },
  1038. ],
  1039. },
  1040. },
  1041. })
  1042. }
  1043. if (form.value.price.length) {
  1044. // 价格数据
  1045. d.apply_data.contents.push({
  1046. control: 'Table',
  1047. id: 'Table-1718768730236',
  1048. value: {
  1049. children: form.value.price.map((p) => {
  1050. return {
  1051. list: [
  1052. {
  1053. control: 'Text',
  1054. id: 'Text-1718769352473',
  1055. value: {
  1056. text: p.pa,
  1057. },
  1058. },
  1059. {
  1060. control: 'Text',
  1061. id: 'Text-1718769658148',
  1062. value: {
  1063. text: p.pb,
  1064. },
  1065. },
  1066. ],
  1067. }
  1068. }),
  1069. },
  1070. })
  1071. }
  1072. if (form.value.goods.length) {
  1073. // 货物数据
  1074. d.apply_data.contents.push({
  1075. control: 'Table',
  1076. id: 'Table-1718950612643',
  1077. value: {
  1078. children: form.value.goods
  1079. .filter((g) => g.number > 0)
  1080. .map((g) => {
  1081. if (g.number > g.quantity) {
  1082. setTimeout(() => {
  1083. ElNotification({
  1084. duration: 0,
  1085. type: 'warning',
  1086. title: '注意',
  1087. message: `${g.name} 发货数量${g.number}大于可发货数量${g.quantity}`,
  1088. })
  1089. }, 0)
  1090. }
  1091. return {
  1092. list: [
  1093. {
  1094. control: 'Text',
  1095. id: 'Text-1718950641228',
  1096. value: {
  1097. text: g.name,
  1098. },
  1099. },
  1100. {
  1101. control: 'Textarea',
  1102. id: 'Textarea-1718950654801',
  1103. value: {
  1104. text: g.desc,
  1105. },
  1106. },
  1107. {
  1108. control: 'Number',
  1109. id: 'Number-1718950666260',
  1110. value: {
  1111. new_number: g.number,
  1112. },
  1113. },
  1114. ],
  1115. }
  1116. }),
  1117. },
  1118. })
  1119. }
  1120. if (form.value.files.length) {
  1121. // 附件
  1122. d.apply_data.contents.push({
  1123. control: 'File',
  1124. id: 'File-1718769828663',
  1125. value: {
  1126. files: form.value.files.map((i) => {
  1127. return { file_id: i.file_id }
  1128. }),
  1129. },
  1130. })
  1131. }
  1132. d.sales_order_detail = soData.value
  1133. d.origin_form = form.value
  1134. console.log(d, 'form data')
  1135. loading.value = true
  1136. submited.value = true
  1137. request
  1138. .post('/Shipping_tracking/createShippingTracking', d)
  1139. .then((res) => {
  1140. const d = res.data
  1141. console.log(d, 'create approval')
  1142. if (d.result.code === 200 && d.code === 1) {
  1143. ElNotification({
  1144. duration: 0,
  1145. type: 'success',
  1146. title: '任务已成功处理',
  1147. message: '本页面将自动跳转CRM',
  1148. })
  1149. setTimeout(() => {
  1150. redirectToCRM()
  1151. }, 3500)
  1152. } else {
  1153. ElNotification({
  1154. duration: 0,
  1155. type: 'error',
  1156. title: '创建审核单出错!请联系管理员',
  1157. message: d.result.message?.errmsg || d.msg || '',
  1158. })
  1159. }
  1160. })
  1161. .finally(() => {
  1162. loading.value = false
  1163. })
  1164. }
  1165. const redirectToCRM = () => {
  1166. window.location.replace(import.meta.env.VITE_CRM_PATH)
  1167. }
  1168. const getLogoPath = function () {
  1169. return new URL('/assets/logo@2x.png', import.meta.url).href
  1170. }
  1171. </script>
  1172. <style lang="scss">
  1173. input[type='number'] {
  1174. -moz-appearance: textfield;
  1175. appearance: textfield;
  1176. &:hover {
  1177. -moz-appearance: textfield;
  1178. appearance: textfield;
  1179. &::-webkit-inner-spin-button,
  1180. &::-webkit-outer-spin-button {
  1181. -webkit-appearance: none;
  1182. margin: 0;
  1183. }
  1184. }
  1185. &::-webkit-inner-spin-button,
  1186. &::-webkit-outer-spin-button {
  1187. -webkit-appearance: none;
  1188. margin: 0;
  1189. }
  1190. }
  1191. </style>
  1192. <style lang="scss" scoped>
  1193. .main-content {
  1194. background-color: #fff;
  1195. padding: 12px 40px 12px;
  1196. width: 1000px;
  1197. min-width: 1000px;
  1198. min-height: 100vh;
  1199. margin: 0 auto;
  1200. box-shadow:
  1201. 0 0 0 1px rgba(255, 255, 255, 0.4) inset,
  1202. 0 0.5em 1em rgba(0, 0, 0, 0.6);
  1203. }
  1204. .logo-area {
  1205. padding: 12px 0 12px;
  1206. img {
  1207. position: relative;
  1208. left: -16px;
  1209. height: 60px;
  1210. }
  1211. }
  1212. .page-title {
  1213. font-size: 24px;
  1214. font-weight: 500;
  1215. color: #222;
  1216. }
  1217. .copyright {
  1218. position: absoloute;
  1219. text-align: right;
  1220. color: #ccc;
  1221. font-size: 14px;
  1222. line-height: 16px;
  1223. right: 16px;
  1224. }
  1225. .addr-input-group {
  1226. ::v-deep {
  1227. input,
  1228. textarea {
  1229. text-align: right;
  1230. }
  1231. }
  1232. .el-input,
  1233. .el-textarea {
  1234. margin-bottom: 10px;
  1235. &:last-of-type {
  1236. margin-bottom: 0;
  1237. }
  1238. }
  1239. }
  1240. </style>