|
@@ -14,13 +14,17 @@
|
|
<!-- 新增/编辑弹窗 -->
|
|
<!-- 新增/编辑弹窗 -->
|
|
<el-dialog :title="popTitle+'商品分类'" :visible.sync="dialogFormVisible" width="30%" :destroy-on-close="true">
|
|
<el-dialog :title="popTitle+'商品分类'" :visible.sync="dialogFormVisible" width="30%" :destroy-on-close="true">
|
|
<by-form :propConfig="addConfig" ref="addFormId">
|
|
<by-form :propConfig="addConfig" ref="addFormId">
|
|
|
|
+ <template v-slot:parentName class="clearfix">
|
|
|
|
+ <i class="el-icon-loading" v-if="selectTreeLoading"></i>
|
|
|
|
+ <select-tree v-else ref="selectTree" :propConfig="selectTreeConfig" @onChange="selectTree"></select-tree>
|
|
|
|
+ </template>
|
|
<template v-slot:status class="clearfix">
|
|
<template v-slot:status class="clearfix">
|
|
<el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">正常</el-radio>
|
|
<el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">正常</el-radio>
|
|
<el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">禁用</el-radio>
|
|
<el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">禁用</el-radio>
|
|
</template>
|
|
</template>
|
|
</by-form>
|
|
</by-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<div slot="footer" class="dialog-footer">
|
|
- <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
|
|
|
+ <el-button @click="dialogFormVisible = false; selectTreeChange = {}">取 消</el-button>
|
|
<el-button type="primary" @click="confirm">确 定</el-button>
|
|
<el-button type="primary" @click="confirm">确 定</el-button>
|
|
</div>
|
|
</div>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
@@ -30,6 +34,7 @@
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
import api from "@/api/currency";
|
|
import api from "@/api/currency";
|
|
import Assembly from "@/components/Assembly/material.vue";
|
|
import Assembly from "@/components/Assembly/material.vue";
|
|
|
|
+ import selectTree from "@/benyun/components/selectTree/selectTree.vue";
|
|
@Component
|
|
@Component
|
|
export default class ProductClassification extends Vue {
|
|
export default class ProductClassification extends Vue {
|
|
// 左边
|
|
// 左边
|
|
@@ -41,6 +46,8 @@
|
|
popTitle : any = ''
|
|
popTitle : any = ''
|
|
radio : any = 0
|
|
radio : any = 0
|
|
dialogFormVisible : boolean = false
|
|
dialogFormVisible : boolean = false
|
|
|
|
+ selectTreeChange: any = {}
|
|
|
|
+ selectTreeLoading : boolean = false
|
|
treeConfig = {
|
|
treeConfig = {
|
|
attr: {
|
|
attr: {
|
|
retConfig: {
|
|
retConfig: {
|
|
@@ -169,6 +176,17 @@
|
|
}]
|
|
}]
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
+ selectTreeConfig = {
|
|
|
|
+ attr: {
|
|
|
|
+ label: 'name',
|
|
|
|
+ clearable: true,
|
|
|
|
+ retConfig: {
|
|
|
|
+ parentId: 'id',
|
|
|
|
+ parentName: 'name',
|
|
|
|
+ },
|
|
|
|
+ defaultExpandAll: true
|
|
|
|
+ },
|
|
|
|
+ }
|
|
addConfig = {
|
|
addConfig = {
|
|
attr: {
|
|
attr: {
|
|
size: 'small',
|
|
size: 'small',
|
|
@@ -187,23 +205,24 @@
|
|
span: 23,
|
|
span: 23,
|
|
label: '上级',
|
|
label: '上级',
|
|
labelWidth: '70px',
|
|
labelWidth: '70px',
|
|
|
|
+ slot: true,
|
|
prop: 'parentName',
|
|
prop: 'parentName',
|
|
- component: 'select-tree',
|
|
|
|
- compConfig: {
|
|
|
|
- attr: {
|
|
|
|
- label: 'name',
|
|
|
|
- clearable: true,
|
|
|
|
- retConfig: {
|
|
|
|
- parentId: 'id',
|
|
|
|
- parentName: 'name',
|
|
|
|
- },
|
|
|
|
- defaultExpandAll: true
|
|
|
|
- },
|
|
|
|
- request: {
|
|
|
|
- url: '/maindata/maindataMaterialCategory/treeUseList',
|
|
|
|
- method: 'GET'
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // component: 'select-tree',
|
|
|
|
+ // compConfig: {
|
|
|
|
+ // attr: {
|
|
|
|
+ // label: 'name',
|
|
|
|
+ // clearable: true,
|
|
|
|
+ // retConfig: {
|
|
|
|
+ // parentId: 'id',
|
|
|
|
+ // parentName: 'name',
|
|
|
|
+ // },
|
|
|
|
+ // defaultExpandAll: true
|
|
|
|
+ // },
|
|
|
|
+ // request: {
|
|
|
|
+ // url: '/maindata/maindataMaterialCategory/treeUseList',
|
|
|
|
+ // method: 'GET'
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
span: 23,
|
|
span: 23,
|
|
@@ -278,7 +297,16 @@
|
|
confirm() {
|
|
confirm() {
|
|
(this as any).$refs.addFormId.validate().then(() => {
|
|
(this as any).$refs.addFormId.validate().then(() => {
|
|
let query = (this as any).$refs.addFormId.getValue();
|
|
let query = (this as any).$refs.addFormId.getValue();
|
|
- // console.log('确认新增/编辑 ==> ', query);
|
|
|
|
|
|
+ // console.log('确认新增/编辑 ==> ', query, this.selectTreeChange);
|
|
|
|
+ if(this.selectTreeChange&&this.selectTreeChange.parentId||this.selectTreeChange.parentId==0){
|
|
|
|
+ if(this.selectTreeChange.parentId==0){
|
|
|
|
+ query.parentId = this.selectTreeChange.parentId;
|
|
|
|
+ query.parentName = null;
|
|
|
|
+ }else{
|
|
|
|
+ query.parentId = this.selectTreeChange.parentId;
|
|
|
|
+ query.parentName = this.selectTreeChange.parentName;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
query.status = this.radio;
|
|
query.status = this.radio;
|
|
this.dialogFormVisible = false;
|
|
this.dialogFormVisible = false;
|
|
if (this.popTitle === '新增') {
|
|
if (this.popTitle === '新增') {
|
|
@@ -290,6 +318,7 @@
|
|
this.$message.success(this.popTitle + '成功!');
|
|
this.$message.success(this.popTitle + '成功!');
|
|
// (this as any).$refs.sideTree.request();
|
|
// (this as any).$refs.sideTree.request();
|
|
this.getDataList();
|
|
this.getDataList();
|
|
|
|
+ this.selectTreeChange = {};
|
|
} else this.$message.error(res.msg);
|
|
} else this.$message.error(res.msg);
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
} else if (this.popTitle === '编辑') {
|
|
} else if (this.popTitle === '编辑') {
|
|
@@ -305,6 +334,7 @@
|
|
this.$message.success(this.popTitle + '成功!');
|
|
this.$message.success(this.popTitle + '成功!');
|
|
// (this as any).$refs.sideTree.request();
|
|
// (this as any).$refs.sideTree.request();
|
|
this.getDataList();
|
|
this.getDataList();
|
|
|
|
+ this.selectTreeChange = {};
|
|
} else this.$message.error(res.msg);
|
|
} else this.$message.error(res.msg);
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
}
|
|
}
|
|
@@ -350,6 +380,31 @@
|
|
}
|
|
}
|
|
}).catch(() => loading.close());
|
|
}).catch(() => loading.close());
|
|
}
|
|
}
|
|
|
|
+ getSelectTreeList(){
|
|
|
|
+ this.selectTreeLoading = true;
|
|
|
|
+ api.treeList('maindataMaterialCategory').then((treeRes : any) => {
|
|
|
|
+ if (treeRes.code === 200) {
|
|
|
|
+ this.selectTreeLoading = false;
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
+ var data:any = [{
|
|
|
|
+ id: 0,
|
|
|
|
+ name: '物料分类',
|
|
|
|
+ children: treeRes.data
|
|
|
|
+ }];
|
|
|
|
+ (this as any).$refs.selectTree.setData(data);
|
|
|
|
+ let query = (this as any).$refs.addFormId.getValue();
|
|
|
|
+ if(query.parentId==0){
|
|
|
|
+ (this as any).$refs.selectTree.setValue("物料分类");
|
|
|
|
+ }else{
|
|
|
|
+ (this as any).$refs.selectTree.setValue(query.parentName);
|
|
|
|
+ }
|
|
|
|
+ },0)
|
|
|
|
+ }
|
|
|
|
+ }).catch(() => {});
|
|
|
|
+ }
|
|
|
|
+ selectTree(e:any){
|
|
|
|
+ this.selectTreeChange = e
|
|
|
|
+ }
|
|
// 工具栏方法
|
|
// 工具栏方法
|
|
clickHandle(e : any) {
|
|
clickHandle(e : any) {
|
|
if (e === 'onAdd') this.onAdd();
|
|
if (e === 'onAdd') this.onAdd();
|
|
@@ -358,7 +413,8 @@
|
|
onAdd() {
|
|
onAdd() {
|
|
this.popTitle = '新增'
|
|
this.popTitle = '新增'
|
|
this.dialogFormVisible = true;
|
|
this.dialogFormVisible = true;
|
|
- this.radio = 0
|
|
|
|
|
|
+ this.radio = 0;
|
|
|
|
+ this.getSelectTreeList();
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
if(this.parentId!=0){
|
|
if(this.parentId!=0){
|
|
var data = {
|
|
var data = {
|
|
@@ -370,12 +426,14 @@
|
|
data.parentName = res.data.name;
|
|
data.parentName = res.data.name;
|
|
data.parentId = res.data.id;
|
|
data.parentId = res.data.id;
|
|
this.dialogFormVisible = true;
|
|
this.dialogFormVisible = true;
|
|
- setTimeout(() => { (this as any).$refs.addFormId.setValue(data) }, 0);
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ (this as any).$refs.addFormId.setValue(data)
|
|
|
|
+ }, 0);
|
|
}
|
|
}
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
}else{
|
|
}else{
|
|
(this as any).$refs.addFormId.setValue();
|
|
(this as any).$refs.addFormId.setValue();
|
|
- (this as any).$refs.addFormId.$refs['parentName--comp'][0].request();
|
|
|
|
|
|
+ // (this as any).$refs.addFormId.$refs['parentName--comp'][0].request();
|
|
}
|
|
}
|
|
}, 0)
|
|
}, 0)
|
|
}
|
|
}
|
|
@@ -394,13 +452,19 @@
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
data.parentName = res.data.name;
|
|
data.parentName = res.data.name;
|
|
this.dialogFormVisible = true;
|
|
this.dialogFormVisible = true;
|
|
- setTimeout(() => { (this as any).$refs.addFormId.setValue(data) }, 0);
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.getSelectTreeList();
|
|
|
|
+ (this as any).$refs.addFormId.setValue(data)
|
|
|
|
+ }, 0);
|
|
}
|
|
}
|
|
}).catch(() => loading.close());
|
|
}).catch(() => loading.close());
|
|
}else{
|
|
}else{
|
|
loading.close();
|
|
loading.close();
|
|
this.dialogFormVisible = true;
|
|
this.dialogFormVisible = true;
|
|
- setTimeout(() => { (this as any).$refs.addFormId.setValue(data) }, 0);
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.getSelectTreeList();
|
|
|
|
+ (this as any).$refs.addFormId.setValue(data)
|
|
|
|
+ }, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}).catch(() => loading.close());
|
|
}).catch(() => loading.close());
|