批量复制

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

View File

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

View File

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