分公司管理

This commit is contained in:
cwchen 2025-04-18 16:04:52 +08:00
parent e4aa8c9acd
commit 45d95752f9
3 changed files with 399 additions and 0 deletions

View File

@ -0,0 +1,55 @@
import request from '@/utils/request';
// 查询分公司列表
export function queryBranchCompanyList(query) {
return request({
url: '/smart-site/branchCompany/queryBranchCompanyList',
method: 'get',
params: query
})
}
// 分公司-新增
export function addBranchCompany(data) {
return request({
url: '/smart-site/branchCompany/addBranchCompany',
method: 'post',
data
})
}
// 分公司-修改
export function editBranchCompany(data) {
return request({
url: '/smart-site/branchCompany/editBranchCompany',
method: 'post',
data
})
}
// 分公司-删除
export function delBranchCompany(data) {
return request({
url: '/smart-site/branchCompany/delBranchCompany',
method: 'post',
data
})
}
// 分公司详情
export function detailBranchCompany(query) {
return request({
url: '/smart-site/branchCompany/detailBranchCompany',
method: 'get',
params: query
})
}
// 分公司-修改状态
export function editBranchCompanyStatus(data) {
return request({
url: '/smart-site/branchCompany/editBranchCompanyStatus',
method: 'post',
data
})
}

View File

