|
|
@@ -41,15 +41,17 @@
|
|
|
</el-card>
|
|
|
|
|
|
<el-dialog :title="Title" :visible.sync="visible" top="5vh">
|
|
|
- <el-form :model="BusinessForm" label-width="100px">
|
|
|
+ <el-form ref="BusinessForm" :rules="formRules" :model="BusinessForm" label-width="100px">
|
|
|
<el-row>
|
|
|
<el-col :span="12" v-if="SupplierTypeCode == '01' && Title == '新增准入范围'">
|
|
|
- <el-form-item label="名称" required>
|
|
|
- <el-select filterable default-first-option v-model="OneCode" placeholder="请选择" style="width: 100%"
|
|
|
+ <el-form-item label="名称" prop="checkName">
|
|
|
+ <!-- <el-select filterable default-first-option v-model="OneCode" placeholder="请选择" style="width: 100%"
|
|
|
@change="getChild()">
|
|
|
- <el-option v-for="item in oneList" :key="item.Id" :label="item.Name" :value="item.Id">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
+ <el-option v-for="item in oneList" :key="item.Id" :label="item.Name" :value="item.Id"></el-option>
|
|
|
+ </el-select> -->
|
|
|
+ <el-cascader ref="cascader" :options="optionsList" style="width:100%" :props="goodsProps" :show-all-levels="false"
|
|
|
+ v-model="selectedOptList" @active-item-change="getChildrens" @change="getGoodsCode" placeholder="请选择分类">
|
|
|
+ </el-cascader>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12" v-if="SupplierTypeCode == '02' && Title == '新增准入范围'">
|
|
|
@@ -60,7 +62,7 @@
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12" v-if="SupplierTypeCode != '02' && Title == '新增准入范围'">
|
|
|
+ <el-col :span="12" v-if="SupplierTypeCode == '03' && Title == '新增准入范围'">
|
|
|
<el-form-item label="名称" required>
|
|
|
<el-cascader :options="techTreeList" :props="orgtreeprops" change-on-select :show-all-levels="false"
|
|
|
v-model="selectedorg" placeholder="请选择菜单" @change="getCode()" style="width:100%"></el-cascader>
|
|
|
@@ -158,6 +160,13 @@
|
|
|
})
|
|
|
},
|
|
|
data () {
|
|
|
+ var CheckSelectedOption = (rule, value, callback) => {
|
|
|
+ if (this.selectedOptList && this.selectedOptList.length < 1) {
|
|
|
+ callback(new Error('请选择分类'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ };
|
|
|
return {
|
|
|
oneList: [],
|
|
|
OneCode: '',
|
|
|
@@ -195,10 +204,83 @@
|
|
|
Size: 10,
|
|
|
CurrentItemCount: 0,
|
|
|
|
|
|
- subfileList: [] // 文档
|
|
|
+ subfileList: [], // 文档
|
|
|
+ //物资类懒加载
|
|
|
+ optionsList: [], //物资类层级列表
|
|
|
+ selectedOptList: [], //已选择的物资类列表
|
|
|
+ goodsProps: {
|
|
|
+ value: 'id',
|
|
|
+ label: 'Name',
|
|
|
+ children: 'children'
|
|
|
+ },
|
|
|
+ //物资类表单规则
|
|
|
+ formRules: {
|
|
|
+ checkName: [{
|
|
|
+ required: true,
|
|
|
+ validator: CheckSelectedOption,
|
|
|
+ trigger: 'blur'
|
|
|
+ }],
|
|
|
+ },
|
|
|
+ // ParentId: 0, //物资类初始父类Id值:0
|
|
|
+ flagId: 0 //标记是否第一次点击
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+
|
|
|
+ //获取下一级所有分类
|
|
|
+ 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
|
|
|
+ getGoodsCode(item) {
|
|
|
+ this.getCodeById(item[item.length-1]) //根据分类Id获取Code
|
|
|
+ },
|
|
|
+
|
|
|
+ //根据分类Id获取Code
|
|
|
+ getCodeById(Id) {
|
|
|
+ let _this = this
|
|
|
+ this.$axios.get('goodsaptitudeclass/getcode/' + Id, {})
|
|
|
+ .then(res => {
|
|
|
+ _this.BusinessForm.SubClassId = Id
|
|
|
+ _this.BusinessForm.Code = res.data.items[0].Code
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
getvalue (SupplierId, SupplierTypeCode, certId) {
|
|
|
this.SupplierId = SupplierId
|
|
|
this.SupplierTypeCode = SupplierTypeCode
|
|
|
@@ -235,10 +317,20 @@
|
|
|
},
|
|
|
addBusiness () {
|
|
|
let _this = this
|
|
|
+ let arr = []
|
|
|
+ arr = _this.$refs['cascader'].currentLabels
|
|
|
+ _this.BusinessForm.Name = arr[arr.length - 1]
|
|
|
_this.BusinessForm.SupplierId = parseInt(_this.BusinessForm.SupplierId)
|
|
|
_this.BusinessForm.SupplierCertId = parseInt(_this.BusinessForm.SupplierCertId)
|
|
|
_this.BusinessForm.SubClassId = parseInt(_this.BusinessForm.SubClassId)
|
|
|
- _this.$axios.post('/suppliercertsub/addbusiness/', _this.BusinessForm)
|
|
|
+ //因为表单验证不能用,所以采用提示验证
|
|
|
+ if (_this.selectedOptList.length < 1) {
|
|
|
+ _this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '名称不能为空,请选择分类!'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _this.$axios.post('/suppliercertsub/addbusiness/', _this.BusinessForm)
|
|
|
.then(res => {
|
|
|
if (res.data.code === 0) {
|
|
|
_this.$message({
|
|
|
@@ -258,6 +350,7 @@
|
|
|
.catch(err => {
|
|
|
console.error(err)
|
|
|
})
|
|
|
+ }
|
|
|
},
|
|
|
editBusiness () {
|
|
|
let _this = this
|
|
|
@@ -319,6 +412,7 @@
|
|
|
this.keyword = ''
|
|
|
this.seachdata()
|
|
|
this.Title = '新增准入范围'
|
|
|
+ this.selectedOptList = [] //置空,防止先修改再添加时的已选分类信息保留
|
|
|
this.BusinessForm.Id = ''
|
|
|
this.BusinessForm.SupplierId = this.SupplierId
|
|
|
this.BusinessForm.SupplierCertId = this.SupplierCertId
|
|
|
@@ -347,17 +441,21 @@
|
|
|
},
|
|
|
getbusiness () {
|
|
|
let _this = this
|
|
|
- if (_this.SupplierTypeCode === '01') { // 获取物资类业务列表
|
|
|
+ if (_this.SupplierTypeCode === '01') { // 获取物资类第一级分类
|
|
|
this.$axios.get('goodsaptitude/goodsparentlist', {})
|
|
|
.then(res => {
|
|
|
- _this.oneList = res.data.items
|
|
|
- if (_this.Title === '编辑准入范围') {
|
|
|
- for (var i = 0; i < _this.oneList.length; i++) {
|
|
|
- if (_this.BusinessForm.Code === _this.oneList[i].Code) {
|
|
|
- _this.OneCode = _this.oneList[i].Id
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ _this.optionsList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId', 'Id,Name')
|
|
|
+ _this.optionsList.forEach((item,index)=>{
|
|
|
+ _this.$set(this.optionsList[index], 'children', [])
|
|
|
+ })
|
|
|
+ // _this.oneList = res.data.items
|
|
|
+ // if (_this.Title === '编辑准入范围') {
|
|
|
+ // for (var i = 0; i < _this.oneList.length; i++) {
|
|
|
+ // if (_this.BusinessForm.Code === _this.oneList[i].Code) {
|
|
|
+ // _this.OneCode = _this.oneList[i].Id
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
})
|
|
|
.catch(err => {
|
|
|
console.error(err)
|