Merge remote-tracking branch 'origin/0.8.X' into 0.8.X
This commit is contained in:
@@ -313,10 +313,10 @@ export default {
|
||||
}
|
||||
|
||||
.default-trigger {
|
||||
padding: 8px 12px;
|
||||
padding: 2px 4px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
min-width: 120px;
|
||||
font-size: 13px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
37
klp-ui/src/utils/coil/coilNo.js
Normal file
37
klp-ui/src/utils/coil/coilNo.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 生成钢卷号前五位
|
||||
* 格式:年份后两位 + 月份字母 + 日期两位
|
||||
* 例如:2026年3月3日生成 26L03
|
||||
* @returns {string} 钢卷号前五位
|
||||
*/
|
||||
export function generateCoilNoPrefix() {
|
||||
const now = new Date();
|
||||
// 取年份后两位
|
||||
const year = now.getFullYear().toString().slice(-2);
|
||||
|
||||
// 月份字母映射
|
||||
const monthLetters = {
|
||||
1: 'J', // 1月
|
||||
2: 'K', // 2月
|
||||
3: 'L', // 3月
|
||||
4: 'M', // 4月
|
||||
5: 'N', // 5月
|
||||
6: 'O', // 6月
|
||||
7: 'P', // 7月
|
||||
8: 'Q', // 8月
|
||||
9: 'R', // 9月
|
||||
10: 'S', // 10月
|
||||
11: 'T', // 11月
|
||||
12: 'U' // 12月
|
||||
};
|
||||
|
||||
// 获取月份字母
|
||||
const month = monthLetters[now.getMonth() + 1];
|
||||
|
||||
// 日期补零
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
|
||||
// 组合前五位:年份后两位 + 月份字母 + 日期两位
|
||||
return year + month + day;
|
||||
}
|
||||
|
||||
85
klp-ui/src/utils/coil/coilNo.test.js
Normal file
85
klp-ui/src/utils/coil/coilNo.test.js
Normal file
@@ -0,0 +1,85 @@
|
||||
import {expect, test} from '@jest/globals';
|
||||
import { generateCoilNoPrefix } from './coilNo';
|
||||
|
||||
describe('generateCoilNoPrefix', () => {
|
||||
// 保存原始的Date方法
|
||||
let originalGetFullYear;
|
||||
let originalGetMonth;
|
||||
let originalGetDate;
|
||||
|
||||
beforeEach(() => {
|
||||
// 保存原始方法
|
||||
originalGetFullYear = Date.prototype.getFullYear;
|
||||
originalGetMonth = Date.prototype.getMonth;
|
||||
originalGetDate = Date.prototype.getDate;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// 恢复原始方法
|
||||
Date.prototype.getFullYear = originalGetFullYear;
|
||||
Date.prototype.getMonth = originalGetMonth;
|
||||
Date.prototype.getDate = originalGetDate;
|
||||
});
|
||||
|
||||
test("生成2026年3月3日的钢卷号前五位", () => {
|
||||
// 模拟日期:2026年3月3日
|
||||
Date.prototype.getFullYear = jest.fn(() => 2026);
|
||||
Date.prototype.getMonth = jest.fn(() => 2); // 3月是索引2
|
||||
Date.prototype.getDate = jest.fn(() => 3);
|
||||
|
||||
const result = generateCoilNoPrefix();
|
||||
expect(result).toBe('26L03');
|
||||
});
|
||||
|
||||
test('生成2026年1月1日的钢卷号前五位', () => {
|
||||
// 模拟日期:2026年1月1日
|
||||
Date.prototype.getFullYear = jest.fn(() => 2026);
|
||||
Date.prototype.getMonth = jest.fn(() => 0); // 1月是索引0
|
||||
Date.prototype.getDate = jest.fn(() => 1);
|
||||
|
||||
const result = generateCoilNoPrefix();
|
||||
expect(result).toBe('26J01');
|
||||
});
|
||||
|
||||
test('生成2026年12月31日的钢卷号前五位', () => {
|
||||
// 模拟日期:2026年12月31日
|
||||
Date.prototype.getFullYear = jest.fn(() => 2026);
|
||||
Date.prototype.getMonth = jest.fn(() => 11); // 12月是索引11
|
||||
Date.prototype.getDate = jest.fn(() => 31);
|
||||
|
||||
const result = generateCoilNoPrefix();
|
||||
expect(result).toBe('26U31');
|
||||
});
|
||||
|
||||
test('生成2027年5月15日的钢卷号前五位', () => {
|
||||
// 模拟日期:2027年5月15日
|
||||
Date.prototype.getFullYear = jest.fn(() => 2027);
|
||||
Date.prototype.getMonth = jest.fn(() => 4); // 5月是索引4
|
||||
Date.prototype.getDate = jest.fn(() => 15);
|
||||
|
||||
const result = generateCoilNoPrefix();
|
||||
expect(result).toBe('27N15');
|
||||
});
|
||||
|
||||
test('钢卷号前五位长度为5', () => {
|
||||
// 模拟任意日期
|
||||
Date.prototype.getFullYear = jest.fn(() => 2026);
|
||||
Date.prototype.getMonth = jest.fn(() => 2);
|
||||
Date.prototype.getDate = jest.fn(() => 3);
|
||||
|
||||
const result = generateCoilNoPrefix();
|
||||
expect(result.length).toBe(5);
|
||||
});
|
||||
|
||||
test('钢卷号前五位格式正确', () => {
|
||||
// 模拟任意日期
|
||||
Date.prototype.getFullYear = jest.fn(() => 2026);
|
||||
Date.prototype.getMonth = jest.fn(() => 2);
|
||||
Date.prototype.getDate = jest.fn(() => 3);
|
||||
|
||||
const result = generateCoilNoPrefix();
|
||||
// 格式:年份后两位(2位数字) + 月份字母(1位字母) + 日期两位(2位数字)
|
||||
const regex = /^\d{2}[JKLMNOPQRSTU]\d{2}$/;
|
||||
expect(regex.test(result)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -226,6 +226,7 @@ import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect
|
||||
import RawMaterialSelector from "@/components/KLPService/RawMaterialSelect";
|
||||
import ProductSelector from "@/components/KLPService/ProductSelect";
|
||||
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
|
||||
import { generateCoilNoPrefix } from "@/utils/coil/coilNo";
|
||||
|
||||
export default {
|
||||
name: 'MergeCoil',
|
||||
@@ -238,12 +239,14 @@ export default {
|
||||
},
|
||||
dicts: ['coil_quality_status'],
|
||||
data() {
|
||||
const currentCoilNoPrefix = generateCoilNoPrefix()
|
||||
return {
|
||||
currentCoilNoPrefix,
|
||||
// 源卷列表
|
||||
sourceCoils: [],
|
||||
// 目标卷信息
|
||||
targetCoil: {
|
||||
currentCoilNo: '',
|
||||
currentCoilNo: currentCoilNoPrefix,
|
||||
team: '',
|
||||
materialType: null,
|
||||
itemType: null,
|
||||
|
||||
@@ -198,6 +198,7 @@ import ProductSelect from "@/components/KLPService/ProductSelect";
|
||||
import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
|
||||
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
|
||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||
import { generateCoilNoPrefix } from "@/utils/coil/coilNo";
|
||||
|
||||
export default {
|
||||
name: 'StepSplit',
|
||||
@@ -223,7 +224,9 @@ export default {
|
||||
},
|
||||
dicts: ['coil_quality_status'],
|
||||
data() {
|
||||
const currentCoilNoPrefix = generateCoilNoPrefix()
|
||||
return {
|
||||
currentCoilNoPrefix,
|
||||
// 待分条钢卷基础信息
|
||||
coilInfo: {},
|
||||
loading: false,
|
||||
@@ -231,7 +234,7 @@ export default {
|
||||
splitForm: {
|
||||
coilId: '', // 分条钢卷ID(编辑时赋值)
|
||||
enterCoilNo: '',
|
||||
currentCoilNo: '',
|
||||
currentCoilNo: currentCoilNoPrefix,
|
||||
supplierCoilNo: '',
|
||||
warehouseId: '',
|
||||
actualWarehouseId: '',
|
||||
@@ -262,6 +265,16 @@ export default {
|
||||
rules: {
|
||||
currentCoilNo: [
|
||||
{ required: true, message: "当前钢卷号不能为空", trigger: "blur" },
|
||||
{
|
||||
// 当前钢卷号必须大于等于10位
|
||||
validator: (rule, value, callback) => {
|
||||
if (value.length < 10) {
|
||||
callback(new Error('当前钢卷号必须大于等于10位'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}, trigger: 'blur'
|
||||
},
|
||||
// 仅在新增的时候校验
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
@@ -400,7 +413,7 @@ export default {
|
||||
this.splitForm = {
|
||||
coilId: undefined,
|
||||
enterCoilNo: '',
|
||||
currentCoilNo: '',
|
||||
currentCoilNo: this.currentCoilNoPrefix,
|
||||
supplierCoilNo: '',
|
||||
warehouseId: '',
|
||||
actualWarehouseId: '',
|
||||
|
||||
@@ -225,6 +225,7 @@ import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect
|
||||
import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
|
||||
import ProductSelect from "@/components/KLPService/ProductSelect";
|
||||
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
|
||||
import { generateCoilNoPrefix } from "@/utils/coil/coilNo";
|
||||
|
||||
export default {
|
||||
name: 'SplitCoil',
|
||||
@@ -236,7 +237,9 @@ export default {
|
||||
},
|
||||
dicts: ['coil_quality_status'],
|
||||
data() {
|
||||
const currentCoilNoPrefix = generateCoilNoPrefix()
|
||||
return {
|
||||
currentCoilNoPrefix,
|
||||
// 母卷信息
|
||||
motherCoil: {
|
||||
coilId: null,
|
||||
@@ -259,7 +262,7 @@ export default {
|
||||
// 子卷列表
|
||||
splitList: [
|
||||
{
|
||||
currentCoilNo: '',
|
||||
currentCoilNo: currentCoilNoPrefix,
|
||||
team: '',
|
||||
materialType: null,
|
||||
itemType: null,
|
||||
@@ -439,7 +442,7 @@ export default {
|
||||
// 添加子卷
|
||||
addSplitItem() {
|
||||
this.splitList.push({
|
||||
currentCoilNo: '',
|
||||
currentCoilNo: this.currentCoilNoPrefix,
|
||||
team: '',
|
||||
materialType: null,
|
||||
itemType: null,
|
||||
|
||||
@@ -215,45 +215,6 @@
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 变更历史(占满整行) -->
|
||||
<!-- <div class="history-section">
|
||||
<el-card class="history-card">
|
||||
<div slot="header" class="card-header">
|
||||
<span><i class="el-icon-time"></i> 变更历史</span>
|
||||
<el-button type="text" size="mini" @click="loadHistory" :loading="historyLoading">
|
||||
<i class="el-icon-refresh"></i> 刷新
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-timeline v-if="historySteps.length > 0">
|
||||
<el-timeline-item v-for="(step, index) in historySteps" :key="index"
|
||||
:timestamp="`步骤 ${step.display_step || step.step}`" placement="top"
|
||||
:type="step.operation === '新增' ? 'success' : 'primary'">
|
||||
<div class="history-item">
|
||||
<div class="history-title">{{ step.operation || step.action }}</div>
|
||||
<div class="history-detail" v-if="step.operator">
|
||||
<span class="detail-label">操作人:</span>
|
||||
<span>{{ step.operator }}</span>
|
||||
</div>
|
||||
<div class="history-detail" v-if="step.old_current_coil_no">
|
||||
<span class="detail-label">原钢卷号:</span>
|
||||
<span>{{ step.old_current_coil_no }}</span>
|
||||
</div>
|
||||
<div class="history-detail" v-if="step.new_current_coil_no">
|
||||
<span class="detail-label">新钢卷号:</span>
|
||||
<span>{{ step.new_current_coil_no }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
|
||||
<div v-else class="empty-history">
|
||||
<i class="el-icon-document"></i>
|
||||
<p>暂无变更历史</p>
|
||||
</div>
|
||||
</el-card>
|
||||
</div> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -268,6 +229,7 @@ import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect
|
||||
import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
|
||||
import ProductSelect from "@/components/KLPService/ProductSelect";
|
||||
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
|
||||
import { generateCoilNoPrefix } from "@/utils/coil/coilNo";
|
||||
|
||||
export default {
|
||||
name: 'TypingCoil',
|
||||
@@ -324,6 +286,16 @@ export default {
|
||||
rules: {
|
||||
currentCoilNo: [
|
||||
{ required: true, message: '请输入当前钢卷号', trigger: 'blur' },
|
||||
{
|
||||
// 当前钢卷号必须大于等于10位
|
||||
validator: (rule, value, callback) => {
|
||||
if (value.length < 10) {
|
||||
callback(new Error('当前钢卷号必须大于等于10位'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}, trigger: 'blur'
|
||||
},
|
||||
// 仅在新增的时候校验
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
@@ -524,6 +496,9 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
const currentCoilNoPrefix = generateCoilNoPrefix()
|
||||
this.$set(this.updateForm, 'currentCoilNo', currentCoilNoPrefix)
|
||||
|
||||
if (actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user