<template>
<div style="padding: 8px 8px;">
<!-- 搜索/高级搜索 -->
<searchinput ref="search" :options="options" @reload="reload">
<template>
<div style="padding: 5px 0;">
<el-button size="mini" type="primary" @click="newAdd()"
>导出Excel</el-button
>
<el-button
size="mini"
type="primary"
icon="el-icon-plus"
@click="newAdd()"
>新增项目</el-button
>
</div>
</template>
</searchinput>
<div class="biaoge">
<!-- 表格 -->
<avue-crud
ref="crud"
:data="tableData"
:option="option"
:page="page"
@on-load="onLoad"
class="guding"
@selection-change="selectionChange"
>
<!-- <template slot-scope="{ row }" slot="vForm">
<el-row :span="24">
<el-col :span="24">
<treeselect
v-model="row.basebybjmingcheng"
:multiple="true"
:options="treeData"
value-consists-of="LEAF_PRIORITY"
:tree="true"
clearable
placeholder="请选择部件名称"
>
</treeselect>
</el-col>
</el-row>
</template> -->
<template slot="basebybjmingcheng" slot-scope="{ row }">
<treeselect
v-model="row.basebybjmingcheng"
:options="treeData"
value-consists-of="LEAF_PRIORITY"
:tree="true"
clearable
placeholder="请选择部件名称"
>
</treeselect>
</template>
</avue-crud>
</div>
</div>
</template>
<script>
import searchinput from "@/views/erp/controls/ctrsearchinput.vue";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { mapGetters } from "vuex";
import { geturl, posturl } from "@/api/ajax";
import {
getsByxiangmuweihu,
delByxiangmuweihu,
postByxiangmuweihu,
getByxiangmuweihu
} from "@/api/baoyang/byxiangmuweihu";
export default {
components: { searchinput, Treeselect },
data() {
return {
page: {
pageSize: 20,
currentPage: 1,
total: 0
},
guding: "",
tableData: [],
option: {
selectionWidth: 35, //行可勾选的宽度
indexWidth: 35, //序号的宽度
stripe: true,
menuAlign: "center",
menuWidth: 150,
// dialogModal: false,
// dialogEscape: true,
// dialogDirection: "rtl",
// dialogType: "drawer",
tip: false,
border: true,
index: true,
addBtn: false,
delBtn: true,
menu: true, //操作栏显隐
editBtn: true,
columnBtn: false,
refreshBtn: false,
cancelBtn: false,
indexFixed: false,
selectionFixed: false,
rowKey: "byxiangmuweihuid",
indexLabel: "序号",
selection: false,
selectable: (row, index) => {
return index === 1;
},
column: [
{
label: "设备名称",
prop: "shebeimingcheng",
overHidden: true,
width: 150
},
{
label: "部件名称",
prop: "basebybjmingcheng",
overHidden: true,
width: 150,
slot: true
},
{
label: "保养方式",
prop: "baoyangfangshi",
width: 80,
type: "select",
dicData: [
{
label: "时间",
value: "0"
},
{
label: "转数",
value: "1"
}
],
overHidden: true
},
{
label: "保养周期",
prop: "baoyangzhouqi",
overHidden: true,
width: 120
},
{
label: "保养说明",
prop: "byshuoming",
overHidden: true
},
{
label: "保养用时",
prop: "baoyangyongshi",
overHidden: true,
width: 120
},
{
label: "参与人员",
prop: "canyurenyuan",
overHidden: true,
width: 150
},
{
label: "创建人",
prop: "chuangjianren",
overHidden: true,
width: 150,
display: false
},
{
label: "创建时间",
prop: "chuangjianrq",
type: "date",
format: "MM-dd hh:mm",
valueFormat: "yyyy-MM-dd hh:mm:ss",
overHidden: true,
width: 150,
display: false
}
]
},
options: {
placeholder: "",
self: true,
refrash: true,
change: true,
hideSearch: true,
hideClickSearch: true,
hideGroup: true,
query: {
__bianhao__: "byxiangmuweihu"
},
columns: [
{
title: "设备名称",
prop: "shebeimingcheng",
type: "input"
},
{
title: "保养方式",
prop: "baoyangfangshi",
type: "select",
dicData: [
{
label: "时间",
value: "0"
},
{
label: "转数",
value: "1"
}
]
},
{
title: "参与人员",
prop: "canyurenyuan",
type: "input"
}
]
},
selectionList: [],
treeData: [],
mclist: []
};
},
computed: {
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.byxiangmuweihuid);
});
return ids.join(",");
},
...mapGetters(["LIB"])
},
created() {
geturl("/api/byxiangmuweihu/Getbybujian").then(res => {
this.treeData = res.data.data;
console.log("=============", this.treeData);
});
window.addEventListener("setItem", () => {
this.guding = sessionStorage.getItem("watchStorage");
});
},
methods: {
reload(where) {
Object.assign(this.options.query, where);
this.onLoad(this.page);
},
//表格内容加载事件
onLoad(page) {
this.page = page;
console.log(page);
getsByxiangmuweihu(
page.currentPage,
page.pageSize,
this.options.query
).then(res => {
const tableList = res.data.data;
this.page.total = tableList.total;
this.tableData = tableList.records;
//执行统计方法
this.$refs.search.loadGroup(this.page.total);
//清空选择项
this.$refs.crud.toggleSelection();
});
},
//选中的数据
selectionChange(list) {
this.selectionList = list;
},
//刷新表格
refresh() {
this.onLoad(this.page);
},
newAdd() {
this.$refs.crud.rowAdd();
}
}
};
</script>
<style scoped lang="scss"></style>
为什么 treeselect 不显示? 新增执行的方法this.$refs.crud.rowAdd();
最新发布