|
@@ -9,7 +9,7 @@ import {
|
|
getTasks,
|
|
getTasks,
|
|
postCreateTask,
|
|
postCreateTask,
|
|
postDeleteTask,
|
|
postDeleteTask,
|
|
- postSendMessage,
|
|
|
|
|
|
+ postSendMessage, postUpdateManyTask,
|
|
postUpdateTask,
|
|
postUpdateTask,
|
|
postUpdateTaskStatus
|
|
postUpdateTaskStatus
|
|
} from '/src/views/reportManage/TaskManage/api.ts';
|
|
} from '/src/views/reportManage/TaskManage/api.ts';
|
|
@@ -124,10 +124,10 @@ const gridOptions = reactive<VxeGridProps<RowVO>>({
|
|
pageSizes: [10, 20, 30],
|
|
pageSizes: [10, 20, 30],
|
|
},
|
|
},
|
|
editConfig: {
|
|
editConfig: {
|
|
- trigger: 'manual',
|
|
|
|
|
|
+ trigger: 'click',
|
|
mode: 'row',
|
|
mode: 'row',
|
|
showStatus: true,
|
|
showStatus: true,
|
|
- autoClear: false,
|
|
|
|
|
|
+ //autoClear: false,
|
|
},
|
|
},
|
|
checkboxConfig: {
|
|
checkboxConfig: {
|
|
reserve: true,
|
|
reserve: true,
|
|
@@ -149,7 +149,7 @@ const gridOptions = reactive<VxeGridProps<RowVO>>({
|
|
editRender: { autofocus: '.vxe-input--inner' },
|
|
editRender: { autofocus: '.vxe-input--inner' },
|
|
slots: { edit: 'name_edit' },
|
|
slots: { edit: 'name_edit' },
|
|
align: 'center',
|
|
align: 'center',
|
|
- minWidth: 150
|
|
|
|
|
|
+ minWidth: 150, isEditing: false
|
|
},
|
|
},
|
|
{
|
|
{
|
|
field: 'country',
|
|
field: 'country',
|
|
@@ -171,7 +171,9 @@ const gridOptions = reactive<VxeGridProps<RowVO>>({
|
|
field: 'user_name',
|
|
field: 'user_name',
|
|
title: '填写人',
|
|
title: '填写人',
|
|
editRender: {},
|
|
editRender: {},
|
|
- slots: { edit: 'operation_edit' },
|
|
|
|
|
|
+ slots: { edit: 'operation_edit' ,
|
|
|
|
+ //default: 'operation_default'
|
|
|
|
+ },
|
|
align: 'center',
|
|
align: 'center',
|
|
minWidth: 104
|
|
minWidth: 104
|
|
},
|
|
},
|
|
@@ -274,30 +276,60 @@ const editRowEvent = (row: RowVO) => {
|
|
const $grid = xGrid.value;
|
|
const $grid = xGrid.value;
|
|
if ($grid) {
|
|
if ($grid) {
|
|
// 在进入编辑状态前保存原始数据
|
|
// 在进入编辑状态前保存原始数据
|
|
- originalDataMap.set(row.id, { ...row });
|
|
|
|
- // 初始化 row.user 确保其与 row.user_name 同步
|
|
|
|
|
|
+ //originalDataMap.set(row.id, { ...row });
|
|
|
|
+ //// 初始化 row.user 确保其与 row.user_name 同步
|
|
if (!row.user || row.user.length === 0) {
|
|
if (!row.user || row.user.length === 0) {
|
|
- row.user = operationList.value
|
|
|
|
- .filter(op => row.user_name.includes(op.label))
|
|
|
|
- .map(op => op.value);
|
|
|
|
|
|
+ row.user = userNameToUser(row.user_name); // 转换 user_name 到 user
|
|
}
|
|
}
|
|
|
|
+ console.log('row.user',row.user);
|
|
$grid.setEditRow(row);
|
|
$grid.setEditRow(row);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-const clearRowEvent = (row: RowVO) => {
|
|
|
|
|
|
+// 清除编辑状态并保存已编辑的数据
|
|
|
|
+const clearRowEvent = (row) => {
|
|
const $grid = xGrid.value;
|
|
const $grid = xGrid.value;
|
|
if ($grid) {
|
|
if ($grid) {
|
|
- const originalData = originalDataMap.get(row.id);
|
|
|
|
- if (originalData) {
|
|
|
|
- // 恢复原始数据
|
|
|
|
- Object.assign(row, originalData);
|
|
|
|
- originalDataMap.delete(row.id);
|
|
|
|
|
|
+ // 手动保存当前行的数据
|
|
|
|
+ const editRecord = $grid.getEditRecord();
|
|
|
|
+ console.log("1editRecord", editRecord);
|
|
|
|
+ if (editRecord) {
|
|
|
|
+ const { row: editedRow } = editRecord;
|
|
|
|
+ // 更新原始 row 数据,确保编辑的值被保存
|
|
|
|
+ row.user = editedRow.user;
|
|
|
|
+ row.user_name = userToUserName(editedRow.user);
|
|
}
|
|
}
|
|
|
|
+ // 清除编辑状态
|
|
$grid.clearEdit();
|
|
$grid.clearEdit();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+async function saveEvent (row) {
|
|
|
|
+ const $grid = xGrid.value;
|
|
|
|
+ if ($grid) {
|
|
|
|
+ try {
|
|
|
|
+ const { updateRecords } = $grid.getRecordset();
|
|
|
|
+ updateRecords.forEach(record => {
|
|
|
|
+ if (!record.user || record.user.length === 0) {
|
|
|
|
+ record.user = userNameToUser(record.user_name); // 转换 user_name 到 user
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ await postUpdateManyTask(updateRecords);
|
|
|
|
+ console.log("=>(index.vue:325) updateRecords", updateRecords);
|
|
|
|
+ await getTaskList();
|
|
|
|
+ await VXETable.modal.message({
|
|
|
|
+ content: `更新 ${updateRecords.length} 条`,
|
|
|
|
+ status: 'success',
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log('error',e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// 删除任务
|
|
// 删除任务
|
|
async function deleteTask() {
|
|
async function deleteTask() {
|
|
const $grid = xGrid.value;
|
|
const $grid = xGrid.value;
|
|
@@ -381,7 +413,6 @@ async function updateRow(row) {
|
|
company: row.company,
|
|
company: row.company,
|
|
platform: row.platform,
|
|
platform: row.platform,
|
|
};
|
|
};
|
|
- //console.log('updatedRowData', updatedRowData);
|
|
|
|
try {
|
|
try {
|
|
const response = await postUpdateTask(updatedRowData);
|
|
const response = await postUpdateTask(updatedRowData);
|
|
if (response.code === 2000) {
|
|
if (response.code === 2000) {
|
|
@@ -583,7 +614,34 @@ async function sendMessage(selectedValue: string) {
|
|
} catch (error) {
|
|
} catch (error) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+// 将 user 数组转换为 user_name 字符串
|
|
|
|
+function userToUserName(user: string[]): string {
|
|
|
|
+ return operationList.value
|
|
|
|
+ .filter(op => user.includes(op.value))
|
|
|
|
+ .map(op => op.label)
|
|
|
|
+ .join(', ');
|
|
|
|
+}
|
|
|
|
+// 将 user_name 字符串转换为 user 数组
|
|
|
|
+function userNameToUser(user_name: string): string[] {
|
|
|
|
+ return operationList.value
|
|
|
|
+ .filter(op => user_name.includes(op.label))
|
|
|
|
+ .map(op => op.value);
|
|
|
|
+}
|
|
|
|
+const handleEditActived = ({ row, column }) => {
|
|
|
|
+ if (column.property === 'user_name') {
|
|
|
|
+ if (!row.user || row.user.length === 0) {
|
|
|
|
+ row.user = userNameToUser(row.user_name); // 转换 user_name 到 user
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+const handleEditClosed = ({ row, column }) => {
|
|
|
|
+ if (column.property === 'user_name') {
|
|
|
|
+ // 将 user 转换为 user_name 并更新 row
|
|
|
|
+ row.user_name = userToUserName(row.user);
|
|
|
|
+ // 强制刷新视图
|
|
|
|
+ $grid.refreshRow(row);
|
|
|
|
+ }
|
|
|
|
+};
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
//getTaskList();
|
|
//getTaskList();
|
|
fetchOperationSelect();
|
|
fetchOperationSelect();
|
|
@@ -599,7 +657,7 @@ onMounted(() => {
|
|
<el-card class="my-3" shadow="hover">
|
|
<el-card class="my-3" shadow="hover">
|
|
<div style="position: relative">
|
|
<div style="position: relative">
|
|
<vxe-grid ref="xGrid" :cell-style="cellStyle" :header-cell-style="headerCellStyle" stripe v-bind="gridOptions"
|
|
<vxe-grid ref="xGrid" :cell-style="cellStyle" :header-cell-style="headerCellStyle" stripe v-bind="gridOptions"
|
|
- v-on="gridEvents">
|
|
|
|
|
|
+ v-on="gridEvents" @edit-actived="handleEditActived" @edit-closed="handleEditClosed">
|
|
<template #toolbar_buttons>
|
|
<template #toolbar_buttons>
|
|
<el-button :icon="Plus" plain type="success" @click="dialogFormVisible = true"> 添加任务</el-button>
|
|
<el-button :icon="Plus" plain type="success" @click="dialogFormVisible = true"> 添加任务</el-button>
|
|
<el-dropdown style="padding: 0 10px;" trigger="click">
|
|
<el-dropdown style="padding: 0 10px;" trigger="click">
|
|
@@ -618,8 +676,8 @@ onMounted(() => {
|
|
</el-dropdown-menu>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</template>
|
|
</el-dropdown>
|
|
</el-dropdown>
|
|
- <el-button :disabled="isDeleteDisabled" :icon="Delete" plain type="danger" @click="removeEvent">删除
|
|
|
|
- </el-button>
|
|
|
|
|
|
+ <el-button :disabled="isDeleteDisabled" :icon="Delete" plain type="danger" @click="removeEvent">删除</el-button>
|
|
|
|
+ <el-button :icon="Save" @click="saveEvent">保存</el-button>
|
|
</template>
|
|
</template>
|
|
<template #toolbar_tools>
|
|
<template #toolbar_tools>
|
|
<div class="mx-3.5">
|
|
<div class="mx-3.5">
|
|
@@ -707,6 +765,12 @@ onMounted(() => {
|
|
</template>
|
|
</template>
|
|
</el-autocomplete>
|
|
</el-autocomplete>
|
|
</template>
|
|
</template>
|
|
|
|
+ <!--<template #operation_default="{ row }">-->
|
|
|
|
+ <!-- <vxe-select v-model="row.user_name" multiple>-->
|
|
|
|
+ <!-- <vxe-option v-for="item in operationList" :key="item.value" :label="item.label"-->
|
|
|
|
+ <!-- :value="item.value"></vxe-option>-->
|
|
|
|
+ <!-- </vxe-select>-->
|
|
|
|
+ <!--</template>-->
|
|
</vxe-grid>
|
|
</vxe-grid>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-card>
|