Browse Source

【安宁pc端 标签管理】-【用户标签 - 添加身份标签属性页面】魏凯 2020-12-01

feature/addTag
weikai 5 years ago
parent
commit
40aabeb14d
  1. 121
      src/views/modules/user/tagproperty.vue
  2. 251
      src/views/modules/user/tagpropertyDetail.vue
  3. 32
      src/views/modules/user/tagpropertyRoute.vue

121
src/views/modules/user/tagproperty.vue

@ -2,36 +2,61 @@
<el-card shadow="never" class="aui-card--fill"> <el-card shadow="never" class="aui-card--fill">
<div class="mod-news__tagproperty}"> <div class="mod-news__tagproperty}">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item> <el-form-item label="属性名称">
<el-input v-model="dataForm.id" placeholder="id" clearable></el-input> <el-input v-model="dataForm.propertyName" placeholder="属性名称" clearable></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="属性值">
<el-button @click="getDataList()">{{ $t('query') }}</el-button> <el-input v-model="dataForm.propertyValue" placeholder="属性值" clearable></el-input>
</el-form-item>
<br>
<el-form-item label="注册时间" prop="startTime">
<el-date-picker v-model="dataForm.startTime"
type="date"
:picker-options="pickerBeginDateBefore"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
placeholder="选择日期时间"
style="width:200px" @change="changeTime">
</el-date-picker>
</el-form-item>
<el-form-item label="至" prop="endTime">
<el-date-picker v-model="dataForm.endTime"
type="date"
:picker-options="pickerBeginDateAfter"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
placeholder="选择日期时间"
style="width:200px" @change="changeTime">
</el-date-picker>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button v-if="$hasPermission('news:tagproperty:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button> <el-button @click="getDataList()" type="success">{{ $t('query') }}</el-button>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button v-if="$hasPermission('news:tagproperty:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button> <el-button
type="primary"
@click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;"> <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column> <el-table-column label="序号" header-align="center" align="center" width="50px">
<el-table-column prop="id" label="ID" header-align="center" align="center"></el-table-column> <template slot-scope="scope">
{{scope.$index+1}}
</template>
</el-table-column>
<el-table-column prop="propertyName" label="属性名称" header-align="center" align="center"></el-table-column> <el-table-column prop="propertyName" label="属性名称" header-align="center" align="center"></el-table-column>
<el-table-column prop="propertyValue" label="属性值" header-align="center" align="center"></el-table-column> <el-table-column prop="propertyValue" label="属性值" header-align="center" align="center"></el-table-column>
<el-table-column prop="url" label="徽章图片地址" header-align="center" align="center"></el-table-column> <el-table-column label="徽章" header-align="center" align="center">
<template slot-scope="scope">
<img :src="scope.row.url" width="40" height="40" />
</template>
</el-table-column>
<el-table-column prop="remanrk" label="备注" header-align="center" align="center"></el-table-column> <el-table-column prop="remanrk" label="备注" header-align="center" align="center"></el-table-column>
<el-table-column prop="delFlag" label="逻辑删除" header-align="center" align="center"></el-table-column>
<el-table-column prop="revision" label="乐观锁" header-align="center" align="center"></el-table-column>
<el-table-column prop="createdBy" label="创建人" header-align="center" align="center"></el-table-column>
<el-table-column prop="createdTime" label="创建时间" header-align="center" align="center"></el-table-column> <el-table-column prop="createdTime" label="创建时间" header-align="center" align="center"></el-table-column>
<el-table-column prop="updatedBy" label="更新人" header-align="center" align="center"></el-table-column>
<el-table-column prop="updatedTime" label="更新时间" header-align="center" align="center"></el-table-column>
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="$hasPermission('news:tagproperty:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button> <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
<el-button v-if="$hasPermission('news:tagproperty:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button> <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -58,18 +83,76 @@ export default {
data () { data () {
return { return {
mixinViewModuleOptions: { mixinViewModuleOptions: {
getDataListURL: '/news/tagproperty/page', getDataListURL: '/app-user/property/page',
getDataListIsPage: true, getDataListIsPage: true,
deleteURL: '/news/tagproperty', deleteURL: '/app-user/property',
deleteIsBatch: true deleteIsBatch: true
}, },
dataForm: { dataForm: {
id: '' id: '',
propertyName:'',
propertyValue:'',
startTime:"",
endTime:""
},
pickerBeginDateBefore: {
disabledDate: (time) => {
let beginDateVal = this.dataForm.endTime
if (beginDateVal) {
return time.getTime() > new Date(beginDateVal + ' 00:00:00').getTime()
}
} }
},
pickerBeginDateAfter: {
disabledDate: (time) => {
let EndDateVal = this.dataForm.startTime
if (EndDateVal) {
return time.getTime() < new Date(EndDateVal + ' 00:00:00').getTime()
}
}
},
} }
}, },
components: { components: {
AddOrUpdate AddOrUpdate
},
created () {
this.getDataList();
this.initTime()
},
methods:{
addOrUpdateHandle (id, disabled) {
this.$parent.selectComponent = 'UserTagPropertyDetail'
this.$router.push({ path: '/user-tagpropertyRoute', query: { id: id, disabled: disabled } })
},
initTime () {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
this.time = [start, end]
let year = start.getFullYear()
let month = start.getMonth() + 1
if (month < 10) {
month = '0' + month
}
let date = start.getDate()
if (date < 10) {
date = '0' + date
}
let startDate = year + '-' + month + '-' + date
let yearend = end.getFullYear()
let monthend = end.getMonth() + 1
if (monthend < 10) {
monthend = '0' + monthend
}
let dateend = end.getDate()
if (dateend < 10) {
dateend = '0' + dateend
}
let endDate = yearend + '-' + monthend + '-' + dateend
this.dataForm.startTime = startDate
this.dataForm.endTime = endDate
},
} }
} }
</script> </script>

251
src/views/modules/user/tagpropertyDetail.vue

@ -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>

32
src/views/modules/user/tagpropertyRoute.vue

@ -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…
Cancel
Save