• vue2文件下载和合计表格


    vue2文件数据不多可以直接下载不需要后端的时候

    1.首先,确保你已经安装了 docxfile-saver

    npm install file-saver
    npm install docx file-saver
    

    2.全部代码如下

    1. <template>
    2. <a-modal
    3. title="详情"
    4. width="80%"
    5. v-model="visible"
    6. :confirmLoading="confirmLoading"
    7. >
    8. <a-descriptions title="" bordered>
    9. <a-descriptions-item label="出租方">{{
    10. form.rentOrg
    11. }}</a-descriptions-item>
    12. <a-descriptions-item label="承租方">{{
    13. form.lesseeOrg
    14. }}</a-descriptions-item>
    15. <a-descriptions-item label="统一社会信息代码">{{
    16. form.socialCode
    17. }}</a-descriptions-item>
    18. <a-descriptions-item label="合同时间"
    19. >{{ form.startDate }}-{{ form.endDate }}</a-descriptions-item
    20. >
    21. <a-descriptions-item label="合同编号">
    22. {{ form.contractNo }}
    23. </a-descriptions-item>
    24. <a-descriptions-item label="合同名称"
    25. >{{ form.contractName }}
    26. </a-descriptions-item>
    27. </a-descriptions>
    28. <div class="table-operator">
    29. <a-button
    30. type="primary"
    31. @click="generateDocx"
    32. :disabled="this.selectionRows.length > 0 ? false : true"
    33. >下载缴费单</a-button
    34. >
    35. <!-- <a-button type="primary" @click="getExport">下载缴费单</a-button> -->
    36. </div>
    37. <a-table
    38. ref="table"
    39. rowKey="id"
    40. :columns="columns"
    41. :dataSource="dataSource"
    42. :rowSelection="{
    43. selectedRowKeys: selectedRowKeys,
    44. onChange: onSelectChange,
    45. type: 'radio',
    46. }"
    47. :pagination="false"
    48. bordered
    49. >
    50. <span slot="action" slot-scope="text, record">
    51. <a v-if="record.payStatus == 1" @click="payment(record, false)">缴费</a>
    52. <a v-else @click="payment(record, true)">详情</a>
    53. </span>
    54. </a-table>
    55. <costDeatil ref="costDeatil" @getBillDetail="getBillDetail"></costDeatil>
    56. <div slot="footer">
    57. <a-button type="dashed" @click="visible = false">关闭</a-button>
    58. </div>
    59. </a-modal>
    60. </template>
    61. <script>
    62. import costDeatil from "./components/costDeatil.vue";
    63. import { getBillDetail, assetrentbillList } from "@/api/assetrentplan";
    64. import { JeecgListMixin } from "@/mixins/JeecgListMixin";
    65. // import { downloadFile } from "@/api/manage";
    66. // import { exportWord, getBase64Sync } from "@/components/export.js";
    67. import {
    68. Document,
    69. Packer,
    70. Paragraph,
    71. TextRun,
    72. Table,
    73. TableRow,
    74. TableCell,
    75. WidthType,
    76. AlignmentType,
    77. HeadingLevel,
    78. Indent,
    79. } from "docx";
    80. import { saveAs } from "file-saver";
    81. export default {
    82. components: { costDeatil },
    83. mixins: [JeecgListMixin],
    84. data() {
    85. return {
    86. visible: false,
    87. confirmLoading: false,
    88. columns: [
    89. {
    90. title: "费用周期",
    91. dataIndex: "date",
    92. align: "center",
    93. customRender: (text, record, index) =>
    94. `${record.startDate}-${record.endDate}`,
    95. },
    96. {
    97. title: "租约到期日期",
    98. dataIndex: "rentEndDate",
    99. align: "center",
    100. },
    101. {
    102. title: "应收金额(元)",
    103. dataIndex: "shouldPayMoney",
    104. align: "center",
    105. },
    106. {
    107. title: "缴费状态",
    108. dataIndex: "payStatus",
    109. align: "center",
    110. customRender: (text, record, index) =>
    111. `${text == 1 ? "待缴费" : "已缴费"}`,
    112. },
    113. {
    114. title: "实收金额",
    115. dataIndex: "realPayMoney",
    116. align: "center",
    117. },
    118. {
    119. title: "实收日期",
    120. dataIndex: "realPayDate",
    121. align: "center",
    122. },
    123. {
    124. title: "操作人",
    125. dataIndex: "operatePersonName",
    126. align: "center",
    127. },
    128. {
    129. title: "操作日期",
    130. dataIndex: "operateDate",
    131. align: "center",
    132. },
    133. {
    134. title: "操作",
    135. width: "150px",
    136. scopedSlots: { customRender: "action" },
    137. align: "center",
    138. },
    139. ],
    140. selectedRowKeys: [],
    141. // url: {
    142. // list: `/asset/assetrentcontract/getBillDetail?`,
    143. // },
    144. disableMixinCreated: true,
    145. form: {},
    146. pagination: {
    147. current: 1,
    148. pageSize: 10,
    149. total: 0,
    150. showTotal: (total) => `共 ${total} 条数据`, // 展示总共有几条数据
    151. },
    152. dataSource2: [],
    153. downform: {},
    154. date: "",
    155. };
    156. },
    157. mounted() {
    158. this.date = new Date().toLocaleDateString();
    159. },
    160. methods: {
    161. payment(record, disabled) {
    162. this.$refs.costDeatil.clickShowModal(record, disabled);
    163. },
    164. onSelectChange(selectedRowKeys, selectionRows) {
    165. // console.log("selectedRowKeys", selectedRowKeys);
    166. // console.log("selectionRows", selectionRows);
    167. this.selectedRowKeys = selectedRowKeys;
    168. this.selectionRows = selectionRows;
    169. // this.selectedRowKeys = row;
    170. this.billList(
    171. this.selectionRows[0].id,
    172. this.selectionRows[0].rentContractId
    173. );
    174. },
    175. billList(id, rentContractId) {
    176. assetrentbillList({ id: id, rentContractId: rentContractId }).then(
    177. (res) => {
    178. if (res.code == 0) {
    179. // console.log("获取租金帐单关联资产列表", res);
    180. console.log("res", res);
    181. this.downform = res.data;
    182. this.dataSource2 = res.data.assetRentContractAssetRelationList;
    183. console.log(" this.dataSource2", this.dataSource2);
    184. }
    185. }
    186. );
    187. },
    188. // 详情
    189. getBillDetail() {
    190. this.loading = true;
    191. getBillDetail(this.form.id)
    192. .then((res) => {
    193. this.loading = false;
    194. if (res.code == 0) {
    195. this.form = res.data;
    196. this.dataSource = res.data.assetRentBillList;
    197. }
    198. })
    199. .catch((err) => {
    200. this.loading = false;
    201. });
    202. },
    203. clickShowModal(record) {
    204. // console.log("record", record);
    205. this.visible = true;
    206. // this.dataSource = [];
    207. this.form = record;
    208. // this.queryParam.rentContractId = record.id;
    209. // this.loadData(1);
    210. this.selectionRows = [];
    211. this.selectedRowKeys = [];
    212. this.getBillDetail();
    213. },
    214. assetrentbillList(id, rentContractId) {
    215. assetrentbillList({ id: id, rentContractId: rentContractId }).then(
    216. (res) => {
    217. if (res.code == 0) {
    218. // console.log("获取租金帐单关联资产列表", res);
    219. this.contract = res.data;
    220. this.dataSource2 = res.data.assetRentContractAssetRelationList;
    221. }
    222. }
    223. );
    224. },
    225. generateDocx() {
    226. let totalShouldPayMoney = this.dataSource2.reduce(
    227. (sum, item) => sum + (item.shouludPayMoney || 0),
    228. 0
    229. );
    230. const doc = new Document({
    231. sections: [
    232. {
    233. children: [
    234. new Paragraph({
    235. children: [
    236. new TextRun({
    237. text: "缴费通知单",
    238. heading: HeadingLevel.TITLE,
    239. bold: true,
    240. size: 32,
    241. }),
    242. ],
    243. alignment: AlignmentType.CENTER,
    244. }),
    245. new Paragraph({
    246. children: [
    247. new TextRun({
    248. text: `尊敬的承租户:${this.downform.lesseeOrg}`,
    249. heading: HeadingLevel.HEADING_1,
    250. bold: true,
    251. size: 24,
    252. }),
    253. ],
    254. }),
    255. new Paragraph({
    256. children: [
    257. new TextRun({
    258. text: `本公司特函通知,以下是${this.downform.startDate}至${this.downform.endDate} 费用使用详单。您租赁的项目按合同约定应缴纳以下费用,敬请贵司在收到本通知书单日内将下述款项以银行转账进行缴纳。`,
    259. size: 18,
    260. }),
    261. ],
    262. indent: { firstLine: 480 }, // 设置首行缩进
    263. }),
    264. new Table({
    265. rows: [
    266. new TableRow({
    267. children: [
    268. new TableCell({
    269. children: [new Paragraph("资产编号")],
    270. width: { size: 10, type: WidthType.PERCENTAGE },
    271. alignment: AlignmentType.CENTER,
    272. verticalAlign: AlignmentType.CENTER,
    273. }),
    274. new TableCell({
    275. children: [new Paragraph("资产名称")],
    276. width: { size: 10, type: WidthType.PERCENTAGE },
    277. alignment: AlignmentType.CENTER,
    278. verticalAlign: AlignmentType.CENTER,
    279. }),
    280. new TableCell({
    281. children: [new Paragraph("单月租金(元)")],
    282. width: { size: 10, type: WidthType.PERCENTAGE },
    283. alignment: AlignmentType.CENTER,
    284. verticalAlign: AlignmentType.CENTER,
    285. }),
    286. new TableCell({
    287. children: [new Paragraph("数量")],
    288. width: { size: 10, type: WidthType.PERCENTAGE },
    289. alignment: AlignmentType.CENTER,
    290. verticalAlign: AlignmentType.CENTER,
    291. }),
    292. new TableCell({
    293. children: [new Paragraph("应付金额")],
    294. width: { size: 10, type: WidthType.PERCENTAGE },
    295. alignment: AlignmentType.CENTER,
    296. verticalAlign: AlignmentType.CENTER,
    297. }),
    298. ],
    299. }),
    300. ...this.dataSource2.map(
    301. (item) =>
    302. new TableRow({
    303. children: [
    304. new TableCell({
    305. children: [new Paragraph(item.code || "")],
    306. alignment: AlignmentType.CENTER,
    307. verticalAlign: AlignmentType.CENTER,
    308. }),
    309. new TableCell({
    310. children: [new Paragraph(item.name || "")],
    311. alignment: AlignmentType.CENTER,
    312. verticalAlign: AlignmentType.CENTER,
    313. }),
    314. new TableCell({
    315. children: [
    316. new Paragraph(
    317. item.monthRentMoney.toString() || ""
    318. ),
    319. ],
    320. alignment: AlignmentType.CENTER,
    321. verticalAlign: AlignmentType.CENTER,
    322. }),
    323. new TableCell({
    324. children: [
    325. new Paragraph(item.monthNum.toString() || ""),
    326. ],
    327. alignment: AlignmentType.CENTER,
    328. verticalAlign: AlignmentType.CENTER,
    329. }),
    330. new TableCell({
    331. children: [
    332. new Paragraph(
    333. item.shouludPayMoney.toString() || ""
    334. ),
    335. ],
    336. alignment: AlignmentType.CENTER,
    337. verticalAlign: AlignmentType.CENTER,
    338. }),
    339. ],
    340. })
    341. ),
    342. // 添加合计行
    343. new TableRow({
    344. children: [
    345. new TableCell({
    346. children: [new Paragraph("合计")],
    347. columnSpan: 4, // 合并前四列
    348. alignment: AlignmentType.CENTER,
    349. verticalAlign: AlignmentType.CENTER,
    350. }),
    351. new TableCell({
    352. children: [
    353. new Paragraph(totalShouldPayMoney.toFixed(2)),
    354. ],
    355. alignment: AlignmentType.CENTER,
    356. verticalAlign: AlignmentType.CENTER,
    357. shading: {
    358. color: "#EFEFEF",
    359. val: "clear",
    360. },
    361. borders: {
    362. bottom: { style: "single", size: 12 },
    363. },
    364. }),
    365. ],
    366. }),
    367. ],
    368. }),
    369. new Paragraph({
    370. children: [
    371. new TextRun({
    372. text: `出租方:${this.downform.rentOrgName}`,
    373. size: 18,
    374. }),
    375. ],
    376. alignment: AlignmentType.RIGHT,
    377. }),
    378. new Paragraph({
    379. children: [
    380. new TextRun({
    381. text: `${this.date}`,
    382. size: 18,
    383. }),
    384. ],
    385. alignment: AlignmentType.RIGHT,
    386. }),
    387. ],
    388. },
    389. ],
    390. });
    391. Packer.toBlob(doc).then((blob) => {
    392. saveAs(blob, "缴费单详情.docx");
    393. });
    394. },
    395. },
    396. };
    397. </script>
    1. import {
    2. Document,
    3. Packer,
    4. Paragraph,
    5. TextRun,
    6. Table,
    7. TableRow,
    8. TableCell,
    9. WidthType,
    10. AlignmentType,
    11. HeadingLevel,
    12. Indent,
    13. } from "docx";
    14. import { saveAs } from "file-saver";
    15. -----------------------------------------------------------------------------------------
    16. indent: { firstLine: 480 }, // 设置首行缩进
    17. //字段和数据一起写可以用模板字符串
    18. new Paragraph({
    19. children: [
    20. new TextRun({
    21. text: `尊敬的承租户:${this.downform.lesseeOrg}`,
    22. heading: HeadingLevel.HEADING_1,
    23. bold: true,
    24. size: 24,
    25. }),
    26. ],
    27. }),
    28. // 添加合计行 可以这样写 合并前4
    29. new TableRow({
    30. children: [
    31. new TableCell({
    32. children: [new Paragraph("合计")],
    33. columnSpan: 4, // 合并前四列
    34. alignment: AlignmentType.CENTER,
    35. verticalAlign: AlignmentType.CENTER,
    36. }),

     

    vue2数据很多的时候需要后端

    1. <a-button type="primary" style="margin-left: 8px" @click="getExport"
    2. >下载导入模板</a-button
    3. >
    import { downloadFile } from "@/api/manage";

     

     api/manage代码如下

    1. // import { axios } from '@/utils/request'
    2. import axios from "@/utils/axios";
    3. import signMd5Utils from "@/utils/encryption/signMd5Utils";
    4. const api = {
    5. user: "/mock/api/user",
    6. role: "/mock/api/role",
    7. service: "/mock/api/service",
    8. permission: "/mock/api/permission",
    9. permissionNoPager: "/mock/api/permission/no-pager",
    10. };
    11. export default api;
    12. //post
    13. export function postAction(url, parameter) {
    14. let sign = signMd5Utils.getSign(url, parameter);
    15. //将签名和时间戳,添加在请求接口 Header
    16. let signHeader = {
    17. "X-Sign": sign,
    18. "X-TIMESTAMP": signMd5Utils.getDateTimeToString(),
    19. };
    20. return axios({
    21. url: url,
    22. method: "post",
    23. data: parameter,
    24. headers: signHeader,
    25. });
    26. }
    27. //post method= {post | put}
    28. export function httpAction(url, parameter, method) {
    29. let sign = signMd5Utils.getSign(url, parameter);
    30. //将签名和时间戳,添加在请求接口 Header
    31. let signHeader = {
    32. "X-Sign": sign,
    33. "X-TIMESTAMP": signMd5Utils.getDateTimeToString(),
    34. };
    35. return axios({
    36. url: url,
    37. method: method,
    38. data: parameter,
    39. headers: signHeader,
    40. });
    41. }
    42. //put
    43. export function putAction(url, parameter) {
    44. return axios({
    45. url: url,
    46. method: "put",
    47. data: parameter,
    48. });
    49. }
    50. //get
    51. export function getAction(url, parameter) {
    52. let sign = signMd5Utils.getSign(url, parameter);
    53. //将签名和时间戳,添加在请求接口 Header
    54. let signHeader = {
    55. "X-Sign": sign,
    56. "X-TIMESTAMP": signMd5Utils.getDateTimeToString(),
    57. };
    58. return axios({
    59. url: url,
    60. method: "get",
    61. params: parameter,
    62. headers: signHeader,
    63. });
    64. }
    65. //deleteAction
    66. export function deleteAction(url, parameter) {
    67. return axios({
    68. url: url,
    69. method: "delete",
    70. params: parameter,
    71. });
    72. }
    73. export function getUserList(parameter) {
    74. return axios({
    75. url: api.user,
    76. method: "get",
    77. params: parameter,
    78. });
    79. }
    80. export function getRoleList(parameter) {
    81. return axios({
    82. url: api.role,
    83. method: "get",
    84. params: parameter,
    85. });
    86. }
    87. export function getServiceList(parameter) {
    88. return axios({
    89. url: api.service,
    90. method: "get",
    91. params: parameter,
    92. });
    93. }
    94. export function getPermissions(parameter) {
    95. return axios({
    96. url: api.permissionNoPager,
    97. method: "get",
    98. params: parameter,
    99. });
    100. }
    101. // id == 0 add post
    102. // id != 0 update put
    103. export function saveService(parameter) {
    104. return axios({
    105. url: api.service,
    106. method: parameter.id == 0 ? "post" : "put",
    107. data: parameter,
    108. });
    109. }
    110. /**
    111. * 下载文件 用于excel导出
    112. * @param url
    113. * @param parameter
    114. * @returns {*}
    115. */
    116. export function downFile(url, parameter, method) {
    117. return axios({
    118. url: url,
    119. params: parameter,
    120. method: method ? method : "get",
    121. responseType: "blob",
    122. });
    123. }
    124. /**
    125. * 下载文件
    126. * @param url 文件路径
    127. * @param fileName 文件名
    128. * @param parameter
    129. * @returns {*}
    130. */
    131. export function downloadFile(url, fileName, parameter,method) {
    132. return downFile(url, parameter,method).then((data) => {
    133. // if (!data || data.size === 0) {
    134. // Vue.prototype['$message'].warning('文件下载失败')
    135. // return
    136. // }
    137. if (typeof window.navigator.msSaveBlob !== "undefined") {
    138. window.navigator.msSaveBlob(new Blob([data]), fileName);
    139. } else {
    140. let url = window.URL.createObjectURL(new Blob([data]));
    141. let link = document.createElement("a");
    142. link.style.display = "none";
    143. link.href = url;
    144. link.setAttribute("download", fileName);
    145. document.body.appendChild(link);
    146. link.click();
    147. document.body.removeChild(link); //下载完成移除元素
    148. window.URL.revokeObjectURL(url); //释放掉blob对象
    149. }
    150. });
    151. }
    152. /**
    153. * 文件上传 用于富文本上传图片
    154. * @param url
    155. * @param parameter
    156. * @returns {*}
    157. */
    158. export function uploadAction(url, parameter) {
    159. return axios({
    160. url: url,
    161. data: parameter,
    162. method: "post",
    163. headers: {
    164. "Content-Type": "multipart/form-data", // 文件上传
    165. },
    166. });
    167. }
    168. /**
    169. * 获取文件服务访问路径
    170. * @param avatar
    171. * @param subStr
    172. * @returns {*}
    173. */
    174. export function getFileAccessHttpUrl(avatar, subStr) {
    175. if (!subStr) subStr = "http";
    176. try {
    177. if (avatar && avatar.startsWith(subStr)) {
    178. return avatar;
    179. } else {
    180. if (avatar && avatar.length > 0 && avatar.indexOf("[") == -1) {
    181. return window._CONFIG["staticDomainURL"] + "/" + avatar;
    182. }
    183. }
    184. } catch (err) {
    185. return;
    186. }
    187. }

     使用

    1. //导出模板
    2. getExport() {
    3. downloadFile(
    4. "/asset/entryrecord/exportTemplateXls",
    5. "财务信息模板.xlsx",
    6. {},
    7. "post"
    8. );
    9. },

    合计

    效果如图

    代码

    1. columns: [
    2. {
    3. title: "序号",
    4. customRender: (text, record, index) => {
    5. if (record.isTotalRow) {
    6. return {
    7. children: "合计",
    8. attrs: { colSpan: 3 },
    9. };
    10. }
    11. return index + 1;
    12. },
    13. width: 70,
    14. align: "center",
    15. },
    16. {
    17. title: "企业名称",
    18. align: "center",
    19. dataIndex: "companyName",
    20. width: 150,
    21. customRender: (text, record, index) => {
    22. if (record.isTotalRow) {
    23. return {
    24. children: null,
    25. attrs: { colSpan: 0 },
    26. };
    27. }
    28. return text;
    29. },
    30. },
    31. {
    32. title: "转让资产名称",
    33. align: "center",
    34. dataIndex: "assetName",
    35. width: 150,
    36. customRender: (text, record, index) => {
    37. if (record.isTotalRow) {
    38. return {
    39. children: null,
    40. attrs: { colSpan: 0 },
    41. };
    42. }
    43. return text;
    44. },
    45. },
    46. {
    47. title: "账面净值(元)",
    48. align: "center",
    49. dataIndex: "bookMoney",
    50. width: 150,
    51. },
    52. {
    53. title: "转让方式",
    54. align: "center",
    55. dataIndex: "transferWay",
    56. width: 150,
    57. customRender: (text, record, index) => {
    58. switch (Number.parseInt(text)) {
    59. case 1:
    60. return "公开转让";
    61. case 2:
    62. return "协议转让";
    63. default:
    64. return "/";
    65. }
    66. },
    67. },
    68. {
    69. title: "转让行为最终审批单位",
    70. align: "center",
    71. dataIndex: "transferFinalOrg",
    72. width: 150,
    73. customRender: (text, record, index) => {
    74. switch (Number.parseInt(text)) {
    75. case 1:
    76. return "市政府";
    77. case 2:
    78. return "左海集团";
    79. case 3:
    80. return "二级企业";
    81. default:
    82. return "/";
    83. }
    84. },
    85. },
    86. {
    87. title: "受让方名称",
    88. align: "center",
    89. dataIndex: "receiveName",
    90. width: 150,
    91. },
    92. {
    93. title: "受让方性质",
    94. align: "center",
    95. dataIndex: "receiveType",
    96. width: 150,
    97. customRender: (text, record, index) => {
    98. switch (Number.parseInt(text)) {
    99. case 1:
    100. return "个人";
    101. case 2:
    102. return "私有企业";
    103. case 3:
    104. return "国有全资企业";
    105. case 4:
    106. return "国有控股企业";
    107. case 5:
    108. return "国有实际控制企业";
    109. case 6:
    110. return "国有参股企业";
    111. default:
    112. return "其他";
    113. }
    114. },
    115. },
    116. {
    117. title: "评估价值(元)",
    118. align: "center",
    119. dataIndex: "evaluateMoney",
    120. width: 150,
    121. },
    122. {
    123. title: "转让底价(元)",
    124. align: "center",
    125. dataIndex: "transferMinPrice",
    126. width: 150,
    127. },
    128. {
    129. title: "成交金额(元)",
    130. align: "center",
    131. dataIndex: "dealMoney",
    132. width: 150,
    133. },
    134. {
    135. title: "溢价(元)",
    136. align: "center",
    137. dataIndex: "moreMoney",
    138. width: 150,
    139. },
    140. {
    141. title: "转让合同签订日期",
    142. align: "center",
    143. dataIndex: "signDate",
    144. width: 150,
    145. },
    146. {
    147. title: "备注",
    148. align: "center",
    149. dataIndex: "remark",
    150. width: 150,
    151. },
    152. ],
    1. assetTransferAllCount() {
    2. this.loading = true;
    3. const meta = { companyName: this.queryParam.companyName };
    4. // console.log("this.queryParam", this.queryParam);
    5. assetTransferAllCount(meta)
    6. .then((res) => {
    7. this.loading = false;
    8. if (res.code == 0) {
    9. console.log("res", res);
    10. this.dataSource = res.data.list;
    11. // console.log(" this.dataSource", this.dataSource);
    12. // 使用解构赋值简化对象创建过程
    13. const {
    14. bookMoney,
    15. transferWay,
    16. transferFinalOrg,
    17. receiveName,
    18. receiveType,
    19. evaluateMoney,
    20. transferMinPrice,
    21. dealMoney,
    22. moreMoney,
    23. signDate,
    24. remark,
    25. } = res.data;
    26. const obj = {
    27. isTotalRow: true,
    28. bookMoney,
    29. transferWay: "/",
    30. transferFinalOrg: "/",
    31. receiveName: "/",
    32. receiveType: "/",
    33. evaluateMoney,
    34. transferMinPrice,
    35. dealMoney,
    36. moreMoney,
    37. signDate: "/",
    38. remark,
    39. };
    40. this.dataSource.push(obj);
    41. // console.log(" this.dataSource22", this.dataSource);
    42. }
    43. })
    44. .catch((error) => {
    45. this.loading = false;
    46. console.error("Error fetching data:", error);
    47. });
    48. },

    重点是

      this.dataSource.push(obj);

    对象解构

    第一种

    let { foo, bar } = { foo: 'aaa', bar: 'bbb' };
    1. // 使用解构赋值简化对象创建过程
    2. const {
    3. bookMoney,
    4. transferWay,
    5. transferFinalOrg,
    6. receiveName,
    7. receiveType,
    8. evaluateMoney,
    9. transferMinPrice,
    10. dealMoney,
    11. moreMoney,
    12. signDate,
    13. remark,
    14. } = res.data;
    1. const obj = {
    2. isTotalRow: true,
    3. bookMoney,
    4. transferWay: "/",
    5. transferFinalOrg: "/",
    6. receiveName: "/",
    7. receiveType: "/",
    8. evaluateMoney,
    9. transferMinPrice,
    10. dealMoney,
    11. moreMoney,
    12. signDate: "/",
    13. remark,
    14. };

    第二种

    1. let { foo: baz } = { foo: 'aaa', bar: 'bbb' };
    2. baz // "aaa"
    1. const {
    2. data: res
    3. } = await uni.$http.get('/api/public/v1/goods/detail', {
    4. goods_id
    5. })
    6. console.log('res', res);

  • 相关阅读:
    JavaScript 在前端开发中有什么应用?
    Spring之AOP
    收发电子邮件
    Apache ECharts
    牛客网前端刷题(一)
    全栈之前端 | 6.CSS3基础知识之网页几种布局方法学习(2)
    每日一练 | 华为认证真题练习Day123
    卡码网语言基础课 | 排队取奶茶
    ESP8266-Arduino编程实例-MMA8452加速度计驱动
    万兆以太网MAC设计(8)ICMP协议详解以及ICMP层模块设计
  • 原文地址:https://blog.csdn.net/weixin_42348009/article/details/139660744