<template>
  <div class="body" >
    <p class="title">标的挂牌</p>
    <div class="listing_title">挂牌方简况</div>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm1" label-width="150px" class="ruleForm"  label-position="left" @submit.native.prevent>
      <template v-if="means.account_type==1">
        <el-form-item label="挂牌方名称">
          <el-input v-model="means.firm_name"  class="serial_name" readonly></el-input>
        </el-form-item>
        <div class="listing_flex">
          <el-form-item label="统一社会信用代码">
            <el-input v-model="means.credit_code"  readonly  class="listing_input"></el-input>
          </el-form-item>
        </div>
        <div class="listing_flex">
          <el-form-item label="住  所" >
            <el-input v-model="means.domicile"  readonly class="listing_input"></el-input>
          </el-form-item>
          <el-form-item label="法定代表人" >
            <el-input v-model="means.legal_name" readonly class="listing_input"></el-input>
          </el-form-item>
        </div>
        <div class="listing_flex">
          <el-form-item label="成立日期" >
            <el-input v-model="means.establish_time_date" readonly  class="listing_input"></el-input>
          </el-form-item>
          <el-form-item label="注册资本" >
            <el-input v-model="means.reg_money" readonly  class="listing_input"></el-input>
          </el-form-item>
        </div>
      </template>
      <template v-else>
        <el-form-item label="挂牌方名称">
          <el-input v-model="means.username"  class="serial_name" readonly></el-input>
        </el-form-item>
        <div class="listing_flex">
          <el-form-item label="身份证号码">
            <el-input v-model="means.id_card"  readonly  class="listing_input"></el-input>
          </el-form-item>
        </div>
        <div class="listing_flex">
          <el-form-item label="收货联系人" >
            <el-input v-model="means.uname"  readonly class="listing_input"></el-input>
          </el-form-item>
          <el-form-item label="通讯地址" >
            <el-input v-model="means.address" readonly class="listing_input"></el-input>
          </el-form-item>
        </div>
        <div class="listing_flex">
          <el-form-item label="联系电话" >
            <el-input v-model="means.phone" readonly  class="listing_input"></el-input>
          </el-form-item>
          <el-form-item label="传真" >
            <el-input v-model="means.fax" readonly  class="listing_input"></el-input>
          </el-form-item>
        </div>
        <div class="listing_flex">
          <el-form-item label="邮编" >
            <el-input v-model="means.postcode" readonly  class="listing_input"></el-input>
          </el-form-item>
          <el-form-item label="电子邮件" >
            <el-input v-model="means.email" readonly  class="listing_input"></el-input>
          </el-form-item>
        </div>
      </template>

      <div class="listing_title">挂牌标的信息公告与交易条件</div>
      <el-form-item label="上传标的图片" prop="serial_img" >
        <p class="listing_tips">上传高清质量标的正面图，有助快速通过审核，方便购买方了解资产，图片尺寸建议为800px * 800px</p>
        <div class="listing_upload">
          <el-upload
            class="avatar-uploader"
            :action="action"
            :show-file-list="false"
            :on-change="fileChange"
            :on-success="(res)=>{handleAvatarSuccess(0,res,index)}" v-for="(item,index) in 5" :key="index">
            <img v-if="ruleForm.serial_img[index]" :src="ruleForm.serial_img[index]" class="avatar">
            <template  v-else>
              <i class="el-icon-plus avatar-uploader-icon"></i>
              <p  class="avatar_p">添加上传图片</p>
            </template>
          </el-upload>
        </div>
      </el-form-item>
      <el-form-item label="标的名称" prop="serial_name" >
        <el-input v-model="ruleForm.serial_name" placeholder="请输入标的名称" class="serial_name"></el-input>
      </el-form-item>
      <el-form-item label="标的类型" prop="serial_type" >
        <p class="listing_tips">请确认或修改标的类型</p>
        <el-select v-model="ruleForm.serial_type" 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-item label="标的其他类型" prop="serial_else_type" v-if="ruleForm.serial_type==8">
        <el-input v-model="ruleForm.serial_else_type"    placeholder="请输入标的其他类型" class="listing_input"></el-input>
      </el-form-item>
      <el-form-item label="标的所在地" prop="province">
        <el-select  placeholder="选择具体省份" clearable  filterable v-model="ruleForm.province" class="select_city" @change="changeDate(0)">
          <el-option
          v-for="item in province"
          :key="item.id"
          :label="item.name"
          :value="item.province_code" >
          </el-option>
        </el-select>
        <el-select  placeholder="选择具体城市" clearable  filterable v-model="ruleForm.city" class="select_city" @change="changeDate(1)">
          <el-option
          v-for="item in city"
          :key="item.id"
          :label="item.name"
          :value="item.city_code" >
          </el-option>
        </el-select>
        <el-select  placeholder="选择具体区镇" clearable  filterable v-model="ruleForm.area" class="select_city">
          <el-option
          v-for="item in area"
          :key="item.id"
          :label="item.name"
          :value="item.area_code">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="标的基本情况" prop="asset_file" >
        <p class="listing_tips">
          请如实并详细地填写资资产的基本情况
          <a class="listing_button" v-if="means.account_type" style="margin-left:15px" :href="means.account_type==1? means.file[7]: means.file[6]" target="_blank" rel="nofollow">下载模板</a>
        </p>
        <el-upload
          class="upload-demo"
          :action="action1"
          :show-file-list="false"
          :on-error="handleAvatarError"
          list-type="picture"
          :on-success="(res,file,index)=>{handleAvatarSuccess1(res,file,'asset_file')}"
          >
          <button class="listing_button">上传文件</button>
        </el-upload>
        <!-- <mavon-editor
          v-model="ruleForm.serial_content"
          :subfield="false" ref="md" :boxShadow="false"
          @imgAdd="$imgAdd" @change="change"
          class="listing_editor"/> -->
        <div class="upload_file">
          <div class="listing_tips1" v-if="ruleForm.asset_file">
            已上传文件：
            <div class="table_right_item" >
              <span >{{file_name.asset_file}}</span>
              <i class="el-icon-close" @click="deleteUrl('asset_file')"></i>
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item label="挂牌时长" prop="cartellino_time_id" >
        <el-select  placeholder="选择挂牌时长" clearable  filterable v-model="ruleForm.cartellino_time_id" class="select_city1">
          <el-option
          v-for="item in price"
          :key="item.id"
          :label="item.name"
          :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="标的描述及挂牌方报价" prop="serial_describe" >
        <el-input
          type="textarea"
          :rows="4"
          class="serial_name"
          placeholder="请输入内容"
          v-model="ruleForm.serial_describe">
        </el-input>
      </el-form-item>
      <el-form-item label="标的是否存在抵押情况" prop="serial_guaranty" >
        <el-input
          type="textarea"
          :rows="4"
          class="serial_name"
          placeholder="请输入内容"
          v-model="ruleForm.serial_guaranty">
        </el-input>
      </el-form-item>
      <el-form-item label="其他标的材料" :prop="ruleForm.buy_mode==2?'serial_img' :'' " >
        <p class="listing_tips">
          请上传与标的相关的证明材料（线上交易请在此处上传相关资产）
        </p>
        <el-upload
          class="upload-demo"
          :action="action1"
          :show-file-list="false"
          :on-error="handleAvatarError"
          list-type="picture"
          :on-success="(res,file,index)=>{handleAvatarSuccess1(res,file,'else_serial_file')}"
          >
          <button class="listing_button">上传文件</button>
        </el-upload>
        <div class="upload_file" v-if="ruleForm.else_serial_file.length!=0">
          <div class="listing_tips1" style="display:block">
            已上传文件：
            <div class="table_right_item" v-for="(item,index) in  file_name.else_serial_file " :key="index">
              <span >{{item.name}}</span>
              <i class="el-icon-close" @click="deleteUrl('else_serial_file',index)"></i>
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item label="信息公告期限" prop="info_notice_time" >
        <el-date-picker
          v-model="ruleForm.info_notice_time"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="挂牌类型" prop="cartellino_type" >
        <el-radio v-model="ruleForm.cartellino_type" :label="1">协议</el-radio>
        <!-- <el-radio v-model="ruleForm.cartellino_type" :label="2">拍卖</el-radio> -->
      </el-form-item>
      <el-form-item label="标的单价" prop="price">
        <el-input v-model="ruleForm.price"  onkeyup="value=value.replace(/[^\d]/g,'')"  placeholder="请输入单个标的的价格" class="listing_input"></el-input>
      </el-form-item>
      <div class="listing_flex">
        <el-form-item label="标的单位" prop="asset_unit" >
          <el-input v-model="ruleForm.asset_unit"   placeholder="请输入单个标的单位的量词" class="listing_input"></el-input>
        </el-form-item>
        <el-form-item label="挂牌数量" prop="count">
          <el-input v-model="ruleForm.count"  onkeyup="value=value.replace(/[^\d]/g,'')"  placeholder="请输入需要挂牌资产的数量" class="listing_input"></el-input>
        </el-form-item>
      </div>
      <el-form-item label="起购数量" prop="pay_count">
        <el-input v-model="ruleForm.pay_count"  onkeyup="value=value.replace(/[^\d]/g,'')"  placeholder="请输入购买时单次至少购买数量" class="listing_input"></el-input>
      </el-form-item>
      <el-form-item label="付款方式" prop="pay_mode" >
        <el-radio v-model="ruleForm.pay_mode" :label="1">网银支付</el-radio>
        <el-radio v-model="ruleForm.pay_mode" :label="2">对公转账</el-radio>
        <span class="listing_tips">交易金额大于200万时系统自动选择对公转账</span>
      </el-form-item>
      <el-form-item label="成交价款支付方式" prop="payment_way" >
        <el-radio v-model="ruleForm.payment_way" :label="1">一次性付款</el-radio>
        <el-radio v-model="ruleForm.payment_way" :label="2">分期付款</el-radio>
      </el-form-item>
      <el-form-item label="成交价款支付期限" prop="payment_day" >
        <!-- <el-date-picker
          v-model="ruleForm.payment_day"
          type="date"
          placeholder="选择日期">
        </el-date-picker> -->
        <el-input v-model="ruleForm.payment_day"  onkeyup="value=value.replace(/[^\d]/g,'')"  placeholder="请输入成交价款支付期限" class="listing_input"></el-input>
      </el-form-item>
      <el-form-item label="摘牌方资格条件" prop="buy_condition" >
        <el-input
          type="textarea"
          :rows="4"
          class="serial_name"
          placeholder="请输入内容"
          v-model="ruleForm.buy_condition">
        </el-input>
      </el-form-item>
      <el-form-item label="是否交纳保证金" prop="is_earnest_money" >
        <el-radio v-model="ruleForm.is_earnest_money" :label="1">是</el-radio>
        <el-radio v-model="ruleForm.is_earnest_money" :label="0">否</el-radio>
      </el-form-item>
      <template v-if="ruleForm.is_earnest_money==1">
        <el-form-item label="交纳金额" prop="earnest_money"  class="listing_input1_lable">
          人民币
          <el-input v-model.number="ruleForm.earnest_money"  onkeyup="value=value.replace(/[^\d]/g,'')"  placeholder="请输入金额" class="listing_input1"></el-input>
          万元
        </el-form-item>
        <el-form-item label="交纳时间" prop="submit_earnestmoney_type" class="listing_input1_lable">
          <el-radio v-model="ruleForm.submit_earnestmoney_type" :label="1">意向摘牌方在提交摘牌申请时交纳保证金</el-radio>
          <el-radio v-model="ruleForm.submit_earnestmoney_type" :label="2">
            意向摘牌方经资格确认后
            <el-input v-model="ruleForm.submit_earnestmoney_day"  onkeyup="value=value.replace(/[^\d]/g,'')"  placeholder="请输入" class="listing_input1"></el-input>
            个工作日内交纳
          </el-radio>
        </el-form-item>
        <el-form-item label="交纳方式" prop="submit_earnestmoney_way" >
          <el-radio v-model="ruleForm.submit_earnestmoney_way" :label="1">支票</el-radio>
          <el-radio v-model="ruleForm.submit_earnestmoney_way" :label="2">电汇</el-radio>
          <el-radio v-model="ruleForm.submit_earnestmoney_way" :label="3">网上转账</el-radio>
        </el-form-item>
        <el-form-item label="保证金处置方式" prop="earnestmoney_dispose" >
          <el-radio v-model="ruleForm.earnestmoney_dispose" :label="1">直接退回 </el-radio>
          <el-radio v-model="ruleForm.earnestmoney_dispose" :label="2">成功摘牌后转为成交价款的一部分</el-radio>
        </el-form-item>
      </template>
      <el-form-item label="申请承诺文件" prop="promise_file">
        <p class="listing_tips">
          请上传申请承诺文件
          <a class="listing_button" style="margin-left:15px" :href="means.apply_promise_file" target="_blank" rel="nofollow">下载模板</a>
        </p>

        <el-upload
          class="upload-demo"
          :action="action1"
          :show-file-list="false"
          :on-error="handleAvatarError"
          list-type="picture"
          :on-success="(res,file,index)=>{handleAvatarSuccess1(res,file,'promise_file')}"
          >
          <button class="listing_button">上传文件</button>
        </el-upload>
        <div class="upload_file" v-if="ruleForm.promise_file!=''">
          <div class="listing_tips1">
            已上传文件：
            <div class="table_right_item" >
              <span >{{file_name.promise_file}}</span>
              <i class="el-icon-close" @click="deleteUrl('promise_file')"></i>
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item label="其他披露事项" prop="announcements" >
        <el-input
          type="textarea"
          :rows="4"
          class="serial_name"
          placeholder="请输入内容"
          v-model="ruleForm.announcements">
        </el-input>
      </el-form-item>
      <el-form-item label="附件" >
        <p class="listing_tips">请上传人才产权评价报告</p>

        <el-upload
          class="upload-demo"
          :action="action1"
          :show-file-list="false"
          :on-error="handleAvatarError"
          list-type="picture"
          :on-success="(res,file,index)=>{handleAvatarSuccess1(res,file,'accessory')}"
          >
          <button class="listing_button">上传文件</button>
        </el-upload>
        <div class="upload_file" v-if="ruleForm.accessory!=''">
          <div class="listing_tips1">
            已上传文件：
            <div class="table_right_item" >
              <span >{{file_name.accessory}}</span>
              <i class="el-icon-close" @click="deleteUrl('accessory')"></i>
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item label="业务咨询电话" >
        <el-input v-model="ruleForm.hotline"  onkeyup="value=value.replace(/[^\d]/g,'')"  placeholder="请输入业务咨询电话" class="listing_input"></el-input>
      </el-form-item>
    </el-form>
    <div class="footer" >
      <el-button class="submit" @click="submit" v-if="query.type!=0" :loading="loading">提交资料</el-button>
      <!-- <div style="margin-top:10px">
        <el-checkbox v-model="checked" :true-label=1 :false-label=2></el-checkbox>
        <span class="footer_span">已阅读并同意</span>
        <span class="footer_span1" @click="goAgreement()">《人才产权挂牌申请与承诺》</span>
      </div> -->
    </div>
    <!-- 添加黑名单 -->
    <el-dialog title="资产挂牌付款凭证" :visible.sync="editVisible" width="50%">
        <p class="recordTips">请上传资产挂牌付款凭证</p>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-change="fileChange"
          :on-success="(res)=>{handleAvatarSuccess(1,res)}">
          <img v-if="ruleForm.payment_document" :src="ruleForm.payment_document" class="avatar">
          <template  v-else>
            <i class="el-icon-plus avatar-uploader-icon"></i>
            <p  class="avatar_p">添加上传图片</p>
          </template>
        </el-upload>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editVisible = false">取 消</el-button>
            <el-button type="primary" @click="addBlacklist">确 定</el-button>
        </span>
    </el-dialog>
  </div>
