Merge remote-tracking branch 'origin/hui_dev' into leng_dev

This commit is contained in:
lbw 2023-03-04 20:06:08 +08:00
commit 13497eb635
3 changed files with 203 additions and 169 deletions

View File

@ -8,10 +8,11 @@ export function fetchList(query) {
})
}
export function delObj(id) {
export function delObj(ids:Object) {
return request({
url: '/admin/model/' + id,
method: 'delete'
url: '/admin/model',
method: 'delete',
data: ids
})
}
@ -22,7 +23,7 @@ export function deploy(id) {
})
}
export function addObj(obj) {
export function addObj(obj?: Object) {
return request({
url: '/admin/model/insert',
method: 'post',

View File

@ -1,21 +1,22 @@
<template>
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible" :close-on-click-modal="false"
draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" label-width="90px">
<el-dialog :close-on-click-modal="false" :title="form.id ? $t('common.editBtn') : $t('common.addBtn')"
draggable
v-model="visible">
<el-form :model="form" :rules="dataRules" label-width="90px" ref="dataFormRef" v-loading="loading">
<el-row :gutter="35">
<el-col :span="24" class="mb20">
<el-form-item :label="$t('model.name')" prop="name">
<el-input v-model="form.name" :placeholder="$t('model.inputNameTip')" clearable></el-input>
<el-input :placeholder="$t('model.inputNameTip')" clearable v-model="form.name"></el-input>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="$t('model.key')" prop="key">
<el-input v-model="form.key" :placeholder="$t('model.inputKeyTip')" clearable />
<el-input :placeholder="$t('model.inputKeyTip')" clearable v-model="form.key"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="$t('model.category')" prop="category">
<el-input v-model="form.category" :placeholder="$t('model.inputCategoryTip')" clearable />
<el-input :placeholder="$t('model.inputCategoryTip')" clearable v-model="form.category"/>
</el-form-item>
</el-col>
</el-row>
@ -23,50 +24,52 @@
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
<el-button type="primary" @click="onSubmit">{{ $t('common.confirmButtonText') }}</el-button>
<el-button @click="onSubmit" type="primary">{{ $t('common.confirmButtonText') }}</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="systemRoleDialog">
import { useMessage } from "/@/hooks/message"
import { addObj } from "/@/api/oa/model";
import { useI18n } from "vue-i18n"
<script lang="ts" name="systemRoleDialog" setup>
import {useMessage} from "/@/hooks/message"
import {useI18n} from "vue-i18n"
import {addObj, getObj, putObj} from "/@/api/oa/model";
const emit = defineEmits(['refresh']);
const emit = defineEmits(['refresh']);
const { t } = useI18n();
const {t} = useI18n();
//
const dataFormRef = ref();
const visible = ref(false)
//
const dataFormRef = ref();
const visible = ref(false)
const loading = ref(false)
//
const form = reactive({
//
const form = reactive({
id: '',
key: '',
name: '',
category: ''
});
category: '',
desc: 'vvv',
});
//
const dataRules = ref(
//
const dataRules = ref(
{
key: [
{ required: true, message: '模型表示不能为空', trigger: 'blur' },
{required: true, message: '模型表示不能为空', trigger: 'blur'},
],
name: [
{ required: true, message: '模型名称不能为空', trigger: 'blur' }
{required: true, message: '模型名称不能为空', trigger: 'blur'}
],
category: [
{ required: true, message: '模型分类不能为空', trigger: 'blur' }
{required: true, message: '模型分类不能为空', trigger: 'blur'}
]
}
)
)
//
const openDialog = (id: string) => {
//
const openDialog = (id: string) => {
visible.value = true
form.id = ''
@ -77,29 +80,55 @@ const openDialog = (id: string) => {
if (id) {
form.id = id
getModelData(id);
}
};
const getModelData = (id: string) => {
//
loading.value = true
getObj(id).then((res: any) => {
Object.assign(form, res.data)
}).finally(() => {
loading.value = false
})
}
};
//
const onSubmit = () => {
//
const onSubmit = () => {
dataFormRef.value.validate((valid: boolean) => {
if (!valid) {
return false
}
//
if (form.id) {
loading.value = true
putObj(form).then(() => {
useMessage().success(t('common.editSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
}).finally(() => {
loading.value = false
})
} else {
loading.value = true
addObj(form).then(() => {
useMessage().success(t('common.addSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
}).finally(() => {
loading.value = false
})
}
})
};
};
//
defineExpose({
//
defineExpose({
openDialog,
});
});
</script>

View File

@ -5,7 +5,7 @@
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('model.category')" prop="category">
<el-input :placeholder="$t('model.inputCategoryTip')" style="max-width: 180px"
v-model="state.queryForm.category" />
v-model="state.queryForm.category"/>
</el-form-item>
<el-form-item class="ml2">
<el-button @click="getDataList" icon="search" type="primary">
@ -18,11 +18,11 @@
<el-row>
<div class="mb8" style="width: 100%">
<el-button @click="formDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary"
v-auth="'app_approle_add'">
v-auth="'oa_model_add'">
{{ $t('common.addBtn') }}
</el-button>
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete"
type="primary" v-auth="'app_approle_del'">
type="primary" v-auth="'oa_model_del'">
{{ $t('common.delBtn') }}
</el-button>
<right-toolbar @queryTable="getDataList" class="ml10" style="float: right;margin-right: 20px"
@ -31,20 +31,22 @@
</el-row>
<el-table :data="state.dataList" @selection-change="handleSelectionChange" style="width: 100%"
v-loading="state.loading">
<el-table-column align="center" type="selection" width="50" />
<el-table-column :label="$t('model.index')" type="index" width="80" />
<el-table-column align="center" type="selection" width="50"/>
<el-table-column :label="$t('model.index')" type="index" width="80"/>
<el-table-column :label="$t('model.name')" prop="name" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('model.key')" prop="key" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('model.category')" prop="category" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('model.version')" prop="version" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('model.createTime')" prop="createTime" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('model.createTime')" prop="createTime"
show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('model.lastUpdateTime')" prop="lastUpdateTime"
show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('common.action')" width="200">
<template #default="scope">
<el-button @click="handleView(scope.row.id)" text type="primary" v-auth="'app_approle_edit'">模型图
</el-button>
<el-button @click="handleDeploy(scope.row.id)" text type="primary" v-auth="'app_approle_edit'">部署
<el-button @click="handleDeploy(scope.row.id)" text type="primary" v-auth="'app_approle_edit'">
部署
</el-button>
<el-button @click="handleDelete([scope.row.roleId])" text type="primary"
v-auth="'app_approle_del'">{{
@ -54,66 +56,68 @@
</template>
</el-table-column>
</el-table>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination" />
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle"
v-bind="state.pagination"/>
</el-card>
<form-dialog @refresh="getDataList()" ref="formDialogRef" />
<form-dialog @refresh="getDataList()" ref="formDialogRef"/>
</div>
</template>
<script lang="ts" name="model" setup>
import { BasicTableProps, useTable } from "/@/hooks/table";
import { delObj, deploy, fetchList } from "/@/api/oa/model";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useI18n } from "vue-i18n";
import {BasicTableProps, useTable} from "/@/hooks/table";
import {delObj, deploy, fetchList} from "/@/api/oa/model";
import {useMessage, useMessageBox} from "/@/hooks/message";
import {useI18n} from "vue-i18n";
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const { t } = useI18n()
const router = useRouter()
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const {t} = useI18n()
const router = useRouter()
//
const formDialogRef = ref()
const queryRef = ref()
const showSearch = ref(true)
// rows
const selectObjs = ref([]) as any
//
const formDialogRef = ref()
const queryRef = ref()
const showSearch = ref(true)
// rows
const selectObjs = ref([]) as any
//
const multiple = ref(true)
//
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
category: ''
},
pageList: fetchList // H
});
});
// table hook
const {
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
} = useTable(state)
} = useTable(state)
//
const resetQuery = () => {
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
}
//
const handleSelectionChange = (objs: any) => {
//
const handleSelectionChange = (objs: any) => {
selectObjs.value = []
console.log(objs)
objs.forEach((val: any) => {
selectObjs.value.push(val.roleId)
selectObjs.value.push(val.id)
});
multiple.value = !objs.length
}
}
//
const handleDelete = (ids: string[]) => {
//
const handleDelete = (ids: string[]) => {
useMessageBox().confirm(t('common.delConfirmText'))
.then(() => {
delObj(ids).then(() => {
@ -123,20 +127,20 @@ const handleDelete = (ids: string[]) => {
useMessage().error(err.msg)
})
})
};
};
const handleDeploy = (id: string) => {
const handleDeploy = (id: string) => {
deploy(id).then(() => {
useMessage().success(t('common.optSuccessText'));
})
}
}
const handleView = (id: string) => {
const handleView = (id: string) => {
router.push({
path: "/oa/model/detail",
query: { id: id },
query: {id: id},
});
}
}
</script>