Newer
Older
KaiFengPC / src / views / longoPeration / Patrolmanagement / Inspectionplan.vue
@鲁yixuan 鲁yixuan on 19 Jul 12 KB 1
<template>
  <!-- 巡查计划管理 -->
  <div class="publicContainer">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="计划名称:" prop="planName">
        <el-input v-model="queryParams.planName" placeholder="请输入计划名称" clearable style="width: 180px" />
      </el-form-item>

      <el-form-item label="项目名称:" prop="eventType">
        <el-select clearable v-model="queryParams.eventType" style="width: 180px" placeholder="请选择项目名称">
          <el-option v-for="item in Xmtype" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>

      <el-form-item label="计划状态:" prop="status">
        <el-select clearable v-model="queryParams.status" style="width: 180px" placeholder="请选择计划状态">
          <el-option v-for="item in WaterDate" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>

      <el-form-item label="计划日期" prop="publishTime">
        <el-date-picker
          style="width: 380px"
          format="YYYY-MM-DD"
          v-model="AllData.publishTime"
          type="daterange"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
        />
      </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-form-item>
    </el-form>

    <!-- 按钮区域 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="Plus" @click="handleAdd">新增</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>

    <!-- 表格 -->
    <el-table :data="dataList" v-loading="loading" stripe :max-height="580">
      <el-table-column type="index" width="55" label="序号" />
      <el-table-column label="巡查计划名称" prop="planName" />
      <el-table-column label="项目名称" prop="project" />
      <el-table-column label="巡查人员" prop="planUserIds" />
      <el-table-column label="巡查类型" prop="patrolType">
        <template #default="scope">
          <dict-tag :options="patrol_type" :value="String(scope.row.patrolType)" />
        </template>
      </el-table-column>
      <el-table-column label="巡查公里数(km)" prop="num" />
      <el-table-column label="计划开始时间" prop="startTime" />
      <el-table-column label="计划结束时间" prop="endDate" />
      <el-table-column label="任务频率" prop="patrolFrequencyType" />
      <el-table-column label="创建时间" prop="create" />
      <el-table-column label="巡查要求" prop="remark" />
      <el-table-column label="巡查计划状态" prop="status" />
      <el-table-column label="操作" width="280">
        <template #default="scope">
          <el-button link icon="View" type="success" v-if="scope.row.status == '未激活'" @click="activation(scope.row, 'view')">
            激活
          </el-button>
          <el-button link icon="View" type="primary" @click="handleDetail(scope.row, 'view')">查看</el-button>
          <el-button link type="warning" icon="Edit" v-if="scope.row.status == '未激活'" @click="handleUpdate(scope.row, 'view')">
            修改
          </el-button>
          <el-button link type="danger" icon="Delete" v-if="scope.row.status == '未激活'" @click="handleDelete(scope.row, 'view')">
            删除
          </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="getList"
    />
    <!-- 新增弹窗 -->
    <el-dialog :title="title" v-model="open" width="800px" append-to-body :close-on-click-modal="false">
      <el-form ref="roleRef" :model="form" :rules="rules" label-width="110px" :disabled="multiple">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="巡查计划名称:" prop="planName">
              <el-input v-model="form.planName" placeholder="请输入巡查计划名称" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="项目名称:" prop="projectList">
              <el-select
                clearable
                v-model="form.projectList"
                style="width: 100%"
                placeholder="请选择项目名称"
                value-key="projectNo"
                multiple
                label="projectName"
              >
                <el-option v-for="proj in projectTList" :key="proj.projectNo" :label="proj.projectName" :value="proj" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="巡查计划类型:" prop="patrolType">
              <el-select clearable v-model="form.patrolType" style="width: 100%" placeholder="请选择项目名称">
                <el-option v-for="item in patrol_type" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="巡查频率:" prop="patrolFrequencyType">
              <el-select
                v-model="form.patrolFrequencyType"
                placeholder="请选择巡查频率"
                clearable
                style="width: 100%"
                @change="changeStation"
              >
                <el-option v-for="dict in Xcfrequency" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="巡查频率(周):" prop="fileTag1" v-if="form.fileTag == 'zhou'">
              <el-select v-model="form.fileTag1" placeholder="请选择巡查频率(周)" clearable style="width: 100%">
                <el-option v-for="dict in document_tag" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col> -->
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="巡查人员:" prop="patrolUserList">
              <el-select
                v-model="form.patrolUserList"
                placeholder="请选择巡查人员"
                clearable
                style="width: 100%"
                value-key="userId"
                label="nickName"
                multiple
              >
                <el-option v-for="item in userList" :key="String(item.userId)" :label="item.nickName" :value="item" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划日期" prop="reportTime1">
              <el-date-picker
                style="width: 380px"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                v-model="form.reportTime1"
                type="daterange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script setup name="Inspectionplan">
