Newer
Older
Nanping_sponge_JXKH / src / views / spongePerformance / permeableGroundArea / tableDalgo.vue
@liyingjing’ liyingjing’ on 17 Nov 5 KB 1
<template>
  <div class="water-analysis-page">
    <div class="top">
      <el-form
        label-width="auto"
        :rules="projectEstimateRules"
        inline
        ref="ruleForm"
        :model="FormList"
        :disabled="typeList.type == 1"
      >
        <div v-for="i in typeList.monitorDynamicTableTitleList" style="display: flex; flex-direction: column">
          <el-form-item :label="i.value + ':'" :prop="i.key" :disabled="typeList.type == 1 || typeList.type == 2">
            <el-input-number
              v-if="i.key == 'kstdmArea'"
              :placeholder="i.value"
              :min="0"
              :precision="2"
              :step="0.1"
              :max="typeList.allRealValue"
              @change="trsyAreaChange"
              v-model="FormList[i.key]"
              style="width: 300px"
            >
              <template #append> k㎡ </template>
            </el-input-number>
            <ImageFileUpload
            v-else-if="i.key == 'attachFileList'"
              v-model:saveFileArr="fileSaveRequestList"
              :listType="'text'"
              :refType="'KSSDMMJBL'"
            />
            <div v-else-if="i.key == 'allRealValue'">
              {{ typeList.allRealValue }}
            </div>
            <div v-else-if="i.key == 'kstdmTargetArea'">
              {{ (((itemTarget * typeList.allRealValue) / 100).toFixed(3) || 0) }}
            </div>
            <div v-else-if="i.key == 'itemTarget'">
              {{ itemTarget }}
            </div>
            <div v-else-if="i.key == 'standardFlag'">
              <el-tag v-if="typeList.data.standardFlag === ''" type="warning">未填报</el-tag>
              <el-tag v-else-if="typeList.data.standardFlag === '102'" type="warning">无法评价</el-tag>
              <el-tag v-else :type="typeList.data.standardFlag === '1' ? 'success' : 'error'">{{
                typeList.data.standardFlag === '1' ? '达标' : '未达标'
              }}</el-tag>
            </div>
            <div v-else>
              {{ FormList[i.key] }}
            </div>
          </el-form-item>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script setup>
import { onMounted, defineEmits, reactive, defineProps, defineExpose, computed } from 'vue';
import { projectInfoEdit } from '@/api/naturalWaterArea';
import { getToken } from '@/utils/auth';
import { projectEstimateRules } from '@/utils/rules';
import { projectEstimateForm } from '@/utils/form';
import { ElMessage, ElMessageBox } from 'element-plus';
const { proxy } = getCurrentInstance();
import ImageFileUpload from '@/components/ImageFileUpload'; //图片文件上传

// const { fund_source } = proxy.useDict('fund_source');
const uploadHeader = ref({
  Authorization: 'Bearer ' + getToken(),
});
const { typeList } = defineProps(['typeList']);
const emits = defineEmits();
defineExpose({ submit, closed, resetFiled });
const IsStandFlag1 = ref(0);
const IsStandText = ref('');
const fileSaveRequestList = ref([]);
let FormList = ref({ projectNo: '', fileSaveRequestList: [] });
const itemTarget = computed(() => {
  return typeList.data?.itemDataTypePerformanceEvaluateItemList[0]?.itemTarget;
});
const fileList1 = ref([]);
function handlePreview(file) {
  return ElMessageBox.confirm(`下载此文件: ${file.name}?`).then(
    () => window.open(file.url),
    () => false
  );
}
function beforeRemove(file) {
  return true;
}
function submit() {
  proxy.$refs.ruleForm.validate(valid => {
    if (valid) {
      let flay = null;
      if (IsStandFlag1.value > 0) flay = 1;
      else flay = 0;
      let ar = typeList.data.itemDataTypePerformanceEvaluateItemList;
      let arr1 = typeList.data;
      if (ar.length > 0) {
        ar[0].standardFlag = flay;
        ar[0].realValue = arr1.kstdmAreaRate;
        if (typeList.iSstandardFlag || flay == 1) {
          ar[0].realScore = ar[0].itemScore;
        } else {
          ar[0].realScore = 0;
        }
      } else {
        ar.push({
          standardFlag: flay,
          realValue: typeList.data.kstdmAreaRate,
          realScore: IsStandFlag1.value > 0 ? arr1.kstdmTargetArea || 0 : 0,
        });
      }
     
      typeList.data.itemDataTypePerformanceEvaluateItemList = ar;
      FormList.value = {
        fileSaveRequestList: fileSaveRequestList.value,
        ...typeList.data,
        itemDataType: 'KSSDMMJBL',
      };
      projectInfoEdit(FormList.value).then(({ code }) => {
        if (code == 200) {
          emits('onModalClose');
        }
      });
    }
  });
}
function loadProjerctListData() {
  FormList.value = typeList.data;
  fileSaveRequestList.value = typeList.fileList1;
  IsStandFlag1.value = typeList.data.kstdmArea * 1 - (((itemTarget.value * typeList.allRealValue) / 100).toFixed(3) || 0);
  proxy.$refs.ruleForm.resetFields();
}
function resetFiled() {
  proxy.$refs.ruleForm.resetFields();
  fileSaveRequestList.value = [];
}
function closed() {
  emits('onModalClose');
}
function trsyAreaChange(v) {
  let st = v * 1 - (((itemTarget.value * typeList.allRealValue) / 100 ).toFixed(3)|| 0);
  if (st >= 0) {
    IsStandFlag1.value = 1;
    typeList.data.standardFlag = '1';
  } else {
    IsStandFlag1.value = 0;
    typeList.data.standardFlag = '0';
  }
  FormList.value.kstdmAreaRate = ((v / typeList.allRealValue) * 100).toFixed(2) || 0;
}
onMounted(() => {
  loadProjerctListData();
});
</script>
<style lang="scss" scoped>
.water-analysis-page {
  padding: 20px;
}
</style>