|
@@ -9,7 +9,7 @@
|
|
|
<div class="main-wrap">
|
|
|
<div class="left-wrap">
|
|
|
<div class="add-btn-box">
|
|
|
- <el-button type="primary" v-permission="permissionBtn.enChartPermission.enChartPermission_save" @click="handleAddVariety">添加品种</el-button>
|
|
|
+ <el-button type="primary" @click="handleAddVariety">添加品种</el-button>
|
|
|
</div>
|
|
|
<div class="first-variety-wrap">
|
|
|
<draggable
|
|
@@ -18,14 +18,15 @@
|
|
|
animation="300"
|
|
|
tag="ul"
|
|
|
handle=".icon-drag"
|
|
|
+ @end="handleSortEnd($event,1)"
|
|
|
>
|
|
|
<li
|
|
|
- :class="['item',selectFirstId==item.EnPermissionId?'active':'']"
|
|
|
+ :class="['item',selectFirstId==item.PermissionId?'active':'']"
|
|
|
v-for="item in tableData"
|
|
|
- :key="item.EnPermissionId"
|
|
|
+ :key="item.PermissionId"
|
|
|
@click="handleSelectFirstVariety(item)"
|
|
|
>
|
|
|
- <div class="name">{{item.EnPermissionName}}</div>
|
|
|
+ <div class="name">{{item.PermissionName}}</div>
|
|
|
<div class="menu-box">
|
|
|
<img class="icon-drag" src="~@/assets/img/data_m/move_ico2.png" alt="">
|
|
|
<img class="icon-set" src="~@/assets/img/icons/variety_set.png" alt="" @click="handleShowEdit(item)">
|
|
@@ -34,53 +35,51 @@
|
|
|
</draggable>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div>
|
|
|
<draggable
|
|
|
+ v-model="secondVarietyList"
|
|
|
class="list-wrap"
|
|
|
animation="300"
|
|
|
tag="ul"
|
|
|
handle=".icon-drag"
|
|
|
:move="onMove"
|
|
|
- @start="dragStart"
|
|
|
- @update="dragenter"
|
|
|
- @end="menuDragOver"
|
|
|
+ @end="handleSortEnd($event,2)"
|
|
|
>
|
|
|
- <li class="item add-btn" v-if="selectFirstId">
|
|
|
+ <!-- <li class="item add-btn" v-if="selectFirstId" @click="handleAddVariety(2)">
|
|
|
<img class="icon" src="~@/assets/img/icons/variety_add.png" alt="">
|
|
|
- </li>
|
|
|
- <li class="item" v-for="item in secondVarietyList" :key="item.EnPermissionId">
|
|
|
+ </li> -->
|
|
|
+ <li class="item" v-for="item in secondVarietyList" :key="item.PermissionId">
|
|
|
<div class="top-icons">
|
|
|
<img class="icon-drag" src="~@/assets/img/data_m/move_ico2.png" alt="">
|
|
|
- <el-switch
|
|
|
- :value="true"
|
|
|
- active-color="#0052D9">
|
|
|
- </el-switch>
|
|
|
+ <span @click="handleQuickSet(item,'enable')">
|
|
|
+ <el-switch
|
|
|
+ :value="item.Enabled==1"
|
|
|
+ active-color="#0052D9"
|
|
|
+ />
|
|
|
+ </span>
|
|
|
</div>
|
|
|
<div class="name-box">
|
|
|
- <el-input
|
|
|
- ref="editVal"
|
|
|
- size='mini'
|
|
|
- style="width: 90px"
|
|
|
- placeholder="请输入值"
|
|
|
- class="label-input"
|
|
|
- v-model="new_label"
|
|
|
- v-if="item.isEdit"
|
|
|
- @blur="changeValue(item)"
|
|
|
- />
|
|
|
- <template v-else>
|
|
|
- <div class="name" >{{item.EnPermissionName}}</div>
|
|
|
- <img @click="editNodeLabel(item)" class="icon-edit" src="~@/assets/img/icons/variety_name_edit.png" alt="">
|
|
|
- </template>
|
|
|
+ <div class="name" >{{item.PermissionName}}</div>
|
|
|
+ <img @click="handleShowEdit(item)" class="icon-edit" src="~@/assets/img/icons/variety_name_edit.png" alt="">
|
|
|
</div>
|
|
|
- <div class="tag-box open" v-if="true">
|
|
|
+ <template v-if="typeVal==1">
|
|
|
+ <div class="tag-box open" v-if="item.IsPublic==1" @click="handleQuickSet(item,'ispublic')">
|
|
|
<span class="tag">公有</span>
|
|
|
<img class="icon" src="~@/assets/img/icons/changeLang01.png" alt="">
|
|
|
</div>
|
|
|
- <div class="tag-box close" v-else>
|
|
|
+ <div class="tag-box close" v-else @click="handleQuickSet(item,'ispublic')">
|
|
|
<span class="tag">私有</span>
|
|
|
<img class="icon" src="~@/assets/img/icons/edit_icon01.png" alt="">
|
|
|
</div>
|
|
|
+ </template>
|
|
|
</li>
|
|
|
</draggable>
|
|
|
+ <ul class="list-wrap" style="float:left;margin-top:20px">
|
|
|
+ <li class="item add-btn" v-if="selectFirstId" @click="handleAddVariety(2)">
|
|
|
+ <img class="icon" src="~@/assets/img/icons/variety_add.png" alt="">
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 品种编辑弹窗 -->
|
|
@@ -95,6 +94,16 @@
|
|
|
>
|
|
|
<div class="edit-variety-wrap" style="padding-bottom:30px">
|
|
|
<el-form>
|
|
|
+ <el-form-item label="上级品种" v-if="editBreedData.parentId">
|
|
|
+ <el-select v-model="editBreedData.parentId" style="width:400px">
|
|
|
+ <el-option
|
|
|
+ v-for="item in tableData"
|
|
|
+ :key="item.PermissionId"
|
|
|
+ :label="item.PermissionName"
|
|
|
+ :value="item.PermissionId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="品种名称">
|
|
|
<el-input placeholder="请输入品种名称" v-model="editBreedData.name" style="width:400px"></el-input>
|
|
|
</el-form-item>
|
|
@@ -104,6 +113,21 @@
|
|
|
active-color="#0052D9">
|
|
|
</el-switch>
|
|
|
</el-form-item>
|
|
|
+ <!-- 中文品种特有的设置公有权限 -->
|
|
|
+ <div class="public-auth-box" v-if="typeVal==1&&secondVarietyList.length>0&&editBreedData.parentId==0">
|
|
|
+ <el-tooltip effect="dark" content="默认为私有,勾选并保存设置为公有">
|
|
|
+ <div style="display:inline-block">
|
|
|
+ <span>公有权限设置</span>
|
|
|
+ <i class="el-icon-info"></i>
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ <div class="auth-list-box">
|
|
|
+ <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
|
|
|
+ <el-checkbox-group style="padding:20px" v-model="checkedList" @change="handleCheckedAuthChange">
|
|
|
+ <el-checkbox style="display:block;margin-bottom:10px" v-for="item in secondVarietyList" :label="item.PermissionId" :key="item.PermissionId">{{item.PermissionName}}</el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</el-form>
|
|
|
<div style="text-align: center;margin-top:40px">
|
|
|
<el-button type="primary" plain @click="showEditBreed=false">取消</el-button>
|
|
@@ -116,7 +140,7 @@
|
|
|
|
|
|
<script>
|
|
|
import draggable from 'vuedraggable';
|
|
|
-import {reportVarietyENInterence} from '@/api/api'
|
|
|
+import {reportVarietyENInterence,reportVarietyInterence} from '@/api/modules/reportVariety'
|
|
|
export default {
|
|
|
components:{draggable},
|
|
|
watch: {
|
|
@@ -125,9 +149,13 @@ export default {
|
|
|
this.editBreedData={
|
|
|
id:0,
|
|
|
name:'',
|
|
|
- sort:0,
|
|
|
parentId:0,
|
|
|
+ status:true,//启用状态
|
|
|
+ IsPublic:0,//1公有,0私有
|
|
|
}
|
|
|
+ this.isIndeterminate=false
|
|
|
+ this.checkAll=false
|
|
|
+ this.checkedList=[]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -141,15 +169,17 @@ export default {
|
|
|
selectFirstId:0,//当前选中的一级品种Id
|
|
|
secondVarietyList:[],//当前选中的一级品种下的二级品种数据
|
|
|
|
|
|
- new_label:'',//当前编辑二级品种的名称值
|
|
|
-
|
|
|
showEditBreed:false,
|
|
|
editBreedData:{
|
|
|
id:0,
|
|
|
name:'',
|
|
|
+ parentId:0,
|
|
|
status:true,//启用状态
|
|
|
-
|
|
|
+ IsPublic:0,//1公有,0私有
|
|
|
},
|
|
|
+ isIndeterminate:false,
|
|
|
+ checkAll:false,
|
|
|
+ checkedList:[]
|
|
|
}
|
|
|
},
|
|
|
created(){
|
|
@@ -158,71 +188,149 @@ export default {
|
|
|
methods: {
|
|
|
async getList(){
|
|
|
this.listLoading=true
|
|
|
- const res=await reportVarietyENInterence.varietyList({Keyword:this.searchVal})
|
|
|
+ const res=this.typeVal==1?await reportVarietyInterence.varietyList({Keyword:this.searchVal}) : await reportVarietyENInterence.varietyList({Keyword:this.searchVal})
|
|
|
this.listLoading=false
|
|
|
if(res.Ret===200){
|
|
|
this.tableData=res.Data||[]
|
|
|
if(this.tableData.length>0){
|
|
|
- this.handleSelectFirstVariety(this.tableData[0])
|
|
|
+ if(this.selectFirstId==0){
|
|
|
+ this.handleSelectFirstVariety(this.tableData[0])
|
|
|
+ }else{
|
|
|
+ let index=this.tableData.findIndex(e=>e.PermissionId==this.selectFirstId)
|
|
|
+ this.handleSelectFirstVariety(this.tableData[index])
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 点击一级分类
|
|
|
handleSelectFirstVariety(item){
|
|
|
- this.selectFirstId=item.EnPermissionId
|
|
|
- this.secondVarietyList=item.Child||[]
|
|
|
+ this.selectFirstId=item.PermissionId
|
|
|
+ const arr=item.Child?JSON.parse(JSON.stringify(item.Child)):[]
|
|
|
+ this.secondVarietyList=arr
|
|
|
},
|
|
|
|
|
|
- //点击编辑二级品种名称
|
|
|
- editNodeLabel(item){
|
|
|
- this.$set(item,'isEdit',true)
|
|
|
- this.new_label = item.EnPermissionName;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.editVal[0].focus();
|
|
|
- });
|
|
|
- },
|
|
|
- changeValue(item){
|
|
|
- if(this.new_label) {
|
|
|
- this.$set(item,'isEdit',false)
|
|
|
- // this.new_label !== data.ClassifyName && dataBaseInterface.nodeEdit({
|
|
|
- // ClassifyId: data.ClassifyId,
|
|
|
- // ClassifyName: this.new_label
|
|
|
- // }).then(res => {
|
|
|
- // if(res.Ret === 200) {
|
|
|
- // this.getTreeData();
|
|
|
- // }
|
|
|
- // })
|
|
|
- }else {
|
|
|
- this.$message.warning('名称不能为空')
|
|
|
- }
|
|
|
+ // 快捷设置是否禁用\公有私有
|
|
|
+ async handleQuickSet(item,type){
|
|
|
+ let params={
|
|
|
+ PermissionId:item.PermissionId,
|
|
|
+ PermissionName:item.PermissionName
|
|
|
+ }
|
|
|
+ if(type==='enable'){
|
|
|
+ params.enabled=item.Enabled==1?0:1
|
|
|
+ params.IsPublic=item.IsPublic
|
|
|
+ }else if(type==='ispublic'){
|
|
|
+ params.IsPublic=item.IsPublic==1?0:1
|
|
|
+ params.enabled=item.Enabled
|
|
|
+ }
|
|
|
+ const res=this.typeVal==1?await reportVarietyInterence.editVariety(params):await reportVarietyENInterence.editVariety(params)
|
|
|
+ if(res.Ret===200){
|
|
|
+ this.$message.success(`编辑成功`)
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
},
|
|
|
-
|
|
|
- handleAddVariety(){
|
|
|
- this.showEditBreed=true
|
|
|
- this.editBreedData={
|
|
|
- id:0,
|
|
|
- name:'',
|
|
|
- status:true,//启用状态
|
|
|
+
|
|
|
+ //显示添加品种
|
|
|
+ handleAddVariety(level){
|
|
|
+ if(level==2){
|
|
|
+ this.editBreedData.parentId=this.selectFirstId
|
|
|
}
|
|
|
+ this.showEditBreed=true
|
|
|
},
|
|
|
|
|
|
+ //点击显示编辑品种
|
|
|
handleShowEdit(item){
|
|
|
- this.showEditBreed=true
|
|
|
+ if(item.ParentId){//编辑子分类
|
|
|
+ this.editBreedData={
|
|
|
+ id:item.PermissionId,
|
|
|
+ name:item.PermissionName,
|
|
|
+ parentId:item.ParentId,
|
|
|
+ status:item.Enabled===1?true:false
|
|
|
+ }
|
|
|
+ this.showEditBreed=true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.selectFirstId=item.PermissionId
|
|
|
+ const arr=item.Child?JSON.parse(JSON.stringify(item.Child)):[]
|
|
|
+ this.secondVarietyList=arr
|
|
|
+
|
|
|
+ this.secondVarietyList.forEach(item=>{
|
|
|
+ if(item.IsPublic==1){
|
|
|
+ this.checkedList.push(item.PermissionId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.checkAll = this.checkedList.length === this.secondVarietyList.length;
|
|
|
+ this.isIndeterminate = this.checkedList.length > 0 && this.checkedList.length < this.secondVarietyList.length;
|
|
|
+
|
|
|
this.editBreedData={
|
|
|
- id:item.EnPermissionId,
|
|
|
- name:item.EnPermissionName
|
|
|
+ id:item.PermissionId,
|
|
|
+ name:item.PermissionName,
|
|
|
+ parentId:item.ParentId,
|
|
|
+ status:item.Enabled===1?true:false
|
|
|
}
|
|
|
+
|
|
|
+ console.log(this.isIndeterminate,this.checkedList);
|
|
|
+
|
|
|
+ this.showEditBreed=true
|
|
|
+ },
|
|
|
+
|
|
|
+ // 公有权限设置全选按钮
|
|
|
+ handleCheckAllChange(val){
|
|
|
+ let list=[]
|
|
|
+ this.secondVarietyList.forEach(item => {
|
|
|
+ list.push(item.PermissionId)
|
|
|
+ });
|
|
|
+ this.checkedList=val?list:[]
|
|
|
+ this.isIndeterminate=false
|
|
|
+ },
|
|
|
+ handleCheckedAuthChange(value){
|
|
|
+ let checkedCount = value.length;
|
|
|
+ this.checkAll = checkedCount === this.secondVarietyList.length;
|
|
|
+ this.isIndeterminate = checkedCount > 0 && checkedCount < this.secondVarietyList.length;
|
|
|
},
|
|
|
|
|
|
onMove(e){
|
|
|
- if(e.relatedContext.index===0) return false
|
|
|
+ // if(e.relatedContext.index===0) return false //控制新增按钮不能拖动
|
|
|
return true
|
|
|
},
|
|
|
|
|
|
+ // 拖动排序结束
|
|
|
+ async handleSortEnd(e,level){
|
|
|
+ const arr=level==1?this.tableData:this.secondVarietyList
|
|
|
+ if(arr.length===1) return
|
|
|
+
|
|
|
+ const newIndex=level==1?e.newIndex:e.newIndex//因为子组件前面有个固定的添加项 所以实际index要-1
|
|
|
+ const PermissionId=arr[newIndex].PermissionId
|
|
|
+ let PrevPermissionId=0,NextPermissionId=0;
|
|
|
+
|
|
|
+ if(newIndex==0){//移动到最前面
|
|
|
+ NextPermissionId=arr[newIndex+1].PermissionId
|
|
|
+ }else if(newIndex===arr.length-1){//移动到最后面
|
|
|
+ PrevPermissionId=arr[newIndex-1].PermissionId
|
|
|
+ }else{
|
|
|
+ PrevPermissionId=arr[newIndex-1].PermissionId
|
|
|
+ NextPermissionId=arr[newIndex+1].PermissionId
|
|
|
+ }
|
|
|
+ const params={
|
|
|
+ PermissionId,
|
|
|
+ PrevPermissionId,
|
|
|
+ NextPermissionId
|
|
|
+ }
|
|
|
+ const res=this.typeVal==1?await reportVarietyInterence.sortVariety(params):await reportVarietyENInterence.sortVariety(params)
|
|
|
+ if(res.Ret===200){
|
|
|
+ this.$message.success('操作成功')
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+
|
|
|
// 中英文品种切换
|
|
|
handleTypeChange(type){
|
|
|
this.typeVal=type
|
|
|
+ this.tableData=[]
|
|
|
+ this.selectFirstId=0
|
|
|
+ this.secondVarietyList=[]
|
|
|
+ this.getList()
|
|
|
},
|
|
|
|
|
|
async handleConfirmEidtBreed(){
|
|
@@ -231,50 +339,28 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
let params={
|
|
|
- EnPermissionName:this.editBreedData.name,
|
|
|
+ PermissionName:this.editBreedData.name,
|
|
|
ParentId:this.editBreedData.parentId,
|
|
|
- Sort:Number(this.editBreedData.sort)
|
|
|
+ enabled:this.editBreedData.status?1:0
|
|
|
}
|
|
|
if(this.editBreedData.id){
|
|
|
- params.EnPermissionId=this.editBreedData.id
|
|
|
+ params.PermissionId=this.editBreedData.id
|
|
|
+ }
|
|
|
+ let res
|
|
|
+ // 中文
|
|
|
+ if(this.typeVal===1){
|
|
|
+ if(this.editBreedData.id>0&¶ms.ParentId==0){//编辑一级品种时批量设置公有权限
|
|
|
+ params.PublicPermissionIds=this.checkedList||[]
|
|
|
+ }
|
|
|
+ res=this.editBreedData.id?await reportVarietyInterence.editVariety(params):await reportVarietyInterence.addVariety(params)
|
|
|
+ }else{//英文
|
|
|
+ res=this.editBreedData.id?await reportVarietyENInterence.editVariety(params):await reportVarietyENInterence.addVariety(params)
|
|
|
}
|
|
|
- const res=this.editBreedData.id?await reportVarietyENInterence.editVariety(params):await reportVarietyENInterence.addVariety(params)
|
|
|
if(res.Ret===200){
|
|
|
this.$message.success(`${this.editBreedData.id?'编辑':"新增"}成功`)
|
|
|
this.getList()
|
|
|
this.showEditBreed=false
|
|
|
- this.getParentVarietyList()
|
|
|
}
|
|
|
- },
|
|
|
-
|
|
|
- handleEditBreedItem(item){
|
|
|
- this.editBreedData={
|
|
|
- id:item.EnPermissionId,
|
|
|
- name:item.EnPermissionName,
|
|
|
- sort:item.Sort,
|
|
|
- parentId:item.ParentId||0
|
|
|
- }
|
|
|
- this.getParentVarietyList(item.ParentId?false:true)
|
|
|
- this.showEditBreed=true
|
|
|
- },
|
|
|
-
|
|
|
- // 删除品种
|
|
|
- handleDelBreedItem(item){
|
|
|
- this.$confirm('确认删除吗?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(()=>{
|
|
|
- reportVarietyENInterence.delVariety({
|
|
|
- EnPermissionId:item.EnPermissionId
|
|
|
- }).then(res=>{
|
|
|
- if(res.Ret===200){
|
|
|
- this.$message.success('删除成功')
|
|
|
- this.getList()
|
|
|
- this.getParentVarietyList()
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
}
|
|
|
},
|
|
|
}
|
|
@@ -417,28 +503,13 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
.edit-variety-wrap{
|
|
|
- height: 100%;
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- .header-box{
|
|
|
- display: flex;
|
|
|
- justify-content: space-between;
|
|
|
- align-items: center;
|
|
|
- height: 48px;
|
|
|
- border-bottom: 1px solid #E7E7E7;
|
|
|
- .title{
|
|
|
- width: 88px;
|
|
|
- height: 48px;
|
|
|
- line-height: 48px;
|
|
|
- font-size: 16px;
|
|
|
- text-align: center;
|
|
|
- color: #0052D9;
|
|
|
- border-bottom: 2px solid #0052D9;
|
|
|
+ .public-auth-box{
|
|
|
+ .auth-list-box{
|
|
|
+ margin-top: 20px;
|
|
|
+ padding: 20px;
|
|
|
+ background-color: #F8F8F8;
|
|
|
}
|
|
|
- }
|
|
|
- .content-box{
|
|
|
- flex: 1;
|
|
|
- overflow-y: auto;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
</style>
|