Parcourir la source

迭代八巡查人员:删除、部门传参功能、新建界面的通讯录功能;巡查任务:子任务界面及接口、删除功能

zhangyihao il y a 11 mois
Parent
commit
92f27a7328

+ 33 - 2
src/api/inspectionWork/inspector.ts

@@ -1,9 +1,16 @@
 import request from '@/utils/request';
-import {uploadEventCasualties} from "@/api/duty/eventing";
 // 查询部门列表
 export function deptList(params) {
   return request({
-    url: '/api/riskManagement/allAreas',
+    url: '/api/system/user/deptTree',
+    method: 'get',
+    params: params
+  });
+}
+// 查询通讯录列表
+export function phoneList(params) {
+  return request({
+    url: '/api/info_publish/addressbook/alldepts',
     method: 'get',
     params: params
   });
@@ -38,6 +45,14 @@ export function inspectorAdd(data) {
     data: data
   });
 }
+//巡查人员删除
+export function inspectorDelete(data) {
+  return request({
+    url: '/api/riskManagement/inspection/user/delete',
+    method: 'delete',
+    data: data
+  });
+}
 // 获取新建用户列表
 export function userList(params) {
   return request({
@@ -54,3 +69,19 @@ export function workList(params) {
     params: params
   });
 }
+// 删除巡查任务
+export function workDelete(data) {
+  return request({
+    url: '/api/riskManagement/inspection/task/delete',
+    method: 'delete',
+    data: data
+  });
+}
+// 查询用户详情
+export function workDetail(id) {
+  return request({
+    url: '/api/riskManagement/inspection/task/' + id,
+    method: 'get',
+    params: id
+  });
+}

+ 37 - 11
src/views/inspectionWork/inspector.vue

@@ -21,8 +21,8 @@
             <el-form ref="queryFormRef" :model="queryParams">
               <el-row :gutter="20">
                 <el-col :span="8">
-                  <el-form-item prop="username">
-                    <el-input v-model="queryParams.username" placeholder="请输入巡查人员" clearable />
+                  <el-form-item prop="nickName">
+                    <el-input v-model="queryParams.nickName" placeholder="请输入巡查人员" clearable />
                   </el-form-item>
                 </el-col>
                 <el-col :span="8">
@@ -41,12 +41,12 @@
             <el-button type="primary" plain icon="Top" @click="handleImport()"> 批量导入 </el-button>
           </el-col>
           <el-col :span="1.5">
-            <el-button type="danger" plain :disabled="multiple" icon="Delete" @click="handleDelete()"> 删除 </el-button>
+            <el-button type="danger" plain :disabled="multiple" icon="Delete" @click="handleDelete(selectedRow)"> 删除 </el-button>
           </el-col>
         </el-row>
         <el-table ref="multipleTable" v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
           <el-table-column type="selection" width="55" align="center" />
-          <el-table-column label="姓名" align="center" prop="username" />
+          <el-table-column label="姓名" align="center" prop="nickName" />
           <el-table-column label="联系方式" align="center" prop="phone" />
           <el-table-column label="粤政易组织" align="center" prop="yzy_organization" />
           <el-table-column label="责任区划" align="center" prop="division_responsibility" />
@@ -62,15 +62,16 @@
     </el-row>
   </div>
   <InspectorEdit v-if="inspectorEditState.show" :event-id="inspectorEditState.eventId" @close="handleCancel" />
-  <InspectorAdd v-if="inspectorAddState.show" :event-id="inspectorAddState.eventId" @close="handleCancel" />
+  <InspectorAdd v-if="inspectorAddState.show" @close="handleCancel" />
 </template>
 
 <script setup lang="ts">
 import { onMounted, reactive, ref, watch } from 'vue';
 import { useRouter } from 'vue-router';
-import { deptList, inspectorList } from '@/api/inspectionWork/inspector';
+import { deptList, inspectorList, inspectorDelete } from '@/api/inspectionWork/inspector';
 import InspectorEdit from './inspectorEdit.vue';
 import InspectorAdd from './inspectorAdd.vue';
+import { to } from 'await-to-js';
 const router = useRouter();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const loading = ref(true);
@@ -82,15 +83,21 @@ const total = ref(0);
 const deptOptions = ref([]);
 const deptTreeRef = ref(null);
 const tableData = ref([]);
-
+const selectedRow = ref<InspectorVO | null>(null);
 const initFormData = reactive({
-  username: '',
+  nickName: '',
   phone: '',
   yzy_organization: '',
   division_responsibility: '',
   id: ''
 });
-
+export interface InspectorVO {
+  phone: number;
+  nickName: string;
+  yzy_organization: string;
+  division_responsibility: string;
+  id: number;
+}
 const data = reactive({
   form: { ...initFormData },
   queryParams: {
@@ -118,7 +125,7 @@ const fetchUserData = async () => {
   const res = await inspectorList(queryParams.value); // 调用 inspectorList 接口
   tableData.value = res.data.map((item) => ({
     id: item.id,
-    username: item.user_name,
+    nickName: item.nick_name,
     phone: item.phonenumber,
     yzy_organization: item.yzy_account || '', // 如果 yzy_account 为空,则显示空字符串
     division_responsibility: item.area // 显示责任区划
@@ -148,7 +155,20 @@ const handleImport = () => {
 const handleAdd = async () => {
   inspectorAddState.show = true;
 };
-
+const handleDelete = async (row) => {
+  let id = [];
+  if (row) {
+    id = [row.id];
+  } else {
+    id = ids.value;
+  }
+  const [err] = await to(proxy?.$modal.confirm('是否确认删除选择的数据项?') as any);
+  if (!err) {
+    await inspectorDelete(id);
+    proxy.$modal.msgSuccess('删除成功');
+    fetchUserData();
+  }
+};
 const handleUpdate = (row) => {
   if (row) {
     inspectorEditState.eventId = row.id; // 假设eventId是id字段
@@ -159,6 +179,11 @@ const handleQuery = () => {
   queryParams.value.page = 1;
   fetchUserData();
 };
+/** 节点单击事件 */
+const handleNodeClick = (data: DeptVO) => {
+  queryParams.value.deptId = data.id;
+  handleQuery();
+};
 // 重置查询条件
 const resetQuery = () => {
   queryParams.value = { page: 1, pageSize: 10, nickName: '', deptId: '' };
@@ -166,6 +191,7 @@ const resetQuery = () => {
 };
 const handleSelectionChange = (selection) => {
   ids.value = selection.map((item) => item.id);
+  selectedRow.value = selection.length === 1 ? selection[0] : null;
   single.value = selection.length != 1;
   multiple.value = !selection.length;
 };

+ 20 - 5
src/views/inspectionWork/inspectorAdd.vue

@@ -7,7 +7,13 @@
       <div class="common-dialog-box">
         <el-form ref="form" :model="formData" :rules="rules" label-width="120px">
           <el-form-item label="姓名:" prop="nick_name">
-            <el-input v-model="formData.nick_name" style="width: 468px !important" />
+            <el-tree-select
+              v-model="formData.uuid"
+              :data="treeData"
+              :props="{ label: 'label', value: 'uuid', children: 'children' }"
+              :render-after-expand="false"
+              style="width: 468px"
+            />
           </el-form-item>
           <el-form-item label="粤政易组织:" prop="yzy_account">
             <el-input v-model="formData.yzy_account" style="width: 468px !important" />
@@ -28,9 +34,9 @@
   </div>
 </template>
 <script setup lang="ts">
-import { inspectorAdd } from '@/api/inspectionWork/inspector';
-import { ref, watch } from 'vue';
-import { ElMessage } from 'element-plus';
+import { inspectorAdd, phoneList } from '@/api/inspectionWork/inspector';
+import { ref } from 'vue';
+import { ElMessage, ElTreeSelect } from 'element-plus';
 const emits = defineEmits(['close']);
 const props = defineProps<{
   eventId: string | number;
@@ -39,8 +45,10 @@ const formData = ref({
   nick_name: '',
   phonenumber: '',
   yzy_account: '',
-  area: ''
+  area: '',
+  uuid: ''
 });
+const treeData = ref([]);
 const closeDialog = () => {
   emits('close');
 };
@@ -55,5 +63,12 @@ const submitForm = async () => {
     ElMessage.error(response.msg);
   }
 };
+const fetchPhoneList = async () => {
+  const response = await phoneList();
+  treeData.value = response.data;
+};
+onMounted(() => {
+  fetchPhoneList();
+});
 </script>
 <style scoped></style>

+ 166 - 0
src/views/inspectionWork/patrolSubTasks.vue

@@ -0,0 +1,166 @@
+<template>
+  <div class="app-container p-2">
+    <el-row :gutter="20">
+      <!-- 基础信息 -->
+      <el-col :lg="30" :xs="24" style="">
+        <el-form-item>
+          <div class="back-btn" @click="goBack">
+            <el-icon><Back /></el-icon>
+            返回上一级
+          </div>
+        </el-form-item>
+        <el-row :span="24" :gutter="10">
+          <el-col :span="20" label="任务名称">
+            <h2 key="business" style="font-weight: bolder">{{ detailData.business }}</h2>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="primary" @click="handleUpdate()"> 编辑 </el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="primary" @click="handleWork()"> 完成任务 </el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="danger" @click="handleDelete"> 删除预案 </el-button>
+          </el-col>
+        </el-row>
+        <div class="line" style="background: #e7e7e7; width: auto; height: 0.6px; position: relative"></div>
+        <h3>基础信息</h3>
+        <el-card style="margin-top: 10px" shadow="hover">
+          <el-descriptions title="">
+            <el-descriptions-item key="task_number" label="任务编号:">{{ detailData.task_number }}</el-descriptions-item>
+            <el-descriptions-item key="business" label="巡查业务:">{{ detailData.business }}</el-descriptions-item>
+            <el-descriptions-item key="create_by" label="创建人:">{{ detailData.create_by }}</el-descriptions-item>
+            <el-descriptions-item key="create_time" label="创建时间:">{{ detailData.create_time }}</el-descriptions-item>
+            <el-descriptions-item key="task_time" label="巡查时间范围:">{{ detailData.task_time }}</el-descriptions-item>
+            <el-descriptions-item key="cycle" label="巡查周期:">{{ detailData.cycle }}</el-descriptions-item>
+            <el-descriptions-item key="inspection_range" label="巡查范围:">{{ detailData.inspection_range }}</el-descriptions-item>
+            <el-descriptions-item key="task_status" label="任务状态:">{{ detailData.task_status }}</el-descriptions-item>
+          </el-descriptions>
+        </el-card>
+      </el-col>
+      <el-col :lg="30" :xs="24">
+        <h3>子任务记录</h3>
+        <el-card style="margin-top: 10px" shadow="hover">
+          <el-table ref="multipleTable" v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
+            <el-table-column label="巡查业务" align="center" prop="business" />
+            <el-table-column label="要求巡查时间" align="center" prop="task_time" />
+            <el-table-column label="巡查周期" align="center" prop="cycle" />
+            <el-table-column label="巡查范围" walign="center" prop="inspection_range" />
+            <el-table-column label="执行日期" align="center" prop="run_time" />
+            <el-table-column label="已完成" align="center" prop="finished" />
+            <el-table-column label="未完成" align="center" prop="unfinished" />
+            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+              <template #default="scope">
+                <el-text class="common-btn-text-primary" @click="handleView(scope.row)">巡查结果</el-text>
+              </template>
+            </el-table-column>
+          </el-table>
+          <pagination
+            v-show="total > 0"
+            v-model:page="queryParams.page"
+            v-model:limit="queryParams.pageSize"
+            :total="total"
+            @pagination="tableData"
+          />
+        </el-card>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+<script setup lang="ts">
+import { workDetail } from '@/api/inspectionWork/inspector';
+import { reactive, ref } from 'vue';
+const props = defineProps<{ eventId: string }>();
+const total = ref(0);
+const tableData = ref([]);
+const emits = defineEmits(['close']);
+const detailData = ref({
+  task_number: '',
+  business: '',
+  task_time: '',
+  cycle: '',
+  id: '',
+  inspection_range: '',
+  task_status: '',
+  create_time: '',
+  create_by: ''
+});
+const initFormData = reactive({
+  finished: '',
+  business: '',
+  task_time: '',
+  cycle: '',
+  id: '',
+  inspection_range: '',
+  run_time: '',
+  unfinished: ''
+});
+const data = reactive({
+  form: { ...initFormData },
+  queryParams: {
+    page: 1,
+    pageSize: 10
+  }
+});
+const { queryParams, form } = toRefs(data);
+// 映射表
+const businessMap = {
+  0: '城市隐患巡查',
+  1: '森林防火巡查',
+  2: '重点危化企业巡查',
+  3: '重点水库水位巡查'
+};
+
+const cycleMap = {
+  0: '每年',
+  1: '每月',
+  2: '每周',
+  3: '每日',
+  4: '一次'
+};
+
+const inspectionRangeMap = {
+  0: '市级',
+  1: '区县级',
+  2: '镇街级',
+  3: '村居级'
+};
+
+const taskStatusMap = {
+  0: '未开始',
+  1: '进行中',
+  2: '未完成',
+  3: '已完结'
+};
+const loading = ref(false);
+const fetchWorkDetail = () => {
+  loading.value = true;
+  workDetail(props.eventId) // 使用从父组件接收到的eventId
+    .then((res) => {
+      if (res.code === 200) {
+        let data = res.data;
+        // 转换business
+        data.business = businessMap[data.business] || '未知';
+        // 转换cycle
+        data.cycle = cycleMap[data.cycle] || '未知';
+        // 转换inspection_range
+        data.inspection_range = inspectionRangeMap[data.inspection_range] || '未知';
+        // 转换task_status
+        data.task_status = taskStatusMap[data.task_status] || '未知';
+
+        detailData.value = data; // 将转换后的数据赋值给detailData
+      } else {
+        console.error(res.msg);
+      }
+    })
+    .finally(() => {
+      loading.value = false;
+    });
+};
+const goBack = () => {
+  emits('close');
+};
+onMounted(() => {
+  fetchWorkDetail(); // 在组件挂载后调用此函数以获取数据
+});
+</script>

+ 52 - 7
src/views/inspectionWork/patrolTask.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <div class="app-container">
+    <div v-show="!patrolSubTasksState.show" class="app-container">
       <div>
         <transition name="fade">
           <div v-show="showSearch">
@@ -34,16 +34,16 @@
             <el-button type="primary" icon="Plus" @click="handleAdd">新建</el-button>
           </el-col>
           <el-col :span="1.5">
-            <el-button type="danger" plain :disabled="multiple" icon="Delete" @click="handleDelete()"> 删除 </el-button>
+            <el-button type="danger" plain :disabled="multiple" icon="Delete" @click="handleDelete(selectedRow)"> 删除 </el-button>
           </el-col>
         </el-row>
         <!-- 表格组件 -->
         <el-table ref="multipleTable" v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
           <el-table-column type="selection" width="55" align="center" />
           <el-table-column label="任务编号" align="center" prop="task_number" />
-          <el-table-column label="巡查务" align="center">
+          <el-table-column label="巡查务" align="center">
             <template #default="scope">
-              {{ convertStatus(scope.row.business, 'business') }}
+              <el-text type="primary" @click="openPatrolSubTasks(scope.row)">{{ convertStatus(scope.row.business, 'business') }}</el-text>
             </template>
           </el-table-column>
           <el-table-column label="巡查时间范围" width="200" align="center" prop="task_time" />
@@ -57,7 +57,7 @@
               {{ convertStatus(scope.row.inspection_range, 'inspection_range') }}
             </template>
           </el-table-column>
-          <el-table-column label="创建人" align="center" prop="create_user" />
+          <el-table-column label="创建人" align="center" prop="create_by" />
           <el-table-column label="创建时间" align="center" prop="create_time" />
           <el-table-column label="任务状态" align="center">
             <template #default="scope">
@@ -76,10 +76,13 @@
       </div>
     </div>
   </div>
+  <PatrolSubTasks v-if="patrolSubTasksState.show" :event-id="patrolSubTasksState.eventId" @close="handleCancel" />
 </template>
 <script setup lang="ts">
 import { onMounted, reactive, ref } from 'vue';
-import { workList } from '@/api/inspectionWork/inspector';
+import PatrolSubTasks from './patrolSubTasks.vue';
+import { workList, workDelete } from '@/api/inspectionWork/inspector';
+import { to } from 'await-to-js';
 const loading = ref(true);
 const showSearch = ref(true);
 const multiple = ref(true);
@@ -87,6 +90,19 @@ const ids = ref<Array<number | string>>([]);
 const single = ref(true);
 const total = ref(0);
 const tableData = ref([]);
+const selectedRow = ref<PatrolVO | null>(null);
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+export interface PatrolVO {
+  task_number: number;
+  business: string;
+  task_time: string;
+  cycle: number;
+  id: number;
+  inspection_range: number;
+  task_status: number;
+  create_time: string;
+  create_by: string;
+}
 const initFormData = reactive({
   task_number: '',
   business: '',
@@ -96,7 +112,7 @@ const initFormData = reactive({
   inspection_range: '',
   task_status: '',
   create_time: '',
-  create_user: ''
+  create_by: ''
 });
 const data = reactive({
   form: { ...initFormData },
@@ -158,6 +174,34 @@ function convertStatus(value, type) {
 
   return statusMapping[type]?.[value] || value;
 }
+let patrolSubTasksState = reactive({
+  show: false,
+  eventId: ''
+});
+const handleCancel = () => {
+  patrolSubTasksState.show = false;
+};
+const openPatrolSubTasks = (row) => {
+  if (row) {
+    patrolSubTasksState.eventId = row.id; // 假设eventId是id字段
+    patrolSubTasksState.show = true;
+  }
+};
+const handleDelete = async (row) => {
+  let id = [];
+  if (row) {
+    id = [row.id];
+  } else {
+    id = ids.value;
+  }
+  const [err] = await to(proxy?.$modal.confirm('是否确认删除选择的数据项?') as any);
+  if (!err) {
+    await workDelete(id);
+    proxy.$modal.msgSuccess('删除成功');
+    fetchWorkrData();
+  }
+};
+
 const fetchWorkrData = () => {
   loading.value = true;
   workList(queryParams.value)
@@ -180,6 +224,7 @@ const resetQuery = () => {
 };
 const handleSelectionChange = (selection) => {
   ids.value = selection.map((item) => item.id);
+  selectedRow.value = selection.length === 1 ? selection[0] : null;
   single.value = selection.length != 1;
   multiple.value = !selection.length;
 };