<template>
|
<el-dialog
|
title="添加出入库记录"
|
:visible.sync="visible"
|
width="520px"
|
:close-on-click-modal="false"
|
custom-class="record-detail-dialog"
|
@close="handleClose"
|
>
|
<div class="dialog-content">
|
<el-form :model="formData" label-position="top">
|
<el-form-item label="出库/入库" required>
|
<div class="type-buttons">
|
<el-button
|
:type="formData.type === '1' ? 'primary' : 'default'"
|
@click="formData.type = '1'"
|
>出库</el-button>
|
<el-button
|
:type="formData.type === '2' ? 'primary' : 'default'"
|
@click="formData.type = '2'"
|
>入库</el-button>
|
</div>
|
</el-form-item>
|
|
<el-form-item required>
|
<template #label>
|
<span>操作人签字</span>
|
<el-button type="primary" class="sign-btn" @click="showSignature = true">签名</el-button>
|
</template>
|
<div class="signature-area" :class="{ 'waiting': !formData.handleSignature }">
|
<template v-if="formData.handleSignature">
|
<img :src="formData.handleSignature" alt="操作人签字" />
|
</template>
|
<template v-else>
|
<span class="waiting-text">等待确认</span>
|
</template>
|
</div>
|
</el-form-item>
|
</el-form>
|
</div>
|
<div class="footer-btns">
|
<el-button @click="handleClose">取消</el-button>
|
<el-button type="primary" @click="handleConfirm">确认</el-button>
|
</div>
|
<signature-canvas :visible.sync="showSignature" @confirm="handleSignatureConfirm" />
|
</el-dialog>
|
</template>
|
|
<script>
|
import SignatureCanvas from '@/components/SignatureCanvas.vue'
|
export default {
|
name: 'AddRecordDialog',
|
components: { SignatureCanvas },
|
props: {
|
visible: {
|
type: Boolean,
|
default: false
|
}
|
},
|
data() {
|
return {
|
formData: {
|
type: '1',
|
handleSignature: ''
|
},
|
showSignature: false
|
}
|
},
|
methods: {
|
handleClose() {
|
this.$emit('update:visible', false)
|
this.$emit('close')
|
},
|
handleConfirm() {
|
if (!this.formData.handleSignature) {
|
this.$message.warning('请先签名')
|
return
|
}
|
this.$emit('confirm', this.formData)
|
this.handleClose()
|
},
|
handleSignatureConfirm(dataUrl) {
|
this.formData.handleSignature = dataUrl
|
this.showSignature = false
|
}
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
.record-detail-dialog {
|
:deep(.el-dialog__header) {
|
padding: 20px 24px;
|
margin: 0;
|
border-bottom: 1px solid #DCDFE6;
|
.el-dialog__title {
|
font-size: 16px;
|
font-weight: 600;
|
color: #303133;
|
}
|
}
|
:deep(.el-dialog__body) {
|
padding: 24px;
|
}
|
}
|
.dialog-content {
|
:deep(.el-form-item__label) {
|
padding-bottom: 8px;
|
line-height: 20px;
|
font-size: 14px;
|
color: #606266;
|
&::before {
|
content: '*';
|
color: #F56C6C;
|
margin-right: 4px;
|
}
|
}
|
.type-buttons {
|
display: flex;
|
gap: 12px;
|
.el-button {
|
width: 80px;
|
border-radius: 4px;
|
font-size: 14px;
|
font-weight: 400;
|
box-sizing: border-box;
|
}
|
}
|
.signature-area {
|
height: 120px;
|
width: 100%;
|
background: #F5F7FA;
|
border-radius: 4px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
border: 1px solid #DCDFE6;
|
overflow: hidden;
|
padding: 0;
|
&.waiting {
|
border-style: dashed;
|
background: #FAFAFA;
|
}
|
img {
|
width: 100%;
|
height: 100%;
|
object-fit: cover;
|
display: block;
|
}
|
.waiting-text {
|
color: #909399;
|
font-size: 14px;
|
}
|
}
|
.sign-btn {
|
height: 32px;
|
border-radius: 4px;
|
font-size: 14px;
|
padding: 0 20px;
|
font-weight: 400;
|
margin-left: 12px;
|
}
|
}
|
.footer-btns {
|
display: flex;
|
justify-content: space-between;
|
padding: 24px;
|
padding-top: 0;
|
.el-button {
|
width: 150px;
|
}
|
}
|
</style>
|