DYL0109
2025-04-16 75f043dfa6660716364e66ee0b3cf99f44255686
zhitan-vue/src/views/modelconfiguration/setpeakvalley/setPeakValley.vue
@@ -6,52 +6,70 @@
          <el-input v-model="queryParams.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="handleQuery">
            搜索
          </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-item style="float: right">
          <el-button type="primary" icon="Plus" @click="handleAdd"> 时段配置 </el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="table-box">
      <div class="mt20 mb20">
        <el-button type="primary" icon="Plus" @click="handleAdd">
          时段配置
        </el-button>
    <div class="table-bg-style">
      <div class="table-box">
        <el-table v-loading="loading" :data="productoutputList" style="width: 100%" row-key="id">
          <el-table-column
            label="生效开始日期"
            align="center"
            key="beginDate"
            prop="beginDate"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="生效结束日期"
            align="center"
            key="endDate"
            prop="endDate"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="备注" align="center" key="remark" prop="remark" :show-overflow-tooltip="true" />
          <el-table-column
            label="创建时间"
            align="center"
            key="createTime"
            prop="createTime"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width">
            <template #default="scope">
              <el-tooltip content="电价配置" placement="top">
                <el-button link type="primary" icon="Plus" @click="handleExpandChange(scope.row)"> 电价配置 </el-button>
              </el-tooltip>
              <el-tooltip content="编辑" placement="top">
                <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"> 编辑 </el-button>
              </el-tooltip>
              <el-tooltip content="删除" placement="top">
                <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"> 删除 </el-button>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-table v-loading="loading" :data="productoutputList" style="width: 100%" row-key="id">
        <el-table-column label="生效开始日期" align="center" key="beginDate" prop="beginDate" :show-overflow-tooltip="true" />
        <el-table-column label="生效结束日期" align="center" key="endDate" prop="endDate" :show-overflow-tooltip="true" />
        <el-table-column label="备注" align="center" key="remark" prop="remark" :show-overflow-tooltip="true" />
        <el-table-column label="创建时间" align="center" key="createTime" prop="createTime" :show-overflow-tooltip="true" />
        <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-tooltip content="电价配置" placement="top">
              <el-button link type="primary" icon="Plus" @click="handleExpandChange(scope.row)">
                电价配置
              </el-button>
            </el-tooltip>
            <el-tooltip content="编辑" placement="top">
              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">
                编辑
              </el-button>
            </el-tooltip>
            <el-tooltip content="删除" placement="top">
              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">
                删除
              </el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog :title="title" v-model="open" width="600px" append-to-body>
      <el-form :model="form" :rules="rules" ref="formRef" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="生效日期" prop="beginEndDate">
              <el-date-picker v-model="form.beginEndDate" type="daterange" range-separator="到" format="YYYY-MM-DD"
                value-format="YYYY-MM-DD" start-placeholder="生效开始日期" end-placeholder="生效结束日期" style="width: 100%" />
              <el-date-picker
                v-model="form.beginEndDate"
                type="daterange"
                range-separator="到"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                start-placeholder="生效开始日期"
                end-placeholder="生效结束日期"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
@@ -79,45 +97,89 @@
        </el-row>
        <el-row v-for="(item, index) in formChild.data" :key="item.id">
          <el-col :span="4">
            <el-form-item label="类别名称" :prop="'data.' + index + '.type'" :rules="{
              required: true,
              message: '类别名称不能为空',
              trigger: ['change'],
            }">
            <el-form-item
              label="类别名称"
              :prop="'data.' + index + '.type'"
              :rules="{
                required: true,
                message: '类别名称不能为空',
                trigger: ['change'],
              }"
            >
              <el-select v-model="item.type" placeholder="类别名称" clearable style="width: 100%">
                <el-option v-for="dict in electricity_price" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
                <el-option
                  v-for="dict in electricity_price"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="时段电价" :prop="'data.' + index + '.effecticityPrice'" :rules="{
              required: true,
              message: '时段电价不能为空',
              trigger: ['blur', 'change'],
            }">
              <el-input-number v-model="item.effecticityPrice" :min="0.0" :precision="2" :step="0.1"
                placeholder="时段电价" style="width: 100%" controls-position="right" />
            <el-form-item
              label="时段电价"
              :prop="'data.' + index + '.effecticityPrice'"
              :rules="{
                required: true,
                message: '时段电价不能为空',
                trigger: ['blur', 'change'],
              }"
            >
              <el-input-number
                v-model="item.effecticityPrice"
                :min="0.0"
                :precision="2"
                :step="0.1"
                placeholder="时段电价"
                style="width: 100%"
                controls-position="right"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="开始时间" :prop="'data.' + index + '.startTime'" :rules="{
              required: true,
              message: '开始时间不能为空',
              trigger: ['blur', 'change'],
            }">
              <el-time-select v-model="item.startTime" placeholder="开始时间" :max-time="item.stopTime" start="00:00:00"
                step="00:30:00" end="24:00:00" style="width: 100%" format="HH:mm:00" />
            <el-form-item
              label="开始时间"
              :prop="'data.' + index + '.startTime'"
              :rules="{
                required: true,
                message: '开始时间不能为空',
                trigger: ['blur', 'change'],
              }"
            >
              <el-time-select
                v-model="item.startTime"
                placeholder="开始时间"
                :max-time="item.stopTime"
                start="00:00:00"
                step="00:30:00"
                end="24:00:00"
                style="width: 100%"
                format="HH:mm:00"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="结束时间" :prop="'data.' + index + '.stopTime'" :rules="{
              required: true,
              message: '结束时间不能为空',
              trigger: ['blur', 'change'],
            }">
              <el-time-select v-model="item.stopTime" placeholder="结束时间" :min-time="item.startTime" start="00:00:00"
                step="00:30:00" end="24:00:00" style="width: 100%" format="HH:mm:00" :disabled="item.startTime==null" />
            <el-form-item
              label="结束时间"
              :prop="'data.' + index + '.stopTime'"
              :rules="{
                required: true,
                message: '结束时间不能为空',
                trigger: ['blur', 'change'],
              }"
            >
              <el-time-select
                v-model="item.stopTime"
                placeholder="结束时间"
                :min-time="item.startTime"
                start="00:00:00"
                step="00:30:00"
                end="24:00:00"
                style="width: 100%"
                format="HH:mm:00"
                :disabled="item.startTime == null"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
