// 系统设置功能 import { addModel, createModel, importModel, modelList, updatePoster, delModel, junbiaoList, checkAuth, userList, userState, delUser, createUser, delRole, roleList, createRole, importPOI, listDepart, delDepart, addDepart, editDepart, uploadExcel, tongbus, addModelType, getModelType, editModelType, delModelType, createGraphLabel, importGraphLabel, addGraphLabel, addJunbiaoType, getGraphLabelType2, editGraphLabelType, delGraphLabelType, delGraphLabels, editGraphLabel, importLuWang, getStatus, add_default, getBatteryInfo, setBattery, projectImport, getIniInfo, } from "../../../../api/gisAPI"; import { getElectronPath, copyContent, getBase64Image, getNamefromPath, setDeepObjectPropertyValue, setProperty, } from "../../../../utils"; import { $removeChanel } from "../../../../utils/communication"; import { getInfo } from "../../../../utils/auth"; import { format } from "date-fns"; import fs from "fs"; import { config } from "process"; const { ipcRenderer } = require("electron"); let Store = require("electron-store"); let store = new Store(); export default { data() { return { sandTable_udp_client_status: true, url: "", junbiaoLoading: false, modelLoading: false, modelTypeList: [], graphLabelTypeList: [], graphLabelProps: { id: "type_id", children: "sonNode", label: "type_name", }, selectedModelType: "", selectedGraphLabelType: null, graphLabelDataMaps: new Map(), exportWin: false, importWin: false, native: { port: null, host: null, }, client: { port: null, host: null, }, headers: { token: "", }, config: {}, }; }, // computed: { // graphLabelTypeListLength() { // return this.graphLabelTypeList.length; // }, // modelTypeListLength() { // return this.modelTypeList.length; // }, // }, created() { this.$sendElectronChanel("getIniConfig"); let url = ""; this.$recvElectronChanel("IniConfig", (e, iniContent) => { url = `http://${iniContent.protocol.host}:${iniContent.protocol.port}`; console.log("---------------", url); this.url = url + "/yjearth4.0/api/v1/auth/import"; }); }, mounted() { this.sandTable_udp_client_status = JSON.parse( localStorage.getItem("sandTable_udp_client_status") ); // this.getGraphList() this.$removeChanel("updatePoster"); this.$recvChanel("updatePoster", (res) => { this.updatePoster1(res.modelInfo, true, res.path); }); // 添加token Admin-Token this.headers.token = localStorage.getItem("Admin-Token"); }, beforeDestroy() { // this.$removeChanel("updatePoster") console.log("system破坏了"); }, watch: { selectedModelType(newValue) { this.modelTypeList.forEach((item) => { if (item.type_id == newValue) this.modelTableData = item.children; }); }, /* selectedGraphLabelType(newValue) { this.graphLabelTypeList.forEach(item => { if (item.type_id == newValue) this.graphTableData = item.children }) }*/ }, methods: { change_sandTable_udp_client_status() { localStorage.setItem( "sandTable_udp_client_status", this.sandTable_udp_client_status ); }, // 获取配置信息 getConfig() { getIniInfo().then((res) => { console.log("resresresresres", res); if (res.code == 0) { this.config = res.data; } }); }, // 进入后台管理 management() { let service = localStorage.getItem("service"); let location = service; console.clear(); window.open(location); //可以了 打包 // if (service) { // window.location = service + "/dist"; // } else { // this.$message.error("请先配置后台服务地址"); // } }, getBattery() { /* getBatteryInfo((res) => { this.showBattery = res.hasOwnProperty("if_read") ? res.if_read : false; }); */ }, batteryChange() { if (!this.showBattery) { clearInterval(window.batteryInterval); let windows = $root_home.$remote.getCurrentWindow(); let title = windows.getTitle(); windows.setTitle(title.split("-")[0]); } localStorage.setItem("batteryStatus", this.showBattery); /* console.log(this.showBattery); setBattery( { if_read: this.showBattery, }, (res) => {} ); */ }, graphLabelClick(data, event) { console.log(data) // if (this.selectedGraphLabelType == data.type_id) { // this.graphTableData = []; // this.$nextTick(() => { // this.$refs.myTree && this.$refs.myTree.setCurrentKey(null); // }); // this.selectedGraphLabelType = null; // } else { // this.selectedGraphLabelType = data.type_id; // this.graphTableData = data.children || []; // } this.graphTableData = [...data.children]; this.graphTableSelectData = data.children; if (data.sonNode.length) { let junbiaos = []; this.selectedGraphLabelType = data.type_id; this.JByuanshishuju.forEach((item) => { if (item.p_id == data.type_id && item.children) junbiaos = junbiaos.concat(item.children); }); this.graphTableData.push(...junbiaos); } }, tongbu() { tongbus((res) => { this.$sendChanel("renderNode"); }); }, close() { this.$changeComponentShow("#modal", false); }, submitForm(formName) { this.$refs[formName].validate((valid) => { if (valid) { /* if (formName.indexOf("Role") > -1) { createRole(this.formRole, res => { this.dialogRoleFormVisible = false this.getRoleList() this.resetForm(formName) }) } else { */ console.log(this.userTableData); this.form.depart_id = this.node.depart_id; createUser(this.form, (res) => { this.dialogFormVisible = false; this.getUserList(this.node.depart_id); this.resetForm(formName); }); // } } else { console.log("error submit!!"); return false; } }); }, resetForm(formName) { this.$refs[formName].resetFields(); }, rowClick(row, column, event) { console.log(row); }, dblClick(row, column, event) { console.log(row); let option = { url: row.url, name: row.name, length: 160, }; /* if (row.detail) Object.assign(option, JSON.parse(row.detail)) if (_groundImageOnEarthMap.get(row.jun_biao_id)) { _groundImageOnEarthMap.get(row.jun_biao_id).flyTo() } else { console.log("添加", option) $treeMethods.addGroundImages(option, (arg) => { console.log(arg) if (!option.center) { this.center = arg this.selectedJunBiao = row this.endEditing() } else { _groundImageOnEarthMap.set(row.jun_biao_id, arg) } /!*let obj = new window.JunBiao(window.sdk.earth,) if (row.detail) { obj = new window.JunBiao(window.sdk.earth, row.detail) } _groundImageMap.set(row.jun_biao_id, obj)*!/ }) }*/ }, //打开系统设置框时,获取数据 getData() { this.getConfig(); this.getModelTypeList(); // 标准版本husju this.getGraphLabelTypeList(); //军标树 // this.getModelList(); this.getAuth(); // this.getUserList(); // this.getRoleList(); // this.getDepartlist(); // 标准版本 // this.getSatellite(); // 电池 // this.getBattery(); this.native.port = this.getPort(); this.native.host = this.getHostIP(); this.client.port = store.get("sandTable_udp_client_port"); this.client.host = store.get("sandTable_udp_client_host"); }, //保存对方地址 submitClient() { if (this.client.host && this.client.port) { store.set("sandTable_udp_client_port", this.client.port); store.set("sandTable_udp_client_host", this.client.host); this.$message.success("操作成功"); } }, //保存本机端口 submitPort() { ipcRenderer.send("submitPort", this.native.port); ipcRenderer.once("submitPortRes", (event, op) => { this.$message.success("操作成功"); }); }, getPort() { let Store = require("electron-store"); let store = new Store(); return store.get("sandTable_udp_server_port"); }, getHostIP() { const os = require("os"); const interfaces = os.networkInterfaces(); let hostIP = ""; for (const networkInterface in interfaces) { const iface = interfaces[networkInterface]; for (let i = 0; i < iface.length; i++) { const { address, family, internal } = iface[i]; if (family === "IPv4" && !internal) { hostIP = address; break; } } if (hostIP) { break; } } return hostIP; }, //获取模型列表 getModelList() { if (!["", null, "null"].includes(this.modelLibPath)) this.initModelData(this.modelLibPath); }, //获取卫星连接信息 getSatellite() { getStatus((res) => { console.log("111111111111", res); }); }, // selectModelType(){}, //获取模型类型列表 getModelTypeList() { getModelType((res) => { console.log("", res); this.modelTypeList = res.list; setTimeout(() => { this.modelLoading = false; }); this.selectedModelType = res.list.length ? res.list[0].type_id : ""; this.modelTableData = res.list.length ? res.list[0].children : []; // this.modelTotal = res.total.list[0].length }); }, //编辑模型类型 editModelTypes() { if (!this.selectedModel) { this.$message.warning("请选择模型节点!"); return; } let type_id = this.selectedModel.type_id, type_name = this.selectedModel.type_name; this.$prompt("请输入模型类型", "修改模型类型", { confirmButtonText: "确定", cancelButtonText: "取消", inputValidator: (value) => { // 验证规则:不能为空(不能是纯空白字符),其他内容都允许 return /.*\S+.*/.test(value); }, inputErrorMessage: '请输入模型类型', inputValue: type_name, }) .then(({ value }) => { editModelType({ type_name: value, type_id }, (res) => { this.modelTypeList.forEach((item) => { if (item.type_id == type_id) { item.type_name = value; } }); }); }) .catch(() => { /*this.$message({ type: 'info', message: '取消输入' });*/ }); }, //删除模型类型 delModelTypes() { if (!this.selectedModel) { this.$message.warning("请选择模型节点!"); return; } let type_id = this.selectedModel.type_id; this.$confirm("此操作会删除该类型及其对应的模型,是否继续?", "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then((res) => { delModelType({ type_id }, (res) => { this.modelTypeList = this.modelTypeList.filter( (item) => item.type_id !== type_id ); this.modelTableData = []; // if (this.selectedGraphLabelType == type_id) { // this.selectedGraphLabelType = ""; // this.modelTableData = []; // } }); /* this.modelTypeList.forEach((item, index) => { if (item.type_id == type_id) { this.modelTypeList.splice(index, 1) } })*/ }) .catch(() => {}); }, //获取军标类型列表 getGraphLabelTypeList() { this.graphLabelDataMaps.clear(); this.graphLabelTypeList = []; this.graphTableData = []; this.graphTableSelectData = []; this.JByuanshishuju = []; getGraphLabelType2((res) => { console.log("", res); setTimeout(() => { this.junbiaoLoading = false; }, 1500); if (res.list.length) { this.JByuanshishuju = res.list; console.log("this.graphLabelDataMaps", this.graphLabelDataMaps); res.list.forEach((item) => { item.sonNode = []; if (!this.graphLabelDataMaps.has(item.p_id)) this.graphLabelDataMaps.set(item.p_id, []); let arr = this.graphLabelDataMaps.get(item.p_id); arr.push(item); this.graphLabelDataMaps.set(item.p_id, arr); }); console.log("this.graphLabelDataMaps", this.graphLabelDataMaps); if (this.graphLabelDataMaps.get("-1")) { this.graphLabelTypeList = this.graphLabelDataMaps.get("-1"); } let appendsonNode = (arr) => { arr.forEach((item) => { if (this.graphLabelDataMaps.has(item.type_id)) { item.sonNode = this.graphLabelDataMaps.get(item.type_id); this.graphLabelDataMaps.delete(item.type_id); } if (item.sonNode && item.sonNode.length) { appendsonNode(item.sonNode); } }); }; appendsonNode(this.graphLabelTypeList); /* this.graphLabelTypeList.forEach(item => { if (this.graphLabelDataMaps.has(item.type_id)) { item.sonNode = this.graphLabelDataMaps.get(item.type_id) } })*/ console.log( "this.graphLabelTypeList之后的array", this.graphLabelTypeList ); if (this.graphLabelTypeList > 0) { this.selectedGraphLabelType = this.graphLabelTypeList[0].type_id; // this.selectedGraphLabelType = res.list[0].type_id .sonNode[0] this.graphTableData = this.graphLabelTypeList[0].sonNode[0].children; // this.modelTotal = res.total.list[0].length console.log("this.graphTableData", this.graphTableData); setTimeout(() => { this.$nextTick(() => { this.$refs.myTree && this.$refs.myTree.setCurrentKey( this.graphLabelTypeList[0].type_id ); }); }, 1500); } } }); }, io(dataArr, value) {}, editGraphLabelTypes() { console.log(123); let node = this.$refs.myTree.getCurrentNode(); if (node && node.type_id) { let { type_id, p_id, sonNode, type_name } = node; this.$prompt("", "修改军标类型", { confirmButtonText: "确定", cancelButtonText: "取消", inputValue: type_name, inputPattern: /^[^\s]+$/, inputErrorMessage: "内容不能为空", }) .then(({ value }) => { if (value !== "") { // 输入不为空,处理确认逻辑 editGraphLabelType({ type_name: value, type_id }, (res) => { this.$refs.myTree.getCurrentNode().type_name = value; }); } else { this.$message.error("内容不能为空"); } }) .catch(() => { /*this.$message({ type: 'info', message: '取消输入' });*/ }); } else { this.$message.warning("请先选择军标类型"); } }, delGraphLabelTypes() { let node = this.$refs.myTree.getCurrentNode(); console.log(node); let { type_id, p_id, sonNode } = node; if (sonNode && sonNode.length) { this.$message.warning("该类型存在子类型,无法删除"); } else { this.$confirm("此操作会删除该类型及其对应的军标,是否继续?", "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then((res) => { delGraphLabelType({ type_id }, (res) => { if (p_id == "-1") this.graphLabelTypeList = this.graphLabelTypeList.filter( (item) => item.type_id !== type_id ); else { this.$refs.myTree.remove(node); } if (this.selectedGraphLabelType == type_id) { this.selectedGraphLabelType = ""; this.graphTableData = []; } }); /* this.modelTypeList.forEach((item, index) => { if (item.type_id == type_id) { this.modelTypeList.splice(index, 1) } })*/ }) .catch(() => {}); } }, delGraphLabel(jun_biao_id) { console.log(this.graphLabelTypeList); let msg = "确定删除?"; this.$confirm(msg, "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then((res) => { delGraphLabels({ jun_biao_id }, (res) => { //刷新当前页 // this.pageModelList(); this.getGraphLabelTypeList(); this.graphTableData = this.graphTableData.filter( (item) => item.jun_biao_id !== jun_biao_id ); }); }) .catch(() => {}); }, editGraphLabel(row) { // editGraphLabel() this.$prompt("", "修改军标", { confirmButtonText: "确定", cancelButtonText: "取消", inputValidator: (value) => { // 验证规则:不能为空(不能是纯空白字符),其他内容都允许 return /.*\S+.*/.test(value); }, inputErrorMessage: '内容不能为空', inputValue: row.name, }) .then(({ value }) => { editGraphLabel( { name: value, jun_biao_id: row.jun_biao_id }, (res) => { row.name = value; // this.$refs.myTree.getCurrentNode().type_name = value } ); }) .catch(() => { /*this.$message({ type: 'info', message: '取消输入' });*/ }); }, //获取角色列表 getRoleList() { roleList( (res) => { console.log("userList##############", res); this.roleTableData = res.list; this.roleTotal = res.total; }, { page: this.roleListPage, page_size: this.roleListPageSize } ); }, //创建角色 createRole() { this.$prompt("请输入角色名称", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", inputPattern: /^[\u4E00-\u9FA5A-Za-z0-9]{2,32}$/, inputErrorMessage: "角色名称(长度为2~32)", }) .then(({ value }) => { createRole({ role_name: value }, () => { this.getRoleList(); }); }) .catch(() => { this.$message({ type: "info", message: "取消输入", }); }); // this.dialogRoleFormVisible = true // this.$changeComponentShow("#modal", true, "z-index:12") }, delRole(role_id) { let msg = "确定删除?"; this.$confirm(msg, "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then((res) => { delRole({ role_id }, (res) => { //刷新当前页 this.getRoleList(); }); }) .catch(() => {}); }, handleRoleSizeChange(val) { this.roleListPageSize = val; this.getRoleList(); }, handleRoleCurrentChange(val) { this.roleListPage = val; this.getRoleList(); }, //获取用户列表 getUserList(depart_id) { userList( (res) => { console.log("userList##############", res.list); this.userTableData = res.list; this.userTotal = res.total; }, { page: this.userListPage, page_size: this.userListPageSize, depart_id } ); }, importUser() { console.log(this.node); let option = { properties: ["openFile"], filters: [ { name: "用户数据表", //、底图 extensions: ["xlsx" /*"json"*/], }, ], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { console.log(paths); }); }, onExcelSuccess(response, file, fileList) { console.log(response); console.log(file); console.log(fileList); }, httpRequest(param) { // baseURL+'/yjearth4.0/api/v1/user/import' const formData = new FormData(); // 将文件添加到 FormData 中 formData.append("file", param.file); formData.append("depart_id", this.node.depart_id); //接口方法,请替换成实际的方法和返回的值 uploadExcel(formData, (res) => { console.log(res); }); // 返回的文件也可以加在请求方法之后 }, //创建用户 createUser() { this.dialogFormVisible = true; this.$changeComponentShow("#modal", true, "z-index:12"); }, delUser({ username, depart_id }) { let msg = "确定删除?"; this.$confirm(msg, "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then((res) => { delUser({ username }, (res) => { //刷新当前页 this.getUserList(depart_id); }); }) .catch(() => {}); }, //获取部门列表 getDepartlist() { listDepart().then((res) => { this.departData = res.data.list; if (!this.node) { this.node = this.departData[0]; this.getUserList(this.departData[0].depart_id); this.$nextTick(() => { // 等待挂载完成再进行下面这行代码 // this.$refs.departTree.setCurrentKey(this.departData[0].depart_id) }); } }); }, //懒加载部门树 loadNode(node, resolve) { console.log("11111111111111111111", node, resolve); // return; if (node.level === 0) { return resolve([{ name: "region" }]); } // if (node.level > 1) return resolve([]); setTimeout(() => { listDepart({ depart_id: node.data.depart_id }).then((res) => { if (res.code == 0) { resolve(res.data.list); } }); }, 500); }, //点击部门,获取用户 departChange(e) { this.node = e; console.log("node", this.node); this.getUserList(e.depart_id); }, //创建部门 createDepart() { console.log(this.node); this.$prompt("请输入部门名称", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", inputPattern: /^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]{3,64}$/, inputErrorMessage: "请输入3-64位", }) .then(({ value }) => { addDepart( { depart_name: value, p_id: this.node.depart_id }, (data) => { this.$refs.departTree.append(data, data.p_id); this.getUserList(this.departData[0].depart_id); } ); }) .catch(() => { this.$message({ type: "info", message: "取消输入", }); }); }, //删除部门 deleteDepart() { this.$confirm( "此操作将永久删除部门:" + this.node.depart_name + ", 是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", } ) .then(() => { delDepart({ depart_id: this.node.depart_id }, () => { this.$refs.departTree.remove(this.node); this.node = this.departData[0]; this.getUserList(this.departData[0].depart_id); this.$nextTick(() => { // 等待挂载完成再进行下面这行代码 // this.$refs.departTree.setCurrentKey(this.departData[0].depart_id) }); }); }) .catch(() => { this.$message({ type: "info", message: "已取消删除", }); }); }, //修改部门 editDepart() { this.$prompt("修改部门名称", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", inputValue: this.node.depart_name, inputPattern: /^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]{3,64}$/, inputErrorMessage: "请输入3-64位", closeOnClickModal: false, }) .then(({ value }) => { editDepart( { depart_id: this.node.depart_id, p_id: this.node.p_id, depart_name: value, }, (res) => { if (res != "error") { this.$refs.departTree.getCurrentNode().depart_name = value; } // this.$refs.departTree.insertBefore(node, this.node) // this.$refs.departTree.remove(this.node) } ); }) .catch(() => { this.$message({ type: "info", message: "取消输入", }); }); }, isEnable(scope) { return ( scope.row.username == "admin" || scope.row.username == getInfo().username ); }, //设置用户账户可用性 changeEnable(e, checked, row) { console.log("changeEnable", e); console.log("changeEnable", row); console.log("changeEnable", checked); // console.log(event.srcElement.checked) console.log("++++++++++++++++++++++="); e.preventDefault(); // console.log(event.srcElement.checked) //? userState( { username: row.username, status: row.enable ? 0 : 1 }, (res) => { console.log(")))))))))))))))"); console.log(res); if (res == null) { // row.enable=row.enable row.enable = !row.enable; // event.p } // if(res.code) } ); }, handleUserSizeChange(val) { this.userListPageSize = val; this.getUserList(this.node.depart_id); }, handleUserCurrentChange(val) { this.userListPage = val; this.getUserList(this.node.depart_id); }, getGraphList() { junbiaoList( { page: this.graphListPage, page_size: this.graphListPageSize, }, (res) => { console.log("getGraphList", res); this.graphTotal = res.total; this.graphTableData = res.list; } ); }, getAuth() { this.$sendElectronChanel("getIniConfig"); this.$recvElectronChanel("IniConfig", (e, iniContent) => { console.log("iniContent", iniContent); let url = `http://${iniContent.protocol.host}:${iniContent.protocol.port}`; checkAuth(url, (res) => { console.log(res, "res111111111111111111111111111111111"); window.checkAuthIsValid = res.is_valid; this.authInfo = res; }); }); }, delModel(model_id) { let msg = "确定删除?"; this.$confirm(msg, "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then((res) => { delModel({ model_id }, (res) => { //刷新当前页 this.modelTableData = this.modelTableData.filter( (item) => item.model_id !== model_id ); this.getModelTypeList(); }); }) .catch(() => {}); }, preview(row) { this.$changeComponentShow("#scene", true); this.$sendChanel("openView3d", row); }, selectModel(item) { this.selectedModelType = item.type_id; this.selectedModel = item; }, updatePoster1(row, flag = false, path = "") { let that = this; console.log("row++++++++++++++++++++++"); console.log(path); console.log(row); let cb = (c) => { let formData = new FormData(); formData.append("model_id", row.model_id); formData.append("file", c); updatePoster(formData) .then((res) => { if ([0, 200].includes(res.code)) { that.$message({ type: "success", message: "更新成功", }); row.poster_url = ""; console.log("row.poster_url", res.data.url); this.$nextTick(() => { row.poster_url = res.data.url + "?" + Math.random(); }); this.$sendChanel("updatePosterComplete", res); } }) .catch((err) => { console.log(err); this.$sendChanel("updatePosterComplete", err); }); }; if (!flag) { let option = { properties: ["openFile"], filters: [ { name: "图片", extensions: ["png", "jpg", "jpeg"], }, ], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (paths.length) { console.log(paths[0]); // 取出路径中的文件名 let name = getNamefromPath(paths[0]); // 读取文件 fs.readFile(paths[0], (err, data) => { const blob = new Blob([data], { type: "image/png, image/jpeg, image/jpg", }); var file = new File([blob], `${name}` + ".png"); cb(file); }); // cb(paths[0]); } }); } else { cb(path); } }, handleSizeChange(val) { this.modelListPageSize = val; this.pageModelList(); }, handleCurrentChange(val) { this.modelListPage = val; this.pageModelList(); }, //选择库文件 selectLib(suffix) { let name = "模型库"; if (suffix == "junbiao") name = "军标库"; let option = { properties: ["openFile"], filters: [ { name, //、底图 extensions: [suffix], }, ], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, path) => { if (path.length) this.initModelData(suffix, path[0]); }); }, addModelType() { /**/ this.$prompt("请输入模型类型", "添加模型类型", { confirmButtonText: "确定", inputPattern: /^[^\s]+$/, inputErrorMessage: "请输入非空字符串", cancelButtonText: "取消", }) .then(({ value }) => { addModelType({ type_name: value }, (res) => { console.log(res); this.modelTypeList.push({ type_name: value, type_id: res.type_id, children: [], }); }); }) .catch(() => { /*this.$message({ type: 'info', message: '取消输入' });*/ }); }, addModel() { // addModel() // 需获取模型列表后,并选中一项后 if (this.selectedModelType) { let option = { properties: ["openFile", "multiSelections"], filters: [ { name: "人工模型", extensions: ["glb", "gltf"], }, ], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (paths.length) { addModel( { model_paths: paths, p_id: this.selectedModelType }, (res) => { console.log(res); /* // this.pageModelList() let arr = [] paths.forEach(item => { arr.push({ // model_id: }) })*/ // this.modelTableData = this.modelTableData.concat(res.list) this.getModelTypeList(); } ); } }); } else this.$message.warning("请选择一项类型"); }, pageModelList() { modelList( (res) => { console.log("modelList##############", res); this.modelTableData = res.list; this.modelTotal = res.total; }, { page: this.modelListPage, page_size: this.modelListPageSize } ); }, initModelData(suffix, path) { if (suffix == "model") { this.modelLoading = true; importModel({ model_lib_path: path }, (res) => { this.$store.dispatch("changeModelLibPath", path); this.getModelTypeList(); //导入模型库后,需存在模型类型列表,并有选中项,才获取对应的 // this.pageModelList() }); } else { this.junbiaoLoading = true; this.selectedGraphLabelType = null; importGraphLabel({ junbiao_lib_path: path }, (res) => { this.$store.dispatch("changeGraphLabelLibPath", path); this.getGraphLabelTypeList(); //导入模型库后,需存在模型类型列表,并有选中项,才获取对应的 // this.pageModelList() }); //初始化军标库 } }, // 创建库文件 createLib(key) { let obj = { model: { title: "创建模型库", filename: "YJEarth.model", extensions: ["model"], }, graphLabel: { title: "创建军标库", filename: "YJEarth.junbiao", extensions: ["junbiao"], }, }; let { title, filename, extensions } = obj[key]; let option = { title, filename, filters: [{ name: "保存库文件", extensions }], }; this.$sendElectronChanel("saveFile", option); this.$recvElectronChanel("selectedFileItem", (e, path) => { console.log(path); if (path) { let index = path.lastIndexOf("/"); let model_lib_path = path.slice(0, index); let model_lib_name = path.slice(index + 1); if (key == "model") createModel({ model_lib_name, model_lib_path }, (res) => { this.initModelData(key, path); }); else createGraphLabel( { junbiao_lib_name: model_lib_name, junbiao_lib_path: model_lib_path, }, (res) => { this.initModelData(key, path); } ); // this.initModelData(key, path); } }); }, addGraphLabel() { let _that = this; if (this.selectedGraphLabelType) { let option = { properties: ["openFile", "multiSelections"], filters: [ { name: "军标", extensions: ["svg"], }, ], }; let imgArr = []; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (paths.length) { paths.forEach((item) => { getBase64Image(item).then((base64) => { let params = { name: getNamefromPath(item), p_id: this.selectedGraphLabelType, data: base64, }; // console.log("paramsparamsparams", params); // imgArr.push(params); // console.log("imgArrimgArrimgArrimgArr", imgArr); addGraphLabel(params, (res) => { // console.log(res); // this.pageModelList() let obj = { name: res.name, url: res.url, p_id: res.p_id, jun_biao_id: res.jun_biao_id, }; _that.graphTableData.push(obj); setProperty( this.graphLabelTypeList, "sonNode", "type_id", obj.p_id, "children", [..._that.graphTableSelectData, obj], "assign" ); }); }); }); } }); } else this.$message.warning("请选择一项类型"); }, addGraphLabelType() { this.$prompt("请输入军标类型", "添加军标类型", { confirmButtonText: "确定", inputPattern: /^[^\s]+$/, inputErrorMessage: "请输入非空字符串", cancelButtonText: "取消", }) .then(({ value }) => { let params = { type_name: value, p_id: this.selectedGraphLabelType || -1, }; addJunbiaoType(params, (res) => { let obj = { type_name: value, type_id: res.type_id, p_id: res.p_id, sonNode: [], children: [], }; if (params.p_id != -1) { console.log(this.$refs.myTree); this.$refs.myTree.append(obj, params.p_id); /*setDeepObjectPropertyValue() this.graphLabelTypeList.forEach()*/ // setProperty(this.graphLabelTypeList, 'sonNode', 'type_id', params.p_id, 'sonNode', obj, 'assign') } else this.graphLabelTypeList.push(obj); console.log("utils.js795", this.graphLabelTypeList); }); }) .catch(() => { /*this.$message({ type: 'info', message: '取消输入' });*/ }); }, coordinateChange() {}, sysChange() { this.$store.dispatch("changeSystem", this.systemSetting); let span = document.querySelectorAll(".cc span:first-child"); console.log(span); console.log("this.systemSetting", this.systemSetting); if (this.systemSetting.sheetIndexStatusSwitch) { this.$changeComponentShow(".tufuSelect", true); } else { this.$changeComponentShow(".tufuSelect", false); } if (this.systemSetting.language == "en") { // 找到到类名为cc下面的第一个所有的第一个span span.forEach((item) => { item.style.flex = 1; }); } else { // 删除style中的flex属性 span.forEach((item) => { item.style.flex = "unset"; }); } }, setView() { let msg = "操作成功"; // try { // localStorage.setItem("defaultView", JSON.stringify(YJ.Global.getCurrentView())) let view = YJ.Global.getCurrentView(window.Earth1); const options = { destination: view.position, orientation: view.orientation, }; YJ.Global.setDefaultView(window.Earth1, options); localStorage.setItem("defaultView", JSON.stringify(options)); this.$message.success(msg); }, // 设置默认数据 setData() { add_default({}, (res) => { if (res == null) { this.$message.success("添加完成,2秒后,将重启系统"); setTimeout(() => { window.clicknum = 0; this.$sendElectronChanel("restart"); }, 2000); } }); }, // 授权 uploadUrl() { return this.url; }, onSuccess() { //授权文件导入成功 this.$message.success("导入完成,2秒后,将重启系统"); setTimeout(() => { this.$sendElectronChanel("restart"); }, 2000); }, onFileSubmit() { //授权确认 }, //服务接入 onService(index) { //点击切换服务 this.select_id = index; this.disabled = true; if (index === 3) { //弹出自定义弹框 this.disabled = false; } }, onServiceSubmit() { //服务接入提交确认 console.log("服务接入提交确认"); }, // 海康平台确认 onSubmitInfo() {}, //主题信息提交 onThemeSubmit() {}, copy(e) { console.log("111111111111"); console.log(copyContent(e.target.textContent)); if (copyContent(this.authInfo.license_code)) { this.$message.success("复制成功"); } }, //导入poi importpoi() { let option = { properties: ["openFile"], filters: [ { name: "poi数据", //、底图 extensions: ["poi", "csv"], }, ], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (!paths.length) { return; } importPOI({ path: paths[0] }, (res) => {}); }); }, importLuWang() { let option = { properties: ["openFile"], filters: [ { name: "路网", //、底图 extensions: ["pbf"], }, ], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (!paths.length) { return; } importLuWang({ filePath: paths[0] }, (res) => {}); }); }, // 工程导入(接口) importProjectApi(type) { if (!this.importWin) { this.importWin = true; let option = { properties: ["openFile"], filters: [{ name: "工程包", extensions: ["zip"] }], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (paths.length > 0) { // 取出路径中的文件名 let name = getNamefromPath(paths[0]); // 读取文件 fs.readFile(paths[0], (err, data) => { const blob = new Blob([data], { type: "application/zip", }); var file = new File([blob], `${name}` + ".zip"); let formData = new FormData(); formData.append("file", file); formData.append("type", type); let loadingInstance = this.$openLoading("拼命导入中..."); projectImport(formData).then((res) => { loadingInstance.close(); this.importWin = false; this.$message.success("导入成功"); setTimeout(() => { this.$message.success("载入成功,将在2s后自动重启"); }, 1000); setTimeout(() => { this.$sendElectronChanel("restart"); }, 3000); }); }); } else { this.importWin = false; } }); } }, //工程导入(单机) importProject() { if (!this.importWin) { this.importWin = true; let option = { properties: ["openFile"], filters: [{ name: "工程包", extensions: ["zip"] }], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (paths.length > 0) { let loadingInstance = this.$openLoading("拼命导入中..."); this.importWin = false; let arr = getElectronPath() .replaceAll("\\", "/") .split("/"); arr.pop(); this.$unzip_file(paths[0], arr.join("/")) .then((res) => { loadingInstance.close(); this.$message.success("导入成功"); setTimeout(() => { this.$message.success("载入成功,将在2s后自动重启"); }, 1000); setTimeout(() => { this.$sendElectronChanel("restart"); }, 3000); }) .catch((err) => { console.log(err); }); } else { this.importWin = false; } }); } }, // 合并导入 mergeProject() { if (!this.importWin) { this.importWin = true; let option = { properties: ["openFile"], filters: [{ name: "工程包", extensions: ["zip"] }], }; this.$sendElectronChanel("open-directory-dialog", option); this.$recvElectronChanel("selectedItem", (e, paths) => { if (paths.length > 0) { // 取出路径中的文件名 let name = getNamefromPath(paths[0]); // 读取文件 fs.readFile(paths[0], (err, data) => { const blob = new Blob([data], { type: "application/zip", }); var file = new File([blob], `${name}` + ".zip"); let formData = new FormData(); formData.append("file", file); formData.append("type", type); let loadingInstance = this.$openLoading("拼命导入中..."); projectImport(formData).then((res) => { loadingInstance.close(); this.importWin = false; this.$message.success("导入成功"); setTimeout(() => { this.$message.success("载入成功,将在2s后自动重启"); }, 1000); setTimeout(() => { this.$sendElectronChanel("restart"); }, 3000); }); }); } else { this.importWin = false; } }); } }, //工程导出 derive() { if (!this.exportWin) { this.exportWin = !this.exportWin; const date = new Date(); const formattedDate = format(date, "yyyyMMdd HHmmss"); this.$remote.dialog .showSaveDialog({ title: "请选择要保存的文件名", buttonLabel: "保存", defaultPath: `工程${formattedDate}.zip`, filters: [{ name: "文件类型", extensions: ["zip"] }], }) .then((result) => { if (result.canceled) { this.exportWin = !this.exportWin; return; } let loadingInstance = this.$openLoading("拼命导出中..."); this.exportWin = !this.exportWin; let arr = getElectronPath() .replaceAll("\\", "/") .split("/"); arr[arr.length - 1] = "database.ydb"; let db_path = arr.join("/"); this.$zip_file([db_path], result.filePath, () => { loadingInstance.close(); this.$message.success("导出完成"); }); }) .catch((err) => { console.log(err); }); } }, //打开用户抽屉 userPermission(row) { this.getRoleList(); this.$sendChanel("drawer", { row, data: this.roleTableData, drawer: true, type: "user", }); this.$changeComponentShow("#modal", true); }, //打开角色抽屉 rolePermission(id) { this.$sendChanel("drawer", { id, drawer: true, type: "role" }); this.$changeComponentShow("#modal", true); }, }, };