index.vue 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888
  1. <template>
  2. <div class="boxswai">
  3. <div class="boxnei">
  4. <el-row :gutter="0" style="height: 100%">
  5. <el-col :span="showLeft ? 5 : 0" style="height: 99%">
  6. <div style="fontsize: 18px; font-weight: 900" class="marbottom5">
  7. 元素识别
  8. </div>
  9. <div style="height: 98%; overflow: auto; width: auto">
  10. <div class="flex">
  11. <el-input
  12. size="small"
  13. placeholder="输入关键字搜索"
  14. clearable
  15. @clear="allTreeShow = false"
  16. v-model="filterText"
  17. >
  18. </el-input>
  19. <el-button size="small" class="mg-l-10" @click="treeFilter"
  20. >搜索</el-button
  21. >
  22. </div>
  23. <el-tree
  24. :default-expanded-keys="expandedKeys"
  25. :default-checked-keys="defaultcheckedkeys"
  26. :data="treeData"
  27. :props="treeProps"
  28. @node-click="handleNodeClick"
  29. :load="loadNode"
  30. :expand-on-click-node="false"
  31. lazy
  32. v-show="!allTreeShow"
  33. ></el-tree>
  34. <el-tree
  35. style="width: 100%"
  36. ref="treeall"
  37. v-loading="treeloading"
  38. :data="allTreeData"
  39. :props="treeProps"
  40. @node-click="handleNodeClick"
  41. node-key="id"
  42. :expand-on-click-node="false"
  43. :filter-node-method="filterNode"
  44. v-show="allTreeShow"
  45. >
  46. </el-tree>
  47. </div>
  48. </el-col>
  49. <el-col :span="showLeft ? 19 : 24" style="height: 98%; display: flex">
  50. <div
  51. class="flex flex-center"
  52. style="width: 20px; height: 100%; cursor: pointer"
  53. @click="showLeftChange"
  54. >
  55. <i v-if="showLeft" class="el-icon-d-arrow-left"></i>
  56. <i v-else class="el-icon-d-arrow-right"></i>
  57. </div>
  58. <div class="flex1" style="padding-left: 10px">
  59. <div v-if="addElementForm.nodeName == ''">表名称</div>
  60. <div v-else>{{ addElementForm.nodeName }}</div>
  61. <el-row class="martop20" :gutter="20" style="height: 96%">
  62. <el-col
  63. :span="showLeft ? 16 : 12"
  64. style="
  65. overflow: auto;
  66. height: 100%;
  67. border: 1px solid black;
  68. border-radius: 4px;
  69. box-sizing: border-box;
  70. padding: 10px 10px;
  71. "
  72. >
  73. <div
  74. class="parent hc-excel-table-form"
  75. id="parent"
  76. @dblclick="dblBtnClick($event)"
  77. @click="parentClick($event)"
  78. ></div>
  79. </el-col>
  80. <el-col
  81. :span="showLeft ? 8 : 12"
  82. ref="tablescroll"
  83. style="height: 100%"
  84. :style="{ overflow: 'auto' }"
  85. >
  86. <div class=" flexItemsC " style="top:150px;position: fixed;z-index: 1000;">
  87. <div style="margin-right:20px">
  88. <!-- <el-button
  89. type="info"
  90. size="mini"
  91. :disabled="from.id==''"
  92. @click="automaticRecognition"
  93. >自动识别</el-button> -->
  94. <el-button
  95. type="success"
  96. size="mini"
  97. @click="establish()"
  98. :disabled="from.id == ''"
  99. >关联WBS并创建元素</el-button
  100. >
  101. <el-button
  102. :loading="elloading"
  103. type="success"
  104. size="mini"
  105. @click="addtoElement()"
  106. :disabled="from.id == ''"
  107. >添加到元素库</el-button
  108. >
  109. </div>
  110. <div
  111. class="el-icon-plus"
  112. type="success"
  113. @click="pushTableData"
  114. style="
  115. width: 16px;
  116. height: 16px;
  117. backgroundcolor: #1dd81d;
  118. color: green;
  119. cursor: pointer;
  120. "
  121. ></div>
  122. </div>
  123. <div class="region">
  124. <el-table
  125. class="martop20"
  126. :data="tableData"
  127. border
  128. :row-class-name="tableRowClassName"
  129. style="width: 100%"
  130. >
  131. <el-table-column type="index" label="坐标">
  132. </el-table-column>
  133. <el-table-column prop="textInfo" label="元素名称">
  134. <template slot-scope="scope">
  135. <el-input
  136. v-model="scope.row.textInfo"
  137. placeholder="请输入内容"
  138. ></el-input>
  139. </template>
  140. </el-table-column>
  141. <el-table-column prop="textElementType" label="数据类型">
  142. <template slot-scope="scope">
  143. <el-select
  144. v-model="scope.row.textElementType"
  145. placeholder="请选择"
  146. >
  147. <el-option
  148. v-for="item in dataType"
  149. :key="item.dictKey"
  150. :label="item.dictValue"
  151. :value="item.dictKey"
  152. >
  153. </el-option>
  154. </el-select>
  155. </template>
  156. </el-table-column>
  157. <el-table-column prop="textDeviation" label="允许偏差值">
  158. <template slot-scope="scope">
  159. <el-input
  160. v-model="scope.row.textDeviation"
  161. placeholder="请输入内容"
  162. ></el-input>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="操作" width="100">
  166. <template slot-scope="scope">
  167. <el-link
  168. style="margin-right: 16px"
  169. type="success"
  170. @click="saveELe(scope.row)"
  171. >保存</el-link
  172. >
  173. <el-link
  174. type="danger"
  175. @click="deleteTableData(scope.$index)"
  176. >删除</el-link
  177. >
  178. </template>
  179. </el-table-column>
  180. </el-table>
  181. <!-- <el-button
  182. type="success"
  183. class="martop20 dingwei"
  184. @click="establish()"
  185. :disabled="from.id==''"
  186. >关联WBS并创建元素</el-button> -->
  187. <el-dialog
  188. title="编辑元素信息"
  189. :visible.sync="editTitleDialog"
  190. width="80%"
  191. :modal-append-to-body="false"
  192. :append-to-body="false"
  193. >
  194. <div>
  195. <draggable v-model="titleList">
  196. <div
  197. v-for="(item, key) in titleList"
  198. :key="key"
  199. class="flexBetween flexItemsC title-item"
  200. >
  201. <div>
  202. <span>{{ item }}</span>
  203. </div>
  204. <div class="flexItemsC">
  205. <i
  206. @click="listUp(key)"
  207. class="el-icon-top"
  208. :style="{
  209. 'font-size': '20px',
  210. color: key == 0 ? '#aaa' : '#0A8CD5',
  211. cursor: key != 0 ? 'pointer' : 'default',
  212. }"
  213. ></i>
  214. <i
  215. @click="listDown(key)"
  216. class="el-icon-bottom marleft5"
  217. :style="{
  218. 'font-size': '20px',
  219. color:
  220. key == titleList.length - 1
  221. ? '#aaa'
  222. : '#0A8CD5',
  223. cursor:
  224. key != titleList.length - 1
  225. ? 'pointer'
  226. : 'default',
  227. }"
  228. ></i>
  229. <i
  230. @click="deleTitle(key)"
  231. class="el-icon-circle-close marleft5"
  232. :style="{
  233. 'font-size': '20px',
  234. color: '#ee7049',
  235. cursor: 'pointer',
  236. }"
  237. ></i>
  238. </div>
  239. </div>
  240. </draggable>
  241. </div>
  242. <div style="margin-top: 50px">
  243. <div class="flex jc-sb mg-b-10">
  244. <div class="flex jc-al-c">
  245. <span style="margin-right: 10px">数据类型</span>
  246. <el-select
  247. v-model="titleForm.textElementType"
  248. placeholder="请选择"
  249. style="width: 130px"
  250. >
  251. <el-option
  252. v-for="item in dataType"
  253. :key="item.dictKey"
  254. :label="item.dictValue"
  255. :value="item.dictKey"
  256. >
  257. </el-option>
  258. </el-select>
  259. <span style="margin: 0 10px">允许偏差值</span>
  260. <el-input
  261. v-model="titleForm.textDeviation"
  262. placeholder="请输入内容"
  263. style="width: 150px"
  264. ></el-input>
  265. </div>
  266. <div>
  267. <el-button
  268. size="medium"
  269. type="primary"
  270. @click="setTitleText"
  271. >合成文本</el-button
  272. >
  273. </div>
  274. </div>
  275. <el-input
  276. type="textarea"
  277. rows="5"
  278. v-model="titleForm.textInfo"
  279. ></el-input>
  280. </div>
  281. <el-alert
  282. title="该输入框没有匹配到对应元素字段,确定修改将会新增一个元素字段"
  283. v-if="titleIndex < 0"
  284. type="warning"
  285. :closable="false"
  286. effect="dark"
  287. style="margin-top: 10px"
  288. >
  289. </el-alert>
  290. <span slot="footer" class="dialog-footer">
  291. <el-button @click="editTitleDialog = false"
  292. >取 消</el-button
  293. >
  294. <el-button
  295. type="primary"
  296. v-throttle="2000"
  297. @click="editTitle()"
  298. >确定修改</el-button
  299. >
  300. </span>
  301. </el-dialog>
  302. <el-dialog
  303. title="添加新元素字段"
  304. :visible.sync="addNewElementDialog"
  305. :before-close="handleClose"
  306. width="80%"
  307. :modal-append-to-body="false"
  308. :append-to-body="false"
  309. >
  310. <div>
  311. <!-- <i
  312. @click="addNewElement"
  313. class="el-icon-circle-plus marbottom10"
  314. style="color:red; font-size:24px; float: right;cursor: pointer;"
  315. ></i> -->
  316. <div>
  317. <draggable v-model="titleList">
  318. <div
  319. v-for="(item, key) in titleList"
  320. :key="key"
  321. class="flexBetween flexItemsC title-item"
  322. >
  323. <div>
  324. <span>{{ item }}</span>
  325. </div>
  326. <div class="flexItemsC">
  327. <i
  328. @click="listUp(key)"
  329. class="el-icon-top"
  330. :style="{
  331. 'font-size': '20px',
  332. color: key == 0 ? '#aaa' : '#0A8CD5',
  333. cursor: key != 0 ? 'pointer' : 'default',
  334. }"
  335. ></i>
  336. <i
  337. @click="listDown(key)"
  338. class="el-icon-bottom marleft5"
  339. :style="{
  340. 'font-size': '20px',
  341. color:
  342. key == titleList.length - 1
  343. ? '#aaa'
  344. : '#0A8CD5',
  345. cursor:
  346. key != titleList.length - 1
  347. ? 'pointer'
  348. : 'default',
  349. }"
  350. ></i>
  351. <i
  352. @click="deleTitle(key)"
  353. class="el-icon-circle-close marleft5"
  354. :style="{
  355. 'font-size': '20px',
  356. color: '#ee7049',
  357. cursor: 'pointer',
  358. }"
  359. ></i>
  360. </div>
  361. </div>
  362. </draggable>
  363. <div class="flex jc-sb mg-b-10">
  364. <div class="flex jc-al-c"></div>
  365. <div>
  366. <el-button
  367. size="medium"
  368. type="primary"
  369. @click="setTitleText"
  370. >合成文本</el-button
  371. >
  372. </div>
  373. </div>
  374. </div>
  375. <el-table
  376. :data="newElements"
  377. height="250"
  378. border
  379. style="width: 100%"
  380. >
  381. <el-table-column label="元素名称">
  382. <template slot-scope="scope">
  383. <el-input
  384. v-model="scope.row.textInfo"
  385. placeholder="请输入内容"
  386. ></el-input>
  387. </template>
  388. </el-table-column>
  389. <el-table-column
  390. prop="textElementType"
  391. label="数据类型"
  392. >
  393. <template slot-scope="scope">
  394. <el-select
  395. v-model="scope.row.textElementType"
  396. placeholder="请选择"
  397. >
  398. <el-option
  399. v-for="item in dataType"
  400. :key="item.dictKey"
  401. :label="item.dictValue"
  402. :value="item.dictKey"
  403. >
  404. </el-option>
  405. </el-select>
  406. </template>
  407. </el-table-column>
  408. <el-table-column
  409. prop="textDeviation"
  410. label="允许偏差值"
  411. >
  412. <template slot-scope="scope">
  413. <el-input
  414. v-model="scope.row.textDeviation"
  415. placeholder="请输入内容"
  416. ></el-input>
  417. </template>
  418. </el-table-column>
  419. <el-table-column
  420. prop="date"
  421. align="center"
  422. width="120"
  423. label="操作"
  424. >
  425. <template slot-scope="scope">
  426. <el-button
  427. type="danger"
  428. size="mini"
  429. @click="deleteNewElement(scope.$index)"
  430. >删除</el-button
  431. >
  432. </template>
  433. </el-table-column>
  434. </el-table>
  435. </div>
  436. <span slot="footer" class="dialog-footer">
  437. <el-button @click="handleClose()">取 消</el-button>
  438. <el-button
  439. type="primary"
  440. v-throttle="2000"
  441. :disabled="newElements.length === 0"
  442. @click="addNewElementHandle()"
  443. >确 定</el-button
  444. >
  445. </span>
  446. </el-dialog>
  447. </div>
  448. </el-col>
  449. </el-row>
  450. </div>
  451. </el-col>
  452. </el-row>
  453. <!-- 关联公共WBS模板 -->
  454. <el-dialog
  455. title="关联公共WBS模板22"
  456. class="excelBox"
  457. :visible.sync="AssociatedPublicTap"
  458. modal-append-to-body
  459. append-to-body
  460. :close-on-click-modal="false"
  461. >
  462. <el-row :gutter="20">
  463. <el-col :span="12">
  464. <el-select
  465. style="width: 100%"
  466. v-model="GLExcelFrom.name"
  467. placeholder="请选择"
  468. @change="changetherr()"
  469. >
  470. <el-option
  471. v-for="(item, key) in GLExcelData"
  472. :key="key"
  473. :label="item.wbsName"
  474. :value="item.id"
  475. >
  476. </el-option>
  477. </el-select>
  478. <el-scrollbar style="height: 50vh">
  479. <div class="flex" style="margin-top: 10px" v-if="isShowInput">
  480. <el-input
  481. size="small"
  482. placeholder="输入关键字搜索"
  483. clearable
  484. @clear="clearInput"
  485. v-model="filterText1"
  486. >
  487. </el-input>
  488. <el-button size="small" class="mg-l-10" @click="treeFilter1"
  489. >搜索</el-button
  490. >
  491. </div>
  492. <el-tree
  493. v-if="GLExcelFromtag"
  494. @node-click="handleNodeClickExcel"
  495. ref="tree"
  496. class="filter-tree"
  497. style="margin-top: 10px"
  498. :props="GLExcelProps"
  499. :data="exceldata"
  500. :load="loadNodeTan"
  501. lazy
  502. node-key="id"
  503. accordion
  504. :show-checkbox="activeName == 'add'"
  505. :check-strictly="true"
  506. :default--checked-keys="selectNodeIds"
  507. >
  508. </el-tree>
  509. <el-tree
  510. style="width: 100%"
  511. ref="treeall1"
  512. v-loading="treeloading1"
  513. :data="allTreeData1"
  514. :props="treeProps1"
  515. @node-click="handleNodeClickExcel"
  516. node-key="id"
  517. :expand-on-click-node="false"
  518. :filter-node-method="filterNode1"
  519. v-show="GLExcelFromtag1"
  520. :show-checkbox="activeName == 'add'"
  521. :default--checked-keys="selectNodeIds"
  522. >
  523. </el-tree>
  524. </el-scrollbar>
  525. </el-col>
  526. <el-col :span="12" v-if="addElementForm.wbsId">
  527. <el-tabs v-model="activeName" type="card">
  528. <el-tab-pane label="关联元素表" name="link">
  529. <el-table
  530. :data="addTableData"
  531. border
  532. style="width: 100%"
  533. class="martop20"
  534. >
  535. <el-table-column
  536. prop="tableName"
  537. label="已有元素表名称"
  538. align="center"
  539. >
  540. </el-table-column>
  541. <el-table-column prop="name" label="操作" align="center">
  542. <template slot-scope="scope">
  543. <el-button
  544. type="primary"
  545. size="mini"
  546. style="margin: 0px"
  547. @click="relationMD(scope.row, '关联')"
  548. v-show="!scope.row.checknd"
  549. :loading="scope.row.loading"
  550. >选择关联</el-button
  551. >
  552. <el-button
  553. type="danger"
  554. size="mini"
  555. style="margin: 0px"
  556. @click="relationMD(scope.row, '取消关联')"
  557. v-show="scope.row.checknd"
  558. :loading="scope.row.loading"
  559. >取消关联</el-button
  560. >
  561. </template>
  562. </el-table-column>
  563. </el-table>
  564. </el-tab-pane>
  565. <el-tab-pane label="新增元素表" name="add">
  566. <div>
  567. <div class="flexBetween martop20">
  568. <el-input
  569. v-model="addElementForm.nodeName"
  570. placeholder="请输入表名"
  571. ></el-input>
  572. <el-select
  573. class="marleft10"
  574. v-model="addElementForm.tableType"
  575. placeholder="请选择表类型"
  576. >
  577. <el-option
  578. v-for="(item, index) in exceltypeData"
  579. :key="index"
  580. :label="item.dictValue"
  581. :value="item.dictKey"
  582. ></el-option>
  583. </el-select>
  584. </div>
  585. <el-select
  586. style="width: 100%"
  587. class="martop20"
  588. v-model="addElementForm.tableOwner"
  589. placeholder="请选择所属方"
  590. >
  591. <el-option
  592. v-for="(item, index) in ownerTypeList"
  593. :key="index"
  594. :label="item.dictValue"
  595. :value="item.dictKey"
  596. ></el-option>
  597. </el-select>
  598. </div>
  599. <div class="martop10 text-green">
  600. 系统检测:当前节点不存在当前元素表,允许新增
  601. </div>
  602. <div class="martop10 text-red">
  603. 系统检测:当前节点已存在当前元素表,不允许新增,请请联系项目负责人处理!!!
  604. </div>
  605. <div class="martop20">已有元素表</div>
  606. </el-tab-pane>
  607. </el-tabs>
  608. </el-col>
  609. </el-row>
  610. <span
  611. slot="footer"
  612. class="dialog-footer"
  613. style="display: flex; justify-content: center; align-items: center"
  614. >
  615. <el-button @click="AssociatedPublicClose()">取 消</el-button>
  616. <el-button
  617. style="margin-left: 30px"
  618. type="primary"
  619. @click="saveElementMD()"
  620. >确 定</el-button
  621. >
  622. </span>
  623. </el-dialog>
  624. <!-- 添加到元素库 -->
  625. <el-dialog
  626. title="保存元素表"
  627. class="excelBox"
  628. :visible.sync="eleDialog"
  629. modal-append-to-body
  630. append-to-body
  631. :close-on-click-modal="false">
  632. <div>
  633. <div class="flexBetween martop20">
  634. <el-input
  635. v-model="eleForm.nodeName"
  636. placeholder="请输入表名"
  637. ></el-input>
  638. <el-select
  639. class="marleft10"
  640. v-model="eleForm.tableType"
  641. placeholder="请选择表类型"
  642. >
  643. <el-option
  644. v-for="(item, index) in exceltypeData"
  645. :key="index"
  646. :label="item.dictValue"
  647. :value="item.dictKey"
  648. ></el-option>
  649. </el-select>
  650. </div>
  651. <el-select
  652. style="width: 100%"
  653. class="martop20"
  654. v-model="eleForm.tableOwner"
  655. placeholder="请选择所属方"
  656. >
  657. <el-option
  658. v-for="(item, index) in ownerTypeList"
  659. :key="index"
  660. :label="item.dictValue"
  661. :value="item.dictKey"
  662. ></el-option>
  663. </el-select>
  664. </div>
  665. <span slot="footer" class="dialog-footer">
  666. <el-button @click="eleDialog = false">取 消</el-button>
  667. <el-button type="primary" @click="submitEleDialog"
  668. v-preventClick v-loading="elloading"
  669. >确 定</el-button>
  670. </span>
  671. </el-dialog>
  672. </div>
  673. </div>
  674. </template>
  675. <script>
  676. import {
  677. tabLazytree,
  678. getExcelHtmlCol,
  679. excelType,
  680. excelType1,
  681. submitExcelRelationWbsTreeAndElement,
  682. getWbsTypeList,
  683. getLazytree,
  684. cancelRelation,
  685. saveRelation,
  686. searchNodeTables,
  687. tabLazytreeAll,
  688. exctabcellSave,
  689. exctabcellRemove,
  690. exctabcellUpdate,
  691. } from "@/api/exctab/excelmodel";
  692. import { dictionarydataType } from "@/api/exctab/editelement";
  693. import { getColByTabId } from "@/api/manager/AdjustForm";
  694. import { selectByNodeTable, getAlltree } from "@/api/manager/wbstree";
  695. import { getDictionary } from "@/api/system/dict";
  696. import Vue from "vue";
  697. import draggable from "vuedraggable";
  698. export default {
  699. data() {
  700. return {
  701. //#region 左侧树节点
  702. treeData: [],
  703. expandedKeys:[],//默认展开的节点
  704. defaultcheckedkeys:[],//默认选中
  705. curNode:{},//当前选中的节点
  706. elloading:false,//保存元素表按钮
  707. excelId:'',
  708. treeProps: {
  709. label: "name",
  710. children: "children",
  711. isLeaf: "hasChildren",
  712. },
  713. treeProps1: {
  714. label: "title",
  715. children: "children",
  716. isLeaf: "hasChildren",
  717. },
  718. //#endregion
  719. excelSrc: "",
  720. from: {
  721. id: "",
  722. },
  723. tableData: [], //外层table
  724. dataType: [],
  725. filterText: "", //搜索关键字
  726. filterText1: "",
  727. allTreeShow: false, //是否显示整棵树
  728. treeloading: false,
  729. treeloading1: false,
  730. AssociatedPublicTap: false,
  731. //#region 弹框属性
  732. GLExcelFrom: {
  733. id: "",
  734. name: "",
  735. search: "", //搜素框舒服的值
  736. },
  737. GLExcelData: [], //
  738. allTreeData: [],
  739. allTreeData1: [],
  740. GLExcelProps: {
  741. label: "title",
  742. children: "children",
  743. isLeaf: function (data) {
  744. if (data.hasChildren && data.isExistForm != 1) {
  745. return false;
  746. } else if (data.hasChildren && data.isExistForm == 1) {
  747. return true;
  748. } else {
  749. return true;
  750. }
  751. },
  752. },
  753. isShowInput: false,
  754. exceldata: [], //清表模板树数据
  755. addTableData: [], //新增元素信息表
  756. exceltypeData: [], //清表类型
  757. addElement: false,
  758. GLExcelFromtag: false,
  759. GLExcelFromtag1: false,
  760. addElementForm: {
  761. id: "",
  762. initTableName: "",
  763. nodeName: "",
  764. tableType: "",
  765. tableOwner: "",
  766. wbsId: "",
  767. parentId: "",
  768. },
  769. //#endregion
  770. ownerTypeList: [],
  771. activeName: "link",
  772. showLeft: true, //左侧树是否显示
  773. addNewElementDialog: false, //新增元素弹窗
  774. newElements: [],
  775. editTitleDialog: false, //编辑标题弹窗
  776. titleList: [], //标题拆分的列表
  777. titleForm: {
  778. exctabId: "",
  779. id: "",
  780. textInfo: "",
  781. textElementType: "",
  782. textDeviation: "",
  783. },
  784. titleIndex: -1,
  785. selectedId: "",
  786. nodeIds:[],
  787. nodeIds1:[],
  788. selectNodeIds:[],
  789. eleDialog:false,//保存到元素库弹窗
  790. eleForm:{
  791. nodeName:'',
  792. tableType:'',
  793. tableOwner:""
  794. },
  795. clickData:{}
  796. };
  797. },
  798. components: {
  799. draggable,
  800. },
  801. watch: {
  802. //设置保存后默认展开节点
  803. // treeData: {
  804. // handler () {
  805. // this.expandedKeys.push(this.curNode.id);
  806. // this.defaultcheckedkeys.push(this.curNode.id)
  807. // this.getExcelHtmlCol(this.curNode.id);
  808. // },
  809. // deep: true
  810. // },
  811. },
  812. methods: {
  813. //数组去重
  814. uniqueArr(arr1, arr2) {
  815. //合并两个数组
  816. arr1.push(...arr2)//或者arr1 = [...arr1,...arr2]
  817. //去重
  818. let arr3 = Array.from(new Set(arr1))//let arr3 = [...new Set(arr1)]
  819. return arr3
  820. },
  821. //搜索树
  822. treeFilter() {
  823. if (this.filterText) {
  824. this.allTreeShow = true;
  825. if (!this.allTreeData.length) {
  826. this.treeloading = true;
  827. tabLazytreeAll({
  828. modeId: this.$route.params.id,
  829. name: "",
  830. }).then((res) => {
  831. this.treeloading = false;
  832. this.allTreeData = res.data.data;
  833. this.$nextTick(() => {
  834. console.log("过滤");
  835. this.$refs.treeall.filter(this.filterText);
  836. });
  837. });
  838. } else {
  839. this.$refs.treeall.filter(this.filterText);
  840. }
  841. } else {
  842. this.allTreeShow = false;
  843. }
  844. },
  845. treeFilterAgin() {
  846. this.allTreeShow = true;
  847. if (!this.allTreeData.length) {
  848. this.treeloading = true;
  849. tabLazytreeAll({
  850. modeId: this.$route.params.id,
  851. name: "",
  852. }).then((res) => {
  853. this.treeloading = false;
  854. this.allTreeData = res.data.data;
  855. this.$nextTick(() => {
  856. console.log("过滤");
  857. this.$refs.treeall.filter(this.filterText);
  858. });
  859. });
  860. } else {
  861. this.$refs.treeall.filter(this.filterText);
  862. }
  863. } ,
  864. clearInput() {
  865. (this.selectedId = ""),
  866. (this.GLExcelFromtag1 = false),
  867. (this.GLExcelFromtag = true);
  868. if( this.$refs.tree){
  869. this.nodeIds = this.$refs.tree.getCheckedKeys();
  870. }
  871. if(this.$refs.treeall1){
  872. this.nodeIds1 = this.$refs.treeall1.getCheckedKeys();
  873. }
  874. this.selectNodeIds=this.uniqueArr(this.nodeIds,this.nodeIds1 )
  875. console.log(this.selectNodeIds,'this.selectNodeIds111111');
  876. // this.$refs.tree.setCheckedKeys(this.selectNodeIds)
  877. this.$nextTick(()=>{
  878. this.$refs.tree.setCheckedKeys(this.selectNodeIds)
  879. })
  880. },
  881. //搜索树1
  882. treeFilter1() {
  883. if (this.filterText1) {
  884. if( this.$refs.tree){
  885. this.nodeIds = this.$refs.tree.getCheckedKeys();
  886. }
  887. if(this.$refs.treeall1){
  888. this.nodeIds1 = this.$refs.treeall1.getCheckedKeys();
  889. }
  890. this.selectNodeIds=this.uniqueArr(this.nodeIds,this.nodeIds1 )
  891. this.$refs.treeall1.setCheckedKeys(this.selectNodeIds)
  892. console.log(this.selectNodeIds,'this.selectNodeIds');
  893. this.GLExcelFromtag1 = true;
  894. this.GLExcelFromtag = false;
  895. this.treeloading1 = true;
  896. console.log(this.selectedId, "selectedId");
  897. console.log(this.GLExcelFrom.name, "this.GLExcelFrom.name");
  898. // tabLazytreeAll({
  899. // modeId: this.GLExcelFrom.name,
  900. // name: "",
  901. // })
  902. getAlltree("000000", 1, this.GLExcelFrom.name).then((res) => {
  903. this.treeloading1 = false;
  904. this.allTreeData1 = res.data.data;
  905. console.log(this.exceldata, "this.exceldata");
  906. console.log(this.GLExcelFromtag, "this.GLExcelFromtag");
  907. this.$nextTick(() => {
  908. console.log("过滤2", this.filterText1);
  909. this.$refs.treeall1.filter(this.filterText1);
  910. });
  911. });
  912. }
  913. },
  914. filterNode(value, data) {
  915. if (!value) return true;
  916. return data.name.indexOf(value) !== -1;
  917. },
  918. // filterNode1(value, data) {
  919. // if (!value) return true;
  920. // return data.title.indexOf(value) !== -1;
  921. // },
  922. getReturnNode(node,_array,value){
  923. let isPass = node.data && node.data.title && node.data.title.indexOf(value) !== -1;
  924. isPass?_array.push(isPass):'';
  925. if(!isPass && node.level!=1 && node.parent){
  926. this.getReturnNode(node.parent,_array,value);
  927. }
  928. },
  929. filterNode1(value,data,node) {
  930. if(!value){
  931. return true;
  932. }
  933. let level = node.level;
  934. let _array = [];//这里使用数组存储 只是为了存储值。
  935. this.getReturnNode(node,_array,value);
  936. let result = false;
  937. _array.forEach((item)=>{
  938. result = result || item;
  939. });
  940. return result;
  941. },
  942. //#region
  943. handleNodeClick(data,node) {
  944. //树节点点击事件
  945. console.log(data,'树节点点击事件');
  946. if (data.fileType == 3) {
  947. this.clickData=data
  948. this.getExcelHtmlCol(data.id); //获取excel模板
  949. this.excelId=data.id//表格id
  950. if (this.dataType.length == 0) {
  951. this.dictionarydataType(); //数据类型字典
  952. }
  953. this.addElement = false;
  954. this.addElementForm.nodeName = data.name;
  955. this.eleForm.nodeName=data.name
  956. if (data.tabType > 0 && data.tabType < 100) {
  957. this.addElementForm.tableType = data.tabType + "";
  958. this.eleForm.tableType= data.tabType + ""
  959. } else {
  960. this.addElementForm.tableType = "";
  961. this.eleForm.tableType = "";
  962. }
  963. if (data.tableOwner > 0 && data.tableOwner < 100) {
  964. this.eleForm.tableOwner= data.tableOwner + ""
  965. } else {
  966. this.eleForm.tableOwner = "";
  967. }
  968. this.from.id = data.id;
  969. this.curNode=node
  970. this.tableData = [];
  971. //触发自动识别按钮
  972. this.automaticRecognition();
  973. }
  974. },
  975. async loadNode(node, resolve) {
  976. //懒加载获取节点
  977. if (node.level === 0) {
  978. return resolve(await this.tabLazytree(this.$route.params.id, 0));
  979. }
  980. if (node.level > 0) {
  981. return resolve(
  982. await this.tabLazytree(this.$route.params.id, node.data.id)
  983. );
  984. }
  985. },
  986. automaticRecognition() {
  987. //自动识别按钮
  988. this.getColByTabId();
  989. },
  990. pushTableData() {
  991. //
  992. // if (this.from.id) {
  993. // this.tableData.unshift({
  994. // eName: '',
  995. // eType: 1,
  996. // eAllowDeviation: ''
  997. // })
  998. // }
  999. if (this.from.id) {
  1000. this.showLeft = false;
  1001. this.addNewElementDialog = true;
  1002. this.titleList = [];
  1003. }
  1004. },
  1005. deleteTableData(key) {
  1006. //删除
  1007. exctabcellRemove(this.tableData[key].id).then(() => {
  1008. this.tableData.splice(key, 1);
  1009. this.$message({
  1010. type: "success",
  1011. message: "删除成功!",
  1012. });
  1013. });
  1014. },
  1015. async getColByTabId() {
  1016. //获取字段信息
  1017. const { data: res } = await getColByTabId({ tabId: this.from.id });
  1018. console.log(res);
  1019. if (res.code === 200) {
  1020. res.data.forEach((element) => {
  1021. //element.eName = element.textInfo;
  1022. if (element.textElementType < 1) {
  1023. element.textElementType = 1;
  1024. }
  1025. });
  1026. this.tableData = res.data;
  1027. }
  1028. },
  1029. async getExcelHtmlCol(id) {
  1030. //获取excel模板
  1031. const { data: res } = await getExcelHtmlCol({ id });
  1032. console.log(res);
  1033. if (res.code == 200) {
  1034. // let _that = this
  1035. var MyComponent = await Vue.extend({
  1036. data() {
  1037. return {
  1038. formData: {},
  1039. };
  1040. },
  1041. template: res.data,
  1042. methods: {
  1043. contextmenuClick() {},
  1044. getInformation () {},
  1045. formUploadSuccess(){},
  1046. formUploadExceed(){},
  1047. formUploadLoading(){},
  1048. delTableFormFile(){},
  1049. formUploadError(){},
  1050. uploadprogress(){},
  1051. formRemoteMethod(){},
  1052. getRegularExpression(){},
  1053. checkboxGroupChange(){},
  1054. formRemoteChange(){},
  1055. dateKeydown(){},
  1056. keyupShiftUp() {},
  1057. keyupShiftDown() {},
  1058. keyupShiftLeft() {},
  1059. keyupShiftRight() {},
  1060. inputLeftClick() {},
  1061. }
  1062. });
  1063. var component = new MyComponent().$mount();
  1064. let na = document.getElementById("parent");
  1065. na.innerHTML = `<div
  1066. class='parent'
  1067. id='parent'"
  1068. ></div>`;
  1069. document.getElementById("parent").appendChild(component.$el);
  1070. }
  1071. },
  1072. //#endregion
  1073. //#region 关联公共WBS模板弹框
  1074. establish() {
  1075. //关联WBS并创建元素
  1076. if (this.tableData.length == 0) {
  1077. this.$message({
  1078. type: "warning",
  1079. message: "至少有一条元素才能创建元素表",
  1080. });
  1081. return;
  1082. }
  1083. let arr = [];
  1084. this.tableData.forEach((element, index) => {
  1085. if (element.eName == "") {
  1086. arr.push(index + 1);
  1087. }
  1088. });
  1089. if (arr.length > 0) {
  1090. this.$message({
  1091. type: "warning",
  1092. message: arr.join(",") + "条的元素名称未填写",
  1093. });
  1094. return;
  1095. }
  1096. this.getWbsTypeList();
  1097. this.AssociatedPublicTap = true;
  1098. //清除数据
  1099. this.filterText1 = "";
  1100. this.exceldata = [];
  1101. this.allTreeData1 = [];
  1102. this.selectedId = "";
  1103. this.GLExcelFrom.name = "";
  1104. this.isShowInput = false;
  1105. //清理之前填写的数据
  1106. this.addElementForm.wbsId = "";
  1107. this.addElementForm.tableOwner = "";
  1108. if (this.$refs.tree) {
  1109. this.$refs.tree.setCheckedKeys([]);
  1110. this.$refs.tree.setCurrentKey(null);
  1111. }
  1112. this.addTableData = [];
  1113. },
  1114. addtoElement(){
  1115. const {tabId}=this.clickData
  1116. if(!tabId){
  1117. this.eleDialog=true;
  1118. this.eleForm.tableOwner=''
  1119. this.elloading=false
  1120. }else{
  1121. if (
  1122. this.clickData.name &&
  1123. this.clickData.tabType &&
  1124. this.clickData.tableOwner
  1125. ) {
  1126. this.submitExcelRelationWbsTreeAndElement({
  1127. nodeName: this.clickData.name,
  1128. tableType: this.clickData.tabType,
  1129. tableOwner: this.clickData.tableOwner,
  1130. elementList: this.tableData,
  1131. excelTabId: this.from.id,
  1132. submitStatus: 3,
  1133. })
  1134. }
  1135. }
  1136. },
  1137. submitEleDialog(){
  1138. console.log('确定');
  1139. if (
  1140. this.eleForm.nodeName &&
  1141. this.eleForm.tableType &&
  1142. this.eleForm.tableOwner
  1143. ) {
  1144. this.elloading=true
  1145. this.submitExcelRelationWbsTreeAndElement({
  1146. nodeName: this.eleForm.nodeName,
  1147. tableType: this.eleForm.tableType,
  1148. tableOwner: this.eleForm.tableOwner,
  1149. elementList: this.tableData,
  1150. excelTabId: this.from.id,
  1151. submitStatus: 3,
  1152. })
  1153. } else {
  1154. this.$message({
  1155. type: "warning",
  1156. message: "请填写和选择新增的表名,表类型,表所属方",
  1157. });
  1158. }
  1159. // this.allTreeData=[]//清空搜索树数据
  1160. // this.eleForm={}
  1161. },
  1162. AssociatedPublicClose() {
  1163. console.log("AssociatedPublicClose");
  1164. //清理之前填写的数据
  1165. this.addElementForm.wbsId = "";
  1166. // this.addElementForm.tableType = '';
  1167. this.addElementForm.tableOwner = "";
  1168. if (this.$refs.tree) {
  1169. this.$refs.tree.setCheckedKeys([]);
  1170. this.$refs.tree.setCurrentKey(null);
  1171. }
  1172. this.addTableData = [];
  1173. this.AssociatedPublicTap = false;
  1174. },
  1175. async loadNodeTan(node, resolve) {
  1176. //懒加载
  1177. console.log(node);
  1178. this.selectedId = node.data.id;
  1179. if (node.level === 0) {
  1180. return resolve(await this.getLazytree(0));
  1181. } else {
  1182. return resolve(await this.getLazytree(node.data.id));
  1183. }
  1184. },
  1185. changetherr(item) {
  1186. console.log(item, "item");
  1187. console.log(this.GLExcelFrom.name, "name");
  1188. //下拉框change事件
  1189. this.GLExcelFromtag = false;
  1190. this.GLExcelFromtag1 = false;
  1191. this.filterText1 = "";
  1192. if (this.GLExcelFrom.name != "") {
  1193. this.GLExcelFrom.search = "";
  1194. this.exceldata = [];
  1195. this.addTableData = [];
  1196. this.isShowInput = false;
  1197. this.addElementForm.wbsId = "";
  1198. this.$nextTick(() => {
  1199. this.GLExcelFromtag = true;
  1200. });
  1201. }
  1202. },
  1203. addElementMD() {
  1204. //新增元素信息表按钮
  1205. this.excelType();
  1206. this.addElement = true;
  1207. },
  1208. async getWbsTypeList() {
  1209. //获取清表模板信息
  1210. const { data: res } = await getWbsTypeList({ wbstype: 1 });
  1211. if (res.code === 200 && res.msg === "操作成功") {
  1212. this.GLExcelData = res.data;
  1213. }
  1214. },
  1215. async getLazytree(parentId) {
  1216. //清表树信息
  1217. const { data: res } = await getLazytree({
  1218. parentId: parentId,
  1219. wbsId: this.GLExcelFrom.name,
  1220. wbsType: "1",
  1221. });
  1222. console.log(res);
  1223. if (res.code === 200 && res.msg === "操作成功") {
  1224. this.isShowInput = true;
  1225. console.log(this.isShowInput, " this.isShowInput");
  1226. res.data.forEach((val) => {
  1227. val.isExistForm = !!val.isExistForm;
  1228. });
  1229. return res.data;
  1230. } else {
  1231. return [];
  1232. }
  1233. },
  1234. handleNodeClickExcel(data) {
  1235. //点击节点事件
  1236. this.addElementForm.wbsId = this.GLExcelFrom.name;
  1237. this.addElementForm.parentId = data.id;
  1238. //this.selectByNodeTable(data.id)
  1239. this.searchNodeTables(data.id);
  1240. },
  1241. async selectByNodeTable(id) {
  1242. //获取清表信息
  1243. const { data: res } = await selectByNodeTable(id);
  1244. console.log(res);
  1245. if (res.code == 200) {
  1246. if (res.data.length > 0) {
  1247. res.data.forEach((val) => {
  1248. if (val.isLinkTable == 2) {
  1249. val.checknd = true;
  1250. } else {
  1251. val.checknd = false;
  1252. }
  1253. val.loading = false;
  1254. });
  1255. this.addTableData = res.data;
  1256. } else {
  1257. this.addTableData = [];
  1258. }
  1259. }
  1260. },
  1261. //查看节点下已关联的元素表信息
  1262. searchNodeTables(id) {
  1263. searchNodeTables(id, this.from.id).then((res) => {
  1264. if (res.data.data.length > 0) {
  1265. res.data.data.forEach((val) => {
  1266. if (val.isLinkTable == 2) {
  1267. val.checknd = true;
  1268. } else {
  1269. val.checknd = false;
  1270. }
  1271. val.loading = false;
  1272. });
  1273. this.addTableData = res.data.data;
  1274. } else {
  1275. this.addTableData = [];
  1276. }
  1277. });
  1278. },
  1279. async excelType() {
  1280. //清表类型
  1281. // const { data: res } = await excelType({ code: "sys_excltab_type" });
  1282. const { data: res } = await excelType1({ code: "table_type" });
  1283. console.log(res,'清表类型');
  1284. if (res.code === 200) {
  1285. this.exceltypeData = res.data;
  1286. }
  1287. },
  1288. relationMD(row, type) {
  1289. //关联取消关联
  1290. row.loading = true;
  1291. if (type == "关联") {
  1292. saveRelation(row.id, this.from.id, this.tableData)
  1293. .then(() => {
  1294. row.checknd = true;
  1295. row.isLinkTable = 2;
  1296. })
  1297. .finally(() => {
  1298. row.loading = false;
  1299. });
  1300. } else {
  1301. cancelRelation({
  1302. id: row.id,
  1303. excelTabId: this.from.id,
  1304. })
  1305. .then(() => {
  1306. row.checknd = false;
  1307. row.isLinkTable = 1;
  1308. })
  1309. .finally(() => {
  1310. row.loading = false;
  1311. });
  1312. }
  1313. },
  1314. saveElementMD() {
  1315. //保存按钮
  1316. if (this.addElementForm.wbsId) {
  1317. if (this.activeName == "link") {
  1318. this.submitExcelRelationWbsTreeAndElement({
  1319. excelTabId: this.from.id,
  1320. elementList: this.tableData,
  1321. submitStatus: 1,
  1322. });
  1323. } else {
  1324. if (
  1325. this.addElementForm.nodeName &&
  1326. this.addElementForm.tableType &&
  1327. this.addElementForm.tableOwner
  1328. ) {
  1329. // let nodeIds = this.$refs.tree.getCheckedKeys();
  1330. // let nodeIds1 = this.$refs.treeall1.getCheckedKeys();
  1331. // console.log(nodeIds,'nodeIds');
  1332. // console.log(nodeIds1,'nodeIds1');
  1333. if( this.$refs.tree){
  1334. this.nodeIds = this.$refs.tree.getCheckedKeys();
  1335. }
  1336. if(this.$refs.treeall1){
  1337. this.nodeIds1 = this.$refs.treeall1.getCheckedKeys();
  1338. }
  1339. this.selectNodeIds=this.uniqueArr(this.nodeIds,this.nodeIds1 )
  1340. console.log(this.selectNodeIds,'去重的数组');
  1341. if (this.selectNodeIds.length < 1) {
  1342. this.$message({
  1343. type: "warning",
  1344. message: "至少勾选一个节点",
  1345. });
  1346. return;
  1347. }
  1348. this.submitExcelRelationWbsTreeAndElement({
  1349. nodeName: this.addElementForm.nodeName,
  1350. tableType: this.addElementForm.tableType,
  1351. tableOwner: this.addElementForm.tableOwner,
  1352. wbsId: this.addElementForm.wbsId,
  1353. elementList: this.tableData,
  1354. nodeIds: this.selectNodeIds,
  1355. excelTabId: this.from.id,
  1356. submitStatus: 2,
  1357. });
  1358. } else {
  1359. this.$message({
  1360. type: "warning",
  1361. message: "请填写和选择新增的表名,表类型,表所属方",
  1362. });
  1363. }
  1364. }
  1365. } else {
  1366. this.$message({
  1367. type: "warning",
  1368. message: "请先选择WBS树节点表单",
  1369. });
  1370. }
  1371. this.activeName="link"
  1372. },
  1373. async submitExcelRelationWbsTreeAndElement(da) {
  1374. try {
  1375. // 预处理数据
  1376. da.elementList.forEach((ele) => {
  1377. ele.eName = ele.textInfo;
  1378. ele.eType = ele.textElementType;
  1379. ele.eAllowDeviation = ele.textDeviation;
  1380. });
  1381. this.elloading = true; // 开始加载
  1382. const { data: res } = await submitExcelRelationWbsTreeAndElement(da);
  1383. console.log(res);
  1384. if (res.code === 200) {
  1385. this.$message({
  1386. type: "success",
  1387. message: "设置成功",
  1388. });
  1389. this.AssociatedPublicTap = false;
  1390. this.AssociatedPublicClose();
  1391. this.eleDialog = false;
  1392. } else {
  1393. this.$message({
  1394. type: "error",
  1395. message: "请求失败:" + (res.message || "未知错误"),
  1396. });
  1397. }
  1398. } catch (error) {
  1399. console.error("请求异常:", error);
  1400. } finally {
  1401. this.elloading = false; // 无论成功或失败,最终都关闭加载状态
  1402. }
  1403. },
  1404. //#endregion
  1405. // tree局部刷新
  1406. refreshNodeBy(){
  1407. console.log('刷新');
  1408. console.log(this.curNode,'this.curNode.id');
  1409. this.curNode.loaded = false;
  1410. // this.curNode.expand(); // 主动调用展开节点方法,重新查询该节点下的所有子节点
  1411. if(this.allTreeShow){
  1412. console.log('搜索树');
  1413. this.treeFilterAgin()
  1414. }else{
  1415. if (this.curNode.level === 0) {
  1416. tabLazytree({modeId:this.$route.params.id,parentId:0}).then((res)=>{
  1417. if(res.code==200){
  1418. if (res.data.length > 0) {
  1419. res.data.forEach((val) => {
  1420. val.hasChildren = !val.hasChildren;
  1421. });
  1422. }
  1423. this.treeData=res.data
  1424. }
  1425. })
  1426. }
  1427. if (this.curNode.level > 0) {
  1428. tabLazytree({modeId:this.$route.params.id,parentId:this.curNode.data.parentId}).then((res)=>{
  1429. if(res.code==200){
  1430. if (res.data.length > 0) {
  1431. res.data.forEach((val) => {
  1432. val.hasChildren = !val.hasChildren;
  1433. });
  1434. }
  1435. this.treeData=res.data
  1436. }
  1437. })
  1438. }
  1439. }
  1440. },
  1441. //#region 接口
  1442. async tabLazytree(modeId, parentId) {
  1443. const { data: res } = await tabLazytree({ modeId, parentId });
  1444. console.log(res);
  1445. if (res.code == 200) {
  1446. if (res.data.length > 0) {
  1447. res.data.forEach((val) => {
  1448. val.hasChildren = !val.hasChildren;
  1449. });
  1450. }
  1451. return res.data;
  1452. }
  1453. },
  1454. async dictionarydataType() {
  1455. //数据类型字典
  1456. const { data: res } = await dictionarydataType();
  1457. console.log(res);
  1458. if (res.code == 200) {
  1459. res.data.forEach((element) => {
  1460. element.dictKey = Number(element.dictKey);
  1461. });
  1462. this.dataType = res.data;
  1463. }
  1464. },
  1465. //#endregion
  1466. getOwnerTypelist() {
  1467. if (this.ownerTypeList.length > 1) {
  1468. return;
  1469. }
  1470. getDictionary({
  1471. code: "owner_type",
  1472. }).then((res) => {
  1473. res.data.data.forEach((element) => {
  1474. element.dictKey = Number(element.dictKey);
  1475. });
  1476. this.ownerTypeList = res.data.data;
  1477. });
  1478. },
  1479. //修改树显示状态
  1480. showLeftChange() {
  1481. this.showLeft = !this.showLeft;
  1482. },
  1483. handleClose() {
  1484. this.newElements = [];
  1485. this.addNewElementDialog = false;
  1486. this.activeName='link'
  1487. },
  1488. addNewElement() {
  1489. this.newElements.push({
  1490. exctabId: this.from.id,
  1491. textInfo: "",
  1492. });
  1493. },
  1494. deleteNewElement(index) {
  1495. this.newElements.splice(index, 1);
  1496. },
  1497. addNewElementHandle() {
  1498. exctabcellSave(this.newElements).then(() => {
  1499. this.handleClose();
  1500. //触发自动识别按钮
  1501. this.automaticRecognition();
  1502. this.$message({
  1503. type: "success",
  1504. message: "保存成功!",
  1505. });
  1506. });
  1507. },
  1508. listUp(index) {
  1509. if (index != 0) {
  1510. this.titleList[index] = this.titleList.splice(
  1511. index - 1,
  1512. 1,
  1513. this.titleList[index]
  1514. )[0];
  1515. }
  1516. },
  1517. listDown(index) {
  1518. if (index != this.titleList.length - 1) {
  1519. this.titleList[index] = this.titleList.splice(
  1520. index + 1,
  1521. 1,
  1522. this.titleList[index]
  1523. )[0];
  1524. }
  1525. },
  1526. deleTitle(index) {
  1527. this.titleList.splice(index, 1);
  1528. },
  1529. setTitleText() {
  1530. if (this.addNewElementDialog) {
  1531. this.newElements.push({
  1532. exctabId: this.from.id,
  1533. textInfo: this.titleList.join("_"),
  1534. });
  1535. this.titleList = [];
  1536. } else {
  1537. this.titleForm.textInfo = this.titleList.join("_");
  1538. }
  1539. },
  1540. editTitle() {
  1541. if (this.titleIndex < 0) {
  1542. //新增
  1543. exctabcellSave([
  1544. {
  1545. exctabId: this.from.id,
  1546. textInfo: this.titleForm.textInfo,
  1547. textElementType: this.titleForm.textElementType,
  1548. textDeviation: this.titleForm.textDeviation,
  1549. },
  1550. ]).then(() => {
  1551. this.editTitleDialog = false;
  1552. //触发自动识别按钮
  1553. this.automaticRecognition();
  1554. this.$message({
  1555. type: "success",
  1556. message: "新增成功!",
  1557. });
  1558. });
  1559. } else {
  1560. //修改
  1561. exctabcellUpdate(this.titleForm).then(() => {
  1562. this.tableData[this.titleIndex].textInfo = this.titleForm.textInfo;
  1563. //this.tableData[this.titleIndex].eName = this.titleForm.textInfo;
  1564. this.tableData[this.titleIndex].textElementType =
  1565. this.titleForm.textElementType;
  1566. this.tableData[this.titleIndex].textDeviation =
  1567. this.titleForm.textDeviation;
  1568. //console.log(this.$refs.tablescroll)
  1569. this.$refs.tablescroll.$el.scrollTop = 120 + this.titleIndex * 65;
  1570. this.editTitleDialog = false;
  1571. this.$message({
  1572. type: "success",
  1573. message: "保存成功!",
  1574. });
  1575. });
  1576. }
  1577. },
  1578. dblBtnClick(e) {
  1579. //console.log(e)
  1580. let target = e.target;
  1581. //console.log(target.getAttribute('trindex'))
  1582. if (
  1583. target.getAttribute("trindex") !== null &&
  1584. target.getAttribute("tdindex")
  1585. ) {
  1586. this.titleIndex = -1;
  1587. this.titleList = [];
  1588. this.$refs.tablescroll.$el.scrollTop = 0;
  1589. this.editTitleDialog = true;
  1590. this.showLeft = false;
  1591. let trtd =
  1592. target.getAttribute("trindex") + "_" + target.getAttribute("tdindex");
  1593. for (let i = 0; i < this.tableData.length; i++) {
  1594. let arr = this.tableData[i].xys.split(",");
  1595. if (arr.indexOf(trtd) > -1) {
  1596. this.titleIndex = i;
  1597. break;
  1598. }
  1599. }
  1600. if (this.titleIndex > -1) {
  1601. this.titleForm.textInfo = this.tableData[this.titleIndex].textInfo;
  1602. this.titleForm.textElementType =
  1603. this.tableData[this.titleIndex].textElementType;
  1604. this.titleForm.textDeviation =
  1605. this.tableData[this.titleIndex].textDeviation;
  1606. this.titleForm.exctabId = this.tableData[this.titleIndex].exctabId;
  1607. this.titleForm.id = this.tableData[this.titleIndex].id;
  1608. }
  1609. // let tdEle = this.getParentTD(target);
  1610. // if(tdEle){
  1611. // this.$refs.tablescroll.$el.scrollTop = 0;
  1612. // this.editTitleDialog = true;
  1613. // this.titleForm.textInfo = tdEle.getAttribute('title');
  1614. // //console.log(title)
  1615. // this.titleList = this.titleForm.textInfo.split('_');
  1616. // let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
  1617. // for (let i = 0; i < this.tableData.length; i++) {
  1618. // if(this.tableData[i].xys.indexOf(trtd) > -1){
  1619. // this.titleIndex = i;
  1620. // break;
  1621. // }
  1622. // }
  1623. // }
  1624. } else if (target.innerHTML && target.nodeName === "TD") {
  1625. this.titleList.push(target.innerHTML);
  1626. }
  1627. },
  1628. //excel父节点点击检测
  1629. parentClick(e) {
  1630. let target = e.target;
  1631. let bgs = document.querySelectorAll("#parent .oldlace-bg");
  1632. //console.log(bgs)
  1633. let tdEle = this.getParentTD(target);
  1634. let target1
  1635. if(tdEle){
  1636. let mydiv=tdEle.getElementsByTagName('div')
  1637. target1=mydiv[0]
  1638. }else{
  1639. tdEle=target
  1640. let mydiv=tdEle.getElementsByTagName('div')
  1641. target=mydiv[0]
  1642. }
  1643. for (let i = 0; i < bgs.length; i++) {
  1644. bgs[i].classList.remove("oldlace-bg");
  1645. }
  1646. if (
  1647. target.getAttribute("trindex") !== null &&
  1648. target.getAttribute("tdindex")
  1649. ) {
  1650. target=target
  1651. }else{
  1652. target=target1
  1653. }
  1654. //console.log(target.getAttribute('trindex'))
  1655. if (
  1656. target.getAttribute("trindex") !== null &&
  1657. target.getAttribute("tdindex")
  1658. )
  1659. {
  1660. let tdEle = this.getParentTD(target);
  1661. if (tdEle) {
  1662. target.classList.add("oldlace-bg");
  1663. let trtd =
  1664. target.getAttribute("trindex") +
  1665. "_" +
  1666. target.getAttribute("tdindex");
  1667. for (let i = 0; i < this.tableData.length; i++) {
  1668. let arr = this.tableData[i].xys.split(",");
  1669. if (arr.indexOf(trtd) > -1) {
  1670. this.titleIndex = i;
  1671. break;
  1672. }
  1673. }
  1674. //this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
  1675. //console.log(this.$refs.tablescroll.$el.scrollTop)
  1676. this.$nextTick(() => {
  1677. let row = document.querySelectorAll(".warning-row");
  1678. if (row.length) {
  1679. this.$refs.tablescroll.$el.scrollTop = row[0].offsetTop;
  1680. }
  1681. //console.dir(row[0])
  1682. });
  1683. }
  1684. }
  1685. },
  1686. getParentTD(ele) {
  1687. let targetParent = ele.parentNode;
  1688. while (targetParent.nodeName !== "TD") {
  1689. if (targetParent.id == "parent") {
  1690. return null;
  1691. }
  1692. targetParent = targetParent.parentNode;
  1693. }
  1694. return targetParent;
  1695. },
  1696. tableRowClassName({ rowIndex }) {
  1697. if (rowIndex === this.titleIndex) {
  1698. return "warning-row";
  1699. }
  1700. return "";
  1701. },
  1702. //保存单条元素
  1703. saveELe(row) {
  1704. if (row.textInfo) {
  1705. exctabcellUpdate(row).then(() => {
  1706. this.$message({
  1707. type: "success",
  1708. message: "保存成功!",
  1709. });
  1710. });
  1711. } else {
  1712. this.$message({
  1713. type: "warning",
  1714. message: "请填写元素名称",
  1715. });
  1716. }
  1717. },
  1718. },
  1719. created() {
  1720. this.getOwnerTypelist();
  1721. this.excelType();
  1722. },
  1723. };
  1724. </script>
  1725. <style lang="scss" scoped>
  1726. .text-green{
  1727. color:rgba(82, 178, 0, 1);
  1728. }
  1729. .text-red{
  1730. color:red;
  1731. }
  1732. .boxswai {
  1733. padding: 0px 14px 10px 14px !important;
  1734. }
  1735. .dingwei {
  1736. position: fixed;
  1737. bottom: 40px;
  1738. right: 40px;
  1739. }
  1740. //树结构超长后产生滚动条
  1741. .el-tree > .el-tree-node {
  1742. min-width: 100%;
  1743. display: inline-block;
  1744. }
  1745. .boxswai {
  1746. height: 100%;
  1747. box-sizing: border-box;
  1748. padding-bottom: 10px;
  1749. }
  1750. .title-item {
  1751. box-sizing: border-box;
  1752. width: 100%;
  1753. font-size: 16px;
  1754. height: 30px;
  1755. padding: 3px 20px;
  1756. background-color: #f3f3f3;
  1757. color: #ee7049;
  1758. margin-bottom: 6px;
  1759. cursor: pointer;
  1760. }
  1761. ::v-deep .el-table .warning-row {
  1762. background: oldlace;
  1763. }
  1764. .region {
  1765. position: relative;
  1766. height: 100%;
  1767. }
  1768. .region ::v-deep .el-dialog__wrapper {
  1769. position: absolute !important;
  1770. }
  1771. .region ::v-deep .v-modal {
  1772. position: absolute !important;
  1773. }
  1774. #parent ::v-deep .oldlace-bg {
  1775. background-color: oldlace;
  1776. }
  1777. </style>
  1778. <style lang="scss">
  1779. .parent .el-input .el-input__inner {
  1780. -webkit-appearance: none;
  1781. background-color: #fff;
  1782. background-image: none;
  1783. border-radius: 4px;
  1784. border: 1px solid #dcdfe6;
  1785. -webkit-box-sizing: border-box;
  1786. box-sizing: border-box;
  1787. color: #606266;
  1788. display: inline-block;
  1789. font-size: inherit;
  1790. height: inherit;
  1791. line-height: 40px;
  1792. outline: 0;
  1793. padding: 0 15px;
  1794. -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  1795. transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  1796. width: 100%;
  1797. }
  1798. </style>