✨ feat: 订单模块优化
This commit is contained in:
@@ -2,34 +2,76 @@
|
||||
<div class="klp-list-container">
|
||||
<!-- 列表加载状态 -->
|
||||
<div v-loading="loading" class="list-loading-wrapper">
|
||||
<!-- 列表项渲染 -->
|
||||
<div
|
||||
v-for="(item, index) in listData"
|
||||
:key="item[listKey] || index"
|
||||
class="klp-list-item"
|
||||
:class="{ 'active': isSelected(item) }"
|
||||
@click.stop="handleItemClick(item)"
|
||||
>
|
||||
<!-- 列表标题区域 - 文字溢出省略+Tooltip -->
|
||||
<div class="klp-list-title">
|
||||
<span class="title-label">{{ titleLabel }}:</span>
|
||||
<el-tooltip
|
||||
:content="item[titleField]"
|
||||
placement="top"
|
||||
:disabled="!isContentOverflow(item)"
|
||||
effect="light"
|
||||
>
|
||||
<span class="title-value">{{ item[titleField] }}</span>
|
||||
<!-- 列表项渲染(分两行布局) -->
|
||||
<div v-for="(item, index) in listData" :key="item[listKey] || index" class="klp-list-item"
|
||||
:class="{ 'active': isSelected(item) }" @click.stop="handleItemClick(item)">
|
||||
<!-- 核心内容区:分两行展示6个信息位 -->
|
||||
<div class="klp-list-content">
|
||||
<!-- 第一行:主标题 + 副标题 + 状态(info1~info3) -->
|
||||
<div class="klp-list-row klp-list-row1" :style="{ gap: `${rowGap}px` }">
|
||||
<!-- 信息位1:主标题(保留原Tooltip溢出检测) -->
|
||||
<div class="klp-list-info-item" v-if="showInfoItem('info1', item)">
|
||||
<slot name="info1" :item="item" :isSelected="isSelected(item)">
|
||||
<span class="info-label" v-if="info1Label">{{ info1Label }}:</span>
|
||||
<el-tooltip :content="item[info1Field]" placement="top" :disabled="!isContentOverflow(item, 'info1')"
|
||||
effect="light">
|
||||
<span class="info-value info-value--primary">{{ item[info1Field] }}</span>
|
||||
</el-tooltip>
|
||||
</slot>
|
||||
</div>
|
||||
|
||||
<!-- 右侧操作按钮组 -->
|
||||
<!-- 信息位2:副标题 -->
|
||||
<div class="klp-list-info-item" v-if="showInfoItem('info2', item)">
|
||||
<slot name="info2" :item="item" :isSelected="isSelected(item)">
|
||||
<span class="info-label" v-if="info2Label">{{ info2Label }}:</span>
|
||||
<span class="info-value">{{ item[info2Field] }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
|
||||
<!-- 信息位3:状态(常用插槽自定义,如标签) -->
|
||||
<div class="klp-list-info-item" v-if="showInfoItem('info3', item)">
|
||||
<slot name="info3" :item="item" :isSelected="isSelected(item)">
|
||||
<span class="info-label" v-if="info3Label">{{ info3Label }}:</span>
|
||||
<span class="info-value">{{ item[info3Field] }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第二行:时间 + 数量 + 备注(info4~info6) -->
|
||||
<div class="klp-list-row klp-list-row2" :style="{ gap: `${rowGap}px`, marginBottom: `${rowMarginBottom}px` }">
|
||||
<!-- 信息位4:时间 -->
|
||||
<div class="klp-list-info-item" v-if="showInfoItem('info4', item)">
|
||||
<slot name="info4" :item="item" :isSelected="isSelected(item)">
|
||||
<span class="info-label" v-if="info4Label">{{ info4Label }}:</span>
|
||||
<span class="info-value">{{ item[info4Field] }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
|
||||
<!-- 信息位5:数量/金额 -->
|
||||
<div class="klp-list-info-item" v-if="showInfoItem('info5', item)">
|
||||
<slot name="info5" :item="item" :isSelected="isSelected(item)">
|
||||
<span class="info-label" v-if="info5Label">{{ info5Label }}:</span>
|
||||
<span class="info-value">{{ item[info5Field] }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
|
||||
<!-- 信息位6:备注 -->
|
||||
<div class="klp-list-info-item" v-if="showInfoItem('info6', item)">
|
||||
<slot name="info6" :item="item" :isSelected="isSelected(item)">
|
||||
<span class="info-label" v-if="info6Label">{{ info6Label }}:</span>
|
||||
<span class="info-value">{{ item[info6Field] }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧操作按钮组(位置不变) -->
|
||||
<div class="klp-list-actions">
|
||||
<slot name="actions" :item="item" :isSelected="isSelected(item)"></slot>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 空状态提示 -->
|
||||
<!-- 空状态提示(不变) -->
|
||||
<div v-if="listData.length === 0 && !loading" class="klp-list-empty">
|
||||
<el-empty description="暂无数据" />
|
||||
</div>
|
||||
@@ -42,33 +84,18 @@ export default {
|
||||
name: "KLPList",
|
||||
components: {},
|
||||
props: {
|
||||
// ---------------------- 原有核心Props(保留) ----------------------
|
||||
/** 列表数据源(必传) */
|
||||
listData: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => []
|
||||
},
|
||||
|
||||
/** 列表项唯一标识字段(必传,如orderId、id) */
|
||||
/** 列表项唯一标识字段(必传) */
|
||||
listKey: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
|
||||
/** 列表标题前置标签(如"订单编号:") */
|
||||
titleLabel: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: "标题"
|
||||
},
|
||||
|
||||
/** 列表项标题对应的字段名(如orderCode、name) */
|
||||
titleField: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: "title"
|
||||
},
|
||||
|
||||
/** 列表加载状态 */
|
||||
loading: {
|
||||
type: Boolean,
|
||||
@@ -76,67 +103,128 @@ export default {
|
||||
default: false
|
||||
},
|
||||
|
||||
/** 标题最大宽度占容器的百分比(0-100),控制文字溢出 */
|
||||
titleMaxPercent: {
|
||||
// ---------------------- 新增:6个信息位配置 ----------------------
|
||||
// 信息位1(主标题,兼容原titleField)
|
||||
info1Field: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: "title" // 默认对应原titleField
|
||||
},
|
||||
info1Label: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: "" // 兼容原titleLabel
|
||||
},
|
||||
// 信息位2(副标题)
|
||||
info2Field: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
info2Label: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
// 信息位3(状态)
|
||||
info3Field: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
info3Label: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
// 信息位4(时间)
|
||||
info4Field: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
info4Label: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
// 信息位5(数量/金额)
|
||||
info5Field: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
info5Label: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
// 信息位6(备注)
|
||||
info6Field: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
info6Label: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
|
||||
// ---------------------- 新增:样式控制Props ----------------------
|
||||
/** 每行内部信息位的间距(px) */
|
||||
rowGap: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 80 // 默认占容器80%宽度
|
||||
default: 16 // 默认间距16px
|
||||
},
|
||||
/** 两行之间的垂直间距(px) */
|
||||
rowMarginBottom: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 4 // 默认4px
|
||||
},
|
||||
/** 主标题最大宽度占内容区的百分比(控制溢出) */
|
||||
info1MaxPercent: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 60 // 主标题占比下调,给其他信息位留空间
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 内部管理选中状态:存储当前选中项的唯一键值(单选中)
|
||||
selectedKey: null,
|
||||
// 文字溢出检测临时元素(避免重复创建)
|
||||
overflowCheckElements: {},
|
||||
// 容器宽度缓存
|
||||
containerWidth: 0
|
||||
selectedKey: null, // 选中状态(不变)
|
||||
overflowCheckElements: {}, // 溢出检测临时元素(不变)
|
||||
containerWidth: 0 // 容器宽度缓存(不变)
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 判断当前列表项是否被选中
|
||||
* @param {Object} item - 列表项数据
|
||||
* @returns {Boolean} 选中状态
|
||||
*/
|
||||
// ---------------------- 原有核心方法(保留+微调) ----------------------
|
||||
/** 判断列表项是否选中(不变) */
|
||||
isSelected(item) {
|
||||
const itemKey = item[this.listKey];
|
||||
return this.selectedKey === itemKey;
|
||||
},
|
||||
|
||||
/**
|
||||
* 列表项点击事件:切换选中状态(单选中逻辑)
|
||||
* @param {Object} item - 点击的列表项数据
|
||||
*/
|
||||
/** 列表项点击事件(不变) */
|
||||
handleItemClick(item) {
|
||||
const itemKey = item[this.listKey];
|
||||
// 单选中逻辑:点击已选中项取消选中,点击未选中项切换选中(取消其他项)
|
||||
// this.selectedKey = this.selectedKey === itemKey ? null : itemKey;
|
||||
this.selectedKey = itemKey;
|
||||
|
||||
// 向父组件触发事件:传递当前选中项(null表示无选中)
|
||||
const selectedItem = this.selectedKey ? item : null;
|
||||
this.$emit("item-click", selectedItem, item);
|
||||
},
|
||||
|
||||
/**
|
||||
* 清空选中状态(支持父组件通过ref调用)
|
||||
*/
|
||||
/** 清空选中状态(不变) */
|
||||
clearSelection() {
|
||||
this.selectedKey = null;
|
||||
// 触发清空选中事件
|
||||
this.$emit("selection-cleared");
|
||||
},
|
||||
|
||||
/**
|
||||
* 主动设置选中项(支持父组件通过ref调用)
|
||||
* @param {String/Number} targetKey - 要选中项的唯一键值
|
||||
*/
|
||||
/** 主动设置选中项(不变) */
|
||||
setSelection(targetKey) {
|
||||
const isExist = this.listData.some(item => item[this.listKey] === targetKey);
|
||||
if (isExist) {
|
||||
this.selectedKey = targetKey;
|
||||
// 触发选中事件
|
||||
const selectedItem = this.listData.find(item => item[this.listKey] === targetKey);
|
||||
this.$emit("item-click", selectedItem);
|
||||
} else {
|
||||
@@ -145,31 +233,55 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// ---------------------- 新增:信息位控制方法 ----------------------
|
||||
/**
|
||||
* 判断文字是否溢出(控制Tooltip显示/隐藏)
|
||||
* 判断信息位是否需要显示(插槽存在 或 字段有值)
|
||||
* @param {String} infoKey - 信息位标识(info1~info6)
|
||||
* @param {Object} item - 列表项数据
|
||||
* @returns {Boolean} 是否显示
|
||||
*/
|
||||
showInfoItem(infoKey, item) {
|
||||
// 前置容错:避免item为undefined导致报错
|
||||
if (!item) return false;
|
||||
|
||||
// 1. Vue 3 插槽判断:用 $slots 替代 $scopedSlots,且先判断 $slots 是否存在
|
||||
const hasSlot = this.$slots && this.$slots[infoKey];
|
||||
if (hasSlot) return true;
|
||||
|
||||
// 2. 无插槽时,判断字段配置是否存在 + 字段值是否有效
|
||||
const field = this[`${infoKey}Field`];
|
||||
// 容错:字段未配置(如没传info1Field)则不显示
|
||||
if (!field) return false;
|
||||
// 字段值有效判断(排除 undefined/null/空字符串)
|
||||
return item[field] !== undefined && item[field] !== null && item[field] !== "";
|
||||
},
|
||||
|
||||
/**
|
||||
* 信息位1(主标题)溢出检测(适配新字段)
|
||||
* @param {Object} item - 列表项数据
|
||||
* @param {String} infoKey - 信息位标识(仅info1需要)
|
||||
* @returns {Boolean} 是否溢出
|
||||
*/
|
||||
isContentOverflow(item) {
|
||||
isContentOverflow(item, infoKey) {
|
||||
const itemKey = item[this.listKey];
|
||||
const content = item[this.titleField] || "";
|
||||
const field = this[`${infoKey}Field`];
|
||||
const content = item[field] || "";
|
||||
|
||||
// 内容为空时不显示Tooltip
|
||||
if (!content) return false;
|
||||
// 内容为空或无字段时不显示Tooltip
|
||||
if (!content || !field) return false;
|
||||
|
||||
// 获取容器宽度并增加存在性检查
|
||||
const container = this.$el.querySelector('.klp-list-container');
|
||||
if (!container) return false; // 容器不存在时直接返回
|
||||
this.containerWidth = container.clientWidth;
|
||||
// 获取内容区宽度(原容器宽度改为内容区宽度)
|
||||
const contentEl = this.$el.querySelector(`.klp-list-item:nth-child(${this.listData.indexOf(item) + 1}) .klp-list-content`);
|
||||
if (!contentEl) return false;
|
||||
const contentWidth = contentEl.clientWidth;
|
||||
|
||||
// 计算标题内容最大可用宽度(减去标签和边距)
|
||||
const labelWidth = this.$el.querySelector('.title-label')?.offsetWidth || 60;
|
||||
const availableWidth = (this.containerWidth * this.titleMaxPercent / 100) - labelWidth - 20;
|
||||
// 计算信息位1的最大可用宽度(减去标签宽度)
|
||||
const labelWidth = this.$el.querySelector(`.klp-list-item:nth-child(${this.listData.indexOf(item) + 1}) .info-label`)?.offsetWidth || 40;
|
||||
const maxWidth = (contentWidth * this.info1MaxPercent) / 100 - labelWidth - 12;
|
||||
|
||||
// 创建临时元素测量文字实际宽度(复用元素避免性能问题)
|
||||
// 复用临时元素检测宽度(不变)
|
||||
if (!this.overflowCheckElements[itemKey]) {
|
||||
const tempEl = document.createElement("span");
|
||||
// 复制title-value的样式(确保测量准确)
|
||||
tempEl.style.cssText = `
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
@@ -183,26 +295,21 @@ export default {
|
||||
this.overflowCheckElements[itemKey] = tempEl;
|
||||
}
|
||||
|
||||
// 比较文字实际宽度与可用宽度
|
||||
const tempEl = this.overflowCheckElements[itemKey];
|
||||
return tempEl.offsetWidth > availableWidth;
|
||||
return tempEl.offsetWidth > maxWidth;
|
||||
},
|
||||
|
||||
/**
|
||||
* 监听容器宽度变化
|
||||
*/
|
||||
/** 窗口 resize 重新计算(不变) */
|
||||
handleResize() {
|
||||
// 宽度变化时重新计算溢出状态
|
||||
this.$forceUpdate();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
/** 列表数据变化时,重置选中状态和溢出检测元素 */
|
||||
/** 列表数据变化时清理临时元素(不变) */
|
||||
listData: {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.clearSelection();
|
||||
// 清理临时测量元素
|
||||
Object.values(this.overflowCheckElements).forEach(el => {
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
@@ -210,112 +317,138 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
/** 标题最大百分比变化时,重新计算溢出 */
|
||||
titleMaxPercent() {
|
||||
/** 主标题占比变化时重新计算溢出(适配新prop) */
|
||||
info1MaxPercent() {
|
||||
this.$forceUpdate();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 初始化内容区宽度(适配新结构)
|
||||
this.$nextTick(() => {
|
||||
const container = this.$el.querySelector('.klp-list-container');
|
||||
// 增加存在性检查
|
||||
this.containerWidth = container ? container.clientWidth : 0;
|
||||
const contentEl = this.$el.querySelector('.klp-list-content');
|
||||
this.containerWidth = contentEl ? contentEl.clientWidth : 0;
|
||||
});
|
||||
|
||||
// 监听窗口大小变化
|
||||
window.addEventListener('resize', this.handleResize);
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 清理临时元素
|
||||
// 清理临时元素和事件监听(不变)
|
||||
Object.values(this.overflowCheckElements).forEach(el => {
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
|
||||
// 移除事件监听
|
||||
window.removeEventListener('resize', this.handleResize);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 列表容器基础样式 */
|
||||
/* 列表容器(不变) */
|
||||
.klp-list-container {
|
||||
max-height: calc(100vh - 220px);
|
||||
overflow-y: auto;
|
||||
padding-right: 8px;
|
||||
margin-top: 10px;
|
||||
width: 100%; /* 确保容器宽度正确计算 */
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 加载状态容器(避免加载时容器塌陷) */
|
||||
/* 加载容器(不变) */
|
||||
.list-loading-wrapper {
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
/* 列表项样式 */
|
||||
/* 列表项:改为上下两行+右侧操作的布局 */
|
||||
.klp-list-item {
|
||||
padding: 6px 8px;
|
||||
margin-bottom: 6px;
|
||||
border-bottom: 1px solid #fff;
|
||||
padding: 10px 12px;
|
||||
/* 增加内边距,适配两行 */
|
||||
margin-bottom: 8px;
|
||||
border-bottom: 1px solid #f5f7fa;
|
||||
/* 弱化底边框,突出选中态 */
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
/* 顶部对齐,避免操作区下移 */
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
width: 100%; /* 确保列表项占满容器宽度 */
|
||||
width: 100%;
|
||||
background-color: #fafafa;
|
||||
/* 未选中时浅背景,区分选中态 */
|
||||
}
|
||||
|
||||
/* 列表项选中状态(左侧高亮边框+背景色) */
|
||||
/* 列表项选中状态(不变) */
|
||||
.klp-list-item.active {
|
||||
border-left: 3px solid #2bf;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
/* 增加轻微阴影,突出选中项 */
|
||||
}
|
||||
|
||||
/* 列表标题区域(占满中间空间,让操作按钮靠右) */
|
||||
.klp-list-title {
|
||||
/* 内容区:包裹两行信息位,占满剩余空间 */
|
||||
.klp-list-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
/* 关键:允许内容区缩小,避免溢出 */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 行容器:控制单行信息位布局 */
|
||||
.klp-list-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
min-width: 0; /* 关键:允许flex项缩小到内容尺寸以下 */
|
||||
overflow: hidden; /* 确保内容不会超出容器 */
|
||||
flex-wrap: nowrap;
|
||||
/* 禁止换行,溢出省略 */
|
||||
overflow: hidden;
|
||||
/* 隐藏超出行的内容 */
|
||||
}
|
||||
|
||||
/* 标题前置标签样式 */
|
||||
.klp-list-title .title-label {
|
||||
color: #232323;
|
||||
margin-right: 6px;
|
||||
font-size: 13px;
|
||||
white-space: nowrap; /* 标签不换行 */
|
||||
flex-shrink: 0; /* 标签不缩小 */
|
||||
/* 信息位容器:单个信息的最小单元 */
|
||||
.klp-list-info-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
/* 禁止信息位内部换行 */
|
||||
}
|
||||
|
||||
/* 标题内容样式(溢出省略) */
|
||||
.klp-list-title .title-value {
|
||||
color: #232323;
|
||||
font-weight: 500;
|
||||
/* 信息位标签:次要文字,颜色偏浅 */
|
||||
.info-label {
|
||||
color: #606266;
|
||||
font-size: 12px;
|
||||
margin-right: 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 信息位值:默认样式 */
|
||||
.info-value {
|
||||
color: #303133;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
/* 溢出显示省略号 */
|
||||
}
|
||||
|
||||
/* 主标题(info1)值:加粗突出 */
|
||||
.info-value--primary {
|
||||
font-size: 14px;
|
||||
white-space: nowrap; /* 禁止换行 */
|
||||
overflow: hidden; /* 超出部分隐藏 */
|
||||
text-overflow: ellipsis; /* 超出部分显示省略号 */
|
||||
flex: 1; /* 占据剩余空间 */
|
||||
min-width: 0; /* 关键:允许内容区域缩小 */
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 操作按钮组(按钮间距控制) */
|
||||
/* 右侧操作区(不变,增加顶部对齐) */
|
||||
.klp-list-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0; /* 操作区不缩小 */
|
||||
margin-left: 8px;
|
||||
align-items: flex-start;
|
||||
/* 与内容区顶部对齐 */
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
margin-left: 12px;
|
||||
padding-top: 2px;
|
||||
/* 微调垂直位置 */
|
||||
}
|
||||
|
||||
/* 空状态样式(居中显示) */
|
||||
/* 空状态(不变) */
|
||||
.klp-list-empty {
|
||||
padding: 40px 0;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -16,6 +16,26 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" size="small" @click="handleExport">导出</el-button>
|
||||
</el-col>
|
||||
|
||||
<!-- 含税部分 -->
|
||||
<el-col :span="8">
|
||||
<span>含税金额:</span>
|
||||
<span style="margin-right: 10px;">{{ orderInfo?.taxAmount }}</span>
|
||||
<span style="margin-right: 10px;">-</span>
|
||||
<span style="margin-right: 10px;">{{ actualAmount }}</span>
|
||||
<span style="margin-right: 10px;">=</span>
|
||||
<span style="color: red; margin-right: 10px;">{{ amountDifference }}</span>
|
||||
</el-col>
|
||||
|
||||
<!-- 无税部分 -->
|
||||
<el-col :span="8">
|
||||
<span>无税金额:</span>
|
||||
<span style="margin-right: 10px;">{{ orderInfo?.noTaxAmount }}</span>
|
||||
<span style="margin-right: 10px;">-</span>
|
||||
<span style="margin-right: 10px;">{{ noTaxAmount }}</span>
|
||||
<span style="margin-right: 10px;">=</span>
|
||||
<span style="color: red; margin-right: 10px;">{{ noTaxAmountDifference }}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="orderDetailList">
|
||||
@@ -145,6 +165,22 @@ export default {
|
||||
// 是否可以编辑(订单状态为新建时才能编辑)
|
||||
canEdit() {
|
||||
return this.orderInfo && this.orderInfo.orderStatus === EOrderStatus.NEW;
|
||||
},
|
||||
actualAmount() {
|
||||
return this.orderDetailList?.reduce((total, item) => {
|
||||
return total + (item.taxPrice || 0) * (item.quantity || 0);
|
||||
}, 0) || 0;
|
||||
},
|
||||
amountDifference() {
|
||||
return ((this.orderInfo?.taxAmount || 0) - this.actualAmount);
|
||||
},
|
||||
noTaxAmount() {
|
||||
return this.orderDetailList?.reduce((total, item) => {
|
||||
return total + (item.noTaxPrice || 0) * (item.quantity || 0);
|
||||
}, 0) || 0;
|
||||
},
|
||||
noTaxAmountDifference() {
|
||||
return ((this.orderInfo?.noTaxAmount || 0) - this.noTaxAmount);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -15,17 +15,32 @@
|
||||
</el-row>
|
||||
|
||||
<!-- klp-list组件 -->
|
||||
<klp-list :list-data="orderList" :model-value="selectedIds" title-field="orderCode" list-key="orderId"
|
||||
title-label="订单编号" :loading="loading" @item-click="handleRowClick">
|
||||
<!-- 自定义操作按钮 -->
|
||||
<klp-list :list-data="orderList" list-key="orderId" :loading="loading" @item-click="handleRowClick"
|
||||
info1-field="orderCode" info1-max-percent="40" info5-field="createTime" info4-field="taxAmount">
|
||||
<template #info4="{ item }">
|
||||
<span class="info-value info-value--primary">
|
||||
{{ item.taxAmount }}元(含税)
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #info1="{ item }">
|
||||
<span class="info-value info-value--primary">
|
||||
{{ item.salesManager }}【{{ item.orderCode }}】
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #info2="{ item }">
|
||||
<dict-tag :options="order_status" :value="item.orderStatus" />
|
||||
</template>
|
||||
|
||||
|
||||
<template #actions="{ item }">
|
||||
<!-- 删除按钮 -->
|
||||
<el-button size="small" type="text" style="color: red" icon="Delete"
|
||||
@click.stop="handleDelete(item)"></el-button>
|
||||
</template>
|
||||
</klp-list>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize" @pagination="getList" class="mt-4" layout="total, pager" />
|
||||
</el-col>
|
||||
@@ -90,6 +105,8 @@
|
||||
<el-form-item class="text-right">
|
||||
<el-button type="primary" size="small" :loading="buttonLoading"
|
||||
@click="submitDetailForm">更新订单信息</el-button>
|
||||
<el-button type="primary" size="small" :loading="buttonLoading"
|
||||
@click="copyOrderId(form.orderId)">复制订单ID</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
@@ -106,6 +123,18 @@
|
||||
<ReturnExchange :orderId="selectedOrderId" />
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="应收款" name="receive">
|
||||
<div class="mt-4">
|
||||
<Receive :orderId="selectedOrderId" />
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="应付款" name="pay">
|
||||
<div class="mt-4">
|
||||
<Pay :orderId="selectedOrderId" />
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
@@ -131,6 +160,14 @@
|
||||
<el-input v-model="form.salesManager" style="width: 100%;" placeholder="请输入销售经理" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="交易类型" prop="tradeType">
|
||||
<el-select v-model="form.tradeType" placeholder="请选择交易类型">
|
||||
<el-option label="内贸" value="0" />
|
||||
<el-option label="外贸" value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="含税金额" prop="taxAmount">
|
||||
<el-input-number :controls="false" style="width: 100%;" v-model="form.taxAmount" placeholder="请输入含税金额"
|
||||
@@ -160,16 +197,20 @@
|
||||
|
||||
<script>
|
||||
import { getOrder, delOrder, addOrder, updateOrder, listOrder } from "@/api/oms/order";
|
||||
|
||||
import OrderDetailPanel from './detail.vue';
|
||||
import { EOrderStatus } from "@/utils/enums";
|
||||
import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import klpList from "@/components/GearList/index.vue";
|
||||
import { getCurrentInstance } from "vue";
|
||||
|
||||
import ReturnExchange from './return.vue';
|
||||
import Pay from './pay.vue';
|
||||
import Receive from './receive.vue';
|
||||
|
||||
export default {
|
||||
name: "Order",
|
||||
components: { OrderDetailPanel, CustomerSelect, klpList, ReturnExchange },
|
||||
components: { OrderDetailPanel, CustomerSelect, klpList, ReturnExchange, Pay, Receive },
|
||||
props: {
|
||||
tradeType: {
|
||||
type: String,
|
||||
@@ -222,7 +263,8 @@ export default {
|
||||
orderCode: undefined,
|
||||
customerId: undefined,
|
||||
salesManager: undefined,
|
||||
tradeType: this.tradeType
|
||||
// tradeType: this.tradeType
|
||||
taxAmount: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
@@ -230,7 +272,8 @@ export default {
|
||||
orderCode: undefined,
|
||||
customerId: undefined,
|
||||
salesManager: undefined,
|
||||
tradeType: this.tradeType,
|
||||
// tradeType: this.tradeType,
|
||||
noTaxAmount: undefined,
|
||||
remark: undefined,
|
||||
delFlag: undefined,
|
||||
createTime: undefined,
|
||||
@@ -261,7 +304,7 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.queryParams.orderStatus = this.orderQueryStatus;
|
||||
// this.queryParams.orderStatus = this.orderQueryStatus;
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
@@ -327,7 +370,8 @@ export default {
|
||||
customerId: undefined,
|
||||
salesManager: undefined,
|
||||
orderStatus: this.orderQueryStatus,
|
||||
tradeType: this.tradeType,
|
||||
taxAmount: undefined,
|
||||
// tradeType: this.tradeType,
|
||||
remark: undefined,
|
||||
taxAmount: 0,
|
||||
noTaxAmount: 0,
|
||||
|
||||
354
gear-ui3/src/views/oms/order/panels/pay.vue
Normal file
354
gear-ui3/src/views/oms/order/panels/pay.vue
Normal file
@@ -0,0 +1,354 @@
|
||||
<template>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
size="small"
|
||||
@click="handleAdd"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
size="small"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
size="small"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
size="small"
|
||||
@click="handleExport"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="payableList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="应付ID" align="center" prop="payableId" v-if="false"/>
|
||||
<el-table-column label="供应商" align="center" prop="supplierName" />
|
||||
<el-table-column label="到期日" align="center" prop="dueDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.dueDate, '{y}-{m}-{d}') }}</span>
|
||||
<el-tag v-if="new Date(scope.row.dueDate) < new Date()" type="danger">过期</el-tag>
|
||||
<el-tag v-else-if="new Date(scope.row.dueDate) > new Date()" type="success">还剩{{ parseInt((new Date(scope.row.dueDate) - new Date()) / (1000 * 60 * 60 * 24)) }}天</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="应付金额" align="center" prop="amount" />
|
||||
<el-table-column label="已付金额" align="center" prop="paidAmount" />
|
||||
<el-table-column label="未付金额" align="center" prop="balanceAmount" />
|
||||
<el-table-column label="状态" align="center" prop="status" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
size="small"
|
||||
type="text"
|
||||
icon="Edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="text"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="text"
|
||||
icon="Money"
|
||||
@click="handlePay(scope.row)"
|
||||
v-if="scope.row.balanceAmount > 0"
|
||||
>付款</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"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改应付款管理(宽松版)对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="供应商ID" prop="supplierId">
|
||||
<VendorSelect v-model="form.supplierId" />
|
||||
</el-form-item>
|
||||
<el-form-item label="到期日" prop="dueDate">
|
||||
<el-date-picker clearable
|
||||
v-model="form.dueDate"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择到期日">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="应付金额" prop="amount">
|
||||
<el-input v-model="form.amount" placeholder="请输入应付金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="已付金额" prop="paidAmount">
|
||||
<el-input v-model="form.paidAmount" disabled placeholder="请输入已付金额" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="未付金额" prop="balanceAmount">
|
||||
<el-input v-model="form.balanceAmount" placeholder="请输入未付金额" />
|
||||
</el-form-item> -->
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="付款" v-model="payOpen" width="500px" append-to-body>
|
||||
<el-form ref="payForm" :model="payForm" :rules="rules" label-width="80px">
|
||||
<el-form-item label="付款金额" prop="amount">
|
||||
<el-input-number :controls=false controls-position="right" v-model="payForm.amount" :step="1.00" :precision="2" placeholder="请输入付款金额" :min="0" :max="payForm.balanceAmount" style="width: 100%;"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitPayForm">确 定</el-button>
|
||||
<el-button @click="cancelPay">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listPayable, getPayable, delPayable, addPayable, updatePayable, updatePaidAmount } from "@/api/finance/payable";
|
||||
import VendorSelect from '@/components/VendorSelect/index.vue';
|
||||
|
||||
export default {
|
||||
name: "Payable",
|
||||
components: {
|
||||
VendorSelect
|
||||
},
|
||||
props: {
|
||||
orderId: {
|
||||
type: [String, Number],
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 按钮loading
|
||||
buttonLoading: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 应付款管理(宽松版)表格数据
|
||||
payableList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
supplierId: undefined,
|
||||
orderId: this.orderId,
|
||||
dueDate: undefined,
|
||||
amount: undefined,
|
||||
paidAmount: undefined,
|
||||
balanceAmount: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
},
|
||||
// 付款表单参数
|
||||
payForm: {},
|
||||
// 是否显示付款弹出层
|
||||
payOpen: false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
watch: {
|
||||
orderId(newVal) {
|
||||
this.queryParams.orderId = newVal;
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 查询应付款管理(宽松版)列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listPayable(this.queryParams).then(response => {
|
||||
this.payableList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
payableId: undefined,
|
||||
supplierId: undefined,
|
||||
orderId: this.orderId,
|
||||
dueDate: undefined,
|
||||
amount: undefined,
|
||||
paidAmount: 0,
|
||||
balanceAmount: undefined,
|
||||
status: undefined,
|
||||
delFlag: undefined,
|
||||
remark: undefined,
|
||||
createTime: undefined,
|
||||
createBy: undefined,
|
||||
updateTime: undefined,
|
||||
updateBy: undefined
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.payableId)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加应付款管理(宽松版)";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.loading = true;
|
||||
this.reset();
|
||||
const payableId = row.payableId || this.ids
|
||||
getPayable(payableId).then(response => {
|
||||
this.loading = false;
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改应付款管理(宽松版)";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true;
|
||||
if (this.form.payableId != null) {
|
||||
const {balanceAmount, ...payload} = this.form;
|
||||
updatePayable(payload).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
} else {
|
||||
addPayable(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const payableIds = row.payableId || this.ids;
|
||||
this.$modal.confirm('是否确认删除应付款管理(宽松版)编号为"' + payableIds + '"的数据项?').then(() => {
|
||||
this.loading = true;
|
||||
return delPayable(payableIds);
|
||||
}).then(() => {
|
||||
this.loading = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('klp/payable/export', {
|
||||
...this.queryParams
|
||||
}, `payable_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
// 付款按钮操作
|
||||
handlePay(row) {
|
||||
this.payForm = {
|
||||
payableId: row.payableId,
|
||||
amount: row.balanceAmount,
|
||||
balanceAmount: row.balanceAmount
|
||||
};
|
||||
this.payOpen = true;
|
||||
},
|
||||
// 取消付款按钮操作
|
||||
cancelPay() {
|
||||
this.payOpen = false;
|
||||
this.payForm = {};
|
||||
},
|
||||
submitPayForm() {
|
||||
const payload = {
|
||||
payableId: this.payForm.payableId,
|
||||
paidAmount: this.payForm.amount
|
||||
}
|
||||
this.buttonLoading = true;
|
||||
updatePaidAmount(payload).then(response => {
|
||||
this.$modal.msgSuccess("付款成功");
|
||||
this.payOpen = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
356
gear-ui3/src/views/oms/order/panels/receive.vue
Normal file
356
gear-ui3/src/views/oms/order/panels/receive.vue
Normal file
@@ -0,0 +1,356 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
size="small"
|
||||
@click="handleAdd"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
size="small"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
size="small"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
size="small"
|
||||
@click="handleExport"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="receivableList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="应收ID" align="center" prop="receivableId" v-if="false"/>
|
||||
<el-table-column label="客户" align="center" prop="customerName" />
|
||||
<el-table-column label="到期日" align="center" prop="dueDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.dueDate, '{y}-{m}-{d}') }}</span>
|
||||
<el-tag v-if="new Date(scope.row.dueDate) < new Date()" type="danger">过期</el-tag>
|
||||
<el-tag v-else-if="new Date(scope.row.dueDate) > new Date()" type="success">还剩{{ parseInt((new Date(scope.row.dueDate) - new Date()) / (1000 * 60 * 60 * 24)) }}天</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="应收金额" align="center" prop="amount" />
|
||||
<el-table-column label="已收金额" align="center" prop="paidAmount" />
|
||||
<el-table-column label="未收金额" align="center" prop="balanceAmount" />
|
||||
<el-table-column label="状态" align="center" prop="status" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
size="small"
|
||||
type="text"
|
||||
icon="Edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="text"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="text"
|
||||
icon="Money"
|
||||
@click="handleReceive(scope.row)"
|
||||
v-if="scope.row.balanceAmount > 0"
|
||||
>收款</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"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改应收款管理(宽松版)对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="客户ID" prop="customerId">
|
||||
<CustomerSelect v-model="form.customerId" />
|
||||
</el-form-item>
|
||||
<el-form-item label="到期日" prop="dueDate">
|
||||
<el-date-picker clearable
|
||||
v-model="form.dueDate"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择到期日">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="应收金额" prop="amount">
|
||||
<el-input v-model="form.amount" placeholder="请输入应收金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="已收金额" prop="paidAmount">
|
||||
<el-input v-model="form.paidAmount" disabled placeholder="请输入已收金额" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="未收金额" prop="balanceAmount">
|
||||
<el-input v-model="form.balanceAmount" placeholder="请输入未收金额" />
|
||||
</el-form-item> -->
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="收款" v-model="receiveOpen" width="500px" append-to-body>
|
||||
<el-form ref="receiveForm" :model="receiveForm" :rules="rules" label-width="80px">
|
||||
<el-form-item label="收款金额" prop="amount">
|
||||
<el-input-number :controls=false controls-position="right" v-model="receiveForm.amount" :step="1.00" :precision="2" placeholder="请输入收款金额" :min="0" :max="receiveForm.balanceAmount" style="width: 100%;"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitReceiveForm">确 定</el-button>
|
||||
<el-button @click="cancelReceive">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listReceivable, getReceivable, delReceivable, addReceivable, updateReceivable, updatePaidAmount } from "@/api/finance/receivable";
|
||||
import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
|
||||
export default {
|
||||
name: "Receivable",
|
||||
components: {
|
||||
CustomerSelect
|
||||
},
|
||||
props: {
|
||||
orderId: {
|
||||
type: [String, Number],
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 按钮loading
|
||||
buttonLoading: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 应收款管理(宽松版)表格数据
|
||||
receivableList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
customerId: undefined,
|
||||
orderId: this.orderId,
|
||||
dueDate: undefined,
|
||||
amount: undefined,
|
||||
paidAmount: undefined,
|
||||
balanceAmount: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
},
|
||||
// 收款表单参数
|
||||
receiveForm: {},
|
||||
// 是否显示收款弹出层
|
||||
receiveOpen: false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
watch: {
|
||||
orderId(newVal) {
|
||||
this.queryParams.orderId = newVal;
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 查询应收款管理(宽松版)列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listReceivable(this.queryParams).then(response => {
|
||||
this.receivableList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
receivableId: undefined,
|
||||
customerId: undefined,
|
||||
orderId: this.orderId,
|
||||
dueDate: undefined,
|
||||
amount: undefined,
|
||||
paidAmount: 0,
|
||||
balanceAmount: undefined,
|
||||
status: undefined,
|
||||
delFlag: undefined,
|
||||
remark: undefined,
|
||||
createTime: undefined,
|
||||
createBy: undefined,
|
||||
updateTime: undefined,
|
||||
updateBy: undefined
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.receivableId)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加应收款管理(宽松版)";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.loading = true;
|
||||
this.reset();
|
||||
const receivableId = row.receivableId || this.ids
|
||||
getReceivable(receivableId).then(response => {
|
||||
this.loading = false;
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改应收款管理(宽松版)";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true;
|
||||
if (this.form.receivableId != null) {
|
||||
const {balanceAmount, ...payload} = this.form;
|
||||
updateReceivable(payload).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
} else {
|
||||
addReceivable(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const receivableIds = row.receivableId || this.ids;
|
||||
this.$modal.confirm('是否确认删除应收款管理(宽松版)编号为"' + receivableIds + '"的数据项?').then(() => {
|
||||
this.loading = true;
|
||||
return delReceivable(receivableIds);
|
||||
}).then(() => {
|
||||
this.loading = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('klp/receivable/export', {
|
||||
...this.queryParams
|
||||
}, `receivable_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
// 收款按钮操作
|
||||
handleReceive(row) {
|
||||
this.receiveForm = {
|
||||
receivableId: row.receivableId,
|
||||
amount: row.balanceAmount,
|
||||
balanceAmount: row.balanceAmount
|
||||
};
|
||||
this.receiveOpen = true;
|
||||
},
|
||||
// 取消收款按钮操作
|
||||
cancelReceive() {
|
||||
this.receiveOpen = false;
|
||||
this.receiveForm = {};
|
||||
},
|
||||
submitReceiveForm() {
|
||||
const payload = {
|
||||
receivableId: this.receiveForm.receivableId,
|
||||
paidAmount: this.receiveForm.amount
|
||||
}
|
||||
this.buttonLoading = true;
|
||||
updatePaidAmount(payload).then(response => {
|
||||
this.$modal.msgSuccess("收款成功");
|
||||
this.receiveOpen = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user