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,16 +24,16 @@
<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">
<script lang="ts" name="systemRoleDialog" setup>
import {useMessage} from "/@/hooks/message"
import { addObj } from "/@/api/oa/model";
import {useI18n} from "vue-i18n"
import {addObj, getObj, putObj} from "/@/api/oa/model";
const emit = defineEmits(['refresh']);
@ -41,13 +42,15 @@ const { t } = useI18n();
//
const dataFormRef = ref();
const visible = ref(false)
const loading = ref(false)
//
const form = reactive({
id: '',
key: '',
name: '',
category: ''
category: '',
desc: 'vvv',
});
//
@ -77,8 +80,18 @@ 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 = () => {
@ -86,14 +99,30 @@ const onSubmit = () => {
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
})
}
})
};

View File

@ -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"
@ -37,14 +37,16 @@
<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,7 +56,8 @@
</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"/>
@ -106,8 +109,9 @@ const resetQuery = () => {
//
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
}