overallPlanDesign.vue 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559
  1. <template>
  2. <div>
  3. <GlobalLayout title="靶标保障方案">
  4. <!-- 主页面内容 -->
  5. <template #header-controls>
  6. <div class="header-actions">
  7. <el-button type="primary" @click="saveSolution">保存方案</el-button>
  8. <el-button class="blue-btn" @click="exportAsWord">导出为Word</el-button>
  9. <el-button class="blue-btn">查看试验任务详情</el-button>
  10. <!-- 查看子方案下拉菜单 -->
  11. <el-dropdown trigger="click" @command="handleCommand">
  12. <el-button class="blue-btn" icon="el-icon-folder-opened">
  13. 查看子方案<i class="el-icon-arrow-down el-icon--right"></i>
  14. </el-button>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item command="interference" icon="el-icon-warning-outline">干扰方案</el-dropdown-item>
  17. <el-dropdown-item command="measurement" icon="el-icon-odometer">测量方案</el-dropdown-item>
  18. <el-dropdown-item command="target" icon="el-icon-aim">靶标方案</el-dropdown-item>
  19. </el-dropdown-menu>
  20. </el-dropdown>
  21. </div>
  22. </template>
  23. <el-container class="main-container dark-theme">
  24. <!-- 左侧树形结构 - 深色背景 -->
  25. <el-aside width="280px" class="tree-container dark-tree-bg">
  26. <el-card shadow="never" class="tree-card dark-card">
  27. <div slot="header" class="tree-header dark-header">
  28. <span>方案目录</span>
  29. <div>
  30. <el-button icon="el-icon-plus" size="mini" @click="openAddChapterDialog"></el-button>
  31. <el-button icon="el-icon-delete" size="mini" @click="deleteSection"></el-button>
  32. </div>
  33. </div>
  34. <!-- 横向滚动容器 -->
  35. <div class="tree-wrapper" >
  36. <el-tree
  37. ref="solutionTree"
  38. :data="treeList"
  39. node-key="id"
  40. :props="treeProps"
  41. :expand-on-click-node="false"
  42. :highlight-current="true"
  43. @node-click="handleNodeClick"
  44. class="dark-tree"
  45. >
  46. <span slot-scope="{ node, data }" class="custom-tree-node">
  47. <i :class="data.icon || 'el-icon-folder'" class="tree-icon"></i>
  48. <span>{{ node.label }}</span>
  49. </span>
  50. </el-tree>
  51. </div>
  52. </el-card>
  53. </el-aside>
  54. <!-- 右侧方案编辑器 -->
  55. <el-main class="editor-container">
  56. <el-card shadow shadow="never" class="editor-card-card dark-card">
  57. <div slot="header" class="editor-header dark-header">
  58. <span>{{ currentSection ? currentSection.chapterName : '方案编辑器' }}</span>
  59. <div v-if="currentSection">
  60. <el-button
  61. icon="el-icon-edit"
  62. size="mini"
  63. @click="editSectionTitle"
  64. ></el-button>
  65. </div>
  66. </div>
  67. <!-- 文档式表单区域 -->
  68. <div class="document-form" v-if="currentSection">
  69. <!-- 根据章节类型显示不同编辑器 tabel === 0 -->
  70. <template v-if="currentSection.chapterType === '0'">
  71. <!-- 表格工具栏 -->
  72. <div class="table-toolbar" style="margin-bottom: 10px; display: flex; gap: 10px;">
  73. <el-button
  74. type="primary"
  75. size="small"
  76. @click="addTableRow"
  77. >
  78. <i class="el-icon-plus"></i> 添加行
  79. </el-button>
  80. <el-button
  81. type="warning"
  82. size="small"
  83. @click="addTableColumn"
  84. >
  85. <i class="el-icon-plus"></i> 添加列
  86. </el-button>
  87. <el-button
  88. type="info"
  89. size="small"
  90. @click="openEditHeadersModal"
  91. >
  92. <i class="el-icon-edit"></i> 编辑表头
  93. </el-button>
  94. </div>
  95. <el-table
  96. :data="currentSection.data"
  97. border
  98. style="width: 100%; margin-bottom: 15px;"
  99. class="dark-table"
  100. :key="tableKey"
  101. >
  102. <el-table-column
  103. v-for="(col, index) in currentSection.columns"
  104. :key="col.prop"
  105. :prop="col.prop"
  106. :label="col.label"
  107. >
  108. <!-- 单元格内容 -->
  109. <template slot-scope="scope">
  110. <el-input
  111. v-model="scope.row[col.prop]"
  112. class="dark-input"
  113. size="small"
  114. ></el-input>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="操作">
  118. <template slot-scope="scope">
  119. <el-button
  120. icon="el-icon-delete"
  121. size="mini"
  122. type="danger"
  123. @click="deleteTableRow(scope.$index)"
  124. ></el-button>
  125. </template>
  126. </el-table-column>
  127. </el-table>
  128. </template>
  129. <!-- 文件上传类型章节 -->
  130. <template v-else-if="currentSection.chapterType === '2'">
  131. <div class="upload-section">
  132. <el-upload
  133. class="upload-demo"
  134. action="#"
  135. list-type="picture-card"
  136. :on-preview="handleFilePreview"
  137. :on-remove="handleFileRemove"
  138. :before-remove="beforeFileRemove"
  139. :on-change="handleFileChange"
  140. multiple
  141. :limit="5"
  142. :on-exceed="handleFileExceed"
  143. :file-list="currentSection.files || []"
  144. :auto-upload="false"
  145. accept="image/jpeg,image/png,image/gif"
  146. >
  147. <i class="el-icon-plus"></i>
  148. <div slot="tip" class="el-upload__tip">
  149. 支持上传jpg、png、gif格式图片,单张不超过500kb,最多上传5张
  150. </div>
  151. </el-upload>
  152. </div>
  153. </template>
  154. <template v-else>
  155. <!-- 富文本编辑器 -->
  156. <WangEditor
  157. v-model="currentSection.chapterValue"
  158. :height="600"
  159. :disabled="false"
  160. @change="handleContentChange"
  161. @upload-image="handleImageUpload"
  162. />
  163. </template>
  164. </div>
  165. <div v-else class="empty-editor">
  166. <el-empty description="请从左侧选择方案节点进行编辑" class="dark-empty"></el-empty>
  167. </div>
  168. </el-card>
  169. </el-main>
  170. </el-container>
  171. </GlobalLayout>
  172. <!-- 图片预览弹窗 -->
  173. <el-dialog
  174. title="图片预览"
  175. :visible.sync="previewDialogVisible"
  176. width="80%"
  177. :modal="true"
  178. :close-on-click-modal="true"
  179. >
  180. <div class="preview-dialog-content">
  181. <img
  182. :src="previewImageUrl"
  183. :alt="previewImageName"
  184. class="full-preview-image"
  185. v-if="previewImageUrl"
  186. >
  187. <div v-else>图片加载失败</div>
  188. </div>
  189. </el-dialog>
  190. <!-- 编辑章节标题弹窗 -->
  191. <el-dialog
  192. title="编辑章节标题"
  193. :visible.sync="editTitleDialogVisible"
  194. width="30%"
  195. >
  196. <el-input v-model="tempTitle"></el-input>
  197. <div slot="footer" class="dialog-footer">
  198. <el-button @click="editTitleDialogVisible = false">取消</el-button>
  199. <el-button type="primary" @click="confirmEditTitle" style="margin-right: 20px">确定</el-button>
  200. </div>
  201. </el-dialog>
  202. <!-- 添加列弹窗 -->
  203. <el-dialog
  204. title="添加新列"
  205. :visible.sync="addColumnDialogVisible"
  206. width="30%"
  207. >
  208. <el-form :model="newColumnForm" ref="newColumnForm">
  209. <el-form-item label="列标题" prop="label" :rules="[{ required: true, message: '请输入列标题', trigger: 'blur' }]">
  210. <el-input v-model="newColumnForm.label"></el-input>
  211. </el-form-item>
  212. </el-form>
  213. <span slot="footer" class="dialog-footer">
  214. <el-button @click="addColumnDialogVisible = false">取消</el-button>
  215. <el-button type="primary" @click="confirmAddColumn">确定</el-button>
  216. </span>
  217. </el-dialog>
  218. <!-- 编辑表头弹窗 -->
  219. <el-dialog
  220. title="编辑表头"
  221. :visible.sync="editHeadersModalVisible"
  222. width="50%"
  223. :before-close="cancelEditHeaders"
  224. >
  225. <el-table
  226. :data="tempHeaders"
  227. border
  228. class="dark-table"
  229. >
  230. <el-table-column label="序号" type="index" width="60"></el-table-column>
  231. <el-table-column label="列标题">
  232. <template slot-scope="scope">
  233. <el-input
  234. v-model="tempHeaders[scope.$index].label"
  235. class="dark-input"
  236. placeholder="请输入列标题"
  237. ></el-input>
  238. </template>
  239. </el-table-column>
  240. <el-table-column label="操作">
  241. <template slot-scope="scope">
  242. <el-button
  243. icon="el-icon-delete"
  244. size="mini"
  245. type="danger"
  246. @click="removeTempHeader(scope.$index)"
  247. :disabled="tempHeaders.length <= 1"
  248. ></el-button>
  249. </template>
  250. </el-table-column>
  251. </el-table>
  252. <div style="margin-top: 10px; text-align: right;">
  253. <el-button size="small" @click="addTempHeader">
  254. <i class="el-icon-plus"></i> 添加列
  255. </el-button>
  256. </div>
  257. <span slot="footer" class="dialog-footer">
  258. <el-button @click="cancelEditHeaders">取消</el-button>
  259. <el-button type="primary" @click="confirmEditHeaders">保存修改</el-button>
  260. </span>
  261. </el-dialog>
  262. <!-- 添加章节弹窗 -->
  263. <el-dialog
  264. title="添加新章节"
  265. :visible.sync="addChapterDialogVisible"
  266. width="30%"
  267. >
  268. <el-form :model="chapterForm" ref="chapterForm" :rules="chapterFormRules">
  269. <el-form-item label="章节名称" prop="chapterName">
  270. <el-input v-model="chapterForm.chapterName" placeholder="请输入章节名称"></el-input>
  271. </el-form-item>
  272. <el-form-item label="章节类型" prop="chapterType">
  273. <el-select v-model="chapterForm.chapterType" placeholder="请选择章节类型">
  274. <el-option label="富文本" value="1"></el-option>
  275. <el-option label="表格" value="0"></el-option>
  276. <el-option label="图片上传" value="2"></el-option>
  277. </el-select>
  278. </el-form-item>
  279. </el-form>
  280. <span slot="footer" class="dialog-footer">
  281. <el-button @click="addChapterDialogVisible = false">取消</el-button>
  282. <el-button type="primary" @click="confirmAddChapter">确定</el-button>
  283. </span>
  284. </el-dialog>
  285. <!-- 删除列确认弹窗 -->
  286. <el-dialog
  287. title="确认删除"
  288. :visible.sync="deleteColumnDialogVisible"
  289. width="30%"
  290. >
  291. <p>确定要删除这 {{ columnsToDeleteCount }} 列吗?此操作不可撤销。</p>
  292. <span slot="footer" class="dialog-footer">
  293. <el-button @click="deleteColumnDialogVisible = false">取消</el-button>
  294. <el-button type="danger" @click="confirmDeleteColumns">确定删除</el-button>
  295. </span>
  296. </el-dialog>
  297. </div>
  298. </template>
  299. <script>
  300. import GlobalLayout from '@/components/Components/GlobalLayout.vue'
  301. import WangEditor from "@/components/Components/WangEditor.vue";
  302. import { saveAs } from 'file-saver';
  303. import JSZip from 'jszip';
  304. import Docxtemplater from 'docxtemplater';
  305. import PizZipUtils from 'pizzip/utils/index.js';
  306. import {
  307. addParentId,
  308. flattenTree,
  309. restructureForest,
  310. schemeChapterInsert,
  311. schemeChapterTree, schemeChapterUpdateList
  312. } from "@/api/planningScheme";
  313. import { MessageBox, Message, Loading } from 'element-ui';
  314. import {doUpload} from "@/api/tool/ossTool";
  315. import {exportSolutionToWord} from "@/views/planningSchem/comprehensive/wordExporter";
  316. function loadFile(url, callback) {
  317. PizZipUtils.getBinaryContent(url, callback);
  318. }
  319. export default {
  320. components: {
  321. WangEditor,
  322. GlobalLayout
  323. },
  324. data() {
  325. return {
  326. editTitleDialogVisible: false,
  327. tempTitle: '',
  328. currentSection: null, // 初始化为null而不是空对象
  329. // 图片预览相关
  330. previewDialogVisible: false,
  331. previewImageUrl: '',
  332. previewImageName: '',
  333. // 编辑表头弹窗
  334. editHeadersModalVisible: false,
  335. // 临时表头数据,用于弹窗编辑
  336. tempHeaders: [],
  337. // 原始表头数据,用于取消编辑时恢复
  338. originalHeaders: [],
  339. // 添加列弹窗
  340. addColumnDialogVisible: false,
  341. // 添加章节弹窗
  342. addChapterDialogVisible: false,
  343. // 删除列弹窗
  344. deleteColumnDialogVisible: false,
  345. // 要删除的列数量
  346. columnsToDeleteCount: 0,
  347. // 要删除的列索引
  348. columnsToDelete: [],
  349. // 新列表单数据
  350. newColumnForm: {
  351. chapterName: '',
  352. prop: ''
  353. },
  354. // 章节表单数据
  355. chapterForm: {
  356. chapterName: '',
  357. chapterType: '1' // 默认富文本类型
  358. },
  359. // 章节表单验证规则
  360. chapterFormRules: {
  361. chapterName: [
  362. { required: true, message: '请输入章节名称', trigger: 'blur' },
  363. { min: 1, max: 50, message: '章节名称长度在1到50个字符', trigger: 'blur' }
  364. ],
  365. chapterType: [
  366. { required: true, message: '请选择章节类型', trigger: 'change' }
  367. ]
  368. },
  369. batchId: null,
  370. treeList: [],
  371. // 树形结构数据 - 保留原有完整目录结构
  372. treeData: [
  373. {
  374. id: 'part1',
  375. chapterName: '标题',
  376. icon: 'el-icon-collection',
  377. chapterValue: '<h1 style="text-align: center">关于下发XXXX任务XXXX试验供靶实施方案的通知</h1>' +
  378. '<p><i>[本次编辑方式为半自动式编辑方式,需用户根据实际需求手动编辑!]</i> </p>',
  379. }
  380. // 其他树节点数据...
  381. ],
  382. treeProps: {
  383. children: 'children',
  384. label: 'chapterName'
  385. },
  386. // 方案表单数据
  387. solutionForm: {
  388. title: '靶标保障方案',
  389. version: 'V1.0',
  390. createDate: new Date().toLocaleDateString(),
  391. sections: []
  392. },
  393. // 用于强制刷新表格的key
  394. tableKey: 0
  395. }
  396. },
  397. mounted() {
  398. if (this.$route.query.batchId) {
  399. this.batchId = this.$route.query.batchId;
  400. } else {
  401. return;
  402. }
  403. this.getTree()
  404. },
  405. methods: {
  406. // 打开添加章节弹窗
  407. openAddChapterDialog() {
  408. // 重置表单
  409. this.chapterForm = {
  410. chapterName: '',
  411. chapterType: '1'
  412. };
  413. // 清空表单验证
  414. if (this.$refs.chapterForm) {
  415. this.$refs.chapterForm.resetFields();
  416. }
  417. // 显示弹窗
  418. this.addChapterDialogVisible = true;
  419. },
  420. // 确认添加章节
  421. confirmAddChapter() {
  422. this.$refs.chapterForm.validate(async (valid) => {
  423. if (valid) {
  424. // 生成唯一ID
  425. const newId = this.generateUUID();
  426. // 根据选择的类型初始化不同内容
  427. let newSection = {
  428. id: newId,
  429. chapterName: this.chapterForm.chapterName,
  430. chapterType: this.chapterForm.chapterType,
  431. parentId: '0' // 默认根节点
  432. };
  433. // 根据章节类型初始化内容
  434. switch(this.chapterForm.chapterType) {
  435. case '0': // 表格类型
  436. newSection.columns = [
  437. { prop: 'col1', label: '列1' }
  438. ];
  439. newSection.data = [
  440. { col1: '' }
  441. ];
  442. newSection.chapterValue = JSON.stringify({
  443. data: newSection.data,
  444. columns: newSection.columns
  445. });
  446. break;
  447. case '1': // 富文本类型
  448. newSection.chapterValue = '<p>请输入内容...</p>';
  449. break;
  450. case '2': // 图片上传类型 - 每个章节独立存储文件
  451. newSection.chapterValue = '';
  452. newSection.files = []; // 初始化空文件数组
  453. break;
  454. }
  455. // 如果有选中节点,作为子节点添加
  456. if (this.currentSection) {
  457. newSection.parentId = this.currentSection.id;
  458. if (!this.currentSection.children) {
  459. this.$set(this.currentSection, 'children', []);
  460. }
  461. this.currentSection.children.push(newSection);
  462. } else {
  463. // 否则添加到根节点
  464. this.treeList.push(newSection);
  465. }
  466. // 关闭弹窗
  467. this.addChapterDialogVisible = false;
  468. // 刷新树并选中新节点
  469. this.$nextTick(() => {
  470. this.$refs.solutionTree.setCurrentKey(newId);
  471. this.handleNodeClick(newSection);
  472. });
  473. Message.success('章节添加成功');
  474. }
  475. });
  476. },
  477. // 生成UUID
  478. generateUUID() {
  479. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  480. const r = Math.random() * 16 | 0;
  481. const v = c === 'x' ? r : (r & 0x3 | 0x8);
  482. return v.toString(16);
  483. });
  484. },
  485. // 处理富文本内容变化
  486. handleContentChange(html) {
  487. if (this.currentSection) {
  488. this.currentSection.chapterValue = html;
  489. }
  490. },
  491. async getTree() {
  492. try {
  493. const res = await schemeChapterTree({ batchId: this.batchId })
  494. this.treeList = res.data || [];
  495. function setTable(item) {
  496. // 确保每个文件上传类型章节都有独立的files数组
  497. if (item.chapterType === '2' && item.fileJson) {
  498. const fileList = JSON.parse(item.fileJson).map(item => {
  499. return {
  500. uid: item.uid,
  501. name: item.fileName,
  502. type: item.fileType,
  503. url: item.fileHttp
  504. }
  505. })
  506. this.$set(item, 'files', fileList);
  507. }
  508. if (item.chapterType === '0') { // 表格类型
  509. try {
  510. const data = item.chapterValue ? JSON.parse(item.chapterValue) : {};
  511. // 初始化 columns:用 $set 确保每个属性响应式
  512. const columns = (data.columns && data.columns.length)
  513. ? data.columns.map(col => {
  514. const newCol = {};
  515. this.$set(newCol, 'prop', col.prop || `col${Date.now()}`); // 唯一prop
  516. this.$set(newCol, 'label', col.label || `列${data.columns.indexOf(col) + 1}`); // 初始label
  517. return newCol;
  518. })
  519. : [{ prop: 'col1', label: '列1' }]; // 默认列
  520. this.$set(item, 'columns', columns); // 响应式赋值columns
  521. // 初始化 data:确保每行有对应列的prop
  522. const tableData = (data.data && data.data.length)
  523. ? data.data.map(row => {
  524. const newRow = {};
  525. columns.forEach(col => {
  526. this.$set(newRow, col.prop, row[col.prop] || ''); // 响应式赋值行数据
  527. });
  528. return newRow;
  529. })
  530. : [{ [columns[0].prop]: '' }]; // 默认行
  531. this.$set(item, 'data', tableData); // 响应式赋值data
  532. // 同步 chapterValue(避免数据不一致)
  533. this.$set(item, 'chapterValue', JSON.stringify({
  534. data: tableData,
  535. columns: columns.map(({ prop, label }) => ({ prop, label }))
  536. }));
  537. } catch (e) {
  538. // 解析失败时初始化默认结构
  539. const defaultColumns = [{ prop: 'col1', label: '列1' }];
  540. const defaultData = [{ col1: '' }];
  541. this.$set(item, 'columns', defaultColumns);
  542. this.$set(item, 'data', defaultData);
  543. this.$set(item, 'chapterValue', JSON.stringify({ data: defaultData, columns: defaultColumns }));
  544. console.warn('表格数据解析失败,已初始化默认结构', e);
  545. }
  546. }
  547. }
  548. function traverseTree(node) {
  549. if (node && node.length > 0) {
  550. node.forEach(item => {
  551. setTable.call(this, item); // 绑定this,确保$set生效
  552. if (item.children) traverseTree.call(this, item.children);
  553. });
  554. }
  555. }
  556. traverseTree.call(this, this.treeList);
  557. } catch (error) {
  558. console.error('获取树形结构失败', error);
  559. }
  560. },
  561. // 处理图片上传
  562. handleImageUpload(file, insertFn) {
  563. const reader = new FileReader();
  564. reader.onload = (e) => {
  565. const imgUrl = e.target.result;
  566. insertFn(imgUrl);
  567. };
  568. reader.readAsDataURL(file);
  569. },
  570. // 树节点点击事件 - 确保文件数据隔离
  571. handleNodeClick(data) {
  572. // 重置表格编辑状态和选中列
  573. this.editHeadersModalVisible = false;
  574. this.tableKey = 0; // 重置表格key
  575. this.previewDialogVisible = false; // 关闭图片预览
  576. // 确保文件上传类型章节有files属性
  577. if (data.chapterType === '2' && !data.files) {
  578. this.$set(data, 'files', []);
  579. }
  580. // 使用this.$set来设置currentSection,确保响应式
  581. this.$set(this, 'currentSection', data);
  582. // 如果是新节点,初始化内容
  583. if (!this.currentSection.chapterValue &&
  584. !['0', '2'].includes(this.currentSection.chapterType)) {
  585. this.currentSection.chapterValue = '<p>请输入内容...</p>';
  586. }
  587. },
  588. // 文件上传相关方法
  589. handleFileChange(file, fileList) {
  590. // 为每个文件创建临时URL用于预览
  591. if (file.raw) {
  592. file.objectUrl = URL.createObjectURL(file.raw);
  593. }
  594. // 更新当前章节的文件列表
  595. this.$set(this.currentSection, 'files', fileList);
  596. },
  597. handleFilePreview(file) {
  598. // 显示图片预览弹窗
  599. this.previewImageUrl = file.url || file.objectUrl;
  600. this.previewImageName = file.name;
  601. this.previewDialogVisible = true;
  602. },
  603. handleFileRemove(file, fileList) {
  604. // 释放文件的object URL,避免内存泄漏
  605. if (file.objectUrl) {
  606. URL.revokeObjectURL(file.objectUrl);
  607. }
  608. // 更新当前章节的文件列表
  609. this.$set(this.currentSection, 'files', fileList);
  610. },
  611. beforeFileRemove(file) {
  612. return MessageBox.confirm(`确定要删除图片 "${file.name}" 吗?`);
  613. },
  614. handleFileExceed(files, fileList) {
  615. Message.warning(`当前限制选择 5 张图片,本次选择了 ${files.length} 张,共选择了 ${files.length + fileList.length} 张`);
  616. },
  617. // 截断长文件名
  618. truncateFileName(name, maxLength = 15) {
  619. if (name.length <= maxLength) return name;
  620. return name.substring(0, maxLength) + '...';
  621. },
  622. // 编辑章节标题
  623. editSectionTitle() {
  624. if (this.currentSection) {
  625. this.tempTitle = this.currentSection.chapterName;
  626. this.editTitleDialogVisible = true;
  627. }
  628. },
  629. // 确认编辑标题
  630. confirmEditTitle() {
  631. if (this.tempTitle && this.currentSection) {
  632. this.currentSection.chapterName = this.tempTitle;
  633. this.editTitleDialogVisible = false;
  634. Message.success('标题修改成功');
  635. }
  636. },
  637. // 删除章节
  638. deleteSection() {
  639. if (!this.currentSection) {
  640. Message.warning('请先选择要删除的节点');
  641. return;
  642. }
  643. // 如果是文件上传章节,删除前释放所有object URL
  644. if (this.currentSection.chapterType === '2' && this.currentSection.files) {
  645. this.currentSection.files.forEach(file => {
  646. if (file.objectUrl) {
  647. URL.revokeObjectURL(file.objectUrl);
  648. }
  649. });
  650. }
  651. MessageBox.confirm(
  652. `确定删除 "${this.currentSection.chapterName}" 节点吗?`,
  653. '提示',
  654. {
  655. confirmButtonText: '确定',
  656. cancelButtonText: '取消',
  657. type: 'warning'
  658. }
  659. ).then(() => {
  660. this.removeNode(this.treeList, this.currentSection.id);
  661. this.currentSection = null;
  662. Message.success('删除成功');
  663. }).catch(() => {});
  664. },
  665. // 递归删除节点
  666. removeNode(nodes, id) {
  667. for (let i = 0; i < nodes.length; i++) {
  668. if (nodes[i].id === id) {
  669. // 释放该节点的所有图片URL
  670. if (nodes[i].chapterType === '2' && nodes[i].files) {
  671. nodes[i].files.forEach(file => {
  672. if (file.objectUrl) {
  673. URL.revokeObjectURL(file.objectUrl);
  674. }
  675. });
  676. }
  677. nodes.splice(i, 1);
  678. return true;
  679. }
  680. if (nodes[i].children && nodes[i].children.length) {
  681. if (this.removeNode(nodes[i].children, id)) {
  682. return true;
  683. }
  684. }
  685. }
  686. return false;
  687. },
  688. // 添加表格行
  689. addTableRow() {
  690. if (this.currentSection && this.currentSection.chapterType === '0') {
  691. const newRow = {};
  692. this.currentSection.columns.forEach(col => {
  693. newRow[col.prop] = '';
  694. });
  695. this.currentSection.data.push(newRow);
  696. }
  697. },
  698. // 删除表格行
  699. deleteTableRow(index) {
  700. if (this.currentSection && this.currentSection.chapterType === '0') {
  701. this.currentSection.data.splice(index, 1);
  702. // 确保至少保留一行
  703. if (this.currentSection.data.length === 0) {
  704. this.addTableRow();
  705. }
  706. }
  707. },
  708. // 打开添加列弹窗
  709. addTableColumn() {
  710. if (this.currentSection && this.currentSection.chapterType === '0') {
  711. this.newColumnForm = {
  712. label: '',
  713. prop: ''
  714. };
  715. this.addColumnDialogVisible = true;
  716. }
  717. },
  718. grert() {
  719. const timestamp = Date.now();
  720. const randomNum = Math.floor(Math.random() * 1000);
  721. return `column_${timestamp}_${randomNum}`;
  722. },
  723. // 确认添加列
  724. confirmAddColumn() {
  725. this.$refs.newColumnForm.validate((valid) => {
  726. if (valid) {
  727. // 检查字段名是否已存在
  728. const propExists = this.currentSection.columns.some(col => col.label === this.newColumnForm.label);
  729. if (propExists) {
  730. Message.error('标题已存在,请更换');
  731. return;
  732. }
  733. this.newColumnForm.prop = this.grert();
  734. // 添加新列定义
  735. this.currentSection.columns.push({
  736. label: this.newColumnForm.label,
  737. prop: this.newColumnForm.prop
  738. });
  739. // 为现有行添加新字段
  740. this.currentSection.data.forEach(row => {
  741. this.$set(row, this.newColumnForm.prop, '');
  742. });
  743. this.addColumnDialogVisible = false;
  744. this.tableKey++; // 刷新表格
  745. Message.success('列添加成功');
  746. }
  747. });
  748. },
  749. // 打开编辑表头弹窗
  750. openEditHeadersModal() {
  751. if (!this.currentSection || this.currentSection.chapterType !== '0') return;
  752. // 深拷贝当前表头数据到临时数组,避免直接修改原数据
  753. this.tempHeaders = JSON.parse(JSON.stringify(this.currentSection.columns));
  754. // 保存原始表头用于取消编辑时恢复
  755. this.originalHeaders = JSON.parse(JSON.stringify(this.currentSection.columns));
  756. this.editHeadersModalVisible = true;
  757. },
  758. // 在弹窗中添加临时列
  759. addTempHeader() {
  760. const newProp = this.grert();
  761. this.tempHeaders.push({
  762. prop: newProp,
  763. label: `新列${this.tempHeaders.length + 1}`
  764. });
  765. },
  766. // 在弹窗中移除临时列
  767. removeTempHeader(index) {
  768. if (this.tempHeaders.length <= 1) {
  769. Message.warning('至少需要保留一列');
  770. return;
  771. }
  772. this.tempHeaders.splice(index, 1);
  773. },
  774. // 确认编辑表头
  775. confirmEditHeaders() {
  776. // 验证列标题
  777. const labels = this.tempHeaders.map(header => header.label.trim());
  778. // 检查空标题
  779. const emptyIndex = labels.findIndex(label => !label);
  780. if (emptyIndex !== -1) {
  781. Message.warning(`第${emptyIndex + 1}列标题不能为空`);
  782. return;
  783. }
  784. // 检查重复标题
  785. const duplicates = [];
  786. labels.forEach((label, index) => {
  787. if (labels.indexOf(label) !== index && !duplicates.includes(label)) {
  788. duplicates.push(label);
  789. }
  790. });
  791. if (duplicates.length > 0) {
  792. Message.warning(`存在重复的列标题: ${duplicates.join(', ')}`);
  793. return;
  794. }
  795. // 找出被删除的列的prop
  796. const deletedProps = this.originalHeaders
  797. .map(header => header.prop)
  798. .filter(prop => !this.tempHeaders.some(h => h.prop === prop));
  799. // 更新列定义
  800. this.currentSection.columns = JSON.parse(JSON.stringify(this.tempHeaders));
  801. // 处理行数据:删除被移除列的数据,添加新列的数据
  802. this.currentSection.data.forEach(row => {
  803. // 删除被移除列的数据
  804. deletedProps.forEach(prop => {
  805. this.$delete(row, prop);
  806. });
  807. // 为新列添加空数据
  808. this.currentSection.columns.forEach(col => {
  809. if (row[col.prop] === undefined) {
  810. this.$set(row, col.prop, '');
  811. }
  812. });
  813. });
  814. // 刷新表格
  815. this.tableKey++;
  816. // 关闭弹窗
  817. this.editHeadersModalVisible = false;
  818. Message.success('表头编辑成功');
  819. },
  820. // 取消编辑表头
  821. cancelEditHeaders() {
  822. this.editHeadersModalVisible = false;
  823. },
  824. // 执行删除列操作
  825. confirmDeleteColumns() {
  826. if (!this.columnsToDelete.length) return;
  827. // 从后往前删除,避免索引混乱
  828. this.columnsToDelete.forEach(index => {
  829. // 获取要删除的字段名
  830. const propToRemove = this.currentSection.columns[index].prop;
  831. // 从列定义中删除
  832. this.currentSection.columns.splice(index, 1);
  833. // 从每行数据中删除对应的字段
  834. this.currentSection.data.forEach(row => {
  835. this.$delete(row, propToRemove);
  836. });
  837. });
  838. // 关闭弹窗并重置状态
  839. this.deleteColumnDialogVisible = false;
  840. this.columnsToDelete = [];
  841. this.tableKey++; // 刷新表格
  842. Message.success(`成功删除 ${this.columnsToDeleteCount} 列`);
  843. },
  844. // 保存方案 - 修复节点选中问题
  845. async saveSolution() {
  846. // 显示全局加载
  847. const loading = Loading.service({
  848. lock: true,
  849. text: '正在保存方案...',
  850. spinner: 'el-icon-loading',
  851. background: 'rgba(0, 0, 0, 0.7)'
  852. });
  853. try {
  854. // 收集所有章节数据
  855. const allSections = await this.collectAllSections(this.treeList);
  856. this.solutionForm.sections = flattenTree(allSections);
  857. const res = await schemeChapterUpdateList({
  858. data: this.solutionForm.sections,
  859. batchId: this.batchId
  860. });
  861. if (res.data) {
  862. Message.success('方案保存成功');
  863. // 重新获取树形结构
  864. await this.getTree();
  865. // 清空选中节点
  866. this.$set(this, 'currentSection', null);
  867. }
  868. } catch (error) {
  869. console.error('保存方案失败', error);
  870. Message.error('保存方案失败');
  871. } finally {
  872. // 关闭加载
  873. loading.close();
  874. }
  875. },
  876. // 展开节点的所有父节点
  877. expandNodeParents(nodeId) {
  878. if (!this.$refs.solutionTree) return;
  879. // 获取节点的所有父节点ID
  880. const parentIds = this.findNodeParentIds(this.treeList, nodeId);
  881. // 展开所有父节点
  882. parentIds.forEach(parentId => {
  883. this.$refs.solutionTree.expand(parentId);
  884. });
  885. },
  886. // 查找节点的所有父节点ID
  887. findNodeParentIds(nodes, targetId, parentIds = []) {
  888. for (const node of nodes) {
  889. if (node.id === targetId) {
  890. return parentIds;
  891. }
  892. if (node.children && node.children.length) {
  893. const found = this.findNodeParentIds(node.children, targetId, [...parentIds, node.id]);
  894. if (found) return found;
  895. }
  896. }
  897. return null;
  898. },
  899. // 根据ID查找节点
  900. findNodeById(nodes, id) {
  901. for (const node of nodes) {
  902. if (node.id === id) {
  903. return node;
  904. }
  905. if (node.children && node.children.length) {
  906. const found = this.findNodeById(node.children, id);
  907. if (found) return found;
  908. }
  909. }
  910. return null;
  911. },
  912. // 收集所有章节数据
  913. async collectAllSections(nodes, result = []) {
  914. for (const node of nodes) { // 使用for循环支持异步操作
  915. const sectionData = {
  916. id: node.id,
  917. parentId: node.parentId,
  918. chapterName: node.chapterName,
  919. chapterType: node.chapterType || '0',
  920. chapterValue: node.chapterValue || '',
  921. children: []
  922. };
  923. // 处理表格数据(保持不变)
  924. if (node.chapterType === '0') {
  925. sectionData.tableData = node.data;
  926. sectionData.columns = node.columns;
  927. sectionData.chapterValue = JSON.stringify({
  928. data: node.data,
  929. columns: node.columns
  930. })
  931. }
  932. // 处理文件数据 - 先上传再保存
  933. if (node.chapterType === '2' && node.files && node.files.length) {
  934. try {
  935. // 只处理状态为 'ready' 的文件(需要上传的)
  936. const filesToUpload = node.files.filter(file => file.status === 'ready');
  937. let uploadResults = [];
  938. // 如果有需要上传的文件
  939. if (filesToUpload.length > 0) {
  940. const uploadPromises = filesToUpload.map(async (file) => {
  941. const formData = new FormData();
  942. formData.append('file', file.raw); // 添加文件
  943. try {
  944. const response = await doUpload(formData);
  945. if (response.code === 0) {
  946. // 使用原始 file.uid,保持关联
  947. return {
  948. uid: file.uid,
  949. fileName: file.name,
  950. fileType: response.data.suffix,
  951. fileHttp: response.data.fileStoragePath,
  952. };
  953. } else {
  954. // 上传失败,抛出错误
  955. throw new Error(`文件 ${file.name} 上传失败: ${response.msg || '未知错误'}`);
  956. }
  957. } catch (error) {
  958. console.error(`上传文件 ${file.name} 时发生错误:`, error);
  959. throw error;
  960. }
  961. });
  962. // 等待所有上传完成
  963. uploadResults = await Promise.all(uploadPromises);
  964. }
  965. // 处理已上传的文件
  966. const existingFiles = node.files
  967. .filter(file => file.status === 'success')
  968. .map(file => ({
  969. uid: file.uid,
  970. fileName: file.name,
  971. fileType: file.type,
  972. fileHttp: file.url
  973. }));
  974. // 合并新旧文件信息
  975. const allFileInfos = [...existingFiles, ...uploadResults];
  976. // 保存合并后的所有文件信息
  977. sectionData.fileJson = JSON.stringify(allFileInfos);
  978. } catch (error) {
  979. console.error('文件上传失败', error);
  980. Message.error(error.message || '文件上传失败,请重试');
  981. }
  982. }
  983. // 保留原有字段信息
  984. if (node.fields) {
  985. sectionData.fields = node.fields;
  986. }
  987. result.push(sectionData);
  988. // 递归处理子节点
  989. if (node.children && node.children.length) {
  990. await this.collectAllSections(node.children, sectionData.children);
  991. }
  992. }
  993. return result;
  994. },
  995. // 导出为Word
  996. async exportAsWord() {
  997. try {
  998. await exportSolutionToWord(this.batchId);
  999. this.$message.success('导出Word成功');
  1000. } catch (error) {
  1001. this.$message.error(error.message || '导出Word失败');
  1002. }
  1003. // // 收集数据
  1004. // this.collectAllSections(this.treeList);
  1005. //
  1006. // // 生成HTML内容用于导出Word
  1007. // const htmlContent = this.generateExportHtml();
  1008. //
  1009. // const blob = new Blob(['\ufeff', htmlContent], {
  1010. // type: 'application/msword'
  1011. // });
  1012. //
  1013. // saveAs(blob, `${this.solutionForm.title}.doc`);
  1014. },
  1015. // 生成导出的HTML内容
  1016. generateExportHtml() {
  1017. let html = `
  1018. <html>
  1019. <head>
  1020. <meta charset="UTF-8">
  1021. <title>${this.solutionForm.title}</title>
  1022. <style>
  1023. body { font-family: SimSun; }
  1024. .title { text-align: center; font-size: 24px; margin: 20px 0; }
  1025. .subtitle { text-align: center; margin: 10px 0; }
  1026. h1 { font-size: 20px; margin: 15px 0; }
  1027. h2 { font-size: 18px; margin: 12px 0; }
  1028. h3 { font-size: 16px; margin: 10px 0; }
  1029. p { margin: 8px 0; line-height: 1.5; }
  1030. table { border-collapse: collapse; width: 100%; margin: 10px 0; }
  1031. table, th, td { border: 1px solid #000; padding: 5px; }
  1032. th { background-color: #f0f0f0; }
  1033. .section { margin: 15px 0; }
  1034. .file-item { margin: 5px 0; }
  1035. .image-preview { max-width: 200px; margin: 10px 0; }
  1036. .gantt-task { margin: 5px 0; padding: 5px; background-color: #f5f5f5; }
  1037. </style>
  1038. </head>
  1039. <body>
  1040. <div class="title">${this.solutionForm.title}</div>
  1041. <div class="subtitle">版本:${this.solutionForm.version}</div>
  1042. <div class="subtitle">日期:${this.solutionForm.createDate}</div>
  1043. `;
  1044. // 添加所有章节内容
  1045. html += this.generateSectionsHtml(this.treeList, 1);
  1046. html += `
  1047. </body>
  1048. </html>
  1049. `;
  1050. return html;
  1051. },
  1052. // 生成章节HTML
  1053. generateSectionsHtml(nodes, level) {
  1054. let html = '';
  1055. nodes.forEach(node => {
  1056. const tag = `h${level}`;
  1057. html += `<div class="section">`;
  1058. html += `<${tag}>${node.chapterName}</${tag}>`;
  1059. // 根据类型添加内容
  1060. if (node.chapterType === '1' && node.chapterValue) {
  1061. html += `<div class="content">${node.chapterValue}</div>`;
  1062. }
  1063. // 表格内容
  1064. if (node.chapterType === '0' && node.data && node.columns) {
  1065. html += '<table>';
  1066. // 表头
  1067. html += '<tr>';
  1068. node.columns.forEach(col => {
  1069. html += `<th>${col.label}</th>`;
  1070. });
  1071. html += '</tr>';
  1072. // 表体
  1073. node.data.forEach(row => {
  1074. html += '<tr>';
  1075. node.columns.forEach(col => {
  1076. html += `<td>${row[col.prop] || ''}</td>`;
  1077. });
  1078. html += '</tr>';
  1079. });
  1080. html += '</table>';
  1081. }
  1082. // 图片内容
  1083. if (node.chapterType === '2' && node.fileJson) {
  1084. html += '<div class="images">';
  1085. html += '<p>图片列表:</p>';
  1086. JSON.parse(node.fileJson).forEach(file => {
  1087. // 只在有URL的情况下才添加图片标签
  1088. if (file.fileHttp || file.objectUrl) {
  1089. html += `<p><img src="${file.fileHttp || file.objectUrl}" class="image-preview" alt="${file.fileName}"></p>`;
  1090. }
  1091. html += `<p>${file.fileName}</p>`;
  1092. });
  1093. html += '</div>';
  1094. }
  1095. // 递归处理子节点
  1096. if (node.children && node.children.length) {
  1097. html += this.generateSectionsHtml(node.children, level + 1);
  1098. }
  1099. html += `</div>`;
  1100. });
  1101. return html;
  1102. },
  1103. // 格式化文件大小显示
  1104. formatFileSize(bytes) {
  1105. if (bytes < 1024) return bytes + ' B';
  1106. else if (bytes < 1048576) return (bytes / 1024).toFixed(2) + ' KB';
  1107. else return (bytes / 1048576).toFixed(2) + ' MB';
  1108. },
  1109. // 处理下拉菜单命令
  1110. handleCommand(command) {
  1111. switch(command) {
  1112. case 'interference':
  1113. Message.info('查看干扰方案');
  1114. break;
  1115. case 'measurement':
  1116. Message.info('查看测量方案');
  1117. break;
  1118. case 'target':
  1119. Message.info('查看靶标方案');
  1120. break;
  1121. }
  1122. }
  1123. },
  1124. // 组件销毁时清理所有临时URL
  1125. beforeDestroy() {
  1126. // 递归清理所有图片的临时URL
  1127. function cleanObjectUrls(nodes) {
  1128. nodes.forEach(node => {
  1129. if (node.chapterType === '2' && node.files) {
  1130. node.files.forEach(file => {
  1131. if (file.objectUrl) {
  1132. URL.revokeObjectURL(file.objectUrl);
  1133. }
  1134. });
  1135. }
  1136. if (node.children && node.children.length) {
  1137. cleanObjectUrls(node.children);
  1138. }
  1139. });
  1140. }
  1141. cleanObjectUrls(this.treeList);
  1142. }
  1143. }
  1144. </script>
  1145. <style scoped>
  1146. /* 深色主题基础样式 */
  1147. .dark-theme {
  1148. background-color: #1f2a38;
  1149. color: #e0e6ed;
  1150. }
  1151. /* 左侧树结构背景色 */
  1152. .dark-tree-bg {
  1153. background-color: #1f2a38;
  1154. }
  1155. /* 卡片样式 */
  1156. .dark-card {
  1157. background-color: #2d3a4b;
  1158. border: 1px solid #425163;
  1159. color: #e0e6ed;
  1160. }
  1161. .dark-card ::v-deep .el-card__header {
  1162. background-color: #1f2a38;
  1163. border-bottom: 1px solid #425163;
  1164. color: #ffffff;
  1165. }
  1166. /* 头部样式 */
  1167. .dark-header {
  1168. color: #ffffff;
  1169. border-bottom: 1px solid #425163;
  1170. }
  1171. /* 树形结构样式 - 深色背景 */
  1172. .dark-tree ::v-deep .el-tree {
  1173. background-color: #2d3a4b;
  1174. color: #e0e6ed;
  1175. }
  1176. .dark-tree ::v-deep .el-tree-node__content {
  1177. height: 36px;
  1178. transition: all 0.3s;
  1179. background-color: #2d3a4b;
  1180. }
  1181. .dark-tree ::v-deep .el-tree-node__content:hover {
  1182. background-color: rgba(64, 158, 255, 0.1);
  1183. }
  1184. .dark-tree ::v-deep .el-tree-node:focus > .el-tree-node__content {
  1185. background-color: rgba(64, 158, 255, 0.2);
  1186. }
  1187. .tree-icon {
  1188. margin-right: 5px;
  1189. color: #409EFF;
  1190. }
  1191. /* 表单样式 */
  1192. .dark-input ::v-deep .el-input__inner {
  1193. background-color: #1f2a38;
  1194. border: 1px solid #425163;
  1195. color: #e0e6ed;
  1196. }
  1197. .dark-table ::v-deep .el-table {
  1198. background-color: #2d3a4b;
  1199. color: #e0e6ed;
  1200. }
  1201. .dark-table ::v-deep .el-table th {
  1202. background-color: #1f2a38;
  1203. border-bottom: 1px solid #425163;
  1204. }
  1205. .dark-table ::v-deep .el-table tr {
  1206. background-color: #2d3a4b;
  1207. }
  1208. .dark-table ::v-deep .el-table tr:nth-child(2n) {
  1209. background-color: #283544;
  1210. }
  1211. .dark-table ::v-deep .el-table td {
  1212. border-bottom: 1px solid #425163;
  1213. }
  1214. /* 布局样式 */
  1215. .main-container {
  1216. height: calc(100vh - 60px);
  1217. }
  1218. .tree-container {
  1219. border-right: 1px solid #425163;
  1220. height: 100%;
  1221. }
  1222. .tree-card {
  1223. height: 100%;
  1224. border-radius: 0;
  1225. border: none;
  1226. .el-card__body {
  1227. padding: 0;
  1228. }
  1229. }
  1230. .tree-header {
  1231. display: flex;
  1232. justify-content: space-between;
  1233. align-items: center;
  1234. font-weight: bold;
  1235. }
  1236. .custom-tree-node {
  1237. flex: 1;
  1238. display: flex;
  1239. align-items: center;
  1240. font-size: 14px;
  1241. padding-right: 8px;
  1242. }
  1243. .editor-container {
  1244. padding: 0;
  1245. height: 100%;
  1246. background-color: #1f2a38;
  1247. }
  1248. .editor-card {
  1249. height: 100%;
  1250. border-radius: 0;
  1251. border: none;
  1252. overflow: auto;
  1253. }
  1254. .editor-header {
  1255. display: flex;
  1256. justify-content: space-between;
  1257. align-items: center;
  1258. font-weight: bold;
  1259. }
  1260. .document-form {
  1261. padding: 20px;
  1262. }
  1263. .empty-editor {
  1264. height: 100%;
  1265. display: flex;
  1266. align-items: center;
  1267. justify-content: center;
  1268. overflow: auto;
  1269. }
  1270. .dark-empty ::v-deep .el-empty__description {
  1271. color: #8796ad;
  1272. }
  1273. ::v-deep .el-upload--picture-card{
  1274. background-color: #fdfdfd1c;
  1275. }
  1276. /* 滚动条样式 */
  1277. ::-webkit-scrollbar {
  1278. width: 6px;
  1279. height: 6px;
  1280. }
  1281. ::-webkit-scrollbar-thumb {
  1282. background-color: #425163;
  1283. border-radius: 3px;
  1284. }
  1285. ::-webkit-scrollbar-track {
  1286. background-color: #1f2a38;
  1287. }
  1288. .header-actions {
  1289. display: flex;
  1290. gap: 10px;
  1291. }
  1292. /* 滚动容器:限制高度,允许横向滚动 */
  1293. .tree-wrapper {
  1294. width: 254px;
  1295. max-height: calc(100vh - 140px);
  1296. overflow-x: auto;
  1297. overflow-y: auto;
  1298. }
  1299. .tree-wrapper::-webkit-scrollbar {
  1300. height: 6px;
  1301. }
  1302. .tree-wrapper::-webkit-scrollbar-thumb {
  1303. background-color: #888;
  1304. border-radius: 3px;
  1305. }
  1306. .tree-wrapper::-webkit-scrollbar-thumb:hover {
  1307. background-color: #555;
  1308. }
  1309. .custom-tree .el-tree-node__content {
  1310. white-space: nowrap;
  1311. min-width: 100%;
  1312. }
  1313. .custom-tree-node {
  1314. display: flex;
  1315. align-items: center;
  1316. flex-nowrap: nowrap;
  1317. min-width: max-content;
  1318. }
  1319. /* 图片上传和预览样式 */
  1320. .upload-section {
  1321. margin-top: 10px;
  1322. }
  1323. .image-preview-container {
  1324. margin-top: 20px;
  1325. padding-top: 10px;
  1326. border-top: 1px dashed #425163;
  1327. }
  1328. .image-grid {
  1329. display: grid;
  1330. grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  1331. gap: 15px;
  1332. margin-top: 10px;
  1333. }
  1334. .image-item {
  1335. display: flex;
  1336. flex-direction: column;
  1337. align-items: center;
  1338. }
  1339. .preview-image {
  1340. width: 100%;
  1341. height: 120px;
  1342. cursor: pointer;
  1343. border: 1px solid #425163;
  1344. border-radius: 4px;
  1345. background-color: #1f2a38;
  1346. }
  1347. .image-info {
  1348. width: 100%;
  1349. display: flex;
  1350. justify-content: space-between;
  1351. align-items: center;
  1352. margin-top: 5px;
  1353. font-size: 12px;
  1354. }
  1355. .image-name {
  1356. white-space: nowrap;
  1357. overflow: hidden;
  1358. text-overflow: ellipsis;
  1359. max-width: 110px;
  1360. }
  1361. .delete-image {
  1362. color: #f56c6c;
  1363. padding: 0;
  1364. }
  1365. .image-error {
  1366. width: 100%;
  1367. height: 120px;
  1368. display: flex;
  1369. align-items: center;
  1370. justify-content: center;
  1371. color: #8796ad;
  1372. background-color: #1f2a38;
  1373. border: 1px solid #425163;
  1374. border-radius: 4px;
  1375. }
  1376. /* 图片预览弹窗样式 */
  1377. .preview-dialog-content {
  1378. display: flex;
  1379. justify-content: center;
  1380. align-items: center;
  1381. padding: 10px;
  1382. }
  1383. .full-preview-image {
  1384. max-width: 100%;
  1385. max-height: 80vh;
  1386. object-fit: contain;
  1387. }
  1388. </style>