index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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. :action-list="[
  12. {
  13. text: '创建合同',
  14. action: () => newContract(),
  15. },
  16. ]"
  17. @get-list="getList"
  18. >
  19. <!-- <template #code="{ item }">
  20. <div style="width: 100%">
  21. <a
  22. style="color: #409eff; cursor: pointer; word-break: break-all"
  23. @click="pushProcessApproval(item)"
  24. >{{ item.code }}</a
  25. >
  26. </div>
  27. </template> -->
  28. <template #code="{ item }">
  29. <div style="width: 100%">
  30. <a
  31. style="color: #409eff; cursor: pointer; word-break: break-all"
  32. @click="openDetails(item)"
  33. >{{ item.code }}</a
  34. >
  35. </div>
  36. </template>
  37. <template #amount="{ item }">
  38. <div>
  39. <span style="padding-right: 4px">{{ item.currency }}</span>
  40. <span>{{ moneyFormat(item.amount, 2) }}</span>
  41. </div>
  42. </template>
  43. <template #amountCNY="{ item }">
  44. <div>
  45. <!-- <span style="padding-right: 4px">{{ item.currency }}</span> -->
  46. <span>{{ moneyFormat(item.amountCNY, 2) }}</span>
  47. </div>
  48. </template>
  49. <template #sumClaimMoney="{ item }">
  50. <div>
  51. <!-- <span style="padding-right: 4px">{{ item.currency }}</span> -->
  52. <span>{{ moneyFormat(item.sumClaimMoney, 2) }}</span>
  53. </div>
  54. </template>
  55. <template #scale="{ item }">
  56. <div>
  57. {{ computeScale(item) }}
  58. </div>
  59. </template>
  60. <template #refundStatusNew="{ item }">
  61. <div>
  62. <span v-if="item.refundStatus && item.refundStatus !== 0">
  63. {{ dictValueLabel(item.refundStatus, refundStatusNew) }}
  64. </span>
  65. <span v-else>{{
  66. dictValueLabel(item.refundStatusNew, refundStatusNew)
  67. }}</span>
  68. </div>
  69. </template>
  70. <template #status="{ item }">
  71. <div>
  72. <span :style="getStyle(item.status)">{{
  73. dictValueLabel(item.status, status)
  74. }}</span>
  75. </div>
  76. </template>
  77. </byTable>
  78. </div>
  79. <el-dialog title="打印" v-if="openPrint" v-model="openPrint" width="860">
  80. <ContractPDF :rowData="rowData"></ContractPDF>
  81. <template #footer>
  82. <el-button @click="openPrint = false" size="large">取消</el-button>
  83. <el-button v-print="printObj" size="large">打印</el-button>
  84. <el-button type="primary" @click="clickDownload()" size="large"
  85. >下载PDF</el-button
  86. >
  87. </template>
  88. </el-dialog>
  89. <el-dialog
  90. title="合同详情"
  91. v-if="openDetailsDialog"
  92. v-model="openDetailsDialog"
  93. width="1000"
  94. >
  95. <ContractDetails :contractId="currentContractId"></ContractDetails>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script setup>
  100. import { computed, ref } from "vue";
  101. import byTable from "@/components/byTable/index";
  102. import useUserStore from "@/store/modules/user";
  103. import { ElMessage, ElMessageBox } from "element-plus";
  104. import ContractDetails from "@/components/contractCom/contractDetails.vue";
  105. import ContractPDF from "@/components/PDF/contractPDF.vue";
  106. const route = useRoute();
  107. const { proxy } = getCurrentInstance();
  108. const contractType = ref([]);
  109. const accountCurrency = ref([]);
  110. const tradeMethods = ref([]);
  111. const corporationList = ref([]);
  112. const customerList = ref([]);
  113. const shippingMethod = ref([]);
  114. const productUnit = ref([]);
  115. const userList = ref([]);
  116. const openDetailsDialog = ref(false);
  117. const status = ref([
  118. {
  119. label: "草稿",
  120. value: 0,
  121. },
  122. {
  123. label: "审批中",
  124. value: 10,
  125. },
  126. {
  127. label: "驳回",
  128. value: 20,
  129. },
  130. {
  131. label: "审批通过",
  132. value: 30,
  133. },
  134. {
  135. label: "终止",
  136. value: 99,
  137. },
  138. ]);
  139. const refundStatusNew = ref([
  140. {
  141. label: "未到款",
  142. value: 0,
  143. },
  144. {
  145. label: "部分到款",
  146. value: 10,
  147. },
  148. {
  149. label: "已到款",
  150. value: 20,
  151. },
  152. ]);
  153. const sourceList = ref({
  154. data: [],
  155. pagination: {
  156. total: 0,
  157. pageNum: 1,
  158. pageSize: 10,
  159. keyword: "",
  160. status: "",
  161. sellCorporationId: "",
  162. },
  163. });
  164. const loading = ref(false);
  165. const selectConfig = computed(() => {
  166. return [
  167. {
  168. label: "审批状态",
  169. prop: "status",
  170. data: status.value,
  171. },
  172. {
  173. label: "到款状态",
  174. prop: "refundStatusNew",
  175. data: refundStatusNew.value,
  176. },
  177. {
  178. label: "合同类型",
  179. prop: "contractType",
  180. data: contractType.value,
  181. },
  182. ];
  183. });
  184. const config = computed(() => {
  185. return [
  186. {
  187. attrs: {
  188. label: "归属公司",
  189. prop: "sellCorporationId",
  190. "min-width": 160,
  191. },
  192. render(type) {
  193. return proxy.dictValueLabel(type, corporationList.value);
  194. },
  195. },
  196. {
  197. attrs: {
  198. label: "合同类型",
  199. prop: "contractType",
  200. width: 120,
  201. },
  202. render(type) {
  203. return proxy.dictValueLabel(type, contractType.value);
  204. },
  205. },
  206. {
  207. attrs: {
  208. label: "合同编码",
  209. slot: "code",
  210. width: 180,
  211. },
  212. },
  213. {
  214. attrs: {
  215. label: "客户",
  216. prop: "buyCorporationId",
  217. "min-width": 180,
  218. },
  219. render(type) {
  220. return proxy.dictValueLabel(type, customerList.value);
  221. },
  222. },
  223. // {
  224. // attrs: {
  225. // label: "版本号",
  226. // prop: "version",
  227. // width: 80,
  228. // },
  229. // },
  230. {
  231. attrs: {
  232. label: "合同金额",
  233. slot: "amount",
  234. width: 120,
  235. },
  236. },
  237. {
  238. attrs: {
  239. label: "合同金额(CNY)",
  240. slot: "amountCNY",
  241. width: 120,
  242. },
  243. },
  244. {
  245. attrs: {
  246. label: "已到账金额(CNY)",
  247. slot: "sumClaimMoney",
  248. width: 140,
  249. },
  250. },
  251. {
  252. attrs: {
  253. label: "到账比例",
  254. slot: "scale",
  255. width: 100,
  256. },
  257. },
  258. {
  259. attrs: {
  260. label: "业务员",
  261. prop: "createUser",
  262. width: 140,
  263. },
  264. render(type) {
  265. return proxy.dictValueLabel(type, userList.value);
  266. },
  267. },
  268. {
  269. attrs: {
  270. label: "创建时间",
  271. prop: "createTime",
  272. width: 160,
  273. },
  274. },
  275. {
  276. attrs: {
  277. label: "审批状态",
  278. prop: "status",
  279. width: 120,
  280. slot: "status",
  281. },
  282. // render(type) {
  283. // return proxy.dictValueLabel(type, status.value);
  284. // },
  285. },
  286. {
  287. attrs: {
  288. label: "到款状态",
  289. slot: "refundStatusNew",
  290. width: 120,
  291. },
  292. },
  293. {
  294. attrs: {
  295. label: "操作",
  296. width: "180",
  297. align: "center",
  298. fixed: "right",
  299. },
  300. renderHTML(row) {
  301. return [
  302. !row.refundStatus && row.refundStatusNew == 10
  303. ? {
  304. attrs: {
  305. label: "到款完成",
  306. type: "primary",
  307. text: true,
  308. },
  309. el: "button",
  310. click() {
  311. clickAccomplish(row);
  312. },
  313. }
  314. : {},
  315. row.status == 30
  316. ? {
  317. attrs: {
  318. label: "变更",
  319. type: "primary",
  320. text: true,
  321. },
  322. el: "button",
  323. click() {
  324. clickAlteration(row);
  325. },
  326. }
  327. : {},
  328. {
  329. attrs: {
  330. label: "打印",
  331. type: "primary",
  332. text: true,
  333. },
  334. el: "button",
  335. click() {
  336. clickPrint(row);
  337. },
  338. },
  339. {
  340. attrs: {
  341. label: "作废",
  342. type: "primary",
  343. text: true,
  344. },
  345. el: "button",
  346. click() {
  347. ElMessageBox.confirm(
  348. "此操作将作废该数据, 是否继续?",
  349. "提示",
  350. {
  351. confirmButtonText: "确定",
  352. cancelButtonText: "取消",
  353. type: "warning",
  354. }
  355. ).then(() => {
  356. proxy
  357. .post("/contract/edit", {
  358. id: row.id,
  359. status: 88,
  360. })
  361. .then(() => {
  362. ElMessage({
  363. message: "作废成功",
  364. type: "success",
  365. });
  366. getList();
  367. });
  368. });
  369. },
  370. },
  371. ];
  372. },
  373. },
  374. ];
  375. });
  376. const getDict = () => {
  377. proxy
  378. .getDictOne([
  379. "contract_type",
  380. "account_currency",
  381. "trade_mode",
  382. "shipping_method",
  383. "unit",
  384. ])
  385. .then((res) => {
  386. if (res.contract_type && res.contract_type.length > 0) {
  387. contractType.value = res.contract_type.map((x) => ({
  388. label: x.dictValue,
  389. value: x.dictKey,
  390. }));
  391. }
  392. if (res.account_currency && res.account_currency.length > 0) {
  393. accountCurrency.value = res.account_currency.map((x) => ({
  394. label: x.dictValue,
  395. value: x.dictKey,
  396. }));
  397. }
  398. if (res.trade_mode && res.trade_mode.length > 0) {
  399. tradeMethods.value = res.trade_mode.map((x) => ({
  400. label: x.dictValue,
  401. value: x.dictKey,
  402. }));
  403. }
  404. if (res.shipping_method && res.shipping_method.length > 0) {
  405. shippingMethod.value = res.shipping_method.map((x) => ({
  406. label: x.dictValue,
  407. value: x.dictKey,
  408. }));
  409. }
  410. if (res.unit && res.unit.length > 0) {
  411. productUnit.value = res.unit.map((x) => ({
  412. label: x.dictValue,
  413. value: x.dictKey,
  414. }));
  415. }
  416. });
  417. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  418. corporationList.value = res.rows.map((item) => {
  419. return {
  420. ...item,
  421. label: item.name,
  422. value: item.id,
  423. };
  424. });
  425. });
  426. proxy.post("/customer/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  427. customerList.value = res.rows.map((item) => {
  428. return {
  429. ...item,
  430. label: item.name,
  431. value: item.id,
  432. };
  433. });
  434. });
  435. proxy
  436. .post("/dictTenantData/page", {
  437. pageNum: 1,
  438. pageSize: 999,
  439. dictCode: "shipping_method",
  440. tenantId: useUserStore().user.tenantId,
  441. })
  442. .then((res) => {
  443. if (res.rows && res.rows.length > 0) {
  444. shippingMethod.value = res.rows.map((item) => {
  445. return {
  446. label: item.dictValue,
  447. value: item.dictKey,
  448. };
  449. });
  450. }
  451. });
  452. proxy
  453. .get("/tenantUser/list", {
  454. pageNum: 1,
  455. pageSize: 10000,
  456. tenantId: useUserStore().user.tenantId,
  457. })
  458. .then((res) => {
  459. userList.value = res.rows.map((item) => {
  460. return {
  461. label: item.nickName,
  462. value: item.userId,
  463. };
  464. });
  465. });
  466. };
  467. const getList = async (req) => {
  468. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  469. loading.value = true;
  470. proxy.post("/contract/page", sourceList.value.pagination).then((res) => {
  471. sourceList.value.data = res.rows;
  472. sourceList.value.pagination.total = res.total;
  473. setTimeout(() => {
  474. loading.value = false;
  475. }, 200);
  476. });
  477. };
  478. getDict();
  479. if (route.query.code) {
  480. sourceList.value.pagination.keyword = route.query.code;
  481. }
  482. getList();
  483. const newContract = () => {
  484. proxy.$router.replace({
  485. path: "/platform_manage/process/processApproval",
  486. query: {
  487. flowKey: "contract_flow",
  488. flowName: "销售合同审批流程",
  489. random: proxy.random(),
  490. },
  491. });
  492. };
  493. const openPrint = ref(false);
  494. const printDetails = ref({});
  495. const rowData = ref({});
  496. const clickPrint = (row) => {
  497. // printDetails.value = {};
  498. // openPrint.value = true;
  499. // proxy.post("/contract/getContractPdfInfo", { id: row.id }).then((res) => {
  500. // printDetails.value = res;
  501. // });
  502. rowData.value = {
  503. id: row.id,
  504. };
  505. openPrint.value = true;
  506. };
  507. const clickDownload = () => {
  508. proxy.getPdf("外销合同PDF文件");
  509. };
  510. const statistics = (label, index) => {
  511. let num = 0;
  512. if (
  513. printDetails.value.productInfoList &&
  514. printDetails.value.productInfoList.length > 0
  515. ) {
  516. printDetails.value.productInfoList.map((item) => {
  517. if (item[label]) {
  518. num = parseFloat(Number(num) + Number(item[label])).toFixed(index);
  519. }
  520. });
  521. }
  522. return num;
  523. };
  524. const statisticsTwo = (label, index) => {
  525. let num = 0;
  526. if (
  527. printDetails.value.contractProjectList &&
  528. printDetails.value.contractProjectList.length > 0
  529. ) {
  530. printDetails.value.contractProjectList.map((item) => {
  531. if (item[label]) {
  532. num = parseFloat(Number(num) + Number(item[label])).toFixed(index);
  533. }
  534. });
  535. }
  536. return num;
  537. };
  538. const computeScale = (item) => {
  539. let text = 0;
  540. if (
  541. item.sumClaimMoney &&
  542. Number(item.sumClaimMoney) > 0 &&
  543. item.amountCNY &&
  544. Number(item.amountCNY) > 0
  545. ) {
  546. text = parseFloat(
  547. (Number(item.sumClaimMoney) / Number(item.amountCNY)) * 100
  548. ).toFixed(2);
  549. }
  550. return text + "%";
  551. };
  552. const clickAccomplish = (row) => {
  553. proxy.post("/contract/toTheAccount", { id: row.id }).then(() => {
  554. getList();
  555. });
  556. };
  557. const pushProcessApproval = (row) => {
  558. proxy.$router.push({
  559. path: "/platform_manage/process/processApproval",
  560. query: {
  561. flowKey: "contract_flow",
  562. id: row.flowId,
  563. processType: 20,
  564. random: proxy.random(),
  565. flowName: "销售合同详情",
  566. },
  567. });
  568. return;
  569. };
  570. const currentContractId = ref("");
  571. const openDetails = (row) => {
  572. currentContractId.value = row.id;
  573. openDetailsDialog.value = true;
  574. };
  575. const printObj = ref({
  576. id: "printMe",
  577. popTitle: "",
  578. extraCss:
  579. "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",
  580. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  581. });
  582. const clickAlteration = (row) => {
  583. proxy.$router.push({
  584. path: "/platform_manage/process/processApproval",
  585. query: {
  586. flowKey: "contract_update_flow",
  587. flowName: "销售合同变更流程",
  588. contractId: row.id,
  589. random: proxy.random(),
  590. },
  591. });
  592. };
  593. const getStyle = (status) => {
  594. if (status == 10) {
  595. return {
  596. color: "#FF9315",
  597. };
  598. } else if (status == 30) {
  599. return {
  600. color: "#39C55A",
  601. };
  602. } else if (status == 20 || status == 99) {
  603. return {
  604. color: "#FF655B",
  605. };
  606. } else {
  607. return {};
  608. }
  609. };
  610. </script>
  611. <style lang="scss" scoped>
  612. .tenant {
  613. padding: 20px;
  614. }
  615. ::v-deep(.el-input-number .el-input__inner) {
  616. text-align: left;
  617. }
  618. .baseRow {
  619. min-height: 24px;
  620. border-top: 1px solid black;
  621. border-left: 1px solid black;
  622. }
  623. .contentRow {
  624. border-right: 1px solid black;
  625. line-height: 24px;
  626. padding-left: 4px;
  627. }
  628. </style>