Browse Source

智能导入

feature
jiangyuying 2 years ago
parent
commit
85b4ac42dc
  1. 2
      src/views/modules/base/residentManagement/louzhang/addForm.vue
  2. 219
      src/views/modules/base/smartImport.vue

2
src/views/modules/base/residentManagement/louzhang/addForm.vue

@ -246,7 +246,7 @@ export default {
this.formData = { ...data }; this.formData = { ...data };
this.$set(this.formData, 'rangeList', data.rangeList) // this.$set(this.formData, 'rangeList', data.rangeList)
console.log(this.formData) console.log(this.formData)
} else { } else {
this.$message.error(msg); this.$message.error(msg);

219
src/views/modules/base/smartImport.vue

@ -2,115 +2,91 @@
<div class="g-main"> <div class="g-main">
<div class="m-table"> <div class="m-table">
<div class="u-table-btn1"> <div class="u-table-btn1">
<el-dropdown <el-dropdown size="small"
size="small" type="primary"
type="primary" style="margin: 0 10px; height: 30px"
style="margin: 0 10px; height: 30px" trigger="hover">
trigger="hover" <el-button type="primary"
> size="small">
<el-button type="primary" size="small">
表格导入<i class="el-icon-arrow-down el-icon--right"></i> 表格导入<i class="el-icon-arrow-down el-icon--right"></i>
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item <el-dropdown-item v-for="(item, index) in resiClass"
v-for="(item, index) in resiClass" :key="index"
:key="index" @click.native="handleImportType(item.value)">
@click.native="handleImportType(item.value)"
>
{{ item.label }} {{ item.label }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-upload <el-upload :headers="$getElUploadHeaders()"
:headers="$getElUploadHeaders()" ref="upload"
ref="upload" class="upload-btn"
class="upload-btn" action="uploadUlr"
action="uploadUlr" :limit="1"
:limit="1" :accept="'.xls,.xlsx'"
:accept="'.xls,.xlsx'" :with-credentials="true"
:with-credentials="true" :show-file-list="false"
:show-file-list="false" :auto-upload="true"
:auto-upload="true" :on-progress="handleProgress"
:on-progress="handleProgress" :on-success="handleExcelSuccess"
:on-success="handleExcelSuccess" :before-upload="beforeExcelUpload"
:before-upload="beforeExcelUpload" :http-request="uploadHttpRequest"></el-upload>
:http-request="uploadHttpRequest" <el-button class="diy-button--white"
></el-upload> size="small"
<el-button style="margin-left: 10px"
class="diy-button--white" @click="handleExportModule()">下载模板</el-button>
size="small"
style="margin-left: 10px"
@click="handleExportModule()"
>下载模板</el-button
>
</div> </div>
<div v-if="dataList.length > 0"> <div v-if="dataList.length > 0">
<el-table <el-table ref="ref_table"
ref="ref_table" :data="dataList"
:data="dataList" border
border :height="tableHeight"
:height="tableHeight" class="m-table-item"
class="m-table-item" v-loading="dataListLoading"
v-loading="dataListLoading" style="width: 100%">
style="width: 100%" <el-table-column label="序号"
> header-align="center"
<el-table-column align="center"
label="序号" type="index"
header-align="center" width="100"></el-table-column>
align="center" <el-table-column prop="userTableHeader"
type="index" header-align="center"
width="100" align="center"
></el-table-column> label="表格信息"
<el-table-column min-width="100">
prop="userTableHeader"
header-align="center"
align="center"
label="表格信息"
min-width="100"
>
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.userTableHeader || "--" }} {{ scope.row.userTableHeader || "--" }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="itemGroupId"
prop="itemGroupId" header-align="center"
header-align="center" align="center"
align="center" label="平台对应信息"
label="平台对应信息" min-width="110">
min-width="110"
>
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
<el-select <el-select class="item_width_sel"
class="item_width_sel" v-model="scope.row.itemGroupId"
v-model="scope.row.itemGroupId" size="small"
size="small" placeholder="请选择">
placeholder="请选择" <el-option v-for="item in groupList"
> @click.native="handleSelGroup(scope.$index, item, 'change')"
<el-option :key="item.value"
v-for="item in groupList" :label="item.label"
@click.native="handleSelGroup(scope.$index, item, 'change')" :value="item.label">
:key="item.value"
:label="item.label"
:value="item.label"
>
</el-option> </el-option>
</el-select> </el-select>
<el-select <el-select class="item_width_sel"
class="item_width_sel" v-model="scope.row.itemId"
v-model="scope.row.itemId" size="small"
size="small" style="margin-left: 10px"
style="margin-left: 10px" placeholder="请选择">
placeholder="请选择" <el-option v-for="item in scope.row.itemList"
> :key="item.itemId"
<el-option :label="item.label"
v-for="item in scope.row.itemList" :value="item.label">
:key="item.itemId"
:label="item.label"
:value="item.label"
>
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
@ -118,17 +94,16 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<div ref="divEditBtn" class="m-edit-btn"> <div ref="divEditBtn"
<el-button class="m-edit-btn">
type="primary" <el-button type="primary"
size="small" size="small"
class="diy-button--blue" class="diy-button--blue"
@click="handleComfirm" @click="handleComfirm"> </el-button>
> </el-button
>
</div> </div>
</div> </div>
<div class="m-hint" v-else>请先导入表格</div> <div class="m-hint"
v-else>请先导入表格</div>
</div> </div>
</div> </div>
</template> </template>
@ -138,7 +113,7 @@ import { requestPost } from "@/js/dai/request";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
export default { export default {
data() { data () {
return { return {
customerId: "", // id customerId: "", // id
customerName: "", // customerName: "", //
@ -174,7 +149,7 @@ export default {
}, },
computed: { computed: {
tableHeight() { tableHeight () {
const h = this.clientHeight - this.sHeight + this.iframeHeigh; const h = this.clientHeight - this.sHeight + this.iframeHeigh;
const _h = this.clientHeight - this.sHeight; const _h = this.clientHeight - this.sHeight;
return this.$store.state.inIframe ? h : _h; return this.$store.state.inIframe ? h : _h;
@ -183,12 +158,12 @@ export default {
...mapGetters(["clientHeight", "iframeHeight"]), ...mapGetters(["clientHeight", "iframeHeight"]),
}, },
components: {}, components: {},
created() {}, created () { },
watch: { watch: {
//dataList dom //dataList dom
"dataList.length": { "dataList.length": {
immediate: true, immediate: true,
handler(newVal) { handler (newVal) {
this.$nextTick(() => { this.$nextTick(() => {
if (newVal > 0) { if (newVal > 0) {
this.sHeight = this.$refs.divEditBtn.offsetHeight + 300; this.sHeight = this.$refs.divEditBtn.offsetHeight + 300;
@ -197,22 +172,22 @@ export default {
}, },
}, },
}, },
async mounted() { async mounted () {
await this.loadPersonGroup(); await this.loadPersonGroup();
this.getResident(); this.getResident();
}, },
methods: { methods: {
diaClose() { diaClose () {
this.formShow = false; this.formShow = false;
}, },
handleDropdownClick(event) { handleDropdownClick (event) {
event.stopPropagation(); event.stopPropagation();
}, },
async loadPersonGroup() { async loadPersonGroup () {
const url = "/oper/customize/icformitemgroup/list"; const url = "/oper/customize/icformitemgroup/list";
// const url = 'http://yapi.elinkservice.cn/mock/245/gov/org/isServiceProject/service/serviceScopeTree' // const url = 'http://yapi.elinkservice.cn/mock/245/gov/org/isServiceProject/service/serviceScopeTree'
let params = { let params = {
formCode: "resi_base_info", formCode: "resident_base_info",
policyFlag: "1", policyFlag: "1",
}; };
@ -226,7 +201,7 @@ export default {
}, },
// //
async handleSelGroup(index, item, change) { async handleSelGroup (index, item, change) {
console.log(index, item, change); console.log(index, item, change);
console.log("让我看看返回的什么"); console.log("让我看看返回的什么");
const url = "/oper/customize/icformitem/getItemListV2"; const url = "/oper/customize/icformitem/getItemListV2";
@ -250,7 +225,7 @@ export default {
}, },
// //
async loadData() { async loadData () {
this.dataListLoading = true; this.dataListLoading = true;
// const url = 'http://yapi.elinkservice.cn/mock/245/epmetuser/dataSyncConfig/list' // const url = 'http://yapi.elinkservice.cn/mock/245/epmetuser/dataSyncConfig/list'
const url = "/epmetuser/dataSyncConfig/list"; const url = "/epmetuser/dataSyncConfig/list";
@ -272,11 +247,11 @@ export default {
// this.$message.error(msg ) // this.$message.error(msg )
} }
}, },
handleImportType(command) { handleImportType (command) {
this.importType = command; this.importType = command;
this.$refs["upload"].$children[0].$refs.input.click(); this.$refs["upload"].$children[0].$refs.input.click();
}, },
handleChangeScope(value) { handleChangeScope (value) {
this.orgIdArray = value; this.orgIdArray = value;
this.scopeList = []; this.scopeList = [];
let selArray = this.$refs["myCascader"].getCheckedNodes(); let selArray = this.$refs["myCascader"].getCheckedNodes();
@ -293,7 +268,7 @@ export default {
console.log("this.scopeList", this.scopeList); console.log("this.scopeList", this.scopeList);
}, },
async getResident() { async getResident () {
try { try {
const { data } = await this.$http.post("sys/dict/data/dictlist", { const { data } = await this.$http.post("sys/dict/data/dictlist", {
dictType: "resident_category_import", dictType: "resident_category_import",
@ -303,7 +278,7 @@ export default {
console.log(error, "获取居民类别字典"); console.log(error, "获取居民类别字典");
} }
}, },
async handleExportModule() { async handleExportModule () {
let url = "/actual/base/residentBaseInfo/import/download-template"; let url = "/actual/base/residentBaseInfo/import/download-template";
let params = {}; let params = {};
@ -351,7 +326,7 @@ export default {
}); });
}, },
// //
handleExcelSuccess(res, file) { handleExcelSuccess (res, file) {
console.log(res, file); console.log(res, file);
if (!res) return; if (!res) return;
if (res.code === 0 && res.msg === "success") { if (res.code === 0 && res.msg === "success") {
@ -360,11 +335,11 @@ export default {
this.$message.error(res.msg); this.$message.error(res.msg);
} }
}, },
handleProgress(event, file, fileList) { handleProgress (event, file, fileList) {
console.log("percentage", file.percentage); console.log("percentage", file.percentage);
}, },
beforeExcelUpload(file) { beforeExcelUpload (file) {
console.log("file", file); console.log("file", file);
console.log(this.importType); console.log(this.importType);
@ -387,7 +362,7 @@ export default {
} }
return fileType && isLt1M; return fileType && isLt1M;
}, },
async uploadHttpRequest(file) { async uploadHttpRequest (file) {
if (!this.importType) return; if (!this.importType) return;
this.importLoading = true; this.importLoading = true;
this.importBtnTitle = "正在上传中..."; this.importBtnTitle = "正在上传中...";
@ -429,7 +404,7 @@ export default {
this.$refs.upload.clearFiles(); this.$refs.upload.clearFiles();
}, },
async handleComfirm() { async handleComfirm () {
this.importLoading = true; this.importLoading = true;
this.importBtnTitle = "正在上传中..."; this.importBtnTitle = "正在上传中...";
const { importOption, importCode, dataList } = this; const { importOption, importCode, dataList } = this;
@ -460,7 +435,7 @@ export default {
this.importBtnTitle = "导入"; this.importBtnTitle = "导入";
}, },
async upload2(file, code) { async upload2 (file, code) {
this.importLoading = true; this.importLoading = true;
this.importBtnTitle = "正在上传中..."; this.importBtnTitle = "正在上传中...";
const formData = new FormData(); //FormDataappend('key', value) const formData = new FormData(); //FormDataappend('key', value)
@ -484,7 +459,7 @@ export default {
this.$refs.upload.clearFiles(); this.$refs.upload.clearFiles();
}, },
afterSuccess() { afterSuccess () {
this.$message({ this.$message({
showClose: true, showClose: true,
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
@ -503,7 +478,7 @@ export default {
}, },
// //
diaCancel() { diaCancel () {
this.$emit("cancleBack"); this.$emit("cancleBack");
}, },
}, },

Loading…
Cancel
Save