systemUnit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <!-- -->
  2. <template>
  3. <div style="height: 100%" class="flexStar">
  4. <div class="boxswai" style="width: 26%; padding-left: 0px">
  5. <div class="boxnei" style="display: flex; flex-direction: column">
  6. <div style="overflow: auto; flex: 1;height:500px">
  7. <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick">
  8. <span
  9. class="custom-tree-node"
  10. :class="data.moreShow?'show':''"
  11. slot-scope="{ node, data }"
  12. @mouseleave="mouseout(data)"
  13. >
  14. <div class="pd-r-20">
  15. {{ node.label }}
  16. <div class="normal-black">
  17. <div >
  18. <el-link :underline="false">
  19. <i
  20. class="el-icon-menu "
  21. @click="showMenu($event,data, node)"
  22. ></i>
  23. </el-link>
  24. <ul
  25. v-show="menuvisible"
  26. :style="{ left: menuleft + 'px', top: menutop + 'px' }"
  27. class="contextmenu"
  28. >
  29. <li v-for="item in menusData" :key="item" @click="menuClick($event,item,data)" >
  30. <i :class="item.icon"></i>{{item.label}}
  31. </li>
  32. </ul>
  33. </div>
  34. </div>
  35. </div>
  36. </span>
  37. </el-tree>
  38. </div>
  39. </div>
  40. </div>
  41. <div
  42. class="boxswai"
  43. style="width: 74%; padding-left: 0px; padding-right: 0px"
  44. >
  45. <div class="boxnei">
  46. <h4 class="mg-b-10">节点信息</h4>
  47. <form class="form-horizontal">
  48. <table class="table-form" style="width: 100%;">
  49. <tbody><tr>
  50. <td class="tit" width="10%">节点编码:</td>
  51. <td id="code"></td>
  52. <td class="tit" width="10%">节点名称:</td>
  53. <td id="name">竣工文件</td>
  54. <td class="tit" width="10%">节点类型:</td>
  55. <td id="nodeType">分部工程</td>
  56. </tr>
  57. <tr>
  58. <td class="tit" width="10%">工程类型:</td>
  59. <td id="workType">总则</td>
  60. <td class="tit" width="10%">显示类型:</td>
  61. <td id="type">全部</td>
  62. <td class="tit" width="10%">备注:</td>
  63. <td id="remark"></td>
  64. </tr>
  65. </tbody>
  66. </table>
  67. </form>
  68. <h4 class="mg-b-10 mg-t-20">下级节点列表</h4>
  69. <div class="tableclass">
  70. <el-table
  71. :data="tableData"
  72. border
  73. height="650"
  74. style="width: 100%">
  75. <el-table-column
  76. prop="date"
  77. label="节点编号"
  78. width="180">
  79. </el-table-column>
  80. <el-table-column
  81. prop="name"
  82. label="节点名称"
  83. width="180">
  84. </el-table-column>
  85. <el-table-column
  86. prop="address"
  87. label="节点类型">
  88. </el-table-column>
  89. <el-table-column
  90. prop="address"
  91. label="工程类型">
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. </div>
  96. </div>
  97. <!-- 新增编辑节点 -->
  98. <el-dialog
  99. title="新增节点"
  100. :visible.sync="adddialogVisible"
  101. width="30%"
  102. append-to-body
  103. :before-close="handleAddClose">
  104. <el-form label-position="left" label-width="80px" :model="addForm" ref="ruleForm" :rules="addFormrules">
  105. <el-form-item label="节点编码" prop="code">
  106. <el-input v-model="addForm.code"></el-input>
  107. </el-form-item>
  108. <el-form-item label="节点名称" prop="name">
  109. <el-input v-model="addForm.name"></el-input>
  110. </el-form-item>
  111. <el-form-item label="节点类型" prop="nodeType">
  112. <el-select v-model="addForm.nodeType" placeholder="请选择节点类型" style="width: 100%;">
  113. <el-option label="区域一" value="shanghai"></el-option>
  114. <el-option label="区域二" value="beijing"></el-option>
  115. </el-select>
  116. </el-form-item>
  117. <el-form-item label="工程类型" prop="goType">
  118. <el-select v-model="addForm.goType" placeholder="请选择工程类型" style="width: 100%;">
  119. <el-option label="区域一" value="shanghai"></el-option>
  120. <el-option label="区域二" value="beijing"></el-option>
  121. </el-select>
  122. </el-form-item>
  123. <el-form-item label="显示类型" prop="showType">
  124. <el-select v-model="addForm.showType" placeholder="请选择显示类型" style="width: 100%;">
  125. <el-option label="区域一" value="shanghai"></el-option>
  126. <el-option label="区域二" value="beijing"></el-option>
  127. </el-select>
  128. </el-form-item>
  129. </el-form>
  130. <span slot="footer" class="dialog-footer">
  131. <el-button @click="adddialogVisible = false">取 消</el-button>
  132. <el-button type="primary" @click="saveAddform">确 定</el-button>
  133. </span>
  134. </el-dialog>
  135. <!-- 排序弹窗 -->
  136. <el-dialog
  137. title="节点排序"
  138. :visible.sync="sortTag"
  139. append-to-body
  140. width="30%"
  141. :before-close="handleSortClose">
  142. <ManualSorting
  143. v-if="sortTag2"
  144. @bianhua='bianhua()'
  145. :sort='sort'
  146. />
  147. <span slot="footer" class="dialog-footer">
  148. <el-button @click="sortTag = false,sortTag2=false">取 消</el-button>
  149. <el-button type="primary" @click="editSort()">确 定</el-button>
  150. </span>
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script >
  155. import ManualSorting from '@/components/WbsTree/ManualSorting'
  156. export default {
  157. components:{
  158. ManualSorting
  159. },
  160. data() {
  161. return {
  162. data: [{
  163. label: '系统计量单元',
  164. children: [
  165. {
  166. label: '总则',
  167. children: [{
  168. label: '保险费'
  169. }]
  170. },
  171. {
  172. label: '路基工程',
  173. children: [{
  174. label: '清理与掘除'
  175. }]
  176. },
  177. {
  178. label: '路面工程',
  179. children: [{
  180. label: '底基层'
  181. }]
  182. },
  183. ]
  184. }],
  185. defaultProps: {
  186. children: 'children',
  187. label: 'label'
  188. },
  189. menuvisible:false,//右键菜单
  190. menuleft:20,
  191. menutop:0,
  192. menusData:[
  193. {icon: 'el-icon-plus', label: '新增节点', key: "add"},
  194. {icon: 'el-icon-s-promotion', label: '编辑节点', key: "edit"},
  195. {icon: 'el-icon-sort', label: '排序节点', key: "sort"},
  196. {icon: 'el-icon-delete', label: '删除节点', key: "del"},
  197. ],//树组件操作菜单
  198. menuKey:'',
  199. adddialogVisible:false,//新增节点
  200. addForm:{},
  201. addFormrules:{
  202. name: [
  203. { required: true, message: '请输入节点名称', trigger: 'blur' },
  204. ],
  205. goType: [
  206. { required: true, message: '请输入工程类型', trigger: 'blur' }
  207. ]
  208. },
  209. sortTag2: false,
  210. sortTag: false,
  211. sort: [],
  212. tableData:[{
  213. date: '001',
  214. name: '路基工程',
  215. address: '单位工程'
  216. }, {
  217. date: '001',
  218. name: '路基工程',
  219. address: '单位工程'
  220. }, {
  221. date: '001',
  222. name: '路基工程',
  223. address: '单位工程'
  224. }, {
  225. date: '001',
  226. name: '路基工程',
  227. address: '单位工程'
  228. },
  229. ]
  230. };
  231. },
  232. methods: {
  233. handleNodeClick(data) {
  234. console.log(data);
  235. },
  236. //树形控件菜单相关方法
  237. mouseout(){
  238. this.menuvisible=false
  239. },
  240. //展示菜单
  241. showMenu(e,data,node){
  242. e.preventDefault();
  243. console.log(e,'e');
  244. var x = e.pageX; //这个应该是相对于整个浏览器页面的x坐标,左上角为坐标原点(0,0)
  245. var y = e.pageY; //这个应该是相对于整个浏览器页面的y坐标,左上角为坐标原点(0,0)
  246. this.menutop = y;
  247. this.menuleft = x;
  248. this.menuvisible=true
  249. },
  250. menuClick(e,item,data,node){
  251. this.menuKey=''
  252. e.preventDefault();
  253. if(item.key==='add'){
  254. console.log('新增');
  255. this.menuKey='add'
  256. this.adddialogVisible=true
  257. }
  258. else if(item.key==='edit'){
  259. console.log('编辑');
  260. this.menuKey='edit'
  261. this.adddialogVisible=true
  262. }
  263. else if(item.key==='del'){
  264. this.menuKey='del'
  265. console.log('删除');
  266. this.deleNode(data,node)
  267. }
  268. else if(item.key==='sort'){
  269. this.menuKey='sort'
  270. console.log('排序');
  271. this.paixuMD(data,node)
  272. }
  273. },
  274. handleAddClose(){
  275. this.adddialogVisible=false
  276. },
  277. saveAddform(){
  278. //新增节点确定
  279. this.adddialogVisible=false
  280. },
  281. //排序
  282. handleSortClose(){
  283. this.sortdialogVisible=false
  284. },
  285. bianhua () {
  286. this.sortTag2 = false
  287. this.$nextTick(() => {
  288. this.sortTag2 = true
  289. })
  290. },
  291. editSort () {//修改排序
  292. let sortArr = this.sort, newArr = []
  293. for (let i = 0; i < sortArr.length; i++) {
  294. newArr.push({
  295. id: sortArr[i].id,
  296. nodeName: sortArr[i].nodeName
  297. })
  298. }
  299. // this.wbsTreeSort(newArr)
  300. },
  301. paixuMD (data) {
  302. this.sortTag = true
  303. this.sortTag2 = true
  304. console.log(data,'data');
  305. this.sort=[
  306. {tableName: '二级 3-1',
  307. children: [{
  308. tableName: '三级 3-1-1'
  309. }]
  310. }, {
  311. tableName: '二级 3-2',
  312. children: [{
  313. tableName: '三级 3-2-1'
  314. }]
  315. }
  316. ]
  317. // this.findWbsTreeSameLevel(data.id)
  318. },
  319. deleNode(data, node) {
  320. this.$confirm(
  321. "此操作将删除节点【" + data.label + "】, 是否继续?",
  322. "提示",
  323. {
  324. confirmButtonText: "确定",
  325. cancelButtonText: "取消",
  326. type: "warning",
  327. }
  328. )
  329. .then(() => {
  330. // removePrivateTreeNode(pid).then(() => {
  331. // this.$refs.tree.remove(node);
  332. // this.$message({
  333. // type: "success",
  334. // message: "删除成功!",
  335. // });
  336. // });
  337. })
  338. .catch(() => {});
  339. },
  340. }
  341. }
  342. </script>
  343. <style lang='scss' scoped>
  344. .custom-tree-node {
  345. .normal-black {
  346. display: none;
  347. }
  348. &:hover {
  349. .normal-black {
  350. display: inline-block;
  351. }
  352. }
  353. &.show .normal-black {
  354. display: inline-block;
  355. }
  356. }
  357. // 树形控件菜单样式
  358. .contextmenu {
  359. margin: 0;
  360. background: #fff;
  361. z-index: 1000;
  362. position: fixed; //关键样式设置固定定位
  363. list-style-type: none;
  364. padding: 5px 0;
  365. border-radius: 4px;
  366. font-size: 12px;
  367. font-weight: 400;
  368. color: #333;
  369. box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
  370. }
  371. .contextmenu li {
  372. margin: 0;
  373. padding: 7px 16px;
  374. cursor: pointer;
  375. }
  376. .contextmenu li:hover {
  377. background: #eee;
  378. }
  379. .form-horizontal .table-form, .form-horizontal .table-form td {
  380. border: 1px solid #ddd;
  381. background-color: #fdfdfd;
  382. font-size: 14px;
  383. padding: 4px;
  384. }
  385. </style>