index.vue 9.6 KB

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