|
@@ -8,9 +8,10 @@
|
|
|
<div style="display:flex;padding:10px;gap:10px">
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
- @click="showEditBreed=true;getParentVarietyList()"
|
|
|
+ @click="addClassify"
|
|
|
+ v-permission="permissionBtn.enClassifyBtn.classifyList_enClassify_rpAddClassify"
|
|
|
>添加分类</el-button>
|
|
|
- <el-input placeholder="品种名称" v-model="searchVal" style="max-width: 262px;" @change="handleSearch" clearable>
|
|
|
+ <el-input placeholder="分类名称" v-model="searchVal" style="max-width: 262px;" @change="getList" clearable>
|
|
|
<i slot="prefix" class="el-input__icon el-icon-search"></i>
|
|
|
</el-input>
|
|
|
</div>
|
|
@@ -22,44 +23,146 @@
|
|
|
class="drag_list-wrap"
|
|
|
animation="300"
|
|
|
tag="ul"
|
|
|
- @start="dragStart"
|
|
|
- @update="dragenter"
|
|
|
- @end="menuDragOver"
|
|
|
>
|
|
|
- <li class="item" v-for="item in level1_list" :key="item.Id">
|
|
|
+ <li class="item" v-for="item in level1_list" :key="item.Id" @click="handleSelectLevel1(item)">
|
|
|
<span class="tag open-tag">启用</span>
|
|
|
<div style="flex:1">{{item.ClassifyName}}</div>
|
|
|
<div>
|
|
|
- <span class="edit-btn" style="color:#0052D9">编辑</span>
|
|
|
+ <span class="edit-btn" style="color:#0052D9" @click.stop="handleEdit(item,1)">编辑</span>
|
|
|
<span class="edit-btn" style="color:#D54941">禁用</span>
|
|
|
</div>
|
|
|
</li>
|
|
|
</draggable>
|
|
|
</div>
|
|
|
<div class="list-item-wrap">
|
|
|
- <span class="placehoder-text">请选择一级分类</span>
|
|
|
+ <div v-if="level2_list&&level2_list.length>0">
|
|
|
+ <div style="padding: 20px 0 0 20px;">二级分类</div>
|
|
|
+ <draggable
|
|
|
+ v-model="level2_list"
|
|
|
+ class="drag_list-wrap"
|
|
|
+ animation="300"
|
|
|
+ tag="ul"
|
|
|
+ >
|
|
|
+ <li class="item" v-for="item in level2_list" :key="item.Id" @click="handleSelectLevel2(item)">
|
|
|
+ <span class="tag open-tag">启用</span>
|
|
|
+ <div style="flex:1">{{item.ClassifyName}}</div>
|
|
|
+ <div>
|
|
|
+ <span class="edit-btn" style="color:#0052D9" @click.stop="handleEdit(item,2)">编辑</span>
|
|
|
+ <span class="edit-btn" style="color:#D54941">禁用</span>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ </draggable>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span class="placehoder-text" v-else>请选择一级分类</span>
|
|
|
</div>
|
|
|
<div class="list-item-wrap">
|
|
|
- <span class="placehoder-text">请选择二级分类</span>
|
|
|
+ <div v-if="level3_list&&level3_list.length>0">
|
|
|
+ <div style="padding: 20px 0 0 20px;">三级分类</div>
|
|
|
+ <draggable
|
|
|
+ v-model="level3_list"
|
|
|
+ class="drag_list-wrap"
|
|
|
+ animation="300"
|
|
|
+ tag="ul"
|
|
|
+ >
|
|
|
+ <li class="item" v-for="item in level3_list" :key="item.Id" @click="handleSelectLevel2(item)">
|
|
|
+ <span class="tag open-tag">启用</span>
|
|
|
+ <div style="flex:1">{{item.ClassifyName}}</div>
|
|
|
+ <div>
|
|
|
+ <span class="edit-btn" style="color:#0052D9" @click.stop="handleEdit(item,3)">编辑</span>
|
|
|
+ <span class="edit-btn" style="color:#D54941">禁用</span>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ </draggable>
|
|
|
+ </div>
|
|
|
+ <span class="placehoder-text" v-else>请选择二级分类</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
-
|
|
|
+ <!-- 分类弹窗 -->
|
|
|
+ <m-dialog
|
|
|
+ :title="classifyForm.id?'编辑分类':'新增分类'"
|
|
|
+ :show.sync="classifyForm.show"
|
|
|
+ width="650px"
|
|
|
+ >
|
|
|
+ <div style="padding-left: 50px">
|
|
|
+ <el-form
|
|
|
+ :model="classifyForm"
|
|
|
+ :rules="formRules"
|
|
|
+ ref="formRef"
|
|
|
+ label-position="left"
|
|
|
+ hide-required-asterisk
|
|
|
+ label-width="80px">
|
|
|
+ <el-form-item prop="classify_name" label="分类名称">
|
|
|
+ <el-input
|
|
|
+ type="text"
|
|
|
+ v-model="classifyForm.classify_name"
|
|
|
+ placeholder="请输入分类名称"
|
|
|
+ style="width:400px;"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="parent_id" label="上级分类">
|
|
|
+ <el-cascader :options="classifyparentArr" v-model="classifyForm.parent_id" placeholder="请选择"
|
|
|
+ :props="{value:'Id',label:'ClassifyName',children:'Child',checkStrictly:true,emitPath:true}" style="min-width:400px;"></el-cascader>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="variety" label="关联品种" v-if="classifyForm.parent_id&&classifyForm.parent_id.length==2">
|
|
|
+ <el-cascader
|
|
|
+ :options="classifyparentArr"
|
|
|
+ v-model="classifyForm.parent_id"
|
|
|
+ placeholder="请选择"
|
|
|
+ :props="{value:'Id',label:'ClassifyName',children:'Child',checkStrictly:true,emitPath:true}"
|
|
|
+ style="min-width:400px;"
|
|
|
+ ></el-cascader>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div slot="footer" style="margin-top: 20px;">
|
|
|
+ <el-button
|
|
|
+ @click="cancelClassify"
|
|
|
+ style="width: 132px; height: 40px"
|
|
|
+ >取消</el-button>
|
|
|
+ <el-button
|
|
|
+ @click="setClassifyHandle"
|
|
|
+ type="primary"
|
|
|
+ style="width: 132px; height: 40px"
|
|
|
+ >保存</el-button>
|
|
|
+ </div>
|
|
|
+ </m-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import draggable from 'vuedraggable';
|
|
|
+import mDialog from '@/components/mDialog.vue';
|
|
|
import * as classifyEnInterface from "@/api/modules/classifyEnApi.js";
|
|
|
export default {
|
|
|
- components:{draggable},
|
|
|
+ components:{draggable,mDialog},
|
|
|
+ watch: {
|
|
|
+ 'classifyForm.show': {
|
|
|
+ handler(newval) {
|
|
|
+ newval && this.getClassifyOne();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
typeVal:1,
|
|
|
searchVal:'',
|
|
|
level1_list:[],
|
|
|
level2_list:[],
|
|
|
- level2_list:[]
|
|
|
+ level3_list:[],
|
|
|
+
|
|
|
+ classifyForm:{
|
|
|
+ show:false,
|
|
|
+ classify_id:0,
|
|
|
+ classify_name:"",
|
|
|
+ parent_id: ['0'],
|
|
|
+ variety:'',//关联的品种
|
|
|
+ },
|
|
|
+ formRules: {
|
|
|
+ classify_name: [{ required:true,message:'请输入分类名称',trigger:'blur'}]
|
|
|
+ },
|
|
|
+ classifyparentArr:[]
|
|
|
}
|
|
|
},
|
|
|
mounted(){
|
|
@@ -72,12 +175,83 @@ export default {
|
|
|
})
|
|
|
if(res.Ret===200){
|
|
|
this.level1_list=res.Data.List||[]
|
|
|
+ this.level2_list=[]
|
|
|
+ this.level3_list=[]
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ handleSelectLevel1(item){
|
|
|
+ this.level2_list=item.Child||[]
|
|
|
+ this.level3_list=[]
|
|
|
+ },
|
|
|
+ handleSelectLevel2(item){
|
|
|
+ this.level3_list=item.Child||[]
|
|
|
+ },
|
|
|
+ /* 获取一级分类 */
|
|
|
+ getClassifyOne() {
|
|
|
+ classifyEnInterface.classifyOne({ CurrentIndex: 1, PageSize: 9999}).then(res => {
|
|
|
+ if(res.Ret !== 200) return
|
|
|
+
|
|
|
+ this.classifyparentArr=res.Data.List || [];
|
|
|
+
|
|
|
+ this.classifyparentArr.unshift({Id:"0",ClassifyName:'无',Child:null})
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addClassify(){
|
|
|
+ this.classifyForm={
|
|
|
+ show:true,
|
|
|
+ classify_id:0,
|
|
|
+ classify_name:"",
|
|
|
+ parent_id: ['0'],
|
|
|
+ variety:'',//关联的品种
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleEdit(item,level){
|
|
|
+ let parent_id=['0']
|
|
|
+ if(level===2){
|
|
|
+ parent_id=[item.ParentId]
|
|
|
+ }else if(level===3){
|
|
|
+ parent_id=[item.RootId,item.ParentId]
|
|
|
+ }
|
|
|
+ this.classifyForm={
|
|
|
+ show:true,
|
|
|
+ classify_id:item.Id,
|
|
|
+ classify_name:item.ClassifyName,
|
|
|
+ parent_id: parent_id,
|
|
|
+ variety:level===3?item.EnPermissions:'',//关联的品种
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async setClassifyHandle(){
|
|
|
+ await this.$refs.formRef.validate();
|
|
|
+ const { classify_name,parent_id,sort,classify_id } = this.classifyForm;
|
|
|
+ let params = {
|
|
|
+ ClassifyName: classify_name,
|
|
|
+ ParentId: parent_id&&parent_id[parent_id.length-1]?parseInt(parent_id):0,
|
|
|
+ }
|
|
|
+
|
|
|
+ const { Ret,Msg } = classify_id
|
|
|
+ ? await classifyEnInterface.classifyEdit({...params,ClassifyId: classify_id})
|
|
|
+ : await classifyEnInterface.classifyAdd(params)
|
|
|
+
|
|
|
+ if(Ret !== 200) return
|
|
|
+ this.$message.success(Msg)
|
|
|
+ this.cancelClassify();
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ /* 取消 */
|
|
|
+ cancelClassify() {
|
|
|
+ this.$refs.formRef.resetFields();
|
|
|
+ this.classifyForm.show = false;
|
|
|
+ },
|
|
|
},
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
+<style lang="scss">
|
|
|
+.el-cascader .el-input{
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|
|
|
<style lang="scss" scoped>
|
|
|
.top-wrap{
|
|
|
display: flex;
|