Files
BMS/bms-front/src/views/customersuppliermanagement/supplierinfo/index.vue
T

479 lines
21 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="关键词" prop="keywords">
<el-input
v-model="queryParams.keywords"
type="textarea"
:autosize="{ minRows: 1, maxRows: 4 }"
placeholder="供应商编码/供应商名称/对外代码,一行一个,模糊查询(多行为或者关系)"
clearable
style="width: 340px;"
@keyup.enter.ctrl="handleQuery"
/>
</el-form-item>
<el-form-item label="供应商类型" prop="supplierType">
<el-select
v-model="queryParams.supplierType"
placeholder="请选择供应商类型"
clearable
@change="handleQuery"
>
<el-option v-for="item in supplierTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="开票类型" prop="invoiceType">
<el-select
v-model="queryParams.invoiceType"
placeholder="请选择开票类型"
clearable
@change="handleQuery"
>
<el-option v-for="item in invoiceTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="卡车行类型" prop="kacheType">
<el-select
v-model="queryParams.kacheType"
placeholder="请选择卡车行类型"
clearable
@change="handleQuery"
>
<el-option v-for="item in kacheTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="启用状态" prop="isEnable">
<el-select
v-model="queryParams.isEnable"
placeholder="请选择启用状态"
clearable
@change="handleQuery"
>
<el-option label="正常" value="0" />
<el-option label="停用" value="1" />
</el-select>
</el-form-item>
<el-form-item label="采购员" prop="purchaserUserId">
<user-select v-model="queryParams.purchaserUserId" placeholder="请选择采购员" @change="handleQuery" />
</el-form-item>
<el-form-item label="结算员" prop="settlementUserId">
<user-select v-model="queryParams.settlementUserId" placeholder="请选择结算员" @change="handleQuery" />
</el-form-item>
<el-form-item label="跟单员" prop="serviceUserId">
<user-select v-model="queryParams.serviceUserId" placeholder="请选择跟单员" @change="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['customersupplier:supplierinfo:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['customersupplier:supplierinfo:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['customersupplier:supplierinfo:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['customersupplier:supplierinfo:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
<column-settings :columns="columnDefs" :visible-map="colVisible" @toggle="toggleColumn" @reset="resetColumns" />
</el-row>
<el-table v-loading="loading" border :data="supplierList"
@selection-change="handleSelectionChange"
@row-contextmenu="onTableRowContextmenu">
<el-table-column type="selection" width="55" align="center" fixed="left" />
<el-table-column v-if="isColVisible('supplierCode')" label="供应商编码" align="center" width="130" prop="supplierCode" />
<el-table-column v-if="isColVisible('supplierName')" label="供应商名称" align="center" width="130" prop="supplierName" :show-overflow-tooltip="true" />
<el-table-column v-if="isColVisible('supplierCodeDw')" label="对外代码" align="center" width="130" prop="supplierCodeDw" />
<el-table-column v-if="isColVisible('creditCode')" label="统一社会信用代码" align="center" prop="creditCode" />
<el-table-column v-if="isColVisible('supplierType')" label="供应商类型" align="center" width="120" prop="supplierType">
<template #default="scope">{{ formatOption(supplierTypeOptions, scope.row.supplierType) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('invoiceType')" label="开票类型" align="center" prop="invoiceType">
<template #default="scope">{{ formatOption(invoiceTypeOptions, scope.row.invoiceType) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('kacheType')" label="卡车行类型" align="center" prop="kacheType">
<template #default="scope">{{ formatOption(kacheTypeOptions, scope.row.kacheType) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('isEnable')" label="启用状态" align="center" prop="isEnable">
<template #default="scope">
<dict-tag :options="sys_normal_disable" :value="scope.row.isEnable" />
</template>
</el-table-column>
<el-table-column v-if="isColVisible('purchaserUserId')" label="采购员" align="center" prop="purchaserUserId">
<template #default="scope"><user-name :user-id="scope.row.purchaserUserId" /></template>
</el-table-column>
<el-table-column v-if="isColVisible('ed')" label="应付额度" align="center" prop="ed" />
<el-table-column v-if="isColVisible('zq')" label="应付账期" align="center" prop="zq" />
<el-table-column v-if="isColVisible('settlementUserId')" label="结算员" align="center" prop="settlementUserId">
<template #default="scope"><user-name :user-id="scope.row.settlementUserId" /></template>
</el-table-column>
<el-table-column v-if="isColVisible('serviceUserId')" label="跟单员" align="center" prop="serviceUserId">
<template #default="scope"><user-name :user-id="scope.row.serviceUserId" /></template>
</el-table-column>
<el-table-column v-if="isColVisible('settlementType')" label="结算方式" align="center" prop="settlementType">
<template #default="scope">
<dict-tag :options="settlement_type" :value="scope.row.settlementType" />
</template>
</el-table-column>
<el-table-column v-if="isColVisible('tempEd')" label="临时额度" align="center" prop="tempEd" />
<el-table-column v-if="isColVisible('accountBalance')" label="应付余额" align="center" prop="accountBalance" />
<el-table-column v-if="isColVisible('foreignCurrencyBalance')" label="外币应付余额" align="center" prop="foreignCurrencyBalance" />
<el-table-column v-if="isColVisible('creditEd')" label="信用额度" align="center" prop="creditEd" />
<el-table-column v-if="isColVisible('weightThreshold')" label="重量阈值" align="center" prop="weightThreshold" />
<el-table-column v-if="isColVisible('throwRatio')" label="抛比" align="center" prop="throwRatio" />
<el-table-column v-if="isColVisible('cooperationStartDate')" label="合作开始日期" align="center" prop="cooperationStartDate">
<template #default="scope">{{ formatDateOnly(scope.row.cooperationStartDate) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('contractEndDate')" label="合同结束时间" align="center" prop="contractEndDate" width="120">
<template #default="scope">{{ formatDateOnly(scope.row.contractEndDate) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('cooperationStatus')" label="合作状态" align="center" prop="cooperationStatus">
<template #default="scope">{{ formatOption(cooperationStatusOptions, scope.row.cooperationStatus) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('dataSource')" label="数据来源" align="center" prop="dataSource" width="110">
<template #default="scope">
<dict-tag v-if="scope.row.dataSource" :options="bms_supplier_data_source" :value="scope.row.dataSource" />
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column v-if="isColVisible('channelIds')" label="绑定渠道" align="center" prop="channelIds" min-width="200" show-overflow-tooltip>
<template #default="scope">
<span v-if="channelNames(scope.row.channelIds)">{{ channelNames(scope.row.channelIds) }}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column v-if="isColVisible('remark')" label="备注说明" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="270" fixed="right">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['customersupplier:supplierinfo:edit']">修改</el-button>
<el-button link type="primary" icon="Connection" @click="openBind(scope.row)" v-hasPermi="['customersupplier:supplierinfo:bindChannel']">绑定渠道</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['customersupplier:supplierinfo:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<channel-select ref="channelSelectRef" v-model="bindChannelIds" :show-trigger="false" @change="saveBind" />
<!-- 右键复制列值 -->
<table-copy-menu
ref="copyMenuRef"
:columns="copyColumns"
:selected-rows="selectedRows"
:visible-keys="visibleCopyKeys"
/>
</div>
</template>
<script setup name="Supplier">
import { bindSupplierChannels, listSupplier, delSupplier } from "@/api/customersuppliermanagement/supplierinfo/supplier.js"
import { useChannels, parseChannelCodes } from '@/components/ChannelSelect/useChannels'
import { useUsers } from '@/components/UserSelect/useUsers'
import { useColumnSettings } from '@/utils/columnSettings'
const { proxy } = getCurrentInstance()
/** 绑定渠道编码串 -> 渠道编码+名称展示(查不到的渠道回显原编码) */
const { ensureChannels, getChannelLabel } = useChannels()
function channelNames(channelIds) {
return parseChannelCodes(channelIds).map(code => getChannelLabel(code)).join(',')
}
ensureChannels()
/** 可自定义列(默认全部可见;选择列固定、操作列固定右侧不参与设置) */
const columnDefs = [
{ key: 'supplierCode', label: '供应商编码' },
{ key: 'supplierName', label: '供应商名称' },
{ key: 'supplierCodeDw', label: '对外代码' },
{ key: 'creditCode', label: '统一社会信用代码' },
{ key: 'supplierType', label: '供应商类型' },
{ key: 'invoiceType', label: '开票类型' },
{ key: 'kacheType', label: '卡车行类型' },
{ key: 'isEnable', label: '启用状态' },
{ key: 'purchaserUserId', label: '采购员' },
{ key: 'ed', label: '应付额度' },
{ key: 'zq', label: '应付账期' },
{ key: 'settlementUserId', label: '结算员' },
{ key: 'serviceUserId', label: '跟单员' },
{ key: 'settlementType', label: '结算方式' },
{ key: 'tempEd', label: '临时额度' },
{ key: 'accountBalance', label: '应付余额' },
{ key: 'foreignCurrencyBalance', label: '外币应付余额' },
{ key: 'creditEd', label: '信用额度' },
{ key: 'weightThreshold', label: '重量阈值' },
{ key: 'throwRatio', label: '抛比' },
{ key: 'cooperationStartDate', label: '合作开始日期' },
{ key: 'contractEndDate', label: '合同结束时间' },
{ key: 'cooperationStatus', label: '合作状态' },
{ key: 'dataSource', label: '数据来源' },
{ key: 'channelIds', label: '绑定渠道' },
{ key: 'remark', label: '备注说明' }
]
const { colVisible, isColVisible, toggleColumn, resetColumns } = useColumnSettings('supplier-info-list', columnDefs)
const supplierList = ref([])
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const { sys_normal_disable, settlement_type, bms_supplier_type: supplierTypeOptions, bms_supplier_data_source } = useDict("sys_normal_disable", "settlement_type", "bms_supplier_type", "bms_supplier_data_source")
const invoiceTypeOptions = ref([
{ value: "1", label: "增值税普通发票" },
{ value: "2", label: "增值税专用发票" },
{ value: "3", label: "增值税电子普通发票" },
{ value: "4", label: "其他普通发票" }
])
const kacheTypeOptions = ref([
{ value: "0", label: "国内" },
{ value: "1", label: "国外" }
])
const cooperationStatusOptions = ref([
{ value: "0", label: "正常" },
{ value: "1", label: "暂停" },
{ value: "2", label: "终止" }
])
function formatOption(options, value) {
if (value === null || value === undefined || value === '') return ''
const opt = options.find(o => String(o.value) === String(value))
return opt ? opt.label : value
}
function formatDateOnly(value) {
if (!value) return ''
const s = String(value)
return s.length > 10 ? s.substring(0, 10) : s
}
/** 员工ID -> 姓名(与表格 UserName 展示同源) */
const { ensureUsers, getUserName } = useUsers()
ensureUsers()
/* ================= 右键复制列值 ================= */
const copyMenuRef = ref(null)
/** 右键可复制列(取值口径与表格展示一致) */
const copyColumns = computed(() => [
{ key: 'supplierCode', label: '供应商编码', get: r => r.supplierCode || '' },
{ key: 'supplierName', label: '供应商名称', get: r => r.supplierName || '' },
{ key: 'supplierCodeDw', label: '对外代码', get: r => r.supplierCodeDw || '' },
{ key: 'creditCode', label: '统一社会信用代码', get: r => r.creditCode || '' },
{ key: 'supplierType', label: '供应商类型', get: r => formatOption(supplierTypeOptions.value, r.supplierType) },
{ key: 'invoiceType', label: '开票类型', get: r => formatOption(invoiceTypeOptions.value, r.invoiceType) },
{ key: 'kacheType', label: '卡车行类型', get: r => formatOption(kacheTypeOptions.value, r.kacheType) },
{ key: 'isEnable', label: '启用状态', get: r => proxy.selectDictLabel(sys_normal_disable.value, r.isEnable) },
{ key: 'purchaserUserId', label: '采购员', get: r => getUserName(r.purchaserUserId) },
{ key: 'ed', label: '应付额度', get: r => (r.ed === null || r.ed === undefined ? '' : r.ed) },
{ key: 'zq', label: '应付账期', get: r => (r.zq === null || r.zq === undefined ? '' : r.zq) },
{ key: 'settlementUserId', label: '结算员', get: r => getUserName(r.settlementUserId) },
{ key: 'serviceUserId', label: '跟单员', get: r => getUserName(r.serviceUserId) },
{ key: 'settlementType', label: '结算方式', get: r => proxy.selectDictLabel(settlement_type.value, r.settlementType) },
{ key: 'tempEd', label: '临时额度', get: r => (r.tempEd === null || r.tempEd === undefined ? '' : r.tempEd) },
{ key: 'accountBalance', label: '应付余额', get: r => (r.accountBalance === null || r.accountBalance === undefined ? '' : r.accountBalance) },
{ key: 'foreignCurrencyBalance', label: '外币应付余额', get: r => (r.foreignCurrencyBalance === null || r.foreignCurrencyBalance === undefined ? '' : r.foreignCurrencyBalance) },
{ key: 'creditEd', label: '信用额度', get: r => (r.creditEd === null || r.creditEd === undefined ? '' : r.creditEd) },
{ key: 'weightThreshold', label: '重量阈值', get: r => (r.weightThreshold === null || r.weightThreshold === undefined ? '' : r.weightThreshold) },
{ key: 'throwRatio', label: '抛比', get: r => (r.throwRatio === null || r.throwRatio === undefined ? '' : r.throwRatio) },
{ key: 'cooperationStartDate', label: '合作开始日期', get: r => formatDateOnly(r.cooperationStartDate) },
{ key: 'contractEndDate', label: '合同结束时间', get: r => formatDateOnly(r.contractEndDate) },
{ key: 'cooperationStatus', label: '合作状态', get: r => formatOption(cooperationStatusOptions.value, r.cooperationStatus) },
{ key: 'dataSource', label: '数据来源', get: r => proxy.selectDictLabel(bms_supplier_data_source.value, r.dataSource) },
{ key: 'channelIds', label: '绑定渠道', get: r => channelNames(r.channelIds) },
{ key: 'remark', label: '备注说明', get: r => r.remark || '' }
])
/** 右键菜单只展示当前「列设置」中可见的列 */
const visibleCopyKeys = computed(() =>
columnDefs.filter(c => isColVisible(c.key)).map(c => c.key)
)
function onTableRowContextmenu(row, column, event) {
copyMenuRef.value && copyMenuRef.value.open(row, event)
}
const data = reactive({
queryParams: {
pageNum: 1,
pageSize: 10,
keywords: undefined,
creditCode: undefined,
supplierType: undefined,
invoiceType: undefined,
kacheType: undefined,
isEnable: undefined,
purchaserUserId: undefined,
purchaserUser: undefined,
ed: undefined,
zq: undefined,
settlementUserId: undefined,
settlementUser: undefined,
serviceUserId: undefined,
serviceUser: undefined,
settlementType: undefined,
tempEd: undefined,
accountBalance: undefined,
foreignCurrencyBalance: undefined,
weightThreshold: undefined,
throwRatio: undefined,
creditEd: undefined,
cooperationStatus: undefined,
channelIds: undefined,
}
})
const { queryParams } = toRefs(data)
/** 查询供应商列表 */
function getList() {
copyMenuRef.value && copyMenuRef.value.close()
loading.value = true
listSupplier(queryParams.value).then(response => {
supplierList.value = response.rows
total.value = response.total
loading.value = false
})
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef")
handleQuery()
}
/** 多选框选中数据 */
const selectedRows = ref([])
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.supplierId)
selectedRows.value = selection
single.value = selection.length != 1
multiple.value = !selection.length
}
/** 新增:跳转供应商编辑页(页签式,无 supplierId) */
function handleAdd() {
proxy.$router.push({ path: '/customersupplier/supplier-edit/index' })
}
/** 修改:跳转供应商编辑页(操作列传 row;工具栏按钮取勾选行) */
function handleUpdate(row) {
const target = (row && row.supplierId) ? row : selectedRows.value[0]
if (!target || !target.supplierId) {
proxy.$modal.msgWarning("请先勾选一个供应商")
return
}
proxy.$router.push({
path: '/customersupplier/supplier-edit/index',
query: {
supplierId: target.supplierId,
supplierName: target.supplierName,
supplierCode: target.supplierCode
}
})
}
const channelSelectRef = ref(null)
const bindRow = ref(null)
const bindChannelIds = ref('')
/** 打开和编辑页相同的选择渠道弹框,确定后只保存这一家的渠道 */
function openBind(row) {
if (!row || !row.supplierId) {
return
}
bindRow.value = row
bindChannelIds.value = row.channelIds || ''
nextTick(() => {
channelSelectRef.value && channelSelectRef.value.open()
})
}
function saveBind() {
const row = bindRow.value
if (!row || !row.supplierId) {
return
}
const channelIds = bindChannelIds.value || ''
bindSupplierChannels(row.supplierId, { channelIds }).then(() => {
proxy.$modal.msgSuccess('渠道已绑定')
getList()
}).catch(() => {
bindChannelIds.value = row.channelIds || ''
})
}
/** 删除按钮操作 */
function handleDelete(row) {
const _supplierIds = row.supplierId || ids.value
proxy.$modal.confirm('是否确认删除供应商编号为"' + _supplierIds + '"的数据项?').then(function() {
return delSupplier(_supplierIds)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('customersupplier/supplierinfo/export', {
...queryParams.value
}, `supplier_${new Date().getTime()}.xlsx`)
}
getList()
</script>