|
@@ -1,6 +1,6 @@
|
|
|
<script lang="ts" setup>
|
|
|
import Selector from '/src/views/reportManage/dataCenter/normalDisplay/components/Selector/index.vue';
|
|
|
-import { onMounted, reactive, ref, watch } from 'vue';
|
|
|
+import { onMounted, reactive, ref } from 'vue';
|
|
|
import { VxeGridInstance, VxeGridListeners, VxeGridProps, VXETable } from 'vxe-table';
|
|
|
import {
|
|
|
exportTaskData,
|
|
@@ -20,7 +20,6 @@ import { dateType, requiredFields } from '/@/views/reportManage/TaskManage/utils
|
|
|
const selectorRef = ref(null);
|
|
|
const message = ref('');
|
|
|
const currencyList = ref([]);// 货币列表
|
|
|
-const updateSelect = ref(1)
|
|
|
|
|
|
//表单
|
|
|
interface taskRuleForm {
|
|
@@ -72,6 +71,7 @@ const rules = reactive<FormRules>({
|
|
|
|
|
|
// 修改填写人弹窗
|
|
|
const userDialogFormVisible = ref(false);
|
|
|
+const updateSelect = ref(1);
|
|
|
|
|
|
//表格
|
|
|
interface RowVO {
|
|
@@ -92,7 +92,7 @@ interface RowVO {
|
|
|
}
|
|
|
|
|
|
const xGrid = ref<VxeGridInstance<RowVO>>();
|
|
|
-const originalDataMap = new Map();
|
|
|
+const originalData = ref([]);
|
|
|
let allTasks = []; // 用于存储所有任务数据
|
|
|
const operationList = ref([]);// 填写人列表
|
|
|
const filter = ref({}); // 筛选条件
|
|
@@ -262,9 +262,9 @@ const editRowEvent = (row: RowVO) => {
|
|
|
};
|
|
|
|
|
|
const handleEditActived = ({ row, column }) => {
|
|
|
- if (!row.user || row.user.length === 0) {
|
|
|
- row.user = userNameToUser(row.user_name); // 转换 user_name 到 user
|
|
|
- }
|
|
|
+ if (!row.user || row.user.length === 0) {
|
|
|
+ row.user = userNameToUser(row.user_name); // 转换 user_name 到 user
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const handleEditClosed = ({ row, column }) => {
|
|
@@ -318,6 +318,7 @@ async function getTaskList() {
|
|
|
...filter.value,
|
|
|
});
|
|
|
gridOptions.data = response.data;
|
|
|
+ originalData.value = JSON.parse(JSON.stringify(response.data));
|
|
|
gridOptions.pagerConfig.total = response.total;
|
|
|
} catch (error) {
|
|
|
console.error('Error fetching task data:', error);
|
|
@@ -343,23 +344,29 @@ async function saveEvent(row) {
|
|
|
if ($grid) {
|
|
|
try {
|
|
|
const { updateRecords } = $grid.getRecordset();
|
|
|
- updateRecords.forEach(record => {
|
|
|
- // 转换 user_name 到 user
|
|
|
- if (!record.user || record.user.length === 0) {
|
|
|
- record.user = userNameToUser(record.user_name);
|
|
|
+ const originalDataMap = new Map(originalData.value.map(item => [item.id, item]));
|
|
|
+
|
|
|
+ const updatedRecords = updateRecords.map(record => {
|
|
|
+ const originalRecord = originalDataMap.get(record.id);
|
|
|
+ if (!originalRecord) return null;
|
|
|
+
|
|
|
+ const updatedFields = {};
|
|
|
+ // 比较字段并记录变化
|
|
|
+ for (const key in record) {
|
|
|
+ if (record[key] !== originalRecord[key]) {
|
|
|
+ updatedFields[key] = record[key];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 转换 operater 到数组
|
|
|
- if (typeof record.operater === 'string') {
|
|
|
- record.operater = record.operater.split(',').map(item => item.trim()); // 按照中文逗号 ',' 分割并去掉空格
|
|
|
- } else if (Array.isArray(record.operater) && typeof record.operater[0] === 'string') {
|
|
|
- record.operater = record.operater[0].split(',').map(item => item.trim());
|
|
|
- }
|
|
|
- });
|
|
|
- await postUpdateManyTask(updateRecords);
|
|
|
+ return {
|
|
|
+ id: record.id,
|
|
|
+ ...updatedFields
|
|
|
+ };
|
|
|
+ }).filter(record => record); // 过滤掉值为 null 的记录
|
|
|
+ await postUpdateManyTask(updatedRecords);
|
|
|
await getTaskList();
|
|
|
await VXETable.modal.message({
|
|
|
- content: `更新 ${updateRecords.length} 条`,
|
|
|
+ content: `更新 ${ updatedRecords.length } 条`,
|
|
|
status: 'success',
|
|
|
});
|
|
|
|
|
@@ -404,7 +411,7 @@ async function updateUser() {
|
|
|
} catch (error) {
|
|
|
console.error('修改失败', error);
|
|
|
ElMessage.error('修改失败');
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
// 清除表单数据
|
|
|
taskRuleForm.operation = []; // 清除选择的填写人
|
|
|
updateSelect.value = 1; // 清除操作类型
|
|
@@ -412,7 +419,7 @@ async function updateUser() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function updateUserCancel(){
|
|
|
+function updateUserCancel() {
|
|
|
taskRuleForm.operation = [];
|
|
|
updateSelect.value = 1;
|
|
|
userDialogFormVisible.value = false;
|
|
@@ -501,8 +508,6 @@ async function updateRow(row) {
|
|
|
company: row.company,
|
|
|
platform: row.platform,
|
|
|
};
|
|
|
- console.log("=>(index.vue:442) updatedRowData", updatedRowData);
|
|
|
-
|
|
|
try {
|
|
|
const response = await postUpdateTask(updatedRowData);
|
|
|
if (response.code === 2000) {
|
|
@@ -733,7 +738,9 @@ onMounted(() => {
|
|
|
<!--<el-button plain type="success" @click="saveEvent">保存</el-button>-->
|
|
|
<el-button :disabled="isDeleteDisabled" :icon="Delete" plain type="danger" @click="removeEvent">删除
|
|
|
</el-button>
|
|
|
- <el-button v-if ="!isDeleteDisabled" @click="userDialogFormVisible =true" plain type="success" round>修改填写人</el-button>
|
|
|
+ <el-button v-if="!isDeleteDisabled" plain round type="success" @click="userDialogFormVisible =true">
|
|
|
+ 修改填写人
|
|
|
+ </el-button>
|
|
|
</template>
|
|
|
<template #toolbar_tools>
|
|
|
<div class="pr-2.5">
|
|
@@ -927,15 +934,15 @@ onMounted(() => {
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
- <el-dialog v-model="userDialogFormVisible" :before-close="updateUserCancel" style="border-radius: 10px;"
|
|
|
- title="修改填写人" width="500" align-center>
|
|
|
+ <el-dialog v-model="userDialogFormVisible" :before-close="updateUserCancel" align-center
|
|
|
+ style="border-radius: 10px;" title="修改填写人" width="500">
|
|
|
<div class="mb-3">
|
|
|
<el-radio-group v-model="updateSelect">
|
|
|
<el-radio :label="1">添加</el-radio>
|
|
|
<el-radio :label="2">删除</el-radio>
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
- <el-form-item label="录入人员:" prop="operation" width="500" align-center>
|
|
|
+ <el-form-item align-center label="录入人员:" prop="operation" width="500">
|
|
|
<el-select v-model="taskRuleForm.operation" collapse-tags collapse-tags-tooltip multiple
|
|
|
placeholder="请选择录入人员">
|
|
|
<el-option v-for="item in operationList" :key="item.value" :label="item.label"
|