index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. <template>
  2. <div class="tenant">
  3. <byTable
  4. :hideTable="true"
  5. :hidePagination="true"
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :statConfig="statConfig"
  10. :loading="loading"
  11. :selectConfig="selectConfig"
  12. highlight-current-row
  13. :action-list="[
  14. {
  15. text: '默认汇率',
  16. action: () => openModal(),
  17. },
  18. ]"
  19. @get-list="getList"
  20. >
  21. </byTable>
  22. <div
  23. style="padding: 0 20px 20px 20px; background-color: white"
  24. v-if="rateStatus"
  25. >
  26. <el-table :data="sourceList.data">
  27. <el-table-column label="合同编号" prop="code" width="160" fixed />
  28. <el-table-column
  29. label="客户名称"
  30. prop="customerName"
  31. min-width="200"
  32. fixed
  33. />
  34. <el-table-column label="业务员" prop="userName" width="140" fixed />
  35. <el-table-column label="合同金额" width="140">
  36. <template #default="{ row }">
  37. <div>{{ row.currency }} {{ row.amount }}</div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="应付货款" width="140">
  41. <template #default="{ row }">
  42. <div>
  43. <span v-if="row.otherSumAmount">{{ row.otherSumAmount }}</span>
  44. <span v-else>{{ row.ehsdSumAmount }}</span>
  45. </div>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="税率" width="140">
  49. <template #default="{ row }">
  50. <div>13%</div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. label="应退税金额"
  55. prop="refundableAmount"
  56. width="140"
  57. />
  58. <el-table-column label="包材金额" width="140">
  59. <template #default="{ row }">
  60. <div>{{ row.peritectoidAmount }}</div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="配件金额" width="140">
  64. <template #default="{ row }">
  65. <div>{{ row.accessoriesAmount }}</div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="拖车费" width="140">
  69. <template #default="{ row }">
  70. <div>{{ row.trailerFee }}</div>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="报关费" width="140">
  74. <template #default="{ row }">
  75. <div>{{ row.customsFee }}</div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="代理费" width="140">
  79. <template #default="{ row }">
  80. <div>{{ row.agencyFee }}</div>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="港杂费" width="140">
  84. <template #default="{ row }">
  85. <div>{{ row.portMixedFee }}</div>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="验货红包" width="140">
  89. <template #default="{ row }">
  90. <div>
  91. {{ row.inspectionRedPack }}
  92. </div>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="佣金" width="140">
  96. <template #default="{ row }">
  97. <div>{{ row.commission }}</div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="其他" width="140">
  101. <template #default="{ row }">
  102. <div>{{ row.other }}</div>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="收入总计" prop="incomeAmount" width="140" />
  106. <el-table-column
  107. label="支出总计"
  108. prop="expenditureAmount"
  109. width="140"
  110. />
  111. <el-table-column label="毛利率" width="140">
  112. <template #default="{ row }">
  113. <div>{{ parseFloat(row.grossRate).toFixed(2) }}%</div>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="毛利" prop="gross" width="140" />
  117. <el-table-column label="操作" align="center" width="160" fixed="right">
  118. <template #default="{ row }">
  119. <div>
  120. <el-button type="primary" @click="changeExchangeRate(row)" link
  121. >汇率</el-button
  122. >
  123. <el-button type="primary" @click="changeBudget(row)" link
  124. >预算</el-button
  125. >
  126. </div>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <el-row style="padding: 20px" justify="end" type="flex">
  131. <el-pagination
  132. background
  133. layout="total, sizes, prev, pager, next, jumper"
  134. :current-page="sourceList.pagination.pageNum"
  135. :page-size="sourceList.pagination.pageSize"
  136. :total="sourceList.pagination.total"
  137. @size-change="handleSizeChange"
  138. @current-change="handlePageChange"
  139. />
  140. </el-row>
  141. </div>
  142. <el-dialog
  143. title="默认汇率"
  144. v-if="dialogVisible"
  145. v-model="dialogVisible"
  146. width="600"
  147. >
  148. <byForm
  149. :formConfig="formConfig"
  150. :formOption="formOption"
  151. v-model="formData.data"
  152. :rules="rules"
  153. ref="submit"
  154. >
  155. <template #currencyList>
  156. <el-table
  157. :data="formData.data.list"
  158. style="width: 100%"
  159. v-loading="loadingDialog"
  160. >
  161. <el-table-column label="币种">
  162. <template #default="{ row }">
  163. <div>{{ dictValueLabel(row.type, accountCurrency) }}</div>
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="兑 CHY 汇率">
  167. <template #default="{ row, $index }">
  168. <el-form-item
  169. :prop="'list.' + $index + '.rate'"
  170. :rules="rules.rate"
  171. :inline-message="true"
  172. >
  173. <el-input-number
  174. onmousewheel="return false;"
  175. v-model="row.rate"
  176. placeholder="请输入兑 CHY 汇率"
  177. style="width: 100%"
  178. :precision="6"
  179. :controls="false"
  180. :min="0"
  181. />
  182. </el-form-item>
  183. </template>
  184. </el-table-column>
  185. </el-table>
  186. </template>
  187. </byForm>
  188. <template #footer>
  189. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  190. <el-button type="primary" @click="submitForm()" size="large"
  191. >确 定</el-button
  192. >
  193. </template>
  194. </el-dialog>
  195. <el-dialog
  196. title="调整汇率"
  197. v-if="openChange"
  198. v-model="openChange"
  199. width="600"
  200. >
  201. <byForm
  202. :formConfig="formChangeConfig"
  203. :formOption="formOption"
  204. v-model="formChangeData.data"
  205. :rules="rules"
  206. ref="change"
  207. >
  208. <template #currencyList>
  209. <el-table
  210. :data="formChangeData.data.list"
  211. style="width: 100%"
  212. v-loading="loadingDialog"
  213. >
  214. <el-table-column label="币种">
  215. <template #default="{ row }">
  216. <div>{{ dictValueLabel(row.type, accountCurrency) }}</div>
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="兑 CHY 汇率">
  220. <template #default="{ row, $index }">
  221. <el-form-item
  222. :prop="'list.' + $index + '.rate'"
  223. :rules="rules.rate"
  224. :inline-message="true"
  225. >
  226. <el-input-number
  227. onmousewheel="return false;"
  228. v-model="row.rate"
  229. placeholder="请输入兑 CHY 汇率"
  230. style="width: 100%"
  231. :precision="6"
  232. :controls="false"
  233. :min="0"
  234. />
  235. </el-form-item>
  236. </template>
  237. </el-table-column>
  238. </el-table>
  239. </template>
  240. </byForm>
  241. <template #footer>
  242. <el-button @click="openChange = false" size="large">取 消</el-button>
  243. <el-button type="primary" @click="submitChangeForm()" size="large"
  244. >确 定</el-button
  245. >
  246. </template>
  247. </el-dialog>
  248. <el-dialog title="预算" v-if="openBudget" v-model="openBudget" width="400">
  249. <byForm
  250. :formConfig="formBudgetConfig"
  251. :formOption="formOption"
  252. v-model="formBudgetData.data"
  253. ref="budget"
  254. >
  255. <template #budgetMoney>
  256. <div style="width: 100%">
  257. <el-form-item label="拖车费" prop="trailerFee">
  258. <el-input
  259. v-model="formBudgetData.data.trailerFee"
  260. placeholder="请输入拖车费"
  261. class="input-with-select"
  262. >
  263. <template #prepend>
  264. <el-select
  265. v-model="formBudgetData.data.trailerFeeCurrency"
  266. placeholder="请选择货币"
  267. style="width: 115px"
  268. disabled
  269. >
  270. <el-option
  271. v-for="(item, index) in accountCurrency"
  272. :key="index"
  273. :label="item.label"
  274. :value="item.value"
  275. />
  276. </el-select>
  277. </template>
  278. </el-input>
  279. </el-form-item>
  280. <el-form-item
  281. label="报关费"
  282. prop="customsFee"
  283. style="margin-top: 20px"
  284. >
  285. <el-input
  286. v-model="formBudgetData.data.customsFee"
  287. placeholder="请输入报关费"
  288. class="input-with-select"
  289. >
  290. <template #prepend>
  291. <el-select
  292. v-model="formBudgetData.data.customsFeeCurrency"
  293. placeholder="请选择货币"
  294. style="width: 115px"
  295. disabled
  296. >
  297. <el-option
  298. v-for="(item, index) in accountCurrency"
  299. :key="index"
  300. :label="item.label"
  301. :value="item.value"
  302. />
  303. </el-select>
  304. </template>
  305. </el-input>
  306. </el-form-item>
  307. <el-form-item
  308. label="代理费"
  309. prop="agencyFee"
  310. style="margin-top: 20px"
  311. >
  312. <el-input
  313. v-model="formBudgetData.data.agencyFee"
  314. placeholder="请输入代理费"
  315. class="input-with-select"
  316. >
  317. <template #prepend>
  318. <el-select
  319. v-model="formBudgetData.data.agencyFeeCurrency"
  320. placeholder="请选择货币"
  321. style="width: 115px"
  322. disabled
  323. >
  324. <el-option
  325. v-for="(item, index) in accountCurrency"
  326. :key="index"
  327. :label="item.label"
  328. :value="item.value"
  329. />
  330. </el-select>
  331. </template>
  332. </el-input>
  333. </el-form-item>
  334. <el-form-item
  335. label="港杂费"
  336. prop="portMixedFee"
  337. style="margin-top: 20px"
  338. >
  339. <el-input
  340. v-model="formBudgetData.data.portMixedFee"
  341. placeholder="请输入港杂费"
  342. class="input-with-select"
  343. >
  344. <template #prepend>
  345. <el-select
  346. v-model="formBudgetData.data.portMixedFeeCurrency"
  347. placeholder="请选择货币"
  348. style="width: 115px"
  349. disabled
  350. >
  351. <el-option
  352. v-for="(item, index) in accountCurrency"
  353. :key="index"
  354. :label="item.label"
  355. :value="item.value"
  356. />
  357. </el-select>
  358. </template>
  359. </el-input>
  360. </el-form-item>
  361. <el-form-item
  362. label="验货红包"
  363. prop="inspectionRedPack"
  364. style="margin-top: 20px"
  365. >
  366. <el-input
  367. v-model="formBudgetData.data.inspectionRedPack"
  368. placeholder="请输入验货红包"
  369. class="input-with-select"
  370. >
  371. <template #prepend>
  372. <el-select
  373. v-model="formBudgetData.data.inspectionRedPackCurrency"
  374. placeholder="请选择货币"
  375. style="width: 115px"
  376. disabled
  377. >
  378. <el-option
  379. v-for="(item, index) in accountCurrency"
  380. :key="index"
  381. :label="item.label"
  382. :value="item.value"
  383. />
  384. </el-select>
  385. </template>
  386. </el-input>
  387. </el-form-item>
  388. <el-form-item
  389. label="佣金"
  390. prop="commission"
  391. style="margin-top: 20px"
  392. >
  393. <el-input
  394. v-model="formBudgetData.data.commission"
  395. placeholder="请输入佣金"
  396. class="input-with-select"
  397. >
  398. <template #prepend>
  399. <el-select
  400. v-model="formBudgetData.data.commissionCurrency"
  401. placeholder="请选择货币"
  402. style="width: 115px"
  403. disabled
  404. >
  405. <el-option
  406. v-for="(item, index) in accountCurrency"
  407. :key="index"
  408. :label="item.label"
  409. :value="item.value"
  410. />
  411. </el-select>
  412. </template>
  413. </el-input>
  414. </el-form-item>
  415. <el-form-item label="其他" prop="other" style="margin-top: 20px">
  416. <el-input
  417. v-model="formBudgetData.data.other"
  418. placeholder="请输入其他"
  419. class="input-with-select"
  420. >
  421. <template #prepend>
  422. <el-select
  423. v-model="formBudgetData.data.otherCurrency"
  424. placeholder="请选择货币"
  425. style="width: 115px"
  426. disabled
  427. >
  428. <el-option
  429. v-for="(item, index) in accountCurrency"
  430. :key="index"
  431. :label="item.label"
  432. :value="item.value"
  433. />
  434. </el-select>
  435. </template>
  436. </el-input>
  437. </el-form-item>
  438. </div>
  439. </template>
  440. </byForm>
  441. <template #footer>
  442. <el-button @click="openBudget = false" size="large">取 消</el-button>
  443. <el-button type="primary" @click="submitBudgetForm()" size="large"
  444. >确 定</el-button
  445. >
  446. </template>
  447. </el-dialog>
  448. </div>
  449. </template>
  450. <script setup>
  451. import { computed, ref } from "vue";
  452. import byTable from "@/components/byTable/index";
  453. import byForm from "@/components/byForm/index";
  454. import useUserStore from "@/store/modules/user";
  455. import { ElMessage } from "element-plus";
  456. const { proxy } = getCurrentInstance();
  457. const accountCurrency = ref([]);
  458. const userList = ref([]);
  459. const sourceList = ref({
  460. data: [],
  461. pagination: {
  462. total: 0,
  463. pageNum: 1,
  464. pageSize: 10,
  465. keyword: "",
  466. userId: "",
  467. },
  468. });
  469. const loading = ref(false);
  470. const selectConfig = computed(() => {
  471. return [
  472. {
  473. label: "业务员",
  474. prop: "userId",
  475. data: userList.value,
  476. },
  477. ];
  478. });
  479. const config = computed(() => {
  480. return [];
  481. });
  482. const headerData = ref({});
  483. const statConfig = computed(() => [
  484. {
  485. label: "统计",
  486. data: [
  487. //一个卡牌多数据配置
  488. {
  489. label: "订单统计(CNY)",
  490. type: 2,
  491. data: [
  492. {
  493. label: "销售总金额",
  494. num: proxy.moneyFormat(headerData.value.contractSumAmount, 2),
  495. color: "#C280FF",
  496. },
  497. {
  498. label: "采购总金额",
  499. num: proxy.moneyFormat(headerData.value.purchaseSumAmount, 2),
  500. color: "#C280FF",
  501. },
  502. ],
  503. },
  504. {
  505. label: "收入统计(CNY)",
  506. type: 3,
  507. data: [
  508. {
  509. label: "应退税",
  510. num: proxy.moneyFormat(headerData.value.taxReturnMoneySumAmount, 2),
  511. color: "#FF9315",
  512. },
  513. ],
  514. },
  515. {
  516. label: "支出统计(CNY)",
  517. type: 5,
  518. data: [
  519. {
  520. label: "包材金额",
  521. num: proxy.moneyFormat(headerData.value.peritectoidSumAmount, 2),
  522. color: "#FF6F67",
  523. },
  524. {
  525. label: "配件金额",
  526. num: proxy.moneyFormat(headerData.value.accessoriesSumAmount, 2),
  527. color: "#FF6F67",
  528. },
  529. {
  530. label: "拖车费",
  531. num: proxy.moneyFormat(headerData.value.trailerFeeSumAmount, 2),
  532. color: "#FF6F67",
  533. },
  534. {
  535. label: "报关费",
  536. num: proxy.moneyFormat(headerData.value.customsFeeSumAmount, 2),
  537. color: "#FF6F67",
  538. },
  539. {
  540. label: "代理费",
  541. num: proxy.moneyFormat(headerData.value.agencyFeeSumAmount, 2),
  542. color: "#FF6F67",
  543. },
  544. {
  545. label: "港杂费",
  546. num: proxy.moneyFormat(headerData.value.portMixedFeeSumAmount, 2),
  547. color: "#FF6F67",
  548. },
  549. {
  550. label: "验货红包",
  551. num: proxy.moneyFormat(
  552. headerData.value.inspectionRedPackSumAmount,
  553. 2
  554. ),
  555. color: "#FF6F67",
  556. },
  557. {
  558. label: "佣金",
  559. num: proxy.moneyFormat(headerData.value.commissionSumAmount, 2),
  560. color: "#FF6F67",
  561. },
  562. {
  563. label: "其他",
  564. num: proxy.moneyFormat(headerData.value.otherSumAmount, 2),
  565. color: "#FF6F67",
  566. },
  567. ],
  568. },
  569. {
  570. label: "收支统计(CNY)",
  571. type: 1,
  572. data: [
  573. {
  574. label: "总收入",
  575. num: proxy.moneyFormat(headerData.value.totalIncomeSumAmount, 2),
  576. color: "#0084ff",
  577. },
  578. {
  579. label: "总支出",
  580. num: proxy.moneyFormat(headerData.value.totalExpensesSumAmount, 2),
  581. color: "#0084ff",
  582. },
  583. {
  584. label: "总毛利",
  585. num: proxy.moneyFormat(headerData.value.grossProfitSum, 2),
  586. color: "#0084ff",
  587. },
  588. {
  589. label: "毛利率",
  590. num: headerData.value.grossProfitMargin + " %",
  591. color: "#0084ff",
  592. },
  593. ],
  594. },
  595. ],
  596. },
  597. ]);
  598. const getDict = () => {
  599. proxy
  600. .post("/dictTenantData/page", {
  601. pageNum: 1,
  602. pageSize: 999,
  603. dictCode: "account_currency",
  604. tenantId: useUserStore().user.tenantId,
  605. })
  606. .then((res) => {
  607. if (res.rows && res.rows.length > 0) {
  608. accountCurrency.value = res.rows.map((item) => {
  609. return {
  610. label: item.dictValue,
  611. value: item.dictKey,
  612. };
  613. });
  614. judgeRate();
  615. } else {
  616. ElMessage("请先添加货币");
  617. }
  618. });
  619. proxy
  620. .get("/tenantUser/list", {
  621. pageNum: 1,
  622. pageSize: 10000,
  623. tenantId: useUserStore().user.tenantId,
  624. })
  625. .then((res) => {
  626. userList.value = res.rows.map((item) => {
  627. return {
  628. label: item.nickName,
  629. value: item.userId,
  630. };
  631. });
  632. });
  633. };
  634. const getList = async (req) => {
  635. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  636. loading.value = true;
  637. proxy
  638. .post("/contract/getProfitBudgetPage", sourceList.value.pagination)
  639. .then((res) => {
  640. sourceList.value.data = res.rows;
  641. sourceList.value.pagination.total = res.total;
  642. setTimeout(() => {
  643. loading.value = false;
  644. }, 200);
  645. });
  646. proxy
  647. .post("/contract/getProfitBudgetHeadStatistic", sourceList.value.pagination)
  648. .then((res) => {
  649. headerData.value = res;
  650. });
  651. };
  652. const rateStatus = ref(false);
  653. const judgeRate = () => {
  654. proxy.post("/currencyRate/list", {}).then(
  655. (res) => {
  656. if (res && res.length > 0) {
  657. for (let i = 0; i < accountCurrency.value.length; i++) {
  658. let currencyStatus = true;
  659. for (let j = 0; j < res.length; j++) {
  660. if (accountCurrency.value[i].value === res[j].type) {
  661. currencyStatus = false;
  662. break;
  663. }
  664. }
  665. if (currencyStatus) {
  666. return ElMessage("请先完成默认汇率的配置");
  667. }
  668. }
  669. rateStatus.value = true;
  670. getList();
  671. } else {
  672. ElMessage("请先完成默认汇率的配置");
  673. }
  674. },
  675. (err) => {
  676. console.log(err);
  677. ElMessage("请先完成默认汇率的配置");
  678. }
  679. );
  680. };
  681. getDict();
  682. const handleSizeChange = (val) => {
  683. sourceList.value.pagination.pageNum = 1;
  684. sourceList.value.pagination.pageSize = val;
  685. getList();
  686. };
  687. const handlePageChange = (val) => {
  688. sourceList.value.pagination.pageNum = val;
  689. getList();
  690. };
  691. const dialogVisible = ref(false);
  692. const loadingDialog = ref(false);
  693. const submit = ref(null);
  694. const formOption = reactive({
  695. inline: true,
  696. labelWidth: 100,
  697. itemWidth: 100,
  698. rules: [],
  699. });
  700. const formData = reactive({
  701. data: {
  702. list: [],
  703. },
  704. });
  705. const formConfig = computed(() => {
  706. return [
  707. {
  708. type: "slot",
  709. prop: "currencyList",
  710. slotName: "currencyList",
  711. label: "",
  712. },
  713. ];
  714. });
  715. const rules = ref({
  716. rate: [{ required: true, message: "请输入兑 CHY 汇率", trigger: "blur" }],
  717. });
  718. const openModal = () => {
  719. if (accountCurrency.value && accountCurrency.value.length > 0) {
  720. formData.data = {
  721. list: accountCurrency.value.map((item) => {
  722. return {
  723. id: "",
  724. type: item.value,
  725. rate: 1,
  726. };
  727. }),
  728. };
  729. } else {
  730. formData.data = {
  731. list: [],
  732. };
  733. }
  734. loadingDialog.value = true;
  735. dialogVisible.value = true;
  736. proxy.post("/currencyRate/list", {}).then(
  737. (res) => {
  738. if (res && res.length > 0 && formData.data.list.length > 0) {
  739. formData.data.list = formData.data.list.map((item) => {
  740. for (let i = 0; i < res.length; i++) {
  741. if (item.type === res[i].type) {
  742. item.id = res[i].id;
  743. item.rate = res[i].rate;
  744. break;
  745. }
  746. }
  747. return {
  748. ...item,
  749. };
  750. });
  751. }
  752. loadingDialog.value = false;
  753. },
  754. (err) => {
  755. console.log(err);
  756. loadingDialog.value = false;
  757. }
  758. );
  759. };
  760. const submitForm = () => {
  761. submit.value.handleSubmit(() => {
  762. loadingDialog.value = true;
  763. proxy.post("/currencyRate/edit", formData.data.list).then(
  764. () => {
  765. ElMessage({
  766. message: "保存成功",
  767. type: "success",
  768. });
  769. dialogVisible.value = false;
  770. rateStatus.value = true;
  771. getList();
  772. },
  773. (err) => {
  774. console.log(err);
  775. loadingDialog.value = false;
  776. }
  777. );
  778. });
  779. };
  780. const openChange = ref(false);
  781. const change = ref(null);
  782. const formChangeData = reactive({
  783. data: {
  784. list: [],
  785. },
  786. });
  787. const formChangeConfig = computed(() => {
  788. return [
  789. {
  790. type: "slot",
  791. prop: "currencyList",
  792. slotName: "currencyList",
  793. label: "",
  794. },
  795. ];
  796. });
  797. const changeExchangeRate = (row) => {
  798. formChangeData.data = {
  799. id: row.contractId,
  800. list: [],
  801. };
  802. if (accountCurrency.value && accountCurrency.value.length > 0) {
  803. formChangeData.data.list = accountCurrency.value.map((item) => {
  804. return {
  805. type: item.value,
  806. rate: 1,
  807. };
  808. });
  809. }
  810. loadingDialog.value = true;
  811. openChange.value = true;
  812. if (row.currencyRateJson) {
  813. let currencyRateJson = JSON.parse(row.currencyRateJson);
  814. formChangeData.data.list = formChangeData.data.list.map((item) => {
  815. for (let i = 0; i < currencyRateJson.length; i++) {
  816. if (item.type === currencyRateJson[i].type) {
  817. item.rate = currencyRateJson[i].rate;
  818. break;
  819. }
  820. }
  821. return {
  822. ...item,
  823. };
  824. });
  825. loadingDialog.value = false;
  826. } else {
  827. proxy.post("/currencyRate/list", {}).then(
  828. (res) => {
  829. if (res && res.length > 0 && formChangeData.data.list.length > 0) {
  830. formChangeData.data.list = formChangeData.data.list.map((item) => {
  831. for (let i = 0; i < res.length; i++) {
  832. if (item.type === res[i].type) {
  833. item.rate = res[i].rate;
  834. break;
  835. }
  836. }
  837. return {
  838. ...item,
  839. };
  840. });
  841. }
  842. loadingDialog.value = false;
  843. },
  844. (err) => {
  845. console.log(err);
  846. loadingDialog.value = false;
  847. }
  848. );
  849. }
  850. };
  851. const submitChangeForm = () => {
  852. change.value.handleSubmit(() => {
  853. loadingDialog.value = true;
  854. let data = {};
  855. data.id = formChangeData.data.id;
  856. data.currencyRateJson = JSON.stringify(formChangeData.data.list);
  857. proxy.post("/contract/edit", data).then(
  858. () => {
  859. ElMessage({
  860. message: "保存成功",
  861. type: "success",
  862. });
  863. openChange.value = false;
  864. getList();
  865. },
  866. (err) => {
  867. console.log(err);
  868. loadingDialog.value = false;
  869. }
  870. );
  871. });
  872. };
  873. const openBudget = ref(false);
  874. const budget = ref(null);
  875. const formBudgetData = reactive({
  876. data: {},
  877. });
  878. const formBudgetConfig = computed(() => {
  879. return [
  880. {
  881. type: "title",
  882. title: "合同信息",
  883. label: "",
  884. },
  885. {
  886. type: "input",
  887. prop: "code",
  888. label: "合同编号",
  889. itemType: "text",
  890. disabled: true,
  891. },
  892. {
  893. type: "input",
  894. prop: "customerName",
  895. label: "客户名称",
  896. itemType: "text",
  897. disabled: true,
  898. },
  899. {
  900. type: "input",
  901. prop: "userName",
  902. label: "业务员",
  903. itemType: "text",
  904. disabled: true,
  905. },
  906. {
  907. type: "title",
  908. title: "预算金额",
  909. label: "",
  910. },
  911. {
  912. type: "slot",
  913. slotName: "budgetMoney",
  914. label: "",
  915. },
  916. ];
  917. });
  918. const changeBudget = (row) => {
  919. let currency = "CNY";
  920. if (accountCurrency.value && accountCurrency.value.length > 0) {
  921. currency = accountCurrency.value[0].value;
  922. }
  923. formBudgetData.data = {
  924. contractId: row.contractId,
  925. code: row.code,
  926. customerName: row.customerName,
  927. userName: row.userName,
  928. trailerFeeCurrency: currency,
  929. trailerFee: row.trailerFee,
  930. customsFeeCurrency: currency,
  931. customsFee: row.customsFee,
  932. agencyFeeCurrency: currency,
  933. agencyFee: row.agencyFee,
  934. portMixedFeeCurrency: currency,
  935. portMixedFee: row.portMixedFee,
  936. inspectionRedPackCurrency: currency,
  937. inspectionRedPack: row.inspectionRedPack,
  938. commissionCurrency: currency,
  939. commission: row.commission,
  940. otherCurrency: currency,
  941. other: row.other,
  942. };
  943. openBudget.value = true;
  944. };
  945. const submitBudgetForm = () => {
  946. proxy.post("/contractBudget/budget", formBudgetData.data).then(() => {
  947. ElMessage({
  948. message: "保存成功",
  949. type: "success",
  950. });
  951. openBudget.value = false;
  952. getList();
  953. });
  954. };
  955. </script>
  956. <style lang="scss" scoped>
  957. .tenant {
  958. padding: 20px;
  959. }
  960. ::v-deep(.el-input-number .el-input__inner) {
  961. text-align: left;
  962. }
  963. </style>