import {
  patrolPlanpage,
  FloodPreventionMaterialedit,
  patrolPlanadd,
  FloodPreventionMaterialdelete,
} from '@/api/longoPeration/Inspectionplana';
import { listUser } from '@/api/system/user';
import { getProjectInfoList } from '@/api/preassess/targetManage';
const { proxy } = getCurrentInstance();
const { patrol_type } = proxy.useDict('patrol_type'); //  巡查类型的字典
console.log(patrol_type);
const open = ref(false);
const multiple = ref(false);
const showSearch = ref(true);
const projectTList = ref([]);
const Xcfrequency = ref([
  { value: 'for_day', label: '天' },
  { value: 'for_week', label: '周' },
]);
const WaterDate = ref([
  { value: '0', label: '已完成' },
  { value: '1', label: '已激活' },
  { value: '2', label: '未激活' },
]);
const userList = ref([]);
const loading = ref(true);
const total = ref(1);
const title = ref('');
const dataList = ref([]);
const AllData = reactive({
  id: '',
  caseid: '',
  caseidone: '',
  publishTime: [proxy.moment(new Date()).subtract(3, 'days').format('YYYY-MM-DD'), proxy.moment().format('YYYY-MM-DD')],
  form: {},
  formDate: {},
  caseFormDate: { id: '' },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    planName: '',
    status: '',
    startTime: '',
    endDate: '',
  },
  rules: {
    planName: [{ required: true, message: '请输入巡查计划名称', trigger: 'blur' }],
    projectList: [{ required: true, message: '请选择项目名称', trigger: 'blur' }],
    patrolType: [{ required: true, message: '请选择项目名称', trigger: 'blur' }],
    // fileTag: [{ required: true, message: '请选择项目名称', trigger: 'blur' }],
    patrolUserList: [{ required: true, message: '请选择巡查人员', trigger: 'blur' }],
    reportTime1: [{ required: true, message: '请选择计划日期', trigger: 'blur' }],
    eventDescription: [{ required: true, message: '请输入', trigger: 'blur' }],
  },
});
const { queryParams, form, rules } = toRefs(AllData);

//搜索
function handleQuery() {
  if (AllData.publishTime) {
    queryParams.value.startTime = AllData.publishTime[0];
    queryParams.value.endDate = AllData.publishTime[1];
  } else {
    queryParams.value.startTime = '';
    queryParams.value.endDate = '';
  }
  getList();
}
//重置
function resetQuery() {
  AllData.publishTime = [proxy.moment(new Date()).subtract(3, 'days').format('YYYY-MM-DD '), proxy.moment().format('YYYY-MM-DD 23:59:59')];
  proxy.resetForm('queryRef');
  handleQuery();
}
// 新增
function handleAdd() {
  title.value = '新增巡查计划';
  open.value = true;
  form.value = {};
  multiple.value = false;
  form.value.patrolFrequencyType = Xcfrequency.value[0].value;
}
// 新增中取消事件
function cancel() {
  open.value = false;
  proxy.resetForm('roleRef');
}

// 巡查频率下拉框点击事件
function changeStation(value) {
  // console.log(value, 'value');
}

//查看详情操作
function handleDetail(row) {
  open.value = true;
  title.value = '查看巡查计划';
  multiple.value = true;
  form.value = row;
}
// 修改按钮操作
function handleUpdate(row) {
  open.value = true;
  title.value = '修改巡查计划';
  multiple.value = false;
  form.value = { ...row };
}
// 项目接口
async function projectTypeListM() {
  let { data } = await getProjectInfoList();
  projectTList.value = data;
}
//查询维修人员列表
function getUserList() {
  listUser().then(res => {
    userList.value = res.data;
  });
}

/** 查询列表 */
const getList = async () => {
  loading.value = true;
  if (AllData.publishTime) {
    queryParams.value.startTime = AllData.publishTime[0];
    queryParams.value.endDate = AllData.publishTime[1];
  }

  let res = await patrolPlanpage(queryParams.value);
  dataList.value = res.data;
  console.log(dataList.value, 'dataList.value');
  total.value = res.total;
  loading.value = false;
};

/** 提交按钮 */
function submitForm() {
  proxy.$refs['roleRef'].validate(valid => {
    if (valid) {
      // 处理时间传参
      form.value.startDate = form.value.reportTime1[0];
      form.value.endDate = form.value.reportTime1[1];
      // 处理项目传参
      form.value.projectList = form.value.projectList.map(obj => {
        return { projectNo: obj.projectNo, projectName: obj.projectName };
      });
      // 处理人员传参
      form.value.patrolUserList = form.value.patrolUserList.map(obj => {
        return { userId: String(obj.userId) };
      });
      form.value.basicInfoId = '1686274734091489284';
      // console.log(form.value, 'form.value');
      patrolPlanadd(form.value).then(response => {
        proxy.$modal.msgSuccess('新增成功');
        open.value = false;
        getList();
      });
    }
  });
}

onMounted(() => {
  getList();
  projectTypeListM();
  getUserList();
});
</script>
<style scoped lang="scss">
.dituclass {
  width: 100%;
  height: 300px;
  // background: red;
  margin-bottom: 10px;
  border: 1px solid #004565;
}
</style>