<template>
  <div id="marketingqueryId" class="content">
    <div class="search">
      <mobile-input label-width="10px" :reset="resetvalue" input-align="left" name="searchContent" v-model="searchContent" placeholder="请输入关键字" size="small" />
      <div style="width: 200px; display: flex;justify-content: space-evenly;align-items: self-start">
        <van-button color="#FF574C" type="primary" @click="reset" plain style="width: 70px;height: 34px" size="small">重置</van-button>
        <van-button color="#FF574C" type="primary" @click="selectGDYXJHCX" style="width: 70px;height: 34px" size="small">查询</van-button>
      </div>
    </div>
    <div class="Managementdata">
      <scroller-view v-if="nodata" v-calculate-height :pulldown="pulldown" :pullup="pullup" :refresh-data="onrefreshdata" :load-data="onloaddata">
        <div v-for="(item, index) in itemDataList" :key="index" class="customer-bottom-list">
          <div class="faceSign-sty">
            <div class="customer-list-left">
              <div>
                <svg class="icon svg-sty" aria-hidden="true">
                  <use xlink:href="#icon-gongsimingcheng"></use>
                </svg>
              </div>
            </div>
            <div class="customer-list-right">
              <div>
                <span>【随意分】     {{ item.CUSTOMERNAME }}</span>
                <span style="margin-left: 10px">{{ item.BUSINESSDATE }}</span>
              </div>
              <div class="list-right-bottom">
                <span>
                  <svg class="icon" aria-hidden="true">
                    <use xlink:href="#icon-shoujizhanghao"></use>
                  </svg>
                </span>
                <span>{{ item.TELPHONE }}</span>
                <span>{{ item.COMPANYADD }}</span>
              </div>
            </div>
          </div>
          <div class="btn-sty">
            <van-button @click="invalidPopShow(item)" round color="#FF574C" plain size="small">作废</van-button>
            <van-button @click="selectSignPeople(item)" round color="#FF574C" plain size="small">移交</van-button>
            <van-button @click="toFaceSignProcess(item)" round color="#FF574C" plain size="small">面签</van-button>
          </div>
        </div>
      </scroller-view>
    </div>
    <base-popup showCancel="true" showConfirm="true" @cancel="signPopupShow = false" @confirm="becomeInvalid" v-model="signPopupShow" title="作废提示">
      <div class="bottom-sty">
        <div class="reason-sty">
          <div>作废说明：</div>
          <mobile-input
            :rules="[{ required: true, message: '备注说明不能为空' }]"
            type="textarea"
            :maxlength="500"
            :rows="7"
            input-align="left"
            name="REMAKE"
            v-model="invalidReason"
            size="small"
          />
        </div>
      </div>
    </base-popup>
    <base-popup showCancel="true" showConfirm="true" @cancel="transferPopupShow = false" @input="checked = 0" @confirm="transferClick" v-model="transferPopupShow" title="移交">
      <div class="bottom-sty">
        <div class="reason-sty">
          <van-radio-group v-model="checked" direction="horizontal">
            <van-radio v-for="(item, index) in customerList" :key="index" icon-size="25px" class="radio-sty" checked-color="#ee0a24" :name="index+1">{{ item.USERNAME }}</van-radio>
          </van-radio-group>
        </div>
      </div>
    </base-popup>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { Search, Radio, RadioGroup } from 'vant';
import nettyApi from "@/constants/api/ms-netty/netty.api.ts";
import IF from "@/public/factory/InterFaceFactory";
import { NativeUI } from "@/public/ts/NativeUI";
import { Popup } from 'vant';
import BasePopup from "@/components/general/BasePopup.vue";

Vue.use(Popup);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(Search);
/**
 * @Description 电话营销
 * @Author JiangTao
 * @Date 2022-01-18 下午 04:06
 */
@Component({
  name: "FaceSignList",
  components: { BasePopup },
})
export default class FaceSignList extends Vue {
  itemDataList = [];
  searchContent = ''; //搜索内容
  resetvalue = false;
  pageNo = 1;
  pullup = true;
  pulldown = true;
  nodata = true;
  signPopupShow = false;
  invalidReason = '';
  taskInfo = {
    BUSINESSDATE: '',
    BUSINESSSUM: '',
    CERTID: '',
    COMPANYADD: '',
    COMPANYNAME: '',
    CUSTOMERID: '',
    CUSTOMERNAME: '',
    GJJTYPE: '',
    SERIALNO: '',
    SEX: '',
    SIGNSTATUS: '',
    SIGNYPE: '',
    TELPHONE: '',
    OBJECTNO: ''
  };
  transferPopupShow = false;
  checked = 0;
  customerList: any = [];

