dongyukun
2025-05-27 53a86ab33c9b6ab0e2c75853d60eae31e60d4d8f
src/views/model/sche/snapshotConf/det/index.vue
@@ -23,14 +23,14 @@
            class="!w-240px"
          />
        </el-form-item>
<!--        <el-form-item label="参数编码" prop="paramCode">-->
<!--          <el-input-->
<!--            v-model="queryParams.paramCode"-->
<!--            placeholder="请输入"-->
<!--            clearable-->
<!--            class="!w-240px"-->
<!--          />-->
<!--        </el-form-item>-->
        <!--        <el-form-item label="参数编码" prop="paramCode">-->
        <!--          <el-input-->
        <!--            v-model="queryParams.paramCode"-->
        <!--            placeholder="请输入"-->
        <!--            clearable-->
        <!--            class="!w-240px"-->
        <!--          />-->
        <!--        </el-form-item>-->
        <el-form-item>
          <el-button @click="handleQuery">
            <Icon icon="ep:search" class="mr-5px"/>
@@ -45,7 +45,7 @@
            plain
            @click="openForm('create')"
          >
            <Icon icon="ep:plus" class="mr-5px" />
            <Icon icon="ep:plus" class="mr-5px"/>
            新增
          </el-button>
@@ -60,7 +60,11 @@
        :data="list"
        row-key="id"
      >
        <el-table-column prop="dataType" label="数据类型"/>
        <el-table-column prop="dataType" align="center" label="数据类型">
          <template #default="scope">
            <dict-tag :type="DICT_TYPE.SUGGEST_SNAPSHOT_DATA_TYPE" :value="scope.row.dataType"/>
          </template>
        </el-table-column>
        <el-table-column prop="dataName" label="数据名称"/>
        <el-table-column prop="dataNo" label="数据编号"/>
        <el-table-column prop="leftLength" label="左侧长度(min)"/>
@@ -98,91 +102,91 @@
    </ContentWrap>
    <!-- 表单弹窗:添加/修改 -->
    <ConfigDetForm ref="formRef" @success="getList" />
    <ConfigDetForm ref="formRef" @success="getList"/>
  </el-drawer>
</template>
<script lang="ts" setup>
import {dateFormatter} from '@/utils/formatTime'
import * as configDetApi from '@/api/model/sche/suggest/snapshotConfigDet'
import ConfigDetForm from './configDetForm.vue'
  import {dateFormatter} from '@/utils/formatTime'
  import * as configDetApi from '@/api/model/sche/suggest/snapshotConfigDet'
  import ConfigDetForm from './configDetForm.vue'
  import type {DrawerProps} from "element-plus";
  import {DICT_TYPE, getIntDictOptions, getStrDictOptions} from '@/utils/dict'
import type {DrawerProps} from "element-plus";
  defineOptions({name: 'ConfigDet'})
defineOptions({name: 'ConfigDet'})
  const message = useMessage() // 消息弹窗
  const {t} = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const {t} = useI18n() // 国际化
  const drawer = ref(false)
  const loading = ref(true) // 列表的加载中
  const total = ref(0) // 列表的总页数
  const list = ref([]) // 字典表格数据
  const queryParams = reactive({
    page: 1,
    limit: 10,
    confId: '',
  })
  const queryFormRef = ref() // 搜索的表单
const drawer = ref(false)
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 字典表格数据
const queryParams = reactive({
  page: 1,
  limit: 10,
  confId: '',
})
const queryFormRef = ref() // 搜索的表单
const getList = async () => {
  loading.value = true
  try {
    const data = await configDetApi.getPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  const getList = async () => {
    loading.value = true
    try {
      const data = await configDetApi.getPage(queryParams)
      list.value = data.list
      total.value = data.total
    } finally {
      loading.value = false
    }
  }
}
/** 搜索按钮操作 */
const handleQuery = () => {
  getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: string) => {
  formRef.value.open(type, id, queryParams.confId)
}
/** 删除按钮操作 */
const handleDelete = async (id: string) => {
  try {
    // 删除的二次确认
    await message.delConfirm()
    // 发起删除
    await configDetApi.del(id)
    message.success(t('common.delSuccess'))
    // 刷新列表
    await getList()
  } catch {
  }
}
/** 打开弹窗 */
const open = async (confId?: string) => {
  resetForm()
  drawer.value = true
  queryParams.confId = confId
  if (confId) {
  /** 搜索按钮操作 */
  const handleQuery = () => {
    getList()
  }
}
defineExpose({open}) // 提供 open 方法,用于打开弹窗
/** 重置表单 */
const resetForm = () => {
  queryParams.confId = ''
}
  /** 重置按钮操作 */
  const resetQuery = () => {
    queryFormRef.value.resetFields()
    handleQuery()
  }
const handleClose = (done: () => void) => {
  drawer.value = false
}
  /** 添加/修改操作 */
  const formRef = ref()
  const openForm = (type: string, id?: string) => {
    formRef.value.open(type, id, queryParams.confId)
  }
  /** 删除按钮操作 */
  const handleDelete = async (id: string) => {
    try {
      // 删除的二次确认
      await message.delConfirm()
      // 发起删除
      await configDetApi.del(id)
      message.success(t('common.delSuccess'))
      // 刷新列表
      await getList()
    } catch {
    }
  }
  /** 打开弹窗 */
  const open = async (confId?: string) => {
    resetForm()
    drawer.value = true
    queryParams.confId = confId
    if (confId) {
      getList()
    }
  }
  defineExpose({open}) // 提供 open 方法,用于打开弹窗
  /** 重置表单 */
  const resetForm = () => {
    queryParams.confId = ''
  }
  const handleClose = (done: () => void) => {
    drawer.value = false
  }
</script>