element.vue 40 KB

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