index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. @get-list="getList">
  12. <template #code="{ item }">
  13. <div style="width: 100%">
  14. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="pushProcessApproval(item)">{{ item.code }}</a>
  15. </div>
  16. </template>
  17. <template #amount="{ item }">
  18. <div>
  19. <span style="padding-right: 4px">{{ item.currency }}</span>
  20. <span>{{ moneyFormat(item.amount, 2) }}</span>
  21. </div>
  22. </template>
  23. <template #sellCorporationName="{ item }">
  24. <div>
  25. <span v-if="item.sellCorporationName">{{ item.sellCorporationName }}</span>
  26. <span v-else>{{ item.oldSellCorporationName }}</span>
  27. </div>
  28. </template>
  29. <template #buyCorporationName="{ item }">
  30. <div>
  31. <span v-if="item.buyCorporationName">{{ item.buyCorporationName }}</span>
  32. <span v-else>{{ item.oldBuyCorporationName }}</span>
  33. </div>
  34. </template>
  35. </byTable>
  36. </div>
  37. <el-dialog title="打印" v-if="openPrint" v-model="openPrint" width="660">
  38. <div id="printMe">
  39. <div id="pdfDom" style="padding: 16px; font-size: 12px !important;font-family: 'msyh';">
  40. <div style="font-size: 18px; text-align: center">
  41. {{ printDetails.sellCorporationNameEn }}
  42. </div>
  43. <div style="text-align: center">
  44. {{ printDetails.sellDetailedAddress }},{{ printDetails.sellCityName }},{{ printDetails.sellProvinceName }},{{ printDetails.sellCountryName }}
  45. </div>
  46. <div style="font-size: 14px; color: #409eff; text-align: center; padding-top: 16px">PROFORMA INVOICE</div>
  47. <div style="padding-top: 8px">
  48. <div>PI NO. : {{ printDetails.contractCode }}</div>
  49. <div>PI DATE: {{ printDetails.createTimeEn }}</div>
  50. </div>
  51. <div style="border: 1px solid black; display: flex">
  52. <div style="width: 50%; border-right: 1px solid black">
  53. <div style="color: #409eff">VENDOR:</div>
  54. <div>{{ printDetails.sellCorporationNameEn }}</div>
  55. <div style="padding: 16px 0">
  56. {{ printDetails.sellDetailedAddress }},{{ printDetails.sellCityName }},{{ printDetails.sellProvinceName }},{{ printDetails.sellCountryName }}
  57. </div>
  58. <div>CONTACT: {{ printDetails.sellContactName }}</div>
  59. <div>TEL.: {{ printDetails.sellContactNumber }}</div>
  60. </div>
  61. <div style="width: 50%">
  62. <div style="color: #409eff">BUYER:</div>
  63. <div>{{ printDetails.buyCorporationName }}</div>
  64. <div style="padding: 16px 0">
  65. {{ printDetails.buyDetailedAddress }},{{ printDetails.buyCityName }},{{ printDetails.buyProvinceName }},{{ printDetails.buyCountryName }}
  66. </div>
  67. <div>CONTACT: {{ printDetails.buyContactName }}</div>
  68. <div>TEL.: {{ printDetails.buyContactNumber }}</div>
  69. </div>
  70. </div>
  71. <div style="height: 16px"></div>
  72. <div style="border: 1px solid black">
  73. <div style="display: flex; width: 100%">
  74. <div style="width: 33%; border-bottom: 1px solid black; border-right: 1px solid black">
  75. <div style="color: #409eff">COUNTRY OF ORIGIN:</div>
  76. <div>{{ printDetails.sellCountryName }}</div>
  77. </div>
  78. <div style="width: 34%; border-bottom: 1px solid black; border-right: 1px solid black">
  79. <div style="color: #409eff">COUNTRY OF DESTINATION:</div>
  80. <div>{{ printDetails.buyCountryName }}</div>
  81. </div>
  82. <div style="width: 33%; border-bottom: 1px solid black">
  83. <div style="color: #409eff">PLACE OF DISCHARGE:</div>
  84. <div>{{ printDetails.transportRemark }}</div>
  85. </div>
  86. </div>
  87. <div style="display: flex; width: 100%">
  88. <div style="width: 33%; border-bottom: 1px solid black; border-right: 1px solid black">
  89. <div style="color: #409eff">TERMS OF DELIVERY:</div>
  90. <div>
  91. {{ dictValueLabel(printDetails.tradeMethods, tradeMethods) }}
  92. </div>
  93. </div>
  94. <div style="width: 34%; border-bottom: 1px solid black; border-right: 1px solid black">
  95. <div style="color: #409eff">CURRENCY:</div>
  96. <div>
  97. {{ printDetails.currency }}
  98. </div>
  99. </div>
  100. <div style="width: 33%; border-bottom: 1px solid black">
  101. <div style="color: #409eff">EXPORT BY/VIA:</div>
  102. <div>
  103. {{ dictValueLabel(printDetails.transportMethod, shippingMethod) }}
  104. </div>
  105. </div>
  106. </div>
  107. <div style="display: flex; width: 100%">
  108. <div style="width: 33%; border-right: 1px solid black">
  109. <div style="color: #409eff">DELIVERY TIME:</div>
  110. <div>{{ printDetails.deliveryTime }}</div>
  111. </div>
  112. <div style="width: 67%">
  113. <div style="color: #409eff">TERMS OF PAYMENT:</div>
  114. <div>{{ printDetails.remark }}</div>
  115. </div>
  116. </div>
  117. </div>
  118. <div style="height: 16px"></div>
  119. <div class="baseRow" style="display: flex; color: #409eff">
  120. <div class="contentRow" style="width: 50px; text-align: center">NO.</div>
  121. <div class="contentRow" style="width: calc(100% - 450px); text-align: center">COMMODITY, SPECIFICATION</div>
  122. <div class="contentRow" style="width: 100px; text-align: center">UNIT</div>
  123. <div class="contentRow" style="width: 100px; text-align: center">QUANTITY</div>
  124. <div class="contentRow" style="width: 100px; text-align: center">UNIT PRICE</div>
  125. <div class="contentRow" style="width: 100px; text-align: center">TOTAL PRICE</div>
  126. </div>
  127. <div v-if="printDetails.productInfoList && printDetails.productInfoList.length > 0">
  128. <div class="baseRow" style="display: flex" v-for="(item, index) in printDetails.productInfoList" :key="item.productId">
  129. <div class="contentRow" style="width: 50px; text-align: center">
  130. {{ index + 1 }}
  131. </div>
  132. <div class="contentRow" style="width: calc(100% - 450px); text-align: center">
  133. {{ item.productName }}
  134. </div>
  135. <div class="contentRow" style="width: 100px; text-align: center">
  136. {{ dictValueLabel(item.productUnit, productUnit) }}
  137. </div>
  138. <div class="contentRow" style="width: 100px; text-align: center">
  139. {{ item.productQuantity }}
  140. </div>
  141. <div class="contentRow" style="width: 100px; text-align: center">
  142. {{ item.productPrice }}
  143. </div>
  144. <div class="contentRow" style="width: 100px; text-align: center">
  145. {{ item.amount }}
  146. </div>
  147. </div>
  148. </div>
  149. <div class="baseRow" style="display: flex; color: #409eff">
  150. <div class="contentRow" style="width: calc(100% - 400px); text-align: center">SUBTOTAL:</div>
  151. <div class="contentRow" style="width: 100px; text-align: center"></div>
  152. <div class="contentRow" style="width: 100px; text-align: center">
  153. {{ statistics("productQuantity", 0) }}
  154. </div>
  155. <div class="contentRow" style="width: 100px; text-align: center"></div>
  156. <div class="contentRow" style="width: 100px; text-align: center">
  157. {{ statistics("amount", 2) }}
  158. </div>
  159. </div>
  160. <div class="baseRow" style="display: flex">
  161. <div class="contentRow" style="width: calc(100% - 100px); text-align: right; color: #409eff">FREIGHT COST:</div>
  162. <div class="contentRow" style="width: 100px; text-align: center">
  163. {{ statisticsTwo("amount", 2) }}
  164. </div>
  165. </div>
  166. <div class="baseRow" style="display: flex">
  167. <div class="contentRow" style="width: calc(100% - 100px); text-align: right; color: #409eff">TOTAL PRICE:</div>
  168. <div class="contentRow" style="width: 100px; text-align: center">
  169. {{ printDetails.totalAmount }}
  170. </div>
  171. </div>
  172. <div class="baseRow" style="display: flex; border-bottom: 1px solid black">
  173. <div class="contentRow" style="width: 100%">
  174. {{ translateIntoEnglish(printDetails.totalAmount, printDetails.currency) }}
  175. </div>
  176. </div>
  177. <div style="height: 16px"></div>
  178. <div class="baseRow" style="color: #409eff">
  179. <div class="contentRow" style="width: 100%">ACCOUNT INFORMATION:</div>
  180. </div>
  181. <div class="baseRow" style="border-bottom: 1px solid black">
  182. <div class="contentRow" style="width: 100%">
  183. <div style="line-height: 24px; padding-left: 4px; word-break: break-all; word-wrap: break-word">
  184. Beneficiary Name: {{ printDetails.beneficiaryName }}
  185. </div>
  186. <div style="line-height: 24px; padding-left: 4px; word-break: break-all; word-wrap: break-word">
  187. Beneficiary Bank: {{ printDetails.beneficiaryBank }}
  188. </div>
  189. <div style="line-height: 24px; padding-left: 4px; word-break: break-all; word-wrap: break-word">
  190. Beneficiary Bank Address: {{ printDetails.beneficiaryBankAddress }}
  191. </div>
  192. <div style="line-height: 24px; padding-left: 4px; word-break: break-all; word-wrap: break-word">
  193. Beneficiary Account Number: {{ printDetails.beneficiaryAccountNumber }}
  194. </div>
  195. <div style="line-height: 24px; padding-left: 4px; word-break: break-all; word-wrap: break-word">Swift Code: {{ printDetails.swiftCode }}</div>
  196. <div style="line-height: 24px; padding-left: 4px; word-break: break-all; word-wrap: break-word">
  197. Beneficiary Address: {{ printDetails.beneficiaryAddress }}
  198. </div>
  199. </div>
  200. </div>
  201. <div style="height: 32px"></div>
  202. <div style="display: flex">
  203. <div style="width: 50%">
  204. <div style="color: #409eff">CONFIRMED BY VENDOR:</div>
  205. <div>{{ printDetails.sellCorporationNameEn }}</div>
  206. </div>
  207. <div style="width: 50%">
  208. <div style="color: #409eff">CONFIRMED BY BUYER:</div>
  209. <div>{{ printDetails.buyCorporationName }}</div>
  210. </div>
  211. </div>
  212. </div>
  213. </div>
  214. <template #footer>
  215. <el-button @click="openPrint = false" size="large">取消</el-button>
  216. <el-button v-print="printObj" size="large">打印</el-button>
  217. <el-button type="primary" @click="clickDownload()" size="large">下载PDF</el-button>
  218. </template>
  219. </el-dialog>
  220. <el-dialog title="编辑" v-if="openUpdate" v-model="openUpdate" width="500">
  221. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="update">
  222. <template #sellContactName>
  223. <div style="width: 100%">
  224. <el-autocomplete
  225. v-model="formData.data.sellContactName"
  226. :fetch-suggestions="querySearchSellPerson"
  227. clearable
  228. class="inline-input w-50"
  229. placeholder="请输入联系人"
  230. @select="handleSellPerson">
  231. </el-autocomplete>
  232. </div>
  233. </template>
  234. <template #buyContactName>
  235. <div style="width: 100%">
  236. <el-autocomplete
  237. v-model="formData.data.buyContactName"
  238. :fetch-suggestions="querySearchBuyPerson"
  239. clearable
  240. class="inline-input w-50"
  241. placeholder="请输入联系人"
  242. @select="handleBuyPerson">
  243. </el-autocomplete>
  244. </div>
  245. </template>
  246. </byForm>
  247. <template #footer>
  248. <el-button @click="openUpdate = false" size="large">取 消</el-button>
  249. <el-button type="primary" @click="clickSubmit()" size="large">确 定</el-button>
  250. </template>
  251. </el-dialog>
  252. </div>
  253. </template>
  254. <script setup>
  255. import { computed, ref } from "vue";
  256. import byTable from "@/components/byTable/index";
  257. import { ElMessage } from "element-plus";
  258. import byForm from "@/components/byForm/index";
  259. const { proxy } = getCurrentInstance();
  260. const tradeMethods = ref([]);
  261. const corporationList = ref([]);
  262. const shippingMethod = ref([]);
  263. const productUnit = ref([]);
  264. const sellPerson = ref([]);
  265. const buyPerson = ref([]);
  266. const sourceList = ref({
  267. data: [],
  268. pagination: {
  269. total: 0,
  270. pageNum: 1,
  271. pageSize: 10,
  272. keyword: "",
  273. },
  274. });
  275. const loading = ref(false);
  276. const selectConfig = computed(() => {
  277. return [
  278. {
  279. label: "销售方",
  280. prop: "sellCorporationId",
  281. data: corporationList.value,
  282. },
  283. {
  284. label: "采购方",
  285. prop: "buyCorporationId",
  286. data: corporationList.value,
  287. },
  288. ];
  289. });
  290. const config = computed(() => {
  291. return [
  292. {
  293. attrs: {
  294. label: "合同编码",
  295. slot: "code",
  296. width: 220,
  297. },
  298. },
  299. {
  300. attrs: {
  301. label: "合同金额",
  302. slot: "amount",
  303. width: 140,
  304. },
  305. },
  306. {
  307. attrs: {
  308. label: "销售方",
  309. slot: "sellCorporationName",
  310. "min-width": 200,
  311. },
  312. },
  313. {
  314. attrs: {
  315. label: "采购方",
  316. slot: "buyCorporationName",
  317. "min-width": 200,
  318. },
  319. },
  320. {
  321. attrs: {
  322. label: "最近操作人",
  323. prop: "opUserName",
  324. width: 180,
  325. },
  326. },
  327. {
  328. attrs: {
  329. label: "最近操作时间",
  330. prop: "updateTime",
  331. width: 180,
  332. },
  333. },
  334. {
  335. attrs: {
  336. label: "操作",
  337. width: "120",
  338. align: "center",
  339. fixed: "right",
  340. },
  341. renderHTML(row) {
  342. return [
  343. {
  344. attrs: {
  345. label: "编辑",
  346. type: "primary",
  347. text: true,
  348. },
  349. el: "button",
  350. click() {
  351. clickUpdate(row);
  352. },
  353. },
  354. {
  355. attrs: {
  356. label: "打印",
  357. type: "primary",
  358. text: true,
  359. },
  360. el: "button",
  361. click() {
  362. clickPrint(row);
  363. },
  364. },
  365. ];
  366. },
  367. },
  368. ];
  369. });
  370. const getDict = () => {
  371. proxy.getDictOne(["trade_mode", "shipping_method", "unit"]).then((res) => {
  372. if (res.trade_mode && res.trade_mode.length > 0) {
  373. tradeMethods.value = res.trade_mode.map((x) => ({
  374. label: x.dictValue,
  375. value: x.dictKey,
  376. }));
  377. }
  378. if (res.shipping_method && res.shipping_method.length > 0) {
  379. shippingMethod.value = res.shipping_method.map((x) => ({
  380. label: x.dictValue,
  381. value: x.dictKey,
  382. }));
  383. }
  384. if (res.unit && res.unit.length > 0) {
  385. productUnit.value = res.unit.map((x) => ({
  386. label: x.dictValue,
  387. value: x.dictKey,
  388. }));
  389. }
  390. });
  391. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  392. corporationList.value = res.rows.map((item) => {
  393. return {
  394. ...item,
  395. label: item.name,
  396. value: item.id,
  397. };
  398. });
  399. });
  400. };
  401. const getPerson = () => {
  402. proxy.post("/intermediateContract/contactList", {}).then((res) => {
  403. sellPerson.value = res.map((item) => {
  404. return {
  405. ...item,
  406. value: item.sellContactName,
  407. };
  408. });
  409. buyPerson.value = res.map((item) => {
  410. return {
  411. ...item,
  412. value: item.buyContactName,
  413. };
  414. });
  415. });
  416. };
  417. const getList = async (req) => {
  418. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  419. loading.value = true;
  420. proxy.post("/intermediateContract/page", sourceList.value.pagination).then((res) => {
  421. sourceList.value.data = res.rows;
  422. sourceList.value.pagination.total = res.total;
  423. setTimeout(() => {
  424. loading.value = false;
  425. }, 200);
  426. });
  427. };
  428. getDict();
  429. getList();
  430. const openPrint = ref(false);
  431. const printDetails = ref({});
  432. const clickPrint = (row) => {
  433. printDetails.value = {};
  434. openPrint.value = true;
  435. proxy.post("/intermediateContract/getPrintInfo", { documentsId: row.documentsId }).then((res) => {
  436. printDetails.value = res;
  437. });
  438. };
  439. const clickDownload = () => {
  440. proxy.getPdf("外销合同PDF文件");
  441. };
  442. const statistics = (label, index) => {
  443. let num = 0;
  444. if (printDetails.value.productInfoList && printDetails.value.productInfoList.length > 0) {
  445. printDetails.value.productInfoList.map((item) => {
  446. if (item[label]) {
  447. num = parseFloat(Number(num) + Number(item[label])).toFixed(index);
  448. }
  449. });
  450. }
  451. return num;
  452. };
  453. const statisticsTwo = (label, index) => {
  454. let num = 0;
  455. if (printDetails.value.contractProjectList && printDetails.value.contractProjectList.length > 0) {
  456. printDetails.value.contractProjectList.map((item) => {
  457. if (item[label]) {
  458. num = parseFloat(Number(num) + Number(item[label])).toFixed(index);
  459. }
  460. });
  461. }
  462. return num;
  463. };
  464. const pushProcessApproval = (row) => {
  465. proxy.$router.push({
  466. path: "/platform_manage/process/processApproval",
  467. query: {
  468. flowKey: "contract_flow",
  469. id: row.flowId,
  470. processType: 20,
  471. random: proxy.random(),
  472. flowName: "销售合同详情",
  473. },
  474. });
  475. return;
  476. };
  477. const printObj = ref({
  478. id: "printMe",
  479. popTitle: "",
  480. extraCss: "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
  481. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  482. });
  483. const openUpdate = ref(false);
  484. const update = ref(null);
  485. const formData = reactive({
  486. data: {},
  487. });
  488. const formOption = reactive({
  489. inline: true,
  490. labelWidth: 100,
  491. itemWidth: 100,
  492. rules: [],
  493. });
  494. const formConfig = computed(() => {
  495. return [
  496. {
  497. type: "select",
  498. label: "销售方",
  499. prop: "sellCorporationId",
  500. data: corporationList.value,
  501. },
  502. {
  503. type: "slot",
  504. slotName: "sellContactName",
  505. prop: "sellContactName",
  506. label: "销售联系信息",
  507. itemWidth: 40,
  508. },
  509. {
  510. type: "input",
  511. prop: "sellContactNumber",
  512. label: " ",
  513. itemWidth: 60,
  514. itemType: "text",
  515. },
  516. {
  517. type: "select",
  518. label: "采购方",
  519. prop: "buyCorporationId",
  520. data: corporationList.value,
  521. },
  522. {
  523. type: "slot",
  524. slotName: "buyContactName",
  525. prop: "buyContactName",
  526. label: "采购联系信息",
  527. itemWidth: 40,
  528. },
  529. {
  530. type: "input",
  531. prop: "buyContactNumber",
  532. label: " ",
  533. itemWidth: 60,
  534. itemType: "text",
  535. },
  536. ];
  537. });
  538. const rules = ref({
  539. sellCorporationId: [{ required: true, message: "请选择销售方", trigger: "change" }],
  540. sellContactName: [{ required: true, message: "请输入销售联系人", trigger: "blur" }],
  541. sellContactNumber: [{ required: true, message: "请输入销售联系电话", trigger: "blur" }],
  542. buyCorporationId: [{ required: true, message: "请选择采购方", trigger: "change" }],
  543. buyContactName: [{ required: true, message: "请输入采购联系人", trigger: "blur" }],
  544. buyContactNumber: [{ required: true, message: "请输入采购联系电话", trigger: "blur" }],
  545. });
  546. const clickUpdate = (row) => {
  547. getPerson();
  548. formData.data = {
  549. documentsId: row.documentsId,
  550. sellCorporationId: "",
  551. sellContactName: "",
  552. sellContactNumber: "",
  553. buyCorporationId: "",
  554. buyContactName: "",
  555. buyContactNumber: "",
  556. };
  557. openUpdate.value = true;
  558. };
  559. const clickSubmit = () => {
  560. update.value.handleSubmit(() => {
  561. proxy.post("/intermediateContract/edit", formData.data).then((res) => {
  562. printDetails.value = res;
  563. ElMessage({
  564. message: "编辑成功",
  565. type: "success",
  566. });
  567. openUpdate.value = false;
  568. getList();
  569. });
  570. });
  571. };
  572. const createFilter = (queryString) => {
  573. return (restaurant) => {
  574. return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
  575. };
  576. };
  577. const querySearchSellPerson = (queryString, callback) => {
  578. const resultsSell = queryString ? sellPerson.value.filter(createFilter(queryString)) : sellPerson.value;
  579. callback(resultsSell);
  580. };
  581. const handleSellPerson = (item) => {
  582. formData.data.sellContactNumber = item.sellContactNumber;
  583. };
  584. const querySearchBuyPerson = (queryString, callback) => {
  585. const resultsBuy = queryString ? buyPerson.value.filter(createFilter(queryString)) : buyPerson.value;
  586. callback(resultsBuy);
  587. };
  588. const handleBuyPerson = (item) => {
  589. formData.data.buyContactNumber = item.buyContactNumber;
  590. };
  591. </script>
  592. <style lang="scss" scoped>
  593. .tenant {
  594. padding: 20px;
  595. }
  596. ::v-deep(.el-input-number .el-input__inner) {
  597. text-align: left;
  598. }
  599. .baseRow {
  600. min-height: 24px;
  601. border-top: 1px solid black;
  602. border-left: 1px solid black;
  603. }
  604. .contentRow {
  605. border-right: 1px solid black;
  606. line-height: 24px;
  607. padding-left: 4px;
  608. }
  609. </style>