CardImport.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class="card-import">
  3. <qm-low-form :fields="fields"> </qm-low-form>
  4. <a-table :data-source="tableData" :columns="columns" size="middle" bordered>
  5. <template #bodyCell="{ column, record }">
  6. <template v-if="column.key === 'operation'">
  7. <qm-button type="link" @click="editRow(record)">修改</qm-button>
  8. <qm-button type="link" @click="deleteRow(record)">删除</qm-button>
  9. </template>
  10. </template>
  11. </a-table>
  12. <AddCardDialog
  13. v-model="showAddDialog"
  14. v-if="showAddDialog"
  15. :cur-row="curRow"
  16. ></AddCardDialog>
  17. </div>
  18. </template>
  19. <script name="CardImport" lang="ts" setup>
  20. import { ref } from "vue";
  21. import AddCardDialog from "./AddCardDialog.vue";
  22. import type { TableColumnsType } from "@qmth/ui";
  23. const showAddDialog = ref(false);
  24. const curRow = ref(null);
  25. const editRow = (row: any) => {
  26. curRow.value = row;
  27. showAddDialog.value = true;
  28. };
  29. const fields = ref([
  30. {
  31. type: "buttons",
  32. children: [
  33. {
  34. text: "导入卡格式",
  35. attrs: {
  36. style: { marginLeft: 0 },
  37. },
  38. },
  39. {
  40. text: "新增卡格式",
  41. attrs: {
  42. type: "default",
  43. onClick: () => {
  44. showAddDialog.value = true;
  45. },
  46. },
  47. },
  48. ],
  49. },
  50. ]);
  51. const tableData = ref([{ a: 1, b: 2, c: 3, d: 4, e: 5 }]);
  52. const columns: TableColumnsType = [
  53. {
  54. title: "序号",
  55. dataIndex: "index",
  56. key: "index",
  57. width: 100,
  58. customRender: ({ index }) => `${index + 1}`,
  59. },
  60. {
  61. title: "科目",
  62. dataIndex: "a",
  63. },
  64. {
  65. title: "属性",
  66. dataIndex: "b",
  67. },
  68. {
  69. title: "张数",
  70. dataIndex: "c",
  71. },
  72. {
  73. title: "备注",
  74. dataIndex: "d",
  75. },
  76. {
  77. title: "更新时间",
  78. dataIndex: "e",
  79. },
  80. {
  81. title: "操作",
  82. key: "operation",
  83. width: 300,
  84. },
  85. ];
  86. const deleteRow = (row: any) => {
  87. window.$confirm({
  88. title: () => "系统通知",
  89. content: () => "请确认是否立即删除?",
  90. onOk() {
  91. //todo 执行删除接口
  92. },
  93. });
  94. };
  95. </script>
  96. <style lang="less" scoped>
  97. .card-import {
  98. padding: 0 20px 20px 20px;
  99. }
  100. </style>