index.vue 8.1 KB

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