目录管理的bug修改

xuhongjie
项洋 3 months ago
parent 8c160c3816
commit 0e6bd72e0d

@ -2,40 +2,74 @@
<div>
<!-- 表单查询项 -->
<div class="headerbox">
<el-form ref="queryForm" :model="queryParams" size="small" label-width="100px">
<el-form
ref="queryForm"
:model="queryParams"
size="small"
label-width="100px"
>
<el-row>
<el-col :span="5">
<el-form-item label="上楼目录类别" prop="slmllb">
<el-select v-model="queryParams.slmllb" placeholder="请选择上楼目录类别">
<el-option v-for="dict in dict.type.shangloumulu" :key="dict.value" :label="dict.label"
:value="dict.value"></el-option>
<el-select
v-model="queryParams.slmllb"
placeholder="请选择上楼目录类别"
>
<el-option
v-for="dict in dict.type.shangloumulu"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="工业大类" prop="gydl" style="width: 100%;">
<el-input v-model="queryParams.gydl" placeholder="请输入工业大类" :fetch-suggestions="querySearchAsync"
@keyup.enter.native="handleQuery" />
<el-form-item label="工业大类" prop="gydl" style="width: 100%">
<el-input
v-model="queryParams.gydl"
placeholder="请输入工业大类"
:fetch-suggestions="querySearchAsync"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item label="产业" prop="cy" style="width: 100%;">
<el-input v-model="queryParams.cy" placeholder="请输入产业" style="width: 20.5rem;"
@keyup.enter.native="handleQuery" />
<el-form-item label="产业" prop="cy" style="width: 100%">
<el-input
v-model="queryParams.cy"
placeholder="请输入产业"
style="width: 20.5rem"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="更新时间" prop="updateTime">
<el-date-picker v-model="queryParams.startTime" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
:style="{ width: '13.5rem' }" placeholder="选择日期" clearable />
<el-date-picker
v-model="queryParams.startTime"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
:style="{ width: '13.5rem' }"
placeholder="选择日期"
clearable
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item style="margin-left: -100px;">
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" @click="resetQuery"></el-button>
<el-form-item style="margin-left: -100px">
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
>查询</el-button
>
<el-button icon="el-icon-refresh" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-col>
</el-row>
@ -48,55 +82,109 @@
<div class="tablebtntwo">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd"></el-button>
<el-button type="primary" icon="el-icon-plus" @click="handleAdd"
>新增</el-button
>
</el-col>
</el-row>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-download" @click="handleImport"></el-button>
<el-button
type="primary"
icon="el-icon-download"
@click="handleImport"
>导入</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-upload2" @click="handleExport"></el-button>
<el-button
type="primary"
icon="el-icon-upload2"
@click="handleExport"
>全量导出</el-button
>
</el-col>
</el-row>
</div>
<el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="postList"
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column label="序号" width="60" align="center">
<template slot-scope="scope">
{{ (queryParams.current - 1) * queryParams.size + scope.$index + 1 }}
{{
(queryParams.current - 1) * queryParams.size + scope.$index + 1
}}
</template>
</el-table-column>
<el-table-column label="上楼目录类别" align="center">
<template slot-scope="scope">
<dict-tag :options="dict.type.shangloumulu" :value="scope.row.slmllb" />
<dict-tag
:options="dict.type.shangloumulu"
:value="scope.row.slmllb"
/>
</template>
</el-table-column>
<el-table-column label="工业大类" align="center" prop="gydl" />
<el-table-column label="产业" align="center" prop="cy" />
<el-table-column label="更新时间" align="center" prop="updateTime" width="180" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column
label="更新时间"
align="center"
prop="updateTime"
width="180"
/>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button type="text" @click="handleUpdate(scope.row)"></el-button>
<el-button type="text" @click="handleDelete(scope.row)" style="color: red;">删除</el-button>
<el-button type="text" @click="handleUpdate(scope.row)"
>编辑</el-button
>
<el-button
type="text"
@click="handleDelete(scope.row)"
style="color: red"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.current" :limit.sync="queryParams.size"
@pagination="getList" />
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.current"
:limit.sync="queryParams.size"
@pagination="getList"
/>
</div>
<!-- 添加或修改项目对话框 -->
<el-dialog :title="title" :visible.sync="open" width="40rem" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="7rem">
<el-form-item label="上楼目录类别" prop="slmllb">
<el-select v-model="form.slmllb" placeholder="请选择上楼目录类别" style="width: 100%;">
<el-option v-for="dict in dict.type.shangloumulu" :key="dict.value" :label="dict.label"
:value="parseInt(dict.value)" />
<el-select
v-model="form.slmllb"
placeholder="请选择上楼目录类别"
style="width: 100%"
>
<el-option
v-for="dict in dict.type.shangloumulu"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="工业大类" prop="gydl">
<el-input v-model="form.gydl" placeholder="请输入工业大类" maxlength="50" />
<el-input
v-model="form.gydl"
placeholder="请输入工业大类"
maxlength="50"
/>
</el-form-item>
<el-form-item label="产业" prop="cy">
<el-input v-model="form.cy" placeholder="请输入产业" maxlength="50" />
@ -109,16 +197,35 @@
</el-dialog>
<!-- 导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
:on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
@click="importTemplate">下载模板</el-link>
<el-link
type="primary"
:underline="false"
style="font-size: 12px; vertical-align: baseline"
@click="importTemplate"
>下载模板</el-link
>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
@ -126,19 +233,23 @@
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getToken } from "@/utils/auth";
import { getAllCatalogs, addCatalog, editCatalog, deleteCatalog } from "@/api/ManageApi/index";
import fileload from "@/components/FileUpload/index.vue"
import {
getAllCatalogs,
addCatalog,
editCatalog,
deleteCatalog,
} from "@/api/ManageApi/index";
import fileload from "@/components/FileUpload/index.vue";
export default {
dicts: ['shangloumulu'],
dicts: ["shangloumulu"],
components: {
fileload
fileload,
},
data() {
return {
@ -168,7 +279,7 @@ export default {
size: 10,
gydl: undefined,
slmllb: undefined,
startTime: undefined
startTime: undefined,
},
//
form: {
@ -181,15 +292,19 @@ export default {
createTime: undefined,
updateBy: undefined,
updateId: undefined,
updateTime: undefined
updateTime: undefined,
},
//
rules: {
gydl: [
{ required: true, message: "文件名称不能为空", trigger: "blur" }
{ required: true, message: "文件名称不能为空", trigger: "blur" },
],
slmllb: [
{ required: true, message: "上楼目录类别不能为空", trigger: "change" }
{
required: true,
message: "上楼目录类别不能为空",
trigger: "change",
},
],
},
//
@ -218,32 +333,55 @@ export default {
this.getList();
},
methods: {
querySearchAsync(queryString, cb) {
let results = [];
getAllCatalogs({ gydl: queryString }).then(res => {
res.data.records.forEach(item => {
getAllCatalogs({ gydl: queryString }).then((res) => {
res.data.records.forEach((item) => {
results.push({
value: item.gydl,
id: item.id,
});
});
});
cb(results);
},
//
getList() {
async getList(deleteId) {
this.loading = true;
getAllCatalogs(this.queryParams).then(response => {
this.postList = response.data.records.map(item => ({
...item,
}));
this.total = response.data.total;
this.loading = false;
}).catch(error => {
this.loading = false;
});
if (deleteId) {
await getAllCatalogs(this.queryParams)
.then((response) => {
if (
response.data.records &&
response.data.records.length === 0 &&
this.queryParams.current > 1
) {
this.queryParams.current = this.queryParams.current - 1;
this.getList();
} else {
this.postList = response.data.records.map((item) => ({
...item,
}));
this.total = response.data.total;
this.loading = false;
}
})
.catch((error) => {
this.loading = false;
});
} else {
getAllCatalogs(this.queryParams)
.then((response) => {
this.postList = response.data.records.map((item) => ({
...item,
}));
this.total = response.data.total;
this.loading = false;
})
.catch((error) => {
this.loading = false;
});
}
},
//
cancel() {
@ -262,7 +400,7 @@ export default {
createTime: undefined,
updateBy: undefined,
updateId: undefined,
updateTime: undefined
updateTime: undefined,
};
this.resetForm("form");
},
@ -278,7 +416,7 @@ export default {
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id);
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
@ -298,24 +436,28 @@ export default {
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id !== undefined) {
editCatalog(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).catch(error => {
console.error('API Request Error:', error);
});
editCatalog(this.form)
.then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
})
.catch((error) => {
console.error("API Request Error:", error);
});
} else {
addCatalog(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).catch(error => {
console.error('API Request Error:', error);
});
addCatalog(this.form)
.then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
})
.catch((error) => {
console.error("API Request Error:", error);
});
}
}
});
@ -323,12 +465,16 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const catalogIds = row.id || this.ids;
this.$modal.confirm('是否确认删除该数据项?').then(() => {
return deleteCatalog([catalogIds]);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => { });
this.$modal
.confirm("是否确认删除该数据项?")
.then(() => {
return deleteCatalog([catalogIds]);
})
.then(() => {
this.getList(catalogIds);
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
/**导出 */
handleExport() {
@ -363,8 +509,8 @@ export default {
this.$refs.upload.clearFiles();
this.$alert(
"<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
response.msg +
"</div>",
response.msg +
"</div>",
"导入结果",
{ dangerouslyUseHTMLString: true }
);
@ -374,24 +520,24 @@ export default {
submitFileForm() {
this.$refs.upload.submit();
},
}
},
};
</script>
<style scoped>
.headerbox {
background-color: #fff;
border-radius: .5rem;
border-radius: 0.5rem;
padding: 1rem;
margin: .5rem;
margin: 0.5rem;
border: 1px solid #eee;
}
.tablebox {
background-color: #fff;
border-radius: .5rem;
border-radius: 0.5rem;
padding: 1rem;
margin: .5rem;
margin: 0.5rem;
border: 1px solid #eee;
}
@ -412,4 +558,4 @@ export default {
display: flex;
justify-content: space-between;
}
</style>
</style>

Loading…
Cancel
Save