Commit 0cf6a9af authored by trumansdo's avatar trumansdo
Browse files

- doing

parent 9af1aa03
<!-- <!--
* @Author: 一日看尽长安花 * @Author: 一日看尽长安花
* @since: 2020-05-30 12:53:38 * @since: 2020-05-30 12:53:38
* @LastEditTime: 2020-05-31 21:13:33 * @LastEditTime: 2020-06-01 22:02:17
* @LastEditors: 一日看尽长安花 * @LastEditors: 一日看尽长安花
* @Description: * @Description:
--> -->
...@@ -93,7 +93,12 @@ ...@@ -93,7 +93,12 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<sel-func-dialog :visible.sync="dialogVisible" :tree-data="treeData"> <sel-func-dialog
v-model="formModel"
:per-level-label="['parent']"
:visible.sync="dialogVisible"
:tree-data="treeData"
>
</sel-func-dialog> </sel-func-dialog>
</div> </div>
</template> </template>
......
<!-- <!--
* @Author: 一日看尽长安花 * @Author: 一日看尽长安花
* @since: 2020-05-30 12:53:38 * @since: 2020-05-30 12:53:38
* @LastEditTime: 2020-05-31 21:28:18 * @LastEditTime: 2020-06-01 22:49:52
* @LastEditors: 一日看尽长安花 * @LastEditors: 一日看尽长安花
* @Description: * @Description:
--> -->
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
ref="tree" ref="tree"
:data="treeData" :data="treeData"
node-key="id" node-key="id"
:label="label"
:show-checkbox="true" :show-checkbox="true"
default-expand-all default-expand-all
:check-strictly="true"
:expand-on-click-node="false" :expand-on-click-node="false"
:filter-node-method="filterNode" :filter-node-method="filterNode"
> >
...@@ -30,11 +32,7 @@ ...@@ -30,11 +32,7 @@
</template> </template>
</el-tree> </el-tree>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button <el-button type="primary" @click="saveSelect">确 定</el-button>
type="primary"
@click="dialogFormVisible = false"
>确 定</el-button
>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
...@@ -45,6 +43,10 @@ import { funcs } from '@/api/func'; ...@@ -45,6 +43,10 @@ import { funcs } from '@/api/func';
export default { export default {
name: 'SelFuncDialog', name: 'SelFuncDialog',
components: {}, components: {},
model: {
prop: 'value',
event: 'updateValue'
},
props: { props: {
visible: { visible: {
type: Boolean, type: Boolean,
...@@ -55,6 +57,18 @@ export default { ...@@ -55,6 +57,18 @@ export default {
default: function() { default: function() {
return []; return [];
} }
},
label: {
type: String,
default: 'name'
},
perLevelLabel: {
type: Array,
required: true
},
value: {
type: Object,
required: true
} }
}, },
data() { data() {
...@@ -71,6 +85,31 @@ export default { ...@@ -71,6 +85,31 @@ export default {
filterNode(value, data) { filterNode(value, data) {
if (!value) return true; if (!value) return true;
return data.name.indexOf(value) !== -1; return data.name.indexOf(value) !== -1;
},
saveSelect() {
// 包括半选节点
const selNodes = this.$refs.tree.getCheckedNodes(false, true);
if (selNodes && selNodes.length === 0) {
this.$emit('update:visible', false);
}
if (selNodes && selNodes.length !== 1) {
this.$message({
message: '只能选择一个节点',
type: 'warning'
});
return;
}
let _node = this.$refs.tree.getNode(selNodes[0]);
let resObj = {};
for (let i = this.perLevelLabel.length - 1; i >= 0; i--) {
const _label = this.perLevelLabel[i];
this.$lodash.set(resObj, _label, _node.data);
_node = _node.parent;
}
debugger;
const updateValue = this.$lodash.assignIn({}, this.value, resObj);
this.$emit('updateValue', updateValue);
this.$emit('update:visible', false);
} }
} }
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment