Commit cf1c4ce3 by 李长胜

车型管理新增修改查看

1 parent f85b9290
......@@ -20,9 +20,10 @@
<span @click="goToPage('/app-vue-history/about')">app-vue-history About</span>
</p>
</div> -->
<keep-alive>
<keep-alive exclude="vehicleAddUpadate,vehicleTypeManage">
<router-view />
</keep-alive>
</div>
</template>
......
......@@ -33,6 +33,8 @@ const VEHICLETYPE_API={
VEHICLETYPE_TYPES:'/trialdrive/vehicle/types',
VEHICLETYPE_ADD:'/trialdrive/vehicle/savetypes',
VEHICLETYPE_EDIT:'/trialdrive/vehicle/gettenanttypes',
VEHICLETYPE_DELETE:'/trialdrive/vehicle/tenanttypes/delete',
VEHICLETYPE_INFO:'/trialdrive/vehicle/gettenanttypes'
}
......
......@@ -26,6 +26,7 @@ const routes = [
path: '/vehicleTypeManage',
name: 'vehicleTypeManage',
meta: { title: '车型管理' },
keepAlive:false,
component: () => import('../views/vehicleTypeManage/index.vue')
},
{
......
......@@ -47,7 +47,16 @@ function GETVEHICLEINFO(params) {
const url = VEHICLETYPE_API.VEHICLETYPE_INFO
return request(params, url)
}
//删除一条表数据
function delelteTableRowData(params) {
const url = VEHICLETYPE_API.VEHICLETYPE_DELETE
return request(params, url)
}
//获取编辑的接口,获取页面信息
function editVehicleType(params) {
const url = VEHICLETYPE_API.VEHICLETYPE_EDIT
return request(params, url)
}
export { getTableList, getTenantList, getMenuTree, getMenuTreeFirst, getMenuTreeSecond,getMenuTreeThird, geMenuTreeLeaf, addVehicleType, GETVEHICLEINFO}
export { getTableList, getTenantList, getMenuTree, getMenuTreeFirst, getMenuTreeSecond,getMenuTreeThird, geMenuTreeLeaf, addVehicleType, GETVEHICLEINFO,delelteTableRowData,editVehicleType}
......@@ -68,31 +68,15 @@
>
</span>
</basic-table>
<basic-dialog
class="vehicle"
:title="vehicleTypeDialogTitle"
:isVisible="vehicleTypeVisible"
@confirmDialog="handleConfirm"
@closeDialog="handleClose"
>
<slot>
<rule-form
:ruleForm="vehicleTypeForm"
:rules="vehicleTypeRules"
:ruleData="vehicleTypeData"
:labelWidth="'120px'"
ref="vehicleTypeForm"
>
</rule-form>
</slot>
</basic-dialog>
</div>
</div>
</template>
<script>
import { getTableList } from "services/vehicletype";
import { getTableList, delelteTableRowData } from "services/vehicletype";
export default {
name: "vehicleTypeManage",
data() {
return {
USERSTATUS: this.$Constants.USER_STATUS,
......@@ -101,7 +85,7 @@ export default {
{
type: "input",
inputType: "text",
prop: "name",
prop: "term",
placeholder: "所属组织|车型库名称",
},
],
......@@ -116,7 +100,6 @@ export default {
{
label: "车型库名称",
prop: "name",
width: 100,
},
{
label: "创建人",
......@@ -152,8 +135,7 @@ export default {
},
},
getListApi: getTableList,
vehicleTypeDialogTitle: "新增车型",
vehicleTypeVisible: false,
vehicleTypeTitle: "add",
//以下为弹出框表单
vehicleTypeForm: {
enableStatus: true,
......@@ -170,61 +152,81 @@ export default {
tenantList: [],
};
},
mounted() {},
activated(){
created(){
},
mounted() {},
activated() {},
methods: {
// 重置搜索条件
refresh() {
this.searchForm = {};
this.$refs.vehicleTypeTable.refreshTable();
},
//弹窗的确定按钮
handleConfirm() {
this.handleClose();
this.$refs.vehicleTypeTable.refreshTable();
},
// 弹窗的取消按钮
handleClose() {
this.vehicleTypeVisible = !this.vehicleTypeVisible;
},
//按钮事件
btnClick(pType, scope) {
console.log(pType, scope);
switch (pType) {
case "create":
this.vehicleTypeDialogTitle = "新增车型";
this.vehicleTypeTitle = "add";
this.vehicleTypeForm = {
enableStatus: true,
};
this.$router.push({name:'vehicleAddUpadate',query:{}})
this.$router.push({ name: "vehicleAddUpadate", query: { title: this.vehicleTypeTitle } });
//this.handleClose(); //控制弹窗打开
break;
case "edit":
this.vehicleTypeDialogTitle = "编辑车型";
const params = { vehicleTypeId: scope.id };
// this.getTenantList(params);
// this.getPermission(params);
//this.editEvent(scope);
this.$router.push({name:'vehicleAddUpadate',query:{id:scope.tenantId}})
this.vehicleTypeTitle = "edit";
this.$router.push({
name: "vehicleAddUpadate",
query: { title: this.vehicleTypeTitle, id: scope.tenantId },
});
break;
case "view":
this.vehicleTypeTitle = "view";
this.$router.push({
name: "vehicleAddUpadate",
query: { title: this.vehicleTypeTitle, id: scope.tenantId },
});
break;
case "delete":
this.deleteEvent(scope.id);
this.delelteTableRowData(scope.tenantId);
break;
}
},
//编辑触发事件
editEvent() {
const that=this;
const that = this;
this.handleClose();
},
// 删除触发事件
deleteEvent() {
//删除接口
delelteTableRowData(id) {
const that = this;
const tipData = {
that: that,
tipText: "是否删除当前记录",
tipTitle: "提示",
type: "error",
callBack: () => {
delelteTableRowData({ tenantId: id }).then((res) => {
if (res.code == "200") {
this.$message({
type: "success",
message: "删除成功!",
});
this.$refs.vehicleTypeTable.refreshTable();
} else {
this.$message({
type: "error",
message: res.message,
});
}
});
},
};
this.$Common.confirmDialog(tipData);
},
},
};
</script>
......
......@@ -2,10 +2,26 @@
<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="请选择" 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>
......@@ -15,17 +31,36 @@
</div> -->
</rule-form>
</div>
<div class="treebox" v-loading="loading">
<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="treebox" >
<!-- <span class="el-icon-loading"></span> -->
<div class="layer" v-if="!showTree">正在加载中...</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">保存</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>
</div>
</template>
<script>
......@@ -33,6 +68,7 @@ import {
getTenantList,
getMenuTree,
addVehicleType,
editVehicleType,
GETVEHICLEINFO,
} from "services/vehicletype";
export default {
......@@ -47,12 +83,19 @@ export default {
};
return {
addUpdateForm: {
// initOrganize: "",
// enableStatus: true,
name: "",
initOrganize: "",
enableStatus: true,
// menuIdList: [],
},
addUpdateData: [
{ label: "车型库名称:", prop: "name", type: "input", maxlength: 50 },
{
label: "车型库名称:",
prop: "name",
type: "input",
maxlength: 50,
disabled: this.$route.query.title == "view",
},
{
label: "组织:",
prop: "initOrganize",
......@@ -60,7 +103,7 @@ export default {
slotName: "select-type",
},
{ label: "状态:", prop: "enableStatus", type: "switch" },
{ type: "customize", slotName: "btns-type" },
// { type: "customize", slotName: "btns-type" },
],
// {
// prop: "menuIdList",
......@@ -74,7 +117,7 @@ export default {
{ required: true, message: "请选择组织", trigger: "change" },
],
enableStatus: [{ required: true }],
menuIdList: [{ required: true, validator: checkMenu, trigger: "blur" }],
// menuIdList: [{ required: true, validator: checkMenu, trigger: "blur" }],
},
treedata: [],
treeLeafData: [],
......@@ -89,15 +132,40 @@ export default {
checkList: [],
aloading: false,
expandedKey: [],
tenantListElement: {},
type: 1,
};
},
created() {},
computed: {
setPageTitle() {
return this.$route.query.title == "add"
? "add"
: this.$route.query.title == "edit"
? "edit"
: "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 });
}
},
mounted() {
let _this = this;
let o = _this.$route.query;
//判断?
//判断
this.getTenantList();
setTimeout(function () {
......@@ -106,7 +174,7 @@ export default {
: [];
if (n && n.length > 0) {
console.log(n);
// console.log(n);
_this.flatData(n);
_this.showTree = true;
_this.loading = false;
......@@ -127,10 +195,26 @@ export default {
}
},
methods: {
// 获取页面详情的接口
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);
}
});
},
// 获取租户列表
getTenantList(params) {
getTenantList(params).then((res) => {
this.tenantList = res.data;
this.tenantList = res.data || [];
});
},
// 获取菜单权限列表
......@@ -161,7 +245,7 @@ export default {
loadNode(node, resolve) {
let arr = [];
let id = node.key;
console.log(node, "选中的node");
// console.log(node, "选中的node");
if (node.level === 0) {
id = 0;
}
......@@ -192,7 +276,7 @@ export default {
arr = this.newArr.filter((item) => {
return item.pid == id;
});
console.log(arr, "过滤之后");
// console.log(arr, "过滤之后");
resolve(arr);
},
......@@ -226,7 +310,7 @@ export default {
}
_this.checkList = [];
let _list = _this.$refs.tree.getCheckedNodes();
console.log(_list);
_this.getChilds(_list);
console.log(_this.checkList);
......@@ -238,8 +322,12 @@ export default {
let params = {
name: _this.addUpdateForm.name,
};
this.tenantListElement = this.tenantList.find(
(item) => item.tenantId == this.addUpdateForm.initOrganize
);
params.from = this.type;
params.tenantId = Number(_this.addUpdateForm.initOrganize);
params.tenantName = this.tenantListElement.departmentName;
params.enableStatus = _this.addUpdateForm.enableStatus ? 1 : 2;
params.typeIds = _this.checkList;
......@@ -253,7 +341,7 @@ export default {
}
_this.$message({
message: "新增成功",
message: "提交成功",
type: "success",
});
......@@ -264,6 +352,7 @@ export default {
// 取消保存
handCancle(formName) {
console.log("66")
this.goBack();
},
......@@ -299,6 +388,7 @@ export default {
return false;
}
let o = res.data || {};
let typeList = o.typeIds || [];
let _models = []; //子节点
let _brand = []; // 品牌
......@@ -362,7 +452,20 @@ export default {
width: 40%;
}
.treebox {
height: 300px;
height: 385px;
overflow-y: scroll;
position: relative;
.layer{
width: 100%;
height: 385px;
text-align: center;
line-height: 385px;
position: absolute;
z-index:10;
}
}
.pull-right {
margin-top: 20px;
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!