| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <div class="content-container">
- <el-row class="tool-bar">
- <el-col :span="12" class="left">
- <div class="page-title">
- 行业管理
- </div>
- </el-col>
- <el-col :span="12" class="right">
- <el-input v-model="conditions.keywords" class="search-input m-right-15" placeholder="请输入内容">
- <el-button slot="append" icon="el-icon-search" @click="getData()" />
- </el-input>
- <el-button type="primary" @click="handleAddRoot">添加</el-button>
- </el-col>
- </el-row>
- <el-row class="content-body">
- <el-table
- v-loading="listLoading"
- class="page-table"
- height="calc(100vh - 180px)"
- row-key="industryId"
- :default-expand-all="tableExpandAllStatus"
- :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
- :data="dataList"
- >
- <el-table-column type="selection" width="50" align="center" />
- <el-table-column type="index" align="center" label="序号" width="70" />
- <el-table-column width="350px" align="left" header-align="center" label="行业名称">
- <template v-slot="{row}">
- <span>{{ row.industryName }}</span>
- </template>
- </el-table-column>
- <el-table-column width="200px" label="类型" align="center" header-align="center">
- <template v-slot="{row}">
- <span>{{ row.industryTypeTitle }}</span>
- </template>
- </el-table-column>
- <el-table-column width="250" label="行业代码" align="center" header-align="center">
- <template v-slot="{row}">
- <span>{{ row.industryCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="说明" align="left" header-align="left">
- <template v-slot="{row}">
- <span>{{ row.industryDesc }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="300" align="center">
- <template v-slot="{row}">
- <el-button size="mini" @click="handleEdit(row)">修改</el-button>
- <el-button size="mini" type="primary" @click="handleAddSub(row)">下级</el-button>
- <el-button size="mini" type="danger" @click="handleDelete(row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-row>
- <industry ref="AddIndustry" title="新增" @formSuccess="getData" />
- <industry ref="EditIndustry" title="编辑" @formSuccess="getData" />
- </div>
- </template>
- <script>
- import Industry from './components/Industry.vue'
- import { toTree } from '@/utils/build-tree'
- import { getIndustryByList, deleteIndustryById } from '@/api/system/industryApi'
- export default {
- name: 'IndustryList',
- components: {
- Industry
- },
- props: {
- currentTreeNode: {
- type: Object,
- default: null
- }
- },
- data() {
- return {
- dataList: [],
- listLoading: false,
- total: 0,
- conditions: {
- page: 1,
- limit: 10,
- keywords: ''
- },
- tableExpandAllStatus: true // 表格展示状态
- }
- },
- computed: {},
- mounted() {
- this.getData()
- },
- methods: {
- // Fetch Data
- getData() {
- this.listLoading = true
- getIndustryByList().then((resp) => {
- const { data, total } = resp
- this.listLoading = false
- const temp = toTree(data, {
- value: 'industryId',
- name: 'label',
- pValue: 'parentId'
- }, {
- value: 'industryId',
- name: 'industryName',
- pValue: 'parentId'
- })
- this.dataList = temp
- this.total = total
- }).catch((error) => {
- console.log(error)
- })
- },
- // Click "Add"
- handleAddRoot() {
- this.$refs['AddIndustry'].showAddModel(0, '')
- },
- // Click "Sub"
- handleAddSub(row) {
- const { parentId, parentName } = row
- this.$refs['AddIndustry'].showAddModel(parentId, parentName)
- },
- // Click "Edit"
- handleEdit(row) {
- const { industryId } = row
- this.$refs['EditIndustry'].showEditModel(industryId)
- },
- // Click "Delete"
- handleDelete(row) {
- const { industryId } = row
- this.$confirm('确定删除吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteIndustryById(industryId).then((resp) => {
- const { msg } = resp
- this.getData()
- this.$message.success(msg)
- })
- }).catch(() => {
- this.$message.info('已取消操作')
- })
- }
- }
- }
- </script>
- <style lang="scss">
- </style>
- <style lang="scss" scoped>
- .content-container {
- height: calc(100vh - 86px);
- .page-title {
- font-size: 18px;
- font-weight: bold;
- color:#fff;
- }
- .tool-bar {
- .left {
- float: left;
- }
- .right {
- float: right;
- text-align: right;
- }
- .title {
- line-height: 36px;
- font-size: 26px;
- }
- .search-input {
- width: 300px;
- }
- }
- .el-dropdown {
- margin: 0 10px;
- }
- .el-link{
- color: #FFFFFF;
- }
- }
- </style>
|