guoyujie
9 天以前 a6c698f7418c1b0ea6202f068993d74a3347b0e6
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
<template>
    <view style="width: 100%;height: 100%;">
        <view >
            <uni-datetime-picker
             @change='changeTime'
            v-model="datetimerange" 
            type="daterange" 
            rangeSeparator="/" />
        </view>
        <uni-table  border stripe  style='width:100%;height: 100%;overflow: auto;'>
            <uni-tr>
                <uni-th  align="center">编辑</uni-th>
                <uni-th v-for='(item,keys,index) in reportingWorkTitle'  align="center">{{item}}</uni-th>
            </uni-tr>
            <uni-tr v-for="items in reportingWorkList">
                <uni-td  align="center">
                        <button 
                        @click='deleteReportingWorkClick(items.reportingWorkId,items.processId)'
                        class="uni-button" 
                        size="mini" 
                        type="warn">删除</button>
                </uni-td>
                <uni-td align="center" v-for='(item,keys) in reportingWorkTitle'>{{items[keys]}}</uni-td>
                
            </uni-tr>
        </uni-table>
    </view>
    <view>
        <!-- 提示信息弹窗 -->
        <uni-popup ref="message" type="message">
            <uni-popup-message :type="msgType" :message="messageText" :duration="2000" />
        </uni-popup>
    </view>
    
    <uni-popup ref="popup" type="dialog">
        <uni-popup-dialog mode="base"
        :title="'提示'"
         type='warn'
         content="确定删除报工!" 
        :before-close="true" 
        @close="close"
        @confirm="confirm"/>
    </uni-popup>
</template>
 
<script setup>
    import { computed, onMounted,ref, watch } from 'vue'
    import request from '../../utils/request'
    import userInfo from '@/stores/userInfo'
    const message = ref(null)
    const msgType=ref('success')
    const messageText=ref('')
    const popup = ref(null)
    
    const store=userInfo()
    const reportingWorkList = ref([])
    const reportingWorkTitle = ref({
        reportingWorkId:"报工编号",
        processId:'流程卡',
        thisProcess:'工序',
        thisCompletedQuantity:'完工',
        thisWornQuantity:'次破',
        creator:'班组'
    })
    
    //点击删除按钮
    let reportingWorkId = ref(null)
    let processId = ref(null)
    
    const datetimerange = ref([null,null])
    
    onMounted(async() => {
        await getReportingWorkList()
    })
    
    const changeTime = () => {
        getReportingWorkList()
    }
    
    const getReportingWorkList = async () => {
        const obj = {
            userId:store.user.userId,//store.user.userId
            process:store.user.address,//
            searchDate:datetimerange.value
        }
        await request.post("/reportingWork/selectReportingWorkRecordByPhone",obj).then(res => {
            datetimerange.value = res.data.date
            reportingWorkList.value = res.data.data
        }).catch(err => {
            uni.showModal({
                title: '提示',
                content: err,
                showCancel:false
            });
        })
    }
    const deleteReportingWorkClick = (reportingWorkId1,processId1) => {
        reportingWorkId.value = reportingWorkId1
        processId.value = processId1
        popup.value.open()
    }
    
    const deleteReportingWork = (reportingWorkId,processId) => {
        processId=processId.split('/')[0];
        request.post(`/reportingWork/deleteWork/${reportingWorkId}/${processId}/${store.user.address}/${store.user.userId}/${store.user.userName}`).then(async res => {
            if(res.code==='200' && res.data===true){
                
                await getReportingWorkList()
                messageToggle('success','删除成功')
            }else{
                messageToggle('error','删除失败,请检查下工序是否已报工或者已补片返工')
            }
        }).catch(err => {
            uni.showModal({
                title: '提示',
                content: err,
                showCancel:false
            });
        })
    }
    
    //提示打开
    const messageToggle = (type,msg) =>{
        msgType.value = type
        messageText.value = msg
        message.value.open()
    }
    
    const close = async () => {
        await popup.value.close()
        reportingWorkId.value = null
        processId.value = null
    }
    
    const confirm = async () => {
        await popup.value.close()
        await deleteReportingWork(reportingWorkId.value,processId.value)
        reportingWorkId.value = null
        processId.value = null
    }
</script>
 
<style>
 
</style>