Преглед изворни кода

Merge branch 'feature/NG-93' of guanli/ngfrontend into master

Tyler пре 1 година
родитељ
комит
f4cd7f8fa7

+ 8 - 0
src/api/finance.js

@@ -72,4 +72,12 @@ export function fetchApplyRecharge(data) {
   })
 }
 
+export function editApplyRecharge(data) {
+  return request({
+    url: '/v1/finance/recharge-update',
+    method: 'post',
+    data
+  })
+}
+
 

+ 0 - 1
src/components/Breadcrumb/index.vue

@@ -38,7 +38,6 @@ export default {
     getBreadcrumb() {
       // only show routes with meta.title
       let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
-      console.log(matched)
       const first = matched[0]
 
       if (!this.isDashboard(first)) {

+ 1 - 1
src/components/Pagination/index.vue

@@ -36,7 +36,7 @@ export default {
     pageSizes: {
       type: Array,
       default() {
-        return [10, 20, 30, 50]
+        return [5, 10, 20, 30, 50]
       }
     },
     layout: {

+ 3 - 1
src/lang/en.js

@@ -558,7 +558,9 @@ export default {
     viewVoucher: 'View',
     bankInformation: 'Bank Info',
     selectBank: 'Select Bank',
-    accountName: 'Account Name'
+    accountName: 'Account Name',
+    uploadEdit: 'Edit',
+    paymentReference: 'Payment Reference',
   },
   notificationProps: {
     title: '📢 system update',

+ 3 - 1
src/lang/zh.js

@@ -553,7 +553,9 @@ export default {
     viewVoucher: '查看',
     bankInformation: '银行信息',
     selectBank: '请选择开户行',
-    accountName: '开户支行'
+    accountName: '开户支行',
+    uploadEdit: '编辑',
+    paymentReference: '汇款账号',
   },
   notificationProps: {
     title: '📢 系统更新',

+ 44 - 0
src/utils/tool.js

@@ -59,6 +59,50 @@ const tool = {
     if (withTime) return Y + M + D + h + m + s
     return Y + M + D
   },
+  convertToNigeriaTime(timestamp) {
+    timestamp = this.normalizeTimestamp(timestamp)
+    const options = {
+      timeZone: 'Africa/Lagos',
+      year: 'numeric',
+      month: '2-digit',
+      day: '2-digit',
+      hour: '2-digit',
+      minute: '2-digit',
+      second: '2-digit',
+      hour12: false // 24-hour format
+    };
+    const formatter = new Intl.DateTimeFormat('en-GB', options);
+    const formattedDate = formatter.format(new Date(timestamp));
+
+    // Reformatting to YYYY-MM-DD HH:mm:ss
+    const [date, time] = formattedDate.split(', ');
+    const [day, month, year] = date.split('/');
+    return `${year}-${month}-${day} ${time}`;
+  },
+  convertToNigeriaDayTime(timestamp) {
+    timestamp = this.normalizeTimestamp(timestamp)
+    const options = {
+      timeZone: 'Africa/Lagos',
+      year: 'numeric',
+      month: '2-digit',
+      day: '2-digit',
+      hour: '2-digit',
+      minute: '2-digit',
+      second: '2-digit',
+      hour12: false // 24-hour format
+    };
+    const formatter = new Intl.DateTimeFormat('en-GB', options);
+    const formattedDate = formatter.format(new Date(timestamp));
+
+    // Reformatting to YYYY-MM-DD HH:mm:ss
+    const [date, time] = formattedDate.split(', ');
+    const [day, month, year] = date.split('/');
+    return `${year}-${month}-${day}`;
+  },
+  normalizeTimestamp(timestamp) {
+    // 如果小于毫秒级最小值,认为是秒级时间戳
+    return timestamp < 1000000000000 ? timestamp * 1000 : timestamp;
+  },
   /**
    * 处理错误结果
    * @param error

+ 7 - 2
src/views/article/article-list.vue

@@ -21,7 +21,7 @@
 			</el-table-column>
       <el-table-column align="center" :label="$t('article.createTime')" prop="CREATED_AT">
         <template slot-scope="{row}">
-          <span>{{ row.CREATED_AT | parseTime('{y}-{m}-{d}') }}</span>
+          <span>{{ tool.convertToNigeriaDayTime(row.CREATED_AT) }}</span>
         </template>
       </el-table-column>
     </el-table>
@@ -32,7 +32,7 @@
 			<div class="white-box" style="margin-top: -20px; padding: 0;">
 				<div class="white-box-title" style="text-align: center">
 					<h1>{{ article.TITLE }}</h1>
-					<span>{{ article.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
+					<span>{{ tool.convertToNigeriaTime(article.CREATED_AT) }}</span>
 				</div>
 				<div v-html="article.CONTENT" class="white-box-content">
 				</div>
@@ -50,6 +50,11 @@ import tool from "@/utils/tool";
 
 export default {
   name: 'ArticleList',
+  computed: {
+    tool() {
+      return tool
+    }
+  },
   components: { Pagination },
   directives: { waves },
   data() {

+ 7 - 2
src/views/dashboard/admin/index.vue

@@ -36,7 +36,7 @@
 								</el-button>
 							</template>
 							<template slot-scope="{row}">
-								<span>{{ row.CREATED_AT | parseTime('{y}-{m}-{d}') }}</span>
+								<span>{{ tool.convertToNigeriaDayTime(row.CREATED_AT) }}</span>
 							</template>
 						</el-table-column>
 					</el-table>
@@ -59,7 +59,7 @@
 			<div class="white-box" style="margin-top: -20px; padding: 0;">
 				<div class="white-box-title" style="text-align: center">
 					<h1>{{ article.TITLE }}</h1>
-					<span>{{ article.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
+					<span>{{ tool.convertToNigeriaTime(article.CREATED_AT) }}</span>
 				</div>
 				<div v-html="article.CONTENT" class="white-box-content">
 				</div>
@@ -103,6 +103,11 @@ const lineChartData = {
 
 export default {
   name: 'DashboardAdmin',
+  computed: {
+    tool() {
+      return tool
+    }
+  },
   components: {
     GithubCorner,
     PanelGroup,

+ 91 - 27
src/views/finance/recharge-list.vue

@@ -3,7 +3,7 @@
     <el-table :data="list" border fit highlight-current-row>
       <el-table-column align="center" :label="$t('finance.createdTime')" prop="CREATED_AT" min-width="140px">
         <template slot-scope="{row}">
-          <span>{{ row.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
+          <span>{{ tool.convertToNigeriaTime(row.CREATED_AT) }}</span>
         </template>
       </el-table-column>
       <el-table-column align="center" min-width="160px" :label="$t('finance.rechargeAmount')" prop="AMOUNT">
@@ -17,28 +17,30 @@
         </template>
       </el-table-column>
       <el-table-column align="center" min-width="180px" :label="$t('finance.bankName')" prop="OPEN_BANK_NAME" />
-      <el-table-column align="center" min-width="150px" :label="$t('finance.bankAccount')" prop="BANK_NO" />
+      <el-table-column align="center" min-width="150px" :label="$t('finance.paymentReference')" prop="BANK_NO" />
       <el-table-column align="center" min-width="150px" :label="$t('finance.printVoucher')">
         <template slot-scope="{row}">
           <el-button v-if="row.AUDIT_STATUS === '0'" type="primary" size="mini" @click="handleUpload(row.ID)">{{ $t('finance.uploadVoucher') }}</el-button>
           <el-button v-if="row.AUDIT_STATUS !== '0'" type="success" size="mini" @click="handleView(row)">{{ $t('finance.viewVoucher') }}</el-button>
+          <el-button v-if="row.AUDIT_STATUS === '0'" type="success" size="mini" @click="handleEdit(row)">{{ $t('finance.uploadEdit') }}</el-button>
+
         </template>
       </el-table-column>
     </el-table>
 
     <div class="white-box-footer" style="margin-top: 10px;">
-      <el-button size="small" type="primary" @click="dialog = true">{{ $t('finance.recharge') }}</el-button>
+      <el-button size="small" type="primary" @click="dialog = true, isEdit = false">{{ $t('finance.recharge') }}</el-button>
       <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
     </div>
 
     <el-dialog :title="$t('finance.recharge')" :visible.sync="dialog" :width="screenWidth" style="margin-top: -70px;">
-      <el-form ref="form" v-loading="loading" :model="form" :rules="rules" :label-position="labelPosition" style="margin-top: -20px; margin-bottom: -30px;">
+      <el-form ref="form" v-if="dialog" v-loading="loading" :model="form" :rules="rules" :label-position="labelPosition" style="margin-top: -20px; margin-bottom: -30px;">
         <el-row :gutter="20">
           <el-col :xs="24" :sm="24" :lg="24">
             <el-form-item :label="$t('finance.rechargeAmount')" prop="applyAmount" required>
               <el-input-number v-model.number="form.applyAmount" :min="minAmount" :max="maxAmount" :step="10000" style="width: 100%" clearable />
             </el-form-item>
-            <el-form-item :label="$t('finance.bankAccount')" prop="bankNo" required>
+            <el-form-item :label="$t('finance.paymentReference')" prop="bankNo" required>
               <el-input v-model="form.bankNo" type="text" clearable style="width: 100%" />
             </el-form-item>
             <el-form-item :label="$t('finance.bankName')" prop="openBank" required>
@@ -84,7 +86,7 @@
 </template>
 
 <script>
-import { fetchApplyRecharge, fetchBankList, fetchRechargeList } from '@/api/finance'
+import { fetchApplyRecharge, fetchBankList, fetchRechargeList, editApplyRecharge } from '@/api/finance'
 import { fetchToken } from '@/api/file'
 import waves from '@/directive/waves'
 import Pagination from '@/components/Pagination'
@@ -108,6 +110,28 @@ export default {
       return statusEnums[status] || 'warning'
     }
   },
+  watch: {
+    dialog: {
+      handler(newValue, old){
+        if(newValue === false){
+          this.form = {
+            applyAmount: 1,
+            bankNo: '',
+            openBank: '',
+            bankAddress: ''
+          }
+          this.$forceUpdate()
+        }
+      }
+    },
+    uploadVoucher: {
+      handler(newValue, old){
+        if(newValue === false){
+          this.imageUrl = ''
+        }
+      }
+    }
+  },
   data() {
     return {
       tool: tool,
@@ -116,9 +140,8 @@ export default {
       listLoading: true,
       listQuery: {
         page: 1,
-        pageSize: 5
+        pageSize: 10
       },
-
       dialog: false,
       loading: false,
       form: {
@@ -131,7 +154,7 @@ export default {
       maxAmount: 10000000000,
       rules: {
         applyAmount: [required, integer, range(this.minAmount, this.maxAmount)],
-        bankNo: [{ required: true, message: this.$t('finance.bankAccount') + this.$t('common.require'), trigger: 'blur' }],
+        bankNo: [{ required: true, message: this.$t('finance.paymentReference') + this.$t('common.require'), trigger: 'blur' }],
         openBank: [{ required: true, message: this.$t('finance.bankName') + this.$t('common.require'), trigger: 'blur' }]
       },
       bankList: [],
@@ -154,7 +177,8 @@ export default {
         'Device-Type': 'pc',
         'Suppress-Response-Code': '1',
         'Authorization': ''
-      }
+      },
+      isEdit: false,
     }
   },
   created() {
@@ -184,27 +208,55 @@ export default {
       this.$refs['form'].validate((valid) => {
         if (valid) {
           this.loading = true
-          fetchApplyRecharge(this.form).then(response => {
-            this.$message({
-              message: response.data,
-              type: 'success',
-              duration: 1.5 * 1000
-            })
+          let form = {}
+          let { applyAmount, bankNo, openBank, bankAddress, ID } = this.form
+          if(this.isEdit){
+            form = { applyAmount, bankNo, openBank, bankAddress, id: ID }
+            editApplyRecharge(form).then(response => {
+              this.$message({
+                message: response.data,
+                type: 'success',
+                duration: 1.5 * 1000
+              })
 
-            this.$refs['form'].resetFields()
-            this.dialog = false
-            this.loading = false
+              this.$refs['form'].resetFields()
+              this.dialog = false
+              this.loading = false
 
-            this.getList()
-          }).catch((err) => {
-            this.$message({
-              message: err,
-              type: 'error',
-              duration: 3 * 1000
+              this.getList()
+            }).catch((err) => {
+              this.$message({
+                message: err,
+                type: 'error',
+                duration: 3 * 1000
+              })
+
+              this.loading = false
             })
+          } else {
+            form = { applyAmount, bankNo, openBank, bankAddress }
+            fetchApplyRecharge(form).then(response => {
+              this.$message({
+                message: response.data,
+                type: 'success',
+                duration: 1.5 * 1000
+              })
+
+              this.$refs['form'].resetFields()
+              this.dialog = false
+              this.loading = false
 
-            this.loading = false
-          })
+              this.getList()
+            }).catch((err) => {
+              this.$message({
+                message: err,
+                type: 'error',
+                duration: 3 * 1000
+              })
+
+              this.loading = false
+            })
+          }
         } else {
           return false
         }
@@ -232,6 +284,18 @@ export default {
         this.uploadVoucher = true
       }, 0.5 * 1000)
     },
+    handleEdit(row){
+      let { AMOUNT, BANK_NO, OPEN_BANK, ID } = row
+      this.form = {
+        applyAmount: AMOUNT,
+        bankNo: BANK_NO,
+        openBank: OPEN_BANK,
+        ID: ID
+      }
+      this.isEdit = true
+      this.dialog = true
+      this.$forceUpdate()
+    },
     async uploaderHandleBefore() {
       this.$message({
         message: this.$t('common.uploadHints'),

+ 1 - 1
src/views/finance/transfer-list.vue

@@ -76,7 +76,7 @@
 			</el-table-column>
 			<el-table-column min-width="160px"  align="center" :label="$t('finance.transferTime')" prop="CREATED_AT">
 				<template slot-scope="{row}">
-					<span>{{ row.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
+					<span>{{ tool.convertToNigeriaTime(row.CREATED_AT) }}</span>
 				</template>
 			</el-table-column>
 			<el-table-column align="center" min-width="150px" :label="$t('finance.remark')" prop="REMARK"></el-table-column>

+ 21 - 7
src/views/profile/components/UserCard.vue

@@ -30,7 +30,7 @@
 							</el-col>
 							<el-col :span="12">
 								<div class="grid-content bg-purple-light">
-									<span>{{ tool.formatDate(tool.getTimestamp()) }}</span>
+									<span>{{ nowDateTime }}</span>
 								</div>
 							</el-col>
 						</el-row>
@@ -132,14 +132,28 @@ export default {
 	data() {
 		return {
 			tool: tool,
-		}
+      nowTime: this.getTime()
+    }
 	},
-
-
-
+  computed: {
+    nowDateTime() {
+      return this.$moment(this.nowTime * 1000).utcOffset('+0100' ).format('YYYY-MM-DD HH:mm:ss') + ' (WAT)'
+    },
+  },
+  mounted() {
+    this.calcTime()
+  },
   methods: {
-
-
+    getTime() {
+      let dateObj = new Date()
+      return Math.round(dateObj.getTime() / 1000 + (0 * 86400))
+    },
+    calcTime () {
+      let obj = this
+      setInterval(function () {
+        obj.nowTime += 1
+      }, 1000)
+    },
   }
 }
 </script>

+ 7 - 2
src/views/shop/order-list.vue

@@ -92,12 +92,12 @@
       <el-table-column align="center" :label="$t('shop.payment')" prop="PAY_TYPE" min-width="100px"></el-table-column>
       <el-table-column align="center" :label="$t('shop.createdTime')" prop="CREATED_AT" min-width="110px">
         <template slot-scope="{row}">
-          <span>{{ row.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
+          <span>{{ tool.convertToNigeriaTime(row.CREATED_AT) }}</span>
         </template>
       </el-table-column>
       <el-table-column align="center" :label="$t('shop.payTime')" prop="PAY_AT" min-width="110px">
         <template slot-scope="{row}">
-          <span>{{ row.PAY_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
+          <span>{{ tool.convertToNigeriaTime(row.PAY_AT) }}</span>
         </template>
       </el-table-column>
       <el-table-column align="center" :label="$t('shop.payStatus')" prop="STATUS" min-width="110px">
@@ -128,6 +128,11 @@ import tool from '@/utils/tool'
 
 export default {
   name: 'OrderList',
+  computed: {
+    tool() {
+      return tool
+    }
+  },
   components: { Pagination },
   directives: { waves },
   filters: {

+ 7 - 2
src/views/user/member-order.vue

@@ -92,12 +92,12 @@
       <el-table-column align="center" :label="$t('shop.payment')" prop="PAY_TYPE" min-width="100px" />
       <el-table-column align="center" :label="$t('shop.createdTime')" prop="CREATED_AT" min-width="110px">
         <template slot-scope="{row}">
-          <span>{{ row.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
+          <span>{{ tool.convertToNigeriaTime(row.CREATED_AT) }}</span>
         </template>
       </el-table-column>
       <el-table-column align="center" :label="$t('shop.payTime')" prop="PAY_AT" min-width="110px">
         <template slot-scope="{row}">
-          <span>{{ row.PAY_AT | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
+          <span>{{ tool.convertToNigeriaTime(row.PAY_AT) }}</span>
         </template>
       </el-table-column>
       <el-table-column align="center" :label="$t('shop.payStatus')" prop="STATUS" min-width="110px">
@@ -128,6 +128,11 @@ import tool from '@/utils/tool'
 
 export default {
   name: 'MemberOrder',
+  computed: {
+    tool() {
+      return tool
+    }
+  },
   components: { Pagination },
   directives: { waves },
   filters: {