<template>
  <a-card :bordered="false" :body-style="{ padding: '0px 0px 8px' }" >
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="关键字">
              <a-input placeholder="请输入姓名、家长姓名、联系方式、备注" v-model="queryParam.keywords"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="录入日期">
                <a-range-picker v-model="queryParam.dateQ"
                  format="YYYY-MM-DD"
                  :placeholder="['开始日期', '结束日期']"
                  @change="onCreateTimeChange" />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="校区ID">
                <j-dict-select-tag placeholder="请选择校区ID" v-model="queryParam.schoolDistrictId" dictCode="school_organization,name,id"/>
              </a-form-item>
            </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="跟进状态">
                <j-dict-select-tag placeholder="请选择跟进状态" v-model="queryParam.followStatus" dictCode="customer_follow_status"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="学员类型">
                <!-- <j-dict-select-tag placeholder="请选择类型"  v-model="queryParam.type" dictCode="customer_pc_type"/> -->
                <a-select  v-model="selectValue" @change="handleInput">
                  <a-select-option value= 0 >全部</a-select-option>
                  <a-select-option v-for="(item, key) in typeOptions" :key="key" :value="item.value">
                    <span style="display: inline-block;width: 100%" :title=" item.text || item.label ">
                      {{ item.text || item.label }}
                    </span>
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="意向课程">
                <j-dict-select-tag placeholder="请选择意向课程" v-model="queryParam.intendedCourse" dictCode="education_course,name,id"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="上次跟进">
                <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择上次跟进" v-model="queryParam.lastFollowTime"></j-date>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="顾问">
                <j-select-user-by-dep placeholder="请选择顾问" v-model="queryParam.saleCode"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="采单员">
                <j-select-user-by-dep placeholder="请选择采单员" v-model="queryParam.collectinoCode"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="渠道类型">
                <j-tree-select
                ref="treeSelect"
                placeholder="请选择渠道类型"
                v-model="queryParam.channelType"
                dict="promotion_channel,name,id"
                pidValue="0"
                >
              </j-tree-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="意向度">
                <j-dict-select-tag placeholder="请选择意向度" v-model="queryParam.intendedDegress" dictCode="customer_intention_status"/>
              </a-form-item>
            </a-col>
            <!-- 年龄 -->
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
             <a-form-item label="年龄">
              <a-input-group >
                <a-input type = "number" v-model:value="queryParam.ageMin" 
                style="width: 100px; text-align: center ; border-right: 0;" placeholder="最小年龄" />
                <a-input v-model:value="value13"
                  style="width: 30px; border-left: 0; border-right: 0; pointer-events: none; background-color: #fff"
                  placeholder="~" disabled />
                <a-input type = "number" v-model:value="queryParam.ageMax"
                  style="width: 100px; text-align: center; border-left: 0" placeholder="最大年龄" />
              </a-input-group>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="年级">
                <j-dict-select-tag placeholder="请选择年级" v-model="queryParam.grade" dictCode="customer_grade"/>
              </a-form-item>
            </a-col>
            <!-- 标签 -->
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="学校">
                <j-dict-select-tag placeholder="请选择学校" v-model="queryParam.school" dictCode="school_school,name,id"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="">
                <a-checkbox :checked="checked"  @change="invalidChange(checked)">不显示无效潜客</a-checkbox>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
      <a-button type="primary" icon="download" @click="handleExportXls('潜客管理')">导出</a-button>
      <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a @click="handleDetail(record)">详情</a>
          <!-- <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm> -->
          <a-divider type="vertical" v-has="'user:appoint'"/>
          <a @click="handleFollow(record)" v-has="'user:appoint'">领取</a>
          <a-divider type="vertical" v-has="'user:appoint'"/>
          <a @click="handleVisiting(record)" v-has="'user:appoint'">分配</a>
          <a-divider type="vertical" v-has="'user:appoint'"/>
          <a @click="handleAudition(record)" v-has="'user:appoint'">删除</a>
          <a-divider type="vertical" v-has="'user:appoint'"/>
        </span>

       <!--插槽NNNN-->
       <a slot="detail" slot-scope="text, record" @click="handleFollowDetail(record)" >{{text}}</a>
      </a-table>
    </div>
    <!--弹出窗口-->
    <a-modal
      title="跟进信息新增"
      ok-text="确认" 
      cancel-text="取消"
      :visible="followVisible"
      :confirm-loading="followloading"
      @ok="followOk"
      @cancel="followCancel">
      <a-form-item label="跟进类别">
        <a-input placeholder="请输入跟进类别" v-model="followType"></a-input>
      </a-form-item>
      <a-form-item label="跟进内容">
        <a-textarea v-model="followContent" rows="4" placeholder="请输入跟进内容" />
      </a-form-item>
      <a-form-item label="下次跟进">
        <a-date-picker v-model="nextFollowTime" 
          name = "nextFollowTime"
          dateFormat="YYYY-MM-DD"
          :disabledDate="disabledDate"
          v-decorator="['nextFollowTime',rules.date]"
          @change="onChangeTime"
          ></a-date-picker>
      </a-form-item>
      <a-form-item label="图片"  style="width: 400px">
        <j-image-upload text="上传" v-model="fileList" :isMultiple="true" ></j-image-upload>
      </a-form-item>
    </a-modal>

     <a-modal
      title="来访信息添加"
      ok-text="确认" 
      cancel-text="取消"
      :visible="visitingVisible"
      :confirm-loading="visitingloading"
      @ok="visitingOk"
      @cancel="visitingCancel">
      <a-form-item label="客户来访日期"  style="width: 400px">
        <a-date-picker v-model="dateStr" 
        name = "dateStr"
        dateFormat="YYYY-MM-DD"
        :disabledDate="disabledDate"
        v-decorator="['dateStr',rules.date]"
        ></a-date-picker>
      </a-form-item>
    </a-modal>

    <a-modal
      title="试听信息添加"
      ok-text="确认" 
      cancel-text="取消"
      :visible="auditionVisible"
      :confirm-loading="auditionloading"
      @ok="auditionOk"
      @cancel="auditionCancel">
      <a-form-item label="客户试听日期"  style="width: 400px">
        <a-date-picker v-model="dateAudition" 
        name = "dateAudition"
        dateFormat="YYYY-MM-DD"
        :disabledDate="disabledDate"
        v-decorator="['dateAudition',rules.date]"
        ></a-date-picker>
      </a-form-item>
    </a-modal>


    <a-modal
      title="跟进详情"
      :visible="followDetailVisible"
      :width=900
      @cancel="cancelFollowDetail"
      cancelText="关闭"
      :body-style="{width:200}"
      >
      <a-list item-layout="horizontal" :data-source="dataFollowDetail">
          <a-list-item :key="index" v-for="(item, index) in dataFollowDetail">
              <a-list-item-meta>
               <template #title>
                <a-descriptions bordered>
                  <a-descriptions-item label="潜客姓名">{{item.cpName}}</a-descriptions-item>
                  <a-descriptions-item label="跟进人">{{item.salesName}}</a-descriptions-item>
                  <a-descriptions-item label="跟进日期">{{item.createTime}}</a-descriptions-item>
                  <a-descriptions-item label="校区" :span="1">{{item.schoolDistrictName}}</a-descriptions-item>
                  <a-descriptions-item label="跟进类型" :span="2">{{item.followType}}</a-descriptions-item>
                  <a-descriptions-item label="跟进内容" :span="3">{{item.followContent}}</a-descriptions-item>
                  <a-descriptions-item label="图片" :span="3">
                   <!-- 为啥不能用a-image? -->
                   <div v-if="item.picList != null">
                      <div v-if = "(item.picList.more)">
                        <div v-for="(imgItem,index) in item.picList.imgPath" :key="index">
                          <div style="float: left;width:104px;height:104px;margin-right: 10px;margin: 0 8px 8px 0;">
                            <div
                              style="width: 100%;height: 100%;position: relative;padding: 8px;border: 0px solid #d9d9d9;border-radius: 4px;">
                              <img style="width: 100%;" :src="imgItem.imgUrl" :preview="item.picList.key">
                            </div>
                          </div>
                        </div>
                      </div>
                      <div v-else>
                         <div style="float: left;width:104px;height:104px;margin-right: 10px;margin: 0 8px 8px 0;">
                            <div
                              style="width: 100%;height: 100%;position: relative;padding: 8px;border: 0px solid #d9d9d9;border-radius: 4px;">
                              <img style="width: 100%;" :src="item.picList.imgPath.imgUrl" :preview="item.picList.key">
                            </div>
                          </div>
                      </div>
                   </div>
                  </a-descriptions-item>
                </a-descriptions>
               </template>
            </a-list-item-meta>
          </a-list-item>
      </a-list>

       <template slot="footer">
        <a-button key="back" @click="cancelFollowDetail">关闭</a-button>
      </template>
    </a-modal>


    <customer-potential-modal ref="modalForm" @ok="modalFormOk"></customer-potential-modal>
  </a-card>
