add:设备告警修改流程对接

This commit is contained in:
zhaohy
2024-07-23 08:35:51 +08:00
parent c390535202
commit 5c5acf6942
8 changed files with 89 additions and 190 deletions

View File

@@ -11,25 +11,24 @@
<a-tabs>
<a-tab-pane key="1" tab="更新状态">
<div style="width: 100%; padding: 24px">
<a-form ref="formRef" :model="infoObject" :rules="rules">
<a-form-item ref="state" label="当前状态" createName="state">
<a-form ref="formRef" :model="infoObject">
<a-form-item ref="state" label="当前状态" name="state">
<a-select
v-model:value="infoObject.state"
show-search
placeholder="请选择设备点位"
placeholder="请选择当前状态"
style="width: 85%"
:options="stateOptions"
:disabled="showEdit"
:filter-option="filterDevicePoint" />
:disabled="showEdit" />
<ns-icon
size="20"
@click="changeShowEdit"
style="margin-left: 20px"
:createName="showEdit ? 'bianji' : 'baocun'" />
:name="showEdit ? 'bianji' : 'baocun'" />
</a-form-item>
<a-form-item label="备注" createName="desc">
<a-form-item label="备注" name="remarks">
<a-textarea
v-model:value="infoObject.desc"
v-model:value="infoObject.remarks"
placeholder="请输入异常描述"
:disabled="showEdit"
style="width: 85%"
@@ -61,49 +60,49 @@
export default defineComponent({
components: { NsSteps },
setup() {
setup(props, { emit }) {
const visible = ref(false);
const showEdit = ref(true);
const infoObject = ref({});
const equipmentAlarm = ref({});
const stateOptions = ref();
const logList = ref([
{ createName: '李四', state: 3, createTime: '2024-03-10 10:00:00', desc: '完成' },
{ createName: '王五', state: 5, createTime: '2024-03-10 10:00:00' },
{ createName: '王五', state: 4, createTime: '2024-03-10 10:00:00' },
{ createName: '王五', state: 2, createTime: '2024-03-10 10:00:00', desc: '创建工单' },
{ createName: '赵六', state: 1, createTime: '2024-03-10 10:00:00' },
]);
const logList = ref([]);
const config = ref({
size: logList.value.length,
dataSource: logList.value,
});
const handleClose = () => {
equipmentAlarm.value = P;
showEdit.value = true;
equipmentAlarm.value = {};
infoObject.value = {};
visible.value = false;
};
const btnClick = () => {
NsMessage.success('操作成功');
delete infoObject.value.createTime;
console.log(infoObject.value, equipmentAlarm.value, '操作');
console.log('btnClick');
infoObject.value.alarmEquipmentLogId = equipmentAlarm.value.id;
if (equipmentAlarm.value.createWorkOrder === 0) {
http.post(equipmentAlarmApi.noCreatOrUpdateLog, infoObject.value).then((res) => {
if (res.msg === 'success') {
NsMessage.success('操作成功');
showEdit.value = true;
equipmentAlarm.value = {};
infoObject.value = {};
visible.value = false;
emit('logAdd', null);
}
});
}
};
//修改状态
const changeShowEdit = () => {
if (equipmentAlarm.value.createWorkOrder === 1) {
// 未生成工单
if (equipmentAlarm.value.createWorkOrder === 0) {
showEdit.value = !showEdit.value;
}
};
const toggle = async (data) => {
equipmentAlarm.value = { ...data };
infoObject.value = { ...logList.value[0] };
await http
.post(equipmentAlarmApi.getSelectAlarmEquipmentLogStatusProcess, {
id: data.id,
})
.then((res) => {
console.log(res);
});
visible.value = true;
if (equipmentAlarm.value.createWorkOrder === 1) {
stateOptions.value = [
{ value: 1, label: '待处理' },
@@ -120,26 +119,31 @@
{ value: 5, label: '已关闭' },
];
}
let statusMap = {
1: '待处理',
2: '处理中',
3: '已完成',
4: '超时',
5: '已关闭',
};
let colorMap = {
1: '#ff7602',
2: '#00a1e6',
3: '#04d919',
4: '#d9001b',
5: '#a6a6a6',
};
logList.value.forEach((item) => {
item.stateName = statusMap[item.state];
item.color = colorMap[item.state];
item.src = 'state-' + item.state;
});
visible.value = true;
console.log(data, 'data');
await http
.post(equipmentAlarmApi.getSelectAlarmEquipmentLogStatusProcess, {
alarmEquipmentLogId: data.id,
})
.then((res) => {
if (res.msg === 'success') {
logList.value = res.data;
infoObject.value = { ...logList.value[0] };
infoObject.value.state = infoObject.value.state.value;
let colorMap = {
1: '#ff7602',
2: '#00a1e6',
3: '#04d919',
4: '#d9001b',
5: '#a6a6a6',
};
logList.value.forEach((item) => {
item.stateName = item.state.label;
item.color = colorMap[item.state.value];
item.src = 'state-' + item.state.value;
});
config.value.dataSource = logList.value;
}
});
};
return {
infoObject,