MrShi
2024-01-03 0f1443d33d4099564f84e1a3f4f1572841a370ff
admin/src/views/business/internalCompany.vue
@@ -1,75 +1,71 @@
<template>
    <TableLayout :permissions="['business:company:query']">
    <TableLayout>
<!--        :permissions="['business:company:query']"-->
        <!-- 搜索表单 -->
        <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
            <el-form-item label="组织名称" prop="name">
                <el-input v-model="searchForm.name" placeholder="请输入组织名称" @keypress.enter.native="search"></el-input>
            </el-form-item>
            <el-form-item label="所属上级组织" prop="parentName">
                <el-input v-model="searchForm.parentName" placeholder="请输入所属上级组织" @keypress.enter.native="search"></el-input>
            </el-form-item>
            <section>
                <el-button type="primary" @click="search">搜索</el-button>
                <el-button @click="reset">重置</el-button>
            </section>
        </el-form>
<!--        <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>-->
<!--            <el-form-item label="组织名称" prop="name">-->
<!--                <el-input v-model="searchForm.name" placeholder="请输入组织名称" @keypress.enter.native="search"></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item label="所属上级组织" prop="parentName">-->
<!--                <el-input v-model="searchForm.parentName" placeholder="请输入所属上级组织" @keypress.enter.native="search"></el-input>-->
<!--            </el-form-item>-->
<!--            <section>-->
<!--                <el-button type="primary" @click="search">搜索</el-button>-->
<!--                <el-button @click="reset">重置</el-button>-->
<!--            </section>-->
<!--        </el-form>-->
        <!-- 表格和分页 -->
        <template v-slot:table-wrap>
            <ul class="toolbar" v-permissions="['business:company:create', 'business:company:delete']">
                <li><el-button type="primary" v-permissions="['business:company:create']" @click="synchronous()">同步</el-button></li>
<!--                <li><el-button type="primary" v-permissions="['business:company:create']" @click="synchronous()">同步</el-button></li>-->
                <li><el-button type="primary" v-permissions="['business:company:create']" @click="$refs.OperaInternalCompanyWindow.open('新建企业')">新建</el-button></li>
            </ul>
            <el-table
                v-loading="isWorking.search"
                :data="tableData.list"
                :data="list"
                stripe
                :tree-props="{children: 'childList'}"
                row-key="id"
                @selection-change="handleSelectionChange"
            >
                <el-table-column type="selection" width="55"></el-table-column>
<!--                <el-table-column type="selection" width="55"></el-table-column>-->
                <el-table-column prop="name" label="组织名称" min-width="100px"></el-table-column>
                <el-table-column prop="parentName" label="上级组织" min-width="100px"></el-table-column>
                <el-table-column prop="editDate" label="最后更新时间" min-width="100px"></el-table-column>
<!--                <el-table-column-->
<!--                    v-if="containPermissions(['business:company:update', 'business:company:delete'])"-->
<!--                    label="操作"-->
<!--                    min-width="80"-->
<!--                    fixed="right"-->
<!--                >-->
<!--                    <template slot-scope="{row}">-->
<!--                        <el-button type="text" @click="$refs.OperaInternalCompanyWindow.open('编辑企业信息表', row)" icon="el-icon-edit" v-permissions="['business:company:update']">编辑</el-button>-->
<!--                        <el-button type="text" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:company:delete']">删除</el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
                <el-table-column
                    label="操作"
                    width="230"
                    fixed="right"
                >
                    <template slot-scope="{row}">
                        <el-button type="text" @click="$refs.OperaInternalCompanyWindow.open('编辑企业信息', row)" icon="el-icon-edit" v-permissions="['business:company:update']">编辑</el-button>
                        <el-button type="text" @click="$refs.OperaInternalCompanyWindow.open('新建子级', { disable: true, parentId: row.id })" icon="el-icon-plus">新建子级</el-button>
                        <el-button type="text" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:company:delete']">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination
                @size-change="handleSizeChange"
                @current-change="handlePageChange"
                :pagination="tableData.pagination"
            >
            </pagination>
        </template>
        <!-- 新建/修改 -->
<!--        <OperaInternalCompanyWindow ref="OperaInternalCompanyWindow" @success="handlePageChange"/>-->
        <OperaInternalCompanyWindow ref="OperaInternalCompanyWindow" :list="list" @success="handlePageChange"/>
    </TableLayout>
</template>
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import { companySync } from '@/api/business/company'
// import OperaInternalCompanyWindow from '@/components/business/OperaInternalCompanyWindow'
// import { companySync } from '@/api/business/company'
import OperaInternalCompanyWindow from '@/components/business/OperaInternalCompanyWindow'
export default {
  name: 'internalCompany',
  extends: BaseTable,
  components: { TableLayout, Pagination },
  components: { TableLayout, OperaInternalCompanyWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        name: '',
        parentName: '',
        type: 1
      }
      },
      list: [],
      total: 0
    }
  },
  created () {
@@ -82,12 +78,27 @@
    this.search()
  },
  methods: {
    // 同步信息
    async synchronous () {
      const message = await companySync({})
      this.$message.success(message)
      this.search()
    // 页码变更处理
    handlePageChange (pageIndex) {
      this.__checkApi()
      this.isWorking.search = true
      this.api.fetchList(this.searchForm.type)
        .then(data => {
          this.list = data
        })
        .catch(e => {
          this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.isWorking.search = false
        })
    }
    // 同步信息
    // async synchronous () {
    //   const message = await companySync({})
    //   this.$message.success(message)
    //   this.search()
    // }
  }
}
</script>