  //重置功能
  reset() {
    this.resetvalue = true;
    this.searchContent = '';
    this.selectGDYXJHCX();
  }
  created() {
    this.selectGDYXJHCX();
  }
  /**
   * @Description 跳转面签流程
   * @Author XWH
   * @Date 2022-02-11 下午 17:02
   */
  toFaceSignProcess(item: any) {
    this.$store.commit("setFaceSignInfo",item);
    this.$router.push({
      path: "/FaceSignView",
      query: {
        formView: '1'
      }
    });
  }
  //上拉加载
  onloaddata() {
    this.pageNo = Math.ceil(this.itemDataList.length / 10) + 1;
    return this.selectGDYXJHCX(this.pageNo);
  }
  /**
   * @Description 下拉刷新
   * @Author JiangTao
   * @Date 2022-01-17 下午 05:14
   */;
  onrefreshdata() {
    return this.selectGDYXJHCX();
  }
  selectGDYXJHCX(pageNo = 1) {
    const param = {
      USERCODE: sessionStorage.getItem("user_code"),
      ORGCODE: sessionStorage.getItem("org_code"),
      QUERYFLAG: 1,
      QUERYNAME: this.searchContent,
      tc: nettyApi.TRADE_CODE.selectFaceSignTaskList
    },
    _this = this;
    NativeUI.showWaiting('正在查询...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      console.log('面签列表',res)
      if(res.rc == "1"){
        if (res.ARRAY.length > 0) {
          _this.itemDataList = res.ARRAY;
        }
        if (res.ARRAY && res.ARRAY.length < 10) {
          this.pullup = false;
        }
        if (this.itemDataList.length == 0) {
          this.nodata = false;
          this.pulldown = false;
        }
      } else {
        NativeUI.toast(res.msg);
      }
    });
  }
  invalidPopShow(item: any){
    this.signPopupShow = true;
    this.taskInfo = item;
  }
  /**
   * @Description 面签任务作废
   * @Author xwh
   * @Date 2022-02-16 下午 03:13
   */
  becomeInvalid(){
    const item = this.taskInfo;
    const param = {
        USERCODE: sessionStorage.getItem("user_code"),
        ORGCODE: sessionStorage.getItem("org_code"),
        USERNAME: sessionStorage.getItem("ORGNAME"),
        ORGNAME: sessionStorage.getItem("USERNAME"),
        SERIALNO: item.SERIALNO,
        OBJECTNO: item.OBJECTNO,
        OBJECTMODEL: '3', //1面签岗提交、2面签岗转让、3面签岗作废、4面签复核岗退回、5面签复核岗提交
        SIGNYPE: item.SIGNYPE,
        REMARK: this.invalidReason,
        tc: nettyApi.TRADE_CODE.faceSignTaskProcess
      },
      _this = this;
    NativeUI.showWaiting('正在作废...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      if(res.rc == 1){
        this.signPopupShow = false;
        _this.selectGDYXJHCX();
      }else{
        NativeUI.toast(res.msg);
      }
    });
  }
  /**
   * @Description 面签人员查询
   * @Author xwh
   * @Date 2022-02-16 下午 18:13
   */
  selectSignPeople(item: any){
    this.taskInfo = item;
    const param = {
        USERCODE: sessionStorage.getItem("user_code"),
        ORGCODE: sessionStorage.getItem("org_code"),
        ROLEID: 'R1016',
        OBJECTMODEL: '2',//1流程提交用户查询、2总行面签岗人员查询
        tc: nettyApi.TRADE_CODE.selectSignPerson
      },
      _this = this;
    NativeUI.showWaiting('正在查询...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      console.log('查询用户列表',res)

      if(res.rc == 1){
        if(res.ARRAY.length > 0){
          _this.transferPopupShow = true;
          _this.customerList = res.ARRAY;
        }else{
          NativeUI.toast('未查询到可移交人员信息');
        }
      }else{
        NativeUI.toast(res.msg);
      }
    });
  }
  //转让
  transferClick(){
    let item = this.taskInfo,
      custInfo = this.customerList[this.checked-1];
    const param = {
        USERCODE: sessionStorage.getItem("user_code"),
        ORGCODE: sessionStorage.getItem("org_code"),
        USERNAME: sessionStorage.getItem("ORGNAME"),
        ORGNAME: sessionStorage.getItem("USERNAME"),
        SERIALNO: item.SERIALNO,
        OBJECTNO: item.OBJECTNO,
        OBJECTMODEL: '2', //1面签岗提交、2面签岗转让、3面签岗作废、4面签复核岗退回、5面签复核岗提交
        SIGNYPE: item.SIGNYPE,
        REMARK: '',
        FLOWUSERID: custInfo.USERID,
        FLOWUSERNAME: custInfo.USERNAME,
        FLOWORGNAME: custInfo.ORGNAME,
        FLOWORGID: custInfo.ORGID,
        tc: nettyApi.TRADE_CODE.faceSignTaskProcess
      },
      _this = this;
    console.log(param);
    NativeUI.showWaiting('正在加载...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      console.log('面签转让',res)
      if(res.rc == 1){
        NativeUI.toast('转让成功');
        this.transferPopupShow = false;
        _this.selectGDYXJHCX();
      }else{
        NativeUI.toast(res.msg);
      }
    });
  }
}
</script>