</template>

<script>
  import {getDictItemsFromCache} from '@/api/api'
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import CustomerPotentialModal from './CustomerPotentialModal'
  import JSelectMultiUser from '@/components/jeecgbiz/JSelectMultiUser'
  import {postAction} from '@/api/manage'
  import moment from 'moment'
  import JImageUpload from '@/components/jeecg/JImageUpload'
  import store from '@/store'
  import JEllipsis from "@/components/jeecg/JEllipsis"
  export default {
    name: 'PotentialListTabPublic',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      CustomerPotentialModal,JSelectMultiUser,JImageUpload,JEllipsis
    },
    data () {
      let ellipsis = (v, l = 20) => (<j-ellipsis value = {v} length = {l}/>)
      return {
        description: '潜客管理管理页面',
        followVisible: false,
        followloading: false,
        checked: false,
        dataFollow:"",
        followType:"",
        followContent:"",
        followDetailVisible: false,
        nextFollowTime:"",
        realFollowTime:"",
        fileList:[],
        visitingVisible: false,
        visitingloading: false,
        dataVisit:"",
        dateStr:"",
        auditionVisible: false,
        auditionloading: false,
        dataAudition:"",
        dateAudition:"",
        form: this.$form.createForm(this),
        users: "",
        dataFollowDetail: [],
        selectValue: "0",
        key:"",
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'name',
            scopedSlots: { customRender: 'detail' }
          },
          {
            title:'联系方式',
            align:"center",
            dataIndex: 'contactPhone'
          },
          {
            title:'意向度', 
            align:"center",
            dataIndex: 'intendedDegress_dictText'
          },
          {
            title:'意向课程',
            align:"center",
            dataIndex: 'intendedCourse_dictText'
          },
          {
            title:'顾问',
            align:"center",
            dataIndex: 'saleCode_dictText'
          },
          {
            title:'最近跟进时间',
            align:"center",
            dataIndex: 'lastFollowTime'
          },
          {
            title:'最近跟进记录',
            align:"center",
            dataIndex: 'follow_log'
          },
          {
            title:'下次跟进日期',
            align:"center",
            dataIndex: 'nextFollowTime'
          },
          {
            title:'跟进状态',
            align:"center",
            dataIndex: 'followStatusDictText'
          },
          {
            title:'学员类型',
            align:"center",
            dataIndex: 'type_dictText'
          },
          {
            title:'年龄',
            align:"center",
            dataIndex: 'birthday'
          },
          {
            title:'来源',
            align:"center",
            dataIndex: 'channelType_dictText'
          },
          {
            title:'采单员',
            align:"center",
            dataIndex: 'collectinoCode_dictText'
          },
          {
            title:'学校',
            align:"center",
            dataIndex: 'school_dictText'
          },
          {
            title:'年级',
            align:"center",
            dataIndex: 'grade_dictText'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'markString',
            customRender: (text) => {
              return ellipsis(text);
            }
          },
          {
            title:'录入时间',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        rules: {
          date: [
            { required: true, message: '请输入预约日期!', trigger: 'blur'},
           ],
        },
        url: {
          list: "/customer/customerInfo/list",
          delete: "/customer/customerInfo/delete",
          deleteBatch: "/customer/customerInfo/deleteBatch",
          exportXlsUrl: "/customer/customerInfo/exportXls",
          importExcelUrl: "customer/customerInfo/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
        imageSource: [{
          key:0,
          fileDetails:[
            {
              imgUrl:"https://static.jeecg.com/upload/test/3a4490d5d1cd495b826e528537a47cc1.jpg"
            },
            {
              imgUrl:"https://static.jeecg.com/temp/国炬软件logo_1606575029126.png"
            }
          ]
          },{
            key:1,
            fileDetails:[
              {
                imgUrl:"https://static.jeecg.com/upload/test/u27356337152749454924fm27gp0_1588149731821.jpg"
              },
              {
                imgUrl:"https://static.jeecg.com/upload/test/1_1588149743473.jpg"
              }
            ]
          }
      ],
      typeOptions:[],
      ageMin: undefined,
      ageMax: undefined,
      value13: undefined,
      }
    },
    props: ['tabPara'],
    created() {
      this.queryParam = {
        type: 5
      };
      this.getSuperFieldList();
      this.typeOptions = getDictItemsFromCache('customer_pc_type');
    },
    watch: {
      tabPara : {
        immediate: true,
        handler(param){
          if (String(param) === "2") {
            this.queryParam = {
              saleCode:store.getters.userInfo.username
            }
          } else if (String(param) === "3") {
            this.queryParam = {
              type: 5
            };
          } 
        }
      }
    },
    methods: {
      initDictConfig(){
      },
      disabledDate(current) {
        return current < moment().endOf("day"); // 当前时间之前的所有日期都禁用
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'int',value:'schoolDistrictId',text:'校区ID',dictCode:"school_organization,name,id"})
        fieldList.push({type:'string',value:'name',text:'姓名',dictCode:''})
        fieldList.push({type:'string',value:'nickname',text:'昵称',dictCode:''})
        fieldList.push({type:'int',value:'sex',text:'性别',dictCode:'sex'})
        fieldList.push({type:'string',value:'contactName',text:'家长姓名',dictCode:''})
        fieldList.push({type:'string',value:'contactPhone',text:'家长电话',dictCode:''})
        fieldList.push({type:'string',value:'contact1Name',text:'备选联系人1',dictCode:''})
        fieldList.push({type:'string',value:'contact1Phone',text:'备选联系人1电话',dictCode:''})
        fieldList.push({type:'string',value:'contact2Name',text:'备选联系人2',dictCode:''})
        fieldList.push({type:'string',value:'contact2Phone',text:'备选联系人2电话',dictCode:''})
        fieldList.push({type:'int',value:'age',text:'年龄',dictCode:''})
        fieldList.push({type:'date',value:'birthday',text:'生日'})
        fieldList.push({type:'string',value:'school',text:'学校',dictCode:"school_school,name,id"})
        fieldList.push({type:'string',value:'grade',text:'年级',dictCode:'customer_grade'})
        fieldList.push({type:'string',value:'class',text:'班级',dictCode:''})
        fieldList.push({type:'string',value:'idCard',text:'身份证',dictCode:''})
        fieldList.push({type:'string',value:'address',text:'住址',dictCode:''})
        fieldList.push({type:'string',value:'channelType',text:'渠道类型'})
        fieldList.push({type:'string',value:'intendedCourse',text:'意向课程',dictCode:"education_course,name,id"})
        fieldList.push({type:'int',value:'intendedDegress',text:'意向度',dictCode:'customer_intention_status'})
        fieldList.push({type:'sel_user',value:'saleCode',text:'顾问'})
        fieldList.push({type:'string',value:'referencesPhone',text:'推荐人',dictCode:''})
        fieldList.push({type:'sel_user',value:'collectinoCode',text:'采单员'})
        fieldList.push({type:'int',value:'status',text:'状态',dictCode:'customer_pc_status'})
        fieldList.push({type:'int',value:'followStatus',text:'跟进状态',dictCode:'customer_follow_status'})
        fieldList.push({type:'datetime',value:'lastFollowTime',text:'上次跟进'})
        fieldList.push({type:'datetime',value:'nextFollowTime',text:'下次跟进'})
        fieldList.push({type:'Blob',value:'mark',text:'备注',dictCode:''})
        this.superFieldList = fieldList
      },
      handleFollow(row) {
        // addloading
        this.followVisible = true;
        this.dataFollow = row;
      },
      onCreateTimeChange: function (value, dateString) {
        this.queryParam.beginTime=dateString[0];
        this.queryParam.endTime=dateString[1];
      },
      followOk() {
        if (this.followType == "") {
          this.$message.warn('请输入跟进类型');
          return;
        }
        if (this.followContent == "") {
          this.$message.warn('请输入跟进内容');
          return;
        }
        if (this.nextFollowTime == "") {
          this.$message.warn('请输入跟进日期');
          return;
        }
        let params = {
          schoolDistrictId: this.dataFollow.schoolDistrictId,
          cpId: this.dataFollow.id,
          followType:this.followType,
          followContent:this.followContent,
          followPic:this.fileList,
          salesCode:this.dataFollow.saleCode,
          createBy:store.getters.userInfo.username,
          nextFollowTime:this.realFollowTime
        }
        console.log(params);
        this.followloading = true;
        postAction("/customer/customerFollow/addFollow", params).then((res) => {
          if (res.success) {
            this.$emit('ok');
            this.$message.success('添加成功');
          } else {
            this.$message.warn('添加失败:' + res.message);
          }
        }).finally(() => {
          this.followloading = false;
          this.followVisible = false;
          this.followType = "";
          this.followContent = "";
          this.fileList = "";
          this.dataFollow = "";
          this.nextFollowTime = "";
          this.realFollowTime = "";
          this.loadData();
        });
      },
      followCancel() {
        if(JSON.stringify(this.fileList) !== '[]' || Object.keys(this.fileList).length !== 0) {
          let bizPath =[];
          if(this.fileList.indexOf(",")!= -1) {
            bizPath = this.fileList.split(',');
          }else {
            bizPath.push(this.fileList)
          }
          postAction("/sys/common/delUploadTemp", bizPath).then((res) => {
          });
        }
        this.fileList = [];
        this.dataFollow = "";
        this.followVisible = false;
        this.followType = "";
        this.followContent = "";
        this.nextFollowTime = "";
        this.realFollowTime = "";
      },
      handleSign(row) {
        let params = {
          id: row.id,
          status: 2,
          followStatus: 8,
          name: row.name,
          contactPhone: row.contactPhone
        }
        postAction("/customer/customerInfo/sign", params).then((res) => {
          if (res.success) {
            this.$emit('ok');
            this.$message.success(res.message);
          } else {
            this.$message.warn('报名失败:' + res.message);
          }
        }).finally(() => {
          this.dialogloading = false;
          this.dialogPvVisible = false;
          this.loadData();
        });
      },
      handleReject(row) {
         let params = {
          id: row.id,
          status: 3,
          followStatus: 1,
          name: row.name,
          contactPhone: row.contactPhone
        }
        postAction("/customer/customerInfo/statusEdit", params).then((res) => {
          if (res.success) {
            this.$emit('ok');
            this.$message.success(res.message);
          } else {
            this.$message.warn('修改失败:' + res.message);
          }
        }).finally(() => {
          this.dialogloading = false;
          this.dialogPvVisible = false;
          this.loadData();
        });
      },
      handleInvalid(row) {
        let params = {
          id: row.id,
          status: 4,
          followStatus: 9,
          name: row.name,
          contactPhone: row.contactPhone
        }
        postAction("/customer/customerInfo/statusEdit", params).then((res) => {
          if (res.success) {
            this.$emit('ok');
            this.$message.success(res.message);
          } else {
            this.$message.warn('修改失败:' + res.message);
          }
        }).finally(() => {
          this.dialogloading = false;
          this.dialogPvVisible = false;
          this.loadData();
        });
      },
      getFormFieldValue(field){
        return this.form.getFieldValue(field)
      },
      visitingOk(){
        if (this.dateStr == "") {
          this.$message.warn('请输入客户预约日期！');
          return null;
        } else {
          this.visitingloading = true;
          let params = {
            schoolDistrictId: this.dataVisit.schoolDistrictId,
            cpId: this.dataVisit.id,
            cpName: this.dataVisit.name,
            cpPhone: this.dataVisit.contactPhone,
            visitingTime: this.dateStr,
            salesCode: this.dataVisit.saleCode
          }
          console.log(params);
          postAction("/customer/customerInfo/addVisit", params).then((res) => {
            if (res.success) {
              this.$emit('ok');
              this.$message.success(res.message);
            } else {
              this.$message.warn(res.message);
            }
          }).finally(() => {
            this.visitingloading = false;
            this.visitingVisible = false;
            this.dateStr = "";
            this.dataVisit = "";
            this.loadData();
          });
        }
      },
      handleVisiting(row) {
        this.visitingVisible = true;
        this.dataVisit = row;
      },
      visitingCancel(){
        this.dateStr = "";
        this.dataVisit = "";
        this.visitingVisible = false;
      },

      auditionOk() {
        if (this.dateAudition == "") {
          this.$message.warn('请输入客户试听日期！');
          return null;
        } else {
          this.auditionloading = true;
          let params = {
            schoolDistrictId: this.dataAudition.schoolDistrictId,
            cpId: this.dataAudition.id,
            cpName: this.dataAudition.name,
            cpPhone: this.dataAudition.contactPhone,
            auditionTime: this.dateAudition,
            salesCode: this.dataAudition.saleCode
          }
          postAction("/customer/customerInfo/addAudition", params).then((res) => {
            if (res.success) {
              this.$emit('ok');
              this.$message.success(res.message);
            } else {
              this.$message.warn(res.message);
            }
          }).finally(() => {
            this.auditionVisible = false;
            this.auditionloading = false;
            this.dateAudition = "";
            this.dataAudition = "";
            this.loadData();
          });
        }
      },
      handleAudition(row) {
        this.auditionVisible = true;
        this.dataAudition = row;
      },
      auditionCancel(){
        this.dateAudition = "";
        this.dataAudition = "";
        this.auditionVisible = false;
      },
      onChangeTime(value,dateString) {
        this.nextFollowTime = dateString;
        this.realFollowTime  = dateString;
      },
      handleFollowDetail(row) {
        this.followDetailVisible = true;
        let params = {
          cp_id:row.id
        }
        postAction("/customer/customerFollow/followDetail", params).then((res) => {
          if (res.length > 0) {
            this.dataFollowDetail = res;
          } else {
            this.$message.success("无跟进信息");
          }
        });
      },
      cancelFollowDetail() {
        this.followDetailVisible = false;
        this.dataFollowDetail = [];
      },
      searchReset() {
        this.queryParam = {
          type: 5
        };
        this.loadData();
        this.checked = false;
      },
      invalidChange(value) {
        this.checked = !value;
        if (this.checked) {
          this.queryParam.noInvalid = "unShow";
          this.loadData();
        } else {
          this.queryParam.noInvalid = null;
          this.loadData();
        }
      },
      handleInput(e) {
        if (e == 0) {
          this.queryParam.type = undefined
        } else {
          this.queryParam.type = e
        }
      },
      // var params = this.getQueryParams();//获取查询条件
      // searchQuery() {
      //   console.log(this.getQueryParams());
      //   this.queryParam = {
      //     type: 5
      //   };
      //   this.loadData(this.queryParam);
      // }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
<!-- <style lang="less" scoped>
  /deep/ .ant-modal-content {
    height: 400px;
  }
</style> -->