当前位置:网站首页>Display the remaining valid days according to the valid period

Display the remaining valid days according to the valid period

2022-06-12 08:37:00 Month to month better

 Insert picture description here

<v-simple-table
   class="table-wrapper"
   style="position: relative; width: 100%"
 >
   <template v-slot:default>
     <thead>
       <tr>
         <th> name </th>
         <th> The period of validity </th>
         <th> operation </th>
       </tr>
     </thead>
     <tbody v-if="lists.length > 0">
       <tr v-for="item in lists" :key="item.id">
         <td>{
    {
     item.name }}</td>
         <td>
           <v-icon
             v-if="vailDays(item.expiry)"
             size="22"
             color="#4caf50"
           >
             mdi-check-decagram
           </v-icon>
           <v-icon v-else size="22" color="#f44336"
             >mdi-close-octagon</v-icon
           >
           {
    {
     item.expiry }}
           <span
             >({
    {
    
               vailDays(item.extracted.expiry)
                 ? ` The remaining ${
     vailDays(item.expiry)} God `
                 : " Has expired "
             }})</span
           >
         </td>
         <td>
           <span
             class="btn-style"
             > see </span
           >
           <span class="ml-4 btn-style" 
             > Delete </span
           >
         </td>
       </tr>
     </tbody>
     <tbody v-else>
       <tr class="text-center">
         <td colspan="8" style="width: 100%; color: #7b7b7b">
           {
    {
     loading ? " Temporarily no data " : " Data loading " }}
         </td>
       </tr>
     </tbody>
   </template>
 </v-simple-table>


import {
     vailDays, isErrData } from "./util/dealData";
export default {
    
  name: "License",
  data() {
    
    return {
    
      vailDays,
      errMsg,
      loading: true,
      lists:[
      	{
    id:1,name:"a",expiry: 1634256000},
      	{
    id:2,name:"b",expiry: 1656288000}
      ]
    };
  },
 }

util/dealData.js

//  The period of validity 
function vailDays(expire) {
    
  let curTime = Math.floor(new Date().getTime());
  let vaildTime = Math.floor((expire * 1000 - curTime) / (1000 * 3600 * 24));
  if (vaildTime > 0 || vaildTime === 0) {
    
    return vaildTime;
  }
}

export {
     vailDays};
原网站

版权声明
本文为[Month to month better]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206120828077706.html