|
@@ -12,32 +12,16 @@
|
|
|
</module-view>
|
|
|
</div>
|
|
|
<!-- 新增/编辑弹窗 -->
|
|
|
- <el-dialog :title="popTitle+'机构商品分类'" :visible.sync="dialogFormVisible2" width="30%">
|
|
|
- <by-form :propConfig="addConfig2" ref="addFormId2">
|
|
|
- <template v-slot:logo>
|
|
|
- <el-upload :limit='1' :action="baseURL+'/file/upload'" list-type="picture-card"
|
|
|
- :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
|
|
|
- <i class="el-icon-plus"></i>
|
|
|
- </el-upload>
|
|
|
- </template>
|
|
|
- <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="1">禁用</el-radio>
|
|
|
- </template>
|
|
|
- </by-form>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="dialogFormVisible2 = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="confirm2">确 定</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
- <!-- 新增/编辑弹窗 -->
|
|
|
- <el-dialog :title="popTitle+'机构商品分类'" :visible.sync="dialogFormVisible" width="30%">
|
|
|
+ <el-dialog :title="popTitle+'机构商品分类'" :visible.sync="dialogFormVisible" width="30%" :destroy-on-close="true">
|
|
|
<by-form :propConfig="addConfig" ref="addFormId">
|
|
|
<template v-slot:logo>
|
|
|
<el-upload :limit='1' :action="baseURL+'/file/upload'" list-type="picture-card"
|
|
|
:on-preview="handlePictureCardPreview" :on-remove="handleRemove">
|
|
|
<i class="el-icon-plus"></i>
|
|
|
</el-upload>
|
|
|
+ </template>
|
|
|
+ <template v-slot:select-tree class="clearfix">
|
|
|
+
|
|
|
</template>
|
|
|
<template v-slot:status class="clearfix">
|
|
|
<el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">正常</el-radio>
|
|
@@ -63,8 +47,6 @@
|
|
|
popTitle : any = ''
|
|
|
radio : any = 0
|
|
|
dialogFormVisible : boolean = false
|
|
|
- dialogFormVisible2 : boolean = false
|
|
|
- datlis : boolean = true
|
|
|
treeConfig = {
|
|
|
attr: {
|
|
|
retConfig: {
|
|
@@ -73,12 +55,12 @@
|
|
|
},
|
|
|
defaultExpandAll: true,
|
|
|
label: 'name',
|
|
|
- resType: 'data'
|
|
|
+ // resType: 'data'
|
|
|
},
|
|
|
- request: {
|
|
|
- url: '/maindata/maindataMaterialOrganizationCategory/treeList',
|
|
|
- method: 'GET'
|
|
|
- }
|
|
|
+ // request: {
|
|
|
+ // url: '/maindata/maindataMaterialOrganizationCategory/treeList',
|
|
|
+ // method: 'GET'
|
|
|
+ // }
|
|
|
}
|
|
|
config : any = {
|
|
|
attr:{
|
|
@@ -200,9 +182,9 @@
|
|
|
name: [{
|
|
|
required: true, message: '请输入名称', trigger: 'blur'
|
|
|
}],
|
|
|
- parentName: [{
|
|
|
- required: true, message: '请选择上级', trigger: 'change'
|
|
|
- }],
|
|
|
+ // parentName: [{
|
|
|
+ // required: true, message: '请选择上级', trigger: 'change'
|
|
|
+ // }],
|
|
|
}
|
|
|
},
|
|
|
columns: [
|
|
@@ -269,61 +251,22 @@
|
|
|
],
|
|
|
]
|
|
|
}
|
|
|
- addConfig2 = {
|
|
|
- attr: {
|
|
|
- size: 'small',
|
|
|
- rules: {
|
|
|
- name: [{
|
|
|
- required: true, message: '请输入名称', trigger: 'blur'
|
|
|
- }],
|
|
|
- }
|
|
|
- },
|
|
|
- columns: [
|
|
|
- [
|
|
|
- {
|
|
|
- labelWidth: '70px',
|
|
|
- span: 23,
|
|
|
- label: '名称',
|
|
|
- prop: 'name',
|
|
|
- component: 'by-input',
|
|
|
- },
|
|
|
- {
|
|
|
- labelWidth: '70px',
|
|
|
- span: 23,
|
|
|
- label: '简称',
|
|
|
- slot: true,
|
|
|
- prop: 'shortName',
|
|
|
- component: 'by-input',
|
|
|
- },
|
|
|
- {
|
|
|
- labelWidth: '70px',
|
|
|
- span: 23,
|
|
|
- label: '状态',
|
|
|
- slot: true,
|
|
|
- prop: 'status',
|
|
|
- },
|
|
|
- {
|
|
|
- labelWidth: '70px',
|
|
|
- span: 23,
|
|
|
- label: '备注',
|
|
|
- slot: true,
|
|
|
- prop: 'remark',
|
|
|
- component: 'by-input',
|
|
|
- compConfig: {
|
|
|
- attr: {
|
|
|
- size: 'mini',
|
|
|
- placeholder: '请输入备注',
|
|
|
- type: 'textarea'
|
|
|
- },
|
|
|
- }
|
|
|
- },
|
|
|
- ],
|
|
|
- ]
|
|
|
- }
|
|
|
mounted() {
|
|
|
this.timer = setInterval(() => {
|
|
|
this.getDataList()
|
|
|
}, 300)
|
|
|
+ this.getTreeList();
|
|
|
+ }
|
|
|
+ getTreeList(){
|
|
|
+ api.treeList('maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
+ console.log(res);
|
|
|
+ var data:any = [{
|
|
|
+ id: 0,
|
|
|
+ name: '机构商品分类',
|
|
|
+ children: res.data
|
|
|
+ }];
|
|
|
+ (this as any).$refs.sideTree.setData(data);
|
|
|
+ })
|
|
|
}
|
|
|
//点击树获取数据
|
|
|
onChangeTree(e : any) {
|
|
@@ -355,16 +298,25 @@
|
|
|
api.saveList(query, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message.success(this.popTitle + '成功!');
|
|
|
- (this as any).$refs.sideTree.request();
|
|
|
+ // (this as any).$refs.sideTree.request();
|
|
|
+ this.getTreeList()
|
|
|
this.dialogFormVisible = false;
|
|
|
this.getDataList();
|
|
|
} else this.$message.error(res.msg);
|
|
|
}).catch(() => {});
|
|
|
} else if (this.popTitle === '编辑') {
|
|
|
+ if(!query.parentId){
|
|
|
+ query.parentId=0
|
|
|
+ }
|
|
|
+ if(query.parentId==query.id){
|
|
|
+ this.$message.error('不能设置自己是自己的上级节点')
|
|
|
+ return false
|
|
|
+ }
|
|
|
api.updateList(query, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message.success(this.popTitle + '成功!');
|
|
|
- (this as any).$refs.sideTree.request();
|
|
|
+ // (this as any).$refs.sideTree.request();
|
|
|
+ this.getTreeList()
|
|
|
this.dialogFormVisible = false;
|
|
|
this.getDataList();
|
|
|
} else this.$message.error(res.msg);
|
|
@@ -372,32 +324,6 @@
|
|
|
}
|
|
|
}).catch(() => {});
|
|
|
}
|
|
|
- confirm2() {
|
|
|
- (this as any).$refs.addFormId2.validate().then(() => {
|
|
|
- let query = (this as any).$refs.addFormId2.getValue();
|
|
|
- query.status = this.radio;
|
|
|
- if (this.popTitle === '新增') {
|
|
|
- query.parentId = 0;
|
|
|
- api.saveList(query, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.$message.success(this.popTitle + '成功!');
|
|
|
- (this as any).$refs.sideTree.request();
|
|
|
- this.dialogFormVisible2 = false;
|
|
|
- this.getDataList();
|
|
|
- } else this.$message.error(res.msg);
|
|
|
- }).catch(() => {});
|
|
|
- } else if (this.popTitle === '编辑') {
|
|
|
- api.updateList(query, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.$message.success(this.popTitle + '成功!');
|
|
|
- (this as any).$refs.sideTree.request();
|
|
|
- this.dialogFormVisible2 = false;
|
|
|
- this.getDataList();
|
|
|
- } else this.$message.error(res.msg);
|
|
|
- }).catch(() => {});
|
|
|
- }
|
|
|
- }).catch(() => {});
|
|
|
- }
|
|
|
// 获取列表数据
|
|
|
getDataList() {
|
|
|
if (!this.$refs.moduleView) {
|
|
@@ -418,11 +344,6 @@
|
|
|
api.pageList(query, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
loading.close();
|
|
|
if (res.code === 200) {
|
|
|
- if(res.data.records.length==0){
|
|
|
- this.datlis = false
|
|
|
- }else{
|
|
|
- this.datlis = true
|
|
|
- };
|
|
|
(this.$refs.moduleView as any).setTableValue(res.data.records);
|
|
|
let page = {
|
|
|
pageNo: res.data.current, //当前页
|
|
@@ -441,25 +362,22 @@
|
|
|
onAdd() {
|
|
|
this.popTitle = '新增'
|
|
|
this.radio = 0
|
|
|
- console.log(this.datlis)
|
|
|
- if(!this.datlis){
|
|
|
- this.dialogFormVisible2 = true;
|
|
|
- }else{
|
|
|
- this.dialogFormVisible = true;
|
|
|
- setTimeout(() => {
|
|
|
- (this as any).$refs.addFormId.setValue();
|
|
|
- (this as any).$refs.addFormId.$refs['parentName--comp'][0].request();
|
|
|
- this.$nextTick(()=>{
|
|
|
- (this as any).$refs.addFormId.clearValidate();
|
|
|
- })
|
|
|
- }, 0)
|
|
|
- }
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ this.getTreeList();
|
|
|
+ setTimeout(() => {
|
|
|
+ (this as any).$refs.addFormId.setValue();
|
|
|
+ (this as any).$refs.addFormId.$refs['parentName--comp'][0].request();
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ (this as any).$refs.addFormId.clearValidate();
|
|
|
+ })
|
|
|
+ }, 0)
|
|
|
}
|
|
|
// 打开编辑
|
|
|
openEdit(e : any) {
|
|
|
console.log('打开编辑 ==> ', e);
|
|
|
this.popTitle = '编辑';
|
|
|
let loading = this.$loading({ target: '.main-container' });
|
|
|
+ this.getTreeList();
|
|
|
api.single({ id: e.id }, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
let data = res.data;
|
|
@@ -468,7 +386,6 @@
|
|
|
api.single({ id: data.parentId }, 'maindataMaterialOrganizationCategory').then((v : any) => {
|
|
|
loading.close();
|
|
|
if (v.code === 200) {
|
|
|
- console.log(data.parentId)
|
|
|
data.parentName = v.data.name;
|
|
|
this.dialogFormVisible = true;
|
|
|
setTimeout(() => { (this as any).$refs.addFormId.setValue(data) }, 0);
|
|
@@ -476,9 +393,10 @@
|
|
|
}).catch(() => loading.close());
|
|
|
}else{
|
|
|
loading.close();
|
|
|
- this.dialogFormVisible2 = true;
|
|
|
- setTimeout(() => { (this as any).$refs.addFormId2.setValue(data) }, 0);
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ setTimeout(() => { (this as any).$refs.addFormId.setValue(data) }, 0);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}).catch(() => loading.close());
|
|
|
}
|
|
@@ -492,7 +410,8 @@
|
|
|
}).then(() => {
|
|
|
api.delCategoryId({ id: item.id }, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
- (this as any).$refs.sideTree.request();
|
|
|
+ // (this as any).$refs.sideTree.request();
|
|
|
+ this.getTreeList()
|
|
|
this.getDataList();
|
|
|
this.$message.success('删除成功');
|
|
|
} else this.$message.error(res.msg);
|
|
@@ -502,7 +421,8 @@
|
|
|
// 刷新/重置
|
|
|
onRefresh() {
|
|
|
(this as any).$refs.moduleView.clearSearch();
|
|
|
- (this as any).$refs.sideTree.request();
|
|
|
+ // (this as any).$refs.sideTree.request();
|
|
|
+ this.getTreeList()
|
|
|
this.parentIds = '';
|
|
|
this.getDataList();
|
|
|
}
|