|
|
@@ -86,8 +86,8 @@
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="分类名称" prop="checkSelectedOptList">
|
|
|
- <el-cascader ref="cascader" :options="optionsList" style="width:100%" :props="goodsProps" change-on-select :show-all-levels="false"
|
|
|
- v-model="selectedOptList" @change="getCode" placeholder="请选择分类">
|
|
|
+ <el-cascader ref="cascader" :options="optionsList" style="width:100%" :props="goodsProps" :show-all-levels="false"
|
|
|
+ v-model="selectedOptList" @active-item-change="getChildrens" @change="getCode" placeholder="请选择分类">
|
|
|
</el-cascader>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -160,6 +160,8 @@
|
|
|
label: 'Name',
|
|
|
children: 'children'
|
|
|
},
|
|
|
+ ParentId: 0, //物资类初始父类Id值:0
|
|
|
+ flagId: 0, //标记是否第一次点击
|
|
|
organizeTreeList: [], //推荐单位层级列表
|
|
|
selectedOrgList: [], //已选择的单位列表
|
|
|
organizeTreeProps: {
|
|
|
@@ -244,7 +246,7 @@
|
|
|
this.getSortList()
|
|
|
}
|
|
|
this.getOrgTreeList() //获取推荐单位层级列表
|
|
|
- this.getGoodsTreeList() //获取物资类层级列表
|
|
|
+ this.getGoodsTreeList(this.ParentId) //获取物资类层级列表
|
|
|
this.getSupplierList() //获取供应方公司列表
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -279,17 +281,56 @@
|
|
|
},
|
|
|
|
|
|
//获取物资类层级列表
|
|
|
- getGoodsTreeList() {
|
|
|
+ getGoodsTreeList(Id) {
|
|
|
let _this = this
|
|
|
- this.$axios.get('goodsaptitudeclass/getgoodsclasslist', {})
|
|
|
+ this.$axios.get('goodsaptitudeclass/getgoodsclasslist/' + Id, {})
|
|
|
.then(res => {
|
|
|
_this.optionsList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId', 'Id,Name')
|
|
|
+ _this.optionsList.forEach((item,index)=>{
|
|
|
+ _this.$set(this.optionsList[index], 'children', [])
|
|
|
+ })
|
|
|
})
|
|
|
.catch(err => {
|
|
|
console.error(err)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ //获取下一级分类
|
|
|
+ getChildrens(val) {
|
|
|
+ let _this = this
|
|
|
+ let Id = val[0]
|
|
|
+ if (Id != _this.flagId) { //判断是否是第一次,若不相等则为第一次
|
|
|
+ this.$axios.get('goodsaptitudeclass/getchildlist/' + Id, {})
|
|
|
+ .then(res => {
|
|
|
+ //获取下一级所有级联数据
|
|
|
+ if (res.data.items) {//判断是否有数据
|
|
|
+ let tempList = []
|
|
|
+ tempList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId', 'Id,Name')
|
|
|
+ //添加到上一级对应的选项中
|
|
|
+ for (let i = 0; i < _this.optionsList.length; i++) {
|
|
|
+ if (_this.optionsList[i].id === Id) {
|
|
|
+ _this.$set(_this.optionsList[i], 'children', tempList)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //修改上一级的children属性
|
|
|
+ for (let i = 0; i < _this.optionsList.length; i++) {
|
|
|
+ if (_this.optionsList[i].id === Id) {
|
|
|
+ _this.$set(_this.optionsList[i], 'children', '')
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //做标记
|
|
|
+ _this.flagId = Id
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
//获取分类级联Id
|
|
|
getCode(item) {
|
|
|
let sortFlagStr = item.toString()
|
|
|
@@ -457,6 +498,32 @@
|
|
|
}
|
|
|
_this.selectedOptList = arr2
|
|
|
}
|
|
|
+ let Id = _this.selectedOptList[0]
|
|
|
+ this.$axios.get('goodsaptitudeclass/getchildlist/' + Id, {})
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.items) {//判断是否有数据
|
|
|
+ let tempList = []
|
|
|
+ tempList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId', 'Id,Name')
|
|
|
+ //添加到上一级对应的选项中
|
|
|
+ for (let i = 0; i < _this.optionsList.length; i++) {
|
|
|
+ if (_this.optionsList[i].id === Id) {
|
|
|
+ _this.$set(_this.optionsList[i], 'children', tempList)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //修改上一级的children属性
|
|
|
+ for (let i = 0; i < _this.optionsList.length; i++) {
|
|
|
+ if (_this.optionsList[i].id === Id) {
|
|
|
+ _this.$set(_this.optionsList[i], 'children', '')
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
//取消
|