<template>
  <div>
    <el-dialog v-model="dialogVisible" :close-on-click-modal="false" custom-class="custom-inquiry-dialog" width="450px">
      <div class="info-section">
        <div class="info-item">
          <span class="label">首选商家：</span>
          <span class="value">{{ diodescription }}</span>
        </div>
        <div class="info-item">
          <span class="label">选择服务：</span>
          <span class="value">{{ diotext }}</span>
        </div>
      </div>

      <el-form ref="formRef" :model="form" label-position="top">
        <el-form-item label="需求量：" prop="quantity" :rules="[{ required: true, message: '请输入重量' }]">
          <el-input v-model="form.quantity" placeholder="请输入重量（kg）">
            <template #suffix>kg</template>
          </el-input>
        </el-form-item>

        <el-form-item label="您的称呼：" prop="name" :rules="[{ required: true, message: '请输入您的称呼' }]">
          <el-input v-model="form.name" placeholder="请输入您的称呼" />
        </el-form-item>

        <el-form-item
          label="您的电话："
          prop="phone"
          :rules="[
            { required: true, message: '请输入电话' },
            { pattern: /^1[3-9]\d{9}$/, message: '手机号格式错误' },
          ]"
        >
          <el-input v-model="form.phone" placeholder="请输入电话号码" />
        </el-form-item>
      </el-form>

      <template #footer>
        <div class="dialog-footer">
          <el-button class="cancel-btn" @click="dialogVisible = false">取消</el-button>
          <el-button class="submit-btn" type="primary" @click="handleSubmit">发送询价</el-button>
        </div>
      </template>
    </el-dialog>
    <!--  <page-layout :menus="state.menus"> </page-layout>-->
    <section>
      <common>
        <template #main>
          <el-card shadow="none" style="border-radius: 14px; position: relative">
            <div class="tabs tabs0">
              <div class="tab cursor">
                <div
                  v-for="(item, index) in tab0"
                  :key="index"
                  class="tab_list_li"
                  style="margin-left: 20px; margin-bottom: 10px"
                  :class="{ active: currentTab0 === index, tab_list_li0: currentTab0 === index }"
                  @click.stop="
                    currentTab0 = index;
                    currentTab1 = 0;
                    currentTab2 = 0;
                  "
                >
                  {{ item }}
                </div>
              </div>
            </div>
            <div class="tabs">
              <div class="tab cursor">
                <div
                  v-for="(item, index) in tab1"
                  :key="index"
                  class="tab_list_li"
                  :class="{ active: currentTab1 === index }"
                  @click.stop="currentTab1 = index"
                >
                  {{ item }}
                </div>
              </div>
            </div>
            <div class="tabs">
              <div class="tab cursor">
                <div
                  v-for="(item, index) in tab2"
                  :key="index"
                  class="tab_list_li"
                  :class="{ active: currentTab2 === index }"
                  @click.stop="currentTab2 = index"
                >
                  {{ item }}
                </div>
              </div>
            </div>
            <div style="position: absolute; right: 3%; top: 27%">
              <el-button style="padding: 10px 50px" size="large" type="primary" @click="applicationPackaging">发布需求</el-button>
            </div>
          </el-card>
          <el-row :gutter="20" style="margin-top: 10px">
            <el-col v-for="(item, index) in state.data" :key="index" :span="24">
              <el-card class="storage-card" shadow="hover">
                <div class="storage-content">
                  <div class="storage-content-top" @click="toLink(item)">
                    <img :src="getAssetsFile(`${item.imageUrl}`)" fit="cover" class="storage-image" />
                    <div class="storage-info">
                      <h3 class="storage-title">{{ item.title }}</h3>
                      <div class="storage-desc">
                        <span>{{ item.type }} | </span><span>{{ item.description }}</span>
                      </div>
                      <p class="storage-location storage-location1">{{ item.introduce }}</p>
                    </div>
                  </div>
                  <div v-if="item.rank" class="rank-badge">
                    <p style="text-align: right; font-size: 22px; color: #25bf82">￥{{ item.price }}/个</p>
                    <el-button style="padding: 5px 50px; margin-top: 50px" type="primary" @click="handleClick">购买</el-button>
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>

          <page-pagination :total="5" @current-change="currentChange" />
        </template>
      </common>
    </section>
  </div>
</template>
<script setup name="page-menu">
import { ref, reactive, watch } from 'vue';
import { getAssetsFile } from '@/utils';
import { useRoute, useRouter } from 'vue-router';
import warehouseLogisticsRoutes from '@/router/modules/warehouseLogistics';
import Common from './components/common.vue';

const route = useRoute();
const router = useRouter();

