yangys
2025-09-17 ae2c3f847da927b6124e872d8d74c0457a1eea14
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
<!--
 * @Date: 2025-06-18 09:17:09
 * @LastEditors: gaoshp
 * @LastEditTime: 2025-08-17 08:46:49
 * @FilePath: /mdmweb/src/views/flowmgr/processQuery2.vue
 
-->
<template>
    <basic-container>
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page"
        :search="query"
            @search-change="searchChange" @search-reset="searchReset" @current-change="currentChange"
            @size-change="sizeChange" @refresh-change="refreshChange"  @on-load="onLoad"
            >
            
            <template #menu-left>
            
              <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">导出</el-button>
             
          </template>
        </avue-crud>
 
    </basic-container>
</template>
 
<script>
import { getList } from '@/api/flowmgr/programonmachine.js';
import { exportBlobPost } from '@/api/common';
import NProgress from 'nprogress';
import { downloadFile } from '@/utils/util';
import 'nprogress/nprogress.css';
 
export default {
    data() {
        return {
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            query: {
               endTime: [this.getBeginDate(), this.getToday()]
            },
            form:{},
            loading: true,
            data: [],
            
            option: {
                addBtn: false,
                editBtn: false,
                delBtn: false,
                viewBtn: false,
                columnBtn: false,
                tip: false,
                searchShow: true,
                searchMenuSpan: 7,
                searchEnter:true,
                dialogWidth: '70%',
                // tree: true,
                border: true,
                index: true,
                selection: false,
                menuWidth: 100,
                menu: false,
                labelWidth: 90,
                menuSpan: 6,
                dialogClickModal: false,
                column: [
                    {
                        label: '审批时间',
                        prop: 'endTime',
                        type: 'date',
                        format: 'YYYY-MM-DD',
                        valueFormat: 'YYYY-MM-DD',
                        search: true,
                        searchRange: true,
                        hide: true,
                    },
                    
                     {
                        label: '零组件号',
                        prop: 'drawingNo',
                        search: true,
                        searchType: 'input',
                        width: 180,
                        render: ({ row }) => {
                            return h('span', {}, row?.variables?.drawingNo || '');
                        }
                    },
                    {
                        label: '工序号',
                        prop: 'processNo',
                        width: 80,
                        render: ({ row }) => {
                            return h('span', {}, row?.variables?.processNo || '');
                        }
                    },
                    {
                        label: '工序名称',
                        prop: 'processName',
                        width: 100,
                        render: ({ row }) => {
                            return h('span', {}, row?.variables?.processName || '');
                        }
                    },
                    {
                        label: '工序版次',
                        prop: 'processEdition',
                        width: 80,
                        render: ({ row }) => {
                            return h('span', {}, row?.variables?.processEdition || '');
                        }
                    },
                   {
                        label: '批次号',
                        prop: 'variables.craftEdition',
                        width: 80,
                        render: ({ row }) => {
                            return h('span', {}, row?.variables?.craftEdition || '');
                        }
                    },
                    {
                        label: '任务车间',
                        prop: 'workshop',
                        width: 80,
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.workshop || '');
                        }
                    },
                    {
                        label: '过程卡号',
                        prop: '',
                        width: 80,
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.processCard || '');
                        },
                    },
                    
                    {
                        label: '产品型号',
                        prop: '',
                        width: 100,
                        render: ({ row }) => {
                            return h('p',
                                {
                                    attrs: {},
                                    class: {},
                                    style: {},
                                }, row?.variables?.productModel)
                        },
                        renderForm: ({ row }) => {
                            return h('span', {
                                attrs: {},
                                class: {},
                                style: {},
                            }, row?.variables?.productModel || '');
                        }
                    },
                    
                    {
                        label: '机床',
                        prop: '',
                        render: ({ row }) => {
                            return h('p',
                                {
                                    attrs: {},
                                    class: {},
                                    style: {},
                                }, row?.variables?.machineCode)
                        },
                        renderForm: ({ row }) => {
                            return h('span', {
                                attrs: {},
                                class: {},
                                style: {},
                            }, row?.variables?.machineCode || '');
                        }
                    },
                    {
                        label: '创建时间',
                        prop: 'processCreateTime',
                    },
                ],
            },
            
        }
    },
    mounted() {
        const startDate = this.$dayjs().subtract(7, 'day').format('YYYY-MM-DD');
        const endDate = this.$dayjs().format('YYYY-MM-DD')
   
    },
    methods: {
        
         getToday() {
            let today = new Date();
            return `${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2, '0')}-${today.getDate().toString().padStart(2, '0')}`;
 
        },
        getBeginDate() {
            var beginDate = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
            return `${beginDate.getFullYear()}-${(beginDate.getMonth() + 1).toString().padStart(2, '0')}-${beginDate.getDate().toString().padStart(2, '0')}`;
            },
        handleExport(row, index,) {
           //确认表下载
            this.$confirm('是否导出现场编程记录?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                
                NProgress.start();
                const data = {
                    ...this.query,
                    endTimeBegin: this.query.endTimeBegin,
                    endTimeEnd: this.query.endTimeEnd,
                    //drawingNo: query.drawingNo || '',
                };
                exportBlobPost(
                    `/blade-mdm/flowmgr/programonmachine/export`,
                    data
                ).then(res => {
                    let name = res.headers['content-disposition'].split('filename=')[1]
                    name = decodeURI(name)
                    downloadFile(res.data, `${name}`);
                    NProgress.done();
                });
            });
            
 
        },
        searchChange(params, done) {
            let data = {}
            this.query = params;
            this.page.currentPage = 1;
           
            this.onLoad(this.page, data);
            done();
        },
        searchReset() {
            this.onLoad(this.page, {});
            done();
        },
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
            // this.onLoad();
        },
        sizeChange(pageSize) {
            this.page.pageSize = pageSize;
        },
        refreshChange() {
            this.onLoad(this.page, this.query);
        },
        /** * 页面加载时获取数据
         */
        onLoad(page, params = {}) {
            const data = {
                ...this.query,
                endTimeBegin: this.query?.endTime?.[0] || undefined,
                endTimeEnd: this.query?.endTime?.[1] || undefined,
                drawingNo: params.drawingNo || '',
            };
            this.loading = true;
            getList(page.currentPage, page.pageSize, Object.assign(data, params)).then(res => {
                const data = res.data.data
                this.page.total = data.total;
                this.data = data.records.map(v=> {
                    return {
                        ...v,
                    }
                });
                this.loading = false;
            }, () => {
                this.data = [];
                this.loading = false;
            }).catch(err => {
                this.data = [];
                this.loading = false;
            });
        }
    }
};
</script>
 
<style lang="scss">
.margin0 {
    margin: 0
}
</style>