index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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. :loading="loading"
  10. :selectConfig="selectConfig"
  11. highlight-current-row
  12. :action-list="[
  13. {
  14. text: '默认汇率',
  15. action: () => openModal(),
  16. },
  17. ]"
  18. @get-list="getList">
  19. </byTable>
  20. <div style="padding: 0 20px 20px 20px; background-color: white" v-if="rateStatus">
  21. <el-table v-loading="loading" :data="sourceList.data">
  22. <el-table-column label="合同编号" prop="code" width="160" fixed />
  23. <el-table-column label="客户名称" prop="customerName" min-width="200" fixed />
  24. <el-table-column label="业务员" prop="userName" width="140" fixed />
  25. <el-table-column label="合同金额" width="140">
  26. <template #default="{ row }">
  27. <div>{{ row.amount }}</div>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="应付货款" width="140">
  31. <template #default="{ row }">
  32. <div>
  33. <span v-if="row.otherSumAmount">{{ row.otherSumAmount }}</span>
  34. <span v-else>{{ row.ehsdSumAmount }}</span>
  35. </div>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="税率" width="140">
  39. <template #default="{ row }">
  40. <div>13%</div>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="应退税金额" prop="refundableAmount" width="140" />
  44. <el-table-column label="包材金额" width="140">
  45. <template #default="{ row }">
  46. <div>{{ row.otherCurrency }}{{ row.other }}</div>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="配件金额" width="140">
  50. <template #default="{ row }">
  51. <div>{{ row.otherCurrency }}{{ row.other }}</div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="拖车费" width="140">
  55. <template #default="{ row }">
  56. <div>{{ row.trailerFeeCurrency }}{{ row.trailerFee }}</div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="报关费" width="140">
  60. <template #default="{ row }">
  61. <div>{{ row.customsFeeCurrency }}{{ row.customsFee }}</div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="代理费" width="140">
  65. <template #default="{ row }">
  66. <div>{{ row.agencyFeeCurrency }}{{ row.agencyFee }}</div>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="港杂费" width="140">
  70. <template #default="{ row }">
  71. <div>{{ row.portMixedFeeCurrency }}{{ row.portMixedFee }}</div>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="验货红包" width="140">
  75. <template #default="{ row }">
  76. <div>{{ row.inspectionRedPackCurrency }}{{ row.inspectionRedPack }}</div>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="佣金" width="140">
  80. <template #default="{ row }">
  81. <div>{{ row.commissionCurrency }}{{ row.commission }}</div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="其他" width="140">
  85. <template #default="{ row }">
  86. <div>{{ row.otherCurrency }}{{ row.other }}</div>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="收入总计" prop="incomeAmount" width="140" />
  90. <el-table-column label="支出总计" prop="expenditureAmount" width="140" />
  91. <el-table-column label="毛利率" width="140">
  92. <template #default="{ row }">
  93. <div>{{ row.grossRate }}%</div>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="毛利" prop="gross" width="140" />
  97. <el-table-column label="操作" align="center" width="160" fixed="right">
  98. <template #default="{ row }">
  99. <div>
  100. <el-button type="primary" @click="changeExchangeRate(row)" link>汇率</el-button>
  101. <el-button type="primary" @click="changeBudget(row)" link>预算</el-button>
  102. </div>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <el-row style="padding: 20px" justify="end" type="flex">
  107. <el-pagination
  108. background
  109. layout="total, sizes, prev, pager, next, jumper"
  110. :current-page="sourceList.pagination.pageNum"
  111. :page-size="sourceList.pagination.pageSize"
  112. :total="sourceList.pagination.total"
  113. @size-change="handleSizeChange"
  114. @current-change="handlePageChange" />
  115. </el-row>
  116. </div>
  117. <el-dialog title="默认汇率" v-if="dialogVisible" v-model="dialogVisible" width="600">
  118. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  119. <template #currencyList>
  120. <el-table :data="formData.data.list" style="width: 100%" v-loading="loadingDialog">
  121. <el-table-column label="币种">
  122. <template #default="{ row }">
  123. <div>{{ dictValueLabel(row.type, accountCurrency) }}</div>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="兑 CHY 汇率">
  127. <template #default="{ row, $index }">
  128. <el-form-item :prop="'list.' + $index + '.rate'" :rules="rules.rate" :inline-message="true">
  129. <el-input-number
  130. onmousewheel="return false;"
  131. v-model="row.rate"
  132. placeholder="请输入兑 CHY 汇率"
  133. style="width: 100%"
  134. :precision="6"
  135. :controls="false"
  136. :min="0" />
  137. </el-form-item>
  138. </template>
  139. </el-table-column>
  140. </el-table>
  141. </template>
  142. </byForm>
  143. <template #footer>
  144. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  145. <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
  146. </template>
  147. </el-dialog>
  148. <el-dialog title="调整汇率" v-if="openChange" v-model="openChange" width="600">
  149. <byForm :formConfig="formChangeConfig" :formOption="formOption" v-model="formChangeData.data" :rules="rules" ref="change">
  150. <template #currencyList>
  151. <el-table :data="formChangeData.data.list" style="width: 100%" v-loading="loadingDialog">
  152. <el-table-column label="币种">
  153. <template #default="{ row }">
  154. <div>{{ dictValueLabel(row.type, accountCurrency) }}</div>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="兑 CHY 汇率">
  158. <template #default="{ row, $index }">
  159. <el-form-item :prop="'list.' + $index + '.rate'" :rules="rules.rate" :inline-message="true">
  160. <el-input-number
  161. onmousewheel="return false;"
  162. v-model="row.rate"
  163. placeholder="请输入兑 CHY 汇率"
  164. style="width: 100%"
  165. :precision="6"
  166. :controls="false"
  167. :min="0" />
  168. </el-form-item>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. </template>
  173. </byForm>
  174. <template #footer>
  175. <el-button @click="openChange = false" size="large">取 消</el-button>
  176. <el-button type="primary" @click="submitChangeForm()" size="large">确 定</el-button>
  177. </template>
  178. </el-dialog>
  179. <el-dialog title="预算" v-if="openBudget" v-model="openBudget" width="400">
  180. <byForm :formConfig="formBudgetConfig" :formOption="formOption" v-model="formBudgetData.data" ref="budget">
  181. <template #budgetMoney>
  182. <div style="width: 100%">
  183. <el-form-item label="拖车费" prop="trailerFee">
  184. <el-input v-model="formBudgetData.data.trailerFee" placeholder="请输入拖车费" class="input-with-select">
  185. <template #prepend>
  186. <el-select v-model="formBudgetData.data.trailerFeeCurrency" placeholder="请选择货币" style="width: 115px">
  187. <el-option v-for="(item, index) in accountCurrency" :key="index" :label="item.label" :value="item.value" />
  188. </el-select>
  189. </template>
  190. </el-input>
  191. </el-form-item>
  192. <el-form-item label="报关费" prop="customsFee" style="margin-top: 20px">
  193. <el-input v-model="formBudgetData.data.customsFee" placeholder="请输入报关费" class="input-with-select">
  194. <template #prepend>
  195. <el-select v-model="formBudgetData.data.customsFeeCurrency" placeholder="请选择货币" style="width: 115px">
  196. <el-option v-for="(item, index) in accountCurrency" :key="index" :label="item.label" :value="item.value" />
  197. </el-select>
  198. </template>
  199. </el-input>
  200. </el-form-item>
  201. <el-form-item label="代理费" prop="agencyFee" style="margin-top: 20px">
  202. <el-input v-model="formBudgetData.data.agencyFee" placeholder="请输入代理费" class="input-with-select">
  203. <template #prepend>
  204. <el-select v-model="formBudgetData.data.agencyFeeCurrency" placeholder="请选择货币" style="width: 115px">
  205. <el-option v-for="(item, index) in accountCurrency" :key="index" :label="item.label" :value="item.value" />
  206. </el-select>
  207. </template>
  208. </el-input>
  209. </el-form-item>
  210. <el-form-item label="港杂费" prop="portMixedFee" style="margin-top: 20px">
  211. <el-input v-model="formBudgetData.data.portMixedFee" placeholder="请输入港杂费" class="input-with-select">
  212. <template #prepend>
  213. <el-select v-model="formBudgetData.data.portMixedFeeCurrency" placeholder="请选择货币" style="width: 115px">
  214. <el-option v-for="(item, index) in accountCurrency" :key="index" :label="item.label" :value="item.value" />
  215. </el-select>
  216. </template>
  217. </el-input>
  218. </el-form-item>
  219. <el-form-item label="验货红包" prop="inspectionRedPack" style="margin-top: 20px">
  220. <el-input v-model="formBudgetData.data.inspectionRedPack" placeholder="请输入验货红包" class="input-with-select">
  221. <template #prepend>
  222. <el-select v-model="formBudgetData.data.inspectionRedPackCurrency" placeholder="请选择货币" style="width: 115px">
  223. <el-option v-for="(item, index) in accountCurrency" :key="index" :label="item.label" :value="item.value" />
  224. </el-select>
  225. </template>
  226. </el-input>
  227. </el-form-item>
  228. <el-form-item label="佣金" prop="commission" style="margin-top: 20px">
  229. <el-input v-model="formBudgetData.data.commission" placeholder="请输入佣金" class="input-with-select">
  230. <template #prepend>
  231. <el-select v-model="formBudgetData.data.commissionCurrency" placeholder="请选择货币" style="width: 115px">
  232. <el-option v-for="(item, index) in accountCurrency" :key="index" :label="item.label" :value="item.value" />
  233. </el-select>
  234. </template>
  235. </el-input>
  236. </el-form-item>
  237. <el-form-item label="其他" prop="other" style="margin-top: 20px">
  238. <el-input v-model="formBudgetData.data.other" placeholder="请输入其他" class="input-with-select">
  239. <template #prepend>
  240. <el-select v-model="formBudgetData.data.otherCurrency" placeholder="请选择货币" style="width: 115px">
  241. <el-option v-for="(item, index) in accountCurrency" :key="index" :label="item.label" :value="item.value" />
  242. </el-select>
  243. </template>
  244. </el-input>
  245. </el-form-item>
  246. </div>
  247. </template>
  248. </byForm>
  249. <template #footer>
  250. <el-button @click="openBudget = false" size="large">取 消</el-button>
  251. <el-button type="primary" @click="submitBudgetForm()" size="large">确 定</el-button>
  252. </template>
  253. </el-dialog>
  254. </div>
  255. </template>
  256. <script setup>
  257. import { computed, ref } from "vue";
  258. import byTable from "@/components/byTable/index";
  259. import byForm from "@/components/byForm/index";
  260. import useUserStore from "@/store/modules/user";
  261. import { ElMessage } from "element-plus";
  262. const { proxy } = getCurrentInstance();
  263. const accountCurrency = ref([]);
  264. const userList = ref([]);
  265. const sourceList = ref({
  266. data: [],
  267. pagination: {
  268. total: 0,
  269. pageNum: 1,
  270. pageSize: 10,
  271. keyword: "",
  272. userId: "",
  273. },
  274. });
  275. const loading = ref(false);
  276. const selectConfig = computed(() => {
  277. return [
  278. {
  279. label: "业务员",
  280. prop: "userId",
  281. data: userList.value,
  282. },
  283. ];
  284. });
  285. const config = computed(() => {
  286. return [];
  287. });
  288. const getDict = () => {
  289. proxy
  290. .post("/dictTenantData/page", {
  291. pageNum: 1,
  292. pageSize: 999,
  293. dictCode: "account_currency",
  294. tenantId: useUserStore().user.tenantId,
  295. })
  296. .then((res) => {
  297. if (res.rows && res.rows.length > 0) {
  298. accountCurrency.value = res.rows.map((item) => {
  299. return {
  300. label: item.dictValue,
  301. value: item.dictKey,
  302. };
  303. });
  304. judgeRate();
  305. } else {
  306. ElMessage("请先添加货币");
  307. }
  308. });
  309. proxy
  310. .get("/tenantUser/list", {
  311. pageNum: 1,
  312. pageSize: 10000,
  313. tenantId: useUserStore().user.tenantId,
  314. })
  315. .then((res) => {
  316. userList.value = res.rows.map((item) => {
  317. return {
  318. label: item.nickName,
  319. value: item.userId,
  320. };
  321. });
  322. });
  323. };
  324. const getList = async (req) => {
  325. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  326. loading.value = true;
  327. proxy.post("/contract/getProfitBudgetPage", sourceList.value.pagination).then((res) => {
  328. sourceList.value.data = res.rows;
  329. sourceList.value.pagination.total = res.total;
  330. setTimeout(() => {
  331. loading.value = false;
  332. }, 200);
  333. });
  334. };
  335. const rateStatus = ref(false);
  336. const judgeRate = () => {
  337. proxy.post("/currencyRate/list", {}).then(
  338. (res) => {
  339. if (res && res.length > 0) {
  340. for (let i = 0; i < accountCurrency.value.length; i++) {
  341. let currencyStatus = true;
  342. for (let j = 0; j < res.length; j++) {
  343. if (accountCurrency.value[i].value === res[j].type) {
  344. currencyStatus = false;
  345. break;
  346. }
  347. }
  348. if (currencyStatus) {
  349. return ElMessage("请先完成默认汇率的配置");
  350. }
  351. }
  352. rateStatus.value = true;
  353. getList();
  354. } else {
  355. ElMessage("请先完成默认汇率的配置");
  356. }
  357. },
  358. (err) => {
  359. ElMessage("请先完成默认汇率的配置");
  360. }
  361. );
  362. };
  363. getDict();
  364. const handleSizeChange = (val) => {
  365. sourceList.value.pagination.pageNum = 1;
  366. sourceList.value.pagination.pageSize = val;
  367. getList();
  368. };
  369. const handlePageChange = (val) => {
  370. sourceList.value.pagination.pageNum = val;
  371. getList();
  372. };
  373. const dialogVisible = ref(false);
  374. const loadingDialog = ref(false);
  375. const submit = ref(null);
  376. const formOption = reactive({
  377. inline: true,
  378. labelWidth: 100,
  379. itemWidth: 100,
  380. rules: [],
  381. });
  382. const formData = reactive({
  383. data: {
  384. list: [],
  385. },
  386. });
  387. const formConfig = computed(() => {
  388. return [
  389. {
  390. type: "slot",
  391. prop: "currencyList",
  392. slotName: "currencyList",
  393. label: "",
  394. },
  395. ];
  396. });
  397. const rules = ref({
  398. rate: [{ required: true, message: "请输入兑 CHY 汇率", trigger: "blur" }],
  399. });
  400. const openModal = () => {
  401. if (accountCurrency.value && accountCurrency.value.length > 0) {
  402. formData.data = {
  403. list: accountCurrency.value.map((item) => {
  404. return {
  405. id: "",
  406. type: item.value,
  407. rate: 1,
  408. };
  409. }),
  410. };
  411. } else {
  412. formData.data = {
  413. list: [],
  414. };
  415. }
  416. loadingDialog.value = true;
  417. dialogVisible.value = true;
  418. proxy.post("/currencyRate/list", {}).then(
  419. (res) => {
  420. if (res && res.length > 0 && formData.data.list.length > 0) {
  421. formData.data.list = formData.data.list.map((item) => {
  422. for (let i = 0; i < res.length; i++) {
  423. if (item.type === res[i].type) {
  424. item.id = res[i].id;
  425. item.rate = res[i].rate;
  426. break;
  427. }
  428. }
  429. return {
  430. ...item,
  431. };
  432. });
  433. }
  434. loadingDialog.value = false;
  435. },
  436. (err) => {
  437. loadingDialog.value = false;
  438. }
  439. );
  440. };
  441. const submitForm = () => {
  442. submit.value.handleSubmit(() => {
  443. loadingDialog.value = true;
  444. proxy.post("/currencyRate/edit", formData.data.list).then(
  445. () => {
  446. ElMessage({
  447. message: "保存成功",
  448. type: "success",
  449. });
  450. dialogVisible.value = false;
  451. rateStatus.value = true;
  452. getList();
  453. },
  454. (err) => {
  455. loadingDialog.value = false;
  456. }
  457. );
  458. });
  459. };
  460. const openChange = ref(false);
  461. const change = ref(null);
  462. const formChangeData = reactive({
  463. data: {
  464. list: [],
  465. },
  466. });
  467. const formChangeConfig = computed(() => {
  468. return [
  469. {
  470. type: "slot",
  471. prop: "currencyList",
  472. slotName: "currencyList",
  473. label: "",
  474. },
  475. ];
  476. });
  477. const changeExchangeRate = (row) => {
  478. formChangeData.data = {
  479. id: row.contractId,
  480. list: [],
  481. };
  482. if (accountCurrency.value && accountCurrency.value.length > 0) {
  483. formChangeData.data.list = accountCurrency.value.map((item) => {
  484. return {
  485. type: item.value,
  486. rate: 1,
  487. };
  488. });
  489. }
  490. loadingDialog.value = true;
  491. openChange.value = true;
  492. if (row.currencyRateJson) {
  493. let currencyRateJson = JSON.parse(row.currencyRateJson);
  494. formChangeData.data.list = formChangeData.data.list.map((item) => {
  495. for (let i = 0; i < currencyRateJson.length; i++) {
  496. if (item.type === currencyRateJson[i].type) {
  497. item.rate = currencyRateJson[i].rate;
  498. break;
  499. }
  500. }
  501. return {
  502. ...item,
  503. };
  504. });
  505. loadingDialog.value = false;
  506. } else {
  507. proxy.post("/currencyRate/list", {}).then(
  508. (res) => {
  509. if (res && res.length > 0 && formChangeData.data.list.length > 0) {
  510. formChangeData.data.list = formChangeData.data.list.map((item) => {
  511. for (let i = 0; i < res.length; i++) {
  512. if (item.type === res[i].type) {
  513. item.rate = res[i].rate;
  514. break;
  515. }
  516. }
  517. return {
  518. ...item,
  519. };
  520. });
  521. }
  522. loadingDialog.value = false;
  523. },
  524. (err) => {
  525. loadingDialog.value = false;
  526. }
  527. );
  528. }
  529. };
  530. const submitChangeForm = () => {
  531. change.value.handleSubmit(() => {
  532. loadingDialog.value = true;
  533. let data = {};
  534. data.id = formChangeData.data.id;
  535. data.currencyRateJson = JSON.stringify(formChangeData.data.list);
  536. proxy.post("/contract/edit", data).then(
  537. () => {
  538. ElMessage({
  539. message: "保存成功",
  540. type: "success",
  541. });
  542. openChange.value = false;
  543. getList();
  544. },
  545. (err) => {
  546. loadingDialog.value = false;
  547. }
  548. );
  549. });
  550. };
  551. const openBudget = ref(false);
  552. const budget = ref(null);
  553. const formBudgetData = reactive({
  554. data: {},
  555. });
  556. const formBudgetConfig = computed(() => {
  557. return [
  558. {
  559. type: "title",
  560. title: "合同信息",
  561. label: "",
  562. },
  563. {
  564. type: "input",
  565. prop: "code",
  566. label: "合同编号",
  567. itemType: "text",
  568. disabled: true,
  569. },
  570. {
  571. type: "input",
  572. prop: "customerName",
  573. label: "客户名称",
  574. itemType: "text",
  575. disabled: true,
  576. },
  577. {
  578. type: "input",
  579. prop: "userName",
  580. label: "业务员",
  581. itemType: "text",
  582. disabled: true,
  583. },
  584. {
  585. type: "title",
  586. title: "预算金额",
  587. label: "",
  588. },
  589. {
  590. type: "slot",
  591. slotName: "budgetMoney",
  592. label: "",
  593. },
  594. ];
  595. });
  596. const changeBudget = (row) => {
  597. formBudgetData.data = {
  598. id: row.id,
  599. code: row.code,
  600. customerName: row.customerName,
  601. userName: row.userName,
  602. trailerFeeCurrency: row.trailerFeeCurrency,
  603. trailerFee: row.trailerFee,
  604. customsFeeCurrency: row.customsFeeCurrency,
  605. customsFee: row.customsFee,
  606. agencyFeeCurrency: row.agencyFeeCurrency,
  607. agencyFee: row.agencyFee,
  608. portMixedFeeCurrency: row.portMixedFeeCurrency,
  609. portMixedFee: row.portMixedFee,
  610. inspectionRedPackCurrency: row.inspectionRedPackCurrency,
  611. inspectionRedPack: row.inspectionRedPack,
  612. commissionCurrency: row.commissionCurrency,
  613. commission: row.commission,
  614. otherCurrency: row.otherCurrency,
  615. other: row.other,
  616. };
  617. openBudget.value = true;
  618. };
  619. const submitBudgetForm = () => {
  620. proxy.post("/contract/edit", formBudgetData.data).then(() => {
  621. ElMessage({
  622. message: "保存成功",
  623. type: "success",
  624. });
  625. openBudget.value = false;
  626. getList();
  627. });
  628. };
  629. </script>
  630. <style lang="scss" scoped>
  631. .tenant {
  632. padding: 20px;
  633. }
  634. ::v-deep(.el-input-number .el-input__inner) {
  635. text-align: left;
  636. }
  637. </style>