accountList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="account-list-page">
  3. <el-button
  4. type="primary"
  5. @click="showEditAccount=true;activeTermId=0;initData={}"
  6. v-permission="permissionBtn.dataSourcePermission.dataSource_account_add"
  7. >{{$t('SystemManage.DataSourceAccount.add_btn')}}</el-button>
  8. <el-table
  9. style="margin-top:30px"
  10. :data="tableData"
  11. border
  12. >
  13. <el-table-column
  14. v-for="col in tableColOpts"
  15. :key="col.key"
  16. :label="col.name"
  17. :prop="col.key"
  18. :sortable="col.sortable"
  19. align="center"
  20. >
  21. <template slot-scope="scope">
  22. <span
  23. v-if="col.key==='Status'"
  24. :style="{color:scope.row.Status===1?'':'#FF0000'}"
  25. >{{scope.row.Status===1?$t('Common.enable'):$t('Common.disable')}}</span>
  26. <span v-else>{{scope.row[col.key]}}</span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column :label="$t('Table.column_operations')" align="center" width="100">
  30. <template slot-scope="scope">
  31. <span
  32. style="color:#409EFF;cursor: pointer;"
  33. @click="handleEditAccount(scope.row)"
  34. v-permission="permissionBtn.dataSourcePermission.dataSource_account_edit"
  35. >{{$t('Table.edit_btn')}}</span>
  36. <span
  37. style="color:#409EFF;cursor: pointer;"
  38. @click="handleSetAccountStatus(scope.row,2)"
  39. v-if="scope.row.Status===1"
  40. v-permission="permissionBtn.dataSourcePermission.dataSource_account_enable"
  41. >{{$t('Common.disable')}}</span>
  42. <span
  43. style="color:#409EFF;cursor: pointer;"
  44. @click="handleSetAccountStatus(scope.row,1)"
  45. v-if="scope.row.Status===2"
  46. v-permission="permissionBtn.dataSourcePermission.dataSource_account_enable"
  47. >{{$t('Common.enable')}}</span>
  48. </template>
  49. </el-table-column>
  50. <div slot="empty">
  51. <tableNoData :text="$t('Table.prompt_slogan')"/>
  52. </div>
  53. </el-table>
  54. <!-- 新增/编辑终端账号 -->
  55. <EditAccount
  56. v-model="showEditAccount"
  57. :TerminalId="activeTermId"
  58. :initData="initData"
  59. @change="getAccountList"
  60. />
  61. </div>
  62. </template>
  63. <script>
  64. import EditAccount from './components/EditAccount.vue'
  65. import {apiDataSource} from '@/api/modules/dataSource.js'
  66. export default {
  67. components:{EditAccount},
  68. computed:{
  69. tableColOpts(){
  70. return [
  71. {
  72. name:this.$t('SystemManage.DataSourceAccount.table_col01'),
  73. key:'TerminalCode',
  74. },
  75. {
  76. name:this.$t('SystemManage.DataSourceAccount.table_col02'),
  77. key:'Name',
  78. },
  79. {
  80. name:this.$t('SystemManage.DataSourceAccount.table_col03'),
  81. key:'DirPath',
  82. },
  83. {
  84. name:this.$t('SystemManage.DataSourceAccount.table_col04'),
  85. key:'ServerUrl',
  86. },
  87. {
  88. name:this.$t('SystemManage.DataSourceAccount.table_col05'),
  89. key:'Value',
  90. },
  91. {
  92. name:this.$t('SystemManage.DataSourceAccount.table_col06'),
  93. key:'Source',
  94. },
  95. {
  96. name:this.$t('SystemManage.DataSourceAccount.table_col07'),
  97. key:'Status',
  98. },
  99. {
  100. name:this.$t('SystemManage.DataSourceAccount.table_col08'),
  101. key:'Num',
  102. },
  103. {
  104. name:this.$t('SystemManage.DataSourceAccount.table_col09'),
  105. key:'ModifyTime',
  106. sortable:true
  107. },
  108. ]
  109. }
  110. },
  111. data() {
  112. return {
  113. tableData:[],
  114. showEditAccount:false,
  115. activeTermId:0,
  116. initData:{},
  117. }
  118. },
  119. created() {
  120. this.getAccountList()
  121. },
  122. methods: {
  123. async getAccountList(){
  124. const res=await apiDataSource.accountList({})
  125. if(res.Ret===200){
  126. const arr=res.Data.List||[]
  127. this.tableData=arr
  128. }
  129. },
  130. // 点击编辑账号
  131. handleEditAccount(e){
  132. this.activeTermId=e.TerminalId
  133. this.initData=e
  134. this.showEditAccount=true
  135. },
  136. // 启用/禁用账号
  137. handleSetAccountStatus(e,status){
  138. apiDataSource.accountSet({
  139. TerminalId:e.TerminalId,
  140. Status:status
  141. }).then(res=>{
  142. if(res.Ret===200){
  143. this.$message.success(/* '操作成功' */this.$t('MsgPrompt.operate_success_msg'))
  144. this.getAccountList()
  145. }
  146. })
  147. }
  148. },
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .account-list-page{
  153. padding: 30px;
  154. border-radius: 4px;
  155. border: 1px solid #DCDFE6;
  156. background-color: #fff;
  157. min-height: calc(100vh - 260px);
  158. }
  159. </style>