1 changed files with 106 additions and 0 deletions
@ -0,0 +1,106 @@ |
|||||||
|
<template> |
||||||
|
<div class="app-container app-container-bg"> |
||||||
|
<el-card class="first-card" ref='firstCard' shadow="always"> |
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" @submit.native.prevent> |
||||||
|
<!-- <el-form-item label="测站名称" prop="stnm"> |
||||||
|
<el-input v-model="queryParams.stnm" placeholder="请输入测站名称" clearable @keyup.enter.native="handleQuery" /> |
||||||
|
</el-form-item> --> |
||||||
|
<el-form-item> |
||||||
|
<el-button type="primary" icon="Edit" @click="handleUpdate">修改</el-button> |
||||||
|
<!-- <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> --> |
||||||
|
<!-- <el-button icon="Refresh" @click="resetQuery">重置</el-button> --> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
</el-card> |
||||||
|
<div class="el-card-p card-shadow carder-border mt10 pad10 "> |
||||||
|
<el-table class="table-box" v-table-height v-loading="loading" :data="weightSetList"> |
||||||
|
<el-table-column type="index" label="序号" width="55" :align="alignment" /> |
||||||
|
<el-table-column label="测站名称" :align="alignment" prop="stnm" /> |
||||||
|
<el-table-column label="权重" :align="alignment" prop="value" /> |
||||||
|
</el-table> |
||||||
|
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> |
||||||
|
</div> |
||||||
|
<el-dialog class="custom-dialog" :title="title" v-model="open" width="600px" append-to-body> |
||||||
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto"> |
||||||
|
<el-row :gutter="50"> |
||||||
|
<el-col v-for="(item, index) in updateTable" :key="index" :span="11"> |
||||||
|
<el-form-item :label="item.stnm" :prop="item.prop"> |
||||||
|
<el-input v-model="item.value" :disabled="item.disabled" /> |
||||||
|
</el-form-item> |
||||||
|
</el-col> |
||||||
|
</el-row> |
||||||
|
</el-form> |
||||||
|
<template #footer> |
||||||
|
<div class="dialog-footer"> |
||||||
|
<el-button type="primary" @click="submitForm(formRef)" v-loading='btnLoading'>确 定</el-button> |
||||||
|
<el-button @click="cancel">取 消</el-button> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
</el-dialog> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
<script setup> |
||||||
|
import { ref, reactive, onMounted, nextTick, getCurrentInstance } from 'vue' |
||||||
|
import { getToken } from "@/utils/auth"; |
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance() |
||||||
|
const alignment = 'center' |
||||||
|
const showSearch = ref(true) |
||||||
|
const queryParams = reactive({ |
||||||
|
pageNum: 1, |
||||||
|
pageSize: 10, |
||||||
|
stnm: '', |
||||||
|
}) |
||||||
|
const loading = ref(false) |
||||||
|
const total = ref(0) |
||||||
|
const weightSetList = ref([]) |
||||||
|
const getList = async () => { |
||||||
|
loading.value = true; |
||||||
|
try { |
||||||
|
const res = await proxy.axiosGet('/basic/weight/list', queryParams) |
||||||
|
if (res.code == 0) { |
||||||
|
weightSetList.value = res.data |
||||||
|
total.value = res.count |
||||||
|
} |
||||||
|
|
||||||
|
} catch (error) { |
||||||
|
} finally { |
||||||
|
loading.value = false |
||||||
|
} |
||||||
|
} |
||||||
|
const updateTable = ref([]) |
||||||
|
const handleUpdate = () => { |
||||||
|
open.value = true |
||||||
|
title.value = '修改权重设置' |
||||||
|
updateTable.value = JSON.parse(JSON.stringify(weightSetList.value)) |
||||||
|
} |
||||||
|
/*************************************************** 弹窗 ***************************************************/ |
||||||
|
const open = ref(false) |
||||||
|
const title = ref('修改') |
||||||
|
const form = reactive({}) |
||||||
|
const formRef = ref(null) |
||||||
|
const cancel = () => { |
||||||
|
open.value = false; |
||||||
|
} |
||||||
|
|
||||||
|
const submitForm = async (formRef) => { |
||||||
|
const totalValue = updateTable.value.reduce((sum, item) => sum + (parseFloat(item.value) || 0), 0); |
||||||
|
if (totalValue !== 1) { |
||||||
|
proxy.$message.warning('所有值的总和必须等于1.'); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
let res = await proxy.$axiosPost('/basic/weight/info/update', updateTable.value) |
||||||
|
if (res.code === 0) { |
||||||
|
proxy.$message.success(res.msg) |
||||||
|
await getList() |
||||||
|
} |
||||||
|
} finally { |
||||||
|
open.value = false |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
onMounted(() => { |
||||||
|
getList() |
||||||
|
}) |
||||||
|
</script> |
||||||
Loading…
Reference in new issue