增加预警排除清单
This commit is contained in:
parent
187fa28ea6
commit
816f58e29a
@ -66,7 +66,36 @@ export default {
|
|||||||
return await http.post(this.url,params,{'Content-Type': 'multipart/form-data'});
|
return await http.post(this.url,params,{'Content-Type': 'multipart/form-data'});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
exclude:{
|
||||||
|
list:{
|
||||||
|
url: `${config.API_URL}/warning.exclude.list`,
|
||||||
|
name: "排除备件列表",
|
||||||
|
get: async function (params) {
|
||||||
|
return await http.post(this.url, params);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
field:{
|
||||||
|
url: `${config.API_URL}/warning.exclude.field.list`,
|
||||||
|
name: "排除备件检索",
|
||||||
|
post: async function (params) {
|
||||||
|
return await http.post(this.url, params);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
template:{
|
||||||
|
url: `${config.API_URL}/warning.exclude.import.template`,
|
||||||
|
name: "排除备件导入模版",
|
||||||
|
post: async function (params) {
|
||||||
|
return await http.get(this.url,params,{responseType: 'arraybuffer'});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
import:{
|
||||||
|
url: `${config.API_URL}/warning.exclude.import`,
|
||||||
|
name: "排除备件导入",
|
||||||
|
post: async function (params) {
|
||||||
|
return await http.post(this.url,params,{'Content-Type': 'multipart/form-data'});
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -113,7 +113,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getWsResult(res){
|
getWsResult(res){
|
||||||
if(res.data && (res.data.type == 4 || res.data.type == 5 || res.data.type == 10 || res.data.type == 17 || res.data.type == 18 || res.data.type == 27 || res.data.type == 28 || res.data.type == 31 || res.data.type == 42 || res.data.type == 44 || res.data.type == 45 || res.data.type == 48 || res.data.type == 49 || res.data.type == 50)){
|
if(res.data && (res.data.type == 4 || res.data.type == 5 || res.data.type == 10 || res.data.type == 17 || res.data.type == 18 || res.data.type == 27 || res.data.type == 28 || res.data.type == 31 || res.data.type == 42 || res.data.type == 44 || res.data.type == 45 || res.data.type == 48 || res.data.type == 49 || res.data.type == 50 || res.data.type == 51)){
|
||||||
if(this.type == res.data.type){
|
if(this.type == res.data.type){
|
||||||
this.importInfo = res.data;
|
this.importInfo = res.data;
|
||||||
this.progressShow = true;
|
this.progressShow = true;
|
||||||
|
|||||||
289
src/views/earlyManager/exclude.vue
Normal file
289
src/views/earlyManager/exclude.vue
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
<template>
|
||||||
|
<el-container class="mainBox mainBoxHeaderNoBorder">
|
||||||
|
<el-header class="header">
|
||||||
|
<div class="left-panel">
|
||||||
|
<scImport ref="scImport" :size="size" type="51" :httpDisabled="httpDisabled" title="批量导入排除清单" @parentParams="importUpload" @importSuccess="importSuccess">
|
||||||
|
<template #header>
|
||||||
|
<el-button v-auth="'warningExcludeImport'" type="primary" :size="size" plain @click="importFile" style="margin-right: 12px;">批量导入</el-button>
|
||||||
|
</template>
|
||||||
|
<template #download>
|
||||||
|
<div v-auth="'warningExcludeImportTemplate'" @click="importTemplate">下载导入模版</div>
|
||||||
|
</template>
|
||||||
|
</scImport>
|
||||||
|
</div>
|
||||||
|
<div class="right-panel">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</el-header>
|
||||||
|
<el-main class="nopadding">
|
||||||
|
<div class="searchMain searchMainMarginNone">
|
||||||
|
<scTableSearch ref="scSearch" :searchList="list.column" :paramsData="params" :searchShow="searchShow" @fetchSelectData="getSelectData" @changeHeaderData="getHeaderData"></scTableSearch>
|
||||||
|
|
||||||
|
<div class="searchItem searchBtn" v-if="searchHeaderShow">
|
||||||
|
<el-button :size="size" :icon="searchShow?'el-icon-ArrowUpBold':'el-icon-ArrowDownBold'" @click="searchShowClick">{{searchShow?'收起':'更多'}}</el-button>
|
||||||
|
<el-button :size="size" type="primary" icon="el-icon-search" @click="upSearch">查询</el-button>
|
||||||
|
<el-button :size="size" type="info" icon="el-icon-RefreshRight" @click="reset">重置</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<scTable ref="table" :apiObj="list.apiObj" :column="list.column" row-key="id" @selection-change="selectionChange" @columnBack="columnBack" border stripe :size="size">
|
||||||
|
<template #region_name="scope">
|
||||||
|
<span v-if="scope.row.region_info">{{scope.row.region_info.region_name}}</span>
|
||||||
|
</template>
|
||||||
|
</scTable>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {eventBus} from "@/utils/eventBus";
|
||||||
|
export default {
|
||||||
|
name: 'exclude',
|
||||||
|
components: {
|
||||||
|
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
fieldsShow:false,
|
||||||
|
size:'small',
|
||||||
|
httpDisabled:false,
|
||||||
|
dialog: {
|
||||||
|
save: false,
|
||||||
|
usageSave:false,
|
||||||
|
permission: false
|
||||||
|
},
|
||||||
|
exportShow:false,
|
||||||
|
list:{
|
||||||
|
apiObj: this.$API.early.exclude.list,
|
||||||
|
column:[],
|
||||||
|
fields:{}
|
||||||
|
},
|
||||||
|
searchShow:false,
|
||||||
|
searchHeaderShow:false,
|
||||||
|
filterMap:{
|
||||||
|
data:{}
|
||||||
|
},
|
||||||
|
selection: [],
|
||||||
|
params: {},
|
||||||
|
importParams:{
|
||||||
|
is_save_repeat:false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
provide(){
|
||||||
|
return{
|
||||||
|
filterUploadClick:this.filterClick,
|
||||||
|
filterUploadParams:this.filterParams,
|
||||||
|
filterTagClose:this.tagClose,
|
||||||
|
filterModelParams:this.filterModelParams,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch:{
|
||||||
|
'list.column':{
|
||||||
|
handler(val){
|
||||||
|
this.searchHeaderShow = val.length>0 && val.some(em=>em.is_search);
|
||||||
|
},
|
||||||
|
immediate:false,
|
||||||
|
deep:true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
filterModelParams(){
|
||||||
|
return this.filterMap
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* 表格检索开始
|
||||||
|
* */
|
||||||
|
searchClick(){
|
||||||
|
this.fieldsShow = true;
|
||||||
|
},
|
||||||
|
fieldsSwitch(val){
|
||||||
|
this.fieldsShow = val;
|
||||||
|
},
|
||||||
|
fieldsSearch(params){
|
||||||
|
this.params = params;
|
||||||
|
this.upSearch();
|
||||||
|
},
|
||||||
|
|
||||||
|
columnBack(val, fieldsData){
|
||||||
|
this.list.column = val;
|
||||||
|
this.list.fields = fieldsData;
|
||||||
|
},
|
||||||
|
async filterClick(item) {
|
||||||
|
let {data, params} = item;
|
||||||
|
let filterParams = Object.assign(this.params,params);
|
||||||
|
this.filterMap.data = filterParams;
|
||||||
|
let searchParams = this.$TOOL.objCopy(this.params);
|
||||||
|
searchParams.field = ""
|
||||||
|
if (typeof data.prop === 'string') {
|
||||||
|
searchParams.field = data.prop;
|
||||||
|
} else {
|
||||||
|
searchParams.field = data.prop[0];
|
||||||
|
}
|
||||||
|
if (data.search_type == 'select' || data.search_type == 'checkbox') {
|
||||||
|
await this.getField(data,searchParams);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filterParams(params){
|
||||||
|
let filterParams = Object.assign(this.params,params);
|
||||||
|
this.filterMap.data = filterParams;
|
||||||
|
this.upSearch();
|
||||||
|
},
|
||||||
|
tagClose(params){
|
||||||
|
let filterParams = Object.assign(this.params,params);
|
||||||
|
this.filterMap.data = filterParams;
|
||||||
|
},
|
||||||
|
searchShowClick(){
|
||||||
|
this.searchShow = !this.searchShow;
|
||||||
|
eventBus.$emit('close-all-popovers');
|
||||||
|
},
|
||||||
|
getHeaderData(params){
|
||||||
|
this.params = params;
|
||||||
|
this.filterMap.data = params;
|
||||||
|
},
|
||||||
|
async getSelectData(item) {
|
||||||
|
let {data, params} = item;
|
||||||
|
this.params = params; // 列表需要的参数
|
||||||
|
this.filterMap.data = params; // 表头组件需要转 才能传的参数
|
||||||
|
let searchParams = this.$TOOL.objCopy(params);
|
||||||
|
searchParams.field = ""
|
||||||
|
if (typeof data.prop === 'string') {
|
||||||
|
searchParams.field = data.prop;
|
||||||
|
} else {
|
||||||
|
searchParams.field = data.prop[0];
|
||||||
|
}
|
||||||
|
if (data.search_type == 'select' || data.search_type == 'checkbox') {
|
||||||
|
await this.getField(data,searchParams);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getField(data,searchParams) {
|
||||||
|
const res = await this.$API.early.exclude.field.post(searchParams);
|
||||||
|
if (res.code == 200) {
|
||||||
|
if (res.data && res.data.length > 0) {
|
||||||
|
res.data.forEach(item => {
|
||||||
|
item.label = item[data.prop];
|
||||||
|
item.value = item[data.prop];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.list.column.forEach(item => {
|
||||||
|
if (item.prop == data.prop) {
|
||||||
|
item.data = res.data;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 表格检索结束 */
|
||||||
|
//删除
|
||||||
|
async table_del(row){
|
||||||
|
const reqData = {ids: [row.id]};
|
||||||
|
const res = await this.$API.early.earlyWarn.delete.post(reqData);
|
||||||
|
if(res.code == 200){
|
||||||
|
this.$refs.table.refresh();
|
||||||
|
this.$message.success("删除成功");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//批量删除
|
||||||
|
async batch_del(){
|
||||||
|
this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?`, '提示', {
|
||||||
|
type: 'warning'
|
||||||
|
}).then(async () => {
|
||||||
|
const loading = this.$loading();
|
||||||
|
const params = {ids: this.selection.map(em => em.id)}
|
||||||
|
const res = await this.$API.early.earlyWarn.delete.post(params);
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.$refs.table.refresh()
|
||||||
|
loading.close();
|
||||||
|
this.$message.success("操作成功")
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 批量导入
|
||||||
|
importFile(){
|
||||||
|
this.$nextTick(()=>{
|
||||||
|
this.$refs.scImport.importFile();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async importTemplate() {
|
||||||
|
const res = await this.$API.early.exclude.template.post();
|
||||||
|
const blob = new Blob([res]);
|
||||||
|
const text = new Date().getTime();
|
||||||
|
const eLink = document.createElement('a');
|
||||||
|
eLink.download = "排除清单导入模版_"+text+'.xlsx';
|
||||||
|
eLink.style.display = 'none';
|
||||||
|
eLink.href = URL.createObjectURL(blob);
|
||||||
|
document.body.appendChild(eLink);
|
||||||
|
eLink.click();
|
||||||
|
URL.revokeObjectURL(eLink.href);
|
||||||
|
document.body.removeChild(eLink);
|
||||||
|
},
|
||||||
|
async importUpload(params) {
|
||||||
|
const updateOrAppend = (formData, key, value) => {
|
||||||
|
let found = false;
|
||||||
|
for (let [k] of formData.entries()) {
|
||||||
|
if (k === key) {
|
||||||
|
formData.set(k, value); // 替换已存在的值
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
formData.append(key, value); // 如果没有找到,则添加新项
|
||||||
|
}
|
||||||
|
};
|
||||||
|
updateOrAppend(params, 'is_save_repeat', this.importParams.is_save_repeat);
|
||||||
|
|
||||||
|
this.httpDisabled = true;
|
||||||
|
const res = await this.$API.early.exclude.import.post(params);
|
||||||
|
if(res.code == 200){
|
||||||
|
this.$message.success('上传成功,开始导入数据');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
importSuccess(refresh){
|
||||||
|
this.httpDisabled = false;
|
||||||
|
if(!refresh){
|
||||||
|
this.$refs.table.refresh()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//表格选择后回调事件
|
||||||
|
selectionChange(selection){
|
||||||
|
this.selection = selection;
|
||||||
|
},
|
||||||
|
//搜索
|
||||||
|
upSearch(){
|
||||||
|
this.$refs.table.upData(this.params);
|
||||||
|
},
|
||||||
|
reset(){
|
||||||
|
this.params = {};
|
||||||
|
this.filterMap.data = {};
|
||||||
|
this.$refs.scSearch.reload();
|
||||||
|
eventBus.$emit('reset-popovers');
|
||||||
|
this.$refs.table.reload();
|
||||||
|
},
|
||||||
|
//本地更新数据
|
||||||
|
handleSaveSuccess(){
|
||||||
|
this.$refs.table.refresh()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.mainBox{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.danger{
|
||||||
|
color: var(--el-color-danger);
|
||||||
|
}
|
||||||
|
.warning{
|
||||||
|
color: var(--el-color-warning);
|
||||||
|
}
|
||||||
|
.success{
|
||||||
|
color: var(--el-color-success);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
@ -1,397 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-container class="mainBox mainBoxHeaderNoBorder">
|
<el-main class="tabsMain">
|
||||||
<el-header class="header">
|
<el-tabs tab-position="top" class="tabsPadding" v-model="tabsTrue">
|
||||||
<div class="left-panel">
|
<el-tab-pane label="预警列表" name="list">
|
||||||
<el-button type="primary" v-auth="'sparePartsWaterLevelWarningEdit'" :size="size" icon="el-icon-plus" @click="add">新增预警</el-button>
|
<list v-if="tabsTrue == 'list'"></list>
|
||||||
<el-button type="primary" v-auth="'sparePartsWaterLevelWarningBatchEdit'" :size="size" plain :disabled="selection.length==0" @click="usage">批量修改预计用量</el-button>
|
</el-tab-pane>
|
||||||
<el-button type="danger" v-auth="'sparePartsWaterLevelWarningDelete'" plain :size="size" icon="el-icon-Delete" :disabled="selection.length==0" @click="batch_del"></el-button>
|
|
||||||
<scImport ref="scImport" :size="size" type="50" :httpDisabled="httpDisabled" title="批量导入预计六个月用量" @parentParams="importUpload" @importSuccess="importSuccess">
|
|
||||||
<template #header>
|
|
||||||
<el-button v-auth="'sparePartsWaterLevelWarningBatchImport'" type="primary" :size="size" plain @click="importFile" style="margin-right: 12px;">批量导入</el-button>
|
|
||||||
</template>
|
|
||||||
<template #download>
|
|
||||||
<div v-auth="'warningManagementImportTemplate'" @click="importTemplate">下载导入模版</div>
|
|
||||||
</template>
|
|
||||||
</scImport>
|
|
||||||
</div>
|
|
||||||
<div class="right-panel">
|
|
||||||
<scExport :size="size" @exportData="exportData" @updateShow="exportChangeShow" :show="exportShow" type="43">
|
|
||||||
<el-button :size="size" v-auth="'sparePartsWaterLevelWarningExport'" icon="sc-icon-Download" :disabled="exportShow" @click="exportData">导出</el-button>
|
|
||||||
</scExport>
|
|
||||||
</div>
|
|
||||||
</el-header>
|
|
||||||
<el-main class="nopadding">
|
|
||||||
<div class="fieldsSwitchBox searchConditionItem" style="margin-top: 10px;" v-if="!fieldsShow">
|
|
||||||
<div class="leftBox"></div>
|
|
||||||
<div class="rightBox" @click="searchClick">
|
|
||||||
<el-icon class="icon"><sc-icon-SwitchQuery /></el-icon>
|
|
||||||
<span class="name">切换查询方式</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="searchMain searchMainMarginNone" :class="!searchHeaderShow?'emptySearchMain':''" v-if="!fieldsShow">
|
|
||||||
<scTableSearch ref="scSearch" :searchList="list.column" :paramsData="params" :searchShow="searchShow" @fetchSelectData="getSelectData" @changeHeaderData="getHeaderData"></scTableSearch>
|
|
||||||
|
|
||||||
<div class="searchItem searchBtn" v-if="searchHeaderShow">
|
<el-tab-pane label="排除清单" name="exclude">
|
||||||
<el-button :size="size" :icon="searchShow?'el-icon-ArrowUpBold':'el-icon-ArrowDownBold'" @click="searchShowClick">{{searchShow?'收起':'更多'}}</el-button>
|
<exclude v-if="tabsTrue == 'exclude'"></exclude>
|
||||||
<el-button :size="size" type="primary" icon="el-icon-search" @click="upSearch">查询</el-button>
|
</el-tab-pane>
|
||||||
<el-button :size="size" type="info" icon="el-icon-RefreshRight" @click="reset">重置</el-button>
|
</el-tabs>
|
||||||
</div>
|
</el-main>
|
||||||
</div>
|
|
||||||
<div class="searchMain searchMainMarginNone searchMainBodyMarginNone searchMainNoTop" v-if="fieldsShow">
|
|
||||||
<herderMultipleSearch @fieldsSwitch="fieldsSwitch" @fieldsSearch="fieldsSearch" :fieldsShow="fieldsShow" :searchList="list.fields"></herderMultipleSearch>
|
|
||||||
</div>
|
|
||||||
<scTable ref="table" :apiObj="list.apiObj" :column="list.column" row-key="id" @selection-change="selectionChange" @columnBack="columnBack" border stripe :size="size">
|
|
||||||
<el-table-column type="selection" align="center" width="40"></el-table-column>
|
|
||||||
<template #region_name="scope">
|
|
||||||
<span v-if="scope.row.region_info">{{scope.row.region_info.region_name}}</span>
|
|
||||||
</template>
|
|
||||||
<template #risk_level="scope">
|
|
||||||
<span :class="{'success':scope.row.risk_level==1,'warning':scope.row.risk_level==2,'danger':scope.row.risk_level==3}">{{scope.row['risk_level']}}</span>
|
|
||||||
</template>
|
|
||||||
<template #risk_description="scope">
|
|
||||||
<span :class="{'success':scope.row.risk_level==1,'warning':scope.row.risk_level==2,'danger':scope.row.risk_level==3}">{{scope.row['risk_description']}}</span>
|
|
||||||
</template>
|
|
||||||
<el-table-column label="操作" fixed="right" align="center" width="150">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-dropdown>
|
|
||||||
<el-button class="noBorderBtn" icon="el-icon-more" :size="size"></el-button>
|
|
||||||
<template #dropdown>
|
|
||||||
<el-dropdown-menu>
|
|
||||||
<el-dropdown-item @click="table_show(scope.row, 'see')" icon="sc-icon-See">查看</el-dropdown-item>
|
|
||||||
<span v-auth="'sparePartsWaterLevelWarningEdit'">
|
|
||||||
<el-dropdown-item @click="table_edit(scope.row, 'edit')" icon="sc-icon-Edit">编辑</el-dropdown-item>
|
|
||||||
</span>
|
|
||||||
<span v-auth="'sparePartsWaterLevelWarningDelete'">
|
|
||||||
<el-dropdown-item @click="table_del(scope.row, 'delete')" divided icon="sc-icon-Delete">删除</el-dropdown-item>
|
|
||||||
</span>
|
|
||||||
</el-dropdown-menu>
|
|
||||||
</template>
|
|
||||||
</el-dropdown>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</scTable>
|
|
||||||
</el-main>
|
|
||||||
</el-container>
|
|
||||||
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" @closed="dialog.save=false"></save-dialog>
|
|
||||||
<usageDialog v-if="dialog.usageSave" ref="usageDialog" @success="handleSaveSuccess" @closed="dialog.usageSave=false"></usageDialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import saveDialog from "./save"
|
import list from './list'
|
||||||
import usageDialog from "./usage"
|
import exclude from './exclude'
|
||||||
import {eventBus} from "@/utils/eventBus";
|
|
||||||
export default {
|
export default {
|
||||||
name: 'earlyManager',
|
name: 'earlyManager',
|
||||||
components: {
|
components: {
|
||||||
saveDialog,
|
list,
|
||||||
usageDialog
|
exclude
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
fieldsShow:false,
|
|
||||||
size:'small',
|
size:'small',
|
||||||
httpDisabled:false,
|
tabsTrue:'list',
|
||||||
dialog: {
|
|
||||||
save: false,
|
|
||||||
usageSave:false,
|
|
||||||
permission: false
|
|
||||||
},
|
|
||||||
exportShow:false,
|
|
||||||
list:{
|
|
||||||
apiObj: this.$API.early.earlyWarn.list,
|
|
||||||
column:[],
|
|
||||||
fields:{}
|
|
||||||
},
|
|
||||||
searchShow:false,
|
|
||||||
searchHeaderShow:false,
|
|
||||||
filterMap:{
|
|
||||||
data:{}
|
|
||||||
},
|
|
||||||
selection: [],
|
|
||||||
params: {},
|
|
||||||
importParams:{
|
|
||||||
is_save_repeat:false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
provide(){
|
|
||||||
return{
|
|
||||||
filterUploadClick:this.filterClick,
|
|
||||||
filterUploadParams:this.filterParams,
|
|
||||||
filterTagClose:this.tagClose,
|
|
||||||
filterModelParams:this.filterModelParams,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch:{
|
|
||||||
'list.column':{
|
|
||||||
handler(val){
|
|
||||||
this.searchHeaderShow = val.length>0 && val.some(em=>em.is_search);
|
|
||||||
},
|
|
||||||
immediate:false,
|
|
||||||
deep:true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed:{
|
|
||||||
filterModelParams(){
|
|
||||||
return this.filterMap
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
|
||||||
* 表格检索开始
|
|
||||||
* */
|
|
||||||
searchClick(){
|
|
||||||
this.fieldsShow = true;
|
|
||||||
},
|
|
||||||
fieldsSwitch(val){
|
|
||||||
this.fieldsShow = val;
|
|
||||||
},
|
|
||||||
fieldsSearch(params){
|
|
||||||
this.params = params;
|
|
||||||
this.upSearch();
|
|
||||||
},
|
|
||||||
|
|
||||||
columnBack(val, fieldsData){
|
|
||||||
this.list.column = val;
|
|
||||||
this.list.fields = fieldsData;
|
|
||||||
},
|
|
||||||
async filterClick(item) {
|
|
||||||
let {data, params} = item;
|
|
||||||
let filterParams = Object.assign(this.params,params);
|
|
||||||
this.filterMap.data = filterParams;
|
|
||||||
let searchParams = this.$TOOL.objCopy(this.params);
|
|
||||||
searchParams.field = ""
|
|
||||||
if (typeof data.prop === 'string') {
|
|
||||||
searchParams.field = data.prop;
|
|
||||||
} else {
|
|
||||||
searchParams.field = data.prop[0];
|
|
||||||
}
|
|
||||||
if (data.search_type == 'select' || data.search_type == 'checkbox') {
|
|
||||||
if(data.prop === "region_name"){
|
|
||||||
await this.getRegionName(data, searchParams);
|
|
||||||
}else{
|
|
||||||
await this.getField(data,searchParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
filterParams(params){
|
|
||||||
let filterParams = Object.assign(this.params,params);
|
|
||||||
this.filterMap.data = filterParams;
|
|
||||||
this.upSearch();
|
|
||||||
},
|
|
||||||
tagClose(params){
|
|
||||||
let filterParams = Object.assign(this.params,params);
|
|
||||||
this.filterMap.data = filterParams;
|
|
||||||
},
|
|
||||||
searchShowClick(){
|
|
||||||
this.searchShow = !this.searchShow;
|
|
||||||
eventBus.$emit('close-all-popovers');
|
|
||||||
},
|
|
||||||
getHeaderData(params){
|
|
||||||
this.params = params;
|
|
||||||
this.filterMap.data = params;
|
|
||||||
},
|
|
||||||
async getSelectData(item) {
|
|
||||||
let {data, params} = item;
|
|
||||||
this.params = params; // 列表需要的参数
|
|
||||||
this.filterMap.data = params; // 表头组件需要转 才能传的参数
|
|
||||||
let searchParams = this.$TOOL.objCopy(params);
|
|
||||||
searchParams.field = ""
|
|
||||||
if (typeof data.prop === 'string') {
|
|
||||||
searchParams.field = data.prop;
|
|
||||||
} else {
|
|
||||||
searchParams.field = data.prop[0];
|
|
||||||
}
|
|
||||||
if (data.search_type == 'select' || data.search_type == 'checkbox') {
|
|
||||||
if(data.prop === "region_name"){
|
|
||||||
await this.getRegionName(data, searchParams);
|
|
||||||
}else{
|
|
||||||
await this.getField(data,searchParams)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async getField(data,searchParams) {
|
|
||||||
const res = await this.$API.early.earlyWarn.field.post(searchParams);
|
|
||||||
if (res.code == 200) {
|
|
||||||
if (res.data && res.data.length > 0) {
|
|
||||||
res.data.forEach(item => {
|
|
||||||
item.label = item[data.prop];
|
|
||||||
item.value = item[data.prop];
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.list.column.forEach(item => {
|
|
||||||
if (item.prop == data.prop) {
|
|
||||||
item.data = res.data;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async getRegionName(data,searchParams) {
|
|
||||||
const res = await this.$API.setup.regional.regionalConstList.post(searchParams);
|
|
||||||
if(res.code == 200){
|
|
||||||
if (res.data && res.data.length > 0) {
|
|
||||||
res.data.forEach(item => {
|
|
||||||
item.label = item[data.prop];
|
|
||||||
item.value = item[data.prop];
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.list.column.forEach(item => {
|
|
||||||
if (item.prop == data.prop) {
|
|
||||||
item.data = res.data;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/** 表格检索结束 */
|
|
||||||
// 批量修改
|
|
||||||
usage(){
|
|
||||||
this.dialog.usageSave = true
|
|
||||||
const reqData = {ids: this.selection.map(em=>em.id)};
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.usageDialog.open('edit').setData(reqData)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
//添加
|
|
||||||
add(){
|
|
||||||
this.dialog.save = true
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.saveDialog.open()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
//编辑
|
|
||||||
table_edit(row){
|
|
||||||
this.dialog.save = true
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.saveDialog.open('edit').setData(row)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
//查看
|
|
||||||
table_show(row){
|
|
||||||
this.dialog.save = true
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.saveDialog.open('show').setData(row)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
//删除
|
|
||||||
async table_del(row){
|
|
||||||
const reqData = {ids: [row.id]};
|
|
||||||
const res = await this.$API.early.earlyWarn.delete.post(reqData);
|
|
||||||
if(res.code == 200){
|
|
||||||
this.$refs.table.refresh();
|
|
||||||
this.$message.success("删除成功");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//批量删除
|
|
||||||
async batch_del(){
|
|
||||||
this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?`, '提示', {
|
|
||||||
type: 'warning'
|
|
||||||
}).then(async () => {
|
|
||||||
const loading = this.$loading();
|
|
||||||
const params = {ids: this.selection.map(em => em.id)}
|
|
||||||
const res = await this.$API.early.earlyWarn.delete.post(params);
|
|
||||||
if (res.code == 200) {
|
|
||||||
this.$refs.table.refresh()
|
|
||||||
loading.close();
|
|
||||||
this.$message.success("操作成功")
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
|
||||||
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
// 批量导入
|
|
||||||
importFile(){
|
|
||||||
this.$nextTick(()=>{
|
|
||||||
this.$refs.scImport.importFile();
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async importTemplate() {
|
|
||||||
const res = await this.$API.early.earlyWarn.template.post();
|
|
||||||
const blob = new Blob([res]);
|
|
||||||
const text = new Date().getTime();
|
|
||||||
const eLink = document.createElement('a');
|
|
||||||
eLink.download = "预计六个月用量导入模版_"+text+'.xlsx';
|
|
||||||
eLink.style.display = 'none';
|
|
||||||
eLink.href = URL.createObjectURL(blob);
|
|
||||||
document.body.appendChild(eLink);
|
|
||||||
eLink.click();
|
|
||||||
URL.revokeObjectURL(eLink.href);
|
|
||||||
document.body.removeChild(eLink);
|
|
||||||
},
|
|
||||||
async importUpload(params) {
|
|
||||||
const updateOrAppend = (formData, key, value) => {
|
|
||||||
let found = false;
|
|
||||||
for (let [k] of formData.entries()) {
|
|
||||||
if (k === key) {
|
|
||||||
formData.set(k, value); // 替换已存在的值
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
formData.append(key, value); // 如果没有找到,则添加新项
|
|
||||||
}
|
|
||||||
};
|
|
||||||
updateOrAppend(params, 'is_save_repeat', this.importParams.is_save_repeat);
|
|
||||||
|
|
||||||
this.httpDisabled = true;
|
|
||||||
const res = await this.$API.early.earlyWarn.import.post(params);
|
|
||||||
if(res.code == 200){
|
|
||||||
this.$message.success('上传成功,开始导入数据');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
importSuccess(refresh){
|
|
||||||
this.httpDisabled = false;
|
|
||||||
if(!refresh){
|
|
||||||
this.$refs.table.refresh()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//表格选择后回调事件
|
|
||||||
selectionChange(selection){
|
|
||||||
this.selection = selection;
|
|
||||||
},
|
|
||||||
//搜索
|
|
||||||
upSearch(){
|
|
||||||
this.$refs.table.upData(this.params);
|
|
||||||
},
|
|
||||||
reset(){
|
|
||||||
this.params = {};
|
|
||||||
this.filterMap.data = {};
|
|
||||||
this.$refs.scSearch.reload();
|
|
||||||
eventBus.$emit('reset-popovers');
|
|
||||||
this.$refs.table.reload();
|
|
||||||
},
|
|
||||||
//本地更新数据
|
|
||||||
handleSaveSuccess(){
|
|
||||||
this.$refs.table.refresh()
|
|
||||||
},
|
|
||||||
|
|
||||||
// 下载导出
|
|
||||||
exportChangeShow(params){
|
|
||||||
if(params.type == 43){
|
|
||||||
this.exportShow = params.status==0?true:false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async exportData() {
|
|
||||||
if(this.exportShow) return
|
|
||||||
const res = await this.$API.early.earlyWarn.export.post(this.params);
|
|
||||||
if(res.code == 200){
|
|
||||||
this.$message.success('开始导出');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.danger{
|
|
||||||
color: var(--el-color-danger);
|
|
||||||
}
|
|
||||||
.warning{
|
|
||||||
color: var(--el-color-warning);
|
|
||||||
}
|
|
||||||
.success{
|
|
||||||
color: var(--el-color-success);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
400
src/views/earlyManager/list.vue
Normal file
400
src/views/earlyManager/list.vue
Normal file
@ -0,0 +1,400 @@
|
|||||||
|
<template>
|
||||||
|
<el-container class="mainBox mainBoxHeaderNoBorder">
|
||||||
|
<el-header class="header">
|
||||||
|
<div class="left-panel">
|
||||||
|
<el-button type="primary" v-auth="'sparePartsWaterLevelWarningEdit'" :size="size" icon="el-icon-plus" @click="add">新增预警</el-button>
|
||||||
|
<el-button type="primary" v-auth="'sparePartsWaterLevelWarningBatchEdit'" :size="size" plain :disabled="selection.length==0" @click="usage">批量修改预计用量</el-button>
|
||||||
|
<el-button type="danger" v-auth="'sparePartsWaterLevelWarningDelete'" plain :size="size" icon="el-icon-Delete" :disabled="selection.length==0" @click="batch_del"></el-button>
|
||||||
|
<scImport ref="scImport" :size="size" type="50" :httpDisabled="httpDisabled" title="批量导入预计六个月用量" @parentParams="importUpload" @importSuccess="importSuccess">
|
||||||
|
<template #header>
|
||||||
|
<el-button v-auth="'sparePartsWaterLevelWarningBatchImport'" type="primary" :size="size" plain @click="importFile" style="margin-right: 12px;">批量导入</el-button>
|
||||||
|
</template>
|
||||||
|
<template #download>
|
||||||
|
<div v-auth="'warningManagementImportTemplate'" @click="importTemplate">下载导入模版</div>
|
||||||
|
</template>
|
||||||
|
</scImport>
|
||||||
|
</div>
|
||||||
|
<div class="right-panel">
|
||||||
|
<scExport :size="size" @exportData="exportData" @updateShow="exportChangeShow" :show="exportShow" type="43">
|
||||||
|
<el-button :size="size" v-auth="'sparePartsWaterLevelWarningExport'" icon="sc-icon-Download" :disabled="exportShow" @click="exportData">导出</el-button>
|
||||||
|
</scExport>
|
||||||
|
</div>
|
||||||
|
</el-header>
|
||||||
|
<el-main class="nopadding">
|
||||||
|
<div class="fieldsSwitchBox searchConditionItem" style="margin-top: 10px;" v-if="!fieldsShow">
|
||||||
|
<div class="leftBox"></div>
|
||||||
|
<div class="rightBox" @click="searchClick">
|
||||||
|
<el-icon class="icon"><sc-icon-SwitchQuery /></el-icon>
|
||||||
|
<span class="name">切换查询方式</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="searchMain searchMainMarginNone" :class="!searchHeaderShow?'emptySearchMain':''" v-if="!fieldsShow">
|
||||||
|
<scTableSearch ref="scSearch" :searchList="list.column" :paramsData="params" :searchShow="searchShow" @fetchSelectData="getSelectData" @changeHeaderData="getHeaderData"></scTableSearch>
|
||||||
|
|
||||||
|
<div class="searchItem searchBtn" v-if="searchHeaderShow">
|
||||||
|
<el-button :size="size" :icon="searchShow?'el-icon-ArrowUpBold':'el-icon-ArrowDownBold'" @click="searchShowClick">{{searchShow?'收起':'更多'}}</el-button>
|
||||||
|
<el-button :size="size" type="primary" icon="el-icon-search" @click="upSearch">查询</el-button>
|
||||||
|
<el-button :size="size" type="info" icon="el-icon-RefreshRight" @click="reset">重置</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="searchMain searchMainMarginNone searchMainBodyMarginNone searchMainNoTop" v-if="fieldsShow">
|
||||||
|
<herderMultipleSearch @fieldsSwitch="fieldsSwitch" @fieldsSearch="fieldsSearch" :fieldsShow="fieldsShow" :searchList="list.fields"></herderMultipleSearch>
|
||||||
|
</div>
|
||||||
|
<scTable ref="table" :apiObj="list.apiObj" :column="list.column" row-key="id" @selection-change="selectionChange" @columnBack="columnBack" border stripe :size="size">
|
||||||
|
<el-table-column type="selection" align="center" width="40"></el-table-column>
|
||||||
|
<template #region_name="scope">
|
||||||
|
<span v-if="scope.row.region_info">{{scope.row.region_info.region_name}}</span>
|
||||||
|
</template>
|
||||||
|
<template #risk_level="scope">
|
||||||
|
<span :class="{'success':scope.row.risk_level==1,'warning':scope.row.risk_level==2,'danger':scope.row.risk_level==3}">{{scope.row['risk_level']}}</span>
|
||||||
|
</template>
|
||||||
|
<template #risk_description="scope">
|
||||||
|
<span :class="{'success':scope.row.risk_level==1,'warning':scope.row.risk_level==2,'danger':scope.row.risk_level==3}">{{scope.row['risk_description']}}</span>
|
||||||
|
</template>
|
||||||
|
<el-table-column label="操作" fixed="right" align="center" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-dropdown>
|
||||||
|
<el-button class="noBorderBtn" icon="el-icon-more" :size="size"></el-button>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item @click="table_show(scope.row, 'see')" icon="sc-icon-See">查看</el-dropdown-item>
|
||||||
|
<span v-auth="'sparePartsWaterLevelWarningEdit'">
|
||||||
|
<el-dropdown-item @click="table_edit(scope.row, 'edit')" icon="sc-icon-Edit">编辑</el-dropdown-item>
|
||||||
|
</span>
|
||||||
|
<span v-auth="'sparePartsWaterLevelWarningDelete'">
|
||||||
|
<el-dropdown-item @click="table_del(scope.row, 'delete')" divided icon="sc-icon-Delete">删除</el-dropdown-item>
|
||||||
|
</span>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</scTable>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" @closed="dialog.save=false"></save-dialog>
|
||||||
|
<usageDialog v-if="dialog.usageSave" ref="usageDialog" @success="handleSaveSuccess" @closed="dialog.usageSave=false"></usageDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import saveDialog from "./save"
|
||||||
|
import usageDialog from "./usage"
|
||||||
|
import {eventBus} from "@/utils/eventBus";
|
||||||
|
export default {
|
||||||
|
name: 'list',
|
||||||
|
components: {
|
||||||
|
saveDialog,
|
||||||
|
usageDialog
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
fieldsShow:false,
|
||||||
|
size:'small',
|
||||||
|
httpDisabled:false,
|
||||||
|
dialog: {
|
||||||
|
save: false,
|
||||||
|
usageSave:false,
|
||||||
|
permission: false
|
||||||
|
},
|
||||||
|
exportShow:false,
|
||||||
|
list:{
|
||||||
|
apiObj: this.$API.early.earlyWarn.list,
|
||||||
|
column:[],
|
||||||
|
fields:{}
|
||||||
|
},
|
||||||
|
searchShow:false,
|
||||||
|
searchHeaderShow:false,
|
||||||
|
filterMap:{
|
||||||
|
data:{}
|
||||||
|
},
|
||||||
|
selection: [],
|
||||||
|
params: {},
|
||||||
|
importParams:{
|
||||||
|
is_save_repeat:false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
provide(){
|
||||||
|
return{
|
||||||
|
filterUploadClick:this.filterClick,
|
||||||
|
filterUploadParams:this.filterParams,
|
||||||
|
filterTagClose:this.tagClose,
|
||||||
|
filterModelParams:this.filterModelParams,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch:{
|
||||||
|
'list.column':{
|
||||||
|
handler(val){
|
||||||
|
this.searchHeaderShow = val.length>0 && val.some(em=>em.is_search);
|
||||||
|
},
|
||||||
|
immediate:false,
|
||||||
|
deep:true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
filterModelParams(){
|
||||||
|
return this.filterMap
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* 表格检索开始
|
||||||
|
* */
|
||||||
|
searchClick(){
|
||||||
|
this.fieldsShow = true;
|
||||||
|
},
|
||||||
|
fieldsSwitch(val){
|
||||||
|
this.fieldsShow = val;
|
||||||
|
},
|
||||||
|
fieldsSearch(params){
|
||||||
|
this.params = params;
|
||||||
|
this.upSearch();
|
||||||
|
},
|
||||||
|
|
||||||
|
columnBack(val, fieldsData){
|
||||||
|
this.list.column = val;
|
||||||
|
this.list.fields = fieldsData;
|
||||||
|
},
|
||||||
|
async filterClick(item) {
|
||||||
|
let {data, params} = item;
|
||||||
|
let filterParams = Object.assign(this.params,params);
|
||||||
|
this.filterMap.data = filterParams;
|
||||||
|
let searchParams = this.$TOOL.objCopy(this.params);
|
||||||
|
searchParams.field = ""
|
||||||
|
if (typeof data.prop === 'string') {
|
||||||
|
searchParams.field = data.prop;
|
||||||
|
} else {
|
||||||
|
searchParams.field = data.prop[0];
|
||||||
|
}
|
||||||
|
if (data.search_type == 'select' || data.search_type == 'checkbox') {
|
||||||
|
if(data.prop === "region_name"){
|
||||||
|
await this.getRegionName(data, searchParams);
|
||||||
|
}else{
|
||||||
|
await this.getField(data,searchParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filterParams(params){
|
||||||
|
let filterParams = Object.assign(this.params,params);
|
||||||
|
this.filterMap.data = filterParams;
|
||||||
|
this.upSearch();
|
||||||
|
},
|
||||||
|
tagClose(params){
|
||||||
|
let filterParams = Object.assign(this.params,params);
|
||||||
|
this.filterMap.data = filterParams;
|
||||||
|
},
|
||||||
|
searchShowClick(){
|
||||||
|
this.searchShow = !this.searchShow;
|
||||||
|
eventBus.$emit('close-all-popovers');
|
||||||
|
},
|
||||||
|
getHeaderData(params){
|
||||||
|
this.params = params;
|
||||||
|
this.filterMap.data = params;
|
||||||
|
},
|
||||||
|
async getSelectData(item) {
|
||||||
|
let {data, params} = item;
|
||||||
|
this.params = params; // 列表需要的参数
|
||||||
|
this.filterMap.data = params; // 表头组件需要转 才能传的参数
|
||||||
|
let searchParams = this.$TOOL.objCopy(params);
|
||||||
|
searchParams.field = ""
|
||||||
|
if (typeof data.prop === 'string') {
|
||||||
|
searchParams.field = data.prop;
|
||||||
|
} else {
|
||||||
|
searchParams.field = data.prop[0];
|
||||||
|
}
|
||||||
|
if (data.search_type == 'select' || data.search_type == 'checkbox') {
|
||||||
|
if(data.prop === "region_name"){
|
||||||
|
await this.getRegionName(data, searchParams);
|
||||||
|
}else{
|
||||||
|
await this.getField(data,searchParams)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getField(data,searchParams) {
|
||||||
|
const res = await this.$API.early.earlyWarn.field.post(searchParams);
|
||||||
|
if (res.code == 200) {
|
||||||
|
if (res.data && res.data.length > 0) {
|
||||||
|
res.data.forEach(item => {
|
||||||
|
item.label = item[data.prop];
|
||||||
|
item.value = item[data.prop];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.list.column.forEach(item => {
|
||||||
|
if (item.prop == data.prop) {
|
||||||
|
item.data = res.data;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getRegionName(data,searchParams) {
|
||||||
|
const res = await this.$API.setup.regional.regionalConstList.post(searchParams);
|
||||||
|
if(res.code == 200){
|
||||||
|
if (res.data && res.data.length > 0) {
|
||||||
|
res.data.forEach(item => {
|
||||||
|
item.label = item[data.prop];
|
||||||
|
item.value = item[data.prop];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.list.column.forEach(item => {
|
||||||
|
if (item.prop == data.prop) {
|
||||||
|
item.data = res.data;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 表格检索结束 */
|
||||||
|
// 批量修改
|
||||||
|
usage(){
|
||||||
|
this.dialog.usageSave = true
|
||||||
|
const reqData = {ids: this.selection.map(em=>em.id)};
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.usageDialog.open('edit').setData(reqData)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//添加
|
||||||
|
add(){
|
||||||
|
this.dialog.save = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.saveDialog.open()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//编辑
|
||||||
|
table_edit(row){
|
||||||
|
this.dialog.save = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.saveDialog.open('edit').setData(row)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//查看
|
||||||
|
table_show(row){
|
||||||
|
this.dialog.save = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.saveDialog.open('show').setData(row)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//删除
|
||||||
|
async table_del(row){
|
||||||
|
const reqData = {ids: [row.id]};
|
||||||
|
const res = await this.$API.early.earlyWarn.delete.post(reqData);
|
||||||
|
if(res.code == 200){
|
||||||
|
this.$refs.table.refresh();
|
||||||
|
this.$message.success("删除成功");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//批量删除
|
||||||
|
async batch_del(){
|
||||||
|
this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?`, '提示', {
|
||||||
|
type: 'warning'
|
||||||
|
}).then(async () => {
|
||||||
|
const loading = this.$loading();
|
||||||
|
const params = {ids: this.selection.map(em => em.id)}
|
||||||
|
const res = await this.$API.early.earlyWarn.delete.post(params);
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.$refs.table.refresh()
|
||||||
|
loading.close();
|
||||||
|
this.$message.success("操作成功")
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 批量导入
|
||||||
|
importFile(){
|
||||||
|
this.$nextTick(()=>{
|
||||||
|
this.$refs.scImport.importFile();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async importTemplate() {
|
||||||
|
const res = await this.$API.early.earlyWarn.template.post();
|
||||||
|
const blob = new Blob([res]);
|
||||||
|
const text = new Date().getTime();
|
||||||
|
const eLink = document.createElement('a');
|
||||||
|
eLink.download = "预计六个月用量导入模版_"+text+'.xlsx';
|
||||||
|
eLink.style.display = 'none';
|
||||||
|
eLink.href = URL.createObjectURL(blob);
|
||||||
|
document.body.appendChild(eLink);
|
||||||
|
eLink.click();
|
||||||
|
URL.revokeObjectURL(eLink.href);
|
||||||
|
document.body.removeChild(eLink);
|
||||||
|
},
|
||||||
|
async importUpload(params) {
|
||||||
|
const updateOrAppend = (formData, key, value) => {
|
||||||
|
let found = false;
|
||||||
|
for (let [k] of formData.entries()) {
|
||||||
|
if (k === key) {
|
||||||
|
formData.set(k, value); // 替换已存在的值
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
formData.append(key, value); // 如果没有找到,则添加新项
|
||||||
|
}
|
||||||
|
};
|
||||||
|
updateOrAppend(params, 'is_save_repeat', this.importParams.is_save_repeat);
|
||||||
|
|
||||||
|
this.httpDisabled = true;
|
||||||
|
const res = await this.$API.early.earlyWarn.import.post(params);
|
||||||
|
if(res.code == 200){
|
||||||
|
this.$message.success('上传成功,开始导入数据');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
importSuccess(refresh){
|
||||||
|
this.httpDisabled = false;
|
||||||
|
if(!refresh){
|
||||||
|
this.$refs.table.refresh()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//表格选择后回调事件
|
||||||
|
selectionChange(selection){
|
||||||
|
this.selection = selection;
|
||||||
|
},
|
||||||
|
//搜索
|
||||||
|
upSearch(){
|
||||||
|
this.$refs.table.upData(this.params);
|
||||||
|
},
|
||||||
|
reset(){
|
||||||
|
this.params = {};
|
||||||
|
this.filterMap.data = {};
|
||||||
|
this.$refs.scSearch.reload();
|
||||||
|
eventBus.$emit('reset-popovers');
|
||||||
|
this.$refs.table.reload();
|
||||||
|
},
|
||||||
|
//本地更新数据
|
||||||
|
handleSaveSuccess(){
|
||||||
|
this.$refs.table.refresh()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导出
|
||||||
|
exportChangeShow(params){
|
||||||
|
if(params.type == 43){
|
||||||
|
this.exportShow = params.status==0?true:false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async exportData() {
|
||||||
|
if(this.exportShow) return
|
||||||
|
const res = await this.$API.early.earlyWarn.export.post(this.params);
|
||||||
|
if(res.code == 200){
|
||||||
|
this.$message.success('开始导出');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.mainBox{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.danger{
|
||||||
|
color: var(--el-color-danger);
|
||||||
|
}
|
||||||
|
.warning{
|
||||||
|
color: var(--el-color-warning);
|
||||||
|
}
|
||||||
|
.success{
|
||||||
|
color: var(--el-color-success);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user