This commit is contained in:
庞东林
2021-12-08 18:11:44 +08:00
parent fd65e985b1
commit bafaf600af
2 changed files with 98 additions and 59 deletions

View File

@@ -12,36 +12,6 @@
:visiable="visiable" :visiable="visiable"
:loading="loading" :loading="loading"
/> />
<!-- 表格 -->
<!-- <ele-pro-table
v-model:selection="selectionList"
ref="table"
row-key="drinkingWaterId"
:datasource="url"
:columns="columns"
:where="where"
:scroll="{ x: 'max-content' }"
@done="(d) => (data = d.data)"
>
<template #county="{text}">
{{text="市区"}}
</template>
<template #enumber="{ text, record }">
<div class="editable-cell">
<div v-if="editableData[record.key]" class="editable-cell-input-wrapper">
<a-input v-model:value="editableData[record.key].name" @pressEnter="save(record.key)" />
<check-outlined class="editable-cell-icon-check" @click="save(record.key)" />
</div>
<div v-else class="editable-cell-text-wrapper">
{{ text || ' ' }}
<edit-outlined class="editable-cell-icon" @click="edit(record.key)" />
</div>
</div>
</template>
</ele-pro-table> -->
<ele-pro-table ref="table" row-key="drinkingWaterId" :datasource="datasource" :columns="columns" :where="where" <ele-pro-table ref="table" row-key="drinkingWaterId" :datasource="datasource" :columns="columns" :where="where"
:scroll="{ x: 'max-content' }" @done="(d) => (data = d.data)"> :scroll="{ x: 'max-content' }" @done="(d) => (data = d.data)">
@@ -50,18 +20,58 @@
</template> </template>
<template #enumber="{ text, record ,index }"> <template #enumber="{ text, record ,index }">
<div class="editable-cell"> <div class="editable-cell">
<div v-if="editableData[index]" class="editable-cell-input-wrapper"> <div v-if="editableData[index] && editableData[index].edable=='index1'" class="editable-cell-input-wrapper">
<a-input v-model:value="editableData[index].place" @pressEnter="save(record,index)" /> <a-input v-model:value="editableData[index][index3]" @pressEnter="save(editableData[index],index)" />
<check-outlined class="editable-cell-icon-check" @click="save(record,index)" /> <check-outlined class="editable-cell-icon-check" @click="save(editableData[index],index)" />
</div> </div>
<div v-else class="editable-cell-text-wrapper"> <div v-else class="editable-cell-text-wrapper">
{{ text || ' ' }} {{ text || ' ' }}
<edit-outlined class="editable-cell-icon" @click="edit(record,index)" /> <edit-outlined class="editable-cell-icon" @click="edit(record,index,'index3')" />
</div> </div>
</div> </div>
</template> </template>
<template #wnumber="{ text, record ,index }">
<div class="editable-cell">
<div v-if="editableData[index] && editableData[index].edable=='index2'" class="editable-cell-input-wrapper">
<a-input v-model:value="editableData[index][index4]" @pressEnter="save(editableData[index],index)" />
<check-outlined class="editable-cell-icon-check" @click="save(editableData[index],index)" />
</div>
<div v-else class="editable-cell-text-wrapper">
{{ text || ' ' }}
<edit-outlined class="editable-cell-icon" @click="edit(record,index,'index4')" />
</div>
</div>
</template>
<template #desc="{ text, record ,index }">
<div class="editable-cell">
<div v-if="editableData[index] && editableData[index].edable=='index6'" class="editable-cell-input-wrapper">
<a-input v-model:value="editableData[index][index6]" @pressEnter="save(editableData[index],index)" />
<check-outlined class="editable-cell-icon-check" @click="save(editableData[index],index)" />
</div>
<div v-else class="editable-cell-text-wrapper">
{{ text || ' ' }}
<edit-outlined class="editable-cell-icon" @click="edit(record,index,'index6')" />
</div>
</div>
</template>
<template #remark="{ text, record ,index }">
<div class="editable-cell">
<div v-if="editableData[index] && editableData[index].edable=='remark'" class="editable-cell-input-wrapper">
<a-input v-model:value="editableData[index][remark]" @pressEnter="save(editableData[index],index)" />
<check-outlined class="editable-cell-icon-check" @click="save(editableData[index],index)" />
</div>
<div v-else class="editable-cell-text-wrapper">
{{ text || ' ' }}
<edit-outlined class="editable-cell-icon" @click="edit(record,index,'remark')" />
</div>
</div>
</template>
</ele-pro-table> </ele-pro-table>
</a-card> </a-card>
@@ -120,10 +130,11 @@ export default {
{key: "index",title:"序号",dataIndex: "index",width: 48,align: "center",customRender: ({ index }) => index + 1,}, {key: "index",title:"序号",dataIndex: "index",width: 48,align: "center",customRender: ({ index }) => index + 1,},
{title:"城市",dataIndex:"city",}, {title:"城市",dataIndex:"city",},
{title:"县城",dataIndex:"county",slots:{customRender:'county'}}, {title:"县城",dataIndex:"county",slots:{customRender:'county'}},
{title:"水源地名称",dataIndex:"place",}, {title:"水源地名称",dataIndex:"sourceWaterName",},
{title:"类型",dataIndex:"waterSourceProperty",}, {title:"类型",dataIndex:"waterSourceProperty",},
{title:"监测时间",dataIndex:"reportTime",customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").format("YYYY/MM/DD")}, {title:"监测时间",dataIndex:"reportTime"},
{title:"应当监测项目个数",dataIndex:'',filters:[ // {title:"监测时间",dataIndex:"reportTime",customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").format("YYYY/MM/DD")},
{title:"应当监测项目个数",dataIndex:'index1',filters:[
{ {
text: '61', text: '61',
value: '61', value: '61',
@@ -137,16 +148,22 @@ export default {
value: '64', value: '64',
}, },
]}, ]},
{title:"未测个数",dataIndex:"",}, {title:"未测个数",dataIndex:"index2",},
{title:"独立分析项目个数",dataIndex:"place", {title:"独立分析项目个数",dataIndex:"index3",
slots: { slots: {
customRender: 'enumber', customRender: 'enumber',
}, },
}, },
{title:"外送分析项目个数",dataIndex:"",}, {title:"外送分析项目个数",dataIndex:"index4", slots: {
{title:"超标项目",dataIndex:"",}, customRender: 'wnumber',
{title:"情况说明或原因",dataIndex:""}, },},
{title:"备注",dataIndex:"remark"}, {title:"超标项目",dataIndex:"index5",},
{title:"情况说明或原因",dataIndex:"index6", slots: {
customRender: 'desc',
}},
{title:"备注",dataIndex:"remark",slots: {
customRender: 'remark',
},},
], ],
@@ -182,15 +199,16 @@ export default {
}, },
//编辑单元格 //编辑单元格
edit(item,index){ edit(item,index,key){
this.editableData[index] = item this.editableData[index] = item
this.editableData[index].edable=key
}, },
save(item,index){ save(item,index){
console.log('item',item) console.log('item',item)
console.log('item.remark', item.remark)
this.datasource[index] = item this.datasource[index] = item
this.editableData = [] this.editableData = []
}, },

