drawer-wbs.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. <template>
  2. <hc-drawer
  3. v-model="isShow"
  4. to-id="hc-main-box"
  5. is-close
  6. @close="drawerClose"
  7. >
  8. <div class="hc-project-wbs-tree flex">
  9. <div class="header hc-flex">
  10. <div class="name flex-1">
  11. {{ dataInfo.wbsName }}
  12. </div>
  13. <div class="hc-flex">
  14. <el-button
  15. v-if="curTreeNode && curTreeNode.level == 2"
  16. hc-btn
  17. type="primary"
  18. >
  19. 导入划分
  20. </el-button>
  21. <el-button
  22. v-if="!isShowInfo"
  23. hc-btn
  24. type="primary"
  25. @click="showInfoClick"
  26. >
  27. 元素设置
  28. </el-button>
  29. <el-button
  30. v-if="isShowInfo"
  31. hc-btn
  32. type="primary"
  33. @click="hideInfoClick"
  34. >
  35. 元素公式设置
  36. </el-button>
  37. <el-button hc-btn type="warning" @click="nodeParamClick">
  38. 节点参数设置
  39. </el-button>
  40. </div>
  41. </div>
  42. <div class="body">
  43. <hc-body split :options="splitOptions">
  44. <template #left>
  45. <hc-card scrollbar>
  46. <template #header>
  47. <hc-search-input
  48. v-model="searchTreeName"
  49. @search="searchTreeNameClick"
  50. @clear="searchTreeNameClick"
  51. >
  52. <template #prepend>
  53. <el-select
  54. v-model="queryType"
  55. placeholder="类型"
  56. style="width: 75px"
  57. >
  58. <el-option label="节点" value="1" />
  59. <el-option label="表名" value="2" />
  60. </el-select>
  61. </template>
  62. </hc-search-input>
  63. </template>
  64. <hc-lazy-tree
  65. v-if="isTreeMode"
  66. :root-menu="treeMenuData"
  67. :menus="treeMenuDatas"
  68. :h-props="treeProps"
  69. tree-key="id"
  70. :auto-expand-keys="autoExpandKeys"
  71. @load="treeLoadNode"
  72. @node-tap="treeNodeTap"
  73. @menu-tap="treeMenuClick"
  74. >
  75. <template #nodeName="{ data }">
  76. <span class="text-16px font-400">{{
  77. data.nodeName
  78. }}</span>
  79. </template>
  80. </hc-lazy-tree>
  81. <template v-if="isTreeMode === false">
  82. <hc-data-tree
  83. ref="treeRef"
  84. default-expand-all
  85. :h-props="treeProps"
  86. tree-key="id"
  87. :datas="treeData"
  88. @node-tap="treeNodeTap"
  89. >
  90. <template #name="{ data }">
  91. <span class="text-16px font-400">{{
  92. data.title
  93. }}</span>
  94. </template>
  95. </hc-data-tree>
  96. </template>
  97. </hc-card>
  98. </template>
  99. <hc-card class="hc-desk-system-unit-temp">
  100. <template v-if="!isNullES(nodeInfo.id)">
  101. <div v-if="isShowInfo" class="body-top">
  102. <hc-card title="节点信息">
  103. <hc-table
  104. :is-index="false"
  105. :column="nodeTableColumn"
  106. :datas="nodeTableData"
  107. >
  108. <template #nodeType="{ row }">
  109. {{
  110. getDictionaryName(
  111. majorDatatype,
  112. row.nodeType,
  113. true,
  114. )
  115. }}
  116. </template>
  117. </hc-table>
  118. </hc-card>
  119. </div>
  120. <div class="body-content">
  121. <hc-card title="当前已创建的元素表">
  122. <template #extra>
  123. <el-button
  124. v-if="isShowInfo"
  125. size="small"
  126. type="primary"
  127. @click="createNew"
  128. >
  129. 创建元素表
  130. </el-button>
  131. <el-button
  132. v-if="isShowInfo"
  133. size="small"
  134. type="warning"
  135. @click="editEleClick"
  136. >
  137. 编辑元素表单
  138. </el-button>
  139. <el-button
  140. v-if="isShowInfo"
  141. size="small"
  142. type="success"
  143. @click="sortClick"
  144. >
  145. 排序
  146. </el-button>
  147. </template>
  148. <hc-table
  149. :column="tableColumn"
  150. :datas="tableData"
  151. :loading="tableLoading"
  152. :is-index="false"
  153. :is-current-row="false"
  154. >
  155. <template #tableType="{ row }">
  156. {{
  157. getDictionaryName(
  158. tableTypelist,
  159. row.tableType,
  160. true,
  161. )
  162. }}
  163. </template>
  164. <template #tableOwner="{ row }">
  165. {{
  166. getDictionaryName(
  167. ownerTypeList,
  168. row.tableOwner,
  169. true,
  170. )
  171. }}
  172. </template>
  173. <template #action="{ row, index }">
  174. <el-link
  175. v-if="isShowInfo"
  176. type="warning"
  177. @click="editRowClick(row)"
  178. >
  179. 编辑
  180. </el-link>
  181. <el-link
  182. v-else
  183. type="warning"
  184. @click="editFormulaClick(row)"
  185. >
  186. 编辑元素公式
  187. </el-link>
  188. <el-link
  189. type="danger"
  190. @click="rowDelClick(row)"
  191. >
  192. 删除
  193. </el-link>
  194. </template>
  195. </hc-table>
  196. </hc-card>
  197. </div>
  198. </template>
  199. <hc-empty v-else title="请先点击左侧树节点" />
  200. </hc-card>
  201. </hc-body>
  202. </div>
  203. </div>
  204. <!-- 树节点调整排序 -->
  205. <hc-dialog
  206. v-model="isSortingShow"
  207. title="调整排序"
  208. widths="600px"
  209. is-table
  210. @close="sortingClose"
  211. >
  212. <hc-table
  213. ref="tableSortingRef"
  214. :column="tableSortingColumn"
  215. :datas="tableSortingData"
  216. is-row-drop
  217. is-sort
  218. quick-sort
  219. @row-drop="sortingRowDropTap"
  220. @row-sort="sortingRowSortTap"
  221. />
  222. <template #footer>
  223. <el-button hc-btn @click="sortingClose">取消</el-button>
  224. <el-button
  225. hc-btn
  226. type="primary"
  227. :disabled="tableSortingData.length <= 0"
  228. :loading="sortingLoading"
  229. @click="sortingSubmit"
  230. >
  231. 提交
  232. </el-button>
  233. </template>
  234. </hc-dialog>
  235. <!-- 树节点新增修改 -->
  236. <TreeNodeEditDialog
  237. v-model="isAddEditShow"
  238. :node="formModel"
  239. :type="Number(wbsType)"
  240. :wid="dataInfo.id"
  241. :tree-props="treeProps"
  242. :node-type="majorDatatype"
  243. :major-type="majorDataTypeList"
  244. :title="modalTreeTitle"
  245. @close="addEditClose"
  246. @change="treeNodeEditChange"
  247. />
  248. <!-- 创建新的元素表 -->
  249. <createNewExcel
  250. v-model="isCreateShow"
  251. :node="nodeDetail"
  252. :wid="dataInfo.id"
  253. :table-typelist="tableTypelist"
  254. :owner-type-list="ownerTypeList"
  255. :title="modalTitle"
  256. :table-id="tableId"
  257. :init-table-name="initTableName"
  258. :init-table-id="initTableId"
  259. :e-key="eKey"
  260. :is-add="isAddType"
  261. @close="createClose"
  262. />
  263. <!-- 编辑元素表信息 -->
  264. <editElePage
  265. v-model="editEleShow"
  266. :table-typelist="tableTypelist"
  267. :owner-type-list="ownerTypeList"
  268. :tab="tableData"
  269. @close="editClose"
  270. />
  271. <!-- 表单调整排序 -->
  272. <tableSort
  273. v-model="tableSortShow"
  274. :tab="tableData"
  275. @close="tableSortShowClose"
  276. />
  277. <!-- 编辑元素公式 -->
  278. <editFormulaDialog
  279. v-model="editFormulaShow"
  280. :table-id="tableId"
  281. @close="editFormulaClose"
  282. @formula="toFormulaClick"
  283. />
  284. </hc-drawer>
  285. <!-- 节点参数设置 -->
  286. <nodeParamDialog
  287. v-model="nodeParamShow"
  288. :node-id="nodeInfo.id"
  289. :scope-type="1"
  290. :node-info="nodeInfo"
  291. @close="nodeParamClose"
  292. />
  293. <!-- 编辑公式 -->
  294. <HcEditFormula
  295. v-model="isEditFormulaShow"
  296. :data="editFormulaData"
  297. @finish="editFormulaFinish"
  298. />
  299. </template>
  300. <script setup>
  301. import { nextTick, onMounted, ref, watch } from 'vue'
  302. import { HcDelMsg } from 'hc-vue3-ui'
  303. import { getDictionaryData, getDictionaryName } from '~src/utils/tools'
  304. import HcEditFormula from '~src/views/project/list/edit-formula.vue'
  305. import { getStoreValue, setStoreValue } from '~uti/storage'
  306. import tableSort from './table-sort.vue'
  307. import editFormulaDialog from './edit-formula-dialog.vue'
  308. import {
  309. arrToId,
  310. deepClone,
  311. getArrValue,
  312. getObjValue,
  313. isNullES,
  314. } from 'js-fast-way'
  315. import mainApi from '~api/wbs/tree'
  316. import mainWbsApi from '~api/wbs/wbsforelement'
  317. import { useAppStore } from '~src/store'
  318. import TreeNodeEditDialog from './tree-node-edit.vue'
  319. import createNewExcel from './create-new-excel.vue'
  320. import editElePage from './edit-ele.vue'
  321. import nodeParamDialog from './node-param-dialog.vue'
  322. const props = defineProps({
  323. data: {
  324. type: Object,
  325. default: () => ({}),
  326. },
  327. })
  328. const emit = defineEmits(['close'])
  329. const splitOptions = { sizes: [25, 75], snapOffset: 0, minSize: [300, 300] }
  330. //缓存
  331. const store = useAppStore()
  332. const userInfo = ref(store.getUserInfo)
  333. watch(
  334. () => store.getUserInfo,
  335. (info) => {
  336. userInfo.value = info
  337. },
  338. { immediate: true, deep: true },
  339. )
  340. //双向绑定
  341. const isShow = defineModel('modelValue', {
  342. default: false,
  343. })
  344. //监听数据
  345. const dataInfo = ref(props.data)
  346. const wbsType = ref(props.data.wbsType)
  347. watch(
  348. () => props.data,
  349. (data) => {
  350. dataInfo.value = data
  351. wbsType.value = data.wbsType
  352. },
  353. { immediate: true, deep: true },
  354. )
  355. //监听显示
  356. watch(isShow, (val) => {
  357. if (val) getDataApi()
  358. getMajorList()
  359. getOwnerTypelist()
  360. getTableTypelist(Number(wbsType.value - 1))
  361. })
  362. //渲染完成
  363. onMounted(() => {
  364. autoExpandKeys.value = getStoreValue('autoExpandKeys') || []
  365. })
  366. //处理相关数据
  367. const majorDatatype = ref([])
  368. const getDataApi = async () => {
  369. isTreeMode.value = true
  370. const type = wbsType.value
  371. let code = ''
  372. if (type === 5) {
  373. code = 'lar_node_type' //征拆
  374. } else if (type === 2) {
  375. code = 'trial_node_type' //试验
  376. } else if (type === 3) {
  377. code = 'meter_node_type' //计量
  378. } else {
  379. {
  380. code = 'wbs_node_type' //质检
  381. }
  382. }
  383. majorDatatype.value = await getDictionaryData(code, false)
  384. }
  385. //树搜索
  386. const queryType = ref('1')
  387. const searchTreeName = ref('')
  388. const searchTreeNameClick = async () => {
  389. if (isNullES(searchTreeName.value)) {
  390. isTreeMode.value = true
  391. } else {
  392. isTreeMode.value = false
  393. await getSearchData()
  394. }
  395. }
  396. const getSearchData = async () => {
  397. const { id } = getObjValue(dataInfo.value)
  398. const { data } = await mainApi.getQueryValueByType({
  399. wbsId: id,
  400. type: queryType.value,
  401. queryValue: searchTreeName.value,
  402. projectId: '',
  403. })
  404. treeData.value = data
  405. }
  406. //节点详情
  407. const nodeDetail = ref({})
  408. const getNodeDetail = async (data1, node) => {
  409. let parentName = ''
  410. if (node.parent.data) {
  411. parentName = node.parent.data.title
  412. }
  413. const { data } = await mainApi.getDetail(data1.id, node)
  414. nodeInfo.value = data
  415. nodeDetail.value = data
  416. formModel.value = data
  417. formModel.value.parentName = parentName
  418. nodeInfo.value.parentName = parentName
  419. nodeInfo.value.nodeTypeName = getDictionaryName(
  420. majorDatatype.value,
  421. data.nodeType,
  422. )
  423. defaultCheckedKeys.value = nodeDetail.value.mixRatioTestIds
  424. ? nodeDetail.value.mixRatioTestIds.split(',')
  425. : []
  426. const res = getObjValue(data)
  427. nodeTableData.value = [res]
  428. }
  429. //内业资料类型
  430. const majorDataTypeList = ref([])
  431. const getMajorList = async () => {
  432. majorDataTypeList.value = await getDictionaryData('major_data_type', false)
  433. }
  434. //树配置
  435. const isTreeMode = ref(false)
  436. const treeProps = {
  437. label: 'title',
  438. children: 'children',
  439. isLeaf: function (data) {
  440. if (data.hasChildren && data.isExistForm != 1) {
  441. return false
  442. } else if (data.hasChildren && data.isExistForm == 1) {
  443. return true
  444. } else {
  445. return true
  446. }
  447. },
  448. }
  449. const treeData = ref([])
  450. const autoExpandKeys = ref([])
  451. const defaultCheckedKeys = ref([])
  452. //懒加载树
  453. const treeLoadNode = async ({ item, level }, resolve) => {
  454. const { tenant_id } = getObjValue(userInfo.value)
  455. const parentId = level === 0 ? 0 : item.id
  456. const { id } = getObjValue(dataInfo.value)
  457. const { data } = await mainApi.getLazytree({
  458. parentId: parentId,
  459. wbsId: id,
  460. tenantId: tenant_id,
  461. })
  462. resolve(getArrValue(data))
  463. }
  464. //树菜单根节点
  465. const treeMenuData = [
  466. { icon: 'add-circle', label: '新增节点', key: 'add' },
  467. { icon: 'draft', label: '编辑节点', key: 'edit' },
  468. { icon: 'delete-bin', label: '删除节点', key: 'del' },
  469. ]
  470. const treeMenuDatas = [
  471. { icon: 'add-circle', label: '新增节点', key: 'add' },
  472. { icon: 'draft', label: '编辑节点', key: 'edit' },
  473. { icon: 'arrow-up-down', label: '排序节点', key: 'rank' },
  474. { icon: 'delete-bin', label: '删除节点', key: 'del' },
  475. ]
  476. //试验树数据
  477. //菜单被点击
  478. const treeMenuClick = async ({ key, data, node, keys }) => {
  479. nodeInfo.value = data
  480. autoExpandKeys.value = keys || []
  481. setStoreValue('autoExpandKeys', keys)
  482. if (key === 'add') {
  483. formModel.value = {}
  484. let parentName = ''
  485. if (node.parent.data) {
  486. parentName = node.parent.data.title
  487. }
  488. formModel.value.parentName = parentName
  489. await getNodeDetail(data, node)
  490. formModel.value.parentId = data.id
  491. formModel.value.id = ''
  492. formModel.value.nodeName = ''
  493. formModel.value.partitionCode = ''
  494. formModel.value.uniqueCode = ''
  495. formModel.value.majorDataType = ''
  496. formModel.value.fullName = ''
  497. await nextTick()
  498. if (
  499. nodeInfo.value.nodeType == 6
  500. || nodeInfo.value.isExistForm == 1
  501. || nodeInfo.value.unitName
  502. || nodeInfo.value.className
  503. ) {
  504. window.$message({
  505. type: 'warning',
  506. message: '该节点下无法新增节点',
  507. })
  508. return
  509. }
  510. isAddEditShow.value = true
  511. modalTreeTitle.value = '新增节点'
  512. } else if (key === 'edit') {
  513. formModel.value = deepClone(data)
  514. formModel.value.nodeName = formModel.value.title
  515. getNodeDetail(data, node)
  516. await nextTick()
  517. isAddEditShow.value = true
  518. modalTreeTitle.value = '编辑节点'
  519. } else if (key === 'rank') {
  520. const pid = node.parent.data.id
  521. const { data } = await mainApi.findWbsTreeSameLevel({ parentId: pid })
  522. tableSortingData.value = getArrValue(data)
  523. isSortingShow.value = true
  524. } else if (key === 'del') {
  525. HcDelMsg(async (resolve) => {
  526. const { code } = await mainApi.remove(data.id)
  527. resolve() //关闭弹窗的回调
  528. if (code !== 200) return
  529. window.$message.success('删除成功')
  530. setTreeMode()
  531. }).then()
  532. }
  533. }
  534. //树节点被点击
  535. const nodeInfo = ref({})
  536. const curTreeNode = ref({})
  537. const treeNodeTap = async ({ data, node, keys }) => {
  538. curTreeNode.value = node
  539. autoExpandKeys.value = keys || []
  540. setStoreValue('autoExpandKeys', keys)
  541. await getNodeDetail(data, node)
  542. await getTableData()
  543. }
  544. //节点信息
  545. const nodeTableColumn = ref([
  546. { key: 'nodeName', name: '当前节点', align: 'center' },
  547. { key: 'nodeType', name: '节点类型', align: 'center' },
  548. { key: 'parentName', name: '上级节点', align: 'center' },
  549. ])
  550. const nodeTableData = ref([])
  551. //表格数据
  552. const tableColumn = ref([
  553. { key: 'tableName', name: '表单名称' },
  554. { key: 'elementTotal', name: '元素总量' },
  555. { key: 'fillRate', name: '填报率' },
  556. { key: 'tableType', name: '表单类型' },
  557. { key: 'tableOwner', name: '所属方' },
  558. { key: 'action', name: '操作', align: 'center' },
  559. ])
  560. const tableData = ref([{}])
  561. //获取表格数据
  562. const tableLoading = ref(false)
  563. //获取数据
  564. const getTableData = async () => {
  565. tableData.value = []
  566. const { id } = nodeInfo.value
  567. tableLoading.value = true
  568. const { data } = await mainApi.selectByNodeTable({
  569. id,
  570. })
  571. tableLoading.value = false
  572. const res = getArrValue(data)
  573. tableData.value = res
  574. }
  575. //获取表单类型
  576. const tableTypelist = ref([])
  577. const getTableTypelist = async (type) => {
  578. //计量管理,征拆划分,实验划分,WBS树管理,日志树管理
  579. const types = [
  580. 'table_type',
  581. 'trial_table_type',
  582. 'table_type',
  583. 'table_type',
  584. 'table_type',
  585. ]
  586. const data = await getDictionaryData(types[type])
  587. tableTypelist.value = getArrValue(data)
  588. }
  589. const ownerTypeList = ref([])
  590. const getOwnerTypelist = async () => {
  591. const data = await getDictionaryData('owner_type')
  592. ownerTypeList.value = getArrValue(data)
  593. }
  594. //新增、编辑节点
  595. const isAddEditShow = ref(false)
  596. const modalTreeTitle = ref('新增节点')
  597. const formModel = ref({})
  598. //新增、编辑节点提交
  599. //关闭 新增、编辑节点
  600. const addEditClose = () => {
  601. isAddEditShow.value = false
  602. formModel.value = {}
  603. }
  604. //编辑节点被修改
  605. const treeNodeEditChange = () => {
  606. isAddEditShow.value = false
  607. formModel.value = {}
  608. console.log('编辑节点被修改')
  609. setTreeMode()
  610. }
  611. //树重加载
  612. const setTreeMode = () => {
  613. isTreeMode.value = false
  614. nodeInfo.value = {}
  615. tableData.value = []
  616. setTimeout(() => {
  617. isTreeMode.value = true
  618. }, 500)
  619. }
  620. //排序
  621. const isSortingShow = ref(false)
  622. const tableSortingRef = ref(null)
  623. //排序表
  624. const tableSortingColumn = [{ key: 'nodeName', name: '节点名称' }]
  625. const tableSortingData = ref([])
  626. // 行拖拽
  627. const sortingRowDropTap = async (rows) => {
  628. // 先清空,否则排序会异常
  629. tableData.value = []
  630. await nextTick()
  631. tableData.value = rows
  632. }
  633. // 点击排序
  634. const sortingRowSortTap = async (rows) => {
  635. // 先清空,否则排序会异常
  636. tableData.value = []
  637. await nextTick()
  638. tableData.value = rows
  639. }
  640. //排序提交
  641. const sortingLoading = ref(false)
  642. const sortingSubmit = async () => {
  643. const arr = tableSortingData.value
  644. if (arr.length <= 0) {
  645. window?.$message?.warning('暂无数据')
  646. return
  647. }
  648. sortingLoading.value = true
  649. const ids = arrToId(arr)
  650. const { error, code } = await mainApi.wbsTreeSort(arr)
  651. sortingLoading.value = false
  652. if (!error && code === 200) {
  653. window?.$message?.success('操作成功')
  654. sortingClose()
  655. setTreeMode()
  656. }
  657. }
  658. //关闭排序
  659. const sortingClose = () => {
  660. isSortingShow.value = false
  661. tableData.value = []
  662. }
  663. //关闭抽屉
  664. const drawerClose = () => {
  665. isShow.value = false
  666. isTreeMode.value = false
  667. nodeInfo.value = {}
  668. emit('close')
  669. }
  670. const tableId = ref('')
  671. const initTableName = ref('')
  672. const initTableId = ref('')
  673. const eKey = ref('')
  674. const editRowClick = async (row) => {
  675. await nextTick()
  676. isCreateShow.value = true
  677. isAddType.value = false
  678. modalTitle.value = row.tableName + '元素编辑'
  679. tableId.value = row.id
  680. initTableName.value = row.initTableName
  681. initTableId.value = row.initTableId
  682. eKey.value = row.ekey
  683. }
  684. const rowDelClick = async (row) => {
  685. console.log('删除')
  686. HcDelMsg(async (resolve) => {
  687. const { isRes } = await mainWbsApi.removeTable({ id: row.id })
  688. resolve() //关闭弹窗的回调
  689. if (!isRes) return
  690. getTableData()
  691. })
  692. }
  693. //创建新的元素表
  694. const isCreateShow = ref(false)
  695. const modalTitle = ref('创建新的元素表')
  696. const isAddType = ref(false)
  697. const createClose = async () => {
  698. // getTableData()
  699. isCreateShow.value = false
  700. }
  701. const createNew = async () => {
  702. const { id } = nodeInfo.value
  703. tableId.value = ''
  704. if (id) {
  705. await nextTick()
  706. isCreateShow.value = true
  707. modalTitle.value = '创建新的元素表'
  708. isAddType.value = true
  709. tableId.value = ''
  710. } else {
  711. window.$message.warning('请先选择在哪个节点下创建表')
  712. }
  713. }
  714. //编辑元素表单
  715. const editEleShow = ref(false)
  716. const editClose = () => {
  717. editEleShow.value = false
  718. getTableData()
  719. }
  720. const editEleClick = () => {
  721. const { id } = nodeInfo.value
  722. if (id) {
  723. editEleShow.value = true
  724. } else {
  725. window.$message.warning('请先选择编辑哪个节点')
  726. }
  727. }
  728. // 元素表排序
  729. const tableSortShow = ref(false)
  730. const sortClick = () => {
  731. tableSortShow.value = true
  732. }
  733. const tableSortShowClose = () => {
  734. tableSortShow.value = false
  735. getTableData()
  736. }
  737. //按钮切换
  738. const isShowInfo = ref(true)
  739. const hideInfoClick = () => {
  740. const { id } = nodeInfo.value
  741. if (id) {
  742. isShowInfo.value = false
  743. } else {
  744. window.$message.warning('请先选择左侧节点')
  745. }
  746. }
  747. const showInfoClick = () => {
  748. isShowInfo.value = true
  749. }
  750. //编辑元素公式
  751. const editFormulaShow = ref(false)
  752. const editFormulaClose = () => {
  753. editFormulaShow.value = false
  754. elementFormulasObj.value = {}
  755. }
  756. const elementFormulasObj = ref({})
  757. const editFormulaClick = (row) => {
  758. const { id } = nodeInfo.value
  759. elementFormulasObj.value = row
  760. if (id) {
  761. tableId.value = row.id
  762. editFormulaShow.value = true
  763. } else {
  764. window.$message.warning('请先选择左侧节点')
  765. }
  766. }
  767. //公式
  768. const editFormulaData = ref({})
  769. const isEditFormulaShow = ref(false)
  770. const toFormulaClick = async ({ type, data }) => {
  771. const { id } = getObjValue(dataInfo.value)
  772. if (type === 'global') {
  773. //全局公式
  774. editFormulaData.value = {
  775. node: data,
  776. wbsId: id,
  777. nodeId: nodeDetail.value.id,
  778. eleId: data.id,
  779. eleType: false,
  780. tableType: true,
  781. globalType: 1,
  782. }
  783. await nextTick()
  784. isEditFormulaShow.value = true
  785. } else if (type === 'node') {
  786. //节点公式
  787. editFormulaData.value = {
  788. node: nodeDetail.value,
  789. wbsId: id,
  790. nodeId: nodeDetail.value.id,
  791. eleId: data.id,
  792. globalType: 2,
  793. }
  794. await nextTick()
  795. isEditFormulaShow.value = true
  796. }
  797. }
  798. //公式操作完成
  799. const editFormulaFinish = () => {
  800. }
  801. //节点参数设置
  802. const nodeParamShow = ref(false)
  803. const nodeParamClose = () => {
  804. nodeParamShow.value = false
  805. }
  806. const nodeParamClick = () => {
  807. const { id } = nodeInfo.value
  808. if (id) {
  809. nodeParamShow.value = true
  810. } else {
  811. window.$message.warning('请先选择左侧节点')
  812. }
  813. }
  814. </script>
  815. <style lang="scss">
  816. .hc-desk-system-unit-temp .el-card {
  817. .hc-card-item-box {
  818. height: auto;
  819. padding: 10px 14px;
  820. .hc-card-item-header {
  821. color: #4a4a4a;
  822. margin-bottom: 6px;
  823. }
  824. }
  825. .hc-card-item-box + .hc-card-item-box {
  826. margin-top: 20px;
  827. }
  828. }
  829. .border-class {
  830. position: relative;
  831. height: 300px;
  832. border: 1px solid #dddfe6;
  833. }
  834. </style>
  835. <style scoped lang="scss">
  836. .hc-project-wbs-tree {
  837. position: relative;
  838. background: #ececec;
  839. border-radius: 4px;
  840. height: 100%;
  841. flex-direction: column;
  842. overflow: hidden;
  843. .header {
  844. color: white;
  845. background: #54565a;
  846. padding: 10px 14px;
  847. flex-shrink: 0;
  848. .name {
  849. white-space: nowrap;
  850. overflow: hidden;
  851. text-overflow: ellipsis;
  852. }
  853. }
  854. .body {
  855. flex: 1;
  856. flex-basis: auto;
  857. position: relative;
  858. }
  859. }
  860. </style>
  861. <style lang="scss">
  862. .hc-project-wbs-tree .body {
  863. .el-card.hc-card-box {
  864. --el-card-padding: 12px;
  865. --el-card-border-radius: 5px;
  866. }
  867. .hc-page-split-content {
  868. position: relative;
  869. .body-top {
  870. position: relative;
  871. height: 119.5px;
  872. }
  873. .body-content {
  874. position: relative;
  875. margin-top: 10px;
  876. height: calc(100% - 129.5px);
  877. }
  878. }
  879. }
  880. </style>