index.vue 32 KB

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