View File

@@ -15,7 +15,8 @@
v-model:selection="selectionList" v-model:selection="selectionList"
ref="table" ref="table"
row-key="drinkingWaterId" row-key="drinkingWaterId"
:datasource="url" :datasource="datasource"
:loading="loading"
:columns="columns" :columns="columns"
:where="where" :where="where"
:scroll="{ x: 'max-content' }" :scroll="{ x: 'max-content' }"
@@ -32,10 +33,12 @@
// import _ from "lodash"; // import _ from "lodash";
import XLSX from "xlsx"; import XLSX from "xlsx";
import Search from "./../components/search.vue"; import Search from "./../components/search.vue";
import { import {
pageDrinkingWaterStatisticUrl, getWaterCount
// getColumnOptions } from "@/api/ecology/new-drinking-water";
} from "@/api/ecology/drinking-water";
import locale from "ant-design-vue/es/date-picker/locale/zh_CN"; import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
// import { tableColumns } from "./colums"; // import { tableColumns } from "./colums";
@@ -65,7 +68,6 @@ export default {
locale, locale,
bill: {}, bill: {},
// 表格数据接口 // 表格数据接口
url: pageDrinkingWaterStatisticUrl,
selection: [], selection: [],
columns: [ columns: [
{title: "水源名称",dataIndex: "sourceWaterName",sorter: true,}, {title: "水源名称",dataIndex: "sourceWaterName",sorter: true,},
@@ -84,12 +86,30 @@ export default {
}, },
// 表格选中数据 // 表格选中数据
selectionList: [], selectionList: [],
loading: false
}; };
}, },
mounted() { mounted() {
// this.loadOptionData(); // this.loadOptionData();
}, },
methods: { methods: {
// 获取列表数据
getPageData(){
this.loading = true;
getWaterCount(this.where).then(res=>{
this.loading = false;
if(res.data.code){
this.$message.error(res.data.msg);
this.datasource = []
}else{
this.datasource = res.data.data
}
}).catch(()=>{
this.loading = false;
})
},
JumpFieldClick(record, column) { JumpFieldClick(record, column) {
console.log(column.dataIndex); console.log(column.dataIndex);
}, },
@@ -107,9 +127,10 @@ export default {
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.$refs.table.reload({ this.getPageData()
where: this.where, // this.$refs.table.reload({
}); // where: this.where,
// });
}, },
/* 重置搜索 */ /* 重置搜索 */
reset() { reset() {