parent
9cc9e268ed
commit
809a66956c
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<j-data-table
|
<div ref="tableContainer">
|
||||||
|
<j-data-table
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:data-source="dataSource"
|
:data-source="dataSource"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
@change="(data) => dataSourceCache = data"
|
@change="(data) => dataSourceCache = data"
|
||||||
>
|
>
|
||||||
<template #expand>
|
<template #expand>
|
||||||
<PermissionButton
|
<!-- <PermissionButton
|
||||||
type="primary"
|
type="primary"
|
||||||
v-if="!showSave"
|
v-if="!showSave"
|
||||||
:hasPermission="`${permission}:update`"
|
:hasPermission="`${permission}:update`"
|
||||||
|
@ -30,12 +31,11 @@
|
||||||
placement="topRight"
|
placement="topRight"
|
||||||
>
|
>
|
||||||
新增
|
新增
|
||||||
</PermissionButton>
|
</PermissionButton> -->
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
type="primary"
|
type="primary"
|
||||||
:hasPermission="`${permission}:update`"
|
:hasPermission="`${permission}:update`"
|
||||||
key="update"
|
key="update"
|
||||||
v-else
|
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
|
||||||
:disabled="hasOperate('add', type) || !editStatus"
|
:disabled="hasOperate('add', type) || !editStatus"
|
||||||
|
@ -202,7 +202,26 @@
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
</j-space>
|
</j-space>
|
||||||
</template>
|
</template>
|
||||||
</j-data-table>
|
</j-data-table>
|
||||||
|
<PermissionButton
|
||||||
|
type="dashed"
|
||||||
|
block
|
||||||
|
:hasPermission="`${permission}:update`"
|
||||||
|
key="add"
|
||||||
|
:disabled="hasOperate('add', type)"
|
||||||
|
:tooltip="{
|
||||||
|
placement: hasOperate('add', type) ? 'topRight' : 'top',
|
||||||
|
title: hasOperate('add', type)
|
||||||
|
? '当前的存储方式不支持新增'
|
||||||
|
: '新增',
|
||||||
|
getPopupContainer: getPopupContainer,
|
||||||
|
}"
|
||||||
|
@click="handleAddClick()"
|
||||||
|
placement="topRight"
|
||||||
|
>
|
||||||
|
新增
|
||||||
|
</PermissionButton>
|
||||||
|
</div>
|
||||||
<PropertiesModal
|
<PropertiesModal
|
||||||
v-if="type === 'properties' && detailData.visible"
|
v-if="type === 'properties' && detailData.visible"
|
||||||
:data="detailData.data"
|
:data="detailData.data"
|
||||||
|
@ -278,6 +297,7 @@ const props = defineProps({
|
||||||
|
|
||||||
const _target = inject<'device' | 'product'>('_metadataType', props.target);
|
const _target = inject<'device' | 'product'>('_metadataType', props.target);
|
||||||
|
|
||||||
|
const tableContainer = ref()
|
||||||
const system = useSystem();
|
const system = useSystem();
|
||||||
const {basicLayout} = storeToRefs(system);
|
const {basicLayout} = storeToRefs(system);
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
@ -402,6 +422,11 @@ const handleAddClick = async (_data?: any, index?: number) => {
|
||||||
const newObject = _data || getDataByType()
|
const newObject = _data || getDataByType()
|
||||||
|
|
||||||
const _addData = await tableRef.value.addItem(newObject, index)
|
const _addData = await tableRef.value.addItem(newObject, index)
|
||||||
|
nextTick(()=>{
|
||||||
|
if(tableContainer.value.classList.value === 'tableContainer'){
|
||||||
|
tableContainer.value.classList.remove('tableContainer')
|
||||||
|
}
|
||||||
|
})
|
||||||
// if (_addData.length === 1) {
|
// if (_addData.length === 1) {
|
||||||
// showLastDelete.value = true
|
// showLastDelete.value = true
|
||||||
// }
|
// }
|
||||||
|
@ -534,6 +559,11 @@ onUnmounted(() => {
|
||||||
|
|
||||||
watch(() => metadata.value, () => {
|
watch(() => metadata.value, () => {
|
||||||
dataSource.value = metadata.value
|
dataSource.value = metadata.value
|
||||||
|
if(!dataSource.value.length){
|
||||||
|
nextTick(()=>{
|
||||||
|
tableContainer.value.classList.add('tableContainer')
|
||||||
|
})
|
||||||
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
onBeforeRouteUpdate((to, from, next) => { // 设备管理内路由跳转
|
onBeforeRouteUpdate((to, from, next) => { // 设备管理内路由跳转
|
||||||
|
@ -552,4 +582,9 @@ onBeforeRouteLeave((to, from, next) => { // 设备管理外路由跳转
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding-bottom: 16px;
|
padding-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
.tableContainer{
|
||||||
|
:deep(.ant-table-body){
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -147,7 +147,10 @@
|
||||||
{
|
{
|
||||||
validator: form.rules.checkUserName,
|
validator: form.rules.checkUserName,
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},{
|
||||||
|
validator: form.rules.checkCh,
|
||||||
|
trigger: 'change'
|
||||||
|
}
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<j-input
|
<j-input
|
||||||
|
@ -189,6 +192,9 @@
|
||||||
validator: form.rules.checkAgainPassword,
|
validator: form.rules.checkAgainPassword,
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<j-input-password
|
<j-input-password
|
||||||
|
@ -261,10 +267,14 @@ const form = reactive({
|
||||||
data: {} as formType,
|
data: {} as formType,
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
|
checkCh: (_rule:Rule,value:string): Promise<any> =>
|
||||||
|
new Promise((resolve,reject) => {
|
||||||
|
if (/[\u4e00-\u9fa5]/.test(value)) return reject('用户名不能包含中文');
|
||||||
|
else return resolve('')
|
||||||
|
}),
|
||||||
checkUserName: (_rule: Rule, value: string): Promise<any> =>
|
checkUserName: (_rule: Rule, value: string): Promise<any> =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
if (props.type === 'edit') return resolve('');
|
if (props.type === 'edit') return resolve('');
|
||||||
|
|
||||||
if (!value) return reject('请输入用户名');
|
if (!value) return reject('请输入用户名');
|
||||||
else if (value.length > 64) return reject('最多可输入64个字符');
|
else if (value.length > 64) return reject('最多可输入64个字符');
|
||||||
validateField_api('username', value).then((resp: any): any => {
|
validateField_api('username', value).then((resp: any): any => {
|
||||||
|
|
Loading…
Reference in New Issue