Newer
Older
KaiFengPC / src / views / project / processControl / approval / index.vue
@zhangdeliang zhangdeliang 24 days ago 14 KB update
<template>
  <!-- 项目立项 -->
  <div class="publicContainer approval">
    <div class="top">
      <el-form ref="ruleForm" :model="form" v-show="showSearch">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="项目名称:" prop="projectName" class="formItem110">
              <el-input v-model="form.projectName" placeholder="请输入项目名称" style="width: 100%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目运作模式:" prop="projectOperationPattern" class="formItem110">
              <el-select v-model="form.projectOperationPattern" placeholder="请选择项目运作模式" style="width: 100%">
                <el-option label="全部" value=""></el-option>
                <el-option v-for="dict in project_operation_pattern" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="建设单位:" prop="chargeDepartment">
              <el-input v-model="form.chargeDepartment" placeholder="请输入建设单位" style="width: 100%"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="责任人:" prop="chargeUser" class="formItem110">
              <el-input v-model="form.chargeUser" placeholder="请输入责任人" style="width: 100%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="建设状态:" prop="buildStatus" class="formItem110">
              <el-select v-model="form.buildStatus" placeholder="请选择建设状态" style="width: 100%">
                <el-option label="全部" value=""></el-option>
                <el-option v-for="dict in build_status" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目类型:" prop="projectTypeId">
              <el-select v-model="form.projectTypeId" placeholder="请选择项目类型" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option v-for="dict in projectTypes" :key="dict.id" :label="dict.projectTypeName" :value="dict.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="Search" @click="search"> 搜索</el-button>
              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <el-row class="row">
      <el-button type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增项目立项</el-button>
      <!-- <el-button type="primary" plain icon="Edit" @click="editSchedule">修改进度</el-button> -->
      <right-toolbar v-model:showSearch="showSearch" @queryTable="resetQuery"></right-toolbar>
    </el-row>
    <div class="table" ref="table_box">
      <el-table :data="tableData" v-loading="loading" stripe max-height="580" ref="multipleTableRef">
        <!-- <el-table-column type="selection" width="55" /> -->
        <el-table-column label="项目编码" prop="projectNo" show-overflow-tooltip />
        <el-table-column label="项目类型" prop="projectTypeId" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectTypes.find(it => it.id === row.projectTypeId)?.projectTypeName || '' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="项目名称" prop="projectName" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ row.projectName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="项目估算(万元)" prop="valuation" show-overflow-tooltip />
        <el-table-column label="项目运作模式" prop="projectOperationPattern" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ findText('project_operation_pattern', row.projectOperationPattern) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="建设单位" prop="chargeDepartment" show-overflow-tooltip />
        <el-table-column label="责任人" prop="chargeUser" show-overflow-tooltip />
        <el-table-column label="联系方式" prop="phone" show-overflow-tooltip />
        <el-table-column label="建设状态" prop="buildStatus" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ findText('build_status', row.buildStatus) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="可研批复文件" show-overflow-tooltip>
          <template #default="{ row }">
            <el-button type="primary" link @click="viewFile(row)">查看</el-button>
          </template>
        </el-table-column>
        <el-table-column label="操作" show-overflow-tooltip width="240">
          <template #default="{ row }">
            <el-button icon="View" type="primary" link @click="openDialog(row, 'view')">详情</el-button>
            <el-button type="warning" icon="Edit" link @click="openDialog(row, 'edit')">修改</el-button>
            <el-button type="danger" icon="Delete" link @click="del(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination class="pagination" :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />
    </div>
    <el-dialog
      v-model="visible"
      :title="`${opts.text}项目立项`"
      :close-on-click-modal="false"
      width="70%"
      :before-close="close"
      class="dialog"
    >
      <operate ref="operateRef" :cur-row="curRow" v-if="visible" @close="close" :opts="opts" />
      <template #footer v-if="opts.type !== 'view'">
        <div class="dialog-footer">
          <el-button type="primary" @click="submit">确 定</el-button>
          <el-button @click="close">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog v-model="visible1" title="修改建设进度" :close-on-click-modal="false" width="40%" :before-close="dialogClose" class="dialog">
      <el-form ref="dialogRuleFormRef" :model="dialogForm" :rules="dialogRules" v-if="visible1">
        <el-form-item label="建设状态:" prop="buildStatus">
          <el-select v-model="dialogForm.buildStatus" placeholder="请选择建设状态" style="width: 100%">
            <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="projectProgress">
          <div style="display: flex; width: 100%">
            <el-slider v-model="dialogForm.projectProgress" style="flex: 1" />
            <span style="margin-left: 10px">{{ dialogForm.projectProgress + '%' }}</span>
          </div>
        </el-form-item>
        <el-form-item label="完成项目总投资(含主体工程)(万元):" prop="accomplishTotalInvest">
          <el-input v-model="dialogForm.accomplishTotalInvest" placeholder="请输入完成项目总投资" />
        </el-form-item>
        <el-form-item label="完成海绵相关投资(不含主体工程)(万元):" prop="accomplishSpongeInvest">
          <el-input v-model="dialogForm.accomplishSpongeInvest" placeholder="请输入完成海绵相关投资" />
        </el-form-item>
        <el-form-item label="建设过程中照片:" prop="underWay">
          <ImageFileUpload
            listType="picture-card"
            :limit="1"
            :saveFileArr="constractionFlieList"
            refType="projectInfoNew"
            refField="constraction"
            :fileType="['png', 'jpg', 'jpeg']"
          />
        </el-form-item>
        <el-form-item label="建设完成后照片:" prop="complete">
          <ImageFileUpload
            listType="picture-card"
            :limit="1"
            :saveFileArr="postConstractionFlieList"
            refType="projectInfoNew"
            refField="postConstraction"
            :fileType="['png', 'jpg', 'jpeg']"
          />
        </el-form-item>
      </el-form>
      <template #footer v-if="opts.type !== 'view'">
        <div class="dialog-footer">
          <el-button type="primary" @click="dialogSubmit">确 定</el-button>
          <el-button @click="dialogClose">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog v-model="visible2" title="查看位置" :close-on-click-modal="false" width="60%" class="dialog">
      <div class="mapBox" v-if="visible2">
        <MapBox
          ref="mapBoxRef"
          :isShowTool="false"
          :isShowSearch="false"
          :previousPoint="previousPoint"
          :previousPointName="previousPointName"
        ></MapBox>
      </div>
    </el-dialog>
    <el-dialog v-model="visible3" title="查看文件" :close-on-click-modal="false" width="60%" class="dialog">
      <div class="fileSaveRequestList">
        <div class="file-item" v-for="item in fileList">
          <div>{{ item.name }}</div>
          <el-button type="warning" @click="handlePreview(item)" style="margin-left: 20px">预览</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, watch, onMounted, shallowRef } from 'vue';
