index.vue 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  1. <template>
  2. <div class="boxswai">
  3. <div class="boxnei">
  4. <el-row
  5. :gutter="0"
  6. style="height:100%;"
  7. >
  8. <el-col
  9. :span="showLeft?5:0"
  10. style="height:99%;"
  11. >
  12. <div
  13. style="fontSize:18px; font-weight: 900;"
  14. class="marbottom5"
  15. >元素识别</div>
  16. <div style="height:98%;overflow: auto;width:auto;">
  17. <div class="flex">
  18. <el-input
  19. size="small"
  20. placeholder="输入关键字搜索"
  21. clearable
  22. @clear="allTreeShow = false"
  23. v-model="filterText">
  24. </el-input>
  25. <el-button size="small" class="mg-l-10" @click="treeFilter">搜索</el-button>
  26. </div>
  27. <el-tree
  28. :data="treeData"
  29. :props="treeProps"
  30. @node-click="handleNodeClick"
  31. :load="loadNode"
  32. :expand-on-click-node="false"
  33. lazy
  34. v-show="!allTreeShow"
  35. ></el-tree>
  36. <el-tree
  37. style="width:100%;"
  38. ref="treeall"
  39. v-loading="treeloading"
  40. :data="allTreeData"
  41. :props="treeProps"
  42. @node-click="handleNodeClick"
  43. node-key="id"
  44. :expand-on-click-node="false"
  45. :filter-node-method="filterNode"
  46. v-show="allTreeShow"
  47. >
  48. </el-tree>
  49. </div>
  50. </el-col>
  51. <el-col
  52. :span="showLeft?19:24"
  53. style="height:98%;display: flex;"
  54. >
  55. <div class="flex flex-center" style="width:20px;height:100%;cursor: pointer;" @click="showLeftChange">
  56. <i v-if="showLeft" class="el-icon-d-arrow-left"></i>
  57. <i v-else class="el-icon-d-arrow-right"></i>
  58. </div>
  59. <div class="flex1" style="padding-left:10px;">
  60. <div v-if="addElementForm.nodeName==''">表名称</div>
  61. <div v-else>{{addElementForm.nodeName}}</div>
  62. <el-row
  63. class="martop20"
  64. :gutter="20"
  65. style="height:96%;"
  66. >
  67. <el-col
  68. :span="showLeft?16:12"
  69. style="overflow:auto;height:100%;border:1px solid black; border-radius: 4px;box-sizing: border-box;padding: 10px 10px;"
  70. >
  71. <div
  72. class="parent"
  73. id='parent'
  74. @dblclick="dblBtnClick($event)"
  75. @click="parentClick($event)"
  76. >
  77. </div>
  78. </el-col>
  79. <el-col
  80. :span="showLeft?8:12" ref="tablescroll"
  81. style="height:100%;"
  82. :style="{'overflow':'auto'}"
  83. >
  84. <div class="region">
  85. <div class="flexBetween flexItemsC">
  86. <div>
  87. <el-button
  88. type="info"
  89. size="mini"
  90. :disabled="from.id==''"
  91. @click="automaticRecognition"
  92. >自动识别</el-button>
  93. <el-button
  94. type="success"
  95. size="mini"
  96. @click="establish()"
  97. :disabled="from.id==''"
  98. >关联WBS并创建元素</el-button>
  99. </div>
  100. <div
  101. class="el-icon-plus"
  102. @click="pushTableData"
  103. style="width:16px;height:16px;backgroundColor:#1DD81D;color:#fff;cursor: pointer;"
  104. ></div>
  105. </div>
  106. <el-table
  107. class="martop20"
  108. :data="tableData"
  109. border :row-class-name="tableRowClassName"
  110. style="width: 100%"
  111. >
  112. <el-table-column
  113. type="index"
  114. label="坐标"
  115. >
  116. </el-table-column>
  117. <el-table-column
  118. prop="textInfo"
  119. label="元素名称"
  120. >
  121. <template slot-scope="scope">
  122. <el-input
  123. v-model="scope.row.textInfo"
  124. placeholder="请输入内容"
  125. ></el-input>
  126. </template>
  127. </el-table-column>
  128. <el-table-column
  129. prop="textElementType"
  130. label="数据类型"
  131. >
  132. <template slot-scope="scope">
  133. <el-select
  134. v-model="scope.row.textElementType"
  135. placeholder="请选择"
  136. >
  137. <el-option
  138. v-for="item in dataType"
  139. :key="item.dictKey"
  140. :label="item.dictValue"
  141. :value="item.dictKey"
  142. >
  143. </el-option>
  144. </el-select>
  145. </template>
  146. </el-table-column>
  147. <el-table-column
  148. prop="textDeviation"
  149. label="允许偏差值"
  150. >
  151. <template slot-scope="scope">
  152. <el-input
  153. v-model="scope.row.textDeviation"
  154. placeholder="请输入内容"
  155. ></el-input>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="操作" width="100">
  159. <template slot-scope="scope">
  160. <el-link style="margin-right:16px;"
  161. type="success"
  162. @click="saveELe(scope.row)"
  163. >保存</el-link>
  164. <el-link
  165. type="danger"
  166. @click="deleteTableData(scope.$index)"
  167. >删除</el-link>
  168. </template>
  169. </el-table-column>
  170. </el-table>
  171. <!-- <el-button
  172. type="success"
  173. class="martop20 dingwei"
  174. @click="establish()"
  175. :disabled="from.id==''"
  176. >关联WBS并创建元素</el-button> -->
  177. <el-dialog
  178. title="编辑元素信息"
  179. :visible.sync="editTitleDialog"
  180. width="80%"
  181. :modal-append-to-body='false'
  182. :append-to-body="false"
  183. >
  184. <div>
  185. <draggable v-model="titleList">
  186. <div
  187. v-for="(item,key) in titleList"
  188. :key="key"
  189. class="flexBetween flexItemsC title-item"
  190. >
  191. <div>
  192. <span>{{item}}</span>
  193. </div>
  194. <div class="flexItemsC">
  195. <i
  196. @click="listUp(key)"
  197. class="el-icon-top"
  198. :style="{'font-size':'20px','color':key==0 ?'#aaa':'#0A8CD5', 'cursor': key!=0?'pointer':'default'}"
  199. ></i>
  200. <i
  201. @click="listDown(key)"
  202. class="el-icon-bottom marleft5"
  203. :style="{'font-size':'20px','color':key==titleList.length-1?'#aaa':'#0A8CD5', 'cursor': key!=titleList.length-1?'pointer':'default'}"
  204. ></i>
  205. <i
  206. @click="deleTitle(key)"
  207. class="el-icon-circle-close marleft5"
  208. :style="{'font-size':'20px',
  209. 'color':'#ee7049','cursor':'pointer'}"
  210. ></i>
  211. </div>
  212. </div>
  213. </draggable>
  214. </div>
  215. <div style="margin-top:50px;">
  216. <div class="flex jc-sb mg-b-10">
  217. <div class="flex jc-al-c">
  218. <span style="margin-right:10px;">数据类型</span>
  219. <el-select
  220. v-model="titleForm.textElementType"
  221. placeholder="请选择" style="width:130px"
  222. >
  223. <el-option
  224. v-for="item in dataType"
  225. :key="item.dictKey"
  226. :label="item.dictValue"
  227. :value="item.dictKey"
  228. >
  229. </el-option>
  230. </el-select>
  231. <span style="margin:0 10px;">允许偏差值</span>
  232. <el-input
  233. v-model="titleForm.textDeviation"
  234. placeholder="请输入内容" style="width:150px"
  235. ></el-input>
  236. </div>
  237. <div>
  238. <el-button size="medium" type="primary" @click="setTitleText">合成文本</el-button>
  239. </div>
  240. </div>
  241. <el-input type="textarea" rows="5" v-model="titleForm.textInfo"></el-input>
  242. </div>
  243. <el-alert
  244. title="该输入框没有匹配到对应元素字段,确定修改将会新增一个元素字段" v-if="titleIndex < 0"
  245. type="warning" :closable="false"
  246. effect="dark" style="margin-top:10px;">
  247. </el-alert>
  248. <span
  249. slot="footer"
  250. class="dialog-footer"
  251. >
  252. <el-button @click="editTitleDialog = false">取 消</el-button>
  253. <el-button
  254. type="primary"
  255. v-throttle='2000'
  256. @click="editTitle()"
  257. >确定修改</el-button>
  258. </span>
  259. </el-dialog>
  260. <el-dialog
  261. title="添加新元素字段"
  262. :visible.sync="addNewElementDialog"
  263. :before-close="handleClose"
  264. width="80%"
  265. :modal-append-to-body='false'
  266. :append-to-body="false"
  267. >
  268. <div>
  269. <!-- <i
  270. @click="addNewElement"
  271. class="el-icon-circle-plus marbottom10"
  272. style="color:red; font-size:24px; float: right;cursor: pointer;"
  273. ></i> -->
  274. <div>
  275. <draggable v-model="titleList">
  276. <div
  277. v-for="(item,key) in titleList"
  278. :key="key"
  279. class="flexBetween flexItemsC title-item"
  280. >
  281. <div>
  282. <span>{{item}}</span>
  283. </div>
  284. <div class="flexItemsC">
  285. <i
  286. @click="listUp(key)"
  287. class="el-icon-top"
  288. :style="{'font-size':'20px','color':key==0 ?'#aaa':'#0A8CD5', 'cursor': key!=0?'pointer':'default'}"
  289. ></i>
  290. <i
  291. @click="listDown(key)"
  292. class="el-icon-bottom marleft5"
  293. :style="{'font-size':'20px','color':key==titleList.length-1?'#aaa':'#0A8CD5', 'cursor': key!=titleList.length-1?'pointer':'default'}"
  294. ></i>
  295. <i
  296. @click="deleTitle(key)"
  297. class="el-icon-circle-close marleft5"
  298. :style="{'font-size':'20px',
  299. 'color':'#ee7049','cursor':'pointer'}"
  300. ></i>
  301. </div>
  302. </div>
  303. </draggable>
  304. <div class="flex jc-sb mg-b-10">
  305. <div class="flex jc-al-c">
  306. </div>
  307. <div>
  308. <el-button size="medium" type="primary" @click="setTitleText">合成文本</el-button>
  309. </div>
  310. </div>
  311. </div>
  312. <el-table
  313. :data="newElements"
  314. height="250"
  315. border
  316. style="width: 100%"
  317. >
  318. <el-table-column
  319. label="元素名称"
  320. >
  321. <template slot-scope="scope">
  322. <el-input
  323. v-model="scope.row.textInfo"
  324. placeholder="请输入内容"
  325. ></el-input>
  326. </template>
  327. </el-table-column>
  328. <el-table-column
  329. prop="textElementType"
  330. label="数据类型"
  331. >
  332. <template slot-scope="scope">
  333. <el-select
  334. v-model="scope.row.textElementType"
  335. placeholder="请选择"
  336. >
  337. <el-option
  338. v-for="item in dataType"
  339. :key="item.dictKey"
  340. :label="item.dictValue"
  341. :value="item.dictKey"
  342. >
  343. </el-option>
  344. </el-select>
  345. </template>
  346. </el-table-column>
  347. <el-table-column
  348. prop="textDeviation"
  349. label="允许偏差值"
  350. >
  351. <template slot-scope="scope">
  352. <el-input
  353. v-model="scope.row.textDeviation"
  354. placeholder="请输入内容"
  355. ></el-input>
  356. </template>
  357. </el-table-column>
  358. <el-table-column
  359. prop="date"
  360. align="center"
  361. width="120"
  362. label="操作"
  363. >
  364. <template slot-scope="scope">
  365. <el-button
  366. type="danger"
  367. size="mini"
  368. @click="deleteNewElement(scope.$index)"
  369. >删除</el-button>
  370. </template>
  371. </el-table-column>
  372. </el-table>
  373. </div>
  374. <span
  375. slot="footer"
  376. class="dialog-footer"
  377. >
  378. <el-button @click="handleClose()">取 消</el-button>
  379. <el-button
  380. type="primary"
  381. v-throttle='2000'
  382. :disabled="newElements.length===0"
  383. @click="addNewElementHandle()"
  384. >确 定</el-button>
  385. </span>
  386. </el-dialog>
  387. </div>
  388. </el-col>
  389. </el-row>
  390. </div>
  391. </el-col>
  392. </el-row>
  393. <!-- 关联公共WBS模板 -->
  394. <el-dialog
  395. title="关联公共WBS模板"
  396. class="excelBox"
  397. :visible.sync="AssociatedPublicTap"
  398. modal-append-to-body
  399. append-to-body
  400. >
  401. <el-row :gutter="20">
  402. <el-col :span="12">
  403. <el-select
  404. style="width:100%;"
  405. v-model="GLExcelFrom.name"
  406. placeholder="请选择"
  407. @change="changetherr()"
  408. >
  409. <el-option
  410. v-for="(item,key) in GLExcelData"
  411. :key="key"
  412. :label="item.wbsName"
  413. :value="item.id"
  414. >
  415. </el-option>
  416. </el-select>
  417. <el-scrollbar style="height:50vh;">
  418. <el-tree
  419. v-if="GLExcelFromtag"
  420. @node-click="handleNodeClickExcel"
  421. ref="tree"
  422. class="filter-tree"
  423. style="margin-top:10px;"
  424. :props="GLExcelProps"
  425. :data="exceldata"
  426. :load="loadNodeTan"
  427. lazy
  428. node-key="id"
  429. accordion
  430. :show-checkbox="activeName == 'add'"
  431. :check-strictly="true"
  432. >
  433. </el-tree>
  434. </el-scrollbar>
  435. </el-col>
  436. <el-col
  437. :span="12"
  438. v-if="addElementForm.wbsId"
  439. >
  440. <el-tabs v-model="activeName" type="card" >
  441. <el-tab-pane label="关联元素表" name="link">
  442. <el-table
  443. :data="addTableData"
  444. border
  445. style="width: 100%"
  446. class="martop20"
  447. >
  448. <el-table-column
  449. prop="tableName"
  450. label="已有元素表名称"
  451. align="center"
  452. >
  453. </el-table-column>
  454. <el-table-column
  455. prop="name"
  456. label="操作"
  457. align="center"
  458. >
  459. <template slot-scope="scope">
  460. <el-button
  461. type="primary"
  462. size="mini"
  463. style="margin:0px;"
  464. @click="relationMD(scope.row,'关联')"
  465. v-show="!scope.row.checknd"
  466. :loading="scope.row.loading"
  467. >选择关联</el-button>
  468. <el-button
  469. type="danger"
  470. size="mini"
  471. style="margin:0px;"
  472. @click="relationMD(scope.row,'取消关联')"
  473. v-show="scope.row.checknd"
  474. :loading="scope.row.loading"
  475. >取消关联</el-button>
  476. </template>
  477. </el-table-column>
  478. </el-table>
  479. </el-tab-pane>
  480. <el-tab-pane label="新增元素表" name="add">
  481. <div>
  482. <div class="flexBetween martop20">
  483. <el-input
  484. v-model="addElementForm.nodeName"
  485. placeholder="请输入表名"
  486. ></el-input>
  487. <el-select
  488. class="marleft10"
  489. v-model="addElementForm.tableType"
  490. placeholder="请选择表类型"
  491. >
  492. <el-option
  493. v-for="(item,index) in exceltypeData"
  494. :key="index"
  495. :label="item.dictValue"
  496. :value="item.dictKey"
  497. ></el-option>
  498. </el-select>
  499. </div>
  500. <el-select
  501. style="width:100%;"
  502. class="martop20"
  503. v-model="addElementForm.tableOwner"
  504. placeholder="请选择所属方"
  505. >
  506. <el-option
  507. v-for="(item,index) in ownerTypeList"
  508. :key="index"
  509. :label="item.dictValue"
  510. :value="item.dictKey"
  511. ></el-option>
  512. </el-select>
  513. </div>
  514. </el-tab-pane>
  515. </el-tabs>
  516. </el-col>
  517. </el-row>
  518. <span
  519. slot="footer"
  520. class="dialog-footer"
  521. style="display: flex;justify-content: center;align-items: center;"
  522. >
  523. <el-button @click="AssociatedPublicClose()">取 消</el-button>
  524. <el-button
  525. style="margin-left:30px;"
  526. type="primary"
  527. @click="saveElementMD()"
  528. >确 定</el-button>
  529. </span>
  530. </el-dialog>
  531. </div>
  532. </div>
  533. </template>
  534. <script>
  535. import { tabLazytree, getExcelHtmlCol, excelType, submitExcelRelationWbsTreeAndElement, getWbsTypeList, getLazytree,cancelRelation,saveRelation,searchNodeTables,tabLazytreeAll,exctabcellSave,exctabcellRemove , exctabcellUpdate} from "@/api/exctab/excelmodel";
  536. import { dictionarydataType } from "@/api/exctab/editelement";
  537. import { getColByTabId } from "@/api/manager/AdjustForm";
  538. import { selectByNodeTable } from "@/api/manager/wbstree";
  539. import { getDictionary } from "@/api/system/dict";
  540. import Vue from 'vue'
  541. import draggable from 'vuedraggable'
  542. export default {
  543. data () {
  544. return {
  545. //#region 左侧树节点
  546. treeData: [],
  547. treeProps: {
  548. label: 'name',
  549. children: 'children',
  550. isLeaf: 'hasChildren'
  551. },
  552. //#endregion
  553. excelSrc: '',
  554. from: {
  555. id: '',
  556. },
  557. tableData: [],//外层table
  558. dataType: [],
  559. filterText:"",//搜索关键字
  560. allTreeShow:false,//是否显示整棵树
  561. treeloading:false,
  562. AssociatedPublicTap: false,
  563. //#region 弹框属性
  564. GLExcelFrom: {
  565. id: "",
  566. name: '',
  567. search: '',//搜素框舒服的值
  568. },
  569. GLExcelData: [],//
  570. allTreeData:[],
  571. GLExcelProps: {
  572. label: 'title',
  573. children: 'children',
  574. isLeaf: function (data) {
  575. if (data.hasChildren && data.isExistForm != 1) {
  576. return false
  577. } else if (data.hasChildren && data.isExistForm == 1) {
  578. return true
  579. } else {
  580. return true
  581. }
  582. }
  583. },
  584. exceldata: [],//清表模板树数据
  585. addTableData: [],//新增元素信息表
  586. exceltypeData: [],//清表类型
  587. addElement: false,
  588. GLExcelFromtag: false,
  589. addElementForm: {
  590. id: "",
  591. initTableName: "",
  592. nodeName: '',
  593. tableType: '',
  594. tableOwner: '',
  595. wbsId: '',
  596. parentId: '',
  597. },
  598. //#endregion
  599. ownerTypeList: [],
  600. activeName:'link',
  601. showLeft:true,//左侧树是否显示
  602. addNewElementDialog:false,//新增元素弹窗
  603. newElements:[],
  604. editTitleDialog:false,//编辑标题弹窗
  605. titleList:[],//标题拆分的列表
  606. titleForm:{
  607. exctabId:'',
  608. id:'',
  609. textInfo:'',
  610. textElementType:'',
  611. textDeviation:'',
  612. },
  613. titleIndex:-1,
  614. }
  615. },
  616. components: {
  617. draggable,
  618. },
  619. methods: {
  620. //搜索树
  621. treeFilter(){
  622. if(this.filterText){
  623. this.allTreeShow = true;
  624. if(!this.allTreeData.length){
  625. this.treeloading = true;
  626. tabLazytreeAll({
  627. modeId: this.$route.params.id,
  628. name:'',
  629. }).then((res)=>{
  630. this.treeloading = false;
  631. this.allTreeData = res.data.data;
  632. this.$nextTick(()=>{
  633. this.$refs.treeall.filter(this.filterText);
  634. })
  635. })
  636. }else{
  637. this.$refs.treeall.filter(this.filterText);
  638. }
  639. }else{
  640. this.allTreeShow = false;
  641. }
  642. },
  643. filterNode(value, data) {
  644. if (!value) return true;
  645. return data.name.indexOf(value) !== -1;
  646. },
  647. //#region
  648. handleNodeClick (data) {//树节点点击事件
  649. console.log(data);
  650. if (data.fileType == 3) {
  651. this.getExcelHtmlCol(data.id)//获取excel模板
  652. if (this.dataType.length == 0) {
  653. this.dictionarydataType() //数据类型字典
  654. }
  655. this.addElement = false
  656. this.addElementForm.nodeName = data.name
  657. this.from.id = data.id
  658. this.tableData = [];
  659. //触发自动识别按钮
  660. this.automaticRecognition();
  661. }
  662. },
  663. async loadNode (node, resolve) {//懒加载获取节点
  664. if (node.level === 0) {
  665. return resolve(await this.tabLazytree(this.$route.params.id, 0))
  666. }
  667. if (node.level > 0) {
  668. return resolve(await this.tabLazytree(this.$route.params.id, node.data.id))
  669. }
  670. },
  671. automaticRecognition () {//自动识别按钮
  672. this.getColByTabId()
  673. },
  674. pushTableData () {//
  675. // if (this.from.id) {
  676. // this.tableData.unshift({
  677. // eName: '',
  678. // eType: 1,
  679. // eAllowDeviation: ''
  680. // })
  681. // }
  682. if (this.from.id) {
  683. this.showLeft = false;
  684. this.addNewElementDialog = true;
  685. }
  686. },
  687. deleteTableData (key) {//删除
  688. exctabcellRemove(this.tableData[key].id).then(()=>{
  689. this.tableData.splice(key, 1)
  690. this.$message({
  691. type: "success",
  692. message: "删除成功!"
  693. });
  694. })
  695. },
  696. async getColByTabId () {//获取字段信息
  697. const { data: res } = await getColByTabId({ tabId: this.from.id })
  698. console.log(res);
  699. if (res.code === 200) {
  700. res.data.forEach((element)=>{
  701. //element.eName = element.textInfo;
  702. if(element.textElementType < 1){
  703. element.textElementType = 1;
  704. }
  705. })
  706. this.tableData = res.data
  707. }
  708. },
  709. async getExcelHtmlCol (id) {//获取excel模板
  710. const { data: res } = await getExcelHtmlCol({ id })
  711. console.log(res);
  712. if (res.code == 200) {
  713. // let _that = this
  714. var MyComponent = await Vue.extend({
  715. data () {
  716. return {
  717. formData: {}
  718. }
  719. },
  720. template: res.data,
  721. })
  722. var component = new MyComponent().$mount()
  723. let na = document.getElementById('parent')
  724. na.innerHTML = `<div
  725. class='parent'
  726. id='parent'"
  727. ></div>`
  728. document.getElementById('parent').appendChild(component.$el);
  729. }
  730. },
  731. //#endregion
  732. //#region 关联公共WBS模板弹框
  733. establish () {//关联WBS并创建元素
  734. if(this.tableData.length == 0){
  735. this.$message({
  736. type: 'warning',
  737. message: '至少有一条元素才能创建元素表'
  738. })
  739. return;
  740. }
  741. let arr = [];
  742. this.tableData.forEach((element,index)=>{
  743. if(element.eName == ''){
  744. arr.push(index+1);
  745. }
  746. })
  747. if(arr.length > 0){
  748. this.$message({
  749. type: 'warning',
  750. message: arr.join(',')+'条的元素名称未填写'
  751. })
  752. return;
  753. }
  754. this.getWbsTypeList()
  755. this.AssociatedPublicTap = true
  756. },
  757. AssociatedPublicClose () {//关联公共WBS模板关闭事件
  758. // this.addElementForm = {
  759. // id: "",
  760. // initTableName: "",
  761. // nodeName: this.addElementForm.nodeName,
  762. // tableType: '',
  763. // tableOwner: '',
  764. // wbsId: '',
  765. // parentId: '',
  766. // }
  767. // this.GLExcelFrom = {
  768. // name: '',
  769. // search: ''
  770. // }
  771. // this.exceldata = []
  772. // this.addElement = false
  773. //清理之前填写的数据
  774. this.addElementForm.wbsId = '';
  775. this.addElementForm.tableType = '';
  776. this.addElementForm.tableOwner = '';
  777. if(this.$refs.tree){
  778. this.$refs.tree.setCheckedKeys([]);
  779. this.$refs.tree.setCurrentKey(null);
  780. }
  781. this.addTableData = []
  782. this.AssociatedPublicTap = false
  783. },
  784. async loadNodeTan (node, resolve) {//懒加载
  785. console.log(node);
  786. if (node.level === 0) {
  787. return resolve(await this.getLazytree(0));
  788. } else {
  789. return resolve(await this.getLazytree(node.data.id));
  790. }
  791. },
  792. changetherr () {//下拉框change事件
  793. this.GLExcelFromtag = false
  794. if (this.GLExcelFrom.name != "") {
  795. this.GLExcelFrom.search = ''
  796. this.exceldata = []
  797. this.addTableData = []
  798. this.addElementForm.wbsId = ''
  799. this.$nextTick(() => {
  800. this.GLExcelFromtag = true
  801. })
  802. }
  803. },
  804. addElementMD () {//新增元素信息表按钮
  805. this.excelType()
  806. this.addElement = true
  807. },
  808. async getWbsTypeList () {//获取清表模板信息
  809. const { data: res } = await getWbsTypeList({ wbstype: 1 })
  810. console.log(res);
  811. if (res.code === 200 && res.msg === '操作成功') {
  812. this.GLExcelData = res.data
  813. }
  814. },
  815. async getLazytree (parentId) {//清表树信息
  816. const { data: res } = await getLazytree({
  817. parentId: parentId,
  818. wbsId: this.GLExcelFrom.name,
  819. wbsType: '1'
  820. })
  821. console.log(res);
  822. if (res.code === 200 && res.msg === '操作成功') {
  823. res.data.forEach(val => {
  824. val.isExistForm = !!val.isExistForm
  825. })
  826. return res.data
  827. } else {
  828. return []
  829. }
  830. },
  831. handleNodeClickExcel (data) {//点击节点事件
  832. this.addElementForm.wbsId = this.GLExcelFrom.name
  833. this.addElementForm.parentId = data.id
  834. //this.selectByNodeTable(data.id)
  835. this.searchNodeTables(data.id)
  836. },
  837. async selectByNodeTable (id) {//获取清表信息
  838. const { data: res } = await selectByNodeTable(id)
  839. console.log(res);
  840. if (res.code == 200) {
  841. if (res.data.length > 0) {
  842. res.data.forEach(val => {
  843. if (val.isLinkTable == 2) {
  844. val.checknd = true
  845. } else {
  846. val.checknd = false
  847. }
  848. val.loading = false;
  849. })
  850. this.addTableData = res.data
  851. }else{
  852. this.addTableData = []
  853. }
  854. }
  855. },
  856. //查看节点下已关联的元素表信息
  857. searchNodeTables(id){
  858. searchNodeTables(id,this.from.id).then((res)=>{
  859. if (res.data.data.length > 0) {
  860. res.data.data.forEach(val => {
  861. if (val.isLinkTable == 2) {
  862. val.checknd = true
  863. } else {
  864. val.checknd = false
  865. }
  866. val.loading = false;
  867. })
  868. this.addTableData = res.data.data
  869. }else{
  870. this.addTableData = []
  871. }
  872. })
  873. },
  874. async excelType () {//清表类型
  875. const { data: res } = await excelType({ code: 'sys_excltab_type' })
  876. console.log(res);
  877. if (res.code === 200) {
  878. this.exceltypeData = res.data
  879. }
  880. },
  881. relationMD (row, type) {//关联取消关联
  882. row.loading = true;
  883. if (type == '关联') {
  884. saveRelation(row.id,this.from.id,this.tableData).then(()=>{
  885. row.checknd = true;
  886. row.isLinkTable = 2;
  887. }).finally(()=>{
  888. row.loading = false;
  889. })
  890. } else {
  891. cancelRelation({
  892. id:row.id,
  893. excelTabId:this.from.id,
  894. }).then(()=>{
  895. row.checknd = false;
  896. row.isLinkTable = 1;
  897. }).finally(()=>{
  898. row.loading = false;
  899. })
  900. }
  901. },
  902. saveElementMD () {//保存按钮
  903. if (this.addElementForm.wbsId) {
  904. if (this.activeName == 'link') {
  905. this.submitExcelRelationWbsTreeAndElement({
  906. excelTabId:this.from.id,
  907. elementList: this.tableData,
  908. submitStatus:1
  909. })
  910. } else {
  911. if (this.addElementForm.nodeName && this.addElementForm.tableType && this.addElementForm.tableOwner) {
  912. let nodeIds = this.$refs.tree.getCheckedKeys();
  913. if(nodeIds.length < 1){
  914. this.$message({
  915. type: 'warning',
  916. message: '至少勾选一个节点'
  917. })
  918. return;
  919. }
  920. this.submitExcelRelationWbsTreeAndElement({
  921. nodeName: this.addElementForm.nodeName,
  922. tableType: this.addElementForm.tableType,
  923. tableOwner: this.addElementForm.tableOwner,
  924. wbsId: this.addElementForm.wbsId,
  925. elementList: this.tableData,
  926. nodeIds:nodeIds,
  927. excelTabId:this.from.id,
  928. submitStatus:2
  929. })
  930. }else{
  931. this.$message({
  932. type: 'warning',
  933. message: '请填写和选择新增的表名,表类型,表所属方'
  934. })
  935. }
  936. }
  937. } else {
  938. this.$message({
  939. type: 'warning',
  940. message: '请先选择WBS树节点表单'
  941. })
  942. }
  943. },
  944. async submitExcelRelationWbsTreeAndElement (da) {//保存接口
  945. da.elementList.forEach((ele)=>{
  946. ele.eName = ele.textInfo;
  947. ele.eType = ele.textElementType;
  948. ele.eAllowDeviation = ele.textDeviation;
  949. })
  950. const { data: res } = await submitExcelRelationWbsTreeAndElement(da)
  951. console.log(res);
  952. if (res.code == 200) {
  953. this.$message({
  954. type: 'success',
  955. message: '设置成功'
  956. })
  957. this.AssociatedPublicTap = false
  958. this.AssociatedPublicClose()
  959. }
  960. },
  961. //#endregion
  962. //#region 接口
  963. async tabLazytree (modeId, parentId) {
  964. const { data: res } = await tabLazytree({ modeId, parentId })
  965. console.log(res);
  966. if (res.code == 200) {
  967. if (res.data.length > 0) {
  968. res.data.forEach(val => {
  969. val.hasChildren = !val.hasChildren
  970. });
  971. }
  972. return res.data
  973. }
  974. },
  975. async dictionarydataType () {//数据类型字典
  976. const { data: res } = await dictionarydataType()
  977. console.log(res);
  978. if (res.code == 200) {
  979. res.data.forEach(element => {
  980. element.dictKey = Number(element.dictKey)
  981. });
  982. this.dataType = res.data
  983. }
  984. },
  985. //#endregion
  986. getOwnerTypelist () {
  987. if (this.ownerTypeList.length > 1) {
  988. return;
  989. }
  990. getDictionary({
  991. code: 'owner_type'
  992. }).then((res) => {
  993. res.data.data.forEach(element => {
  994. element.dictKey = Number(element.dictKey)
  995. });
  996. this.ownerTypeList = res.data.data;
  997. })
  998. },
  999. //修改树显示状态
  1000. showLeftChange(){
  1001. this.showLeft = !this.showLeft;
  1002. },
  1003. handleClose () {
  1004. this.newElements = []
  1005. this.addNewElementDialog = false;
  1006. },
  1007. addNewElement(){
  1008. this.newElements.push({
  1009. exctabId:this.from.id,
  1010. textInfo: ''
  1011. })
  1012. },
  1013. deleteNewElement(index){
  1014. this.newElements.splice(index, 1);
  1015. },
  1016. addNewElementHandle(){
  1017. exctabcellSave(this.newElements).then(()=>{
  1018. this.handleClose();
  1019. //触发自动识别按钮
  1020. this.automaticRecognition();
  1021. this.$message({
  1022. type: "success",
  1023. message: "保存成功!"
  1024. });
  1025. })
  1026. },
  1027. listUp(index){
  1028. if(index != 0){
  1029. this.titleList[index] = this.titleList.splice(index-1,1,this.titleList[index])[0];
  1030. }
  1031. },
  1032. listDown(index){
  1033. if(index != this.titleList.length-1){
  1034. this.titleList[index] = this.titleList.splice(index+1,1,this.titleList[index])[0];
  1035. }
  1036. },
  1037. deleTitle(index){
  1038. this.titleList.splice(index,1);
  1039. },
  1040. setTitleText(){
  1041. if(this.addNewElementDialog){
  1042. this.newElements.push({
  1043. exctabId:this.from.id,
  1044. textInfo: this.titleList.join('_')
  1045. })
  1046. this.titleList = [];
  1047. }else{
  1048. this.titleForm.textInfo = this.titleList.join('_');
  1049. }
  1050. },
  1051. editTitle(){
  1052. if(this.titleIndex < 0){
  1053. //新增
  1054. exctabcellSave([this.titleForm]).then(()=>{
  1055. this.editTitleDialog = false;
  1056. //触发自动识别按钮
  1057. this.automaticRecognition();
  1058. this.$message({
  1059. type: "success",
  1060. message: "新增成功!"
  1061. });
  1062. })
  1063. }else{
  1064. //修改
  1065. exctabcellUpdate(this.titleForm).then(()=>{
  1066. this.tableData[this.titleIndex].textInfo = this.titleForm.textInfo;
  1067. //this.tableData[this.titleIndex].eName = this.titleForm.textInfo;
  1068. this.tableData[this.titleIndex].textElementType = this.titleForm.textElementType;
  1069. this.tableData[this.titleIndex].textDeviation = this.titleForm.textDeviation;
  1070. //console.log(this.$refs.tablescroll)
  1071. this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
  1072. this.editTitleDialog = false;
  1073. this.$message({
  1074. type: "success",
  1075. message: "保存成功!"
  1076. });
  1077. })
  1078. }
  1079. },
  1080. dblBtnClick(e){
  1081. //console.log(e)
  1082. let target = e.target;
  1083. //console.log(target.getAttribute('trindex'))
  1084. if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
  1085. this.titleIndex = -1;
  1086. this.titleList = [];
  1087. this.$refs.tablescroll.$el.scrollTop = 0;
  1088. this.editTitleDialog = true;
  1089. this.showLeft = false;
  1090. let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
  1091. for (let i = 0; i < this.tableData.length; i++) {
  1092. if(this.tableData[i].xys.indexOf(trtd) > -1){
  1093. this.titleIndex = i;
  1094. break;
  1095. }
  1096. }
  1097. if(this.titleIndex > -1){
  1098. this.titleForm.textInfo = this.tableData[this.titleIndex].textInfo;
  1099. this.titleForm.textElementType = this.tableData[this.titleIndex].textElementType;
  1100. this.titleForm.textDeviation = this.tableData[this.titleIndex].textDeviation;
  1101. this.titleForm.exctabId = this.tableData[this.titleIndex].exctabId;
  1102. this.titleForm.id = this.tableData[this.titleIndex].id;
  1103. }
  1104. // let tdEle = this.getParentTD(target);
  1105. // if(tdEle){
  1106. // this.$refs.tablescroll.$el.scrollTop = 0;
  1107. // this.editTitleDialog = true;
  1108. // this.titleForm.textInfo = tdEle.getAttribute('title');
  1109. // //console.log(title)
  1110. // this.titleList = this.titleForm.textInfo.split('_');
  1111. // let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
  1112. // for (let i = 0; i < this.tableData.length; i++) {
  1113. // if(this.tableData[i].xys.indexOf(trtd) > -1){
  1114. // this.titleIndex = i;
  1115. // break;
  1116. // }
  1117. // }
  1118. // }
  1119. }else if(target.innerHTML && target.nodeName === "TD"){
  1120. this.titleList.push(target.innerHTML)
  1121. }
  1122. },
  1123. parentClick(e){
  1124. let target = e.target;
  1125. //console.log(target.getAttribute('trindex'))
  1126. if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
  1127. let tdEle = this.getParentTD(target);
  1128. if(tdEle){
  1129. let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
  1130. for (let i = 0; i < this.tableData.length; i++) {
  1131. if(this.tableData[i].xys.indexOf(trtd) > -1){
  1132. this.titleIndex = i;
  1133. break;
  1134. }
  1135. }
  1136. this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
  1137. }
  1138. }
  1139. },
  1140. getParentTD(ele){
  1141. let targetParent = ele.parentNode;
  1142. while (targetParent.nodeName !== "TD") {
  1143. if(targetParent.id == 'parent'){
  1144. return null;
  1145. }
  1146. targetParent = targetParent.parentNode;
  1147. }
  1148. return targetParent;
  1149. },
  1150. tableRowClassName({rowIndex}) {
  1151. if (rowIndex === this.titleIndex) {
  1152. return 'warning-row';
  1153. }
  1154. return '';
  1155. },
  1156. //保存单条元素
  1157. saveELe(row){
  1158. if(row.textInfo){
  1159. exctabcellUpdate(row).then(()=>{
  1160. this.$message({
  1161. type: "success",
  1162. message: "保存成功!"
  1163. });
  1164. })
  1165. }else{
  1166. this.$message({
  1167. type: "warning",
  1168. message: "请填写元素名称"
  1169. });
  1170. }
  1171. }
  1172. },
  1173. created () {
  1174. this.getOwnerTypelist();
  1175. this.excelType();
  1176. }
  1177. }
  1178. </script>
  1179. <style lang="scss" scoped>
  1180. .boxswai {
  1181. padding: 0px 14px 10px 14px !important;
  1182. }
  1183. .dingwei {
  1184. position: fixed;
  1185. bottom: 40px;
  1186. right: 40px;
  1187. }
  1188. //树结构超长后产生滚动条
  1189. .el-tree > .el-tree-node {
  1190. min-width: 100%;
  1191. display: inline-block;
  1192. }
  1193. .boxswai{
  1194. height: 100%;
  1195. box-sizing: border-box;
  1196. padding-bottom: 10px;
  1197. }
  1198. .title-item{
  1199. box-sizing: border-box;
  1200. width:100%;
  1201. font-size:16px;
  1202. height:30px;
  1203. padding:3px 20px;
  1204. background-color: #f3f3f3;
  1205. color: #ee7049;
  1206. margin-bottom: 6px;
  1207. cursor:pointer;
  1208. }
  1209. /deep/ .el-table .warning-row {
  1210. background: oldlace;
  1211. }
  1212. .region{
  1213. position: relative;
  1214. }
  1215. .region /deep/ .el-dialog__wrapper{
  1216. position: absolute !important;
  1217. }
  1218. .region /deep/ .v-modal{
  1219. position: absolute !important;
  1220. }
  1221. </style>