material_request.vue 4.95 KB
<!--
 * @Date: 2024-07-23 12:53:15
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2024-07-23 16:38:59
 * @FilePath: /temple_material_request/src/views/material_request.vue
 * @Description: 申领物资页面
-->
<template>
  <div class="material-request-page">
    <van-tabs v-model:active="active" @change="onChange" sticky :color="styleColor.baseColor">
      <van-tab v-for="index in 8" :title="'标签 ' + index">
        <div class="list-wrapper">
          <van-sticky  :offset-top="44">
            <van-row justify="space-between" class="select-all-item">
              <van-col span="8"><van-icon name="passed" size="1.25rem" />&nbsp;&nbsp;<span :style="{ color: styleColor.baseColor }">全选</span></van-col>
              <van-col span="16" style="text-align: right; font-size: 0.85rem; color: #666666;">参考上次同类活动的领用情况</van-col>
            </van-row>
          </van-sticky>
          <van-list
            v-model:loading="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
          >
            <div v-for="item in list" :key="item" class="list-boxer">
              <van-row align="center" justify="space-between">
                <van-col span="16" style="display: flex;">
                  <van-icon name="passed" size="1.25rem" />&nbsp;&nbsp;<div class="van-ellipsis" :style="{ color: styleColor.baseColor, textDecoration: 'underline' }" @click="onClickTitle(item)">床垫 1.2m*2m</div>
                </van-col>
                <van-col span="8" style="display: flex; align-items: center;">
                  <van-field v-model="num_value" style="border: 1px solid #f0f0f0; padding: 0; border-radius: 5px;" label="" label-width="0" input-align="center" placeholder="数量" type="number" >
                    <template #left-icon></template>
                  </van-field>&nbsp;&nbsp;<span style="font-size: 0.9rem; color: #666;">个</span>
                </van-col>
              </van-row>
            </div>
          </van-list>
          <div style="height: 6rem;"></div>
        </div>
      </van-tab>
    </van-tabs>
    <div class="control-bar">
      <div>
        <van-button icon="plus" type="primary" :color="styleColor.baseColor" @click="addMore">添加更多</van-button>
      </div>
      <div style="display: flex; align-items: center;">
        <van-button plain type="primary" :color="styleColor.baseColor" @click="addShoppingCart">加入购物车</van-button>
        &nbsp;&nbsp;
        <van-badge :content="5">
          <van-icon name="shopping-cart-o" size="2.5rem" :color="styleColor.baseColor" @click="goShoppingCart" />
        </van-badge>
      </div>
    </div>
  </div>

  <choose-material :show="show_choose_material" @close="onCloseChoose"></choose-material>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'

import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js'
//import { } from '@/utils/generateModules.js'
//import { } from '@/utils/generateIcons.js'
//import { } from '@/composables'
import { styleColor } from "@/constant.js";
import chooseMaterial from '@/components/chooseMaterial/index.vue';

const $route = useRoute();
const $router = useRouter();
useTitle($route.meta.title);

const num_value = ref('');

const active = ref(0);
const onChange = (index) => {
  console.warn(index);
}

const list = ref([]);
const loading = ref(false);
const finished = ref(false);

const onLoad = () => {
  // 异步更新数据
  // setTimeout 仅做示例,真实场景中一般为 ajax 请求
  setTimeout(() => {
    for (let i = 0; i < 10; i++) {
      list.value.push(list.value.length + 1);
    }

    // 加载状态结束
    loading.value = false;

    // 数据全部加载完成
    if (list.value.length >= 40) {
      finished.value = true;
    }
  }, 1000);
};

const onClickTitle = (item) => { // 点击物资标题回调
  console.warn(item);
}

const addMore = () => { // 添加更多
  console.warn('addMore');
  show_choose_material.value = true;
}

const addShoppingCart = () => { // 加入购物车
  console.warn('addShoppingCart');
}

const goShoppingCart = () => { // 跳转购物车
  console.warn('goShoppingCart');
  $router.push({ path: '/material_pre_request' });
}

const show_choose_material = ref(false);
const onCloseChoose = () => {
  show_choose_material.value = false;
}
</script>

<style lang="less" scoped>
.material-request-page {
  .list-wrapper {
    width: 100%;
    .select-all-item {
      padding: 0.5rem 1rem;
      border-top: 1px solid #f0f0f0;
      background-color: white;
    }
    .list-boxer {
      margin: 0; padding: 1rem; border-top: 1px solid #f0f0f0;
    }
  }

  .control-bar {
    display: flex; position: fixed; padding: 1rem 1.5rem; left: 0; right: 0; bottom: 0; background-color: white; width: calc(100% - 3rem); justify-content: space-between; align-items: center; box-shadow: 0rem -0.33rem 0.33rem 0.08rem rgba(0,0,0,0.06);
  }
}
</style>