城阳pc工作端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

395 lines
11 KiB

<template>
3 years ago
<div class="div_main">
<div class="div_search">
<el-form
:inline="true"
:model="dataForm"
@keyup.enter.native="getDataList()"
>
<!--<el-form-item label="所属组织名称" prop="orgName">-->
<!--<el-select v-model="dataForm.orgName" placeholder="所属组织名称">-->
<!--<el-option-->
<!--ref="org"-->
<!--v-for="item in organizationList"-->
<!--:key="item.orgId"-->
<!--:label="item.orgName"-->
<!--:value="item.orgId"-->
<!--&gt;-->
<!--</el-option>-->
<!--</el-select>-->
<!--</el-form-item>-->
<el-form-item label="所属组织名称" prop="orgName" label-width="130px">
<el-cascader
ref="org"
v-model="orgIds"
:options="organizationList"
:props="{ checkStrictly: false, multiple: false, emitPath: true }"
style="width: 200px"
clearable
@change="orgChangeHandle"
>
</el-cascader>
</el-form-item>
<el-form-item label="核酸检测点名称" prop="name">
<el-input
v-model="dataForm.name"
placeholder="核酸检测点名称"
clearable
></el-input>
</el-form-item>
<el-form-item label="咨询电话" prop="mobile">
<el-input
v-model="dataForm.mobile"
placeholder="咨询电话"
clearable
></el-input>
</el-form-item>
<el-form-item>
<el-button class="diy-button--search" @click="getDataList()">{{
$t("query")
}}</el-button>
</el-form-item>
<el-form-item>
<el-button
class="diy-button--add"
type="primary"
@click="addOrUpdateHandle()"
>{{ $t("add") }}</el-button
>
</el-form-item>
<!--<el-form-item>-->
<!--<el-button type="danger" @click="deleteHandle()">{{-->
<!--$t("deleteBatch")-->
<!--}}</el-button>-->
<!--</el-form-item>-->
</el-form>
3 years ago
</div>
<div class="div_table">
<div class="exportBtn">
3 years ago
<el-button
style="margin-left: 10px"
class="diy-button--export"
size="small"
@click="handleExportModule()"
>下载核酸检测点模板</el-button
>
3 years ago
<el-upload
style=""
ref="upload"
3 years ago
:multiple="false"
:show-file-list="false"
:before-upload="
(file) => {
beforeUpload(file);
}
"
action=""
accept=".xls,.xlsx"
:http-request="
() => {
uploadFile();
}
"
>
<el-button
style="margin-left: 10px"
size="small"
class="diy-button--delete"
>导入核酸监测点数据</el-button
>
</el-upload>
</div>
<el-table
v-loading="dataListLoading"
:data="dataList"
border
@selection-change="dataListSelectionChangeHandle"
style="width: 100%"
>
<el-table-column
type="selection"
header-align="center"
align="center"
width="50"
></el-table-column>
<el-table-column
prop="orgName"
label="所属组织名称"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="name"
label="核酸检测点名称"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="serveTime"
label="服务时间"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="mobile"
label="咨询电话"
header-align="center"
align="center"
></el-table-column>
<el-table-column
prop="address"
label="检测点地址"
header-align="center"
align="center"
></el-table-column>
<el-table-column
:label="$t('handle')"
fixed="right"
header-align="center"
align="center"
width="150"
>
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click="addOrUpdateHandle(scope.row.id)"
>{{ $t("update") }}</el-button
>
<el-button
type="text"
size="small"
@click="deleteHandle(scope.row.id)"
>{{ $t("delete") }}</el-button
>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="limit"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="pageSizeChangeHandle"
@current-change="pageCurrentChangeHandle"
>
</el-pagination>
</div>
3 years ago
<!-- 弹窗, 新增 / 修改 -->
<el-dialog
:visible.sync="addOrUpdateVisible"
:title="!updateId ? $t('add') : $t('update')"
3 years ago
:close-on-click-modal="false"
:close-on-press-escape="false"
:destroy-on-close="true"
>
<add-or-update
v-if="addOrUpdateVisible"
3 years ago
ref="addOrUpdate"
@refreshDataList="getDataList"
@closeDialog="closeDialog"
3 years ago
></add-or-update>
</el-dialog>
</div>
</template>
<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./icpointnucleicmonitoring-add-or-update";
export default {
mixins: [mixinViewModule],
data() {
return {
mixinViewModuleOptions: {
getDataListURL: "/epmetuser/icPointNucleicMonitoring/page",
getDataListIsPage: true,
deleteURL: "/epmetuser/icPointNucleicMonitoring",
deleteIsBatch: true,
},
dataForm: {
name: "",
mobile: "",
orgId: "",
},
organizationList: [],
orgIds: [],
updateId: null,
};
},
components: {
AddOrUpdate,
},
created() {
this.getFormInfo();
},
3 years ago
methods: {
// 新增 / 修改
addOrUpdateHandle(id) {
this.updateId = id;
this.$nextTick(() => {
this.$refs.addOrUpdate.dataForm.id = id;
this.$refs.addOrUpdate.init();
});
this.addOrUpdateVisible = true;
},
// 关闭弹窗
closeDialog() {
this.addOrUpdateVisible = false;
this.uploadId = null;
},
// 获取所属组织列表
getFormInfo() {
this.$http
.post(`/gov/org/agency/getOrgTreeListByCustomerId`)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
}
this.organizationList = res.data;
this.deleteChildren(this.organizationList);
})
.catch(() => {});
},
deleteChildren(arr) {
let childs = arr;
for (let i = childs.length; i--; i > 0) {
if (childs[i].children) {
if (childs[i].children.length) {
this.deleteChildren(childs[i].children);
} else {
delete childs[i].children;
}
}
}
return arr;
},
orgChangeHandle() {
this.dataForm.orgId = this.orgIds[this.orgIds.length - 1];
console.log(this.dataForm);
},
3 years ago
handleExportModule() {
let title = "核酸检测点模板";
let url = "/epmetuser/icPointNucleicMonitoring/exporttemplate";
3 years ago
let params = {};
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
3 years ago
this.download(data, title + ".xls");
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
// 下载文件
download(data, fileName) {
if (!data) {
return;
}
var csvData = new Blob([data]);
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(csvData, fileName);
}
// for Non-IE (chrome, firefox etc.)
else {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
var url = window.URL.createObjectURL(csvData);
a.href = url;
a.download = fileName;
a.click();
a.remove();
window.URL.revokeObjectURL(url);
}
},
// 上传文件之前的钩子
3 years ago
beforeUpload(file) {
this.files = file;
3 years ago
const isText = file.type === "application/vnd.ms-excel";
const isTextComputer =
file.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
if (!isText && !isTextComputer) {
3 years ago
this.$message.error("请选择正确格式的文件");
this.files = null;
this.fileName = "";
return false;
} else {
this.fileName = file.name;
3 years ago
return true;
}
},
3 years ago
async uploadFile() {
if (this.fileName == "") {
3 years ago
this.$message.warning("请选择要上传的文件!");
return false;
}
this.$message({
showClose: true,
3 years ago
message: "导入中,请到系统管理-导入记录中查看进度",
duration: 0,
});
//清空上传列表
this.$refs["upload"].clearFiles();
3 years ago
let url = "";
let fileFormData = new FormData();
3 years ago
fileFormData.append("file", this.files); //filename是键,file是值,就是要传的文件,test.zip是要传的文件名
url = "/epmetuser/icPointNucleicMonitoring/pointImport";
window.app.ajax.post2(
url,
fileFormData,
(data, rspMsg) => {
3 years ago
if (data.code === 0 && data.msg == "success") {
// this.$message.success('导入成功')
} else {
// this.$message({
// showClose: true,
// message: rspMsg,
// duration: 0,
// type: "error"
// })
// this.$message.error(rspMsg)
}
3 years ago
this.loadTable();
},
(rspMsg, data) => {},
3 years ago
{ headers: { "Content-Type": "multipart/form-data" } }
);
},
3 years ago
},
};
</script>
<style lang="scss" scoped>
3 years ago
@import "@/assets/scss/modules/visual/communityManage.scss";
@import "@/assets/scss/modules/management/list-main.scss";
.exportBtn {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.div_left_table {
margin-top: 10px;
margin-left: 15px;
background-color: #ffffff;
border-radius: 5px;
padding: 10px;
}
</style>