2025-02-22 14:30:29 +08:00

127 lines
2.9 KiB
Vue

<template>
<!-- 故障响应 -->
<view>
<view class="refresh-box">
<button :disabled="loading" :loading="loading" type="primary" plain="true" @click="getList">刷新</button>
</view>
<uni-list>
<uni-list-item v-for="(item, index) in list" :key="index" :title="item.title" :note="item.note">
<template v-slot:footer>
<button class="button-inner" type="primary" @click="clickButton(item)">签到</button>
</template>
</uni-list-item>
</uni-list>
<!-- 消息 -->
<view>
<uni-popup ref="dialogRef" type="dialog">
<uni-popup-dialog :title="dialogData.title" :content="dialogData.content" :type="dialogData.type" cancelText="关闭"></uni-popup-dialog>
</uni-popup>
</view>
<!-- 签到确认 -->
<view>
<uni-popup ref="dialogRef2" type="dialog">
<uni-popup-dialog
before-close
:title="dialogData.title"
placeholder="请输入响应人"
mode="input"
:content="dialogData.content"
:type="dialogData.type"
cancelText="关闭"
@close="dialog2Close()"
@confirm="confirm"
></uni-popup-dialog>
</uni-popup>
</view>
</view>
</template>
<script>
import * as AndonApi from '@/api/andon/index.js';
export default {
data() {
return {
loading: false,
dialogRef: null,
dialogRef2: null,
dialogData: {
data: {},
title: '提示',
content: '',
type: 'error'
},
list: []
};
},
onLoad() {
this.init();
},
methods: {
init() {
this.getList();
},
getList() {
this.loading = true;
AndonApi.WaitingResponse().then((res) => {
if (res.code === 200) {
this.list = res.data.map((item) => {
return {
id: item.id,
title: `问题类别: ${item.faultDict}`,
note: `线别: ${item.lineCode}\n问题描述: ${item.faultContext}\n报警人: ${item.askPerson}\n报警时间: ${item.startTime}`
};
});
this.loading = false;
}
});
},
clickButton(item) {
this.dialogData.title = '签到确认';
this.dialogData.data = JSON.parse(JSON.stringify(item));
this.$refs.dialogRef2.open();
},
dialog2Close() {
this.$refs.dialogRef2.close();
},
// 确认签到
confirm(val) {
if (val === '' || val === null) {
this.$modal.showToast('请输入响应人');
return;
}
const params = {
id: this.dialogData.data.id,
responsePerson: val
};
AndonApi.SignIn(params).then((res) => {
if (res.code === 200) {
this.dialog2Close();
this.dialogData.type = 'success';
this.dialogData.title = '签到结果';
this.dialogData.content = '签到成功';
this.$refs.dialogRef.open();
} else {
this.dialogData.type = 'error';
this.dialogData.title = '签到结果';
this.dialogData.content = '签到失败';
this.$refs.dialogRef.open();
}
this.getList();
});
}
}
};
</script>
<style scoped>
.refresh-box {
margin: 10px;
}
.button-inner {
display: flex;
align-items: center;
justify-content: center;
}
</style>