zhaojiale
2022-09-16 357231819223f9241077700ed692f9b5fc58f02c
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
<template>
    <div>
        <el-form :model="ruleForm" status-icon label-width="20px" class="topTitle">
            <el-row>
                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="ruleForm.searchParams.qName" size="default" placeholder="安全目标指标" />
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="ruleForm.searchParams.indexNum" size="default" placeholder="目标指标编号" />
                    </el-form-item>
                </el-col>
                <el-col :span="16">
                    <el-form-item>
                        <el-button type="primary" size="default" @click="listApi">查询</el-button>
                        <el-button size="default" @click="resetForm">重置</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div class="minCenter">
            <el-tabs v-model="ruleForm.searchParams.targetType" class="demo-tabs" @tab-click="handleClick">
                <div class="btns">
                    <div>
                        <el-button type="primary" size="default" :icon="Plus" @click="openD('新建')">新建</el-button>
                        <el-button type="danger" :disabled="danger" size="default" @click="onDeleteAll" :icon="Delete" plain>删除</el-button>
                    </div>
                    <div>
                        <!-- <el-button size="default" :icon="Upload" @click="upButton"></el-button>
                <el-button size="default" :icon="Download"></el-button>
                <el-button size="default" :icon="Refresh"></el-button> -->
                    </div>
                </div>
                <el-tab-pane label="目标定制(年)" name="1"> </el-tab-pane>
                <el-tab-pane label="目标定制(月)" name="2"></el-tab-pane>
                <el-tab-pane label="目标定制(半年)" name="3"></el-tab-pane>
                <el-tab-pane label="目标定制(季度)" name="4"></el-tab-pane>
            </el-tabs>
            <el-table ref="multipleTableRef" :data="tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <el-table-column label="序号" align="center" type="index" width="70" />
                <el-table-column type="selection" align="center" width="55" />
                <el-table-column label="安全目标指标" align="center" property="qName" sortable />
                <el-table-column property="indexNum" align="center" label="目标指标编号" sortable />
                <el-table-column property="year" label="年度" align="center" sortable show-overflow-tooltip />
                <el-table-column property="value" label="指标值" align="center" sortable show-overflow-tooltip />
                <el-table-column property="level" label="指标级别" align="center" sortable show-overflow-tooltip >
                <template #default="scope">
                    <span v-if="scope.row.level == 1">公司级</span>
                    <span v-if="scope.row.level == 2">部门分厂级</span>
                    <span v-if="scope.row.level == 3">工段班组级</span>
                </template>
                </el-table-column>
                <el-table-column property="completeDate" label="完成期限" align="center" :formatter="timeDate" sortable show-overflow-tooltip />
                <el-table-column label="状态" align="center" sortable show-overflow-tooltip>
                    <template #default="scope">
                        <span v-if="scope.row.divideStatus == 1">已分解</span>
                        <span v-if="scope.row.divideStatus == 2">未分解</span>
                    </template>
                </el-table-column>
                <el-table-column property="memo" label="备注信息" align="center" sortable show-overflow-tooltip />
                <el-table-column label="操作" align="center" width="300" sortable show-overflow-tooltip>
                    <template #default="scope">
                        <el-button link type="primary" size="default" :icon="View" @click="openD('查看', scope.row.id)">查看</el-button>
                        <el-button link type="primary" size="default" :icon="View" @click="openD('修改', scope.row.id)">修改</el-button>
                        <el-button link type="primary" size="default" :icon="Delete" @click="onDelete(scope.row.id)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pages">
                <el-pagination
                    v-model:currentPage="currentPage4"
                    v-model:page-size="pageSize4"
                    :page-sizes="[10, 20, 30, 40]"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                />
            </div>
            <dailogAdd ref="openAdd" @navAddorUpdata="onAddorUpdata"></dailogAdd>
            <upData ref="upShow"></upData>
        </div>
    </div>
