增删改查

This commit is contained in:
weicw
2021-08-02 18:31:25 +08:00
parent 428125d7fb
commit 1d94a57e39
12 changed files with 871 additions and 208 deletions

49
package-lock.json generated
View File

@@ -18,6 +18,7 @@
"echarts": "~5.1.2", "echarts": "~5.1.2",
"echarts-wordcloud": "~2.0.0", "echarts-wordcloud": "~2.0.0",
"ele-admin-pro": "~1.5.0", "ele-admin-pro": "~1.5.0",
"lodash": "^4.17.21",
"nprogress": "~0.2.0", "nprogress": "~0.2.0",
"tinymce": "~5.8.2", "tinymce": "~5.8.2",
"vue": "~3.1.5", "vue": "~3.1.5",
@@ -4837,11 +4838,6 @@
"vue": ">=3.1.0" "vue": ">=3.1.0"
} }
}, },
"node_modules/ant-design-vue/node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/any-promise": { "node_modules/any-promise": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
@@ -11738,9 +11734,9 @@
} }
}, },
"node_modules/lodash": { "node_modules/lodash": {
"version": "4.17.20", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}, },
"node_modules/lodash-es": { "node_modules/lodash-es": {
"version": "4.17.21", "version": "4.17.21",
@@ -15526,12 +15522,6 @@
"url": "https://github.com/fb55/domutils?sponsor=1" "url": "https://github.com/fb55/domutils?sponsor=1"
} }
}, },
"node_modules/renderkid/node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/renderkid/node_modules/nth-check": { "node_modules/renderkid/node_modules/nth-check": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
@@ -17869,12 +17859,6 @@
"node": ">=8.0.0" "node": ">=8.0.0"
} }
}, },
"node_modules/vue-eslint-parser/node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/vue-eslint-parser/node_modules/semver": { "node_modules/vue-eslint-parser/node_modules/semver": {
"version": "6.3.0", "version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
@@ -23031,13 +23015,6 @@
"shallow-equal": "^1.0.0", "shallow-equal": "^1.0.0",
"vue-types": "^3.0.0", "vue-types": "^3.0.0",
"warning": "^4.0.0" "warning": "^4.0.0"
},
"dependencies": {
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}
} }
}, },
"any-promise": { "any-promise": {
@@ -28497,9 +28474,9 @@
} }
}, },
"lodash": { "lodash": {
"version": "4.17.20", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}, },
"lodash-es": { "lodash-es": {
"version": "4.17.21", "version": "4.17.21",
@@ -31492,12 +31469,6 @@
"domhandler": "^4.2.0" "domhandler": "^4.2.0"
} }
}, },
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"nth-check": { "nth-check": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
@@ -33463,12 +33434,6 @@
"estraverse": "^4.1.1" "estraverse": "^4.1.1"
} }
}, },
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"semver": { "semver": {
"version": "6.3.0", "version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",

View File

@@ -20,6 +20,7 @@
"echarts": "~5.1.2", "echarts": "~5.1.2",
"echarts-wordcloud": "~2.0.0", "echarts-wordcloud": "~2.0.0",
"ele-admin-pro": "~1.5.0", "ele-admin-pro": "~1.5.0",
"lodash": "^4.17.21",
"nprogress": "~0.2.0", "nprogress": "~0.2.0",
"tinymce": "~5.8.2", "tinymce": "~5.8.2",
"vue": "~3.1.5", "vue": "~3.1.5",

View File

@@ -1,7 +1,55 @@
// import axios from 'axios'; import axios from 'axios';
const pageBillUrl = '/ecology/sound/road/bill/page'; // ----------------------列表-----------------------
const pageBillUrl = '/collect/sound/road/bill/page';
// 添加
const saveRoadSoundBill = function (data) {
return axios.post("/collect/sound/road/bill",data)
}
// 删除
const removeRoadSoundBill = function (id) {
return axios.delete(`/collect/sound/road/bill/${id}`,)
}
// 批量删除
const removeBatchRoadSoundBill = function (ids) {
return axios.delete("/collect/sound/road/bill/batch",{data:ids})
}
// 修改
const updateRoadSoundBill = function (data) {
return axios.put("/collect/sound/road/bill",data)
}
// -------------------------数据---------------------
const pageRoadSoundUrl = '/collect/sound/road/page';
// 添加
const saveRoadSound = function (data) {
return axios.post("/collect/sound/road",data)
}
// 删除
const removeRoadSound = function (id) {
return axios.delete(`/collect/sound/road/${id}`,)
}
// 批量删除
const removeBatchRoadSound = function (ids) {
return axios.delete("/collect/sound/road/batch",{data:ids})
}
// 修改
const updateRoadSound = function (data) {
return axios.put("/collect/sound/road",data)
}
export { export {
pageBillUrl, pageBillUrl,
saveRoadSoundBill,
removeRoadSoundBill,
updateRoadSoundBill,
removeBatchRoadSoundBill,
pageRoadSoundUrl,
saveRoadSound,
removeRoadSound,
updateRoadSound,
removeBatchRoadSound
} }

View File

@@ -46,9 +46,6 @@ axios.interceptors.response.use((res) => {
if (access_token) { if (access_token) {
setting.cacheToken(access_token); setting.cacheToken(access_token);
} }
if(res.data.code != 0){
return Promise.reject(res.data.msg);
}
return res; return res;
}, (error) => { }, (error) => {
return Promise.reject(error); return Promise.reject(error);

View File

@@ -11,7 +11,7 @@ export default {
// 不需要登录的路由 // 不需要登录的路由
whiteList: ['/login', '/forget'], whiteList: ['/login', '/forget'],
// 菜单数据接口 // 菜单数据接口
menuUrl: '/main/menu?type=pro', menuUrl: '/main/menu',
// 自定义解析菜单接口数据 // 自定义解析菜单接口数据
parseMenu: null, parseMenu: null,
// 自定义解析菜单接口单个数据格式 // 自定义解析菜单接口单个数据格式
@@ -49,9 +49,9 @@ export default {
// 首页路径, 为空会自动获取 // 首页路径, 为空会自动获取
homePath: null, homePath: null,
// 顶栏是否显示主题设置按钮 // 顶栏是否显示主题设置按钮
showSetting: true, showSetting: false,
// 开启多页签是否缓存组件 // 开启多页签是否缓存组件
tabKeepAlive: true, tabKeepAlive: false,
// 是否折叠侧边栏 // 是否折叠侧边栏
collapse: false, collapse: false,
// 侧边栏风格: light(亮色), dark(暗色) // 侧边栏风格: light(亮色), dark(暗色)
@@ -61,7 +61,7 @@ export default {
// 标签页风格: default(默认), dot(圆点), card(卡片) // 标签页风格: default(默认), dot(圆点), card(卡片)
tabStyle: 'default', tabStyle: 'default',
// 布局风格: side(默认), top(顶栏菜单), mix(混合菜单) // 布局风格: side(默认), top(顶栏菜单), mix(混合菜单)
layoutStyle: 'side', layoutStyle: 'mix',
// 侧边栏菜单风格: default(默认), mix(双排菜单) // 侧边栏菜单风格: default(默认), mix(双排菜单)
sideMenuStyle: 'default', sideMenuStyle: 'default',
// 是否固定侧栏 // 是否固定侧栏

View File

@@ -32,12 +32,12 @@
</div> </div>
<template #overlay> <template #overlay>
<a-menu @click="onUserDropClick"> <a-menu @click="onUserDropClick">
<a-menu-item key="profile"> <!-- <a-menu-item key="profile">
<div class="ele-cell"> <div class="ele-cell">
<user-outlined/> <user-outlined/>
<div class="ele-cell-content">{{ $t('layout.header.profile') }}</div> <div class="ele-cell-content">{{ $t('layout.header.profile') }}</div>
</div> </div>
</a-menu-item> </a-menu-item> -->
<a-menu-item key="password"> <a-menu-item key="password">
<div class="ele-cell"> <div class="ele-cell">
<key-outlined/> <key-outlined/>
@@ -67,7 +67,7 @@ import {createVNode} from 'vue';
import { import {
DownOutlined, DownOutlined,
MoreOutlined, MoreOutlined,
UserOutlined, // UserOutlined,
KeyOutlined, KeyOutlined,
LogoutOutlined, LogoutOutlined,
ExclamationCircleOutlined, ExclamationCircleOutlined,
@@ -83,7 +83,7 @@ export default {
components: { components: {
DownOutlined, DownOutlined,
MoreOutlined, MoreOutlined,
UserOutlined, // UserOutlined,
KeyOutlined, KeyOutlined,
LogoutOutlined, LogoutOutlined,
FullscreenOutlined, FullscreenOutlined,

View File

@@ -434,6 +434,7 @@ export default {
* @param value {Array} * @param value {Array}
*/ */
setKeepAliveExclude({ commit }, value) { setKeepAliveExclude({ commit }, value) {
console.log(value);
commit('SET', {key: 'keepAliveExclude', value: value}); commit('SET', {key: 'keepAliveExclude', value: value});
}, },
/** /**

View File

@@ -2,34 +2,66 @@
<div class="ele-body"> <div class="ele-body">
<a-card :bordered="false"> <a-card :bordered="false">
<!-- 搜索表单 --> <!-- 搜索表单 -->
<a-form :model="where" :label-col="{md: {span: 6}, sm: {span: 24}}" :wrapper-col="{md: {span: 18}, sm: {span: 24}}"> <a-form :model="where" :labelCol="{ offset: 1}">
<a-row> <a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24"> <a-col :lg="8" :md="12" :sm="24" :xs="24">
<a-form-item label="菜单名称:"> <a-form-item label="表格名称:">
<a-input v-model:value.trim="where.title" placeholder="请输入" allow-clear /> <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-form-item label="上报时间:">
<a-range-picker separator="/" v-model:value="where.createTime" />
</a-form-item>
</a-col>
<a-col :lg="8" :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-form-item>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
<!-- 表格 --> <!-- 表格 -->
<ele-pro-table ref="table" row-key="ecoRoadSoundBillId" :datasource="url" :columns="columns" :where="where" :scroll="{x: 'max-content'}"> <ele-pro-table v-model:selection="selectionList" ref="table" row-key="roadSoundBillId" :datasource="url"
:columns="columns" :where="where" :scroll="{x: 'max-content'}">
<template #toolbar> <template #toolbar>
<a-space> <a-space>
<a-upload :before-upload="importFile" :show-file-list="false" accept=".xls,.xlsx,.csv"> <a-upload :before-upload="importFile" :showUploadList="false" accept=".xls,.xlsx,.csv">
<a-button>导入excel</a-button> <a-button>导入excel</a-button>
</a-upload> </a-upload>
<a-popconfirm :disabled="selectionList.length == 0" :title="`确认删除${selectionList.length}条数据吗?`"
ok-text="Yes" cancel-text="No" @confirm="removeBatch">
<a-button :disabled="selectionList.length == 0" type="primary" ghost danger>删除</a-button>
</a-popconfirm>
</a-space> </a-space>
</template> </template>
<template #billName="{ text, record }">
<div class="editable-cell">
<div v-if="editableData[record.roadSoundBillId]" class="editable-cell-input-wrapper">
<a-input v-model:value="editableData[record.roadSoundBillId].billName" @pressEnter="save(record)" />
<check-outlined class="editable-cell-icon-check" @click="save(record)" />
</div>
<div v-else class="editable-cell-text-wrapper">
{{ text || ' ' }}
<edit-outlined class="editable-cell-icon" @click="edit(record)" />
</div>
</div>
</template>
<template #action="{ record }"> <template #action="{ record }">
<a-space> <a-space>
<a @click="openEdit(null, record.menuId)">添加</a>
<a-divider type="vertical" /> <a-button @click="detail(record)" shape="round" size="small">查看</a-button>
<a @click="openEdit(record)">修改</a> <a-popconfirm :title="`审核通过后将无法修改,确认?`" ok-text="Yes" cancel-text="No" @confirm="remove(record)">
<a-divider type="vertical" /> <a-button type="primary" shape="round" size="small">审核</a-button>
<a-popconfirm @confirm="remove(record)" title="确定要删除此菜单吗?">
<a class="ele-text-danger">删除</a>
</a-popconfirm> </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> </a-space>
</template> </template>
</ele-pro-table> </ele-pro-table>
@@ -40,17 +72,31 @@
<script> <script>
import XLSX from 'xlsx'; import XLSX from 'xlsx';
import {} from '@ant-design/icons-vue'; import _ from "lodash"
import { import {
pageBillUrl CheckOutlined,
EditOutlined
} from '@ant-design/icons-vue';
import {
pageBillUrl,
saveRoadSoundBill,
removeRoadSoundBill,
removeBatchRoadSoundBill,
updateRoadSoundBill
} from "@/api/ecology/road_sound"; } from "@/api/ecology/road_sound";
import utils from "./utils";
export default { export default {
name: 'RoadSound', name: 'RoadSound',
components: {}, components: {
CheckOutlined,
EditOutlined
},
data() { data() {
return { return {
// 表格数据接口 // 表格数据接口
url: pageBillUrl, url: pageBillUrl,
selection: [],
// 表格列配置 // 表格列配置
columns: [{ columns: [{
key: 'index', key: 'index',
@@ -61,27 +107,50 @@ export default {
index index
}) => index + 1 }) => index + 1
}, },
{
title: '表格名称',
dataIndex: 'billName',
sorter: true,
slots: {
customRender: 'billName',
},
},
{
title: '条目',
dataIndex: 'recordSize',
sorter: true,
},
// { // {
// title: '菜单名称', // title: '菜单名称',
// dataIndex: 'title', // dataIndex: 'title',
// sorter: true // sorter: true
// }, // },
{ {
title: '创建时间', title: '上报时间',
dataIndex: 'createTime', dataIndex: 'reportTime',
sorter: true, sorter: true,
customRender: ({ customRender: ({
text text
}) => this.$util.toDateString(text) }) => this.$util.toDateString(text)
}, },
{ {
title: '更新时间', title: '导入时间',
dataIndex: 'updateTime', dataIndex: 'createTime',
sorter: true, sorter: true,
customRender: ({ customRender: ({
text text
}) => this.$util.toDateString(text) }) => this.$util.toDateString(text)
}, },
// {
// title: '更新时间',
// dataIndex: 'updateTime',
// sorter: true,
// customRender: ({
// text
// }) => this.$util.toDateString(text)
// },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
@@ -95,13 +164,15 @@ export default {
// 表格搜索条件 // 表格搜索条件
where: {}, where: {},
// 表格选中数据 // 表格选中数据
selection: [], selectionList: [],
editableData: {},
// 当前编辑数据 // 当前编辑数据
current: null, current: null,
}; };
}, },
methods: { methods: {
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.$refs.table.reload({ this.$refs.table.reload({
@@ -113,11 +184,43 @@ export default {
this.where = {}; this.where = {};
this.reload(); this.reload();
}, },
detail(record) {
this.$router.replace({
path: "/collect/sound/road/table/" + record.roadSoundBillId
})
},
edit(record) {
this.editableData[record.roadSoundBillId] = _.cloneDeep(record);
},
save(record) {
const hide = this.$message.loading('请求中..', 0);
const {
roadSoundBillId,
billName
} = this.editableData[record.roadSoundBillId];
updateRoadSoundBill({
roadSoundBillId,
billName
}).then(res => {
if (res.data.code == 0) {
this.$message.success(res.data.msg);
record.billName = billName;
} else {
this.$message.error(res.data.msg);
}
}).catch(e => {
console.log(e);
// this.$message.error(e.msg);
}).finally(() => {
delete this.editableData[record.roadSoundBillId]
hide()
})
},
/* 删除单个 */ /* 删除单个 */
remove(row) { remove(row) {
const hide = this.$message.loading('请求中..', 0); const hide = this.$message.loading('请求中..', 0);
this.$http.delete('/sys/menu/' + row.menuId).then(res => { removeRoadSoundBill(row.roadSoundBillId).then(res => {
hide();
if (res.data.code === 0) { if (res.data.code === 0) {
this.$message.success(res.data.msg); this.$message.success(res.data.msg);
this.reload(); this.reload();
@@ -125,12 +228,27 @@ export default {
this.$message.error(res.data.msg); this.$message.error(res.data.msg);
} }
}).catch(e => { }).catch(e => {
hide(); this.$message.error(e.msg);
this.$message.error(e.message); }).finally(() => hide());
}); },
removeBatch() {
const ids = this.selectionList.map(item => item.roadSoundBillId);
const hide = this.$message.loading('请求中..', 0);
removeBatchRoadSoundBill(ids).then(res => {
if (res.data.code === 0) {
this.$message.success(res.data.msg);
this.reload();
} else {
this.$message.error(res.data.msg);
}
}).catch(e => {
this.$message.error(e.msg);
}).finally(() => hide());
}, },
/* 导入本地excel文件 */ /* 导入本地excel文件 */
importFile(file) { importFile(file) {
try {
let reader = new FileReader(); let reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
let data = new Uint8Array(e.target.result); let data = new Uint8Array(e.target.result);
@@ -141,16 +259,75 @@ export default {
let worksheet = workbook.Sheets[sheetNames[0]]; let worksheet = workbook.Sheets[sheetNames[0]];
// 解析成二维数组 // 解析成二维数组
let aoa = XLSX.utils.sheet_to_json(worksheet, { let aoa = XLSX.utils.sheet_to_json(worksheet, {
header: 1 header: 1,
}); });
console.log(aoa); const reportDate = aoa[1][0].replace(/[^\d]+/g, "-")
const roadSoundList = aoa.filter(item => item.length == 21 && typeof item[0] == "number");
// 解析成对象数组
const billData = utils.toObjData(roadSoundList);
// 上传到服务器
saveRoadSoundBill({
reportTime: new Date(reportDate).getTime(),
billName: file.name.substr(0, file.name.lastIndexOf(".")),
roadSoundList: billData
}).then(() => {
this.reload()
})
// console.log(billData);
}; };
reader.readAsArrayBuffer(file); reader.readAsArrayBuffer(file);
} catch (error) {
this.$message.error("表格格式有误,请检查后重新上传!");
}
return false; return false;
} }
} }
} }
</script> </script>
<style scoped> <style scoped lang="less">
.editable-cell {
position: relative;
.editable-cell-input-wrapper,
.editable-cell-text-wrapper {
padding-right: 24px;
}
.editable-cell-text-wrapper {
padding: 5px 24px 5px 5px;
}
.editable-cell-icon,
.editable-cell-icon-check {
position: absolute;
right: 0;
width: 20px;
cursor: pointer;
}
.editable-cell-icon {
margin-top: 4px;
display: none;
}
.editable-cell-icon-check {
line-height: 28px;
}
.editable-cell-icon:hover,
.editable-cell-icon-check:hover {
color: #108ee9;
}
.editable-add-btn {
margin-bottom: 8px;
}
}
.editable-cell:hover .editable-cell-icon {
display: inline-block;
}
</style> </style>

View File

@@ -0,0 +1,438 @@
<template>
<div class="ele-body">
<a-card :bordered="false">
<!-- 搜索表单 -->
<a-form :model="where" :label-col="{md: {span: 6}, sm: {span: 24}}"
: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>
</a-col>
</a-row>
</a-form>
<a-modal v-model:visible="showEdit" :title="form.roadSoundId!==undefined?'修改用户':'添加用户'" :confirm-loading="loading"
:width="1000" :body-style="{paddingBottom: '8px'}" @ok="save">
<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-row>
<a-col :md="12" :sm="24">
<a-form-item label="日期" name="monitorDate">
<a-date-picker v-model:value="form.monitorDate" :locale="locale" />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="时间" name="monitorTime">
<a-time-picker v-model:value="form.monitorTime" format="HH:mm" />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="时段" name="timeSlot">
<a-select v-model:value="form.timeSlot">
<a-select-option value="昼"></a-select-option>
<a-select-option value="夜"></a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="测点名称" name="place">
<a-input v-model:value="form.place" placeholder="请输入测点名称" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="点号" name="placeCode">
<a-input v-model:value="form.placeCode" placeholder="请输入点号" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="所属路段" name="road">
<a-input v-model:value="form.road" placeholder="请输入测点名称" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="所属城区" name="area">
<a-input v-model:value="form.area" placeholder="请输入点号" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="路长" name="roadLength">
<a-input v-model:value="form.roadLength" placeholder="请输入路长(米)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="总路宽" name="roadWidth">
<a-input v-model:value="form.roadWidth" placeholder="请输入总路宽(米)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="中小型车流量" name="smallTrafficFlow">
<a-input type="number" v-model:value="form.smallTrafficFlow" placeholder="请输入中小型车流量(辆/20分钟"
allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="大型车流量" name="largeTrafficFlow">
<a-input type="number" v-model:value="form.largeTrafficFlow" placeholder="请输入大型车流量(辆/20分钟"
allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="LeqdB(A)" name="indexLeq">
<a-input type="number" v-model:value="form.indexLeq" placeholder="请输入LeqdB(A)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="SDdB(A)" name="indexSd">
<a-input type="number" v-model:value="form.indexSd" placeholder="请输入大SDdB(A)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="L10dB(A)" name="indexL10">
<a-input type="number" v-model:value="form.indexL10" placeholder="请输入L10dB(A)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="L50dB(A)" name="indexL50">
<a-input type="number" v-model:value="form.indexL50" placeholder="请输入L50dB(A)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="L90dB(A)" name="indexL90">
<a-input type="number" v-model:value="form.indexL90" placeholder="请输入L90dB(A)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="LmindB(A)" name="indexLmin">
<a-input type="number" v-model:value="form.indexLmin" placeholder="请输入LmindB(A)" allow-clear />
</a-form-item>
</a-col>
<a-col :md="12" :sm="24">
<a-form-item label="LmaxdB(A)" name="indexLmax">
<a-input type="number" v-model:value="form.indexLmax" placeholder="请输入LmaxdB(A)" allow-clear />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
<!-- 表格 -->
<ele-pro-table v-model:selection="selectionList" ref="table" row-key="roadSoundId" :datasource="url"
:columns="columns" :where="where" :scroll="{x: 'max-content'}">
<template #toolbar>
<a-space>
<a-button @click="openEdit" type="primary">新增</a-button>
<a-popconfirm :disabled="selectionList.length == 0" :title="`确认删除${selectionList.length}条数据吗?`"
ok-text="Yes" cancel-text="No" @confirm="removeBatch">
<a-button :disabled="selectionList.length == 0" type="primary" ghost danger>删除</a-button>
</a-popconfirm>
</a-space>
</template>
<template #action="{ record }">
<a-space>
<a-button @click="openEdit(record)" type="primary" shape="round" size="small">修改</a-button>
<a-popconfirm :title="`确认删除这条数据吗?`" 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>
</a-card>
</div>
<!-- 编辑弹窗 -->
</template>
<script>
import _ from "lodash"
import {
pageRoadSoundUrl,
saveRoadSound,
removeRoadSound,
removeBatchRoadSound,
updateRoadSound,
} from "@/api/ecology/road_sound";
import locale from 'ant-design-vue/es/date-picker/locale/zh_CN';
import moment from 'moment';
// import utils from "./utils";
export default {
name: 'RoadSound',
components: {},
data() {
const {
billId
} = this.$route.params
return {
locale,
// 表格数据接口
url: pageRoadSoundUrl,
selection: [],
// 表格列配置
columns: [
// {
// title: '序号',
// key: 'index',
// dataIndex: 'index',
// width: 48,
// align: 'center',
// customRender: ({
// index
// }) => index + 1
// },
{
title: '监测日期',
dataIndex: 'monitorTime',
sorter: true
},
{
title: '测点名称',
dataIndex: 'place',
sorter: true
},
{
title: '点号',
dataIndex: 'placeCode',
sorter: true
},
{
title: '所属路段',
dataIndex: 'road',
sorter: true
},
{
title: '所属城区',
dataIndex: 'area',
sorter: true
},
{
title: '路长',
dataIndex: 'roadLength',
sorter: true
},
{
title: '路宽',
dataIndex: 'roadWidth',
sorter: true
},
{
title: '中小型车流量(辆/20分钟',
dataIndex: 'smallTrafficFlow',
sorter: true
},
{
title: '大型车流量(辆/20分钟',
dataIndex: 'largeTrafficFlow',
sorter: true
},
{
title: '时段',
dataIndex: 'timeSlot',
sorter: true
},
// {
// title: '月',
// dataIndex: 'monitorMonth',
// sorter: true
// },
// {
// title: '日',
// dataIndex: 'monitorDay',
// sorter: true
// },
// {
// title: '时',
// dataIndex: 'monitorHour',
// sorter: true
// },
// {
// title: '分',
// dataIndex: 'monitorMinute',
// sorter: true
// },
{
title: 'LeqdB(A)',
dataIndex: 'indexLeq',
sorter: true
},
{
title: 'SDdB(A)',
dataIndex: 'indexSd',
sorter: true
},
{
title: 'L10dB(A)',
dataIndex: 'indexL10',
sorter: true
},
{
title: 'L50dB(A)',
dataIndex: 'indexL50',
sorter: true
},
{
title: 'L90dB(A)',
dataIndex: 'indexL90',
sorter: true
},
{
title: 'LmindB(A)',
dataIndex: 'indexLmin',
sorter: true
},
{
title: 'LmaxdB(A)',
dataIndex: 'indexLmax',
sorter: true
},
{
title: '操作',
key: 'action',
width: 150,
align: 'center',
fixed: 'right',
slots: {
customRender: 'action'
}
}
],
// 表格搜索条件
roadSoundBillId: billId,
where: {
roadSoundBillId: billId
},
// 表格选中数据
selectionList: [],
// 是否显示编辑弹窗
showEdit: false,
// 表单数据
form: {},
loading: false,
rules: {}
};
},
methods: {
/* 刷新表格 */
reload() {
console.log(this.$route);
console.log(this.$router);
this.$refs.table.reload({
where: this.where
});
},
/* 重置搜索 */
reset() {
this.where = {
roadSoundBillId: this.roadSoundBillId
};
this.reload();
},
/* 显示编辑 */
openEdit(record) {
const cloneRecord = _.cloneDeep(record)
if (record && cloneRecord.monitorTime) {
console.log(moment(cloneRecord.monitorTime).format('YYYY MM DD'));
cloneRecord.monitorDate = moment(cloneRecord.monitorTime);
cloneRecord.monitorTime = moment(cloneRecord.monitorTime);
}
// cloneRecord.mi
this.form = Object.assign({}, cloneRecord);
this.showEdit = true;
this.$nextTick(() => {
this.$refs.form.clearValidate(); // 清除表单验证信息
});
},
save() {
const hide = this.$message.loading('请求中..', 0);
const form = _.cloneDeep(this.form);
const date = new Date();
date.setFullYear(form.monitorDate.year());
date.setMonth(form.monitorDate.month());
date.setDate(form.monitorDate.date());
date.setHours(form.monitorTime.hour());
date.setMinutes(form.monitorTime.minutes());
form.monitorTime = date.getTime();
form.monitorYear = date.getFullYear();
form.monitorMonth = date.getMonth() + 1;
form.monitorDay = date.getDate();
form.monitorHour = date.getHours();
form.monitorMinute = date.getMinutes();
delete form['monitorDate']
if (form.roadSoundId) {
updateRoadSound(form).then(res => {
if (res.data.code == 0) {
this.showEdit = false;
this.$message.success(res.data.msg);
this.reload();
} else {
this.$message.error(res.data.msg);
}
}).catch((error)=>{
this.$message.error(error.message);
}).finally(()=>{
console.log("finallyfinallyfinallyfinally");
hide();
})
}else{
form.roadSoundBillId = this.roadSoundBillId;
saveRoadSound(form).then(res => {
if (res.data.code == 0) {
this.showEdit = false;
this.$message.success(res.data.msg);
this.reload();
} else {
this.$message.error(res.data.msg);
}
}).catch((error)=>{
this.$message.error(error.message);
}).finally(()=>{
hide();
})
}
},
/* 删除单个 */
remove(row) {
const hide = this.$message.loading('请求中..', 0);
removeRoadSound(row.roadSoundId).then(res => {
if (res.data.code === 0) {
this.$message.success(res.data.msg);
this.reload();
} else {
this.$message.error(res.data.msg);
}
}).catch(e => {
this.$message.error(e.msg);
}).finally(() => hide());
},
removeBatch() {
const ids = this.selectionList.map(item => item.roadSoundId);
const hide = this.$message.loading('请求中..', 0);
removeBatchRoadSound(ids).then(res => {
if (res.data.code === 0) {
this.$message.success(res.data.msg);
this.reload();
} else {
this.$message.error(res.data.msg);
}
}).catch(e => {
this.$message.error(e.msg);
}).finally(() => hide());
},
}
}
</script>
<style scoped lang="less">
</style>

View File

@@ -0,0 +1,37 @@
export default {
toObjData(excelData) {
return excelData.map(item => {
const monitorTime = new Date();
monitorTime.setFullYear(item[0]);
monitorTime.setMonth(item[10]-1);
monitorTime.setDate(item[11]);
monitorTime.setHours(item[12]);
monitorTime.setMinutes(item[13]);
return {
monitorYear: item[0],
place: item[1],
placeCode: item[2],
road: item[3],
area: item[4],
roadLength: item[5],
roadWidth: item[6],
smallTrafficFlow: item[7],
largeTrafficFlow: item[7],
timeSlot: item[9],
monitorMonth: item[10],
monitorDay: item[11],
monitorHour: item[12],
monitorMinute: item[13],
monitorTime: monitorTime.getTime(),
indexLeq: item[14],
indexSd: item[15],
indexL10: item[16],
indexL50: item[17],
indexL90: item[18],
indexLmin: item[19],
indexLmax: item[20],
}
})
}
}

View File

@@ -1,5 +1,7 @@
<template> <template>
<div></div> <div class="ele-body">
123
</div>
</template> </template>
<script> <script>

View File

@@ -8,7 +8,7 @@
<a-avatar :size="110" :src="form.avatar"/> <a-avatar :size="110" :src="form.avatar"/>
<upload-outlined class="user-info-avatar-icon"/> <upload-outlined class="user-info-avatar-icon"/>
</div> </div>
<h1>Jasmine</h1> <h1></h1>
<div>海纳百川有容乃大</div> <div>海纳百川有容乃大</div>
</div> </div>
<div class="user-info-list"> <div class="user-info-list">
@@ -22,7 +22,7 @@
</div> </div>
<div class="ele-cell"> <div class="ele-cell">
<environment-outlined/> <environment-outlined/>
<div class="ele-cell-content">中国 浙江省 杭州市</div> <div class="ele-cell-content">中国 广西 南宁</div>
</div> </div>
<div class="ele-cell"> <div class="ele-cell">
<tag-outlined/> <tag-outlined/>
@@ -35,9 +35,6 @@
<a-tag>很有想法的</a-tag> <a-tag>很有想法的</a-tag>
<a-tag>专注设计</a-tag> <a-tag>专注设计</a-tag>
<a-tag>~</a-tag> <a-tag>~</a-tag>
<a-tag>大长腿</a-tag>
<a-tag>川妹子</a-tag>
<a-tag>海纳百川</a-tag>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
@@ -108,7 +105,7 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-tab-pane> </a-tab-pane>
<a-tab-pane tab="账号绑定" key="account"> <!-- <a-tab-pane tab="账号绑定" key="account">
<div class="user-account-list"> <div class="user-account-list">
<div class="ele-cell"> <div class="ele-cell">
<div class="ele-cell-content"> <div class="ele-cell-content">
@@ -161,7 +158,7 @@
<a>去绑定</a> <a>去绑定</a>
</div> </div>
</div> </div>
</a-tab-pane> </a-tab-pane> -->
</a-tabs> </a-tabs>
</a-card> </a-card>
</a-col> </a-col>
@@ -181,9 +178,9 @@ import {
HomeOutlined, HomeOutlined,
EnvironmentOutlined, EnvironmentOutlined,
TagOutlined, TagOutlined,
QqOutlined, // QqOutlined,
WechatOutlined, // WechatOutlined,
AlipayOutlined // AlipayOutlined
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
import EleCropperModal from 'ele-admin-pro/packages/ele-cropper-modal'; import EleCropperModal from 'ele-admin-pro/packages/ele-cropper-modal';
@@ -195,9 +192,9 @@ export default {
HomeOutlined, HomeOutlined,
EnvironmentOutlined, EnvironmentOutlined,
TagOutlined, TagOutlined,
QqOutlined, // QqOutlined,
WechatOutlined, // WechatOutlined,
AlipayOutlined, // AlipayOutlined,
EleCropperModal EleCropperModal
}, },
data() { data() {