|
@@ -1,114 +1,122 @@
|
|
|
-<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="address" :rules="[{required: true, message: '请选择项目区域'}]">
|
|
|
- <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="项目描述" 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">
|
|
|
- <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">保 存</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'
|
|
|
- export default {
|
|
|
- props: ['isUpdate', 'detailId'],
|
|
|
- data() {
|
|
|
- return {
|
|
|
- projectForm: {
|
|
|
- name: '', //项目名称
|
|
|
- address: [],
|
|
|
- comment: '',
|
|
|
- data: '',
|
|
|
- organizationId: '',
|
|
|
- picture: '',
|
|
|
- tagIds: ''
|
|
|
- },
|
|
|
- specific: '',
|
|
|
- responsibility: []
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.projectForm['organizationId'] = this.$store.getters.user.organization.id;
|
|
|
- if (this.isUpdate) {
|
|
|
- getProjectDetailById(this.detailId).then(res => {
|
|
|
- if (res.state) {
|
|
|
- this.projectForm = res.data;
|
|
|
- this.projectForm.address = JSON.parse(this.projectForm.address);
|
|
|
- if (this.projectForm.picture) this.responsibility = JSON.parse(this.projectForm.picture);
|
|
|
- if (this.projectForm.data) {
|
|
|
- let data = JSON.parse(this.projectForm.data);
|
|
|
- this.specific = data.specific;
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- submit() {
|
|
|
- this.$refs.projectForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- 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();
|
|
|
- if (this.isUpdate) {
|
|
|
- updateProject(postData).then(this.successFunc);
|
|
|
- } else {
|
|
|
- insertProject(postData).then(this.successFunc);
|
|
|
- }
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- successFunc(res) {
|
|
|
- if (res.state) {
|
|
|
- this.$message.success('操作成功');
|
|
|
- this.$emit('callback', 'init');
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- components: {
|
|
|
- city,
|
|
|
- upload,
|
|
|
- tag
|
|
|
- },
|
|
|
- }
|
|
|
-</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="address" :rules="[{required: true, message: '请选择项目区域'}]">
|
|
|
+ <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="项目描述" 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">
|
|
|
+ <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">保 存</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'
|
|
|
+ export default {
|
|
|
+ props: ['isUpdate', 'detailId'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ projectForm: {
|
|
|
+ name: '', //项目名称
|
|
|
+ address: [],
|
|
|
+ comment: '',
|
|
|
+ data: '',
|
|
|
+ organizationId: '',
|
|
|
+ picture: '',
|
|
|
+ tagIds: '',
|
|
|
+ type: 1
|
|
|
+ },
|
|
|
+ specific: '',
|
|
|
+ responsibility: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.projectForm['organizationId'] = this.$store.getters.user.organization.id;
|
|
|
+ if (this.isUpdate) {
|
|
|
+ getProjectDetailById(this.detailId).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ this.projectForm = res.data;
|
|
|
+ this.projectForm.address = JSON.parse(this.projectForm.address);
|
|
|
+ if (this.projectForm.picture) this.responsibility = JSON.parse(this.projectForm.picture);
|
|
|
+ if (this.projectForm.data) {
|
|
|
+ let data = JSON.parse(this.projectForm.data);
|
|
|
+ this.specific = data.specific;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ submit() {
|
|
|
+ this.$refs.projectForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ 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();
|
|
|
+ if (this.isUpdate) {
|
|
|
+ updateProject(postData).then(this.successFunc);
|
|
|
+ } else {
|
|
|
+ insertProject(postData).then(this.successFunc);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ successFunc(res) {
|
|
|
+ if (res.state) {
|
|
|
+ this.$message.success('操作成功');
|
|
|
+ this.$emit('callback', 'init');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ city,
|
|
|
+ upload,
|
|
|
+ tag
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
<style lang="scss"></style>
|