// const tab0 = reactive(['包装服务', '包装需求']);
const tab0 = reactive(['包装服务']);
const tab1 = reactive(['全部', '熟料容器', '金属容器', '纸类容器']);
const tab2 = reactive(['全部', '塑料框', '纸箱', '泡沫箱', '冰瓶']);
const tab3 = reactive(['水产', '其他类']);
const state = reactive({
  menus: warehouseLogisticsRoutes[0].children,
  query: {
    current: 1,
  },
  data: [
    {
      title: '5L堆码桶',
      description: '5L 7元/个',
      introduce:
        '5L堆码桶是一种专为液体包装设计的塑料容器，容量为5升，具备堆码功能，可节省存储和运输空间。其材质通常采用高密度聚乙烯（HDPE），具有耐酸碱、抗腐蚀、耐冲击、耐高低温等特性，符合食品级和化工级标准，广泛应用于化工、涂料、润滑油、食品、医药等行业。',
      price: '7.00',
      //地址
      address: '临沧市耿马县孟定镇100号',
      locationUrl: 'images/dz.png',
      //联系人
      contact: '刘冬冬',
      type: '塑料容器',
      //电话
      phone: '15678459087',

      rank: '1',
      imageUrl: 'images/11.jpg',
    },
    {
      title: '二手吨桶,八九成新两百升蓝桶',
      description: '100 380元/个',
      introduce:
        '材质与结构内容器：采用进口高密度聚乙烯（HDPE）或线性低密度聚乙烯（LLDPE），耐酸碱、抗腐蚀，符合食品级标准。外框架：镀锌钢管焊接网格，底盘为四向进叉型全钢托盘，结构稳固，可用铲车直接装卸。工艺：旋转滚塑一次成型，无缝焊接，壁厚≥5mm，强度高，使用寿命长。性能参数容量：标称1000L（实际灌装密度1.5时容积约1060L）。尺寸：外型尺寸约1200×1000×1160mm，净重60±1KG。压力测试：液压试验压力120kPa，渗漏试验压力22kPa，跌落试验高度2m。堆码能力：灌装密度≤1.5时可堆码2层，密度＞1.5时堆码1层，满载静态堆码高度可达4层。',
      price: '380.00',
      //地址
      address: '临沧市耿马县孟定镇100号',
      locationUrl: 'images/dz.png',
      //联系人
      contact: '李伟',
      type: '塑料容器',
      //电话
      phone: '15678459087',

      rank: '1',
      imageUrl: 'images/22.jpg',
    },
    {
      title: '快递水果纸箱,苹果橙子纸箱定做印刷纸箱',
      description: '4号箱 1.4元/件',
      introduce:
        '基础材质瓦楞纸板：主流采用三层或五层结构，由面纸、瓦楞芯纸和里纸复合而成。五层纸板（如“B楞+C楞”组合）抗压强度提升40%，适合长途运输或堆码存储。环保材料：部分厂家使用再生纸浆或FSC认证纸板，符合欧盟环保标准，可降解率达90%以上。结构优化加强设计：针对苹果、橙子等重果，箱体四角增加L型护角或内置十字隔板，抗压强度从500kg提升至800kg。防潮处理：外层涂布防水膜或使用PE淋膜纸板，防潮性能提升3倍，适应冷链运输环境。',
      price: '1.40',
      //地址
      address: '临沧市耿马县孟定镇100号',
      locationUrl: 'images/dz.png',
      //联系人
      contact: '张可然',
      type: '纸箱',
      //电话
      phone: '15678459087',

      rank: '1',
      imageUrl: 'images/33.jpg',
    },
    {
      title: '纸箱包装盒,物流箱包装箱',
      description: '通货 0.5元/个',
      introduce:
        '材质与结构基础材料：以瓦楞纸板为主，分为三层（单瓦楞）、五层（双瓦楞）和七层结构。三层瓦楞：面纸+瓦楞芯纸+里纸，成本低，适用于轻量商品（如日用品、电子产品配件）。五层瓦楞：增加一层芯纸和面纸，抗压强度提升50%-80%，常用于家电、家具等重物包装。七层瓦楞：超强承重设计，适用于工业设备、大型机械等极端承重需求。环保升级：部分采用再生纸浆或FSC认证材料，可降解率达90%以上，符合欧盟ROHS标准。',
      price: '0.50',
      //地址
      address: '临沧市耿马县孟定镇100号',
      locationUrl: 'images/dz.png',
      //联系人
      contact: '张可然',
      type: '纸箱',
      //电话
      phone: '15678459087',

      rank: '1',
      imageUrl: 'images/44.jpg',
    },
  ],
});

const currentTab0 = ref(0);
const currentTab1 = ref(0);
const currentTab2 = ref(0);
const currentTab3 = ref(0);
const dialogVisible = ref(false);
const formRef = ref(null);

const form = reactive({
  quantity: '',
  title: '',
  phone: '',
  name: '',
});

const diotext = ref('');
const diodescription = ref('');

const goDei = (data) => {
  diodescription.value = data.description;
  diotext.value = data.title;
  dialogVisible.value = true;
};

const handleSubmit = () => {
  formRef.value.validate((valid) => {
    if (valid) {
      console.log('提交数据:', form);
      dialogVisible.value = false;
    }
  });
};

const currentChange = (current) => {
  state.query.current = current;
};

