<!--
 * @Author: your name
 * @Date: 2020-12-04 09:09:37
 * @LastEditTime: 2020-12-04 13:59:25
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \rs-cloud-platform-ui\src\views\webSiteManagement\industryApplication\applicationList\addApp\index.vue
-->
<template>
  <div id='addApp'>
      <div class="top">
        <div class="title" @click="backup">
            <img src="/static/images/return.png"/>
            返回上一页
        </div>
    </div>
    <div class="content">
      <el-form ref="form" :model="form" label-width="120px">
        <div class="item">
          <div class="title">基本信息</div>
          <div class="form">
            <el-form-item label="*应用名称">
                <el-col :span="12">
                    <el-input v-model="form.name" placeholder="请输入应用名称"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="*封面图">
                <singleImageX :value="form.coverImg" @input="onCoverPreview"></singleImageX>
            </el-form-item>
            <el-form-item label="*详情图">
                <singleImageX :value="form.detailImg" @input="onDetailPreview"></singleImageX>
            </el-form-item>
          </div>
        </div>
        <div class="item">
          <div class="title">应用参数</div>
          <div class="form">
            <el-form-item label="*行业">
                <el-col :span="12">
                    <el-input v-model="form.industry" placeholder="请输入行业"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="*地区">
                <el-col :span="12">
                    <el-input v-model="form.region" placeholder="请输入地区"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="*数据采集时间">
                <el-col :span="12">
                    <el-input v-model="form.collectTime" placeholder="请输入数据采集时间"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="*数据来源">
                <el-col :span="12">
                    <el-input v-model="form.origin" placeholder="请输入数据来源"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="*成果形式">
                <el-col :span="12">
                    <el-input v-model="form.achievement" placeholder="请输入成果形式"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="*分辨率">
                <el-col :span="12">
                    <el-input v-model="form.resolvpower" placeholder="请输入分辨率"></el-input>
                </el-col>
            </el-form-item>
            <el-form-item label="*是否提供样例">
                <el-radio-group v-model="form.isSample">
                  <el-radio-button label="是"></el-radio-button>
                  <el-radio-button label="否"></el-radio-button>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="*是否提供定制">
                <el-radio-group v-model="form.isCustomized">
                  <el-radio-button label="是"></el-radio-button>
                  <el-radio-button label="否"></el-radio-button>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="*上传样例">
                <el-upload class="upload-demo" action="#" :auto-upload="false" :on-preview="handlePreview" :on-remove="handleRemove" 
                :before-remove="beforeRemove" multiple :limit="100" :on-exceed="handleExceed" :http-request="onUploadRequest" :file-list="form.fileList">
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
              </el-upload>
            </el-form-item>
          </div>
        </div>
        <div class="item">
          <div class="title">应用简介</div>
          <div class="form">
            <el-form-item label="*产品简介">
                <kind-editor id="editor_id" :content.sync="form.editorText" :afterChange="afterChange()" :loadStyleMode="false"@on-content-change="onContentChange"></kind-editor>
            </el-form-item>
          </div>
        </div>
        <el-form-item>
            <el-button @click="$parent.componentName='appList'">取消</el-button>
            <el-button type="primary" @click="onSubmit">确定</el-button>
        </el-form-item>
      </el-form>
      </div>
  </div>
</template>

<script>
import singleImageX from '@/components/Upload/singleImageX';
import KindEditor from "@/components/Kindeditor";
export default {
  name: 'addApp',
  components: {
    singleImageX,
    KindEditor
  },
  data(){
    return {
      form: {
        name: '',
        coverImg: '',
        detailImg: '',
        industry: '',
        region: '',
        collectTime: '',
        origin: '',
        achievement: '',
        resolvpower: '',
        isSample: '是',
        isCustomized: '是',
        fileList: [],
        editorText: '', // 双向同步的变量
      }
    }
  },
  mounted() {
    this.$bus.$emit('hideThreeRoute',false)
  },
  beforeDestroy(){
      this.$bus.$emit('hideThreeRoute',true)
  },
  methods: {
    onContentChange (val) {
      console.log(val)
    },
    afterChange () {

    },
    backup(){
      this.$parent.componentName='appList'
      this.$bus.$emit('hideThreeRoute',true)
    },
    // 上传样例
    onUploadRequest(data) {
      console.log("uploadData=>",data)
    },
    onCoverPreview(url){   
      this.form.coverImg = url
    },
    onDetailPreview(url){
      this.form.detailImg = url
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${ file.name }？`);
    },
    onSubmit() {
        console.log('submit!');
    }
  },
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  #addApp{
        margin: 0 1% 0 1%;
        width: 98%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        color: #5178F2;
        .top{
            width: 100%;
            height: 68px;
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            overflow: hidden;
            border-bottom: 1px solid #EEEEEE;
            .title{ 
                width: auto;
                margin: 0 0 0 30px;
                height: 46px;
                display: flex;
                flex-direction: row;
                justify-content: center;
                align-items: center;
                color: #5178F2;
                overflow: hidden;
                cursor: pointer;
            }
        }
        .content{
          width: 100%;
          height: auto;
          display: flex;
          flex-direction: column;
          justify-content: flex-start;
          .item{
            width: 100%;
            height: auto;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            .title{
              padding-left: 40px;
              width: calc(100% - 40px);
              height: 36px;
              display: flex;
              flex-direction: row;
              justify-content: flex-start;
              align-items: center;
              background-color: #F2F2F2;
              color: #000000;
            }
            .form{
              padding-top: 20px;
              padding-left: 20px;
              width: calc(100% - 40px);
              height: auto;
            }
          }
        }
  }
</style>