|
|
@ -10,7 +10,7 @@ |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="门类类型" prop="isType"> |
|
|
|
<el-select v-model="form.isType" style="width: 370px;" :disabled="crud.status.edit === 1" @change="changeType"> |
|
|
|
<el-option v-for="item in selectOptions" :key="item.value" :label="item.label" :value="item.value" /> |
|
|
|
<el-option v-for="item in selectOptions" :key="item.value" :label="item.label" :value="item.value" :disabled="item.typeState" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item v-if="crud.status.add === 1" label="选择模板" prop="dicExplain"> |
|
|
@ -30,7 +30,7 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getCategoryTree, getCategoryType } from '@/api/category/category' |
|
|
|
import { form } from '@crud/crud' |
|
|
|
import CRUD, { form } from '@crud/crud' |
|
|
|
import Treeselect from '@riophae/vue-treeselect' |
|
|
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css' |
|
|
|
|
|
|
@ -42,6 +42,14 @@ export default { |
|
|
|
return Object.assign({ pid: this.pid }, defaultForm) |
|
|
|
}) |
|
|
|
], |
|
|
|
props: { |
|
|
|
selectedCategory: { |
|
|
|
type: Object, |
|
|
|
default: function() { |
|
|
|
return {} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
pid: null, |
|
|
@ -58,6 +66,27 @@ export default { |
|
|
|
this.getSelectOptions() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 新建时,判断当前节点类型,“门类类型” option区分可选 |
|
|
|
[CRUD.HOOK.beforeToAdd]() { |
|
|
|
this.form.isType = null |
|
|
|
this.selectOptions.forEach(item => { |
|
|
|
if (this.selectedCategory.isType === 2) { |
|
|
|
if (item.value !== 3) { |
|
|
|
item.typeState = true |
|
|
|
} |
|
|
|
} else if (this.selectedCategory.isType === 3) { |
|
|
|
if (item.value !== 4) { |
|
|
|
item.typeState = true |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 表单取消之后,“门类类型”可选状态恢复默认 |
|
|
|
[CRUD.HOOK.beforeAddCancel]() { |
|
|
|
this.selectOptions.forEach(item => { |
|
|
|
item.typeState = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
changeType() { |
|
|
|
if (this.form.isType === 6) { |
|
|
|
// this.crudDict.getDicts() |
|
|
@ -74,7 +103,8 @@ export default { |
|
|
|
for (const key in res) { |
|
|
|
this.selectOptions.push({ |
|
|
|
value: Number(key), |
|
|
|
label: res[key] |
|
|
|
label: res[key], |
|
|
|
typeState: false |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|