From a5e0e0de30cfa041d473dbd2d5111abb7689c9d7 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 03 三月 2026 10:25:49 +0800
Subject: [PATCH] fix: 售后移除维修记录
---
src/views/customerService/afterSalesHandling/index.vue | 206 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 183 insertions(+), 23 deletions(-)
diff --git a/src/views/customerService/afterSalesHandling/index.vue b/src/views/customerService/afterSalesHandling/index.vue
index 4994365..dd07ddb 100644
--- a/src/views/customerService/afterSalesHandling/index.vue
+++ b/src/views/customerService/afterSalesHandling/index.vue
@@ -22,9 +22,15 @@
clearable
@change="handleQuery"
/>
+ <span style = "margin-left: 10px;" class="search_title">澶勭悊鐘舵�侊細</span>
+ <el-select v-model="searchForm.status" placeholder="璇烽�夋嫨鐘舵��" @change="handleQuery" style="width: 140px" clearable>
+ <el-option label="寰呭鐞�" :value="1"></el-option>
+ <el-option label="宸插鐞�" :value="2"></el-option>
+ </el-select>
<el-button type="primary" @click="handleQuery" style="margin-left: 10px"
>鎼滅储</el-button
>
+ <el-button @click="handleOut" style="margin-left: 10px">瀵煎嚭</el-button>
</div>
</div>
<div class="table_list">
@@ -40,15 +46,30 @@
></PIMTable>
</div>
<form-dia ref="formDia" @close="handleQuery"></form-dia>
+ <FileListDialog
+ ref="fileListRef"
+ v-model="fileListDialogVisible"
+ title="鍞悗闄勪欢"
+ :show-upload-button="true"
+ :show-delete-button="true"
+ :upload-method="handleFileUpload"
+ :delete-method="handleFileDelete"
+ />
</div>
</template>
<script setup>
-import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref} from "vue";
+import { onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick } from "vue";
import FormDia from "@/views/customerService/afterSalesHandling/components/formDia.vue";
-import {ElMessageBox} from "element-plus";
-import {afterSalesServiceDelete, afterSalesServiceListPage} from "@/api/customerService/index.js";
+import FileListDialog from "@/components/Dialog/FileListDialog.vue";
+import { ElMessageBox } from "element-plus";
+import request from "@/utils/request";
+import { getToken } from "@/utils/auth";
+import {
+ afterSalesServiceListPage,
+ afterSalesServiceFileListPage,
+ afterSalesServiceFileDel,
+} from "@/api/customerService/index.js";
import useUserStore from "@/store/modules/user.js";
const { proxy } = getCurrentInstance();
const userStore = useUserStore()
@@ -128,7 +149,7 @@
label: "鎿嶄綔",
align: "center",
fixed: 'right',
- width: 120,
+ width: 240,
operation: [
{
name: "澶勭悊",
@@ -145,6 +166,14 @@
type: "text",
clickFun: (row) => {
openForm("view", row);
+ },
+ },
+ // TODO 涓哄啓鎶ュ憡娣诲姞鐨�
+ {
+ name: "闄勪欢",
+ type: "text",
+ clickFun: (row) => {
+ openFilesFormDia(row);
},
},
],
@@ -164,6 +193,150 @@
selectedRows.value = selection;
};
const formDia = ref()
+const fileListRef = ref(null)
+const fileListDialogVisible = ref(false)
+const currentFileRow = ref(null)
+
+
+// 鎵撳紑闄勪欢寮规
+const openFilesFormDia = async (row) => {
+ currentFileRow.value = row
+ try {
+ const res = await afterSalesServiceFileListPage({
+ afterSalesServiceId: row.id,
+ current: 1,
+ size: 100,
+ })
+ if (res.code === 200 && fileListRef.value) {
+ const fileList = (res.data?.records || []).map((item) => ({
+ name: item.name || item.fileName,
+ url: item.url || item.fileUrl,
+ id: item.id,
+ ...item,
+ }))
+ fileListRef.value.open(fileList)
+ fileListDialogVisible.value = true
+ } else {
+ fileListRef.value?.open([])
+ fileListDialogVisible.value = true
+ }
+ } catch (error) {
+ proxy.$modal.msgError("鑾峰彇闄勪欢鍒楄〃澶辫触")
+ fileListRef.value?.open([])
+ fileListDialogVisible.value = true
+ }
+}
+
+// 涓婁紶闄勪欢
+const handleFileUpload = async () => {
+ if (!currentFileRow.value) {
+ proxy.$modal.msgWarning("璇峰厛閫夋嫨鏁版嵁")
+ return
+ }
+ return new Promise((resolve) => {
+ const input = document.createElement("input")
+ input.type = "file"
+ input.style.display = "none"
+ input.onchange = async (e) => {
+ const file = e.target.files[0]
+ if (!file) {
+ resolve(null)
+ return
+ }
+ try {
+ const formData = new FormData()
+ formData.append("file", file)
+ formData.append("id", currentFileRow.value.id)
+ const uploadRes = await request({
+ url: "/afterSalesService/file/upload",
+ method: "post",
+ data: formData,
+ headers: {
+ "Content-Type": "multipart/form-data",
+ Authorization: `Bearer ${getToken()}`,
+ },
+ })
+ if (uploadRes.code === 200) {
+ proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛")
+ // 閲嶆柊鑾峰彇鏂囦欢鍒楄〃
+ const listRes = await afterSalesServiceFileListPage({
+ afterSalesServiceId: currentFileRow.value.id,
+ current: 1,
+ size: 100,
+ })
+ if (listRes.code === 200 && fileListRef.value) {
+ const fileList = (listRes.data?.records || []).map((item) => ({
+ name: item.fileName,
+ url: item.fileUrl,
+ id: item.id,
+ ...item,
+ }))
+ fileListRef.value.setList(fileList)
+ }
+ resolve({ name: file.name, url: "", id: null })
+ } else {
+ proxy.$modal.msgError(uploadRes.msg || "鏂囦欢涓婁紶澶辫触")
+ resolve(null)
+ }
+ } catch (err) {
+ proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触")
+ resolve(null)
+ } finally {
+ document.body.removeChild(input)
+ }
+ }
+ document.body.appendChild(input)
+ input.click()
+ })
+}
+
+// 鍒犻櫎闄勪欢
+const handleFileDelete = async (row) => {
+ try {
+ // 娣诲姞纭瀵硅瘽妗�
+ const confirmResult = await ElMessageBox.confirm(
+ '纭畾瑕佸垹闄よ繖涓檮浠跺悧锛�',
+ '鍒犻櫎纭',
+ {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }
+ )
+
+ if (confirmResult === 'confirm') {
+ const res = await afterSalesServiceFileDel(row.id)
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
+ if (currentFileRow.value && fileListRef.value) {
+ const listRes = await afterSalesServiceFileListPage({
+ afterSalesServiceId: currentFileRow.value.id,
+ current: 1,
+ size: 100,
+ })
+ if (listRes.code === 200) {
+ const fileList = (listRes.data?.records || []).map((item) => ({
+ name: item.fileName,
+ url: item.fileUrl,
+ id: item.id,
+ ...item,
+ }))
+ fileListRef.value.setList(fileList)
+ }
+ }
+ } else {
+ proxy.$modal.msgError(res.msg || "鍒犻櫎澶辫触")
+ return false
+ }
+ }
+ } catch (error) {
+ // 濡傛灉鐢ㄦ埛鍙栨秷鍒犻櫎锛屼笉鏄剧ず閿欒淇℃伅
+ if (error !== 'cancel') {
+ proxy.$modal.msgError("鍒犻櫎澶辫触")
+ }
+ return false
+ }
+}
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -192,34 +365,21 @@
})
};
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
confirmButtonText: "纭",
cancelButtonText: "鍙栨秷",
type: "warning",
})
.then(() => {
- tableLoading.value = true;
- afterSalesServiceDelete(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
+ proxy.download("/afterSalesService/exportTwo", {}, "鍞悗澶勭悊.xlsx");
})
.catch(() => {
proxy.$modal.msg("宸插彇娑�");
});
};
+
onMounted(() => {
getList();
});
--
Gitblit v1.9.3