<template>
  <div class="app-container">
  	<div style="margin-bottom:10px">
  		<el-button type="success" @click="addBtn">新增</el-button>
  		<!--<el-button type="success" @click="importBtn">导入</el-button>
  		<el-button type="success" @click="exportTempBtn">模版下载</el-button>-->
  	</div>
    <!--搜索-->
    <el-form class="mt_15" ref="form" inline size="small">
  		<el-form-item label="商品参数">
  			<el-select v-model.trim="searchParm.paramsType" placeholder="请选择">
			    <el-option
			      v-for="item in searchParamsTypeList"
			      :key="item.name"
			      :label="item.name"
			      :value="item.id">
			    </el-option>
			  </el-select>
  		</el-form-item>
  		<el-form-item label="国家">
    		<el-input v-model.trim="searchParm.country" clearable></el-input>
  		</el-form-item>
  		<el-form-item label="账号">
    		<el-input v-model.trim="searchParm.account" clearable></el-input>
  		</el-form-item>
  		<el-form-item label="状态">
  			<el-select v-model.trim="searchParm.status" placeholder="请选择">
			    <el-option
			      v-for="item in statusList"
			      :key="item.name"
			      :label="item.name"
			      :value="item.id">
			    </el-option>
			  </el-select>
  		</el-form-item>
  		<el-form-item>
    		<el-button type="primary" @click="goSearch">搜索</el-button>
    		<el-button type="warning" @click="resetForm">重置</el-button>
  		</el-form-item>
		</el-form>
    <!--表格渲染-->
    <el-table ref="table" border size="small" :data="list" :header-cell-style="{textAlign:'center'}">
      <el-table-column label="商品属性" prop="paramsType" align="center">
      	<template slot-scope="scope">
	     		{{ scope.row.paramsType | getparamsType}}
	     	</template>
      </el-table-column>
    	<el-table-column label="国家" prop="country" align="center"/>
    	<el-table-column label="账号" prop="account" align="center"/>
      <el-table-column label="公司名称" prop="companyName" align="center"/>
      <el-table-column label="加购商品Ids" prop="carGoodIds" align="center"/>
      <el-table-column label="状态" prop="status" align="center">
      	<template slot-scope="scope">
	     		{{ scope.row.status | getStatus}}
	     	</template>
      </el-table-column>
      <el-table-column label="创建时间" prop="createdAt" align="center"/>
      <el-table-column label="修改时间" prop="updatedAt" align="center"/>
      <el-table-column label="操作" width="270" align="left" >
      	<template slot-scope="scope">
			<el-button type="info" @click="getBtnById(scope.row.id)">查看</el-button>
			<span v-if="scope.row.status == 1 || scope.row.status == 4" slot="footer">
  			<el-button type="warning" @click="editById(scope.row.id)" style="margin-left: 0px">修改</el-button>
  		</span>
			<span v-if="scope.row.status == 3" slot="footer">
  			<el-button type="danger" @click="orderSuccessBtn(scope.row.id)">下单成功</el-button>
  		</span>
  		<span v-if="scope.row.status == 5" slot="footer">
  			<el-button type="danger" @click="toBeCatchBtn(scope.row.id)">支付成功</el-button>
  		</span>
  		<!-- 好评 -->
  		<span v-if="scope.row.status == 8" slot="footer">
  			<el-button type="info" @click="getBtnWellReceivedById(scope.row.id)">好评</el-button>
  		</span>
  		
			<span v-if="scope.row.status == 1" slot="footer">
  			<el-button type="danger" @click="delById(scope.row.id)">删除</el-button>
  		</span>
  		<span v-if="scope.row.status == 8" slot="footer">
  			<el-button type="danger" @click="getOrderBtnById(scope.row.id)">订单</el-button>
  		</span>
      	</template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <div class="mt_15">
	    <el-pagination
	      @size-change="handleSizeChange"
	      @current-change="handleCurrentChange"
	      :current-page="searchParm.page"
	      :page-sizes="[10, 20, 30, 40, 50]"
	      :page-size="searchParm.pageSize"
	      layout="total, sizes, prev, pager, next, jumper"
	      :total="total">
	    </el-pagination>
  </div>
  
  <!--新增弹窗-->
  <el-dialog :visible.sync="dialogAddVisible" :title="dialogAddTitle" center width="45%">
  	<div class="dialog-content">
  		 <el-form ref="addParm" size="small" :model="addParm" :rules="rules" label-width="100px">
  		 	<el-form-item label="买家账号" prop="account">
            <el-input v-model.trim="addParm.account" clearable style="width:270px"/>
            <el-button
              type="primary"
              icon="el-icon-search"
              @click="goSearchBuyer"
              style="width:130px"
            >请选择买家</el-button>
        </el-form-item>
	  		<!-- 先选择应用 后才能选择这个  根据应用调用不同的对应的 请求参数 分页查询 -->
      	<el-form-item label="商品参数" prop="paramsType">
	        <el-radio-group v-model.trim="addParm.paramsType" @change="changeCheckRange">
	          <el-radio :label="1">关键词</el-radio>
	          <el-radio :label="2">链接</el-radio>
	        </el-radio-group>
      	</el-form-item>
      	
      	<el-form-item v-if="labelVal === 1">
      		<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in addParm.carGoodKeys" :key="index">		  		
	          
			  		<el-form-item>
			  			<el-button v-if="index+1 == addParm.carGoodKeys.length" @click="addItemKey" type="primary">增加</el-button>
			  			<el-button v-if="index !== 0" @click="deleteItemKey(item,index)" type="danger">删除</el-button>
			  		</el-form-item>
	  			</div>
        </el-form-item>
        
        
         <el-form-item v-if="labelVal === 1">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in addParm.carGoodKeys" :key="index">		  					  		
			  		<el-form-item label="店铺名称" prop="'carGoodKeys.' + index + 'shopName'">
			    		<el-input v-model.trim="item.shopName" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="关键词" prop="'carGoodKeys.' + index + 'keyWord'">
			    		<el-input v-model.trim="item.keyWord" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="标题" prop="'carGoodKeys.' + index + 'title'">
			    		<el-input v-model.trim="item.title" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="最小价格区间" prop="'carGoodKeys.' + index + 'sectionMin'">
			    		<el-input v-model.trim="item.sectionMin" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="最大价格区间" prop="'carGoodKeys.' + index + 'sectionMax'">
			    		<el-input v-model.trim="item.sectionMax" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="Item" prop="'carGoodKeys.' + index + 'item'">
			    		<el-input v-model.trim="item.item" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="数量" prop="'carGoodKeys.' + index + 'number'">
			    		<el-input v-model.trim="item.number" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="'carGoodKeys.' + index + 'specification'">
			    		<el-input v-model.trim="item.specification" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="'carGoodKeys.' + index + 'color'">
			    		<el-input v-model.trim="item.color" clearable></el-input>
			  		</el-form-item>		
			  		
			  		<el-form-item>
			  			<el-button v-if="index+1 == addParm.carGoodKeys.length" @click="addItemKey" type="primary">增加</el-button>
			  			<el-button v-if="index !== 0" @click="deleteItemKey(item,index)" type="danger">删除</el-button>
			  		</el-form-item>
	  			</div>
				</el-form-item>
          
        <el-form-item v-if="labelVal === 2">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in addParm.carGoodLinks" :key="index">		  		
		  			<el-form-item label="链接" prop="'carGoodLinks.' + index + 'link'">
			    		<el-input v-model.trim="item.link" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="数量" prop="'carGoodLinks.' + index + 'number'">
			    		<el-input v-model.trim="item.number" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="'carGoodLinks.' + index + 'specification'">
			    		<el-input v-model.trim="item.specification" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="'carGoodLinks.' + index + 'color'">
			    		<el-input v-model.trim="item.color" clearable></el-input>
			  		</el-form-item>		  		
			  		<el-form-item>
			  			<el-button v-if="index+1 == addParm.carGoodLinks.length" @click="addItemLink" type="primary">增加</el-button>
			  			<el-button v-if="index !== 0" @click="deleteItemLink(item,index)" type="danger">删除</el-button>
			  		</el-form-item>
	  			</div>
				</el-form-item>
			</el-form>
  	</div>
  	<span slot="footer">
  		<el-button type="info" @click="sureAddCancle('addParm')">取消</el-button>
      <el-button type="primary" @click="sureAdd('addParm')">确认</el-button>
  	</span>
  </el-dialog>
  
  
  <!-- 买家弹窗 -->
	<el-dialog :visible.sync="dialogBuyerVisible" :title="dialogBuyerTitle" center width="75%">
	  <div class="dialog-content">
	    <!--搜索-->
	    <el-form class="mt_15" ref="form" inline size="small">
	      <el-form-item label="账号">
	        <el-input v-model.trim="searchBuyerParm.account" clearable placeholder="账号"></el-input>
	      </el-form-item>
	      <el-form-item label="昵称">
	        <el-input v-model.trim="searchBuyerParm.nickName" clearable></el-input>
	      </el-form-item>
	      <el-form-item label="密码">
	        <el-input v-model.trim="searchBuyerParm.pwd" clearable></el-input>
	      </el-form-item>
	      <el-form-item label="公司">
	        <el-select v-model.trim="searchBuyerParm.companyId" placeholder="请选择">
	          <el-option
	            v-for="item in companys"
	            :key="item.name"
	            :label="item.name"
	            :value="item.id"
	          ></el-option>
	        </el-select>
	      </el-form-item>
	      <el-form-item>
	        <el-button type="primary" @click="goSearchBuyer">搜索</el-button>
	        <el-button type="warning" @click="resetBuyerForm">重置</el-button>
	      </el-form-item>
	    </el-form>
	    <!--表格渲染-->
	    <el-table
	      ref="table"
	      border
	      size="small"
	      :data="buyerList"
	      :header-cell-style="{textAlign:'center'}"
	      :cell-style="{textAlign:'center'}"
	    >
	      <el-table-column label="序号" type="index" width="50" />
	      <el-table-column label="账号" prop="account" />
	      <el-table-column label="所属国家" prop="contntryShort" />
	      <el-table-column label="昵称" prop="nickName" />
	      <el-table-column label="密码" prop="pwd" />
	      <el-table-column label="公司" prop="companyName" />
	      <el-table-column label="平台" prop="platformName" />
	      <el-table-column label="VPNIP" prop="ipAddress" />
	      <el-table-column label="信用卡卡号" prop="number" />
	      <el-table-column label="州" prop="state" />
	      <el-table-column label="国家" prop="country" />
	      <el-table-column label="地址1" prop="addressline1" />
	      <el-table-column label="占用状态" prop="status">
	        <template slot-scope="scope">{{ scope.row.status | getBuyerStatus}}</template>
	      </el-table-column>
	      <el-table-column label="创建时间" prop="createdAt" />
	      <el-table-column label="修改时间" prop="updatedAt" />
	      <el-table-column label="操作" width="220">
	        <template slot-scope="scope">
	          <el-button type="info" @click="getBuyerBtnById(scope.row.id)">查看</el-button>
			  <el-button type="success" @click="getBuyerById(scope.row)" v-if="buyerId !== scope.row.id">选中</el-button>
			  <div v-if="buyerId === scope.row.id">已选中</div>
	        </template>
	      </el-table-column>
	    </el-table>
	    <!--分页-->
	    <div class="mt_15">
	      <el-pagination
	        @size-change="handleSizeChange"
	        @current-change="handleCurrentChange"
	        :current-page="searchBuyerParm.page"
	        :page-sizes="[10, 20, 30, 40, 50]"
	        :page-size="searchBuyerParm.pageSize"
	        layout="total, sizes, prev, pager, next, jumper"
	        :total="total"
	      ></el-pagination>
	    </div>
	  </div>
	</el-dialog>
  
  <!--导入  importBtn-->
  <el-dialog :visible.sync="dialogImportVisible" :title="dialogImportTitle" center width="22%">
  	<div class="dialog-content">
	  		<el-upload
				  class="upload-demo"
				  drag
				  ref="upload"
				  :action="uploadFileUrl"
				  :headers="uploadHeaders"
				  :show-file-list = "false"
				  :on-success="uploadSuccess"
				  :before-upload="beforeAvatarUpload"
				  multiple>
				  <i class="el-icon-upload"></i>
				  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
				  <div class="el-upload__tip" slot="tip">只能上传xlsl文件，且不超过10M</div>
				</el-upload>
  	</div>
  </el-dialog>
  
  <!--修改弹窗-->
  <el-dialog :visible.sync="dialogEditVisible" :title="dialogEditTitle" center width="45%">
  	<div class="dialog-content">
  		<el-form ref="editParm" size="small" :model="editParm" :rules="rules" label-width="100px">
	  		<el-form-item label="买家账号" prop="account">
	        <el-input v-model.trim="editParm.account" :disabled="true" style="width:200px" />
	        <el-button
	          type="primary"
	          icon="el-icon-search"
	          @click="goSearchBuyer"
	          style="width:130px"
	        >请选择设</el-button>
		    </el-form-item>
		    
	  		<!-- 先选择应用 后才能选择这个  根据应用调用不同的对应的 请求参数 分页查询 -->
      	<el-form-item label="商品参数" prop="paramsType">
	        <el-radio-group v-model.trim="editParm.paramsType" @change="changeCheckRange">
	          <el-radio :label="1">关键词</el-radio>
	          <el-radio :label="2">链接</el-radio>
	        </el-radio-group>
      	</el-form-item>
      	
      	
      	<el-form-item v-if="labelVal === 1">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in editParm.carGoodKeys" :key="index">		 
			    	<el-input v-model.trim="item.id" type="hidden" clearable></el-input>
			  		<el-form-item label="店铺名称" prop="shopName">
			    		<el-input v-model.trim="item.shopName" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="关键词" prop="keyWord">
			    		<el-input v-model.trim="item.keyWord" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="标题" prop="title">
			    		<el-input v-model.trim="item.title" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="最小价格区间" prop="sectionMin">
			    		<el-input v-model.trim="item.sectionMin" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="最大价格区间" prop="sectionMax">
			    		<el-input v-model.trim="item.sectionMax" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="Item" prop="item">
			    		<el-input v-model.trim="item.item" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="数量" prop="number">
			    		<el-input v-model.trim="item.number" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="specification">
			    		<el-input v-model.trim="item.specification" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="color">
			    		<el-input v-model.trim="item.color" clearable></el-input>
			  		</el-form-item>		
			  		
			  		<el-form-item>
			  			<el-button v-if="index+1 == editParm.carGoodKeys.length" @click="addEditItemKey" type="primary">增加</el-button>
			  			<el-button v-if="index !== 0" @click="deleteEditItemKey(item,index)" type="danger">删除</el-button>
			  		</el-form-item>
	  			</div>
				</el-form-item>
          
        <el-form-item v-if="labelVal === 2">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in editParm.carGoodLinks" :key="index">		  
        		<el-input v-model.trim="item.id" type="hidden" clearable></el-input>
		  			<el-form-item label="链接" prop="link">
			    		<el-input v-model.trim="item.link" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="数量" prop="number">
			    		<el-input v-model.trim="item.number" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="specification">
			    		<el-input v-model.trim="item.specification" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="color">
			    		<el-input v-model.trim="item.color" clearable></el-input>
			  		</el-form-item>		  		
			  		<el-form-item>
			  			<el-button v-if="index+1 == editParm.carGoodLinks.length" @click="addEditItemLink" type="primary">增加</el-button>
			  			<el-button v-if="index !== 0" @click="deleteEditItemLink(item,index)" type="danger">删除</el-button>
			  		</el-form-item>
	  			</div>
				</el-form-item>
			</el-form>
  	</div>
  	<span slot="footer">
  		<el-button type="info" @click="sureEditCancle('editParm')">取消</el-button>
      <el-button type="primary" @click="sureEdit('editParm')">确认</el-button>
  	</span>
  </el-dialog>
  
  <!--详情弹窗-->
  <el-dialog :visible.sync="dialogDetailVisible" :title="dialogDetailTitle" center width="45%">
  	<div class="dialog-content">
  		 <el-form ref="form" size="small" label-width="100px">
	  		<el-form-item label="买家账号" prop="account">
	    		<el-input v-model.trim="detailParm.account" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<!-- 先选择应用 后才能选择这个  根据应用调用不同的对应的 请求参数 分页查询 -->
      	<el-form-item label="商品参数" prop="paramsType">
	        <el-radio-group v-model.trim="detailParm.paramsType" @change="changeCheckRange">
	          <el-radio :label="1" :disabled="true">关键词</el-radio>
	          <el-radio :label="2" :disabled="true">链接</el-radio>
	        </el-radio-group>
      	</el-form-item>
      	
      	<el-form-item v-if="labelVal === 1">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in detailParm.carGoodKeys" :key="index">		 
			    	<el-input v-model.trim="item.id" type="hidden" clearable></el-input>
			  		<el-form-item label="店铺名称" prop="shopName">
			    		<el-input v-model.trim="item.shopName" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="关键词" prop="keyWord">
			    		<el-input v-model.trim="item.keyWord" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="标题" prop="title">
			    		<el-input v-model.trim="item.title" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="最小价格区间" prop="sectionMin">
			    		<el-input v-model.trim="item.sectionMin" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="最大价格区间" prop="sectionMax">
			    		<el-input v-model.trim="item.sectionMax" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="Item" prop="item">
			    		<el-input v-model.trim="item.item" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="数量" prop="number">
			    		<el-input v-model.trim="item.number" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="specification">
			    		<el-input v-model.trim="item.specification" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="color">
			    		<el-input v-model.trim="item.color" clearable></el-input>
			  		</el-form-item>		
	  			</div>
				</el-form-item>
          
        <el-form-item v-if="labelVal === 2">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in detailParm.carGoodLinks" :key="index">		  
        		<el-input v-model.trim="item.id" type="hidden" clearable></el-input>
		  			<el-form-item label="链接" prop="link">
			    		<el-input v-model.trim="item.link" clearable></el-input>
			  		</el-form-item>
			  		<el-form-item label="数量" prop="number">
			    		<el-input v-model.trim="item.number" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="specification">
			    		<el-input v-model.trim="item.specification" clearable></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="color">
			    		<el-input v-model.trim="item.color" clearable></el-input>
			  		</el-form-item>		  		
	  			</div>
				</el-form-item>
				
	  		<el-form-item label="执行结果" prod="response">
	    		<el-input v-model.trim="detailParm.response" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		<el-form-item label="状态" prod="status">
  			<el-select v-model.trim="detailParm.status" :disabled="true" placeholder="请选择">
			    <el-option
			      v-for="item in detailStatusList"
			      :key="item.name"
			      :label="item.name"
			      :value="item.id">
			    </el-option>
			  </el-select>
			  </el-form-item>
			</el-form>
  	</div>
  </el-dialog>
  
  
  <!--好评-回显-弹窗-->
  <el-dialog :visible.sync="dialogWellReceivedVisible" :title="dialogWellReceivedTitle" center width="45%">
  	<div class="dialog-content">
  		 <el-form ref="form" size="small" label-width="100px">
	  		<el-form-item label="买家账号" prop="account">
	    		<el-input v-model.trim="detailParm.account" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<!-- 先选择应用 后才能选择这个  根据应用调用不同的对应的 请求参数 分页查询 -->
      	<el-form-item label="商品参数" prop="paramsType">
	        <el-radio-group v-model.trim="detailParm.paramsType" @change="changeCheckRange">
	          <el-radio :label="1" :disabled="true">关键词</el-radio>
	          <el-radio :label="2" :disabled="true">链接</el-radio>
	        </el-radio-group>
      	</el-form-item>
      	
      	<el-form-item v-if="labelVal === 1">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in detailParm.carGoodKeys" :key="index">		 
			    	<el-input v-model.trim="item.id" type="hidden" clearable></el-input>
			  		<el-form-item label="店铺名称" prop="shopName">
			    		<el-input v-model.trim="item.shopName" :disabled="true"></el-input>
			  		</el-form-item>
			  		<el-form-item label="关键词" prop="keyWord">
			    		<el-input v-model.trim="item.keyWord" :disabled="true"></el-input>
			  		</el-form-item>
			  		<el-form-item label="标题" prop="title">
			    		<el-input v-model.trim="item.title" :disabled="true"></el-input>
			  		</el-form-item>
			  		<el-form-item label="最小价格区间" prop="sectionMin">
			    		<el-input v-model.trim="item.sectionMin" :disabled="true"></el-input>
			  		</el-form-item>
			  		<el-form-item label="最大价格区间" prop="sectionMax">
			    		<el-input v-model.trim="item.sectionMax" :disabled="true"></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="Item" prop="item">
			    		<el-input v-model.trim="item.item" :disabled="true"></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="数量" prop="number">
			    		<el-input v-model.trim="item.number" :disabled="true"></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="specification">
			    		<el-input v-model.trim="item.specification" :disabled="true"></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="color">
			    		<el-input v-model.trim="item.color" :disabled="true"></el-input>
			  		</el-form-item>	
			  		
			  		<el-form-item label="评论" prop="comment">
			    		<el-input v-model.trim="item.comment" clearable></el-input>
			  		</el-form-item>
						<el-input v-model.trim="item.paths" type="hidden" clearable></el-input>
				  	<el-upload
						  class="upload-demo"
						  :data = "updateFileType"
						  :action="uploadFileImgUrl"
						  :on-preview="handlePreview"
						  :headers="uploadHeaders"
						  :on-remove="handleRemove.bind(null, {'index':index, 'paramsType': 1})"
						  :on-success="uploadImgSuccess.bind(null, {'index':index, 'paramsType': 1})"
						  :before-upload="beforeImgUpload"
						  :before-remove="beforeRemove"
						  :file-list="fileList[index]" 
						  list-type="picture">
						  <el-button size="small" type="primary">点击上传</el-button>
							  <div slot="tip" class="el-upload__tip">只能上传img/jpg/png/jpeg文件，且不超过5M</div>
						</el-upload>
						
	  			</div>
				</el-form-item>
          
        <el-form-item v-if="labelVal === 2">
        	<!--带按钮的新增 操作-->
        	<div v-for="(item, index) in detailParm.carGoodLinks" :key="index">		  
        		<el-input v-model.trim="item.id" type="hidden" clearable></el-input>
		  			<el-form-item label="链接" prop="link">
			    		<el-input v-model.trim="item.link"  :disabled="true"></el-input>
			  		</el-form-item>
			  		<el-form-item label="数量" prop="number">
			    		<el-input v-model.trim="item.number"  :disabled="true"></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="规格" prop="specification">
			    		<el-input v-model.trim="item.specification"  :disabled="true"></el-input>
			  		</el-form-item>
			  		
			  		<el-form-item label="颜色" prop="color">
			    		<el-input v-model.trim="item.color"  :disabled="true"></el-input>
			  		</el-form-item>	
			  		
			  		<el-form-item label="评论" prop="comment">
			    		<el-input v-model.trim="item.comment" clearable></el-input>
			  		</el-form-item>
						<el-input v-model.trim="item.paths" type="hidden" clearable></el-input>
				  	<el-upload
						  class="upload-demo"
						  :data = "updateFileType"
						  :action="uploadFileImgUrl"
						  :on-preview="handlePreview"
						  :headers="uploadHeaders"
						  :on-remove="handleRemove.bind(null, {'index':index, 'paramsType':2})"
						  :on-success="uploadImgSuccess.bind(null, {'index':index, 'paramsType':2})"
						  :before-upload="beforeImgUpload"
						  :before-remove="beforeRemove"
						  :file-list="fileList[index]" 
						  list-type="picture">
						  <el-button size="small" type="primary">点击上传</el-button>
							  <div slot="tip" class="el-upload__tip">只能上传img/jpg/png/jpeg文件，且不超过5M</div>
						</el-upload>
	  			</div>
				</el-form-item>
				
	  		<el-form-item label="执行结果" prod="response">
	    		<el-input v-model.trim="detailParm.response" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		<el-form-item label="状态" prod="status">
  			<el-select v-model.trim="detailParm.status" :disabled="true" placeholder="请选择">
			    <el-option
			      v-for="item in detailStatusList"
			      :key="item.name"
			      :label="item.name"
			      :value="item.id">
			    </el-option>
			  </el-select>
			  </el-form-item>
			</el-form>
  	</div>
  	<span slot="footer">
  		<el-button type="info" @click="sureWellReceivedCancle('detailParm')">取消</el-button>
      <el-button type="primary" @click="sureWellReceived('detailParm')">确认</el-button>
  	</span>
  </el-dialog>
  
  
  
  <!--Order详情弹窗-->
  <el-dialog :visible.sync="dialogOrderDetailVisible" :title="dialogOrderDetailTitle" center width="45%">
  	<div class="dialog-content">
  		 <el-form ref="form" size="small" label-width="100px">
	  		<el-form-item label="创建时间" prop="createdAt">
	    		<el-input v-model.trim="orderDetailParm.createdAt" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<el-form-item label="修改时间" prop="updatedAt">
	    		<el-input v-model.trim="orderDetailParm.updatedAt" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<el-form-item label="总金额" prop="amount">
	    		<el-input v-model.trim="orderDetailParm.amount" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<el-form-item label="状态描述" prop="paymentResults">
	    		<el-input v-model.trim="orderDetailParm.paymentResults" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<el-form-item label="店铺名称" prop="shop">
	    		<el-input v-model.trim="orderDetailParm.shop" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<!--<el-form-item label="购买数量" prop="pricesNumber">
	    		<el-input v-model.trim="orderDetailParm.pricesNumber" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<el-form-item label="订单id" prop="orderId">
	    		<el-input v-model.trim="orderDetailParm.orderId" :disabled="true" clearable></el-input>
	  		</el-form-item>
	  		
	  		<el-form-item label="商品名称" prop="shopName">
	    		<el-input v-model.trim="orderDetailParm.shopName" :disabled="true" clearable></el-input>
	  		</el-form-item>-->
	  		
	  		<el-form-item label="时间" prop="orderDate">
	    		<el-input v-model.trim="orderDetailParm.orderDate" :disabled="true" clearable></el-input>
	  		</el-form-item>
			</el-form>
  	</div>
  </el-dialog>
  
  <!--详情弹窗-->
    <el-dialog :visible.sync="dialogBuyerDetailVisible" :title="dialogBuyerDetailTitle" center width="45%">
      <div class="dialog-content">
        <el-form ref="form" size="small" label-width="120px">
          <el-form-item label="账号" prop="account">
            <el-input v-model.trim="detailBuyerParm.account" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="昵称" prop="nickName">
            <el-input v-model.trim="detailBuyerParm.nickName" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="pwd">
            <el-input v-model.trim="detailBuyerParm.pwd" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="公司" prop="companyId">
            <el-select v-model.trim="detailBuyerParm.companyId" disabled placeholder="请选择">
              <el-option
                v-for="item in companys"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="平台" prop="platformId">
            <el-select v-model.trim="detailBuyerParm.platformId" disabled placeholder="请选择">
              <el-option
                v-for="item in platformList"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>

          <!--国家-->
          <el-form-item label="国家" prop="contntryShort">
            <el-input v-model.trim="detailBuyerParm.contntryShort" disabled clearable></el-input>
          </el-form-item>
          <!--VPN vpnId -->
          <el-form-item label="VPNIP" prop="vpnIp">
            <el-input v-model.trim="detailBuyerParm.vpnIp" disabled clearable></el-input>
          </el-form-item>
          <!--信用卡ID  cardId -->
          <el-form-item label="信用卡卡号" prop="cardNumber">
            <el-input v-model.trim="detailBuyerParm.cardNumber" disabled clearable></el-input>
          </el-form-item>
          <!--用户等级    level -->
          <el-form-item label="用户等级" prop="level">
            <el-select v-model.trim="detailBuyerParm.level" disabled placeholder="请选择">
              <el-option
                v-for="item in levelList"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <!--占用状态 occupyStatus -->
          <el-form-item label="占用状态" prop="occupyStatus">
            <el-select v-model.trim="detailBuyerParm.occupyStatus" disabled placeholder="请选择">
              <el-option
                v-for="item in occupyStatusList"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <!--状态 status -->
          <el-form-item label="状态" prop="status">
            <el-select v-model.trim="detailBuyerParm.status" disabled placeholder="请选择">
              <el-option
                v-for="item in buyerStatusList"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <!--占用账户-->
          <el-form-item label="占用账户" prop="occupyAccount">
            <el-input v-model.trim="detailBuyerParm.occupyAccount" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--账户余额-->
          <el-form-item label="账户余额" prop="balance">
            <el-input v-model.trim="detailBuyerParm.balance" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--购买总金额-->
          <el-form-item label="账户购买总金额" prop="buyTotalMoney">
            <el-input v-model.trim="detailBuyerParm.buyTotalMoney" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--地址1-->
          <el-form-item label="地址1" prop="addressline1">
            <el-input v-model.trim="detailBuyerParm.addressline1" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--国家-->
          <el-form-item label="国家" prop="country">
            <el-input v-model.trim="detailBuyerParm.country" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--州-->
          <el-form-item label="州" prop="state">
            <el-input v-model.trim="detailBuyerParm.state" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--电话-->
          <el-form-item label="电话" prop="tel">
            <el-input v-model.trim="detailBuyerParm.tel" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--lastname-->
          <el-form-item label="lastname" prop="lastname">
            <el-input v-model.trim="detailBuyerParm.lastname" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--税号-->
          <el-form-item label="税号" prop="vatNumber">
            <el-input v-model.trim="detailBuyerParm.vatNumber" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--城市-->
          <el-form-item label="城市" prop="city">
            <el-input v-model.trim="detailBuyerParm.city" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--地址2-->
          <el-form-item label="地址2" prop="addressline2">
            <el-input v-model.trim="detailBuyerParm.addressline2" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--firstname-->
          <el-form-item label="firstname" prop="firstname">
            <el-input v-model.trim="detailBuyerParm.firstname" :disabled="true" clearable></el-input>
          </el-form-item>
          <!--邮政编码-->
          <el-form-item label="邮政编码" prop="postalcode">
            <el-input v-model.trim="detailBuyerParm.postalcode" :disabled="true" clearable></el-input>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>

  </div>
