operationTable.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="operation-table">
  3. <a-form ref="formSta" :model="formState" layout="horizontal" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
  4. <a-form-item name="areaPercentThreshold" label="面积百分比阈值(%)">
  5. <a-input v-model:value="formState.areaPercentThreshold" type="number" allowClear placeholder="请输入面积百分比阈值"></a-input>
  6. </a-form-item>
  7. <a-form-item label="门板最大基准面积(cm²)" name="maxAreaBase">
  8. <a-input v-model:value="formState.maxAreaBase" type="number" allowClear placeholder="请输入门板最大基准面积"></a-input>
  9. </a-form-item>
  10. <a-form-item label="像素面积比" name="pixelAreaRatio">
  11. <a-input v-model:value="formState.pixelAreaRatio" type="number" placeholder="请输入像素面积比"></a-input>
  12. </a-form-item>
  13. <a-form-item label="检测时间(秒)" name="detectInterval">
  14. <a-input v-model:value="formState.detectInterval" type="number" placeholder="请输入检测时间"></a-input>
  15. </a-form-item>
  16. <a-form-item label="持续时间阈值(秒)" name="durationThreshold">
  17. <a-input v-model:value="formState.durationThreshold" type="number" placeholder="请输入持续时间阈值"></a-input>
  18. </a-form-item>
  19. <a-form-item label="模型路径" name="segModelPath">
  20. <a-input v-model:value="formState.segModelPath" placeholder="请输入模型路径"></a-input>
  21. </a-form-item>
  22. <a-form-item label="摄像头" name="cameraId">
  23. <a-select ref="select" v-model:value="formState.cameraId">
  24. <a-select-option v-for="(item, index) in cameraData" :key="index" :value="item.value">{{ item.label }}</a-select-option>
  25. </a-select>
  26. </a-form-item>
  27. <a-form-item label="任务状态" name="status">
  28. <a-select ref="select" v-model:value="formState.status">
  29. <a-select-option v-for="(item, index) in taskData" :key="index" :value="item.value">{{ item.label }}</a-select-option>
  30. </a-select>
  31. </a-form-item>
  32. </a-form>
  33. <div style="display: flex; justify-content: flex-end; margin: 20px">
  34. <a-button style="margin-right: 10px" type="primary" @click="handleConfirm">确定</a-button>
  35. <a-button @click="handleCancel">取消</a-button>
  36. </div>
  37. </div>
  38. </template>
  39. <script setup lang="ts">
  40. import { ref, reactive, watch } from 'vue';
  41. import { saveOrUpdate } from '../faultConfig.api';
  42. import { taskData } from '../faultConfig.data';
  43. import { useMessage } from '/@/hooks/web/useMessage';
  44. let props = defineProps({
  45. gateId: {
  46. type: String,
  47. default: '',
  48. },
  49. recordData: {
  50. type: Object,
  51. default: () => {
  52. return {};
  53. },
  54. },
  55. cameraData: {
  56. type: Array,
  57. default: () => {
  58. return [];
  59. },
  60. },
  61. });
  62. const { createMessage } = useMessage();
  63. let formSta = ref();
  64. let formState = reactive({
  65. id: null,
  66. gateId: null,
  67. areaPercentThreshold: null,
  68. cameraId: null,
  69. detectInterval: null,
  70. durationThreshold: null,
  71. maxAreaBase: null,
  72. pixelAreaRatio: null,
  73. segModelPath: null,
  74. status: null,
  75. });
  76. let $emit = defineEmits(['handleClose']);
  77. //确定
  78. async function handleConfirm() {
  79. let res;
  80. if (props.recordData.id) {
  81. res = await saveOrUpdate(formState, true);
  82. } else {
  83. formState.gateId = props.gateId;
  84. res = await saveOrUpdate(formState, false);
  85. }
  86. if (res.code == 200) {
  87. createMessage.success('操作成功!');
  88. formSta.value.resetFields();
  89. $emit('handleClose');
  90. } else {
  91. createMessage.error('操作失败!');
  92. }
  93. }
  94. //取消
  95. function handleCancel() {
  96. formSta.value.resetFields();
  97. $emit('handleClose');
  98. }
  99. watch(
  100. () => props.recordData,
  101. (newV, oldV) => {
  102. if (JSON.stringify(props.recordData) != '{}') {
  103. formState = Object.assign(formState, newV) as any;
  104. }
  105. },
  106. {
  107. immediate: true,
  108. }
  109. );
  110. </script>
  111. <style lang="less" scoped>
  112. .zxm-form {
  113. padding: 20px 100px 20px 80px !important;
  114. }
  115. </style>