Merge remote-tracking branch 'origin/dev-dictionary' into dev-dictionary

This commit is contained in:
XieYongHong 2023-09-21 09:41:16 +08:00
commit 1a0cb1d9c8
4 changed files with 134 additions and 145 deletions

View File

@ -14,7 +14,6 @@
> >
新增字典 新增字典
</PermissionButton> </PermissionButton>
<!-- <j-button type="primary" @click="showSave" style="width: 60%;">新增字典</j-button> -->
<PermissionButton <PermissionButton
type="text" type="text"
hasPermission="system/Dictionary:down" hasPermission="system/Dictionary:down"
@ -22,7 +21,6 @@
> >
下载 下载
</PermissionButton> </PermissionButton>
<!-- <j-button type="text" @click="downVisible=true">下载</j-button> -->
<j-upload <j-upload
:before-upload="beforeUpload" :before-upload="beforeUpload"
accept=".json" accept=".json"
@ -44,10 +42,10 @@
<div class="itemText"><Ellipsis style="width: calc(100%-100px)">{{ item.name }}</Ellipsis></div> <div class="itemText"><Ellipsis style="width: calc(100%-100px)">{{ item.name }}</Ellipsis></div>
<div @click="(e) => e.stopPropagation()"> <div @click="(e) => e.stopPropagation()">
<j-popconfirm v-if="hasPermission('system/Dictionary:action')" :title="item.data.status === 1 ? '确定禁用?' : '确定启用?'" @confirm="()=>updateDic(item.data)"> <j-popconfirm v-if="hasPermission('system/Dictionary:action')" :title="item.data.status === 1 ? '确定禁用?' : '确定启用?'" @confirm="()=>updateDic(item.data)">
<j-switch v-model:checked="item.status" :disabled="!hasPermission('system/Dictionary:action')" :checkedValue="1" :unCheckedValue="0"></j-switch> <j-switch :checked="item.status" :disabled="!hasPermission('system/Dictionary:action')" :checkedValue="1" :unCheckedValue="0"></j-switch>
</j-popconfirm> </j-popconfirm>
<j-tooltip v-else placement="top" title="暂无权限,请联系管理员"> <j-tooltip v-else placement="top" title="暂无权限,请联系管理员">
<j-switch v-model:checked="item.status" :disabled="!hasPermission('system/Dictionary:action')" :checkedValue="1" :unCheckedValue="0"></j-switch> <j-switch :checked="item.status" :disabled="!hasPermission('system/Dictionary:action')" :checkedValue="1" :unCheckedValue="0"></j-switch>
</j-tooltip> </j-tooltip>
<PermissionButton <PermissionButton
type="text" type="text"
@ -59,9 +57,6 @@
> >
删除 删除
</PermissionButton> </PermissionButton>
<!-- <j-popconfirm title="确认删除?" @confirm="()=>deleteDic(item.id)">
<j-button type="text">删除</j-button>
</j-popconfirm> -->
<PermissionButton <PermissionButton
type="text" type="text"
hasPermission="system/Dictionary:update" hasPermission="system/Dictionary:update"
@ -69,7 +64,6 @@
> >
编辑 编辑
</PermissionButton> </PermissionButton>
<!-- <j-button type="text" @click="()=>showEdit(item.data)">编辑</j-button> -->
</div> </div>
</div> </div>
</template> </template>
@ -88,7 +82,6 @@ import Save from './save/index.vue'
import { onlyMessage} from '@/utils/comm'; import { onlyMessage} from '@/utils/comm';
import Export from './Export/index.vue' import Export from './Export/index.vue'
import { usePermissionStore } from '@/store/permission'; import { usePermissionStore } from '@/store/permission';
import { first } from 'lodash-es';
const emit = defineEmits(['selectData']) const emit = defineEmits(['selectData'])
const hasPermission = usePermissionStore().hasPermission; const hasPermission = usePermissionStore().hasPermission;
const saveShow = ref(false) const saveShow = ref(false)

View File

