<!-- 因子设置 --> <script lang="ts" setup name="EnergyConsumptionSetUp"> import edit from './components/edit.vue' import { getSetUpList } from '@/api/api/energy/setup' const searchQuery = ref({ factorName: '', factorType: '', }) const loadingTable = ref(true) const columns = ref([ { text: '因子名称', value: 'factorName', align: 'center' }, { text: '因子类型', value: 'factorType', align: 'center' }, { text: '缺省值', value: 'defaultValue', align: 'center' }, { text: '值类型', value: 'valueTypeName', align: 'center' }, { text: '设定值', value: 'settingValue', align: 'center' }, { text: '单位价格设定', value: 'price', align: 'center' }, ]) // 表格 const total = ref<number>(0) const list = ref<any[]>([]) const search = () => { loadingTable.value = true getSetUpList(searchQuery.value).then((res) => { list.value = res.data.map((item: any) => ({ ...item, valueTypeName: String(item.valueType) === '0' ? '默认' : String(item.valueType) === '1' ? '设定' : '', })) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } search() const reset = () => { searchQuery.value = { factorName: '', factorType: '', } search() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 // const changePage = (val: { size?: number; page?: number }) => { // if (val && val.size) { // searchQuery.value.limit = val.size // } // if (val && val.page) { // searchQuery.value.offset = val.page // } // search() // } const editRef = ref() const editRow = (row: any) => { editRef.value.initDialog(row.id, 'edit') } const detailRow = (row: any) => { editRef.value.initDialog(row.id, 'detail') } </script> <template> <div> <edit ref="editRef" @refresh="search" /> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-input v-model="searchQuery.factorName" placeholder="因子名称" type="text" /> </search-item> <search-item> <el-input v-model="searchQuery.factorType" placeholder="因子类型" type="text" /> </search-item> </search-area> <table-container> <!-- <template #btns-right> </template> --> <!-- 表格区域 --> <normal-table :data="list" :columns="columns" :query="searchQuery" :list-loading="loadingTable" :is-multi="false" :pagination="false" > <template #preColumns> <el-table-column label="序号" width="55" align="center"> <template #default="scope"> {{ scope.$index + 1 }} </template> </el-table-column> </template> <template #columns> <el-table-column label="操作" align="center" width="120"> <template #default="{ row }"> <el-button type="primary" link size="small" @click="detailRow(row)"> 查看 </el-button> <el-button type="primary" link size="small" @click="editRow(row)"> 编辑 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </div> </template>