index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="content-container">
  3. <el-row class="tool-bar">
  4. <el-col :span="12" class="left">
  5. <div class="page-title">
  6. 行业管理
  7. </div>
  8. </el-col>
  9. <el-col :span="12" class="right">
  10. <el-input v-model="conditions.keywords" class="search-input m-right-15" placeholder="请输入内容">
  11. <el-button slot="append" icon="el-icon-search" @click="getData()" />
  12. </el-input>
  13. <el-button type="primary" @click="handleAddRoot">添加</el-button>
  14. </el-col>
  15. </el-row>
  16. <el-row class="content-body">
  17. <el-table
  18. v-loading="listLoading"
  19. class="page-table"
  20. height="calc(100vh - 180px)"
  21. row-key="industryId"
  22. :default-expand-all="tableExpandAllStatus"
  23. :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
  24. :data="dataList"
  25. >
  26. <el-table-column type="selection" width="50" align="center" />
  27. <el-table-column type="index" align="center" label="序号" width="70" />
  28. <el-table-column width="350px" align="left" header-align="center" label="行业名称">
  29. <template v-slot="{row}">
  30. <span>{{ row.industryName }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column width="200px" label="类型" align="center" header-align="center">
  34. <template v-slot="{row}">
  35. <span>{{ row.industryTypeTitle }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column width="250" label="行业代码" align="center" header-align="center">
  39. <template v-slot="{row}">
  40. <span>{{ row.industryCode }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="说明" align="left" header-align="left">
  44. <template v-slot="{row}">
  45. <span>{{ row.industryDesc }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" width="300" align="center">
  49. <template v-slot="{row}">
  50. <el-button size="mini" @click="handleEdit(row)">修改</el-button>
  51. <el-button size="mini" type="primary" @click="handleAddSub(row)">下级</el-button>
  52. <el-button size="mini" type="danger" @click="handleDelete(row)">删除</el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. </el-row>
  57. <industry ref="AddIndustry" title="新增" @formSuccess="getData" />
  58. <industry ref="EditIndustry" title="编辑" @formSuccess="getData" />
  59. </div>
  60. </template>
  61. <script>
  62. import Industry from './components/Industry.vue'
  63. import { toTree } from '@/utils/build-tree'
  64. import { getIndustryByList, deleteIndustryById } from '@/api/system/industryApi'
  65. export default {
  66. name: 'IndustryList',
  67. components: {
  68. Industry
  69. },
  70. props: {
  71. currentTreeNode: {
  72. type: Object,
  73. default: null
  74. }
  75. },
  76. data() {
  77. return {
  78. dataList: [],
  79. listLoading: false,
  80. total: 0,
  81. conditions: {
  82. page: 1,
  83. limit: 10,
  84. keywords: ''
  85. },
  86. tableExpandAllStatus: true // 表格展示状态
  87. }
  88. },
  89. computed: {},
  90. mounted() {
  91. this.getData()
  92. },
  93. methods: {
  94. // Fetch Data
  95. getData() {
  96. this.listLoading = true
  97. getIndustryByList().then((resp) => {
  98. const { data, total } = resp
  99. this.listLoading = false
  100. const temp = toTree(data, {
  101. value: 'industryId',
  102. name: 'label',
  103. pValue: 'parentId'
  104. }, {
  105. value: 'industryId',
  106. name: 'industryName',
  107. pValue: 'parentId'
  108. })
  109. this.dataList = temp
  110. this.total = total
  111. }).catch((error) => {
  112. console.log(error)
  113. })
  114. },
  115. // Click "Add"
  116. handleAddRoot() {
  117. this.$refs['AddIndustry'].showAddModel(0, '')
  118. },
  119. // Click "Sub"
  120. handleAddSub(row) {
  121. const { parentId, parentName } = row
  122. this.$refs['AddIndustry'].showAddModel(parentId, parentName)
  123. },
  124. // Click "Edit"
  125. handleEdit(row) {
  126. const { industryId } = row
  127. this.$refs['EditIndustry'].showEditModel(industryId)
  128. },
  129. // Click "Delete"
  130. handleDelete(row) {
  131. const { industryId } = row
  132. this.$confirm('确定删除吗?', '提示', {
  133. confirmButtonText: '确定',
  134. cancelButtonText: '取消',
  135. type: 'warning'
  136. }).then(() => {
  137. deleteIndustryById(industryId).then((resp) => {
  138. const { msg } = resp
  139. this.getData()
  140. this.$message.success(msg)
  141. })
  142. }).catch(() => {
  143. this.$message.info('已取消操作')
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. </style>
  151. <style lang="scss" scoped>
  152. .content-container {
  153. height: calc(100vh - 86px);
  154. .page-title {
  155. font-size: 18px;
  156. font-weight: bold;
  157. color:#fff;
  158. }
  159. .tool-bar {
  160. .left {
  161. float: left;
  162. }
  163. .right {
  164. float: right;
  165. text-align: right;
  166. }
  167. .title {
  168. line-height: 36px;
  169. font-size: 26px;
  170. }
  171. .search-input {
  172. width: 300px;
  173. }
  174. }
  175. .el-dropdown {
  176. margin: 0 10px;
  177. }
  178. .el-link{
  179. color: #FFFFFF;
  180. }
  181. }
  182. </style>