lzhe
2024-06-06 a2441175073f8b09a7eff29effd7e3e617de2f7d
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<!--
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-05-24 18:18:17
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div class="user-main">
        <div class="user-top">
            <div class="noteTop"> 
                <import-table class="marginR12" :exportUrl="exportUrl" :uploadUrl="uploadUrl"></import-table>
                <el-button type="primary" @click="getExport">导出</el-button>
                <el-button type="danger" plain @click="delData">删除</el-button>
            </div>
            <el-form :inline="true" :model="searchData" label-width="80px" style="width: 381px;">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="状态">
                            <el-select v-model="searchData.status" style="width: 100%" @change="searchChange">
                                <el-option key="1" label="启用" value="1"/>
                                <el-option key="0" label="停用" value="0"/>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="">
                            <el-input v-model="searchData.keyword" placeholder="请输入搜索内容" clearable style="width: 100%" @change="searchChange"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <div class="user-bottom">
            <div class="user-table">
                <div class="addLeftData" @click="addLeftData">+ 快速创建</div>
                <el-row style="margin-top: 12px;margin-bottom: 12px;" v-if="isAddData0">
                    <el-col :span="4">
                        <el-input v-model="addData0.name" size="small" placeholder="工序名称" style="padding-right: 20px;"></el-input>
                    </el-col>
                    <el-col :span="4">
                        <el-select v-model="addData0.type" placeholder="工种" size="small" style="padding-right: 20px;">
                            <el-option v-for="item in typeList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey"/>
                        </el-select>
                    </el-col>
                    <el-col :span="4">
                        <el-input v-model="addData0.description" size="small" placeholder="工序描述" style="padding-right: 20px;"></el-input>
                    </el-col>
                    <el-col :span="4">
                        <el-select v-model="addData0.status" size="small" style="padding-right: 20px;">
                            <el-option key="1" label="启用" value="1"/>
                            <el-option key="0" label="停用" value="0"/>
                        </el-select>
                    </el-col>
                    <el-col :span="4">
                        <el-button type="primary" size="small" @click="addData0Submit0">确定</el-button>
                        <el-button size="small" @click="addDataCencel0">取消</el-button>
                    </el-col>
                </el-row>
                <el-table ref="multipleTableRef0" :data="tableData0" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange" @row-click="rowClick">
                    <el-table-column type="selection" width="55" />
                    <el-table-column prop="code" label="工序编号"></el-table-column>
                    <el-table-column prop="name" label="工序名称"></el-table-column>
                    <el-table-column prop="typeName" label="工种"></el-table-column>
                    <el-table-column prop="description" label="工序描述"></el-table-column>
                    <el-table-column prop="status" label="状态">
                        <template #default="scope">
                            <span>{{ scope.row.status == "1"?"启用":"停用" }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column fixed="right" label="操作">
                        <template #default="scope">
                            <el-button type="text" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination
                    style="margin-top: 12px;"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage4"
                    :page-sizes="[15, 50, 100]"
                    :page-size="15"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total0">
                </el-pagination>
            </div>
            <div class="working-detail">
                <div class="container-title">工序详情</div>
                <ul>
                    <li>工序编号<span>{{workDetail.code}}</span></li>
                    <li>工序名称<span>{{workDetail.name}}</span></li>
                    <li>工种<span>{{workDetail.typeName}}</span></li>
                    <li>工序描述<span>{{workDetail.description}}</span></li>
                </ul>
                <div class="info-top-title">工位</div>
                <div class="addRightData" @click="addRightData">+ 快速创建</div>
                <el-row style="margin-top: 12px;margin-bottom: 12px;" v-if="isAddData1">
                    <el-col :span="4">
                        <el-select v-model="addData1.bizId" placeholder="工位编号" size="small" style="padding-right: 20px;">
                            <el-option v-for="item in bizIdList" :key="item.id" :label="item.code" :value="item.id"/>
                        </el-select>
                    </el-col>
                    <el-col :span="4">
                        <el-button type="primary" size="small" @click="addData0Submit1">确定</el-button>
                        <el-button size="small" @click="addDataCencel1">取消</el-button>
                    </el-col>
                </el-row>
                <el-table ref="multipleTableRef1" :data="tableData1" border style="width: 100%" class="multipleTableRef">
                    <el-table-column prop="workstationCode" label="工位编号"></el-table-column>
                    <el-table-column prop="workstationName" label="工位名称"></el-table-column>
                    <el-table-column fixed="right" label="操作">
                        <template #default="scope">
                            <el-button type="text" size="small" @click="biz_table_del(scope.row, scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
    </div>
    <!-- 删除 -->
    <el-dialog title="" v-model="delTypeModel" :width="400" destroy-on-close>
        <div>
            <div style="margin-bottom: 6px;"><span class="delIcon">!</span>请你谨慎选择!</div>
            <div style="text-indent: 24px;">删除数据会影响已关联的业务 ,若您想在已关联的业务中依然显示这些数据, 您可以选择 停用 操作。停用后此数据将不能再被新业务使用。</div>
        </div>
        <template #footer>
            <div class="footerDiv">
                <div class="delBtn" @click="delTypeDataSingle(0)">删除</div>
                <div class="delBtn" @click="delTypeDataSingle(1)">停用</div>
            </div>
        </template>
    </el-dialog>
    <!-- 删除left -->
    <el-dialog title="" v-model="delLeftModel" :width="400" destroy-on-close>
        <div>
            <div style="margin-bottom: 6px;"><span class="delIcon">!</span>请你谨慎选择!</div>
            <div style="text-indent: 24px;">删除数据会影响已关联的业务 ,若您想在已关联的业务中依然显示这些数据, 您可以选择 停用 操作。停用后此数据将不能再被新业务使用。</div>
        </div>
        <template #footer>
            <div class="footerDiv">
                <div class="delBtn" @click="delLeft(0)">删除</div>
                <div class="delBtn" @click="delLeft(1)">停用</div>
            </div>
        </template>
    </el-dialog>
</template>
<script>
    import importTable from '@/layout/components/importTable.vue'
    export default {
        name: "working",
        data(){
            return {
                delleftId: "",
                bizIdList: [],
                leftId: "",
                delTypeModel: false,
                delLeftModel: false,
                typeList: [],
                addData0: {
                    name: "",
                    type: "",
                    description: "",
                    status: "1"
                },
                addData1: {
                    bizId: "",
                    processId: "",
                    type: "1"
                },
                isAddData0: false,
                isAddData1: false,
                uploadUrl: "/api/blade-cps/employee/import-employee",
                exportUrl: "/api/blade-cps/employee/export-template",
                categoryList: [],
                selection: [],
                searchData: {
                    status: "1",
                    keyword: "",
                    current: "1",
                    size: "15"
                },
                total0: 0,
                total1: 0,
                isSaveing: false,
                dialog: {
                    save: false
                },
                tableData0: [],
                tableData1: [],
                workDetail: {
                    code: "",
                    name: "",
                    typeName: "",
                    description: ""
                }
            }
        },
        created(){
            
        },
        mounted(){
            this.getData();
            this.getTypeList();  //工种
            this.getBizIdList();  //工位编号
        },
        components: {
            importTable
        },
        methods: {
            rowClick(row, column, event) {
                this.id = row.id;
                this.getWorkDetail();
                this.getPage1();
            },
            delLeft(type) {
                var selStr = "";
                this.selection.map(item=> {
                    selStr += item.id + ","
                })
                selStr = selStr.replace(/,$/, '');
                var url = `/api/blade-cps/process/remove?processIds=${selStr}&type=${type}`;
                this.$HTTP.delete(url).then(res=> {
                    if(res.code == 200) {
                        this.$message.success("操作成功");
                        this.delLeftModel = false;
                        this.selection = [];
                        this.getData();
                    }
                })
            },
            delTypeDataSingle(type) {
                var url = `/api/blade-cps/process/remove?processIds=${this.leftId}&type=${type}`;
                this.$HTTP.delete(url).then(res=> {
                    if(res.code == 200) {
                        this.$message.success("操作成功");
                        this.delTypeModel = false;
                        this.leftId = "";
                        this.getData();
                    }
                })
            },
            addData0Submit0() {
                this.$HTTP.post(`/api/blade-cps/process/save`,this.addData0).then(res => {
                    if (res.code == 200) {
                        this.getData();
                        this.clearData0();
                    }
                })
            },
            clearData0() {
                this.isAddData0 = false;
                this.addData0 = {
                    name: "",
                    type: "",
                    description: "",
                    status: "1"
                }
            },
            addDataCencel0() {
                this.clearData0();
            },
            addData0Submit1() {
                this.addData1.processId = this.id;
                this.$HTTP.post(`/api/blade-cps/process-association/save`,this.addData1).then(res => {
                    if (res.code == 200) {
                        this.getPage1();
                        this.clearData1();
                    }
                })
            },
            clearData1() {
                this.isAddData1 = false;
                this.addData1 = {
                    bizId: "",
                    processId: "",
                    type: "1"
                }
            },
            addDataCencel1() {
                this.clearData1();
            },
            addLeftData() {
                this.isAddData0 = true;
            },
            addRightData() {
                this.isAddData1 = true;
            },
            getTypeList() {
                this.$HTTP.get(`/api/blade-system/dict/dictionary?code=work_type`).then(res => {
                    if (res.code == 200) {
                        this.typeList = res.data;
                    }
                })
            },
            getBizIdList() {
                this.$HTTP.get(`/api/blade-cps/workstation/page?workstationCode=&workstationName=&size=-1&groupId=&keyWord=`).then(res => {
                    if (res.code == 200) {
                        this.bizIdList = res.data.records;
                    }
                })
            },
            getExport() {
                this.$HTTP.get(`/api/blade-cps/process/export-process?keyword=&status=1`).then(res => {
                    if (res.code == 200) {
                        window.open(res.data.link);
                    }
                })
            },
            searchChange() {
                this.getData();
            },
            addUserSuccess() {
                this.getData();
            },
            getWorkDetail(id) {
                this.$HTTP.get(`/api/blade-cps/process/get?processId=${this.id}`).then(res=> {
                    if(res.code == 200) {
                        this.workDetail = res.data;
                    }
                })
            },
            getData() {
                this.$HTTP.get(`/api/blade-cps/process/page?status=${this.searchData.status}&keyword=${this.searchData.keyword}&current=${this.searchData.current}&size=${this.searchData.size}`).then(res=> {
                    if(res.code == 200) {
                        this.tableData0 = res.data.records;
                        if(this.tableData0.length != 0) {
                            this.id = this.tableData0[0].id;
                            this.getWorkDetail();
                            this.getPage1();
                        }else {
                            this.workDetail = {
                                code: "",
                                name: "",
                                typeName: "",
                                description: ""
                            }
                        }
                    }
                })
            },
            getPage1() {
                this.$HTTP.get(`/api/blade-cps/process-association/page?processId=${this.id}`).then(res=> {
                    if(res.code == 200) {
                        this.tableData1 = res.data.workstationList;
                    }
                })
            },
            //删除
            table_del(row) {
                this.leftId = row.id;
                this.delTypeModel = true;
            },
            //删除
            biz_table_del(row) {
                var url = `/api/blade-cps/process-association/remove?bizId=${row.id}&processId=${this.id}`;
                this.$HTTP.delete(url).then(res=> {
                    if(res.code == 200) {
                        this.$message.success("操作成功");
                        this.getPage1();
                    }
                })
            },
            handleSelectionChange(selection) {
                this.selection = selection;
            },
            delData() {
                if(this.selection.length == 0) {
                    this.$message({
                      message: '请选择至少一条数据',
                      type: 'warning'
                    });
                    return;
                }
                this.delLeftModel = true;
            },
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
                this.searchData.current = "1";
                this.searchData.size = val;
                this.getData();
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
                this.searchData.current = val;
                this.getData();
            }
        }
    }
