schangxiang@126.com
2025-05-21 496f78c085e7f8c5ba261835f9b8bda99c25b4cb
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
import { computed, defineComponent, onMounted, reactive, ref } from 'vue' 
import type { Ref } from 'vue' 
import BaseTable from '@/components/Table/Table' 
import styles from './WorkTask.module.scss' 
import { useWorkTask } from '../../../Controllers/WorkTask' 
import IconButton from '@/components/IconButton/IconButton' 
import WorkTaskDrawer from '../Dialog/WorkTaskDrawer/WorkTaskDrawer' 
import WorkTaskQueryDrawer from '../Dialog/WorkTaskQueryDrawer/WorkTaskQueryDrawer' 
import Search from '@/components/Search/Search' 
import { columns } from './Config' 
import TdButton from '@/components/TdButton/TdButton' 
import { vPermission } from '@/libs/Permission/Permission' 
import dayjs from 'dayjs' 
import { 
  getWmsEnumData 
} from '@/widgets/WorkTask/Models/Service/WorkTaskDrawer' 
import { 
  ElInput, 
  ElSelect, 
  ElOption, 
  ElDatePicker, 
  ElForm, 
  ElFormItem, 
} from 'element-plus' 
import { injectModel } from '@/libs/Provider/Provider' 
// 引入公共选项配置  
import {   
  FILTER_MODE_OPTIONS_STRING_KEY 
} from '@/components/DyFormForHighQuery/DyFormForHighQueryOptions';  
// 引入公共高级查询工具文件   
import { commonSaveCurHighQueryData,setValueForCurHighQueryData,commonGetHighQueryForm,initQueryForm,GetFilteredData } from '@/utils/myHighQueryUtils';  
 
