Newer
Older
Nanping_sponge_GCGL / src / views / project / processControl / completionAcceptance / index.vue
@liyingjing liyingjing on 25 Oct 2023 12 KB 海绵工程管理
<template>
  <div class="completionAcceptance">
    <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">
              <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="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 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="constructUnit">
              <el-select
                v-model="form.constructUnit"
                placeholder="请选择施工单位"
                style="width: 100%"
              >
                <el-option label="全部" value="" />
                <el-option
                  v-for="dict in projectCompanyList"
                  :key="dict.id"
                  :label="dict.unitName"
                  :value="dict.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设计单位:" prop="designUnit">
              <el-select
                v-model="form.designUnit"
                placeholder="请选择设计单位"
                style="width: 100%"
              >
                <el-option label="全部" value="" />
                <el-option
                  v-for="dict in projectCompanyList"
                  :key="dict.id"
                  :label="dict.unitName"
                  :value="dict.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="流程步骤:" prop="status">
              <el-select
                v-model="form.status"
                placeholder="请选择流程步骤"
                style="width: 100%"
              >
                <el-option label="全部" value="" />
                <el-option label="开始" value="start" />
                <el-option label="验收审查" value="acceptanceReview" />
                <el-option label="驳回" value="submit" />
                <el-option label="结束" value="end" />
              </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
      >
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="resetQuery"
        class="rightToolbar"
      ></right-toolbar>
    </el-row>
    <el-tabs :model-value="status" class="demo-tabs" @tab-click="handleClick">
      <el-tab-pane label="我的" name="0"></el-tab-pane>
      <el-tab-pane label="待办列表" name="1"></el-tab-pane>
      <el-tab-pane label="已办列表" name="2"></el-tab-pane>
    </el-tabs>
    <div class="table" ref="table_box">
      <el-table
        :data="tableData"
        v-loading="loading"
        stripe
        :max-height="maxHeight"
        ref="multipleTableRef"
      >
        <!-- <el-table-column type="selection" align="center" width="55" /> -->
        <el-table-column label="项目编码" prop="projectNo" show-overflow-tooltip />
        <el-table-column label="项目类型" align="center" 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="申请时间" align="center" prop="applyTime" show-overflow-tooltip />
        <el-table-column label="联系人" align="center" prop="chargeUser" show-overflow-tooltip />
        <el-table-column label="联系方式" align="center" prop="phone" show-overflow-tooltip />
        <el-table-column label="建设单位" align="center" prop="chargeDepartment" show-overflow-tooltip />
        <el-table-column label="设计单位" align="center" prop="designUnit" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectCompanyList.find(it => it.id === row.designUnit)?.unitName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="施工单位" align="center" prop="constructUnit" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectCompanyList.find(it => it.id === row.constructUnit)?.unitName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="监理单位" align="center" prop="supervisorUnit" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectCompanyList.find(it => it.id === row.supervisorUnit)?.unitName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="验收状态" align="center" prop="status" show-overflow-tooltip>
          <template #default="{ row }">
            <el-tag v-if="row.fromStatus" class="ml-2" type="danger">驳回</el-tag>
            <el-tag v-else class="ml-2" type="success">{{ statusMap.get(row.status) }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" show-overflow-tooltip :width="curWidth">
          <template #default="{ row }">
            <el-button type="primary" link @click="openDialog(row, 'view')">查看</el-button>
            <el-button type="primary" link @click="openDialog(row, 'audit')" v-show="status === '1' && !row.fromStatus">审核</el-button>
            <el-button
              type="primary"
              link
              @click="openDialog(row, 'edit')"
              v-show="status === '0' || (status === '1' && row.fromStatus)"
              :disabled="(row.status !== 'start' && !row.fromStatus) || userInfo.name !== row.createBy"
            >编辑</el-button>
            <el-button
              type="danger"
              link
              @click="del(row)"
              v-show="status === '0'"
              :disabled="row.status !== 'start'"
            >删除</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"
        :opts="opts"
        :types="projectTypes"
        :company-list="projectCompanyList"
        @close="close"
        v-if="visible"
      />
      <template #footer v-if="opts.type !== 'view'">
        <div class="dialog-footer">
          <el-button @click="close">取 消</el-button>
          <el-button type="primary" @click="save" v-if="opts.type !== 'audit'">保 存</el-button>
          <el-button type="primary" @click="submit" v-if="opts.type !== 'audit'">提 交</el-button>
          <el-button type="primary" @click="handleAudit('false')" v-if="opts.type === 'audit'">驳 回</el-button>
          <el-button type="primary" @click="handleAudit('true')" v-if="opts.type === 'audit'">通 过</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, watch, onMounted, shallowRef } from 'vue'