import { usePagination, useAdaption, useDicts } from '@/hooks';
import operate from './operate.vue';
import { required } from '@/utils/validate-helper';
import { optTextMap } from '@/utils/map';
import { getProjectApprovalPage, projectApprovalDel } from '@/api/project/projectApproval';
import { projectInfoNewDetail, getFileLIst, updateProjectBuildStatus, projectTypeList } from '@/api/project/projectInformationNew';
import MapBox from '@/components/Map';
import { inheritAttr } from '@/utils/v3';
const { proxy } = getCurrentInstance();
const { project_operation_pattern, build_status, findText } = useDicts(proxy);
const { maxHeight, onResize } = useAdaption(proxy, 'table_box');
const showSearch = ref(true);
const visible = ref(false);
const opts = reactive({
  type: '',
  text: '',
});
const curRow = shallowRef({});
const visible1 = ref(false);
const form = reactive({
  projectName: '',
  projectOperationPattern: '',
  chargeDepartment: '',
  chargeUser: '',
  buildStatus: '',
  projectTypeId: '',
});

const dialogForm = reactive({
  projectNo: '',
  buildStatus: '',
  projectProgress: 0,
  accomplishTotalInvest: '',
  accomplishSpongeInvest: '',
  underWay: '',
  complete: '',
  sysFileSaveRequestList: [],
});

