增删改查over

This commit is contained in:
weicw
2021-08-03 14:41:25 +08:00
parent 1d94a57e39
commit b706a8a155
3 changed files with 135 additions and 32 deletions

View File

@@ -19,7 +19,13 @@ const removeBatchRoadSoundBill = function (ids) {
const updateRoadSoundBill = function (data) {
return axios.put("/collect/sound/road/bill",data)
}
// 审核
const verifyRoadSoundBill = function (data) {
return axios.put("/collect/sound/road/bill/verify",data);
}
const getRoadSoundBill = function (id) {
return axios.get(`/collect/sound/road/bill/${id}`)
}
// -------------------------数据---------------------
const pageRoadSoundUrl = '/collect/sound/road/page';
// 添加
@@ -46,6 +52,8 @@ export {
removeRoadSoundBill,
updateRoadSoundBill,
removeBatchRoadSoundBill,
verifyRoadSoundBill,
getRoadSoundBill,
pageRoadSoundUrl,
saveRoadSound,
removeRoadSound,

View File

@@ -4,17 +4,25 @@
<!-- 搜索表单 -->
<a-form :model="where" :labelCol="{ offset: 1}">
<a-row>
<a-col :lg="8" :md="12" :sm="24" :xs="24">
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="审核状态:">
<a-select v-model:value="where.checked" allowClear placeholder="全部">
<a-select-option value="1">已审核</a-select-option>
<a-select-option value="0">未审核</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="表格名称:">
<a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear />
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :sm="24" :xs="24">
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="上报时间:">
<a-range-picker separator="/" v-model:value="where.createTime" />
<a-range-picker separator="~" v-model:value="reportTimeScope" />
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :sm="24" :xs="24">
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item class="ele-text-right" :wrapper-col="{span: 24}">
<a-space>
<a-button type="primary" @click="reload">查询</a-button>
@@ -22,7 +30,7 @@
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
<!-- 表格 -->
@@ -51,17 +59,34 @@
</div>
</div>
</template>
<template #reportTime="{ text, record }">
<div class="editable-cell">
<div v-if="editableData[record.roadSoundBillId]" class="editable-cell-input-wrapper">
<a-date-picker v-model:value="editableData[record.roadSoundBillId].reportTime"></a-date-picker>
<!-- <a-input v-model:value="editableData[record.roadSoundBillId].reportTime" @pressEnter="save(record)" /> -->
<check-outlined class="editable-cell-icon-check" @click="save(record)" />
</div>
<div v-else class="editable-cell-text-wrapper">
{{ $util.toDateString(text,'yyyy-MM-dd') || ' ' }}
<edit-outlined class="editable-cell-icon" @click="edit(record)" />
</div>
</div>
</template>
<template #checked="{text}">
<span>
<a-tag v-if="text" color="green">已审核</a-tag>
<a-tag v-else color="orange">未审核</a-tag>
</span>
</template>
<template #action="{ record }">
<a-space>
<a-button @click="detail(record)" shape="round" size="small">查看</a-button>
<a-popconfirm :title="`审核通过后将无法修改,确认?`" ok-text="Yes" cancel-text="No" @confirm="remove(record)">
<a-button @click="detail(record)" shape="round" size="small">查看</a-button>
<a-popconfirm :title="`审核通过后将无法修改,确认?`" ok-text="Yes" cancel-text="No" @confirm="verify(record)">
<a-button type="primary" shape="round" size="small">审核</a-button>
</a-popconfirm>
<a-popconfirm :title="`确认删除${record.billName}吗?`" ok-text="Yes" cancel-text="No" @confirm="remove(record)">
<a-button type="primary" danger shape="round" size="small">删除</a-button>
</a-popconfirm>
</a-space>
</template>
</ele-pro-table>
@@ -82,9 +107,11 @@
saveRoadSoundBill,
removeRoadSoundBill,
removeBatchRoadSoundBill,
updateRoadSoundBill
updateRoadSoundBill,
verifyRoadSoundBill
} from "@/api/ecology/road_sound";
import utils from "./utils";
import moment from "moment";
export default {
name: 'RoadSound',
components: {
@@ -131,9 +158,12 @@
title: '上报时间',
dataIndex: 'reportTime',
sorter: true,
customRender: ({
text
}) => this.$util.toDateString(text)
slots: {
customRender: 'reportTime',
},
// customRender: ({
// text
// }) => this.$util.toDateString(text)
},
{
title: '导入时间',
@@ -143,6 +173,15 @@
text
}) => this.$util.toDateString(text)
},
{
title: '审核状态',
dataIndex: 'checked',
sorter: true,
slots: {
customRender: 'checked',
},
},
// {
// title: '更新时间',
// dataIndex: 'updateTime',
@@ -163,6 +202,7 @@
],
// 表格搜索条件
where: {},
reportTimeScope: [],
// 表格选中数据
selectionList: [],
editableData: {},
@@ -175,6 +215,12 @@
/* 刷新表格 */
reload() {
this.where.reportTimeStart = null;
this.where.reportTimeEnd = null;
if (this.reportTimeScope && this.reportTimeScope.length == 2) {
this.where.reportTimeStart = this.reportTimeScope[0].format("Y-M-D H:m:s")
this.where.reportTimeEnd = this.reportTimeScope[1].format("Y-M-D H:m:s")
}
this.$refs.table.reload({
where: this.where
});
@@ -182,6 +228,7 @@
/* 重置搜索 */
reset() {
this.where = {};
this.reportTimeScope = [];
this.reload();
},
detail(record) {
@@ -191,26 +238,53 @@
},
edit(record) {
this.editableData[record.roadSoundBillId] = _.cloneDeep(record);
this.editableData[record.roadSoundBillId].reportTime = moment(this.editableData[record.roadSoundBillId]
.reportTime)
},
verify(record) {
const hide = this.$message.loading('请求中..', 0);
verifyRoadSoundBill({roadSoundBillId:record.roadSoundBillId}).then(res => {
if (res.data.code == 0) {
record.checked = 1
this.$message.success(res.data.msg);
} else {
this.$message.error(res.data.msg);
}
}).catch((e) => {
this.$message.error(e.message);
}).finally(() => {
hide();
})
},
save(record) {
const hide = this.$message.loading('请求中..', 0);
const {
let {
roadSoundBillId,
billName
billName,
reportTime
} = this.editableData[record.roadSoundBillId];
if (!roadSoundBillId || !reportTime) {
this.$message.error('请填写完整信息再提交')
return
}
const hide = this.$message.loading('请求中..', 0);
reportTime = reportTime.format("x")
reportTime = Number(reportTime)
updateRoadSoundBill({
roadSoundBillId,
billName
billName,
reportTime
}).then(res => {
if (res.data.code == 0) {
this.$message.success(res.data.msg);
record.billName = billName;
record.reportTime = reportTime
} else {
this.$message.error(res.data.msg);
}
}).catch(e => {
console.log(e);
// this.$message.error(e.msg);
this.$message.error(e.message);
}).finally(() => {
delete this.editableData[record.roadSoundBillId]
hide()

View File

@@ -6,8 +6,26 @@
:wrapper-col="{md: {span: 18}, sm: {span: 24}}">
<a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="菜单名称:">
<a-input v-model:value.trim="where.title" placeholder="请输入" allow-clear />
<a-form-item label="测点名称:">
<a-input v-model:value.trim="where.place" placeholder="请输入测点名称" allow-clear />
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="路段:">
<a-input v-model:value.trim="where.road" placeholder="请输入路段名称" allow-clear />
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="城区">
<a-input v-model:value.trim="where.area" placeholder="请输入城区名称" allow-clear />
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item class="ele-text-right" :wrapper-col="{span: 24}">
<a-space>
<a-button type="primary" @click="reload">查询</a-button>
<a-button @click="reset">重置</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
@@ -123,7 +141,7 @@
<!-- 表格 -->
<ele-pro-table v-model:selection="selectionList" ref="table" row-key="roadSoundId" :datasource="url"
:columns="columns" :where="where" :scroll="{x: 'max-content'}">
<template #toolbar>
<template v-if="bill.checked != 1" #toolbar>
<a-space>
<a-button @click="openEdit" type="primary">新增</a-button>
<a-popconfirm :disabled="selectionList.length == 0" :title="`确认删除${selectionList.length}条数据吗?`"
@@ -156,6 +174,7 @@
removeRoadSound,
removeBatchRoadSound,
updateRoadSound,
getRoadSoundBill
} from "@/api/ecology/road_sound";
import locale from 'ant-design-vue/es/date-picker/locale/zh_CN';
import moment from 'moment';
@@ -170,21 +189,12 @@
return {
locale,
bill:{},
// 表格数据接口
url: pageRoadSoundUrl,
selection: [],
// 表格列配置
columns: [
// {
// title: '序号',
// key: 'index',
// dataIndex: 'index',
// width: 48,
// align: 'center',
// customRender: ({
// index
// }) => index + 1
// },
{
title: '监测日期',
dataIndex: 'monitorTime',
@@ -317,6 +327,17 @@
};
},
mounted(){
const {
billId
} = this.$route.params
getRoadSoundBill(billId).then(res=>{
this.bill = res.data.data
if(res.data.data.checked == 1){
this.columns.splice(this.columns.length-1,1)
}
})
},
methods: {
/* 刷新表格 */
reload() {