index.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  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. :close-on-click-modal="false"
  401. >
  402. <el-row :gutter="20">
  403. <el-col :span="12">
  404. <el-select
  405. style="width:100%;"
  406. v-model="GLExcelFrom.name"
  407. placeholder="请选择"
  408. @change="changetherr()"
  409. >
  410. <el-option
  411. v-for="(item,key) in GLExcelData"
  412. :key="key"
  413. :label="item.wbsName"
  414. :value="item.id"
  415. >
  416. </el-option>
  417. </el-select>
  418. <el-scrollbar style="height:50vh;">
  419. <el-tree
  420. v-if="GLExcelFromtag"
  421. @node-click="handleNodeClickExcel"
  422. ref="tree"
  423. class="filter-tree"
  424. style="margin-top:10px;"
  425. :props="GLExcelProps"
  426. :data="exceldata"
  427. :load="loadNodeTan"
  428. lazy
  429. node-key="id"
  430. accordion
  431. :show-checkbox="activeName == 'add'"
  432. :check-strictly="true"
  433. >
  434. </el-tree>
  435. </el-scrollbar>
  436. </el-col>
  437. <el-col
  438. :span="12"
  439. v-if="addElementForm.wbsId"
  440. >
  441. <el-tabs v-model="activeName" type="card" >
  442. <el-tab-pane label="关联元素表" name="link">
  443. <el-table
  444. :data="addTableData"
  445. border
  446. style="width: 100%"
  447. class="martop20"
  448. >
  449. <el-table-column
  450. prop="tableName"
  451. label="已有元素表名称"
  452. align="center"
  453. >
  454. </el-table-column>
  455. <el-table-column
  456. prop="name"
  457. label="操作"
  458. align="center"
  459. >
  460. <template slot-scope="scope">
  461. <el-button
  462. type="primary"
  463. size="mini"
  464. style="margin:0px;"
  465. @click="relationMD(scope.row,'关联')"
  466. v-show="!scope.row.checknd"
  467. :loading="scope.row.loading"
  468. >选择关联</el-button>
  469. <el-button
  470. type="danger"
  471. size="mini"
  472. style="margin:0px;"
  473. @click="relationMD(scope.row,'取消关联')"
  474. v-show="scope.row.checknd"
  475. :loading="scope.row.loading"
  476. >取消关联</el-button>
  477. </template>
  478. </el-table-column>
  479. </el-table>
  480. </el-tab-pane>
  481. <el-tab-pane label="新增元素表" name="add">
  482. <div>
  483. <div class="flexBetween martop20">
  484. <el-input
  485. v-model="addElementForm.nodeName"
  486. placeholder="请输入表名"
  487. ></el-input>
  488. <el-select
  489. class="marleft10"
  490. v-model="addElementForm.tableType"
  491. placeholder="请选择表类型"
  492. >
  493. <el-option
  494. v-for="(item,index) in exceltypeData"
  495. :key="index"
  496. :label="item.dictValue"
  497. :value="item.dictKey"
  498. ></el-option>
  499. </el-select>
  500. </div>
  501. <el-select
  502. style="width:100%;"
  503. class="martop20"
  504. v-model="addElementForm.tableOwner"
  505. placeholder="请选择所属方"
  506. >
  507. <el-option
  508. v-for="(item,index) in ownerTypeList"
  509. :key="index"
  510. :label="item.dictValue"
  511. :value="item.dictKey"
  512. ></el-option>
  513. </el-select>
  514. </div>
  515. </el-tab-pane>
  516. </el-tabs>
  517. </el-col>
  518. </el-row>
  519. <span
  520. slot="footer"
  521. class="dialog-footer"
  522. style="display: flex;justify-content: center;align-items: center;"
  523. >
  524. <el-button @click="AssociatedPublicClose()">取 消</el-button>
  525. <el-button
  526. style="margin-left:30px;"
  527. type="primary"
  528. @click="saveElementMD()"
  529. >确 定</el-button>
  530. </span>
  531. </el-dialog>
  532. </div>
  533. </div>
  534. </template>
  535. <script>
  536. import { tabLazytree, getExcelHtmlCol, excelType, submitExcelRelationWbsTreeAndElement, getWbsTypeList, getLazytree,cancelRelation,saveRelation,searchNodeTables,tabLazytreeAll,exctabcellSave,exctabcellRemove , exctabcellUpdate} from "@/api/exctab/excelmodel";
  537. import { dictionarydataType } from "@/api/exctab/editelement";
  538. import { getColByTabId } from "@/api/manager/AdjustForm";
  539. import { selectByNodeTable } from "@/api/manager/wbstree";
  540. import { getDictionary } from "@/api/system/dict";
  541. import Vue from 'vue'
  542. import draggable from 'vuedraggable'
  543. export default {
  544. data () {
  545. return {
  546. //#region 左侧树节点
  547. treeData: [],
  548. treeProps: {
  549. label: 'name',
  550. children: 'children',
  551. isLeaf: 'hasChildren'
  552. },
  553. //#endregion
  554. excelSrc: '',
  555. from: {
  556. id: '',
  557. },
  558. tableData: [],//外层table
  559. dataType: [],
  560. filterText:"",//搜索关键字
  561. allTreeShow:false,//是否显示整棵树
  562. treeloading:false,
  563. AssociatedPublicTap: false,
  564. //#region 弹框属性
  565. GLExcelFrom: {
  566. id: "",
  567. name: '',
  568. search: '',//搜素框舒服的值
  569. },
  570. GLExcelData: [],//
  571. allTreeData:[],
  572. GLExcelProps: {
  573. label: 'title',
  574. children: 'children',
  575. isLeaf: function (data) {
  576. if (data.hasChildren && data.isExistForm != 1) {
  577. return false
  578. } else if (data.hasChildren && data.isExistForm == 1) {
  579. return true
  580. } else {
  581. return true
  582. }
  583. }
  584. },
  585. exceldata: [],//清表模板树数据
  586. addTableData: [],//新增元素信息表
  587. exceltypeData: [],//清表类型
  588. addElement: false,
  589. GLExcelFromtag: false,
  590. addElementForm: {
  591. id: "",
  592. initTableName: "",
  593. nodeName: '',
  594. tableType: '',
  595. tableOwner: '',
  596. wbsId: '',
  597. parentId: '',
  598. },
  599. //#endregion
  600. ownerTypeList: [],
  601. activeName:'link',
  602. showLeft:true,//左侧树是否显示
  603. addNewElementDialog:false,//新增元素弹窗
  604. newElements:[],
  605. editTitleDialog:false,//编辑标题弹窗
  606. titleList:[],//标题拆分的列表
  607. titleForm:{
  608. exctabId:'',
  609. id:'',
  610. textInfo:'',
  611. textElementType:'',
  612. textDeviation:'',
  613. },
  614. titleIndex:-1,
  615. }
  616. },
  617. components: {
  618. draggable,
  619. },
  620. methods: {
  621. //搜索树
  622. treeFilter(){
  623. if(this.filterText){
  624. this.allTreeShow = true;
  625. if(!this.allTreeData.length){
  626. this.treeloading = true;
  627. tabLazytreeAll({
  628. modeId: this.$route.params.id,
  629. name:'',
  630. }).then((res)=>{
  631. this.treeloading = false;
  632. this.allTreeData = res.data.data;
  633. this.$nextTick(()=>{
  634. this.$refs.treeall.filter(this.filterText);
  635. })
  636. })
  637. }else{
  638. this.$refs.treeall.filter(this.filterText);
  639. }
  640. }else{
  641. this.allTreeShow = false;
  642. }
  643. },
  644. filterNode(value, data) {
  645. if (!value) return true;
  646. return data.name.indexOf(value) !== -1;
  647. },
  648. //#region
  649. handleNodeClick (data) {//树节点点击事件
  650. console.log(data);
  651. if (data.fileType == 3) {
  652. this.getExcelHtmlCol(data.id)//获取excel模板
  653. if (this.dataType.length == 0) {
  654. this.dictionarydataType() //数据类型字典
  655. }
  656. this.addElement = false
  657. this.addElementForm.nodeName = data.name
  658. if(data.tabType > 0 && data.tabType < 100){
  659. this.addElementForm.tableType = data.tabType+'';
  660. }else{
  661. this.addElementForm.tableType = ''
  662. }
  663. this.from.id = data.id
  664. this.tableData = [];
  665. //触发自动识别按钮
  666. this.automaticRecognition();
  667. }
  668. },
  669. async loadNode (node, resolve) {//懒加载获取节点
  670. if (node.level === 0) {
  671. return resolve(await this.tabLazytree(this.$route.params.id, 0))
  672. }
  673. if (node.level > 0) {
  674. return resolve(await this.tabLazytree(this.$route.params.id, node.data.id))
  675. }
  676. },
  677. automaticRecognition () {//自动识别按钮
  678. this.getColByTabId()
  679. },
  680. pushTableData () {//
  681. // if (this.from.id) {
  682. // this.tableData.unshift({
  683. // eName: '',
  684. // eType: 1,
  685. // eAllowDeviation: ''
  686. // })
  687. // }
  688. if (this.from.id) {
  689. this.showLeft = false;
  690. this.addNewElementDialog = true;
  691. this.titleList = [];
  692. }
  693. },
  694. deleteTableData (key) {//删除
  695. exctabcellRemove(this.tableData[key].id).then(()=>{
  696. this.tableData.splice(key, 1)
  697. this.$message({
  698. type: "success",
  699. message: "删除成功!"
  700. });
  701. })
  702. },
  703. async getColByTabId () {//获取字段信息
  704. const { data: res } = await getColByTabId({ tabId: this.from.id })
  705. console.log(res);
  706. if (res.code === 200) {
  707. res.data.forEach((element)=>{
  708. //element.eName = element.textInfo;
  709. if(element.textElementType < 1){
  710. element.textElementType = 1;
  711. }
  712. })
  713. this.tableData = res.data
  714. }
  715. },
  716. async getExcelHtmlCol (id) {//获取excel模板
  717. const { data: res } = await getExcelHtmlCol({ id })
  718. console.log(res);
  719. if (res.code == 200) {
  720. // let _that = this
  721. var MyComponent = await Vue.extend({
  722. data () {
  723. return {
  724. formData: {}
  725. }
  726. },
  727. template: res.data,
  728. })
  729. var component = new MyComponent().$mount()
  730. let na = document.getElementById('parent')
  731. na.innerHTML = `<div
  732. class='parent'
  733. id='parent'"
  734. ></div>`
  735. document.getElementById('parent').appendChild(component.$el);
  736. }
  737. },
  738. //#endregion
  739. //#region 关联公共WBS模板弹框
  740. establish () {//关联WBS并创建元素
  741. if(this.tableData.length == 0){
  742. this.$message({
  743. type: 'warning',
  744. message: '至少有一条元素才能创建元素表'
  745. })
  746. return;
  747. }
  748. let arr = [];
  749. this.tableData.forEach((element,index)=>{
  750. if(element.eName == ''){
  751. arr.push(index+1);
  752. }
  753. })
  754. if(arr.length > 0){
  755. this.$message({
  756. type: 'warning',
  757. message: arr.join(',')+'条的元素名称未填写'
  758. })
  759. return;
  760. }
  761. this.getWbsTypeList()
  762. this.AssociatedPublicTap = true
  763. },
  764. AssociatedPublicClose () {//关联公共WBS模板关闭事件
  765. // this.addElementForm = {
  766. // id: "",
  767. // initTableName: "",
  768. // nodeName: this.addElementForm.nodeName,
  769. // tableType: '',
  770. // tableOwner: '',
  771. // wbsId: '',
  772. // parentId: '',
  773. // }
  774. // this.GLExcelFrom = {
  775. // name: '',
  776. // search: ''
  777. // }
  778. // this.exceldata = []
  779. // this.addElement = false
  780. //清理之前填写的数据
  781. this.addElementForm.wbsId = '';
  782. // this.addElementForm.tableType = '';
  783. this.addElementForm.tableOwner = '';
  784. if(this.$refs.tree){
  785. this.$refs.tree.setCheckedKeys([]);
  786. this.$refs.tree.setCurrentKey(null);
  787. }
  788. this.addTableData = []
  789. this.AssociatedPublicTap = false
  790. },
  791. async loadNodeTan (node, resolve) {//懒加载
  792. console.log(node);
  793. if (node.level === 0) {
  794. return resolve(await this.getLazytree(0));
  795. } else {
  796. return resolve(await this.getLazytree(node.data.id));
  797. }
  798. },
  799. changetherr () {//下拉框change事件
  800. this.GLExcelFromtag = false
  801. if (this.GLExcelFrom.name != "") {
  802. this.GLExcelFrom.search = ''
  803. this.exceldata = []
  804. this.addTableData = []
  805. this.addElementForm.wbsId = ''
  806. this.$nextTick(() => {
  807. this.GLExcelFromtag = true
  808. })
  809. }
  810. },
  811. addElementMD () {//新增元素信息表按钮
  812. this.excelType()
  813. this.addElement = true
  814. },
  815. async getWbsTypeList () {//获取清表模板信息
  816. const { data: res } = await getWbsTypeList({ wbstype: 1 })
  817. console.log(res);
  818. if (res.code === 200 && res.msg === '操作成功') {
  819. this.GLExcelData = res.data
  820. }
  821. },
  822. async getLazytree (parentId) {//清表树信息
  823. const { data: res } = await getLazytree({
  824. parentId: parentId,
  825. wbsId: this.GLExcelFrom.name,
  826. wbsType: '1'
  827. })
  828. console.log(res);
  829. if (res.code === 200 && res.msg === '操作成功') {
  830. res.data.forEach(val => {
  831. val.isExistForm = !!val.isExistForm
  832. })
  833. return res.data
  834. } else {
  835. return []
  836. }
  837. },
  838. handleNodeClickExcel (data) {//点击节点事件
  839. this.addElementForm.wbsId = this.GLExcelFrom.name
  840. this.addElementForm.parentId = data.id
  841. //this.selectByNodeTable(data.id)
  842. this.searchNodeTables(data.id)
  843. },
  844. async selectByNodeTable (id) {//获取清表信息
  845. const { data: res } = await selectByNodeTable(id)
  846. console.log(res);
  847. if (res.code == 200) {
  848. if (res.data.length > 0) {
  849. res.data.forEach(val => {
  850. if (val.isLinkTable == 2) {
  851. val.checknd = true
  852. } else {
  853. val.checknd = false
  854. }
  855. val.loading = false;
  856. })
  857. this.addTableData = res.data
  858. }else{
  859. this.addTableData = []
  860. }
  861. }
  862. },
  863. //查看节点下已关联的元素表信息
  864. searchNodeTables(id){
  865. searchNodeTables(id,this.from.id).then((res)=>{
  866. if (res.data.data.length > 0) {
  867. res.data.data.forEach(val => {
  868. if (val.isLinkTable == 2) {
  869. val.checknd = true
  870. } else {
  871. val.checknd = false
  872. }
  873. val.loading = false;
  874. })
  875. this.addTableData = res.data.data
  876. }else{
  877. this.addTableData = []
  878. }
  879. })
  880. },
  881. async excelType () {//清表类型
  882. const { data: res } = await excelType({ code: 'sys_excltab_type' })
  883. console.log(res);
  884. if (res.code === 200) {
  885. this.exceltypeData = res.data
  886. }
  887. },
  888. relationMD (row, type) {//关联取消关联
  889. row.loading = true;
  890. if (type == '关联') {
  891. saveRelation(row.id,this.from.id,this.tableData).then(()=>{
  892. row.checknd = true;
  893. row.isLinkTable = 2;
  894. }).finally(()=>{
  895. row.loading = false;
  896. })
  897. } else {
  898. cancelRelation({
  899. id:row.id,
  900. excelTabId:this.from.id,
  901. }).then(()=>{
  902. row.checknd = false;
  903. row.isLinkTable = 1;
  904. }).finally(()=>{
  905. row.loading = false;
  906. })
  907. }
  908. },
  909. saveElementMD () {//保存按钮
  910. if (this.addElementForm.wbsId) {
  911. if (this.activeName == 'link') {
  912. this.submitExcelRelationWbsTreeAndElement({
  913. excelTabId:this.from.id,
  914. elementList: this.tableData,
  915. submitStatus:1
  916. })
  917. } else {
  918. if (this.addElementForm.nodeName && this.addElementForm.tableType && this.addElementForm.tableOwner) {
  919. let nodeIds = this.$refs.tree.getCheckedKeys();
  920. if(nodeIds.length < 1){
  921. this.$message({
  922. type: 'warning',
  923. message: '至少勾选一个节点'
  924. })
  925. return;
  926. }
  927. this.submitExcelRelationWbsTreeAndElement({
  928. nodeName: this.addElementForm.nodeName,
  929. tableType: this.addElementForm.tableType,
  930. tableOwner: this.addElementForm.tableOwner,
  931. wbsId: this.addElementForm.wbsId,
  932. elementList: this.tableData,
  933. nodeIds:nodeIds,
  934. excelTabId:this.from.id,
  935. submitStatus:2
  936. })
  937. }else{
  938. this.$message({
  939. type: 'warning',
  940. message: '请填写和选择新增的表名,表类型,表所属方'
  941. })
  942. }
  943. }
  944. } else {
  945. this.$message({
  946. type: 'warning',
  947. message: '请先选择WBS树节点表单'
  948. })
  949. }
  950. },
  951. async submitExcelRelationWbsTreeAndElement (da) {//保存接口
  952. da.elementList.forEach((ele)=>{
  953. ele.eName = ele.textInfo;
  954. ele.eType = ele.textElementType;
  955. ele.eAllowDeviation = ele.textDeviation;
  956. })
  957. const { data: res } = await submitExcelRelationWbsTreeAndElement(da)
  958. console.log(res);
  959. if (res.code == 200) {
  960. this.$message({
  961. type: 'success',
  962. message: '设置成功'
  963. })
  964. this.AssociatedPublicTap = false
  965. this.AssociatedPublicClose()
  966. }
  967. },
  968. //#endregion
  969. //#region 接口
  970. async tabLazytree (modeId, parentId) {
  971. const { data: res } = await tabLazytree({ modeId, parentId })
  972. console.log(res);
  973. if (res.code == 200) {
  974. if (res.data.length > 0) {
  975. res.data.forEach(val => {
  976. val.hasChildren = !val.hasChildren
  977. });
  978. }
  979. return res.data
  980. }
  981. },
  982. async dictionarydataType () {//数据类型字典
  983. const { data: res } = await dictionarydataType()
  984. console.log(res);
  985. if (res.code == 200) {
  986. res.data.forEach(element => {
  987. element.dictKey = Number(element.dictKey)
  988. });
  989. this.dataType = res.data
  990. }
  991. },
  992. //#endregion
  993. getOwnerTypelist () {
  994. if (this.ownerTypeList.length > 1) {
  995. return;
  996. }
  997. getDictionary({
  998. code: 'owner_type'
  999. }).then((res) => {
  1000. res.data.data.forEach(element => {
  1001. element.dictKey = Number(element.dictKey)
  1002. });
  1003. this.ownerTypeList = res.data.data;
  1004. })
  1005. },
  1006. //修改树显示状态
  1007. showLeftChange(){
  1008. this.showLeft = !this.showLeft;
  1009. },
  1010. handleClose () {
  1011. this.newElements = []
  1012. this.addNewElementDialog = false;
  1013. },
  1014. addNewElement(){
  1015. this.newElements.push({
  1016. exctabId:this.from.id,
  1017. textInfo: ''
  1018. })
  1019. },
  1020. deleteNewElement(index){
  1021. this.newElements.splice(index, 1);
  1022. },
  1023. addNewElementHandle(){
  1024. exctabcellSave(this.newElements).then(()=>{
  1025. this.handleClose();
  1026. //触发自动识别按钮
  1027. this.automaticRecognition();
  1028. this.$message({
  1029. type: "success",
  1030. message: "保存成功!"
  1031. });
  1032. })
  1033. },
  1034. listUp(index){
  1035. if(index != 0){
  1036. this.titleList[index] = this.titleList.splice(index-1,1,this.titleList[index])[0];
  1037. }
  1038. },
  1039. listDown(index){
  1040. if(index != this.titleList.length-1){
  1041. this.titleList[index] = this.titleList.splice(index+1,1,this.titleList[index])[0];
  1042. }
  1043. },
  1044. deleTitle(index){
  1045. this.titleList.splice(index,1);
  1046. },
  1047. setTitleText(){
  1048. if(this.addNewElementDialog){
  1049. this.newElements.push({
  1050. exctabId:this.from.id,
  1051. textInfo: this.titleList.join('_')
  1052. })
  1053. this.titleList = [];
  1054. }else{
  1055. this.titleForm.textInfo = this.titleList.join('_');
  1056. }
  1057. },
  1058. editTitle(){
  1059. if(this.titleIndex < 0){
  1060. //新增
  1061. exctabcellSave([{
  1062. "exctabId": this.from.id,
  1063. "textInfo": this.titleForm.textInfo,
  1064. "textElementType": this.titleForm.textElementType,
  1065. "textDeviation": this.titleForm.textDeviation
  1066. }]).then(()=>{
  1067. this.editTitleDialog = false;
  1068. //触发自动识别按钮
  1069. this.automaticRecognition();
  1070. this.$message({
  1071. type: "success",
  1072. message: "新增成功!"
  1073. });
  1074. })
  1075. }else{
  1076. //修改
  1077. exctabcellUpdate(this.titleForm).then(()=>{
  1078. this.tableData[this.titleIndex].textInfo = this.titleForm.textInfo;
  1079. //this.tableData[this.titleIndex].eName = this.titleForm.textInfo;
  1080. this.tableData[this.titleIndex].textElementType = this.titleForm.textElementType;
  1081. this.tableData[this.titleIndex].textDeviation = this.titleForm.textDeviation;
  1082. //console.log(this.$refs.tablescroll)
  1083. this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
  1084. this.editTitleDialog = false;
  1085. this.$message({
  1086. type: "success",
  1087. message: "保存成功!"
  1088. });
  1089. })
  1090. }
  1091. },
  1092. dblBtnClick(e){
  1093. //console.log(e)
  1094. let target = e.target;
  1095. //console.log(target.getAttribute('trindex'))
  1096. if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
  1097. this.titleIndex = -1;
  1098. this.titleList = [];
  1099. this.$refs.tablescroll.$el.scrollTop = 0;
  1100. this.editTitleDialog = true;
  1101. this.showLeft = false;
  1102. let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
  1103. for (let i = 0; i < this.tableData.length; i++) {
  1104. let arr = this.tableData[i].xys.split(',')
  1105. if(arr.indexOf(trtd) > -1){
  1106. this.titleIndex = i;
  1107. break;
  1108. }
  1109. }
  1110. if(this.titleIndex > -1){
  1111. this.titleForm.textInfo = this.tableData[this.titleIndex].textInfo;
  1112. this.titleForm.textElementType = this.tableData[this.titleIndex].textElementType;
  1113. this.titleForm.textDeviation = this.tableData[this.titleIndex].textDeviation;
  1114. this.titleForm.exctabId = this.tableData[this.titleIndex].exctabId;
  1115. this.titleForm.id = this.tableData[this.titleIndex].id;
  1116. }
  1117. // let tdEle = this.getParentTD(target);
  1118. // if(tdEle){
  1119. // this.$refs.tablescroll.$el.scrollTop = 0;
  1120. // this.editTitleDialog = true;
  1121. // this.titleForm.textInfo = tdEle.getAttribute('title');
  1122. // //console.log(title)
  1123. // this.titleList = this.titleForm.textInfo.split('_');
  1124. // let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
  1125. // for (let i = 0; i < this.tableData.length; i++) {
  1126. // if(this.tableData[i].xys.indexOf(trtd) > -1){
  1127. // this.titleIndex = i;
  1128. // break;
  1129. // }
  1130. // }
  1131. // }
  1132. }else if(target.innerHTML && target.nodeName === "TD"){
  1133. this.titleList.push(target.innerHTML)
  1134. }
  1135. },
  1136. //excel父节点点击检测
  1137. parentClick(e){
  1138. let target = e.target;
  1139. let bgs = document.querySelectorAll("#parent .oldlace-bg")
  1140. //console.log(bgs)
  1141. for (let i = 0; i < bgs.length; i++) {
  1142. bgs[i].classList.remove("oldlace-bg");
  1143. }
  1144. //console.log(target.getAttribute('trindex'))
  1145. if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
  1146. let tdEle = this.getParentTD(target);
  1147. if(tdEle){
  1148. target.classList.add("oldlace-bg");
  1149. let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
  1150. for (let i = 0; i < this.tableData.length; i++) {
  1151. let arr = this.tableData[i].xys.split(',')
  1152. if(arr.indexOf(trtd) > -1){
  1153. this.titleIndex = i;
  1154. break;
  1155. }
  1156. }
  1157. //this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
  1158. //console.log(this.$refs.tablescroll.$el.scrollTop)
  1159. this.$nextTick(()=>{
  1160. let row = document.querySelectorAll(".warning-row");
  1161. if(row.length){
  1162. this.$refs.tablescroll.$el.scrollTop = row[0].offsetTop;
  1163. }
  1164. //console.dir(row[0])
  1165. })
  1166. }
  1167. }
  1168. },
  1169. getParentTD(ele){
  1170. let targetParent = ele.parentNode;
  1171. while (targetParent.nodeName !== "TD") {
  1172. if(targetParent.id == 'parent'){
  1173. return null;
  1174. }
  1175. targetParent = targetParent.parentNode;
  1176. }
  1177. return targetParent;
  1178. },
  1179. tableRowClassName({rowIndex}) {
  1180. if (rowIndex === this.titleIndex) {
  1181. return 'warning-row';
  1182. }
  1183. return '';
  1184. },
  1185. //保存单条元素
  1186. saveELe(row){
  1187. if(row.textInfo){
  1188. exctabcellUpdate(row).then(()=>{
  1189. this.$message({
  1190. type: "success",
  1191. message: "保存成功!"
  1192. });
  1193. })
  1194. }else{
  1195. this.$message({
  1196. type: "warning",
  1197. message: "请填写元素名称"
  1198. });
  1199. }
  1200. }
  1201. },
  1202. created () {
  1203. this.getOwnerTypelist();
  1204. this.excelType();
  1205. }
  1206. }
  1207. </script>
  1208. <style lang="scss" scoped>
  1209. .boxswai {
  1210. padding: 0px 14px 10px 14px !important;
  1211. }
  1212. .dingwei {
  1213. position: fixed;
  1214. bottom: 40px;
  1215. right: 40px;
  1216. }
  1217. //树结构超长后产生滚动条
  1218. .el-tree > .el-tree-node {
  1219. min-width: 100%;
  1220. display: inline-block;
  1221. }
  1222. .boxswai{
  1223. height: 100%;
  1224. box-sizing: border-box;
  1225. padding-bottom: 10px;
  1226. }
  1227. .title-item{
  1228. box-sizing: border-box;
  1229. width:100%;
  1230. font-size:16px;
  1231. height:30px;
  1232. padding:3px 20px;
  1233. background-color: #f3f3f3;
  1234. color: #ee7049;
  1235. margin-bottom: 6px;
  1236. cursor:pointer;
  1237. }
  1238. /deep/ .el-table .warning-row {
  1239. background: oldlace;
  1240. }
  1241. .region{
  1242. position: relative;
  1243. height: 100%;
  1244. }
  1245. .region /deep/ .el-dialog__wrapper{
  1246. position: absolute !important;
  1247. }
  1248. .region /deep/ .v-modal{
  1249. position: absolute !important;
  1250. }
  1251. #parent /deep/ .oldlace-bg{
  1252. background-color: oldlace;
  1253. }
  1254. </style>