Kaynağa Gözat

style(types): 修改ts报错

Yi 2 yıl önce
ebeveyn
işleme
f9a03abe82

+ 6 - 18
src/typings/basic.d.ts

@@ -26,23 +26,11 @@ declare namespace RowField {
 }
 declare namespace EventSelectBox {
   interface Data {
-    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-    // @ts-ignore
     cowFieldData: any | undefined;
-    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-    // @ts-ignore
     isRequired: any | undefined;
-    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-    // @ts-ignore
     dataSource: any | undefined;
-    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-    // @ts-ignore
     isList: any | undefined;
-    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-    // @ts-ignore
     isDetails: any | undefined;
-    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-    // @ts-ignore
     showLine: any | undefined;
   }
 }
@@ -54,21 +42,21 @@ declare namespace RowIndicators {
     trigger_operation: number;
     is_cumulative: number;
     impact_mode: number;
-    impact_value: string;
+    impact_value: number | null | undefined;
     start_time: number;
   }
 }
 
 declare namespace IndicatorsSelectBox {
   interface Data {
-    cowEventData: ApiBackground.BasicCowField[] | null;
+    cowEventData: any | null;
     eventId: number;
     eventName: string;
-    triggerOperation: ApiBackground.BasicSelectValue[] | null;
-    isCumulative: ApiBackground.BasicSelectValue[] | null;
-    impactMode: ApiBackground.BasicSelectValue[] | null;
+    triggerOperation: any | null;
+    isCumulative: any | null;
+    impactMode: any | null;
     impactValue: number;
-    startTime: ApiBackground.BasicSelectValue[] | null;
+    startTime: any | null;
   }
 }
 

+ 0 - 45
src/views/background/event/components/select-box.vue

@@ -1,45 +0,0 @@
-<!--
-<template>
-  <n-select
-    v-model:value="selectValue"
-    size="large"
-    :options="getOptions"
-    style="width: 120px"
-    @update:value="handleUpdateValue"
-  />
-</template>
-
-<script lang="ts">
-import { defineComponent, computed, onMounted } from 'vue';
-export default defineComponent({
-  props: {
-    fieldOptions: {
-      type: Array,
-      default: null,
-      required: true
-    },
-    value: {
-      type: null,
-      default: null,
-      required: true
-    }
-  },
-  setup(props, { emit }) {
-    onMounted(() => {
-      // console.log(props);
-    });
-    const getOptions = computed(() => {
-      return props.fieldOptions;
-    });
-    // const emit = defineEmits(["updateTableValue"]);
-    return {
-      getOptions,
-      selectValue: props.value,
-      handleUpdateValue(value: string) {
-        emit('updateTableValue', value);
-      }
-    };
-  }
-});
-</script>
--->

+ 6 - 6
src/views/background/event/components/table-action-modal.vue

