<template>
  <Container>
    <div slot="left">
      <el-button
        v-if="$accessCheck($Access.DeliverySetsetSelfData)"
        size="small"
        type="primary"
        @click="
          $router.push('/SystemSettings/jiaoyiset/AddSelffetch/' + delivery_id)
        "
      >
        新建自提点
      </el-button>
    </div>
    <el-table :data="selffetch_list">
      <el-table-column
        prop="name"
        label="自提点名称"
        min-width="140"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="shopName"
        label="所属店铺"
        show-overflow-tooltip
        min-width="140"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="address"
        label="自提点地址"
        min-width="230"
      >
        <template slot-scope="scope">
          {{ scope.row.provinceName }}-{{ scope.row.cityName }}-{{
            scope.row.districtName
          }}-{{ scope.row.address }}
        </template>
      </el-table-column>
      <el-table-column prop="mobil" label="联系方式" min-width="120">
        <template slot-scope="scope">
          <p>{{ scope.row.concatName }}</p>
          <p>{{ scope.row.mobile }}</p>
        </template>
      </el-table-column>
      <el-table-column label="营业时间" min-width="140">
        <template slot-scope="scope">
          <p v-if="scope.row.saleTimeType === 5">
            {{ scope.row.startTime }}-{{ scope.row.endTime }}
          </p>
          <p v-else>全天</p>
          <p>{{ scope.row.day.join(",") }}</p>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="120">
        <template slot-scope="scope">
          <el-button
            v-if="$accessCheck($Access.DeliverySeteditSelfData)"
            type="text"
            @click="
              $router.push(
                '/SystemSettings/jiaoyiset/EditSelffetch/' +
                  scope.row.id +
                  '/' +
                  delivery_id
              )
            "
          >
            编辑
          </el-button>

          <el-button
            v-if="$accessCheck($Access.DeliverySetdelDeliverySelfRule)"
            type="text"
            @click="delData(scope.row.id)"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </Container>
</template>

<script>
  import { delDeliverySelfRule, DeliveryInfo } from "@/api/System";
  export default {
    name: "SelffetchList",
    data() {
      return {
        delivery_id: "",
        selffetch_list: [],
      };
    },
    created() {
      this.delivery_id = this.$route.params.deiId;
      this.DeliveryInfo();
    },
    activated() {
      if (this.$_isInit()) return;
      this.DeliveryInfo();
    },
    methods: {
      delData(id) {
        this.$confirm("确定要删除该自提点吗？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          const data = await delDeliverySelfRule(id);

          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.DeliveryInfo();
        });
      },
      // 获取运费模版
      async DeliveryInfo() {
        const { data } = await DeliveryInfo(this.delivery_id);

        this.selffetch_list = data.setData;
      },
    },
  };
</script>

<style scoped></style>
