批量复制

This commit is contained in:
weicw
2021-09-27 03:40:11 +08:00
parent ad3b1fc7e6
commit 1fc4e2590a
3 changed files with 119 additions and 32 deletions

View File

@@ -20,7 +20,9 @@ const removeBatchPlace = function (ids) {
const updatePlace = function (data) { const updatePlace = function (data) {
return axios.put("/sound/road/place",data) return axios.put("/sound/road/place",data)
} }
const copyBatchPlace = function (data){
return axios.post("/sound/road/place/copyBatch",data)
}
const getColumnOptions = function(column){ const getColumnOptions = function(column){
return axios.get("/sound/road/place/options",{params:{column}}) return axios.get("/sound/road/place/options",{params:{column}})
} }
@@ -30,6 +32,7 @@ export {
updatePlace, updatePlace,
removeBatchPlace, removeBatchPlace,
removePlace, removePlace,
getColumnOptions getColumnOptions,
copyBatchPlace
} }

View File

@@ -24,6 +24,9 @@ const updatePlace = function (data) {
const getColumnOptions = function(column){ const getColumnOptions = function(column){
return axios.get("/sound/zone/place/options",{params:{column}}) return axios.get("/sound/zone/place/options",{params:{column}})
} }
const copyBatchPlace = function (data){
return axios.post("/sound/zone/copyBatch",data)
}
export { export {
@@ -32,6 +35,7 @@ export {
updatePlace, updatePlace,
removeBatchPlace, removeBatchPlace,
removePlace, removePlace,
copyBatchPlace,
getColumnOptions getColumnOptions
} }

View File

@@ -10,8 +10,8 @@
> >
<a-row> <a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24"> <a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="你放:"> <a-form-item label="年份:">
<a-select v-model:value="where.year"> <a-select v-model:value="where.year" allow-clear show-search>
<a-select-option <a-select-option
v-for="(item) in yearOptions" v-for="(item) in yearOptions"
:key="item.value" :key="item.value"
@@ -25,12 +25,31 @@
<a-col :lg="24" :md="24" :sm="24" :xs="24"> <a-col :lg="24" :md="24" :sm="24" :xs="24">
<a-space> <a-space>
<a-button type="primary" @click="reload">查询</a-button> <a-button type="primary" @click="reload">查询</a-button>
<a-button type="primary" @click="copy">批量复制</a-button>
<a-button @click="reset">重置</a-button> <a-button @click="reset">重置</a-button>
</a-space> </a-space>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
<a-modal
v-model:visible="showNYear"
:title="'批量复制'"
:confirm-loading="loading"
:body-style="{ paddingBottom: '8px' }"
@ok="copyBatch"
>
<a-form
ref="form"
:model="form"
:rules="rules"
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
>
<a-form-item label="新年份" name="nYear">
<a-input-number id="inputNumber" v-model:value="nYear" :min="1970" :max="2050" />
</a-form-item>
</a-form>
</a-modal>
<a-modal <a-modal
v-model:visible="showEdit" v-model:visible="showEdit"
:title="form.roadNoisePlaceId !== undefined ? '修改' : '添加'" :title="form.roadNoisePlaceId !== undefined ? '修改' : '添加'"
@@ -46,6 +65,9 @@
:label-col="{ md: { span: 6 }, sm: { span: 24 } }" :label-col="{ md: { span: 6 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }" :wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
> >
<a-form-item label="年份" name="year">
<a-input v-model:value="form.year" placeholder="请输入年份" allow-clear/>
</a-form-item>
<a-form-item label="测点名称" name="placeName"> <a-form-item label="测点名称" name="placeName">
<a-input v-model:value="form.placeName" placeholder="请输入测点名称" allow-clear/> <a-input v-model:value="form.placeName" placeholder="请输入测点名称" allow-clear/>
</a-form-item> </a-form-item>
@@ -109,6 +131,19 @@
<template #toolbar> <template #toolbar>
<a-space> <a-space>
<a-button @click="openEdit" type="primary">新增</a-button> <a-button @click="openEdit" type="primary">新增</a-button>
<a-dropdown>
<template #overlay>
<a-menu @click="setCYear">
<a-menu-item v-for="item in yearOptions" :key="item.value">
{{ item.label }}
</a-menu-item>
</a-menu>
</template>
<a-button>
批量复制
<DownOutlined/>
</a-button>
</a-dropdown>
<a-popconfirm <a-popconfirm
:disabled="selectionList.length == 0" :disabled="selectionList.length == 0"
:title="`确认删除${selectionList.length}条数据吗?`" :title="`确认删除${selectionList.length}条数据吗?`"
@@ -133,7 +168,8 @@
type="primary" type="primary"
shape="round" shape="round"
size="small" size="small"
>修改</a-button >修改
</a-button
> >
<a-popconfirm <a-popconfirm
:title="`确认删除这条数据吗?`" :title="`确认删除这条数据吗?`"
@@ -142,7 +178,8 @@
@confirm="remove(record)" @confirm="remove(record)"
> >
<a-button type="primary" danger shape="round" size="small" <a-button type="primary" danger shape="round" size="small"
>删除</a-button >删除
</a-button
> >
</a-popconfirm> </a-popconfirm>
</a-space> </a-space>
@@ -161,12 +198,14 @@ import {
updatePlace, updatePlace,
removePlace, removePlace,
removeBatchPlace, removeBatchPlace,
copyBatchPlace,
getColumnOptions getColumnOptions
} from "@/api/ecology/noise/road-noise-place"; } from "@/api/ecology/noise/road-noise-place";
import {DownOutlined} from '@ant-design/icons-vue';
// import moment from "moment"; // import moment from "moment";
export default { export default {
name: "RoadNoisePlace", name: "RoadNoisePlace",
components: {}, components: {DownOutlined},
data() { data() {
return { return {
data: [], data: [],
@@ -175,6 +214,11 @@ export default {
selection: [], selection: [],
// 表格列配置 // 表格列配置
columns: [ columns: [
{
title: "年份",
dataIndex: "year",
sorter: true,
},
{ {
title: "测点名称", title: "测点名称",
dataIndex: "placeName", dataIndex: "placeName",
@@ -261,14 +305,16 @@ export default {
}, },
}, },
], ],
// 表格搜索条件 // 表格搜索条件
where: {}, where: {},
yearOption:[], yearOptions: [],
// 表格选中数据 // 表格选中数据
selectionList: [], selectionList: [],
// 是否显示编辑弹窗 // 是否显示编辑弹窗
showEdit: false, showEdit: false,
showNYear:false,
cYear: undefined,
nYear:undefined,
// 表单数据 // 表单数据
form: {}, form: {},
loading: false, loading: false,
@@ -280,9 +326,7 @@ export default {
}; };
}, },
mounted() { mounted() {
getColumnOptions("year").then(res=>{ this.getOptions();
console.log(res)
})
}, },
methods: { methods: {
/* 刷新表格 */ /* 刷新表格 */
@@ -292,6 +336,19 @@ export default {
where: this.where, where: this.where,
}); });
}, },
getOptions(){
getColumnOptions("year").then(res => {
console.log(res)
if (res.data.code == 0) {
this.yearOptions = res.data.data.map(item => {
return {
label: item,
value: item
}
})
}
})
},
/* 重置搜索 */ /* 重置搜索 */
reset() { reset() {
this.where = {}; this.where = {};
@@ -317,6 +374,7 @@ export default {
this.showEdit = false; this.showEdit = false;
this.$message.success(res.data.msg); this.$message.success(res.data.msg);
this.reload(); this.reload();
this.getOptions();
} else { } else {
this.$message.error(res.data.msg); this.$message.error(res.data.msg);
} }
@@ -334,6 +392,7 @@ export default {
this.showEdit = false; this.showEdit = false;
this.$message.success(res.data.msg); this.$message.success(res.data.msg);
this.reload(); this.reload();
this.getOptions();
} else { } else {
this.$message.error(res.data.msg); this.$message.error(res.data.msg);
} }
@@ -378,6 +437,27 @@ export default {
}).finally(() => { }).finally(() => {
hide(); hide();
}) })
},
setCYear(e){
this.cYear = e.key;
this.showNYear = true;
},
copyBatch(){
const hide = this.$message.loading('请求中..', 0);
copyBatchPlace({cyear:Number(this.cYear),nyear:this.nYear}).then(res=>{
if (res.data.code === 0) {
this.$message.success(res.data.msg);
this.reload();
this.getOptions();
} else {
this.$message.error(res.data.msg);
}
this.showNYear = false;
}).catch(e => {
this.$message.error(e.message);
}).finally(() => {
hide();
})
} }
}, },