</template>
<script lang="ts">
import dailogAdd from './component/dailogAdd.vue';
import {timeDate} from '/@/assets/index.ts'
import upData from '../../../components/updata/updata.vue';
import { ref, toRefs, reactive, onMounted, defineComponent } from 'vue';
import { ElMessageBox, ElMessage, ElButton, ElInput, TabsPaneContext, FormInstance } from 'element-plus';
import { Plus, Delete, Upload, Download, Refresh, View } from '@element-plus/icons-vue';
import { goalManagementApi } from '/@/api/goalManagement';
export default defineComponent({
    components: { ElButton, ElInput, dailogAdd, upData },
    setup() {
        // 搜索条件
        const ruleForm = reactive({
            pageSize: 10,
            pageIndex: 1,
            searchParams: {
                qName: '', ////安全目标指标
                indexNum: '', ////目标指标编号
                targetType: '1', ////指标类型 1:年指标 2:月指标
                divideStatus: '', ////分解状态 1:已分解 2:未分解
            },
        });
        // 重置
        const resetForm = () => {
            ruleForm.searchParams.qName = '';
            ruleForm.searchParams.indexNum = '';
            listApi()
        };
        const listApi = () => {
            goalManagementApi()
                .getTargetMngList(ruleForm)
                .then((res) => {
                    if (res.data.code == 200) {
                        tableData.value = res.data.data;
                        currentPage4.value = res.data.pageIndex;
                        pageSize4.value = res.data.pageSize;
                        total.value = res.data.total;
                    } else {
                        ElMessage.error(res.data.msg);
                    }
                });
        };
        //
        const handleClick = (val: any) => {
            let targetType = JSON.parse(JSON.stringify(val));
            ruleForm.searchParams.targetType = targetType.paneName;
            listApi();
        };
        onMounted(() => {
            listApi();
        });
        const onAddorUpdata = () => {
            listApi();
        };
        // 表格
        const tableData = ref();
        const currentPage4 = ref();
        const pageSize4 = ref();
        const total = ref();
        const small = ref(false);
        const disabled = ref(false);
        const background = ref(false);
        const handleSizeChange = (val: number) => {
            // console.log(`${val} items per page`);
            ruleForm.pageSize = val;
            listApi();
        };
        const handleCurrentChange = (val: number) => {
            // console.log(`current page: ${val}`);
            ruleForm.pageIndex = val;
            listApi();
        };
        // 弹窗
        const openAdd = ref();
        const openD = (title: String, id: number) => {
            openAdd.value.openDialog(title, ruleForm.searchParams.targetType, id);
        };
        // 删除
        const onDelete = (id: number) => {
            let arr=[]
            arr.push(id)
            ElMessageBox.confirm('确定删除所选项吗?', 'Warning', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    goalManagementApi()
                        .getTargetMngDelete(arr)
                        .then((res) => {
                            if (res.data.code == 200) {
                                ElMessage({
                                    message: res.data.msg,
                                    type: 'success',
                                });
                                listApi();
                            } else {
                                ElMessage.error(res.data.msg);
                            }
                        });
                })
                .catch(() => {
                    ElMessage({
                        type: 'info',
                        message: 'Delete canceled',
                    });
                });
        };
        // 批量删除
        // const warning = ref(true);
        const danger = ref(true);
        const deletAll = ref();
        const handleSelectionChange = (val: any) => {
            let valId = JSON.parse(JSON.stringify(val));
            let arr = [];
            for (let i = 0; i < valId.length; i++) {
                arr.push(valId[i].id);
            }
            deletAll.value = arr
            if (val.length == 1) {
                // warning.value = false;
                danger.value = false;
            } else if (val.length == 0) {
                // warning.value = true;
                danger.value = true;
            } else {
                // warning.value = true;
                danger.value = false;
            }
        };
        const onDeleteAll = () => {
            ElMessageBox.confirm('确定删除所选项吗?', 'Warning', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    goalManagementApi()
                        .getTargetMngDelete(deletAll.value)
                        .then((res) => {
                            if (res.data.code == 200) {
                                ElMessage({
                                    message: res.data.msg,
                                    type: 'success',
                                });
                                listApi();
                            } else {
                                ElMessage.error(res.data.msg);
                            }
                        });
                })
                .catch(() => {
                    // ElMessage({
                    //     type: 'info',
                    //     message: 'Delete canceled',
                    // });
                });
        };
        // 上传
        // const upShow = ref();
        // const upButton = () => {
        //     upShow.value.openDialog();
        // };
        return {
            timeDate,
            tableData,
            currentPage4,
            pageSize4,
            total,
            handleSizeChange,
            handleCurrentChange,
            handleClick,
            openAdd,
            openD,
            // upShow,
            // upButton,
            small,
            disabled,
            background,
            Plus,
            Delete,
            Upload,
            Download,
            Refresh,
            View,
            listApi,
            ruleForm,
            resetForm,
            onAddorUpdata,
            onDelete,
            handleSelectionChange,
            deletAll,
            danger,
            onDeleteAll,
        };
    },
});
</script>
<style scoped>
.topTitle {
    background-color: #fff;
    padding: 20px 0px 20px 0px;
}
.minCenter {
    width: 100%;
    background-color: #fff;
    margin-top: 10px;
    padding: 0 20px;
}
.btns {
    padding: 0px 0px 10px 0px;
    display: flex;
    justify-content: space-between;
}
.pages {
    padding: 20px 0;
    display: flex;
    justify-content: right;
}
</style>