Commit 5f0a1b74 authored by “yiyousong”'s avatar “yiyousong”

perf: 优化业务管理

parent 65bb590a
<template>
<a-table
:columns="columns"
:data-source="data"
:bordered="bordered"
:defaultExpandAllRows="DefaultExpandAllRows"
:expandRowByClick="ExpandRowByClick"
:showHeader="ShowHeader"
:pagination="Pagination"
:rowKey="rowKey"
@change="handleTableChange"
v-bind="$attrs"
v-on="$listeners"
>
<template
slot-scope="text, record, index"
:slot="slot"
v-for="slot in Object.keys($scopedSlots).filter(
(key) => key !== 'expandedRowRender'
)"
>
<slot :name="slot" v-bind="{ text, record, index }"></slot>
</template>
<template :slot="slot" v-for="slot in Object.keys($slots)">
<slot :name="slot"></slot>
</template>
<template
slot-scope="record, index, indent, expanded"
:slot="$scopedSlots.expandedRowRender ? 'expandedRowRender' : ''"
>
<slot
v-bind="{ record, index, indent, expanded }"
:name="$scopedSlots.expandedRowRender ? 'expandedRowRender' : ''"
></slot>
</template>
</a-table>
</template>
<script>
export default {
props: {
columns: {
required: true,
type: Array,
default: () => [],
},
data: {
required: true,
type: Array,
default: () => [],
},
pageSize: {
required: true,
type: Number,
default: 10,
},
current: {
required: true,
type: Number,
default: 1,
},
total: {
required: true,
type: Number,
default: 0,
},
bordered: {
type: Boolean,
default: true,
},
defaultExpandAllRows: {
type: Boolean,
default: false,
},
expandRowByClick: {
type: Boolean,
default: false,
},
showHeader: {
type: Boolean,
default: true,
},
rowKey: {
type: [String, Function],
default: "id",
},
pagination: {
type: Object,
default: () => {},
},
pageSizeOptions: {
type: Array,
default: () => ["10", "30", "50", "100", "200"],
},
},
data() {
return {};
},
computed: {
Bordered() {
return !!this.bordered;
},
DefaultExpandAllRows() {
return !!this.defaultExpandAllRows;
},
ExpandRowByClick() {
return !!this.expandRowByClick;
},
ShowHeader() {
return !!this.showHeader;
},
PageSize: {
get() {
return this.pageSize;
},
set(value) {
this.$emit("update:pageSize", value);
},
},
Current: {
get() {
return this.current;
},
set(value) {
this.$emit("update:current", value);
},
},
Pagination() {
return {
showTotal: (total) => `共 ${total} 条`,
total: this.total,
current: this.Current,
pageSize: this.pageSize,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: this.pageSizeOptions,
...this.pagination,
};
},
},
methods: {
handleTableChange(pagination, filters, sorter, { currentDataSource }) {
let { current, pageSize } = pagination;
this.Current = current;
this.PageSize = pageSize;
if (this.$listeners.changePagination) {
this.$listeners.changePagination();
}
this.$emit("change", pagination, filters, sorter, { currentDataSource });
},
},
};
</script>
<style lang="less" scoped></style>
...@@ -270,7 +270,7 @@ import { ...@@ -270,7 +270,7 @@ import {
delSiteMatter, delSiteMatter,
delMatter, delMatter,
} from "@/services/matter"; } from "@/services/matter";
import { getBusinessMatterList, delBusinessMatter } from "@/services/business"; import { businessMatterList, delBusinessMatter } from "@/services/business";
import { getDeptList } from "@/services/dept"; import { getDeptList } from "@/services/dept";
import EditSiteMatter from "../group/EditSiteMatter.vue"; import EditSiteMatter from "../group/EditSiteMatter.vue";
import { pageSizeOptions } from "@/config/pageConfig.js"; import { pageSizeOptions } from "@/config/pageConfig.js";
...@@ -607,7 +607,7 @@ export default { ...@@ -607,7 +607,7 @@ export default {
this.businessLinkage(str); this.businessLinkage(str);
return; return;
} }
let res = await getBusinessMatterList({ let res = await businessMatterList({
matterId: arr[num], matterId: arr[num],
siteId: this.siteId, siteId: this.siteId,
}); });
...@@ -620,7 +620,7 @@ export default { ...@@ -620,7 +620,7 @@ export default {
}; };
delData(); delData();
} else { } else {
let res = await getBusinessMatterList({ let res = await businessMatterList({
matterId: row.matterId, matterId: row.matterId,
siteId: this.siteId, siteId: this.siteId,
}); });
......
...@@ -283,9 +283,9 @@ import { getSiteMatterList } from "@/services/matter"; ...@@ -283,9 +283,9 @@ import { getSiteMatterList } from "@/services/matter";
import { pageSizeOptions } from "@/config/pageConfig.js"; import { pageSizeOptions } from "@/config/pageConfig.js";
import { getDeptList } from "@/services/dept"; import { getDeptList } from "@/services/dept";
import { import {
getSiteBusinessList, siteBusinessList,
// addBusinessMatter, // addBusinessMatter,
getBusinessMatterList, businessMatterList,
delBusinessMatter, delBusinessMatter,
getBusinesslistData, getBusinesslistData,
addBatchSave, addBatchSave,
...@@ -440,12 +440,12 @@ export default { ...@@ -440,12 +440,12 @@ export default {
// 获取站点业务关联-事项列表 // 获取站点业务关联-事项列表
async getMatterlistData(search = {}) { async getMatterlistData(search = {}) {
let res = await getBusinessMatterList(search); let res = await businessMatterList(search);
this.unboundMatterData = res.data.data.data; this.unboundMatterData = res.data.data.data;
}, },
// 获取站点业务列表 // 获取站点业务列表
async getSiteBusinessData(search = {}) { async getSiteBusinessData(search = {}) {
let res = await getSiteBusinessList({ let res = await siteBusinessList({
siteId: this.siteId, siteId: this.siteId,
page: 1, page: 1,
size: -1, size: -1,
...@@ -564,7 +564,7 @@ export default { ...@@ -564,7 +564,7 @@ export default {
if (num > arr.length - 1) { if (num > arr.length - 1) {
return; return;
} }
let res = await getBusinessMatterList({ let res = await businessMatterList({
siteId: this.siteId, siteId: this.siteId,
siteBusinessId: arr[num], siteBusinessId: arr[num],
}); });
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<a-modal <a-modal
:title="title" :title="title"
:visible="visibleAll" :visible="visibleAll"
:confirm-loading="confirmLoading"
@cancel="handleCancel" @cancel="handleCancel"
:maskClosable="false" :maskClosable="false"
> >
<a-button slot="footer" @click="handleReset">重置</a-button> <a-button slot="footer" @click="handleReset">重置</a-button>
<a-button slot="footer" type="primary" @click="handleOk">确定</a-button> <a-button slot="footer" type="primary" @click="handleOk" :loading="loading"
>确定</a-button
>
<a-form-model <a-form-model
:model="form" :model="form"
ref="formData" ref="formData"
...@@ -83,9 +84,9 @@ import local from "@/utils/local"; ...@@ -83,9 +84,9 @@ import local from "@/utils/local";
import YSwitch from "@/components/yswitch/YSwitch.vue"; import YSwitch from "@/components/yswitch/YSwitch.vue";
import { import {
saveBusiness, saveBusiness,
// getBusinessList, // businessList,
addInBusiness, addInBusiness,
getSiteBusinessList, siteBusinessList,
} from "@/services/business"; } from "@/services/business";
export default { export default {
components: { components: {
...@@ -94,6 +95,7 @@ export default { ...@@ -94,6 +95,7 @@ export default {
data() { data() {
return { return {
siteId: local.getLocal("siteId"), siteId: local.getLocal("siteId"),
loading: false,
form: { form: {
isBusiness: "", isBusiness: "",
parentId: undefined, parentId: undefined,
...@@ -107,7 +109,6 @@ export default { ...@@ -107,7 +109,6 @@ export default {
businessType: 1, businessType: 1,
}, },
parentBusiness: [], //下拉框数据 parentBusiness: [], //下拉框数据
confirmLoading: false,
rules: { rules: {
isBusiness: [ isBusiness: [
{ required: true, message: "请选择业务等级", trigger: "change" }, { required: true, message: "请选择业务等级", trigger: "change" },
...@@ -129,11 +130,21 @@ export default { ...@@ -129,11 +130,21 @@ export default {
type: String, type: String,
}, },
}, },
computed: {
visibleAll: {
get() {
return this.visible;
},
set(val) {
this.$emit("update:visible", val);
},
},
},
created() {}, created() {},
methods: { methods: {
// 获取业务列表 // 获取业务列表
async getBusinessData() { async getBusinessData() {
let res = await getSiteBusinessList({ let res = await siteBusinessList({
page: 1, page: 1,
size: -1, size: -1,
siteId: this.siteId, siteId: this.siteId,
...@@ -146,12 +157,12 @@ export default { ...@@ -146,12 +157,12 @@ export default {
}, },
// 关闭窗口 // 关闭窗口
handleCancel() { handleCancel() {
this.visibleAll = false;
this.$refs.formData.resetFields(); this.$refs.formData.resetFields();
this.visibleAll = false;
}, },
// 新增 // 新增
onAdd() { async onAdd() {
this.getBusinessData(); await this.getBusinessData();
Object.assign(this.form, this.$options.data().form); Object.assign(this.form, this.$options.data().form);
this.form.id && this.$delete(this.form, "id"); this.form.id && this.$delete(this.form, "id");
}, },
...@@ -181,9 +192,8 @@ export default { ...@@ -181,9 +192,8 @@ export default {
// 确定 // 确定
handleOk() { handleOk() {
this.$refs.formData.validate(async (valid) => { this.$refs.formData.validate(async (valid) => {
console.log(this.form.parentId);
if (valid) { if (valid) {
this.confirmLoading = true; this.loading = true;
let res = await saveBusiness({ let res = await saveBusiness({
...this.form, ...this.form,
parentId: this.form.parentId == undefined ? 0 : this.form.parentId, parentId: this.form.parentId == undefined ? 0 : this.form.parentId,
...@@ -197,20 +207,18 @@ export default { ...@@ -197,20 +207,18 @@ export default {
siteId: this.siteId, siteId: this.siteId,
}); });
if (result.data.code === 1) { if (result.data.code === 1) {
this.visibleAll = false;
this.$message.success(msg); this.$message.success(msg);
this.getBusinessData(); this.getBusinessData();
this.$refs.formData.resetFields(); this.$emit("success");
this.$emit("newBusiness"); this.handleCancel();
} }
} else { } else {
this.visibleAll = false;
this.$message.success(msg); this.$message.success(msg);
this.getBusinessData(); this.getBusinessData();
this.$refs.formData.resetFields(); this.$emit("success");
this.$emit("newBusiness"); this.handleCancel();
} }
this.confirmLoading = false; this.loading = false;
} }
} }
}); });
...@@ -223,16 +231,6 @@ export default { ...@@ -223,16 +231,6 @@ export default {
); );
}, },
}, },
computed: {
visibleAll: {
get() {
return this.visible;
},
set(val) {
this.$emit("update:visible", val);
},
},
},
}; };
</script> </script>
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
onChange: changePage, onChange: changePage,
}" }"
:columns="columns" :columns="columns"
:data-source="siteBusinessList" :data-source="siteBusinessData"
:rowKey="(record) => record.businessId" :rowKey="(record) => record.businessId"
:row-selection="{ :row-selection="{
selectedRowKeys: rowKeys, selectedRowKeys: rowKeys,
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
</template> </template>
<script> <script>
import { getSiteBusinessList } from "@/services/business"; import { siteBusinessList } from "@/services/business";
import { addBusinessToWindow } from "@/services/dept"; import { addBusinessToWindow } from "@/services/dept";
// import { extractTree } from "@/utils/util"; // import { extractTree } from "@/utils/util";
import local from "@/utils/local"; import local from "@/utils/local";
...@@ -110,7 +110,7 @@ export default { ...@@ -110,7 +110,7 @@ export default {
size: -1, size: -1,
page: 1, page: 1,
total: 0, total: 0,
siteBusinessList: [], // 站点业务列表 siteBusinessData: [], // 站点业务列表
businessName: "", businessName: "",
rowKeys: [], rowKeys: [],
formData: { formData: {
...@@ -134,7 +134,7 @@ export default { ...@@ -134,7 +134,7 @@ export default {
methods: { methods: {
// 获取窗口信息 // 获取窗口信息
async getWindowInfo(info) { async getWindowInfo(info) {
await this.getSiteBusinessList(); await this.siteBusinessList();
this.formData = info; this.formData = info;
if (info.businessIds.length) { if (info.businessIds.length) {
this.rowKeys = info.businessIds; this.rowKeys = info.businessIds;
...@@ -156,7 +156,7 @@ export default { ...@@ -156,7 +156,7 @@ export default {
// 获取站点业务列表 // 获取站点业务列表
async getSiteBusinessList() { async getSiteBusinessList() {
this.loading = true; this.loading = true;
let res = await getSiteBusinessList({ let res = await siteBusinessList({
page: this.page, page: this.page,
size: this.size, size: this.size,
siteId: this.siteId, siteId: this.siteId,
...@@ -166,7 +166,7 @@ export default { ...@@ -166,7 +166,7 @@ export default {
if (res.data.code === 1) { if (res.data.code === 1) {
let { data, total } = res.data.data; let { data, total } = res.data.data;
this.total = total; this.total = total;
this.siteBusinessList = this.delChildren(data); this.siteBusinessData = this.delChildren(data);
} }
}, },
// 搜索 // 搜索
......
...@@ -418,7 +418,7 @@ export default { ...@@ -418,7 +418,7 @@ export default {
}, },
// 获取站点业务数据 // 获取站点业务数据
// async getBusinessData(obj = {}) { // async getBusinessData(obj = {}) {
// let res = await getSiteBusinessList({ // let res = await siteBusinessList({
// page: 1, // page: 1,
// size: -1, // size: -1,
// siteId: this.siteId, // siteId: this.siteId,
......
...@@ -585,16 +585,23 @@ export default { ...@@ -585,16 +585,23 @@ export default {
pmWorkEndTime, pmWorkEndTime,
logoPath, logoPath,
} = (this.formInfo = data); } = (this.formInfo = data);
this.areaInfo.areaID = areaID; this.areaInfo.areaID = areaID;
this.areaInfo.areaCode = areaCode; this.areaInfo.areaCode = areaCode;
this.areaInfo.areaName = areaName; this.areaInfo.areaName = areaName;
this.cityData = [proCode, cityCode, districtCode]; this.cityData = [proCode, cityCode, districtCode];
this.formInfo.modelIds = modelIds.map(Number); this.formInfo.modelIds = modelIds.map(Number);
this.formInfo.amWorkStartTime = String(amWorkStartTime); [
this.formInfo.amWorkEndTime = String(amWorkEndTime); this.formInfo.amWorkStartTime,
this.formInfo.pmWorkStartTime = String(pmWorkStartTime); this.formInfo.amWorkEndTime,
this.formInfo.pmWorkEndTime = String(pmWorkEndTime); this.formInfo.pmWorkStartTime,
this.formInfo.pmWorkEndTime,
] = [
amWorkStartTime,
amWorkEndTime,
pmWorkStartTime,
pmWorkEndTime,
].map(String);
if (logoPath) { if (logoPath) {
this.fileList = [ this.fileList = [
{ {
...@@ -633,16 +640,17 @@ export default { ...@@ -633,16 +640,17 @@ export default {
}, },
// 上传限制 // 上传限制
beforeUpload(file) { beforeUpload(file) {
let restrict = 10; // 限制文件大小MB
const isJpgOrPng = const isJpgOrPng =
file.type === "image/jpeg" || file.type === "image/png"; file.type === "image/jpeg" || file.type === "image/png";
if (!isJpgOrPng) { if (!isJpgOrPng) {
this.$message.error("请上传jpeg或者png图片!"); this.$message.error("请上传jpeg或者png图片!");
} }
const isLt10M = file.size / 1024 / 1024 < 10; const isExceed = file.size / 1024 / 1024 <= restrict;
if (!isLt10M) { if (!isExceed) {
this.$message.error("图片大小不能超过10MB!"); this.$message.error(`图片大小不能超过${restrict}MB!`);
} }
return isJpgOrPng && isLt10M; return isJpgOrPng && isExceed;
}, },
// 上传图片 // 上传图片
handleChange({ file, fileList }) { handleChange({ file, fileList }) {
......
import { import { business, sitebusiness, businessmatter } from "@/services/basicsetApi";
business,sitebusiness,businessmatter
} from '@/services/basicsetApi'
import {request, METHOD} from '@/utils/request' import { request, METHOD } from "@/utils/request";
/** /**
* 一体化业务 * 一体化业务
*/ */
// 查看业务 // 查看业务
export async function getBusinessInfo(data) { export async function businessInfo(data) {
return request(business.info, METHOD.GET, data) return request(business.info, METHOD.GET, data);
} }
//获取业务列表 //获取业务列表
export async function getBusinessList(data) { export async function businessList(data) {
return request(business.list, METHOD.POST, data) return request(business.list, METHOD.POST, data);
} }
//保存更新业务 //保存更新业务
export async function saveBusiness(data) { export async function saveBusiness(data) {
return request(business.save, METHOD.POST, data) return request(business.save, METHOD.POST, data);
} }
//删除业务 //删除业务
export async function businessDel(data) { export async function businessDel(data) {
return request(business.delete, METHOD.GET, data) return request(business.delete, METHOD.GET, data);
} }
// 添加业务到站点 // 添加业务到站点
export async function addInBusiness(data) { export async function addInBusiness(data) {
return request(business.addBusinessToSite, METHOD.POST, data) return request(business.addBusinessToSite, METHOD.POST, data);
} }
/** /**
* 站点业务 * 站点业务
*/ */
// 查看站点业务列表 // 查看站点业务列表
export async function getSiteBusinessList(data) { export async function siteBusinessList(data) {
return request(sitebusiness.list, METHOD.POST, data) return request(sitebusiness.list, METHOD.POST, data);
} }
// 新增站点业务 // 新增站点业务
export async function addSite(data) { export async function addSite(data) {
return request(sitebusiness.save, METHOD.POST, data) return request(sitebusiness.save, METHOD.POST, data);
} }
// 编辑站点业务 // 编辑站点业务
export async function editSiteBusiness(data) { export async function editSiteBusiness(data) {
return request(sitebusiness.edit, METHOD.GET, data) return request(sitebusiness.edit, METHOD.GET, data);
} }
//删除站点业务 //删除站点业务
export async function delSiteBusiness(data) { export async function delSiteBusiness(data) {
return request(sitebusiness.delete, METHOD.GET, data) return request(sitebusiness.delete, METHOD.GET, data);
} }
/** /**
...@@ -56,26 +53,26 @@ export async function delSiteBusiness(data) { ...@@ -56,26 +53,26 @@ export async function delSiteBusiness(data) {
*/ */
// 保存业务关联事项 // 保存业务关联事项
export async function addBusinessMatter(data) { export async function addBusinessMatter(data) {
return request(businessmatter.save, METHOD.POST, data) return request(businessmatter.save, METHOD.POST, data);
} }
// 获取业务关联事项列表 // 获取业务关联事项列表
export async function getBusinessMatterList(data) { export async function businessMatterList(data) {
return request(businessmatter.list, METHOD.POST, data) return request(businessmatter.list, METHOD.POST, data);
} }
// 删除业务事项关联 // 删除业务事项关联
export async function delBusinessMatter(data) { export async function delBusinessMatter(data) {
return request(businessmatter.delete, METHOD.GET, data) return request(businessmatter.delete, METHOD.GET, data);
} }
// 业务关联列表 // 业务关联列表
export async function getBusinesslistData(data) { export async function getBusinesslistData(data) {
return request(businessmatter.businesslist, METHOD.POST, data) return request(businessmatter.businesslist, METHOD.POST, data);
} }
// 事项关联列表 // 事项关联列表
export async function getMatterlistData(data) { export async function getMatterlistData(data) {
return request(businessmatter.matterlist, METHOD.POST, data) return request(businessmatter.matterlist, METHOD.POST, data);
} }
// 批量关联业务事项 // 批量关联业务事项
export async function addBatchSave(data) { export async function addBatchSave(data) {
return request(businessmatter.batchSave, METHOD.POST, data) return request(businessmatter.batchSave, METHOD.POST, data);
} }
Markdown is supported
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