Newer
Older
KaiFengPC / src / views / project / projectJinDu / monthReport.vue
@zhangdeliang zhangdeliang on 21 Aug 15 KB update
<template>
  <!-- 项目综合管理 项目进度管理  月度上报-->
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true">
      <el-form-item label="月份选择:" prop="reportMonth">
        <el-date-picker type="month" v-model="queryParams.reportMonth" value-format="YYYY-MM" placeholder="请选择日期"> </el-date-picker>
      </el-form-item>
      <el-form-item label="项目名称:" prop="projectNo">
        <el-select v-model="queryParams.projectNo" filterable clearable placeholder="请选择">
          <el-option v-for="dict in projectList" :key="dict.projectNo" :label="dict.projectName" :value="dict.projectNo" />
        </el-select>
      </el-form-item>
      <el-form-item label="建设状态:" prop="buildStatus">
        <el-select v-model="queryParams.buildStatus" clearable placeholder="请选择">
          <el-option v-for="dict in build_status" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </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-button type="warning" icon="Upload" @click="importData">导入</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格 -->
    <el-table v-loading="tableLoading" :data="tableData" max-height="650">
      <el-table-column label="月份" prop="reportMonth" />
      <el-table-column label="项目名称" prop="projectName" />
      <el-table-column label="项目类别" prop="projectTypeCode">
        <template #default="scope">
          <span>
            {{ !!scope.row.projectTypeCode ? projectType.filter(item => item.value == scope.row.projectTypeCode)[0].label : '--' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="责任单位" prop="chargeDepartment" />
      <el-table-column label="建设状态" prop="buildStatusName" />
      <el-table-column label="建设进度(%)" prop="projectProgress" />
      <el-table-column label="累计完成项目总投资(含主体工程)(万元)" prop="accomplishTotalInvest" />
      <el-table-column label="累计完成海绵投资(不含主体工程)(万元)" prop="accomplishSpongeInvest" />
      <el-table-column label="本月完成投资(万元)" prop="monthAccomplishTotalInvest" />
      <el-table-column label="本月完成海绵投资(万元)" prop="monthAccomplishSpongeInvest" />
      <el-table-column label="项目照片" prop="publishTime">
        <template #default="scope">
          <div v-if="scope.row.sysFileSaveRequestList && scope.row.sysFileSaveRequestList.length > 0">
            <el-image
              :src="item.url"
              v-for="(item, index) in scope.row.sysFileSaveRequestList"
              :key="index"
              style="width: 100px; height: 100px"
            ></el-image>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="备注" prop="remark" />
      <el-table-column label="操作" width="240" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="warning" icon="Edit" @click="handleEdit(scope.row)">修改</el-button>
          <el-button link type="View" icon="Comment" @click="handleNotice(scope.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="导入月报进度" v-model="dialogShowDR" width="500px" append-to-body>
      <el-form ref="formRefDR" :model="formExport" :rules="rulesFormDR" label-width="110px" class="publicForm">
        <el-form-item label="月份:" prop="reportMonth">
          <el-date-picker type="month" v-model="formExport.reportMonth" value-format="YYYY-MM" placeholder="请选择日期"> </el-date-picker>
        </el-form-item>
        <el-form-item label="月度报表:" prop="file" style="width: 100%">
          <el-upload
            ref="uploadRef"
            :limit="1"
            accept=".xlsx, .xls"
            action="/"
            :on-change="uploadFile"
            :on-progress="handleFileUploadProgress"
            :on-success="handleFileSuccess"
            :on-remove="handleRemove"
            :auto-upload="false"
            drag
          >
            <el-icon class="el-icon--upload"><upload-filled /></el-icon>
            <div class="el-upload__text"><em>将文件拖到此处,或点击上传</em></div>
          </el-upload>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="info" @click="dialogShowDR = false">取 消</el-button>
          <el-button type="primary" @click="submitFormExport">确 定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 修改弹窗 -->
    <el-dialog title="修改进度" v-model="dialogShow" width="900px" append-to-body>
      <el-form ref="formRef" :model="formData" :rules="rulesForm" label-width="170px" class="publicForm flex50">
        <el-form-item label="项目名称:" prop="projectName">
          <el-input type="text" v-model="formData.projectName" placeholder="请输入" clearable disabled />
        </el-form-item>
        <el-form-item label="责任单位:" prop="chargeDepartment">
          <el-input type="text" v-model="formData.chargeDepartment" placeholder="请输入" clearable disabled />
        </el-form-item>
        <el-form-item label="累计完成总投资(万元):" prop="accomplishTotalInvest">
          <el-input type="number" :min="0" v-model="formData.accomplishTotalInvest" placeholder="请输入" clearable />
        </el-form-item>
        <el-form-item label="累计完成海绵投资(万元):" prop="accomplishSpongeInvest">
          <el-input type="number" :min="0" v-model="formData.accomplishSpongeInvest" placeholder="请输入" clearable />
        </el-form-item>
        <el-form-item label="本月完成投资(万元):" prop="monthAccomplishTotalInvest">
          <el-input type="number" :min="0" v-model="formData.monthAccomplishTotalInvest" placeholder="请输入" clearable />
        </el-form-item>
        <el-form-item label="本月完成海绵投资(万元):" prop="monthAccomplishSpongeInvest">
          <el-input type="number" :min="0" v-model="formData.monthAccomplishSpongeInvest" placeholder="请输入" clearable />
        </el-form-item>
        <el-form-item label="建设进度(%):" prop="projectProgress">
          <el-input type="number" :min="0" v-model="formData.projectProgress" placeholder="请输入" clearable />
        </el-form-item>
        <el-form-item label="建设状态:" prop="buildStatus">
          <el-select v-model="formData.buildStatus" clearable placeholder="请选择">
            <el-option v-for="dict in build_status" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="项目照片:" prop="sysFileSaveRequestList" style="width: 100%">
          <ImageFileUpload
            :limit="5"
            :listType="'picture-card'"
            :saveFileArr="formData.sysFileSaveRequestList"
            :refField="'pjdPhotos'"
            :refType="'projectMonthReportImages'"
          ></ImageFileUpload>
        </el-form-item>
        <el-form-item label="备注:" prop="remark" style="width: 100%">
          <el-input type="textarea" v-model="formData.remark" placeholder="请输入" clearable />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="info" @click="dialogShow = false">取 消</el-button>
          <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 通知提醒弹窗 -->
    <el-dialog title="通知提醒" v-model="dialogShowTZ" width="600px" append-to-body>
      <el-form ref="formRefTZ" :model="formDataTZ" :rules="rulesFormTZ" label-width="120px" class="publicForm">
        <el-form-item label="责任人:" prop="userName">
          <!-- <el-input type="text" v-model="formDataTZ.userName" placeholder="请输入责任人" clearable /> -->
          <el-select clearable v-model="formDataTZ.userName" style="width: 250px" placeholder="请输入责任人" @change="changeObj">
            <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId" />
          </el-select>
        </el-form-item>
        <el-form-item label="责任人电话:" prop="userPhone">
          <el-input type="text" v-model="formDataTZ.userPhone" :disabled="true" placeholder="请输入责任人电话" clearable maxlength="11" />
        </el-form-item>
        <el-form-item label="通知单:" prop="fileList">
          <ImageFileUpload
            :limit="1"
            :saveFileArr="formDataTZ.fileList"
            :listType="'text'"
            :fileType="['pdf']"
            :refField="'coverPhotos'"
            :refType="'rtu_site_info'"
          ></ImageFileUpload>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="info" @click="dialogShowTZ = false">取 消</el-button>
          <el-button type="primary" @click="submitFormTZ">确 定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="月度上报">
import { getProjectInfoNewList } from '@/api/document/projectTransfer';
import { pageUser } from '@/api/system/user';
import { MonthReportImport, MonthReportPage, MonthReportEdit } from '@/api/project/monthJD.js';
import { useDicts } from '@/hooks';
import { getToken } from '@/utils/auth';
import ImageFileUpload from '@/components/ImageFileUpload/index.vue'; //图片文件上传
import { projectTypeList } from '@/api/project/projectInformationNew';

const { proxy } = getCurrentInstance();
const { build_status } = useDicts(proxy);
const tableData = ref([]);
const tableLoading = ref(false);
const total = ref(0);
const dialogShow = ref(false);
const dialogShowTZ = ref(false);
const dialogShowDR = ref(false);
const projectList = ref([]);
const userList = ref([]);
const allData = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    reportMonth: null,
    projectNo: '',
    buildStatus: '',
  },
  formData: {},
  rulesForm: {
    title: [{ required: true, message: '请输入', trigger: 'blur' }],
  },
  formDataTZ: {
    userName: '',
    fileList: [],
    userPhone: '',
  },
  rulesFormTZ: {
    userName: [{ required: true, message: '请输入', trigger: 'blur' }],
    userPhone: [
      {
        pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
        message: '请输入正确的手机号码',
        trigger: 'blur',
        required: true,
      },
    ],
    // fileList: [{ required: true, message: '请输入', trigger: 'blur', type: 'array' }],
  },
  formExport: {
    file: '',
    reportMonth: proxy.moment(new Date()).format('YYYY-MM'),
  },
  rulesFormDR: {
    reportMonth: [{ required: true, message: '请选择', trigger: 'change' }],
    // file: [{ required: true, message: '请选择', trigger: 'change' }],
  },
});
const { queryParams, formData, rulesForm, formDataTZ, rulesFormTZ, formExport, rulesFormDR } = toRefs(allData);
const formExportData = ref({});
const projectType = ref([]);

