<template>
  <div class="content">
    <div class="search">
      <mobile-input label-width="10px" :reset="resetvalue" input-align="left" name="CUSTOMERNAME" v-model="CUSTOMERNAME" 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;display: block" size="small">重置</van-button>
        <van-button color="#FF574C" type="primary" @click="search" style="width: 70px;height: 34px;display: block" 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" @click="collection(item)">
          <div class="customer-bottom-list-top">
            <div>
              <svg style="width: 30px;height: 35px" class="icon" aria-hidden="true">
                <use xlink:href="#icon-gongsimingcheng"></use>
              </svg>
            </div>
            <div>{{ item.customerName }}</div>
            <div>{{ item.marketTypeName }}</div>
            <div v-if="item.createType == '1'" class="labelData">总行</div>
            <div v-if="item.createType == '2'" class="labelData">分(支)行</div>
            <div v-if="item.createType == '3'" class="labelData">自建</div>
          </div>
          <div class="customer-bottom-list-bottom">
            <span>营销时间:{{ item.createTime }}</span>
          </div>
        </div>
      </scroller-view>
    </div>
    <div @click="addButton" class="add-button">新增</div>
    <base-popup v-model="flagPopup" title="营销选择">
      <div class="popup-content">
        <div @click="customer_visit" class="customer-visit">
          <div><img style="width: 100%" src="@/assets/images/DGKHBF.png" alt=""></div>
          <div>客户拜访</div>
        </div>
        <div @click="business_marketing" class="business-marketing">
          <div><img style="width: 100%" src="@/assets/images/DGZSYZ.png" alt=""></div>
          <div>招商引资企业营销</div>
        </div>
        <div @click="information_pattern" class="information-pattern">
          <div><img style="width: 100%" src="@/assets/images/DGKHXXMC.png" alt=""></div>
          <div>公司精准信息摸排</div>
        </div>
        <div @click="marketing_special" class="marketing-special">
          <div><img style="width: 100%" src="@/assets/images/DGKHYXQK.png" alt=""></div>
          <div>精准营销专项</div>
        </div>
      </div>
    </base-popup>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { Search } from 'vant';
import BasePopup from "@/components/general/BasePopup.vue";
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 applicationApi from "@/constants/api/ms-application/application.api";
import { getText } from "@/stores";

Vue.use(Popup);

Vue.use(Search);
/**
 * @Description 对公上门营销(待办)
 * @Author JiangTao
 * @Date 2022-01-18 下午 04:06
 */
@Component({
  name: "ComMarketingView",
  components: { BasePopup },
})
export default class ComMarketingView extends Vue {
  resetvalue = false;
  CUSTOMERNAME = "";
  itemDataList = [];
  pageNo = 1;
  pullup = true;
  pulldown = true;
  nodata = true;
  flagPopup = false;
  createType = '';

  mounted() {
    this.flagPopup = false;
    this.selectContactList(1);
  }
  activated() {
    this.flagPopup = false;
    this.selectContactList(1);
  }
  /**
   * @Description 客户拜访
   * @Author JiangTao
   * @Date 2022-01-27 下午 03:25
   */
  customer_visit() {
    this.$store.commit("setEmpty");
    this.flagPopup = false;
    this.$router.push({
      path: "/ComVisitMarkDetail",
    });
  }
  /**
   * @Description 招商引资企业营销
   * @Author JiangTao
   * @Date 2022-01-27 下午 03:26
   */
  business_marketing() {
    this.$store.commit("setEmpty");
    this.flagPopup = false;
    this.$router.push({
      path: "/ComAttractMarkDetail",
    });
  }
  /**
   * @Description 公司精准信息摸排
   * @Author JiangTao
   * @Date 2022-01-27 下午 03:26
   */
  information_pattern() {
    this.$store.commit("setEmpty");
    this.flagPopup = false;
    this.$router.push({
      path: "/ComProjectMarkDetail",
    });
  }
  /**
   * @Description 精准营销专项
   * @Author JiangTao
   * @Date 2022-01-27 下午 03:26
   */
  marketing_special() {
    this.$store.commit("setEmpty");
    this.flagPopup = false;
    this.$router.push({
      path: "/ComPreMarkDetail",
    });
  }
  /**
   * @Description 新增
   * @Author JiangTao
   * @Date 2022-01-28 上午 11:24
   */
  addButton() {
    this.$store.commit("setEmpty");
    this.flagPopup = true;
    // this.$router.push({
    //   path: "/PerMarketingAdd"
    // });
  }
  /**
   * @Description 点击列表事件
   * @Author JiangTao
   * @Date 2022-01-18 下午 07:15
   */
  collection(item: any) {
    this.$store.commit("setEmpty");
    this.$store.commit("setCusInfo", item);
    if (item.marketType == '1') {
      this.$router.push({
        path: "/ComVisitMarkDetail",
      });
    } else if (item.marketType == '2') {
      this.$router.push({
        path: "/ComAttractMarkDetail",
      });
    } else if (item.marketType == '3') {
      this.$router.push({
        path: "/ComProjectMarkDetail",
      });
    } else if (item.marketType == '4') {
      this.$router.push({
        path: "/ComPreMarkDetail",
      });
    }
  }
  /**
   * @Description 查询
   * @Author JiangTao
   * @Date 2022-01-18 下午 04:17
   */
  search() {
    this.selectContactList(1);
  }
  /**
   * @Description 重置
   * @Author JiangTao
   * @Date 2022-01-18 下午 05:36
   */
  reset() {
    this.CUSTOMERNAME = "";
    this.resetvalue = true;
    this.selectContactList(1);
  }
  /**
   * @Description 上拉加载
   * @Author JiangTao
   * @Date 2022-01-18 下午 04:04
   */
  onloaddata() {
    this.pageNo = Math.ceil(this.itemDataList.length / 10) + 1;
    return this.selectContactList(this.pageNo);
  }
  /**
   * @Description 下拉刷新
   * @Author JiangTao
   * @Date 2022-01-17 下午 05:14
   */
  onrefreshdata() {
    return this.selectContactList();
  }
  /**
   * @Description 对公营销
   * @Author JiangTao
   * @Date 2022-01-18 下午 03:46
   */
  selectContactList(pageNo = 1) {
    this.nodata = true;
    this.pullup = true;
    this.pulldown = true;
    const param = {
      customerName: this.CUSTOMERNAME,
      exeUser: sessionStorage.getItem('workcode'),
      pageNum: pageNo,
      pageSize: '10',
      tc: 'MCEP'
    };
    NativeUI.showWaiting('正在查询...');
    return IF.transferDataInter(applicationApi.selectTodoTaskManager, param).then((res: any) => {
      console.log(res);
      NativeUI.closeWaiting();
      if (res.code == '1') {
        if (res.data.records && res.data.records.length > 0) {
          if (pageNo == 1) {
            this.itemDataList = res.data.records;
          } else {
            this.itemDataList = this.itemDataList.concat(res.data.records);
          }
          for (let i = 0; i < this.itemDataList.length; i++) {
            Vue.set(this.itemDataList[i], 'marketTypeName', getText((this.itemDataList[i] as any).marketType, 'marketType'));
          }
        } else {
          if (pageNo == 1) {
            this.itemDataList = [];
          }
        }
      } else {
        NativeUI.toast(res.msg);
      }
      if (res.data.records && res.data.records.length < 10) {
        this.pullup = false;
      }
      if (this.itemDataList.length == 0) {
        this.pulldown = false;
      }
    });
  }
}
</script>

