- <template>
- <!-- 城区内河人工水位采集 -->
- <div class="publicContainer">
- <el-form :model="queryParams" ref="queryRef" :inline="true">
- <!-- <el-form-item label="采样年份:" prop="sampleYear">
- <el-date-picker
- clearable
- format="YYYY"
- value-format="YYYY"
- v-model="queryParams.sampleYear"
- type="year"
- placeholder="请选择"
- @change="change"
- />
- </el-form-item> -->
- <el-form-item label="采样时间:" prop="sampleTime">
- <el-date-picker
- clearable
- format="YYYY-MM"
- value-format="YYYY-MM"
- v-model="queryParams.sampleTime"
- type="month"
- placeholder="请选择"
- @change="change"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="Search" @click="searchData">搜索</el-button>
- <el-button icon="Refresh" @click="resetData">重置</el-button>
- <el-button icon="Plus" type="success" @click="addData">新增上报</el-button>
- </el-form-item>
- </el-form>
- <!-- 表格 -->
- <el-table :data="tableData" v-loading="tableLoading" :max-height="650">
- <el-table-column type="index" width="55" label="序号" />
- <el-table-column label="采样月份" prop="sampleDate" />
- <el-table-column label="后湖" prop="houRiver" />
- <el-table-column label="董湖" prop="dongRiver" />
- <el-table-column label="春晖湖" prop="chunhuiRiver" />
- <el-table-column label="航空公园" prop="hkgyRiver" />
- <el-table-column label="湖北职业学院" prop="zyxyRiver" />
- <el-table-column label="操作" show-overflow-tooltip width="200">
- <template #default="{ row }">
- <el-button type="primary" link @click="checkDetail(row)">详情</el-button>
- <el-button type="primary" link @click="editData(row)">修改</el-button>
- <el-button type="danger" link @click="deleteData(row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页 -->
- <pagination
- v-show="total > 0"
- :total="total"
- v-model:page="queryParams.pageNum"
- v-model:limit="queryParams.pageSize"
- @pagination="getDataList"
- />
- <!-- 添加 修改 查看彈框 -->
- <el-dialog :title="dialogTitle" v-model="showDialog" width="50%" :close-on-click-modal="false">
- <el-form ref="ruleForm" :model="formData" :rules="formRules" label-width="150" :disabled="isDisab">
- <el-row>
- <el-form-item label="采样时间:" prop="sampleTime1">
- <el-date-picker
- clearable
- format="YYYY-MM"
- value-format="YYYY-MM"
- v-model="formData.sampleTime1"
- type="month"
- placeholder="请选择"
- @change="change"
- />
- </el-form-item>
- <el-form-item label="后湖:" prop="houRiver" style="width: 45%">
- <el-input v-model="formData.houRiver" placeholder="请输入" style="width: 100%" clearable />
- </el-form-item>
-
- <el-form-item label="董湖:" prop="dongRiver" style="width: 45%">
- <el-input v-model="formData.dongRiver" placeholder="请输入" style="width: 100%" clearable />
- </el-form-item>
-
- <el-form-item label="春晖湖:" prop="chunhuiRiver" style="width: 45%">
- <el-input v-model="formData.chunhuiRiver" placeholder="请输入" style="width: 100%" clearable />
- </el-form-item>
- <el-form-item label="航空公园:" prop="hkgyRiver" style="width: 45%">
- <el-input v-model="formData.hkgyRiver" placeholder="请输入" style="width: 100%" clearable />
- </el-form-item>
- <el-form-item label="湖北职业学院:" prop="zyxyRiver" style="width: 45%">
- <el-input v-model="formData.zyxyRiver" placeholder="请输入" style="width: 100%" clearable />
- </el-form-item>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm" v-show="!isDisab">保 存</el-button>
- <el-button @click="cancel">关闭</el-button>
- </div>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import {
- artificialInlandRiversWaterPage,
- artificialInlandRiversWaterAdd,
- waterQualitySampleInfoEdit,
- artificialInlandRiversWaterDelete,
- } from '@/api/newPageline/riverCapacity.js';
- const { proxy } = getCurrentInstance();
- const tableData = ref([]);
- const tableLoading = ref(false);
- const isDisab = ref(false);
- const showDialog = ref(false);
- const dialogTitle = ref('');
- const total = ref(0);
- const AllData = reactive({
- formData: { sampleYear: '', sampleDate: '' },
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- houRiver: '',
- dongRiver: '',
- chunhuiRiver: '',
- hkgyRiver: '',
- zyxyRiver: '',
- sampleTime: '',
- sampleYear: '',
- sampleDate: '',
- },
- formRules: {
- riverId: [{ required: true, message: '请选择', trigger: 'blur' }],
- sampleTime1: [{ required: true, message: '请选择', trigger: 'blur' }],
- },
- });
- const { queryParams, formData, formRules } = toRefs(AllData);
-
- /** 表单重置 */
- function resetForm() {
- formData.value = {
- sampleDate: undefined,
- houRiver: undefined,
- dongRiver: undefined,
- chunhuiRiver: undefined,
- hkgyRiver: undefined,
- zyxyRiver: undefined,
- sampleTime: undefined,
- sampleYear: undefined,
- };
- proxy.resetForm('ruleForm');
- }
- //搜索
- function searchData() {
- queryParams.value.pageNum = 1;
- getDataList();
- }
- //重置
- function resetData() {
- proxy.resetForm('queryRef');
- searchData();
- }
-
- /** 查询列表 */
- function getDataList() {
- tableLoading.value = true;
- if (queryParams.value.sampleTime) {
- queryParams.value.sampleYear = queryParams.value.sampleTime.split('-')[0];
- queryParams.value.sampleDate = queryParams.value.sampleTime;
- } else {
- queryParams.value.sampleYear = [];
- queryParams.value.sampleDate = [];
- }
- let param = {
- orderBy: 'id asc',
- pageNum: 1,
- pageSize: 10,
- ...queryParams.value,
- };
- artificialInlandRiversWaterPage(param).then(res => {
- tableData.value = res.data;
- total.value = res.total;
- tableLoading.value = false;
- });
- }
- /** 新增按钮操作 */
- function addData() {
- resetForm();
- isDisab.value = false;
- showDialog.value = true;
- dialogTitle.value = '新增上报';
- }
-
- //表格修改
- function editData(row) {
- formData.value = { ...row };
- isDisab.value = false;
- showDialog.value = true;
- dialogTitle.value = '修改上报';
- console.log(row, 'row');
- formData.value.sampleTime1 = formData.value.sampleDate;
- }
-
- //详情按钮
- function checkDetail(row) {
- dialogTitle.value = '查看上报记录';
- isDisab.value = true;
- showDialog.value = true;
- formData.value = { ...row };
- formData.value.sampleTime1 = formData.value.sampleDate;
- }
-
- /** 新增弹框 修改弹框 提交按钮 */
- async function submitForm() {
- proxy.$refs['ruleForm'].validate(valid => {
- if (valid) {
- console.log('formData.value', formData.value);
- if (formData.value.sampleTime1) {
- formData.value.sampleYear = formData.value.sampleTime1.split('-')[0];
- formData.value.sampleDate = formData.value.sampleTime1;
- }
- if (formData.value.id != undefined) {
- waterQualitySampleInfoEdit(formData.value).then(() => {
- console.log(formData.value, 'formData.value');
- proxy.$modal.msgSuccess('修改成功');
- showDialog.value = false;
- getDataList();
- });
- } else {
- artificialInlandRiversWaterAdd(formData.value).then(() => {
- console.log(formData.value, 'formData.valueformData.valueformData.value');
- proxy.$modal.msgSuccess('新增成功');
- showDialog.value = false;
- getDataList();
- });
- }
- }
- });
- }
- // 表格删除
- function deleteData(row) {
- proxy.$modal
- .confirm('是否确认删除?')
- .then(async () => {
- const res = await artificialInlandRiversWaterDelete(row.id);
- if (res?.code !== 200) return;
- proxy.$modal.msgSuccess('操作成功!');
- getDataList();
- })
- .catch(() => {});
- }
-
- /** 取消按钮 */
- function cancel() {
- showDialog.value = false;
- resetForm();
- }
-
- onMounted(() => {
- getDataList();
- });
- </script>
- <style scoped lang="scss"></style>