<template>
|
<div>
|
<!-- 列表页面 -->
|
|
<div class="page-container" v-if="showEdit == 0">
|
<!-- 查询条件 -->
|
<div class="search-section">
|
<el-form :inline="true" :model="queryForm" label-width="auto">
|
<el-form-item label="关键字">
|
<el-input
|
v-model="queryForm.keyword"
|
placeholder="姓名/性别/电话/公司/地址/邮箱/职务/备注"
|
clearable
|
style="width: 300px"
|
/>
|
</el-form-item>
|
|
<el-form-item>
|
<el-button type="primary" @click="search">查询</el-button>
|
<el-button type="primary" @click="add">新增</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
<!-- 表格 -->
|
<div class="table-section">
|
<!-- <el-table :data="tableData" v-loading="loading" style="width: 100%"
|
:row-class-name="rowClassName"
|
fit>
|
<el-table-column type="index" :index="indexMethod" label="序号" fixed="left" width="60px"></el-table-column>
|
|
<el-table-column v-for="column in tableColumns"
|
:key="column.prop"
|
:prop="column.prop"
|
:label="column.label"
|
:min-width="column.minWidth"
|
>
|
|
</el-table-column> -->
|
<el-table :data="tableData" v-loading="loading" style="width: 100%" :row-class-name="rowClassName" fit>
|
<el-table-column prop="company_name" label="供应商名称"></el-table-column>
|
<el-table-column prop="name" label="联系人"></el-table-column>
|
<el-table-column prop="contact" label="联系方式">
|
<template #default="scope"> {{ scope.row.phone }} {{ scope.row.email_address }} </template>
|
</el-table-column>
|
<el-table-column prop="project_names" label="参与的项目"></el-table-column>
|
<el-table-column prop="skill_names" label="擅长"></el-table-column>
|
|
<el-table-column label="操作栏" fixed="right" width="200px">
|
<template #default="scope">
|
<el-button type="text" size="small" round @click="handleEdit(scope.row)">编辑</el-button>
|
<el-button type="text" size="small" round @click="handleDelete(scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<div class="demo-pagination-block">
|
<!-- <div class="demonstration">All combined</div> -->
|
<el-pagination
|
v-model:current-page="currentPage"
|
v-model:page-size="pageSize"
|
:page-sizes="[10, 20, 30]"
|
:small="small"
|
:disabled="disabled"
|
:background="background"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="totalSize"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
/>
|
</div>
|
</div>
|
</div>
|
|
<!-- 编辑页面 -->
|
|
<contact-add v-if="showEdit == 1" :editId="editId" @editClose="editClose"></contact-add>
|
</div>
|
</template>
|
|
<script>
|
import { ref, reactive, onMounted } from 'vue'
|
import { ElMessageBox, ElMessage } from 'element-plus'
|
|
import sysDictItemModel from '@/model/sysDictItem'
|
import ContactInfo from '@/model/supplierContactInfo'
|
import contactAdd from '@/view/supplier/supplierContact/supplier-contact-add'
|
|
import { getDefaultDate, getYesterdayDate, getStartAndEndOfWeek, getPreviousWeekDates } from '@/utils/dateUtils'
|
|
export default {
|
components: {
|
contactAdd,
|
},
|
|
setup() {
|
const editId = ref(1)
|
|
const showEdit = ref(0)
|
|
const loading = ref(false)
|
|
const currentPage = ref(1)
|
const pageSize = ref(10)
|
const totalSize = ref(100)
|
|
const dailyTypeArr = ref([])
|
|
const queryForm = reactive({
|
keyword: '',
|
page: 1,
|
count: 10,
|
})
|
|
const tableColumns = ref([
|
{ label: '供应商名称', prop: 'company_name', minWidth: '120px', width: '' },
|
{ label: '联系人', prop: 'name', minWidth: '100px', width: '' },
|
{ label: '职务/角色', prop: 'title', minWidth: '120px', width: '' },
|
{ label: '性别', prop: 'sex_name', minWidth: '80px', width: '' },
|
{ label: '电话', prop: 'phone', minWidth: '100px', width: '' },
|
{ label: '邮箱', prop: 'email_address', minWidth: '100px', width: '' },
|
{ label: '地址', prop: 'address', minWidth: '260px', width: '' },
|
{ label: '关联项目', prop: 'project_list', minWidth: '200px', width: '' },
|
{ label: '备注', prop: 'remark', minWidth: '100px', width: '' },
|
// 其他列信息
|
])
|
|
const resultPage = ref({})
|
|
const tableData = ref([])
|
|
onMounted(() => {
|
// 列出所有项目信息
|
getPageList()
|
loadDictDitems()
|
})
|
|
const getPageList = async () => {
|
try {
|
queryForm.page = currentPage.value
|
queryForm.count = pageSize.value
|
|
loading.value = true
|
resultPage.value = await ContactInfo.getContactInfoPage(queryForm)
|
tableData.value = resultPage.value.items
|
totalSize.value = resultPage.value.total
|
|
currentPage.value = resultPage.value.page
|
pageSize.value = resultPage.value.count
|
|
loading.value = false
|
} catch (error) {
|
loading.value = false
|
if (error.code === 10020) {
|
tableData.value = []
|
}
|
}
|
}
|
|
const search = () => {
|
getPageList()
|
}
|
|
// 根据字典类型查询字典
|
const loadDictDitems = async () => {
|
dailyTypeArr.value = await sysDictItemModel.getSysDictItemListByType('daily_type')
|
}
|
|
const handleEdit = row => {
|
// 编辑操作
|
editId.value = row.id
|
showEdit.value = 1
|
}
|
|
const handleDelete = row => {
|
// 删除操作
|
ElMessageBox.confirm('此操作将永久删除该记录 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning',
|
})
|
.then(async () => {
|
const res = await ContactInfo.deleteContactInfo(row.id)
|
if (res.code < window.MAX_SUCCESS_CODE) {
|
getPageList()
|
ElMessage.success(`${res.message}`)
|
}
|
})
|
.catch(() => {
|
// 用户点击取消按钮时执行的操作
|
// 可以选择不做任何事情,也可以显示取消消息
|
// ElMessage.info('操作已取消'); // 如果需要显示取消消息,可以取消注释
|
})
|
}
|
|
const handleSizeChange = val => {
|
pageSize.value = val
|
getPageList()
|
}
|
|
const handleCurrentChange = val => {
|
currentPage.value = val
|
getPageList()
|
}
|
|
const indexMethod = index => (currentPage.value - 1) * pageSize.value + index + 1
|
|
// 子控部分
|
|
const add = () => {
|
editId.value = ''
|
showEdit.value = 1
|
}
|
|
const editClose = () => {
|
showEdit.value = 0
|
loadDictDitems()
|
getPageList()
|
}
|
|
return {
|
loading,
|
|
dailyTypeArr,
|
|
queryForm,
|
tableData,
|
tableColumns,
|
search,
|
handleEdit,
|
handleDelete,
|
|
indexMethod,
|
currentPage,
|
pageSize,
|
totalSize,
|
|
handleSizeChange,
|
handleCurrentChange,
|
|
showEdit,
|
editId,
|
editClose,
|
add,
|
}
|
},
|
}
|
</script>
|
|
<style scoped>
|
.demo-form-inline .el-input {
|
--el-input-width: 220px;
|
}
|
|
.page-container {
|
padding: 10px;
|
}
|
|
.search-section {
|
margin-bottom: 10px;
|
padding: 20px;
|
/* background-color: #f5f5f5; */
|
border-radius: 4px;
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
}
|
|
.table-section {
|
padding: 20px;
|
background-color: #fff;
|
border-radius: 4px;
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
}
|
.demo-pagination-block {
|
margin-top: 10px;
|
}
|
.demo-pagination-block .demonstration {
|
margin-bottom: 16px;
|
}
|
</style>
|
|
<style>
|
.supplementary-row {
|
background-color: rgb(215, 218, 50) !important;
|
width: 100%;
|
}
|
|
.no-supplementary-row {
|
background-color: #f8f9fa !important;
|
}
|
</style>
|