<template>
|
<el-dialog
|
title="选择结算方式"
|
:visible.sync="dialogVisible"
|
width="80%"
|
:before-close="handleClose"
|
append-to-body
|
>
|
<div class="settle-style-dialog">
|
<!-- 搜索区域 -->
|
<el-card class="search-card">
|
<div slot="header" class="clearfix">
|
<span>查询条件</span>
|
<el-button
|
style="float: right; padding: 3px 0"
|
type="text"
|
@click="toggleCollapse"
|
>
|
{{ collapse ? '展开' : '收起' }}
|
</el-button>
|
</div>
|
|
<el-form :model="queryParams" ref="queryForm" :inline="true">
|
<el-row :gutter="20">
|
<el-col :span="6">
|
<el-form-item label="代码">
|
<el-input
|
v-model="queryParams.HNumber"
|
placeholder="请输入代码"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="6">
|
<el-form-item label="名称">
|
<el-input
|
v-model="queryParams.HName"
|
placeholder="请输入名称"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="6">
|
<el-form-item label="结算方式代码">
|
<el-input
|
v-model="queryParams.HNumber2"
|
placeholder="请输入结算方式代码"
|
clearable
|
style="width: 190px"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="6">
|
<el-form-item>
|
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
|
<el-button type="primary" @click="handleResCnz" style="margin-left: 10px">重新同步</el-button>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<!-- 高级搜索 -->
|
<el-collapse-transition>
|
<div v-show="!collapse">
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="过滤字段">
|
<el-select v-model="queryParams.ColName" placeholder="请选择字段" style="width: 100%">
|
<el-option value="0" label=""></el-option>
|
<el-option
|
v-for="column in visibleColumns"
|
:key="column.field"
|
:label="column.label"
|
:value="column.field"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="比较符">
|
<el-select v-model="queryParams.Comparator" placeholder="请选择比较符" style="width: 100%">
|
<el-option value="0" label=""></el-option>
|
<el-option label="=" value="=" />
|
<el-option label=">=" value=">=" />
|
<el-option label=">" value=">" />
|
<el-option label="<=" value="<=" />
|
<el-option label="<" value="<" />
|
<el-option label="<>" value="<>" />
|
<el-option label="包含" value="7" />
|
<el-option label="左包含" value="8" />
|
<el-option label="右包含" value="9" />
|
<el-option label="不包含" value="10" />
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="内容">
|
<el-input
|
v-model="queryParams.ColContent"
|
placeholder="请输入内容"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
</el-collapse-transition>
|
|
<!-- 当前过滤方案显示 -->
|
<div v-if="currentFilterScheme" class="filter-scheme">
|
{{ currentFilterScheme }}
|
</div>
|
</el-form>
|
</el-card>
|
|
<!-- 表格区域 -->
|
<el-card class="table-card">
|
<div slot="header" class="clearfix">
|
<span>结算方式列表</span>
|
<el-button-group style="float: right">
|
<el-button type="primary" icon="el-icon-refresh" @click="handleRefresh">刷新</el-button>
|
<el-button type="primary" icon="el-icon-close" @click="handleExit">退出</el-button>
|
</el-button-group>
|
</div>
|
|
<el-table
|
ref="table"
|
:data="tableData"
|
v-loading="loading"
|
height="400"
|
border
|
highlight-current-row
|
@row-dblclick="handleRowDblClick"
|
@row-click="handleRowClick"
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column
|
v-for="column in tableColumns"
|
:key="column.field"
|
:prop="column.field"
|
:label="column.label"
|
:width="column.width"
|
:align="column.align"
|
:sortable="column.sortable"
|
show-overflow-tooltip
|
>
|
<template slot-scope="{ row, column }">
|
<span v-if="column.property.includes('时间') || column.property.includes('日期')">
|
{{ formatDate(row[column.property]) }}
|
</span>
|
<span v-else>{{ row[column.property] }}</span>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 分页 -->
|
<el-pagination
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
:current-page="pagination.page"
|
:page-sizes="[50, 100, 500, 5000]"
|
:page-size="pagination.size"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="pagination.total"
|
style="margin-top: 15px; text-align: right;"
|
/>
|
</el-card>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import axios from 'axios'
|
|
export default {
|
name: 'SettleStyleDialog',
|
props: {
|
visible: {
|
type: Boolean,
|
default: false
|
}
|
},
|
data() {
|
return {
|
dialogVisible: false,
|
collapse: false,
|
loading: false,
|
|
// 查询参数
|
queryParams: {
|
HNumber: '',
|
HName: '',
|
HNumber2: '',
|
ColName: '0',
|
Comparator: '0',
|
ColContent: ''
|
},
|
|
// 表格数据
|
tableData: [],
|
tableColumns: [],
|
selectedRow: null,
|
multipleSelection: [],
|
|
// 分页
|
pagination: {
|
page: 1,
|
size: 50,
|
total: 0
|
},
|
|
// 过滤方案
|
currentFilterScheme: '',
|
HInterID_Choose: 0,
|
|
// 隐藏字段
|
hiddenFields: ["HItemID", "HUSEORGID", "HCREATEORGID", "父级ID"],
|
|
baseURL: process.env.VUE_APP_BASE_API || 'http://47.96.97.237/API/',
|
user: 'admin',
|
HModName: 'Gy_SettleStyle',
|
HModuleName: '结算方式维护',
|
Organization: '100038'
|
}
|
},
|
computed: {
|
visibleColumns() {
|
return this.tableColumns
|
.filter(col => !this.hiddenFields.includes(col.field))
|
.map(col => ({
|
field: col.field,
|
label: col.label
|
}))
|
}
|
},
|
watch: {
|
visible: {
|
immediate: true,
|
handler(val) {
|
this.dialogVisible = val
|
if (val) {
|
this.initData()
|
}
|
}
|
},
|
dialogVisible(val) {
|
this.$emit('update:visible', val)
|
}
|
},
|
methods: {
|
// 初始化数据
|
initData() {
|
this.loadTableData()
|
this.getDefaultFilterScheme()
|
},
|
|
// 加载表格数据
|
async loadTableData() {
|
this.loading = true
|
try {
|
const sWhere = this.buildQueryCondition()
|
|
const response = await axios.get(`${this.baseURL}/Gy_SettleStyle/SettleStyleList`, {
|
params: {
|
sWhere: sWhere,
|
user: this.user,
|
Organization: this.Organization
|
}
|
})
|
|
if (response.data.count === 1) {
|
this.tableData = response.data.data
|
console.log('结算方式数据:', this.tableData)
|
this.pagination.total = response.data.total || response.data.data.length
|
this.generateTableColumns(response.data.list)
|
} else {
|
this.$message.error(response.data.Message || '加载数据失败')
|
}
|
} catch (error) {
|
console.error('加载结算方式数据失败:', error)
|
this.$message.error('加载结算方式数据失败')
|
} finally {
|
this.loading = false
|
}
|
},
|
|
// 构建查询条件
|
buildQueryCondition() {
|
let sWhere = ""
|
|
// 基本查询条件
|
if (this.queryParams.HNumber) {
|
sWhere += ` and 结算方式代码 like '%${this.queryParams.HNumber}%'`
|
}
|
if (this.queryParams.HName) {
|
sWhere += ` and 结算方式名称 like '%${this.queryParams.HName}%'`
|
}
|
|
// 高级过滤条件
|
if (this.queryParams.ColName && this.queryParams.ColName !== "0" &&
|
this.queryParams.Comparator && this.queryParams.Comparator !== "0") {
|
let com = ""
|
switch (this.queryParams.Comparator) {
|
case "7":
|
com = `like '%${this.queryParams.ColContent}%'`
|
break
|
case "8":
|
com = `like '%${this.queryParams.ColContent}'`
|
break
|
case "9":
|
com = `like '${this.queryParams.ColContent}%'`
|
break
|
case "10":
|
com = `not like '%${this.queryParams.ColContent}%'`
|
break
|
default:
|
com = `${this.queryParams.Comparator} '${this.queryParams.ColContent}'`
|
break
|
}
|
sWhere += ` and ${this.queryParams.ColName} ${com}`
|
}
|
|
// 添加打开类型的过滤条件
|
sWhere += this.addSWhereByOpenType()
|
|
return sWhere
|
},
|
|
// 根据打开类型添加条件
|
addSWhereByOpenType() {
|
// 这里可以根据需要添加特定的过滤条件
|
return " and 禁用标记 = ''"
|
},
|
|
// 生成表格列
|
generateTableColumns(columnList) {
|
this.tableColumns = []
|
|
// 添加选择列
|
this.tableColumns.push({ type: 'selection', fixed: 'left' })
|
|
// 动态生成列
|
if (columnList && columnList.length > 0) {
|
columnList.forEach(item => {
|
if (!this.hiddenFields.includes(item.ColmCols)) {
|
const column = {
|
field: item.ColmCols,
|
label: item.ColmCols,
|
align: 'center',
|
sortable: true,
|
width: 200
|
}
|
|
// 根据字段类型设置不同的模板
|
if (item.ColmType === 'DateTime') {
|
column.formatter = this.formatDate
|
}
|
|
this.tableColumns.push(column)
|
}
|
})
|
} else {
|
// 默认列(如果接口没有返回列信息)
|
const defaultColumns = [
|
{ field: '结算方式代码', label: '结算方式代码', align: 'center', width: 120 },
|
{ field: '结算方式名称', label: '结算方式名称', align: 'center', width: 120 },
|
{ field: '条码编号', label: '条码编号', align: 'center', width: 120 },
|
{ field: '禁用标记', label: '禁用标记', align: 'center', width: 100 },
|
{ field: '备注', label: '备注', align: 'center', width: 150 },
|
{ field: '审核人', label: '审核人', align: 'center', width: 100 },
|
{ field: '创建人', label: '创建人', align: 'center', width: 100 },
|
{ field: '创建时间', label: '创建时间', align: 'center', width: 150 }
|
]
|
this.tableColumns = [...this.tableColumns, ...defaultColumns]
|
}
|
},
|
|
// 查询
|
handleQuery() {
|
this.pagination.page = 1
|
this.loadTableData()
|
},
|
|
// 重置查询
|
handleReset() {
|
this.queryParams = {
|
HNumber: '',
|
HName: '',
|
HNumber2: '',
|
ColName: '0',
|
Comparator: '0',
|
ColContent: ''
|
}
|
this.pagination.page = 1
|
this.loadTableData()
|
},
|
|
// 重新同步
|
async handleResCnz() {
|
if (!this.queryParams.HNumber2) {
|
this.$message.warning('请输入结算方式代码')
|
return
|
}
|
|
try {
|
const response = await axios.get(`${this.baseURL}/Gy_SettleStyle/Gy_SettleStyleViewApi`, {
|
params: {
|
Number: this.queryParams.HNumber2,
|
Type: 'JSFS'
|
}
|
})
|
|
if (response.data.count === 1) {
|
this.$message.success(response.data.Message)
|
this.loadTableData() // 重新加载数据
|
} else {
|
this.$message.error(response.data.Message)
|
}
|
} catch (error) {
|
console.error('重新同步失败:', error)
|
this.$message.error('重新同步失败')
|
}
|
},
|
|
// 刷新
|
handleRefresh() {
|
this.loadTableData()
|
},
|
|
// 切换折叠状态
|
toggleCollapse() {
|
this.collapse = !this.collapse
|
},
|
|
// 行双击事件
|
handleRowDblClick(row) {
|
this.selectedRow = row
|
this.confirmSelection()
|
},
|
|
// 行点击事件
|
handleRowClick(row) {
|
this.$refs.table.toggleRowSelection(row)
|
this.selectedRow = row
|
},
|
|
// 选择变化
|
handleSelectionChange(selection) {
|
this.multipleSelection = selection
|
if (selection.length === 1) {
|
this.selectedRow = selection[0]
|
}
|
},
|
|
// 确认选择
|
confirmSelection() {
|
if (this.selectedRow) {
|
this.$emit('selected', {
|
HItemID: this.selectedRow.HItemID,
|
结算方式名称: this.selectedRow.结算方式名称
|
})
|
this.dialogVisible = false
|
} else {
|
this.$message.warning('请选择一条数据')
|
}
|
},
|
|
// 退出
|
handleExit() {
|
this.dialogVisible = false
|
},
|
|
// 关闭对话框
|
handleClose(done) {
|
this.$confirm('确认关闭?')
|
.then(_ => {
|
done()
|
})
|
.catch(_ => {})
|
},
|
|
// 分页大小改变
|
handleSizeChange(size) {
|
this.pagination.size = size
|
this.pagination.page = 1
|
this.loadTableData()
|
},
|
|
// 当前页改变
|
handleCurrentChange(page) {
|
this.pagination.page = page
|
this.loadTableData()
|
},
|
|
// 格式化日期
|
formatDate(dateString) {
|
if (!dateString) return ''
|
try {
|
const date = new Date(dateString)
|
return date.toLocaleDateString('zh-CN')
|
} catch (error) {
|
return dateString
|
}
|
},
|
|
// 获取默认过滤方案
|
async getDefaultFilterScheme() {
|
try {
|
const response = await axios.get(`${this.baseURL}/Xt_FastICScheme/Chooselist`, {
|
params: {
|
user: this.user,
|
HModuleName: this.HModuleName,
|
HInterID: 0,
|
Type: "Default"
|
}
|
})
|
|
if (response.data.count === 1) {
|
const data = response.data.data[0]
|
this.HInterID_Choose = data.hmainid
|
this.currentFilterScheme = `当前过滤方案:${data.方案名称} (${data.备注})`
|
|
// 应用过滤条件
|
this.applyFilterConditions(response.data.data)
|
}
|
} catch (error) {
|
console.error('获取过滤方案失败:', error)
|
}
|
},
|
|
// 应用过滤条件
|
applyFilterConditions(filterData) {
|
filterData.forEach(item => {
|
if (this.queryParams.hasOwnProperty(item.过滤字段ID)) {
|
this.queryParams[item.过滤字段ID] = item.过滤值
|
}
|
})
|
},
|
|
// 保存过滤方案
|
handleSaveScheme() {
|
this.$message.info('保存方案功能')
|
},
|
|
// 读取过滤方案
|
handleReadScheme() {
|
this.$message.info('读取方案功能')
|
},
|
|
// 列设置
|
handleColumnSetting() {
|
this.$message.info('列设置功能')
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.settle-style-dialog {
|
height: 70vh;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.search-card {
|
margin-bottom: 15px;
|
}
|
|
.table-card {
|
flex: 1;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.table-card >>> .el-card__body {
|
flex: 1;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.clearfix:before,
|
.clearfix:after {
|
display: table;
|
content: "";
|
}
|
.clearfix:after {
|
clear: both;
|
}
|
|
.el-form-item {
|
margin-bottom: 15px;
|
}
|
|
.el-table {
|
flex: 1;
|
}
|
|
.filter-scheme {
|
text-align: center;
|
font-size: 15px;
|
font-weight: bold;
|
color: #fc9393;
|
margin: 10px 0;
|
}
|
</style>
|