Ver Fonte

feat(工单): 完善工单状态处理和编辑功能

扩展工单状态处理逻辑,支持更多状态下的操作
实现编辑对话框中的待跟进和反馈功能
修复状态显示和字典选择逻辑
ylong há 3 semanas atrás
pai
commit
446061c447

+ 5 - 4
src/views/workOrder/recycle/index.vue

@@ -33,18 +33,18 @@
                 <div class="flex justify-center space-x-2">
                     <!-- Logic: Creator -->
                     <template v-if="isCreator(row)">
-                        <template v-if="[1, 2].includes(row.status)"> <!-- Pending, Processing -->
+                        <template v-if="[1, 2, 3].includes(row.status)"> <!-- Pending, Processing -->
                             <el-button link type="danger" @click="handleVoid(row)">作废</el-button>
                             <el-button link type="primary" @click="handleEdit(row)">编辑</el-button>
                             <el-button link type="success" @click="handleComplete(row)">完成</el-button>
                         </template>
-                        <template v-else-if="[3, 4].includes(row.status)"> <!-- Completed, Void -->
+                        <template v-else-if="[4, 5].includes(row.status)"> <!-- Completed, Void -->
                             <el-button link type="warning" @click="handleReopen(row)">重开</el-button>
                         </template>
                     </template>
                     <!-- Logic: Assignee -->
                     <template v-else-if="isAssignee(row)">
-                        <template v-if="[1, 2].includes(row.status)">
+                        <template v-if="[1, 2, 3].includes(row.status)">
                             <el-button link type="success" @click="handleComplete(row)">完成</el-button>
                             <el-button link type="primary" @click="handleEdit(row)">编辑</el-button>
                         </template>
@@ -59,13 +59,14 @@
 </template>
 
 <script setup>
-import { ref, reactive, computed, onMounted } from 'vue'
+import { ref, reactive, computed, onMounted, getCurrentInstance } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import CommonTable from '@/components/CommonPage/CommonTable.vue'
 import PageSearch from '@/views/workOrder/sell/components/page-search.vue'
 import EditDialog from '@/views/workOrder/sell/components/edit-dialog.vue'
 import { useUserStore } from '@/store/modules/user'
 import { Plus, Check } from '@element-plus/icons-vue'
+const { proxy } = getCurrentInstance();
 
 const userStore = useUserStore()
 const currentUserId = computed(() => userStore.info?.userId || userStore.info?.id)

+ 57 - 5
src/views/workOrder/sell/components/edit-dialog.vue

