fix:指标新增编辑功能
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { download } from '@/api/request';
|
||||
import { download, post } from '@/api/request';
|
||||
|
||||
const env = import.meta.env;
|
||||
const PREFIX = env.VITE_API_PREFIX_TASK;
|
||||
@@ -11,3 +11,12 @@ const PREFIX = env.VITE_API_PREFIX_TASK;
|
||||
export const exportPerformanceApi = (params: any, fileName: any) => {
|
||||
return download(`${PREFIX}taskPerformance/exportPerformance`, params, fileName);
|
||||
};
|
||||
|
||||
/**
|
||||
* 编辑指标
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export const editPerformanceApi = (params: any) => {
|
||||
return post(`${PREFIX}taskPerformance/editPerformance`, params);
|
||||
};
|
||||
|
||||
69
src/components/taskDetail/editPerformancePage.vue
Normal file
69
src/components/taskDetail/editPerformancePage.vue
Normal file
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<div class="comp-content">
|
||||
<el-drawer
|
||||
v-model="visible"
|
||||
:title="`编辑指标`"
|
||||
:size="600"
|
||||
:close-on-click-modal="false"
|
||||
@close="closeFun"
|
||||
>
|
||||
<div class="content">
|
||||
<TableForm ref="tableFormRef" tableName="PERFORMANCE_POOL" />
|
||||
</div>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-button @click="closeFun">关闭</el-button>
|
||||
<el-button type="primary" @click="submitFun">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick, watch } from 'vue';
|
||||
import TableForm from '@/components/common/table/tableForm.vue';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
const props = defineProps(['performanceInfo']);
|
||||
const emit = defineEmits(['cancel', 'submit']);
|
||||
|
||||
const tableFormRef = ref();
|
||||
const visible = ref(true);
|
||||
|
||||
const closeFun = () => {
|
||||
emit('cancel');
|
||||
};
|
||||
|
||||
const submitFun = async () => {
|
||||
const valid = await tableFormRef.value.validateFun();
|
||||
if (valid) {
|
||||
const fromData = tableFormRef.value.getFormDataFun();
|
||||
|
||||
console.log(fromData, 'fromData');
|
||||
emit('submit', fromData);
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.performanceInfo,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
nextTick(() => {
|
||||
console.log(newVal, 'newVal');
|
||||
const info = cloneDeep(newVal) ;
|
||||
nextTick(() => {
|
||||
tableFormRef.value.setFormDataFun(info);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 18px !important;
|
||||
}
|
||||
</style>
|
||||
@@ -27,14 +27,11 @@
|
||||
<el-button type="primary" @click="openAddPerformanceWindFun">新增</el-button>
|
||||
<el-button v-if="showSaveButton" type="primary" @click="saveFun">保存</el-button>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<template #operate="{ row }">
|
||||
<el-button type="danger" link @click="delPerformance(row)">删除</el-button>
|
||||
|
||||
</template>
|
||||
|
||||
</BaseTable>
|
||||
|
||||
<addTaskPerformance
|
||||
@@ -44,19 +41,25 @@
|
||||
@submit="addPerformanceFun"
|
||||
>
|
||||
</addTaskPerformance>
|
||||
|
||||
<editPerformancePage
|
||||
v-if="editPerformanceVisible"
|
||||
@cancel="editPerformanceVisible = false"
|
||||
:performance-info="currentPerformance"
|
||||
@submit="updatePerformanceFun"
|
||||
></editPerformancePage>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ref, onMounted, nextTick } from 'vue';
|
||||
import BaseTable from '@/components/common/table/baseTable.vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { getTaskPerformanceApi, batchAddTaskPerformanceApi, batchDeleteTaskPerformanceApi, getRunPerformanceApi } from '@/api/task/taskpool';
|
||||
import { FileUtil } from '@/utils/file';
|
||||
import addTaskPerformance from './addTaskPerformance.vue';
|
||||
import { exportPerformanceApi } from '@/api/task/taskPerformance';
|
||||
import { editPerformanceApi, exportPerformanceApi } from '@/api/task/taskPerformance';
|
||||
import { getFormConfigureApi } from '@/api/system/systemData';
|
||||
import editPerformancePage from './editPerformancePage.vue';
|
||||
|
||||
const props = defineProps({
|
||||
taskId: {
|
||||
@@ -82,6 +85,7 @@ const props = defineProps({
|
||||
});
|
||||
const baseTableRef = ref();
|
||||
const performanceVisible = ref(false);
|
||||
const editPerformanceVisible = ref(false);
|
||||
|
||||
const performanceData = ref<any>([]);
|
||||
const getTaskPerformanceDataFun = async () => {
|
||||
@@ -406,13 +410,13 @@ const arraysConvertedToObjects = (arr: any) => {
|
||||
const excelHeaders = ref<any>({});
|
||||
const excelParams = ref<any>({});
|
||||
const getFormConfigureFun = async () => {
|
||||
const res:any = await getFormConfigureApi({
|
||||
const res: any = await getFormConfigureApi({
|
||||
formName: 'PERFORMANCE_POOL',
|
||||
});
|
||||
|
||||
if (res && res.code === 200) {
|
||||
const cloumn:any = JSON.parse(res.data.formConfig) || [];
|
||||
excelHeaders.value = cloumn.map((item:any) => {
|
||||
const cloumn: any = JSON.parse(res.data.formConfig) || [];
|
||||
excelHeaders.value = cloumn.map((item: any) => {
|
||||
return {
|
||||
key: item.key,
|
||||
title: item.title,
|
||||
@@ -438,6 +442,13 @@ defineExpose({
|
||||
});
|
||||
|
||||
const actionList = ref([
|
||||
{
|
||||
title: '编辑',
|
||||
type: 'primary',
|
||||
click: (row: any) => {
|
||||
editPerformanceFun(row);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '删除',
|
||||
type: 'danger',
|
||||
@@ -449,12 +460,29 @@ const actionList = ref([
|
||||
},
|
||||
]);
|
||||
|
||||
const currentPerformance = ref<any>({});
|
||||
const editPerformanceFun = (row: any) => {
|
||||
currentPerformance.value = row;
|
||||
editPerformanceVisible.value = true;
|
||||
};
|
||||
|
||||
const updatePerformanceFun = async (data: any) => {
|
||||
editPerformanceVisible.value = false;
|
||||
const res: any = await editPerformanceApi(data);
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('操作成功');
|
||||
|
||||
}
|
||||
|
||||
await baseTableRef.value.resetFun();
|
||||
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await getTaskPerformanceDataFun();
|
||||
|
||||
await getFormConfigureFun();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user