</script>
 
<style scoped>
    .user-main {
        background-color: #f9fafb;
        border: 1px solid #dcdfe6;
        box-shadow: 0 2px 4px 0 rgba(0,0,0,.12), 0 0 6px 0 rgba(0,0,0,.04);
        margin: 8px;
        padding: 8px;
        background-color: #fff;
    }
    .user-top {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
    .user-table {
        width: 50%;
        margin-bottom: 8px;
        margin-right: 12px;
        
    }
    .working-detail {
        flex: 1;
    }
    .working-detail ul {
        overflow: hidden;
        padding: 12px 30px;
    }
    .working-detail ul li {
        width: 50%;
        float: left;
        list-style: none;
        margin-bottom:12px;
    }
    .working-detail ul li span {
        margin-left:12px;
    }
    .multipleTableRef {
        margin-bottom: 8px;
    }
    .user-bottom {
        display: flex;
    }
    .container-title {
        font-size: 16px;
        text-align: center;
        height: 38px;
        line-height: 38px;
        border-bottom: 1px solid #e2e2e2;
        background-color: #409eff;
        color: #fff;
        border-radius: 2px 2px 0 0;
        margin-bottom: 12px;
    }
    .marginR12 {
        margin-right: 12px;
    }
    .info-top-title {
        padding-left: 8px;
        border-left: 4px solid #86bffa;
        line-height: 18px;
        margin-bottom: 16px;
        font-weight: 700;
        font-size: 16px;
        color: #333;
    }
    .addLeftData,.addRightData {
        font-size: 14px;
        margin-bottom: 12px;
        color: #1573f3;
        text-decoration-line: underline;
        cursor: pointer;
    }
    .delIcon {
        color: #fff;
        background: red;
        border-radius: 50%;
        display: inline-block;
        width: 20px;
        height: 20px;
        font-size: 14px;
        text-align: center;
        line-height: 20px;
        margin-right: 6px;
    }
    .footerDiv {
        text-align: center;
    }
    .delBtn {
        color: #fff;
        width: 112px;
        height: 32px;
        display: inline-block;
        color: #fa554c;
        background-color: #fff;
        border: 1px solid #fdbbb7;
        text-align: center;
        line-height: 32px;
        cursor: pointer;
    }
 
    .delBtn:nth-child(1) {
        margin-right: 4px;
    }
    .delBtn:hover {
        background-color: #f34d5b;
        border-color: #f34d5b;
        color: #fff;
    }
</style>