Commit 63187be5 by 李长胜

车型修改添加页面调整

1 parent 77ae9ecf
......@@ -2,10 +2,29 @@
<div class="system-container">
<div class="container">
<div class="topform">
<rule-form :ruleForm="addUpdateForm" :rules="rules" :ruleData="addUpdateData" :labelWidth="'120px'" ref="addUpdateForm">
<rule-form
:ruleForm="addUpdateForm"
:rules="rules"
:ruleData="addUpdateData"
:labelWidth="'120px'"
ref="addUpdateForm"
>
<div slot="select-type">
<el-select v-model="addUpdateForm.initOrganize" placeholder="请选择" :disabled="this.$route.query.title == 'view' || this.$route.query.title=='edit'" filterable>
<el-option v-for="i in tenantList" :key="i.tenantId" :label="i.departmentName" :value="i.tenantId">
<el-select
v-model="addUpdateForm.initOrganize"
placeholder="请选择"
:disabled="
this.$route.query.title == 'view' ||
this.$route.query.title == 'edit'
"
filterable
>
<el-option
v-for="i in tenantList"
:key="i.tenantId"
:label="i.departmentName"
:value="i.tenantId"
>
</el-option>
</el-select>
</div>
......@@ -17,14 +36,33 @@
</div>
<div class="treebox">
<!-- <span class="el-icon-loading"></span> -->
<div class="layer" v-if="!showTree"> <i class="el-icon-loading"></i> 正在加载中...</div>
<el-tree v-if="showTree" :data="treedata" :default-expanded-keys="expandedKey" :props="defaultProps" show-checkbox node-key="id" ref="tree" highlight-current lazy :load="loadNode">
<div class="layer" v-if="!showTree">
<i class="el-icon-loading"></i> 正在加载中...
</div>
<el-tree
v-if="showTree"
:data="treedata"
:default-expanded-keys="expandedKey"
:props="defaultProps"
show-checkbox
node-key="id"
ref="tree"
highlight-current
lazy
:load="loadNode"
>
</el-tree>
</div>
</div>
<div class="pull-right">
<el-button type="primary" @click="submitForm" :loading="aloading" v-if="!(setPageTitle == 'view')">保存</el-button>
<el-button
type="primary"
@click="submitForm"
:loading="aloading"
v-if="!(setPageTitle == 'view')"
>保存</el-button
>
<el-button @click="handCancle('addUpdateForm')">取消</el-button>
</div>
</div>
......@@ -102,6 +140,7 @@ export default {
expandedKey: [],
tenantListElement: {},
type: 1,
typeList: [],
};
},
computed: {
......@@ -113,21 +152,7 @@ export default {
: "view";
},
},
created() {
var title = this.$route.query.title;
var id = this.$route.query.id;
if (title == "add") {
this.type = 1; //后台要区分新增,和编辑,1:新增,2:编辑
} else if (title == "edit") {
this.type = 2;
this.editVehicleType({ tenantId: id });
// this.getInfo({ tenantId: id });
} else if (title == "view") {
this.rules = {};
this.editVehicleType({ tenantId: id });
// this.getInfo({ tenantId: id });
}
},
created() {},
mounted() {
let _this = this;
......@@ -145,7 +170,8 @@ export default {
if (n && n.length > 0) {
// console.log(n,"浏览器存储");
//_this.flatData(n);
_this.mainWorker(n).then(res => {
_this.mainWorker(n).then((res) => {
_this.showTree = true;
_this.loading = false;
});
......@@ -157,6 +183,13 @@ export default {
if (o.id) {
this.getInfo(o.id);
}
if (o.title == "add") {
this.type = 1; //后台要区分新增,和编辑,1:新增,2:编辑
} else if (o.title == "edit") {
this.type = 2;
} else if (o.title == "view") {
this.rules = {};
}
},
activated() {
let _this = this;
......@@ -170,15 +203,10 @@ export default {
editVehicleType(params) {
editVehicleType(params).then((res) => {
if (res.code == "200") {
// console.log(res.data, "编辑、查看数据");
this.addUpdateForm.name = res.data.name || "暂无";
this.addUpdateForm.initOrganize = res.data.tenantId;
this.addUpdateForm.enableStatus =
res.data.enableStatus == 2 ? false : true;
// var _this = this;
// setTimeout(() => {
// _this.$refs.tree.setCheckedKeys(res.data.typeIds);
// }, 10000);
}
});
},
......@@ -265,9 +293,7 @@ export default {
(arr || []).forEach((item) => {
item.pid = id || 0;
item.level = i;
if (item.level == 3) {
item.leaf = true;
}
n.push(item);
if (!id) {
_this.treedata.push(item);
......@@ -331,7 +357,6 @@ export default {
// 取消保存
handCancle(formName) {
console.log("66");
this.goBack();
},
......@@ -367,62 +392,70 @@ export default {
return false;
}
let o = res.data || {};
this.addUpdateForm.name = o.name || "暂无";
this.addUpdateForm.initOrganize = o.tenantId;
this.addUpdateForm.enableStatus = o.enableStatus == 2 ? false : true;
this.typeList = o.typeIds || [];
});
},
getExpandNode() {
let _this = this;
let typeList = this.typeList;
let _models = []; //子节点
let _brand = []; // 品牌
let _subBrand = []; // 子品牌
let _series = []; // 车系
let list = this.newArr;
console.log("1", list.length);
let _earr = []; // 默认展开的节点
// 半选数组
let _half = [];
// 全选数组
let _check = [];
typeList.map((k) => {
let m, b, f;
//寻找当前元素
let n = list.find((j) => j.id == k && j.level == 3);
// 找第三级
if (n) {
m = list.find((j) => j.id == n.pid && j.level == 2);
//_series.push(m);
_earr.push(m.id);
}
let typeList = o.typeIds || [];
let _models = []; //子节点
let _brand = []; // 品牌
let _subBrand = []; // 子品牌
let _series = []; // 车系
let list = this.newArr;
let _earr = []; // 默认展开的节点
// 半选数组
let _half = [];
// 全选数组
let _check = [];
typeList.map((k) => {
let m, b, f;
//寻找当前元素
let n = list.find((j) => j.id == k && j.level == 3);
// 找第三级
if (n) {
m = list.find((j) => j.id == n.pid && j.level == 2);
//_series.push(m);
_earr.push(m.id);
}
// 找第二级
if (m) {
b = list.find((j) => j.id == m.pid && j.level == 1);
//_subBrand.push(b);
_earr.push(b.id);
}
// 找第二级
if (m) {
b = list.find((j) => j.id == m.pid && j.level == 1);
//_subBrand.push(b);
_earr.push(b.id);
}
// 找第一级
if (b) {
f = list.find((j) => {
return j.id == b.pid && j.level == 0;
});
// 找第一级
if (b) {
f = list.find((j) => {
return j.id == b.pid && j.level == 0;
});
let _idx = _brand.findIndex((v) => v.id == f.id);
if (_idx < 0) {
_brand.push(f);
_earr.push(f.id);
}
let _idx = _brand.findIndex((v) => v.id == f.id);
if (_idx < 0) {
_brand.push(f);
_earr.push(f.id);
}
});
_this.expandedKey = _earr;
}
});
_this.expandedKey = _earr;
console.log("typeList:", typeList);
console.log(_this.expandedKey.length, typeList.length, "长度");
setTimeout(() => {
_this.$refs.tree.setCheckedKeys(typeList);
});
}, 3000);
},
// 创建分线程
createWorker() {
let myWorker = function () {
......@@ -443,6 +476,9 @@ export default {
(arr || []).forEach((item) => {
item.pid = id || 0;
item.level = i;
if (item.childs === null) {
item.leaf = true;
}
n.push(item);
if (!id) {
_tree.push(item);
......@@ -471,7 +507,10 @@ export default {
webWorker.onmessage = function (e) {
let _obj = e.data;
_this.treedata = _obj.tree;
console.log("treedata的个数:", _this.treedata);
_this.newArr = _obj.data;
console.log("newArr的个数:", _this.newArr);
_this.getExpandNode();
resolve(_obj);
};
// 监听文件失败
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!