|
@@ -1,184 +1,192 @@
|
|
|
-<template>
|
|
|
- <div class="hui-flex hui-dialog">
|
|
|
- <div class="hui-flex-box hui-dialog-content">
|
|
|
- <el-form ref="projectForm" label-position="top" :model="projectForm">
|
|
|
- <el-form-item label="项目名称" prop="name" :rules="[{required: true, message: '请输入项目名称'}]">
|
|
|
- <el-input type="text" v-model="projectForm.name" placeholder="请输入项目名称"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="项目类型" prop="type" :rules="[{required: true, message: '请选择项目类型'}]">
|
|
|
- <el-select v-model="projectForm.type" placeholder="请选择项目类型">
|
|
|
- <el-option :label="item.name" :value="item.id" v-for="(item,index) in $field.field.projectType"
|
|
|
- :key="item.id">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="项目区域" prop="address" :rules="[{required: true, message: '请选择项目区域'}]">
|
|
|
- <city ref="city" v-model="projectForm.address"></city>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="具体地点">
|
|
|
- <el-input type="text" v-model="specific" placeholder="请输入具体地点">
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="配套设施" prop="type">
|
|
|
- <el-select v-model="supportingFacilities" placeholder="请选择配套设施" multiple collapse-tags>
|
|
|
- <el-option :label="item.name" :value="item.id"
|
|
|
- v-for="(item,index) in $field.field.supportingFacilities" :key="item.id">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="项目描述" class="hui-textarea">
|
|
|
- <el-input type="textarea" v-model="projectForm.comment" placeholder="请输入项目描述" resize="none">
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="地图位置" class="hui-textarea">
|
|
|
- <select-location ref="map" v-if="showMap" type="insert" :coordinates="projectForm.coordinates">
|
|
|
- </select-location>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="项目配图" class="hui-textarea">
|
|
|
- <upload ref="upload" :list="responsibility" type="insert"></upload>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="项目标签" class="hui-textarea">
|
|
|
- <tag ref="tag" type="insert" :tagType="1"
|
|
|
- :tagActive="projectForm.tagIds ? projectForm.tagIds.split(',') : []">
|
|
|
- </tag>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </div>
|
|
|
- <div class="hui-dialog-submit">
|
|
|
- <el-button size="medium" @click="$emit('callback')">取 消</el-button>
|
|
|
- <el-button size="medium" type="primary" @click="submit" :loading="loading">保 存</el-button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
- import {
|
|
|
- insertProject,
|
|
|
- getProjectDetailById,
|
|
|
- updateProject
|
|
|
- } from '@/httpApi/space'
|
|
|
- import upload from '@/components/common/upload'
|
|
|
- import city from '@/components/common/city'
|
|
|
- import tag from '@/components/common/tag'
|
|
|
- import selectLocation from '@/components/work/common/selectLocation'
|
|
|
- export default {
|
|
|
- props: ['isUpdate', 'detailId'],
|
|
|
- data() {
|
|
|
- return {
|
|
|
- projectForm: {
|
|
|
- name: '', //项目名称
|
|
|
- address: [],
|
|
|
- comment: '',
|
|
|
- data: '',
|
|
|
- organizationId: '',
|
|
|
- picture: '',
|
|
|
- tagIds: '',
|
|
|
- type: 1,
|
|
|
- coordinates: '',
|
|
|
- supportingFacilities: ''
|
|
|
- },
|
|
|
- specific: '',
|
|
|
- responsibility: [],
|
|
|
- showMap: false,
|
|
|
- supportingFacilities: [],
|
|
|
- isCache: true,
|
|
|
- loading: false
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- if (this.isUpdate) {
|
|
|
- this.isCache = false;
|
|
|
- getProjectDetailById(this.detailId).then(res => {
|
|
|
- if (res.state) {
|
|
|
- this.projectForm = res.data;
|
|
|
- this.showMap = true;
|
|
|
- this.projectForm.address = JSON.parse(this.projectForm.address);
|
|
|
- if (this.projectForm.picture) this.responsibility = JSON.parse(this.projectForm.picture);
|
|
|
- if (this.projectForm.supportingFacilities) this.supportingFacilities = this.projectForm
|
|
|
- .supportingFacilities.split(',').map(node => Number(node));
|
|
|
- if (this.projectForm.data) {
|
|
|
- let data = JSON.parse(this.projectForm.data);
|
|
|
- this.specific = data.specific;
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- if (this.$store.getters.projectData && JSON.stringify(this.$store.getters.projectData) != '{}') {
|
|
|
- if (this.$store.getters.projectData.organizationId != this.$store.getters.organization.id) {
|
|
|
- return this.$store.dispatch('projectBase/changeProjectData', {});
|
|
|
- }
|
|
|
- // this.initForm(this.$store.getters.projectData);
|
|
|
- }
|
|
|
- this.projectForm['organizationId'] = this.$store.getters.organization.id;
|
|
|
- this.showMap = true;
|
|
|
- }
|
|
|
- },
|
|
|
- beforeDestroy() {
|
|
|
- // this.cacheData();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- initForm(data) {
|
|
|
- this.projectForm = data;
|
|
|
- this.projectForm.address = JSON.parse(this.projectForm.address);
|
|
|
- if (this.projectForm.picture) this.responsibility = JSON.parse(this.projectForm.picture);
|
|
|
- if (this.projectForm.supportingFacilities) this.supportingFacilities = this.projectForm
|
|
|
- .supportingFacilities.split(',').map(node => Number(node));
|
|
|
- if (this.projectForm.data) {
|
|
|
- let data = JSON.parse(this.projectForm.data);
|
|
|
- this.specific = data.specific;
|
|
|
- }
|
|
|
- },
|
|
|
- cacheData() {
|
|
|
- if (!this.isCache) return;
|
|
|
- this.$store.dispatch('projectBase/changeProjectData', this.setData());
|
|
|
- },
|
|
|
- setData() {
|
|
|
- let postData = JSON.parse(JSON.stringify(this.projectForm));
|
|
|
- postData.data = JSON.stringify({
|
|
|
- specific: this.specific
|
|
|
- });
|
|
|
- postData['picture'] = JSON.stringify(this.$refs.upload.fileList);
|
|
|
- postData['address'] = JSON.stringify(this.projectForm.address);
|
|
|
- postData['tagIds'] = this.$refs.tag.tagIds();
|
|
|
- postData['coordinates'] = this.$refs.map.address;
|
|
|
- postData['supportingFacilities'] = this.supportingFacilities.join(',');
|
|
|
- postData['addressCode'] = this.$refs.city.addressCode();
|
|
|
- return postData;
|
|
|
- },
|
|
|
- submit() {
|
|
|
- this.loading = true;
|
|
|
- this.$refs.projectForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- let postData = this.setData();
|
|
|
- if (this.isUpdate) {
|
|
|
- updateProject(postData).then(this.successFunc);
|
|
|
- } else {
|
|
|
- insertProject(postData).then(this.successFunc);
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.loading = false;
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- successFunc(res) {
|
|
|
- this.loading = false;
|
|
|
- if (res.state) {
|
|
|
- this.$store.dispatch('projectBase/changeProjectData', {});
|
|
|
- this.isCache = false;
|
|
|
- this.$message.success('操作成功');
|
|
|
- this.$emit('callback', 'init');
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
- components: {
|
|
|
- city,
|
|
|
- upload,
|
|
|
- tag,
|
|
|
- selectLocation
|
|
|
- },
|
|
|
- }
|
|
|
-</script>
|
|
|
-
|
|
|
+<template>
|
|
|
+ <div class="hui-flex hui-dialog">
|
|
|
+ <div class="hui-flex-box hui-dialog-content">
|
|
|
+ <el-form ref="projectForm" label-position="top" :model="projectForm">
|
|
|
+ <el-form-item label="项目名称" prop="name" :rules="[{required: true, message: '请输入项目名称'}]">
|
|
|
+ <el-input type="text" v-model="projectForm.name" placeholder="请输入项目名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="类型" prop="type" :rules="[{required: true, message: '请选择类型'}]">
|
|
|
+ <el-select v-model="projectForm.type" placeholder="请选择类型">
|
|
|
+ <el-option :label="item.name" :value="item.id" v-for="(item,index) in $field.field.projectType"
|
|
|
+ :key="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="项目类型" prop="type" :rules="[{required: true, message: '请选择项目类型'}]">
|
|
|
+ <el-select v-model="projectForm.projectType" placeholder="请选择项目类型">
|
|
|
+ <el-option :label="item.name" :value="item.id" v-for="(item,index) in $field.field.projectTypes"
|
|
|
+ :key="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="建筑面积">
|
|
|
+ <el-input type="text" v-model="projectForm.buildingArea" placeholder="请输入建筑面积">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="竣工时间">
|
|
|
+ <el-date-picker v-model="projectForm.completionTime" type="date" placeholder="竣工时间"
|
|
|
+ value-format="yyyy-MM-dd">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="项目区域" prop="address" :rules="[{required: true, message: '请选择项目区域'}]">
|
|
|
+ <city ref="city" v-model="projectForm.address"></city>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="具体地点">
|
|
|
+ <el-input type="text" v-model="projectForm.specificLocation" placeholder="请输入具体地点">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="配套设施" prop="type">
|
|
|
+ <el-select v-model="supportingFacilities" placeholder="请选择配套设施" multiple collapse-tags>
|
|
|
+ <el-option :label="item.name" :value="item.id"
|
|
|
+ v-for="(item,index) in $field.field.supportingFacilities" :key="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="项目介绍" class="hui-textarea">
|
|
|
+ <el-input type="textarea" v-model="projectForm.comment" placeholder="请输入项目介绍" resize="none">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="地图位置" class="hui-textarea">
|
|
|
+ <select-location ref="map" v-if="showMap" type="insert" :coordinates="projectForm.coordinates">
|
|
|
+ </select-location>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="项目配图" class="hui-textarea">
|
|
|
+ <upload ref="upload" :list="responsibility" type="insert"></upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="项目标签" class="hui-textarea">
|
|
|
+ <tag ref="tag" type="insert" :tagType="1"
|
|
|
+ :tagActive="projectForm.tagIds ? projectForm.tagIds.split(',') : []">
|
|
|
+ </tag>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div class="hui-dialog-submit">
|
|
|
+ <el-button size="medium" @click="$emit('callback')">取 消</el-button>
|
|
|
+ <el-button size="medium" type="primary" @click="submit" :loading="loading">保 存</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ insertProject,
|
|
|
+ getProjectDetailById,
|
|
|
+ updateProject
|
|
|
+ } from '@/httpApi/space'
|
|
|
+ import upload from '@/components/common/upload'
|
|
|
+ import city from '@/components/common/city'
|
|
|
+ import tag from '@/components/common/tag'
|
|
|
+ import selectLocation from '@/components/work/common/selectLocation'
|
|
|
+ export default {
|
|
|
+ props: ['isUpdate', 'detailId'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ projectForm: {
|
|
|
+ name: '', //项目名称
|
|
|
+ address: [],
|
|
|
+ comment: '',
|
|
|
+ data: '',
|
|
|
+ organizationId: '',
|
|
|
+ picture: '',
|
|
|
+ tagIds: '',
|
|
|
+ type: 1,
|
|
|
+ projectType: 1,
|
|
|
+ coordinates: '',
|
|
|
+ supportingFacilities: '',
|
|
|
+ specificLocation: '',
|
|
|
+ completionTime: '',
|
|
|
+ buildingArea: ''
|
|
|
+ },
|
|
|
+ responsibility: [],
|
|
|
+ showMap: false,
|
|
|
+ supportingFacilities: [],
|
|
|
+ isCache: true,
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ if (this.isUpdate) {
|
|
|
+ this.isCache = false;
|
|
|
+ getProjectDetailById(this.detailId).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ this.projectForm = res.data;
|
|
|
+ this.showMap = true;
|
|
|
+ this.projectForm.address = JSON.parse(this.projectForm.address);
|
|
|
+ if (this.projectForm.picture) this.responsibility = JSON.parse(this.projectForm.picture);
|
|
|
+ if (this.projectForm.supportingFacilities) this.supportingFacilities = this.projectForm
|
|
|
+ .supportingFacilities.split(',').map(node => Number(node));
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (this.$store.getters.projectData && JSON.stringify(this.$store.getters.projectData) != '{}') {
|
|
|
+ if (this.$store.getters.projectData.organizationId != this.$store.getters.organization.id) {
|
|
|
+ return this.$store.dispatch('projectBase/changeProjectData', {});
|
|
|
+ }
|
|
|
+ // this.initForm(this.$store.getters.projectData);
|
|
|
+ }
|
|
|
+ this.projectForm['organizationId'] = this.$store.getters.organization.id;
|
|
|
+ this.showMap = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ // this.cacheData();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initForm(data) {
|
|
|
+ this.projectForm = data;
|
|
|
+ this.projectForm.address = JSON.parse(this.projectForm.address);
|
|
|
+ if (this.projectForm.picture) this.responsibility = JSON.parse(this.projectForm.picture);
|
|
|
+ if (this.projectForm.supportingFacilities) this.supportingFacilities = this.projectForm
|
|
|
+ .supportingFacilities.split(',').map(node => Number(node));
|
|
|
+ },
|
|
|
+ cacheData() {
|
|
|
+ if (!this.isCache) return;
|
|
|
+ this.$store.dispatch('projectBase/changeProjectData', this.setData());
|
|
|
+ },
|
|
|
+ setData() {
|
|
|
+ let postData = JSON.parse(JSON.stringify(this.projectForm));
|
|
|
+ postData['picture'] = JSON.stringify(this.$refs.upload.fileList);
|
|
|
+ postData['address'] = JSON.stringify(this.projectForm.address);
|
|
|
+ postData['tagIds'] = this.$refs.tag.tagIds();
|
|
|
+ postData['coordinates'] = this.$refs.map.address;
|
|
|
+ postData['supportingFacilities'] = this.supportingFacilities.join(',');
|
|
|
+ postData['addressCode'] = this.$refs.city.addressCode();
|
|
|
+ return postData;
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ this.loading = true;
|
|
|
+ this.$refs.projectForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let postData = this.setData();
|
|
|
+ if (this.isUpdate) {
|
|
|
+ updateProject(postData).then(this.successFunc);
|
|
|
+ } else {
|
|
|
+ insertProject(postData).then(this.successFunc);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.loading = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ successFunc(res) {
|
|
|
+ this.loading = false;
|
|
|
+ if (res.state) {
|
|
|
+ this.$store.dispatch('projectBase/changeProjectData', {});
|
|
|
+ this.isCache = false;
|
|
|
+ this.$message.success('操作成功');
|
|
|
+ this.$emit('callback', 'init');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ city,
|
|
|
+ upload,
|
|
|
+ tag,
|
|
|
+ selectLocation
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
<style lang="scss"></style>
|