web
2025-03-17 56d13900e2d74eeb9e22a9d86dc929640a676f6f
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
<script setup name="Post">
import {facilityExamineRecordApi} from "@/api/examine/record/index.js";
import setPostParams from "@/utils/searchParams.js";
import facilityApi from "@/api/facility/index.js";
const {proxy} = getCurrentInstance();
/**
 * 搜索
 */
const queryParams = ref({
    name:''
})
/** 搜索操作 */
function handleQuery() {
    getList({keywords:queryParams.value.name})
}
/** 表单重置 */
function reset() {
    form.value = {
        facilityCode: '',
        facilityName: '',
        facilityUrl: '',
    };
    proxy.resetForm("postRef");
}
/**
 * 绑定相关
 */
//绑定数据
const facilityExamineData = ref({
    facilityExamineId:'',
 
})
//已选
/**
 * 重置
 */
const resetQuery = () =>{
    queryParams.value.name = ''
    getList()
}
/** 列表 */
const route = useRoute();
const tableData = ref([]); //初始化列表
const loading = ref(true); //加载状态
const total = ref(0);
const open = ref(false);
const form = ref({});
 
/** 表头 */
let tableHeader = ref({
    content: '巡检内容',
    inspectUrl: '巡检图片',
    resultTypeView: '执行结果',
    inspectUser: '巡检人员',
    createTimeView: '创建时间',
})
//分页
const pageParam = ref({
    total:0,
    limit:10,
    page:1,
})
/** 新增按钮操作 */
async function handleAdd() {
    reset();
    open.value = true;
    title.value = "新增";
    console.log('form',form.value)
}
 
/** 修改按钮操作 */
async function handleUpdate(row) {
    reset();
    form.value = Object.assign({},row)
    open.value = true;
    title.value = "修改用户分类";
}
 
/** 删除按钮操作 */
function handleDelete(row) {
    proxy.$modal.confirm('是否确认删除名称为"' + row.contact + '"的数据项?').then(function () {
        return facilityApi().remove(row.id);
    }).then(() => {
        getList();
        proxy.$modal.msgSuccess("删除成功");
    }).catch(() => {
    });
}
 
/** 获取列表 */
const getList = async (val) => {
    loading.value = true;
    let postParam = setPostParams(val)
    let res = await facilityExamineRecordApi().search(postParam)
    loading.value = false;
    if (res.code == 200 && res.data.list.length > 0) {
        tableData.value = res.data.list;
        tableData.value.forEach((item) => {
            if (item.resultType == 1) {
                item.resultType = '正常'
            } else if (item.resultType == 2) {
                item.resultType = '异常'
            }
        })
        pageParam.value.total = res.data.total;
        pageParam.value.page = res.data.page;
        pageParam.value.limit = res.data.limit;
    }
}
//上传文件,添加图片地址信息
const uploadData = (data) => {
    form.value.inspectUrl = data.toString();
}
/** 提交按钮 */
function submitForm() {
    proxy.$refs["postRef"].validate(valid => {
        if (valid) {
            // form.value.contactPhone = Number(form.value.contactPhone)
 
            if (form.value.id != undefined) {
                facilityExamineRecordApi().modify(form.value).then(res => {
                    proxy.$modal.msgSuccess("修改成功");
                    open.value = false;
                    getList();
                }).catch(() => {
                    open.value = false;
                    proxy.$modal.msgError("修改失败");
                });
            } else {
                facilityExamineRecordApi().create(form.value).then(res => {
                    proxy.$modal.msgSuccess("新增成功");
                    open.value = false;
                    getList();
                }).catch(() => {
                    open.value = false;
                    proxy.$modal.msgError("新增失败");
                });
                ;
            }
        }
    });
}
/** 绑定按钮操作 */
const handleband = async(row) =>{
    facilityExamineData.value.facilityExamineId = row.id
    await getParamList()
    openParamForm.value = true
}
/** 取消按钮 */
function cancel() {
    open.value = false;
    openParamForm.value = false;
    reset();
}
getList();
</script>
<template>
    <div class="app-container">
        <!--搜索框-->
        <el-form :model="queryParams" ref="queryRef" :inline="true">
            <el-form-item label="" prop="name">
                <el-input
                        v-model="queryParams.name"
                        placeholder="请输入计划名称"
                        clearable
                        style="width: 200px"
                        @keyup.enter="handleQuery"
                />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="Plus"
                    @click="handleAdd"
                >新增
                </el-button>
            </el-col>
        </el-row>
        <!--表格及分页-->
        <el-table v-loading="loading" :data="tableData">
            <el-table-column
                    v-for="(item, key, index) of tableHeader"
                    :prop="key.toString()"
                    :label="item"
                    :key="index"
                    align="center"
            >
                <template #default="scope">
                    <div v-if="key.toString() === 'inspectUrl'"> <img :src="scope.row.inspectUrl" alt="" style="width:50px;height: 50px"></div>
                </template>
            </el-table-column>
            <el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width">
                <template #default="scope">
                    <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
                    <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination
            v-show="pageParam.total > 0"
            :total="pageParam.total"
            v-model:page="pageParam.page"
            v-model:limit="pageParam.limit"
            @pagination="getList"
        />
        <!-- 添加表单弹窗 -->
        <el-dialog :title="title" v-model="open"  center>
            <el-form class="form-box" ref="postRef" :model="form" :rules="rules" label-width="90px">
                <el-form-item label="巡检内容" prop="content">
                    <el-input v-model="form.content" type="textarea" placeholder="请输入内容" />
                </el-form-item>
                <el-form-item label="图片上传" prop="inspectUrl">
                    <upload-icons @uploadData="uploadData" :imageList="form.inspectUrl" :limit="1"
                                  :disabled='isDetail ? true : false'></upload-icons>
                    <span style="display: block;">(请上传1张现场图片)</span>
                </el-form-item>
                <el-form-item label="备注" prop="remark">
                    <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
                </el-form-item>
                <el-form-item label="巡检状态" prop="resultType">
                    <el-radio-group v-model="form.resultType">
                        <el-radio-button value="1">正常</el-radio-button>
                        <el-radio-button value="2">异常</el-radio-button>
                    </el-radio-group>
                </el-form-item>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="submitForm">确 定</el-button>
                    <el-button @click="cancel">取 消</el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>