Newer
Older
KaiFengPC / src / views / preassess / examineManage / index.vue
@鲁yixuan 鲁yixuan on 14 Aug 8 KB updata
<template>
  <div class="examineManage">
    <div class="top">
      <el-form ref="ruleForm" :model="form">
        <el-row :gutter="20">
          <el-col :span="5">
            <el-form-item label="使用状态:" prop="status">
              <el-select v-model="form.status" placeholder="请选择使用状态" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option label="启用" value="1" />
                <el-option label="停用" value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="生效时间:" prop="time">
              <el-date-picker
                v-model="form.time"
                type="daterange"
                range-separator="~"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="13">
            <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>
      <el-row class="mb8">
        <el-button class="mr10" type="primary" plain icon="Plus" @click="openDialog('add')">新增</el-button>
      </el-row>
    </div>
    <el-table :data="tableData" v-loading="loading" :max-height="600">
      <el-table-column type="index" width="55" label="序号" />
      <el-table-column label="记录名称" prop="recordName" show-overflow-tooltip width="200">
        <template #default="{ row }">
          <span style="color: #409eef">{{ row.recordName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工程类型" prop="engineeringType" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ engineeringTypeText(row.engineeringType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="考核类型" prop="assessType" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ assessTypeText(row.assessType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="停用时间" prop="dwonTime" show-overflow-tooltip />
      <el-table-column label="修改人" prop="updateNickName" show-overflow-tooltip />
      <el-table-column label="修改日期" prop="updateTime" show-overflow-tooltip width="160" />
      <el-table-column label="使用状态" prop="status" show-overflow-tooltip>
        <template #default="{ row }">
          <el-tag :type="statusMap.get(row.status).type" v-if="row.status">{{ statusMap.get(row.status).text }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" show-overflow-tooltip width="200">
        <template #default="{ row }">
          <el-button type="primary" link @click="copy(row)">复制</el-button>
          <el-button type="primary" link @click="operateHandle(row, 'view')">查看</el-button>
          <el-button type="primary" link @click="operateHandle(row, 'edit')">修改</el-button>
          <el-button type="danger" link @click="del(row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />
    <!-- 新增考核指标 -->
    <el-dialog
      v-model="visible"
      :title="`${opts.text}考核指标`"
      :close-on-click-modal="false"
      width="30%"
      :before-close="close"
      class="dialog"
    >
      <operate v-if="visible" ref="operateRef" @close="close" />
      <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="visibleCheck" title="查看考核指标" :close-on-click-modal="false" width="1500px">
      <ControlCheck v-if="visibleCheck" :checkObj="checkObj"></ControlCheck>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog v-model="visibleEdit" title="修改考核指标" :close-on-click-modal="false" width="1500px">
      <EditCheck v-if="visibleEdit" :editObj="editObj"></EditCheck>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue';
import operate from './operate.vue';
import ControlCheck from './control/index.vue';
import EditCheck from './mark/index.vue';
import { getAssessTargetConfigPage, assessTargetConfigCopy, assessTargetConfigDel } from '@/api/preassess/examineManage.js';
import { optTextMap, statusMap } from '@/utils/map';
import { usePagination } from '@/hooks';
const { proxy } = getCurrentInstance();

const emit = defineEmits(['toggle']);
const visibleCheck = ref(false);
const checkObj = ref({});
const visibleEdit = ref(false);
const editObj = ref({});

const { sponge_engineering_type } = proxy.useDict('sponge_engineering_type');
const engineeringTypeText = itemType => {
  const item = sponge_engineering_type.value.find(it => it.value === itemType);
  return item?.label || '';
};
const { assess_type } = proxy.useDict('assess_type');
const assessTypeText = itemType => {
  const item = assess_type.value.find(it => it.value === itemType);
  return item?.label || '';
};

const form = reactive({
  status: '',
  time: [],
});

const params = computed(() => {
  const args = JSON.parse(JSON.stringify(form));
  const { time } = args;
  delete args.time;
  return {
    ...args,
    openStartTime: time[0] || '',
    openEndTime: time[1] || '',
  };
});

const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(getAssessTargetConfigPage, params);
const opts = reactive({
  type: '',
  text: '',
});
const visible = ref(false);

const search = () => {
  pageNum.value = 1;
  getTableList();
};

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

const openDialog = type => {
  visible.value = true;
  opts.type = type;
  opts.text = optTextMap.get(type);
};
const close = type => {
  visible.value = false;
  opts.type = '';
  opts.text = '';
  if (type === 'add') search();
};

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

const operateHandle = (data, type) => {
  if (data.assessType === 'control') {
    checkObj.value = {
      controlId: data.id,
      type: type,
      status: data.status,
      engineeringType: data.engineeringType,
    };
    visibleCheck.value = true;
    // router.push(
    //   `/preassess/examine/control/${data.id}?type=${type}&status=${data.status}&name=${data.recordName}&engineeringType=${data.engineeringType}`
    // );
  } else if (data.assessType === 'score') {
    editObj.value = {
      markId: data.id,
      type: type,
      status: data.status,
      engineeringType: data.engineeringType,
    };
    visibleEdit.value = true;
    // router.push(
    //   `/preassess/examine/mark/${data.id}?type=${type}&status=${data.status}&name=${data.recordName}&engineeringType=${data.engineeringType}`
    // );
  }
};

const copy = row => {
  proxy.$modal
    .confirm('是否确认复制?')
    .then(async () => {
      const formData = new FormData();
      formData.append('assessTargetId', row.id);
      const res = await assessTargetConfigCopy(formData);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getTableList();
    })
    .catch(() => {});
};

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

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

<style lang="scss" scoped>
.examineManage {
  padding: 20px;
  height: 90vh;
  overflow-y: hidden;
  .top {
    margin-bottom: 15px;
  }
}
</style>