index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :searchConfig="searchConfig"
  10. highlight-current-row
  11. :action-list="[
  12. // {
  13. // text: '登记对账',
  14. // action: () => clickModal(),
  15. // },
  16. {
  17. text: 'Excel文件',
  18. action: () => clickExcelFile(),
  19. },
  20. {
  21. text: '手动同步',
  22. action: () => clickManualSynchronization(),
  23. },
  24. ]"
  25. @get-list="getList"
  26. @clickReset="clickReset">
  27. <template #timePeriod="{ item }">
  28. <div>
  29. <el-row>
  30. <el-col :span="11">{{ item.timePeriod }}</el-col>
  31. <el-col :span="2" style="text-align: center">-</el-col>
  32. <el-col :span="11">{{ item.timePeriod }}</el-col>
  33. </el-row>
  34. </div>
  35. </template>
  36. <template #receiptFileList="{ item }">
  37. <div>
  38. <el-button type="primary" @click="clickReceiptFile(item)" v-if="item.receiptFileList && item.receiptFileList.length > 0" text>查看</el-button>
  39. <el-button type="danger" @click="clickReceiptFile(item)" v-else text>上传</el-button>
  40. </div>
  41. </template>
  42. <template #proofFileList="{ item }">
  43. <div>
  44. <el-button type="primary" @click="clickProofFile(item)" v-if="item.proofFileList && item.proofFileList.length > 0" text>查看</el-button>
  45. <el-button type="danger" @click="clickProofFile(item)" v-else text>上传</el-button>
  46. </div>
  47. </template>
  48. </byTable>
  49. </el-card>
  50. <el-dialog :title="modalType == 'add' ? '登记对账' : '编辑对账'" v-if="openDialog" v-model="openDialog" width="80%">
  51. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data">
  52. <template #orderIdList>
  53. <div style="width: 100%">
  54. <el-form-item label="事业部" prop="departmentId" style="margin-bottom: 18px">
  55. <el-select v-model="formData.data.departmentId" placeholder="请选择事业部" clearable @change="changeDepartment" :disabled="formData.data.id">
  56. <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  57. </el-select>
  58. <el-button type="primary" size="small" style="margin-left: 16px" @click="clickAddOrder()">选择合同</el-button>
  59. </el-form-item>
  60. <el-table :data="formData.data.orderList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  61. <el-table-column label="事业部" prop="departmentName" width="140" />
  62. <el-table-column label="订单号" prop="orderCode" min-width="180" />
  63. <el-table-column label="订单总金额 ¥" prop="totalAmount" align="right" width="120" />
  64. <el-table-column label="产品总金额 ¥" prop="productTotalAmount" align="right" width="120" />
  65. <el-table-column label="定制加工费 ¥" prop="customProcessingFee" align="right" width="110" />
  66. <el-table-column label="代发费 ¥" prop="lssueFee" align="right" width="100" />
  67. <el-table-column label="快递包材费 ¥" prop="deliveryMaterialsFee" align="right" width="110" />
  68. <el-table-column label="包装人工费 ¥" prop="packingLabor" align="right" width="110" />
  69. <el-table-column label="包材费 ¥" prop="packagingMaterialCost" align="right" width="100" />
  70. <el-table-column label="管理费 ¥" prop="managementFee" align="right" width="100" />
  71. <el-table-column label="操作" align="center" fixed="right" width="60">
  72. <template #default="{ $index }">
  73. <el-button type="danger" @click="clickOrderDelete($index)" text>删除</el-button>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. </div>
  78. </template>
  79. </byForm>
  80. <template #footer>
  81. <el-button @click="openDialog = false" size="large">取 消</el-button>
  82. <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
  83. </template>
  84. </el-dialog>
  85. <el-dialog title="上传对账单" v-if="openReceiptFile" v-model="openReceiptFile" width="600">
  86. <el-upload
  87. v-model:fileList="fileList"
  88. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  89. :data="uploadReceiptData"
  90. multiple
  91. :before-upload="uploadReceiptFile"
  92. :on-success="handleReceiptSuccess"
  93. :on-preview="onPreviewFile">
  94. <el-button type="primary">上传</el-button>
  95. </el-upload>
  96. <template #footer>
  97. <el-button @click="openReceiptFile = false" size="large">取 消</el-button>
  98. <el-button type="primary" @click="submitReceiptFile()" size="large" v-preReClick>确 定</el-button>
  99. </template>
  100. </el-dialog>
  101. <el-dialog title="上传转账凭证" v-if="openProofFile" v-model="openProofFile" width="600">
  102. <el-upload
  103. v-model:fileList="fileList"
  104. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  105. :data="uploadProofData"
  106. multiple
  107. :before-upload="uploadProofFile"
  108. :on-success="handleProofSuccess"
  109. :on-preview="onPreviewFile">
  110. <el-button type="primary">上传</el-button>
  111. </el-upload>
  112. <template #footer>
  113. <el-button @click="openProofFile = false" size="large">取 消</el-button>
  114. <el-button type="primary" @click="submitProofFile()" size="large" v-preReClick>确 定</el-button>
  115. </template>
  116. </el-dialog>
  117. <el-dialog title="选择合同" v-if="openOrder" v-model="openOrder" width="90%">
  118. <SelectOrder :selectStatus="true" :departmentId="formData.data.departmentId" @selectOrder="selectOrder"></SelectOrder>
  119. <template #footer>
  120. <el-button @click="openOrder = false" size="large">关 闭</el-button>
  121. </template>
  122. </el-dialog>
  123. <el-dialog title="打印" v-if="openPrint" v-model="openPrint" width="94%">
  124. <el-tabs v-model="activeName" class="demo-tabs">
  125. <el-tab-pane label="SKU对账单" name="sku">
  126. <PrintSKU :rowData="rowData" :activeName="activeName" @clickCancel="openPrint = false"></PrintSKU>
  127. </el-tab-pane>
  128. <el-tab-pane label="BOM对账单" name="bom">
  129. <PrintBOM :rowData="rowData" :activeName="activeName" @clickCancel="openPrint = false"></PrintBOM>
  130. </el-tab-pane>
  131. <el-tab-pane label="订单对账单" name="order">
  132. <PrintOrder :rowData="rowData" :activeName="activeName" @clickCancel="clickCancel"></PrintOrder>
  133. </el-tab-pane>
  134. </el-tabs>
  135. </el-dialog>
  136. <el-dialog title="Excel文件" v-if="openFileList" v-model="openFileList" width="60%">
  137. <ExcelFile></ExcelFile>
  138. <template #footer>
  139. <el-button @click="openFileList = false" size="large">关 闭</el-button>
  140. </template>
  141. </el-dialog>
  142. </div>
  143. </template>
  144. <script setup>
  145. import byTable from "/src/components/byTable/index";
  146. import byForm from "/src/components/byForm/index";
  147. import { ElMessage, ElMessageBox } from "element-plus";
  148. import SelectOrder from "/src/views/group/order/management/index";
  149. import PrintSKU from "/src/views/group/finance/check-bill/printSKU.vue";
  150. import PrintBOM from "/src/views/group/finance/check-bill/printBOM.vue";
  151. import PrintOrder from "/src/views/group/finance/check-bill/printOrder.vue";
  152. import { copyText } from "vue3-clipboard";
  153. import ExcelFile from "/src/views/group/finance/check-bill/ExcelFile.vue";
  154. const { proxy } = getCurrentInstance();
  155. const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
  156. const sourceList = ref({
  157. data: [],
  158. pagination: {
  159. total: 0,
  160. pageNum: 1,
  161. pageSize: 10,
  162. code: "",
  163. departmentId: "",
  164. beginTime: "",
  165. endTime: "",
  166. },
  167. });
  168. const loading = ref(false);
  169. const searchConfig = computed(() => {
  170. return [
  171. {
  172. type: "input",
  173. prop: "code",
  174. label: "对账单号",
  175. },
  176. {
  177. type: "select",
  178. prop: "departmentId",
  179. data: departmentList.value,
  180. label: "事业部",
  181. },
  182. {
  183. type: "date",
  184. propList: ["beginTime", "endTime"],
  185. label: "对账日期",
  186. },
  187. ];
  188. });
  189. const config = computed(() => {
  190. return [
  191. {
  192. attrs: {
  193. label: "对账单号",
  194. prop: "code",
  195. },
  196. },
  197. {
  198. attrs: {
  199. label: "创建时间",
  200. prop: "createTime",
  201. width: 160,
  202. },
  203. },
  204. {
  205. attrs: {
  206. label: "客户",
  207. prop: "departmentName",
  208. },
  209. },
  210. {
  211. attrs: {
  212. label: "对账金额",
  213. prop: "amount",
  214. align: "right",
  215. width: 180,
  216. },
  217. },
  218. {
  219. attrs: {
  220. label: "合同数量",
  221. prop: "orderNum",
  222. width: 100,
  223. },
  224. },
  225. {
  226. attrs: {
  227. label: "对账时间",
  228. prop: "timePeriod",
  229. align: "center",
  230. width: 180,
  231. },
  232. },
  233. {
  234. attrs: {
  235. label: "对账单",
  236. slot: "receiptFileList",
  237. align: "center",
  238. width: 120,
  239. },
  240. },
  241. {
  242. attrs: {
  243. label: "转账凭证",
  244. slot: "proofFileList",
  245. align: "center",
  246. width: 120,
  247. },
  248. },
  249. {
  250. attrs: {
  251. label: "操作",
  252. width: 180,
  253. align: "center",
  254. fixed: "right",
  255. },
  256. renderHTML(row) {
  257. return [
  258. {
  259. attrs: {
  260. label: "复制单号",
  261. type: "primary",
  262. text: true,
  263. },
  264. el: "button",
  265. click() {
  266. clickCopyWLNCode(row);
  267. },
  268. },
  269. {
  270. attrs: {
  271. label: "打印",
  272. type: "primary",
  273. text: true,
  274. },
  275. el: "button",
  276. click() {
  277. clickPrint(row);
  278. },
  279. },
  280. {
  281. attrs: {
  282. label: "编辑",
  283. type: "primary",
  284. text: true,
  285. },
  286. el: "button",
  287. click() {
  288. clickUpdate(row);
  289. },
  290. },
  291. {
  292. attrs: {
  293. label: "删除",
  294. type: "danger",
  295. text: true,
  296. },
  297. el: "button",
  298. click() {
  299. clickDelete(row);
  300. },
  301. },
  302. ];
  303. },
  304. },
  305. ];
  306. });
  307. const getDemandData = () => {
  308. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  309. if (res.rows && res.rows.length > 0) {
  310. departmentList.value = departmentList.value.concat(
  311. res.rows.map((item) => {
  312. return {
  313. dictKey: item.id,
  314. dictValue: item.name,
  315. };
  316. })
  317. );
  318. }
  319. });
  320. };
  321. getDemandData();
  322. const getList = async (req, status) => {
  323. if (status) {
  324. sourceList.value.pagination = {
  325. pageNum: sourceList.value.pagination.pageNum,
  326. pageSize: sourceList.value.pagination.pageSize,
  327. };
  328. } else {
  329. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  330. }
  331. loading.value = true;
  332. proxy.post("/statementOfAccount/page", sourceList.value.pagination).then((res) => {
  333. sourceList.value.data = res.rows;
  334. sourceList.value.pagination.total = res.total;
  335. setTimeout(() => {
  336. loading.value = false;
  337. }, 200);
  338. });
  339. };
  340. getList();
  341. const clickReset = () => {
  342. getList("", true);
  343. };
  344. const modalType = ref("add");
  345. const openDialog = ref(false);
  346. const formOption = reactive({
  347. inline: true,
  348. labelWidth: "120px",
  349. itemWidth: 100,
  350. rules: [],
  351. labelPosition: "right",
  352. });
  353. const formData = reactive({
  354. data: {},
  355. });
  356. const formConfig = computed(() => {
  357. return [
  358. {
  359. type: "title",
  360. title: "对账合同",
  361. label: "",
  362. },
  363. {
  364. type: "slot",
  365. slotName: "orderIdList",
  366. label: "",
  367. },
  368. ];
  369. });
  370. const clickModal = () => {
  371. modalType.value = "add";
  372. formData.data = {
  373. departmentId: "",
  374. amount: "",
  375. orderIdList: [],
  376. orderList: [],
  377. };
  378. openDialog.value = true;
  379. };
  380. const changeDepartment = () => {
  381. formData.data.orderList = [];
  382. };
  383. const openOrder = ref(false);
  384. const clickAddOrder = () => {
  385. if (formData.data.departmentId) {
  386. openOrder.value = true;
  387. } else {
  388. return ElMessage("请先选择事业部");
  389. }
  390. };
  391. const selectOrder = (row) => {
  392. if (formData.data.orderList && formData.data.orderList.length > 0) {
  393. let list = formData.data.orderList.filter((item) => item.orderId === row.id);
  394. if (list && list.length > 0) {
  395. return ElMessage("该订单已添加");
  396. }
  397. } else {
  398. formData.data.orderList = [];
  399. }
  400. formData.data.orderList.push({
  401. orderId: row.id,
  402. departmentName: row.departmentName,
  403. orderCode: row.code,
  404. totalAmount: row.totalAmount,
  405. productTotalAmount: row.productTotalAmount,
  406. customProcessingFee: row.customProcessingFee,
  407. lssueFee: row.lssueFee,
  408. deliveryMaterialsFee: row.deliveryMaterialsFee,
  409. packingLabor: row.packingLabor,
  410. managementFee: row.managementFee,
  411. outerBoxPackingFee: row.outerBoxPackingFee,
  412. packagingMaterialCost: row.packagingMaterialCost,
  413. });
  414. ElMessage({ message: "添加成功", type: "success" });
  415. };
  416. const clickOrderDelete = (index) => {
  417. formData.data.orderList.splice(index, 1);
  418. };
  419. const submitForm = () => {
  420. if (formData.data.orderList && formData.data.orderList.length > 0) {
  421. let amount = 0;
  422. for (let i = 0; i < formData.data.orderList.length; i++) {
  423. amount = Number(Math.round((amount + formData.data.orderList[i].totalAmount) * 100) / 100);
  424. }
  425. let orderIdList = formData.data.orderList.map((item) => item.orderId);
  426. proxy
  427. .post("/statementOfAccount/" + modalType.value, {
  428. id: formData.data.id,
  429. departmentId: formData.data.departmentId,
  430. amount: amount,
  431. orderIdList: orderIdList,
  432. })
  433. .then(() => {
  434. ElMessage({
  435. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  436. type: "success",
  437. });
  438. openDialog.value = false;
  439. getList();
  440. });
  441. } else {
  442. return ElMessage("请先添加订单");
  443. }
  444. };
  445. const clickUpdate = (row) => {
  446. formData.data = {
  447. id: row.id,
  448. };
  449. modalType.value = "edit";
  450. proxy.post("/statementOfAccount/detail", { id: row.id }).then((res) => {
  451. if (res && res.length > 0) {
  452. formData.data.departmentId = res[0].departmentId;
  453. formData.data.orderList = res;
  454. }
  455. openDialog.value = true;
  456. });
  457. };
  458. const clickDelete = (row) => {
  459. ElMessageBox.confirm("你是否确认此操作", "提示", {
  460. confirmButtonText: "确定",
  461. cancelButtonText: "取消",
  462. type: "warning",
  463. })
  464. .then(() => {
  465. proxy.post("/statementOfAccount/delete", { id: row.id }).then(() => {
  466. ElMessage({ message: "删除成功", type: "success" });
  467. getList();
  468. });
  469. })
  470. .catch(() => {});
  471. };
  472. const openReceiptFile = ref(false);
  473. const formReceiptData = reactive({
  474. data: {
  475. id: "",
  476. fileList: [],
  477. },
  478. });
  479. const fileList = ref([]);
  480. const clickReceiptFile = (row) => {
  481. formReceiptData.data = {
  482. id: row.id,
  483. fileList: [],
  484. };
  485. if (row.receiptFileList && row.receiptFileList.length > 0) {
  486. fileList.value = proxy.deepClone(
  487. row.receiptFileList.map((item) => {
  488. return {
  489. raw: item,
  490. name: item.fileName,
  491. url: item.fileUrl,
  492. };
  493. })
  494. );
  495. } else {
  496. fileList.value = [];
  497. }
  498. openReceiptFile.value = true;
  499. };
  500. const uploadReceiptData = ref({});
  501. const uploadReceiptFile = async (file) => {
  502. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  503. uploadReceiptData.value = res.uploadBody;
  504. file.id = res.id;
  505. file.fileName = res.fileName;
  506. file.fileUrl = res.fileUrl;
  507. file.uploadState = true;
  508. return true;
  509. };
  510. const handleReceiptSuccess = (any, UploadFile) => {
  511. UploadFile.raw.uploadState = false;
  512. };
  513. const onPreviewFile = (file) => {
  514. window.open(file.raw.fileUrl, "_blank");
  515. };
  516. const submitReceiptFile = () => {
  517. if (fileList.value && fileList.value.length > 0) {
  518. for (let i = 0; i < fileList.value.length; i++) {
  519. if (fileList.value[i].raw.uploadState) {
  520. return ElMessage("文件上传中,请稍后提交");
  521. }
  522. }
  523. formReceiptData.data.fileList = fileList.value.map((item) => {
  524. return {
  525. id: item.raw.id,
  526. fileName: item.raw.fileName,
  527. fileUrl: item.raw.fileUrl,
  528. };
  529. });
  530. } else {
  531. formReceiptData.data.fileList = [];
  532. }
  533. proxy.post("/statementOfAccount/editReceiptFile", formReceiptData.data).then(() => {
  534. openReceiptFile.value = false;
  535. getList();
  536. });
  537. };
  538. const openProofFile = ref(false);
  539. const formProofData = reactive({
  540. data: {
  541. id: "",
  542. fileList: [],
  543. },
  544. });
  545. const clickProofFile = (row) => {
  546. formProofData.data = {
  547. id: row.id,
  548. fileList: [],
  549. };
  550. if (row.proofFileList && row.proofFileList.length > 0) {
  551. fileList.value = proxy.deepClone(
  552. row.proofFileList.map((item) => {
  553. return {
  554. raw: item,
  555. name: item.fileName,
  556. url: item.fileUrl,
  557. };
  558. })
  559. );
  560. } else {
  561. fileList.value = [];
  562. }
  563. openProofFile.value = true;
  564. };
  565. const uploadProofData = ref({});
  566. const uploadProofFile = async (file) => {
  567. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  568. uploadProofData.value = res.uploadBody;
  569. file.id = res.id;
  570. file.fileName = res.fileName;
  571. file.fileUrl = res.fileUrl;
  572. file.uploadState = true;
  573. return true;
  574. };
  575. const handleProofSuccess = (any, UploadFile) => {
  576. UploadFile.raw.uploadState = false;
  577. };
  578. const submitProofFile = () => {
  579. if (fileList.value && fileList.value.length > 0) {
  580. for (let i = 0; i < fileList.value.length; i++) {
  581. if (fileList.value[i].raw.uploadState) {
  582. return ElMessage("文件上传中,请稍后提交");
  583. }
  584. }
  585. formProofData.data.fileList = fileList.value.map((item) => {
  586. return {
  587. id: item.raw.id,
  588. fileName: item.raw.fileName,
  589. fileUrl: item.raw.fileUrl,
  590. };
  591. });
  592. } else {
  593. formProofData.data.fileList = [];
  594. }
  595. proxy.post("/statementOfAccount/editProofFile", formProofData.data).then(() => {
  596. openProofFile.value = false;
  597. getList();
  598. });
  599. };
  600. const openPrint = ref(false);
  601. const rowData = ref({});
  602. const activeName = ref("sku");
  603. const clickPrint = (row) => {
  604. activeName.value = "sku";
  605. rowData.value = row;
  606. openPrint.value = true;
  607. };
  608. const clickCopyWLNCode = (row) => {
  609. ElMessage("复制数据中,请稍后");
  610. proxy.post("/statementOfAccount/getOrderWlnCodeStr", [row.id]).then((res) => {
  611. copyText(res, undefined, (error) => {
  612. if (error) {
  613. ElMessage.error(`复制失败: ${error} !`);
  614. } else {
  615. ElMessage.success(`复制成功!`);
  616. }
  617. });
  618. });
  619. };
  620. const openFileList = ref(false);
  621. const clickCancel = (status) => {
  622. openPrint.value = false;
  623. if (status) {
  624. openFileList.value = true;
  625. }
  626. };
  627. const clickExcelFile = () => {
  628. openFileList.value = true;
  629. };
  630. const clickManualSynchronization = () => {
  631. loading.value = true;
  632. proxy.post("/orderHandle/createStatementOfAccount", {}).then(
  633. () => {
  634. loading.value = false;
  635. ElMessage({ message: "同步完成", type: "success" });
  636. getList();
  637. },
  638. (err) => {
  639. console.log(err);
  640. loading.value = false;
  641. }
  642. );
  643. };
  644. </script>
  645. <style lang="scss" scoped>
  646. :deep(.el-dialog) {
  647. margin-top: 10px !important;
  648. margin-bottom: 10px !important;
  649. }
  650. </style>