1、
This commit is contained in:
		| @ -2,5 +2,5 @@ | |||||||
| ENV = 'development' | ENV = 'development' | ||||||
|  |  | ||||||
| # base api | # base api | ||||||
| VUE_APP_BASE_API = 'http://127.0.0.1:8000' | VUE_APP_BASE_API = 'http://192.168.2.102:8000' | ||||||
|  |  | ||||||
|  | |||||||
| @ -53,6 +53,14 @@ export function exportWmTransferItemExcel(data) { | |||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // 清理数据 | ||||||
|  | export function wmTransferItemClear() { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/wm-transfer-item/clear', | ||||||
|  |     method: 'delete' | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
| // 导出自动转账日志Excel | // 导出自动转账日志Excel | ||||||
| export function exportWmTransferItemAutoLogExcel(data) { | export function exportWmTransferItemAutoLogExcel(data) { | ||||||
|   return request({ |   return request({ | ||||||
|  | |||||||
| @ -51,3 +51,20 @@ export function clearAllWmWalletInfo() { | |||||||
|     method: 'delete' |     method: 'delete' | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | export function batchUpdateWmWalletInfo(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/wm-wallet-info/batch', | ||||||
|  |     method: 'put', | ||||||
|  |     data: data | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // excel导入 | ||||||
|  | export function wmWalletInfoExcelImport(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/wm-wallet-info/excel-import', | ||||||
|  |     method: 'post', | ||||||
|  |     data: data | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  | |||||||
| @ -31,6 +31,7 @@ service.interceptors.request.use( | |||||||
|   } |   } | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // export const baseURL = window.CONFIG.VUE_APP_BASE_API | ||||||
| // response interceptor | // response interceptor | ||||||
| service.interceptors.response.use( | service.interceptors.response.use( | ||||||
|   /** |   /** | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ const mimeMap = { | |||||||
|   zip: 'application/zip' |   zip: 'application/zip' | ||||||
| } | } | ||||||
|  |  | ||||||
| const baseUrl = process.env.VUE_APP_BASE_API | export const baseUrl = process.env.VUE_APP_BASE_API | ||||||
| export function downLoadZip(str, filename) { | export function downLoadZip(str, filename) { | ||||||
|   var url = baseUrl + str |   var url = baseUrl + str | ||||||
|   axios({ |   axios({ | ||||||
|  | |||||||
| @ -34,6 +34,7 @@ | |||||||
|  |  | ||||||
|         <el-table v-loading="loading" :data="wmNetworkList" @selection-change="handleSelectionChange"> |         <el-table v-loading="loading" :data="wmNetworkList" @selection-change="handleSelectionChange"> | ||||||
|           <el-table-column type="selection" width="55" align="center" /> |           <el-table-column type="selection" width="55" align="center" /> | ||||||
|  |           <el-table-column label="编号" prop="id" align="center" width="55" /> | ||||||
|           <el-table-column label="网络名称" align="center" prop="networkName" :show-overflow-tooltip="true" /> |           <el-table-column label="网络名称" align="center" prop="networkName" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="网络代码" align="center" prop="code" :show-overflow-tooltip="true" /> |           <el-table-column label="网络代码" align="center" prop="code" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column |           <el-table-column | ||||||
|  | |||||||
| @ -22,7 +22,16 @@ | |||||||
|             @keyup.enter.native="handleQuery" |             @keyup.enter.native="handleQuery" | ||||||
|           /> |           /> | ||||||
|           </el-form-item> |           </el-form-item> | ||||||
|  |           <el-form-item label="转账类型" prop="transType"> | ||||||
|  |             <el-select v-model="queryParams.transType" clearable placeholder="请选择"> | ||||||
|  |               <el-option | ||||||
|  |                 v-for="item in transTypeOptions" | ||||||
|  |                 :key="'querytransType' + item.value" | ||||||
|  |                 :label="item.label" | ||||||
|  |                 :value="item.value" | ||||||
|  |               /> | ||||||
|  |             </el-select> | ||||||
|  |           </el-form-item> | ||||||
|           <el-form-item> |           <el-form-item> | ||||||
|             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||||||
|             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||||||
| @ -65,7 +74,9 @@ | |||||||
|         </el-row> |         </el-row> | ||||||
|  |  | ||||||
|         <el-table v-loading="loading" :data="wmTokenList" @selection-change="handleSelectionChange"> |         <el-table v-loading="loading" :data="wmTokenList" @selection-change="handleSelectionChange"> | ||||||
|           <el-table-column type="selection" width="55" align="center" /><el-table-column |           <el-table-column type="selection" width="55" align="center" /> | ||||||
|  |           <el-table-column label="编号" prop="id" align="center" width="55" /> | ||||||
|  |           <el-table-column | ||||||
|             label="网络" |             label="网络" | ||||||
|             align="center" |             align="center" | ||||||
|             prop="networkId" |             prop="networkId" | ||||||
| @ -80,7 +91,7 @@ | |||||||
|             prop="tokenName" |             prop="tokenName" | ||||||
|             :show-overflow-tooltip="true" |             :show-overflow-tooltip="true" | ||||||
|           /><el-table-column |           /><el-table-column | ||||||
|             label="代币地址" |             label="合约地址" | ||||||
|             align="center" |             align="center" | ||||||
|             prop="tokenAddress" |             prop="tokenAddress" | ||||||
|             :show-overflow-tooltip="true" |             :show-overflow-tooltip="true" | ||||||
| @ -100,13 +111,13 @@ | |||||||
|               <el-tag v-else type="danger">关闭</el-tag> |               <el-tag v-else type="danger">关闭</el-tag> | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|  |           <el-table-column label="触发代币数" align="center" prop="triggerAmount" /> | ||||||
|           <el-table-column label="转账类型" align="center" width="100"> |           <el-table-column label="转账类型" align="center" width="100"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
|               {{ transTypeFormat(scope.row) }} |               {{ transTypeFormat(scope.row) }} | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|           <el-table-column label="转账值" prop="transValue" align="center" width="100" /> |           <el-table-column label="自动转账值" prop="transValue" align="center" width="100" /> | ||||||
|           <el-table-column label="触发代币数" align="center" prop="triggerAmount" /> |  | ||||||
|           <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |           <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
|  |  | ||||||
| @ -157,8 +168,8 @@ | |||||||
|             <el-form-item label="代币名称" prop="tokenName"> |             <el-form-item label="代币名称" prop="tokenName"> | ||||||
|               <el-input v-model="form.tokenName" placeholder="代币名称" maxlength="20" show-word-limit /> |               <el-input v-model="form.tokenName" placeholder="代币名称" maxlength="20" show-word-limit /> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item label="代币地址" prop="tokenAddress"> |             <el-form-item label="合约地址" prop="tokenAddress"> | ||||||
|               <el-input v-model="form.tokenAddress" placeholder="代币地址 请注意如果未填写则为主币!!" /> |               <el-input v-model="form.tokenAddress" placeholder="合约地址 请注意只填写 0 为主币!!" /> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item label="代币精度" prop="decimals"> |             <el-form-item label="代币精度" prop="decimals"> | ||||||
|               <el-input v-model="form.decimals" placeholder="代币精度" /> |               <el-input v-model="form.decimals" placeholder="代币精度" /> | ||||||
| @ -259,8 +270,8 @@ export default { | |||||||
|         pageIndex: 1, |         pageIndex: 1, | ||||||
|         pageSize: 10, |         pageSize: 10, | ||||||
|         networkId: undefined, |         networkId: undefined, | ||||||
|         tokenName: undefined |         tokenName: undefined, | ||||||
|  |         idOrder: 'desc' | ||||||
|       }, |       }, | ||||||
|       // 表单参数 |       // 表单参数 | ||||||
|       form: { |       form: { | ||||||
|  | |||||||
| @ -6,13 +6,30 @@ | |||||||
|     @open="reloadDta" |     @open="reloadDta" | ||||||
|     @close="closeDialog" |     @close="closeDialog" | ||||||
|   > |   > | ||||||
|     <el-table v-loading="loading" :data="wmTransferItemList" @cell-dblclick="handleCellDblClick"> |     <el-table | ||||||
|  |       v-loading="loading" | ||||||
|  |       :data="wmTransferItemList" | ||||||
|  |       @cell-dblclick="handleCellDblClick" | ||||||
|  |     > | ||||||
|       <!-- <el-table-column |       <!-- <el-table-column | ||||||
|         label="代币地址" |         label="代币地址" | ||||||
|         align="center" |         align="center" | ||||||
|         prop="tokenAddress" |         prop="tokenAddress" | ||||||
|         :show-overflow-tooltip="true" |         :show-overflow-tooltip="true" | ||||||
|       /> --> |       /> --> | ||||||
|  |  | ||||||
|  |       <el-table-column | ||||||
|  |         label="网络" | ||||||
|  |         width="150" | ||||||
|  |         prop="networkName" | ||||||
|  |         align="center" | ||||||
|  |       /> | ||||||
|  |       <el-table-column | ||||||
|  |         label="代币名称" | ||||||
|  |         width="80" | ||||||
|  |         prop="tokenName" | ||||||
|  |         align="center" | ||||||
|  |       /> | ||||||
|       <el-table-column |       <el-table-column | ||||||
|         label="来源地址" |         label="来源地址" | ||||||
|         align="center" |         align="center" | ||||||
| @ -50,7 +67,11 @@ | |||||||
|         prop="privateKey" |         prop="privateKey" | ||||||
|         :show-overflow-tooltip="true" |         :show-overflow-tooltip="true" | ||||||
|       /> |       /> | ||||||
|       <el-table-column label="交易hash" prop="hash" :show-overflow-tooltip="true" /> |       <el-table-column | ||||||
|  |         label="交易hash" | ||||||
|  |         prop="hash" | ||||||
|  |         :show-overflow-tooltip="true" | ||||||
|  |       /> | ||||||
|       <el-table-column label="状态" prop="status"> |       <el-table-column label="状态" prop="status"> | ||||||
|         <template slot-scope="scope"> |         <template slot-scope="scope"> | ||||||
|           {{ statusFormat(scope.row) }} |           {{ statusFormat(scope.row) }} | ||||||
| @ -187,7 +208,9 @@ export default { | |||||||
|       return transferType ? transferType.label : '' |       return transferType ? transferType.label : '' | ||||||
|     }, |     }, | ||||||
|     statusFormat(row) { |     statusFormat(row) { | ||||||
|       const status = this.statusOptions.find((item) => item.value === row.status) |       const status = this.statusOptions.find( | ||||||
|  |         (item) => item.value === row.status | ||||||
|  |       ) | ||||||
|       return status ? status.label : '' |       return status ? status.label : '' | ||||||
|     }, |     }, | ||||||
|     /** 查询参数列表 */ |     /** 查询参数列表 */ | ||||||
| @ -233,13 +256,22 @@ export default { | |||||||
|       // 获取单元格文本内容 |       // 获取单元格文本内容 | ||||||
|       const cellText = row[column.property] |       const cellText = row[column.property] | ||||||
|  |  | ||||||
|  |       // 检查 navigator.clipboard 是否可用 | ||||||
|  |       if (!navigator.clipboard) { | ||||||
|  |         this.$message.error('您的浏览器不支持剪贴板 API,请尝试手动复制。') | ||||||
|  |         return // 结束函数执行,避免出错 | ||||||
|  |       } | ||||||
|  |  | ||||||
|       // 使用 Clipboard API 复制文本 |       // 使用 Clipboard API 复制文本 | ||||||
|       navigator.clipboard.writeText(cellText).then(() => { |       navigator.clipboard | ||||||
|         this.$message.success('已复制到剪贴板: ' + cellText) |         .writeText(cellText) | ||||||
|       }).catch(err => { |         .then(() => { | ||||||
|         console.error('复制失败:', err) |           this.$message.success('已复制到剪贴板: ' + cellText) | ||||||
|         this.$message.error('复制失败') |         }) | ||||||
|       }) |         .catch((err) => { | ||||||
|  |           console.error('复制失败:', err) | ||||||
|  |           this.$message.error('复制失败: ' + err.message) // 显示更详细的错误信息 | ||||||
|  |         }) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -71,6 +71,8 @@ | |||||||
|  |  | ||||||
|         <el-table v-loading="loading" :data="wmTransferList" @selection-change="handleSelectionChange"> |         <el-table v-loading="loading" :data="wmTransferList" @selection-change="handleSelectionChange"> | ||||||
|           <el-table-column type="selection" width="55" align="center" /> |           <el-table-column type="selection" width="55" align="center" /> | ||||||
|  |           <el-table-column label="网络" width="150" prop="networkName" align="center" /> | ||||||
|  |           <el-table-column label="代币名称" width="80" prop="tokenName" align="center" /> | ||||||
|           <el-table-column label="类型" align="center" prop="type" width="80"> |           <el-table-column label="类型" align="center" prop="type" width="80"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
|               {{ typeFormat(scope.row) }} |               {{ typeFormat(scope.row) }} | ||||||
| @ -485,8 +487,12 @@ export default { | |||||||
|     handleExport(row) { |     handleExport(row) { | ||||||
|       this.loading = true |       this.loading = true | ||||||
|       exportWmTransferItemExcel({ transferId: row.id }).then(res => { |       exportWmTransferItemExcel({ transferId: row.id }).then(res => { | ||||||
|         resolveBlobByName(res, null, '转账明细.xlsx') |         if (res.type === 'application/json') { | ||||||
|         this.msgSuccess('导出成功') |           this.msgError('暂无数据') | ||||||
|  |         } else { | ||||||
|  |           resolveBlobByName(res, null, '转账明细.xlsx') | ||||||
|  |           this.msgSuccess('导出成功') | ||||||
|  |         } | ||||||
|       }).finally(() => { |       }).finally(() => { | ||||||
|         this.loading = false |         this.loading = false | ||||||
|       }) |       }) | ||||||
|  | |||||||
| @ -14,7 +14,30 @@ | |||||||
|               /> |               /> | ||||||
|             </el-select> |             </el-select> | ||||||
|           </el-form-item> |           </el-form-item> | ||||||
|  |           <el-form-item label="代币数量"> | ||||||
|  |             <div style="display: flex;;"> | ||||||
|  |               <div> | ||||||
|  |                 <el-input | ||||||
|  |                   v-model="queryParams.startAmount" | ||||||
|  |                   width="60" | ||||||
|  |                   clearable | ||||||
|  |                   placeholder="请输入代币数量" | ||||||
|  |                 /> | ||||||
|  |               </div> | ||||||
|  |               <div style="width:10px;text-align: center;">-</div> | ||||||
|  |               <div> <el-input | ||||||
|  |                 v-model="queryParams.endAmount" | ||||||
|  |                 width="60" | ||||||
|  |                 clearable | ||||||
|  |                 placeholder="请输入代币数量" | ||||||
|  |               /> </div> | ||||||
|  |             </div> | ||||||
|  |           </el-form-item> | ||||||
|  |           <el-form-item label="状态" prop="status"> | ||||||
|  |             <el-select v-model="queryParams.status" clearable placeholder="请选择状态"> | ||||||
|  |               <el-option v-for="item in statusOptions" :key="'querystatus' + item.value" :label="item.label" :value="item.value" /> | ||||||
|  |             </el-select> | ||||||
|  |           </el-form-item> | ||||||
|           <el-form-item> |           <el-form-item> | ||||||
|             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||||||
|             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||||||
| @ -33,6 +56,16 @@ | |||||||
|             >导出 |             >导出 | ||||||
|             </el-button> |             </el-button> | ||||||
|           </el-col> |           </el-col> | ||||||
|  |           <el-col :span="1.5"> | ||||||
|  |             <el-button | ||||||
|  |               v-permisaction="['admin:wmAutoLog:clearAll']" | ||||||
|  |               type="danger" | ||||||
|  |               icon="el-icon-delete" | ||||||
|  |               size="mini" | ||||||
|  |               @click="handleClearAll" | ||||||
|  |             >清除所有 | ||||||
|  |             </el-button> | ||||||
|  |           </el-col> | ||||||
|         </el-row> |         </el-row> | ||||||
|         <el-table v-loading="loading" :data="wmTransferItemList" @cell-dblclick="handleCellDblClick"> |         <el-table v-loading="loading" :data="wmTransferItemList" @cell-dblclick="handleCellDblClick"> | ||||||
|           <el-table-column |           <el-table-column | ||||||
| @ -49,10 +82,10 @@ | |||||||
|             width="80px" |             width="80px" | ||||||
|             :show-overflow-tooltip="true" |             :show-overflow-tooltip="true" | ||||||
|           /> |           /> | ||||||
|  |           <el-table-column label="私钥" align="center" prop="privateKey" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="来源地址" align="center" prop="fromAddress" :show-overflow-tooltip="true" /> |           <el-table-column label="来源地址" align="center" prop="fromAddress" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="目标地址" align="center" prop="toAddress" :show-overflow-tooltip="true" /> |           <el-table-column label="目标地址" align="center" prop="toAddress" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="代币数量" align="center" prop="amount" :show-overflow-tooltip="true" /> |           <el-table-column label="代币数量" align="center" prop="amount" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="私钥" align="center" prop="privateKey" :show-overflow-tooltip="true" /> |  | ||||||
|           <el-table-column label="交易hash" prop="hash" :show-overflow-tooltip="true" /> |           <el-table-column label="交易hash" prop="hash" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="状态" prop="status" width="80" align="center"> |           <el-table-column label="状态" prop="status" width="80" align="center"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
| @ -79,7 +112,7 @@ | |||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
| import { getWmTransferItemAutoLogPage, exportWmTransferItemAutoLogExcel } from '@/api/admin/wm-transfer-item' | import { getWmTransferItemAutoLogPage, exportWmTransferItemAutoLogExcel, wmTransferItemClear } from '@/api/admin/wm-transfer-item' | ||||||
| import { listWmNetwork } from '@/api/admin/wm-network' | import { listWmNetwork } from '@/api/admin/wm-network' | ||||||
| import { resolveBlobByName } from '@/utils/zipdownload' | import { resolveBlobByName } from '@/utils/zipdownload' | ||||||
|  |  | ||||||
| @ -119,10 +152,6 @@ export default { | |||||||
|         } |         } | ||||||
|       ], |       ], | ||||||
|       statusOptions: [ |       statusOptions: [ | ||||||
|         { |  | ||||||
|           label: '默认', |  | ||||||
|           value: 0 |  | ||||||
|         }, |  | ||||||
|         { |         { | ||||||
|           label: '交易中', |           label: '交易中', | ||||||
|           value: 1 |           value: 1 | ||||||
| @ -139,7 +168,11 @@ export default { | |||||||
|       queryParams: { |       queryParams: { | ||||||
|         pageIndex: 1, |         pageIndex: 1, | ||||||
|         pageSize: 10, |         pageSize: 10, | ||||||
|  |         networkId: undefined, | ||||||
|  |         startAmount: undefined, | ||||||
|  |         endAmount: undefined, | ||||||
|         type: undefined, |         type: undefined, | ||||||
|  |         status: undefined, | ||||||
|         idOrder: 'desc' |         idOrder: 'desc' | ||||||
|       }, |       }, | ||||||
|       networkList: [], |       networkList: [], | ||||||
| @ -199,6 +232,8 @@ export default { | |||||||
|     resetQuery() { |     resetQuery() { | ||||||
|       this.dateRange = [] |       this.dateRange = [] | ||||||
|       this.resetForm('queryForm') |       this.resetForm('queryForm') | ||||||
|  |       this.queryParams.startAmount = undefined | ||||||
|  |       this.queryParams.endAmount = undefined | ||||||
|       this.handleQuery() |       this.handleQuery() | ||||||
|     }, |     }, | ||||||
|     handleCellDblClick(row, column, cell, event) { |     handleCellDblClick(row, column, cell, event) { | ||||||
| @ -216,11 +251,36 @@ export default { | |||||||
|     handleExport() { |     handleExport() { | ||||||
|       this.loading = true |       this.loading = true | ||||||
|       exportWmTransferItemAutoLogExcel(this.queryParams).then(res => { |       exportWmTransferItemAutoLogExcel(this.queryParams).then(res => { | ||||||
|         resolveBlobByName(res, null, '自动转账明细.xlsx') |         if (res.type === 'application/json') { | ||||||
|         this.msgSuccess('导出成功') |           this.msgError('暂无数据') | ||||||
|  |         } else { | ||||||
|  |           resolveBlobByName(res, null, '自动转账明细.xlsx') | ||||||
|  |           this.msgSuccess('导出成功') | ||||||
|  |         } | ||||||
|       }).finally(() => { |       }).finally(() => { | ||||||
|         this.loading = false |         this.loading = false | ||||||
|       }) |       }) | ||||||
|  |     }, | ||||||
|  |     handleClearAll() { | ||||||
|  |       const _this = this | ||||||
|  |  | ||||||
|  |       this.$confirm('是否确认清除所有记录?', '警告', { | ||||||
|  |         confirmButtonText: '确定', | ||||||
|  |         cancelButtonText: '取消', | ||||||
|  |         type: 'warning' | ||||||
|  |       }).then(function() { | ||||||
|  |         _this.loading = true | ||||||
|  |         return wmTransferItemClear() | ||||||
|  |       }).then((response) => { | ||||||
|  |         if (response.code === 200) { | ||||||
|  |           this.msgSuccess(response.msg) | ||||||
|  |           this.getList() | ||||||
|  |         } else { | ||||||
|  |           this.msgError(response.msg) | ||||||
|  |         } | ||||||
|  |       }).finally(() => { | ||||||
|  |         _this.loading = false | ||||||
|  |       }) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										129
									
								
								src/views/admin/wm-wallet-info/excel-import.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								src/views/admin/wm-wallet-info/excel-import.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,129 @@ | |||||||
|  | <template> | ||||||
|  |   <el-dialog title="Excel导入" :visible.sync="showDialog" width="600px" :close-on-click-modal="false" @open="opened"> | ||||||
|  |     <el-form ref="form" :model="form" :rules="rules" label-width="100px"> | ||||||
|  |       <el-form-item label="模板文件"> | ||||||
|  |         <p style="margin: 0;    color: #1890ff;"><a | ||||||
|  |           :href="futuresUrl" | ||||||
|  |           download="钱包导入模板.xlsx" | ||||||
|  |         >钱包导入模板.xlsx</a></p> | ||||||
|  |  | ||||||
|  |       </el-form-item> | ||||||
|  |       <el-form-item label="Excel文件" prop="file"> | ||||||
|  |         <el-upload | ||||||
|  |           class="upload-demo" | ||||||
|  |           drag | ||||||
|  |           :auto-upload="false" | ||||||
|  |           action="" | ||||||
|  |           accept=".xls,.xlsx" | ||||||
|  |           :file-list="fileList" | ||||||
|  |           :before-upload="beforeUpload" | ||||||
|  |           :on-change="handleFileChange" | ||||||
|  |           :on-remove="handleFileRemove" | ||||||
|  |           :limit="1" | ||||||
|  |         > | ||||||
|  |           <i class="el-icon-upload" /> | ||||||
|  |           <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> | ||||||
|  |           <div slot="tip" class="el-upload__tip">只能上传xls/xlsx文件</div> | ||||||
|  |         </el-upload> | ||||||
|  |       </el-form-item> | ||||||
|  |  | ||||||
|  |     </el-form> | ||||||
|  |  | ||||||
|  |     <div slot="footer" class="dialog-footer"> | ||||||
|  |       <el-button type="primary" :loading="formLoading" @click="submitForm">确 定</el-button> | ||||||
|  |       <el-button @click="cancel">取 消</el-button> | ||||||
|  |     </div> | ||||||
|  |   </el-dialog> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | import { wmWalletInfoExcelImport } from '@/api/admin/wm-wallet-info' | ||||||
|  | import { baseUrl } from '@/utils/zipdownload' | ||||||
|  |  | ||||||
|  | export default { | ||||||
|  |   name: 'ExcelImport', | ||||||
|  |   props: { | ||||||
|  |     show: Boolean | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       form: { | ||||||
|  |         file: null | ||||||
|  |       }, | ||||||
|  |       formLoading: false, | ||||||
|  |       futuresUrl: baseUrl + '/static/excel/钱包导入模板.xlsx', | ||||||
|  |       fileList: [], // 用于存储选中的文件 | ||||||
|  |       showDialog: false, | ||||||
|  |       rules: { | ||||||
|  |         file: [{ required: true, message: '文件不能为空', trigger: 'blur' }] | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   watch: { | ||||||
|  |     show(val) { | ||||||
|  |       this.showDialog = val | ||||||
|  |     }, | ||||||
|  |     showDialog(val) { | ||||||
|  |       this.$emit('update:show', val) | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     cancel() { | ||||||
|  |       this.showDialog = false | ||||||
|  |     }, | ||||||
|  |     // 在上传文件之前触发 | ||||||
|  |     beforeUpload(file) { | ||||||
|  |       this.form.file = file | ||||||
|  |       return false // 阻止自动上传 | ||||||
|  |     }, | ||||||
|  |     // 文件列表改变时触发 | ||||||
|  |     handleFileChange(file, fileList) { | ||||||
|  |       this.fileList = fileList | ||||||
|  |       this.form.file = fileList.length > 0 ? fileList[0].raw : null | ||||||
|  |     }, | ||||||
|  |     // 移除文件时触发 | ||||||
|  |     handleFileRemove() { | ||||||
|  |       this.fileList = [] | ||||||
|  |       this.form.file = null | ||||||
|  |     }, | ||||||
|  |     /** 提交按钮 */ | ||||||
|  |     submitForm: function() { | ||||||
|  |       this.$refs['form'].validate(valid => { | ||||||
|  |         if (valid) { | ||||||
|  |           this.formLoading = true | ||||||
|  |           const _this = this | ||||||
|  |           // 创建表单数据 | ||||||
|  |           const formData = new FormData() | ||||||
|  |  | ||||||
|  |           if (this.form.file) { | ||||||
|  |             formData.append('file', this.form.file) | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |           wmWalletInfoExcelImport(formData).then(response => { | ||||||
|  |             _this.formLoading = false | ||||||
|  |             if (response.code === 200) { | ||||||
|  |               this.msgSuccess(response.msg) | ||||||
|  |               this.showDialog = false | ||||||
|  |               this.$emit('upload-success') | ||||||
|  |             } else { | ||||||
|  |               this.msgError(response.msg) | ||||||
|  |             } | ||||||
|  |           }) | ||||||
|  |             .finally(() => { | ||||||
|  |               _this.formLoading = false | ||||||
|  |             }) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     reset() { | ||||||
|  |       this.fileList = [] | ||||||
|  |       this.form = { | ||||||
|  |         file: null | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     opened() { | ||||||
|  |       this.reset() | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
| @ -19,27 +19,6 @@ | |||||||
|         </el-form> |         </el-form> | ||||||
|  |  | ||||||
|         <el-row :gutter="10" class="mb8"> |         <el-row :gutter="10" class="mb8"> | ||||||
|           <!-- <el-col :span="1.5"> |  | ||||||
|                         <el-button |  | ||||||
|                                 v-permisaction="['admin:wmWalletInfo:add']" |  | ||||||
|                                 type="primary" |  | ||||||
|                                 icon="el-icon-plus" |  | ||||||
|                                 size="mini" |  | ||||||
|                                 @click="handleAdd" |  | ||||||
|                         >新增 |  | ||||||
|                         </el-button> |  | ||||||
|                     </el-col> |  | ||||||
|                     <el-col :span="1.5"> |  | ||||||
|                         <el-button |  | ||||||
|                                 v-permisaction="['admin:wmWalletInfo:edit']" |  | ||||||
|                                 type="success" |  | ||||||
|                                 icon="el-icon-edit" |  | ||||||
|                                 size="mini" |  | ||||||
|                                 :disabled="single" |  | ||||||
|                                 @click="handleUpdate" |  | ||||||
|                         >修改 |  | ||||||
|                         </el-button> |  | ||||||
|                     </el-col> --> |  | ||||||
|           <el-col :span="1.5"> |           <el-col :span="1.5"> | ||||||
|             <el-button |             <el-button | ||||||
|               v-permisaction="['admin:wmWalletInfo:add']" |               v-permisaction="['admin:wmWalletInfo:add']" | ||||||
| @ -47,9 +26,30 @@ | |||||||
|               icon="el-icon-plus" |               icon="el-icon-plus" | ||||||
|               size="mini" |               size="mini" | ||||||
|               @click="handleAdd" |               @click="handleAdd" | ||||||
|  |             >批量添加 | ||||||
|  |             </el-button> | ||||||
|  |           </el-col> | ||||||
|  |           <el-col :span="1.5"> | ||||||
|  |             <el-button | ||||||
|  |               v-permisaction="['admin:wmWalletInfo:upload']" | ||||||
|  |               type="primary" | ||||||
|  |               icon="el-icon-plus" | ||||||
|  |               size="mini" | ||||||
|  |               @click="handleUploadExcel" | ||||||
|             >导入钱包 |             >导入钱包 | ||||||
|             </el-button> |             </el-button> | ||||||
|           </el-col> |           </el-col> | ||||||
|  |           <el-col :span="1.5"> | ||||||
|  |             <el-button | ||||||
|  |               v-permisaction="['admin:wmWalletInfo:edit']" | ||||||
|  |               type="primary" | ||||||
|  |               icon="el-icon-edit" | ||||||
|  |               size="mini" | ||||||
|  |               :disabled="multiple" | ||||||
|  |               @click="handleUpdate" | ||||||
|  |             >修改备注 | ||||||
|  |             </el-button> | ||||||
|  |           </el-col> | ||||||
|           <el-col :span="1.5"> |           <el-col :span="1.5"> | ||||||
|             <el-button |             <el-button | ||||||
|               v-permisaction="['admin:wmWalletInfo:remove']" |               v-permisaction="['admin:wmWalletInfo:remove']" | ||||||
| @ -75,23 +75,26 @@ | |||||||
|  |  | ||||||
|         <el-table v-loading="loading" :data="wmWalletInfoList" @selection-change="handleSelectionChange"> |         <el-table v-loading="loading" :data="wmWalletInfoList" @selection-change="handleSelectionChange"> | ||||||
|           <el-table-column type="selection" width="55" align="center" /> |           <el-table-column type="selection" width="55" align="center" /> | ||||||
|  |           <el-table-column label="编号" prop="id" align="center" width="55" /> | ||||||
|           <el-table-column label="钱包私钥" align="center" prop="privateKey" :show-overflow-tooltip="true" /> |           <el-table-column label="钱包私钥" align="center" prop="privateKey" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="钱包地址" align="center" prop="address" :show-overflow-tooltip="true" /> |           <el-table-column label="钱包地址" align="center" prop="address" /> | ||||||
|  |           <el-table-column label="备注" prop="remark" :show-overflow-tooltip="true" /> | ||||||
|           <el-table-column label="创建时间" prop="createdAt" width="155"> |           <el-table-column label="创建时间" prop="createdAt" width="155"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
|               <span>{{ parseTime(scope.row.createdAt) }}</span> |               <span>{{ parseTime(scope.row.createdAt) }}</span> | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|           <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |           <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
|               <!-- <el-popconfirm class="delete-popconfirm" title="确认要修改吗?" confirm-button-text="修改" |               <el-button | ||||||
|                                 @confirm="handleUpdate(scope.row)"> |                 slot="reference" | ||||||
|                                 <el-button slot="reference" v-permisaction="['admin:wmWalletInfo:edit']" size="mini" |                 v-permisaction="['admin:wmWalletInfo:edit']" | ||||||
|                                     type="text" icon="el-icon-edit">修改 |                 size="mini" | ||||||
|                                 </el-button> |                 type="text" | ||||||
|                             </el-popconfirm> --> |                 icon="el-icon-delete" | ||||||
|               <!-- <el-popconfirm class="delete-popconfirm" title="确认要删除吗?" confirm-button-text="删除" |                 @click="handleUpdate(scope.row)" | ||||||
|                                 @confirm="handleDelete(scope.row)"> --> |               >编辑 | ||||||
|  |               </el-button> | ||||||
|               <el-button |               <el-button | ||||||
|                 slot="reference" |                 slot="reference" | ||||||
|                 v-permisaction="['admin:wmWalletInfo:remove']" |                 v-permisaction="['admin:wmWalletInfo:remove']" | ||||||
| @ -101,7 +104,6 @@ | |||||||
|                 @click="handleDelete(scope.row)" |                 @click="handleDelete(scope.row)" | ||||||
|               >删除 |               >删除 | ||||||
|               </el-button> |               </el-button> | ||||||
|               <!-- </el-popconfirm> --> |  | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|         </el-table> |         </el-table> | ||||||
| @ -132,17 +134,41 @@ | |||||||
|             <el-button @click="cancel">取 消</el-button> |             <el-button @click="cancel">取 消</el-button> | ||||||
|           </div> |           </div> | ||||||
|         </el-dialog> |         </el-dialog> | ||||||
|  |  | ||||||
|  |         <el-dialog title="修改备注" :visible.sync="remarkOpen" width="500px"> | ||||||
|  |           <el-form ref="remarkForm" :model="remarkForm" label-width="80px"> | ||||||
|  |             <el-form-item label="备注" prop="remark"> | ||||||
|  |               <el-input | ||||||
|  |                 v-model="remarkForm.remark" | ||||||
|  |                 placeholder="请填写备注" | ||||||
|  |                 type="textarea" | ||||||
|  |                 :rows="3" | ||||||
|  |                 clearable | ||||||
|  |                 maxlength="255" | ||||||
|  |                 show-word-limit | ||||||
|  |               /> | ||||||
|  |             </el-form-item> | ||||||
|  |           </el-form> | ||||||
|  |           <div slot="footer" class="dialog-footer"> | ||||||
|  |             <el-button type="primary" :loading="loading" @click="submitRemarkForm">确 定</el-button> | ||||||
|  |             <el-button @click="cancel">取 消</el-button> | ||||||
|  |           </div> | ||||||
|  |         </el-dialog> | ||||||
|  |  | ||||||
|  |         <ExcelImport :show.sync="fileOpen" @upload-success="handleExcelSuccess" /> | ||||||
|       </el-card> |       </el-card> | ||||||
|     </template> |     </template> | ||||||
|   </BasicLayout> |   </BasicLayout> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
| import { addWmWalletInfo, delWmWalletInfo, getWmWalletInfo, listWmWalletInfo, clearAllWmWalletInfo } from '@/api/admin/wm-wallet-info' | import { addWmWalletInfo, delWmWalletInfo, listWmWalletInfo, clearAllWmWalletInfo, batchUpdateWmWalletInfo } from '@/api/admin/wm-wallet-info' | ||||||
|  | import ExcelImport from '@/views/admin/wm-wallet-info/excel-import' | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   name: 'WmWalletInfo', |   name: 'WmWalletInfo', | ||||||
|   components: { |   components: { | ||||||
|  |     ExcelImport | ||||||
|   }, |   }, | ||||||
|   data() { |   data() { | ||||||
|     return { |     return { | ||||||
| @ -160,7 +186,9 @@ export default { | |||||||
|       title: '', |       title: '', | ||||||
|       // 是否显示弹出层 |       // 是否显示弹出层 | ||||||
|       open: false, |       open: false, | ||||||
|  |       remarkOpen: false, | ||||||
|       isEdit: false, |       isEdit: false, | ||||||
|  |       fileOpen: false, | ||||||
|       // 类型数据字典 |       // 类型数据字典 | ||||||
|       typeOptions: [], |       typeOptions: [], | ||||||
|       wmWalletInfoList: [], |       wmWalletInfoList: [], | ||||||
| @ -171,12 +199,13 @@ export default { | |||||||
|       queryParams: { |       queryParams: { | ||||||
|         pageIndex: 1, |         pageIndex: 1, | ||||||
|         pageSize: 10, |         pageSize: 10, | ||||||
|         privateKey: undefined |         privateKey: undefined, | ||||||
|  |         idOrder: 'desc' | ||||||
|       }, |       }, | ||||||
|       // 表单参数 |       // 表单参数 | ||||||
|       form: { |       form: { | ||||||
|       }, |       }, | ||||||
|  |       remarkForm: {}, | ||||||
|       // 表单校验 |       // 表单校验 | ||||||
|       rules: { |       rules: { | ||||||
|         keys: [{ required: true, message: '钱包私钥不能为空', trigger: 'blur' }] |         keys: [{ required: true, message: '钱包私钥不能为空', trigger: 'blur' }] | ||||||
| @ -200,7 +229,15 @@ export default { | |||||||
|     // 取消按钮 |     // 取消按钮 | ||||||
|     cancel() { |     cancel() { | ||||||
|       this.open = false |       this.open = false | ||||||
|  |       this.remarkOpen = false | ||||||
|       this.reset() |       this.reset() | ||||||
|  |       this.resetRemarkForm() | ||||||
|  |     }, | ||||||
|  |     resetRemarkForm() { | ||||||
|  |       this.remarkForm = { | ||||||
|  |         ids: undefined, | ||||||
|  |         remark: undefined | ||||||
|  |       } | ||||||
|     }, |     }, | ||||||
|     // 表单重置 |     // 表单重置 | ||||||
|     reset() { |     reset() { | ||||||
| @ -246,15 +283,11 @@ export default { | |||||||
|     }, |     }, | ||||||
|     /** 修改按钮操作 */ |     /** 修改按钮操作 */ | ||||||
|     handleUpdate(row) { |     handleUpdate(row) { | ||||||
|       this.reset() |       this.resetRemarkForm() | ||||||
|       const id = |       const id = | ||||||
|                 row.id || this.ids |                 row.id ? [row.id] : this.ids | ||||||
|       getWmWalletInfo(id).then(response => { |       this.remarkForm.ids = id | ||||||
|         this.form = response.data |       this.remarkOpen = true | ||||||
|         this.open = true |  | ||||||
|         this.title = '修改钱包信息' |  | ||||||
|         this.isEdit = true |  | ||||||
|       }) |  | ||||||
|     }, |     }, | ||||||
|     /** 提交按钮 */ |     /** 提交按钮 */ | ||||||
|     submitForm: function() { |     submitForm: function() { | ||||||
| @ -276,6 +309,25 @@ export default { | |||||||
|         } |         } | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|  |     submitRemarkForm: function() { | ||||||
|  |       this.$refs['remarkForm'].validate(valid => { | ||||||
|  |         if (valid) { | ||||||
|  |           this.loading = true | ||||||
|  |           batchUpdateWmWalletInfo(this.remarkForm).then(response => { | ||||||
|  |             if (response.code === 200) { | ||||||
|  |               this.msgSuccess(response.msg) | ||||||
|  |               this.remarkOpen = false | ||||||
|  |               this.getList() | ||||||
|  |             } else { | ||||||
|  |               this.msgError(response.msg) | ||||||
|  |             } | ||||||
|  |           }) | ||||||
|  |             .finally(() => { | ||||||
|  |               this.loading = false | ||||||
|  |             }) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|     /** 删除按钮操作 */ |     /** 删除按钮操作 */ | ||||||
|     handleDelete(row) { |     handleDelete(row) { | ||||||
|       var Ids = (row.id && [row.id]) || this.ids |       var Ids = (row.id && [row.id]) || this.ids | ||||||
| @ -322,6 +374,13 @@ export default { | |||||||
|         .finally(() => { |         .finally(() => { | ||||||
|           _this.loading = false |           _this.loading = false | ||||||
|         }) |         }) | ||||||
|  |     }, | ||||||
|  |     handleExcelSuccess() { | ||||||
|  |       this.getList() | ||||||
|  |     }, | ||||||
|  |     handleUploadExcel() { | ||||||
|  |       console.log('上传文件') | ||||||
|  |       this.fileOpen = true | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user