<template>
|
<a-spin :spinning="confirmLoading">
|
<j-form-container :disabled="formDisabled">
|
<a-form-model
|
ref="form"
|
:model="model"
|
:rules="validatorRules"
|
slot="detail"
|
>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item
|
label="单据号"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
prop="num"
|
>
|
<a-input
|
v-model="model.num"
|
placeholder="请输入单据号"
|
></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item
|
label="是否停机维修"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
prop="isStop"
|
>
|
<a-select
|
v-model="isStop"
|
:placeholder="disableSubmit ? '' : '请选择状态'"
|
:options="isMaintenance"
|
@change="(e) => handleChange(e, 1)"
|
style="width: 100%"
|
:disabled="disableSubmit"
|
/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item
|
label="设备编码/名称/型号"
|
:labelCol="{span:6}"
|
:wrapperCol="{span:15}"
|
prop="equipmentId"
|
>
|
<a-select
|
v-model="equipmentId"
|
:placeholder="disableSubmit ? '' : '请选择设备编码 / 名称 / 型号'"
|
:options="equipmentList"
|
@change="(e) => handleChange(e, 2)"
|
:disabled="disableSubmit"
|
/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item
|
label="故障描述"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
v-model="model.faultDescription"
|
placeholder="请输入故障描述"
|
></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item
|
label="故障时间"
|
prop="name"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<j-date
|
style="width: 100%"
|
v-model="model.faultTime"
|
placeholder="请选择故障时间"
|
:showTime="true"
|
dateFormat="YYYY-MM-DD HH:mm:ss"
|
/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
label="备 注"
|
>
|
<a-textarea
|
allow-clear
|
placeholder="请输入备注"
|
v-model="model.remark"
|
/>
|
</a-form-model-item>
|
</a-col>
|
|
<a-col :span="12">
|
<a-form-model-item
|
label="故障照片"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
prop="name"
|
>
|
<j-image-upload-self
|
v-model="model.photo"
|
@ok="uploadOk"
|
>
|
</j-image-upload-self>
|
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
</a-spin>
|
</template>
|
|
<script>
|
|
import { httpAction, getAction, getFileAccessHttpUrl } from '@/api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
import JImageUploadSelf from '@/components/jeecg/JImageUploadSelf'
|
import Vue from 'vue'
|
export default {
|
name: 'MalfunctionRepaireForm',
|
components: {
|
JImageUploadSelf
|
},
|
props: {
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
}
|
},
|
data() {
|
return {
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
confirmLoading: false,
|
validatorRules: {
|
num: {
|
rules: [
|
{ required: true, message: '请输入单据号!' },
|
]
|
},
|
equipmentId: {
|
rules: [
|
{ required: true, message: '请选择设备!' },
|
]
|
},
|
faultTime: {
|
rules: [
|
{ required: true, message: '请选择故障日期!' },
|
]
|
},
|
},
|
disableSubmit: false,
|
url: {
|
add: "/eam/equipmentReportRepair/add",
|
edit: "/eam/equipmentReportRepair/edit",
|
queryById: "/eam/equipmentReportRepair/queryById",
|
equipmentList: '/eam/equipment/list'
|
},
|
isMaintenance: [
|
{ label: '是', value: true },
|
{ label: '否', value: false },
|
],
|
equipmentList: [],
|
selectStatus: 1,
|
isStop: false,
|
equipmentId: '',
|
equipmentList_bf: []
|
}
|
},
|
computed: {
|
formDisabled() {
|
return this.disabled
|
},
|
},
|
created() {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
},
|
methods: {
|
uploadOk(imgList) {
|
debugger
|
const res = this.getSrc(imgList[0])
|
this.$set(this.model, 'photo', res);
|
this.$set(this.model, 'sysUploadList', imgList);
|
},
|
|
getSrc(record) {
|
if (!record.path) {
|
return '';
|
}
|
//本地:local\Minio:minio\阿里云:alioss
|
if (record.uploadType == 'local') {
|
let ssoLoginFlag = Vue.ls.get("ssoLoginFlag");
|
let deployMode = Vue.ls.get("deployMode");
|
if (ssoLoginFlag && deployMode == "container") {
|
var baseProject = Vue.ls.get("baseProject");
|
console.log("baseProject==>" + baseProject)
|
|
var hostname = window.location.protocol + "//" + window.location.host;
|
var url = hostname + '/' + baseProject + '/sys/common/static';
|
// return getFileAccessHttpUrl(record.path + record.encodeName, url, window._CONFIG['hyperTextTransfer'])
|
return record.path + record.encodeName
|
} else {
|
//根据发布状态修改https 或 http
|
// return getFileAccessHttpUrl(record.path + record.encodeName, this.url.urlDownload, window._CONFIG['hyperTextTransfer'])
|
return record.path + record.encodeName
|
}
|
} else if (record.uploadType == 'alioss') {
|
const OSS = require('ali-oss')
|
const client = new OSS({
|
// region以杭州为例(oss-cn-hangzhou),其他region按实际情况填写。
|
region: window._CONFIG['region'],
|
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
|
accessKeyId: window._CONFIG['accessKeyId'],
|
accessKeySecret: window._CONFIG['accessKeySecret'],
|
bucket: window._CONFIG['bucket'],
|
})
|
// object-key表示从OSS下载文件时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
|
return client.signatureUrl(record.path)
|
}
|
},
|
async fetchList() {
|
this.equipmentList = []
|
await getAction(this.url.equipmentList).then(res => {
|
console.log(res);
|
this.equipmentList_bf = res.result.records
|
let tmparr = res.result.records
|
tmparr.forEach(r => {
|
this.equipmentList.push({
|
label: `${r.num}/${r.name}/${r.model}`,
|
value: r.id
|
})
|
})
|
|
})
|
},
|
handleChange(e, type) {
|
switch (type) {
|
case 0:
|
this.$set(this.model, 'status', e);
|
return
|
case 1:
|
this.$set(this.model, 'isStop', e);
|
return
|
case 2:
|
this.$set(this.model, 'equipmentId', e);
|
return
|
};
|
},
|
add() {
|
this.modelDefault.status = 1
|
this.modelDefault.isStop = false
|
this.edit(this.modelDefault);
|
},
|
async edit(record) {
|
await this.fetchList()
|
this.model = Object.assign({}, record);
|
if (this.model.id) {
|
|
this.selectStatus = Number(record.status)
|
record.isStop == 'true' ? this.isStop = true : this.isStop = false
|
this.equipmentId = String(record.equipmentId)
|
}
|
this.visible = true;
|
|
},
|
handleOkAndAdd() {
|
const that = this;
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true;
|
httpAction(this.url.add, this.model, 'post').then((res) => {
|
if (res.success) {
|
that.$message.success(res.message);
|
} else {
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.confirmLoading = false;
|
this.model = {}
|
this.$set(this.model, 'status', 1);
|
this.$set(this.model, 'isStop', false);
|
this.selectStatus = this.isStop = this.equipmentId = ''
|
})
|
}
|
})
|
},
|
submitForm() {
|
const that = this;
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true;
|
let httpurl = '';
|
let method = '';
|
if (!this.model.id) {
|
httpurl += this.url.add;
|
method = 'post';
|
} else {
|
httpurl += this.url.edit;
|
method = 'put';
|
}
|
httpAction(httpurl, this.model, method).then((res) => {
|
if (res.success) {
|
that.$message.success(res.message);
|
that.$emit('ok');
|
} else {
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.confirmLoading = false;
|
})
|
}
|
|
})
|
},
|
}
|
}
|
</script>
|
<style>
|
</style>
|