@@ -207,7 +207,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
       return h(NSelect, {
         options: selectBoxData.cowFieldData,
         value: tableData.value[index].column_name,
-        onUpdateTableValue(value: string) {
+        onUpdateValue(value: string) {
           tableData.value[index].column_name = value;
         }
       });
@@ -222,7 +222,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
       return h(NSelect, {
         options: selectBoxData.isRequired,
         value: tableData.value[index].is_required,
-        onUpdateTableValue(value: number) {
+        onUpdateValue(value: number) {
           tableData.value[index].is_required = value;
         }
       });
@@ -237,7 +237,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
       return h(NSelect, {
         options: selectBoxData.dataSource,
         value: tableData.value[index].data_source,
-        onUpdateTableValue(value: number) {
+        onUpdateValue(value: number) {
           tableData.value[index].data_source = value;
         }
       });
@@ -252,7 +252,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
       return h(NSelect, {
         options: selectBoxData.isList,
         value: tableData.value[index].is_list,
-        onUpdateTableValue(value: number) {
+        onUpdateValue(value: number) {
           tableData.value[index].is_list = value;
         }
       });
@@ -297,8 +297,8 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
         h(
           NButton,
           {
-            text: true,
-            style: { marginRight: '10px', color: 'red' },
+            type: 'error',
+            size: 'small',
             onClick: () => deleteData(index) // 点击按钮后的回调
           },
           { default: () => '删除' } // 按钮显示名称

+ 29 - 23
src/views/background/event/components/table-setting-modal.vue

@@ -7,7 +7,7 @@
       </n-space>
       <n-space class="w-full pt-16px" :size="25" justify="end">
         <n-button class="w-72px" @click="closeModal">取消</n-button>
-        <n-button class="w-72px" type="primary" @click="handleSubmit">保</n-button>
+        <n-button class="w-72px" type="primary" @click="handleSubmit">保</n-button>
       </n-space>
     </n-form>
   </n-modal>
@@ -16,7 +16,7 @@
 <script setup lang="ts">
 import { computed, h, reactive, ref, watch } from 'vue';
 import type { FormInst, DataTableColumns } from 'naive-ui';
-import { NButton, NSelect, NTag, NSpace } from 'naive-ui';
+import { NButton, NSelect, NTag, NSpace, NInput } from 'naive-ui';
 export interface Props {
   /** 弹窗可见性 */
   settingVisible: boolean;
@@ -87,7 +87,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
           { label: 'No', value: '2' }
         ],
         // value: tableData.value[index].column_name,
-        onUpdateTableValue(value: string) {
+        onUpdateValue(value: string) {
           console.log('选择事件', value);
         }
       });
@@ -99,16 +99,23 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
     maxWidth: 200,
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     render(row, index) {
-      return h(NSelect, {
-        options: [
-          { label: 'OK', value: '1' },
-          { label: 'No', value: '2' }
-        ],
-        // value: tableData.value[index].column_name,
-        onUpdateTableValue(value: string) {
-          console.log('选择事件', value);
-        }
-      });
+      return [
+        h(NSelect, {
+          options: [
+            { label: 'OK', value: '1' },
+            { label: 'No', value: '2' }
+          ],
+          // value: tableData.value[index].column_name,
+          onUpdateValue(value: string) {
+            console.log('选择事件', value);
+          },
+          style: { width: '30%' }
+        }),
+        h(NInput, {
+          size: 'small',
+          style: { width: '30%' }
+        })
+      ];
     }
   },
   {
@@ -123,7 +130,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
           { label: 'No', value: '2' }
         ],
         // value: tableData.value[index].column_name,
-        onUpdateTableValue(value: string) {
+        onUpdateValue(value: string) {
           console.log('选择事件', value);
         }
       });
@@ -141,7 +148,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
           { label: 'No', value: '2' }
         ],
         // value: tableData.value[index].column_name,
-        onUpdateTableValue(value: string) {
+        onUpdateValue(value: string) {
           console.log('选择事件', value);
         }
       });