import { useAdaption } from '@/hooks'
import operate from './operate.vue'
import { optTextMap } from '@/utils/map'
import { statusMap } from './map'
import {
  projectTypeList,
  getProjectCompanyList
} from '@/api/projectInformationNew'
import {
  getProjectCompletionAcceptanceMyPage,
  getProjectCompletionAcceptancePage,
  projectCompletionAcceptanceeDel
} from '@/api/completionAcceptance'
import useUserStore from '@/store/modules/user'
const userInfo = useUserStore()
const { proxy } = getCurrentInstance();
// const { build_status, sponge_land_type, project_content_type, 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 form = reactive({
  projectName: '',
  projectTypeId: '',
  chargeDepartment: '',
  constructUnit: '',
  designUnit: '',
  status: '',
  pageNum: 1,
  pageSize: 10,
  queryScope: ''
})

const status = ref('0')
const curWidth = computed(() => {
  if(status.value === '0') return 170
  return 120
})

const projectTypes = ref([])
const projectCompanyList = ref([])

const tableData = ref([])
const total = ref(0)
const loading = ref(false)

const getTableList = async () => {
  loading.value = true
  if(status.value === '0') {
    const res = await getProjectCompletionAcceptanceMyPage(form)
    loading.value = false
    if(res?.code === 200){
      tableData.value = res?.data || []
      total.value = res?.total || 0
    }
  } else {
    if(status.value === '1'){
      form.queryScope = 'todo'
    } else {
      form.queryScope = 'done'
    }
    const res = await getProjectCompletionAcceptancePage(form)
    loading.value = false
    if(res?.code === 200){
      tableData.value = res?.data || []
      total.value = res?.total || 0
    }
  }
}

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

const getProjectCompanyLists =async () => {
  const res = await getProjectCompanyList()
  if(res?.code !== 200) return
  projectCompanyList.value = res?.data || []
}

const openDialog = (data, type) => {
  visible.value = true
  opts.type = type
  opts.text = optTextMap.get(type)
  curRow.value = data
}

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

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

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

const handleClick = (tab) => {
  status.value = tab.paneName
  search()
}

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

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

const handleAudit = (result) => {
  proxy.$refs.operateRef.handleAudit(result)
}

watch(showSearch, onResize)

onMounted(() => {
  getProjectTypeList()
  getProjectCompanyLists()
  getTableList()

})
</script>

<style lang="scss" scoped>
.completionAcceptance {
  padding: 20px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  .top,
  .row {
    flex-shrink: 0;
    margin-bottom: 10px;
  }
  .table {
    flex: 1;
    :deep(.pagination) {
      margin-top: 0;
      margin-right: 10px;
      .el-pagination {
        right: 20px;
      }
    }
  }
  :deep(.formItem110) {
    .el-form-item__label {
      width: 110px;
      word-break: keep-all;
      white-space: nowrap;
    }
  }

  :deep(.formItem140) {
    .el-form-item__label {
      width: 140px;
      word-break: keep-all;
      white-space: nowrap;
    }
  }

  :deep(.formItem300) {
    .el-form-item__label {
      width: 300px;
      word-break: keep-all;
      white-space: nowrap;
    }
  }
}

:deep(.el-dialog__body) {
  background-color: #eef1fb;
}

.rightToolbar {
  transform: translateY(40px);
}
</style>