index2.vue 2.8 KB

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