index2.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="">
  3. <BasicTable @register="registerTable" :columns="workFaceWarningColumns">
  4. <template #tableTitle>
  5. <a-button preIcon="ant-design:plus-outlined" type="primary" @click="openModal()">新增</a-button>
  6. </template>
  7. <template #action="{ record }">
  8. <a class="table-action-link" @click="openModalFn(record)">编辑</a>
  9. <a-popconfirm title="确定删除?" @confirm="handleDelete(record)">
  10. <a class="table-action-link">删除</a>
  11. </a-popconfirm>
  12. </template>
  13. </BasicTable>
  14. <BaseModal @register="register" @add="onSubmit" @update="onSubmit" :form-schemas="workFaceWarningFormSchemas" />
  15. </div>
  16. </template>
  17. <script lang="ts" name="system-user" setup>
  18. import { BasicTable, TableAction } from '/@/components/Table';
  19. import { useListPage } from '/@/hooks/system/useListPage';
  20. import BaseModal from './BaseModal1.vue';
  21. import { useModal } from '/@/components/Modal';
  22. import { workFaceWarningColumns, workFaceWarningFormSchemas } from './warning.data';
  23. import { warningLogList, warningLogAdd, warningLogEdit, warningLogDeleteById } from './warning.api';
  24. const props = defineProps({
  25. deviceId: { type: String },
  26. });
  27. const { tableContext } = useListPage({
  28. tableProps: {
  29. api: warningLogList.bind(null, { sysId: props.deviceId }),
  30. scroll: { y: 390 },
  31. size: 'small',
  32. // expandRowByClick: true,
  33. clickToRowSelect: true,
  34. useSearchForm: false,
  35. rowSelection: {
  36. columnWidth: 20,
  37. },
  38. showTableSetting: false,
  39. formConfig: {
  40. disabled: true,
  41. showResetButton: false,
  42. showSubmitButton: false,
  43. },
  44. },
  45. });
  46. const [registerTable, { reload }] = tableContext;
  47. const [register, { openModal, closeModal }] = useModal();
  48. function openModalFn(record?) {
  49. if (record) {
  50. openModal(true, {
  51. isUpdate: true,
  52. record,
  53. });
  54. } else {
  55. openModal(true, {
  56. isUpdate: false,
  57. });
  58. }
  59. }
  60. async function handleDelete(record) {
  61. await warningLogDeleteById(record.id);
  62. }
  63. async function onSubmit(flag, values) {
  64. // 提交数据弹窗
  65. if (flag == 'update') {
  66. await warningLogEdit(values);
  67. } else {
  68. await warningLogAdd({ ...values, sysId: props.deviceId });
  69. }
  70. closeModal();
  71. //刷新列表
  72. reload();
  73. }
  74. </script>
  75. <style scoped></style>