@@ -83,7 +83,11 @@ const formItems = computed(() => [
         label: '任务类型',
         prop: 'taskType',
         type: 'dictSelect',
-        props: { class: 'w-full', placeholder: '请选择任务类型', code: 'task_type' }
+        props: {
+            class: 'w-full',
+            placeholder: '请选择任务类型',
+            code: form.type === 1 ? 'sell_task_type' : 'task_type'
+        }
     },
     {
         label: '指派给',
@@ -123,7 +127,7 @@ const formItems = computed(() => [
             class: 'w-full',
             placeholder: '请选择发货快递',
             filterable: true,
-            code: 'final_express'
+            code: 'shop_order_express_name'
         }
     },
     {
@@ -274,7 +278,7 @@ const handleSubmit = () => {
                 deatil: form.detail, // detail -> deatil
                 orderId: form.orderNo, // orderNo -> orderId
                 expressType: form.carrierId, // carrierId -> expressType
-                type: 1, // Fixed: 1-Sell Book
+                type: form.type, // Fixed: 1-Sell Book
 
                 // handleUserId is already an array of IDs
                 handleUsers: Array.isArray(form.handleUserId) ? form.handleUserId : (form.handleUserId ? [form.handleUserId] : []),
@@ -302,11 +306,59 @@ const handleSubmit = () => {
 };
 
 const handleFollowUp = () => {
-    ElMessage.info('功能待开发: 待跟进');
+    if (!form.id) return;
+
+    loading.value = true;
+    const submitData = {
+        id: form.id,
+        updateType: 1, // 待跟进
+        deatil: form.detail || '',
+        handleUsers: Array.isArray(form.handleUserId) ? form.handleUserId : (form.handleUserId ? [form.handleUserId] : []),
+        imgInfo: form.fileList ? JSON.parse(form.fileList) : []
+    };
+
+    proxy.$http.post('/workorder/workorderinfo/update', submitData).then(res => {
+        if (res.data.code === 200) {
+            ElMessage.success('已设置为待跟进');
+            emit('success');
+            handleClose();
+        } else {
+            ElMessage.error(res.data.msg || '操作失败');
+        }
+    }).catch(e => {
+        console.error(e);
+        ElMessage.error('操作失败');
+    }).finally(() => {
+        loading.value = false;
+    });
 };
 
 const handleFeedback = () => {
-    ElMessage.info('功能待开发: 反馈');
+    if (!form.id) return;
+
+    loading.value = true;
+    const submitData = {
+        id: form.id,
+        updateType: 2, // 反馈
+        deatil: form.detail || '',
+        handleUsers: Array.isArray(form.handleUserId) ? form.handleUserId : (form.handleUserId ? [form.handleUserId] : []),
+        imgInfo: form.fileList ? JSON.parse(form.fileList) : []
+    };
+
+    proxy.$http.post('/workorder/workorderinfo/update', submitData).then(res => {
+        if (res.data.code === 200) {
+            ElMessage.success('已提交反馈');
+            emit('success');
+            handleClose();
+        } else {
+            ElMessage.error(res.data.msg || '操作失败');
+        }
+    }).catch(e => {
+        console.error(e);
+        ElMessage.error('操作失败');
+    }).finally(() => {
+        loading.value = false;
+    });
 };
 
 defineExpose({ handleOpen });

+ 7 - 22
src/views/workOrder/sell/index.vue

@@ -18,7 +18,7 @@
             <template #handleUsers="{ row }">
                 <div v-if="row.handleUsers && row.handleUsers.length">
                     <span class="mr-1 text-gray-500">({{ getCompletedCount(row.handleUsers) }}/{{ row.handleUsers.length
-                    }})</span>
+                        }})</span>
                     <span v-for="(user, index) in row.handleUsers" :key="user.id">
                         <span :class="{ 'text-green-600 font-medium': user.status === 2 }">{{ user.userName }}</span>
                         <span v-if="user.status === 2" class="text-green-600 ml-0.5">✓</span>
@@ -33,18 +33,18 @@
                 <div class="flex justify-center space-x-2">
                     <!-- Logic: Creator -->
                     <template v-if="isCreator(row)">
-                        <template v-if="[1, 2].includes(row.status)"> <!-- Pending, Processing -->
+                        <template v-if="[1, 2, 3].includes(row.status)"> <!-- Pending, Processing -->
                             <el-button link type="danger" @click="handleVoid(row)">作废</el-button>
                             <el-button link type="primary" @click="handleEdit(row)">编辑</el-button>
                             <el-button link type="success" @click="handleComplete(row)">完成</el-button>
                         </template>
-                        <template v-else-if="[3, 4].includes(row.status)"> <!-- Completed, Void -->
+                        <template v-else-if="[4, 5].includes(row.status)"> <!-- Completed, Void -->
                             <el-button link type="warning" @click="handleReopen(row)">重开</el-button>
                         </template>
                     </template>
                     <!-- Logic: Assignee -->
                     <template v-else-if="isAssignee(row)">
-                        <template v-if="[1, 2].includes(row.status)">
+                        <template v-if="[1, 2, 3].includes(row.status)">
                             <el-button link type="success" @click="handleComplete(row)">完成</el-button>
                             <el-button link type="primary" @click="handleEdit(row)">编辑</el-button>
                         </template>
@@ -59,7 +59,7 @@
 </template>
 
 <script setup>
-import { ref, reactive, computed, onMounted } from 'vue'
+import { ref, reactive, computed, onMounted, getCurrentInstance } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import CommonTable from '@/components/CommonPage/CommonTable.vue'
 import PageSearch from './components/page-search.vue'
@@ -67,6 +67,7 @@ import EditDialog from './components/edit-dialog.vue'
 import { useUserStore } from '@/store/modules/user'
 import { Plus, Check } from '@element-plus/icons-vue'
 
+const { proxy } = getCurrentInstance();
 const userStore = useUserStore()
 const currentUserId = computed(() => userStore.info?.userId || userStore.info?.id)
 
@@ -99,22 +100,6 @@ const columns = ref([
     { columnKey: 'action', label: '操作', width: 150, fixed: 'right', align: 'center', slot: 'action' }
 ])
 
-// Helpers
-const getTaskTypeName = (type) => {
-    const map = { 1: '仓库缺货', 2: '部分发货', 3: '书单不符' }
-    return map[type] || '未知'
-}
-
-const getStatusName = (status) => {
-    const map = { 1: '待处理', 2: '处理中', 3: '已完成', 4: '已作废' }
-    return map[status] || '未知'
-}
-
-const getStatusType = (status) => {
-    const map = { 1: 'primary', 2: 'warning', 3: 'success', 4: 'info' }
-    return map[status] || 'info'
-}
-
 const getCompletedCount = (handleUsers) => {
     if (!handleUsers) return 0
     return handleUsers.filter(u => u.status === 2).length
@@ -142,7 +127,7 @@ const handleAdd = () => {
 
 const handleBatchComplete = () => {
     const selectedRows = tableRef.value?.getSelections()
-    
+
     tableRef.value?.operatBatch({
         method: 'post',
         url: '/workorder/workorderinfo/finish',