element.vue 41 KB

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