1、注定查询字符数
This commit is contained in:
		| @ -1,63 +1,63 @@ | |||||||
| import request from "@/utils/request"; | import request from '@/utils/request' | ||||||
|  |  | ||||||
| // 查询TmMember列表 | // 查询TmMember列表 | ||||||
| export function listTmMember(query) { | export function listTmMember(query) { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member", |     url: '/api/v1/tm-member', | ||||||
|     method: "get", |     method: 'get', | ||||||
|     params: query, |     params: query | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| // 查询TmMember详细 | // 查询TmMember详细 | ||||||
| export function getTmMember(id) { | export function getTmMember(id) { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member/" + id, |     url: '/api/v1/tm-member/' + id, | ||||||
|     method: "get", |     method: 'get' | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| // 新增TmMember | // 新增TmMember | ||||||
| export function addTmMember(data) { | export function addTmMember(data) { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member", |     url: '/api/v1/tm-member', | ||||||
|     method: "post", |     method: 'post', | ||||||
|     data: data, |     data: data | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| // 修改TmMember | // 修改TmMember | ||||||
| export function updateTmMember(data) { | export function updateTmMember(data) { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member/" + data.id, |     url: '/api/v1/tm-member/' + data.id, | ||||||
|     method: "put", |     method: 'put', | ||||||
|     data: data, |     data: data | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| // 删除TmMember | // 删除TmMember | ||||||
| export function delTmMember(data) { | export function delTmMember(data) { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member", |     url: '/api/v1/tm-member', | ||||||
|     method: "delete", |     method: 'delete', | ||||||
|     data: data, |     data: data | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| // 获取API Key | // 获取API Key | ||||||
| export function getMyKey() { | export function getMyKey() { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member/api-key", |     url: '/api/v1/tm-member/api-key', | ||||||
|     method: "get", |     method: 'get' | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| // 获取使用量统计 | // 获取使用量统计 | ||||||
| export function getTranslateDataStatistic() { | export function getTranslateDataStatistic() { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/translate/datastatistics", |     url: '/api/v1/translate/datastatistics', | ||||||
|     method: "get", |     method: 'get' | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| // 字符充值 | // 字符充值 | ||||||
| @ -69,18 +69,28 @@ export function getTranslateDataStatistic() { | |||||||
| //   }) | //   }) | ||||||
| // } | // } | ||||||
|  |  | ||||||
|  | // 管理员充值 | ||||||
| export function tmMemberManageRecharge(data) { | export function tmMemberManageRecharge(data) { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member/manager-recharge", |     url: '/api/v1/tm-member/manager-recharge', | ||||||
|     method: "post", |     method: 'post', | ||||||
|     data: data, |     data: data | ||||||
|   }); |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 管理员扣除字符 | ||||||
|  | export function tmMemberManageDeduct(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/tm-member/manager-deduct', | ||||||
|  |     method: 'put', | ||||||
|  |     data: data | ||||||
|  |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| export function changeTmMemberStatus(data) { | export function changeTmMemberStatus(data) { | ||||||
|   return request({ |   return request({ | ||||||
|     url: "/api/v1/tm-member/status", |     url: '/api/v1/tm-member/status', | ||||||
|     method: "put", |     method: 'put', | ||||||
|     data: data, |     data: data | ||||||
|   }); |   }) | ||||||
| } | } | ||||||
|  | |||||||
| @ -44,3 +44,11 @@ export function delTmPlatformAccount(data) { | |||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // 更新TmPlatformAccount剩余量 | ||||||
|  | export function tmPlatformAccountRemain(id) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/tm-platform-account/query-remain/' + id, | ||||||
|  |     method: 'put' | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										46
									
								
								src/api/admin/tm-recharge-package.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/api/admin/tm-recharge-package.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | |||||||
|  | import request from '@/utils/request' | ||||||
|  |  | ||||||
|  | // 查询TmRechargePackage列表 | ||||||
|  | export function listTmRechargePackage(query) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/tm-recharge-package', | ||||||
|  |     method: 'get', | ||||||
|  |     params: query | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 查询TmRechargePackage详细 | ||||||
|  | export function getTmRechargePackage(id) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/tm-recharge-package/' + id, | ||||||
|  |     method: 'get' | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 新增TmRechargePackage | ||||||
|  | export function addTmRechargePackage(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/tm-recharge-package', | ||||||
|  |     method: 'post', | ||||||
|  |     data: data | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 修改TmRechargePackage | ||||||
|  | export function updateTmRechargePackage(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/tm-recharge-package/' + data.id, | ||||||
|  |     method: 'put', | ||||||
|  |     data: data | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 删除TmRechargePackage | ||||||
|  | export function delTmRechargePackage(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/api/v1/tm-recharge-package', | ||||||
|  |     method: 'delete', | ||||||
|  |     data: data | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  |  | ||||||
| @ -3,8 +3,13 @@ | |||||||
|     <template #wrapper> |     <template #wrapper> | ||||||
|       <el-card class="box-card"> |       <el-card class="box-card"> | ||||||
|         <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px"> |         <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px"> | ||||||
|           <el-form-item label="用户昵称" prop="nickName"><el-input v-model="queryParams.nickName" placeholder="请输入用户昵称" |           <el-form-item label="用户昵称" prop="nickName"><el-input | ||||||
|               clearable size="small" @keyup.enter.native="handleQuery" /> |             v-model="queryParams.nickName" | ||||||
|  |             placeholder="请输入用户昵称" | ||||||
|  |             clearable | ||||||
|  |             size="small" | ||||||
|  |             @keyup.enter.native="handleQuery" | ||||||
|  |           /> | ||||||
|           </el-form-item> |           </el-form-item> | ||||||
|           <el-form-item label="状态" prop="status"> |           <el-form-item label="状态" prop="status"> | ||||||
|  |  | ||||||
| @ -56,16 +61,22 @@ | |||||||
|           <el-table-column label="剩余字符" align="center" prop="remainChars"> |           <el-table-column label="剩余字符" align="center" prop="remainChars"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
|               <div v-for="(item, index) in scope.row.platforms" :key="'remains' + index">{{ item.name }}:{{ |               <div v-for="(item, index) in scope.row.platforms" :key="'remains' + index">{{ item.name }}:{{ | ||||||
|                 item.totalChars }} <el-button v-permisaction="['admin:tmMember:changeChars']" size="mini" type="text" |                 item.totalChars }} | ||||||
|  |                 <!-- <el-button v-permisaction="['admin:tmMember:changeChars']" size="mini" type="text" | ||||||
|                   icon="el-icon-edit" class="char-btn" |                   icon="el-icon-edit" class="char-btn" | ||||||
|                   @click="handleChangeChar(item, scope.row.nickName, 1)">修改</el-button> |                   @click="handleChangeChar(item, scope.row.nickName, 1)">修改</el-button> --> | ||||||
|               </div> |               </div> | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|           <el-table-column label="状态" align="center" width="80px"> |           <el-table-column label="状态" align="center" width="80px"> | ||||||
|             <template slot-scope="scope"> |             <template slot-scope="scope"> | ||||||
|               <el-switch v-if="checkPermisAction(['admin:tmMember:changeStatus'])" v-model="scope.row.status" |               <el-switch | ||||||
|                 :active-value="1" :inactive-value="2" @change="handleStatusChange(scope.row)" /> |                 v-if="checkPermisAction(['admin:tmMember:changeStatus'])" | ||||||
|  |                 v-model="scope.row.status" | ||||||
|  |                 :active-value="1" | ||||||
|  |                 :inactive-value="2" | ||||||
|  |                 @change="handleStatusChange(scope.row)" | ||||||
|  |               /> | ||||||
|               <div v-else> |               <div v-else> | ||||||
|                 <el-tag v-if="scope.row.status === 1" type="success">启用</el-tag> |                 <el-tag v-if="scope.row.status === 1" type="success">启用</el-tag> | ||||||
|                 <el-tag v-else type="danger">禁用</el-tag> |                 <el-tag v-else type="danger">禁用</el-tag> | ||||||
| @ -98,19 +109,42 @@ | |||||||
|                                     type="text" icon="el-icon-delete">删除 |                                     type="text" icon="el-icon-delete">删除 | ||||||
|                                 </el-button> |                                 </el-button> | ||||||
|                             </el-popconfirm> --> |                             </el-popconfirm> --> | ||||||
|               <el-popconfirm class="delete-popconfirm" title="确认要充值吗?" confirm-button-text="充值" |               <el-popconfirm | ||||||
|                 @confirm="handleRecharge(scope.row)"> |                 class="delete-popconfirm" | ||||||
|                 <el-button slot="reference" v-permisaction="['admin:tmMember:recharge']" size="mini" type="text" |                 title="确认要充值吗?" | ||||||
|                   icon="el-icon-edit">充值 |                 confirm-button-text="充值" | ||||||
|  |                 @confirm="handleRecharge(scope.row)" | ||||||
|  |               > | ||||||
|  |                 <el-button | ||||||
|  |                   slot="reference" | ||||||
|  |                   v-permisaction="['admin:tmMember:recharge']" | ||||||
|  |                   size="mini" | ||||||
|  |                   type="text" | ||||||
|  |                   icon="el-icon-edit" | ||||||
|  |                 >充值 | ||||||
|  |                 </el-button> | ||||||
|  |               </el-popconfirm> | ||||||
|  |               <el-popconfirm class="delete-popconfirm" title="确认要扣除吗?" confirm-button-text="扣除" @confirm="handleDeduct(scope.row)"> | ||||||
|  |                 <el-button | ||||||
|  |                   slot="reference" | ||||||
|  |                   v-permisaction="['admin:tmMember:deduct']" | ||||||
|  |                   size="mini" | ||||||
|  |                   type="text" | ||||||
|  |                   icon="el-icon-delete" | ||||||
|  |                 >扣除 | ||||||
|                 </el-button> |                 </el-button> | ||||||
|               </el-popconfirm> |               </el-popconfirm> | ||||||
|  |  | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|         </el-table> |         </el-table> | ||||||
|  |  | ||||||
|         <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageIndex" |         <pagination | ||||||
|           :limit.sync="queryParams.pageSize" @pagination="getList" /> |           v-show="total > 0" | ||||||
|  |           :total="total" | ||||||
|  |           :page.sync="queryParams.pageIndex" | ||||||
|  |           :limit.sync="queryParams.pageSize" | ||||||
|  |           @pagination="getList" | ||||||
|  |         /> | ||||||
|  |  | ||||||
|         <!-- 添加或修改对话框 --> |         <!-- 添加或修改对话框 --> | ||||||
|         <!-- <el-dialog :title="title" :visible.sync="open" width="500px"> |         <!-- <el-dialog :title="title" :visible.sync="open" width="500px"> | ||||||
| @ -151,8 +185,23 @@ | |||||||
|                     </div> |                     </div> | ||||||
|                 </el-dialog> --> |                 </el-dialog> --> | ||||||
|  |  | ||||||
|         <tm-member-recharge :userId="showRechargeData.UserId" v-model="showRecharge" :memberId="showRechargeData.memberId" |         <tm-member-recharge | ||||||
|           :api-key="showRechargeData.showApiKey" :nick-name="showRechargeData.showNickName" @close="handleRechargeClose" /> |           v-model="showRecharge" | ||||||
|  |           :user-id="showRechargeData.UserId" | ||||||
|  |           :member-id="showRechargeData.memberId" | ||||||
|  |           :api-key="showRechargeData.showApiKey" | ||||||
|  |           :nick-name="showRechargeData.showNickName" | ||||||
|  |           @close="handleRechargeClose" | ||||||
|  |         /> | ||||||
|  |  | ||||||
|  |         <tm-member-deduct | ||||||
|  |           v-model="showDeduct" | ||||||
|  |           :user-id="showRechargeData.UserId" | ||||||
|  |           :member-id="showRechargeData.memberId" | ||||||
|  |           :api-key="showRechargeData.showApiKey" | ||||||
|  |           :nick-name="showRechargeData.showNickName" | ||||||
|  |           @close="handleRechargeClose" | ||||||
|  |         /> | ||||||
|  |  | ||||||
|         <!-- <tm-member-change :visible.sync="showChange" :memberId="showCangeData.memberId" |         <!-- <tm-member-change :visible.sync="showChange" :memberId="showCangeData.memberId" | ||||||
|           :userId="showCangeData.userId" |           :userId="showCangeData.userId" | ||||||
| @ -168,13 +217,15 @@ | |||||||
| import { addTmMember, delTmMember, getTmMember, listTmMember, updateTmMember, changeTmMemberStatus } from '@/api/admin/tm-member' | import { addTmMember, delTmMember, getTmMember, listTmMember, updateTmMember, changeTmMemberStatus } from '@/api/admin/tm-member' | ||||||
| import TmMemberRecharge from './tm-member-recharge.vue' | import TmMemberRecharge from './tm-member-recharge.vue' | ||||||
| import checkPermisAction from '@/utils/permisaction' | import checkPermisAction from '@/utils/permisaction' | ||||||
| import TmMemberChange from './tm-member-change.vue' | // import TmMemberChange from './tm-member-change.vue' | ||||||
|  | import TmMemberDeduct from './tm-member-deduct.vue' | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   name: 'TmMember', |   name: 'TmMember', | ||||||
|   components: { |   components: { | ||||||
|     TmMemberRecharge, |     TmMemberRecharge, | ||||||
|     TmMemberChange |     // TmMemberChange, | ||||||
|  |     TmMemberDeduct | ||||||
|   }, |   }, | ||||||
|   data() { |   data() { | ||||||
|     return { |     return { | ||||||
| @ -194,11 +245,12 @@ export default { | |||||||
|       open: false, |       open: false, | ||||||
|       isEdit: false, |       isEdit: false, | ||||||
|       showRecharge: false, |       showRecharge: false, | ||||||
|  |       showDeduct: false, | ||||||
|       showRechargeData: { |       showRechargeData: { | ||||||
|         showApiKey: undefined, |         showApiKey: undefined, | ||||||
|         showNickName: undefined, |         showNickName: undefined, | ||||||
|         memberId: undefined, |         memberId: undefined, | ||||||
|         userId: undefined, |         userId: undefined | ||||||
|       }, |       }, | ||||||
|       showChange: false, |       showChange: false, | ||||||
|       showCangeData: { |       showCangeData: { | ||||||
| @ -206,7 +258,7 @@ export default { | |||||||
|         platformId: undefined, |         platformId: undefined, | ||||||
|         platformName: undefined, |         platformName: undefined, | ||||||
|         totalNum: undefined, |         totalNum: undefined, | ||||||
|         type: undefined, |         type: undefined | ||||||
|       }, |       }, | ||||||
|       rechargeId: undefined, |       rechargeId: undefined, | ||||||
|       // 类型数据字典 |       // 类型数据字典 | ||||||
| @ -283,10 +335,10 @@ export default { | |||||||
|       } |       } | ||||||
|       this.resetForm('form') |       this.resetForm('form') | ||||||
|     }, |     }, | ||||||
|     getImgList: function () { |     getImgList: function() { | ||||||
|       this.form[this.fileIndex] = this.$refs['fileChoose'].resultList[0].fullUrl |       this.form[this.fileIndex] = this.$refs['fileChoose'].resultList[0].fullUrl | ||||||
|     }, |     }, | ||||||
|     fileClose: function () { |     fileClose: function() { | ||||||
|       this.fileOpen = false |       this.fileOpen = false | ||||||
|     }, |     }, | ||||||
|     areaCodeFormat(row) { |     areaCodeFormat(row) { | ||||||
| @ -331,7 +383,7 @@ export default { | |||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|     /** 提交按钮 */ |     /** 提交按钮 */ | ||||||
|     submitForm: function () { |     submitForm: function() { | ||||||
|       this.$refs['form'].validate(valid => { |       this.$refs['form'].validate(valid => { | ||||||
|         if (valid) { |         if (valid) { | ||||||
|           if (this.form.id !== undefined) { |           if (this.form.id !== undefined) { | ||||||
| @ -366,7 +418,7 @@ export default { | |||||||
|         confirmButtonText: '确定', |         confirmButtonText: '确定', | ||||||
|         cancelButtonText: '取消', |         cancelButtonText: '取消', | ||||||
|         type: 'warning' |         type: 'warning' | ||||||
|       }).then(function () { |       }).then(function() { | ||||||
|         return delTmMember({ 'ids': Ids }) |         return delTmMember({ 'ids': Ids }) | ||||||
|       }).then((response) => { |       }).then((response) => { | ||||||
|         if (response.code === 200) { |         if (response.code === 200) { | ||||||
| @ -376,11 +428,11 @@ export default { | |||||||
|         } else { |         } else { | ||||||
|           this.msgError(response.msg) |           this.msgError(response.msg) | ||||||
|         } |         } | ||||||
|       }).catch(function () { |       }).catch(function() { | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|     handleRecharge(row) { |     handleRecharge(row) { | ||||||
|       this.showRechargeData={ |       this.showRechargeData = { | ||||||
|         UserId: row.userId, |         UserId: row.userId, | ||||||
|         memberId: row.id, |         memberId: row.id, | ||||||
|         showApiKey: row.apiKey, |         showApiKey: row.apiKey, | ||||||
| @ -388,6 +440,15 @@ export default { | |||||||
|       } |       } | ||||||
|       this.showRecharge = true |       this.showRecharge = true | ||||||
|     }, |     }, | ||||||
|  |     handleDeduct(row) { | ||||||
|  |       this.showRechargeData = { | ||||||
|  |         UserId: row.userId, | ||||||
|  |         memberId: row.id, | ||||||
|  |         showApiKey: row.apiKey, | ||||||
|  |         showNickName: row.nickName | ||||||
|  |       } | ||||||
|  |       this.showDeduct = true | ||||||
|  |     }, | ||||||
|     handleRechargeClose() { |     handleRechargeClose() { | ||||||
|       this.getList() |       this.getList() | ||||||
|     }, |     }, | ||||||
| @ -421,7 +482,6 @@ export default { | |||||||
|       } |       } | ||||||
|  |  | ||||||
|       this.showChange = true |       this.showChange = true | ||||||
|  |  | ||||||
|     }, |     }, | ||||||
|     // 修改字符关闭事件 |     // 修改字符关闭事件 | ||||||
|     handleChangeCharClose() { |     handleChangeCharClose() { | ||||||
| @ -435,4 +495,4 @@ export default { | |||||||
| .char-btn { | .char-btn { | ||||||
|   margin-left: 5px; |   margin-left: 5px; | ||||||
| } | } | ||||||
| </style> | </style> | ||||||
|  | |||||||
							
								
								
									
										123
									
								
								src/views/admin/tm-member/tm-member-deduct.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								src/views/admin/tm-member/tm-member-deduct.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,123 @@ | |||||||
|  | <template> | ||||||
|  |   <el-dialog title="字符扣除" :visible.sync="value" width="500px" @close="handleClose" @open="handleOpen"> | ||||||
|  |     <el-form ref="form" :model="form" :rules="rules" label-width="120px"> | ||||||
|  |       <el-form-item label="用户昵称" prop="nickName"> | ||||||
|  |         {{ nickName }} | ||||||
|  |       </el-form-item> | ||||||
|  |       <el-form-item label="翻译平台" prop="platformId"> | ||||||
|  |         <el-select v-model="form.platformId" placeholder="请选择翻译平台"> | ||||||
|  |           <el-option v-for="item in platformList" :key="item.id" :label="item.name" :value="item.id" /> | ||||||
|  |         </el-select> | ||||||
|  |       </el-form-item> | ||||||
|  |       <el-form-item label="apiKey"> | ||||||
|  |         {{ apiKey }} | ||||||
|  |       </el-form-item> | ||||||
|  |       <el-form-item label="扣除字符(万)" prop="totalChars"> | ||||||
|  |         <el-input v-model.number="form.totalChars" placeholder="充值字符(万)" /> | ||||||
|  |       </el-form-item> | ||||||
|  |  | ||||||
|  |     </el-form> | ||||||
|  |     <div slot="footer" class="dialog-footer"> | ||||||
|  |       <el-button type="primary" :loading="loading" @click="submitForm">确 定</el-button> | ||||||
|  |       <el-button @click="cancel">取 消</el-button> | ||||||
|  |     </div> | ||||||
|  |   </el-dialog> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | import { tmMemberManageDeduct } from '@/api/admin/tm-member' | ||||||
|  | import { listTmPlatform } from '@/api/admin/tm-platform' | ||||||
|  |  | ||||||
|  | export default { | ||||||
|  |   name: 'TmMemberRecharge', | ||||||
|  |   props: { | ||||||
|  |     value: { | ||||||
|  |       type: Boolean, | ||||||
|  |       default: false | ||||||
|  |     }, | ||||||
|  |     apiKey: { | ||||||
|  |       type: String, | ||||||
|  |       default: '' | ||||||
|  |     }, | ||||||
|  |     nickName: { | ||||||
|  |       type: String, | ||||||
|  |       default: '' | ||||||
|  |     }, | ||||||
|  |     memberId: { | ||||||
|  |       type: Number, | ||||||
|  |       default: 0 | ||||||
|  |     }, | ||||||
|  |     userId: { | ||||||
|  |       type: Number, | ||||||
|  |       default: 0 | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       loading: false, | ||||||
|  |       form: {}, | ||||||
|  |       remainChars: 0, | ||||||
|  |       rules: { | ||||||
|  |         platformId: [{ required: true, message: '请选择翻译平台', trigger: 'blur' }], | ||||||
|  |         totalChars: [{ required: true, message: '请输入扣除字符(万)', trigger: 'blur' }] | ||||||
|  |       }, | ||||||
|  |       platformList: [] | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   methods: { | ||||||
|  |     handleOpen() { | ||||||
|  |       this.getPlatform() | ||||||
|  |     }, | ||||||
|  |     getPlatform() { | ||||||
|  |       listTmPlatform({ pageIndex: 1, pageSize: 1000 }).then(response => { | ||||||
|  |         if (response.code === 200) { | ||||||
|  |           this.platformList = response.data.list | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     resetForm() { | ||||||
|  |       this.form = { | ||||||
|  |         id: undefined, | ||||||
|  |         apiKey: undefined, | ||||||
|  |         totalChars: undefined, | ||||||
|  |         userId: undefined, | ||||||
|  |         memberId: undefined, | ||||||
|  |         expireDays: undefined | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     handleClose() { | ||||||
|  |       this.resetForm() | ||||||
|  |       this.$emit('input', false) | ||||||
|  |       this.$emit('close') | ||||||
|  |     }, | ||||||
|  |     cancel() { | ||||||
|  |       this.loading = false | ||||||
|  |       this.handleClose() | ||||||
|  |     }, | ||||||
|  |     submitForm() { | ||||||
|  |       this.$refs['form'].validate(valid => { | ||||||
|  |         if (valid) { | ||||||
|  |           this.loading = true | ||||||
|  |           this.form.memberId = this.memberId | ||||||
|  |           this.form.userId = this.userId | ||||||
|  |           const platform = this.platformList.find(item => item.id === this.form.platformId) | ||||||
|  |           this.form.platformCode = platform.code | ||||||
|  |  | ||||||
|  |           tmMemberManageDeduct(this.form).then(response => { | ||||||
|  |             if (response.code === 200) { | ||||||
|  |               this.$message.success('操作成功') | ||||||
|  |               this.handleClose() | ||||||
|  |             } else { | ||||||
|  |               this.$message.error(response.message) | ||||||
|  |             } | ||||||
|  |           }) | ||||||
|  |             .finally(() => { | ||||||
|  |               this.loading = false | ||||||
|  |             }) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
| @ -71,12 +71,21 @@ | |||||||
|             align="center" |             align="center" | ||||||
|             prop="apiSecret" |             prop="apiSecret" | ||||||
|             :show-overflow-tooltip="true" |             :show-overflow-tooltip="true" | ||||||
|           /><el-table-column |           /> | ||||||
|  |           <el-table-column label="剩余字符" align="center" prop="remainChars" :show-overflow-tooltip="true" /> | ||||||
|  |  | ||||||
|  |           <el-table-column label="状态" align="center" width="80px"> | ||||||
|  |             <template slot-scope="scope"> | ||||||
|  |               <el-tag v-if="scope.row.status === 1" type="success">启用</el-tag> | ||||||
|  |               <el-tag v-else type="danger">禁用</el-tag> | ||||||
|  |             </template> | ||||||
|  |           </el-table-column> | ||||||
|  |           <!-- <el-table-column | ||||||
|             label="qps限制" |             label="qps限制" | ||||||
|             align="center" |             align="center" | ||||||
|             prop="qpsLimit" |             prop="qpsLimit" | ||||||
|             :show-overflow-tooltip="true" |             :show-overflow-tooltip="true" | ||||||
|           /> |           /> --> | ||||||
|           <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"> | ||||||
|               <el-popconfirm |               <el-popconfirm | ||||||
| @ -109,6 +118,21 @@ | |||||||
|                 >删除 |                 >删除 | ||||||
|                 </el-button> |                 </el-button> | ||||||
|               </el-popconfirm> |               </el-popconfirm> | ||||||
|  |               <el-popconfirm | ||||||
|  |                 class="delete-popconfirm" | ||||||
|  |                 title="确定要查询剩余字符吗?" | ||||||
|  |                 confirm-button-text="查询" | ||||||
|  |                 @confirm="handleQueryRemainChars(scope.row)" | ||||||
|  |               > | ||||||
|  |                 <el-button | ||||||
|  |                   slot="reference" | ||||||
|  |                   v-permisaction="['admin:tmPlatformAccount:query']" | ||||||
|  |                   size="mini" | ||||||
|  |                   type="text" | ||||||
|  |                   icon="el-icon-s-data" | ||||||
|  |                 >查询 | ||||||
|  |                 </el-button> | ||||||
|  |               </el-popconfirm> | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|         </el-table> |         </el-table> | ||||||
| @ -155,7 +179,7 @@ | |||||||
|             </el-form-item> |             </el-form-item> | ||||||
|           </el-form> |           </el-form> | ||||||
|           <div slot="footer" class="dialog-footer"> |           <div slot="footer" class="dialog-footer"> | ||||||
|             <el-button type="primary" @click="submitForm">确 定</el-button> |             <el-button type="primary" :loading="loading" @click="submitForm">确 定</el-button> | ||||||
|             <el-button @click="cancel">取 消</el-button> |             <el-button @click="cancel">取 消</el-button> | ||||||
|           </div> |           </div> | ||||||
|         </el-dialog> |         </el-dialog> | ||||||
| @ -165,7 +189,7 @@ | |||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
| import { addTmPlatformAccount, delTmPlatformAccount, getTmPlatformAccount, listTmPlatformAccount, updateTmPlatformAccount } from '@/api/admin/tm-platform-account' | import { addTmPlatformAccount, delTmPlatformAccount, getTmPlatformAccount, listTmPlatformAccount, updateTmPlatformAccount, tmPlatformAccountRemain } from '@/api/admin/tm-platform-account' | ||||||
| import { listTmPlatform } from '@/api/admin/tm-platform' | import { listTmPlatform } from '@/api/admin/tm-platform' | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
| @ -347,6 +371,24 @@ export default { | |||||||
|         } |         } | ||||||
|       }).catch(function() { |       }).catch(function() { | ||||||
|       }) |       }) | ||||||
|  |     }, | ||||||
|  |     /** | ||||||
|  |      * 查询字符余额 | ||||||
|  |      *  */ | ||||||
|  |     handleQueryRemainChars(row) { | ||||||
|  |       this.loading = true | ||||||
|  |  | ||||||
|  |       tmPlatformAccountRemain(row.id).then(response => { | ||||||
|  |         if (response.code === 200) { | ||||||
|  |           this.msgSuccess(response.msg) | ||||||
|  |           this.getList() | ||||||
|  |         } else { | ||||||
|  |           this.msgError(response.msg) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |         .finally(() => { | ||||||
|  |           this.loading = false | ||||||
|  |         }) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -153,7 +153,13 @@ | |||||||
|         <el-dialog :title="title" :visible.sync="open" width="600px"> |         <el-dialog :title="title" :visible.sync="open" width="600px"> | ||||||
|           <el-form ref="form" :model="form" :rules="rules" label-width="120px"> |           <el-form ref="form" :model="form" :rules="rules" label-width="120px"> | ||||||
|             <el-form-item label="平台编码" prop="code"> |             <el-form-item label="平台编码" prop="code"> | ||||||
|               <el-input v-model="form.code" placeholder="平台编码" show-word-limit maxlength="20" :disabled="isEdit" /> |               <el-input | ||||||
|  |                 v-model="form.code" | ||||||
|  |                 placeholder="平台编码" | ||||||
|  |                 show-word-limit | ||||||
|  |                 maxlength="20" | ||||||
|  |                 :disabled="isEdit" | ||||||
|  |               /> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|             <el-form-item label="平台名称" prop="name"> |             <el-form-item label="平台名称" prop="name"> | ||||||
|               <el-input v-model="form.name" placeholder="平台名称" show-word-limit maxlength="20" /> |               <el-input v-model="form.name" placeholder="平台名称" show-word-limit maxlength="20" /> | ||||||
| @ -173,9 +179,22 @@ | |||||||
|             <el-form-item label="单价" prop="price"> |             <el-form-item label="单价" prop="price"> | ||||||
|               <el-input v-model="form.price" placeholder="单价" /> |               <el-input v-model="form.price" placeholder="单价" /> | ||||||
|             </el-form-item> |             </el-form-item> | ||||||
|  |             <el-form-item label="收款链" prop="blockChain"> | ||||||
|  |               <el-select v-model="form.blockChain" placeholder="请选择"> | ||||||
|  |                 <el-option | ||||||
|  |                   v-for="item in blockChainOptions" | ||||||
|  |                   :key="'blockChain'+item.value" | ||||||
|  |                   :label="item.label" | ||||||
|  |                   :value="item.value" | ||||||
|  |                 /> | ||||||
|  |               </el-select> | ||||||
|  |             </el-form-item> | ||||||
|  |             <el-form-item label="钱包地址" prop="receiveAddress"> | ||||||
|  |               <el-input v-model="form.receiveAddress" placeholder="钱包地址" show-word-limit maxlength="100" /> | ||||||
|  |             </el-form-item> | ||||||
|           </el-form> |           </el-form> | ||||||
|           <div slot="footer" class="dialog-footer"> |           <div slot="footer" class="dialog-footer"> | ||||||
|             <el-button type="primary" @click="submitForm">确 定</el-button> |             <el-button type="primary" :loading="loading" @click="submitForm">确 定</el-button> | ||||||
|             <el-button @click="cancel">取 消</el-button> |             <el-button @click="cancel">取 消</el-button> | ||||||
|           </div> |           </div> | ||||||
|         </el-dialog> |         </el-dialog> | ||||||
| @ -215,7 +234,10 @@ export default { | |||||||
|       tmPlatformList: [], |       tmPlatformList: [], | ||||||
|       codeOptions: [], |       codeOptions: [], | ||||||
|       // 关系表类型 |       // 关系表类型 | ||||||
|  |       blockChainOptions: [{ | ||||||
|  |         label: 'TRX', | ||||||
|  |         value: 'trx' | ||||||
|  |       }], | ||||||
|       // 查询参数 |       // 查询参数 | ||||||
|       queryParams: { |       queryParams: { | ||||||
|         pageIndex: 1, |         pageIndex: 1, | ||||||
| @ -226,6 +248,8 @@ export default { | |||||||
|         code: undefined, |         code: undefined, | ||||||
|         character: undefined, |         character: undefined, | ||||||
|         price: undefined, |         price: undefined, | ||||||
|  |         blockChain: 'trx', | ||||||
|  |         receiveAddress: undefined, | ||||||
|         idOrder: 'desc' |         idOrder: 'desc' | ||||||
|       }, |       }, | ||||||
|       // 表单参数 |       // 表单参数 | ||||||
| @ -238,7 +262,9 @@ export default { | |||||||
|         apiBaseUrl: [{ required: true, message: '平台接口地址不能为空', trigger: 'blur' }], |         apiBaseUrl: [{ required: true, message: '平台接口地址不能为空', trigger: 'blur' }], | ||||||
|         code: [{ required: true, message: '平台编码(字典 tm_platform)不能为空', trigger: 'blur' }], |         code: [{ required: true, message: '平台编码(字典 tm_platform)不能为空', trigger: 'blur' }], | ||||||
|         character: [{ required: true, message: '字符数不能为空', trigger: 'blur' }], |         character: [{ required: true, message: '字符数不能为空', trigger: 'blur' }], | ||||||
|         price: [{ required: true, message: '单价不能为空', trigger: 'blur' }] |         price: [{ required: true, message: '单价不能为空', trigger: 'blur' }], | ||||||
|  |         blockChain: [{ required: true, message: '请选择钱包类型', trigger: 'blur' }], | ||||||
|  |         receiveAddress: [{ required: true, message: '钱包地址不能为空', trigger: 'blur' }] | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| @ -275,7 +301,9 @@ export default { | |||||||
|         description: undefined, |         description: undefined, | ||||||
|         code: undefined, |         code: undefined, | ||||||
|         character: undefined, |         character: undefined, | ||||||
|         price: undefined |         price: undefined, | ||||||
|  |         blockChain: 'trx', | ||||||
|  |         receiveAddress: undefined | ||||||
|       } |       } | ||||||
|       this.resetForm('form') |       this.resetForm('form') | ||||||
|     }, |     }, | ||||||
| @ -331,6 +359,9 @@ export default { | |||||||
|     submitForm: function() { |     submitForm: function() { | ||||||
|       this.$refs['form'].validate(valid => { |       this.$refs['form'].validate(valid => { | ||||||
|         if (valid) { |         if (valid) { | ||||||
|  |           this.form.price = Number(this.form.price) | ||||||
|  |           this.form.character = Number(this.form.character) | ||||||
|  |  | ||||||
|           if (this.form.id !== undefined) { |           if (this.form.id !== undefined) { | ||||||
|             updateTmPlatform(this.form).then(response => { |             updateTmPlatform(this.form).then(response => { | ||||||
|               if (response.code === 200) { |               if (response.code === 200) { | ||||||
|  | |||||||
							
								
								
									
										390
									
								
								src/views/admin/tm-recharge-package/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										390
									
								
								src/views/admin/tm-recharge-package/index.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,390 @@ | |||||||
|  |  | ||||||
|  | <template> | ||||||
|  |   <BasicLayout> | ||||||
|  |     <template #wrapper> | ||||||
|  |       <el-card class="box-card"> | ||||||
|  |         <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px"> | ||||||
|  |           <el-form-item label="平台id" prop="platformId"><el-select | ||||||
|  |             v-model="queryParams.platformId" | ||||||
|  |             placeholder="请选择" | ||||||
|  |             clearable | ||||||
|  |             size="small" | ||||||
|  |           > | ||||||
|  |             <el-option | ||||||
|  |               v-for="dict in platformIdOptions" | ||||||
|  |               :key="dict.key" | ||||||
|  |               :label="dict.value" | ||||||
|  |               :value="dict.key" | ||||||
|  |             /> | ||||||
|  |           </el-select> | ||||||
|  |           </el-form-item> | ||||||
|  |           <el-form-item label="状态" prop="status"> | ||||||
|  |             <el-select v-model="queryParams.status" placeholder="请选择" clearable size="small"> | ||||||
|  |               <el-option | ||||||
|  |                 v-for="dict in statusOptions" | ||||||
|  |                 :key="dict.value" | ||||||
|  |                 :label="dict.label" | ||||||
|  |                 :value="dict.value" | ||||||
|  |               /> | ||||||
|  |             </el-select> | ||||||
|  |           </el-form-item> | ||||||
|  |  | ||||||
|  |           <el-form-item> | ||||||
|  |             <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-form-item> | ||||||
|  |         </el-form> | ||||||
|  |  | ||||||
|  |         <el-row :gutter="10" class="mb8"> | ||||||
|  |           <el-col :span="1.5"> | ||||||
|  |             <el-button | ||||||
|  |               v-permisaction="['admin:tmRechargePackage: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:tmRechargePackage:edit']" | ||||||
|  |               type="success" | ||||||
|  |               icon="el-icon-edit" | ||||||
|  |               size="mini" | ||||||
|  |               :disabled="single" | ||||||
|  |               @click="handleUpdate" | ||||||
|  |             >修改 | ||||||
|  |             </el-button> | ||||||
|  |           </el-col> | ||||||
|  |           <el-col :span="1.5"> | ||||||
|  |             <el-button | ||||||
|  |               v-permisaction="['admin:tmRechargePackage:remove']" | ||||||
|  |               type="danger" | ||||||
|  |               icon="el-icon-delete" | ||||||
|  |               size="mini" | ||||||
|  |               :disabled="multiple" | ||||||
|  |               @click="handleDelete" | ||||||
|  |             >删除 | ||||||
|  |             </el-button> | ||||||
|  |           </el-col> | ||||||
|  |         </el-row> | ||||||
|  |  | ||||||
|  |         <el-table v-loading="loading" :data="tmRechargePackageList" @selection-change="handleSelectionChange"> | ||||||
|  |           <el-table-column type="selection" width="55" align="center" /> | ||||||
|  |           <el-table-column label="平台" align="center" prop="platformId" :formatter="platformIdFormat"> | ||||||
|  |             <template slot-scope="scope"> | ||||||
|  |               {{ platformIdFormat(scope.row) }} | ||||||
|  |             </template> | ||||||
|  |           </el-table-column> | ||||||
|  |           <el-table-column | ||||||
|  |             label="套餐金额(U)" | ||||||
|  |             align="center" | ||||||
|  |             prop="amount" | ||||||
|  |             :show-overflow-tooltip="true" | ||||||
|  |           /> | ||||||
|  |           <el-table-column | ||||||
|  |             label="状态" | ||||||
|  |             align="center" | ||||||
|  |             prop="status" | ||||||
|  |             width="100" | ||||||
|  |           > | ||||||
|  |             <template slot-scope="scope"> | ||||||
|  |               {{ statusFormat(scope.row) }} | ||||||
|  |             </template> | ||||||
|  |           </el-table-column> | ||||||
|  |           <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width"> | ||||||
|  |             <template slot-scope="scope"> | ||||||
|  |               <el-popconfirm | ||||||
|  |                 class="delete-popconfirm" | ||||||
|  |                 title="确认要修改吗?" | ||||||
|  |                 confirm-button-text="修改" | ||||||
|  |                 @confirm="handleUpdate(scope.row)" | ||||||
|  |               > | ||||||
|  |                 <el-button | ||||||
|  |                   slot="reference" | ||||||
|  |                   v-permisaction="['admin:tmRechargePackage:edit']" | ||||||
|  |                   size="mini" | ||||||
|  |                   type="text" | ||||||
|  |                   icon="el-icon-edit" | ||||||
|  |                 >修改 | ||||||
|  |                 </el-button> | ||||||
|  |               </el-popconfirm> | ||||||
|  |               <el-popconfirm | ||||||
|  |                 class="delete-popconfirm" | ||||||
|  |                 title="确认要删除吗?" | ||||||
|  |                 confirm-button-text="删除" | ||||||
|  |                 @confirm="handleDelete(scope.row)" | ||||||
|  |               > | ||||||
|  |                 <el-button | ||||||
|  |                   slot="reference" | ||||||
|  |                   v-permisaction="['admin:tmRechargePackage:remove']" | ||||||
|  |                   size="mini" | ||||||
|  |                   type="text" | ||||||
|  |                   icon="el-icon-delete" | ||||||
|  |                 >删除 | ||||||
|  |                 </el-button> | ||||||
|  |               </el-popconfirm> | ||||||
|  |             </template> | ||||||
|  |           </el-table-column> | ||||||
|  |         </el-table> | ||||||
|  |  | ||||||
|  |         <pagination | ||||||
|  |           v-show="total>0" | ||||||
|  |           :total="total" | ||||||
|  |           :page.sync="queryParams.pageIndex" | ||||||
|  |           :limit.sync="queryParams.pageSize" | ||||||
|  |           @pagination="getList" | ||||||
|  |         /> | ||||||
|  |  | ||||||
|  |         <!-- 添加或修改对话框 --> | ||||||
|  |         <el-dialog :title="title" :visible.sync="open" width="500px"> | ||||||
|  |           <el-form ref="form" :model="form" :rules="rules" label-width="100px"> | ||||||
|  |  | ||||||
|  |             <el-form-item label="平台" prop="platformId"> | ||||||
|  |               <el-select | ||||||
|  |                 v-model="form.platformId" | ||||||
|  |                 placeholder="请选择" | ||||||
|  |               > | ||||||
|  |                 <el-option | ||||||
|  |                   v-for="dict in platformIdOptions" | ||||||
|  |                   :key="dict.key" | ||||||
|  |                   :label="dict.value" | ||||||
|  |                   :value="dict.id" | ||||||
|  |                 /> | ||||||
|  |               </el-select> | ||||||
|  |             </el-form-item> | ||||||
|  |             <el-form-item label="套餐金额(U)" prop="amount"> | ||||||
|  |               <el-input | ||||||
|  |                 v-model.number="form.amount" | ||||||
|  |                 placeholder="套餐金额(U)" | ||||||
|  |               /> | ||||||
|  |             </el-form-item> | ||||||
|  |             <el-form-item label="状态" prop="status"> | ||||||
|  |               <el-radio-group v-model="form.status"> | ||||||
|  |                 <el-radio | ||||||
|  |                   v-for="dict in statusOptions" | ||||||
|  |                   :key="dict.value" | ||||||
|  |                   :label="dict.value" | ||||||
|  |                 >{{ dict.label }}</el-radio> | ||||||
|  |               </el-radio-group> | ||||||
|  |             </el-form-item> | ||||||
|  |           </el-form> | ||||||
|  |           <div slot="footer" class="dialog-footer"> | ||||||
|  |             <el-button type="primary" @click="submitForm">确 定</el-button> | ||||||
|  |             <el-button @click="cancel">取 消</el-button> | ||||||
|  |           </div> | ||||||
|  |         </el-dialog> | ||||||
|  |       </el-card> | ||||||
|  |     </template> | ||||||
|  |   </BasicLayout> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | import { addTmRechargePackage, delTmRechargePackage, getTmRechargePackage, listTmRechargePackage, updateTmRechargePackage } from '@/api/admin/tm-recharge-package' | ||||||
|  |  | ||||||
|  | import { listTmPlatform } from '@/api/admin/tm-platform' | ||||||
|  | export default { | ||||||
|  |   name: 'TmRechargePackage', | ||||||
|  |   components: { | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       // 遮罩层 | ||||||
|  |       loading: true, | ||||||
|  |       // 选中数组 | ||||||
|  |       ids: [], | ||||||
|  |       // 非单个禁用 | ||||||
|  |       single: true, | ||||||
|  |       // 非多个禁用 | ||||||
|  |       multiple: true, | ||||||
|  |       // 总条数 | ||||||
|  |       total: 0, | ||||||
|  |       // 弹出层标题 | ||||||
|  |       title: '', | ||||||
|  |       // 是否显示弹出层 | ||||||
|  |       open: false, | ||||||
|  |       isEdit: false, | ||||||
|  |       // 类型数据字典 | ||||||
|  |       typeOptions: [], | ||||||
|  |       tmRechargePackageList: [], | ||||||
|  |       statusOptions: [{ | ||||||
|  |         value: 1, | ||||||
|  |         label: '启用' | ||||||
|  |       }, { | ||||||
|  |         value: 2, | ||||||
|  |         label: '禁用' | ||||||
|  |       }], | ||||||
|  |       // 关系表类型 | ||||||
|  |       platformIdOptions: [], | ||||||
|  |  | ||||||
|  |       // 查询参数 | ||||||
|  |       queryParams: { | ||||||
|  |         pageIndex: 1, | ||||||
|  |         pageSize: 10, | ||||||
|  |         platformId: undefined, | ||||||
|  |         status: undefined | ||||||
|  |  | ||||||
|  |       }, | ||||||
|  |       // 表单参数 | ||||||
|  |       form: { | ||||||
|  |       }, | ||||||
|  |       // 表单校验 | ||||||
|  |       rules: { platformId: [{ required: true, message: '平台不能为空', trigger: 'blur' }], | ||||||
|  |         status: [{ required: true, message: '状态不能为空', trigger: 'blur' }], | ||||||
|  |         amount: [{ required: true, message: '套餐金额不能为空', trigger: 'blur' }] | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   created() { | ||||||
|  |     this.getList() | ||||||
|  |     this.getTmPlatformItems() | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     statusFormat(row) { | ||||||
|  |       const status = this.statusOptions.find(item => item.value === row.status) | ||||||
|  |       return status ? status.label : '' | ||||||
|  |     }, | ||||||
|  |     /** 查询参数列表 */ | ||||||
|  |     getList() { | ||||||
|  |       this.loading = true | ||||||
|  |       listTmRechargePackage(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||||||
|  |         this.tmRechargePackageList = response.data.list | ||||||
|  |         this.total = response.data.count | ||||||
|  |         this.loading = false | ||||||
|  |       } | ||||||
|  |       ) | ||||||
|  |     }, | ||||||
|  |     // 取消按钮 | ||||||
|  |     cancel() { | ||||||
|  |       this.open = false | ||||||
|  |       this.reset() | ||||||
|  |     }, | ||||||
|  |     // 表单重置 | ||||||
|  |     reset() { | ||||||
|  |       this.form = { | ||||||
|  |  | ||||||
|  |         id: undefined, | ||||||
|  |         platformId: undefined, | ||||||
|  |         amount: undefined, | ||||||
|  |         status: undefined | ||||||
|  |       } | ||||||
|  |       this.resetForm('form') | ||||||
|  |     }, | ||||||
|  |     getImgList: function() { | ||||||
|  |       this.form[this.fileIndex] = this.$refs['fileChoose'].resultList[0].fullUrl | ||||||
|  |     }, | ||||||
|  |     fileClose: function() { | ||||||
|  |       this.fileOpen = false | ||||||
|  |     }, | ||||||
|  |     platformIdFormat(row) { | ||||||
|  |       return this.selectItemsLabel(this.platformIdOptions, row.platformId) | ||||||
|  |     }, | ||||||
|  |     // 关系 | ||||||
|  |     getTmPlatformItems() { | ||||||
|  |       this.getItems(listTmPlatform, undefined).then(res => { | ||||||
|  |         const items = this.setItems(res, 'id', 'name') | ||||||
|  |         this.platformIdOptions = items.map(item => ({ | ||||||
|  |           ...item, // 复制所有现有属性 | ||||||
|  |           id: parseInt(item.key, 10) // 将 id 属性转换为整数 | ||||||
|  |         })) | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     // 文件 | ||||||
|  |     /** 搜索按钮操作 */ | ||||||
|  |     handleQuery() { | ||||||
|  |       this.queryParams.pageIndex = 1 | ||||||
|  |       this.getList() | ||||||
|  |     }, | ||||||
|  |     /** 重置按钮操作 */ | ||||||
|  |     resetQuery() { | ||||||
|  |       this.dateRange = [] | ||||||
|  |       this.resetForm('queryForm') | ||||||
|  |       this.handleQuery() | ||||||
|  |     }, | ||||||
|  |     /** 新增按钮操作 */ | ||||||
|  |     handleAdd() { | ||||||
|  |       this.reset() | ||||||
|  |       this.open = true | ||||||
|  |       this.title = '添加充值套餐' | ||||||
|  |       this.isEdit = false | ||||||
|  |     }, | ||||||
|  |     // 多选框选中数据 | ||||||
|  |     handleSelectionChange(selection) { | ||||||
|  |       this.ids = selection.map(item => item.id) | ||||||
|  |       this.single = selection.length !== 1 | ||||||
|  |       this.multiple = !selection.length | ||||||
|  |     }, | ||||||
|  |     /** 修改按钮操作 */ | ||||||
|  |     handleUpdate(row) { | ||||||
|  |       this.reset() | ||||||
|  |       const id = | ||||||
|  |                 row.id || this.ids | ||||||
|  |       getTmRechargePackage(id).then(response => { | ||||||
|  |         this.form = response.data | ||||||
|  |         this.open = true | ||||||
|  |         this.title = '修改tm_recharge_package' | ||||||
|  |         this.isEdit = true | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     /** 提交按钮 */ | ||||||
|  |     submitForm: function() { | ||||||
|  |       this.$refs['form'].validate(valid => { | ||||||
|  |         if (valid) { | ||||||
|  |           this.loading = true | ||||||
|  |           this.form.platformId = Number(this.form.platformId) | ||||||
|  |  | ||||||
|  |           if (this.form.id !== undefined) { | ||||||
|  |             updateTmRechargePackage(this.form).then(response => { | ||||||
|  |               if (response.code === 200) { | ||||||
|  |                 this.msgSuccess(response.msg) | ||||||
|  |                 this.open = false | ||||||
|  |                 this.getList() | ||||||
|  |               } else { | ||||||
|  |                 this.msgError(response.msg) | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |               .finally(() => { | ||||||
|  |                 this.loading = false | ||||||
|  |               }) | ||||||
|  |           } else { | ||||||
|  |             addTmRechargePackage(this.form).then(response => { | ||||||
|  |               if (response.code === 200) { | ||||||
|  |                 this.msgSuccess(response.msg) | ||||||
|  |                 this.open = false | ||||||
|  |                 this.getList() | ||||||
|  |               } else { | ||||||
|  |                 this.msgError(response.msg) | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |               .finally(() => { | ||||||
|  |                 this.loading = false | ||||||
|  |               }) | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     /** 删除按钮操作 */ | ||||||
|  |     handleDelete(row) { | ||||||
|  |       var Ids = (row.id && [row.id]) || this.ids | ||||||
|  |  | ||||||
|  |       this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', '警告', { | ||||||
|  |         confirmButtonText: '确定', | ||||||
|  |         cancelButtonText: '取消', | ||||||
|  |         type: 'warning' | ||||||
|  |       }).then(function() { | ||||||
|  |         return delTmRechargePackage({ 'ids': Ids }) | ||||||
|  |       }).then((response) => { | ||||||
|  |         if (response.code === 200) { | ||||||
|  |           this.msgSuccess(response.msg) | ||||||
|  |           this.open = false | ||||||
|  |           this.getList() | ||||||
|  |         } else { | ||||||
|  |           this.msgError(response.msg) | ||||||
|  |         } | ||||||
|  |       }).catch(function() { | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
		Reference in New Issue
	
	Block a user