</template>
<script>
import { mavonEditor } from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import {get_asset_type,getProvince,getCity,getArea,cartellino,getPrice,assetInfo,update_cartellino,uploadimg ,getAccountInfo} from '../../../api/index'
export default {
  data(){
    return{
      host:'http://wenhua.xingtongworld.com',
      action:'http://wenhua.xingtongworld.com/api/Index/uploadimg',
      action1:'http://wenhua.xingtongworld.com/api/Index/uploadFile',
      query:{
        id:'',
        type:1
      },
      checked:1,
      isTypeOther:false,
      editVisible:false,
      options:[
        {value: 1,label: '知识产权（著作权、专利权、专有技术、商标专有权）'},
        {value: 2,label: '销售网络及客户关系'},
        {value: 3,label: '特许经营权'},
        {value: 4,label: '合同权益'},
        {value: 5,label: '域名'},
        {value: 6,label: '商誉'},
        {value: 7,label: '时间和档期'},
        {value: 8,label: '其它'},
      ],
      props: {
        value:'id',
        label:'name',
        leaf:'is_son',
        emitPath:false
      },
      loading:false,
      province:[],
      city:[],
      area:[],
      price:[],
      ruleForm:{
        serial_name:'',
        serial_img:[],
        serial_type:'',
        serial_else_type:'',
        serial_describe:'',
        serial_guaranty:'',
        info_notice_time:[],
        payment_way:'',
        payment_day:'',
        buy_condition:'',
        is_earnest_money:0,
        earnest_money:'',
        submit_earnestmoney_type:'',
        submit_earnestmoney_day:'',
        submit_earnestmoney_way:'',
        earnestmoney_dispose:'',
        announcements:'',
        accessory:'',
        hotline:'',
        else_serial_file:[],
        province:'',
        city:'',
        area:'',
        cartellino_type:'',
        price:'',
        asset_unit:'',
        count:'',
        pay_count:'',
        pay_mode:'',
        cartellino_time_id:'',
        promise_file:'',
        payment_document:'',
      },
      file_name:{
        asset_file:'',
        else_serial_file:[],
      },
      means:{},
      rules:{
        serial_img: [
          { required: true, message: '请上传标的图片', trigger: 'blur' },
        ],
        serial_else_type: [
          { required: true, message: '请输入标的其他类型', trigger: 'blur' },
        ],
        serial_name: [
          { required: true, message: '请输入标的名称', trigger: 'blur' },
        ],
        province: [
          { required: true, message: '请选择标的所在地（省）', trigger: 'blur' },
        ],
        serial_content: [
          { required: true, message: '请输入标的描述', trigger: 'blur' },
        ],
        else_serial_file: [
          { required: true, message: '请上传其他标的材料', trigger: 'blur' },
        ],
        cartellino_time_id: [
          { required: true, message: '请选择挂牌时长', trigger: 'blur' },
        ],
        cartellino_type: [
          { required: true, message: '请选择挂牌类型', trigger: 'blur' },
        ],
        price: [
          { required: true, message: '请输入标的单价', trigger: 'blur' },
        ],
        asset_unit: [
          { required: true, message: '请输入标的单位', trigger: 'blur' },
        ],
        count: [
          { required: true, message: '请输入挂牌数量', trigger: 'blur' },
        ],
        pay_count: [
          { required: true, message: '请输入购买时单次至少购买数量', trigger: 'blur' },
        ],
        pay_mode: [
          { required: true, message: '请选择付款方式', trigger: 'blur' },
        ],
        buy_mode: [
          { required: true, message: '请选择交易方式', trigger: 'blur' },
        ],
        pay_type: [
          { required: true, message: '请选择支付方式', trigger: 'blur' },
        ],
        start_auction_money: [
          { required: true, message: '请输入起拍单价', trigger: 'blur' },
        ],
        bidding_money: [
          { required: true, message: '请输入竞价金额', trigger: 'blur' },
        ],
        serial_type: [
          { required: true, message: '请选择标的类型', trigger: 'blur' },
        ],
        serial_describe: [
          { required: true, message: '请输入标的描述及挂牌方报价', trigger: 'blur' },
        ],
        serial_guaranty: [
          { required: true, message: '请输入标的抵押情况', trigger: 'blur' },
        ],
        info_notice_time: [
          { required: true, message: '请选择信息公告期限', trigger: 'blur' },
        ],
        payment_way: [
          { required: true, message: '请选择成交价款支付方式', trigger: 'blur' },
        ],
        payment_day: [
          { required: true, message: '请输入成交价款支付期限', trigger: 'blur' },
        ],
        buy_condition: [
          { required: true, message: '请输入摘牌方资格条件', trigger: 'blur' },
        ],
        is_earnest_money: [
          { required: true, message: '请选择是否要保证金', trigger: 'blur' },
        ],
        earnest_money: [
          { required: true, message: '请输入保证金金额', trigger: 'blur' },
        ],
        submit_earnestmoney_type: [
          { required: true, message: '请选择交纳时间', trigger: 'blur' },
        ],
        submit_earnestmoney_way: [
          { required: true, message: '请选择交纳方式', trigger: 'blur' },
        ],
        earnestmoney_dispose: [
          { required: true, message: '请选择保证金处置方式', trigger: 'blur' },
        ],
        promise_file: [
          { required: true, message: '请上传申请承诺文件', trigger: 'blur' },
        ],
        asset_file: [
          { required: true, message: '请上传标的基本情况', trigger: 'blur' },
        ],
      },
    }
  },
  components: {
    mavonEditor
  },
  created(){
    if(this.$route.query.id){
      this.query=this.$route.query
      this.getAssetInfo()
    }
    this.getAccountInfo()
    // this.get_asset_type();
    this.getProvince();
    this.getPrice()
  },
  methods:{
    addBlacklist(){
      this.submit()
    },
    goAgreement(){
      let type
      if (this.means.account_type==1) {
        type=1
      }else{
        type=2
      }
      let routeData = this.$router.resolve({path: "/agreement",query: {type:type}});
      window.open(routeData.href, '_blank');
    },
    //获取资料信息
    getAccountInfo(){
      let data={
        open_account_type:'enter_shop'
      }
      getAccountInfo(data).then(res => {
        console.info(res)
        if (res.code==100) {
          if(res.data!=null){
            res.data.establish_time=res.data.establish_time*1000
            res.data.check_message = res.data.check_message.replace(/\n/gm, "<br/>")
            this.means=res.data
          }
        }
      });
    },
    changeType(val,opt){
      const checkedNodes = this.$refs['cascaderUnit'].getCheckedNodes()
      console.log(checkedNodes) // 获取当前点击的节点
      if (checkedNodes[0].data.type==1) {
        this.isTypeOther=true
      }else{
        this.isTypeOther=false
      }
    },
    deleteUrl(key,index){
      if(key=="else_file"){
        this.ruleForm.else_file[index].splice(index,1)
        this.file_name.else_file[index].splice(index,1)
        if(this.ruleForm.else_file.length==0){
          this.file_name[key]=[];
          this.ruleForm[key]=[]
        }
      }else{
        this.file_name[key]='';
        this.ruleForm[key]=''
      }
    },
    handleAvatarSuccess1(res,file,index){
      console.info(file)
      console.info(res)
      if(res.code==1){
        let contract={
          url:this.host+res.data.img_url,
          name:file.name
        };
        // this.ruleForm[index]=contract
        if (index=='else_serial_file') {
          this.ruleForm[index].push(this.host+res.data.img_url)
          this.file_name[index].push(contract)
        }else{
          this.$set(this.ruleForm, index, contract.url);
          this.$set(this.file_name, index, file.name);
        }

        console.info(this.ruleForm)
        this.$message.success('文件上传成功！');
      }else{
        this.$message.error(res.msg);
      }
    },
    handleAvatarError(){
      this.$message.error('文件上传失败！');
    },
    //获取资产详情
    getAssetInfo(){
      assetInfo(this.query).then(res=>{
        console.info(res)
        if(res.code==100){
          res.data.province=parseInt(res.data.province)
          res.data.city=parseInt(res.data.city)
          res.data.area=parseInt(res.data.area)
          res.data.pay_type=[parseInt(res.data.pay_type)]
          if (res.data.else_file==null) {
            res.data.else_file=[]
          }
          this.ruleForm=res.data
          this.getCity()
          this.getArea()
        }else{
          this.$message.error(res.msg)
        }
      })
    },
    getPrice(){
      getPrice().then(res => {
        console.info(res)
        if(res.code==100){
          this.price=res.data
        }
      })
    },
    changeDate(type){
      if(type==0){
        this.getCity()
      }else if(type==1){
        this.getArea()
      }
    },
    getProvince(){
      getProvince().then(res => {
        if(res.code==100){
          this.province=res.list
        }
      })
    },
    getCity(){
      let data={
        code:this.ruleForm.province
      }
      getCity(data).then(res=>{
        if(res.code==100){
          this.city=res.list
        }
      })
    },
    getArea(){
      let data={
        code:this.ruleForm.city
      }
      getArea(data).then(res=>{
        if(res.code==100){
          this.area=res.list
        }
      })
    },
    get_asset_type(){
      get_asset_type().then(res=>{
        if(res.code==100){
          this.options=res.data
        }
      })
    },
    submit(){
      console.info(this.ruleForm)
        // this.$message.error('请先勾选《人才产权挂牌申请与承诺》')
        this.$refs["ruleForm1"].validate((valid) => {
          if(valid){
            if (this.ruleForm.payment_document=='') {
              this.editVisible=true
            }else{
              this.loading=true
              if(this.query.type==2){
                this.update_cartellino()
              }else{
                this.cartellino()
              }
            }
          }
        })
    },
    //资产挂牌
    cartellino(){
      cartellino(this.ruleForm).then(res=>{
        console.info(res)
        this.loading=false
        if(res.code==100){
          this.$message.success('上传成功！请等待审核~');
          this.$router.push({path:'/examine'});
        }else{
          this.$message.error(res.msg);
        }
      })
    },
    //修改资产挂牌
    update_cartellino(){
      update_cartellino(this.ruleForm).then(res=>{
        console.info(res)
        this.loading=false
        if(res.code==100){
          this.$message.success('修改成功！请等待审核~');
          this.$router.push({path:'/examine'});
        }else{
          this.$message.error(res.msg);
        }
      })
    },
    // 将图片上传到服务器，返回地址替换到md中
    $imgAdd(pos, $file){
      var formdata = new FormData();
      formdata.append('file', $file);
      // 这里没有服务器供大家尝试，可将下面上传接口替换为你自己的服务器接口
      // let data =
      uploadimg(formdata).then(res=>{
        if (res.code==1) {
          let url=this.host + res.data.img_url;
          this.$refs.md.$img2Url(pos, url);
        }
      })
      // this.$axios({
      //     url: this.action,
      //     method: 'post',
      //     data: formdata,
      //     headers: { 'Content-Type': 'multipart/form-data' },
      // }).then((url) => {
      //     this.$refs.md.$img2Url(pos, url);
      // })
    },
    change(value, render){
      // render 为 markdown 解析后的结果
      this.html = render;
    },
    fileChange(file){
      const typeArr = ['image/png', 'image/gif', 'image/jpeg', 'image/jpg'];
      const isJPG = typeArr.indexOf(file.raw.type) !== -1;
      const isLt3M = file.size / 1024 / 1024 < 10;
      if (!isJPG) {
        this.$message.error('只能是图片!');
        this.$refs.upload.clearFiles();
        return;
      }
      if (!isLt3M) {
        this.$message.error('上传图片大小不能超过 10MB!');
        this.$refs.upload.clearFiles();
        return;
      }
    },
    overstep(){
      this.$message.error('只能上传一张图片！');
    },
    handleAvatarSuccess(type,res,index) {
      console.info(res)
      if(res.code == 1){
        let url=this.host + res.data.img_url;
        if(type==0){
          console.info(index)
          if(this.ruleForm.serial_img[index]){
            // this.ruleForm.serial_img[index]=url
            this.$set(this.ruleForm.serial_img,index,url)
          }else{
            this.ruleForm.serial_img.push(url)
          }
          console.info(this.ruleForm.serial_img)
        }else if(type==1){
          this.$set(this.ruleForm,'payment_document',url)
        }
      }
    }
  }
}
</script>
<style scoped>
  .body{
    margin-top: 15px;
  }
  .title{
    color: #333333;
    font-size: 18px;
    margin-bottom: 15px;
  }
  .listing_title1{
    display: flex;
    align-items: center;
    width: 800px;
    justify-content: space-between;
    margin-bottom: 15px;
  }
  .listing_title{
    background-color: #C94D4D;
    color: white;
    font-size: 16px;
    height: 40px;
    line-height: 40px;
    padding-left: 20px;
    margin-bottom: 10px;
  }
  .upload_file{
    margin: 15px 0;
  }
  .listing_flex{
    display: flex;
  }
  .listing_editor{
    min-height: 500px;
    width: 800px;
    border: 1px solid #D1D1D1;
  }
  .listing_title1_right{
    width: 160px;
    display: flex;
    justify-content: space-between;
  }
  .listing_button{
    display: inline-block;
    width: 70px;
    height: 32px;
    border-radius: 5px;
    border: 1px solid #E7B0B0;
    background: #F3D8D8;
    font-size: 14px;
    color: rgba(201, 76, 76, 0.898039215686275);
    text-align: center;
    cursor: pointer;
  }
  .listing_upload{
    display: flex;
    margin-top: 10px;
  }
  .select_type{
    width: 800px;
    height: 50px;
    color: #7F7F7F;
    padding-left: 15px;
    line-height: 50px;
    background-color: #FDF8F8;
    border: 1px solid #F3D8D8;
    margin-bottom: 10px;
  }
  .listing_tips1,listing_tips{
    font-size: 14px;
    color: rgba(127, 127, 127, 0.898039215686275);
  }
  .listing_tips1{
    display: flex;
    align-items: center;
  }
  .table_right_item{
    width: 250px;
    display: flex;
    align-items: center;
    color: #333333;
    font-size: 14px;
    justify-content: space-between;
  }
  .table_right_item>span{
    cursor: pointer;
  }
  .table_right_item:hover{
    color: #D85E5E;
  }
  .table_right_item>i{
    cursor: pointer;
  }
  .listing_tips:hover{
    color: #D85E5E;
  }
  .avatar_p{
    font-size: 14px;
    color: #7F7F7F;
  }
  .serial_name{
    width: 800px;
  }
  .select_city{
    width: 200px;
    margin-right: 15px;
  }
  .select_city1{
    width: 400px;
  }
  .listing_input{
    width: 300px;
  }
  .listing_input1{
    width: 150px;
  }
  .listing_input1>>>.el-input__inner{
    border: none;
    border-radius: 0;
    border-bottom: 1px solid #DCDFE6;
  }
  .listing_input1_lable>>>.el-form-item__error{
    left: 45px;
  }
  .footer{
    text-align: center;
    margin-top: 50px;
  }
  .submit{
    width: 340px;
    height: 40px;
    background: -moz-linear-gradient(top, #F8D89F 0%, #D98282 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F8D89F), color-stop(100%,#D98282));
    background: -webkit-linear-gradient(top, #F8D89F 0%,#D98282 100%);
    background: -o-linear-gradient(top, #F8D89F 0%,#D98282 100%);
    background: -ms-linear-gradient(top, #F8D89F 0%,#D98282 100%);
    background: linear-gradient(to bottom, #F8D89F 0%,#D98282 100%);
    font-size: 14px;
    color: #FFFFFF;
    border: none;
    margin-bottom: 10px;
  }



  .avatar-uploader{
    margin-right: 15px;
  }
  .ruleForm>>>.el-form-item__label{
    padding-left: 20px;
    text-align: right;
    width: 185px !important;
  }
  .ruleForm>>>.el-form-item__content{
    margin-left: 185px !important;
  }
  .avatar-uploader >>> .el-upload--text{
      width: 120px;
      height: 120px;
      /* line-height: 120px; */
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
  }
  .avatar-uploader .el-upload {
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
      border-color: #409EFF;
  }
  .avatar-uploader-icon {
      font-size: 40px;
      color: #8c939d;
      width: 40px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      color: #CB5151;
  }
  .avatar-uploader img{
      width: 120px;
      height: 120px;
      line-height: 120px;
  }
  .footer_span{
    color: rgb(127, 127, 127);
  }
  .footer_span1{
    color: rgb(201, 76, 76);
    text-decoration: underline;
    cursor: pointer;
  }
</style>
