3 changed files with 302 additions and 16 deletions
@ -0,0 +1,248 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__masteruserrelation}"> |
|||
<el-form label-width="500px" label-position="left" :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :disabled="pageDisabled"> |
|||
<div v-for="(item, index) in this.dataForm.totalConfigList" :key="index"> |
|||
<div> |
|||
<el-form-item :label="item.totalDescribe" prop="showFlag" > |
|||
<el-select v-model="item.showFlag" placeholder="是否显示" style="width:100px"> |
|||
<el-option v-for="meetTypeItem in isShowArr" :key="meetTypeItem.dictValue" :label="meetTypeItem.dictName" :value="meetTypeItem.dictValue" > |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</div> |
|||
<el-row :gutter="10"> |
|||
<div v-for="(configitem, configindex) in item.configList" :key="configindex"> |
|||
<el-col :span="6"> |
|||
<el-form-item v-if="item.showFlag == '1'" :label="configitem.totalName" prop="total" :label-width="configitem.totalName.length*17+'px'"> |
|||
<el-input-number v-model="configitem.total" :min="0" :max="100000000" label="数量" style="width: 10rem;"></el-input-number> |
|||
</el-form-item> |
|||
</el-col> |
|||
</div> |
|||
</el-row> |
|||
</div> |
|||
<el-form-item label="14、本周小结" prop="content" label-width="110px"> |
|||
<el-input |
|||
type="textarea" |
|||
:rows="3" |
|||
placeholder="请输入本周小结,2000字以内" |
|||
v-model="dataForm.content" |
|||
maxlength="2000" |
|||
style="max-width:515px"> |
|||
</el-input> |
|||
</el-form-item> |
|||
<el-form-item label="添加图片" v-loading="loading" prop="images" label-width="90px"> |
|||
<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:480px"> |
|||
<i class="el-icon-plus"></i> |
|||
</el-upload> |
|||
<el-dialog :visible.sync="dialogVisible"> |
|||
<img width="100%" :src="dialogImageUrl" alt=""> |
|||
</el-dialog> |
|||
<div><font color="gray">1~9张图</font></div> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-form> |
|||
<el-form-item style="margin-left:35px;"> |
|||
<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> |
|||
</div> |
|||
</el-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import debounce from 'lodash/debounce' |
|||
import Cookies from 'js-cookie' |
|||
import MapSelect from './map-select' |
|||
import 'quill/dist/quill.snow.css' |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
dataForm: { |
|||
id: '', |
|||
content: '', |
|||
state: '', |
|||
images: [], |
|||
totalConfigList: [] |
|||
}, |
|||
isShowArr: [ |
|||
{ dictValue: '0', dictName: '否' }, |
|||
{ dictValue: '1', dictName: '是' } |
|||
], |
|||
formData: [], |
|||
isAble: false, |
|||
hideUpload: false, |
|||
pageDisabled: false, |
|||
uploadUrl: '', |
|||
loading: false, |
|||
dialogImageUrl: '', |
|||
dialogVisible: false |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
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/uploadAllFile?token=${Cookies.get('token')}` |
|||
}, |
|||
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() |
|||
// } |
|||
this.getFormDataInfo() |
|||
}, |
|||
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 |
|||
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 |
|||
return false |
|||
} |
|||
}, |
|||
handleAvatarSuccess (res, file) { |
|||
this.loading = false |
|||
this.isAble = false |
|||
this.dataForm.images.push({ url: res.data.imgUrl, thumbnail: res.data.thumbnail, fileType: 1, fileName: res.data.fileName }) |
|||
this.hideUpload = this.dataForm.images.length >= 9 |
|||
}, |
|||
handelError () { |
|||
this.loading = false |
|||
this.isAble = false |
|||
this.$message.error('上传文件失败!') |
|||
}, |
|||
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 |
|||
}, |
|||
handlePictureCardPreview (file) { |
|||
this.dialogImageUrl = file.url |
|||
this.dialogVisible = true |
|||
}, |
|||
// 返回按钮点击事件 |
|||
backToUserRelationList () { |
|||
this.$emit('refreshDataList') |
|||
this.$parent.selectComponent = 'Weekrecordinfo' |
|||
this.$router.push({ path: '/workRecord-weekrecordinforoute' }) |
|||
}, |
|||
// 获取信息 |
|||
// getInfo () { |
|||
// this.$http.get(`/workRecord/weekrecordinfo/${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 |
|||
// } |
|||
// }).catch(() => {}) |
|||
// }, |
|||
// 获取生成代码所需信息信息 |
|||
getFormDataInfo () { |
|||
let postData = { |
|||
weekInfoId: this.$route.query.id, |
|||
isAdd: this.$route.query.isAdd |
|||
} |
|||
this.$http.post(`/workRecord/resourcesdictionary/getResourcesDictionaryInitInfo`, postData).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 |
|||
} |
|||
}).catch(() => {}) |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.isAble = true |
|||
this.$http[!this.dataForm.id ? 'post' : 'put']('/workRecord/weekrecordinfo/', 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 }) |
|||
}, |
|||
components: { |
|||
MapSelect |
|||
} |
|||
} |
|||
</script> |
|||
<style> |
|||
.hide .el-upload--picture-card { |
|||
display: none; |
|||
} |
|||
</style> |
@ -0,0 +1,29 @@ |
|||
<template> |
|||
<keep-alive include="weekrecordinfo"> |
|||
<component :is="selectComponent"></component> |
|||
</keep-alive> |
|||
</template> |
|||
<script> |
|||
import Weekrecordinfo from './weekrecordinfo' |
|||
import WeekrecordinfoDetail from './weekrecordinfoDetail' |
|||
export default { |
|||
data () { |
|||
return { |
|||
selectComponent: Weekrecordinfo |
|||
} |
|||
}, |
|||
components: { |
|||
Weekrecordinfo, |
|||
WeekrecordinfoDetail |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.selectComponent = Weekrecordinfo |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
|
|||
</style> |
Loading…
Reference in new issue