buhuazhen
5 天以前 401952cc1bf9208667cdac24e2878d4d0e7e6ea9
feat(expiryAfterSales): 添加处理功能并优化表单字段控制

- 将状态为1的记录的“编辑”按钮改为“处理”按钮
- 新增“处理”操作类型,仅允许编辑处理人、处理日期和处理结果字段
- 提交处理时自动将状态更新为2并显示相应成功消息
- 使用 isFieldDisabled 方法统一管理表单字段禁用逻辑,提高代码可维护性
已修改2个文件
54 ■■■■ 文件已修改
src/views/customerService/expiryAfterSales/components/formDia.vue 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/customerService/expiryAfterSales/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/customerService/expiryAfterSales/components/formDia.vue
@@ -20,7 +20,7 @@
                                v-model="form.productName"
                                placeholder="请输入产品名称"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('productName')"
                            />
                        </el-form-item>
                    </el-col>
@@ -30,7 +30,7 @@
                                v-model="form.batchNumber"
                                placeholder="请输入产品批号"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('batchNumber')"
                            />
                        </el-form-item>
                    </el-col>
@@ -46,7 +46,7 @@
                                type="date"
                                placeholder="请选择临期日期"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('expiryDate')"
                            />
                        </el-form-item>
                    </el-col>
@@ -57,7 +57,7 @@
                                :min="0"
                                placeholder="请输入库存数量"
                                style="width: 100%"
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('stockQuantity')"
                            />
                        </el-form-item>
                    </el-col>
@@ -69,7 +69,7 @@
                                v-model="form.customerName"
                                placeholder="请输入客户名称"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('customerName')"
                            />
                        </el-form-item>
                    </el-col>
@@ -79,7 +79,7 @@
                                v-model="form.contactPhone"
                                placeholder="请输入联系电话"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('contactPhone')"
                            />
                        </el-form-item>
                    </el-col>
@@ -91,7 +91,7 @@
                                v-model="form.problemDesc"
                                placeholder="请输入问题描述"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('problemDesc')"
                                type="textarea"
                                :rows="3"
                            />
@@ -105,7 +105,7 @@
                                v-model="form.handlerId"
                                placeholder="请选择处理人"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('handlerId')"
                                style="width: 100%"
                            >
                                <el-option
@@ -127,7 +127,7 @@
                                type="date"
                                placeholder="请选择处理日期"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('handleDate')"
                            />
                        </el-form-item>
                    </el-col>
@@ -139,7 +139,7 @@
                                v-model="form.handleResult"
                                placeholder="请输入处理结果"
                                clearable
                                :disabled="operationType === 'view'"
                                :disabled="isFieldDisabled('handleResult')"
                                type="textarea"
                                :rows="3"
                            />
@@ -175,6 +175,8 @@
            return '新增临期售后';
        case 'edit':
            return '编辑临期售后';
        case 'handle':
            return '处理临期售后';
        case 'view':
            return '查看临期售后';
        default:
@@ -212,6 +214,13 @@
})
const { form, rules } = toRefs(data);
const userList = ref([])
const handleEditableFields = ["handlerId", "handleDate", "handleResult"];
const isFieldDisabled = (field) => {
    if (operationType.value === "view") return true;
    if (operationType.value === "handle") return !handleEditableFields.includes(field);
    return false;
};
// 打开弹框
const openDialog = (type, row) => {
@@ -242,7 +251,7 @@
    } else {
        // 编辑或查看时填充数据
        form.value = { ...row };
        if (type === 'edit' && !form.value.handlerId) {
        if (type === 'handle' && !form.value.handlerId) {
            form.value.handlerId = userStore.id;
            form.value.handleDate = getCurrentDate();
        }
@@ -250,8 +259,22 @@
}
const submitForm = () => {
    if (operationType.value === "handle") {
        if (!form.value.handlerId || !form.value.handleDate || !form.value.handleResult) {
            proxy.$modal.msgWarning("请填写处理人、处理日期和处理结果");
            return;
        }
        handleSubmit();
        return;
    }
    proxy.$refs["formRef"].validate(valid => {
        if (valid) {
            handleSubmit();
        }
    });
}
const handleSubmit = () => {
            const submitData = {
                id: form.value.id,
                productName: form.value.productName,
@@ -261,7 +284,7 @@
                customerName: form.value.customerName,
                contactPhone: form.value.contactPhone,
                disRes: form.value.problemDesc,
                status: form.value.status,
        status: operationType.value === "handle" ? 2 : form.value.status,
                disposeUserId: form.value.handlerId,
                disposeNickName: userList.value.find(item => item.userId === form.value.handlerId)?.nickName,
                disposeResult: form.value.handleResult,
@@ -270,13 +293,12 @@
            
            const apiCall = operationType.value === 'add' ? expiryAfterSalesAdd : expiryAfterSalesUpdate;
            apiCall(submitData).then(() => {
                proxy.$modal.msgSuccess(operationType.value === 'add' ? "新增成功" : "更新成功");
        const successText = operationType.value === "add" ? "新增成功" : operationType.value === "handle" ? "处理成功" : "更新成功";
        proxy.$modal.msgSuccess(successText);
                closeDia();
            }).catch(error => {
                console.error('提交数据失败:', error);
                proxy.$modal.msgError('提交数据失败,请稍后重试');
            });
        }
    });
}
src/views/customerService/expiryAfterSales/index.vue
@@ -60,7 +60,7 @@
                <template #operation="{ row }">
                    <el-button type="primary" link @click="openForm('view', row)">查看</el-button>
                    <el-button type="primary" link @click="openForm('edit', row)" v-if="row.status === 1">编辑</el-button>
                    <el-button type="primary" link @click="openForm('handle', row)" v-if="row.status === 1">处理</el-button>
                </template>
            </PIMTable>
        </div>