调整采购入库和修改可拖拽部门树组件
This commit is contained in:
1 parent
f0105c0325
commit
6177e3e053
5 files changed
+368
-403
No files matched your search
@@ -1,216 +0,0 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<!-- 头部区域 -->
|
||||
<div class="container-header">
|
||||
<div class="container-header-input">
|
||||
<el-input
|
||||
v-model="searchName"
|
||||
suffix-icon="search"
|
||||
:placeholder="placeholder"
|
||||
clearable
|
||||
@change="getTreeData"
|
||||
/>
|
||||
</div>
|
||||
<div class="container-header-dropdown" v-if="showExpand">
|
||||
<el-dropdown :hide-on-click="false">
|
||||
<el-icon style="transform: rotate(90deg)">
|
||||
<MoreFilled />
|
||||
</el-icon>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>
|
||||
<el-button
|
||||
class="!h-[20px] !text-gray-500 dark:!text-white dark:hover:!text-primary"
|
||||
link
|
||||
:icon="isExpand ? 'expand' : 'fold'"
|
||||
@click="toggleRowExpansionAll(isExpand ? false : true)"
|
||||
>
|
||||
{{ isExpand ? "折叠" : "展开" }}
|
||||
</el-button>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 树形结构 -->
|
||||
<div class="container-tree">
|
||||
<el-tree
|
||||
ref="depTreeRef"
|
||||
:props="props.props"
|
||||
:data="state.treeList"
|
||||
:expand-on-click-node="false"
|
||||
:loading="state.loading"
|
||||
node-key="id"
|
||||
highlight-current
|
||||
default-expand-all
|
||||
@node-click="handleNodeClick"
|
||||
show-checkbox
|
||||
@check-change="handleCheckChange"
|
||||
>
|
||||
<template #default="{ node, data }" v-if="$slots.default">
|
||||
<slot :node="node" :data="data" />
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
|
||||
<!-- 底部区域 -->
|
||||
<div class="container-switch">
|
||||
<el-switch
|
||||
v-model="state.isDeep"
|
||||
@change="handleTreeDeepSearch"
|
||||
:inactive-text="switchInactiveText"
|
||||
:active-text="switchActiveText"
|
||||
:disabled="checkedTreeNodes.length > 0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="dep-tree">
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string // 输入框占位符
|
||||
loading?: boolean // 加载中的状态
|
||||
showExpand?: boolean // 折叠控制
|
||||
query?: (searchName?: string) => Promise<any> // 查询函数
|
||||
props?: object
|
||||
switchInactiveText?: string | undefined
|
||||
switchActiveText?: string | undefined
|
||||
}>(),
|
||||
{
|
||||
placeholder: "",
|
||||
loading: false,
|
||||
showExpand: true,
|
||||
query: () => new Promise((resolve) => resolve([])),
|
||||
props: () => {
|
||||
return {
|
||||
label: "name",
|
||||
children: "children",
|
||||
value: "id",
|
||||
}
|
||||
},
|
||||
switchInactiveText: "当前级",
|
||||
switchActiveText: "当前级及子级",
|
||||
},
|
||||
)
|
||||
const emit = defineEmits(["nodeClick", "treeDeepSearch"])
|
||||
|
||||
const state = reactive({
|
||||
treeList: [],
|
||||
loading: props.loading,
|
||||
isDeep: false,
|
||||
})
|
||||
|
||||
const depTreeRef = ref() // 树组件的引用
|
||||
const searchName = ref() // 查询关键字
|
||||
const isExpand = ref(true) // 是否展开所有节点
|
||||
// 被勾选的树节点
|
||||
const checkedTreeNodes = ref([])
|
||||
|
||||
// 获取部门树形结构数据
|
||||
const getTreeData = () => {
|
||||
if (props.query instanceof Function) {
|
||||
state.loading = true
|
||||
|
||||
// 调用传入的查询函数,并将查询关键字作为参数传入
|
||||
const result = props.query(unref(searchName))
|
||||
|
||||
// 如果查询结果为 Promise 类型,则进行后续处理
|
||||
if ((typeof result === "object" || typeof result === "function") && typeof result.then === "function") {
|
||||
result
|
||||
.then((r: any) => {
|
||||
state.treeList = r.data
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg)
|
||||
})
|
||||
.finally(() => (state.loading = false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 点击树形结构节点
|
||||
const handleNodeClick = (item: any) => emit("nodeClick", item)
|
||||
|
||||
// 节点深度搜索
|
||||
const handleTreeDeepSearch = () => emit("treeDeepSearch", state.isDeep)
|
||||
|
||||
// 切换所有节点的展开/收起状态。status:true 为展开,false 为收起
|
||||
const toggleRowExpansionAll = (status: boolean) => {
|
||||
isExpand.value = status
|
||||
const nodes = depTreeRef.value.store._getAllNodes()
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
nodes[i].expanded = status
|
||||
}
|
||||
}
|
||||
|
||||
watch(checkedTreeNodes, (val) => {
|
||||
if (checkedTreeNodes.value.length > 0) {
|
||||
state.isDeep = false
|
||||
}
|
||||
})
|
||||
|
||||
// 勾选树节点时
|
||||
const handleCheckChange = (data: any, checked: boolean, indeterminate: boolean) => {
|
||||
checkedTreeNodes.value = depTreeRef.value.getCheckedNodes()
|
||||
// console.log(data, checked, indeterminate)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTreeData()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
getTreeData,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
&-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 10px;
|
||||
box-shadow: 0 8px 8px -8px rgba(0, 0, 0, 0.1);
|
||||
z-index: 10;
|
||||
|
||||
&-input {
|
||||
width: 90%;
|
||||
}
|
||||
&-dropdown {
|
||||
flex: 1;
|
||||
margin-left: 5%;
|
||||
line-height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&-tree {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
|
||||
&:hover {
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&-switch {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding-top: 10px;
|
||||
box-shadow: 0 -8px 8px -8px rgba(0, 0, 0, 0.1);
|
||||
z-index: 999;
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,277 @@
|
||||
<template>
|
||||
<Splitpanes @resize="treeWidth = $event[0].size">
|
||||
<pane :size="treeWidth">
|
||||
<div class="container">
|
||||
<!-- 头部区域 -->
|
||||
<div class="container-header">
|
||||
<div class="container-header-input">
|
||||
<el-input v-model="searchName" suffix-icon="search" :placeholder="placeholder" clearable @change="getTreeData" />
|
||||
</div>
|
||||
<div class="container-header-dropdown" v-if="showExpand">
|
||||
<el-dropdown :hide-on-click="false">
|
||||
<el-icon style="transform: rotate(90deg)">
|
||||
<MoreFilled />
|
||||
</el-icon>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>
|
||||
<el-button
|
||||
class="!h-[20px] !text-gray-500 dark:!text-white dark:hover:!text-primary"
|
||||
link
|
||||
:icon="isExpand ? 'expand' : 'fold'"
|
||||
@click="toggleRowExpansionAll(isExpand ? false : true)"
|
||||
>
|
||||
{{ isExpand ? "折叠" : "展开" }}
|
||||
</el-button>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 树形结构 -->
|
||||
<div class="container-tree">
|
||||
<el-tree
|
||||
ref="treeRef"
|
||||
:props="props.props"
|
||||
:data="state.treeDataList"
|
||||
:expand-on-click-node="false"
|
||||
:loading="state.loading"
|
||||
node-key="id"
|
||||
highlight-current
|
||||
default-expand-all
|
||||
@node-click="handleNodeClick"
|
||||
show-checkbox
|
||||
@check-change="handleCheckChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 底部区域 -->
|
||||
<div class="container-switch">
|
||||
<el-switch
|
||||
v-model="state.isDeep"
|
||||
@change="handleTreeDeepSearch"
|
||||
:inactive-text="switchInactiveText"
|
||||
:active-text="switchActiveText"
|
||||
:disabled="checkedTreeNodes.length > 0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</pane>
|
||||
|
||||
<pane :size="100 - treeWidth" class="pl-4 relative">
|
||||
<!-- 拖拽线 -->
|
||||
<div
|
||||
class="w-[12px] h-[56px] absolute left-0 top-[44vh] translate-y-[-50%] transition-all cursor-pointer"
|
||||
@click="handleClickDepTreeDrawer(isOpen)"
|
||||
style="background-color: #e3e9ed; border-top-right-radius: 10px; border-bottom-right-radius: 10px"
|
||||
>
|
||||
<i class="drawer-icon">
|
||||
<el-icon>
|
||||
<ArrowLeftBold v-if="treeWidth > 0" />
|
||||
<ArrowRightBold v-else />
|
||||
</el-icon>
|
||||
</i>
|
||||
</div>
|
||||
|
||||
<div class="w-full h-full overflow-auto">
|
||||
<slot name="default" />
|
||||
</div>
|
||||
</pane>
|
||||
</Splitpanes>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="DraggableDepTree">
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string // 输入框占位符
|
||||
loading?: boolean // 加载中的状态
|
||||
showExpand?: boolean // 折叠控制
|
||||
query?: (searchName?: string) => Promise<any> // 查询函数
|
||||
props?: object
|
||||
switchInactiveText?: string | undefined
|
||||
switchActiveText?: string | undefined
|
||||
defaultTreeWidth?: number | string
|
||||
}>(),
|
||||
{
|
||||
placeholder: "",
|
||||
loading: false,
|
||||
showExpand: true,
|
||||
query: () => new Promise((resolve) => resolve([])),
|
||||
props: () => {
|
||||
return {
|
||||
label: "name",
|
||||
children: "children",
|
||||
value: "id",
|
||||
}
|
||||
},
|
||||
switchInactiveText: "当前级",
|
||||
switchActiveText: "当前级及子级",
|
||||
defaultTreeWidth: 20,
|
||||
},
|
||||
)
|
||||
const emit = defineEmits(["nodeClick", "treeDeepSearch", "treeNodeCheckChange"])
|
||||
|
||||
const treeRef = ref() // 树组件的引用
|
||||
const searchName = ref() // 查询关键字
|
||||
const isExpand = ref(true) // 是否展开所有节点
|
||||
const isOpen = ref(true) // 是否展开树组件
|
||||
const treeWidth = ref<number>(Number(props.defaultTreeWidth)) // 部门树组件宽度
|
||||
const checkedTreeNodes = ref([])
|
||||
const state = reactive({
|
||||
treeDataList: [],
|
||||
loading: props.loading,
|
||||
isDeep: false,
|
||||
})
|
||||
|
||||
// 获取部门树形结构数据
|
||||
const getTreeData = () => {
|
||||
if (props.query instanceof Function) {
|
||||
state.loading = true
|
||||
|
||||
// 调用传入的查询函数,并将查询关键字作为参数传入
|
||||
const result = props.query(unref(searchName))
|
||||
|
||||
// 如果查询结果为 Promise 类型,则进行后续处理
|
||||
if ((typeof result === "object" || typeof result === "function") && typeof result.then === "function") {
|
||||
result
|
||||
.then((r: any) => {
|
||||
state.treeDataList = r.data
|
||||
})
|
||||
.catch((err) => {
|
||||
useMessage().error(err.msg)
|
||||
})
|
||||
.finally(() => (state.loading = false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const tempTreeWidth = ref()
|
||||
// 点击展开树组件
|
||||
const handleClickDepTreeDrawer = (isDrawerOpen: boolean) => {
|
||||
if (isDrawerOpen) {
|
||||
tempTreeWidth.value = treeWidth.value
|
||||
treeWidth.value = 0
|
||||
} else {
|
||||
treeWidth.value = tempTreeWidth.value
|
||||
}
|
||||
isOpen.value = !isOpen.value
|
||||
}
|
||||
|
||||
// 点击树形结构节点
|
||||
const handleNodeClick = (item: any) => emit("nodeClick", item)
|
||||
|
||||
// 节点深度搜索
|
||||
const handleTreeDeepSearch = () => emit("treeDeepSearch", state.isDeep)
|
||||
|
||||
// 勾选树节点时
|
||||
const handleCheckChange = (data: any, checked: boolean, indeterminate: boolean) => {
|
||||
const checkedNodes = treeRef.value.getCheckedNodes()
|
||||
checkedTreeNodes.value = checkedNodes
|
||||
emit("treeNodeCheckChange", checkedNodes)
|
||||
}
|
||||
|
||||
// 切换所有节点的展开/收起状态。status:true 为展开,false 为收起
|
||||
const toggleRowExpansionAll = (status: boolean) => {
|
||||
isExpand.value = status
|
||||
const nodes = treeRef.value.store._getAllNodes()
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
nodes[i].expanded = status
|
||||
}
|
||||
}
|
||||
|
||||
// 勾选树节点关闭switch
|
||||
watch(checkedTreeNodes, (val) => {
|
||||
if (checkedTreeNodes.value.length > 0) {
|
||||
state.isDeep = false
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getTreeData()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
getTreeData,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
&-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 10px;
|
||||
box-shadow: 0 8px 8px -8px rgba(0, 0, 0, 0.1);
|
||||
z-index: 10;
|
||||
|
||||
&-input {
|
||||
width: 90%;
|
||||
}
|
||||
&-dropdown {
|
||||
flex: 1;
|
||||
margin-left: 5%;
|
||||
line-height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&-tree {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
|
||||
&:hover {
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&-switch {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding-top: 10px;
|
||||
box-shadow: 0 -8px 8px -8px rgba(0, 0, 0, 0.1);
|
||||
z-index: 999;
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
.splitpanes--vertical > .splitpanes__splitter {
|
||||
background: var(--el-color-primary);
|
||||
/* min-width: 2px; */
|
||||
width: 2px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.splitpanes--vertical > .splitpanes__splitter:active {
|
||||
background: var(--el-color-primary);
|
||||
opacity: 0.6;
|
||||
}
|
||||
.splitpanes--vertical > .splitpanes__splitter:hover {
|
||||
background: var(--el-color-primary);
|
||||
opacity: 0.6;
|
||||
}
|
||||
.drawer-icon {
|
||||
color: #b7bdc8;
|
||||
font-size: 1rem;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
line-height: 64px;
|
||||
}
|
||||
.drawer-icon:hover {
|
||||
opacity: 0.5;
|
||||
}
|
||||
/* .drawer-icon::before {
|
||||
content: "<";
|
||||
background: none;
|
||||
box-sizing: inherit;
|
||||
color: #b7bdc8;
|
||||
font-size: 1em;
|
||||
} */
|
||||
</style>
|
||||
@@ -12,7 +12,7 @@ import Tip from "/@/components/Tip/index.vue"
|
||||
import TagList from "/@/components/TagList/index.vue"
|
||||
import SvgIcon from "/@/components/SvgIcon/index.vue"
|
||||
import PreviewImage from "/@/components/PreviewImage/index.vue"
|
||||
import DepTree from "/@/components/DepTree/index.vue"
|
||||
import DraggableDepTree from "/@/components/DraggableDepTree/index.vue"
|
||||
|
||||
// 业务组件
|
||||
import SelectUser from "/@/components/Select/SelectUser.vue"
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
app.component("TagList", TagList)
|
||||
app.component("SvgIcon", SvgIcon)
|
||||
app.component("PreviewImage", PreviewImage)
|
||||
app.component("DepTree", DepTree)
|
||||
app.component("DraggableDepTree", DraggableDepTree)
|
||||
|
||||
app.component("SelectUser", SelectUser)
|
||||
app.component("SelectWalletType", SelectWalletType)
|
||||
|
||||
@@ -1,52 +1,19 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<Splitpanes @resize="depTreeWidth = $event[0].size">
|
||||
<pane :size="depTreeWidth">
|
||||
<dep-tree
|
||||
class="p-2"
|
||||
ref="depTreeRef"
|
||||
:placeholder="$t('common.queryDeptTip')"
|
||||
:query="deptData.queryList"
|
||||
:show-expand="true"
|
||||
@node-click="handleNodeClick"
|
||||
@treeDeepSearch="treeDeepSearch"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
>
|
||||
<!-- 没有数据权限提示 -->
|
||||
<template #default="{ node, data }">
|
||||
<el-tooltip
|
||||
v-if="data.isLock"
|
||||
class="item"
|
||||
effect="dark"
|
||||
:content="$t('sysuser.noDataScopeTip')"
|
||||
placement="right-start"
|
||||
>
|
||||
<span>
|
||||
{{ node.label }}
|
||||
<SvgIcon name="ele-Lock" />
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<span v-if="!data.isLock">{{ node.label }}</span>
|
||||
</template>
|
||||
</dep-tree>
|
||||
</pane>
|
||||
|
||||
<pane :size="100 - depTreeWidth" class="pl8 relative">
|
||||
<div
|
||||
class="w-[12px] h-[56px] absolute left-0 top-[44vh] translate-y-[-50%] transition-all cursor-pointer"
|
||||
@click="handleClickDepTreeDrawer(isOpen)"
|
||||
style="background-color: #e3e9ed; border-top-right-radius: 10px; border-bottom-right-radius: 10px"
|
||||
>
|
||||
<i class="drawer-icon">
|
||||
<el-icon>
|
||||
<ArrowLeftBold v-if="depTreeWidth > 0.5" />
|
||||
<ArrowRightBold v-else />
|
||||
</el-icon>
|
||||
</i>
|
||||
</div>
|
||||
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<DraggableDepTree
|
||||
ref="draggableDepTreeRef"
|
||||
placeholder="请输入部门名称"
|
||||
:query="deptData.queryList"
|
||||
:show-expand="true"
|
||||
@node-click="handleNodeClick"
|
||||
@treeDeepSearch="treeDeepSearch"
|
||||
@treeNodeCheckChange="treeNodeCheckChange"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
:defaultTreeWidth="20"
|
||||
>
|
||||
<template #default>
|
||||
<el-row v-show="showSearch">
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
<el-form-item label="用户" prop="userIds">
|
||||
@@ -66,20 +33,12 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button v-auth="'sys_user_add'" icon="folder-add" type="primary" @click="userDialogRef.openDialog()">
|
||||
{{ $t("common.addBtn") }}
|
||||
</el-button>
|
||||
<el-button
|
||||
plain
|
||||
v-auth="'sys_user_add'"
|
||||
class="ml10"
|
||||
icon="upload-filled"
|
||||
type="primary"
|
||||
@click="excelUploadRef.show()"
|
||||
>
|
||||
<el-button plain v-auth="'sys_user_add'" class="ml10" icon="upload-filled" type="primary" @click="excelUploadRef.show()">
|
||||
{{ $t("common.importBtn") }}
|
||||
</el-button>
|
||||
|
||||
@@ -116,12 +75,7 @@
|
||||
>
|
||||
<el-table-column :selectable="handleSelectable" type="selection" width="40" />
|
||||
<el-table-column :label="$t('sysuser.index')" type="index" width="60" fixed="left" />
|
||||
<el-table-column
|
||||
:label="$t('sysuser.username')"
|
||||
prop="username"
|
||||
fixed="left"
|
||||
show-overflow-tooltip
|
||||
></el-table-column>
|
||||
<el-table-column :label="$t('sysuser.username')" prop="username" fixed="left" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column :label="$t('sysuser.name')" prop="name" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column :label="$t('sysuser.phone')" prop="phone" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column :label="$t('sysuser.post')" show-overflow-tooltip>
|
||||
@@ -165,7 +119,7 @@
|
||||
<el-table-column
|
||||
v-auths="['sys_user_edit', 'userFace_sysUserFace_view', 'sys_user_del']"
|
||||
:label="$t('common.action')"
|
||||
width="300"
|
||||
width="200"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="scope">
|
||||
@@ -199,11 +153,7 @@
|
||||
人脸管理
|
||||
</el-button>
|
||||
<!-- 删除用户 -->
|
||||
<el-tooltip
|
||||
:content="$t('sysuser.deleteDisabledTip')"
|
||||
:disabled="scope.row.userId !== '1'"
|
||||
placement="top"
|
||||
>
|
||||
<el-tooltip :content="$t('sysuser.deleteDisabledTip')" :disabled="scope.row.userId !== '1'" placement="top">
|
||||
<span style="margin-left: 12px">
|
||||
<el-button
|
||||
icon="delete"
|
||||
@@ -220,12 +170,10 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle">
|
||||
</pagination>
|
||||
</div>
|
||||
</pane>
|
||||
</Splitpanes>
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle"> </pagination>
|
||||
</template>
|
||||
</DraggableDepTree>
|
||||
</div>
|
||||
|
||||
<user-form ref="userDialogRef" @refresh="getDataList(false)" :deptId="state.queryForm.deptId" />
|
||||
<face-manage ref="faceManageRef" @refresh="getDataList(false)" />
|
||||
@@ -248,22 +196,19 @@ import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useI18n } from "vue-i18n"
|
||||
import { auth } from "/@/utils/authFunction"
|
||||
|
||||
// 动态引入组件
|
||||
const UserForm = defineAsyncComponent(() => import("./form.vue"))
|
||||
const FaceManage = defineAsyncComponent(() => import("./face-manage.vue"))
|
||||
const PopoverInput = defineAsyncComponent(() => import("/@/components/PopoverInput/index.vue"))
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// 定义变量内容
|
||||
const userDialogRef = ref()
|
||||
const faceManageRef = ref()
|
||||
const excelUploadRef = ref()
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const inputPassword = ref()
|
||||
const depTreeRef = ref() // 树组件ref引用
|
||||
const depTreeWidth = ref<number>(20) // 部门树组件宽度
|
||||
const draggableDepTreeRef = ref() // 树组件ref引用
|
||||
|
||||
// 多选rows
|
||||
const selectObjs = ref([]) as any
|
||||
@@ -291,6 +236,7 @@ const deptData = reactive({
|
||||
},
|
||||
})
|
||||
|
||||
// 是否深度搜索
|
||||
const treeDeepSearch = (isDeep: boolean) => {
|
||||
state.queryForm.isDeepDept = isDeep
|
||||
getDataList()
|
||||
@@ -300,7 +246,7 @@ const treeDeepSearch = (isDeep: boolean) => {
|
||||
const resetQuery = () => {
|
||||
queryRef.value?.resetFields()
|
||||
state.queryForm.deptId = ""
|
||||
depTreeRef.value.getTreeData()
|
||||
draggableDepTreeRef.value.getTreeData()
|
||||
getDataList()
|
||||
}
|
||||
|
||||
@@ -310,6 +256,12 @@ const handleNodeClick = (e: any) => {
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 树节点勾选改变
|
||||
const treeNodeCheckChange = (checkedNodes: any) => {
|
||||
state.queryForm.deptId = checkedNodes.map((item: any) => item.id)
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile("/admin/user/export", Object.assign(state.queryForm, { ids: selectObjs }), "users.xlsx")
|
||||
@@ -374,50 +326,4 @@ const changePassword = async (row: any) => {
|
||||
useMessage().success(t("common.optSuccessText"))
|
||||
getDataList()
|
||||
}
|
||||
|
||||
const isOpen = ref(true)
|
||||
const temp = ref()
|
||||
const handleClickDepTreeDrawer = (isDrawerOpen: boolean) => {
|
||||
if (isDrawerOpen) {
|
||||
temp.value = depTreeWidth.value
|
||||
depTreeWidth.value = 0.5
|
||||
} else {
|
||||
depTreeWidth.value = temp.value
|
||||
}
|
||||
isOpen.value = !isOpen.value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.splitpanes--vertical > .splitpanes__splitter {
|
||||
background: var(--el-color-primary);
|
||||
/* min-width: 2px; */
|
||||
width: 2px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.splitpanes--vertical > .splitpanes__splitter:active {
|
||||
background: var(--el-color-primary);
|
||||
opacity: 0.6;
|
||||
}
|
||||
.splitpanes--vertical > .splitpanes__splitter:hover {
|
||||
background: var(--el-color-primary);
|
||||
opacity: 0.6;
|
||||
}
|
||||
.drawer-icon {
|
||||
color: #b7bdc8;
|
||||
font-size: 1rem;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
line-height: 64px;
|
||||
}
|
||||
.drawer-icon:hover {
|
||||
opacity: 0.5;
|
||||
}
|
||||
/* .drawer-icon::before {
|
||||
content: "<";
|
||||
background: none;
|
||||
box-sizing: inherit;
|
||||
color: #b7bdc8;
|
||||
font-size: 1em;
|
||||
} */
|
||||
</style>
|
||||
@@ -101,7 +101,12 @@
|
||||
</template>
|
||||
</vxe-column> -->
|
||||
|
||||
<vxe-column field="productName" title="库存商品" />
|
||||
<vxe-column field="productName" title="库存商品">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.productName">{{ row.productName }}</span>
|
||||
<span v-else>{{ row.erpSpuId && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId).productName }}</span>
|
||||
</template>
|
||||
</vxe-column>
|
||||
|
||||
<vxe-column field="unitId" title="包装单位" :edit-render="{}">
|
||||
<template #edit="{ row }">
|
||||
@@ -166,7 +171,7 @@
|
||||
<el-tooltip effect="dark" content="返回列表页面" placement="top">
|
||||
<el-button type="primary" plain @click="router.back()">取消</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="保存并清空数据" placement="top">
|
||||
<el-tooltip v-if="!baseDataForm.id" effect="dark" content="保存并清空数据" placement="top">
|
||||
<el-button type="primary" plain @click="onContinueAdd">继续添加</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="保存并返回列表页面" placement="top">
|
||||
@@ -251,14 +256,14 @@ import { ref, reactive, computed, onMounted } from "vue"
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj, getPlanCode, getCgPlanSpuPage } from "/@/api/supermarketerp/smErpCgPlan"
|
||||
import { getObj, addObj, putObj, getPlanCode, getCgPlanSpuPage, getErpSpuSimpleAll } from "/@/api/supermarketerp/smErpCgPlan"
|
||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||
import { storePrice } from "/@/utils/formatMoney"
|
||||
|
||||
// 基本表单数据类型
|
||||
interface FormVO {
|
||||
id?: string
|
||||
id: string | undefined
|
||||
planCode: string
|
||||
orderNumber: string
|
||||
planDate: string
|
||||
@@ -300,15 +305,19 @@ const baseDataForm = reactive<FormVO>({
|
||||
})
|
||||
const state = reactive<{
|
||||
editableTableData: RowVO[]
|
||||
erpSpuItemsMemo: RowVO[]
|
||||
selectedRowsErpSpuIds: string[]
|
||||
insertedRowNumber: number
|
||||
erpSpuSimpleAll: any
|
||||
spuSelectDialogVisible: boolean
|
||||
spuDataList: any[]
|
||||
selectedSpuObjs: any[]
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
|
||||
insertedRowNumber: 0, // 可编辑表格插入行的行号
|
||||
erpSpuSimpleAll: [], // 简要商品列表
|
||||
|
||||
spuSelectDialogVisible: false, // 商品选择对话框开关
|
||||
spuDataList: [], // 商品列表
|
||||
@@ -333,31 +342,26 @@ const getInitData = async () => {
|
||||
baseDataForm.id = undefined
|
||||
const id = route.query.id as string
|
||||
if (id) {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(baseDataForm, {
|
||||
id: res.data.id,
|
||||
planCode: res.data.planCode,
|
||||
orderNumber: res.data.orderNumber,
|
||||
planDate: res.data.planDate,
|
||||
supplierId: res.data.supplierId,
|
||||
handlerUserId: res.data.handlerUserId,
|
||||
remark: res.data.remark,
|
||||
})
|
||||
state.editableTableData = res.data.items
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
// 获取采购计划数据 & 获取简要商品列表
|
||||
const [cgPlanData, erpSpuSimpleAll] = await Promise.allSettled([getObj(id), getErpSpuSimpleAll()])
|
||||
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||
.finally(() => (loading.value = false))
|
||||
|
||||
// 获取货商选项 & 获取简要商品列表
|
||||
// const [supplierTypeOptions, planCode] = await Promise.allSettled([getSupplierTypeOptions(), getPlanCode()]).then((results) =>
|
||||
// results.map((result) => (result.status === "fulfilled" ? result.value : null)),
|
||||
// )
|
||||
// supplierTypeOptions && supplierTypeOptions.code === 0 && (supplierTypeDict.value = supplierTypeOptions.data)
|
||||
// planCode && planCode.code === 0 && (baseDataForm.planCode = planCode.data)
|
||||
if (cgPlanData && cgPlanData.code === 0) {
|
||||
Object.assign(baseDataForm, {
|
||||
id: cgPlanData.data.id,
|
||||
planCode: cgPlanData.data.planCode,
|
||||
orderNumber: cgPlanData.data.orderNumber,
|
||||
planDate: cgPlanData.data.planDate,
|
||||
supplierId: cgPlanData.data.supplierId,
|
||||
handlerUserId: cgPlanData.data.handlerUserId,
|
||||
remark: cgPlanData.data.remark,
|
||||
})
|
||||
state.editableTableData = cgPlanData.data.items
|
||||
state.erpSpuItemsMemo = cgPlanData.data.items
|
||||
}
|
||||
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
|
||||
}
|
||||
|
||||
// 获取货商选项 & 获取采购计划编号
|
||||
@@ -401,6 +405,7 @@ const addEvent = () => {
|
||||
// 底部表格行新增
|
||||
const pushEvent = () => {
|
||||
const newRow: RowVO = {
|
||||
id: "",
|
||||
erpSpuId: "",
|
||||
quantity: null,
|
||||
unitPrice: null,
|
||||
@@ -420,6 +425,7 @@ const pushEvent = () => {
|
||||
// 在指定行插入
|
||||
const insertEvent = () => {
|
||||
const newRow: RowVO = {
|
||||
id: "",
|
||||
erpSpuId: "",
|
||||
quantity: null,
|
||||
unitPrice: null,
|
||||
@@ -442,7 +448,7 @@ const removeSelectRowEvent = () => {
|
||||
if ($table) {
|
||||
const selectRecords = $table.getCheckboxRecords()
|
||||
if (selectRecords.length > 0) {
|
||||
state.editableTableData = state.editableTableData.filter((item) => !selectRecords.some((row) => row.id === item.id))
|
||||
state.editableTableData = state.editableTableData.filter((item) => !selectRecords.some((row) => row.erpSpuId === item.erpSpuId))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -456,10 +462,10 @@ const handleClickSpuSelect = async () => {
|
||||
try {
|
||||
const { code, data } = await getCgPlanSpuPage().finally(() => (spuListLoading.value = false))
|
||||
if (code === 0) {
|
||||
state.spuDataList = data.records
|
||||
state.spuDataList = data.records.map((item: RowVO) => ({ ...item, erpSpuId: item.id }))
|
||||
|
||||
// 勾选已经选择的商品
|
||||
const target = state.spuDataList.filter((row: any) => state.selectedSpuObjs.some((item: any) => row.id === item.id))
|
||||
const target = state.spuDataList.filter((row: any) => state.selectedSpuObjs.some((item: any) => row.erpSpuId === item.erpSpuId))
|
||||
target.forEach((row: any) => nextTick(() => spuMultipleTableRef.value!.toggleRowSelection(row)))
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -470,12 +476,12 @@ const handleClickSpuSelect = async () => {
|
||||
|
||||
// 点击商品列表表格行
|
||||
const rowClick = (row: any) => {
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.id === row.id) === -1
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1
|
||||
? // state.selectedSpuObjs.indexOf(row) === -1
|
||||
state.selectedSpuObjs.push(row)
|
||||
: state.selectedSpuObjs.splice(
|
||||
// state.selectedSpuObjs.indexOf(row)
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.id === row.id),
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId),
|
||||
1,
|
||||
)
|
||||
console.log("click-select", state.selectedSpuObjs)
|
||||
@@ -484,12 +490,12 @@ const rowClick = (row: any) => {
|
||||
|
||||
// 选中商品列表表格行
|
||||
const handleSelect = (selectedRows: any[], row: any) => {
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.id === row.id) === -1
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1
|
||||
? // state.selectedSpuObjs.indexOf(row) === -1
|
||||
state.selectedSpuObjs.push(row)
|
||||
: state.selectedSpuObjs.splice(
|
||||
// state.selectedSpuObjs.indexOf(row)
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.id === row.id),
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId),
|
||||
1,
|
||||
)
|
||||
console.log("check-select", state.selectedSpuObjs)
|
||||
@@ -499,13 +505,13 @@ const handleSelect = (selectedRows: any[], row: any) => {
|
||||
const handleSelectAll = (selectedRows: any[]) => {
|
||||
if (selectedRows.length > 0) {
|
||||
selectedRows.forEach((row: any) => {
|
||||
if (state.selectedSpuObjs.findIndex((item: any) => item.id === row.id) === -1) {
|
||||
if (state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1) {
|
||||
state.selectedSpuObjs.push(row)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
state.spuDataList.forEach((row: any) => {
|
||||
const index = state.selectedSpuObjs.findIndex((item: any) => item.id === row.id)
|
||||
const index = state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId)
|
||||
if (index !== -1) {
|
||||
state.selectedSpuObjs.splice(index, 1)
|
||||
}
|
||||
@@ -525,19 +531,21 @@ const handleSelectDialogConfirm = () => {
|
||||
|
||||
// 筛选新勾选的项
|
||||
const addedItems = state.selectedSpuObjs
|
||||
.map((item: any) => ({ ...item, erpSpuId: item.id }))
|
||||
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.id === item.id))
|
||||
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.erpSpuId === item.erpSpuId))
|
||||
.map((addItem) => {
|
||||
if (state.erpSpuItemsMemo.some((item: any) => item.erpSpuId === addItem.erpSpuId)) return addItem
|
||||
return { ...addItem, isNew: true }
|
||||
}) // 为新增的数据项添加isNew标志,若该项原本已经存在,则不添加isNew标志
|
||||
// 仅添加新勾选的项
|
||||
// state.editableTableData.push(...addedItems)
|
||||
state.editableTableData = [...state.editableTableData, ...addedItems]
|
||||
|
||||
// 筛选取消勾选的项
|
||||
const removedItems = state.editableTableData.filter(
|
||||
(item: any) => !state.selectedSpuObjs.some((selectedItem: any) => selectedItem.id === item.id),
|
||||
(item: any) => !state.selectedSpuObjs.some((selectedItem: any) => selectedItem.erpSpuId === item.erpSpuId),
|
||||
)
|
||||
// 仅移除取消勾选的项
|
||||
state.editableTableData = state.editableTableData.filter(
|
||||
(item: any) => !removedItems.some((removeItem: any) => removeItem.id === item.id),
|
||||
(item: any) => !removedItems.some((removeItem: any) => removeItem.erpSpuId === item.erpSpuId),
|
||||
)
|
||||
// state.editableTableData.push(item)
|
||||
// nextTick(() => {
|
||||
@@ -555,7 +563,7 @@ const cgPlanSpuItems = computed(() => {
|
||||
return state.editableTableData.map((item: any) => {
|
||||
const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
|
||||
return {
|
||||
id: "",
|
||||
id: item.isNew ? undefined : item.id,
|
||||
erpSpuId: item.erpSpuId,
|
||||
quantity: item.quantity,
|
||||
unitPrice: unit.purchasePrice ? storePrice(unit?.purchasePrice) : 0,
|
||||
@@ -622,17 +630,18 @@ const submitData = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
|
||||
console.log("提交的数据:", {
|
||||
const _pa = {
|
||||
...baseDataForm,
|
||||
items: cgPlanSpuItems.value,
|
||||
})
|
||||
}
|
||||
|
||||
const res = await addObj({
|
||||
...baseDataForm,
|
||||
items: cgPlanSpuItems.value,
|
||||
}).finally(() => (loading.value = false))
|
||||
console.log("提交的数据:", _pa)
|
||||
|
||||
const res = baseDataForm.id
|
||||
? await putObj(_pa).finally(() => (loading.value = false))
|
||||
: await addObj(_pa).finally(() => (loading.value = false))
|
||||
if (res.code === 0) {
|
||||
useMessage().success("添加成功")
|
||||
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
|
||||
return true
|
||||
} else {
|
||||
useMessage().error(res.msg)
|
||||
@@ -661,15 +670,4 @@ const clearData = () => {
|
||||
onMounted(() => {
|
||||
getInitData()
|
||||
})
|
||||
// const onSubmit = async () => {
|
||||
// try {
|
||||
// loading.value = true
|
||||
// form.id ? await putObj(form) : await addObj(form)
|
||||
// useMessage().success(form.id ? "修改成功" : "添加成功")
|
||||
// } catch (err: any) {
|
||||
// useMessage().error(err.msg)
|
||||
// } finally {
|
||||
// loading.value = false
|
||||
// }
|
||||
// }
|
||||
</script>
|
||||
Reference in new issue
Block a user