parent
d4e46f9694
commit
06a9bdbb6c
@ -0,0 +1,149 @@ |
|||||||
|
<template> |
||||||
|
<div class="app-container"> |
||||||
|
<div class="search-container"> |
||||||
|
<el-form :model="queryForm" :inline="true"> |
||||||
|
<el-row> |
||||||
|
<el-col :span="6"> |
||||||
|
<el-form-item label="查询条件"> |
||||||
|
<el-select |
||||||
|
v-model="queryForm.selectName" |
||||||
|
placeholder="请选择" |
||||||
|
style="width: 240px" |
||||||
|
clearable |
||||||
|
> |
||||||
|
<el-option |
||||||
|
v-for="item in options" |
||||||
|
:key="item.value" |
||||||
|
:label="item.label" |
||||||
|
:value="item.value" |
||||||
|
/> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
</el-col> |
||||||
|
<el-col :span="6" v-if="queryForm.selectName != undefined"> |
||||||
|
<el-input |
||||||
|
v-model="queryForm.selectValue" |
||||||
|
placeholder="请输入" |
||||||
|
style="width: 300px" |
||||||
|
/> |
||||||
|
</el-col> |
||||||
|
<el-col :span="buttonColSpan"> |
||||||
|
<el-form-item> |
||||||
|
<el-button type="primary" :icon="Search" @click="queryCustomer" |
||||||
|
>搜索</el-button |
||||||
|
> |
||||||
|
</el-form-item> |
||||||
|
</el-col> |
||||||
|
</el-row> |
||||||
|
</el-form> |
||||||
|
</div> |
||||||
|
<el-card shadow="never"> |
||||||
|
<template #header> |
||||||
|
<div style="display: flex; justify-content: flex-end"> |
||||||
|
<el-button type="primary" :icon="Position" @click="bindingCustom" |
||||||
|
>绑定</el-button |
||||||
|
> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
<div class="any-table"> |
||||||
|
<el-table |
||||||
|
:data="customData" |
||||||
|
v-loading="loading" |
||||||
|
max-height="350" |
||||||
|
highlight-current-row |
||||||
|
@current-change="handleCustomerChange" |
||||||
|
> |
||||||
|
<el-table-column prop="customType" label="客户类型" align="center" /> |
||||||
|
<el-table-column |
||||||
|
prop="regionAreaName" |
||||||
|
label="客户系统管理域" |
||||||
|
align="center" |
||||||
|
/> |
||||||
|
<el-table-column |
||||||
|
prop="customStatus" |
||||||
|
label="客户状态" |
||||||
|
align="center" |
||||||
|
/> |
||||||
|
</el-table> |
||||||
|
<pagination |
||||||
|
v-if="customTotal > 0" |
||||||
|
v-model:total="customTotal" |
||||||
|
v-model:page="queryForm.pageNum" |
||||||
|
v-model:limit="queryForm.pageSize" |
||||||
|
@pagination="queryCustomer" |
||||||
|
/> |
||||||
|
</div> |
||||||
|
</el-card> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script setup lang="ts"> |
||||||
|
import { Position, Search } from "@element-plus/icons-vue"; |
||||||
|
import { ElTable } from "element-plus"; |
||||||
|
import { CustomerVO } from "@/api/customer/types"; |
||||||
|
import { customerPage } from "@/api/customer"; |
||||||
|
import { bindingCustomAPI } from "@/api/resources-equipment"; |
||||||
|
const queryForm = ref<SelectForm>({ |
||||||
|
pageNum: 1, |
||||||
|
pageSize: 10, |
||||||
|
}); |
||||||
|
const route = useRoute(); |
||||||
|
let devId: number = parseInt(<string>route.params.devId); |
||||||
|
const loading = ref<boolean>(false); |
||||||
|
const customData = ref<CustomerVO[]>([]); |
||||||
|
const customTotal = ref<number>(0); |
||||||
|
const options = ref<OptionType[]>([{ label: "客户名称", value: "customName" }]); |
||||||
|
const buttonColSpan = computed(() => { |
||||||
|
return queryForm.value.selectName === undefined ? 18 : 12; |
||||||
|
}); |
||||||
|
const queryCustomer = () => { |
||||||
|
if ( |
||||||
|
queryForm.value.selectName === undefined || |
||||||
|
queryForm.value.selectValue === undefined |
||||||
|
) { |
||||||
|
ElMessage({ |
||||||
|
message: "查询条件不能为空", |
||||||
|
type: "error", |
||||||
|
duration: 1000, |
||||||
|
}); |
||||||
|
return; |
||||||
|
} |
||||||
|
loading.value = true; |
||||||
|
customerPage(queryForm.value) |
||||||
|
.then(({ data }) => { |
||||||
|
customData.value = data.list; |
||||||
|
customTotal.value = data.total; |
||||||
|
}) |
||||||
|
.finally(() => { |
||||||
|
loading.value = false; |
||||||
|
}); |
||||||
|
}; |
||||||
|
const currentCustomerId = ref<number | undefined>(0); |
||||||
|
const handleCustomerChange = (val: CustomerVO) => { |
||||||
|
currentCustomerId.value = val.customId; |
||||||
|
}; |
||||||
|
const bindingCustom = () => { |
||||||
|
if (currentCustomerId.value === 0) { |
||||||
|
ElMessage({ |
||||||
|
message: "请选择一个客户绑定", |
||||||
|
duration: 1000, |
||||||
|
type: "error", |
||||||
|
}); |
||||||
|
return; |
||||||
|
} |
||||||
|
loading.value = true; |
||||||
|
bindingCustomAPI(devId, currentCustomerId.value) |
||||||
|
.then(() => { |
||||||
|
ElMessage({ |
||||||
|
message: "操作成功", |
||||||
|
duration: 1000, |
||||||
|
type: "success", |
||||||
|
}); |
||||||
|
}) |
||||||
|
.finally(() => { |
||||||
|
loading.value = false; |
||||||
|
}); |
||||||
|
}; |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped></style> |
Loading…
Reference in new issue