Newer
Older
Nanping_sponge_JXKH / src / views / waterUtilizationRate / tableDalgo.vue
@liyingjing liyingjing on 25 Oct 2023 6 KB 海绵绩效考个
<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
              style="width: 300px"
              v-if="i.key == 'zssUseCount'"
              :placeholder="i.value"
              :min="0"
              :precision="2"
              :step="0.1"
              :max="FormList.zssTotalCount"
              @change="trsyAreaChange"
              v-model="FormList[i.key]"
            >
              <template #append> k㎡ </template>
            </el-input-number>

            <el-input-number
              style="width: 300px"
              v-else-if="i.key == 'zssTotalCount'"
              :placeholder="i.value"
              :min="0"
              :precision="2"
              :step="0.1"
              v-model="FormList[i.key]"
            >
              <template #append> k㎡ </template>
            </el-input-number>

            <el-upload
              v-else-if="i.key == 'attachFileList'"
              v-model:file-list="fileList1"
              class="upload-demo"
              action="/prod-api/system/upload"
              :headers="uploadHeader"
              multiple
              :on-preview="handlePreview"
              :before-remove="beforeRemove"
              style="width: 100vh"
            >
              <el-button type="primary">选择文件</el-button>
            </el-upload>
            <div
              v-else-if="i.key == 'standardFlag' && typeList.iSstandardFlag"
              :style="{ color: typeList.iSstandardFlag ? '#108ee9' : 'red' }"
            >
              {{ typeList.iSstandardFlag ? '达标' : '未达标' }}
            </div>

            <div v-else-if="i.key == 'allRealValue'">
              {{ typeList.allRealValue }}
            </div>
            <div v-else-if="i.key == 'zssTargetAreaCount'">
              {{ ((FormList.zssTotalCount * itemTarget) / 100 || 0).toFixed(2) }}
            </div>
            <div v-else-if="i.key == 'itemTarget'">
              {{ itemTarget || 0 }}
            </div>
            <div
              v-else-if="i.key == 'standardFlag' && !typeList.iSstandardFlag"
              :style="{ color: IsStandFlag1 >= 0 ? '#108ee9' : 'red' }"
            >
              <span v-show="false">{{ IsStandFlag1 ? (IsStandText = 1) : (IsStandText = 0) }}</span>
              {{ IsStandFlag1 >= 0 ? '达标' : '未达标' }}
            </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();
// 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(-1);
const IsStandText = 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) {
      const fileSaveRequestList = [];
      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 = typeList.data.zzsUseRate;
        if (typeList.iSstandardFlag || flay == 1) {
          ar[0].realScore = ar[0].itemScore;
        } else {
          ar[0].realScore = 0;
        }
      } else {
        ar.push({
           standardFlag: flay,
           realScore: IsStandFlag1.value > 0 ?(arr1.zssUseCount||0) : 0,
          });
      }
      typeList.data.itemDataTypePerformanceEvaluateItemList = ar;
      fileList1.value.forEach(element => {
        if (element.hasOwnProperty('response')) {
          element.response.data.refType = 'ZSSLYL';
          fileSaveRequestList.push(element.response.data);
        } else {
          fileSaveRequestList.push(element);
        }
      });

      FormList.value = {
        fileSaveRequestList,
        ...typeList.data,
        itemDataType: 'ZSSLYL',
      };
      projectInfoEdit(FormList.value).then(({ code }) => {
        if (code == 200) {
          emits('onModalClose');
        }
      });
    }
  });
}
function loadProjerctListData() {
  FormList.value = typeList.data;
  fileList1.value = typeList.fileList1;
  IsStandFlag1.value = typeList.data.zssUseCount * 1 - ((itemTarget.value * typeList.allRealValue) / 100 || 0);
  proxy.$refs.ruleForm.resetFields();
  console.log('FormList', FormList.value);
}
function resetFiled() {
  proxy.$refs.ruleForm.resetFields();
  fileList1.value = [];
}
function closed() {
  emits('onModalClose');
}
function trsyAreaChange(v) {
  console.log('v', v);
  FormList.value.zzsUseRate = (((v * 1) / FormList.value.zssTotalCount) * 100 || 0).toFixed(2);
  let st = FormList.value.zzsUseRate - itemTarget.value;
  if (st >= 0) IsStandFlag1.value = 1;
  else IsStandFlag1.value = 0;
}
onMounted(() => {
  loadProjerctListData();
});
</script>
<style lang="scss" scoped>
.water-analysis-page {
  padding: 20px;
}
</style>