</template>
<script>
//	import { editById, delById, getById } from '@/api/group/clickfarming'
	import { getById } from '@/api/group/dhAddCarCatch'
	import { getDetailById } from '@/api/group/clickOrder'
	import { getBuyerList, getBuyerById } from "@/api/group/dhPay";
	import { getAll } from "@/api/group/company";
	import { doMainName } from "@/api/group/fileUpload";
	import { add, getList, getEditDetailById, sureEditById, delById, orderSuccess, toBeCatch, wellReceive } from '@/api/group/dhAddCar'
export default {
	filters: {
	  getStatus: function (value) {
	  	// 状态 1.待执行 2.执行中 3.加购成功 4.加购失败 5.下单成功 6.支付成功 7.抓单成功 8.抓单失败
			   if(value == 1) {
			   		return '待执行';
			   } else if (value == 2) {
			   		return '执行中';
			   } else if (value == 3) {
			   		return '加购成功';
			   } else if(value == 4) {
			   		return '加购失败';
			   } else if(value == 5) {
			   		return '下单成功';
			   } else if(value == 6) {
			   		return '待抓单';
			   } else if(value == 7) {
			   		return '抓单中';
			   } else if(value == 8) {
			   		return '抓单成功';
			   } else {
			   	 return '抓单失败';
			   }
		  },
	  getBuyerStatus:function (value) {
	  	if(value == 1) {
		   	return '已占用';
		   } else{
		   	return '未占用';
		   }
	  },
		getparamsType: function (value) {
		   if(value == 1) {
		   	 return '关键词';
		   } else if (value == 2) {
		   	 return '链接';
		   }
	  }
	},
//	数据
  data() {
    return {
    	searchParm: {
    		page: 1,
    		pageSize: 10,
    		sort:'created_at',
    		order:'desc',
    		status:null,
    		shopName:'',
    		payOrderId:null,
    		paramsType:null,
    		country:null,
    		account:null
    	},
    	total:0,
    	labelVal:"1",
      list: [],
      buyerList: [],
      companys:[],
      buyerId: null,
      fileList:[],
      paths:[],
      doMainNameUrl: null,
	  	uploadHeaders:{ Authorization: this.$store.getters.token },
      dialogAddVisible: false,
      dialogAddTitle: '新增',
      dialogDetailVisible: false,
      dialogDetailTitle: '详情',
      dialogWellReceivedVisible: false,
      dialogWellReceivedTitle: '好评',
      dialogOrderDetailVisible: false,
      dialogOrderDetailTitle: '订单详情',
      dialogEditVisible: false,
      dialogEditTitle: '修改',
      dialogSupplementVisible: false,
      dialogSupplementTitle: '补录',
      dialogImportVisible: false,
      dialogImportTitle:'导入',
      dialogBuyerVisible: false,
      dialogBuyerTitle: "买家列表",
      dialogBuyerVisible: false,
      dialogBuyerTitle: "买家列表",
      dialogBuyerDetailVisible: false,
	    dialogBuyerDetailTitle: "买家详情",
	    updateFileType: {type: 13},
      uploadFileUrl: process.env.VUE_APP_BASE_API + '/api/clickFarming/import',
      uploadFileImgUrl: process.env.VUE_APP_BASE_API + '/api/file/uploadFile',
      updateBoolean: false,
      tempUrl: process.env.VUE_APP_BASE_API + '/api/clickFarming/exportTemp',
	    fileImages:{
		  	name: null,
		  	url: null
		  },
     // 状态 1.待执行 2.执行中 3.加购成功 4.加购失败 5.下单成功 6.支付成功 7.抓单成功 8.抓单失败
	   		detailStatusList:[
	        {
	          id: 1,
	          name: '待执行'
	        },
      		{
	          id: 2,
	          name: '执行中'
      		},
      		{
	          id: 3,
	          name: '加购成功'
	        },
      		{
	          id: 4,
	          name: '加购失败'
	        },{
	        	id:5,
	        	name:"下单成功"
	        },{
	        	id:6,
	        	name:"待抓单"
	        },{
	        	id:7,
	        	name:"抓单中"
	        },{
	        	id:8,
	        	name:"抓单成功"
	        },{
	        	id:9,
	        	name:"抓单失败"
	        }],
	    statusList:[
	    		{
	          id: null,
	          name: '全部'
	        },
	        {
	          id: 1,
	          name: '待执行'
	        },
      		{
	          id: 2,
	          name: '执行中',
      		},
      		{
	          id: 3,
	          name: '加购成功'
	        },
      		{
	          id: 4,
	          name: '加购失败'
	        },{
	        	id:5,
	        	name:"下单成功"
	        },{
	        	id:6,
	        	name:"待抓单"
	        },{
	        	id:7,
	        	name:"抓单中"
	        },{
	        	id:8,
	        	name:"抓单成功"
	        },{
	        	id:9,
	        	name:"抓单失败"
	        }],
	    searchParamsTypeList:[
	    	{
	          id: null,
	          name: '全部'
	        },
	        {
	          id: 1,
	          name: '关键词'
	        },
      		{
	          id: 2,
	          name: '链接',
      		},
	    ],
	      occupyStatusList: [
	        {
	          id: 1,
	          name: "已占用"
	        },
	        {
	          id: 2,
	          name: "未占用"
	        }
	      ],
	      buyerStatusList: [
	      	{
	          id: 1,
	          name: "待注册"
	        },
	        {
	          id: 2,
	          name: "待验证"
	        },
	        {
	          id: 3,
	          name: "待完善"
	        },
	        {
	          id: 4,
	          name: "正常"
	        },
	        {
	          id: 5,
	          name: "异常"
	        },
	        {
	          id: 6,
	          name: "可用但已用"
	        },
	        {
	          id: 7,
	          name: "删除"
	        }
	      ],
	      levelList: [
	        {
	          id: 1,
	          name: "普通"
	        },
	        {
	          id: 2,
	          name: "精品"
	        },
	        {
	          id: 3,
	          name: "压力"
	        },
	        {
	          id: 4,
	          name: "内部账号"
	        }
	      ],
	      platformList: [
	        {
	          id: 1,
	          name: "敦煌"
	        },
	        {
	          id: 2,
	          name: "速卖通"
	        },
	        {
	          id: 3,
	          name: "马帮"
	        }
	      ],
      addParm: {
      	buyerId:null,
      	paramsType: null,
    		carGoodKeys:[
		      {
		      	shopName: null,
		     		keyWord:null,
			      title:null,
			      specification:null,
			      color:null,
			      number:null,
			      sectionMin:null,
			      sectionMax:null,
			      item:null,
			      paramsType:1
		      }
    		],
    		carGoodLinks:[
      		{
		      	link:null,
		      	specification:null,
		      	color:null,
		     	  number:null,
		     	  paramsType:2
	     	  }
      	]
      },
      searchBuyerParm: {
        page: 1,
        pageSize: 10,
        account: null,
        sort: "created_at",
        order: "desc",
        nickName: null,
        pwd: null,
        companyId: null,
        platformId: 1
      },
      editParm: {
      	id: null,
      	buyerId:null,
      	account:null,
      	paramsType: null,
    		carGoodKeys:[
		      {
		      	id:null,
		      	shopName: null,
		     		keyWord:null,
			      title:null,
			      specification:null,
			      color:null,
			      number:null,
			      sectionMin:null,
			      sectionMax:null,
			      item:null,
			      paramsType:1
		      }
    		],
    		carGoodLinks:[
      		{
      			id:null,
		      	link:null,
		      	specification:null,
		      	color:null,
		     	  number:null,
		     	  paramsType:2
	     	  }
      	]
      },
      dialogWellReceived:{
      	id:null,
      	dialogWellReceivedGoods:[
	      	{
	      		id:null,
			    	comment:null,
			    	paths:null
	      	}
	      ]
      },
      detailParm: {
      	id: null,
      	buyerId:null,
      	account:null,
      	paramsType: null,
      	status:null,
    		carGoodKeys:[
		      {
		      	id:null,
		      	shopName: null,
		     		keyWord:null,
			      title:null,
			      specification:null,
			      color:null,
			      number:null,
			      sectionMin:null,
			      sectionMax:null,
			      item:null,
			      paramsType:1,
			      comment:null,
			      paths:[]
		      }
    		],
    		carGoodLinks:[
      		{
      			id:null,
		      	link:null,
		      	specification:null,
		      	color:null,
		     	  number:null,
		     	  paramsType:2,
		     	  comment:null,
			      paths:[]
	     	  }
      	]
      },
      orderDetailParm: {
      	id: null,
      	createdAt:null,
    		updatedAt:null,
    		amount:null,
    		paymentResults:null,
    		shop:null,
//  		pricesNumber:null,
//  		orderId:null,
//  		shopName:null,
    		orderDate:null
      },
      detailBuyerParm: {
      	id: null,
      	nickName:null,
    		pwd:null,
    		account: null,
    		companyId:null,
    		platformId:null,
    		contntryShort:null,
    		vpnId:null,
				vpnIp:null,
  			cardId:null,
				cardNumber:null,
  			level:null,
  			occupyStatus:null,
  			addressline1:null,
  			country:null,
  			state:null,
  			tel:null,
  			lastname:null,
  			vatNumber:null,
  			city:null,
  			addressline2:null,
  			firstname:null,
  			postalcode:null,
  			status:null
      },
      rules: {
       type: [
       	 {required: true, message:"请选择操作类型", trigger: 'blur'}
       ],
       paramsType: [
       	 {required: true, message:"请选择商品参数", trigger: 'blur'}
       ],
//     shopName: [
//       { required: true, message: '请输入店铺名称', trigger: 'blur' }
//     ],
//      keyWord: [
//       { required: true, message: '请输入关键词', trigger: 'blur' }
//     ],
//      title: [
//       { required: true, message: '请输入标题', trigger: 'blur' }
//     ],
//      link: [
//       { required: true, message: '请输入链接', trigger: 'blur' }
//     ],
//      number: [
//       { required: true, message: '请输入数量', trigger: 'blur' }
//     ],
//     item: [
//       { required: true, message: '请输入Item', trigger: 'blur' }
//     ],
        amessage: [
         { required: true, message: '请输入留言', trigger: 'blur' }
       ]
      }
    }
  },
  // 调用
  created() {
  	this.getFileDoMainName();
		this.fileList = [];
		this.goSearch();
  },
	//方法
  methods: {
  	// 获取图片域名请求url fileDoMainName
		getFileDoMainName() {
			doMainName().then(res => {
				if(res.code==200) {
					this.doMainNameUrl = res.data;
					console.log("898989898========")
					console.log(this.doMainNameUrl)
				}
			}).catch(err => {
				console.log(err)
			})
		},
  	// 图片上传
  	handleRemove(data, file, fileList) {
  		console.log("========data=======");
  		console.log(data);
  		console.log("========fileList=======");
  		console.log(fileList);
  		
  		var goodPaths = [];
  		for (let i = 0; i < fileList.length; i++) {
		  	const imgUrl = fileList[i].url;
		  	if (imgUrl.includes("/file/")) {
		  		imgUrl =  imgUrl.substring(imgUrl.lastIndexOf("\/file\/") + 5, imgUrl.length);
			  	goodPaths.push(imgUrl);
		  	}
		  }
  		console.log("888888888888888");
			console.log(goodPaths);
			
  		if (data.paramsType == 1) {
				this.detailParm.carGoodKeys[data.index].paths = goodPaths.join(',');
			}
			if (data.paramsType == 2) {
				this.detailParm.carGoodLinks[data.index].paths = goodPaths.join(',');
			}
			console.log("99999999999999");
			console.log(this.detailParm);
		},
		handlePreview(file) {
		  console.log("======handlePreview=======");
		  console.log(file);
		},
		uploadImgSuccess(data, res, file) {
	    if(res.code==200) {
				const picIndex = res.data.list[0].path.lastIndexOf("\/");
				this.fileImages.name = res.data.list[0].path.substring(picIndex + 1, res.data.list[0].path.length);
				this.fileImages.url = this.doMainNameUrl + res.data.list[0].path;
				var oldPaths = null;
				if (data.paramsType == 1) {
					oldPaths = this.detailParm.carGoodKeys[data.index].paths;
					if (oldPaths != "undefined" && oldPaths != null && oldPaths != "" && oldPaths != "null" && oldPaths != "NULL") {
						oldPaths = oldPaths + "," + res.data.list[0].path;
					} else {
						oldPaths = res.data.list[0].path;
					}
					this.detailParm.carGoodKeys[data.index].paths = oldPaths;
				}
				if (data.paramsType == 2) {
					oldPaths = this.detailParm.carGoodLinks[data.index].paths;
					if (oldPaths != "undefined" && oldPaths != null && oldPaths != "" && oldPaths != "null" && oldPaths != "NULL") {
						oldPaths = oldPaths + "," + res.data.list[0].path;
					} else {
						oldPaths = res.data.list[0].path;
						console.log("oldPaths--" + oldPaths)
					}
					this.detailParm.carGoodLinks[data.index].paths = oldPaths;
				}
				console.log(this.detailParm);
		  }
	 },
	//重置
  	resetForm() {
    		this.searchParm.status=null;
    		this.searchParm.paramsType=null;
    		this.searchParm.country=null;
    		this.searchParm.account=null;
    		this.goSearch();
	  },
	 beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
     },
	 beforeImgUpload(file) {
	 	console.log(file);
	 	
	 	const isXlsImg = file.type === 'image/img';
	 	const isXlsJpg = file.type === 'image/jpg';
	 	const isXlsPng = file.type === 'image/png';
	 	const isXlsJpeg = file.type === 'image/jpeg';
	 	
	 	console.log("isXlsImg:" + isXlsImg);
	 	console.log("isXlsJpg:" + isXlsJpg);
	 	console.log("isXlsPng:" + isXlsPng);
	 	console.log("isXlsJpeg:" + isXlsJpeg);
	 	
    	const isLt10M = file.size / 1024 / 1024 < 5;
		const isXls = true;
	    if (!isXlsImg && !isXlsJpg && !isXlsPng && !isXlsJpeg) {
	       this.$message.error('上传头像图片只能是img/jpg/png/jpeg 格式!');
	       isXls = false;
	    }
		
	    const isLt5M = file.size / 1024 / 1024 <5;
	    if (!isLt5M) {
	      this.$message.error('上传Excel文件大小不能超过 5MB!');
	    }
	    
	    return isXls && isLt5M;
	 },
	  // input 增加 删除方法 -新增
	  addItemLink() {
	  	this.addParm.carGoodLinks.push({
	  		paramsType: 2
	  	});
	  },
	  deleteItemLink(item,index) {
	  	this.addParm.carGoodLinks.splice(index, 1);
	  },
	  addItemKey() {
	  	this.addParm.carGoodKeys.push({
	  		paramsType: 1
	  	});
	  },
	  deleteItemKey(item,index) {
	  	this.addParm.carGoodKeys.splice(index, 1);
	  },
	  // input 增加 删除方法 - 修改
	  addEditItemLink() {
	  	this.editParm.carGoodLinks.push({
	  		paramsType: 2
	  	});
	  },
	  deleteEditItemLink(item,index) {
	  	this.editParm.carGoodLinks.splice(index, 1);
	  },
	  addEditItemKey() {
	  	this.editParm.carGoodKeys.push({
	  		paramsType: 1
	  	});
	  },
	  deleteEditItemKey(item,index) {
	  	this.editParm.carGoodKeys.splice(index, 1);
	  },
	  changeCheckRange(val) {
      this.labelVal = val;
    },
	  // 获取所有公司信息
    getCompanyAll() {
      getAll()
        .then(res => {
          this.companys = res.data;
          if (res.code == 200) {
            console.log(this.companys);
          }
        })
        .catch(() => {});
    },
	  resetBuyerForm() {
      this.searchBuyerParm.account = null;
      this.searchBuyerParm.pwd = null;
      this.searchBuyerParm.nickName = null;
      this.searchBuyerParm.companyId = null;
      this.searchBuyerParm.platformId = null;
      this.goSearchBuyer();
    },
   	//	查询
		goSearch() {
			this.searchParm.page=1;
			this.getCompanyAll();
			this.getDataList();
		},
		goSearchBuyer() {
      this.dialogBuyerVisible = true;
      this.searchBuyerParm.page = 1;
      this.searchBuyerParm.platformId = 1;
      this.getBuyerDataList();
    },
    getBuyerDataList() {
      getBuyerList(this.searchBuyerParm)
        .then(res => {
          console.log(res);
          if (res.code == 200) {
            this.buyerList = res.data.list;
            this.buyerTotal = res.data.total;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    getBuyerById(data){
			this.account = data.account;
			this.buyerId = data.id;
			if(this.dialogAddVisible == true) {
				this.addParm.buyerId = data.id;
				this.addParm.account = data.account;
			}
			
			if(this.dialogEditVisible == true) {
				this.editParm.buyerId = data.id;
				this.editParm.account = data.account;
			}
			
			this.dialogBuyerVisible = false;
			console.log(data);
			this.$message.success("选择成功");
		},
		// 查看买家信息根据id
    getBuyerBtnById(id) {
      getBuyerById({ id })
        .then(res => {
          if (res.code == 200) {
            this.detailBuyerParm.id = res.data.id;
            this.detailBuyerParm.nickName = res.data.nickName;
            this.detailBuyerParm.pwd = res.data.pwd;
            this.detailBuyerParm.account = res.data.account;
            this.detailBuyerParm.companyId = res.data.companyId;
            this.detailBuyerParm.platformId = res.data.platformId;
            this.detailBuyerParm.contntryShort = res.data.contntryShort;
            this.detailBuyerParm.vpnId = res.data.vpnId;
            this.detailBuyerParm.vpnIp = res.data.ipAddress;
            this.detailBuyerParm.cardNumber = res.data.number;
            this.detailBuyerParm.cardId = res.data.cardId;
            this.detailBuyerParm.level = res.data.level;
            this.detailBuyerParm.occupyStatus = res.data.occupyStatus;
            this.detailBuyerParm.occupyAccount = res.data.occupyAccount;
            this.detailBuyerParm.balance = res.data.balance;
            this.detailBuyerParm.buyTotalMoney = res.data.buyTotalMoney;
            this.detailBuyerParm.addressline1 = res.data.addressline1;
            this.detailBuyerParm.country = res.data.country;
            this.detailBuyerParm.state = res.data.state;
            this.detailBuyerParm.tel = res.data.tel;
            this.detailBuyerParm.lastname = res.data.lastname;
            this.detailBuyerParm.vatNumber = res.data.vatNumber;
            this.detailBuyerParm.city = res.data.city;
            this.detailBuyerParm.addressline2 = res.data.addressline2;
            this.detailBuyerParm.firstname = res.data.firstname;
            this.detailBuyerParm.postalcode = res.data.postalcode;
            this.detailBuyerParm.status = res.data.status;

            this.dialogBuyerDetailVisible = true;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
		beforeAvatarUpload(file) {
	    console.log(file);
		//  const isXlsl = file.type === 'xlsl';
		    const isLt10M = file.size / 1024 / 1024 <10;
		
		//  if (!isXlsl) {
		//    this.$message.error('上传头像图片只能是 xlsl 格式!');
		//  }
		    if (!isLt10M) {
		      this.$message.error('上传头像图片大小不能超过 10MB!');
		    }
		//  return isXlsl && isLt10M;
		    return isLt10M;
		 },
	  uploadSuccess(res, file) {
	  	this.dialogImportVisible = false;
	    if(res.code==200) {
	    	  console.log(res.data);
					this.$message.success('导入成功!');
					
					if(res.data != null) {
						window.location.href = res.data;
					}
			}
				this.getDataList();
	  },
		// 新增
		addBtn(){
			this.dialogAddVisible = true;
			this.addParm = {
      	buyerId:null,
      	paramsType: null,
    		shopName: null,
    		carGoodKeys:[
		      {
		     		keyWord:null,
			      title:null,
			      specification:null,
			      color:null,
			      number:null,
			      sectionMin:null,
			      sectionMax:null,
			      item:null,
			      paramsType:1
		      }
    		],
    		carGoodLinks:[
      		{
		      	link:null,
		      	specification:null,
		      	color:null,
		     	  number:null,
		     	  paramsType:2
	     	  }
      	]
    	};
		},
		// 导入
		importBtn() {
			this.dialogImportVisible = true
		},
		exportTempBtn() {
			console.log(this.tempUrl)
			window.location.href = this.tempUrl;
		},
		//	根据id删除
		delById(id){
			this.$confirm('确认删除?','提示',{
				confirmButtonText: '确定',
	      cancelButtonText: '取消',
	      type: 'warning'
			}).then(() => {
				delById({id}).then(res => {
					if(res.code==200) {
						this.$message.success('删除成功!')
						this.getDataList()
					} else {
						this.$message.warning(res);
					}
				}).catch(err => {
					this.$message.error(err);
					console.log(err)
				})
			}).catch(() => {
				this.$message.info('取消删除')
			})
		},
		//	根据id 下单成功
		orderSuccessBtn(id){
			this.$confirm('确认下单成功?','提示',{
				confirmButtonText: '确定',
	      cancelButtonText: '取消',
	      type: 'warning'
			}).then(() => {
				orderSuccess({id}).then(res => {
					if(res.code==200) {
						this.$message.success('下单成功!')
						this.getDataList()
					} else {
						this.$message.warning(res);
					}
				}).catch(err => {
					this.$message.error(err);
					console.log(err)
				})
			}).catch(() => {
				this.$message.info('取消下单成功')
			})
		},
		//	根据id 支付成功
		toBeCatchBtn(id){
			this.$confirm('确认支付成功?','提示',{
				confirmButtonText: '确定',
	      cancelButtonText: '取消',
	      type: 'warning'
			}).then(() => {
				toBeCatch({id}).then(res => {
					if(res.code==200) {
						this.$message.success('支付成功!')
						this.getDataList()
					} else {
						this.$message.warning(res);
					}
				}).catch(err => {
					this.$message.error(err);
					console.log(err)
				})
			}).catch(() => {
				this.$message.info('取消支付成功')
			})
		},
		// 根据id 设置状态异常
		abNormalById(id){
			this.$confirm('确认状态修改为异常?','提示',{
				confirmButtonText: '确定',
	      cancelButtonText: '取消',
	      type: 'warning'
			}).then(() => {
				abMormal({id}).then(res => {
					if(res.code==200) {
						this.$message.success('修改异常状态成功!')
						this.getDataList()
					}
				}).catch(err => {
					this.$message.error(err);
					console.log(err)
				})
			}).catch(() => {
				this.$message.info('取消修改')
			})
		},
		//	修改
		editById(value){
			getEditDetailById({id: value}).then(res => {
				if(res.code==200) {
					
					
					
					this.editParm.id = res.data.id;
					this.editParm.buyerId= res.data.buyerId;
    			this.editParm.account= res.data.account;
    			this.editParm.paramsType = res.data.paramsType;
    			if(res.data.paramsType === 1) {
    				this.editParm.carGoodKeys = res.data.carGoodKeys;
    				this.editParm.carGoodLinks = [
			      		{
					      	link:null,
					      	specification:null,
					      	color:null,
					     	  number:null,
					     	  paramsType:2
				     	  }
			      	];
    			}
    			
    			if(res.data.paramsType === 2) {
    				this.editParm.carGoodLinks = res.data.carGoodLinks;
    				this.editParm.carGoodKeys = [
					      {
					     		keyWord:null,
						      title:null,
						      specification:null,
						      color:null,
						      number:null,
						      sectionMin:null,
						      sectionMax:null,
						      item:null,
						      paramsType:1
					      }
			    		];
    			}
					
					this.dialogEditVisible = true;
					this.labelVal = res.data.paramsType;
//					this.$refs.editParm.clearValidate();
				}
			}).catch(err => {
				this.$message.error(err);
				console.log(err)
			})
		},
		// 确认修改
		sureEdit(editParm){
			console.log("-----edit");
			this.$refs[editParm].validate((valid) => {
		  if (valid) {
			  	this.$refs.editParm.clearValidate();
			  	if(this.editParm.paramsType === 2) {
						this.editParm.carGoodKeys = null;
					}
					if(this.editParm.paramsType === 1) {
						this.editParm.carGoodLinks = null;
					}
					sureEditById(this.editParm).then(res => {
						if(res.code==200) {
							this.editParm.buyerId = this.buyerId;
							this.dialogEditVisible = false
							this.$message.success('修改成功!')
							this.getDataList()
						}
					}).catch(err => {
						this.$message.error(err);
						console.log(err)
					})
			  } else {
					console.log('error submit!!');
					return false;
			  }
			});
		},
		sureEditCancle(editParm) {
			dialogEditVisible=flase
			this.$refs.editParm.clearValidate();
		},
		sureWellReceivedCancle(detailParm) {
			dialogWellReceivedVisible=flase
			this.$refs.detailParm.clearValidate();
		},
		// 确认好评
		sureWellReceived(detailParm){
			// 判断 图片评论 图片必填
			// console.log('error submit!!');
			//		return false;
	  	
	  	// dialogWellReceivedGoods
	  	// 封装goods
	  	var goods = null;
	  	this.dialogWellReceived.dialogWellReceivedGoods = [];
	  	this.dialogWellReceived.id = this.detailParm.id;
	  	if(this.detailParm.paramsType === 1) {
	  		goods = this.detailParm.carGoodKeys;
			}
			
			if(this.detailParm.paramsType === 2) {
				goods =  this.detailParm.carGoodLinks;
			}
			
			for (let item of goods) {
				var wellReceived = {
					id:null,
		      comment:null,
		      paths:null
				};
				wellReceived.id = item.id;
				wellReceived.comment = item.comment;
				wellReceived.paths = item.paths;
				this.dialogWellReceived.dialogWellReceivedGoods.push(wellReceived);
			}
			
			wellReceive(this.dialogWellReceived).then(res => {
			if(res.code==200) {
				this.addParm.buyerId = this.buyerId;
						this.dialogWellReceivedVisible = false
						this.$message.success('评论成功!')
						this.getDataList()
					}
			}).catch(err => {
				this.$message.error(err);
					console.log(err)
			})
		},
		// 确认新增
		sureAdd(addParm){
			this.$refs[addParm].validate((valid) => {
		  if (valid) {
			  	this.$refs.addParm.clearValidate();
			  	if(this.addParm.paramsType === 2) {
						this.addParm.carGoodKeys = null;
					}
					
					if(this.addParm.paramsType === 1) {
						this.addParm.carGoodLinks = null;
					}
					add(this.addParm).then(res => {
					if(res.code==200) {
						this.addParm.buyerId = this.buyerId;
								this.dialogAddVisible = false
								this.$message.success('新增成功!')
								this.getDataList()
							}
					}).catch(err => {
						this.$message.error(err);
							console.log(err)
					})
			  } else {
					console.log('error submit!!');
					return false;
			  }
			});
		},
		sureAddCancle(addParm) {
			dialogAddVisible=false;
			this.$refs.addParm.clearValidate();
		},
		// 查看根据id
		getBtnById(id){
			getEditDetailById({id}).then(res => {
				if(res.code==200) {
					
					this.detailParm.id = res.data.id;
					this.detailParm.buyerId= res.data.buyerId;
    			this.detailParm.account= res.data.account;
    			this.detailParm.paramsType = res.data.paramsType;
    			this.detailParm.carGoodKeys = res.data.carGoodKeys;
    			this.detailParm.carGoodLinks = res.data.carGoodLinks;
					
					this.dialogDetailVisible = true
					this.labelVal = res.data.paramsType;
				}
			}).catch(err => {
				console.log(err)
			})
		},
		// 敦煌好评回显 - 查看根据id
		getBtnWellReceivedById(id){
			getEditDetailById({id}).then(res => {
				if(res.code==200) {
					
					this.detailParm.id = res.data.id;
					this.detailParm.buyerId= res.data.buyerId;
    			this.detailParm.account= res.data.account;
    			this.detailParm.paramsType = res.data.paramsType;
    			this.detailParm.carGoodKeys = res.data.carGoodKeys;
    			this.detailParm.carGoodLinks = res.data.carGoodLinks;
    			
    			var goods = null;
    			if (this.detailParm.paramsType == 1) {
    				goods = this.detailParm.carGoodKeys;
    			}
    			
    			if (this.detailParm.paramsType == 2) {
    				goods = this.detailParm.carGoodLinks;
    			}
    			
    			var fileImages = {
				  	name: null,
				  	url: null
				  };
    			
    			// fileList + i  赋值每个对象的所有商品images
    			for (let i in goods) {
    				var good = goods[i];
    				console.log("----------------------0")
    				console.log(good)
    				if (good.paths == "undefined" || good.paths == null || good.paths == "" || good.paths == "null" || good.paths == "NULL") {
    					console.log("----------------------1")
    					this.fileList[i] = null;
    				}else if(!good.paths.includes(",")) {
    					console.log("----------------------2")
    					const index = good.paths.lastIndexOf("\/");
							fileImages.name = good.paths.substring(index + 1, good.paths.length);
							fileImages.url = this.doMainNameUrl + good.paths;
							
							var fileImageList = [];
							fileImageList.push(fileImages);
							
    					this.fileList[i] = fileImageList;
    				} else {
    					console.log("----------------------3")
    					this.fileList[i] = good.paths.split(',').map(val => {
								return {name: val.substring(val.lastIndexOf("\/") + 1, val.length), url: this.doMainNameUrl + val}
								console.log("url:" + val);
				    	})
    				}
    				console.log("----------------------4---i" + i)
    				console.log(this.fileList[i])
					}
					
					this.dialogWellReceivedVisible = true
					this.labelVal = res.data.paramsType;
				}
			}).catch(err => {
				console.log(err)
			})
		},
		// 获取订单详情
		getOrderBtnById(id){
			getById({id}).then(res => {
				if(res.code==200) {
					this.orderDetailParm.id = res.data.id;
					this.orderDetailParm.createdAt = res.data.createdAt;
    			this.orderDetailParm.updatedAt = res.data.updatedAt;
    			this.orderDetailParm.amount = res.data.amount;
    			this.orderDetailParm.paymentResults = res.data.paymentResults;
    			this.orderDetailParm.shop = res.data.shop;
//  			this.orderDetailParm.pricesNumber = res.data.pricesNumber;
//  			this.orderDetailParm.orderId = res.data.orderId;
//  			this.orderDetailParm.shopName = res.data.shopName;
    			this.orderDetailParm.orderDate = res.data.orderDate;
    			
					this.dialogOrderDetailVisible = true
					
				}
			}).catch(err => {
				console.log(err)
			})
		},
		// 分页获取表格数据
		getDataList(){
			getList(this.searchParm).then(res => {
					if(res.code==200) {
						this.list = res.data.list;
						this.total = res.data.total;
					}
				}).catch(err => {
					console.log(err)
				})
		},
	
		//	分页
		handleSizeChange(val) {
   		console.log(`每页 ${val} 条`);
   		this.searchParm.pageSize = val;
   		this.getDataList();
  	},
  	handleCurrentChange(val) {
    	console.log(`当前页: ${val}`);
    	this.searchParm.page = val;
    	this.getDataList();
  	}
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
</style>
