3 changed files with 386 additions and 20 deletions
@ -0,0 +1,251 @@ |
|||||
|
<template> |
||||
|
<el-card shadow="never" class="aui-card--fill"> |
||||
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'" > |
||||
|
<el-form-item label="属性名称" prop="propertyName" label-width="100px"> |
||||
|
<el-input |
||||
|
placeholder="请输入属性名称" |
||||
|
v-model="dataForm.propertyName" |
||||
|
style="width:50%"> |
||||
|
</el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="属性值" prop="propertyValue" label-width="100px"> |
||||
|
<el-input |
||||
|
placeholder="请输入属性值" |
||||
|
v-model="dataForm.propertyValue" |
||||
|
style="width:50%"> |
||||
|
</el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="徽章图片" v-loading="loading" prop="images" label-width="100px"> |
||||
|
<el-upload |
||||
|
ref="upload" |
||||
|
:action="uploadUrl" |
||||
|
:class="{hide:hideUpload}" |
||||
|
list-type="picture-card" |
||||
|
:file-list="dataForm.replyPicture" |
||||
|
:limit=1 |
||||
|
:on-preview="handlePictureCardPreview" |
||||
|
:on-remove="handleRemove" |
||||
|
:on-success="handleAvatarSuccess" |
||||
|
:on-error="handelError" |
||||
|
:before-upload="beforeAvatarUpload" |
||||
|
style="width:480px"> |
||||
|
<i class="el-icon-plus"></i> |
||||
|
</el-upload> |
||||
|
<el-dialog :visible.sync="dialogVisible"> |
||||
|
<img width="100%" :src="dialogImageUrl" alt=""> |
||||
|
</el-dialog> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="备注" label-width="100px"> |
||||
|
<el-input |
||||
|
type="textarea" |
||||
|
:rows="3" |
||||
|
placeholder="请输入备注,100字以内" |
||||
|
v-model="dataForm.remanrk" |
||||
|
maxlength="2000" |
||||
|
style="width:50%"> |
||||
|
</el-input> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
|
||||
|
<el-form> |
||||
|
<el-form-item style="margin-left:35px;"> |
||||
|
<el-button type="primary" @click="backToUserRelationList">{{"返回"}}</el-button> |
||||
|
<el-button type="primary" :disabled="isAble" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</el-card> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import debounce from 'lodash/debounce' |
||||
|
import Cookies from 'js-cookie' |
||||
|
export default { |
||||
|
data () { |
||||
|
return { |
||||
|
visible: false, |
||||
|
pove: false, |
||||
|
dataForm: { |
||||
|
id:'', |
||||
|
propertyName:'', |
||||
|
propertyValue:'', |
||||
|
replyPicture: [], |
||||
|
remanrk:'', |
||||
|
}, |
||||
|
isAble: false, |
||||
|
replyInfoState: false, |
||||
|
meetTypeArr: [], |
||||
|
dailyTypeArr: [], |
||||
|
hideUpload: false, |
||||
|
|
||||
|
pageDisabled: false, |
||||
|
|
||||
|
uploadUrl: '', |
||||
|
loading: false, |
||||
|
dialogImageUrl: '', |
||||
|
dialogVisible: false, |
||||
|
options: [] |
||||
|
} |
||||
|
}, |
||||
|
created: function () { |
||||
|
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/uploadImg?token=${Cookies.get('token')}` |
||||
|
}, |
||||
|
computed: { |
||||
|
dataRule () { |
||||
|
return { |
||||
|
propertyName: [ |
||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
||||
|
], |
||||
|
propertyValue: [ |
||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
mounted () { |
||||
|
this.pageDisabled = this.$route.query.disabled |
||||
|
this.hideUpload = this.$route.query.disabled |
||||
|
if (this.$route.query.id !== '' && this.$route.query.id != null) { |
||||
|
this.dataForm.id = this.$route.query.id |
||||
|
this.getInfo() |
||||
|
} else { |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
init () { |
||||
|
this.visible = true |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs['dataForm'].resetFields() |
||||
|
if (this.dataForm.id) { |
||||
|
this.getInfo() |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
// 获取信息 |
||||
|
getInfo () { |
||||
|
this.$http.get(`/app-user/property/${this.dataForm.id}`).then(({ data: res }) => { |
||||
|
this.dataForm = { |
||||
|
...this.dataForm, |
||||
|
...res.data, |
||||
|
} |
||||
|
let picture=[ |
||||
|
{ |
||||
|
url : res.data.url, |
||||
|
breviaryUrl : res.data.url |
||||
|
} |
||||
|
]; |
||||
|
if (res.data.url === ''){ |
||||
|
picture=[]; |
||||
|
} |
||||
|
this.dataForm.replyPicture = picture; |
||||
|
if (res.data.url === ''){ |
||||
|
this.hideUpload=false |
||||
|
}else { |
||||
|
this.hideUpload=true |
||||
|
} |
||||
|
|
||||
|
}).catch(() => {}) |
||||
|
}, |
||||
|
// 表单提交 |
||||
|
dataFormSubmitHandle: debounce(function () { |
||||
|
this.$refs['dataForm'].validate((valid) => { |
||||
|
if (!valid) { |
||||
|
return false |
||||
|
} |
||||
|
let pageDate={ |
||||
|
id:this.dataForm.id, |
||||
|
propertyName: this.dataForm.propertyName, |
||||
|
propertyValue:this.dataForm.propertyValue, |
||||
|
url: this.dataForm.replyPicture[0] === undefined ? undefined : this.dataForm.replyPicture[0].url, |
||||
|
remanrk: this.dataForm.remanrk, |
||||
|
} |
||||
|
this.$http[!this.dataForm.id ? 'post' : 'put']('/app-user/property', pageDate).then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.$message({ |
||||
|
message: this.$t('prompt.success'), |
||||
|
type: 'success', |
||||
|
duration: 500, |
||||
|
onClose: () => { |
||||
|
this.visible = false |
||||
|
this.$emit('refreshDataList') |
||||
|
this.backToUserRelationList(); |
||||
|
} |
||||
|
}) |
||||
|
}).catch(() => {}) |
||||
|
}) |
||||
|
}, 1000, { 'leading': true, 'trailing': false }), |
||||
|
|
||||
|
handleAvatarSuccess (res, file) { |
||||
|
this.loading = false |
||||
|
this.isAble = false |
||||
|
if (res === null || res.data === null || res.data.imgUrl === null) { |
||||
|
this.$message.error('文件上传失败!') |
||||
|
this.handleErrorRemove(file) |
||||
|
return false |
||||
|
} |
||||
|
this.dataForm.replyPicture.push({ url: res.data.imgUrl, breviaryUrl: res.data.thumbnail, fileType: 1 }) |
||||
|
this.hideUpload = this.dataForm.replyPicture.length >= 1 |
||||
|
}, |
||||
|
handleErrorRemove (file) { |
||||
|
// 实现缩略图模板时删除文件 |
||||
|
let fileList = this.$refs.upload.uploadFiles |
||||
|
for (var i = 0; i < fileList.length; i++) { |
||||
|
let item = fileList[i] |
||||
|
if (item.url === file.url) { |
||||
|
fileList.splice(i, 1) |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
handelError () { |
||||
|
this.loading = false |
||||
|
this.isAble = false |
||||
|
this.$message.error('上传文件失败!') |
||||
|
}, |
||||
|
handlePictureCardPreview (file) { |
||||
|
this.dialogImageUrl = file.url |
||||
|
this.dialogVisible = true |
||||
|
}, |
||||
|
handleRemove (file, fileList) { |
||||
|
for (var i = 0; i < this.dataForm.replyPicture.length; i++) { |
||||
|
let item = this.dataForm.replyPicture[i] |
||||
|
if (item.url === file.url) { |
||||
|
this.dataForm.replyPicture.splice(i, 1) |
||||
|
} |
||||
|
} |
||||
|
this.hideUpload = this.dataForm.replyPicture.length >= 1 |
||||
|
}, |
||||
|
beforeAvatarUpload (file) { |
||||
|
if (this.dataForm.replyPicture.length === 1) { |
||||
|
this.$message.error('最多上传1张图片!') |
||||
|
return false |
||||
|
} |
||||
|
this.loading = true |
||||
|
this.isAble = true |
||||
|
const isJPG = file.type === 'image/jpeg' |
||||
|
const isPNG = file.type === 'image/png' |
||||
|
// const isLt1M = file.size / 1024 / 1024 < 1 |
||||
|
// 判断是否符合格式要求 |
||||
|
if (!isJPG && !isPNG) { |
||||
|
this.$message.error('上传文件必须是jpg、png格式!') |
||||
|
this.loading = false |
||||
|
this.isAble = false |
||||
|
return false |
||||
|
} |
||||
|
}, |
||||
|
// 返回按钮点击事件 |
||||
|
backToUserRelationList () { |
||||
|
this.$emit('UserTagProperty') |
||||
|
this.$parent.selectComponent = 'UserTagProperty' |
||||
|
this.$router.push({ path: '/user-tagpropertyRoute' }) |
||||
|
}, |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
.hide .el-upload--picture-card { |
||||
|
display: none; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,32 @@ |
|||||
|
<template> |
||||
|
<keep-alive include="UserTagPorperty"> |
||||
|
<component :is="selectComponent"></component> |
||||
|
</keep-alive> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import UserTagProperty from './tagproperty' |
||||
|
import UserTagPropertyDetail from './tagpropertyDetail' |
||||
|
|
||||
|
export default { |
||||
|
name: 'tagpropertyRoute', |
||||
|
data () { |
||||
|
return { |
||||
|
selectComponent: UserTagProperty |
||||
|
} |
||||
|
}, |
||||
|
components: { |
||||
|
UserTagProperty, |
||||
|
UserTagPropertyDetail |
||||
|
}, |
||||
|
methods: { |
||||
|
init () { |
||||
|
this.selectComponent = UserTagProperty |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
|
||||
|
</style> |
Loading…
Reference in new issue