index2.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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, warningLogAddLeather, 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. if (values.alarmType === 'leather_') {
  70. // 调用第二个接口
  71. await warningLogAddLeather({ ...values, sysId: props.deviceId });
  72. } else {
  73. // 调用默认接口
  74. await warningLogAdd({ ...values, sysId: props.deviceId });
  75. }
  76. // await warningLogAdd({ ...values, sysId: props.deviceId });
  77. }
  78. closeModal();
  79. //刷新列表
  80. reload();
  81. }
  82. const workFaceWarningSchemas: FormSchema[] = [
  83. ...workFaceWarningFormSchemas,
  84. {
  85. label: '关联条目',
  86. field: 'relatedEntries',
  87. component: 'ApiSelect',
  88. componentProps: {
  89. labelField: 'alarmName',
  90. valueField: 'id',
  91. resultField: 'records',
  92. api: warningLogList.bind(null, { sysId: props.deviceId }),
  93. },
  94. },
  95. {
  96. label: '预警后自动控制',
  97. field: 'isAutoControl',
  98. component: 'RadioGroup',
  99. componentProps: {
  100. //options里面由一个一个的radio组成,支持disabled
  101. options: [
  102. { label: '是', value: true },
  103. { label: '否', value: false },
  104. ],
  105. },
  106. },
  107. {
  108. label: '解除后自动复位',
  109. field: 'isAutoReset',
  110. component: 'RadioGroup',
  111. componentProps: {
  112. //options里面由一个一个的radio组成,支持disabled
  113. options: [
  114. { label: '是', value: true },
  115. { label: '否', value: false },
  116. ],
  117. },
  118. },
  119. ];
  120. </script>
  121. <style scoped></style>