const constractionFlieList = ref([]);
const postConstractionFlieList = ref([]);

const dialogRules = reactive({
  buildStatus: required('建设状态'),
  projectProgress: required('建设进度'),
  accomplishTotalInvest: required('完成项目总投资'),
  accomplishSpongeInvest: required('完成海绵相关投资'),
  underWay: required('建设过程中照片'),
  complete: required('建设完成后照片'),
});

const params = computed(() => {
  return JSON.parse(JSON.stringify(form));
});

const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(getProjectApprovalPage, params);

const projectTypes = ref([]);

const visible2 = ref(false);
const checkedList = shallowRef([]);

const visible3 = ref(false);
const fileList = ref([]);
const previousPoint = ref('');
const previousPointName = ref('');

const viewFile = row => {
  console.log(row);
  fileList.value = row.fileSaveRequestList;
  visible3.value = true;
};

const handlePreview = file => {
  if (opts.type === 'view') return;
  window.open(file.url);
};

const getProjectTypeList = async () => {
  const res = await projectTypeList({ status: '0' });
  if (res?.code !== 200) return;
  projectTypes.value = res?.data || [];
};

const openDialog = (data, type) => {
  visible.value = true;
  opts.type = type;
  opts.text = optTextMap.get(type);
  curRow.value = data;
  console.log('rowrowrowrow', data);
  previousPoint.value = data.projectLocation;
  previousPointName.value = data.projectName;
  console.log('previousPoint.value', previousPoint.value, previousPointName.value);
};

const close = () => {
  visible.value = false;
  opts.type = '';
  opts.text = '';
  search();
};

const search = () => {
  pageNum.value = 1;
  getTableList();
};
const resetQuery = () => {
  proxy.$refs.ruleForm.resetFields();
  search();
};

const submit = () => {
  proxy.$refs.operateRef.submit();
};

const dialogClose = () => {
  visible1.value = false;
  checkedList.value = [];
};

const dialogSubmit = () => {
  proxy.$refs.dialogRuleFormRef.validate(async (valid, fields) => {
    if (valid) {
      console.log('submit!', dialogForm);
      const res = await updateProjectBuildStatus({
        projectNo: checkedList.value[0].projectNo,
        ...dialogForm,
        sysFileSaveRequestList: [].concat(constractionFlieList.value, postConstractionFlieList.value),
      });
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getTableList();
      dialogClose();
    } else {
      console.log('error submit!', fields);
    }
  });
};

const del = row => {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await projectApprovalDel(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getTableList();
    })
    .catch(() => {});
};

watch(showSearch, onResize);

watch(
  constractionFlieList,
  val => {
    if (val?.[0]?.url) {
      dialogForm.underWay = val[0].url;
    } else {
      dialogForm.underWay = '';
    }
  },
  { deep: true }
);

watch(
  postConstractionFlieList,
  val => {
    if (val?.[0]?.url) {
      dialogForm.complete = val[0].url;
    } else {
      dialogForm.complete = '';
    }
  },
  { deep: true }
);

onMounted(() => {
  getTableList();
  getProjectTypeList();
});
</script>

<style lang="scss" scoped>
.approval {
  .table {
    margin-top: 10px;
  }
}

.img {
  position: relative;
  width: 178px;
  height: 178px;
  img {
    width: 100%;
    height: 100%;
  }
  .mask {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    .icon {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      color: #fff;
    }
  }
  &:hover {
    .mask {
      display: block;
    }
  }
}

.fileSaveRequestList {
  margin-bottom: 30px;
  .file-item {
    white-space: nowrap;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    color: #c6c6c6;
    &:last-of-type {
      margin-bottom: 0;
    }
  }
}
</style>