|
@@ -100,6 +100,23 @@
|
|
|
v-model="isTreeNodeEditShow" :node="treeInfo" :type="Number(isType)" :wid="wbsId" :pid="projectInfo.id" :tree-props="treeProps"
|
|
|
:node-type="nodeTypelist" :major-type="majorDataTypeList" @close="treeNodeEditClose" @change="treeNodeEditChange"
|
|
|
/>
|
|
|
+ <!-- 节点排序 -->
|
|
|
+ <hc-new-dialog v-model="nodeSortModalShow" is-table widths="1100px" title="调整排序" @save="nodeSortModalSave">
|
|
|
+ <hc-table
|
|
|
+ ui="hc-table-row-drop" :column="nodeSortTableColumn" :datas="nodeSortTableData"
|
|
|
+ :loading="nodeSortNodeLoading" is-row-drop quick-sort :index-style="{ width: 80 }"
|
|
|
+ @row-drop="nodeSortTableRowDrop" @row-sort="nodeSortTableRowDrop"
|
|
|
+ >
|
|
|
+ <template #action="{ row, index }">
|
|
|
+ <span class="text-xl" :class="index === 0 ? 'text-gray' : 'text-link'" @click="upNodeSortClick(row, index)">
|
|
|
+ <hc-icon name="arrow-up" fill />
|
|
|
+ </span>
|
|
|
+ <span class="ml-2 text-xl" :class="index === (nodeSortTableData.length - 1) ? 'text-gray' : 'text-link'" @click="downNodeSortClick(row, index)">
|
|
|
+ <hc-icon name="arrow-down" fill />
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </hc-table>
|
|
|
+ </hc-new-dialog>
|
|
|
</hc-drawer>
|
|
|
</template>
|
|
|
|
|
@@ -107,7 +124,7 @@
|
|
|
import { nextTick, ref, watch } from 'vue'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
import { HcFirmMsg, getStore, setStore } from 'hc-vue3-ui'
|
|
|
-import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
+import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
import { getDictionaryData, reloadPage } from '~uti/tools'
|
|
|
import wbsTreeApi from '~api/wbs/tree'
|
|
|
import mainApi from '~api/wbs/private'
|
|
@@ -352,7 +369,22 @@ const treeMenuClick = async ({ key, node, data }) => {
|
|
|
}
|
|
|
})
|
|
|
} else if (key === 'sort') {
|
|
|
+ const { parentId } = data
|
|
|
+ const { id } = projectInfo.value
|
|
|
+ if (isNullES(id) || isNullES(wbsId.value)) {
|
|
|
+ window.$message.warning('参数异常,请稍后重试')
|
|
|
+ return
|
|
|
+ }
|
|
|
//调整排序
|
|
|
+ nodeSortModalShow.value = true
|
|
|
+ nodeSortNodeLoading.value = true
|
|
|
+ const { data: apiData } = await wbsTreeApi.findWbsTreePrivateSameLevel({
|
|
|
+ parentId: parentId,
|
|
|
+ projectId: id,
|
|
|
+ wbsId: wbsId.value,
|
|
|
+ })
|
|
|
+ nodeSortNodeLoading.value = false
|
|
|
+ nodeSortTableData.value = getArrValue(apiData)
|
|
|
} else if (key === 'del') {
|
|
|
if (node.level <= 1) {
|
|
|
window.$message.warning('当前节点无法删除')
|
|
@@ -381,6 +413,69 @@ const treeMenuClick = async ({ key, node, data }) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//节点排序
|
|
|
+const nodeSortModalShow = ref(false)
|
|
|
+const nodeSortTableColumn = ref([
|
|
|
+ { key:'tableName', name: '节点名称' },
|
|
|
+ { key:'action', name: '排序', width: 90 },
|
|
|
+])
|
|
|
+const nodeSortTableData = ref([])
|
|
|
+const nodeSortNodeLoading = ref(false)
|
|
|
+
|
|
|
+//拖动完成
|
|
|
+const nodeSortTableRowDrop = (rows) => {
|
|
|
+ nodeSortTableData.value = [] // 先清空,否则排序会异常
|
|
|
+ nextTick(() => {
|
|
|
+ nodeSortTableData.value = rows
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//向上
|
|
|
+const upNodeSortClick = (row, index) => {
|
|
|
+ const data = nodeSortTableData.value || []
|
|
|
+ if (index !== 0) {
|
|
|
+ const tmp = data.splice(index - 1, 1)
|
|
|
+ nodeSortTableData.value.splice(index, 0, tmp[0])
|
|
|
+ } else {
|
|
|
+ window?.$message?.warning('已经处于置顶,无法上移')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//向下
|
|
|
+const downNodeSortClick = (row, index) => {
|
|
|
+ const indexs = index + 1
|
|
|
+ const data = nodeSortTableData.value
|
|
|
+ if (indexs !== data.length) {
|
|
|
+ const tmp = data.splice(indexs, 1)
|
|
|
+ nodeSortTableData.value.splice(index, 0, tmp[0])
|
|
|
+ } else {
|
|
|
+ window?.$message?.warning('已经处于置底,无法下移')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//节点排序完成
|
|
|
+const nodeSortModalSave = async () => {
|
|
|
+ const arr = deepClone(nodeSortTableData.value)
|
|
|
+ if (arr.length <= 0) {
|
|
|
+ window.$message.warning('数据异常,请稍后重试')
|
|
|
+ nodeSortModalShow.value = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //处理顺序
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
+ arr[i].sort = i + 1
|
|
|
+ }
|
|
|
+ //发起请求
|
|
|
+ const { error, code, msg } = await wbsTreeApi.wbsTreePrivateSort(arr)
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success('排序完成')
|
|
|
+ nodeSortModalShow.value = false
|
|
|
+ reloadPage()
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg ?? '排序失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//编辑节点
|
|
|
const isTreeNodeEditShow = ref(false)
|
|
|
//编辑节点被关闭
|