<template>
  <div class="FSQStoreDetail">
    <div class="header">
      <van-nav-bar class="navBar" title="仿石漆服务商详情" left-arrow @click-left="onClickLeft">
        <template #right>
          <span v-if="fromData.updatable" style="color: #0057ba" @click="editorFn">编辑 </span>
        </template>
      </van-nav-bar>
    </div>
    <div class="content">
      <div class="detailHeader">
        <van-icon name="volume" color="#64a8eb" size="18" />
        <span>如需修改服务商的姓名和手机号，请提IT工单到低代码合同系统修改</span>
      </div>
      <van-tabs class="myTab" v-model="tabVal" color="#0057ba" @change="tabChange">
        <van-tab title="基础信息" name="insidePlan" ref="dispsps">
          <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="请输入名称"
              :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-row style="border-bottom: 1px solid #ebedf0">
              <van-field
                rows="1"
                autosize
                type="textarea"
                readonly
                clickable
                name="picker"
                :value="fromData.chainName"
                label="经销商名称"
                placeholder="点击选择经销商名称"
                :rules="[
                  {
                    required: true,
                    message: '请选择经销商',
                  },
                ]">
                <template #left-icon>
                  <span class="van-f-red"></span>
                </template>
              </van-field>
            </van-row>
            <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.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>
        </van-tab>
        <!-- 质感服务商档案 -->
        <van-tab title="服务商档案" name="outsidePlan">
          <FSQattributeDetail
            :storeArchives="fromData.serviceProviderArchives"></FSQattributeDetail>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import { getById } from '@/api/index';
import FSQattributeDetail from './FSQattributeDetail.vue';
export default {
  components: { FSQattributeDetail },
  data() {
    return {
      tabVal: 'insidePlan',
      fromData: {
        storeCode: '',
        storeName: '',
        telephone: '',
        storeCategoryName: '',
        provinceName: '',
        cityName: '',
        districtName: '',
        addressLine: '',
        orgName: '',
        chainName: '',
        townName: '',
        contactName: '',
        salesmanName: '',
      },
    };
  },
  activated() {
    this.tabVal = 'insidePlan';
    this.toastLoading(0, '加载中...', true);
    // 获取详情
    this.getDetail();
  },
  methods: {
    editorFn() {
      this.$router.push({
        path: '/FSQStoreEdit',
        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;
        }
      });
    },
    tabChange(name, title) {},
    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;
    .myTab .van-tabs__nav--card {
      margin: 0 !important;
      border-left: 0;
      border-right: 0;
    }
    .myTab .van-tabs__wrap,
    .van-tabs__nav--card {
      height: 40px;
    }
    .myTab .van-tab {
      line-height: 40px;
    }
  }
  .detailHeader {
    padding: 10px 20px;
    background: #dfeeff;
    font-size: 14px;
    display: flex;
    flex-direction: row;
    .van-icon {
      margin-right: 8px;
    }
    span {
      line-height: 20px;
      color: #323233;
    }
  }
}
</style>
