4 changed files with 754 additions and 92 deletions
@ -0,0 +1,326 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__masteruserrelation}"> |
|||
<el-form> |
|||
<el-form-item> |
|||
<el-button type="primary" @click="backToUserRelationList">{{"返回"}}</el-button> |
|||
<el-button v-if="!pageDisabled" type="primary" :disabled="isAble" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'" :disabled="pageDisabled"> |
|||
<el-form-item v-if="dailyTypeArr.length > 0" label="随手记" prop="dailyType"> |
|||
<el-select v-model="dataForm.dailyType" placeholder="随手记类型" @change="selectModel($event)" clearable style="width:50%"> |
|||
<el-option v-for="item in dailyTypeArr" :key="item.dictValue" :label="item.dictName" :value="item.dictValue" > |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item v-if="meetTypeArr.length > 0" label="会议类型" prop="meetType"> |
|||
<el-select v-model="dataForm.meetType" placeholder="会议类型" @change="selectModelMeetType($event)" clearable style="width:50%"> |
|||
<el-option v-for="item in meetTypeArr" :key="item.dictValue" :label="item.dictName" :value="item.dictValue" > |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="会议时间" prop="dailyDate"> |
|||
<el-date-picker v-model="dataForm.dailyDate" |
|||
type="datetime" |
|||
value-format="yyyy-MM-dd HH:mm" |
|||
format="yyyy-MM-dd HH:mm" |
|||
:picker-options="isSignupEndTime" |
|||
placeholder="选择日期时间" style="width:50%"> |
|||
</el-date-picker> |
|||
</el-form-item> |
|||
<el-form-item label="地址" prop="address"> |
|||
<el-input v-model="dataForm.address" placeholder="地址" maxlength="60" style="width:50%"></el-input> |
|||
<div><font color="gray">默认定位,可手动修改</font></div> |
|||
</el-form-item> |
|||
<el-form-item label="参加人数" prop="joinNum"> |
|||
<el-input-number v-model="dataForm.joinNum" :min="1" :max="100000000" label="参加人数" style="width:50%"></el-input-number> |
|||
</el-form-item> |
|||
<el-form-item label="内容" prop="content"> |
|||
<el-input |
|||
type="textarea" |
|||
:rows="3" |
|||
placeholder="请输入内容,2000字以内" |
|||
v-model="dataForm.content" |
|||
maxlength="2000" |
|||
style="width:50%"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="添加图片" v-loading="loading" prop="images"> |
|||
<!-- :action="uploadUrl" --> |
|||
<!-- action="https://jsonplaceholder.typicode.com/posts/" --> |
|||
<el-upload |
|||
:action="uploadUrl" |
|||
:class="{hide:hideUpload}" |
|||
list-type="picture-card" |
|||
:file-list="dataForm.images" |
|||
:limit=9 |
|||
:on-preview="handlePictureCardPreview" |
|||
:on-remove="handleRemove" |
|||
:on-success="handleAvatarSuccess" |
|||
:on-error="handelError" |
|||
:before-upload="beforeAvatarUpload" |
|||
style="width:40%"> |
|||
<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> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</div> |
|||
</el-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import debounce from 'lodash/debounce' |
|||
import Cookies from 'js-cookie' |
|||
import 'quill/dist/quill.snow.css' |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
dataForm: { |
|||
id: '', |
|||
userId: '', |
|||
nickName: '', |
|||
userFace: '', |
|||
deptName: '', |
|||
deptId: '', |
|||
dailyType: '', |
|||
meetType: '', |
|||
resourceId: '', |
|||
dailyDate: '', |
|||
address: '', |
|||
joinNum: '', |
|||
content: '', |
|||
images: [] |
|||
}, |
|||
isSignupEndTime: { |
|||
disabledDate (time) { |
|||
return time < Date.now() - 8.64e7 // 8.64e7=1000*60*60*24一天 |
|||
} |
|||
}, |
|||
isAble: false, |
|||
meetTypeArr: [], |
|||
dailyTypeArr: [], |
|||
hideUpload: false, |
|||
pageDisabled: false, |
|||
// imgUrlArr: [], |
|||
uploadUrl: '', |
|||
loading: false, |
|||
dialogImageUrl: '', |
|||
dialogVisible: false |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
nickName: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
dailyType: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
meetType: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
resourceId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
dailyDate: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
address: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
joinNum: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
content: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
created: function () { |
|||
// this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|||
this.uploadUrl = `http://219.146.91.110:10000/epdc-api/oss/file/uploadImg?token=${Cookies.get('token')}` |
|||
}, |
|||
mounted () { |
|||
console.log('this.$route.query.disabled:' + this.$route.query.disabled) |
|||
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 { |
|||
// 随手记下拉框赋值 |
|||
this.getDailyTypeArrInfo('0') |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.dataForm.id = this.$route.query.id |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
beforeAvatarUpload (file) { |
|||
if (this.dataForm.length === 9) { |
|||
this.$message.error('最多上传9张图片!') |
|||
return false |
|||
} |
|||
this.loading = 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格式!') |
|||
return false |
|||
} |
|||
}, |
|||
handleAvatarSuccess (res, file) { |
|||
console.log('res:') |
|||
console.log(res) |
|||
console.log('file:') |
|||
console.log(file) |
|||
this.loading = false |
|||
// this.imgUrlArr.push({ url: file.url, thumbnail: file.url, fileType: 1 }) |
|||
this.dataForm.images.push({ url: res.data.imgUrl, thumbnail: res.data.thumbnail, fileType: 1 }) |
|||
console.log('++++++新增后+++++++') |
|||
console.log(this.dataForm.images) |
|||
this.hideUpload = this.dataForm.images.length >= 9 |
|||
}, |
|||
handelError () { |
|||
this.loading = false |
|||
}, |
|||
handleRemove (file, fileList) { |
|||
for (var i = 0; i < this.dataForm.images.length; i++) { |
|||
let item = this.dataForm.images[i] |
|||
if (item.url === file.url) { |
|||
this.dataForm.images.splice(i, 1) |
|||
} |
|||
} |
|||
this.hideUpload = this.dataForm.images.length >= 9 |
|||
console.log('++++++删除出后+++++++') |
|||
console.log(this.dataForm.images) |
|||
}, |
|||
handlePictureCardPreview (file) { |
|||
this.dialogImageUrl = file.url |
|||
this.dialogVisible = true |
|||
}, |
|||
// 返回按钮点击事件 |
|||
backToUserRelationList () { |
|||
this.$emit('refreshDataList') |
|||
this.$parent.selectComponent = 'Dailyrecordinfo' |
|||
this.$router.push({ path: '/workRecord-dailyrecordinforoute' }) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/workRecord/dailyrecordinfo/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
// 判断是否存在九张照片,九张照片隐藏上传操作按钮 |
|||
if (!this.$route.query.disabled) { |
|||
this.hideUpload = this.dataForm.images.length >= 9 |
|||
} |
|||
// 随手记下拉框赋值 |
|||
this.getDailyTypeArrInfo('0') |
|||
}).catch(() => {}) |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.isAble = true |
|||
this.$http[!this.dataForm.id ? 'post' : 'put']('/workRecord/dailyrecordinfo/', this.dataForm).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
this.isAble = false |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.$message({ |
|||
message: this.$t('prompt.success'), |
|||
type: 'success', |
|||
duration: 500, |
|||
onClose: () => { |
|||
this.isAble = false |
|||
this.visible = false |
|||
this.$emit('refreshDataList') |
|||
// 返回主列表 |
|||
this.backToUserRelationList() |
|||
} |
|||
}) |
|||
}).catch(() => {}) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }), |
|||
// 随手记类型取值变化事件 |
|||
selectModel (event) { |
|||
this.$set(this.dataForm, 'meetType', '') |
|||
this.dailyTypeArr.find((item) => { |
|||
if (item.dictValue === event) { |
|||
this.getMeetTypeArrInfo(item.id) |
|||
this.dataForm.resourceId = item.id |
|||
} else { |
|||
this.meetTypeArr = [] |
|||
} |
|||
}) |
|||
}, |
|||
// 会议类型下拉取值变化事件 |
|||
selectModelMeetType (event) { |
|||
this.meetTypeArr.find((item) => { |
|||
if (item.dictValue === event) { |
|||
this.dataForm.resourceId = item.id |
|||
} |
|||
}) |
|||
}, |
|||
// 获取随手记类型下拉信息 |
|||
getDailyTypeArrInfo (pid) { |
|||
this.$http.get(`/workRecord/dailyrecordinfo/getDailyTypeArrInfo/${pid}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dailyTypeArr = res.data |
|||
if (this.dataForm.id !== null && this.dataForm.id !== '') { |
|||
// 若为修改页对会议类型下拉框进行赋值 |
|||
this.dailyTypeArr.find((item) => { |
|||
if (item.dictValue === this.dataForm.dailyType) { |
|||
this.getMeetTypeArrInfo(item.id) |
|||
} |
|||
}) |
|||
} |
|||
}).catch(() => {}) |
|||
}, |
|||
// 获取会议类型下拉信息 |
|||
getMeetTypeArrInfo (id) { |
|||
this.$http.get(`/workRecord/dailyrecordinfo/getDailyTypeArrInfo/` + id).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.meetTypeArr = res.data |
|||
}).catch(() => {}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style> |
|||
.hide .el-upload--picture-card { |
|||
display: none; |
|||
} |
|||
</style> |
@ -0,0 +1,29 @@ |
|||
<template> |
|||
<keep-alive include="dailyrecordinfo"> |
|||
<component :is="selectComponent"></component> |
|||
</keep-alive> |
|||
</template> |
|||
<script> |
|||
import Dailyrecordinfo from './dailyrecordinfo' |
|||
import DailyrecordinfoDetail from './dailyrecordinfoDetail' |
|||
export default { |
|||
data () { |
|||
return { |
|||
selectComponent: Dailyrecordinfo |
|||
} |
|||
}, |
|||
components: { |
|||
Dailyrecordinfo, |
|||
DailyrecordinfoDetail |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.selectComponent = Dailyrecordinfo |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
|
|||
</style> |
Loading…
Reference in new issue