interface RenderTableType { 
  url?: string 
  dataSource: Ref<any[]> 
  isDrag?: boolean 
  isChecked?: boolean 
  isHidePagination?: boolean 
  params?: Record<string, any> 
  autoHeight?: boolean 
 
export default defineComponent({ 
  name: 'WorkTask', 
  directives: { 
    permission: vPermission, 
  }, 
  setup(props, ctx) { 
    const { 
      dataSource, 
      contextMenu, 
      dialogConfig, 
      dialogConfigForQuery, 
      tableRef, 
      current, 
      search, 
      sort, 
      headers, 
      onError, 
      onSearch, 
      onRowClick, 
      onConfirmWorkTask, 
      onCheck, 
      onAddWorkTask, 
      onAdvancedQuery, 
      onExport, 
      openDetail, 
      onSuccess, 
      onBeforeUpload, 
    } = useWorkTask(props, ctx) 
 
    //定义高级查询引用 
   const workTaskQueryDrawerRef=ref(null); 
     
    //定义整体模糊查询的列数组(注意:必须大小写跟后端的实体类属性名一致,否则会导致匹配不对的问题) 
    const _searchFormInputAttrs = ref([ 
     'Son_TaskCode','TaskCode','PipeSpecCode','PipeSectionName','PipeSpecMode','ProcessName','ShipNumber','ProjectNumber','ProcessRouteNumber','DataIdentifier','MaterialMode','MarkingContent','WeldingHeatInput','PipeAllowableStress','FactoryCode','ProductCode','WorkstationCode','EquipmentCode','ProdLineCode','PipeFittingCode','PreSerialNumber','Material','TeamInfo','Timestamp','CreatorName','LastModifierName','Remark' 
    ]); 
    const searchFormInputAttrs_Placeholder = ref('请输入子任务编码/任务编码/管段编码/管段名称/管段型号/工序名称/船号/项目号/工艺流向编号/原料标识/原料型号/打码内容/法兰公称压力/法兰冲码内容/工厂代码/产品代码/工位代码/设备代码/产线编码/管件编码/顺序号/材质/班组信息/时间戳/创建人/修改人/备注'); 
     
 
    // 动态枚举选项 
    const enumOptions = reactive({ 
      workPlanStatus: [] as Array<{label: string; value: any }>, 
callMaterialStatus: [] as Array<{label: string; value: any }>,  
    }) 
 
    // 获取枚举数据 
    const fetchEnumData = async () => { 
      try { 
        const workPlanStatusEnumData = await getWmsEnumData({ 
 EnumName: 'WorkPlanStatusEnum', 
}) 
enumOptions.workPlanStatus = workPlanStatusEnumData.map((item) => ({ 
  label: item.description, 
  value: item.value, 
})) 
const callMaterialStatusEnumData = await getWmsEnumData({ 
 EnumName: 'CallMaterialStatusEnum', 
}) 
enumOptions.callMaterialStatus = callMaterialStatusEnumData.map((item) => ({ 
  label: item.description, 
  value: item.value, 
})) 
 
      } catch (error) { 
        console.error('获取枚举数据失败:', error) 
      } 
    } 
 
    /*******************************************************[高级查询]开始********************************************************************************* */ 
    // 组件挂载时获取枚举数据  
    onMounted(() => {  
      fetchEnumData()  
      resetQuery(); 
    })  
    // 新增的查询条件  
    const queryForm = ref({ searchVal: '',str_searchFormInputAttrs:[],searchVal_FilterMode:'' });    
    // 定义响应式查询数据   
    const _curHighQueryData = ref({ searchVal: '',str_searchFormInputAttrs:[],searchVal_FilterMode:'' });    
    // 新版的查询方法(主页面中的按钮【查询】)  
    const handleQueryForMain = async () => {  
      setValueForCurHighQueryData(_curHighQueryData,queryForm,_searchFormInputAttrs);  
      tableRef.value.getList(_curHighQueryData.value)  
    }  
    // 新版的查询方法(高级查询中的按钮【查询】)  
    const handleQuery = async (extraParams = {}) => {  
      let filteredData = GetFilteredData(extraParams,queryForm,_searchFormInputAttrs,_curHighQueryData); 
      tableRef.value.getList(filteredData)  
    }  
    // 新版的查询重置  
    const resetQuery = () => {  
      initQueryForm(queryForm,_searchFormInputAttrs,FILTER_MODE_OPTIONS_STRING_KEY); 
      setValueForCurHighQueryData(_curHighQueryData,queryForm,_searchFormInputAttrs);  
    }  
     //新版的导出方法  
     const handleExport=()=>{  
      onExport(_curHighQueryData.value);  
    }  
    // 新版的查询弹出框关闭方法  
    const closeQuery = (extraParams={}) => {  
      GetFilteredData(extraParams,queryForm,_searchFormInputAttrs,_curHighQueryData); 
    }  
    /*******************************************************[高级查询]结束********************************************************************************* */  
 
    /** 
     * @returns 表格 
     */ 
    const RenderBaseTable = (props: RenderTableType) => { 
      const { 
        url, 
        dataSource, 
        isDrag, 
        isChecked, 
        isHidePagination, 
        params, 
        autoHeight, 
      } = props 
 
      return ( 
        <div 
          class={{ 
            [styles.workTaskList]: true, 
          }} 
        > 
          <BaseTable 
            ref={tableRef} 
            url={url} 
            sortUrlTpl="/api/v1/PipeLineLems/workTask/{id}/adjustsort/{sort}" 
            v-model:dataSource={dataSource.value} 
            columns={columns} 
            contextMenu={contextMenu} 
            params={params} 
            isDrag={isDrag} 
            isChecked={isChecked} 
            autoHeight={autoHeight} 
            onCheck={onCheck} 
            onRowClick={onRowClick} 
            isHidePagination={isHidePagination} 
            pageSize={20} 
            v-slots={{ 
              plannedStartTime: ({ row }: any) => { 
 return ( 
   <div>  
     {row.plannedStartTime != null 
     ? dayjs(row.plannedStartTime).format('YYYY-MM-DD HH:mm:ss') 
      : '-'} 
   </div>  
  ) 
},
plannedEndTime: ({ row }: any) => { 
 return ( 
   <div>  
     {row.plannedEndTime != null 
     ? dayjs(row.plannedEndTime).format('YYYY-MM-DD HH:mm:ss') 
      : '-'} 
   </div>  
  ) 
},
creationTime: ({ row }: any) => { 
 return ( 
   <div>  
     {row.creationTime != null 
     ? dayjs(row.creationTime).format('YYYY-MM-DD HH:mm:ss') 
      : '-'} 
   </div>  
  ) 
},
lastModificationTime: ({ row }: any) => { 
 return ( 
   <div>  
     {row.lastModificationTime != null 
     ? dayjs(row.lastModificationTime).format('YYYY-MM-DD HH:mm:ss') 
      : '-'} 
   </div>  
  ) 
},
isDeleted: ({ row }: any) => { 
 return ( 
   <div>  
     {row.isDeleted != null ? (row.isDeleted ? '是' : '否') : '-'} 
   </div>  
  ) 
},
deletionTime: ({ row }: any) => { 
 return ( 
   <div>  
     {row.deletionTime != null 
     ? dayjs(row.deletionTime).format('YYYY-MM-DD HH:mm:ss') 
      : '-'} 
   </div>  
  ) 
},
isDisabled: ({ row }: any) => { 
 return ( 
   <div>  
     {row.isDisabled != null ? (row.isDisabled ? '是' : '否') : '-'} 
   </div>  
  ) 
}, 
              name: ({ row }: any) => { 
                return row?.name ? ( 
                  <TdButton 
                    onClick={() => openDetail(row)} 
                    text={<span style="color:#5a84ff">详情</span>} 
                    icon="scale" 
                    tip={row?.name} 
                    hover 
                  > 
                    {row?.name} 
                  </TdButton> 
                ) : ( 
                  '-' 
                ) 
              }, 
            }} 
          ></BaseTable> 
        </div> 
      ) 
    } 
 
    return () => { 
      return ( 
        <div class={styles.workTaskContent}> 
          {/* 添加/编辑 */} 
          <WorkTaskDrawer 
            v-model={dialogConfig.visible} 
            title={dialogConfig.title} 
            row={current.value} 
            sort={sort.value} 
            onConfirm={onConfirmWorkTask} 
          /> 
          {/* 高级查询 */} 
          <WorkTaskQueryDrawer 
            ref="workTaskQueryDrawerRef" 
            v-model={dialogConfigForQuery.visible} 
            title={dialogConfigForQuery.title} 
            row={current.value} 
            sort={sort.value} 
            onConfirmQuery={handleQuery} 
            onRestQuery={resetQuery} 
            onClose={closeQuery} 
          /> 
 
          <div class={styles.headerContent}> 
            <div class={styles.header}> 
              <IconButton 
                v-permission="workTask-add" 
                icon="add-p" 
                onClick={onAddWorkTask} 
                type="primary" 
              > 
                添加 
              </IconButton> 
              <el-divider direction="vertical" /> 
 
              <el-upload 
                v-permission="workTask-import" 
                name="file" 
                accept=".xlsx,.xls,.csv" 
                show-file-list={false} 
                onError={onError} 
                onSuccess={onSuccess} 
                before-upload={onBeforeUpload} 
                headers={headers.value} 
                action="/api/v1/PipeLineLems/workTask/import" 
              > 
                <IconButton icon="in">导入</IconButton> 
              </el-upload> 
 
              <IconButton 
                v-permission="workTask-output" 
                icon="out" 
                onClick={handleExport} 
              > 
                导出 
              </IconButton> 
            </div> 
            <ElFormItem style={{ marginTop: '15px' }}> 
              <ElFormItem label="关键字"> 
                 <el-tooltip 
                  class="box-item" 
                  effect="dark" 
                  content={searchFormInputAttrs_Placeholder.value} 
                  placement="top-start" 
                > 
                <ElInput 
                  v-model={queryForm.value.searchVal} 
                  placeholder={searchFormInputAttrs_Placeholder.value} 
                  clearable 
                  class={styles.formItem} 
                /> 
                </el-tooltip> 
              </ElFormItem> 
              <ElFormItem label="" style="width:100px;">  
                   <ElSelect 
                                v-model={queryForm.value.searchVal_FilterMode} 
                                placeholder="请选择" 
                                class={styles.formItem} 
                              > 
                                {FILTER_MODE_OPTIONS_STRING_KEY.map((option) => ( 
                                  <ElOption 
                                    key={option.value} 
                                    label={option.label} 
                                    value={option.value} 
                                  /> 
                                ))} 
                              </ElSelect> 
              </ElFormItem>  
              <IconButton type="primary" icon="search" onClick={handleQueryForMain}> 
                查询 
              </IconButton> 
              {/* <IconButton style="" icon="refresh" onClick={resetQuery}> 
                重置 
              </IconButton> */} 
              <IconButton 
                v-permission="workTask-add" 
                icon="search" 
                onClick={onAdvancedQuery} 
                type="primary" 
              > 
                高级查询 
              </IconButton> 
            </ElFormItem> 
          </div> 
 
          <RenderBaseTable 
            url="/api/v1/PipeLineLems/workTask/page" 
            dataSource={dataSource} 
            isChecked={true} 
            isDrag={true} 
          /> 
        </div> 
      ) 
    } 
  }, 
})