<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="渐近速度系数" prop="dE">
        <el-input
          v-model="queryParams.dE"
          placeholder="请输入渐近速度系数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="相对密度系数" prop="dFg">
        <el-input
          v-model="queryParams.dFg"
          placeholder="请输入相对密度系数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流动温度系数" prop="dFt">
        <el-input
          v-model="queryParams.dFt"
          placeholder="请输入流动温度系数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="气体动力黏度" prop="dDViscosity">
        <el-input
          v-model="queryParams.dDViscosity"
          placeholder="请输入气体动力黏度"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="可膨胀性系数" prop="dDExpCoefficient">
        <el-input
          v-model="queryParams.dDExpCoefficient"
          placeholder="请输入可膨胀性系数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="孔板锐利度系数" prop="dBk">
        <el-input
          v-model="queryParams.dBk"
          placeholder="请输入孔板锐利度系数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="管道雷诺数" prop="dRoughNessPipe">
        <el-input
          v-model="queryParams.dRoughNessPipe"
          placeholder="请输入管道雷诺数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流出系数" prop="dCd">
        <el-input
          v-model="queryParams.dCd"
          placeholder="请输入流出系数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="修正流出系数" prop="dCdCorrect">
        <el-input
          v-model="queryParams.dCdCorrect"
          placeholder="请输入修正流出系数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="管道气体流速" prop="dVelocityFlow">
        <el-input
          v-model="queryParams.dVelocityFlow"
          placeholder="请输入管道气体流速"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="压力损失" prop="dPressLost">
        <el-input
          v-model="queryParams.dPressLost"
          placeholder="请输入压力损失"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="直径比" prop="dBeta">
        <el-input
          v-model="queryParams.dBeta"
          placeholder="请输入直径比"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="等熵指数" prop="dKappa">
        <el-input
          v-model="queryParams.dKappa"
          placeholder="请输入等熵指数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="超压缩因子" prop="dFpv">
        <el-input
          v-model="queryParams.dFpv"
          placeholder="请输入超压缩因子"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工况体积流量" prop="dVFlowfSs">
        <el-input
          v-model="queryParams.dVFlowfSs"
          placeholder="请输入工况体积流量"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="标准状态体积流量" prop="dVFlowbSs">
        <el-input
          v-model="queryParams.dVFlowbSs"
          placeholder="请输入标准状态体积流量"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="标准状态质量流量" prop="dMFlowbSs">
        <el-input
          v-model="queryParams.dMFlowbSs"
          placeholder="请输入标准状态质量流量"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="标准状态能量流量" prop="dEFlowbSs">
        <el-input
          v-model="queryParams.dEFlowbSs"
          placeholder="请输入标准状态能量流量"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="管道雷诺数" prop="dRnPipe">
        <el-input
          v-model="queryParams.dRnPipe"
          placeholder="请输入管道雷诺数"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段1" prop="dRyl1">
        <el-input
          v-model="queryParams.dRyl1"
          placeholder="请输入预留字段1"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段2" prop="dRyl2">
        <el-input
          v-model="queryParams.dRyl2"
          placeholder="请输入预留字段2"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段3" prop="dRyl3">
        <el-input
          v-model="queryParams.dRyl3"
          placeholder="请输入预留字段3"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段4" prop="dRyl4">
        <el-input
          v-model="queryParams.dRyl4"
          placeholder="请输入预留字段4"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段5" prop="dRyl5">
        <el-input
          v-model="queryParams.dRyl5"
          placeholder="请输入预留字段5"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段6" prop="dRyl6">
        <el-input
          v-model="queryParams.dRyl6"
          placeholder="请输入预留字段6"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段7" prop="dRyl7">
        <el-input
          v-model="queryParams.dRyl7"
          placeholder="请输入预留字段7"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段8" prop="dRyl8">
        <el-input
          v-model="queryParams.dRyl8"
          placeholder="请输入预留字段8"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段9" prop="dRyl9">
        <el-input
          v-model="queryParams.dRyl9"
          placeholder="请输入预留字段9"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段10" prop="dRyl10">
        <el-input
          v-model="queryParams.dRyl10"
          placeholder="请输入预留字段10"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['plc:processresult:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['plc:processresult:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['plc:processresult:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['plc:processresult:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="processresultList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="渐近速度系数" align="center" prop="dE" />
      <el-table-column label="相对密度系数" align="center" prop="dFg" />
      <el-table-column label="流动温度系数" align="center" prop="dFt" />
      <el-table-column label="气体动力黏度" align="center" prop="dDViscosity" />
      <el-table-column label="可膨胀性系数" align="center" prop="dDExpCoefficient" />
      <el-table-column label="孔板锐利度系数" align="center" prop="dBk" />
      <el-table-column label="管道雷诺数" align="center" prop="dRoughNessPipe" />
      <el-table-column label="流出系数" align="center" prop="dCd" />
      <el-table-column label="修正流出系数" align="center" prop="dCdCorrect" />
      <el-table-column label="管道气体流速" align="center" prop="dVelocityFlow" />
      <el-table-column label="压力损失" align="center" prop="dPressLost" />
      <el-table-column label="直径比" align="center" prop="dBeta" />
      <el-table-column label="等熵指数" align="center" prop="dKappa" />
      <el-table-column label="超压缩因子" align="center" prop="dFpv" />
      <el-table-column label="工况体积流量" align="center" prop="dVFlowfSs" />
      <el-table-column label="标准状态体积流量" align="center" prop="dVFlowbSs" />
      <el-table-column label="标准状态质量流量" align="center" prop="dMFlowbSs" />
      <el-table-column label="标准状态能量流量" align="center" prop="dEFlowbSs" />
      <el-table-column label="管道雷诺数" align="center" prop="dRnPipe" />
      <el-table-column label="预留字段1" align="center" prop="dRyl1" />
      <el-table-column label="预留字段2" align="center" prop="dRyl2" />
      <el-table-column label="预留字段3" align="center" prop="dRyl3" />
      <el-table-column label="预留字段4" align="center" prop="dRyl4" />
      <el-table-column label="预留字段5" align="center" prop="dRyl5" />
      <el-table-column label="预留字段6" align="center" prop="dRyl6" />
      <el-table-column label="预留字段7" align="center" prop="dRyl7" />
      <el-table-column label="预留字段8" align="center" prop="dRyl8" />
      <el-table-column label="预留字段9" align="center" prop="dRyl9" />
      <el-table-column label="预留字段10" align="center" prop="dRyl10" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['plc:processresult:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['plc:processresult:remove']">删除</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="getList"
    />

    <!-- 添加或修改流量处理结果对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="processresultRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="渐近速度系数" prop="dE">
          <el-input v-model="form.dE" placeholder="请输入渐近速度系数" />
        </el-form-item>
        <el-form-item label="相对密度系数" prop="dFg">
          <el-input v-model="form.dFg" placeholder="请输入相对密度系数" />
        </el-form-item>
        <el-form-item label="流动温度系数" prop="dFt">
          <el-input v-model="form.dFt" placeholder="请输入流动温度系数" />
        </el-form-item>
        <el-form-item label="气体动力黏度" prop="dDViscosity">
          <el-input v-model="form.dDViscosity" placeholder="请输入气体动力黏度" />
        </el-form-item>
        <el-form-item label="可膨胀性系数" prop="dDExpCoefficient">
          <el-input v-model="form.dDExpCoefficient" placeholder="请输入可膨胀性系数" />
        </el-form-item>
        <el-form-item label="孔板锐利度系数" prop="dBk">
          <el-input v-model="form.dBk" placeholder="请输入孔板锐利度系数" />
        </el-form-item>
        <el-form-item label="管道雷诺数" prop="dRoughNessPipe">
          <el-input v-model="form.dRoughNessPipe" placeholder="请输入管道雷诺数" />
        </el-form-item>
        <el-form-item label="流出系数" prop="dCd">
          <el-input v-model="form.dCd" placeholder="请输入流出系数" />
        </el-form-item>
        <el-form-item label="修正流出系数" prop="dCdCorrect">
          <el-input v-model="form.dCdCorrect" placeholder="请输入修正流出系数" />
        </el-form-item>
        <el-form-item label="管道气体流速" prop="dVelocityFlow">
          <el-input v-model="form.dVelocityFlow" placeholder="请输入管道气体流速" />
        </el-form-item>
        <el-form-item label="压力损失" prop="dPressLost">
          <el-input v-model="form.dPressLost" placeholder="请输入压力损失" />
        </el-form-item>
        <el-form-item label="直径比" prop="dBeta">
          <el-input v-model="form.dBeta" placeholder="请输入直径比" />
        </el-form-item>
        <el-form-item label="等熵指数" prop="dKappa">
          <el-input v-model="form.dKappa" placeholder="请输入等熵指数" />
        </el-form-item>
        <el-form-item label="超压缩因子" prop="dFpv">
          <el-input v-model="form.dFpv" placeholder="请输入超压缩因子" />
        </el-form-item>
        <el-form-item label="工况体积流量" prop="dVFlowfSs">
          <el-input v-model="form.dVFlowfSs" placeholder="请输入工况体积流量" />
        </el-form-item>
        <el-form-item label="标准状态体积流量" prop="dVFlowbSs">
          <el-input v-model="form.dVFlowbSs" placeholder="请输入标准状态体积流量" />
        </el-form-item>
        <el-form-item label="标准状态质量流量" prop="dMFlowbSs">
          <el-input v-model="form.dMFlowbSs" placeholder="请输入标准状态质量流量" />
        </el-form-item>
        <el-form-item label="标准状态能量流量" prop="dEFlowbSs">
          <el-input v-model="form.dEFlowbSs" placeholder="请输入标准状态能量流量" />
        </el-form-item>
        <el-form-item label="管道雷诺数" prop="dRnPipe">
          <el-input v-model="form.dRnPipe" placeholder="请输入管道雷诺数" />
        </el-form-item>
        <el-form-item label="预留字段1" prop="dRyl1">
          <el-input v-model="form.dRyl1" placeholder="请输入预留字段1" />
        </el-form-item>
        <el-form-item label="预留字段2" prop="dRyl2">
          <el-input v-model="form.dRyl2" placeholder="请输入预留字段2" />
        </el-form-item>
        <el-form-item label="预留字段3" prop="dRyl3">
          <el-input v-model="form.dRyl3" placeholder="请输入预留字段3" />
        </el-form-item>
        <el-form-item label="预留字段4" prop="dRyl4">
          <el-input v-model="form.dRyl4" placeholder="请输入预留字段4" />
        </el-form-item>
        <el-form-item label="预留字段5" prop="dRyl5">
          <el-input v-model="form.dRyl5" placeholder="请输入预留字段5" />
        </el-form-item>
        <el-form-item label="预留字段6" prop="dRyl6">
          <el-input v-model="form.dRyl6" placeholder="请输入预留字段6" />
        </el-form-item>
        <el-form-item label="预留字段7" prop="dRyl7">
          <el-input v-model="form.dRyl7" placeholder="请输入预留字段7" />
        </el-form-item>
        <el-form-item label="预留字段8" prop="dRyl8">
          <el-input v-model="form.dRyl8" placeholder="请输入预留字段8" />
        </el-form-item>
        <el-form-item label="预留字段9" prop="dRyl9">
          <el-input v-model="form.dRyl9" placeholder="请输入预留字段9" />
        </el-form-item>
        <el-form-item label="预留字段10" prop="dRyl10">
          <el-input v-model="form.dRyl10" placeholder="请输入预留字段10" />
        </el-form-item>
        <el-form-item label="主表id" prop="mainId">
          <el-input v-model="form.mainId" placeholder="请输入主表id" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Processresult">
import { listProcessresult, getProcessresult, delProcessresult, addProcessresult, updateProcessresult } from "@/api/production/plc/processresult/processresult"

const { proxy } = getCurrentInstance()

const processresultList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    dE: null,
    dFg: null,
    dFt: null,
    dDViscosity: null,
    dDExpCoefficient: null,
    dBk: null,
    dRoughNessPipe: null,
    dCd: null,
    dCdCorrect: null,
    dVelocityFlow: null,
    dPressLost: null,
    dBeta: null,
    dKappa: null,
    dFpv: null,
    dVFlowfSs: null,
    dVFlowbSs: null,
    dMFlowbSs: null,
    dEFlowbSs: null,
    dRnPipe: null,
    dRyl1: null,
    dRyl2: null,
    dRyl3: null,
    dRyl4: null,
    dRyl5: null,
    dRyl6: null,
    dRyl7: null,
    dRyl8: null,
    dRyl9: null,
    dRyl10: null,
  },
  rules: {
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询流量处理结果列表 */
function getList() {
  loading.value = true
  listProcessresult(queryParams.value).then(response => {
    processresultList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
    remark: null,
    dE: null,
    dFg: null,
    dFt: null,
    dDViscosity: null,
    dDExpCoefficient: null,
    dBk: null,
    dRoughNessPipe: null,
    dCd: null,
    dCdCorrect: null,
    dVelocityFlow: null,
    dPressLost: null,
    dBeta: null,
    dKappa: null,
    dFpv: null,
    dVFlowfSs: null,
    dVFlowbSs: null,
    dMFlowbSs: null,
    dEFlowbSs: null,
    dRnPipe: null,
    dRyl1: null,
    dRyl2: null,
    dRyl3: null,
    dRyl4: null,
    dRyl5: null,
    dRyl6: null,
    dRyl7: null,
    dRyl8: null,
    dRyl9: null,
    dRyl10: null,
    mainId: null
  }
  proxy.resetForm("processresultRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加流量处理结果"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset()
  const _id = row.id || ids.value
  getProcessresult(_id).then(response => {
    form.value = response.data
    open.value = true
    title.value = "修改流量处理结果"
  })
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["processresultRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updateProcessresult(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addProcessresult(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value
  proxy.$modal.confirm('是否确认删除流量处理结果编号为"' + _ids + '"的数据项？').then(function() {
    return delProcessresult(_ids)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => {})
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('plc/processresult/export', {
    ...queryParams.value
  }, `processresult_${new Date().getTime()}.xlsx`)
}

getList()
</script>
