<template>
  <div class="FSQStoreDetail">
    <div class="header">
      <van-nav-bar class="navBar" title="客户详情" left-arrow @click-left="onClickLeft">
        <template #right v-if="fromData.updatable">
          <span style="color: #0057ba" @click="editorFn">编辑 </span>
        </template>
      </van-nav-bar>
    </div>
    <div class="content">
      <van-form ref="tabstoreVal" readonly :scroll-to-error="true" :show-error="false">
        <van-field readonly :value="fromData.storeCode" label="客户编码">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field
          v-model="fromData.storeName"
          label="客户名称"
          placeholder="请输入客户名称"
          rows="1"
          autosize
          type="textarea"
          :rules="[
            {
              required: true,
              message: '请输入客户名称',
            },
          ]">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field
          readonly
          clickable
          name="picker"
          :value="fromData.storeCategoryName"
          label="客户类型"
          placeholder="点击选择客户类型">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field
          v-model="fromData.orgName"
          label="销售部"
          placeholder="请输入销售部"
          :rules="[{ required: true, message: '请输入销售部' }]">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field
          readonly
          clickable
          name="picker"
          :value="fromData.provinceName"
          label="省(州)"
          placeholder="点击选择省(州)">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field
          readonly
          clickable
          name="picker"
          :value="fromData.cityName"
          label="城市"
          placeholder="点击选择城市">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field
          readonly
          clickable
          name="picker"
          :value="fromData.districtName"
          label="区(县)"
          placeholder="点击选择区(县)">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <!-- <van-field
          readonly
          clickable
          name="picker"
          :value="fromData.townName"
          label="街道"
          placeholder="点击选择街道">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field> -->
        <van-field
          v-model="fromData.addressLine"
          label="地址"
          placeholder="请输入地址"
          rows="1"
          autosize
          type="textarea"
          :rules="[
            {
              required: true,
              message: '请输入地址',
            },
          ]">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field readonly v-model="fromData.cityLevel" label="城市等级">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field readonly v-model="fromData.contactName" label="客户联系人">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field
          type="tel"
          v-model="fromData.telephone"
          label="客户联系人电话"
          placeholder="请输入客户联系人电话">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
        <van-field readonly v-model="fromData.salesmanName" label="销售员" placeholder="销售员">
          <template #left-icon>
            <span class="van-f-red"></span>
          </template>
        </van-field>
      </van-form>
    </div>
  </div>
</template>

<script>
import { getById } from '@/api/index';
export default {
  data() {
    return {
      fromData: {
        storeCode: '',
        storeName: '',
        telephone: '',
        storeCategoryName: '',
        provinceName: '',
        cityName: '',
        districtName: '',
        addressLine: '',
        orgName: '',
        contactName: '',
        salesmanName: '',
        cityLevel: '',
      },
    };
  },
  activated() {
    this.toastLoading(0, '加载中...', true);
    // 获取详情
    this.getDetail();
  },
  methods: {
    editorFn() {
      this.$router.push({
        path: '/competingStoresEdit',
        query: { id: this.$route.query.id },
      });
    },
    getDetail() {
      getById({ storeId: this.$route.query.id }).then((res) => {
        this.toastLoading().clear();
        if (res.code == 200) {
          this.fromData = res.data;
        }
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang="scss" scoped>
.FSQStoreDetail {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  .header {
    height: 46px;
  }
  .content {
    flex: 1;
    overflow-y: auto;
  }
}
</style>
