|
@@ -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;
|
|
|
};
|