Newer
Older
KaiFengPC / src / views / longoPeration / duChaLedger.vue
@鲁yixuan 鲁yixuan on 25 Jul 8 KB updata
<template>
  <!-- 长效运维子系统 督查巡查台账 -->
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="台账名称" prop="title">
        <el-input v-model="queryParams.title" placeholder="请输入" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="巡查类型" prop="typeId">
        <el-select v-model="queryParams.typeId" placeholder="请选择" clearable>
          <el-option v-for="item in xcLedger_type" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="年份" prop="year">
        <el-date-picker type="year" v-model="queryParams.year" value-format="YYYY" placeholder="请选择日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button type="success" 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" plain icon="Plus" @click="handleAdd" v-hasPermi="['floodSys:jing:add']">新增</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table v-loading="tableLoading" :data="tableData" max-height="650">
      <el-table-column label="日期" prop="date" />
      <el-table-column label="督查/巡查" prop="type" />
      <el-table-column label="项目名称" prop="name" />
      <el-table-column label="项目数量" prop="pnum" />
      <el-table-column label="巡查人数" prop="unum" />
      <el-table-column label="参加单位" prop="unit" />
      <el-table-column label="创建时间" prop="createTime" />
      <el-table-column label="备注" prop="remark" />
      <el-table-column label="操作" width="160" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="warning" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
          <el-button link type="danger" icon="Delete" @click="handleDelete(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="dialogTitle" v-model="dialogShow" width="600px" append-to-body>
      <el-form ref="formRef" :model="formData" :rules="rulesForm" label-width="90px" class="publicForm">
        <el-form-item label="巡查日期" prop="date">
          <el-date-picker type="date" v-model="formData.date" value-format="YYYY-MM-DD" placeholder="请选择日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="巡查类别" prop="typeId">
          <el-select v-model="formData.typeId" placeholder="请选择" clearable>
            <el-option v-for="item in xcLedger_type" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="项目名称" prop="degist">
          <el-input type="textarea" v-model="formData.degist" controls-position="right" />
        </el-form-item>
        <el-form-item label="项目数量" prop="degist">
          <el-input type="number" v-model="formData.degist" controls-position="right" />
        </el-form-item>
        <el-form-item label="巡查人数" prop="degist">
          <el-input type="number" v-model="formData.degist" controls-position="right" />
        </el-form-item>
        <el-form-item label="参加单位" prop="degist">
          <el-input type="textarea" v-model="formData.degist" controls-position="right" />
        </el-form-item>
        <el-form-item label="备注" prop="degist">
          <el-input type="textarea" v-model="formData.degist" controls-position="right" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="info" @click="cancelForm">取 消</el-button>
          <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="科普知识">
import { knowledgePage, knowledgeAdd, knowledgeDel, knowledgeDetail, knowledgeEdit } from '@/api/publicService/index';

const { proxy } = getCurrentInstance();
// const { xcLedger_type } = proxy.useDict('xcLedger_type'); //获取接口返回字典数据
const xcLedger_type = ref([
  { value: '1', label: '巡查' },
  { value: '2', label: '绩效考核' },
  { value: '4', label: '月巡查' },
  { value: '5', label: '整改巡查' },
  { value: '6', label: '督察' },
  { value: '7', label: '节日巡查' },
  { value: '8', label: '人大调研' },
]);
const tableData = ref([
  {
    date: '2023-02-23',
    type: '巡查',
    name: '道路雨水管渠及泵站进出水管渠非开挖修复、汴京路(公园路-工农路)、汴京路东郊沟雨水泵站新建项目、龙亭北路(龙亭西路—内环路)、五福路(五一路—中山路)、铁路北沿街(解放路—侯庄桥)',
    pnum: '6',
    unum: '6',
    unit: '市城管局、市海绵中心工作人员、中规院专家、市政设计院',
    createTime: '2023-02-23 10:23:10',
    remark: '',
  },
  {
    date: '2023-09-19',
    type: '整改巡查',
    name: '晋安路46号院、综合保税园区一期项目、南城墙(环城公园一期、三期、五期)',
    pnum: '3',
    unum: '2',
    unit: '市节水型(海绵)城市建设服务中心业务科室及中规院',
    createTime: '2023-09-20 10:23:10',
    remark: '示范区46号院项目现场基本完成、环城墙公园一三五期整改现场停工。',
  },
]);
const tableLoading = ref(true);
const total = ref(0);
const dialogShow = ref(false);
const dialogTitle = ref('');
const showSearch = ref(true);

const allData = reactive({
  formData: {
    content: '',
    degist: '',
    title: '',
    typeId: '',
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    title: undefined,
    typeId: undefined,
    year: proxy.moment().subtract('1', 'year').format('YYYY'),
  },
  rulesForm: {
    postName: [{ required: true, message: '请输入', trigger: 'blur' }],
    degist: [{ required: true, message: '请输入', trigger: 'blur' }],
    typeId: [{ required: true, message: '请选择', trigger: 'change' }],
  },
});
const { queryParams, formData, rulesForm } = toRefs(allData);

/** 获取查询数据列表 */
function getDataList() {
  tableLoading.value = true;
  knowledgePage(queryParams.value).then(response => {
    // tableData.value = response.data;
    total.value = response.total;
    tableLoading.value = false;
  });
}
/** 取消按钮 */
function cancelForm() {
  dialogShow.value = false;
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getDataList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
/** 新增按钮操作 */
function handleAdd() {
  proxy.resetForm('formRef'); //清空表单
  formData.value.content = ' ';
  dialogShow.value = true;
  dialogTitle.value = '添加科普知识';
}
/** 修改按钮操作 */
function handleUpdate(row) {
  const postId = row.id;
  knowledgeDetail(postId).then(response => {
    dialogShow.value = true;
    dialogTitle.value = '修改科普知识';
    nextTick(() => {
      formData.value = response.data;
    });
  });
}
/** 提交按钮 */
function submitForm() {
  proxy.$refs['formRef'].validate(valid => {
    if (valid) {
      if (dialogTitle.value == '修改科普知识') {
        knowledgeEdit(formData.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          dialogShow.value = false;
          getDataList();
        });
      } else {
        if (formData.value.id) delete formData.value.id;
        knowledgeAdd(formData.value).then(response => {
          proxy.$modal.msgSuccess('新增成功');
          dialogShow.value = false;
          getDataList();
        });
      }
    }
  });
}
/** 删除按钮操作 */
function handleDelete(row) {
  const postIds = row.id;
  proxy.$modal
    .confirm('是否确认删除该数据项?')
    .then(function () {
      return knowledgeDel(postIds);
    })
    .then(() => {
      getDataList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}

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