|
@@ -17,15 +17,19 @@
|
|
|
<el-form-item label="设备SN码:" prop="snCode">
|
|
|
<el-input v-model="formData.snCode" placeholder="设备SN码" />
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="认证日期:" prop="authDate">
|
|
|
+ <el-date-picker v-model="formData.authDate" type="date" placeholder="选择日期" style="width: 100%" />
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="授权牌:" prop="certificateImageType">
|
|
|
<el-radio-group v-model="formData.certificateImageType" size="mini">
|
|
|
<el-radio :label="1">模板库生成</el-radio>
|
|
|
<el-radio :label="2">自定义上传</el-radio>
|
|
|
</el-radio-group>
|
|
|
<template v-if="formData.certificateImageType === 1">
|
|
|
- <div>
|
|
|
+ <div v-if="authTempFlag">
|
|
|
<preview-image v-if="formData.certificateImage" :src="formData.certificateImage" />
|
|
|
</div>
|
|
|
+ <div v-else>无</div>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<upload-image
|
|
@@ -37,6 +41,19 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item v-if="authTempFlag && formData.certificateImageType === 1" label="授权牌logo:">
|
|
|
+ <div class="form-label-tip">授权牌logo(提示:授权牌logo与机构名称组合)</div>
|
|
|
+ <div style="margin-top: 8px">
|
|
|
+ <upload-image
|
|
|
+ :tip="authImageLogoUploadTip"
|
|
|
+ :image-list="authImageLogoList"
|
|
|
+ :before-upload="beforeAuthImageLogoUpload"
|
|
|
+ @success="uploadAuthImageLogoSuccess"
|
|
|
+ @remove="handleAuthImageLogoRemove"
|
|
|
+ />
|
|
|
+ <el-input v-show="false" v-model="formData.authImageLogo" />
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="购买渠道:" prop="purchaseWay">
|
|
|
<el-input v-model="formData.purchaseWay" placeholder="购买渠道" />
|
|
|
</el-form-item>
|
|
@@ -66,6 +83,8 @@ import UploadImage from '@/components/UploadImage'
|
|
|
import { fetchProductSelectList, getProductById, saveProduct } from '@/api/product'
|
|
|
import { isSnCode } from '@/utils/validate'
|
|
|
import { getStorage } from '@/utils/storage'
|
|
|
+import { authTempUsed } from '@/api/system'
|
|
|
+import { formatDate } from '@/utils'
|
|
|
export default {
|
|
|
components: { UploadImage },
|
|
|
data() {
|
|
@@ -90,7 +109,9 @@ export default {
|
|
|
certificateImageType: 1,
|
|
|
productTypeId: '',
|
|
|
purchaseWay: '', // 购买渠道
|
|
|
- invoiceImage: '' // 发票
|
|
|
+ invoiceImage: '', // 发票
|
|
|
+ authDate: '',
|
|
|
+ authImageLogo: ''
|
|
|
},
|
|
|
productCateList: [],
|
|
|
certificateImageList: [],
|
|
@@ -99,12 +120,23 @@ export default {
|
|
|
certificateImage: [{ required: true, message: '授权牌照不能为空', trigger: 'change' }],
|
|
|
snCode: [{ required: true, message: 'SN码不能为空' }, { validator: valideSNcode }],
|
|
|
productTypeId: [{ required: true, message: '设备名称不能为空', trigger: 'change' }]
|
|
|
- }
|
|
|
+ },
|
|
|
+ authTempFlag: false,
|
|
|
+ // 验证
|
|
|
+ validatorFields: {
|
|
|
+ authImageLogoWidth: 100,
|
|
|
+ authImageLogoHeight: 100
|
|
|
+ },
|
|
|
+ authImageLogoList: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
authTypeName() {
|
|
|
return this.formData.authType === 1 ? '新设备认证' : '关联已认证设备'
|
|
|
+ },
|
|
|
+ // 授权牌logo上传提示
|
|
|
+ authImageLogoUploadTip() {
|
|
|
+ return `限制尺寸:${this.validatorFields.authImageLogoWidth}px *${this.validatorFields.authImageLogoHeight}px`
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -117,6 +149,7 @@ export default {
|
|
|
if (this.editType === 'edit') {
|
|
|
this.fetchProductDetail()
|
|
|
}
|
|
|
+ this.fetchAuthTempUsed()
|
|
|
},
|
|
|
methods: {
|
|
|
// 提交
|
|
@@ -132,6 +165,7 @@ export default {
|
|
|
// 保存
|
|
|
async onSave() {
|
|
|
try {
|
|
|
+ this.formData.authDate = this.formData.authDate ? formatDate(this.formData.authDate, 'yyyy.MM.DD') : ''
|
|
|
await saveProduct(this.formData)
|
|
|
const h = this.$createElement
|
|
|
const tip = this.editType === 'add' ? '添加' : '修改'
|
|
@@ -169,6 +203,11 @@ export default {
|
|
|
this.formData[key] = data[key]
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ this.formData.authImageLogo = data.authImageLogo
|
|
|
+ if (data.authImageLogo) {
|
|
|
+ this.authImageLogoList = [{ name: '授权牌logo', url: data.authImageLogo }]
|
|
|
+ }
|
|
|
}
|
|
|
if (data.invoiceImage) {
|
|
|
this.invoiceImageList = [{ name: '发票', url: data.invoiceImage }]
|
|
@@ -189,6 +228,23 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 获取当前机构可用授权牌模板
|
|
|
+ async fetchAuthTempUsed() {
|
|
|
+ try {
|
|
|
+ const res = await authTempUsed({
|
|
|
+ authUserId: this.authUserId,
|
|
|
+ authFlag: 1,
|
|
|
+ status: 1
|
|
|
+ })
|
|
|
+ this.authTempFlag = res.data != null
|
|
|
+ const [width, height] = res.data.logoSize.split(',')
|
|
|
+ this.validatorFields.authImageLogoWidth = width
|
|
|
+ this.validatorFields.authImageLogoHeight = height
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 授权牌照上传
|
|
|
beforeCertificateImageUpload(file) {
|
|
|
const flag = file.size / 1024 / 1024 < 1
|
|
@@ -221,6 +277,35 @@ export default {
|
|
|
handleInvoiceImageRemove({ file, fileList }) {
|
|
|
this.invoiceImageList = fileList
|
|
|
this.formData.invoiceImage = ''
|
|
|
+ },
|
|
|
+ // 授权牌logo上传
|
|
|
+ beforeAuthImageLogoUpload(file) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (file.size > 5 * 1024 * 1024) {
|
|
|
+ this.$message.error('授权牌logo图片大小不能超过 5MB!')
|
|
|
+ reject('图片大小超出最大限制')
|
|
|
+ }
|
|
|
+ const image = new Image()
|
|
|
+ image.src = URL.createObjectURL(file)
|
|
|
+ image.onload = (e) => {
|
|
|
+ const { naturalWidth, naturalHeight } = e.path ? e.path[0] : e.target
|
|
|
+ const { authImageLogoWidth: width, authImageLogoHeight: height } = this.validatorFields
|
|
|
+ if (naturalWidth > width || naturalHeight > height) {
|
|
|
+ this.$message.error('图片尺寸校验未通过')
|
|
|
+ reject('图片尺寸校验未通过')
|
|
|
+ } else {
|
|
|
+ resolve('图片尺寸校验通过')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ uploadAuthImageLogoSuccess({ response, file, fileList }) {
|
|
|
+ this.authImageLogoList = fileList
|
|
|
+ this.formData.authImageLogo = response.data
|
|
|
+ },
|
|
|
+ handleAuthImageLogoRemove({ file, fileList }) {
|
|
|
+ this.authImageLogoList = fileList
|
|
|
+ this.formData.authImageLogo = ''
|
|
|
}
|
|
|
}
|
|
|
}
|