<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-row type="flex" justify="space-between"
|
><el-col :span="15">
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
class="l-mes"
|
label-width="80px"
|
>
|
<el-form-item label="工作站" prop="workstationName">
|
<el-input
|
class="innerClass"
|
v-model="dataForm.workstationName"
|
placeholder="请选择工作站"
|
readonly
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openWorkstationDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="产出" prop="productNo">
|
<el-input
|
class="innerClass"
|
v-model="dataForm.productNo"
|
placeholder="请选择产出"
|
readonly
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openProductoutDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="异常类型" prop="exceptionType">
|
<el-select
|
v-model="dataForm.exceptionType"
|
style="width:100%;"
|
placeholder="异常类型"
|
>
|
<el-option
|
v-for="item in exceptionHandleTypeOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="异常描述" prop="exceptionDescription">
|
<el-input
|
type="textarea"
|
:rows="2"
|
v-model="dataForm.exceptionDescription"
|
placeholder="异常描述"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="处理人" prop="processUserName">
|
<el-input
|
class="innerClass"
|
v-model="dataForm.processUserName"
|
placeholder="请选择处理人"
|
readonly
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openUserDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="微信通知组" prop="notifierGroupId">
|
<el-select
|
v-model="dataForm.notifierGroupId"
|
style="width:100%;"
|
placeholder="微信通知组"
|
>
|
<el-option
|
v-for="item in wxNoticeOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input
|
type="textarea"
|
:rows="2"
|
v-model="dataForm.remark"
|
placeholder="备注"
|
></el-input>
|
</el-form-item>
|
</el-form> </el-col
|
><el-col :span="8">
|
<div v-if="!dataForm.id">
|
<el-upload
|
class="upload-demo"
|
action="/mes/exception/addQualityException"
|
:headers="headers"
|
:data="postData"
|
:file-list="fileList"
|
list-type="picture"
|
:with-credentials="true"
|
:auto-upload="false"
|
:on-success="uploadSuccess"
|
:on-error="uploadError"
|
:limit="1"
|
:on-exceed="handleExceed"
|
:before-upload="beforeUpload"
|
ref="exceptionUpload"
|
>
|
<el-button size="small" type="primary">点击上传</el-button>
|
<div slot="tip" class="el-upload__tip">
|
只能上传jpg图片,且不超过2MB
|
</div>
|
</el-upload>
|
</div>
|
<div v-if="dataForm.id">
|
<div v-for="(ele, index) in fileList" :key="index">
|
<el-image
|
:src="ele.url"
|
fit="fill"
|
:preview-src-list="[ele.url]"
|
></el-image>
|
</div>
|
</div> </el-col
|
></el-row>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`dataFormSubmit`"
|
>确定</el-button
|
>
|
</span>
|
<workstation-dialog
|
:currshowlist.sync="workstationVisible"
|
@listenToWorkStationEvent="selectWorkstation"
|
/>
|
<productout-dialog
|
:currshowlist.sync="productoutVisible"
|
:paramObj="paramObj"
|
@listenToproductionEvent="selectProductout"
|
/>
|
<user-dialog
|
:currshowlist.sync="userVisible"
|
@listenToUserEvent="selectUser"
|
/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { getObj, putObj } from '@/api/quality/exception'
|
import { fetchList } from '@/api/quality/wxnotice'
|
import workstationDialog from '@/views/common/workstation.vue'
|
import productoutDialog from '@/views/common/productout.vue'
|
import { getStore } from '../../../util/store'
|
import { remote } from '@/api/admin/dict'
|
import userDialog from '@/views/common/user.vue'
|
|
export default {
|
components: { workstationDialog, productoutDialog, userDialog },
|
data() {
|
return {
|
paramObj: {},
|
productoutVisible: false,
|
workstationVisible: false,
|
visible: false,
|
dataForm: {
|
id: 0,
|
code: '',
|
workstationId: 0,
|
productoutId: 0,
|
exceptionType: '',
|
exceptionDescription: '',
|
handleWay: '',
|
handleUser: '',
|
createTime: '',
|
remark: '',
|
workstationName: '',
|
productNo: '',
|
notifierGroupId: null,
|
processUser: null,
|
processUserName: null
|
},
|
dataRule: {
|
workstationName: [
|
{ required: true, message: '工作站不能为空', trigger: 'blur' }
|
],
|
productNo: [
|
{ required: true, message: '产出不能为空', trigger: 'blur' }
|
]
|
},
|
isSubmit: false,
|
headers: {
|
Authorization: 'Bearer ' + getStore({ name: 'access_token' })
|
},
|
postData: {},
|
fileList: [],
|
exceptionHandleTypeOptions: [],
|
wxNoticeOptions: [],
|
userVisible: false
|
}
|
},
|
created() {
|
this.getExceptionHandleType()
|
this.getWxNoticeList()
|
},
|
methods: {
|
init(id) {
|
this.dataForm.workstationId = 0
|
this.dataForm.productoutId = 0
|
this.dataForm.id = id || 0
|
this.fileList = []
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
getObj(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
this.fileList = response.data.data.urlList
|
})
|
}
|
})
|
},
|
// 弹出工作站
|
openWorkstationDialog() {
|
this.workstationVisible = true
|
},
|
selectWorkstation(workstation) {
|
if (workstation) {
|
this.dataForm.workstationId = workstation.id
|
this.paramObj = { workstationId: workstation.id }
|
this.dataForm.workstationName = workstation.name
|
}
|
},
|
openProductoutDialog() {
|
if (this.dataForm.workstationId) {
|
this.productoutVisible = true
|
} else {
|
this.$message.error('请先选择工作站')
|
}
|
},
|
selectProductout(productout) {
|
if (productout) {
|
this.dataForm.productoutId = productout.id
|
this.dataForm.productNo = productout.productNo
|
}
|
},
|
handleExceed(files, fileList) {
|
this.$message.warning('新增时,限制上传一个图片')
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putObj(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
} else {
|
this.postData.workstationId = this.dataForm.workstationId
|
this.postData.productoutId = this.dataForm.productoutId
|
this.postData.exceptionType = this.dataForm.exceptionType
|
this.postData.exceptionDescription = this.dataForm.exceptionDescription
|
this.postData.remark = this.dataForm.remark
|
this.postData.notifierGroupId = this.dataForm.notifierGroupId
|
this.postData.processUser = this.dataForm.processUser
|
this.postData.processUserName = this.dataForm.processUserName
|
|
this.$refs.exceptionUpload.submit()
|
this.isSubmit = false
|
}
|
} else {
|
this.isSubmit = false
|
}
|
})
|
},
|
uploadSuccess(response, file, fileList) {
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
this.$message.success('添加成功')
|
},
|
uploadError(err, file, fileList) {
|
// console.log(err)
|
// this.$message.error('请先选择图片')
|
},
|
getExceptionHandleType() {
|
remote('exception_handle_type').then((response) => {
|
if (response.data.code === 0) {
|
this.exceptionHandleTypeOptions = response.data.data
|
} else {
|
this.exceptionHandleTypeOptions = []
|
}
|
})
|
},
|
getWxNoticeList() {
|
this.wxNoticeOptions = []
|
fetchList({ current: 1, size: 1000 }).then((response) => {
|
const resRecords = response.data.data.records
|
resRecords.forEach((ele) => {
|
this.wxNoticeOptions.push({
|
value: ele.id,
|
label: ele.groupName
|
})
|
})
|
})
|
},
|
selectUser(param) {
|
if (param) {
|
this.dataForm.processUser = param.userId
|
this.dataForm.processUserName = param.username
|
}
|
},
|
openUserDialog() {
|
this.userVisible = true
|
},
|
beforeUpload(file) {}
|
}
|
}
|
</script>
|