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.

308 lines
9.6 KiB

3 years ago
<template>
<div style="padding: 0 20px">
3 years ago
3 years ago
<div ref="lxHeader">
3 years ago
<lx-header icon="md-apps" text="档案管理" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
3 years ago
<slot>
3 years ago
<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
<Input v-model="select.keyword" style="width: 200px;margin-right: 10px;" placeholder="搜索" />
<Button type="primary" @click="getindex"></Button>
<Button icon="ios-add" type="primary" style="margin-left: 10px;"
@click="$refs['addRecord'].isShow = true,$refs['addRecord'].type = 'add'">添加</Button>
3 years ago
<Button icon="ios-add" type="primary" style="margin-left: 10px;"
@click="$refs['imports'].show()">导入</Button>
<Button icon="ios-add" type="primary" style="margin-left: 10px;"
@click="exportExcel(new Date().getTime().toString())">导出</Button>
3 years ago
</div>
</slot>
</lx-header>
</div>
3 years ago
<xy-table :list="list" :total="total" @pageSizeChange="e => select.pageSize = e" @pageIndexChange="pageChange"
:table-item="table">
3 years ago
<template v-slot:btns>
3 years ago
<el-table-column fixed="right" label="操作" width="260" header-align="center">
3 years ago
<template slot-scope="scope">
3 years ago
<Button type="primary" size="small" @click="editorRecord(scope.row.id,'editor')"></Button>
<Button type="primary" size="small" style="margin-left: 10px;"
3 years ago
@click="editorView(scope.row.id,'add')">访视</Button>
<Button type="primary" size="small" style="margin-left: 10px;"
@click="showInfo(scope.row.id)">视图</Button>
3 years ago
<Poptip transfer confirm title="确认要删除吗?" @on-ok="deleteRecord(scope.row)">
<Button type="primary" style="margin-left: 10px;" size="small" ghost>删除</Button>
3 years ago
</Poptip>
</template>
</el-table-column>
</template>
</xy-table>
3 years ago
<addRecord ref="addRecord" @refresh="getindex"></addRecord>
<addViewRecord ref="addViewRecord" @refresh="getindex"></addViewRecord>
3 years ago
<imports :table-name="customForm.tableName" :form-info="importForm" ref="imports" @refresh="getindex"></imports>
3 years ago
3 years ago
</div>
</template>
<script>
3 years ago
import {
index,
destroy
} from "@/api/system/baseForm.js"
import addRecord from "./components/addRecord.vue"
import addViewRecord from "@/views/viewrecords/components/addViewRecord.vue"
import {
Message
} from 'element-ui'
import imports from "@/views/component/imports.vue"
3 years ago
import * as XLSX from "xlsx";
import { saveAs } from "file-saver";
3 years ago
import {
index as fieldIndex
} from "@/api/system/customFormField";
import {
getparameter
} from "@/api/system/dictionary";
3 years ago
export default {
components: {
3 years ago
addRecord,
addViewRecord,
imports
3 years ago
},
data() {
return {
select: {
pageSize: 10,
3 years ago
pageIndex: 1,
3 years ago
keyword: ""
},
3 years ago
rukuType: '',
customForm: {
3 years ago
customFormId: 1,
3 years ago
tableName: "records"
},
3 years ago
form: [],
importForm:[],
exportForm:[],
3 years ago
total: 0,
3 years ago
list: [],
3 years ago
table: [{
3 years ago
label: '序号',
type: 'index',
fixed: 'left',
width: 80
3 years ago
},
{
label: "所属街道",
width: 120,
prop: 'street',
align: 'center'
3 years ago
},
{
3 years ago
label: "姓名",
width: 120,
3 years ago
prop: 'name',
3 years ago
align: 'center',
fixed: 'left'
},
{
3 years ago
label: "性别",
3 years ago
width: 120,
3 years ago
prop: 'sex',
3 years ago
align: 'center'
},
{
3 years ago
label: "身份证号",
3 years ago
width: 180,
3 years ago
prop: 'idcard',
align: 'center'
3 years ago
},
{
3 years ago
label: "联系电话",
width: 120,
prop: 'mobile',
3 years ago
align: 'center'
},
{
3 years ago
label: "固话",
width: 120,
prop: 'telephone',
3 years ago
align: 'center'
},
{
3 years ago
label: "残疾证号",
3 years ago
width: 180,
3 years ago
prop: 'number',
3 years ago
align: 'center'
},
{
3 years ago
label: "残疾类别",
width: 120,
prop: 'disabilitytype',
3 years ago
align: 'center'
},
{
3 years ago
label: "残疾等级",
width: 120,
prop: 'disabilitylevel',
align: 'center'
},
{
label: "有效期至",
3 years ago
width: 180,
3 years ago
prop: 'validity',
3 years ago
align: 'center'
},
{
3 years ago
label: "户籍地址",
3 years ago
width: 240,
3 years ago
prop: 'address',
3 years ago
align: 'left'
},
{
3 years ago
label: "现居住地",
3 years ago
width: 240,
3 years ago
prop: 'reside',
3 years ago
align: 'left'
}
]
}
},
3 years ago
methods: {
showInfo(id) {
this.$router.push({path:"/record/personinfo",query:{id:id}})
},
3 years ago
async getindex() {
const res = await index({
page_size: this.select.pageSize,
page: this.select.pageIndex,
3 years ago
table_name: this.customForm.tableName,
show_relation:['admin','department'],
3 years ago
filter: [{
"key": "name",
"op": "like",
"value": this.select.keyword
}],
})
this.list = res.data
this.total = res.total
3 years ago
},
3 years ago
pageChange(e) {
this.select.pageIndex = e
},
editorRecord(id, type) {
this.$refs['addRecord'].id = id
this.$refs['addRecord'].isShow = true
this.$refs['addRecord'].type = type
},
editorView(id, type) {
console.log(id,type)
this.$refs['addViewRecord'].person_id = id
this.$refs['addViewRecord'].isShow = true
this.$refs['addViewRecord'].type = type
3 years ago
3 years ago
},
deleteRecord(row) {
destroy({
id: row.id,
table_name: this.customForm.tableName
}).then(res => {
Message({
type: 'success',
message: '删除成功'
})
this.getindex()
})
},
// 获取表信息
async getField() {
3 years ago
// console.log(this.$route.meta.params, "---", this.$route)
// return
// if (this.$route.meta.params?.custom_form) {
// let decode = decodeURIComponent(this.$route.meta.params?.custom_form)
// try {
// let custom_form = JSON.parse(decode)
// this.customForm.customFormId = custom_form.custom_form_id
// this.customForm.tableName = custom_form.table_name
// console.log("123", this.customForm)
// // this.select.table_name = custom_form.table_name
// } catch (err) {
// console.warn(err)
// }
// }
3 years ago
const res = await fieldIndex({
page: 1,
page_size: 999,
custom_form_id: this.customForm.customFormId,
sort_name: 'sort',
sort_type: 'asc',
})
if (res.data && res.data instanceof Array) {
res.data.forEach(i => {
if (i.field) {
if (
(i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
i.parameter_id
) {
getparameter({
id: i.parameter_id
}).then((res) => {
i._paramters = res.detail ?? [];
});
}
if (
(i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
i.link_table_name
) {
index({
page: 1,
page_size: 999,
table_name: i.link_table_name,
}).then((res) => {
i._paramters = res.data ?? [];
});
}
}
})
}
3 years ago
this.form = res.data
this.importForm = this.form
?.filter((i) => i.form_show&&i.list_show)
.map((i)=>{
return i
})
this.exportForm = this.form
?.filter((i) => i.list_show)
.map((i)=>{
return i
})
3 years ago
},
async exportExcel(sheetName) {
const res = await index(Object.assign(this.select,{ page: 1,page_size: 99999,table_name: this.customForm.tableName}))
if(res.data){
3 years ago
let headers = this.exportForm.map(i => {
3 years ago
return {
key: i.field,
title: i.name
}
})
const data = res.data.map(row => headers.map(header => row[header.key]));
data.unshift(headers.map(header => header.title));
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet(data);
XLSX.utils.book_append_sheet(wb, ws, sheetName);
const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
saveAs(new Blob([wbout], { type: 'application/octet-stream' }), `${sheetName}.xlsx`);
}
3 years ago
},
},
mounted() {
3 years ago
this.getindex()
this.getField()
3 years ago
}
}
</script>
<style scoped lang="scss">
</style>