CardImport.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div class="card-import">
  3. <qm-low-form :fields="fields"></qm-low-form>
  4. <a-table
  5. :data-source="dataList"
  6. :columns="columns"
  7. size="middle"
  8. bordered
  9. :loading="loading"
  10. :pagination="pagination"
  11. >
  12. <template #bodyCell="{ column, record }">
  13. <template v-if="column.key === 'operation'">
  14. <qm-button type="link" @click="editRow(record)">修改</qm-button>
  15. <qm-button type="link" @click="deleteRow(record)">删除</qm-button>
  16. </template>
  17. </template>
  18. </a-table>
  19. <AddCardDialog
  20. v-model="showAddDialog"
  21. v-if="showAddDialog"
  22. :cur-row="curRow"
  23. ></AddCardDialog>
  24. <ImportCardDialog
  25. v-model="showImportCardDialog"
  26. v-if="showImportCardDialog"
  27. ></ImportCardDialog>
  28. </div>
  29. </template>
  30. <script name="CardImport" lang="ts" setup>
  31. import { ref, computed, reactive } from "vue";
  32. import AddCardDialog from "./AddCardDialog.vue";
  33. import type { TableColumnsType } from "@qmth/ui";
  34. import useTable from "@/hooks/useTable";
  35. import { getCardList } from "@/ap/baseDataConfig";
  36. import { useUserStore } from "@/store";
  37. import ImportCardDialog from "./ImportCardDialog.vue";
  38. const userStore = useUserStore();
  39. const showImportCardDialog = ref(false);
  40. const showAddDialog = ref(false);
  41. const curRow = ref(null);
  42. const editRow = (row: any) => {
  43. curRow.value = row;
  44. showAddDialog.value = true;
  45. };
  46. const fields = ref([
  47. {
  48. type: "buttons",
  49. children: [
  50. {
  51. text: "导入卡格式",
  52. attrs: {
  53. style: { marginLeft: 0 },
  54. onClick: () => {
  55. showImportCardDialog.value = true;
  56. },
  57. },
  58. },
  59. {
  60. text: "新增卡格式",
  61. attrs: {
  62. type: "default",
  63. onClick: () => {
  64. showAddDialog.value = true;
  65. },
  66. },
  67. },
  68. ],
  69. },
  70. ]);
  71. const { dataList, pagination, loading, getList, toPage } = useTable(
  72. getCardList,
  73. { examId: userStore.curExam?.id },
  74. true
  75. );
  76. const columns: TableColumnsType = [
  77. {
  78. title: "编号",
  79. dataIndex: "number",
  80. key: "index",
  81. width: 100,
  82. },
  83. {
  84. title: "科目",
  85. dataIndex: "subjectName",
  86. },
  87. {
  88. title: "属性",
  89. dataIndex: "parameter",
  90. },
  91. {
  92. title: "张数",
  93. dataIndex: "paperCount",
  94. },
  95. {
  96. title: "备注",
  97. dataIndex: "remark",
  98. },
  99. {
  100. title: "更新时间",
  101. dataIndex: "updateTime",
  102. },
  103. {
  104. title: "操作",
  105. key: "operation",
  106. width: 300,
  107. },
  108. ];
  109. const deleteRow = (row: any) => {
  110. window.$confirm({
  111. title: () => "系统通知",
  112. content: () => "请确认是否立即删除?",
  113. onOk() {
  114. //todo 执行删除接口
  115. },
  116. });
  117. };
  118. </script>
  119. <style lang="less" scoped>
  120. .card-import {
  121. padding: 0 20px 20px 20px;
  122. }
  123. </style>