index.vue 20 KB

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