index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <el-container class="content-height-fit">
  3. <el-container class="resize-fit-container">
  4. <div class="app-container">
  5. <div class="filter-container blue-top-border">
  6. <el-input
  7. v-model="listQuery.deviceNo"
  8. placeholder="客户端ID"
  9. class="filter-item"
  10. clearable
  11. @change="getList"
  12. />
  13. <el-button
  14. v-waves
  15. class="filter-item"
  16. type="primary"
  17. icon="el-icon-search"
  18. size="small"
  19. @click="handleFilter"
  20. >查询</el-button>
  21. <el-button
  22. v-waves
  23. class="filter-item"
  24. type="primary"
  25. icon="el-icon-edit"
  26. size="small"
  27. @click="handleCreate"
  28. >新增</el-button>
  29. <el-button
  30. v-waves
  31. class="filter-item"
  32. type="primary"
  33. icon="el-icon-edit"
  34. size="small"
  35. >下载加密文件</el-button>
  36. </div>
  37. <div class="content-container">
  38. <el-table
  39. v-loading="listLoading"
  40. row-key="id"
  41. :data="list"
  42. border
  43. fit
  44. highlight-current-row
  45. style="width: 100%"
  46. height="calc(100vh - 276px)"
  47. >
  48. <el-table-column label="序号" type="index" width="50" align="center" />
  49. <el-table-column label="客户端key" prop="deviceNo" :show-overflow-tooltip="true" align="center" />
  50. <el-table-column label="客户端Secret" prop="deviceName" :show-overflow-tooltip="true" align="center" />
  51. <el-table-column label="过期时间" prop="categoryName" :show-overflow-tooltip="true" align="center" />
  52. <el-table-column
  53. label="操作"
  54. align="center"
  55. width="110"
  56. class-name="small-padding fixed-width"
  57. >
  58. <template slot-scope="{ row }">
  59. <el-button
  60. type="primary"
  61. size="mini"
  62. @click="handleUpdate(row)"
  63. >修改</el-button>
  64. <el-button
  65. size="mini"
  66. type="danger"
  67. @click="handleDelete(row)"
  68. >删除</el-button>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </div>
  73. <el-dialog
  74. title="创建客户端凭证"
  75. :close-on-click-modal="false"
  76. :visible.sync="dialogFormVisible"
  77. >
  78. <el-form
  79. ref="dataForm"
  80. v-loading="formLoading"
  81. :rules="rules"
  82. :model="entity"
  83. label-position="right"
  84. label-width="120px"
  85. >
  86. <el-row :gutter="16">
  87. <el-col :span="12">
  88. <el-form-item label="客户端key" prop="client_key">
  89. <el-input v-model="entity.deviceNo" :show-overflow-tooltip="true" />
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row :gutter="16">
  94. <el-col :span="12">
  95. <el-form-item label="客户端Secret" prop="client_secret">
  96. <el-input v-model="entity.deviceName" :show-overflow-tooltip="true" />
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="12">
  100. <el-form-item label="过期时间" prop="expires_in">
  101. <el-select v-model="entity.deviceType" class="w100p">
  102. <el-option
  103. v-for="item in deviceTypes"
  104. :key="item.key"
  105. :value="item.key"
  106. :label="item.name"
  107. />
  108. </el-select>
  109. </el-form-item>
  110. </el-col>
  111. </el-row>
  112. </el-form>
  113. <div slot="footer" class="dialog-footer">
  114. <el-button
  115. :disabled="formLoading"
  116. @click="dialogFormVisible = false"
  117. >取消</el-button>
  118. <el-button
  119. :disabled="formLoading"
  120. type="primary"
  121. @click="dialogStatus === 'create' ? createData() : updateData()"
  122. >确认</el-button>
  123. </div>
  124. </el-dialog>
  125. </div>
  126. </el-container>
  127. </el-container>
  128. </template>
  129. <script>
  130. import * as clientSettingApi from '@/api/client-setting'
  131. import waves from '@/directive/waves' // waves directive
  132. export default {
  133. name: 'DeviceMng',
  134. directives: { waves },
  135. data() {
  136. return {
  137. list: [],
  138. entity: {},
  139. total: 0,
  140. listLoading: false,
  141. listQuery: {
  142. skipCount: 0,
  143. maxResultCount: 20
  144. },
  145. dialogFormVisible: false,
  146. formLoading: false,
  147. rules: {
  148. client_key: [
  149. { required: true, message: '请输入客户端Key', trigger: 'blur' },
  150. { max: 32, message: '长度必须少于32个字符', trigger: 'blur' }
  151. ],
  152. client_secret: [
  153. { required: true, message: '请输入客户端', trigger: 'blur' },
  154. { max: 64, message: '长度必须少于64个字符', trigger: 'blur' }
  155. ],
  156. expires_in: [
  157. { required: true, message: '请输入过期时间', trigger: 'blur' }
  158. ]
  159. }
  160. }
  161. },
  162. mounted() {
  163. this.getList()
  164. },
  165. methods: {
  166. // 查询
  167. handleFilter() {
  168. this.listQuery.skipCount = 0
  169. this.getList()
  170. },
  171. // // 创建清空
  172. // resetStation() {
  173. // this.entity = {
  174. // id: undefined,
  175. // projectId: this.listQuery.projectId,
  176. // sectionId: this.listQuery.sectionId,
  177. // sectionAreaId: this.listQuery.sectionAreaId,
  178. // deviceNo: '',
  179. // deviceName: '',
  180. // category: undefined,
  181. // categoryName: '',
  182. // spec: '',
  183. // madeFactory: '',
  184. // driverName: '',
  185. // telephone: '',
  186. // deviceType: undefined
  187. // }
  188. // },
  189. // 创建点击事件
  190. handleCreate() {
  191. this.resetStation()
  192. this.dialogStatus = 'create'
  193. this.dialogFormVisible = true
  194. this.formLoading = false
  195. this.entity = {}
  196. this.$nextTick(() => {
  197. this.$refs['dataForm'].clearValidate()
  198. })
  199. },
  200. // 创建
  201. createData() {
  202. this.$refs['dataForm'].validate(valid => {
  203. if (valid) {
  204. this.formLoading = true
  205. clientSettingApi
  206. .create(this.entity)
  207. .then(() => {
  208. this.getList()
  209. this.dialogFormVisible = false
  210. this.$notify({
  211. title: '成功',
  212. message: '创建成功',
  213. type: 'success',
  214. duration: 2000
  215. })
  216. })
  217. .finally(() => {
  218. this.formLoading = false
  219. })
  220. }
  221. })
  222. },
  223. // 删除
  224. handleDelete(row) {
  225. this.$confirm('此操作将删除该项, 是否继续?', '提示', {
  226. confirmButtonText: '确定',
  227. cancelButtonText: '取消',
  228. type: 'warning'
  229. }).then(() => {
  230. this.listLoading = true
  231. clientSettingApi
  232. .remove(row.id)
  233. .then(() => {
  234. this.getList()
  235. this.$notify({
  236. title: '成功',
  237. message: '删除成功',
  238. type: 'success',
  239. duration: 2000
  240. })
  241. })
  242. .finally(() => {
  243. this.listLoading = false
  244. })
  245. })
  246. }
  247. }
  248. }
  249. </script>
  250. <style scoped>
  251. .number >>> input{
  252. text-align: left !important;
  253. }
  254. .el-selects >>> .el-input--suffix{
  255. width: 150px !important;
  256. }
  257. </style>