<?php
/**
 * 领导机构新增
 * $Id: government_new.inc,v 1.12020/01/03 11:18:46  Exp $
 * @author lixq
 * @access public
 * @package manager.templates
 */

global $csv_error_msg;

?>
<div id="change">
	<p class="edit_title">领导机构新增</p>
	<div class="edit_content">
		<form id="form" method="post" action="government_new_result.php" enctype="multipart/form-data">
			<p>CSV文件</p>
			<input type="file" name="csv_file" class="input_200" @change="getFile($event)" accept=".csv"/><br />
			<el-button type="primary" class="edit_btn"  @click="submitForm()">新增</el-button>
			<el-button type="primary" class="edit_btn"  @Click="window.location='./government_list.php'" />返回</el-button>
		</form>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
  var vm = new Vue({
    el: 'form',
    data: {
        file: ''
    },
    methods: {
        getFile(event) {
            this.file = event.target.files[0];
            //$('#csv_file').attr("value",this.file);
            console.log(this.file);
        },
        submitForm() {
          if(!this.file){
  					this.$message({
  		            type: 'error',
  		            message: '请选择CSV文件!'
  		          });
  		          return;
  				}
          
  				$('#form').submit();
        }
    }
})
  if(<?=$csv_error_msg?1:0 ?>){
    vm.$message({
      type: 'error',
      message: '<?=$csv_error_msg?>'
    });
  }
})

</script>
