280 lines
8.8 KiB
Java
280 lines
8.8 KiB
Java
<template>
|
|
<div>
|
|
<a-drawer
|
|
:title="$t('add')"
|
|
:maskClosable="false"
|
|
:width="1000"
|
|
placement="right"
|
|
:closable="true"
|
|
@close="handleCancel"
|
|
:visible="visible"
|
|
style="height: 100%;overflow: auto;padding-bottom: 53px;">
|
|
<a-spin :spinning="confirmLoading">
|
|
<a-form-model :model="formInline" class="formAdd" ref="ruleForm">
|
|
<a-row :gutter="24">
|
|
<a-col :span="12">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="title-text-text" :title="$t('directoryName')">{{$t('directoryName')}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel">
|
|
<a-input class="box-input"
|
|
:disabled="disabled"
|
|
v-model.trim="formInline.directoryName"
|
|
:placeholder="$t('PleaseEnter')+$t('directoryName')"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="title-text-text" :title="$t('batch')">{{$t('batch')}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel">
|
|
<a-input class="box-input"
|
|
:disabled="disabled"
|
|
v-model.trim="formInline.lot"
|
|
:placeholder="$t('PleaseEnter')+$t('batch')"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row :gutter="24">
|
|
<a-col :span="12">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="title-text-text"
|
|
:title="$t('catalogFile')">{{$t('catalogFile')}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel">
|
|
<a-button type="primary" class="button-text"
|
|
@click="clickButtonToUpload('directoryFile')">
|
|
{{ (formInline.directoryFile === 'null' || formInline.directoryFile === ''||
|
|
formInline.directoryFile == null) ? $t('clickUpload') : $t('viewUploadedFiles') }}
|
|
</a-button>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="title-text-text"
|
|
:title="$t('testScheme')">{{$t('testScheme')}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel">
|
|
<a-button type="primary" class="button-text"
|
|
@click="clickButtonToUpload('experimentFile')">
|
|
{{ (formInline.experimentFile === 'null' || formInline.experimentFile === ''||
|
|
formInline.experimentFile == null) ? $t('clickUpload') : $t('viewUploadedFiles') }}
|
|
</a-button>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row :gutter="24">
|
|
<a-col :span="12">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="title-text-text" :title="$t('testReportLocation')">{{$t('testReportLocation')}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel">
|
|
<a-input class="box-input"
|
|
:disabled="disabled"
|
|
v-model.trim="formInline.detectionReportLocation"
|
|
:placeholder="$t('PleaseEnter')+$t('testReportLocation')"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row :gutter="24">
|
|
<a-col :span="24">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="title-text-text"
|
|
:title="$t('explain')">{{$t('explain')}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel">
|
|
<a-textarea
|
|
style="width: 100%"
|
|
:placeholder="$t('PleaseEnter')+$t('explain')"
|
|
v-model.trim="formInline.explainInfo" :rows="4"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
</a-row>
|
|
</a-form-model>
|
|
</a-spin>
|
|
<div class="drawer-bootom-button">
|
|
<a-button @click="handleCancel" style="margin-right: 16px" type="danger">{{$t('cancel')}}</a-button>
|
|
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{$t('submit')}}</a-button>
|
|
</div>
|
|
</a-drawer>
|
|
<uploadFile ref="uploadFile" @uploadSuccess="uploadSuccess"/>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import { getAction, postAction, putAction } from '@/api/manage'
|
|
import uploadFile from '@/components/uploadFile/file'
|
|
|
|
export default {
|
|
name: 'certificationDirectoryAdd',
|
|
components: {
|
|
uploadFile
|
|
},
|
|
data() {
|
|
return {
|
|
visible: false,
|
|
formInline: {},
|
|
confirmLoading: false,
|
|
disabled: false,
|
|
url: {
|
|
add: '/project/projectCertificationDirectoryEO/add',
|
|
edit: '/project/projectCertificationDirectoryEO/edit'
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
|
|
},
|
|
methods: {
|
|
add() {
|
|
this.visible = true
|
|
this.formInline = {}
|
|
},
|
|
edit(val) {
|
|
this.visible = true
|
|
this.$nextTick(() => {
|
|
this.formInline = val
|
|
})
|
|
},
|
|
handleCancel() {
|
|
this.visible = false
|
|
},
|
|
handleSubmit() {
|
|
if (!this.formInline.directoryName && !this.formInline.lot && !this.formInline.directoryFile &&
|
|
!this.formInline.experimentFile && !this.formInline.detectionReportLocation && !this.formInline.explainInfo) {
|
|
this.$message.warning(this.$t('dataCannotEmpty'))
|
|
} else {
|
|
let Action
|
|
let url = ''
|
|
if (this.formInline.id) {
|
|
url = this.url.edit
|
|
Action = putAction
|
|
} else {
|
|
url = this.url.add
|
|
Action = postAction
|
|
}
|
|
let query = {
|
|
projectLibraryId: this.$route.query.id,
|
|
...this.formInline
|
|
}
|
|
this.confirmLoading = true
|
|
Action(url, query).then((res) => {
|
|
if (res.success) {
|
|
this.$message.success(this.$t('OperationSuccessful'))
|
|
this.visible = false
|
|
this.confirmLoading = false
|
|
this.$emit('certificationDirectoryList')
|
|
} else {
|
|
this.confirmLoading = false
|
|
this.$message.warning(res.message)
|
|
}
|
|
})
|
|
}
|
|
},
|
|
clickButtonToUpload(item) {
|
|
this.$refs.uploadFile.perentHandleFunc()
|
|
this.$refs.uploadFile.visible = true
|
|
this.uploadName = item
|
|
getAction('sys/common/getFileInfos', { id: this.formInline[item] }).then((res) => {
|
|
if (res.success) {
|
|
this.$refs.uploadFile.perentHandleFunc(res.result)
|
|
} else {
|
|
this.$refs.uploadFile.perentHandleFunc()
|
|
}
|
|
})
|
|
},
|
|
/** 上传文件的回调 */
|
|
uploadSuccess(data) {
|
|
let attIdList = []
|
|
if (data && data.length > 0) {
|
|
data.map(item => {
|
|
attIdList.push(item.id || data.name)
|
|
})
|
|
}
|
|
/** 赋值给当前对应的表单文件 */
|
|
this.formInline[this.uploadName] = attIdList.join(',')
|
|
this.formInline = { ...this.formInline }
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.drawer-bootom-button {
|
|
position: absolute;
|
|
bottom: 0;
|
|
width: 100%;
|
|
z-index: 100;
|
|
border-top: 1px solid #e8e8e8;
|
|
padding: 10px 16px;
|
|
text-align: right;
|
|
left: 0;
|
|
background: #fff;
|
|
border-radius: 0 0 2px 2px;
|
|
}
|
|
|
|
.box-title-text {
|
|
line-height: 1.4;
|
|
display: flex;
|
|
/*align-items: center;*/
|
|
}
|
|
|
|
.title-text {
|
|
width: 114px;
|
|
text-align: right;
|
|
display: inline-block;
|
|
font-weight: 500;
|
|
font-size: 14px;
|
|
margin-right: 16px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
height: 42px;
|
|
line-height: 48px;
|
|
}
|
|
|
|
.box-input {
|
|
display: inline-block;
|
|
height: 38px;
|
|
width: 100%;
|
|
}
|
|
|
|
.itemModel {
|
|
width: calc(100% - 130px);
|
|
display: inline-block;
|
|
margin-top: 2px;
|
|
height: 40px;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.title-text-text {
|
|
margin-top: 9px;
|
|
}
|
|
|
|
|
|
.formAdd {
|
|
margin-bottom: 40px;
|
|
}
|
|
|
|
.button-text {
|
|
height: 38px;
|
|
width: calc(100% - 100px);
|
|
line-height: 38px;
|
|
background: #fff;
|
|
border: 1px #00B3BE solid;
|
|
color: #00B3BE;
|
|
}
|
|
</style> |