@ -0,0 +1,175 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
label-width="68px">
<el-form-item label="关键字" prop="keyWord">
<el-input v-model="queryParams.keyWord" placeholder="请输入关键字" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['basic:branchCompany:add']">新增</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['system:post:export']">导出</el-button>
</el-col> -->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="branchCompanyList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="分公司名称" align="center" prop="companyName" />
<el-table-column label="分公司简称" align="center" prop="abbrName" />
<el-table-column label="状态" align="center" key="useStatus">
<template slot-scope="scope">
<el-switch v-model="scope.row.useStatus" active-value="1" inactive-value="0"
@change="handleStatusChange(scope.row)"></el-switch>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="更新人员" align="center" prop="updateUserName" />
<el-table-column label="更新时间" align="center" prop="updateTime" width="180"></el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['basic:branchCompany:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['basic:branchCompany:del']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 新增/编辑 -->
<BranchCompanypop v-if="isflag" :isAdd="isAdd" :rowData="row" @handleQuery="handleQuery" :title="title"
@closeDialog="closeDialog" @showColose="showColose" :dataForm="row" :disabled="loading" :width="600" />
</div>
</template>
<script>
import { queryBranchCompanyList, delDev,editBranchCompanyStatus } from "@/api/system/branchCompany";
import BranchCompanypop from "./prop/branchCompanypop.vue";
export default {
name: "BranchCompany",
dicts: ['video_device'],
components: {
BranchCompanypop
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
branchCompanyList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
keyWord: '',
},
//
form: {},
isflag: false,
row: {},
isAdd: ''
};
},
created() {
this.getList();
},
methods: {
/** 视频设备列表 */
getList() {
this.loading = true;
queryBranchCompanyList(this.queryParams).then(response => {
this.branchCompanyList = response.rows;
this.total = response.total;
this.loading = false;
});
},
closeDialog() {
this.isflag = false;
},
showColose() {
this.isflag = false;
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.title = "新增";
this.isAdd = 'add';
this.isflag = true;
},
/** 修改按钮操作 */
handleUpdate(row) {
this.title = "修改";
this.isAdd = 'edit';
this.row = row;
this.isflag = true;
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id || this.ids;
this.$modal.confirm('是否确认删除分公司名称为"' + row.companyName + '"的数据项?').then(function () {
return delDev({ id: id });
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => { });
},
//
handleStatusChange(row) {
let text = row.useStatus === '1' ? '启用' : '禁用'
this.$modal.confirm('确认要"' + text + '""' + row.companyName + '"数据吗?').then(function () {
return editBranchCompanyStatus({ id: row.id, useStatus: row.useStatus })
}).then(() => {
this.$modal.msgSuccess(text + '成功')
}).catch(function () {
row.useStatus = row.useStatus === '1' ? '0' : '1'
})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/post/export', {
...this.queryParams
}, `post_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -0,0 +1,169 @@
<template>
<!-- 小型弹窗用于完成删除保存等操作 -->
<el-dialog class="l-dialog" :class="lDialog" :title="title" :visible.sync="dialogVisible" :showClose="true"
:closeOnClickModal="false" @close="handleClose" :append-to-body="true">
<div>
<el-form :model="form" :rules="rules" ref="ruleForm" label-width="110px">
<el-form-item label="分公司名称" prop="companyName">
<el-input style="width:100%" v-model="form.companyName" placeholder="请输入分公司名称" maxlength="64"></el-input>
</el-form-item>
<el-form-item label="简称" prop="abbrName">
<el-input style="width:100%" v-model="form.abbrName" placeholder="请输入简称" maxlength="64"></el-input>
</el-form-item>
<el-form-item label="状态" prop="useStatus">
<el-switch v-model="form.useStatus" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input type="textarea" style="width:100%" v-model="form.remark" placeholder="请输入备注" maxlength="255"></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="clear-btn" @click="handleClose" :disabled="disabled">取消</el-button>
<el-button type="primary" class="search-btn" :disabled="disabled" @click="submitForm('ruleForm')">确认</el-button>
</span>
</el-dialog>
</template>
<script>
import { detailBranchCompany, addBranchCompany, editBranchCompany } from "@/api/system/branchCompany";
export default {
name: "BranchCompanypop",
props: ["width", "dataForm", "title", "disabled", "isAdd", "rowData"],
data() {
return {
roles: [],
lDialog: this.width > 500 ? "w700" : "w500",
dialogVisible: true,
isDisabled: true,
form: {
companyName: null,
abbrName: null,
useStatus: 1,
remark:null
},
rules: {
companyName: [
{ required: true, message: '分公司名称不能为空', trigger: 'blur' }
],
abbrName: [
{ required: true, message: '简称不能为空', trigger: 'blur' }
]
},
};
},
mounted() {
if (this.isAdd === 'add') { //
} else if (this.isAdd === 'edit') { //
this.queryDetailDev();
}
},
methods: {
/**详情*/
queryDetailDev() {
detailBranchCompany({ id: this.rowData.id }).then(res => {
this.form = res.data;
this.form.useStatus = parseInt(res.data.useStatus);
}).catch(error => {
})
},
/*关闭弹窗 */
handleClose() {
this.dialogVisible = false;
this.$emit("closeDialog");
setTimeout(() => {
this.dialogVisible = true;
});
},
/**确认弹窗 */
sureBtnClick() {
this.dialogVisible = false;
this.$emit("closeDialog");
setTimeout(() => {
this.dialogVisible = true;
});
},
/**重置表单*/
reset() {
this.form = {
devName: null,
macId: null,
devTypeCode: null,
puid: null,
gbCode: null,
playIdx: 0
};
this.resetForm("ruleForm");
},
handleReuslt(res) {
this.$modal.msgSuccess(res.msg);
this.reset();
this.$emit('handleQuery');
this.handleClose();
},
/**验证 */
submitForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
let loading = this.$loading({
lock: true,
text: "数据提交中,请稍候...",
background: 'rgba(0,0,0,0.2)',
target: this.$el.querySelector('.el-dialog') || document.body
})
let params = _.cloneDeep(this.form);
if (this.isAdd === 'add') {
addBranchCompany(params).then(res => {
loading.close();
if (res.code === 200) {
this.handleReuslt(res);
} else {
this.$modal.msgError(res.msg);
}
}).catch(error => {
loading.close();
});
} else {
editBranchCompany(params).then(res => {
loading.close();
if (res.code === 200) {
this.handleReuslt(res);
} else {
this.$modal.msgError(res.msg);
}
}).catch(error => {
loading.close();
});
}
}
});
}
}
};
</script>
<style lang="scss">
.w700 .el-dialog {
width: 700px;
}
.w500 .el-dialog {
width: 500px;
}
.w500 .el-dialog__header,
.w700 .el-dialog__header {
background: #eeeeee;
.el-dialog__title {
font-size: 16px;
}
}
.yxq .el-range-separator {
margin-right: 7px !important;
}
.el-date-editor--daterange.el-input__inner {
width: 260px;
}
</style>