@ -1,73 +1,57 @@
<template> <template>
<div> <div>
<div class="des_head"> <div class="des_head">
<div>字典ID<span>{{ data.id }}</span></div> <div>字典ID<span>{{ data.id }}</span></div>
<div>说明<span>{{ data.describe }}</span></div> <div>说明<span>{{ data.describe }}</span></div>
<div>创建日期<span>{{ data.name }}</span></div> <div>创建日期<span> {{
</div> dayjs(
<div class="contain"> data?.createTime,
<pro-search ).format(
:columns="columns" 'YYYY-MM-DD HH:mm:ss',
@search="handleSearch" )
/> }}</span></div>
<JProTable :columns="columns" </div>
model="TABLE" <div class="contain">
:request="queryItem" <pro-search :columns="columns" @search="handleSearch" />
:params="params" <JProTable :columns="columns" model="TABLE" :request="queryItem" :params="params" ref="tableRef">
ref="tableRef" <template #headerTitle>
> <PermissionButton type="primary" @click="add" hasPermission="system/Dictionary:add">
<template #headerTitle>
<PermissionButton
type="primary"
@click="add"
hasPermission="system/Dictionary:add"
>
新增 新增
</PermissionButton> </PermissionButton>
</template> </template>
<template #action="slotProps"> <template #action="slotProps">
<j-space> <j-space>
<template <template v-for="i in getActions(slotProps, 'table')" :key="i.key">
v-for="i in getActions(slotProps, 'table')" <PermissionButton :disabled="i.disabled" :popConfirm="i.popConfirm" :tooltip="{
:key="i.key" ...i.tooltip,
> }" @click="i.onClick" type="link" style="padding: 0 5px" :danger="i.key === 'delete'"
<PermissionButton :hasPermission="'system/Dictionary:' + i.key
:disabled="i.disabled" ">
:popConfirm="i.popConfirm" <template #icon>
:tooltip="{ <AIcon :type="i.icon" />
...i.tooltip, </template>
}"
@click="i.onClick"
type="link"
style="padding: 0 5px"
:danger="i.key === 'delete'"
:hasPermission="
'system/Dictionary:' + i.key
"
>
<template #icon
><AIcon :type="i.icon"
/></template>
</PermissionButton> </PermissionButton>
</template> </template>
</j-space> </j-space>
</template> </template>
</JProTable> </JProTable>
</div>
</div> </div>
</div> <Save v-if="saveVisible" :dicId='data.id' :type="modalType" :data="current" :sort=sort @closeModal="closeModal"
<Save v-if="saveVisible" :dicId='data.id' :type="modalType" :data="current" :sort=sort @closeModal="closeModal" @refresh="refresh"/> @refresh="refresh" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { queryDicItem ,deleteDicItem } from '@/api/system/dictionary' import { queryDicItem, deleteDicItem } from '@/api/system/dictionary'
import Save from './Save/index.vue' import Save from './Save/index.vue'
import type { ActionsType } from './typings'; import type { ActionsType } from './typings';
import { onlyMessage } from '@/utils/comm'; import { onlyMessage } from '@/utils/comm';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import dayjs from 'dayjs';
const props = defineProps({ const props = defineProps({
data:{ data: {
type:Object, type: Object,
default:{} default: {}
}, },
}) })
const params = ref() const params = ref()
@ -78,20 +62,20 @@ const modalType = ref('add')
const current = ref() const current = ref()
const columns = [ const columns = [
{ {
title:'序号', title: '序号',
dataIndex:'ordinal', dataIndex: 'ordinal',
key:'ordinal', key: 'ordinal',
search:{ search: {
type:'number' type: 'number'
} }
}, },
{ {
title: 'name', title: 'name',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
ellipsis: true, ellipsis: true,
search:{ search: {
type:'string' type: 'string'
} }
}, },
{ {
@ -99,8 +83,8 @@ const columns = [
dataIndex: 'value', dataIndex: 'value',
key: 'value', key: 'value',
ellipsis: true, ellipsis: true,
search:{ search: {
type:'string' type: 'string'
} }
}, },
{ {
@ -108,13 +92,13 @@ const columns = [
dataIndex: 'text', dataIndex: 'text',
key: 'text', key: 'text',
ellipsis: true, ellipsis: true,
search:{ search: {
type:'string' type: 'string'
} }
},{ }, {
title:'操作', title: '操作',
dataIndex:'action', dataIndex: 'action',
key:'action', key: 'action',
scopedSlots: true, scopedSlots: true,
} }
]; ];
@ -142,18 +126,18 @@ const getActions = (
key: 'delete', key: 'delete',
text: '删除', text: '删除',
tooltip: { tooltip: {
title:'删除', title: '删除',
}, },
popConfirm: { popConfirm: {
title: '确认删除?', title: '确认删除?',
onConfirm: async () => { onConfirm: async () => {
const res = await deleteDicItem(data.id) const res = await deleteDicItem(data.id)
if(res.status ===200){ if (res.status === 200) {
onlyMessage('操作成功!') onlyMessage('操作成功!')
tableRef.value.reload() tableRef.value.reload()
}else{ } else {
onlyMessage('操作失败!','error') onlyMessage('操作失败!', 'error')
} }
}, },
}, },
icon: 'DeleteOutlined', icon: 'DeleteOutlined',
@ -163,73 +147,74 @@ const getActions = (
return actions.filter((i: ActionsType) => i.key !== 'view'); return actions.filter((i: ActionsType) => i.key !== 'view');
return actions; return actions;
}; };
const add = () =>{ const add = () => {
modalType.value = 'add' modalType.value = 'add'
current.value = {} current.value = {}
saveVisible.value = true saveVisible.value = true
} }
const closeModal = () =>{ const closeModal = () => {
saveVisible.value = false saveVisible.value = false
} }
const handleSearch = (i:any)=>{ const handleSearch = (i: any) => {
params.value = i params.value = i
} }
const refresh = () =>{ const refresh = () => {
saveVisible.value = false saveVisible.value = false
tableRef.value.reload() tableRef.value.reload()
} }
const queryItem =async(_params:any)=>{ const queryItem = async (_params: any) => {
if (props.data?.id) { if (props.data?.id) {
const params = { const params = {
..._params, ..._params,
sorts: [{ name: 'createTime', order: 'desc' }], sorts: [{ name: 'createTime', order: 'desc' }],
terms: [ terms: [
..._params.terms, ..._params.terms,
{ {
column: 'dictId', column: 'dictId',
termType: 'eq', termType: 'eq',
value: props.data?.id value: props.data?.id
}, },
], ],
}; };
const resp: any = await queryDicItem(params); const resp: any = await queryDicItem(params);
if(resp.status===200){ if (resp.status === 200) {
const arr = cloneDeep(resp.result.data) const arr = cloneDeep(resp.result.data)
arr?.sort((a:any,b:any)=>{ arr?.sort((a: any, b: any) => {
return b.ordinal - a.ordinal return b.ordinal - a.ordinal
}) })
sort.value =arr.length ? arr[0].ordinal + 1 : 1 sort.value = arr.length ? arr[0].ordinal + 1 : 1
return { return {
code: resp.status, code: resp.status,
result: resp.result, result: resp.result,
status: resp.status, status: resp.status,
};
}
} else {
sort.value= 1
return {
code: 200,
result: {
data: [],
pageIndex: 0,
pageSize: 0,
total: 0,
},
status: 200,
}; };
} }
} else {
sort.value = 1
return {
code: 200,
result: {
data: [],
pageIndex: 0,
pageSize: 0,
total: 0,
},
status: 200,
};
} }
watch(()=>props?.data?.id,()=>{ }
watch(() => props?.data?.id, () => {
tableRef.value.reload() tableRef.value.reload()
}) })
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.des_head{ .des_head {
padding: 10px 20px; padding: 10px 20px;
background-color: rgb(242, 242, 242); background-color: rgb(242, 242, 242);
span{
color:rgb(127, 127, 127) span {
color: rgb(127, 127, 127)
} }
} }
</style> </style>

View File

@ -5,17 +5,16 @@
<AIcon type="SearchOutlined" @click="search" /> <AIcon type="SearchOutlined" @click="search" />
</template> </template>
</j-input> </j-input>
<div class="controls"> <div class="controls" v-if="admin">
<PermissionButton <j-button
type="primary" type="primary"
hasPermission="system/Dictionary:add" @click="addGroup"
@click="addGroup" style="width: 100%"
style="width: 100%"
> >
新增分组 新增分组
</PermissionButton> </j-button>
</div> </div>
<div> <div class="listBox">
<j-tree :tree-data="listData" v-if="listData.length" :fieldNames="{title:'name',key:'id'}" blockNode :selectedKeys="selectedKeys"> <j-tree :tree-data="listData" v-if="listData.length" :fieldNames="{title:'name',key:'id'}" blockNode :selectedKeys="selectedKeys">
<template #title="item"> <template #title="item">
<div class="treeItem" @click="()=>selectGroup(item.data.id)" v-if="!item.data?.edit"> <div class="treeItem" @click="()=>selectGroup(item.data.id)" v-if="!item.data?.edit">
@ -31,6 +30,7 @@
title: `确定要删除?`, title: `确定要删除?`,
onConfirm: () => deleteGroup(item.id), onConfirm: () => deleteGroup(item.id),
}" }"
:disabled="item.id === 'default_group'"
> >
删除 删除
</PermissionButton> </PermissionButton>
@ -38,6 +38,7 @@
type="text" type="text"
hasPermission="system/Role:update" hasPermission="system/Role:update"
@click="editGroup(item.data)" @click="editGroup(item.data)"
:disabled="item.id === 'default_group'"
> >
编辑 编辑
</PermissionButton> </PermissionButton>
@ -45,7 +46,6 @@
</div> </div>
<div v-else> <div v-else>
<j-input v-model:value="addName" @blur="()=>saveGroup(item.data)" ref="inputRef" :maxlength="64"></j-input> <j-input v-model:value="addName" @blur="()=>saveGroup(item.data)" ref="inputRef" :maxlength="64"></j-input>
<div style="color: red;" v-if="validateTip">分组名称不能为空</div>
</div> </div>
</template> </template>
</j-tree> </j-tree>
@ -56,15 +56,22 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onlyMessage } from '@/utils/comm'; import { onlyMessage } from '@/utils/comm';
import { queryRoleGroup , saveRoleGroup , deleteRoleGroup } from '@/api/system/role' import { queryRoleGroup , saveRoleGroup , deleteRoleGroup } from '@/api/system/role';
import { randomString } from '@/utils/utils' import { randomString } from '@/utils/utils';
import { useUserInfo } from '@/store/userInfo';
import { storeToRefs } from 'pinia';
const emit = defineEmits(['selectData']) const emit = defineEmits(['selectData'])
const userInfoStore = useUserInfo()
const { userInfos } = storeToRefs(userInfoStore)
const admin = computed(() => {
return userInfos.value?.username === 'admin';
})
const listData:any = ref([]) const listData:any = ref([])
const selectedKeys = ref<string[]>([]) const selectedKeys = ref<string[]>([])
const searchValue = ref() const searchValue = ref()
const inputRef = ref() const inputRef = ref()
const validateTip = ref()
const addName = ref() const addName = ref()
const addStatus = ref(false) //
const queryGroup = async(select?:Boolean,searchName?:string) =>{ const queryGroup = async(select?:Boolean,searchName?:string) =>{
const params = searchName ? {sorts: [{ name: 'createTime', order: 'desc' }],terms:[{terms:[{value:'%'+ searchName +'%',termType:'like',column:'name'}]}]} : {sorts: [{ name: 'createTime', order: 'desc' }]} const params = searchName ? {sorts: [{ name: 'createTime', order: 'desc' }],terms:[{terms:[{value:'%'+ searchName +'%',termType:'like',column:'name'}]}]} : {sorts: [{ name: 'createTime', order: 'desc' }]}
const req:any = await queryRoleGroup(params) const req:any = await queryRoleGroup(params)
@ -77,7 +84,7 @@ const queryGroup = async(select?:Boolean,searchName?:string) =>{
} }
const addGroup = () =>{ const addGroup = () =>{
addName.value = '' addName.value = ''
listData.value.push({ listData.value.unshift({
name:'', name:'',
edit:true, edit:true,
id: randomString() id: randomString()
@ -88,9 +95,8 @@ const addGroup = () =>{
} }
const saveGroup = async(data:any) =>{ const saveGroup = async(data:any) =>{
if(addName.value === ''){ if(addName.value === ''){
validateTip.value = true listData.value.shift()
}else{ }else{
validateTip.value = false
const saveData = { const saveData = {
name:addName.value, name:addName.value,
id:data.id id:data.id
@ -103,6 +109,7 @@ const saveGroup = async(data:any) =>{
onlyMessage('操作失败!') onlyMessage('操作失败!')
} }
} }
addStatus.value = false
} }
const search = () =>{ const search = () =>{
queryGroup(true,searchValue.value) queryGroup(true,searchValue.value)
@ -152,4 +159,7 @@ onMounted(()=>{
max-width:40% max-width:40%
} }
} }
.listBox{
margin: 10px 0;
}
</style> </style>

View File

@ -94,10 +94,11 @@
: '删除', : '删除',
}" }"
:popConfirm="{ :popConfirm="{
title: `确认删除`, title:slotProps?.type?.id === 'application' ? '此操作将同步删除对应的第三方配置,确认删除?':'确认删除',
onConfirm: () => onConfirm: () =>
table.clickDel(slotProps.id), table.clickDel(slotProps.id),
}" }"
:disabled="slotProps.status" :disabled="slotProps.status"
> >
<AIcon type="DeleteOutlined" /> <AIcon type="DeleteOutlined" />
@ -215,7 +216,7 @@ const columns = [
dataIndex: 'action', dataIndex: 'action',
key: 'action', key: 'action',
fixed: 'right', fixed: 'right',
width: 150, width: 200,
scopedSlots: true, scopedSlots: true,
}, },
]; ];