提交 7867144a 作者: 温凯

fix:任务库-创建航线新增所属单位

上级 006121a3
......@@ -29,4 +29,17 @@ export default class TaskInfo {
data
});
}
}
/**
* 全部单位
* @param {*} params
* @returns
*/
static listAll(params) {
return request({
url: '/admin-api/system/dept/simple-list',
method: 'get',
params,
});
}
}
\ No newline at end of file
......@@ -15,28 +15,30 @@
<el-form-item label="航线名称" required>
<el-input clearable v-model="name"></el-input>
</el-form-item>
<el-form-item label="所属单位:" required>
<el-cascader ref="CascaderRef" v-model="departmentId" :options="orgList" clearable :show-all-levels="false"
placeholder="请选择所属单位" :props="{
children: 'children',
label: 'name',
value: 'id',
checkStrictly: true,
emitPath: false,
}" @change="changeNode"></el-cascader>
</el-form-item>
<el-form-item label="航线速度" prop="speed">
<el-input clearable v-model="curForm.speed"></el-input>
</el-form-item>
<el-form-item label="目标位置" prop="address">
<el-autocomplete
:popper-append-to-body="false"
v-model="curForm.address"
:fetch-suggestions="onAddressInput"
placeholder="请输入目标位置"
:trigger-on-focus="false"
@select="
(item) => {
onAddressChange(item, 'end');
}
"
clearable
>
<el-autocomplete :popper-append-to-body="false" v-model="curForm.address" :fetch-suggestions="onAddressInput"
placeholder="请输入目标位置" :trigger-on-focus="false" @select="(item) => {
onAddressChange(item, 'end');
}
" clearable>
<template slot-scope="{ item }">
<div>
<span style="font-size: 14px; color: #9e9e9e">
{{
item.name
item.name
}}
</span>
<span style="font-size: 12px; color: #999; margin-left: 12px">{{ item.address }}</span>
......@@ -58,27 +60,23 @@
<el-input clearable v-model="curForm.label"></el-input>
</el-form-item>
<el-form-item label="航点动作">
<el-button type="text" @click="showActions = true">{{curForm.actions.length}}个动作</el-button>
<el-button type="text" @click="showActions = true">{{ curForm.actions.length }}个动作</el-button>
</el-form-item>
<el-form-item label="航线总里程">{{distance}}m</el-form-item>
<el-form-item label="预计飞行时间">{{time}}</el-form-item>
<el-form-item label="航线总里程">{{ distance }}m</el-form-item>
<el-form-item label="预计飞行时间">{{ time }}</el-form-item>
</el-form>
<div class="ae-btns">
<el-button type="primary" @click="onSave" :loading="saveLoading">保存</el-button>
<el-button type="danger" @click="onDel">删除航点</el-button>
</div>
</div>
<Actions
v-if="showActions"
@close="showActions = false"
@save="onActionsSave"
:selectActions="curForm.actions"
></Actions>
<Actions v-if="showActions" @close="showActions = false" @save="onActionsSave" :selectActions="curForm.actions">
</Actions>
</div>
</template>
<script>
import { Map, AirLine } from "../../../../../../../../../../../../api";
import { Map, AirLine, TaskInfo } from "../../../../../../../../../../../../api";
import { mapState } from "vuex";
import Utils from "../../../../../../../../../../../../components/cesiumLayer/lib/cesium/utils";
import { nanoid } from "nanoid";
......@@ -115,7 +113,9 @@ export default {
inject: ["rootNode"],
data() {
return {
orgList: [],
name: "", //航线名
departmentId: "", //部门id
form: [], //表单集合
pageIndex: 0, //当前页码
locationIcon: null, //定位图标
......@@ -158,6 +158,7 @@ export default {
},
mounted() {
let viewer = this.cesiumViewer;
this.getOrgList()
this.dataSource = new Cesium.CustomDataSource("airway_edit");
viewer.dataSources.add(this.dataSource);
this.handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas); //获取事件对象
......@@ -184,6 +185,7 @@ export default {
Cesium.ScreenSpaceEventType.LEFT_CLICK
);
this.pickerPointInit();
},
beforeDestroy() {
this.handler.removeInputAction(
......@@ -201,12 +203,63 @@ export default {
this.dataSource.show = false;
},
methods: {
async getOrgList() {
let data = await TaskInfo.listAll();
let res = data.data;
const config = {
id: "id",
parentId: "parentId",
childrenList: "children",
};
const childrenListMap = {};
const nodeIds = {};
const tree = [];
for (const d of res) {
const parentId = d[config.parentId];
if (childrenListMap[parentId] == null) {
childrenListMap[parentId] = [];
}
nodeIds[d[config.id]] = d;
childrenListMap[parentId].push(d);
}
for (const d of res) {
const parentId = d[config.parentId];
if (nodeIds[parentId] == null) {
tree.push(d);
}
}
for (const t of tree) {
adaptToChildrenList(t);
}
function adaptToChildrenList(o) {
if (childrenListMap[o[config.id]] !== null) {
o[config.childrenList] = childrenListMap[o[config.id]];
}
if (o[config.childrenList]) {
for (const c of o[config.childrenList]) {
adaptToChildrenList(c);
}
}
}
this.orgList = tree;
},
changeNode() {
this.$refs.CascaderRef.dropDownVisible = false;
},
// 保存航线
async onSave() {
if (!this.name) {
this.$message.warning("请输入航线名称");
return;
}
if (!this.departmentId) {
this.$message.warning("请选择所属机构");
return;
}
if (this.form.length === 0) {
this.$message.warning("请点击地图选择航点");
return;
......@@ -248,6 +301,7 @@ export default {
content: waypoints,
distance: this.distance,
dutyOrganizationId: "",
departmentId: this.departmentId,
name: this.name,
speed: this.form[0].speed,
};
......@@ -256,6 +310,7 @@ export default {
flightName: airway.name || `${this.userInfo.username}-巡查}`,
pointCount: airway.content.length,
distance: airway.distance,
departmentId: airway.departmentId,
sourceType: 1,
linePointSaveReqVOS: airway.content.map((point) => ({
latitude: point.coordinate.latitude,
......@@ -279,7 +334,7 @@ export default {
this.$message.success("创建航线成功");
this.$emit("addDone", res.data);
this.$emit("close");
} catch (e) {}
} catch (e) { }
this.saveLoading = false;
// 通过事件创建会出现重复创建的情况, 改为标准化里创建
......@@ -302,7 +357,6 @@ export default {
* 动作保存
*/
onActionsSave(actions) {
console.log("动作", actions);
this.curForm.actions = actions;
this.showActions = false;
},
......@@ -606,8 +660,8 @@ export default {
<style lang="scss" scoped>
.airway-edit {
position: absolute;
top: 0px;
width: 351px;
top: 0px;
width: 351px;
z-index: 2;
.dialog-content {
......
......@@ -15,6 +15,16 @@
<el-form-item label="航线名称" required>
<el-input clearable v-model="name"></el-input>
</el-form-item>
<el-form-item label="所属单位:" required>
<el-cascader ref="CascaderRef" v-model="departmentId" :options="orgList" clearable :show-all-levels="false"
placeholder="请选择所属单位" :props="{
children: 'children',
label: 'name',
value: 'id',
checkStrictly: true,
emitPath: false,
}" @change="changeNode"></el-cascader>
</el-form-item>
<el-form-item label="航线速度" prop="speed">
<el-input clearable v-model="curForm.speed"></el-input>
</el-form-item>
......@@ -86,7 +96,7 @@
</template>
<script>
import { Map, AirLine } from "../../../../../../../../../../api";
import { Map, AirLine,TaskInfo } from "../../../../../../../../../../api";
import { mapState } from "vuex";
import Utils from "../../../../../../../../../../components/cesiumLayer/lib/cesium/utils";
import { nanoid } from "nanoid";
......@@ -123,7 +133,9 @@ export default {
inject: ["rootNode"],
data() {
return {
orgList: [],
name: "", //航线名
departmentId:'',//部门id
flightLabel:"",//航线标签
form: [], //表单集合
pageIndex: 0, //当前页码
......@@ -168,6 +180,7 @@ export default {
},
mounted() {
let viewer = this.cesiumViewer;
this.getOrgList();
this.dataSource = new Cesium.CustomDataSource(this.dataSourceName);
viewer.dataSources.add(this.dataSource);
this.handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas); //获取事件对象
......@@ -212,6 +225,53 @@ export default {
this.dataSource.show = false;
},
methods: {
changeNode() {
this.$refs.CascaderRef.dropDownVisible = false;
},
async getOrgList() {
let data = await TaskInfo.listAll();
let res = data.data;
const config = {
id: "id",
parentId: "parentId",
childrenList: "children",
};
const childrenListMap = {};
const nodeIds = {};
const tree = [];
for (const d of res) {
const parentId = d[config.parentId];
if (childrenListMap[parentId] == null) {
childrenListMap[parentId] = [];
}
nodeIds[d[config.id]] = d;
childrenListMap[parentId].push(d);
}
for (const d of res) {
const parentId = d[config.parentId];
if (nodeIds[parentId] == null) {
tree.push(d);
}
}
for (const t of tree) {
adaptToChildrenList(t);
}
function adaptToChildrenList(o) {
if (childrenListMap[o[config.id]] !== null) {
o[config.childrenList] = childrenListMap[o[config.id]];
}
if (o[config.childrenList]) {
for (const c of o[config.childrenList]) {
adaptToChildrenList(c);
}
}
}
this.orgList = tree;
},
async getLabel() {
this.rootNode.$emit("getLabelList", {
callback: (data) => {
......@@ -225,6 +285,10 @@ export default {
this.$message.warning("请输入航线名称");
return;
}
if (!this.departmentId) {
this.$message.warning("请选择所属机构");
return;
}
if (this.form.length === 0) {
this.$message.warning("请点击地图选择航点");
return;
......@@ -269,6 +333,7 @@ export default {
content: waypoints,
distance: this.distance,
dutyOrganizationId: "",
departmentId: this.departmentId, //部门id
name: this.name,
speed: this.form[0].speed,
};
......@@ -277,6 +342,7 @@ export default {
flightName: airway.name || `${this.userInfo.username}-巡查}`,
pointCount: airway.content.length,
distance: airway.distance,
departmentId: airway.departmentId,
sourceType: 1,
linePointSaveReqVOS: airway.content.map((point) => ({
latitude: point.coordinate.latitude,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论