findEnterprise.vue
4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<template>
<div>
<el-dialog :title="props.title" v-model="state.openDialog" width="1000px" append-to-body destroy-on-close @close="handleClose(false)">
<el-form ref="queryForm" :model="state.queryParams" :rules="queryRules" label-position="left" label-width="80px">
<el-row :gutter="10">
<el-col :span="12">
<el-form-item label="企业名称" prop="ename">
<el-input v-model.trim="state.queryParams.ename" placeholder="请输入企业名称" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item>
<el-button type="primary" icon="Search" v-debounceClick="()=>handleSearch()">查询</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-table :data="state.tableList" style="width: 100%" @selection-change="handleSelectionChange" border v-loading="state.isLoading" class="own_table" max-height="400px">
<el-table-column v-for="(table, index) in state.tableColumns" :key="'table'+index" :label="table.label" :prop="table.prop" :min-width="table.width">
<template #default="scope">
<template v-if="table.limitLength">
{{scope.row[table.prop].substring(0, table.limitLength)}}
</template>
</template>
</el-table-column>
<el-table-column label="操作" min-width="40%">
<template #default="scope">
<slot name="cop" :row="scope.row"></slot>
</template>
</el-table-column>
</el-table>
<pagination
v-show="state.total > 0"
:total="state.total"
:page.sync="state.queryParams.pageNum"
:limit.sync="state.queryParams.pageSize"
@pagination="getList"
/>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import * as api from '../interface/api.ts'
import { loginMain } from '../store'
import { storeToRefs } from 'pinia';
let loginAct = loginMain()
let { getStoreToken, getUserInfo } = storeToRefs(loginAct)
let queryForm = ref<FormInstance>()
const emit = defineEmits(["handleClose"]);
let props = defineProps({
title: {
default: "",
type: String
},
open: {
default: false,
type: Boolean
},
openName: {
type: String,
required: true,
default: ""
},
})
let state = reactive( {
openDialog: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
tableList: [],
// { "regStatus": "存续", "estiblishTime": "1995-12-25 00:00:00.0", "regCapital": "120000万人民币", "companyType": 1, "matchType": "公司名称匹配", "type": 1, "legalPersonName": "王晓秋", "regNumber": "310115400033897", "creditCode": "913101156073392545", "name": "联合汽车电子有限公司", "id": 466517252, "orgNumber": "60733925-4", "base": "上海" }
isLoading: false,
total: 0,
queryParams: {
pageNum: 1,
pageSize: 10,
ename: null,
},
tableColumns: [
{
label: "企业名称",
prop: "name"
},{
label: "统一信用代码",
prop: "creditCode",
width: "55%"
},{
label: "法定代表人",
prop: "legalPersonName",
width: "30%"
},{
label: "状态",
prop: "regStatus",
width: "20%"
},{
label: "注册资本",
prop: "regCapital",
width: "40%"
},{
label: "成立日期",
prop: "estiblishTime",
limitLength: 10,
width: "33%"
},
]
})
let queryRules = reactive<FormRules>({
ename: [
{ required: true, message: "企业名称不能为空", trigger: ["blur","change"] }
]
})
let handleClose = (isRefresh: boolean) => {
emit('handleClose', props.openName, false, isRefresh)
}
let handleSearch = () => {
state.queryParams.pageNum = 1
getList()
}
let handleSelectionChange = (selection: Array<any>) => {
state.ids = selection.map((item: Object) => item.id)
state.single = selection.length !== 1
state.multiple = !selection.length
}
let getList = () => {
queryForm.value.validate((valid: boolean, fields: Object)=> {
if (valid) {
state.isLoading = true
api.searchCompany(state.queryParams).then((res: Object)=> {
state.tableList = res.data.rows
}).finally(()=> {
state.isLoading = false
})
}
})
}
let reset = () => {
state.queryParams.ename = null
state.tableList = []
}
watchEffect(()=> {
state.openDialog = props.open
if (props.open) {
reset()
}
})
onMounted(()=>{
})
</script>
<style scoped>
</style>