<style scoped lang="scss">
::v-deep .van-cell__title,
::v-deep .van-field__label {
  display: flex;
  align-items: center;
}
.content {
  width: 100%;
  height: 100%;
}
.search {
  width: 100%;
  height: 70px;
  border: 1px solid #e1e2e3;
  display: flex;
  align-items: center;
  justify-content: center;
}
::v-deep .d-form-field {
  padding-bottom: 0;
  width: 70%;
}
::v-deep .van-field__control {
  height: 30px;
}
.customer-bottom-list {
  border-radius: 10px;
  box-shadow: 0 0 6px #d7d7d7;
  margin: 0 10px 16px 10px;
  //position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.customer-bottom-list > div:nth-child(1) {
  width: 65%;
}
.customer-bottom-list > div:nth-child(2) {
  width: 35%;
  display: flex;
  justify-content: space-around;
}
.customer-bottom-list > div:nth-child(2) button {
  width: 70px !important;
}
.Managementdata {
  padding: 0 20px;
}
::v-deep .screenbutton button {
  margin: 20px auto;
}
::v-deep .screenbutton .van-button__content {
  font-size: 18px;
}
::v-deep .van-picker {
  width: 75%;
  margin-left: 25%;
  border-top-left-radius: 15px;
}
::v-deep  .van-popup--bottom .van-popup--round {
  width: 75% !important;
  margin-left: 25% !important;
}
::v-deep .van-popup--round {
  background-color: rgba(0, 0, 0, 0);
}
.searchStyle {
  display: grid;
  align-items: center;
  grid-template-columns: 1fr 1fr;
}
.searchStyle div {
  width: 90%;
}
::v-deep .scroller {
  margin-top: 10px;
}
::v-deep .van-popup--center {
  height: 50% !important;
  width: 60% !important;
  left: 62.5%;
}
.popup-data {
  width: 60%;
  height: 100%;
  margin: 0 auto;
}
::v-deep .popup-content {
  height: 100%;
}
::v-deep .popup-data .d-form-field {
  width: 100% !important;
  padding-bottom: 20px;
}
::v-deep .van-field__label {
  width: 4.5em;
}
.popup-data > div:nth-child(1) {
  font-size: 20px;
  font-weight: bold;
  padding-left: 1rem;
  margin-bottom: 5px;
}
.shortMessageContent {
  font-size: 18px;
  padding-top: 20px;
}
.labelData {
  width: auto;
  padding: 2px 5px !important;
  margin-left: 10px;
  font-size: 12px;
  color: #ff6e0d;
  background-color: #fff7cc;
  border-radius: 2px;
}
.svg-sty{
  width: 50px;
  height: 50px;
}
.faceSign-sty{
  display: flex;
  align-items: center;
  height: 100px;
}
.customer-list-right{
  display: flex;
  flex-direction: column;
}
div > span:nth-child(1){
  font-size: 16px;
}
div > span:nth-child(2){
  font-size: 14px;
  color: #a19b9b;
}
.list-right-bottom{
  margin-top: 8px;
  color: #a19b9b;
}
.list-right-bottom > span:nth-child(1) > svg{
  width: 20px;
  height: 20px;
}
.list-right-bottom > span:nth-child(2){
  margin-right: 20px;
}
.list-right-bottom > span:nth-child(3){
  font-size: 16px;
}
::v-deep .van-button{
  text-align: center;
}
.bottom-sty{
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  height: 100%;
}
::v-deep .van-field__control{
  width: 400px;
  height: 70%;
}
.radio-sty{
  height: 40px;
  margin: 0 15px 15px 0;
  font-size: 20px;
}
</style>
