提交 7867144a 作者: 温凯

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

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