Browse Source

【pc端 添加网格实体化指标详情】-【基础页面添加】-(魏凯)-2020/12/07

master
weikai 5 years ago
parent
commit
db1d8878a3
  1. 404
      src/views/modules/kpi/kpisubpositiondetail.vue

404
src/views/modules/kpi/kpisubpositiondetail.vue

@ -0,0 +1,404 @@
<template>
<el-card shadow="never" class="aui-card--fill" v-loading="pageloading">
<div class="mod-__masteruserrelation}">
<div v-for="(item, index) in this.checkDiction" :key="index">
<div style="margin-bottom: 20px">
{{index+1}} {{item.label}}:
</div>
<div v-for="(item1, index1) in item.childDiction">
<div style="margin: 20px">
{{index1+1}}) {{item1.label}}
</div>
<el-form label-width="370px" :model="item1" :rules="dataRule" ref="dataForm" >
<el-form-item label="描述:" label-width="90px" style="font-weight:bold;">
<el-input
type="textarea"
:rows="6"
placeholder="描述,最多输入500字以内"
v-model="item1.describe"
maxlength="500"
style="max-width:562px">
</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="item1.images"
:limit=6
: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~6张图</font></div>
</el-form-item>
<el-form-item label="添加文件" v-loading="fileloading" prop="files" label-width="90px">
<el-upload
ref="upload"
class="upload-demo"
:action="uploadFileUrl"
:before-remove="beforeFileRemove"
:file-list="item1.files"
:before-upload="beforeAvatarFileUpload"
:on-remove="handleFileRemove"
:on-success="handleAvatarFileSuccess"
:on-error="handelError"
:on-preview="handleFileCardPreview"
style="width:480px">
<el-button size="small" >点击上传</el-button>
<div slot="tip" class="el-upload__tip">支持扩展名.rar.zip.doc.docxPDFExcel...文件</div>
</el-upload>
</el-form-item>
</el-form>
</div>
<el-form v-if="index == 1" label-width="370px" :model="item" :rules="dataRule" ref="dataForm" >
<el-form-item label="描述:" prop="content" label-width="90px" style="font-weight:bold;">
<el-input
type="textarea"
:rows="6"
placeholder="描述,最多输入500字以内"
v-model="item.describe"
maxlength="500"
style="max-width:562px">
</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="item.images"
:limit=6
: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~6张图</font></div>
</el-form-item>
<el-form-item label="添加文件" v-loading="fileloading" prop="files" label-width="90px">
<el-upload
ref="upload"
class="upload-demo"
:action="uploadFileUrl"
:before-remove="beforeFileRemove"
:file-list="item.files"
:before-upload="beforeAvatarFileUpload"
:on-remove="handleFileRemove"
:on-success="handleAvatarFileSuccess"
:on-error="handelError"
:on-preview="handleFileCardPreview"
style="width:480px">
<el-button size="small" >点击上传</el-button>
<div slot="tip" class="el-upload__tip">支持扩展名.rar.zip.doc.docxPDFExcel...文件</div>
</el-upload>
</el-form-item>
</el-form>
</div>
<el-form>
<el-form-item label="关联网格:" prop="content" label-width="90px" style="font-weight:bold;">
<el-select
v-model="dataForm.grids"
multiple
collapse-tags
placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</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>
</div>
</el-card>
</template>
<script>
import Cookies from "js-cookie";
import debounce from "lodash/debounce";
import MapSelect from "@/views/modules/workRecord/map-select";
export default {
name: "kpisubpositiondetail",
data () {
return {
visible: false,
dataForm: {
grids:[],
subDetail:[],
},
options :[],
isAble:false,
gridIds:[],
//
pageloading:false,
//
loading: false,
//
uploadUrl: '',
//
dialogVisible: false,
//
dialogImageUrl: '',
//
uploadFileUrl:'',
hideUpload: false,
fileloading: false,
checkDiction:[],
}
},
computed: {
dataRule () {
return {
}
}
},
created: function () {
// this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/uploadImg?token=${Cookies.get('token')}`
// this.uploadFileUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/uploadAllFile?token=${Cookies.get('token')}`
this.uploadUrl = `http://219.146.91.110:10000/epdc-api/oss/file/uploadImg?token=${Cookies.get('token')}`
this.uploadFileUrl = `http://219.146.91.110:10000/epdc-api/oss/file/uploadAllFile?token=${Cookies.get('token')}`
this.getOptions();
this.getCheckInfo();
},
mounted () {
if (this.$route.query.disabled === '0') {
} else {
}
this.getFormDataInfo()
},
methods: {
init () {
},
beforeAvatarUpload (file) {
if (this.dataForm.length === 6) {
this.$message.error('最多上传6张图片!')
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
}
},
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.images.push({ url: res.data.imgUrl, thumbnail: res.data.thumbnail, fileType: 1, fileName: res.data.fileName })
this.hideUpload = this.dataForm.images.length >= 6
},
handelError () {
this.loading = false
this.fileloading = false
this.isAble = false
this.$message.error('上传文件失败!')
},
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)
}
}
},
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 >= 6
},
handlePictureCardPreview (file) {
this.dialogImageUrl = file.url
this.dialogVisible = true
},
// --------------------
handleFileCardPreview (file) {
window.location.href = `${window.SITE_CONFIG['apiURL']}/oss/file/download?fileUrl=${file.url}`
// window.location.href = `http://219.146.91.110:10000/epdc-api/oss/file/download?fileUrl=${file.url}`
},
beforeFileRemove (file, fileList) {
if (this.isAutoRemoveFile) {
return this.$confirm(`确定移除${file.name}`)
}
this.isAutoRemoveFile = true
},
handleAvatarFileSuccess (res, file) {
this.fileloading = false
this.isAble = false
if (res === null || res.data === null || res.data.imgUrl === null) {
this.$message.error('文件上传失败!')
return false
}
this.dataForm.files.push({ url: res.data.imgUrl, thumbnail: res.data.thumbnail, fileType: 2, fileName: res.data.fileName, name: res.data.fileName })
},
handleFileRemove (file, fileList) {
for (var i = 0; i < this.dataForm.files.length; i++) {
let item = this.dataForm.files[i]
if (item.url === file.url) {
this.dataForm.files.splice(i, 1)
}
}
},
beforeAvatarFileUpload (file) {
this.fileloading = true
this.isAble = true
if (file.size === 0) {
this.isAutoRemoveFile = false
this.$message.error('文件为空文件,请上传非空文件!')
this.fileloading = false
this.isAble = false
return false
}
// const isJPG = file.type === 'image/jpeg'
// const isPNG = file.type === 'image/png'
// const isLt1M = file.size / 1024 / 1024 < 1
},
//
backToUserRelationList () {
this.$emit('refreshDataList')
this.$parent.selectComponent = 'Weekrecordinfo'
this.$router.push({ path: '/workRecord-weekrecordinforoute' })
},
getOptions () {
this.$http
.get(`/sys/user/deptOptions/getByLoginUser`)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.options = res.data.options
})
.catch(() => {})
},
getCheckInfo(){
this.checkDiction=[
{
id:'01f23eecdda4f20ef58fd2cb344ab3bf',
label:'建站达标',
childDiction:[
{
id:'009ff607df016a3fc1e15a08651c8977',
label:'网格要有布局合理、功能综合,(可共用、共建,原则上不能超过3个网格共用一处)党群服务站'
},
{
id:'2ff0833824d341e6bd26717c49e0ff33',
label:'网格划分边界清析、不交叉、不重叠,实现多网合一'
}
]
},
{
id:'ae35fb5792b9ecaa316b1c238fbffd2b',
label:'人员配备',
childDiction:[
]
}
]
},
//
getFormDataInfo () {
},
//
dataFormSubmitHandle: debounce(function () {
//
let subChild =[];
for (let i of this.checkDiction){
let laber = i.label;
let bigId = i.id;
let childSub = i.childDiction;
if (childSub.length>0) {
for (let j of childSub) {
//
console.log(j)
let childDesribe = j.describe;
//
let childUrl = j.images === undefined ? [] :j.images.url;
//
let childFile =j.files === undefined ? [] : j.files;
let m = {
desribe: childDesribe,
imageUrl: childUrl,
files: childFile
}
subChild.push(m)
}
}else {
console.log(i)
let childDesribe = i.describe;
let childUrl = i.images === undefined ?[]:i.images.url;
let childFile = i.files === undefined ?[]:i.files;
let ai = {
desribe:childDesribe,
imageUrl :childUrl,
files:childFile
}
subChild.push(ai)
}
}
this.dataForm.subDetail =subChild
debugger
}, 1000, { 'leading': true, 'trailing': false })
},
components: {
MapSelect
}
}
</script>
<style scoped>
</style>
Loading…
Cancel
Save