雷神教育集团
2026-03-06 75c4ed0d3c640e66bc95dc170de52b753629e3ed
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<template>
  <view-grid
      ref="grid"
      :columns="columns"
      :detail="detail"
      :editFormFields="editFormFields"
      :editFormOptions="editFormOptions"
      :searchFormFields="searchFormFields"
      :searchFormOptions="searchFormOptions"
      :table="table"
      :extend="extend"
  >
  </view-grid>
</template>
 
<script>
import extend from "@/extension/taskinfo/packaxistask_hty.js";
import { ref, defineComponent, onMounted } from "vue";
 
export default defineComponent({
  setup() {
    // 表格基础配置(指定主键、接口地址、排序字段)
    const table = ref({
      key: "taskId",
      footer: "Foots",
      cnName: "码垛任务历史信息",
      name: "packaxisTask_Hty",
      url: "/PackaxisTask_Hty/",
      sortName: "CreateDate",
    });
 
    // 编辑表单配置(初始化空值,避免undefined)
    const editFormFields = ref({});
    const editFormOptions = ref([]);
 
    // 搜索表单字段(与搜索项一一对应,初始化空字符串)
    const searchFormFields = ref({
      packTaskNum: "",
      barCode: "",
      deviceCode: "",
      roadway: "",
      sourceAddress: "",
      targetAddress: "",
      currentAddress: "",
      nextAddress: "",
      packType: "",
      createDate: "",
      taskState: "", // 补充任务状态搜索字段(原配置遗漏)
      packLength: "", // 补充箱长/宽/高搜索字段
      packWidth: "",
      packHeight: "",
      operateType:""
    });
 
    // 搜索表单布局及字段配置(优化空数据、补充注释)
    const searchFormOptions = ref([
      [
        { title: "码垛任务号", field: "packTaskNum", type: "int" },
        { title: "箱码", field: "barCode", type: "like" },
        { title: "设备编号", field: "deviceCode", type: "like" },
      ],
      [
        {
          title: "任务状态",
          field: "taskState",
          type: "selectList",
          dataKey: "taskState",
          data: [], // 后续在onMounted中填充
        },
        { title: "起始地址", field: "sourceAddress", type: "like" },
        { title: "目标地址", field: "targetAddress", type: "like" },
 
      ],
      [
        { title: "当前位置", field: "currentAddress", type: "like" },
        { title: "下一位置", field: "nextAddress", type: "like" },
        {
          title: "垛型",
          field: "packType",
          type: "select",
          dataKey: "packTypes",
          data: [], // 后续在onMounted中填充
        }
      ],
      [
        { title: "箱长", field: "packLength", type: "like" },
        { title: "箱宽", field: "packWidth", type: "like" },
        { title: "箱高", field: "packHeight", type: "like" },
        { title: "创建时间", field: "createDate", type: "datetime" },
      ],
    ]);
 
    // 表格列配置(修复数据类型、补充空值保护)
    const columns = ref([
      {
        field: "taskId",
        title: "TaskId",
        type: "int",
        width: 90,
        hidden: true,
        readonly: true,
        require: true,
        align: "left",
      },
      {
        field: "packTaskNum",
        title: "任务号",
        type: "int",
        width: 90,
        align: "left",
      },
      {
        field: "barCode",
        title: "箱码",
        type: "string",
        width: 200,
        align: "left",
      },
      {
        field: "deviceCode",
        title: "设备编号",
        type: "string",
        width: 180,
        align: "left",
      },
      {
        field: "packType",
        title: "垛型",
        type: "int",
        width: 150,
        align: "left",
        bind: { key: "packTypes", data: [] }, // 后续填充下拉数据
      },
      {
        field: "taskState",
        title: "任务状态",
        type: "int",
        width: 150,
        align: "left",
        bind: { key: "taskState", data: [] }, // 后续填充下拉数据
      },
      {
        field: "sourceAddress",
        title: "起始地址",
        type: "string", // 修正类型:地址类字段建议用string,避免数字解析错误
        width: 120,
        align: "left",
      },
      {
        field: "targetAddress",
        title: "目标地址",
        type: "string",
        width: 120,
        align: "left",
      },
      {
        field: "currentAddress",
        title: "当前位置",
        type: "string",
        width: 120,
        align: "left",
      },
      {
        field: "nextAddress",
        title: "下一位置",
        type: "string",
        width: 120,
        align: "left",
      },
      {
        title: "箱长",
        field: "packLength",
        type: "int",
        width: 120,
        align: "left",
      },
      {
        title: "箱宽",
        field: "packWidth",
        type: "int",
        width: 120,
        align: "left",
      },
      {
        title: "箱高",
        field: "packHeight",
        type: "int",
        width: 120,
        align: "left",
      },
      {
        field: "dispatchertime",
        title: "任务下发时间",
        type: "datetime",
        width: 150,
        align: "left",
      },
      {
        field: "operateType",
        title: "操作类型",
        type: "string",
        bind: {key: "",data:[{key:"自动完成",value:"自动完成"},{key:"人工删除",value: "人工删除"}]},
        width: 150,
        align: "left",
      },
      {
        field: "insertTime",
        title: "移入历史时间",
        type: "datetime",
        width: 150,
        align: "left",
      },
      {
        field: "creater",
        title: "创建人",
        type: "string",
        width: 90,
        align: "left",
      },
      {
        field: "createDate",
        title: "创建时间",
        type: "datetime",
        width: 150,
        align: "left",
      },
      {
        field: "modifier",
        title: "修改人",
        type: "string",
        width: 100,
        align: "left",
      },
      {
        field: "modifyDate",
        title: "修改时间",
        type: "datetime",
        width: 160,
        align: "left",
      },
      {
        field: "remark",
        title: "备注",
        type: "string",
        width: 100,
        align: "left",
        hidden: true,
      },
    ]);
 
    // 详情配置(初始化空值,避免undefined)
    const detail = ref({
      cnName: "",
      table: "",
      columns: [],
      sortName: "",
      key: "",
    });
 
    // 组件挂载后加载动态下拉数据(核心:避免空数据导致的undefined报错)
    // onMounted(async () => {
    //   try {
    //     // ========== 1. 模拟加载垛型数据(替换为你的实际接口) ==========
    //     // const packTypeData = await api.getPackTypes(); // 真实接口
    //     const packTypeData = [
    //       { key: 1, value: "垛型1" },
    //       { key: 2, value: "垛型2" },
    //       { key: 3, value: "垛型3" },
    //     ];
    //
    //     // 填充搜索表单中的垛型下拉
    //     const packTypeSearchItem = searchFormOptions.value
    //         .flat()
    //         .find(item => item.field === "packType");
    //     if (packTypeSearchItem) {
    //       packTypeSearchItem.data = packTypeData;
    //     }
    //     // 填充表格列中的垛型绑定数据
    //     const packTypeColumn = columns.value.find(col => col.field === "packType");
    //     if (packTypeColumn?.bind) {
    //       packTypeColumn.bind.data = packTypeData;
    //     }
    //
    //     // ========== 2. 模拟加载任务状态数据(替换为你的实际接口) ==========
    //     // const taskStateData = await api.getTaskStates(); // 真实接口
    //     const taskStateData = [
    //       { key: 0, value: "未执行" },
    //       { key: 1, value: "执行中" },
    //       { key: 2, value: "已完成" },
    //       { key: 3, value: "已取消" },
    //     ];
    //
    //     // 填充搜索表单中的任务状态下拉
    //     const taskStateSearchItem = searchFormOptions.value
    //         .flat()
    //         .find(item => item.field === "taskState");
    //     if (taskStateSearchItem) {
    //       taskStateSearchItem.data = taskStateData;
    //     }
    //     // 填充表格列中的任务状态绑定数据
    //     const taskStateColumn = columns.value.find(col => col.field === "taskState");
    //     if (taskStateColumn?.bind) {
    //       taskStateColumn.bind.data = taskStateData;
    //     }
    //
    //   } catch (error) {
    //     console.error("加载下拉选项数据失败:", error);
    //   }
    // });
 
    return {
      table,
      extend,
      editFormFields,
      editFormOptions,
      searchFormFields,
      searchFormOptions,
      columns,
      detail,
    };
  },
});
</script>