index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <div class="system-container">
  3. <el-card class="type-box">
  4. <div slot="header" class="clearfix card-title">
  5. <span>Test</span>
  6. </div>
  7. <el-radio-group v-model="formData.appType" @input="searchTable">
  8. <el-radio-button label="">All</el-radio-button>
  9. <el-radio-button v-for="item in typeData" :key="item.id" :label="item.value">{{ item.label }}</el-radio-button>
  10. </el-radio-group>
  11. </el-card>
  12. <div class="system-box">
  13. <div class="list-filter">
  14. <el-form ref="filterForm" :model="formData" inline>
  15. <el-form-item label="name">
  16. <el-input v-model="formData.systemName" class="filter-item" clearable />
  17. </el-form-item>
  18. <el-form-item label="name2">
  19. <el-input v-model="formData.deptName" class="filter-item" clearable />
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" @click="searchTable">Search</el-button>
  23. </el-form-item>
  24. </el-form>
  25. </div>
  26. <div class="list-button">
  27. <el-button type="primary" @click="showEdit('ADD')">Add</el-button>
  28. <el-upload action="" class="upload-btn">
  29. <el-button>Upload</el-button>
  30. </el-upload>
  31. </div>
  32. <div v-loading="loading" class="list-box">
  33. <el-scrollbar class="list-scrollbar">
  34. <div class="system-item-box">
  35. <div v-for="item in tableData" :key="item.id" class="system-item">
  36. <div class="item-header">
  37. <div class="item-type">{{ formatDictData(item.appType) }}</div>
  38. <div class="item-btn">
  39. <el-button type="text" @click="showEdit('VIEW', item)">Detail</el-button>
  40. <el-button type="text" @click="showEdit('EDIT', item)">Edit</el-button>
  41. <el-button type="text" @click="deleteSystem(item.id)">Delete</el-button>
  42. </div>
  43. </div>
  44. <div class="item-content">
  45. <div class="item-content-left">
  46. <el-avatar :size="56" :src="item.icon" />
  47. <span class="item-name">{{ item.systemName }}</span>
  48. </div>
  49. <el-button class="item-link" size="small" @click="jumpTo(item.url)">Open</el-button>
  50. </div>
  51. <div class="item-footer">{{ item.deptName }}</div>
  52. </div>
  53. </div>
  54. </el-scrollbar>
  55. <div v-if="total > 0" class="page">
  56. <el-pagination
  57. layout="total, prev, pager, next, jumper"
  58. :current-page="current"
  59. :total="total"
  60. :page-sizes="pageSizeAll"
  61. :page-size="size"
  62. @size-change="handleSizeChange"
  63. @current-change="handleCurrentChange"
  64. />
  65. </div>
  66. </div>
  67. </div>
  68. <system-detail ref="systemDetail" :type-data="typeData" />
  69. </div>
  70. </template>
  71. <script>
  72. import SystemDetail from './components/SystemDetail'
  73. import { fetchDictData } from '@/api/dict'
  74. import { fetchAllSystemList, pushDeleteSystem } from '@/api/system'
  75. import { hasValidRecords, formatDictData, isNull } from '@/utils/convert'
  76. export default {
  77. components: { SystemDetail },
  78. data() {
  79. return {
  80. // type
  81. dictType: 'app_type',
  82. typeData: [],
  83. // table
  84. current: 1,
  85. size: 16,
  86. total: 0,
  87. pageSizeAll: [10, 20, 50, 100, 200, 500],
  88. tableData: [],
  89. // filter
  90. formData: {
  91. appType: '',
  92. systemName: '',
  93. deptName: ''
  94. },
  95. // others
  96. loading: false
  97. }
  98. },
  99. created() {
  100. this.getTypeData()
  101. this.searchTable()
  102. },
  103. methods: {
  104. // 改变每页显示条数
  105. handleSizeChange(val) {
  106. this.current = 1
  107. this.size = val
  108. this.getTablelist()
  109. },
  110. // 切换第几页
  111. handleCurrentChange(val) {
  112. this.current = val
  113. this.getTablelist()
  114. },
  115. // 重置搜索项
  116. resetTable(formName) {
  117. this.$refs[formName].resetFields()
  118. this.getTablelist()
  119. },
  120. // 点击搜索按钮
  121. searchTable() {
  122. this.current = 1
  123. this.getTablelist()
  124. },
  125. // 获取table数据
  126. getTablelist() {
  127. this.loading = true
  128. const params = {
  129. page: this.current,
  130. size: this.size,
  131. params: {
  132. delFlag: 0,
  133. appType: this.formData.appType,
  134. systemName: this.formData.systemName,
  135. deptName: this.formData.deptName
  136. }
  137. }
  138. fetchAllSystemList(params).then(response => {
  139. this.loading = false
  140. if (hasValidRecords(response)) {
  141. this.tableData = response.data.records
  142. this.total = response.data.total
  143. } else {
  144. this.tableData = []
  145. this.total = 0
  146. }
  147. }).catch(error => {
  148. console.log(error)
  149. this.loading = false
  150. this.$message.error({
  151. type: 'error',
  152. duration: 0,
  153. showClose: true,
  154. message: ': ' + error.message
  155. })
  156. })
  157. },
  158. jumpTo(link) {
  159. window.open(link, '_blank')
  160. },
  161. showEdit(type, data) {
  162. this.$refs.systemDetail.open(type, data)
  163. },
  164. deleteSystem(id) {
  165. this.loading = true
  166. pushDeleteSystem(id).then(res => {
  167. this.getTablelist()
  168. }).catch(error => {
  169. console.log(error)
  170. this.loading = false
  171. this.$message.error({
  172. type: 'error',
  173. duration: 0,
  174. showClose: true,
  175. message: ': ' + error.message
  176. })
  177. })
  178. },
  179. getTypeData() {
  180. fetchDictData(this.dictType).then(response => {
  181. if (!isNull(response.data)) {
  182. this.typeData = response.data
  183. } else {
  184. this.typeData = []
  185. }
  186. }).catch(error => {
  187. console.log(error)
  188. this.$message.error({
  189. type: 'error',
  190. duration: 0,
  191. showClose: true,
  192. message: '获取应用类型出错: ' + error.message
  193. })
  194. })
  195. },
  196. formatDictData(type) {
  197. return formatDictData(this.typeData, type)
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="scss" scoped>
  203. .system-container {
  204. display: flex;
  205. .type-box {
  206. width: 230px;
  207. min-width: 230px;
  208. margin-right: 5px;
  209. .el-radio-group {
  210. width: 100%;
  211. }
  212. .el-radio-button {
  213. display: block;
  214. }
  215. ::v-deep {
  216. .el-card__header {
  217. height: 60px;
  218. }
  219. .el-card__body {
  220. padding: 20px 0;
  221. }
  222. .el-radio-button__inner {
  223. width: 100%;
  224. border: 0;
  225. text-align: left;
  226. }
  227. .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  228. background-color: #ebf2fd;
  229. color: #0056dd;
  230. }
  231. }
  232. }
  233. .card-title {
  234. font-size: 18px;
  235. line-height: 24px;
  236. color: rgba(0,0,0,0.85);
  237. font-weight: bold;
  238. }
  239. .system-box {
  240. padding-left: 20px;
  241. background-color: #fff;
  242. width: 100%;
  243. height: 100%;
  244. .upload-btn {
  245. display: inline-block;
  246. margin-left: 10px;
  247. }
  248. .page {
  249. margin-right: 20px;
  250. text-align: right;
  251. }
  252. ::v-deep {
  253. .el-scrollbar__wrap{
  254. overflow-x: hidden;
  255. }
  256. .el-scrollbar__bar.is-horizontal {
  257. display: none;
  258. }
  259. }
  260. }
  261. .list-filter {
  262. height: 60px;
  263. width: 800px;
  264. padding-top: 10px;
  265. }
  266. .list-button {
  267. height: 50px;
  268. }
  269. .list-box {
  270. min-width: 800px;
  271. height: calc(100% - 110px);
  272. }
  273. .list-scrollbar {
  274. height: calc(100% - 32px);
  275. }
  276. .system-item-box {
  277. display: flex;
  278. flex-wrap: wrap;
  279. }
  280. .system-item {
  281. width: 380px;
  282. height: 150px;
  283. border: 1px solid rgba(0,0,0,0.09);
  284. border-radius: 4px;
  285. margin-right: 16px;
  286. margin-bottom: 16px;
  287. padding: 0 10px 10px 10px;
  288. display: flex;
  289. flex-direction: column;
  290. justify-content: space-between;
  291. .item-header {
  292. height: 35px;
  293. }
  294. .item-type, .item-btn {
  295. height: 100%;
  296. }
  297. .item-type {
  298. display: inline-block;
  299. font-size: 14px;
  300. line-height: 35px;
  301. color: rgba(0,0,0,0.65);
  302. }
  303. .item-btn {
  304. float: right;
  305. }
  306. .item-content {
  307. display: flex;
  308. justify-content: space-between;
  309. align-items: center;
  310. }
  311. .item-content-left {
  312. display: flex;
  313. align-items: center;
  314. }
  315. .item-name {
  316. font-size: 14px;
  317. color: rgba(0,0,0,0.85);
  318. margin-left: 10px;
  319. display: inline-block;
  320. width: 230px;
  321. text-overflow: ellipsis;
  322. overflow: hidden;
  323. white-space: nowrap;
  324. }
  325. .item-link {
  326. float: right;
  327. }
  328. .item-footer {
  329. font-size: 12px;
  330. color: rgba(0,0,0,0.65);
  331. }
  332. ::v-deep {
  333. .el-button--small {
  334. font-size: 14px;
  335. }
  336. }
  337. }
  338. }
  339. </style>