index.vue 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <script lang="tsx">
  2. //表格
  3. import { defineComponent, ref } from "vue";
  4. import {
  5. costStandardDetailList,
  6. exportcostStandardDetail
  7. } from "@/api/singleLineQuery.js";
  8. import { transformPageResponse } from "@/utils/qomo";
  9. import { download } from "@qomo-platform/utils";
  10. import { ElMessage } from "element-plus";
  11. export default defineComponent({
  12. setup() {
  13. const tableRef = ref();
  14. //列
  15. const columns = ref([
  16. { type: "selection" },
  17. { prop: "materialNumber", label: "内部订单号" },
  18. { label: "物料号", prop: "versionNumber" },
  19. { label: "总实际成本", prop: "level", hideInSearchForm: true },
  20. { label: "材料成本", prop: "figureNumber", hideInSearchForm: true },
  21. { label: "直接人工", prop: "dosage", hideInSearchForm: true },
  22. { label: "折旧", prop: "unit", hideInSearchForm: true },
  23. { label: "燃动力", prop: "materialCost", hideInSearchForm: true },
  24. { label: "辅料", prop: "laborCost", hideInSearchForm: true },
  25. { label: "其他费用", prop: "equipmentCost", hideInSearchForm: true },
  26. { label: "人工工时(分钟)", prop: "driveCost", hideInSearchForm: true },
  27. {
  28. label: "机器工时(分钟)",
  29. prop: "supplyMaterialCost",
  30. hideInSearchForm: true
  31. },
  32. {
  33. type: "operation",
  34. label: "操作",
  35. minWidth: 120,
  36. render: ({ row }) => (
  37. <base-table-operation
  38. btnList={[
  39. {
  40. key: "edit",
  41. label: "查看结构树",
  42. onclick: () => checkTree(row)
  43. },
  44. ]}
  45. />
  46. )
  47. }
  48. ]);
  49. const render = () => {
  50. return (
  51. <BaseTable
  52. columns={columns.value}
  53. queryParamsToUrl
  54. toolbar={{ layout: "search-dnamic,reload,column-setting,fullscreen" }}
  55. ref={tableRef}
  56. issortTable
  57. request={async ({
  58. pageSize = 10,
  59. current = 1,
  60. ...otherSearchParams
  61. }) => {
  62. return transformPageResponse(
  63. await costStandardDetailList({
  64. pageNo: current,
  65. pageSize,
  66. ...otherSearchParams
  67. })
  68. );
  69. }}
  70. v-slots={{
  71. toolbar: ({ doAddOrEdit }) => (
  72. <el-space>
  73. <el-button type="success" onclick={handleExport}>
  74. 批量导出
  75. </el-button>
  76. </el-space>
  77. )
  78. }}
  79. />
  80. );
  81. };
  82. const handleExport = () => {
  83. exportcostStandardDetail(
  84. tableRef.value.selectionRows
  85. ? {
  86. selections: tableRef.value.selectionRows
  87. .map(item => item.id)
  88. .join(",")
  89. }
  90. : {}
  91. ).then(res => {
  92. download(res, "费用预测明细.xlsx");
  93. });
  94. };
  95. const checkTree = (row) => {
  96. ElMessage.info("查看结构树");
  97. };
  98. return render;
  99. }
  100. });
  101. </script>
  102. <style lang="scss" scoped></style>