<style scoped>
::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%;
  height: 50px;
}
::v-deep .van-field__control {
  height: 30px;
}
.customer-bottom-list {
  border-radius: 10px;
  background-color: #f8fdff;
  box-shadow: 0 0 6px #d7d7d7;
  margin: 0 10px 16px 10px;
  padding-bottom: 10px;
  position: relative;
}
.customer-bottom-list-top > div:nth-child(1) svg {
  width: 40px;
  height: 40px;
}
.customer-bottom-list-top > div:nth-child(2) {
  font-size: 115%;
  font-weight: bold;
  font-family: "微软雅黑 Bold", "微软雅黑 Regular", "微软雅黑";
  margin-left: 0.8%;
}
.customer-bottom-list-top {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding-top: 1.5%;
  margin-left: 1.5%;
}
.customer-bottom-list-top > div:nth-child(3) {
  width: auto;
  margin-left: 1%;
  font-size: 12px;
  background-color: #E2F6FF;
  padding: 2px 5px;
  color: #0297D7;
  border-radius: 2px;
}
.customer-bottom-list-top > div:nth-child(3) div {
  color: #ff6e0d;
  background-color: rgba(255, 247, 204, 1);
  font-size: 80%;
  padding-top: 2%;
  padding-bottom: 1.5%;
  border-radius: 2px;
  text-align: center;
  width: 100%;
}
.customer-bottom-list-bottom {
  width: 60%;
  height: 26px;
  display: flex;
  margin-top: 10px;
  padding-left: 70px;
  justify-content: flex-start;
  align-items: center;
}
.Managementdata {
  padding: 0 20px;
  height: calc(100% - 70px);
}
::v-deep .bs-wrapper {
  height: 100%;
}
::v-deep .screenPopup {
  width: 75%;
  margin-left: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 5% 5px 5%;
  z-index: 99 !important;
}
.screenPopup > div:nth-child(1) {
  width: 85%;
  height: 100%;
}
::v-deep .van-overlay {
  z-index: 2101 !important;
}
.screenbutton {
  width: 15%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-content: center;
  justify-content: center;
}
::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--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;
}
.add-button {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 40px;
  background-color: #ff574c;
  top: 80%;
  right: 5%;
  box-shadow: 0 5px 10px #e7aaa8;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 20px;
}
::v-deep .van-popup--center {
  z-index: 2102 !important;
}
.popup-content {
  width: 95%;
  height: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.popup-content > div {
  height: 100%;
  border: 1px solid #e0e1e2;
  width: 23%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}
.popup-content > div > div:nth-child(2) {
  width: 100%;
  text-align: center;
}
.labelData {
  width: auto;
  padding: 2px 5px;
  margin-left: 10px;
  font-size: 12px;
  color: #ff6e0d;
  background-color: #fff7cc;
  border-radius: 2px;
}
</style>