159 lines
4.1 KiB
Vue
159 lines
4.1 KiB
Vue
<template>
|
|
<view>
|
|
<!-- 安灯报警 -->
|
|
<uni-card class="card-box">
|
|
<uni-forms ref="formRef" :rules="rules" :modelValue="formData" label-width="80px">
|
|
<uni-forms-item label="线别" name="lineCode">
|
|
<uni-data-select v-model="formData.lineCode" placeholder="请选择线别" :localdata="lineCodeOptions"></uni-data-select>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="故障类型" name="faultDict">
|
|
<uni-data-select v-model="formData.faultDict" placeholder="请选择故障类型" :localdata="andonTypeOptions"></uni-data-select>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="故障内容" name="faultContext">
|
|
<uni-easyinput trim="all" type="textarea" autoHeight v-model="formData.faultContext" placeholder="请输入故障内容"></uni-easyinput>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="报警人" name="askPerson">
|
|
<uni-easyinput trim="all" v-model="formData.askPerson" placeholder="请输入报警人"></uni-easyinput>
|
|
</uni-forms-item>
|
|
</uni-forms>
|
|
</uni-card>
|
|
<!-- <view>
|
|
<button type="primary" @click="showSystemAlertAndVibrate">弹出信息与震动</button>
|
|
</view> -->
|
|
<view class="bottom-box">
|
|
<button :disabled="loading" type="primary" @click="submit">提交安灯报警信息</button>
|
|
</view>
|
|
|
|
<!-- 消息 -->
|
|
<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>
|
|
</template>
|
|
|
|
<script>
|
|
import * as AndonApi from '@/api/andon/index.js';
|
|
export default {
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
dialogRef: null,
|
|
dialogData: {
|
|
title: '提示',
|
|
content: '',
|
|
type: 'error'
|
|
},
|
|
formRef: null,
|
|
clearForm: {},
|
|
formData: {
|
|
// 产线
|
|
lineCode: '1',
|
|
// 报警人
|
|
askPerson: '',
|
|
// 故障类型
|
|
faultDict: '物料异常',
|
|
// 故障内容
|
|
faultContext: ''
|
|
},
|
|
rules: {
|
|
lineCode: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: '请选择线别'
|
|
}
|
|
]
|
|
},
|
|
faultDict: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: '请选择故障类型'
|
|
}
|
|
]
|
|
}
|
|
},
|
|
lineCodeOptions: [
|
|
{ value: '1', text: '1号线' },
|
|
{ value: '2', text: '2号线' },
|
|
{ value: '3', text: '3号线' },
|
|
{ value: '4', text: '4号线' }
|
|
],
|
|
andonTypeOptions: [
|
|
{ value: '人员异常', text: '人员异常' },
|
|
{ value: '设备异常', text: '设备异常' },
|
|
{ value: '物料异常', text: '物料异常' }
|
|
]
|
|
};
|
|
},
|
|
onLoad() {
|
|
this.init();
|
|
},
|
|
methods: {
|
|
init() {
|
|
this.clearForm = JSON.parse(JSON.stringify(this.formData));
|
|
this.getLineCodeOptions();
|
|
this.getAndonTypeOptions();
|
|
},
|
|
clear() {
|
|
this.formData = JSON.parse(JSON.stringify(this.clearForm));
|
|
},
|
|
getLineCodeOptions() {
|
|
AndonApi.getAllRoute().then((res) => {
|
|
const { code, data } = res;
|
|
if (code === 200) {
|
|
this.lineCodeOptions = data.map((item) => {
|
|
return {
|
|
text: item.name,
|
|
value: item.code
|
|
};
|
|
});
|
|
}
|
|
});
|
|
},
|
|
getAndonTypeOptions() {
|
|
AndonApi.GetAndonAlarmTypeDict().then((res) => {
|
|
const { code, data } = res;
|
|
if (code === 200) {
|
|
this.andonTypeOptions = data.map((item) => {
|
|
return {
|
|
text: item.name,
|
|
value: item.name
|
|
};
|
|
});
|
|
}
|
|
});
|
|
},
|
|
submit() {
|
|
this.$refs.formRef
|
|
.validate()
|
|
.then((formData) => {
|
|
AndonApi.CallHandle(formData).then((res) => {
|
|
const { code, data } = res;
|
|
if (code === 200) {
|
|
if (data > 0) {
|
|
this.dialogData.type = 'success';
|
|
this.dialogData.title = '提交成功';
|
|
this.dialogData.content = '安灯报警信息提交成功';
|
|
this.$refs.dialogRef.open();
|
|
this.clear();
|
|
} else {
|
|
this.dialogData.type = 'error';
|
|
this.dialogData.title = '提交失败';
|
|
this.dialogData.content = '安灯报警信息提交失败';
|
|
this.$refs.dialogRef.open();
|
|
}
|
|
}
|
|
});
|
|
})
|
|
.catch((err) => {});
|
|
},
|
|
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style></style>
|