@@ -150,15 +157,14 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
   {
     title: '操作',
     key: 'actions',
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    render(row, index) {
+    render: row => {
       return [
         h(
           NButton,
           {
             type: 'info',
             size: 'small',
-            onClick: () => editData(index) // 点击按钮后的回调
+            onClick: () => editData(row) // 点击按钮后的回调
           },
           { default: () => '编辑' } // 按钮显示名称
         ),
@@ -167,7 +173,7 @@ const createColumns = (): DataTableColumns<RowField.Data> => [
           {
             type: 'error',
             size: 'small',
-            onClick: () => deleteData(index) // 点击按钮后的回调
+            onClick: () => deleteData(row) // 点击按钮后的回调
           },
           { default: () => '删除' } // 按钮显示名称
         )
@@ -233,12 +239,12 @@ function createDefaultFormModel(): FormModel {
   };
 }
 
-function deleteData(index: number) {
-  console.log('==index=====', index);
+function deleteData(row: RowField.Data) {
+  console.log('==index=====', row);
 }
 
-function editData(index: number) {
-  console.log('==index=====', index);
+function editData(row: RowField.Data) {
+  console.log('==index=====', row);
 }
 
 function handleUpdateFormModelByModalType() {

+ 23 - 19
src/views/background/indicators/components/table-action-modal.vue

@@ -30,7 +30,7 @@
 <script setup lang="ts">
 import { ref, computed, reactive, watch, h } from 'vue';
 import type { FormInst, FormItemRule, DataTableColumns } from 'naive-ui';
-import { NButton, NTag, NInput, NInputNumber } from 'naive-ui';
+import { NButton, NTag, NInput, NInputNumber, NSelect } from 'naive-ui';
 import {
   EditSelectBoxDataSource,
   EditSelectBoxIsShow,
@@ -40,7 +40,6 @@ import {
 } from '@/constants';
 import { createRequiredFormRule } from '@/utils';
 import { basicEventList, fetchIndicatorsAdd, fetchIndicatorsEdit } from '@/service/api/event';
-import SelectBox from '@/views/background/event/components/select-box.vue';
 
 export interface Props {
   /** 弹窗可见性 */
@@ -114,7 +113,7 @@ const createData = (): RowIndicators.Data[] => [
     trigger_operation: 1,
     is_cumulative: 1,
     impact_mode: 1,
-    impact_value: '0',
+    impact_value: 0,
     start_time: 1
   }
 ];
@@ -171,10 +170,10 @@ const createColumns = (): DataTableColumns<RowIndicators.Data> => [
     maxWidth: 300,
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     render(row, index) {
-      return h(SelectBox, {
-        fieldOptions: selectBoxData.cowEventData,
+      return h(NSelect, {
+        options: selectBoxData.cowEventData,
         value: tableData.value[index].event_name,
-        onUpdateTableValue(value: string) {
+        onUpdateValue(value: string) {
           tableData.value[index].event_name = value;
         }
       });
@@ -186,10 +185,10 @@ const createColumns = (): DataTableColumns<RowIndicators.Data> => [
     maxWidth: 100,
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     render(row, index) {
-      return h(SelectBox, {
-        fieldOptions: selectBoxData.triggerOperation,
+      return h(NSelect, {
+        options: selectBoxData.triggerOperation,
         value: tableData.value[index].trigger_operation,
-        onUpdateTableValue(value: number) {
+        onUpdateValue(value: number) {
           tableData.value[index].trigger_operation = value;
         }
       });
@@ -201,10 +200,10 @@ const createColumns = (): DataTableColumns<RowIndicators.Data> => [
     maxWidth: 200,
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     render(row, index) {
-      return h(SelectBox, {
-        fieldOptions: selectBoxData.isCumulative,
+      return h(NSelect, {
+        options: selectBoxData.isCumulative,
         value: tableData.value[index].is_cumulative,
-        onUpdateTableValue(value: number) {
+        onUpdateValue(value: number) {
           tableData.value[index].is_cumulative = value;
         }
       });
@@ -216,10 +215,10 @@ const createColumns = (): DataTableColumns<RowIndicators.Data> => [
     maxWidth: 200,
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     render(row, index) {
-      return h(SelectBox, {
-        fieldOptions: selectBoxData.impactMode,
+      return h(NSelect, {
+        options: selectBoxData.impactMode,
         value: tableData.value[index].impact_mode,
-        onUpdateTableValue(value: number) {
+        onUpdateValue(value: number) {
           tableData.value[index].impact_mode = value;
         }
       });
@@ -231,9 +230,14 @@ const createColumns = (): DataTableColumns<RowIndicators.Data> => [
     maxWidth: 100,
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     render(row, index) {
-      return h(NInput, {
+      return h(NInputNumber, {
         value: tableData.value[index].impact_value,
-        onUpdateTableValue(value: string) {
+        showButton: false,
+        keyboard: {
+          ArrowDown: false,
+          ArrowUp: false
+        },
+        onUpdateValue(value) {
           tableData.value[index].impact_value = value;
         }
       });
@@ -245,8 +249,8 @@ const createColumns = (): DataTableColumns<RowIndicators.Data> => [
     maxWidth: 200,
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     render(row, index) {
-      return h(SelectBox, {
-        fieldOptions: selectBoxData.startTime,
+      return h(NSelect, {
+        options: selectBoxData.startTime,
         value: tableData.value[index].start_time,
         onUpdateValue(value: number) {
           tableData.value[index].start_time = value;