const toLink = (row) => {
  row.data = ['高品质', '杀菌灭毒', '绿色'];
  router.push({
    path: '/sub-operation-service/packaging/details1',
    query: row,
  });
};
const applicationPackaging = () => {
  router.push({
    path: '/sub-operation-service/packaging/details2',
  });
};
</script>
<style lang="scss" scoped>
// 基础颜色配置
$primary-color: #25bf82; // 主色调
$text-dark: #25bf82; // 深色文字
$text-regular: #606266; // 常规文字
$border-color: #dcdfe6; // 边框颜色

// 弹窗整体样式
:deep(.custom-inquiry-dialog) {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

  .el-dialog__header {
    padding: 20px;
    border-bottom: 1px solid #f2f6fc;
    .el-dialog__title {
      font-size: 18px;
      color: $text-dark;
      font-weight: 600;
    }
  }

  .el-dialog__body {
    padding: 20px 28px;
  }

  .el-form-item__label {
    color: $text-regular;
    font-size: 14px;
    padding-bottom: 6px;
  }
}

.info-section {
  padding: 0px 50px;
  margin-bottom: 24px;
  .info-item {
    margin-bottom: 12px;
    .label {
      color: $text-regular;
      margin-right: 8px;
      font-size: 20px;
    }
    .value {
      color: $text-dark;
      font-weight: 500;
      font-size: 20px;
    }
  }
}

// 输入框样式覆盖
:deep(.el-input) {
  .el-input__inner {
    height: 40px;
    line-height: 40px;
    border-radius: 4px;
    &:focus {
      border-color: $primary-color;
    }
  }
  .el-input__suffix {
    color: $text-regular;
    right: 12px;
  }
}

// 下拉菜单样式
:deep(.custom-select-dropdown) {
  .el-select-dropdown__item {
    color: $text-regular;
    &.selected {
      color: $primary-color;
    }
  }
}

// 按钮组样式
.dialog-footer {
  text-align: right;
  .el-button {
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 14px;
  }
  .cancel-btn {
    color: $text-regular;
    &:hover {
      color: $primary-color;
      border-color: $primary-color;
    }
  }
  .submit-btn {
    color: #fff;
    background: $primary-color;
    &:hover {
      background: mix($primary-color, #fff, 85%);
    }
  }
}
.tabs {
  //height: 160px;
  line-height: 50px;
  display: flex;
  flex-direction: column;
  font-size: 18px;
  align-items: flex-start;
  justify-content: space-between;
  // padding: 0 20px;
}
.tabs0 {
  padding: 0;
}
.tab {
  // height: 100px;
  width: 850px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
  overflow: auto; /* 启用滚动 */
  white-space: nowrap; /* 强制单行显示 */
  -ms-overflow-style: none; /* IE/Edge 兼容 */
  scrollbar-width: none; /* 隐藏滚动条 */
  .tab_list {
    color: #999999;
    font-size: 20px;
    font-weight: 400;
  }
  .tab_list_li {
    margin-left: 40px;
    color: #000000;
    font-size: 20px;
    font-weight: 400;
  }
  .tab_list_li:first-child {
    margin-left: 20px;
  }
  .tab_list_li.active {
    color: rgba(37, 191, 130, 1);
  }
  .tab_list_li0 {
    border-bottom: 2px solid rgba(37, 191, 130, 1);
  }
}
.cursor {
  cursor: pointer;
}
.active {
  color: rgba(37, 191, 130, 1);
}
.storage-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  border: 0;
  border-radius: 16px;
}
.storage-content {
  @include flex-column;

  gap: 16px;
  &-top {
    @include flex-row;

    align-items: center;
  }
}
.storage-image {
  margin-right: 16px;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  object-fit: cover;
}
.storage-image1 {
  margin-right: 0;
  width: 100%;
  height: auto;
  border-radius: 0;
  object-fit: cover;
  cursor: pointer;
}
.storage-info {
  padding-right: 50px;
  flex: 1;
  cursor: pointer;
}
.storage-title,
.storage-desc,
.storage-tags,
.storage-location {
  margin: 10px 0;
  width: 70%;
  text-align: left;
}
.storage-title {
  font-size: 20px;
  font-weight: 700;
  color: #000000;
  @include ellipsis;
}
.storage-desc {
  font-size: 16px;
  color: #000000;
  @include ellipsis;
  i {
    display: inline-block;
    width: 20px;
    height: 20px;
  }
}
.storage-tags {
  span {
    margin-right: 10px;
  }
}
.storage-location {
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 400;
  color: #000000;
}
.storage-location1 {
  color: #adadad;
  //超出两行省略
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.storage-price {
  display: flex;
  justify-content: space-between;
  align-items: center;
  &-left {
    color: #25bf82;
  }
}
.price-label {
  margin-right: 10px;
  font-size: 16px;
  color: #999999;
}
.price-amount {
  font-size: 20px;
  font-weight: 700;
  color: #25bf82;
}
.contact-btn {
  width: 152px;
  height: 48px;
  font-size: 20px;
  border-radius: 8px;
  background: #25bf82 !important;
  :deep(.el-icon) {
    margin-right: 10px;
  }
}
.rank-badge {
  position: absolute;
  top: 30px;
  right: 20px;
  // width: 80px;
  // height: 80px;
}
</style>
