collaborativeCreate_CL.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <template>
  2. <div>
  3. <div class="w-full p-4" style="background-color: #162d55">
  4. <!-- 顶部信息栏 -->
  5. <div class="flex justify-end items-center text-sm text-blue-200">
  6. <span class="flex flex-1 text-2xl font-bold">
  7. 测量装备布设⽅案编制
  8. </span>
  9. <span class="mr-4">任务编号: TASK-2024-001</span>
  10. <span class="mr-4">任务名称: 综合试验任务</span>
  11. <span>当前状态: 方案编制中</span>
  12. </div>
  13. </div>
  14. <div class="bb-layout-page text-white min-h-screen p-4">
  15. <div class="flex gap-4">
  16. <!-- 左侧侧边栏 -->
  17. <div class="relative max-w-md mx-auto p-6 bg-gray-400 bg-opacity-20 backdrop-blur-lg border-gray-50 rounded-xl">
  18. <div class="flex items-center border-blue-400 border-b mb-4">
  19. <h3 class="text-lg font-bold" style="color: #4fc2f7">任务信息</h3>
  20. </div>
  21. <div class="p-4 mb-4 bg-black bg-opacity-20 rounded-md">
  22. <el-card shadow="hover" class="p-3 mb-2 text-white bg-gray-100 bg-opacity-20 border-l-8 border-blue-400">
  23. <div class="flex justify-between items-center mb-2">
  24. <span class="text-blue-300 font-blod">任务名称</span>
  25. </div>
  26. <div class="flex text-sm mt-2">
  27. <span>{{ planInfo.taskName }}</span>
  28. </div>
  29. </el-card>
  30. <el-card shadow="hover" class="p-3 mb-2 text-white bg-gray-100 bg-opacity-20 border-l-8 border-blue-400">
  31. <div class="flex justify-between items-center mb-2">
  32. <span class="text-blue-300 font-blod">任务类型</span>
  33. </div>
  34. <div class="flex text-sm mt-2">
  35. <span>{{ $getDictNameByValue('task_type',planInfo.taskType+'') || "-" }}</span>
  36. </div>
  37. </el-card>
  38. <el-card shadow="hover" class="p-3 mb-2 text-white bg-gray-100 bg-opacity-20 border-l-8 border-blue-400">
  39. <div class="flex justify-between items-center mb-2">
  40. <span class="text-blue-300 font-blod">布设算法</span>
  41. </div>
  42. <div class="flex text-sm mt-2">
  43. <span>{{ activeTab }}</span>
  44. </div>
  45. </el-card>
  46. <el-card shadow="hover" class="p-3 text-white bg-gray-100 bg-opacity-20 border-l-8 border-blue-400">
  47. <div class="flex justify-between items-center mb-2">
  48. <span class="text-blue-300 font-blod">设备数量</span>
  49. </div>
  50. <div class="flex text-sm mt-2">
  51. <span>{{ algorithmParams.eqNumber1 }}</span>
  52. </div>
  53. </el-card>
  54. </div>
  55. <!-- 方案模板 -->
  56. <div class="flex items-center border-blue-400 border-b mb-4">
  57. <h3 class="text-lg font-bold" style="color: #4fc2f7">方案模板</h3>
  58. </div>
  59. <!-- 搜索栏 -->
  60. <div class="mb-4">
  61. <el-input
  62. v-model="templateSearch"
  63. placeholder="搜索模板..."
  64. prefix-icon="el-icon-search"
  65. size="small"
  66. class="bg-gray-800 bg-opacity-50 border-gray-600 text-white"
  67. ></el-input>
  68. </div>
  69. <!-- 模板表格 -->
  70. <el-table
  71. :data="filteredTemplates"
  72. border
  73. size="small"
  74. highlight-current-row
  75. @row-click="selectTemplate"
  76. class="mb-4 bg-gray-800 bg-opacity-30 border-gray-600"
  77. >
  78. <el-table-column
  79. prop="name"
  80. label="模板名称"
  81. width="140"
  82. show-overflow-tooltip
  83. >
  84. </el-table-column>
  85. <el-table-column
  86. prop="description"
  87. show-overflow-tooltip
  88. label="描述">
  89. </el-table-column>
  90. <el-table-column label="操作" width="80" align="center">
  91. <template #default="scope">
  92. <!-- 使用按钮 -->
  93. <el-button
  94. type="success"
  95. size="small"
  96. @click="handleUse(scope.row)"
  97. >
  98. 应用
  99. </el-button>
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. <!--<div-->
  104. <!-- class="flex flex-col p-4 mb-4 align-center justify-center rounded-md bg-gray-400 bg-opacity-30 border-none cursor-pointer hover:bg-opacity-40 transition-all">-->
  105. <!-- <span class="flex justify-center mb-2 text-lg font-bold">标准模板</span>-->
  106. <!-- <span class="flex justify-center text-sm">常用于常规试验</span>-->
  107. <!--</div>-->
  108. <!--<div-->
  109. <!-- class="flex flex-col p-4 mb-4 align-center justify-center rounded-md bg-gray-400 bg-opacity-30 border-none cursor-pointer hover:bg-opacity-40 transition-all">-->
  110. <!-- <span class="flex justify-center mb-2 text-lg font-bold">高密度模板</span>-->
  111. <!-- <span class="flex justify-center text-sm">常用于密集目标</span>-->
  112. <!--</div>-->
  113. <!--<div-->
  114. <!-- class="flex flex-col p-4 mb-4 align-center justify-center rounded-md bg-gray-400 bg-opacity-30 border-none cursor-pointer hover:bg-opacity-40 transition-all">-->
  115. <!-- <span class="flex justify-center mb-2 text-lg font-bold">分散式模板</span>-->
  116. <!-- <span class="flex justify-center text-sm">常用于分散目标</span>-->
  117. <!--</div>-->
  118. <!--<div class="flex flex-col p-4 mb-4 align-center justify-center rounded-md bg-gray-400 bg-opacity-30 border-none cursor-pointer hover:bg-opacity-40 transition-all">-->
  119. <!-- <span class="flex justify-center mb-2 text-lg font-bold">自定义模板</span>-->
  120. <!-- <span class="flex justify-center text-sm">手动配置参数</span>-->
  121. <!--</div>-->
  122. <!-- 布设算法 -->
  123. <div class="flex items-center border-blue-400 border-b mb-4">
  124. <h3 class="text-lg font-bold" style="color: #4fc2f7">布设算法</h3>
  125. </div>
  126. <el-tabs type="card" stretch v-model="activeTab" class="mb-6">
  127. <el-tab-pane label="随机布设" name="随机布设">
  128. <div class="bg-gray-400 bg-opacity-30 p-4 rounded">
  129. <h2 class="text-lg font-semibold mb-4">随机布设参数</h2>
  130. <el-form :model="algorithmParams" :disabled="!isEdit" label-width="120px">
  131. <el-form-item label="随机种子">
  132. <el-input v-model="algorithmParams.randomSeed" placeholder="请输入随机种子"></el-input>
  133. </el-form-item>
  134. <el-form-item label="布设密度">
  135. <el-select v-model="algorithmParams.layoutDensity" placeholder="请选择布设密度">
  136. <el-option label="低等密度" value="low"></el-option>
  137. <el-option label="中等密度" value="medium"></el-option>
  138. <el-option label="高等密度" value="high"></el-option>
  139. </el-select>
  140. </el-form-item>
  141. <el-form-item label="最小间距(m)">
  142. <el-input v-model.number="algorithmParams.minSpacing1" placeholder="请输入最小间距"></el-input>
  143. </el-form-item>
  144. <div style="border-top: 1px solid #737877;margin-bottom: 10px"></div>
  145. <el-form-item label="装备数量">
  146. <el-input v-model.number="algorithmParams.eqNumber1"></el-input>
  147. </el-form-item>
  148. <el-form-item label="装备类型">
  149. <el-input v-model="algorithmParams.eqType1"></el-input>
  150. </el-form-item>
  151. </el-form>
  152. </div>
  153. </el-tab-pane>
  154. <el-tab-pane label="网格布设" name="网格布设">
  155. <div class="bg-gray-400 bg-opacity-30 p-4 rounded">
  156. <h2 class="text-lg font-semibold mb-4">网格布设参数</h2>
  157. <!-- 可根据需求添加网格布设相关表单元素 -->
  158. <el-form :model="algorithmParams" :disabled="!isEdit" label-width="120px">
  159. <el-form-item label="布设密度">
  160. <el-select v-model="algorithmParams.layoutDensity2" placeholder="请选择布设密度">
  161. <el-option label="低等密度" value="low"></el-option>
  162. <el-option label="中等密度" value="medium"></el-option>
  163. <el-option label="高等密度" value="high"></el-option>
  164. </el-select>
  165. </el-form-item>
  166. <el-form-item label="网格间距(m)">
  167. <el-input v-model.number="algorithmParams.minSpacing2" ></el-input>
  168. </el-form-item>
  169. <div style="border-top: 1px solid #737877;margin-bottom: 10px"></div>
  170. <el-form-item label="装备数量">
  171. <el-input v-model.number="algorithmParams.eqNumber2" ></el-input>
  172. </el-form-item>
  173. <el-form-item label="装备类型">
  174. <el-input v-model="algorithmParams.eqType2"></el-input>
  175. </el-form-item>
  176. </el-form>
  177. </div>
  178. </el-tab-pane>
  179. <el-tab-pane label="聚类布设" name="聚类布设">
  180. <div class="bg-gray-400 bg-opacity-30 p-4 rounded">
  181. <h2 class="text-lg font-semibold mb-4">聚类布设参数</h2>
  182. <!-- 可根据需求添加聚类布设相关表单元素 -->
  183. <el-form :model="algorithmParams" :disabled="!isEdit" label-width="120px">
  184. <el-form-item label="聚类中心">
  185. <el-input v-model="algorithmParams.randomCenter" placeholder="请输入聚类中心"></el-input>
  186. </el-form-item>
  187. <el-form-item label="聚类半径(m)">
  188. <el-input v-model.number="algorithmParams.minSpacing3" ></el-input>
  189. </el-form-item>
  190. <div style="border-top: 1px solid #737877;margin-bottom: 10px"></div>
  191. <el-form-item label="装备数量">
  192. <el-input v-model.number="algorithmParams.eqNumber3" ></el-input>
  193. </el-form-item>
  194. <el-form-item label="装备类型">
  195. <el-input v-model="algorithmParams.eqType3" ></el-input>
  196. </el-form-item>
  197. </el-form>
  198. </div>
  199. </el-tab-pane>
  200. </el-tabs>
  201. <!--<el-tabs type="card" stretch v-model="activeTab" class="mb-6">-->
  202. <!-- <el-tab-pane label="视场覆盖" name="random">-->
  203. <!-- <div class="bg-gray-400 bg-opacity-30 p-4 rounded">-->
  204. <!-- <h2 class="text-lg font-semibold mb-4">视场覆盖参数</h2>-->
  205. <!-- <el-form :model="randomParams" label-width="120px">-->
  206. <!-- <el-form-item label="随机种子">-->
  207. <!-- <el-input v-model="randomParams.randomSeed" placeholder="请输入随机种子"></el-input>-->
  208. <!-- </el-form-item>-->
  209. <!-- <el-form-item label="布设密度">-->
  210. <!-- <el-select v-model="randomParams.layoutDensity" placeholder="请选择布设密度">-->
  211. <!-- <el-option label="低等密度" value="low"></el-option>-->
  212. <!-- <el-option label="中等密度" value="medium"></el-option>-->
  213. <!-- <el-option label="高等密度" value="high"></el-option>-->
  214. <!-- </el-select>-->
  215. <!-- </el-form-item>-->
  216. <!-- <el-form-item label="最小间距(m)">-->
  217. <!-- <el-input v-model.number="randomParams.minSpacing" placeholder="请输入最小间距"></el-input>-->
  218. <!-- </el-form-item>-->
  219. <!-- </el-form>-->
  220. <!-- </div>-->
  221. <!-- </el-tab-pane>-->
  222. <!-- <el-tab-pane label="路径追踪" name="grid">-->
  223. <!-- <div class="bg-gray-400 bg-opacity-30 p-4 rounded">-->
  224. <!-- <h2 class="text-lg font-semibold mb-4">路径追踪参数</h2>-->
  225. <!-- &lt;!&ndash; 可根据需求添加网格布设相关表单元素 &ndash;&gt;-->
  226. <!-- <el-form :model="randomParams" label-width="120px">-->
  227. <!-- <el-form-item label="布设密度">-->
  228. <!-- <el-select v-model="randomParams.layoutDensity" placeholder="请选择布设密度">-->
  229. <!-- <el-option label="低等密度" value="low"></el-option>-->
  230. <!-- <el-option label="中等密度" value="medium"></el-option>-->
  231. <!-- <el-option label="高等密度" value="high"></el-option>-->
  232. <!-- </el-select>-->
  233. <!-- </el-form-item>-->
  234. <!-- <el-form-item label="网格间距(m)">-->
  235. <!-- <el-input v-model.number="randomParams.minSpacing" placeholder="请输入最小间距"></el-input>-->
  236. <!-- </el-form-item>-->
  237. <!-- </el-form>-->
  238. <!-- </div>-->
  239. <!-- </el-tab-pane>-->
  240. <!-- <el-tab-pane label="多传感器融合布设" name="cluster">-->
  241. <!-- <div class="bg-gray-400 bg-opacity-30 p-4 rounded">-->
  242. <!-- <h2 class="text-lg font-semibold mb-4">多传感器融合布设参数</h2>-->
  243. <!-- &lt;!&ndash; 可根据需求添加聚类布设相关表单元素 &ndash;&gt;-->
  244. <!-- <el-form :model="randomParams" label-width="120px">-->
  245. <!-- <el-form-item label="聚类中心">-->
  246. <!-- <el-input v-model="randomParams.randomCenter" placeholder="请输入聚类中心"></el-input>-->
  247. <!-- </el-form-item>-->
  248. <!-- <el-form-item label="聚类半径(m)">-->
  249. <!-- <el-input v-model.number="randomParams.minSpacing" placeholder="请输入最小间距"></el-input>-->
  250. <!-- </el-form-item>-->
  251. <!-- </el-form>-->
  252. <!-- </div>-->
  253. <!-- </el-tab-pane>-->
  254. <!-- <el-tab-pane label="动态调整" name="auto">-->
  255. <!-- <div class="bg-gray-400 bg-opacity-30 p-4 rounded">-->
  256. <!-- <h2 class="text-lg font-semibold mb-4">动态调整参数</h2>-->
  257. <!-- &lt;!&ndash; 可根据需求添加聚类布设相关表单元素 &ndash;&gt;-->
  258. <!-- <el-form :model="randomParams" label-width="120px">-->
  259. <!-- <el-form-item label="聚类中心">-->
  260. <!-- <el-input v-model="randomParams.randomCenter" placeholder="请输入聚类中心"></el-input>-->
  261. <!-- </el-form-item>-->
  262. <!-- <el-form-item label="聚类半径(m)">-->
  263. <!-- <el-input v-model.number="randomParams.minSpacing" placeholder="请输入最小间距"></el-input>-->
  264. <!-- </el-form-item>-->
  265. <!-- </el-form>-->
  266. <!-- </div>-->
  267. <!-- </el-tab-pane>-->
  268. <!--</el-tabs>-->
  269. <!--&lt;!&ndash; BB装备配置 &ndash;&gt;-->
  270. <!--<el-card class="bg-gray-400 bg-opacity-30 border-none">-->
  271. <!-- <div class="text-lg font-bold mb-2">装备配置</div>-->
  272. <!-- <el-form label-position="top" size="small" label-width="60px">-->
  273. <!-- <el-form-item label="装备数量">-->
  274. <!-- <el-input value="12"></el-input>-->
  275. <!-- </el-form-item>-->
  276. <!-- <el-form-item label="装备类型">-->
  277. <!-- <el-select placeholder="请选择" style="width: 100%">-->
  278. <!-- <el-option-->
  279. <!-- v-for="type in equipmentTypes"-->
  280. <!-- :key="type"-->
  281. <!-- :label="type"-->
  282. <!-- :value="type"-->
  283. <!-- ></el-option>-->
  284. <!-- </el-select>-->
  285. <!-- </el-form-item>-->
  286. <!-- </el-form>-->
  287. <!--</el-card>-->
  288. <!-- 操作控制 -->
  289. <div v-if="isEdit" class="space-y-2 mt-4">
  290. <el-button type="success" size="small" @click="back">完成编制</el-button>
  291. <el-button type="warning" size="small" @click="back">保存草稿</el-button>
  292. <!--<el-button type="danger" size="small" @click="back">清空布设</el-button>-->
  293. </div>
  294. </div>
  295. <!-- 右侧主内容区 -->
  296. <div class="flex-1 space-y-4 p-6 bg-gray-400 bg-opacity-20 backdrop-blur-lg border-gray-50 rounded-xl">
  297. <div class="flex items-center mb-4">
  298. <h3 class="text-lg font-bold" style="color: #4fc2f7">方案信息</h3>
  299. </div>
  300. <div class="flex p-4 mb-4 bg-black bg-opacity-20 rounded-md">
  301. <span class="mr-4">{{ schemeInfo.measurementRequirements }}</span>
  302. </div>
  303. <!-- 图例 -->
  304. <div class="flex items-center text-base mb-2">
  305. <span class="inline-block w-3 h-3 bg-orange-500 rounded-full mr-1"></span>
  306. <span class="mr-4">测量装备</span>
  307. <span class="inline-block w-3 h-3 bg-blue-500 rounded-full mr-1"></span>
  308. <span class="mr-4">选中状态</span>
  309. <span class="inline-block w-3 h-3 bg-purple-500 rounded-full mr-1"></span>
  310. <span class="mr-4">聚类中心</span>
  311. <span class="inline-block w-3 h-3 bg-green-500 rounded-full mr-1"></span>
  312. <span>判别线</span>
  313. </div>
  314. <!-- 网格画布(模拟) -->
  315. <div class="w-full bg-black bg-opacity-20 bg-blue-850 border border-blue-700 flex items-center justify-center" style="min-height: 400px">
  316. <!--<span class="text-blue-400">网格画布区域(可结合Canvas等实现交互)</span>-->
  317. <!--<img src="@/assets/plan_images/观测方案.jpg" class="w-full h-full" />-->
  318. <DrawioEmbed ref="drawioRef" />
  319. <!--<img v-else :src="" class="w-full h-full" />-->
  320. </div>
  321. <!--<div class="text-sm bg-blue-400 bg-opacity-20 rounded-md p-4 mt-2">-->
  322. <!-- 操作提示: 点击BB区位可选中,拖拽可调整位置,双击可查看详情,使用右侧配置区设置参数后点击"生成方案"按钮。-->
  323. <!--</div>-->
  324. <!-- 方案信息 -->
  325. <WangEditor
  326. v-model="content"
  327. :height="400"
  328. :disabled="!isEdit"
  329. @change="handleContentChange"
  330. />
  331. </div>
  332. </div>
  333. </div>
  334. <!-- 可拖动悬浮球 -->
  335. <div
  336. class="floating-button"
  337. :style="{ top: floatTop + 'px', left: floatLeft + 'px' }"
  338. @mousedown="startDrag"
  339. @click="toggleDrawer"
  340. >
  341. <i class="el-icon-s-opportunity text-2xl"></i>
  342. </div>
  343. <!-- 抽屉组件 -->
  344. <el-drawer
  345. title="AI助手"
  346. :with-header="false"
  347. :z-index="9999999"
  348. :visible.sync="drawerVisible"
  349. :direction="drawerDirection"
  350. style="z-index: 100;color:white;font-size: 16px"
  351. size="40%"
  352. >
  353. <div class="h-full w-full">
  354. <QAChat :messages="qaMessages" @question="handleQuestion" />
  355. </div>
  356. </el-drawer>
  357. </div>
  358. </template>
  359. <script>
  360. import WangEditor from "@/components/Components/WangEditor.vue";
  361. import QAChat from "@/components/Components/QAChat.vue"
  362. import DrawioEmbed from "@/components/DrawioEmbed/index.vue";
  363. import {getSynergismScheme, planningSchemeUpdate} from "@/api/planningScheme";
  364. export default {
  365. components:{
  366. DrawioEmbed,
  367. WangEditor,
  368. QAChat
  369. },
  370. data() {
  371. return {
  372. dist:{},
  373. content:'',
  374. selectedTemplate: null,
  375. templateSearch: '',
  376. templates: [
  377. {
  378. name: '标准模板',
  379. description: '系统默认标准配置',
  380. applicableScenario: '常规试验'
  381. },
  382. {
  383. name: '高密度模板',
  384. description: '高密度部署配置方案',
  385. applicableScenario: '密集目标'
  386. },
  387. {
  388. name: '分散式模板',
  389. description: '大范围分散部署',
  390. applicableScenario: '分散目标'
  391. },
  392. {
  393. name: '自定义模板',
  394. description: '用户自定义配置',
  395. applicableScenario: '特殊需求'
  396. },
  397. {
  398. name: '快速部署模板',
  399. description: '快速临时部署方案',
  400. applicableScenario: '应急测试'
  401. },
  402. {
  403. name: '高精度模板',
  404. description: '高精度测量配置',
  405. applicableScenario: '精密试验'
  406. }
  407. ],
  408. equipmentTypes: [
  409. '陆地模拟蓝军B系统',
  410. '发烟罐模拟蓝军模拟系统',
  411. '无人机蓝军系统',
  412. '大气状态分析仪'
  413. ],
  414. planInfo: JSON.parse(this.$route.query.plan),
  415. isEdit:this.$route.query.isEdit === 'true' ? true : false,
  416. activeTab: '随机布设',
  417. algorithmParams: {
  418. randomCenter: '1,1,1',
  419. randomSeed: '12345',
  420. layoutDensity: 'medium',
  421. layoutDensity2: 'medium',
  422. minSpacing1: 50,
  423. minSpacing2: 50,
  424. minSpacing3: 50,
  425. eqNumber1:5,
  426. eqNumber2:5,
  427. eqNumber3:5,
  428. eqType1:'',
  429. eqType2:'',
  430. eqType3:'',
  431. },
  432. // 悬浮球相关
  433. floatTop: 200,
  434. floatLeft: window.innerWidth - 80,
  435. isDragging: false,
  436. startX: 0,
  437. startY: 0,
  438. // 抽屉相关
  439. drawerVisible: false,
  440. drawerDirection: 'rtl', // 从右侧滑出
  441. // 历史记录数据
  442. historyData: [
  443. { time: '2025-08-20 11:05', operation: '创建方案', user: '张三' },
  444. { time: '2025-08-20 11:10', operation: '修改随机参数', user: '张三' },
  445. { time: '2025-08-20 11:15', operation: '保存草稿', user: '张三' }
  446. ],
  447. schemeInfo:{},
  448. };
  449. },
  450. computed: {
  451. // 过滤模板数据
  452. filteredTemplates() {
  453. if (!this.templateSearch) {
  454. return this.templates;
  455. }
  456. const searchStr = this.templateSearch.toLowerCase();
  457. return this.templates.filter(template =>
  458. template.name.toLowerCase().includes(searchStr) ||
  459. template.description.toLowerCase().includes(searchStr) ||
  460. template.applicableScenario.toLowerCase().includes(searchStr)
  461. );
  462. }
  463. },
  464. methods: {
  465. async fetchData(){
  466. await getSynergismScheme({id:this.planInfo.id}).then((res)=>{
  467. this.schemeInfo = res.data;
  468. if(res.data.schemeContent){
  469. const data = JSON.parse(res.data.schemeContent)
  470. this.algorithmParams = data.algorithmJson;
  471. this.content = data.textJson;
  472. this.loadDefaultData(data.xml.xmlData);
  473. }
  474. })
  475. },
  476. async loadDefaultData(xml) {
  477. try {
  478. await this.$refs.drawioRef.setData(xml)
  479. console.log('数据加载成功')
  480. } catch (err) {
  481. console.error('加载失败:', err)
  482. }
  483. },
  484. async getXmlData() {
  485. try {
  486. const data = await this.$refs.drawioRef.getData()
  487. console.log('获取数据成功:', data)
  488. return data
  489. } catch (err) {
  490. console.error('获取失败:', err)
  491. }
  492. },
  493. handleUse(plan) {
  494. // 执行“使用”逻辑
  495. console.log('正在使用方案:', plan.planName);
  496. // 或:弹出提示
  497. this.$message({
  498. type: 'success',
  499. message: `已应用模板:${plan.name}`
  500. });
  501. },
  502. handleContentChange(html) {
  503. console.log('编辑器内容变化:', html)
  504. // 可以在这里处理内容,如实时保存等
  505. },
  506. async back(){
  507. const xml = await this.getXmlData()
  508. const planJson = JSON.stringify({
  509. algorithmJson:this.algorithmParams, // 布设算法
  510. textJson: this.content, // 富文本
  511. xml: xml
  512. })
  513. await planningSchemeUpdate({id:this.schemeInfo.id,schemeContent:planJson,version:this.schemeInfo.version})
  514. this.$message.success('操作成功')
  515. this.$router.push({ path: '/scheme/collaborative' })
  516. },
  517. // 悬浮球拖动相关方法
  518. startDrag(e) {
  519. // 阻止事件冒泡,避免点击事件触发
  520. e.stopPropagation();
  521. this.isDragging = true;
  522. this.startX = e.clientX;
  523. this.startY = e.clientY;
  524. // 添加鼠标移动和释放事件监听
  525. document.addEventListener('mousemove', this.handleDrag);
  526. document.addEventListener('mouseup', this.stopDrag);
  527. },
  528. handleDrag(e) {
  529. if (!this.isDragging) return;
  530. // 计算移动距离
  531. const deltaX = e.clientX - this.startX;
  532. const deltaY = e.clientY - this.startY;
  533. // 更新位置,限制在窗口内
  534. let newLeft = this.floatLeft + deltaX;
  535. let newTop = this.floatTop + deltaY;
  536. // 限制在窗口范围内
  537. newLeft = Math.max(20, Math.min(newLeft, window.innerWidth - 80));
  538. newTop = Math.max(20, Math.min(newTop, window.innerHeight - 80));
  539. this.floatLeft = newLeft;
  540. this.floatTop = newTop;
  541. // 更新起始位置
  542. this.startX = e.clientX;
  543. this.startY = e.clientY;
  544. },
  545. stopDrag() {
  546. this.isDragging = false;
  547. // 移除事件监听
  548. document.removeEventListener('mousemove', this.handleDrag);
  549. document.removeEventListener('mouseup', this.stopDrag);
  550. },
  551. // 切换抽屉显示/隐藏
  552. toggleDrawer() {
  553. if (!this.isDragging) { // 只有在非拖动状态下才切换抽屉
  554. this.drawerVisible = !this.drawerVisible;
  555. }
  556. }
  557. },
  558. // 监听窗口大小变化,调整悬浮球位置
  559. mounted() {
  560. console.log(this.$route.query.isEdit)
  561. this.fetchData()
  562. window.addEventListener('resize', () => {
  563. this.floatLeft = Math.min(this.floatLeft, window.innerWidth - 80);
  564. });
  565. },
  566. beforeDestroy() {
  567. window.removeEventListener('resize', () => {
  568. this.floatLeft = Math.min(this.floatLeft, window.innerWidth - 80);
  569. });
  570. }
  571. };
  572. </script>
  573. <style scoped>
  574. .bb-layout-page {
  575. font-size: 16px;
  576. background-color: #030d1e;
  577. position: relative; /* 确保悬浮球相对于此容器定位 */
  578. min-height: calc(100vh - 64px); /* 减去顶部栏高度 */
  579. }
  580. .el-card {
  581. border-radius: 4px;
  582. }
  583. /* 悬浮球样式 */
  584. .floating-button {
  585. position: fixed;
  586. width: 60px;
  587. height: 60px;
  588. border-radius: 50%;
  589. background-color: #4fc2f7;
  590. color: white;
  591. display: flex;
  592. align-items: center;
  593. justify-content: center;
  594. font-size: 24px;
  595. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  596. cursor: move;
  597. z-index: 1000;
  598. transition: all 0.3s ease;
  599. }
  600. .floating-button:hover {
  601. transform: scale(1.1);
  602. background-color: #3ba8e0;
  603. }
  604. /* 抽屉样式调整 */
  605. ::v-deep .el-drawer__header {
  606. border-bottom: 1px solid #4fc2f7;
  607. padding-bottom: 10px;
  608. margin-bottom: 0px;
  609. }
  610. ::v-deep .el-drawer__body {
  611. padding: 0;
  612. display: flex;
  613. }
  614. ::v-deep .el-card__header {
  615. background-color: rgba(79, 194, 247, 0.1);
  616. border-bottom: 1px solid rgba(79, 194, 247, 0.3);
  617. }
  618. ::v-deep .el-tabs__nav-wrap{
  619. background: #09264c;
  620. }
  621. </style>