@@ -127,11 +189,14 @@
          </el-col>
          <el-col :span="4">
            <el-form-item>
              <el-button link type="primary" icon="Plus" @click="handleAddChildChild">
                新增
              </el-button>
              <el-button link type="primary" icon="Delete" @click="handleDeleteChildChild(item, index)"
                v-if="formChild.data.length > 1">
              <el-button link type="primary" icon="Plus" @click="handleAddChildChild"> 新增 </el-button>
              <el-button
                link
                type="primary"
                icon="Delete"
                @click="handleDeleteChildChild(item, index)"
                v-if="formChild.data.length > 1"
              >
                删除
              </el-button>
            </el-form-item>
@@ -157,18 +222,18 @@
  delPeakValleyConfiguration,
  listPeakValleyConfigurationChild,
  updatePeakValleyConfigurationChild,
} from "@/api/modelConfiguration/setPeakValley";
import { nanoid } from "nanoid";
const { proxy } = getCurrentInstance();
const { electricity_price } = proxy.useDict("electricity_price");
const productoutputList = ref([]);
const open = ref(false);
const loading = ref(false);
const showSearch = ref(true);
const title = ref("");
const loadingChild = ref(true);
const openChild = ref(false);
const titleChild = ref("");
} from "@/api/modelConfiguration/setPeakValley"
import { nanoid } from "nanoid"
const { proxy } = getCurrentInstance()
const { electricity_price } = proxy.useDict("electricity_price")
const productoutputList = ref([])
const open = ref(false)
const loading = ref(false)
const showSearch = ref(true)
const title = ref("")
const loadingChild = ref(true)
const openChild = ref(false)
const titleChild = ref("")
const data = reactive({
  form: {},
  queryParams: {
@@ -195,82 +260,80 @@
      },
    ],
  },
});
})
const { queryParams, form, rules, formChild } = toRefs(data);
getList();
const { queryParams, form, rules, formChild } = toRefs(data)
getList()
// 模型配置管理-尖峰平谷配置-列表
function getList() {
  loading.value = true;
  listPeakValleyConfiguration(proxy.addDateRange(queryParams.value)).then(
    (res) => {
      loading.value = false;
      productoutputList.value = res.rows;
      queryParams.value.total = res.total;
    }
  );
  loading.value = true
  listPeakValleyConfiguration(proxy.addDateRange(queryParams.value)).then((res) => {
    loading.value = false
    productoutputList.value = res.rows
    queryParams.value.total = res.total
  })
}
// 模型配置管理-尖峰平谷配置-搜索
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
  queryParams.value.pageNum = 1
  getList()
}
// 模型配置管理-尖峰平谷配置-重置
function resetQuery() {
  proxy.resetForm("queryRef");
  (queryParams.value = {
  proxy.resetForm("queryRef")
  ;(queryParams.value = {
    pageNum: 1,
    pageSize: 10,
    timeType: "YEAR",
    dataTime: null,
    total: 0,
  }),
    handleQuery();
    handleQuery()
}
// 模型配置管理-尖峰平谷配置-新增
function handleAdd() {
  reset();
  open.value = true;
  title.value = "新增尖峰平谷时段配置";
  reset()
  open.value = true
  title.value = "新增尖峰平谷时段配置"
}
// 模型配置管理-尖峰平谷配置-编辑
function handleUpdate(row) {
  reset();
  reset()
  getPeakValleyConfiguration(row.id).then((response) => {
    form.value = response.data;
    form.value.beginEndDate = [response.data.beginDate, response.data.endDate];
    open.value = true;
    title.value = "编辑尖峰平谷时段配置";
  });
    form.value = response.data
    form.value.beginEndDate = [response.data.beginDate, response.data.endDate]
    open.value = true
    title.value = "编辑尖峰平谷时段配置"
  })
}
// 模型配置管理-尖峰平谷配置-新增/编辑-保存
function submitForm() {
  proxy.$refs["formRef"].validate((valid) => {
    if (valid) {
      form.value.beginDate = form.value.beginEndDate[0];
      form.value.endDate = form.value.beginEndDate[1];
      delete form.value.beginEndDate;
      form.value.beginDate = form.value.beginEndDate[0]
      form.value.endDate = form.value.beginEndDate[1]
      delete form.value.beginEndDate
      if (form.value.id != undefined) {
        updatePeakValleyConfiguration(form.value).then((response) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addPeakValleyConfiguration(form.value).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  });
  })
}
// 模型配置管理-尖峰平谷配置-新增/编辑-取消
function cancel() {
  open.value = false;
  proxy.$refs.formRef.resetFields();
  reset();
  open.value = false
  proxy.$refs.formRef.resetFields()
  reset()
}
// 模型配置管理-尖峰平谷配置-新增/编辑-表单重置
function reset() {
@@ -278,88 +341,80 @@
    beginDate: null,
    endDate: null,
    remark: null,
  };
  }
}
// 模型配置管理-尖峰平谷配置-删除
function handleDelete(row) {
  proxy.$modal
    .confirm(
      '是否确认删除生效日期为"' +
      row.beginDate +
      "到" +
      row.endDate +
      '"的数据项?'
    )
    .confirm('是否确认删除生效日期为"' + row.beginDate + "到" + row.endDate + '"的数据项?')
    .then(function () {
      return delPeakValleyConfiguration(row.id);
      return delPeakValleyConfiguration(row.id)
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
      getList()
      proxy.$modal.msgSuccess("删除成功")
    })
    .catch(() => { });
    .catch(() => {})
}
// 模型配置管理-尖峰平谷配置-时段电价配置-新增
function handleExpandChange(row) {
  formChild.value.parentId = row.id;
  formChild.value.beginEndDate = [row.beginDate, row.endDate];
  formChild.value.beginDate = row.beginDate;
  formChild.value.endDate = row.endDate;
  formChild.value.parentId = row.id
  formChild.value.beginEndDate = [row.beginDate, row.endDate]
  formChild.value.beginDate = row.beginDate
  formChild.value.endDate = row.endDate
  listPeakValleyConfigurationChild(
    proxy.addDateRange({
      parentId: row.id,
    })
  ).then((res) => {
    loadingChild.value = false;
    loadingChild.value = false
    formChild.value.data =
      res.rows.length > 0
        ? res.rows
        : [
          {
            parentId: row.id,
            type: null,
            startTime: null,
            stopTime: null,
            effecticityPrice: 0.0,
          },
        ];
  });
  openChild.value = true;
  titleChild.value = "尖峰平谷时段电价配置";
            {
              parentId: row.id,
              type: null,
              startTime: null,
              stopTime: null,
              effecticityPrice: 0.0,
            },
          ]
  })
  openChild.value = true
  titleChild.value = "尖峰平谷时段电价配置"
}
function handleAddChildChild() {
  console.log(formChild.value);
  console.log(formChild.value)
  formChild.value.data.push({
    parentId: formChild.value.parentId,
    type: null,
    startTime: null,
    stopTime: null,
    effecticityPrice: 0.0,
  });
  openChild.value = true;
  titleChild.value = "尖峰平谷时段电价配置";
  })
  openChild.value = true
  titleChild.value = "尖峰平谷时段电价配置"
}
function handleDeleteChildChild(item, index) {
  formChild.value.data.splice(index, 1);
  formChild.value.data.splice(index, 1)
}
// 模型配置管理-尖峰平谷配置-时段电价配置-新增/编辑-保存
function submitFormChild() {
  proxy.$refs["formChildRef"].validate((valid) => {
    if (valid) {
      updatePeakValleyConfigurationChild(formChild.value.data).then(
        (response) => {
          proxy.$modal.msgSuccess("修改成功");
          openChild.value = false;
          getList();
        }
      );
      updatePeakValleyConfigurationChild(formChild.value.data).then((response) => {
        proxy.$modal.msgSuccess("修改成功")
        openChild.value = false
        getList()
      })
    }
  });
  })
}
// 模型配置管理-尖峰平谷配置-新增/编辑-取消
function cancelChild() {
  openChild.value = false;
  proxy.$refs.formChildRef.resetFields();
  openChild.value = false
  proxy.$refs.formChildRef.resetFields()
}
</script>
<style scoped lang="scss">