ke_junjie
2025-06-04 84620534eb627e95811b971a4b552b6a177829bf
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
<template>
    <div class="tasks-of-carriers-input-page subpages-containter-box">
        <search-bar @search="onSearch" @reset="onReset">
            <el-form :inline="true" class="search-form" label-width="70px">
                <el-form-item label="任务号">
                    <el-input placeholder="请输入..." clearable class="default-form-width" v-model.trim="query.taskNo"></el-input>
                </el-form-item>
                <el-form-item label="状态">
                    <el-select placeholder="请选择..." clearable class="default-form-width" v-model="query.taskState">
                        <el-option v-for="(item,index) in selectList.status" :key="'status-'+index" :label="item.TaskStateName" :value="item.TaskState" />
                    </el-select>
                </el-form-item>
                <el-form-item label="创建日期">
                    <el-date-picker v-model="query.dateRange" clearable class="default-form-width" value-format="YYYY-MM-DD" type="daterange"></el-date-picker>
                </el-form-item>
            </el-form>
        </search-bar>
        
        <div class="table-header-row">
            <el-button type="primary" @click="onNew"><el-icon class="btn-left-icon"><e-icon-plus /></el-icon>新建入库任务</el-button>
        </div>
        
        <el-table :data="list" border stripe>
            <el-table-column width="70" label="序号" fixed>
                <template #default="scope">{{(queried.page-1)*queried.pageSize+(scope.$index+1)}}</template>
            </el-table-column>
            <el-table-column prop="TaskNo" label="任务号" min-width="160" />
            <el-table-column prop="TaskStateName" label="状态" />
            <el-table-column prop="Qty" label="数量" />
            <el-table-column prop="RealToPlace" label="货位编号" width="100" />
            <el-table-column prop="RealSourcePlace" label="入库口" />
            <el-table-column prop="FinishTime" label="入库时间" width="160" />
            <el-table-column prop="CreateTime" label="创建时间" width="160" />
            <el-table-column prop="ModifyTime" label="修改时间" width="160" />
            <el-table-column prop="CreateBy" label="创建人" width="100" />
            <el-table-column prop="ModifyBy" label="修改人" width="100" />
            <el-table-column label="操作" width="110" align="center" fixed="right">
                <template #default="scope">
                    <el-button type="danger" size="small" :disabled="scope.row.TaskState===98 || scope.row.TaskState===99" @click="onForceComplete(scope.row)">任务取消</el-button>
                </template>
            </el-table-column>
        </el-table>
        
        <div class="pagination-row">
            <el-pagination :pager-count="5" layout="total, prev, pager, next, jumper" :total="total" @current-change="onPageList" />
        </div>
        
        <add-form-modal v-model:visible="formVisible" @submitCallback="onFormSubmitCallback" />
    </div>
</template>
 
<script>
import SearchBar from '@/components/SearchBar.vue'
import AddFormModal from './compontents/AddFormModal.vue'
import {Plus} from '@element-plus/icons'
const defaultQuery = {
    materialType:2,
    materialType_FilterMode:'2',
    taskState:'',
    taskState_FilterMode:'2',
    taskNo:'',
    taskNo_FilterMode:'1',
    dateRange:[],
    createTime:[]
}
export default {
    name:'tasksOfCarriersInputPage',
    components:{SearchBar,'e-icon-plus':Plus,AddFormModal},
    data(){
        return {
            selectList:{
                status:[]
            },
            list:[],
            total:100,
            query:{...defaultQuery},
            queried:{...this.$config.pagination},
            actionRow:{},
            formVisible:false
        }
    },
    mounted() {
        this.$loading();
        this.getSelectLists((f)=>{
            if (f) {
                this.reset(false,()=>{
                    this.$loading().close();
                })
            } else {
                this.$loading().close();
            }
        })
    },
    methods:{
        /* 页面初始化 */
        init(){
            this.reset()
        },
        /* 搜索按钮 */
        onSearch(){
            this.newList()
        },
        /* 重置按钮 */
        onReset(){
            this.reset()
        },
        reset(needLoading=true,callback){
            this.query = {...defaultQuery}
            this.newList(needLoading,callback)
        },
        /* 翻页功能 */
        onPageList(page){
            this.queried.page = page;
            this.getList();
        },
        /* 表格刷新至首页 */
        newList(needLoading=true,callback){
            this.queried = {...this.query,...this.$config.pagination}
            if (this.queried.dateRange && (this.queried.dateRange instanceof Array) && this.queried.dateRange.length===2) {
                this.queried.createTime[0] = this.queried.dateRange[0] + ' 00:00:00'
                this.queried.createTime[1] = this.queried.dateRange[1] + ' 23:59:59'
            } else {
                this.queried.createTime = []
            }
            this.getList(callback,needLoading)
        },
        /* 更新数据表 */
        getList(callback,needLoading=true){
            if (needLoading) {
                this.$loading();
            }
            this.$api.post('GetTask',this.queried,{block:'taskMain'}).then((d)=>{
                this.total = d.total;
                this.list = d.list.map((currentItem)=>{
                    currentItem.FinishTime = this.$utils.project.parseTimeStr(currentItem.FinishTime)
                    currentItem.CreateTime = this.$utils.project.parseTimeStr(currentItem.CreateTime)
                    currentItem.ModifyTime = this.$utils.project.parseTimeStr(currentItem.ModifyTime)
                    return currentItem
                })
                if (needLoading) {
                    this.$loading().close();
                }
                callback && callback(true)
            }).catch((err)=>{
                if (needLoading) {
                    this.$loading().close();
                }
                callback && callback(false)
            })
        },
        getSelectLists(callback){
            this.$api.get('SalverState',{},{block:'taskMain'}).then((d)=>{
                this.selectList.status = d || []
                callback && callback(true)
            }).catch(()=>{
                callback && callback(false)
            })
        },
        onNew(){
            this.formVisible = true;
        },
        /* 新增/编辑成功提交后的回调 */
        onFormSubmitCallback(needLoading) {
            this.reset(needLoading)
        },
        onForceComplete(obj){
            let warnMsg = `确认要对任务号【${obj.TaskNo}】取消吗?`
            this.$confirm(warnMsg, '系统提示').then(()=>{
                this.forceComplete(obj)
            }).catch(()=>{});
        },
        forceComplete(obj) {
            let params = {Id:obj.Id};
            this.$loading();
            this.$api.put('TaskKill',{},{block:'taskMain'},params).then(()=>{
                this.getList(()=>{
                    this.$loading().close();
                },false)
            }).catch(()=>{
                this.$loading().close();
            })
        }
    }
}
</script>
 
<style scoped lang="scss">
</style>