fix:作业范围
This commit is contained in:
@@ -0,0 +1,192 @@
|
||||
<!--
|
||||
* @Author: SunTao 328867980@qq.com
|
||||
* @Date: 2024-10-16 10:00:40
|
||||
* @LastEditors: SunTao 328867980@qq.com
|
||||
* @LastEditTime: 2024-10-17 09:10:38
|
||||
* @FilePath: \znxjxt-ui\src\views\xj\route\route-scope\components\scope-add.vue
|
||||
* @Description: 作业范围-新增编辑弹窗
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="add-content">
|
||||
<div class="add-form">
|
||||
<el-form
|
||||
ref="dialogForm"
|
||||
:model="dialogForm"
|
||||
:rules="rules"
|
||||
label-width="120px"
|
||||
>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="作业范围名称" prop="segCode">
|
||||
<el-input
|
||||
v-model="dialogForm.segCode"
|
||||
placeholder="请输入作业范围名称"
|
||||
clearable
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="绑定车辆" prop="roadType">
|
||||
<el-select
|
||||
v-model="dialogForm.roadType"
|
||||
placeholder="请选择绑定车辆"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in bindCarList"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="作业范围" prop="coordinates">
|
||||
<el-input
|
||||
type="textarea"
|
||||
:disabled="true"
|
||||
v-model="dialogForm.coordinates"
|
||||
rows="3"
|
||||
resize="none"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="bottom-map">
|
||||
<fssm-map
|
||||
@endEoordinate="geteoordinate"
|
||||
:editCoordinates="editCoordinates"
|
||||
:showChange="true"
|
||||
:showZoom="false"
|
||||
:showDraw="true"
|
||||
></fssm-map>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addScope, updateScope } from "@/api/xj/scope";
|
||||
import FssmMap from "@/components/map/fssm-map";
|
||||
export default {
|
||||
components: { FssmMap },
|
||||
name: "ScopeAdd",
|
||||
props: {
|
||||
dialogItem: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
bindCarList: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 表单绑定
|
||||
dialogForm: {
|
||||
segCode: "",
|
||||
roadType: "",
|
||||
coordinates: "",
|
||||
},
|
||||
rules: {
|
||||
segCode: [
|
||||
{ required: true, message: "作业范围名称不能为空", trigger: "blur" },
|
||||
],
|
||||
roadType: [
|
||||
{ required: true, message: "请选择绑定车辆", trigger: "change" },
|
||||
],
|
||||
coordinates: [
|
||||
{
|
||||
required: true,
|
||||
message: "请在下方地图添加作业范围",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
editCoordinates: [],
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
dialogItem: {
|
||||
handler(val) {
|
||||
if (val.title === "修改") {
|
||||
const a =
|
||||
"122.2772084092066,42.1903654574782;122.4566518803403,41.91936930784885;123.0608999272153,41.9541594027907;122.9638539170191,42.419247153717315;122.37425425176474,42.413753989654815;122.36143698071095,42.24529693046514;122.2772084092066,42.1903654574782";
|
||||
this.dialogForm.coordinates = a;
|
||||
this.editCoordinates = a.split(";").map((item) => {
|
||||
return item.split(",");
|
||||
});
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
/* 获取多边形坐标方法 */
|
||||
geteoordinate(list) {
|
||||
this.dialogForm.coordinates = list.join(";");
|
||||
},
|
||||
/* 点击取消事件 */
|
||||
cancel() {
|
||||
this.$emit("addCancel");
|
||||
},
|
||||
/* 点击确认事件 */
|
||||
submitForm() {
|
||||
this.$refs["dialogForm"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.dialogItem.title === "修改") {
|
||||
updateScope(this.dialogForm).then(({ data, code }) => {
|
||||
if (code === 200) {
|
||||
this.$emit("addCancel");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
addScope(this.dialogForm).then(({ data, code }) => {
|
||||
if (code === 200) {
|
||||
this.$emit("addCancel");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.add-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.add-form {
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-map {
|
||||
width: 100%;
|
||||
height: 30rem;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
width: 100%;
|
||||
height: 2.5rem;
|
||||
margin-top: 1rem;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,296 @@
|
||||
<!--
|
||||
* @Author: SunTao 328867980@qq.com
|
||||
* @Date: 2024-10-16 09:42:28
|
||||
* @LastEditors: SunTao 328867980@qq.com
|
||||
* @LastEditTime: 2024-10-16 10:40:11
|
||||
* @FilePath: \znxjxt-ui\src\views\xj\route\route-scope\index.vue
|
||||
* @Description: 路线管理-作业范围
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="section-content">
|
||||
<!-- 搜索表单 -->
|
||||
<div class="section-form">
|
||||
<el-form
|
||||
:model="sectionForm"
|
||||
ref="queryForm"
|
||||
size="small"
|
||||
:inline="true"
|
||||
label-width="6rem"
|
||||
>
|
||||
<el-form-item label="作业范围名称" prop="name">
|
||||
<el-input
|
||||
v-model="sectionForm.name"
|
||||
placeholder="请输入作业范围名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
|
||||
>重置</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<!-- 操作按钮 -->
|
||||
<div class="btn-row">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增
|
||||
</el-button>
|
||||
</div>
|
||||
<!-- 列表 -->
|
||||
<el-table
|
||||
ref="roadTable"
|
||||
v-loading="loading"
|
||||
:data="sectionList"
|
||||
@selection-change="handleSelectionChange"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column
|
||||
width="300"
|
||||
label="作业范围名称"
|
||||
align="center"
|
||||
prop="segmentCode"
|
||||
/>
|
||||
<el-table-column label="绑定车辆" align="center" prop="name" />
|
||||
<el-table-column
|
||||
width="200"
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="editTable(scope.row)"
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="deleteTable(scope.row)"
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<div class="pagination-part">
|
||||
<el-pagination
|
||||
background
|
||||
:current-page.sync="pagination.page"
|
||||
@current-change="handleCurrentChange"
|
||||
:page-sizes="[10, 20, 30, 40]"
|
||||
:page-size.sync="pagination.size"
|
||||
@size-change="handleSizeChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="tableTotal"
|
||||
>
|
||||
</el-pagination>
|
||||
</div>
|
||||
<!-- 新增/修改弹窗 -->
|
||||
<el-dialog
|
||||
:title="addTitle"
|
||||
:visible.sync="addVisible"
|
||||
width="60%"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
destroy-on-close
|
||||
@close="addCancel"
|
||||
>
|
||||
<scope-add
|
||||
:bindCarList="bindCarList"
|
||||
:dialogItem="dialogItem"
|
||||
@addCancel="addCancel"
|
||||
></scope-add>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getScopeList, deleteScope, getCarList } from "@/api/xj/scope";
|
||||
import ScopeAdd from "./components/scope-add.vue";
|
||||
|
||||
export default {
|
||||
components: { ScopeAdd },
|
||||
name: "RouteScope",
|
||||
data() {
|
||||
return {
|
||||
// 搜索表单
|
||||
sectionForm: {
|
||||
// segmentCode: "",
|
||||
name: "",
|
||||
},
|
||||
// 查询表单
|
||||
searchForm: {},
|
||||
// 列表加载状态
|
||||
loading: false,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 列表数据
|
||||
sectionList: [],
|
||||
// 列表已选数组
|
||||
checkIds: [],
|
||||
// 分页-列表总数
|
||||
tableTotal: 0,
|
||||
// 分页-页数页码
|
||||
pagination: {
|
||||
page: 1,
|
||||
size: 10,
|
||||
},
|
||||
// 绑定车辆下拉
|
||||
bindCarList: [],
|
||||
// 弹窗标题
|
||||
addTitle: "",
|
||||
// 弹窗显隐控制
|
||||
addVisible: false,
|
||||
// 传弹窗数据
|
||||
dialogItem: {},
|
||||
};
|
||||
},
|
||||
mounted() {},
|
||||
created() {
|
||||
this.getTableList();
|
||||
this.getBindCar();
|
||||
},
|
||||
methods: {
|
||||
/* 获取绑定车辆下拉 */
|
||||
getBindCar() {
|
||||
getCarList().then(({ data, code }) => {
|
||||
if (code === 200) {
|
||||
this.bindCarList = data;
|
||||
}
|
||||
});
|
||||
},
|
||||
/* 点击搜索事件 */
|
||||
handleQuery() {
|
||||
this.searchForm = JSON.parse(JSON.stringify(this.sectionForm));
|
||||
this.getTableList();
|
||||
},
|
||||
/* 点击重置事件 */
|
||||
resetQuery() {
|
||||
this.sectionForm = {
|
||||
// segmentCode: "",
|
||||
name: "",
|
||||
};
|
||||
this.searchForm = {};
|
||||
this.getTableList();
|
||||
},
|
||||
/* 获取列表数据 */
|
||||
getTableList() {
|
||||
const params = {
|
||||
...this.searchForm,
|
||||
...this.pagination,
|
||||
};
|
||||
getScopeList(params).then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
this.sectionList = data.rows;
|
||||
}
|
||||
});
|
||||
},
|
||||
/* 点击新增 */
|
||||
handleAdd() {
|
||||
this.addTitle = "新增作业范围";
|
||||
this.dialogItem = {
|
||||
title: "新增",
|
||||
};
|
||||
this.addVisible = true;
|
||||
},
|
||||
/* 列表选择改变事件 */
|
||||
handleSelectionChange(selection) {
|
||||
this.checkIds = selection.map((item) => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/* 列表修改事件 */
|
||||
editTable() {
|
||||
this.addTitle = "修改作业范围";
|
||||
this.dialogItem = {
|
||||
title: "修改",
|
||||
};
|
||||
this.addVisible = true;
|
||||
},
|
||||
/* 列表删除/批量删除事件 */
|
||||
deleteTable(row) {
|
||||
const checkIds = row ? [row.id] : this.checkIds;
|
||||
if (!checkIds.length) {
|
||||
this.$modal.msgWarning("请选择要删除的记录");
|
||||
return;
|
||||
}
|
||||
this.$modal
|
||||
.confirm(`是否确认删除选中的${checkIds.length}条记录?`)
|
||||
.then(() => {
|
||||
return deleteScope(checkIds);
|
||||
})
|
||||
.then(() => {
|
||||
this.getTableList();
|
||||
this.$refs.roadTable.clearSelection();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
/* 切换分页 */
|
||||
handleCurrentChange(arg) {
|
||||
this.pagination.page = arg;
|
||||
this.getTableList();
|
||||
},
|
||||
/* 切换每条/页 */
|
||||
handleSizeChange(arg) {
|
||||
this.pagination.size = arg;
|
||||
this.getTableList();
|
||||
},
|
||||
/* 关闭弹窗事件 */
|
||||
addCancel() {
|
||||
this.addTitle = "";
|
||||
this.dialogItem = {};
|
||||
this.addVisible = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.section-content {
|
||||
width: 100%;
|
||||
height: calc(100vh - 5.3rem);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.section-form {
|
||||
width: 100%;
|
||||
height: 5%;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
height: 6%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
/* 分页样式 */
|
||||
.pagination-part {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
padding-top: 1rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: SunTao 328867980@qq.com
|
||||
* @Date: 2024-10-15 14:27:36
|
||||
* @LastEditors: SunTao 328867980@qq.com
|
||||
* @LastEditTime: 2024-10-16 09:36:51
|
||||
* @LastEditTime: 2024-10-16 10:28:42
|
||||
* @FilePath: \znxjxt-ui\src\views\xj\route\route-section\components\section-add.vue
|
||||
* @Description: 道路段-新增/编辑弹窗
|
||||
-->
|
||||
@@ -172,6 +172,7 @@
|
||||
:disabled="true"
|
||||
v-model="dialogForm.coordinates"
|
||||
rows="4"
|
||||
resize="none"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
Reference in New Issue
Block a user