提交阶段性预览
This commit is contained in:
262
src/views/system/inspection/Item/index2.vue
Normal file
262
src/views/system/inspection/Item/index2.vue
Normal file
@@ -0,0 +1,262 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="项目名称" prop="itemName">
|
||||
<el-input v-model="queryParams.itemName" placeholder="请输入项目名称" clearable @keyup.enter="handleQuery" />
|
||||
</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-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:item:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:item:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:item:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:item:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="itemList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="项目名称" align="center" prop="itemName" />
|
||||
<el-table-column label="巡检标准" align="center" prop="inspectionStandard" />
|
||||
<el-table-column label="状态:0-开启,1-关闭" align="center" prop="status" />
|
||||
<el-table-column label="添加人" align="center" prop="remark" />
|
||||
<el-table-column label="添加时间" align="center" prop="remark" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:item:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:item:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</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-card>
|
||||
<!-- 添加或修改巡检项目对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="itemFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="项目名称" prop="itemName">
|
||||
<el-input v-model="form.itemName" placeholder="请输入项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编号" prop="itemCode">
|
||||
<el-input v-model="form.itemCode" placeholder="请输入项目编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检标准" prop="inspectionStandard">
|
||||
<el-input v-model="form.inspectionStandard" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目类别" prop="category">
|
||||
<el-input v-model="form.category" placeholder="请输入项目类别" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目描述" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="默认值" prop="defaultValue">
|
||||
<el-input v-model="form.defaultValue" placeholder="请输入默认值" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选项,多个用逗号分隔" prop="options">
|
||||
<el-input v-model="form.options" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否必填:0-否,1-是" prop="isRequired">
|
||||
<el-input v-model="form.isRequired" placeholder="请输入是否必填:0-否,1-是" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Item" lang="ts">
|
||||
import { listItem, getItem, delItem, addItem, updateItem } from '@/api/system/InspectionItem/index';
|
||||
import { ItemVO, ItemQuery, ItemForm } from '@/api/system/InspectionItem/type';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
const itemList = ref<ItemVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const itemFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: ItemForm = {
|
||||
id: undefined,
|
||||
itemName: undefined,
|
||||
itemCode: undefined,
|
||||
inspectionStandard: undefined,
|
||||
category: undefined,
|
||||
description: undefined,
|
||||
defaultValue: undefined,
|
||||
inputType: undefined,
|
||||
options: undefined,
|
||||
isRequired: undefined,
|
||||
status: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<ItemForm, ItemQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
itemName: undefined,
|
||||
itemCode: undefined,
|
||||
inspectionStandard: undefined,
|
||||
category: undefined,
|
||||
description: undefined,
|
||||
defaultValue: undefined,
|
||||
inputType: undefined,
|
||||
options: undefined,
|
||||
isRequired: undefined,
|
||||
status: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
itemName: [{ required: true, message: '项目名称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询巡检项目列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listItem(queryParams.value);
|
||||
itemList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
itemFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: ItemVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加巡检项目';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: ItemVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getItem(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改巡检项目';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
itemFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateItem(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addItem(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: ItemVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除巡检项目编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delItem(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'system/item/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`item_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
@@ -1,9 +1,334 @@
|
||||
<template>
|
||||
<div class=" "></div>
|
||||
<div class="AddBuildingBox">
|
||||
<PageHeader></PageHeader>
|
||||
<div class="AddBuildingBody">
|
||||
<div class="title">基本信息</div>
|
||||
<div class="addBuildingFormBody">
|
||||
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
|
||||
<el-form-item label="巡检点名称" prop="pointName">
|
||||
<el-input v-model.trim="form.pointName" placeholder="请输入巡检点名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检项目" prop="itemId">
|
||||
<div class="itembox">
|
||||
<div
|
||||
class="item"
|
||||
:class="{
|
||||
active: checkoutPointItemlist.includes(item.id)
|
||||
}"
|
||||
@click="checkoutItem(item.id)"
|
||||
v-for="(item, index) in pointItemlist"
|
||||
:key="index"
|
||||
>
|
||||
<el-icon><Check /></el-icon>
|
||||
<div>{{ item.itemName }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="打卡方式" prop="checkMode">
|
||||
<el-select v-model="form.checkMode" placeholder="请选择打卡方式" clearable>
|
||||
<el-option v-for="dict in com_inspection_point_checkmode" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检点状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="item in com_inspection_point_status" :value="item.value" :key="item.value" :label="item.value">{{
|
||||
item.label
|
||||
}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检点位置" prop="location">
|
||||
<div class="map" id="containerMap"></div>
|
||||
<div class="tips">
|
||||
<span>点击地图选择位置</span>
|
||||
<span class="deleteMarker" v-show="Boolean(marker)" @click="clearLocation">清空选择地点</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-top: 30px">
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
<el-button @click="cancelForm">返回</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ref, toRefs } from 'vue';
|
||||
import { getCurrentInstance, ComponentInternalInstance } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { addPoint, getPoint, updatePoint } from '@/api/system/InspectionPoint';
|
||||
import { listItem } from '@/api/system/InspectionItem';
|
||||
import { onMounted, onUnmounted } from 'vue';
|
||||
import AMapLoader from '@amap/amap-jsapi-loader';
|
||||
import { getVillageByIdAPI } from '@/api/system/community';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_inspection_point_checkmode } = toRefs<any>(proxy?.useDict('com_inspection_point_checkmode'));
|
||||
const { com_inspection_point_status } = toRefs<any>(proxy?.useDict('com_inspection_point_status'));
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const formRef = ref();
|
||||
const form = ref({
|
||||
id: null,
|
||||
pointName: '',
|
||||
itemId: '',
|
||||
location: '',
|
||||
status: '0',
|
||||
checkMode: '9999'
|
||||
});
|
||||
|
||||
const rules = ref({
|
||||
pointName: [{ required: true, message: '请输入巡检点名称', trigger: 'blur' }],
|
||||
itemId: [{ required: true, message: '请选择巡检项目', trigger: 'change' }],
|
||||
checkMode: [{ required: true, message: '请选择打卡方式', trigger: 'change' }],
|
||||
location: [{ required: true, message: '请选择巡检点位置', trigger: 'change' }]
|
||||
});
|
||||
|
||||
// !== 初始化 =============================================================================
|
||||
|
||||
const pointId = ref(null);
|
||||
const pointItemlist = ref([]);
|
||||
const checkoutPointItemlist = ref([]);
|
||||
function checkoutItem(id: string) {
|
||||
form.value.itemId = ''; // 每次点击都先清空 itemId
|
||||
if (checkoutPointItemlist.value.includes(id)) {
|
||||
checkoutPointItemlist.value = checkoutPointItemlist.value.filter((item) => item !== id);
|
||||
} else {
|
||||
checkoutPointItemlist.value.push(id);
|
||||
}
|
||||
form.value.itemId = checkoutPointItemlist.value.join(','); // 将选中的 id 数组转换为逗号分隔的字符串
|
||||
}
|
||||
function init() {
|
||||
// 获取巡检项目列表
|
||||
listItem().then((res) => {
|
||||
pointItemlist.value = res.rows;
|
||||
});
|
||||
|
||||
if (route.query.id) {
|
||||
pointId.value = route.query.id;
|
||||
// 获取巡检点详情
|
||||
getPoint(pointId.value).then((res) => {
|
||||
form.value = {
|
||||
...form.value,
|
||||
...res.data
|
||||
};
|
||||
// 如果有 itemId,拆分到 checkoutPointItemlist
|
||||
if (res.data.itemId) {
|
||||
checkoutPointItemlist.value = res.data.itemId.split(',');
|
||||
}
|
||||
nextTick(() => {
|
||||
initLocation();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
init();
|
||||
|
||||
// !== 提交 =============================================================================
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
// 设置 itemId
|
||||
form.value.itemId = checkoutPointItemlist.value.join(',');
|
||||
if (pointId.value) {
|
||||
updatePoint(form.value).then((res) => {
|
||||
ElMessage.success('编辑成功');
|
||||
cancelForm();
|
||||
});
|
||||
} else {
|
||||
addPoint(form.value).then((res) => {
|
||||
ElMessage.success('添加成功');
|
||||
cancelForm();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
// 返回
|
||||
const cancelForm = () => {
|
||||
router.push({
|
||||
path: '/inspection/point'
|
||||
});
|
||||
};
|
||||
|
||||
// ! map
|
||||
const mapReady = ref(false);
|
||||
let map = ref(null);
|
||||
const marker = ref(null);
|
||||
const villageid = localStorage.getItem('villageid');
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
|
||||
window._AMapSecurityConfig = { securityJsCode: '09534b3534d8da53968529a9ce164118' };
|
||||
|
||||
AMapLoader.load({
|
||||
key: '8e302fe1be5f4db62bc734db23dca149',
|
||||
version: '2.0',
|
||||
plugins: ['AMap.Scale', 'AMap.Marker']
|
||||
}).then(async (AMap) => {
|
||||
const villageinfo = await getVillageByIdAPI(Number(villageid));
|
||||
console.log(villageinfo);
|
||||
map.value = new AMap.Map('containerMap', {
|
||||
viewMode: '3D',
|
||||
zoom: 11,
|
||||
center: [116.397428, 39.90923]
|
||||
});
|
||||
|
||||
mapReady.value = true;
|
||||
handleMap(AMap);
|
||||
initLocation(AMap);
|
||||
});
|
||||
});
|
||||
|
||||
/** 清空选择地点 */
|
||||
function clearLocation() {
|
||||
form.value.location = '';
|
||||
if (marker.value) {
|
||||
map.value.remove(marker.value);
|
||||
marker.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function handleMap(AMap) {
|
||||
// 添加点击事件
|
||||
map.value.on('click', (e) => {
|
||||
const lnglat = e.lnglat;
|
||||
form.value.location = `${lnglat.lng},${lnglat.lat}`;
|
||||
// 如果有 marker.value,先移除
|
||||
if (marker.value) {
|
||||
map.value.remove(marker.value);
|
||||
}
|
||||
// 添加新 marker
|
||||
marker.value = new AMap.Marker({
|
||||
position: lnglat,
|
||||
map: map.value,
|
||||
title: form.value.pointName || '巡检点'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const initLocation = (AMap) => {
|
||||
if (!map.value || !form.value.location) return;
|
||||
|
||||
const [lng, lat] = form.value.location.split(',').map((v) => Number(v.trim()));
|
||||
if (!Number.isFinite(lng) || !Number.isFinite(lat)) return;
|
||||
if (!lng || !lat) return;
|
||||
|
||||
const lnglat = new AMap.LngLat(lng, lat);
|
||||
map.value.setCenter(lnglat);
|
||||
map.value.setZoom(16);
|
||||
|
||||
if (marker.value) {
|
||||
map.value.remove(marker.value);
|
||||
}
|
||||
|
||||
marker.value = new AMap.Marker({
|
||||
position: lnglat,
|
||||
map: map.value,
|
||||
title: form.value.pointName || '巡检点'
|
||||
});
|
||||
};
|
||||
|
||||
onUnmounted(() => {
|
||||
map.value?.destroy();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
<style scoped lang="scss">
|
||||
.AddBuildingBox {
|
||||
padding: 15px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.AddBuildingBody {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
.title {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding-left: 20px;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
color: rgba(16, 16, 16, 1);
|
||||
border-bottom: 1px solid #bbbbbb;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.formBody {
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
|
||||
.itembox {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
border: 1px solid #ccc;
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
}
|
||||
div {
|
||||
margin-left: 10px;
|
||||
}
|
||||
&.active {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
background-color: #f0f9ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.map {
|
||||
width: 100%;
|
||||
min-height: 500px;
|
||||
background-color: #f0f0f0;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.tips {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: #ccc;
|
||||
.deleteMarker {
|
||||
margin-left: 20px;
|
||||
cursor: pointer;
|
||||
color: #f00;
|
||||
}
|
||||
}
|
||||
&:deep(.el-form-item__content, .el-select, .el-input) {
|
||||
width: 350px !important;
|
||||
margin-right: 10px;
|
||||
.el-cascader {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.el-form-item {
|
||||
margin-bottom: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
.el-button {
|
||||
width: 80px;
|
||||
height: 35px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<div class="h-full flex flex-col p-2">
|
||||
<PageHeader></PageHeader>
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form label-width="100px" ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="巡检点名称" prop="pointName">
|
||||
<el-input v-model="queryParams.pointName" placeholder="请输入巡检点名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<el-card class="flex-1" shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
@@ -38,12 +38,19 @@
|
||||
<el-table v-loading="loading" border :data="pointList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="巡检点名称" align="center" prop="pointName" />
|
||||
<el-table-column label="巡检项目id" align="center" prop="itemId" />
|
||||
<el-table-column label="打卡方式:9999定位打卡、9998蓝牙打卡、9997NFC打卡" align="center" prop="checkMode" />
|
||||
<el-table-column label="打卡方式" align="center" prop="checkModeName">
|
||||
<template #default="scope">
|
||||
<DictTag :options="com_inspection_point_checkmode" :value="scope.row.checkModeName"></DictTag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="巡检点位置" align="center" prop="location" />
|
||||
<el-table-column label="状态:0-开启,1-关闭" align="center" prop="status" />
|
||||
<el-table-column label="添加人" align="center" prop="isCheck" />
|
||||
<el-table-column label="添加时间" align="center" prop="isCheck" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<DictTag :options="com_inspection_point_status" :value="scope.row.status"></DictTag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="添加人" align="center" prop="createByName" />
|
||||
<el-table-column label="添加时间" align="center" prop="createTime" />
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
@@ -67,6 +74,8 @@ import { listPoint, getPoint, delPoint, addPoint, updatePoint } from '@/api/syst
|
||||
import { PointVO, PointQuery, PointForm } from '@/api/system/InspectionPoint/type';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_inspection_point_status } = toRefs<any>(proxy?.useDict('com_inspection_point_status'));
|
||||
const { com_inspection_point_checkmode } = toRefs<any>(proxy?.useDict('com_inspection_point_checkmode'));
|
||||
|
||||
const pointList = ref<PointVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
@@ -219,3 +228,9 @@ onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.el-table {
|
||||
height: calc(100% - 80px);
|
||||
}
|
||||
</style>
|
||||
|
||||
334
src/views/system/inspection/Route/addInspectionRoute.vue
Normal file
334
src/views/system/inspection/Route/addInspectionRoute.vue
Normal file
@@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<div class="AddBuildingBox">
|
||||
<PageHeader></PageHeader>
|
||||
<div class="AddBuildingBody">
|
||||
<div class="title">基本信息</div>
|
||||
<div class="addBuildingFormBody">
|
||||
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
|
||||
<el-form-item label="巡检点名称" prop="pointName">
|
||||
<el-input v-model.trim="form.pointName" placeholder="请输入巡检点名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检项目" prop="itemId">
|
||||
<div class="itembox">
|
||||
<div
|
||||
class="item"
|
||||
:class="{
|
||||
active: checkoutPointItemlist.includes(item.id)
|
||||
}"
|
||||
@click="checkoutItem(item.id)"
|
||||
v-for="(item, index) in pointItemlist"
|
||||
:key="index"
|
||||
>
|
||||
<el-icon><Check /></el-icon>
|
||||
<div>{{ item.itemName }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="打卡方式" prop="checkMode">
|
||||
<el-select v-model="form.checkMode" placeholder="请选择打卡方式" clearable>
|
||||
<el-option v-for="dict in com_inspection_point_checkmode" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检点状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="item in com_inspection_point_status" :value="item.value" :key="item.value" :label="item.value">{{
|
||||
item.label
|
||||
}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检点位置" prop="location">
|
||||
<div class="map" id="containerMap"></div>
|
||||
<div class="tips">
|
||||
<span>点击地图选择位置</span>
|
||||
<span class="deleteMarker" v-show="Boolean(marker)" @click="clearLocation">清空选择地点</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-top: 30px">
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
<el-button @click="cancelForm">返回</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, toRefs } from 'vue';
|
||||
import { getCurrentInstance, ComponentInternalInstance } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { addPoint, getPoint, updatePoint } from '@/api/system/InspectionPoint';
|
||||
import { listItem } from '@/api/system/InspectionItem';
|
||||
import { onMounted, onUnmounted } from 'vue';
|
||||
import AMapLoader from '@amap/amap-jsapi-loader';
|
||||
import { getVillageByIdAPI } from '@/api/system/community';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_inspection_point_checkmode } = toRefs<any>(proxy?.useDict('com_inspection_point_checkmode'));
|
||||
const { com_inspection_point_status } = toRefs<any>(proxy?.useDict('com_inspection_point_status'));
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const formRef = ref();
|
||||
const form = ref({
|
||||
id: null,
|
||||
pointName: '',
|
||||
itemId: '',
|
||||
location: '',
|
||||
status: '0',
|
||||
checkMode: '9999'
|
||||
});
|
||||
|
||||
const rules = ref({
|
||||
pointName: [{ required: true, message: '请输入巡检点名称', trigger: 'blur' }],
|
||||
itemId: [{ required: true, message: '请选择巡检项目', trigger: 'change' }],
|
||||
checkMode: [{ required: true, message: '请选择打卡方式', trigger: 'change' }],
|
||||
location: [{ required: true, message: '请选择巡检点位置', trigger: 'change' }]
|
||||
});
|
||||
|
||||
// !== 初始化 =============================================================================
|
||||
|
||||
const pointId = ref(null);
|
||||
const pointItemlist = ref([]);
|
||||
const checkoutPointItemlist = ref([]);
|
||||
function checkoutItem(id: string) {
|
||||
form.value.itemId = ''; // 每次点击都先清空 itemId
|
||||
if (checkoutPointItemlist.value.includes(id)) {
|
||||
checkoutPointItemlist.value = checkoutPointItemlist.value.filter((item) => item !== id);
|
||||
} else {
|
||||
checkoutPointItemlist.value.push(id);
|
||||
}
|
||||
form.value.itemId = checkoutPointItemlist.value.join(','); // 将选中的 id 数组转换为逗号分隔的字符串
|
||||
}
|
||||
function init() {
|
||||
// 获取巡检项目列表
|
||||
listItem().then((res) => {
|
||||
pointItemlist.value = res.rows;
|
||||
});
|
||||
|
||||
if (route.query.id) {
|
||||
pointId.value = route.query.id;
|
||||
// 获取巡检点详情
|
||||
getPoint(pointId.value).then((res) => {
|
||||
form.value = {
|
||||
...form.value,
|
||||
...res.data
|
||||
};
|
||||
// 如果有 itemId,拆分到 checkoutPointItemlist
|
||||
if (res.data.itemId) {
|
||||
checkoutPointItemlist.value = res.data.itemId.split(',');
|
||||
}
|
||||
nextTick(() => {
|
||||
initLocation();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
init();
|
||||
|
||||
// !== 提交 =============================================================================
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
// 设置 itemId
|
||||
form.value.itemId = checkoutPointItemlist.value.join(',');
|
||||
if (pointId.value) {
|
||||
updatePoint(form.value).then((res) => {
|
||||
ElMessage.success('编辑成功');
|
||||
cancelForm();
|
||||
});
|
||||
} else {
|
||||
addPoint(form.value).then((res) => {
|
||||
ElMessage.success('添加成功');
|
||||
cancelForm();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
// 返回
|
||||
const cancelForm = () => {
|
||||
router.push({
|
||||
path: '/inspection/point'
|
||||
});
|
||||
};
|
||||
|
||||
// ! map
|
||||
const mapReady = ref(false);
|
||||
let map = ref(null);
|
||||
const marker = ref(null);
|
||||
const villageid = localStorage.getItem('villageid');
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
|
||||
window._AMapSecurityConfig = { securityJsCode: '09534b3534d8da53968529a9ce164118' };
|
||||
|
||||
AMapLoader.load({
|
||||
key: '8e302fe1be5f4db62bc734db23dca149',
|
||||
version: '2.0',
|
||||
plugins: ['AMap.Scale', 'AMap.Marker']
|
||||
}).then(async (AMap) => {
|
||||
const villageinfo = await getVillageByIdAPI(Number(villageid));
|
||||
console.log(villageinfo);
|
||||
map.value = new AMap.Map('containerMap', {
|
||||
viewMode: '3D',
|
||||
zoom: 11,
|
||||
center: [116.397428, 39.90923]
|
||||
});
|
||||
|
||||
mapReady.value = true;
|
||||
handleMap(AMap);
|
||||
initLocation(AMap);
|
||||
});
|
||||
});
|
||||
|
||||
/** 清空选择地点 */
|
||||
function clearLocation() {
|
||||
form.value.location = '';
|
||||
if (marker.value) {
|
||||
map.value.remove(marker.value);
|
||||
marker.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function handleMap(AMap) {
|
||||
// 添加点击事件
|
||||
map.value.on('click', (e) => {
|
||||
const lnglat = e.lnglat;
|
||||
form.value.location = `${lnglat.lng},${lnglat.lat}`;
|
||||
// 如果有 marker.value,先移除
|
||||
if (marker.value) {
|
||||
map.value.remove(marker.value);
|
||||
}
|
||||
// 添加新 marker
|
||||
marker.value = new AMap.Marker({
|
||||
position: lnglat,
|
||||
map: map.value,
|
||||
title: form.value.pointName || '巡检点'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const initLocation = (AMap) => {
|
||||
if (!map.value || !form.value.location) return;
|
||||
|
||||
const [lng, lat] = form.value.location.split(',').map((v) => Number(v.trim()));
|
||||
if (!Number.isFinite(lng) || !Number.isFinite(lat)) return;
|
||||
if (!lng || !lat) return;
|
||||
|
||||
const lnglat = new AMap.LngLat(lng, lat);
|
||||
map.value.setCenter(lnglat);
|
||||
map.value.setZoom(16);
|
||||
|
||||
if (marker.value) {
|
||||
map.value.remove(marker.value);
|
||||
}
|
||||
|
||||
marker.value = new AMap.Marker({
|
||||
position: lnglat,
|
||||
map: map.value,
|
||||
title: form.value.pointName || '巡检点'
|
||||
});
|
||||
};
|
||||
|
||||
onUnmounted(() => {
|
||||
map.value?.destroy();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.AddBuildingBox {
|
||||
padding: 15px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.AddBuildingBody {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
.title {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding-left: 20px;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
color: rgba(16, 16, 16, 1);
|
||||
border-bottom: 1px solid #bbbbbb;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.formBody {
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
|
||||
.itembox {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
border: 1px solid #ccc;
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
}
|
||||
div {
|
||||
margin-left: 10px;
|
||||
}
|
||||
&.active {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
background-color: #f0f9ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.map {
|
||||
width: 100%;
|
||||
min-height: 500px;
|
||||
background-color: #f0f0f0;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.tips {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: #ccc;
|
||||
.deleteMarker {
|
||||
margin-left: 20px;
|
||||
cursor: pointer;
|
||||
color: #f00;
|
||||
}
|
||||
}
|
||||
&:deep(.el-form-item__content, .el-select, .el-input) {
|
||||
width: 350px !important;
|
||||
margin-right: 10px;
|
||||
.el-cascader {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.el-form-item {
|
||||
margin-bottom: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
.el-button {
|
||||
width: 80px;
|
||||
height: 35px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
270
src/views/system/inspection/Route/index2.vue
Normal file
270
src/views/system/inspection/Route/index2.vue
Normal file
@@ -0,0 +1,270 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" label-width="120px" :model="queryParams" :inline="true">
|
||||
<el-form-item label="巡检路线名称" prop="routeName">
|
||||
<el-input v-model="queryParams.routeName" placeholder="请输入巡检路线名称" clearable @keyup.enter="handleQuery" />
|
||||
</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-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:route:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:route:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:route:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="routeList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="巡检路线名称" align="center" prop="routeName" />
|
||||
<el-table-column label="路线描述" align="center" prop="description" />
|
||||
<el-table-column label="巡检点" align="center" prop="PointsName" show-overflow-tooltip />
|
||||
<el-table-column label="预计巡检时长" align="center" prop="estimatedTime" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="巡检路线状态" align="center" prop="routeStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="com_inspection_route_status" :value="scope.row.routeStatus"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="起点经度" align="center" prop="startLng" />
|
||||
<el-table-column label="起点纬度" align="center" prop="startLat" />
|
||||
<el-table-column label="终点经度" align="center" prop="endLng" />
|
||||
<el-table-column label="终点纬度" align="center" prop="endLat" />
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:route:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:route:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</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-card>
|
||||
<!-- 添加或修改巡检路线对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="routeFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="巡检路线名称" prop="routeName">
|
||||
<el-input v-model="form.routeName" placeholder="请输入巡检路线名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="路线描述" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检点" prop="totalPoints">
|
||||
<el-input v-model="form.totalPoints" placeholder="请输入巡检点" />
|
||||
</el-form-item>
|
||||
<el-form-item label="预计巡检时长" prop="estimatedTime">
|
||||
<el-input v-model="form.estimatedTime" placeholder="请输入预计巡检时长" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="起点经度" prop="startLng">
|
||||
<el-input v-model="form.startLng" placeholder="请输入起点经度" />
|
||||
</el-form-item>
|
||||
<el-form-item label="起点纬度" prop="startLat">
|
||||
<el-input v-model="form.startLat" placeholder="请输入起点纬度" />
|
||||
</el-form-item>
|
||||
<el-form-item label="终点经度" prop="endLng">
|
||||
<el-input v-model="form.endLng" placeholder="请输入终点经度" />
|
||||
</el-form-item>
|
||||
<el-form-item label="终点纬度" prop="endLat">
|
||||
<el-input v-model="form.endLat" placeholder="请输入终点纬度" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Route" lang="ts">
|
||||
import { listRoute, getRoute, delRoute, addRoute, updateRoute } from '@/api/system/InspectionRoute/index';
|
||||
import { RouteVO, RouteQuery, RouteForm } from '@/api/system/InspectionRoute/type';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_inspection_route_status } = toRefs<any>(proxy?.useDict('com_inspection_route_status'));
|
||||
|
||||
const routeList = ref<RouteVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const routeFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: RouteForm = {
|
||||
id: undefined,
|
||||
routeName: undefined,
|
||||
description: undefined,
|
||||
totalPoints: undefined,
|
||||
estimatedTime: undefined,
|
||||
remark: undefined,
|
||||
routeStatus: undefined,
|
||||
startLng: undefined,
|
||||
startLat: undefined,
|
||||
endLng: undefined,
|
||||
endLat: undefined
|
||||
};
|
||||
const data = reactive<PageData<RouteForm, RouteQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
routeName: undefined,
|
||||
description: undefined,
|
||||
totalPoints: undefined,
|
||||
estimatedTime: undefined,
|
||||
routeStatus: undefined,
|
||||
startLng: undefined,
|
||||
startLat: undefined,
|
||||
endLng: undefined,
|
||||
endLat: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
routeName: [{ required: true, message: '巡检路线名称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询巡检路线列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listRoute(queryParams.value);
|
||||
routeList.value = res.rows;
|
||||
routeList.value.forEach((item) => {
|
||||
if (item.items && item.items.length > 0) {
|
||||
item.PointsName = item.items.map((i) => i.itemName).join(', '); // 将巡检项目名称数组转换为逗号分隔的字符串
|
||||
}
|
||||
});
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
routeFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: RouteVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
const router = useRouter();
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
router.push({
|
||||
path: '/Inspection/addRoute'
|
||||
});
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: RouteVO) => {
|
||||
router.push({
|
||||
path: '/Inspection/addRoute',
|
||||
query: { id: row?.id }
|
||||
});
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
routeFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateRoute(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addRoute(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: RouteVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除巡检路线编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delRoute(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'system/route/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`route_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user