terminalConfig.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <div class="form-wrap">
  3. <div
  4. class="tableBox"
  5. style="margin-top:30px">
  6. <div class="block-title">
  7. 设备配置/更新
  8. <el-button
  9. type="primary"
  10. @click="activeName ==='配置文件'?openConfigDialog('add'): openApkDialog('add')"
  11. >
  12. {{ activeName ==='配置文件'?'新增配置': '新增apk' }}
  13. </el-button>
  14. <el-tabs v-model="activeName">
  15. <el-tab-pane
  16. label="配置文件"
  17. name="配置文件">
  18. <span slot="label">
  19. 配置文件
  20. <!-- <Tip msg="仅包含窗口的门票销售数据,不包含线上门票的销售数据。"></Tip> -->
  21. </span>
  22. <el-table
  23. border
  24. stripe
  25. ref="multipleTable"
  26. tooltip-effect="dark"
  27. v-loading="loading"
  28. :data="configData">
  29. <el-table-column
  30. prop="id"
  31. label="编号"
  32. width="80"
  33. >
  34. </el-table-column>
  35. <el-table-column
  36. prop="name"
  37. label="名称"
  38. >
  39. </el-table-column>
  40. <el-table-column
  41. prop="download_suffix"
  42. label="文件名"
  43. >
  44. </el-table-column>
  45. <el-table-column
  46. prop="download_url"
  47. label="下载地址"
  48. >
  49. </el-table-column>
  50. <el-table-column
  51. prop="update_time"
  52. label="更新时间"
  53. >
  54. <template slot-scope="scope">
  55. {{ scope.row.update_time | formatTime }}
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. label="操作"
  60. >
  61. <template slot-scope="scope">
  62. <el-link
  63. type="primary"
  64. size="small"
  65. @click="downloadFile(scope.row)"
  66. >
  67. 下载
  68. </el-link>
  69. <el-link
  70. type="primary"
  71. size="small"
  72. @click="openConfigDialog('edit',scope.row)"
  73. >
  74. 更新
  75. </el-link>
  76. <el-link
  77. type="primary"
  78. size="small"
  79. @click="deleteConfig(scope.row.id)"
  80. >
  81. 删除
  82. </el-link>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <el-pagination
  87. background
  88. :current-page.sync="form.pageNum"
  89. :page-size="form.pageSize"
  90. layout="total, prev, pager, next"
  91. @current-change="getConfigList"
  92. :total="total">
  93. </el-pagination>
  94. </el-tab-pane>
  95. <el-tab-pane
  96. label="apk更新"
  97. name="apk更新">
  98. <span slot="label">
  99. apk更新
  100. <!-- <Tip msg="仅包含窗口的门票销售数据,不包含线上门票的销售数据。"></Tip> -->
  101. </span>
  102. <el-table
  103. border
  104. stripe
  105. ref="multipleTable"
  106. tooltip-effect="dark"
  107. v-loading="loading"
  108. :data="apkData">
  109. <el-table-column
  110. prop="id"
  111. label="编号"
  112. width="80"
  113. >
  114. </el-table-column>
  115. <el-table-column
  116. prop="name"
  117. label="名称"
  118. >
  119. </el-table-column>
  120. <el-table-column
  121. prop="download_suffix"
  122. label="文件名"
  123. >
  124. </el-table-column>
  125. <el-table-column
  126. prop="version_name"
  127. label="版本名"
  128. >
  129. </el-table-column>
  130. <el-table-column
  131. prop="download_url"
  132. label="下载地址"
  133. >
  134. </el-table-column>
  135. <el-table-column
  136. prop="update_time"
  137. label="更新时间"
  138. >
  139. <template slot-scope="scope">
  140. {{ scope.row.update_time | formatTime }}
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. label="操作"
  145. >
  146. <template slot-scope="scope">
  147. <el-link
  148. type="primary"
  149. size="small"
  150. @click="downloadFile(scope.row)"
  151. >
  152. 下载
  153. </el-link>
  154. <el-link
  155. type="primary"
  156. size="small"
  157. @click="openApkDialog('edit',scope.row)"
  158. >
  159. 更新
  160. </el-link>
  161. <el-link
  162. type="primary"
  163. size="small"
  164. @click="deleteConfig(scope.row.id)"
  165. >
  166. 删除
  167. </el-link>
  168. </template>
  169. </el-table-column>
  170. </el-table>
  171. <el-pagination
  172. background
  173. :current-page.sync="form1.pageNum"
  174. :page-size="form1.pageSize"
  175. layout="total, prev, pager, next"
  176. @current-change="getApkList"
  177. :total="total1">
  178. </el-pagination>
  179. </el-tab-pane>
  180. </el-tabs>
  181. </div>
  182. </div>
  183. <!-- 配置弹框 -->
  184. <ElDialog
  185. :title="dialogType === 'add' ? '新增配置' : '编辑配置'"
  186. width="1000px"
  187. v-model="configDialogVisible"
  188. >
  189. <ConfigSetting
  190. @update="getConfigList"
  191. :config-info="configInfo"
  192. :dialog-type="dialogType"></ConfigSetting>
  193. </ElDialog>
  194. <!-- Apk弹窗 -->
  195. <DialogEdit
  196. @update="getApkList"
  197. ref="dialog"></DialogEdit>
  198. </div>
  199. </template>
  200. <script>
  201. import ConfigSetting from './terminalConfig/ConfigSetting.vue'
  202. import { deleteTicketInventory } from '@/api/ticketInventory'
  203. import { getTerminalConfigList, deleteTerminalConfig } from '@/api/terminalConfig'
  204. import ElDialog from '@/components/Dialog'
  205. import DialogEdit from './terminalConfig/DialogEdit'
  206. export default {
  207. components: {
  208. ElDialog,
  209. ConfigSetting,
  210. DialogEdit
  211. },
  212. data () {
  213. return {
  214. configDialogVisible: false,
  215. configInfo: null,
  216. dialogType: '', // 编辑or新增
  217. form: {
  218. type: 'CONFIG_FILE',
  219. pageNum: 1,
  220. pageSize: 10
  221. },
  222. form1: {
  223. type: 'APK_FILE',
  224. pageNum: 1,
  225. pageSize: 10
  226. },
  227. total: 0,
  228. total1: 0,
  229. apkData: [],
  230. configData: [],
  231. loading: false,
  232. activeName: '配置文件'
  233. }
  234. },
  235. computed: {
  236. userId () {
  237. return this.$store.state.user.id
  238. }
  239. },
  240. created () {
  241. this.getConfigList()
  242. },
  243. methods: {
  244. // 打开配置弹窗
  245. openConfigDialog (type, item) {
  246. this.configInfo = item
  247. this.configDialogVisible = true
  248. this.dialogType = type
  249. },
  250. // 打开Apk配置弹窗
  251. openApkDialog (type, item) {
  252. this.$refs.dialog.show(type, item)
  253. },
  254. // 更新列表
  255. updateList () {
  256. this.activeName === '配置文件' ? this.getConfigList() : this.getApkList()
  257. },
  258. // 删除设备
  259. deleteConfig (id) {
  260. this.$confirm('确定删除?', '提示', {
  261. confirmButtonText: '确定',
  262. cancelButtonText: '取消',
  263. type: 'warning'
  264. }).then(() => {
  265. deleteTerminalConfig(id).then(() => {
  266. this.$message.success('删除成功')
  267. this.updateList()
  268. })
  269. })
  270. },
  271. // 下载
  272. downloadFile (data) {
  273. if (!data.download_url) {
  274. this.$message.error('暂无下载地址')
  275. return
  276. }
  277. let url = ''
  278. if (this.transformUrl) {
  279. const urlObj = new URL(data.download_url)
  280. const localObj = new URL(this.$localStore.get('serverUrl'))
  281. urlObj.hostname = localObj.hostname
  282. urlObj.protocol = localObj.protocol
  283. urlObj.port = localObj.port || '80'
  284. url = urlObj.href
  285. } else {
  286. url = data.download_url
  287. }
  288. const Store = require('electron-store')
  289. const localStore = new Store()
  290. const serverUrl = localStore.get('serverUrl') // 服务器地址
  291. const newUrl = serverUrl + url.split('.cn')[1]
  292. window.location.href = newUrl
  293. // require('electron').ipcRenderer.send('download', newUrl)
  294. },
  295. getApkList () {
  296. this.loading = true
  297. let params = JSON.parse(JSON.stringify(this.form1))
  298. getTerminalConfigList(params).then(res => {
  299. this.apkData = res.list
  300. this.total1 = res.total
  301. }).finally(() => {
  302. this.loading = false
  303. })
  304. },
  305. // 获取配置列表
  306. getConfigList () {
  307. this.loading = true
  308. let params = JSON.parse(JSON.stringify(this.form))
  309. getTerminalConfigList(params).then(res => {
  310. this.configData = res.list
  311. console.log('我更新了')
  312. this.total = res.total
  313. }).finally(() => {
  314. this.loading = false
  315. })
  316. },
  317. reset () {
  318. this.$refs.form.resetFields()
  319. },
  320. handleDelete (id) {
  321. this.$confirm('确认删除吗', '提示', {
  322. confirmButtonText: '确定',
  323. cancelButtonText: '取消',
  324. type: 'warning'
  325. }).then(() => {
  326. deleteTicketInventory(id).then(res => {
  327. this.$message.success('删除成功')
  328. this.getConfigList()
  329. })
  330. }).catch(() => {})
  331. }
  332. },
  333. watch: {
  334. activeName (val) {
  335. if (val === 'apk更新') {
  336. this.getApkList()
  337. } else {
  338. this.getConfigList()
  339. }
  340. }
  341. }
  342. }
  343. </script>
  344. <style lang="scss" scoped>
  345. .form-wrap {
  346. .el-input,.el-select,.el-date-editor,.el-date-editor.el-input,.el-input-number {
  347. width: 300px;
  348. }
  349. }
  350. </style>