/*** 导入参数 */
const upload = reactive({
  // 是否显示弹出层(用户导入)
  open: false,
  // 弹出层标题(用户导入)
  title: '',
  // 是否禁用上传
  isUploading: false,
  // 是否更新已经存在的用户数据
  updateSupport: 0,
  // 设置上传的请求头部
  headers: { Authorization: 'Bearer ' + getToken() },
});

/** 获取查询数据列表 */
function getDataList() {
  tableLoading.value = true;
  MonthReportPage(queryParams.value).then(response => {
    tableData.value = response.data;
    total.value = response.total;
    tableLoading.value = false;
  });
}
/** 查询用户列表 */
function getList() {
  pageUser().then(res => {
    userList.value = res.data || [];
    userList.value.map(item => {
      item.userId = String(item.userId);
    });
  });
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getDataList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
// 修改确定
function submitForm() {
  proxy.$refs['formRef'].validate(valid => {
    if (valid) {
      MonthReportEdit(formData.value).then(res => {
        if (res.code == 200) {
          proxy.$modal.msgSuccess('修改成功');
          getDataList();
          dialogShow.value = false;
        } else {
          proxy.$modal.msgError('修改失败请重试');
        }
      });
    }
  });
}
/** 上报当月进度操作 */
function handleEdit(row) {
  proxy.resetForm('formRefDR'); //清空表单
  formData.value = { ...row };
  dialogShow.value = true;
}
/** 上报当月进度提交 */
function submitFormExport() {
  proxy.$refs['formRefDR'].validate(valid => {
    if (valid) {
      if (typeof formExportData.value.get == 'function') {
        if (formExportData.value.get('file') == null) {
          proxy.$modal.msgError('请上传导入的文件');
          return false;
        }
      } else {
        proxy.$modal.msgError('请上传导入的文件');
        return false;
      }
      MonthReportImport(formExportData.value).then(res => {
        if (res.code == 200) {
          proxy.$modal.msgSuccess('导入成功');
          getDataList();
          dialogShowDR.value = false;
        } else {
          proxy.$modal.msgError('导入失败请重试,请先删除表格中的图片,需单独上传');
        }
      });
    }
  });
}
/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
  upload.isUploading = true;
};
/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
  upload.isUploading = false;
  proxy.$refs['uploadRef'].handleRemove(file);
};
function uploadFile(file) {
  formExport.value.file = '';
  formExportData.value = new FormData();
  formExportData.value.append('file', file.raw);
  formExportData.value.append('reportMonth', formExport.value.reportMonth);
}
function handleRemove(uploadFile, uploadFiles) {
  formExportData.value.delete('file');
}

/** 通知提醒操作 */
function handleNotice(row) {
  proxy.resetForm('formRefTZ'); //清空表单
  dialogShowTZ.value = true;
  getList();
}
/** 通知提醒提交 */
function submitFormTZ() {
  proxy.$refs['formRefTZ'].validate(valid => {
    if (valid) {
    }
  });
}

// 导入
function importData() {
  dialogShowDR.value = true;
  proxy.resetForm('formRefDR'); //清空表单
}

// 获取项目列表
const getProjectList = async () => {
  const res = await getProjectInfoNewList();
  if (res?.code == 200) {
    projectList.value = res.data || [];
  }
};
// 获取项目类别
const projectTypeGet = async () => {
  let { data } = await projectTypeList();
  data.map(item => {
    projectType.value.push({
      value: item.projectTypeCode,
      label: item.projectTypeName,
    });
  });
};
function changeObj(val) {
  console.log(val, '123');
  userList.value.forEach(element => {
    if (val == element.userId) {
      formDataTZ.value.userPhone = element.phonenumber;
    }
  });
}
onMounted(() => {
  projectTypeGet();
  getProjectList();
  getDataList();
});
</script>