hongjli
2025-06-16 90b3b6329fec3205b845198ca6dc539dcde186c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
"use client";
 
import { Dialog, Transition } from '@headlessui/react';
import { Fragment } from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { motion } from 'framer-motion';
 
interface DataPreviewDialogProps {
  isOpen: boolean;
  onClose: () => void;
  markdownContent: string;
  sceneType?: 'chadan' | 'buliao' | 'panorama';  // 添加场景类型属性
}
 
export default function DataPreviewDialog({
  isOpen,
  onClose,
  markdownContent,
  sceneType
}: DataPreviewDialogProps) {
  // 根据场景类型获取对应的数据来源说明
  const getDataSourceDescription = () => {
    if (sceneType === 'chadan') {
      return (
        <div className="space-y-6">
          <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
            <div className="flex items-center gap-3 mb-3">
              <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 7v10c0 2 1 3 3 3h10c2 0 3-1 3-3V7c0-2-1-3-3-3H7C5 4 4 5 4 7z" />
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 12h8" />
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 16V8" />
                </svg>
              </div>
              <h4 className="text-lg font-semibold text-blue-900">ERP核心数据</h4>
            </div>
            <div className="ml-11">
              <p className="text-blue-800">BOM、需求、采购订单、供应商列表</p>
            </div>
          </div>
 
          <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
            <div className="flex items-center gap-3 mb-3">
              <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4" />
                </svg>
              </div>
              <h4 className="text-lg font-semibold text-blue-900">外部系统补充</h4>
            </div>
            <div className="ml-11">
              <p className="text-blue-800">插单需求通常由CRM、MES或人工输入触发,其他系统(PLM/SRM/SCM)可能提供补充或源头数据</p>
            </div>
          </div>
        </div>
      );
    } else if (sceneType === 'buliao') {
      return (
        <div className="space-y-6">
          <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
            <div className="flex items-center gap-3 mb-3">
              <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2M7 7h10" />
                </svg>
              </div>
              <h4 className="text-lg font-semibold text-blue-900">工位信息</h4>
            </div>
            <div className="ml-11">
              <p className="text-blue-800">核心来源系统:MES、SCADA</p>
            </div>
          </div>
 
          <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
            <div className="flex items-center gap-3 mb-3">
              <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
                </svg>
              </div>
              <h4 className="text-lg font-semibold text-blue-900">生产计划数据 (production_plan)</h4>
            </div>
            <div className="ml-11">
              <p className="text-blue-800">核心来源系统:SAP(企业管理系统)</p>
            </div>
          </div>
 
          <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
            <div className="flex items-center gap-3 mb-3">
              <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
                </svg>
              </div>
              <h4 className="text-lg font-semibold text-blue-900">原材料库存</h4>
            </div>
            <div className="ml-11">
              <p className="text-blue-800">核心来源系统:ERP、WMS</p>
            </div>
          </div>
 
          <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
            <div className="flex items-center gap-3 mb-3">
              <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 7v10c0 2 1 3 3 3h10c2 0 3-1 3-3V7c0-2-1-3-3-3H7C5 4 4 5 4 7z" />
                </svg>
              </div>
              <h4 className="text-lg font-semibold text-blue-900">物料主数据</h4>
            </div>
            <div className="ml-11">
              <p className="text-blue-800">核心来源系统:SAP(企业管理系统)</p>
            </div>
          </div>
        </div>
      );
    } else if (sceneType === 'panorama') {
      return (
        <div className="flex flex-col h-full">
          {/* 卡片说明区块,顶部固定 */}
          <div className="space-y-4 flex-shrink-0">
            {/* 订单需求数据 */}
            <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
              <div className="flex items-center gap-3 mb-2">
                <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                  <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
                  </svg>
                </div>
                <h4 className="text-lg font-semibold text-blue-900">订单需求数据</h4>
              </div>
              <div className="ml-11">
                <p className="text-blue-800">核心来源系统:OMS(订单管理系统)</p>
              </div>
            </div>
            {/* 库存数据 */}
            <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
              <div className="flex items-center gap-3 mb-2">
                <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                  <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 7v10c0 2 1 3 3 3h10c2 0 3-1 3-3V7c0-2-1-3-3-3H7C5 4 4 5 4 7z" />
                  </svg>
                </div>
                <h4 className="text-lg font-semibold text-blue-900">库存数据</h4>
              </div>
              <div className="ml-11">
                <p className="text-blue-800">核心来源系统:WMS(仓储管理系统)</p>
              </div>
            </div>
            {/* 生产计划数据 */}
            <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
              <div className="flex items-center gap-3 mb-2">
                <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                  <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
                  </svg>
                </div>
                <h4 className="text-lg font-semibold text-blue-900">生产计划数据</h4>
              </div>
              <div className="ml-11">
                <p className="text-blue-800">核心来源系统:SAP(企业管理系统)</p>
              </div>
            </div>
            {/* 物料主数据 */}
            <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
              <div className="flex items-center gap-3 mb-2">
                <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                  <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 7v10c0 2 1 3 3 3h10c2 0 3-1 3-3V7c0-2-1-3-3-3H7C5 4 4 5 4 7z" />
                  </svg>
                </div>
                <h4 className="text-lg font-semibold text-blue-900">物料主数据</h4>
              </div>
              <div className="ml-11">
                <p className="text-blue-800">核心来源系统:SAP(企业管理系统)</p>
              </div>
            </div>
            {/* 供应商绩效数据 */}
            <div className="bg-white/50 rounded-lg p-4 backdrop-blur-sm border border-blue-100/50">
              <div className="flex items-center gap-3 mb-2">
                <div className="h-8 w-8 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center">
                  <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
                  </svg>
                </div>
                <h4 className="text-lg font-semibold text-blue-900">供应商绩效数据</h4>
              </div>
              <div className="ml-11">
                <p className="text-blue-800">核心来源系统:SRM(供应商关系管理)、质量管理系统</p>
              </div>
            </div>
          </div>
          {/* 数据区块,独立滚动,显示在下方 */}
          <div className="flex-1 min-h-0 mt-4 overflow-y-auto px-1">
            <div className="bg-white/90 rounded-lg p-6 shadow border border-gray-100">
              <ReactMarkdown
                remarkPlugins={[remarkGfm]}
                components={{
                  h3: ({node, ...props}) => <h3 className="text-lg font-bold text-gray-800 mt-6 mb-3" {...props} />,
                  table: ({node, ...props}) => <div className="overflow-x-auto my-4"><table className="min-w-full text-gray-800 text-base" {...props} /></div>,
                  thead: ({node, ...props}) => <thead className="bg-gray-50" {...props} />,
                  th: ({node, ...props}) => <th className="px-4 py-3 text-base font-semibold text-gray-800 border-b border-gray-200 text-center whitespace-nowrap" {...props} />,
                  td: ({node, ...props}) => <td className="px-4 py-3 text-base text-gray-800 border-t border-gray-100 text-center" {...props} />,
                  tr: ({node, ...props}) => <tr className="hover:bg-gray-50" {...props} />
                }}
              >
                {markdownContent}
              </ReactMarkdown>
            </div>
          </div>
        </div>
      );
    }
    return null;
  };
 
  return (
    <Transition appear show={isOpen} as={Fragment}>
      <Dialog as="div" className="relative z-50" onClose={onClose}>
        <Transition.Child
          as={Fragment}
          enter="ease-out duration-300"
          enterFrom="opacity-0"
          enterTo="opacity-100"
          leave="ease-in duration-200"
          leaveFrom="opacity-100"
          leaveTo="opacity-0"
        >
          <div className="fixed inset-0 bg-black/80 backdrop-blur-sm" />
        </Transition.Child>
 
        <div className="fixed inset-0 overflow-y-auto">
          <div className="flex min-h-full items-center justify-center p-4 text-center">
            <Transition.Child
              as={Fragment}
              enter="ease-out duration-300"
              enterFrom="opacity-0 scale-95"
              enterTo="opacity-100 scale-100"
              leave="ease-in duration-200"
              leaveFrom="opacity-100 scale-100"
              leaveTo="opacity-0 scale-95"
            >
              <Dialog.Panel className="w-[800px] h-[600px] transform overflow-hidden rounded-xl bg-white shadow-[0_0_30px_rgba(0,0,0,0.15)] transition-all flex flex-col">
                <div className="flex items-center justify-between p-6 border-b border-gray-200">
                  <Dialog.Title className="text-xl font-semibold text-gray-800 flex items-center">
                    演示数据预览
                    <motion.span 
                      className="ml-2 inline-block w-2 h-2 rounded-full bg-[#6ADBFF]"
                      animate={{ 
                        scale: [1, 1.5, 1],
                        opacity: [0.7, 1, 0.7] 
                      }}
                      transition={{ 
                        duration: 2,
                        repeat: Infinity,
                        ease: "easeInOut"
                      }}
                    />
                  </Dialog.Title>
                  <button
                    onClick={onClose}
                    className="text-gray-500 hover:text-gray-700 transition-colors duration-300 cursor-pointer"
                  >
                    <svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                      <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
                    </svg>
                  </button>
                </div>
                <div className="flex-1 overflow-y-auto p-6">
                  <div className="prose max-w-none">
                    <div className="mb-6 p-6 bg-gradient-to-br from-blue-50 to-blue-100/50 rounded-lg border border-blue-100">
                      <h3 className="text-xl font-semibold text-blue-900 mb-4 pb-3 border-b border-blue-200/50 flex items-center gap-2">
                        <svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                          <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
                        </svg>
                        数据来源说明
                      </h3>
                      {getDataSourceDescription()}
                      <div className="mt-6 pt-3 border-t border-blue-200/50">
                        <p className="text-blue-800/90 text-sm flex items-center gap-2">
                          <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-blue-600/80" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                          </svg>
                          注:以下为模拟演示数据,实际使用时将自动对接相关业务系统
                        </p>
                      </div>
                    </div>
                  </div>
                </div>
              </Dialog.Panel>
            </Transition.Child>
          </div>
        </div>
      </Dialog>
    </Transition>
  );