Compare commits

...

5 Commits

Author SHA1 Message Date
‘937886381’
6d367b121c Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-12 14:17:56 +08:00
‘937886381’
e2385cf813 修改 2025-12-12 14:17:21 +08:00
552b1e6d6a Merge pull request '更新' (#460) from projects/line-new-zwq into projects/line-new
Reviewed-on: #460
2025-12-11 12:52:11 +08:00
zwq
4383067eb1 更新 2025-12-11 12:51:41 +08:00
f80644e07c Merge pull request 'projects/line-new-zhp' (#458) from projects/line-new-zhp into projects/line-new
Reviewed-on: #458
2025-12-09 17:03:35 +08:00
16 changed files with 1175 additions and 871 deletions

View File

@@ -13,8 +13,8 @@ VUE_APP_TITLE = 智能监控分析系统
# 芋道管理系统/开发环境 # 芋道管理系统/开发环境
# VUE_APP_BASE_API = 'http://172.16.33.187:48082' # VUE_APP_BASE_API = 'http://172.16.33.187:48082'
# VUE_APP_BASE_API = 'http://line.kszny.picaiba.com' VUE_APP_BASE_API = 'http://line.kszny.picaiba.com'
VUE_APP_BASE_API = 'http://172.16.32.79:48082' # VUE_APP_BASE_API = 'http://172.16.32.79:48082'
# 路由懒加载 # 路由懒加载

View File

@@ -62,10 +62,10 @@ export function getEquipmentAll() {
export function getTree(query) { export function getTree(query) {
return request({ return request({
url: '/base/factory/getTree', url: '/base/factory/getTreeSimple',
method: 'get', method: 'get',
params: query params: query,
}) });
} }
export function getEquipmentOverall(data) { export function getEquipmentOverall(data) {

View File

@@ -54,7 +54,7 @@ export default {
}; };
}, },
created() { created() {
this.currentMenu = this.menus[0]; // this.currentMenu = this.menus[0];
}, },
watch: { watch: {
currentMenu(val) { currentMenu(val) {

View File

@@ -63,7 +63,7 @@
style="width: 75%" style="width: 75%"
v-model="dataForm.price" v-model="dataForm.price"
clearable clearable
placeholder="请输入允许留存时间" /> placeholder="请输入单价" />
{{ unit }} {{ unit }}
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -140,13 +140,15 @@ export default {
setTimeout(this.setCode(), 1000); setTimeout(this.setCode(), 1000);
} }
}, },
setCode() { setCode() {
console.log('this.MaterialList', this.urlOptions.dictArr.dict0);
this.MaterialList.forEach((item) => { this.MaterialList.forEach((item) => {
if (item.id === this.dataForm.materialId) { if (item.id === this.dataForm.materialId) {
this.dataForm.code = item.code; this.dataForm.code = item.code;
this.unit = this.unit =
'元/' + '元/' +
this.urlOptions.dictArr.dict0.find((d) => d.value === item.unit) this.urlOptions.dictArr.dict0.find((d) => d.value == item.unit)
.label; .label;
} }
}); });

View File

@@ -128,7 +128,7 @@ export default {
this.tableData = response.data; this.tableData = response.data;
this.dataListLoading = false; this.dataListLoading = false;
}); });
}, },
handleClick(val) { handleClick(val) {
const data = { const data = {
...this.time, ...this.time,

View File

@@ -90,6 +90,7 @@ export default {
param: 'lineIds', param: 'lineIds',
defaultSelect: [], defaultSelect: [],
multiple: true, multiple: true,
collapseTags: true,
filterable: true, filterable: true,
width: 300, width: 300,
}, },

View File

@@ -80,6 +80,16 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label=" 基板类型" prop="typeDictValue">
<el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable
style="width: 100%" placeholder="请选择基板类型">
<el-option v-for="dict in typeList" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true"> <small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
@@ -131,160 +141,184 @@
<script> <script>
import { import {
deleteProductAttr, deleteProductAttr,
getProductAttrPage, getProductAttrPage,
} from '@/api/core/base/productAttr'; } from '@/api/core/base/productAttr';
import { import {
createProduct, createProduct,
updateProduct, updateProduct,
getProduct, getProduct,
getCode, getCode,
} from '@/api/core/base/product'; } from '@/api/core/base/product';
import productAttrAdd from './attr-add'; import productAttrAdd from './attr-add';
import { parseTime } from '../../mixins/code-filter'; import { parseTime } from '../../mixins/code-filter';
import SmallTitle from './SmallTitle'; import SmallTitle from './SmallTitle';
import { listData } from "@/api/system/dict/data"; //数据字典接口
const tableBtn = [ const tableBtn = [
{ {
type: 'edit', type: 'edit',
btnName: '编辑', btnName: '编辑',
}, },
{ {
type: 'delete', type: 'delete',
btnName: '删除', btnName: '删除',
}, },
]; ];
const tableProps = [ const tableProps = [
{ {
prop: 'createTime', prop: 'createTime',
label: '添加时间', label: '添加时间',
filter: parseTime, filter: parseTime,
}, },
{ {
prop: 'name', prop: 'name',
label: '属性名', label: '属性名',
}, },
{ {
prop: 'value', prop: 'value',
label: '属性值', label: '属性值',
}, },
]; ];
export default { export default {
components: { productAttrAdd, SmallTitle }, components: { productAttrAdd, SmallTitle },
data() { data() {
return { return {
visible: false, visible: false,
addOrUpdateVisible: false, addOrUpdateVisible: false,
tableBtn, tableBtn,
tableProps, tableProps,
productAttributeList: [], productAttributeList: [],
dataForm: { dataForm: {
id: null, id: null,
name: '', // 产品名称 name: '', // 产品名称
code: '', // 产品编码 code: '', // 产品编码
area: 0, // 深加工单位平方数(float only) area: 0, // 深加工单位平方数(float only)
typeDictValue: null, // 产品类型id typeDictValue: null, // 产品类型id
processTime: null, // 单位产品用时 (s) processTime: null, // 单位产品用时 (s)
specifications: '', // 深加工规格 specifications: '', // 深加工规格
unitDictValue: '', // 单位id unitDictValue: '', // 单位id
originalSpecifications: '', // 原片规格 originalSpecifications: '', // 原片规格
originalArea: 0, // 原片单位平方数 originalArea: 0, // 原片单位平方数
processTypes: [], processTypes: [],
}, typeDictValue: null,
listQuery: { },
pageSize: 10, typeList:[],
pageNo: 1, listQuery: {
total: 0, pageSize: 10,
pageNo: 1,
total: 0,
}, },
processTypeList: [ processTypeList: [
{ // {
value: '1', // value: '1',
label:'压花丝印' // label: '压花丝印'
}, // },
{ // {
value: '2', // value: '2',
label: '无印打孔' // label: '无印打孔'
}, // },
{ // {
value: '3', // value: '3',
label: '单层镀膜' // label: '单层镀膜'
}, { // }, {
value: '4', // value: '4',
label: '双层镀膜' // label: '双层镀膜'
} // }
], ],
dataRule: { dataRule: {
code: [ code: [
{ {
required: true, required: true,
message: '产品编码不能为空', message: '产品编码不能为空',
trigger: 'blur', trigger: 'blur',
}, },
// { // {
// type: 'number', // type: 'number',
// message: '产品编码为数字类型', // message: '产品编码为数字类型',
// trigger: 'blur', // trigger: 'blur',
// transfom: 'val => Number(val)', // transfom: 'val => Number(val)',
// }, // },
], ],
name: [ name: [
{ {
required: true, required: true,
message: '产品名称不能为空', message: '产品名称不能为空',
trigger: 'blur', trigger: 'blur',
}, },
], ],
typeDictValue: [ typeDictValue: [
{ {
required: true, required: true,
message: '产品类型不能为空', message: '产品类型不能为空',
trigger: 'blur', trigger: 'blur',
}, },
], ],
area: [ area: [
{ {
type: 'number', type: 'number',
message: '请输入正确的数值', message: '请输入正确的数值',
trigger: 'change', trigger: 'change',
transform: (val) => Number(val), transform: (val) => Number(val),
}, },
], ],
processTime: [ processTime: [
{ {
required: true, required: true,
message: '完成单位产品用时不能为空', message: '完成单位产品用时不能为空',
trigger: 'blur', trigger: 'blur',
}, },
{ {
type: 'number', type: 'number',
message: '请输入正确的数值', message: '请输入正确的数值',
trigger: 'blur', trigger: 'blur',
transform: (val) => Number(val), transform: (val) => Number(val),
}, },
], ],
}, },
isdetail: false, isdetail: false,
}; };
}, },
methods: { methods: {
initData() { async initData() {
this.productAttributeList.splice(0); this.productAttributeList.splice(0);
this.listQuery.total = 0; this.listQuery.total = 0;
}, const typeRes = await listData({
init(id, isdetail) { pageNo:
this.initData(); 1,
this.isdetail = isdetail || false; pageSize
: 10,
dictType
: 'product_type'
})
this.typeList = typeRes.data.list
console.log('typeRes', this.typeList);
const processTypeRes = await listData({
pageNo:
1,
pageSize
: 10,
dictType
: 'process_type'
})
this.processTypeList = processTypeRes.data.list
console.log('typeRes', this.typeList);
},
init(id, isdetail) {
this.initData();
this.isdetail = isdetail || false;
this.dataForm.id = id || null; this.dataForm.id = id || null;
// this.dataForm.processTypes = [] // 清空工艺选择 // this.dataForm.processTypes = [] // 清空工艺选择
this.visible = true; this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['dataForm'].resetFields(); this.$refs['dataForm'].resetFields();
if (this.dataForm.id) { if (this.dataForm.id) {
// 获取产品详情 // 获取产品详情
getProduct(id).then((res) => { getProduct(id).then((res) => {
const resData = res.data || {}; const resData = res.data || {};
// 逐个字段赋值(保留响应式) // 逐个字段赋值(保留响应式)
@@ -305,161 +339,163 @@ export default {
console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式 console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式
}); });
// 获取产品的属性列表 // 获取产品的属性列表
this.getList(); this.getList();
} else { } else {
getCode().then((res) => { getCode().then((res) => {
this.dataForm.code = res.data; this.dataForm.code = res.data;
}); });
} }
}); });
}, },
getList() { getList() {
// 获取产品的属性列表 // 获取产品的属性列表
getProductAttrPage({ getProductAttrPage({
...this.listQuery, ...this.listQuery,
productId: this.dataForm.id, productId: this.dataForm.id,
}).then((response) => { }).then((response) => {
this.productAttributeList = response.data.list; this.productAttributeList = response.data.list;
this.listQuery.total = response.data.total; this.listQuery.total = response.data.total;
}); });
}, },
handleClick(raw) { handleClick(raw) {
if (raw.type === 'delete') { if (raw.type === 'delete') {
this.$confirm( this.$confirm(
`确定对${ `确定对${raw.data.name
raw.data.name ? '[名称=' + raw.data.name + ']'
? '[名称=' + raw.data.name + ']' : '[序号=' + raw.data._pageIndex + ']'
: '[序号=' + raw.data._pageIndex + ']' }进行删除操作?`,
}进行删除操作?`, '提示',
'提示', {
{ confirmButtonText: '确定',
confirmButtonText: '确定', cancelButtonText: '取消',
cancelButtonText: '取消', type: 'warning',
type: 'warning', }
} )
) .then(() => {
.then(() => { deleteProductAttr(raw.data.id).then(({ data }) => {
deleteProductAttr(raw.data.id).then(({ data }) => { this.$message({
this.$message({ message: '操作成功',
message: '操作成功', type: 'success',
type: 'success', duration: 1500,
duration: 1500, onClose: () => {
onClose: () => { this.getList();
this.getList(); },
}, });
}); });
}); })
}) .catch(() => { });
.catch(() => {}); } else {
} else { this.addNew(raw.data.id);
this.addNew(raw.data.id); }
} },
}, // 表单提交
// 表单提交 dataFormSubmit() {
dataFormSubmit() { this.$refs['dataForm'].validate((valid) => {
this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
// 修改的提交
if (this.dataForm.id) { // 修改的提交
updateProduct(this.dataForm).then((response) => { if (this.dataForm.id) {
this.$modal.msgSuccess('修改成功'); updateProduct(this.dataForm).then((response) => {
this.visible = false; this.$modal.msgSuccess('修改成功');
this.$emit('refreshDataList'); this.visible = false;
}); this.$emit('refreshDataList');
return; });
} return;
// 添加的提交 }
createProduct(this.dataForm).then((response) => { // 添加的提交
this.$modal.msgSuccess('新增成功'); createProduct(this.dataForm).then((response) => {
this.$confirm(`是否新增产品属性?`, '系统提示', { this.$modal.msgSuccess('新增成功');
confirmButtonText: '确定', this.$confirm(`是否新增产品属性?`, '系统提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning', cancelButtonText: '取消',
}) type: 'warning',
.then(() => { })
.then(() => {
this.dataForm.id = response.data this.dataForm.id = response.data
this.addNew(); this.addNew();
}) })
.catch(() => { .catch(() => {
this.visible = false; this.visible = false;
this.$emit('refreshDataList'); this.$emit('refreshDataList');
}); });
}); });
} }
}); });
}, },
goEdit() { goEdit() {
this.isdetail = false; this.isdetail = false;
}, },
// 新增 / 修改 // 新增 / 修改
addNew(id) { addNew(id) {
if (this.dataForm.id) { if (this.dataForm.id) {
this.addOrUpdateVisible = true; this.addOrUpdateVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.addOrUpdate.init(id); this.$refs.addOrUpdate.init(id);
}); });
} else { } else {
this.$message('请先创建产品!'); this.$message('请先创建产品!');
} }
}, },
goback() { goback() {
this.$emit('refreshDataList'); this.$emit('refreshDataList');
this.visible = false; this.visible = false;
this.initData(); this.initData();
}, },
}, },
}; };
</script> </script>
<style scoped> <style scoped>
.drawer >>> .el-drawer { .drawer>>>.el-drawer {
border-radius: 8px 0 0 8px; border-radius: 8px 0 0 8px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.drawer >>> .el-form-item__label { .drawer>>>.el-form-item__label {
padding: 0; padding: 0;
} }
.drawer >>> .el-drawer__header { .drawer>>>.el-drawer__header {
margin: 0; margin: 0;
padding: 32px 32px 24px; padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6; border-bottom: 1px solid #dcdfe6;
}
.drawer >>> .el-drawer__body {
flex: 1;
height: 1px;
display: flex;
flex-direction: column;
} }
.drawer >>> .content { .drawer>>>.el-drawer__body {
padding: 30px 24px; flex: 1;
flex: 1; height: 1px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* height: 100%; */
} }
.drawer >>> .visual-part { .drawer>>>.content {
flex: 1 auto; padding: 30px 24px;
max-height: 76vh; flex: 1;
overflow: hidden; display: flex;
overflow-y: scroll; flex-direction: column;
padding-right: 10px; /* 调整滚动条样式 */ /* height: 100%; */
} }
.drawer >>> .el-form, .drawer>>>.visual-part {
.drawer >>> .attr-list { flex: 1 auto;
padding: 0 16px; max-height: 76vh;
overflow: hidden;
overflow-y: scroll;
padding-right: 10px;
/* 调整滚动条样式 */
}
.drawer>>>.el-form,
.drawer>>>.attr-list {
padding: 0 16px;
} }
.drawer-body__footer { .drawer-body__footer {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
padding: 18px; padding: 18px;
} }
</style> </style>

View File

@@ -104,7 +104,11 @@ export default {
getDataListURL: getProductionLinePage, getDataListURL: getProductionLinePage,
deleteURL: deleteProductionLine, deleteURL: deleteProductionLine,
exportURL: exportProductionLineExcel, exportURL: exportProductionLineExcel,
}, },
listQuery: {
pageSize: 20,
pageNo:1
},
tableProps, tableProps,
tableBtn: [ tableBtn: [
this.$auth.hasPermi(`base:production-line:update`) this.$auth.hasPermi(`base:production-line:update`)
@@ -212,7 +216,7 @@ export default {
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
this.listQuery.pageNo = 1; this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10; this.listQuery.pageSize = 20;
this.listQuery.factoryId = val.factoryId || undefined; this.listQuery.factoryId = val.factoryId || undefined;
this.listQuery.name = val.name; this.listQuery.name = val.name;
this.getDataList(); this.getDataList();
@@ -220,7 +224,7 @@ export default {
case 'reset': case 'reset':
this.$refs.searchBarForm.resetForm(); this.$refs.searchBarForm.resetForm();
this.listQuery = { this.listQuery = {
pageSize: 10, pageSize: 20,
pageNo: 1, pageNo: 1,
total: 1, total: 1,
}; };

View File

@@ -519,6 +519,12 @@ export default {
btnName: '重置', btnName: '重置',
name: 'reset', name: 'reset',
}, },
// {
// type: 'label', // 初始隐藏
// label: '刷新时间', // 自定义标识
// // slot: 'currentTimeSlot', // 自定义插槽名
// // width: 200, // 宽度适配
// },
] ]
}; };
}, },
@@ -541,7 +547,7 @@ export default {
{ {
prop: 'processType', prop: 'processType',
label: '产品类型', label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'), filter: (val) => (val === 1 ? '面板' : '背板'),
fixed: true, fixed: true,
sortable: true, sortable: true,
}, },
@@ -588,12 +594,12 @@ export default {
// end.getTime() // end.getTime()
// ]; // ];
this.$refs.searchBarForm.formInline.timeType = 1 this.$refs.searchBarForm.formInline.timeType = 3
} }
}); });
this.getDayDataList(); // this.getLastDayDataList();
this.getPdLineList(); this.getPdLineList();
const queryParams = { const queryParams = {
pageNo: 1, pageNo: 1,
@@ -642,6 +648,12 @@ export default {
this.formConfig[1].type = ''; // 隐藏查询类型 this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型 this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围 this.formConfig[7].type = ''; // 隐藏时间范围
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
}; };
// 3. 执行公共重置 // 3. 执行公共重置
@@ -656,14 +668,43 @@ export default {
this.formConfig[3].type = 'select'; // 显示产线 this.formConfig[3].type = 'select'; // 显示产线
this.formConfig[4].type = ''; // 隐藏产品工艺 this.formConfig[4].type = ''; // 隐藏产品工艺
this.formConfig[5].type = ''; // 隐藏产品类型 this.formConfig[5].type = ''; // 隐藏产品类型
this.getDayDataList(); this.listQuery.timeType = 3;
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.formInline.timeType = 3;
}
// 主动调用上一班数据接口
this.getLastDayDataList();
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
} else { } else {
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班 // 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班 this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
this.formConfig[3].type = ''; // 隐藏产线 this.formConfig[3].type = ''; // 隐藏产线
this.formConfig[4].type = 'select'; // 显示产品工艺 this.formConfig[4].type = 'select'; // 显示产品工艺
this.formConfig[5].type = 'select'; // 显示产品类型 this.formConfig[5].type = 'select'; // 显示产品类型
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
this.getProductList(); this.getProductList();
} }
@@ -995,6 +1036,26 @@ export default {
} }
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
// 仅当时间维度为【当天】时,添加/更新刷新时间
if (this.listQuery.timeType === 1 || this.listQuery.timeType === 3) {
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
} else if (timeItemIndex > -1) {
// 非当天时,移除刷新时间
this.formConfig.splice(timeItemIndex, 1);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
if (this.listQuery.timeType === 1) { if (this.listQuery.timeType === 1) {
this.getDayDataList(); this.getDayDataList();
@@ -1012,7 +1073,7 @@ export default {
break; break;
case 'reset': case 'reset':
this.$refs.searchBarForm.resetForm(); this.$refs.searchBarForm.resetForm();
this.$refs.searchBarForm.formInline.timeType = 1; this.$refs.searchBarForm.formInline.timeType = 3;
this.formConfig[0].selectOptions = this.activeName === 'productLine' this.formConfig[0].selectOptions = this.activeName === 'productLine'
? this.timeTypeOptions.productLine ? this.timeTypeOptions.productLine
: this.timeTypeOptions.product; : this.timeTypeOptions.product;
@@ -1020,10 +1081,23 @@ export default {
pageSize: 100, pageSize: 100,
pageNo: 1, pageNo: 1,
total: 0, total: 0,
timeType: 1, timeType: this.activeName === 'productLine' ? 3 : 1,
}; };
// 重置后默认是当天,添加刷新时间
const resetTimeIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const resetTimeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (resetTimeIndex > -1) {
this.formConfig.splice(resetTimeIndex, 1, resetTimeLabel);
} else {
this.formConfig.push(resetTimeLabel);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
this.getDayDataList(); this.getLastDayDataList();
} else { } else {
this.getProductList(); this.getProductList();
} }
@@ -1350,29 +1424,48 @@ export default {
this.listQuery.pageNo = val; this.listQuery.pageNo = val;
this.getDataList(); this.getDataList();
}, },
formatCurrentTime() {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${hours}:${minutes}:${seconds} ${year}.${month}.${day}`;
},
// 搜索栏下拉选择变化 // 搜索栏下拉选择变化
handleSearchBarChanged({ param, value }) { handleSearchBarChanged({ param, value }) {
if (param === 'timeType') { if (param === 'timeType') {
console.log(value);
this.listQuery.timeType = value; this.listQuery.timeType = value;
if (value === 2) { const timeItemIndex = this.formConfig.findIndex(item =>
// 切换为“自定义”:显示查询类型和时间范围 item.label?.includes('刷新时间')
);
// 仅移除,不添加(查询时才添加)
if (value !== 1 && value !== 3 && timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
this.$refs.searchBarForm.formInline.timeType = value;
this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
if (value === 1) {
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
} else if (value === 2) {
this.formConfig[1].type = 'select'; this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.timeType = value; this.$refs.searchBarForm.formInline.searchType = 1;
this.listQuery.timeType = value;
this.formConfig[7].type = 'datePicker'; this.formConfig[7].type = 'datePicker';
} else { } else {
this.formConfig[1].type = ''; this.formConfig[1].type = '';
this.formConfig[6].type = ''; this.formConfig[6].type = '';
this.formConfig[7].type = ''; this.formConfig[7].type = '';
this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value;
this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
} }
} else if (param === 'searchType') { } else if (param === 'searchType') {
if (value === 1) { if (value === 1) {
// 统计数据:显示时间范围,隐藏报表类型 // 统计数据:显示时间范围,隐藏报表类型
@@ -1422,7 +1515,10 @@ export default {
label: '时间范围', label: '时间范围',
dateType: 'week', dateType: 'week',
placeholder: '选择日期', placeholder: '选择日期',
format: 'yyyy-MM-dd', format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek', param: 'timeValWeek',
width: 250, width: 250,

View File

@@ -204,94 +204,88 @@ export default {
); );
}); });
}, },
test() { exportXlsx() {
var target = document.getElementsByClassName("right-aside")[0] if (!this.showData.length) {
target.style.background = '#FFFFFF' this.$message.warning('暂无数据可导出');
var that = this return;
setTimeout(() => {
html2canvas(target).then(function(canvas) {
var contentWidth = canvas.width
var contentHeight = canvas.height
// 一页pdf显示html页面生成的canvas高度
var pageHeight = contentHeight / 592.28 * 841.89
// 未生成pdf的html页面高度
var leftHeight = contentHeight
// 页面偏移
var position = 0
// a4纸的尺寸[595.28,841.89]html页面生成的canvas在pdf中图片的高度
var imgWidth = 595.28
var imgHeight = 592.28 / contentWidth * contentHeight
var pageData = canvas.toDataURL('image/jpeg', 1.0)
console.log('nihc URL', leftHeight, pageHeight)
var pdf = new jsPDF('', 'pt', 'a4')
if (leftHeight < pageHeight) {
pdf.addImage(pageData, 'JPEG', 0, 20, imgWidth, imgHeight)
} else {
while(leftHeight > 0) {
pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
leftHeight -= pageHeight
position -= 841.89
// 避免空白页
if (leftHeight > 0) {
pdf.addPage()
}
}
}
pdf.save(that.fileName + '工段统计.pdf')
})
}, 300)
},
exportECL() {
let tables = document.querySelector('.el-table').cloneNode(true)
const fix = tables.querySelector('.el-table__fixed')
const fixRight = tables.querySelector('.el-table__fixed-right')
if (fix) {
tables.removeChild(tables.querySelector('.el-table__fixed'))
}
if (fixRight) {
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
}
let exportTable = XLSX.utils.table_to_book(tables)
var exportTableOut = XLSX.write(exportTable, {
bookType: 'xlsx', bookSST: true, type: 'array'
})
// sheetjs.xlsx为导出表格的标题名称
try {
FileSaver.saveAs(new Blob([exportTableOut], {
type: 'application/octet-stream'
}), this.fileName + '工段统计.xlsx')
} catch (e) {
if (typeof console !== 'undefined') console.log(e, exportTableOut)
} }
return exportTableOut
},
exportPdf() {
this.test()
setTimeout(() =>{
this.dialogVisible = false
this.showData = this.tableData
}, 600)
}, this.exportLoading = true;
exportXlsx() {
this.exportECL() try {
this.dialogVisible = false // 1. 处理导出数据(格式化时间字段)
this.showData = this.tableData const exportData = this.showData.map(item => {
}, const formatItem = { ...item };
handleClose(done) { // 格式化时间字段
this.$confirm('确认关闭?') if (formatItem.startTime) formatItem.startTime = parseTime(formatItem.startTime);
.then(_ => { if (formatItem.endTime) formatItem.endTime = parseTime(formatItem.endTime);
done(); return formatItem;
}) });
.catch(_ => {});
}, // 2. 构建表头映射:{ prop: label },只保留表格配置中存在的列
const headerMap = {};
this.tableProps.forEach(col => {
if (col.prop && col.label) {
headerMap[col.prop] = col.label;
}
});
// 3. 转换数据将prop键名替换为label按tableProps顺序排列列
const formattedData = exportData.map(item => {
const newItem = {};
// 按表格配置顺序遍历列确保Excel列顺序与表格一致
this.tableProps.forEach(col => {
const prop = col.prop;
const label = col.label;
if (prop && label) {
// 处理可能的undefined值避免导出为空字符串
newItem[label] = item[prop] ?? '';
}
});
return newItem;
});
// 4. 创建工作表使用处理后的带label表头的数据
const worksheet = XLSX.utils.json_to_sheet(formattedData);
// 5. 创建工作簿并添加工作表
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, '下片日志数据');
// 6. 生成Excel文件
const excelBuffer = XLSX.write(workbook, {
bookType: 'xlsx',
type: 'array'
});
// 7. 保存文件
const blob = new Blob([excelBuffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
});
// 8. 生成文件名(包含查询条件信息)
let fileName = '下片历史';
if (this.listQuery.productionLineId) {
const lineItem = this.formConfig[0].selectOptions.find(
item => item.id === this.listQuery.productionLineId
);
if (lineItem) fileName += lineItem.name + '_';
}
if (this.listQuery.thick) {
fileName += this.listQuery.thick + '_';
}
// 添加时间戳避免文件名重复
fileName += + '.xlsx';
FileSaver.saveAs(blob, fileName);
this.$message.success('导出成功');
} catch (error) {
console.error('导出失败:', error);
this.$message.error('导出失败,请重试');
} finally {
this.exportLoading = false;
}
},
getPdLineList() { getPdLineList() {
getPdList().then((res) => { getPdList().then((res) => {
this.formConfig[0].selectOptions = res.data || [] this.formConfig[0].selectOptions = res.data || []
@@ -323,7 +317,7 @@ export default {
this.getDataList(); this.getDataList();
break; break;
case 'export': case 'export':
this.handleExport(); this.exportXlsx();
break; break;
default: default:
console.log(val); console.log(val);
@@ -351,12 +345,6 @@ export default {
this.listQuery.pageNo = val; this.listQuery.pageNo = val;
this.getDataList(); this.getDataList();
}, },
handleExport() {
if (this.selectedList.length > 0) {
this.showData = this.selectedList
}
this.dialogVisible = true
}
}, },
}; };
</script> </script>

View File

@@ -570,22 +570,35 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
// 1. 强制设置当前激活标签为 按产品监控
this.activeName = 'product';
if (this.$refs.buttonNav) { if (this.$refs.buttonNav) {
this.$refs.buttonNav.currentMenu = '按产品监控'; this.$refs.buttonNav.currentMenu = '按产品监控';
// 时间维度选项只显示 当天/自定义(无 上一班)
this.formConfig[0].selectOptions = this.timeTypeOptions.product; this.formConfig[0].selectOptions = this.timeTypeOptions.product;
} }
if (this.$refs.searchBarForm) { if (this.$refs.searchBarForm) {
// this.$refs.searchBarForm.formInline.timeVal = [ // 2. 强制设置搜索表单的 timeType 为 1当天
// yesterday.getTime(), this.$refs.searchBarForm.formInline.timeType = 1;
// end.getTime() // 同步查询参数的 timeType
// ]; this.listQuery.timeType = 1;
}
this.$refs.searchBarForm.formInline.timeType = 1 const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
} }
}); });
this.getDayDataList(); // 3. 初始化直接调用 按产品监控 的接口
this.getProductList();
this.getPdLineList(); this.getPdLineList();
const queryParams = { const queryParams = {
pageNo: 1, pageNo: 1,
@@ -597,11 +610,22 @@ export default {
}); });
}, },
methods: { methods: {
formatCurrentTime() {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${hours}:${minutes}:${seconds} ${year}.${month}.${day}`;
},
// 切换按产线/按产品监控 // 切换按产线/按产品监控
currentMenu(val) { currentMenu(val) {
// 1. 确定当前激活的类型(产线/产品) // 1. 确定当前激活的类型(产线/产品)
const isProductLine = val === '按产线监控'; const isProductLine = val === '按产线监控';
this.activeName = isProductLine ? 'productLine' : 'product'; this.activeName = isProductLine ? 'productLine' : 'product';
console.log('isProductLine', isProductLine);
// 2. 提取公共重置逻辑(无论切换到哪个标签,都需要执行的操作) // 2. 提取公共重置逻辑(无论切换到哪个标签,都需要执行的操作)
const resetCommon = () => { const resetCommon = () => {
@@ -634,11 +658,19 @@ export default {
this.formConfig[1].type = ''; // 隐藏查询类型 this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型 this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围 this.formConfig[7].type = ''; // 隐藏时间范围
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
}; };
// 3. 执行公共重置 // 3. 执行公共重置
resetCommon(); resetCommon();
// if (this.activeName === 'productLine') {
// } else {
// }
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分) // 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
if (isProductLine) { if (isProductLine) {
// 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班 // 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班
@@ -646,16 +678,44 @@ export default {
this.formConfig[3].type = 'select'; // 显示产线 this.formConfig[3].type = 'select'; // 显示产线
this.formConfig[4].type = ''; // 隐藏产品工艺 this.formConfig[4].type = ''; // 隐藏产品工艺
this.formConfig[5].type = ''; // 隐藏产品类型 this.formConfig[5].type = ''; // 隐藏产品类型
this.getDayDataList(); this.listQuery.timeType = 3;
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.formInline.timeType = 3;
}
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
// 主动调用上一班数据接口
this.getLastDayDataList();
} else { } else {
this.getProductList();
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班 // 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班 this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
this.formConfig[3].type = ''; // 隐藏产线 this.formConfig[3].type = ''; // 隐藏产线
this.formConfig[4].type = 'select'; // 显示产品工艺 this.formConfig[4].type = 'select'; // 显示产品工艺
this.formConfig[5].type = 'select'; // 显示产品类型 this.formConfig[5].type = 'select'; // 显示产品类型
this.getProductList();
} }
}, },
@@ -947,6 +1007,25 @@ export default {
} }
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
// 仅当时间维度为【当天】时,添加/更新刷新时间
if (this.listQuery.timeType === 1 || this.listQuery.timeType === 3) {
const timeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else {
this.formConfig.push(timeLabel);
}
} else if (timeItemIndex > -1) {
// 非当天时,移除刷新时间
this.formConfig.splice(timeItemIndex, 1);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
if (this.listQuery.timeType === 1) { if (this.listQuery.timeType === 1) {
this.getDayDataList(); this.getDayDataList();
@@ -965,15 +1044,27 @@ export default {
case 'reset': case 'reset':
this.$refs.searchBarForm.resetForm(); this.$refs.searchBarForm.resetForm();
this.$refs.searchBarForm.formInline.timeType = 1; this.$refs.searchBarForm.formInline.timeType = 1;
this.formConfig[0].selectOptions = this.activeName === 'productLine' this.formConfig[0].selectOptions = this.activeName === 'product'
? this.timeTypeOptions.productLine ? this.timeTypeOptions.productLine
: this.timeTypeOptions.product; : this.timeTypeOptions.product;
this.listQuery = { this.listQuery = {
pageSize: 100, pageSize: 100,
pageNo: 1, pageNo: 1,
total: 0, total: 0,
timeType: 1, timeType: this.activeName === 'productLine' ? 3 : 1,
}; };
const resetTimeIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
const resetTimeLabel = {
type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`,
};
if (resetTimeIndex > -1) {
this.formConfig.splice(resetTimeIndex, 1, resetTimeLabel);
} else {
this.formConfig.push(resetTimeLabel);
}
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
this.getDayDataList(); this.getDayDataList();
} else { } else {
@@ -1307,24 +1398,33 @@ export default {
handleSearchBarChanged({ param, value }) { handleSearchBarChanged({ param, value }) {
console.log(value, param); console.log(value, param);
if (param === 'timeType') { if (param === 'timeType') {
console.log(value);
this.listQuery.timeType = value; this.listQuery.timeType = value;
if (value === 2) { const timeItemIndex = this.formConfig.findIndex(item =>
// 切换为“自定义”:显示查询类型和时间范围 item.label?.includes('刷新时间')
);
// 仅移除,不添加(查询时才添加)
if (value !== 1 && value !== 3 && timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
this.$refs.searchBarForm.formInline.timeType = value;
this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
if (value === 1) {
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
} else if (value === 2) {
this.formConfig[1].type = 'select'; this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.timeType = value; this.$refs.searchBarForm.formInline.searchType = 1;
this.listQuery.timeType = value;
this.formConfig[7].type = 'datePicker'; this.formConfig[7].type = 'datePicker';
} else { } else {
this.formConfig[1].type = ''; this.formConfig[1].type = '';
this.formConfig[6].type = ''; this.formConfig[6].type = '';
this.formConfig[7].type = ''; this.formConfig[7].type = '';
this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value;
this.$refs.searchBarForm.formInline.searchType = undefined;
this.$refs.searchBarForm.formInline.reportType = undefined;
this.$refs.searchBarForm.formInline.timeVal = undefined;
} }
} else if (param === 'searchType') { } else if (param === 'searchType') {
if (value === 1) { if (value === 1) {
@@ -1375,7 +1475,10 @@ export default {
label: '时间范围', label: '时间范围',
dateType: 'week', dateType: 'week',
placeholder: '选择日期', placeholder: '选择日期',
format: 'yyyy-MM-dd', format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek', param: 'timeValWeek',
width: 250, width: 250,

View File

@@ -244,7 +244,10 @@ export default {
label: '统计时间', label: '统计时间',
dateType: 'week', dateType: 'week',
placeholder: '选择日期', placeholder: '选择日期',
format: 'yyyy-MM-dd', format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek', param: 'timeValWeek',
width: 250, width: 250,
@@ -453,11 +456,10 @@ export default {
item.statisticType = this.listQuery.statisticType; item.statisticType = this.listQuery.statisticType;
// 匹配产线名称 // 匹配产线名称
const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId); // const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
item.bindObjectName = targetLine ? targetLine.name : ''; // item.bindObjectName = targetLine ? targetLine.name : ''
return item; return item;
}); })
this.listQuery.total = response.data?.total || 0; this.listQuery.total = response.data?.total || 0;
}) })
.catch(err => { .catch(err => {

View File

@@ -1,423 +1,430 @@
<template> <template>
<div class="home-page"> <div class="app-container">
<div class="date-tabs"> <!-- 顶部日期&筛选栏 -->
<!-- @tab-click="handleClick" --> <el-row :gutter="20" class="top-bar">
<el-tabs v-model="activeName" @tab-click="timedayChange" :stretch="true"> <el-col :span="8">
<el-tab-pane
:label="'\u2002\u2002日\u2002\u2002'"
name="日"></el-tab-pane>
<el-tab-pane
:label="'\u2002\u2002周\u2002\u2002'"
name="周"></el-tab-pane>
<el-tab-pane
:label="'\u2002\u2002月\u2002\u2002'"
name="月"></el-tab-pane>
<el-tab-pane
:label="'\u2002\u2002年\u2002\u2002'"
name="年"></el-tab-pane>
</el-tabs>
<div class="detail">
<el-date-picker <el-date-picker
v-model="timeday" v-model="dateRange"
align="right" type="daterange"
type="date" range-separator="~"
format="yyyy-MM-dd" start-placeholder="开始日期"
valueFormat="yyyy-MM-dd" end-placeholder="结束日期"
:clearable="false" value-format="yyyy-MM-dd" />
@change="timedayChange" <el-button type="primary" style="margin-left: 10px">查询</el-button>
placeholder="选择日期"
:picker-options="pickerOptions"></el-date-picker>
</div>
</div>
<el-row class="main-top" :gutter="16">
<el-col :span="24" style="position: relative">
<div class="title">
<svg-icon icon-class="home-produce" />
<span class="title-inner">生产总成本</span>
</div>
<el-row class="box">
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.priceS }}万元</div>
<div class="unit-style">总计成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.matPriceS }}万元</div>
<div class="unit-style">原料成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.energyPriceS }}万元</div>
<div class="unit-style">能源成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.otherPriceS }}万元</div>
<div class="unit-style">其他成本</div>
</el-col>
<!-- <el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.ratioS }}</div>
<div class="unit-style">综合良品率/%</div>
</el-col> -->
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.areaPriceS }}</div>
<div class="unit-style">综合每平米成本</div>
</el-col>
</el-row>
</el-col> </el-col>
<el-col :span="24" style="position: relative"> <el-col :span="16">
<div class="title"> <el-tag type="info" @click="changeTime('yesterday')">昨日</el-tag>
<svg-icon icon-class="home-produce" /> <el-tag type="info" @click="changeTime('week')">本周</el-tag>
<span class="title-inner">原片成本</span> <el-tag type="info" @click="changeTime('month')">本月</el-tag>
</div> <el-tag type="info" @click="changeTime('year')">本年</el-tag>
<el-row class="box">
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.priceO }}万元</div>
<div class="unit-style">原片总成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.matPriceO }}万元</div>
<div class="unit-style">原料成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.energyPriceO }}万元</div>
<div class="unit-style">能源成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.otherPriceO }}万元</div>
<div class="unit-style">其他成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.ratioO }}</div>
<div class="unit-style">原片良品率/%</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.areaPriceO }}</div>
<div class="unit-style">原片每平米成本</div>
</el-col>
</el-row>
</el-col>
<el-col :span="24" style="position: relative">
<div class="title">
<svg-icon icon-class="home-produce" />
<span class="title-inner">深加工成本</span>
</div>
<el-row class="box">
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.priceD }}万元</div>
<div class="unit-style">深加工总成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.energyPriceD }}万元</div>
<div class="unit-style">能源成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.otherPriceD }}万元</div>
<div class="unit-style">其他成本</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.ratioD }}</div>
<div class="unit-style">深加工良品率/%</div>
</el-col>
<el-col :span="4" class="num-box shadow">
<div class="num-style">{{ homeData.areaPriceD }}</div>
<div class="unit-style">深加工每平米成本</div>
</el-col>
</el-row>
</el-col> </el-col>
</el-row> </el-row>
<el-row class="main-bottom" :gutter="16" v-if="false">
<el-col :span="9"> <!-- 成本概览卡片 -->
<div class="chart-wrapper"> <el-row :gutter="20" class="card-row">
<line-chart :chart-data="lineChartData" /> <el-col :span="8">
</div> <el-card class="cost-card">
</el-col> <div class="card-title">总制造成本/平米</div>
<el-col :span="7"> <div class="card-content">
<div class="chart-wrapper"> <div>
<pie-chart /> 目标
</div> <span class="target-val">16</span>
</div>
<div>
实际
<span class="actual-val">12.8</span>
</div>
<el-progress :stroke-width="13" :percentage="80" color="#42b983" />
</div>
</el-card>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<div class="chart-wrapper"> <el-card class="cost-card">
<bar-chart /> <div class="card-title">原片成本/平米</div>
</div> <div class="card-content">
<div>
目标
<span class="target-val">16</span>
</div>
<div>
实际
<span class="actual-val">12.8</span>
</div>
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
</div>
</el-card>
</el-col>
<el-col :span="8">
<el-card class="cost-card">
<div class="card-title">加工成本/平米</div>
<div class="card-content">
<div>
目标
<span class="target-val">16</span>
</div>
<div>
实际
<span class="actual-val">12.8</span>
</div>
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
</div>
</el-card>
</el-col>
</el-row>
<!-- 成本构成区域 -->
<el-row :gutter="20" class="composition-row">
<!-- 饼图 -->
<el-col :span="6">
<el-card class="composition-card">
<div class="card-title">成本构成</div>
<div id="costPie" class="chart" style="height: 350px"></div>
</el-card>
</el-col>
<!-- 原片/加工成本子项 -->
<el-col :span="18">
<el-card class="composition-card">
<div class="card-title">成本构成</div>
<!-- 原片成本子项 -->
<div class="sub-cost-group">
<div class="sub-cost-title">原片成本</div>
<div class="sub-cost">
<div
v-for="(item, idx) in rawSubCosts"
:key="idx"
class="sub-cost-div">
<div class="sub-cost-name">
{{ item.name }}
<div class="sub-cost-val">{{ item.val }}</div>
</div>
<div style="text-align: center">
<el-progress
type="circle"
:percentage="89"
:width="60"
:stroke-width="10"
:show-text="false"
color="#e74c3c" />
</div>
<div class="sub-cost-name">
目标
<span class="red-text">{{ item.target }}</span>
</div>
<div class="sub-cost-name">
完成率
<span class="red-text">89%</span>
</div>
</div>
</div>
</div>
<el-divider></el-divider>
<!-- 加工成本子项 -->
<div class="sub-cost-group" style="margin-top: 20px">
<div class="sub-cost-title">加工成本</div>
<div class="sub-cost">
<div
v-for="(item, idx) in processSubCosts"
:key="idx"
class="sub-cost-div">
<div class="sub-cost-name">
{{ item.name }}
<div class="sub-cost-val">{{ item.val }}</div>
</div>
<div style="text-align: center">
<el-progress
type="circle"
:percentage="89"
:width="60"
:stroke-width="10"
:show-text="false"
color="#e74c3c" />
</div>
<div class="sub-cost-name">
目标
<span class="red-text">{{ item.target }}</span>
</div>
<div class="sub-cost-name">
完成率
<span class="red-text">89%</span>
</div>
</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
<!-- 趋势图区域 -->
<el-row :gutter="20" class="trend-row">
<!-- 总制造成本趋势 -->
<el-col :span="8">
<el-card class="trend-card">
<div class="card-title">总制造成本趋势</div>
<div id="totalTrend" class="chart" style="height: 300px"></div>
</el-card>
</el-col>
<!-- 原片/加工成本趋势 -->
<el-col :span="8">
<el-card class="trend-card">
<div class="card-title">原片/加工成本趋势</div>
<el-tabs v-model="costTab" type="card" style="margin-bottom: 10px">
<el-tab-pane label="原片成本" name="raw"></el-tab-pane>
<el-tab-pane label="加工成本" name="process"></el-tab-pane>
</el-tabs>
<div id="rawProcessTrend" class="chart" style="height: 300px"></div>
</el-card>
</el-col>
<!-- 单项成本趋势 -->
<el-col :span="8">
<el-card class="trend-card">
<div class="card-title">单项成本趋势</div>
<el-tabs v-model="itemTab" type="card" style="margin-bottom: 10px">
<el-tab-pane label="人工成本" name="labor"></el-tab-pane>
<el-tab-pane label="原料成本" name="material"></el-tab-pane>
<el-tab-pane label="制造费用" name="expense"></el-tab-pane>
<el-tab-pane label="玻璃热耗" name="heat"></el-tab-pane>
<el-tab-pane label="原片成品率" name="yield"></el-tab-pane>
</el-tabs>
<div id="itemTrend" class="chart" style="height: 300px"></div>
</el-card>
</el-col> </el-col>
</el-row> </el-row>
<div
class="main-footer"
style="
color: #c7c7c7;
user-select: none;
font-size: 14px;
letter-spacing: 1px;
height: 30px;
display: grid;
place-content: center;
">
&copy; 中建材智能自动化研究院有限公司
</div>
</div> </div>
</template> </template>
<script> <script>
import moment from 'moment'; import * as echarts from 'echarts';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
import LineChart from '../dashboard/LineChart';
import PieChart from '../dashboard/PieChart';
import BarChart from '../dashboard/BarChart';
import PanelGroup from '../dashboard/PanelGroup';
import { getData } from '@/api/cost/allCost';
import { getUserProfile } from '@/api/system/user';
const lineChartData = {
newVisitis: {
expectedData: [100, 120, 161, 134, 105, 160, 165],
actualData: [120, 82, 91, 154, 162, 140, 145],
},
messages: {
expectedData: [200, 192, 120, 144, 160, 130, 140],
actualData: [180, 160, 151, 106, 145, 150, 130],
},
purchases: {
expectedData: [80, 100, 121, 104, 105, 90, 100],
actualData: [120, 90, 100, 138, 142, 130, 130],
},
shoppings: {
expectedData: [130, 140, 141, 142, 145, 150, 160],
actualData: [120, 82, 91, 154, 162, 140, 130],
},
};
export default { export default {
name: 'Home', name: 'CostDashboard',
mixins: [tableHeightMixin],
components: {
LineChart,
PieChart,
PanelGroup,
BarChart,
},
computed: {
gradientBackground() {
return {
'background-image':
'linear-gradient(90deg, #f0f0f0 25%, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0) 50%, #f0f0f0 50%, #f0f0f0 75%, rgba(255, 255, 255, 0) 75%, rgba(255, 255, 255, 0))',
'background-size': '100px 100px', // 调整条纹的大小
};
},
},
data() { data() {
return { return {
activeName: '日', dateRange: ['2023-05-06', '2023-05-06'],
user: '', costTab: 'raw',
lineChartData: lineChartData.newVisitis, itemTab: 'labor',
homeData: {}, // 原片成本子项
timeday: moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD'), rawSubCosts: [
startTime: { name: '人工成本', val: 4.56, target: 4.32 },
moment(new Date()).subtract(0, 'days').format('YYYY-MM-DD') + { name: '原料成本', val: 4.56, target: 4.32 },
' 00:00:00', { name: '原片制造费用', val: 4.56, target: 4.32 },
endTime: { name: '玻璃热耗', val: 4.56, target: 4.32 },
moment(new Date()).subtract(-1, 'days').format('YYYY-MM-DD') + { name: '原片成品率', val: 4.56, target: 4.32 },
' 00:00:00', ],
// 加工成本子项
pickerOptions: { processSubCosts: [
disabledDate(time) { { name: '人工成本', val: 4.56, target: 4.32 },
return time.getTime() + 3600 * 1000 * 24 > Date.now(); { name: '加工动力成本', val: 4.56, target: 4.32 },
}, { name: '加工制造费用', val: 4.56, target: 4.32 },
shortcuts: [ { name: '加工投入产出率', val: 4.56, target: 4.32 },
{ ],
text: '今天', // 趋势图模拟数据
onClick(picker) { trendX: ['00:00', '01:00', '02:00'],
picker.$emit('pick', new Date()); trendY: [20, 40, 50],
}, targetY: 12.54,
},
{
text: '昨天',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', date);
},
},
{
text: '一周前',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', date);
},
},
],
},
}; };
}, },
created() { mounted() {
}, this.initCostPie();
beforeDestroy() { this.initTotalTrend();
this.initRawProcessTrend();
this.initItemTrend();
}, },
methods: { methods: {
getData() { // 切换时间范围(示例)
let listQuery = { changeTime(type) {
//分页 // 实际项目中需根据type请求对应数据
pageSize: 10, console.log('切换时间:', type);
pageNo: 1, },
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName), // 初始化成本构成饼图
startTime: this.timeday + ' 00:00:00', initCostPie() {
}; const pieChart = echarts.init(document.getElementById('costPie'));
getData(listQuery).then((response) => { pieChart.setOption({
this.homeData = response.data; tooltip: { trigger: 'item' },
for (let i in this.homeData) { legend: {
this.homeData[i] = Number(this.homeData[i]).toFixed(2); orient: 'horizontal', // 水平排列
} bottom: 0, // 放在底部
icon: 'circle',
left: 'center',
formatter: function (name) {
return name;
},
},
series: [
{
type: 'pie',
data: [
{ name: '原料成本(4.2元)', value: 29.9 },
{ name: '动力成本(2.1元)', value: 24 },
{ name: '人工成本(1.5元)', value: 24 },
{ name: '辅料成本(0.5元)', value: 21.2 },
{ name: '制造费用(0.5元)', value: 21.2 },
],
label: { show: false },
labelLine: { show: false },
bottom: 10,
},
],
}); });
window.addEventListener('resize', () => pieChart.resize());
}, },
timedayChange() { // 初始化总制造成本趋势图
let listQuery = { initTotalTrend() {
//分页 const totalChart = echarts.init(document.getElementById('totalTrend'));
pageSize: 10, totalChart.setOption({
pageNo: 1, grid: { top: 20, bottom: 30, left: 30, right: 10 },
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName), xAxis: { type: 'category', data: this.trendX },
startTime: this.timeday + ' 00:00:00', yAxis: { type: 'value', min: -20, max: 60 },
}; series: [
getData(listQuery).then((response) => { {
this.homeData = response.data; name: '实际值',
for (let i in this.homeData) { type: 'line',
this.homeData[i] = Number(this.homeData[i]).toFixed(2); data: this.trendY,
} lineStyle: { color: '#409eff' },
}); },
{
name: '目标值',
type: 'line',
data: [this.targetY, this.targetY, this.targetY],
lineStyle: { type: 'dashed', color: '#e6a23c' },
},
],
});
window.addEventListener('resize', () => totalChart.resize());
}, },
goDetail() { // 初始化原片/加工成本趋势图
this.$router.push({ path: 'indexDetail' }); initRawProcessTrend() {
const rpChart = echarts.init(document.getElementById('rawProcessTrend'));
rpChart.setOption({
grid: { top: 10, bottom: 20, left: 20, right: 10 },
xAxis: { type: 'category', data: this.trendX },
yAxis: { type: 'value', min: -20, max: 60 },
series: [
{
name: '实际值',
type: 'line',
data: this.trendY,
lineStyle: { color: '#409eff' },
},
{
name: '目标值',
type: 'line',
data: [this.targetY, this.targetY, this.targetY],
lineStyle: { type: 'dashed', color: '#e6a23c' },
},
],
});
window.addEventListener('resize', () => rpChart.resize());
},
// 初始化单项成本趋势图
initItemTrend() {
const itemChart = echarts.init(document.getElementById('itemTrend'));
itemChart.setOption({
grid: { top: 10, bottom: 20, left: 20, right: 10 },
xAxis: { type: 'category', data: this.trendX },
yAxis: { type: 'value', min: -20, max: 60 },
series: [
{
name: '实际值',
type: 'line',
data: this.trendY,
lineStyle: { color: '#409eff' },
},
{
name: '目标值',
type: 'line',
data: [this.targetY, this.targetY, this.targetY],
lineStyle: { type: 'dashed', color: '#e6a23c' },
},
],
});
window.addEventListener('resize', () => itemChart.resize());
}, },
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style scoped>
.home-page::before { .top-bar {
background-image: url('~@/assets/img/home-bg.png');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: rotate(180deg);
}
.date-tabs {
padding-left: 40px;
padding-top: 20px;
position: relative;
margin-bottom: 20px; margin-bottom: 20px;
} }
:deep(.date-tabs) { .card-row,
.el-tabs__header { .composition-row {
margin-bottom: 8px; margin-bottom: 20px;
display: inline-block;
transform: translateY(-12px);
}
.el-tabs__content {
overflow: visible;
}
.el-tabs__item {
font-size: 18px;
color: #fff;
padding-left: 0 !important;
padding-right: 0 !important;
line-height: 36px !important;
height: 36px;
}
.el-tabs__item.is-active {
color: #0b58ff;
}
} }
.detail { .cost-card .card-title {
display: inline-block; font-size: 22px;
position: absolute; font-weight: bold;
left: 260px; margin-bottom: 15px;
top: 10px;
} }
:deep(.detail) { .cost-card .card-content {
.el-input__inner { display: grid;
background-color: transparent; grid-template-columns: 1fr 1fr 1fr;
color: white; gap: 10px;
} align-items: center;
}
// .current-date {
// color: #fff;
// font-size: 18px;
// position: absolute;
// left: 260px;
// top: 14px;
// }
.current-time {
color: #fff;
font-size: 18px; font-size: 18px;
position: absolute;
right: 38px;
top: 14px;
} }
.main-top { .target-val {
width: 100%; color: #666;
padding: 0 20px 0 40px; margin-left: 5px;
.title { font-size: 20px;
position: absolute;
left: 34px;
top: 20px;
width: 180px;
font-size: 32px;
z-index: 10;
.title-inner {
position: absolute;
left: 42px;
top: 5px;
font-size: calc(100vw * 20 / 1920);
}
}
.box {
background-color: #fff;
border-radius: 24px;
height: 192px;
padding: 40px 24px 32px 24px;
margin-bottom: 20px;
box-shadow: 0 8px 8px 0 gray;
.num-box {
height: 120px;
padding-top: 26px;
text-align: center;
.num-style {
color: #000;
font-size: calc(100vw * 40 / 1920);
}
.unit-style {
color: rgba(0, 0, 0, 0.7);
font-size: calc(100vw * 18 / 1920);
}
}
.shadow {
background: linear-gradient(90deg, #ffffff 80%, #f2f4f9 100%);
}
}
} }
.main-bottom { .actual-val {
width: 100%; color: #42b983;
margin-top: 20px; margin-left: 5px;
.chart-wrapper { font-size: 20px;
margin-left: 10px; }
height: 425px; .composition-card {
background: #fff; height: 480px;
border-radius: 5px; }
box-shadow: 0 3px 3px 0 gray; .composition-card .card-title {
} font-size: 18px;
} font-weight: bold;
</style> margin-bottom: 15px;
<style lang="scss"> }
.home-page { .sub-cost {
.el-progress-bar__inner { display: grid;
background-image: url('~@/assets/img/home-progress-bg.png'); grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
background-size: cover; gap: 10px;
} align-items: center;
}
.sub-cost-group .sub-cost-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}
.sub-cost-group .sub-cost-div {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
align-items: center;
border: 1px solid rgb(220, 220, 220, 0.5);
padding: 10px;
}
.sub-cost-name {
text-align: center;
margin-top: 5px;
font-size: 14px;
}
.sub-cost-val {
font-size: 16px;
font-weight: bold;
}
.completion {
text-align: center;
font-size: 12px;
color: #666;
}
.red-text {
color: #e74c3c;
}
.trend-card {
height: 450px;
}
.trend-card .card-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
} }
</style> </style>

View File

@@ -2,7 +2,7 @@
* @Author: zwq * @Author: zwq
* @Date: 2025-10-13 15:07:24 * @Date: 2025-10-13 15:07:24
* @LastEditors: zwq * @LastEditors: zwq
* @LastEditTime: 2025-12-01 14:40:46 * @LastEditTime: 2025-12-03 15:48:26
* @Description: * @Description:
--> -->
<template> <template>
@@ -826,10 +826,14 @@ export default {
}); });
checkPlan(data).then((RES) => { checkPlan(data).then((RES) => {
createStepFour(this.dataForm.id).then((res) => { createStepFour(this.dataForm.id).then((res) => {
this.$modal.msgSuccess('创建计划成功'); if (res.code === 200 || res.code === 0) {
this.stepNum = 1; this.$modal.msgSuccess('创建计划成功');
this.$emit('setSN', this.stepNum); this.stepNum = 1;
this.$emit('refreshDataList'); this.$emit('setSN', this.stepNum);
this.$emit('refreshDataList');
} else {
this.$message(res.msg);
}
}); });
}); });
return; return;

View File

@@ -2,7 +2,7 @@
* @Author: zwq * @Author: zwq
* @Date: 2021-11-18 14:16:25 * @Date: 2021-11-18 14:16:25
* @LastEditors: zwq * @LastEditors: zwq
* @LastEditTime: 2025-11-27 14:06:11 * @LastEditTime: 2025-12-11 10:47:50
* @Description: * @Description:
--> -->
<template> <template>
@@ -66,7 +66,7 @@
type="date" type="date"
placeholder="选择日期" placeholder="选择日期"
format="yyyy-MM-dd" format="yyyy-MM-dd"
value-format="--MM-dd" value-format="yyyy-MM-dd"
@blur="$forceUpdate()" @blur="$forceUpdate()"
:picker-options="pickerOptions"></el-date-picker> :picker-options="pickerOptions"></el-date-picker>
</el-form-item> </el-form-item>
@@ -81,7 +81,7 @@
v-model="dataForm.dateDayArr" v-model="dataForm.dateDayArr"
type="daterange" type="daterange"
format="yyyy-MM-dd" format="yyyy-MM-dd"
value-format="--MM-dd" value-format="yyyy-MM-dd"
range-separator="" range-separator=""
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
@@ -341,45 +341,70 @@ export default {
this.$refs['dataForm'].resetFields(); this.$refs['dataForm'].resetFields();
if (this.dataForm.id) { if (this.dataForm.id) {
getHoliday(this.dataForm.id).then((res) => { getHoliday(this.dataForm.id).then((res) => {
//设置年份,不重复的直接用返回的年份,重复的直接用当年年份
let year = new Date().getFullYear();
if (res.data.calendarType == 1 && !res.data.repeat) {
year = res.data.noRepeatYear;
} else if (res.data.calendarType == 2 && !res.data.repeat) {
year = res.data.noRepeatYearChinese;
}
this.dataForm = res.data; this.dataForm = res.data;
if ( if (
this.dataForm.dateType == 1 && this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 1 this.dataForm.calendarType == 1
) { ) {
this.dataForm.dateDay = this.dataForm.oneDay; this.dataForm.dateDay =
year + '-' + this.dataForm.oneDay.slice(-5);
} else if ( } else if (
this.dataForm.dateType == 2 && this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1 this.dataForm.calendarType == 1
) { ) {
let num = this.compareMonthDay(
this.dataForm.startDay.slice(-5),
this.dataForm.endDay.slice(-5)
);
this.dataForm.dateDayArr = [ this.dataForm.dateDayArr = [
this.dataForm.startDay, year + '-' + this.dataForm.startDay.slice(-5),
this.dataForm.endDay, (num > 0 ? year : year + 1) +
'-' +
this.dataForm.endDay.slice(-5),
]; ];
} else if ( } else if (
this.dataForm.dateType == 1 && this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2 this.dataForm.calendarType == 2
) { ) {
this.dataForm.dateDayChinese = this.dataForm.dateDayChinese =
'L' + 'L' + year + this.dataForm.oneDayChinese.slice(-6);
new Date().getFullYear() +
this.dataForm.oneDayChinese.slice(-6);
} else if ( } else if (
this.dataForm.dateType == 2 && this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2 this.dataForm.calendarType == 2
) { ) {
let num = this.compareMonthDay(
this.dataForm.startDayChinese.slice(-6),
this.dataForm.endDayChinese.slice(-6)
);
this.dataForm.dateDayArrChinese = [ this.dataForm.dateDayArrChinese = [
'L' + year + this.dataForm.startDayChinese.slice(-6),
'L' + 'L' +
new Date().getFullYear() + (num > 0 ? year : year + 1) +
this.dataForm.startDayChinese.slice(-6), +this.dataForm.endDayChinese.slice(-6),
'L' +
new Date().getFullYear() +
this.dataForm.endDayChinese.slice(-6),
]; ];
} }
}); });
} }
}); });
}, },
//用于比较日期大小判断年份是否要加1
compareMonthDay(dateStr1, dateStr2) {
const [month1, day1] = dateStr1.split('-').map(Number);
const [month2, day2] = dateStr2.split('-').map(Number);
if (month1 !== month2) {
return month2 - month1;
}
return day2 - day1;
},
editHoliday() { editHoliday() {
this.detail = false; this.detail = false;
}, },
@@ -442,13 +467,16 @@ export default {
return false; return false;
} }
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) { if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
this.dataForm.oneDay = this.dataForm.dateDay; const [year, month, day] = this.dataForm.dateDay.split('-');
this.dataForm.oneDay = `--${month}-${day}`;
} else if ( } else if (
this.dataForm.dateType == 2 && this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1 this.dataForm.calendarType == 1
) { ) {
this.dataForm.startDay = this.dataForm.dateDayArr[0]; const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
this.dataForm.endDay = this.dataForm.dateDayArr[1]; this.dataForm.startDay = `--${month}-${day}`;
const [year1, month1, day1] = this.dataForm.dateDayArr[1].split('-');
this.dataForm.endDay = `--${month1}-${day1}`;
} else if ( } else if (
this.dataForm.dateType == 1 && this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2 this.dataForm.calendarType == 2
@@ -464,10 +492,35 @@ export default {
this.dataForm.endDayChinese = this.dataForm.endDayChinese =
'--' + this.dataForm.dateDayArrChinese[1].slice(-5); '--' + this.dataForm.dateDayArrChinese[1].slice(-5);
} }
if (this.dataForm.calendarType == 1 && !this.dataForm.repeat) { //是否每年重复,不重复的话需要传 年份
this.dataForm.noRepeatYear = new Date().getFullYear(); if (
} else if (this.dataForm.calendarType == 2 && !this.dataForm.repeat) { this.dataForm.dateType == 1 &&
this.dataForm.noRepeatYearChinese = new Date().getFullYear(); this.dataForm.calendarType == 1 &&
!this.dataForm.repeat
) {
const [year, month, day] = this.dataForm.dateDay.split('-');
this.dataForm.noRepeatYear = year;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1 &&
!this.dataForm.repeat
) {
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
this.dataForm.noRepeatYear = year;
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2 &&
!this.dataForm.repeat
) {
this.dataForm.noRepeatYearChinese =
this.dataForm.dateDayChinese.slice(1, 5);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2 &&
!this.dataForm.repeat
) {
this.dataForm.noRepeatYearChinese =
this.dataForm.dateDayArrChinese[0].slice(1, 5);
} }
// 修改的提交 // 修改的提交
if (this.dataForm.id) { if (this.dataForm.id) {
@@ -475,8 +528,45 @@ export default {
this.dataForm.inherited = false; this.dataForm.inherited = false;
} }
updateHoliday(this.dataForm).then((res) => { updateHoliday(this.dataForm).then((res) => {
if (res.code === 0 || res.code === 200) {
if (!res.data.updateFlag) {
this.$modal.msgSuccess('修改成功');
this.$emit('refreshPage');
} else {
this.$confirm(
'新增节假日影响已有排班计划,是否立即更新?',
'更新排班',
{
confirmButtonText: '立即更新',
cancelButtonText: '暂不更新',
type: 'warning',
}
)
.then(() => {
updateSchedule({ logId: res.data.logId }).then((res1) => {
this.$modal.msgSuccess('更新成功');
});
this.$emit('refreshPage');
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
this.$emit('refreshPage');
});
}
} else {
this.$modal.msg(res.msg);
}
});
return;
}
// 添加的提交
createHoliday(this.dataForm).then((res) => {
if (res.code === 0 || res.code === 200) {
if (!res.data.updateFlag) { if (!res.data.updateFlag) {
this.$modal.msgSuccess('修改成功'); this.$modal.msgSuccess('新增成功');
this.$emit('refreshPage'); this.$emit('refreshPage');
} else { } else {
this.$confirm( this.$confirm(
@@ -502,37 +592,8 @@ export default {
this.$emit('refreshPage'); this.$emit('refreshPage');
}); });
} }
});
return;
}
// 添加的提交
createHoliday(this.dataForm).then((res) => {
if (!res.data.updateFlag) {
this.$modal.msgSuccess('新增成功');
this.$emit('refreshPage');
} else { } else {
this.$confirm( this.$modal.msg(res.msg);
'新增节假日影响已有排班计划,是否立即更新?',
'更新排班',
{
confirmButtonText: '立即更新',
cancelButtonText: '暂不更新',
type: 'warning',
}
)
.then(() => {
updateSchedule({ logId: res.data.logId }).then((res1) => {
this.$modal.msgSuccess('更新成功');
});
this.$emit('refreshPage');
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
this.$emit('refreshPage');
});
} }
}); });
}); });

View File

@@ -210,7 +210,7 @@
</template> </template>
<script> <script>
import moment from 'moment'; import moment from 'moment';
import JDatePickerScript from './jDatePicker.js' import JDatePickerScript from './JDatePicker.js'
export default { export default {
props: { props: {