element.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  1. <template>
  2. <div
  3. style="height:100%;"
  4. class="flexStar"
  5. >
  6. <div
  7. class="boxswai"
  8. style="width:26%;padding-left:0px;"
  9. >
  10. <div class="boxnei" style="display: flex;flex-direction: column;">
  11. <div style="overflow: auto;flex:1">
  12. <avue-tree
  13. :option="treeOption"
  14. :data="treeData"
  15. @node-click="nodeClick"
  16. ref="avueTree"
  17. style="display: inline-block;min-width: 100%;">
  18. <span
  19. class="custom-tree-node"
  20. slot-scope="{ data ,node }"
  21. @mouseover.stop="mouseOver(data)"
  22. @mouseleave.stop="mouseLeave(data)"
  23. style="box-sizing: border-box;padding-right:70px!important;;"
  24. >
  25. <div style="width:100%;">
  26. <span style="text-overflow: ellipsis;"> {{ data.title }} </span>
  27. <!-- <span> {{ node}} </span> -->
  28. <!-- 添加 -->
  29. <span>
  30. <!-- 调整排序 -->
  31. <el-link :underline="false">
  32. <i
  33. class="el-icon-sort"
  34. @click.stop="sortpai(data, node)"
  35. v-if="node.level == 2"
  36. title="调整排序"
  37. ></i>
  38. </el-link>
  39. </span>
  40. </div>
  41. </span>
  42. </avue-tree>
  43. </div>
  44. </div>
  45. </div>
  46. <div
  47. class="boxswai"
  48. style="width:74%;padding-left:0px;padding-right:0px;"
  49. >
  50. <div class="boxnei">
  51. <div
  52. class="marleft10"
  53. style="height:100%;
  54. display: flex;flex-direction: column;"
  55. >
  56. <!-- 上传、删除、下载操作栏 -->
  57. <div
  58. class="rightHeader"
  59. v-show="from.checkd"
  60. >
  61. </div>
  62. <el-empty
  63. style="height:80%;"
  64. v-show="false"
  65. description="该目录为根目录没有EXCEL文件"
  66. ></el-empty>
  67. <div
  68. class="martop20"
  69. v-if="true"
  70. style="flex:1;"
  71. >
  72. <avue-crud
  73. ref="crud"
  74. :data="loadData"
  75. :option="loadOption"
  76. v-model="obj"
  77. :page.sync="page"
  78. @on-load="onLoad"
  79. @selection-change="selectionChange"
  80. :table-loading="tabloading"
  81. @current-change="currentChange"
  82. @size-change="sizeChange"
  83. @refresh-change="refreshChange"
  84. >
  85. <template slot="menuRight">
  86. <el-button
  87. type="danger"
  88. size="small"
  89. icon="el-icon-delete"
  90. plain
  91. @click="handleDelete">删除元素表
  92. </el-button>
  93. <el-button
  94. size="small"
  95. type="primary"
  96. plain
  97. @click="editele"
  98. >编辑表单
  99. </el-button>
  100. </template>
  101. <template slot="menuLeft" slot-scope="{size}">
  102. <div style="display:flex">
  103. <el-input placeholder="请输入你想搜索的表单名称" v-model="input3" :size="size" clearable @clear="clearinput" > </el-input>
  104. <el-button type="primary" icon="el-icon-search" size="small" @click="searchChange">搜索</el-button>
  105. </div>
  106. </template>
  107. <template slot-scope="{type,size,row}" slot="menu">
  108. <el-button :size="size" :type="type" @click="distribution(row)">分配节点</el-button>
  109. <el-button :size="size" :type="type" @click="handleEditFormula(row)">公式配置</el-button>
  110. <el-button :size="size" :type="type" @click="editElement(row)">编辑元素</el-button>
  111. </template>
  112. </avue-crud>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. <!-- 编辑元素表单信息 -->
  118. <el-dialog
  119. title="编辑元素表单信息"
  120. :visible.sync="editElementFormTag"
  121. width="60%"
  122. :modal-append-to-body="false"
  123. >
  124. <div>
  125. <el-table
  126. :data="formDatass"
  127. border
  128. style="width: 100%"
  129. >
  130. <el-table-column
  131. prop="tableName"
  132. label="表名"
  133. >
  134. <template slot-scope="scope">
  135. <el-input
  136. v-model="scope.row.tableName"
  137. placeholder="请输入表名称"
  138. ></el-input>
  139. </template>
  140. </el-table-column>
  141. <el-table-column
  142. prop="tableType"
  143. label="表类型"
  144. >
  145. <template slot-scope="scope">
  146. <el-select
  147. v-model="scope.row.tableType"
  148. placeholder="请选择"
  149. >
  150. <el-option
  151. v-for="(item,key) in tableTypelist"
  152. :key="key"
  153. :label="item.dictValue"
  154. :value="item.dictKey"
  155. >
  156. </el-option>
  157. </el-select>
  158. </template>
  159. </el-table-column>
  160. <el-table-column
  161. prop="tableOwner"
  162. label="所属方"
  163. >
  164. <template slot-scope="scope">
  165. <el-select
  166. v-model="scope.row.tableOwner"
  167. placeholder="请选择"
  168. >
  169. <el-option
  170. v-for="(item,key) in ownerTypeList"
  171. :key="key"
  172. :label="item.dictValue"
  173. :value="item.dictKey"
  174. >
  175. </el-option>
  176. </el-select>
  177. </template>
  178. </el-table-column>
  179. <el-table-column
  180. prop="fillRate"
  181. label="填报率"
  182. >
  183. <template slot-scope="scope">
  184. <el-input
  185. v-model="scope.row.fillRate"
  186. placeholder="请输入填报率"
  187. ></el-input>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. </div>
  192. <span
  193. slot="footer"
  194. class="dialog-footer"
  195. >
  196. <el-button @click="editElementFormTag = false">取 消</el-button>
  197. <el-button
  198. type="primary"
  199. @click="editeditElementFormMF()"
  200. >确 定</el-button>
  201. </span>
  202. </el-dialog>
  203. <!-- 公式配置 -->
  204. <el-dialog
  205. title="元素公式"
  206. :visible.sync="editEleFormulaVisible"
  207. width="800px"
  208. append-to-body
  209. :close-on-click-modal="false"
  210. >
  211. <div class="flex mg-b-10">
  212. <el-input
  213. v-model="formulaInput"
  214. placeholder="请输入名称"
  215. size="samll" clearable @clear="searchFormulaName"
  216. ></el-input>
  217. <el-button type="info" class="mg-l-10" @click="searchFormulaName">搜索</el-button>
  218. </div>
  219. <el-table
  220. :data="editEleListFilter"
  221. border
  222. style="width: 100%"
  223. height="400px"
  224. >
  225. <el-table-column align="center" prop="eName" label="字段信息">
  226. </el-table-column>
  227. <el-table-column align="center" label="操作" width="200">
  228. <template slot-scope="scope">
  229. <el-link
  230. :type="scope.row.globalFormula == 1 ? 'warning' : 'primary'"
  231. @click="toFormulaEdit(scope.row,1)"
  232. >全局公式</el-link
  233. >
  234. <!-- <el-link
  235. class="mg-l-10"
  236. :type="scope.row.isSaveFormula == 1 ? 'warning' : 'primary'"
  237. @click="toFormulaEdit(scope.row,10)"
  238. >节点公式</el-link
  239. > -->
  240. <!-- <el-link
  241. class="mg-l-10"
  242. type="danger"
  243. @click="delEleRowHandle(scope.$index,editEleListFilter)"
  244. >删除</el-link> -->
  245. </template>
  246. </el-table-column>
  247. </el-table>
  248. </el-dialog>
  249. <!-- 公式 -->
  250. <el-dialog
  251. title="元素公式"
  252. :visible.sync="formulaCompVisible"
  253. fullscreen
  254. append-to-body
  255. class="full-dialog"
  256. @close="closeformulaComp"
  257. >
  258. <FormulaEdit
  259. :fromcurNode="curEleTable"
  260. :wbsid="id"
  261. :nodeid="curTreeData.id"
  262. :eleid="formulaCurRow.id"
  263. :projectid="projectid"
  264. :elementType="formulaCurRow.elementType"
  265. :globaltype="formulaCurRow.globaltype"
  266. @hideDialog="formulaCompVisible = false"
  267. v-if="formulaCompVisible"
  268. ></FormulaEdit>
  269. </el-dialog>
  270. <!-- 关联公共WBS模板 -->
  271. <PublicWbs ref="PublicWbs" :from="from"/>
  272. <!-- 编辑元素 -->
  273. <el-dialog
  274. :title="(curEleTable.title?curEleTable.title:'')+' 元素编辑'"
  275. :visible.sync="editEleVisible"
  276. width="80%"
  277. append-to-body
  278. :close-on-click-modal="false"
  279. >
  280. <p class="font-c-warning">编辑元素信息(请谨慎操作)</p>
  281. <el-table
  282. :data="editEleList"
  283. border
  284. style="width: 100%"
  285. height="400px"
  286. v-loading="editEleloading"
  287. >
  288. <el-table-column
  289. align="center"
  290. type="index"
  291. width="50"
  292. ></el-table-column>
  293. <el-table-column
  294. align="center"
  295. prop="eName"
  296. label="元素名称"
  297. >
  298. <template slot="header">
  299. <i class="required"></i>
  300. <span>元素名称</span>
  301. </template>
  302. <template slot-scope="scope">
  303. <el-input
  304. v-model="scope.row.eName"
  305. size="small"
  306. placeholder="请输入内容"
  307. ></el-input>
  308. </template>
  309. </el-table-column>
  310. <el-table-column
  311. align="center"
  312. prop="eType"
  313. label="数据类型"
  314. width="120"
  315. >
  316. <template slot="header">
  317. <i class="required"></i>
  318. <span>数据类型</span>
  319. </template>
  320. <template slot-scope="scope">
  321. <el-select
  322. v-model="scope.row.eType"
  323. @change="setDefaultLength(scope.row)"
  324. size="small"
  325. placeholder="请选择"
  326. >
  327. <el-option
  328. v-for="item in dataTypeList"
  329. :key="item.id"
  330. :label="item.dictValue"
  331. :value="item.dictKey"
  332. ></el-option>
  333. </el-select>
  334. </template>
  335. </el-table-column>
  336. <el-table-column
  337. align="center"
  338. prop="eLength"
  339. label="长度"
  340. width="120"
  341. >
  342. <template slot="header">
  343. <i class="required"></i>
  344. <span>长度</span>
  345. </template>
  346. <template slot-scope="scope">
  347. <el-input
  348. v-model="scope.row.eLength"
  349. size="small"
  350. placeholder="请输入内容"
  351. ></el-input>
  352. </template>
  353. </el-table-column>
  354. <el-table-column
  355. align="center"
  356. prop="eAllowDeviation"
  357. label="允许偏差值"
  358. >
  359. <template slot-scope="scope">
  360. <div class="flex">
  361. <el-select
  362. v-model="scope.row.allow"
  363. size="small"
  364. placeholder="请选择"
  365. style="width:120px"
  366. >
  367. <el-option
  368. :key="1"
  369. label="-"
  370. value="-"
  371. ></el-option>
  372. <el-option
  373. :key="2"
  374. label=">"
  375. value=">"
  376. ></el-option>
  377. <el-option
  378. :key="3"
  379. label="<"
  380. value="<"
  381. ></el-option>
  382. <el-option
  383. :key="4"
  384. label="≥"
  385. value="≥"
  386. ></el-option>
  387. <el-option
  388. :key="5"
  389. label="≤"
  390. value="≤"
  391. ></el-option>
  392. <el-option
  393. :key="6"
  394. label="±"
  395. value="±"
  396. ></el-option>
  397. <el-option
  398. :key="7"
  399. label="【】"
  400. value="【】"
  401. ></el-option>
  402. </el-select>
  403. <el-input
  404. v-model="scope.row.deviation"
  405. size="small"
  406. placeholder="请输入内容"
  407. ></el-input>
  408. </div>
  409. </template>
  410. </el-table-column>
  411. <el-table-column
  412. align="center"
  413. prop="eInspectionMethod"
  414. label="检查方法和频率"
  415. >
  416. <template slot-scope="scope">
  417. <el-input
  418. v-model="scope.row.eInspectionMethod"
  419. size="small"
  420. placeholder="请输入内容"
  421. ></el-input>
  422. </template>
  423. </el-table-column>
  424. <el-table-column
  425. align="center"
  426. label="操作"
  427. width="120"
  428. >
  429. <template slot="header">
  430. <el-button
  431. @click="addEleRow(editEleList)"
  432. type="text"
  433. icon="el-icon-circle-plus-outline"
  434. class="text-icon"
  435. ></el-button>
  436. </template>
  437. <template slot-scope="scope">
  438. <el-button
  439. v-if="scope.row.id"
  440. icon="el-icon-remove-outline"
  441. type="text"
  442. @click="delEleRowHandle(scope.$index,editEleList)"
  443. class="text-icon text-icon-danger"
  444. ></el-button>
  445. <div
  446. class="flex"
  447. v-else
  448. >
  449. <el-button
  450. @click="saveNewEle(scope.row)"
  451. type="mini"
  452. >保存</el-button>
  453. <el-button
  454. icon="el-icon-remove-outline"
  455. type="text"
  456. @click="delEleRowHandle(scope.$index,editEleList)"
  457. class="text-icon text-icon-danger"
  458. ></el-button>
  459. </div>
  460. </template>
  461. </el-table-column>
  462. </el-table>
  463. <span
  464. slot="footer"
  465. class="dialog-footer"
  466. >
  467. <el-button @click="editEleVisible = false">取 消</el-button>
  468. <el-button
  469. type="primary"
  470. @click="saveEles"
  471. >确 定</el-button>
  472. </span>
  473. </el-dialog>
  474. <!-- 私有wbs树排序弹框 -->
  475. <el-dialog
  476. title="调整排序"
  477. :visible.sync="sortTag"
  478. width="50%"
  479. append-to-body
  480. >
  481. <ManualSorting v-if="sortTag2" @bianhua="bianhua()" :sort="sort" />
  482. <span slot="footer" class="dialog-footer">
  483. <el-button @click="(sortTag = false), (sortTag2 = false)"
  484. >取 消</el-button
  485. >
  486. <el-button type="primary" @click="editSort()">确 定</el-button>
  487. </span>
  488. </el-dialog>
  489. </div>
  490. </template>
  491. <script>
  492. import { excelType} from '@/api/exctab/excelmodel';
  493. import {
  494. updateBatchNodeTableInfoElement,
  495. selectByNodeTable,
  496. selectFormElements,
  497. selectPrivateFormElements
  498. } from "@/api/manager/wbstree";
  499. import {getTableElments} from "@/api/manager/wbstree";
  500. import {tabTypeLazyTreeAll,delTabInfoAll} from "@/api/manager/wbsprivate";
  501. import {saveElement, remove as removeElement, updateBatchElements, getTemplate,importWbsElement} from "@/api/manager/wbsformelement";
  502. import FormulaEdit from "@/views/formula/edit1.vue";
  503. import PublicWbs from './PublicWbs.vue'
  504. import { searchNodeTables, } from "@/api/exctab/excelmodel";
  505. import {wbsInfotabSort} from "@/api/manager/wbsinfo";
  506. import { getDictionary } from "@/api/system/dict";
  507. import ManualSorting from '@/components/WbsTree/ManualSorting'
  508. export default {
  509. components:{
  510. FormulaEdit,
  511. PublicWbs,
  512. ManualSorting
  513. },
  514. data () {
  515. return {
  516. input3:'',
  517. editElementFormTag:false,//编辑元素
  518. tabloading:false,
  519. formDatass: [],
  520. selectionList:[],
  521. tableTypelist:[],
  522. ownerTypeList:[],
  523. dataTypeList:[],
  524. //数据类型的默认长度
  525. dataTypeDefaultMap: {
  526. 1: 250,//字符串
  527. 2: 50,//整数
  528. 3: 50,//小数
  529. 4: 50,//日期
  530. 5: 50,//数值
  531. 6: 50,//签名
  532. 7: 100,//文件
  533. },
  534. page: {
  535. size: 10,
  536. current: 1,
  537. total: 2
  538. },
  539. loadOption: {
  540. height: 'auto',
  541. calcHeight: 30,
  542. tip: false,
  543. searchShow:false,
  544. searchMenuSpan: 6,
  545. border: true,
  546. index: true,
  547. viewBtn: false,
  548. selection: true,
  549. editBtn:false,
  550. delBtn:false,
  551. addBtn:false,
  552. menu:true,
  553. dialogClickModal: false,
  554. column: [
  555. {
  556. label: "元素表名称",
  557. prop: "title",
  558. editDisplay: false,
  559. addDisplay: false,
  560. },
  561. {
  562. label: "元素表类型",
  563. prop: "tabType",
  564. // search: true,
  565. rules: [
  566. {
  567. required: true,
  568. message: "请输入名称",
  569. trigger: "blur",
  570. },
  571. ],
  572. },
  573. {
  574. label: "元素总量",
  575. prop: "elementTotal",
  576. editDisplay: false,
  577. addDisplay: false,
  578. rules: [
  579. {
  580. message: "请输入表数量",
  581. trigger: "blur",
  582. },
  583. ],
  584. },
  585. {
  586. label: "所属方",
  587. prop: "tabOwner",
  588. editDisplay: false,
  589. addDisplay: false,
  590. rules: [
  591. {
  592. message: "请输入表数量",
  593. trigger: "blur",
  594. },
  595. ],
  596. },
  597. {
  598. label: "填报率",
  599. prop: "fillRate",
  600. editDisplay: false,
  601. addDisplay: false,
  602. rules: [
  603. {
  604. message: "请输入表数量",
  605. trigger: "blur",
  606. },
  607. ],
  608. },
  609. ],
  610. },
  611. formelemtfoelemtformrm: {},
  612. elementloading: false,
  613. elemtData:[
  614. {
  615. tableName:'张三',
  616. sex:'男',
  617. id:1
  618. }, {
  619. tableName:'李四',
  620. sex:'女',
  621. id:2
  622. }
  623. ],
  624. curEleTable:{},
  625. eleReg: /(-|>|<|≥|≤|±|【】)?([^≥≤±【】]*)/,
  626. editEleList:[],
  627. editEleListAll:[],
  628. editEleFormulaVisible:false,
  629. editEleListFilter:[],
  630. excelId:'',
  631. treeNode: {},
  632. //#region 鼠标
  633. leftTRee: '',//左侧树ID
  634. threessW: 400,
  635. //#endregion
  636. heightss: '',//
  637. data: [],//清表模板
  638. filterText:"",//搜索关键字
  639. treeloading:false,
  640. defaultProps: {
  641. children: "children",
  642. isLeaf: function (data) {
  643. return !data.hasChildren || (data.isExistForm == 1);
  644. },
  645. },
  646. wbsdata: [],//wbs模板
  647. //#region 右侧数据
  648. from:{
  649. checkd:false
  650. },
  651. rules: {
  652. nodeName: [
  653. { required: true, message: '请输入清表名称', trigger: 'blur' },
  654. ],
  655. tabType: [
  656. { required: true, message: '请选择清表类型', trigger: 'blur' },
  657. ],
  658. },
  659. wbsform: {
  660. id: '',
  661. wbsType: '',
  662. wbsName: '',
  663. },//wbs树选中的值
  664. tableData: [],//右侧表数据
  665. wbsmiddle: false,//选择wbs模板那块是否有
  666. tableList: [],//进行处理的wbs关联表
  667. exceltypeData: [],//清表类型枚举
  668. wbsmodel: [],//wbs模板名称枚举
  669. //#endregion
  670. saveExcelLoad:false,
  671. filterText1: "",
  672. addTableData:[],
  673. //编辑元素
  674. editEleVisible:false,
  675. editEleloading:false,
  676. formulaInput:"",//公式配置
  677. formulaCompVisible: false, //公式弹框
  678. formulaCurRow: {}, //当前元素
  679. id:'',
  680. curTreeData:{},
  681. loadData:[],
  682. treeOption:{
  683. defaultExpandedKeys:[],
  684. currentNode:{},
  685. filter:false,
  686. addBtn:false,
  687. props:{
  688. labelText:'标题',
  689. label:'title',
  690. value:'id',
  691. children:'children'
  692. },
  693. lazy: true,
  694. treeLoad: function (node, resolve) {
  695. const parentId = (node.level === 0) ? 12345678910 : node.data.id;
  696. tabTypeLazyTreeAll({parentId,current:1,size:1000}).then(res => {
  697. resolve(res.data.data.records.map(item => {
  698. return {
  699. ...item,
  700. leaf: !item.hasChildren
  701. }
  702. }))
  703. });
  704. },
  705. },
  706. treeData:'',
  707. projectid:"",
  708. curNode:{},
  709. defaultExpandKey:[],//默认展开的节点
  710. sortTag: false,
  711. sortTag2: false,
  712. sort:[]
  713. }
  714. },
  715. computed:{
  716. ids () {
  717. let ids = [];
  718. this.selectionList.forEach(ele => {
  719. ids.push(ele.id);
  720. });
  721. return ids.join(",");
  722. }
  723. },
  724. methods: {
  725. //关闭公式弹窗
  726. closeformulaComp(){
  727. console.log('关闭');
  728. getTableElments(this.curEleTable.initTableId).then((res) => {
  729. this.editEleListFilter = res.data.data;
  730. this.editEleListAll = [].concat(this.editEleListFilter);
  731. })
  732. },
  733. //#region 树形控件外层左侧事件
  734. mouseLeave (data) {
  735. if (data.moreShow) {
  736. this.$set(data, 'moreShow', false)
  737. }
  738. },
  739. mouseOver (data) {
  740. if (!data.moreShow) {
  741. this.$set(data, 'moreShow', true)
  742. }
  743. },
  744. async sortpai(data,node) {
  745. console.log(data,node);
  746. this.curNode=node;
  747. this.curTreeData=data;
  748. await this.findWbsTreePrivateSameLevel(node,data)
  749. this.sortTag = true;
  750. this.sortTag2 = true;
  751. },
  752. editSort() {
  753. this.wbsInfotabSort();
  754. },
  755. bianhua() {
  756. this.sortTag2 = false;
  757. this.$nextTick(() => {
  758. this.sortTag2 = true;
  759. });
  760. },
  761. async wbsInfotabSort() {
  762. //元素库、独立库节点排序
  763. var newArr=this.sort.map((v)=>{return v.id})
  764. newArr=newArr.join(',')
  765. const { data: res } = await wbsInfotabSort(newArr);
  766. console.log(res);
  767. if (res.code == 200) {
  768. this.sortTag = false;
  769. this.sortTag2 = false;
  770. this.refreshTreeData();
  771. }
  772. },
  773. async findWbsTreePrivateSameLevel(node,data) {
  774. const { data: res } =await tabTypeLazyTreeAll({parentId:node.data.parentId,current:1,size:1000});
  775. if (res.code == 200) {
  776. console.log(res.data,'res1111111');
  777. let tabArr=res.data.records
  778. tabArr.forEach((item)=>{
  779. item.tableName=item.title
  780. })
  781. console.log(tabArr,'tabArr');
  782. this.sort =tabArr
  783. }
  784. },
  785. addEleRow (list) {
  786. list.push({});
  787. },
  788. delEleRow (index, list) {
  789. list.splice(index, 1);
  790. },
  791. delEleRowHandle (index, list) {
  792. let row = list[index];
  793. if (row.id) {
  794. //有id需要请求删除
  795. this.$confirm('是否确认删除?', '删除元素', {
  796. distinguishCancelAndClose: true,
  797. confirmButtonText: '删除',
  798. cancelButtonText: '取消'
  799. }).then(() => {
  800. removeElement(row.id, this.curEleTable.initTableName, row.ekey).then(() => {
  801. list.splice(index, 1);
  802. })
  803. this.curEleTable.elementTotal --;
  804. })
  805. } else {
  806. list.splice(index, 1);
  807. }
  808. },
  809. formatTableType(cellValue) {
  810. for (let i = 0; i < this.tableTypelist.length; i++) {
  811. if (this.tableTypelist[i].dictValue == cellValue) {
  812. return this.tableTypelist[i].dictKey;
  813. }
  814. }
  815. return cellValue;
  816. //console.log(cellValue)
  817. },
  818. formatOwner( cellValue) {
  819. for (let i = 0; i < this.ownerTypeList.length; i++) {
  820. if (this.ownerTypeList[i].dictValue == cellValue) {
  821. return this.ownerTypeList[i].dictKey;
  822. }
  823. }
  824. return cellValue;
  825. //console.log(cellValue)
  826. },
  827. currentChange (currentPage) {
  828. this.page.current = currentPage;
  829. this.page.currentPage = currentPage;
  830. // this.searchChange();
  831. },
  832. sizeChange (pageSize) {
  833. this.page.size = pageSize;
  834. // this.searchChange();
  835. },
  836. selectionChange (list) {
  837. this.selectionList = list;
  838. },
  839. selectionClear () {
  840. this.selectionList = [];
  841. this.$refs.crud.toggleSelection();
  842. },
  843. async tabTypeLazyTreeAll ( parentId,current,size,titleName) {//清表树
  844. console.log(parentId);
  845. const { data: res } = await tabTypeLazyTreeAll({parentId,current,size,titleName} )
  846. if (res.code === 200) {
  847. return res.data
  848. }
  849. },
  850. nodeClick(data,node){
  851. console.log(data,node,'treedata');
  852. this.curNode=node
  853. this.curTreeData=data
  854. this.treeId=data.id
  855. this.page.current=1;
  856. this.page.currentPage=1
  857. if(data.hasChildren){
  858. this.onLoad(this.page)
  859. }
  860. if(data.hasChildren===false&&node.level==2){
  861. this.tabloading=true;
  862. let arr=[]
  863. arr.push(data)
  864. this.loadData=arr
  865. this.page.total=1
  866. setTimeout(() => {
  867. this.tabloading=false
  868. }, 1000);
  869. }else{
  870. this.loadData=[]
  871. this.page.total=0
  872. }
  873. },
  874. refreshChange () {
  875. this.searchChange();
  876. },
  877. onLoad(page, params = {}){
  878. if(this.treeId){
  879. this.tabloading=true;
  880. this.tabTypeLazyTreeAll(this.treeId, page.currentPage,page.pageSize,this.input3).then((res)=>{
  881. this.loadData=res.records
  882. this.page.total=res.total
  883. this.tabloading=false
  884. })
  885. }
  886. },
  887. //编辑后刷新
  888. onLoad1(){
  889. if(this.curNode.level===1&&this.curNode.data.hasChildren){
  890. this.tabloading=true;
  891. this.tabTypeLazyTreeAll(this.treeId, this.page.current,this.page.size,this.input3).then((res)=>{
  892. this.loadData=res.records
  893. this.page.total=res.total
  894. this.tabloading=false
  895. })
  896. }else{
  897. this.tabTypeLazyTreeAll(this.curNode.data.parentId,this.page.current,1000,this.input3).then((res)=>{
  898. let faArr=res.records;
  899. this.loadData=faArr.filter((item)=>{
  900. if(item.id===this.treeId){
  901. return item
  902. }
  903. })
  904. })
  905. }
  906. },
  907. //搜索
  908. searchChange(){
  909. if(this.treeId){
  910. if(this.curTreeData.hasChildren){
  911. this.tabloading=true;
  912. this.tabTypeLazyTreeAll(this.curTreeData.id, this.page.current,this.page.size,this.input3).then((res)=>{
  913. this.loadData=res.records
  914. this.page.total=res.total
  915. this.tabloading=false;
  916. })
  917. }
  918. if(this.curTreeData.hasChildren===false&&this.curNode.level==2){
  919. this.tabloading=true;
  920. let arr=[]
  921. arr.push(this.curTreeData)
  922. this.loadData=arr
  923. this.page.total=1;
  924. setTimeout(() => {
  925. this.tabloading=false
  926. }, 1000);
  927. }else{
  928. this.tabloading=true;
  929. this.loadData=[]
  930. this.page.total=0
  931. setTimeout(() => {
  932. this.tabloading=false
  933. }, 1000);
  934. }
  935. }else{
  936. this.$message.warning("请选选择左侧节点");
  937. }
  938. },
  939. clearinput(){
  940. this.searchChange()
  941. },
  942. resetChange(item){
  943. console.log(item);
  944. this.tabTypeLazyTreeAll(this.treeId, this.page.current,this.page.size).then((res)=>{
  945. this.loadData=res.records
  946. this.page.total=res.total
  947. })
  948. },
  949. handleDelete () {
  950. if (this.selectionList.length === 0) {
  951. this.$message.warning("请选择至少一条数据");
  952. return;
  953. }
  954. this.$confirm("确定将选择数据删除?", {
  955. confirmButtonText: "确定",
  956. cancelButtonText: "取消",
  957. type: "warning"
  958. })
  959. .then(() => {
  960. return delTabInfoAll(this.ids);
  961. })
  962. .then(() => {
  963. this.onLoad(this.page);//刷新表格数据
  964. //刷新左边树形数据
  965. this.refreshTreeData()
  966. this.$message({
  967. type: "success",
  968. message: "操作成功!"
  969. });
  970. this.$refs.crud.toggleSelection();
  971. });
  972. },
  973. // //刷新左边树形数据
  974. // refreshTreeData(){
  975. // const parentId =12345678910
  976. // tabTypeLazyTreeAll({parentId,current:1,siez:1000}).then(res => {
  977. // this.treeData=res.data.data.records;
  978. // this.$nextTick(()=>{
  979. // //树默认展开
  980. // if(this.curNode.level===1){
  981. // this.treeOption.defaultExpandedKeys.push(this.curNode.data.id);
  982. // this.$refs.avueTree.setCurrentKey(this.curNode.data.id)
  983. // }else{
  984. // this.treeOption.defaultExpandedKeys.push(this.curNode.data.parentId);
  985. // // 设置选中的节点
  986. // this.treeOption.currentNode =this.curNode.data.id
  987. // this.$refs.avueTree.setCurrentKey(this.curNode.data.id)
  988. // }
  989. // })
  990. // });
  991. // },
  992. //刷新左边树形数据
  993. refreshTreeData(){
  994. if(this.curNode.level===1){
  995. const parentId =12345678910
  996. tabTypeLazyTreeAll({parentId,current:1,size:1000}).then(res => {
  997. this.data=res.data.data.records;
  998. this.$nextTick(()=>{
  999. this.defaultExpandKey.push(this.curNode.data.id);
  1000. this.$refs.avueTree.setCurrentKey(this.curNode.data.id);
  1001. })
  1002. });
  1003. }else{
  1004. this.updateTreeNewNode()
  1005. }
  1006. },
  1007. //编辑元素表单信息
  1008. updateTreeNewNode() {
  1009. tabTypeLazyTreeAll(
  1010. {parentId:this.curTreeData.parentId,current:1,size:1000}
  1011. ).then((res) => {
  1012. var resarr= res.data.data.records.map(item=>{
  1013. return{
  1014. ...item,
  1015. leaf: !item.hasChildren
  1016. }
  1017. })
  1018. this.$refs.avueTree.updateKeyChildren(
  1019. this.curTreeData.parentId,
  1020. // res.data.data.records
  1021. resarr
  1022. );
  1023. this.$refs.avueTree.setCurrentKey(this.curNode.data.id);
  1024. });
  1025. },
  1026. editElement (row) {
  1027. console.log(row,'row');
  1028. this.curEleTable = row;
  1029. this.editEleloading=true
  1030. selectPrivateFormElements(this.curEleTable.id).then((res) => {
  1031. this.editEleloading=false
  1032. res.data.data.forEach((element) => {
  1033. this.eleReg.exec(element.eAllowDeviation);
  1034. //console.log(RegExp.$1)
  1035. //console.log(RegExp.$2)
  1036. element.allow = RegExp.$1 ? RegExp.$1 : '';
  1037. element.deviation = RegExp.$2 ? RegExp.$2 : '';
  1038. })
  1039. this.editEleList = res.data.data;
  1040. })
  1041. this.editEleVisible = true;
  1042. },
  1043. //修改数据类型,给个默认值
  1044. setDefatableTypeultLength (row) {
  1045. this.$set(row, 'eLength', this.dataTypeDefaultMap[row.eType]);
  1046. },
  1047. //分配节点
  1048. distribution(row){
  1049. console.log(row);
  1050. this.from.id=row.id;
  1051. this.from.title=row.title;
  1052. this.from.tableType=row.tabType
  1053. this.from.tableType=this.formatTableType(this.from.tableType);
  1054. this.from.tableOwner=row.tabOwner
  1055. this.from.tableOwner=this.formatOwner(this.from.tableOwner);
  1056. this.$refs.PublicWbs.show();
  1057. },
  1058. saveNewEle (row) {
  1059. if (!row.eName) {
  1060. this.$message({
  1061. type: "warning",
  1062. message: "请填写元素名称"
  1063. });
  1064. return;
  1065. }
  1066. if (!row.eType) {
  1067. this.$message({
  1068. type: "warning",
  1069. message: "请选择数据类型"
  1070. });
  1071. return;
  1072. }
  1073. row.eAllowDeviation = (row.allow ? row.allow : '') + (row.deviation ? row.deviation : '');
  1074. row.fId = this.curEleTable.id;
  1075. row.initTableName = this.curEleTable.initTableName;
  1076. if (!row.eLength) {
  1077. this.$message({
  1078. type: "warning",
  1079. message: "请填写长度"
  1080. });
  1081. return;
  1082. }
  1083. saveElement(row).then((res) => {
  1084. if (res.data.data) {
  1085. this.$set(row, 'id', res.data.data.id);
  1086. this.$set(row, 'ekey', res.data.data.ekey);
  1087. this.$message({
  1088. type: "success",
  1089. message: "保存成功!"
  1090. });
  1091. }
  1092. })
  1093. },
  1094. saveEles () {
  1095. for (let i = 0; i < this.editEleList.length; i++) {
  1096. if (!this.editEleList[i].id) {
  1097. this.$message({
  1098. type: "warning",
  1099. message: "请先将新增的元素点击保存"
  1100. });
  1101. return;
  1102. }
  1103. if (!this.editEleList[i].eName) {
  1104. this.$message({
  1105. type: "warning",
  1106. message: "请填写第" + (i + 1) + "条元素名称"
  1107. });
  1108. return;
  1109. }
  1110. if (!this.editEleList[i].eType) {
  1111. this.$message({
  1112. type: "warning",
  1113. message: "请选择第" + (i + 1) + "条数据类型"
  1114. });
  1115. return;
  1116. }
  1117. if ( !this.editEleList[i].eLength) {
  1118. this.$message({
  1119. type: "warning",
  1120. message: "请填写第" + (i + 1) + "条长度"
  1121. });
  1122. return;
  1123. }
  1124. }
  1125. if (this.editEleList.length > 0) {
  1126. this.editEleList.forEach((element) => {
  1127. element.eAllowDeviation = (element.allow ? element.allow : '') + (element.deviation ? element.deviation : '');
  1128. // if (element.eType == 4) {
  1129. // this.$set(element, 'eLength', 0);
  1130. // //element.eLength = 0;
  1131. // }
  1132. })
  1133. console.log(this.editEleList,'this.editEleList');
  1134. updateBatchElements(this.editEleList, this.curEleTable.initTableName).then(() => {
  1135. this.editEleVisible = false;
  1136. this.onLoad1(this.page);
  1137. this.$message({
  1138. type: "success",
  1139. message: "保存成功!"
  1140. });
  1141. })
  1142. } else {
  1143. this.editEleVisible = false;
  1144. this.onLoad1(this.page);
  1145. this.$message({
  1146. type: "success",
  1147. message: "保存成功!"
  1148. });
  1149. }
  1150. },
  1151. handleEditFormula ( row) {
  1152. console.log(row,'row');
  1153. this.curEleTable = row;
  1154. getTableElments(this.curEleTable.initTableId).then((res) => {
  1155. this.editEleListFilter = res.data.data;
  1156. this.editEleListAll = [].concat(this.editEleListFilter);
  1157. })
  1158. this.editEleFormulaVisible = true;
  1159. },
  1160. //搜索 筛选
  1161. searchFormulaName(){
  1162. this.editEleListFilter = this.editEleListAll.filter((ele)=>{
  1163. return ele.eName.indexOf(this.formulaInput) > -1;
  1164. })
  1165. },
  1166. //跳转到公式配置页面
  1167. toFormulaEdit(row,type) {
  1168. this.formulaCurRow = row;
  1169. this.formulaCurRow.globaltype = type;
  1170. this.formulaCurRow.elementType = false;
  1171. this.formulaCompVisible = true;
  1172. },
  1173. editele(){
  1174. console.log('编辑元素表单信息');
  1175. if (this.selectionList.length === 0) {
  1176. this.$message.warning("请选择至少一条数据");
  1177. return;
  1178. }
  1179. if (this.elemtData.length) {
  1180. let da = []
  1181. this.formDatass = [...this.selectionList];
  1182. console.log(this.formDatass,'his.formDatass111');
  1183. this.formDatass.forEach(val => {
  1184. da.push({
  1185. tableType: val.tabType,
  1186. tableOwner: val.tabOwner,
  1187. id: val.id,
  1188. tableName: val.title,
  1189. fillRate: val.fillRate,
  1190. })
  1191. })
  1192. this.formDatass = da
  1193. console.log(this.formDatass,'this.formDatass');
  1194. let fa=[]
  1195. this.formDatass.forEach(val=>{
  1196. let newarr= this.tableTypelist.filter(e => e.dictValue===val.tableType);
  1197. let newarr1= this.ownerTypeList.filter(e => e.dictValue===val.tableOwner);
  1198. fa.push({
  1199. tableType: newarr[0].dictKey,
  1200. tableOwner: newarr1[0].dictKey,
  1201. id: val.id,
  1202. tableName: val.tableName,
  1203. fillRate: val.fillRate,
  1204. })
  1205. })
  1206. this.formDatass=fa
  1207. this.editElementFormTag = true;
  1208. }
  1209. },
  1210. getOwnerTypelist() {
  1211. if (this.ownerTypeList.length > 1) {
  1212. return;
  1213. }
  1214. getDictionary({
  1215. code: "owner_type",
  1216. }).then((res) => {
  1217. res.data.data.forEach((element) => {
  1218. element.dictKey = Number(element.dictKey);
  1219. });
  1220. this.ownerTypeList = res.data.data;
  1221. });
  1222. },
  1223. getDataTypelist() {
  1224. if (this.dataTypeList.length > 1) {
  1225. return;
  1226. }
  1227. getDictionary({
  1228. code: "data_type",
  1229. }).then((res) => {
  1230. res.data.data.forEach((element) => {
  1231. element.dictKey = Number(element.dictKey);
  1232. });
  1233. this.dataTypeList = res.data.data;
  1234. });
  1235. },
  1236. getTableTypelist() {
  1237. if (this.tableTypelist.length > 1) {
  1238. return;
  1239. }
  1240. getDictionary({
  1241. code: "table_type",
  1242. }).then((res) => {
  1243. res.data.data.forEach((element) => {
  1244. element.dictKey = Number(element.dictKey);
  1245. });
  1246. this.tableTypelist = res.data.data;
  1247. });
  1248. },
  1249. editeditElementFormMF () {//保存按钮
  1250. let da = []
  1251. let tag = true
  1252. console.log(this.tableTypelist,'tableTypelist');
  1253. this.formDatass.forEach(val => {
  1254. if (!val.tableName || !val.tableType || !val.tableOwner) {
  1255. tag = false
  1256. return
  1257. } else {
  1258. da.push({
  1259. id: val.id,
  1260. nodeName: val.tableName,
  1261. tableType: val.tableType,
  1262. tableOwner:val.tableOwner,
  1263. fillRate: val.fillRate,
  1264. Type:10
  1265. })
  1266. }
  1267. })
  1268. if (tag) {
  1269. this.updateBatchNodeTableInfoElement(da)
  1270. } else {
  1271. this.$message({
  1272. type: 'success',
  1273. message: '请填写完整元素表单的所有信息!',
  1274. })
  1275. }
  1276. },
  1277. async updateBatchNodeTableInfoElement (da) {//共有编辑元素
  1278. console.log(da,'编辑表单');
  1279. const { data: res } = await updateBatchNodeTableInfoElement(da)
  1280. if (res.code == 200) {
  1281. this.$message.success('操作成功');
  1282. this.editElementFormTag = false
  1283. this.onLoad1(this.page);
  1284. }
  1285. },
  1286. async excelType () {//清表类型
  1287. const { data: res } = await excelType({ code: 'sys_excltab_type' })
  1288. console.log(res);
  1289. if (res.code === 200) {
  1290. res.data.forEach(element => {
  1291. element.dictKey = Number(element.dictKey)
  1292. });
  1293. this.exceltypeData = res.data
  1294. }
  1295. },
  1296. //查看节点下已关联的元素表信息
  1297. searchNodeTables(id) {
  1298. searchNodeTables(id, this.from.id).then((res) => {
  1299. if (res.data.data.length > 0) {
  1300. res.data.data.forEach((val) => {
  1301. if (val.isLinkTable == 2) {
  1302. val.checknd = true;
  1303. } else {
  1304. val.checknd = false;
  1305. }
  1306. val.loading = false;
  1307. });
  1308. this.addTableData = res.data.data;
  1309. } else {
  1310. this.addTableData = [];
  1311. }
  1312. });
  1313. },
  1314. },
  1315. created () {
  1316. this.getTableTypelist();
  1317. this.getOwnerTypelist();
  1318. this.getDataTypelist();
  1319. },
  1320. mounted () {
  1321. // this.heightss = this.$refs.rulesss.clientHeight
  1322. }
  1323. }
  1324. </script>
  1325. <style scoped lang="scss">
  1326. .marleft10 {
  1327. margin-left: 10px;
  1328. }
  1329. /deep/.el-tree-node__expand-icon {
  1330. font-size: 16px;
  1331. }
  1332. .colorblue {
  1333. color: rgb(0, 82, 217);
  1334. }
  1335. .treecontent /deep/.el-scrollbar {
  1336. height: 100%;
  1337. }
  1338. .el-scrollbar {
  1339. height: 100%;
  1340. }
  1341. .rightHeader {
  1342. display: flex;
  1343. justify-content: flex-start;
  1344. align-items: top;
  1345. font-size: 14px;
  1346. background-color: #fff;
  1347. .excelname {
  1348. box-sizing: border-box;
  1349. min-width: 200px;
  1350. height: 28px;
  1351. border: 1px solid rgb(220, 220, 220);
  1352. padding: 0 10px;
  1353. border-radius: 3px;
  1354. display: flex;
  1355. justify-content: space-between;
  1356. align-items: center;
  1357. }
  1358. }
  1359. .dialogModel {
  1360. .dialogBox {
  1361. .middle {
  1362. display: flex;
  1363. .left {
  1364. border: 1px solid rgb(220, 220, 220);
  1365. border-radius: 3px;
  1366. height: 500px;
  1367. width: 49%;
  1368. .select {
  1369. box-sizing: border-box;
  1370. display: flex;
  1371. justify-content: center;
  1372. padding: 5px 0;
  1373. border-bottom: 1px solid #e0e0e0;
  1374. }
  1375. .leftscroll {
  1376. height: 450px;
  1377. overflow-y: scroll;
  1378. }
  1379. }
  1380. .right {
  1381. height: auto;
  1382. height: 60px;
  1383. max-height: 500px;
  1384. margin-left: 2%;
  1385. // height: 500px;
  1386. border-radius: 3px;
  1387. td {
  1388. box-sizing: border-box;
  1389. padding: 5px 10px;
  1390. height: 30px;
  1391. line-height: 30px;
  1392. }
  1393. }
  1394. }
  1395. }
  1396. .btbox {
  1397. margin-top: 20px;
  1398. display: flex;
  1399. justify-content: center;
  1400. }
  1401. }
  1402. .rightBox {
  1403. flex: 1;
  1404. }
  1405. .boxswai{
  1406. height: 100%;
  1407. box-sizing: border-box;
  1408. padding-bottom: 10px;
  1409. }
  1410. /deep/.avue-crud__left{
  1411. width: 65% !important;
  1412. }
  1413. /deep/.el-input-group__append{
  1414. background-color: #ecf5ff;
  1415. color: #409EFF;
  1416. }
  1417. /deep/.el-input-group__append:hover{
  1418. background-color: #409EFF;
  1419. color: white;
  1420. }
  1421. /deep/.el-input-group__prepend:hover{
  1422. background-color: #409EFF;
  1423. color: white;
  1424. }
  1425. /deep/.el-input-group__append:active{
  1426. background-color: #9dc5ee;
  1427. color: white;
  1428. }
  1429. /deep/.el-input-group__prepend:active{
  1430. background-color: #9dc5ee;
  1431. color: white;
  1432. }
  1433. </style>