From 2079ba28f20bde46f7736699c97abf0e1564770d Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 14 十月 2024 09:30:46 +0800
Subject: [PATCH] 最新版本
---
admin/src/views/business/internalCompany.vue | 110 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 97 insertions(+), 13 deletions(-)
diff --git a/admin/src/views/business/internalCompany.vue b/admin/src/views/business/internalCompany.vue
index 7c8222f..60279db 100644
--- a/admin/src/views/business/internalCompany.vue
+++ b/admin/src/views/business/internalCompany.vue
@@ -17,29 +17,40 @@
<!-- 琛ㄦ牸鍜屽垎椤� -->
<template v-slot:table-wrap>
<ul class="toolbar" v-permissions="['business:company:create', 'business:company:sync']">
- <li><el-button type="primary" v-permissions="['business:company:create']" @click="$refs.OperaInternalCompanyWindow.open('鏂板缓浼佷笟')">鏂板缓</el-button></li>
- <li><el-button type="primary" v-permissions="['business:company:sync']" :loading="loading" @click="synchronous()">鍚屾</el-button></li>
+ <li><el-button type="primary" v-permissions="['business:company:create']" @click="$refs.OperaInternalCompanyWindow.open('鏂板缓浼佷笟',null,null)">鏂板缓</el-button></li>
+ <li><el-button @click="sort('top')" :loading="sorting" icon="el-icon-sort-up" v-permissions="['business:company:sort']">涓婄Щ</el-button></li>
+ <li><el-button @click="sort('bottom')" :loading="sorting" icon="el-icon-sort-down" v-permissions="['business:company:sort']">涓嬬Щ</el-button></li>
+ <li><el-button type="primary" v-permissions="['business:company:sync']" :loading="loading" @click="synchronous()">鍚屾</el-button></li>
</ul>
<el-table
v-loading="isWorking.search"
:data="list"
stripe
- :tree-props="{children: 'childList'}"
+ :tree-props="{children: 'childList',hasChildren: 'hasChildren'}"
row-key="id"
@selection-change="handleSelectionChange"
+ default-expand-all
>
-<!-- <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="editDate" label="鏈�鍚庢洿鏂版椂闂�" min-width="100px"></el-table-column>
+ <el-table-column prop="name" label="缁勭粐绫诲瀷" min-width="80px">
+ <template scope="{row}">
+ <span v-if="row.type == 0">鐩稿叧鏂圭粍缁�</span>
+ <span v-if="row.type == 1">鍐呴儴缁勭粐</span>
+ </template>
+ </el-table-column>
+ <el-table-column prop="companyNamePath" label="缁勭粐璺緞" min-width="100px"></el-table-column>
+ <el-table-column prop="editorName" label="鎿嶄綔浜�" min-width="100px"></el-table-column>
+ <el-table-column prop="editDate" label="鏈�鍚庢洿鏂版椂闂�" min-width="100px"></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>
+ <el-button type="text" @click="$refs.OperaInternalCompanyWindow.open('缂栬緫浼佷笟淇℃伅',{ id: row.parentId,name:row.parentName,type:row.parentType, companyPath:row.parentCompanyPath}, row)" icon="el-icon-edit" v-permissions="['business:company:update']">缂栬緫</el-button>
+ <el-button type="text" @click="$refs.OperaInternalCompanyWindow.open('鏂板缓瀛愮骇', row,null)" icon="el-icon-plus">鏂板缓瀛愮骇</el-button>
+ <el-button type="text" @click="deleteById(row)" style="color: red" icon="el-icon-delete" v-permissions="['business:company:delete']">鍒犻櫎</el-button>
</template>
</el-table-column>
</el-table>
@@ -52,9 +63,8 @@
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
-import { companySync } from '@/api/business/company'
+import { companySync, sort } from '@/api/business/company'
import OperaInternalCompanyWindow from '@/components/business/OperaInternalCompanyWindow'
-import { memberSync } from '@/api/business/member'
export default {
name: 'internalCompany',
extends: BaseTable,
@@ -62,9 +72,10 @@
data () {
return {
// 鎼滅储
- loading:false,
+ loading: false,
+ sorting: false,
searchForm: {
- type: 1
+ // type: 1
},
list: [],
total: 0
@@ -97,7 +108,7 @@
},
// 鍚屾淇℃伅
async synchronous () {
- this.$dialog.actionConfirm('鎿嶄綔纭鎻愰啋', '鎮ㄧ‘璁ゅ悓姝ュ叏閮ㄤ俊鎭悧锛�')
+ this.$dialog.actionConfirm('璇ユ搷浣滃皢绯荤粺娓呯┖宸叉湁缁勭粐淇℃伅锛屾偍纭鍚屾鍏ㄩ儴淇℃伅鍚楋紵', '鎿嶄綔纭鎻愰啋')
.then(() => {
this.loading = true
companySync({})
@@ -113,6 +124,79 @@
})
})
.catch(() => {})
+ },
+ // 鎺掑簭
+ sort (direction) {
+ if (this.sorting) {
+ return
+ }
+ if (this.tableData.selectedRows.length === 0) {
+ this.$tip.warning('璇烽�夋嫨涓�鏉℃暟鎹�')
+ return
+ }
+ if (this.tableData.selectedRows.length > 1) {
+ this.$tip.warning('鎺掑簭鏃朵粎鍏佽閫夋嫨涓�鏉℃暟鎹�')
+ return
+ }
+ const menuId = this.tableData.selectedRows[0].id
+ // 鎵惧埌鑿滃崟鑼冨洿
+ let menuPool
+ for (const rootMenu of this.list) {
+ console.log(this.list)
+ const parent = this.__findParent(menuId, rootMenu)
+ if (parent != null) {
+ menuPool = parent.children
+ }
+ }
+ menuPool = menuPool || this.list
+ const menuIndex = menuPool.findIndex(menu => menu.id === menuId)
+ // 涓婄Щ鏍¢獙
+ if (direction === 'top' && menuIndex === 0) {
+ this.$tip.warning('鑿滃崟宸插埌椤堕儴')
+ return
+ }
+ // 涓嬬Щ鏍¢獙
+ if (direction === 'bottom' && menuIndex === menuPool.length - 1) {
+ this.$tip.warning('鑿滃崟宸插埌搴曢儴')
+ return
+ }
+ this.sorting = true
+ sort({
+ id: this.tableData.selectedRows[0].id,
+ direction
+ })
+ .then(() => {
+ /* if (direction === 'top') {
+ menuPool.splice(menuIndex, 0, menuPool.splice(menuIndex - 1, 1)[0])
+ } else {
+ menuPool.splice(menuIndex, 0, menuPool.splice(menuIndex + 1, 1)[0])
+ }*/
+ this.search()
+ })
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ .finally(() => {
+ this.sorting = false
+ })
+ },
+ // 鏌ヨ鐖惰妭鐐�
+ __findParent (id, parent) {
+ if (parent.childList === 0) {
+ return
+ }
+ for (const menu of parent.childList) {
+ if (menu.id === id) {
+ return parent
+ }
+ if (menu.childList.length > 0) {
+ const m = this.__findParent(id, menu)
+ if (m != null) {
+ return m
+ }
+ }
+ }
+ return null
}
}
}
--
Gitblit v1.9.3