|  | @@ -9,7 +9,7 @@ import {
 | 
	
		
			
				|  |  |    getTasks,
 | 
	
		
			
				|  |  |    postCreateTask,
 | 
	
		
			
				|  |  |    postDeleteTask,
 | 
	
		
			
				|  |  | -  postSendMessage,
 | 
	
		
			
				|  |  | +  postSendMessage, postUpdateManyTask,
 | 
	
		
			
				|  |  |    postUpdateTask,
 | 
	
		
			
				|  |  |    postUpdateTaskStatus
 | 
	
		
			
				|  |  |  } from '/src/views/reportManage/TaskManage/api.ts';
 | 
	
	
		
			
				|  | @@ -124,10 +124,10 @@ const gridOptions = reactive<VxeGridProps<RowVO>>({
 | 
	
		
			
				|  |  |      pageSizes: [10, 20, 30],
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |    editConfig: {
 | 
	
		
			
				|  |  | -    trigger: 'manual',
 | 
	
		
			
				|  |  | +    trigger: 'click',
 | 
	
		
			
				|  |  |      mode: 'row',
 | 
	
		
			
				|  |  |      showStatus: true,
 | 
	
		
			
				|  |  | -    autoClear: false,
 | 
	
		
			
				|  |  | +    //autoClear: false,
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |    checkboxConfig: {
 | 
	
		
			
				|  |  |      reserve: true,
 | 
	
	
		
			
				|  | @@ -149,7 +149,7 @@ const gridOptions = reactive<VxeGridProps<RowVO>>({
 | 
	
		
			
				|  |  |        editRender: { autofocus: '.vxe-input--inner' },
 | 
	
		
			
				|  |  |        slots: { edit: 'name_edit' },
 | 
	
		
			
				|  |  |        align: 'center',
 | 
	
		
			
				|  |  | -      minWidth: 150
 | 
	
		
			
				|  |  | +      minWidth: 150, isEditing: false
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        field: 'country',
 | 
	
	
		
			
				|  | @@ -171,7 +171,9 @@ const gridOptions = reactive<VxeGridProps<RowVO>>({
 | 
	
		
			
				|  |  |        field: 'user_name',
 | 
	
		
			
				|  |  |        title: '填写人',
 | 
	
		
			
				|  |  |        editRender: {},
 | 
	
		
			
				|  |  | -      slots: { edit: 'operation_edit' },
 | 
	
		
			
				|  |  | +      slots: { edit: 'operation_edit' ,
 | 
	
		
			
				|  |  | +        //default: 'operation_default'
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  |        align: 'center',
 | 
	
		
			
				|  |  |        minWidth: 104
 | 
	
		
			
				|  |  |      },
 | 
	
	
		
			
				|  | @@ -274,30 +276,60 @@ const editRowEvent = (row: RowVO) => {
 | 
	
		
			
				|  |  |    const $grid = xGrid.value;
 | 
	
		
			
				|  |  |    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) {
 | 
	
		
			
				|  |  | -      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);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -const clearRowEvent = (row: RowVO) => {
 | 
	
		
			
				|  |  | +// 清除编辑状态并保存已编辑的数据
 | 
	
		
			
				|  |  | +const clearRowEvent = (row) => {
 | 
	
		
			
				|  |  |    const $grid = xGrid.value;
 | 
	
		
			
				|  |  |    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();
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +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() {
 | 
	
		
			
				|  |  |    const $grid = xGrid.value;
 | 
	
	
		
			
				|  | @@ -381,7 +413,6 @@ async function updateRow(row) {
 | 
	
		
			
				|  |  |        company: row.company,
 | 
	
		
			
				|  |  |        platform: row.platform,
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  | -    //console.log('updatedRowData', updatedRowData);
 | 
	
		
			
				|  |  |      try {
 | 
	
		
			
				|  |  |        const response = await postUpdateTask(updatedRowData);
 | 
	
		
			
				|  |  |        if (response.code === 2000) {
 | 
	
	
		
			
				|  | @@ -583,7 +614,34 @@ async function sendMessage(selectedValue: string) {
 | 
	
		
			
				|  |  |    } 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(() => {
 | 
	
		
			
				|  |  |    //getTaskList();
 | 
	
		
			
				|  |  |    fetchOperationSelect();
 | 
	
	
		
			
				|  | @@ -599,7 +657,7 @@ onMounted(() => {
 | 
	
		
			
				|  |  |      <el-card class="my-3" shadow="hover">
 | 
	
		
			
				|  |  |        <div style="position: relative">
 | 
	
		
			
				|  |  |          <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>
 | 
	
		
			
				|  |  |              <el-button :icon="Plus" plain type="success" @click="dialogFormVisible = true"> 添加任务</el-button>
 | 
	
		
			
				|  |  |              <el-dropdown style="padding: 0 10px;" trigger="click">
 | 
	
	
		
			
				|  | @@ -618,8 +676,8 @@ onMounted(() => {
 | 
	
		
			
				|  |  |                  </el-dropdown-menu>
 | 
	
		
			
				|  |  |                </template>
 | 
	
		
			
				|  |  |              </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 #toolbar_tools>
 | 
	
		
			
				|  |  |              <div class="mx-3.5">
 | 
	
	
		
			
				|  | @@ -707,6 +765,12 @@ onMounted(() => {
 | 
	
		
			
				|  |  |                </template>
 | 
	
		
			
				|  |  |              </el-autocomplete>
 | 
	
		
			
				|  |  |            </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>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |      </el-card>
 |