Compare commits

..

21 Commits

Author SHA1 Message Date
‘937886381’
d2b0565cd1 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-12 16:53:32 +08:00
‘937886381’
7661dc5691 修改 2025-12-12 16:52:45 +08:00
1d698848c2 Merge pull request 'projects/line-new-zhp' (#461) from projects/line-new-zhp into projects/line-new
Reviewed-on: #461
2025-12-12 14:18:34 +08:00
‘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
‘937886381’
1e12b653d6 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-09 16:59:54 +08:00
‘937886381’
b7ba173ca3 修改 2025-12-09 16:57:38 +08:00
c203f1e1dd Merge pull request 'projects/line-new-zhp' (#457) from projects/line-new-zhp into projects/line-new
Reviewed-on: #457
2025-12-09 13:11:32 +08:00
‘937886381’
ccb925003e Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-09 13:10:45 +08:00
‘937886381’
b9f286005c 生产 2025-12-09 13:07:09 +08:00
0e343279ac Merge pull request '更新' (#456) from projects/line-new-zwq into projects/line-new
Reviewed-on: #456
2025-12-01 14:52:38 +08:00
zwq
00ac3dec45 更新 2025-12-01 14:52:21 +08:00
a84f765e73 Merge pull request '班组bug' (#455) from projects/line-new-zwq into projects/line-new
Reviewed-on: #455
2025-11-28 16:29:25 +08:00
zwq
ffa0b2e8dd 班组bug 2025-11-28 16:29:06 +08:00
1e6c6c5656 Merge pull request '班组bug' (#448) from projects/line-new-zwq into projects/line-new
Reviewed-on: #448
2025-11-11 15:38:56 +08:00
zwq
0e76fe7dbf 班组bug 2025-11-11 15:38:31 +08:00
399e2bc965 Merge pull request '更新班组' (#447) from projects/line-new-zwq into projects/line-new
Reviewed-on: #447
2025-11-05 13:58:22 +08:00
zwq
7bee1f7863 更新班组 2025-11-05 13:57:58 +08:00
162 changed files with 13097 additions and 11208 deletions

View File

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

BIN
dist.zip Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
"license": "MIT",
"scripts": {
"local": "vue-cli-service serve --mode local",
"dev": "vue-cli-service serve --mode dev",
"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --mode dev",
"front": "vue-cli-service serve --mode front",
"build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --mode prod",
"build:stage": "vue-cli-service build --mode stage",

View File

@@ -59,3 +59,34 @@ export function getEquipmentAll() {
method: 'get'
})
}
export function getTree(query) {
return request({
url: '/base/factory/getTreeSimple',
method: 'get',
params: query,
});
}
export function getEquipmentOverall(data) {
return request({
url: '/monitoring/equipment-overall/get',
method: 'post',
data: data,
});
}
export function getParamMonitor(data) {
return request({
url: '/monitoring/equipment-monitor/paramMonitor',
method: 'post',
data: data,
});
}
export function getAlarmDet(data) {
return request({
url: 'monitoring/equipment-overall/alarmDet',
method: 'post',
data: data,
});
}

View File

@@ -52,3 +52,5 @@ export function exportEquipmentTypeExcel(query) {
responseType: 'blob'
})
}

View File

@@ -50,6 +50,15 @@ export function getPdlAutoReportNewSearchNow(data) {
});
}
export function getPdlAutoReportNewSearchLastGroup(data) {
return request({
url: '/monitoring/production-monitor/getPdlAutoReportNewSearchLastGroup',
method: 'post',
data: data,
timeout: 60000,
});
}
// 班组自动报表分页
export function getTeamReportPage(data) {

View File

@@ -141,3 +141,13 @@ export function getPerView(data) {
data:data
})
}
// 导出 Excel
export function exportExcel(query) {
return request({
url: '/base/group-scheduling-plan/export-excel',
method: 'get',
params: query,
responseType: 'blob'
})
}

View File

@@ -26,6 +26,13 @@ export function getGroup(id) {
method: 'get'
})
}
// 检查更新-生产班组
export function updateIsProduction(id) {
return request({
url: '/base/group-team/updateIsProduction?id=' + id,
method: 'get'
})
}
// 获得班组基础信息分页
export function getGroupPage(query) {

View File

@@ -90,3 +90,29 @@ export function getEnableData() {
method: 'get',
})
}
// 解除继承节假日
export function disExtends(data) {
return request({
url: '/base/group-holiday/disExtends',
method: 'post',
data: data
})
}
// 恢复继承节假日
export function reExtends(data) {
return request({
url: '/base/group-holiday/reExtends',
method: 'post',
data: data
})
}
// 获得部门节假日继承设置信息设置
export function getSet(query) {
return request({
url: '/base/group-holiday-dept-set/getSet',
method: 'get',
params: query
})
}

View File

@@ -0,0 +1,56 @@
import request from '@/utils/request'
// 创建能源监控配置
export function getDefectSummaryTable(data) {
return request({
url: '/extend/check-gaozhun-record/defectSummaryTable',
method: 'post',
data: data,
});
}
export function getTranslucentPage(data) {
return request({
url: '/monitoring/translucent/page',
method: 'get',
params: data,
});
}
export function exportTranslucent(data) {
return request({
url: '/monitoring/translucent/export-excel',
method: 'get',
params: data,
responseType: 'blob',
});
}
export function getDefectAnalysis(data) {
return request({
url: '/extend/check-gaozhun-record/defectAnalysis',
method: 'post',
data: data,
});
}
export function getSectionDefect(data) {
return request({
url: '/extend/check-gaozhun-record/sectionDefect',
method: 'post',
data: data,
});
}
export function getDefectSummaryChart(data) {
return request({
url: '/extend/check-gaozhun-record/defectSummaryChart',
method: 'post',
data: data,
});
}
export function getDefectSummaryDet(data) {
return request({
url: '/extend/check-gaozhun-record/defectSummaryDet',
method: 'post',
data: data,
});
}

View File

@@ -0,0 +1,63 @@
/*
* @Author: zhp
* @Date: 2023-12-08 15:26:59
* @LastEditTime: 2023-12-11 15:21:44
* @LastEditors: zhp
* @Description:
*/
import request from '@/utils/request'
export function getQualityIsraPage(query) {
return request({
url: '/extend/check-isra-statistics/getIsraData',
method: 'get',
params: query,
});
}
export function getQualityIsraDayMap(query) {
return request({
url: '/base/quality-isra-statistics/dayMap',
method: 'get',
params: query
})
}
export function getQualityIsraWeekMap(query) {
return request({
url: '/base/quality-isra-statistics/weekMap',
method: 'get',
params: query
})
}
export function getQualityIsraMonthMap(query) {
return request({
url: '/base/quality-isra-statistics/monthMap',
method: 'get',
params: query
})
}
export function getQualityIsraDayList(query) {
return request({
url: '/base/quality-isra-statistics/dayList',
method: 'get',
params: query
})
}
export function getQualityIsraWeekList(query) {
return request({
url: '/base/quality-isra-statistics/weekList',
method: 'get',
params: query
})
}
export function getQualityIsraMonthList(query) {
return request({
url: '/base/quality-isra-statistics/monthList',
method: 'get',
params: query
})
}

View File

@@ -1,9 +0,0 @@
import request from '@/utils/request'
export function getLineEdgeLibraryList(data) {
return request({
url: '/wms/line-edge-library/list',
method: 'get',
params: data,
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

View File

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

View File

@@ -6,104 +6,48 @@
-->
<template>
<el-form
ref="form"
:model="form"
:label-width="`${labelWidth}px`"
:size="size"
:label-position="labelPosition"
v-loading="formLoading">
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
<el-input
v-if="col.input"
v-model="form[col.prop]"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
v-bind="col.bind" />
<el-input
v-if="col.textarea"
type="textarea"
v-model="form[col.prop]"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
v-bind="col.bind" />
<el-select
v-if="col.select"
v-model="form[col.prop]"
:placeholder="`请选择${col.label}`"
@change="$emit('update', form)"
v-bind="col.bind">
<el-option
v-for="opt in optionListOf[col.prop]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
<el-date-picker
v-if="col.datetime"
v-model="form[col.prop]"
type="datetime"
:placeholder="`请选择${col.label}`"
value-format="timestamp"
v-bind="col.bind"></el-date-picker>
<el-switch
v-if="col.switch"
v-model="form[col.prop]"
active-color="#0b58ff"
inactive-color="#e1e1e1"
v-bind="col.bind"></el-switch>
<component
v-if="col.subcomponent"
:key="col.key"
:is="col.subcomponent"
:inlineStyle="col.style"></component>
<el-form ref="form" :model="form" :label-width="`${labelWidth}px`" :size="size" :label-position="labelPosition"
v-loading="formLoading">
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
<el-input v-if="col.input" v-model="form[col.prop]" @change="$emit('update', form)"
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
<el-input v-if="col.textarea" type="textarea" v-model="form[col.prop]" @change="$emit('update', form)"
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
<el-select v-if="col.select" v-model="form[col.prop]" :placeholder="`请选择${col.label}`"
@change="$emit('update', form)" v-bind="col.bind">
<el-option v-for="opt in optionListOf[col.prop]" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
<el-date-picker v-if="col.datetime" v-model="form[col.prop]" type="datetime" :placeholder="`请选择${col.label}`"
value-format="timestamp" v-bind="col.bind"></el-date-picker>
<el-switch v-if="col.switch" v-model="form[col.prop]" active-color="#0b58ff" inactive-color="#e1e1e1"
v-bind="col.bind" @change="handleSwitchChange(col.prop)"></el-switch>
<component v-if="col.subcomponent" :key="col.key" :is="col.subcomponent" :inlineStyle="col.style"></component>
<div
class="upload-area"
:class="uploadOpen ? '' : 'height-48'"
ref="uploadArea"
v-if="col.upload">
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
<el-button
type="text"
icon="el-icon-arrow-right"
@click="handleFilesOpen" />
</span>
<!-- :file-list="uploadedFileList" -->
<el-upload
class="upload-in-dialog"
v-if="col.upload"
:action="uploadUrl"
:headers="uploadHeaders"
:show-file-list="false"
icon="el-icon-upload2"
:before-upload="beforeUpload"
:on-success="handleUploadSuccess"
v-bind="col.bind">
<el-button size="mini" :disabled="col.bind?.disabled || false">
<svg-icon
icon-class="icon-upload"
style="color: inherit"></svg-icon>
上传文件
</el-button>
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
</div>
</el-upload>
<uploadedFile
class="file"
v-for="file in form[col.prop] || []"
:file="file"
:key="file.fileUrl"
@delete="handleDeleteFile(file)"
@Preview="handlePreview(file)" />
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="upload-area" :class="uploadOpen ? '' : 'height-48'" ref="uploadArea" v-if="col.upload">
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
<el-button type="text" icon="el-icon-arrow-right" @click="handleFilesOpen" />
</span>
<!-- :file-list="uploadedFileList" -->
<el-upload class="upload-in-dialog" v-if="col.upload" :action="uploadUrl" :headers="uploadHeaders"
:show-file-list="false" icon="el-icon-upload2" :before-upload="beforeUpload"
:on-success="handleUploadSuccess" v-bind="col.bind">
<el-button size="mini" :disabled="col.bind?.disabled || false">
<svg-icon icon-class="icon-upload" style="color: inherit"></svg-icon>
上传文件
</el-button>
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
</div>
</el-upload>
<uploadedFile class="file" v-for="file in form[col.prop] || []" :file="file" :key="file.fileUrl"
@delete="handleDeleteFile(file)" @Preview="handlePreview(file)" />
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
@@ -134,7 +78,8 @@ const uploadedFile = {
data() {
return {};
},
methods: {
methods: {
handleDelete() {
this.$emit('delete', this.file);
},
@@ -251,7 +196,12 @@ export default {
// 处理 options
this.handleOptions();
},
methods: {
methods: {
handleSwitchChange(prop) {
// 触发 update 事件,将最新的 form 数据传递给父组件
this.$emit('update', { ...this.form });
console.log(`switch ${prop} 变化:`, this.form[prop]);
},
/** 模拟透传 ref */
validate(cb) {
return this.$refs.form.validate(cb);

View File

@@ -16,7 +16,7 @@ export default {
},
tableData: [], //table数据
listQuery: { //分页
pageSize: 10,
pageSize: 20,
pageNo: 1,
total: 1,
},

View File

@@ -9,7 +9,7 @@ import { isRelogin } from '@/utils/request'
NProgress.configure({ showSpinner: false })
// 增加三方登陆 update by 芋艿
const whiteList = ['/login', '/social-login','screenbg', '/auth-redirect', '/bind', '/register', '/oauthLogin/gitee']
const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/register', '/oauthLogin/gitee']
router.beforeEach((to, from, next) => {
NProgress.start()
@@ -25,9 +25,9 @@ router.beforeEach((to, from, next) => {
// 获取字典数据 add by 芋艿
store.dispatch('dict/loadDictDatas')
// 判断当前用户是否已拉取完 user_info 信息
store.dispatch('GetInfo').then(userInfo => {
store.dispatch('GetInfo').then(() => {
isRelogin.show = false
store.dispatch('GenerateRoutes', userInfo.menus).then(accessRoutes => {
store.dispatch('GenerateRoutes').then(accessRoutes => {
// 根据 roles 权限生成可访问的路由表
router.addRoutes(accessRoutes) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成

View File

@@ -28,277 +28,223 @@ Vue.use(Router)
// 公共路由
export const constantRoutes = [
{
path: '/redirect',
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path(.*)',
component: (resolve) => require(['@/views/redirect'], resolve),
},
],
},
{
path: '/login',
component: (resolve) => require(['@/views/login'], resolve),
// hidden: true,
},
{
path: '/sso',
component: (resolve) => require(['@/views/sso'], resolve),
hidden: true,
},
{
path: '/social-login',
component: (resolve) => require(['@/views/socialLogin'], resolve),
hidden: true,
},
{
path: '/404',
component: (resolve) => require(['@/views/error/404'], resolve),
hidden: true,
},
{
path: '/401',
component: (resolve) => require(['@/views/error/401'], resolve),
hidden: true,
},
{
path: '/print-design',
component: (resolve) => require(['@/views/print/design'], resolve),
hidden: true,
},
{
path: '',
component: Layout,
redirect: 'index',
children: [
{
path: 'index',
component: (resolve) => require(['@/views/home/index'], resolve),
name: '首页',
meta: { title: '首页', icon: 'dashboard', affix: true },
hidden: true,
},
],
},
{
path: '/screenbg',
component: () =>
import(
/* webpackChunkName: "about" */ '@/views/productionVisualization/equipmentBoard'
),
name: 'screenbg',
meta: { title: '大屏', icon: 'chart' },
},
{
path: '/user',
component: Layout,
hidden: true,
redirect: 'noredirect',
children: [
{
path: 'profile',
component: (resolve) =>
require(['@/views/system/user/profile/index'], resolve),
name: 'Profile',
meta: { title: '个人中心', icon: 'user' },
},
{
path: 'notify-message',
component: (resolve) =>
require(['@/views/system/notify/my/index'], resolve),
name: 'MyNotifyMessage',
meta: { title: '我的站内信', icon: 'message' },
},
],
},
{
path: '/dict',
component: Layout,
hidden: true,
children: [
{
path: 'type/data/:dictId(\\d+)',
component: (resolve) => require(['@/views/system/dict/data'], resolve),
name: 'SystemDictData',
meta: { title: '字典数据', icon: '', activeMenu: '/system/dict' },
},
],
},
{
path: '/job',
component: Layout,
hidden: true,
children: [
{
path: 'log',
component: (resolve) => require(['@/views/infra/job/log'], resolve),
name: 'InfraJobLog',
meta: { title: '调度日志', activeMenu: '/infra/job' },
},
],
},
{
path: '/codegen',
component: Layout,
hidden: true,
children: [
{
path: 'edit/:tableId(\\d+)',
component: (resolve) =>
require(['@/views/infra/codegen/editTable'], resolve),
name: 'InfraCodegenEditTable',
meta: { title: '修改生成配置', activeMenu: '/infra/codegen' },
},
],
},
{
path: '/bpm',
component: Layout,
hidden: true,
redirect: 'noredirect',
children: [
{
path: 'oa/leave/create',
component: (resolve) =>
require(['@/views/bpm/oa/leave/create'], resolve),
name: 'BpmOALeaveCreate',
meta: {
title: '发起 OA 请假',
icon: 'form',
activeMenu: '/bpm/oa/leave',
},
},
{
path: 'oa/leave/detail',
component: (resolve) =>
require(['@/views/bpm/oa/leave/detail'], resolve),
name: 'BpmOALeaveDetail',
meta: {
title: '查看 OA 请假',
icon: 'view',
activeMenu: '/bpm/oa/leave',
},
},
],
},
{
path: '/bpm',
component: Layout,
hidden: true,
children: [
{
path: 'manager/form/edit',
component: (resolve) =>
require(['@/views/bpm/form/formEditor'], resolve),
name: 'BpmFormEditor',
meta: { title: '流程表单-编辑', activeMenu: '/bpm/manager/form' },
},
{
path: 'manager/definition',
component: (resolve) =>
require(['@/views/bpm/definition/index'], resolve),
name: 'BpmProcessDefinition',
meta: { title: '流程定义', activeMenu: '/bpm/manager/model' },
},
{
path: 'manager/model/design',
component: (resolve) =>
require(['@/views/bpm/model/modelEditor'], resolve),
name: 'BpmModelEditor',
meta: { title: '设计流程', activeMenu: '/bpm/manager/model' },
},
{
path: 'process-instance/create',
component: (resolve) =>
require(['@/views/bpm/processInstance/create'], resolve),
name: 'BpmProcessInstanceCreate',
meta: { title: '发起流程', activeMenu: '/bpm/task/my' },
},
{
path: 'process-instance/detail',
component: (resolve) =>
require(['@/views/bpm/processInstance/detail'], resolve),
name: 'BpmProcessInstanceDetail',
meta: { title: '流程详情', activeMenu: '/bpm/task/my' },
},
],
},
{
path: '/property',
component: Layout,
hidden: true,
children: [
{
path: 'value/:propertyId(\\d+)',
component: (resolve) =>
require(['@/views/mall/product/property/value'], resolve),
name: 'ProductPropertyValue',
meta: {
title: '商品属性值',
icon: '',
activeMenu: '/product/property',
},
},
],
},
{
path: '/spu',
component: Layout,
hidden: true,
children: [
{
path: 'edit/:spuId(\\d+)',
component: (resolve) =>
require(['@/views/mall/product/spu/save'], resolve),
name: 'ProductSpuUpdate',
meta: { title: '修改商品', activeMenu: '/product/spu' },
},
{
path: 'add',
component: (resolve) =>
require(['@/views/mall/product/spu/save'], resolve),
name: 'ProductSpuCreate',
meta: { title: '添加商品', activeMenu: '/product/spu' },
},
],
},
{
path: '/trade/order',
component: Layout,
hidden: true,
children: [
{
path: 'detail',
name: 'TradeOrderDetail',
hidden: true,
meta: { title: '订单详情' },
component: (resolve) =>
require(['@/views/mall/trade/order/detail'], resolve),
},
],
},
{
path: '/pay',
component: Layout,
hidden: true,
children: [
{
path: 'order/submit',
name: 'PayOrderSubmit',
hidden: true,
meta: {
title: '收银台',
noCache: true,
},
component: (resolve) => require(['@/views/pay/order/submit'], resolve),
},
],
},
];
{
path: '/redirect',
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path(.*)',
component: (resolve) => require(['@/views/redirect'], resolve)
}
]
},
{
path: '/login',
component: (resolve) => require(['@/views/login'], resolve),
hidden: true
},
{
path: '/sso',
component: (resolve) => require(['@/views/sso'], resolve),
hidden: true
},
{
path: '/social-login',
component: (resolve) => require(['@/views/socialLogin'], resolve),
hidden: true
},
{
path: '/404',
component: (resolve) => require(['@/views/error/404'], resolve),
hidden: true
},
{
path: '/401',
component: (resolve) => require(['@/views/error/401'], resolve),
hidden: true
},
{
path: '/print-design',
component: (resolve) => require(['@/views/print/design'], resolve),
hidden: true
},
{
path: "",
component: Layout,
redirect: "index",
children: [
{
path: "index",
component: (resolve) => require(["@/views/home/index"], resolve),
name: "首页",
meta: { title: "首页", icon: "dashboard", affix: true },
hidden: true
},
],
},
{
path: '/user',
component: Layout,
hidden: true,
redirect: 'noredirect',
children: [{
path: 'profile',
component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
name: 'Profile',
meta: { title: '个人中心', icon: 'user' }
}, {
path: 'notify-message',
component: (resolve) => require(['@/views/system/notify/my/index'], resolve),
name: 'MyNotifyMessage',
meta: { title: '我的站内信', icon: 'message' },
}]
},
{
path: '/dict',
component: Layout,
hidden: true,
children: [{
path: 'type/data/:dictId(\\d+)',
component: (resolve) => require(['@/views/system/dict/data'], resolve),
name: 'SystemDictData',
meta: { title: '字典数据', icon: '', activeMenu: '/system/dict' }
}
]
},
{
path: '/job',
component: Layout,
hidden: true,
children: [{
path: 'log',
component: (resolve) => require(['@/views/infra/job/log'], resolve),
name: 'InfraJobLog',
meta: { title: '调度日志', activeMenu: '/infra/job' }
}
]
}, {
path: '/codegen',
component: Layout,
hidden: true,
children: [{
path: 'edit/:tableId(\\d+)',
component: (resolve) => require(['@/views/infra/codegen/editTable'], resolve),
name: 'InfraCodegenEditTable',
meta: { title: '修改生成配置', activeMenu: '/infra/codegen' }
}
]
},
{
path: '/bpm',
component: Layout,
hidden: true,
redirect: 'noredirect',
children: [{
path: 'oa/leave/create',
component: (resolve) => require(['@/views/bpm/oa/leave/create'], resolve),
name: 'BpmOALeaveCreate',
meta: { title: '发起 OA 请假', icon: 'form', activeMenu: '/bpm/oa/leave' }
}, {
path: 'oa/leave/detail',
component: (resolve) => require(['@/views/bpm/oa/leave/detail'], resolve),
name: 'BpmOALeaveDetail',
meta: { title: '查看 OA 请假', icon: 'view', activeMenu: '/bpm/oa/leave' }
}
]
},
{
path: '/bpm',
component: Layout,
hidden: true,
children: [{
path: 'manager/form/edit',
component: (resolve) => require(['@/views/bpm/form/formEditor'], resolve),
name: 'BpmFormEditor',
meta: { title: '流程表单-编辑', activeMenu: '/bpm/manager/form' }
}, {
path: 'manager/definition',
component: (resolve) => require(['@/views/bpm/definition/index'], resolve),
name: 'BpmProcessDefinition',
meta: { title: '流程定义', activeMenu: '/bpm/manager/model' }
}, {
path: 'manager/model/design',
component: (resolve) => require(['@/views/bpm/model/modelEditor'], resolve),
name: 'BpmModelEditor',
meta: { title: '设计流程', activeMenu: '/bpm/manager/model' }
}, {
path: 'process-instance/create',
component: (resolve) => require(['@/views/bpm/processInstance/create'], resolve),
name: 'BpmProcessInstanceCreate',
meta: { title: '发起流程', activeMenu: '/bpm/task/my' }
}, {
path: 'process-instance/detail',
component: (resolve) => require(['@/views/bpm/processInstance/detail'], resolve),
name: 'BpmProcessInstanceDetail',
meta: { title: '流程详情', activeMenu: '/bpm/task/my' }
}
]
},
{
path: '/property',
component: Layout,
hidden: true,
children: [{
path: 'value/:propertyId(\\d+)',
component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
name: 'ProductPropertyValue',
meta: { title: '商品属性值', icon: '', activeMenu: '/product/property' }
}
]
},
{
path: '/spu',
component: Layout,
hidden: true,
children: [{
path: 'edit/:spuId(\\d+)',
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
name: 'ProductSpuUpdate',
meta: { title: '修改商品', activeMenu: '/product/spu' }
},
{
path: 'add',
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
name: 'ProductSpuCreate',
meta: { title: '添加商品', activeMenu: '/product/spu' }
}
]
},
{
path: '/trade/order',
component: Layout,
hidden: true,
children: [
{
path: 'detail',
name: 'TradeOrderDetail',
hidden: true,
meta: { title: '订单详情' },
component: (resolve) => require(['@/views/mall/trade/order/detail'], resolve)
}
]
},
{
path: '/pay',
component: Layout,
hidden: true,
children: [{
path: 'order/submit',
name: 'PayOrderSubmit',
hidden: true,
meta: {
title: '收银台',
noCache: true
},
component: (resolve) => require(['@/views/pay/order/submit'], resolve)
}]
}
]
// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;

View File

@@ -1,4 +1,5 @@
import {constantRoutes} from '@/router'
import {getRouters} from '@/api/menu'
import Layout from '@/layout/index'
import ParentView from '@/components/ParentView';
import {toCamelCase} from "@/utils";
@@ -26,25 +27,22 @@ const permission = {
},
},
actions: {
/**
* 生成路由
*
* @param commit commit 函数
* @param menus 路由参数
*/
GenerateRoutes({commit}, menus) {
// 生成路由
GenerateRoutes({commit}) {
return new Promise(resolve => {
// 将 menus 菜单,转换为 route 路由数组
const sdata = JSON.parse(JSON.stringify(menus)) // 【重要】用于菜单中的数据
const rdata = JSON.parse(JSON.stringify(menus)) // 用于最后添加到 Router 中的数据
const sidebarRoutes = filterAsyncRouter(sdata)
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
commit('SET_ROUTES', rewriteRoutes)
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
commit('SET_DEFAULT_ROUTES', sidebarRoutes)
commit('SET_TOPBAR_ROUTES', sidebarRoutes)
resolve(rewriteRoutes)
// 向后端请求路由数据(菜单)
getRouters().then(res => {
const sdata = JSON.parse(JSON.stringify(res.data)) // 【重要】用于菜单中的数据
const rdata = JSON.parse(JSON.stringify(res.data)) // 用于最后添加到 Router 中的数据
const sidebarRoutes = filterAsyncRouter(sdata)
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
commit('SET_ROUTES', rewriteRoutes)
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
commit('SET_DEFAULT_ROUTES', sidebarRoutes)
commit('SET_TOPBAR_ROUTES', sidebarRoutes)
resolve(rewriteRoutes)
})
})
}
}

View File

@@ -1,10 +1,10 @@
import axios from 'axios'
import {Message, MessageBox, Notification, Loading} from 'element-ui'
import { Message, MessageBox, Notification, Loading } from 'element-ui'
import store from '@/store'
import {getAccessToken, getRefreshToken, getTenantId, setToken} from '@/utils/auth'
import { getAccessToken, getRefreshToken, getTenantId, setToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import {getPath, getTenantEnable} from "@/utils/ruoyi";
import {refreshToken} from "@/api/login";
import { getPath, getTenantEnable } from "@/utils/ruoyi";
import { refreshToken } from "@/api/login";
// 需要忽略的提示。忽略后,自动 Promise.reject('error')
const ignoreMsgs = [
@@ -86,7 +86,7 @@ service.interceptors.request.use(config => {
for (const propName of Object.keys(config.params)) {
const value = config.params[propName];
const part = encodeURIComponent(propName) + '='
if (value !== null && typeof(value) !== "undefined") {
if (value !== null && typeof (value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
let params = propName + '[' + key + ']';
@@ -104,9 +104,9 @@ service.interceptors.request.use(config => {
}
return config
}, error => {
tryHideFullScreenLoading()
console.log(error)
Promise.reject(error)
tryHideFullScreenLoading()
console.log(error)
Promise.reject(error)
})
// 响应拦截器
@@ -176,36 +176,38 @@ service.interceptors.response.use(async res => {
+ '<div>5 分钟搭建本地环境</div>',
})
return Promise.reject(new Error(msg))
} else if (code === 400) {
//【班组管理】【排班计划】提交的校验按照原型图补充完整,排班计划是否重叠code400 有两个不同的返回信息
return res.data
} else if (code !== 200) {
if (msg === '无效的刷新令牌') { // hard coding忽略这个提示直接登出
console.log(msg)
} else {
Notification.error({
title: msg
})
//【班组管理】【排班计划】提交的校验按照原型图补充完整,排班计划是否重叠code400 有两个不同的返回信息
return res.data
}
return Promise.reject('error')
} else {
return res.data
}
}, error => {
tryHideFullScreenLoading()
console.log('err' + error)
let {message} = error;
if (message === "Network Error") {
message = "后端接口连接异常";
} else if (message.includes("timeout")) {
message = "系统接口请求超时";
} else if (message.includes("Request failed with status code")) {
message = "系统接口" + message.substr(message.length - 3) + "异常";
}
Message({
message: message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
tryHideFullScreenLoading()
console.log('err' + error)
let { message } = error;
if (message === "Network Error") {
message = "后端接口连接异常";
} else if (message.includes("timeout")) {
message = "系统接口请求超时";
} else if (message.includes("Request failed with status code")) {
message = "系统接口" + message.substr(message.length - 3) + "异常";
}
Message({
message: message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
}
)
export function getBaseHeader() {
@@ -219,10 +221,10 @@ function handleAuthorized() {
if (!isRelogin.show) {
isRelogin.show = true;
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录',
cancelButtonText: '取消',
type: 'warning'
}
confirmButtonText: '重新登录',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
isRelogin.show = false;
store.dispatch('LogOut').then(() => {

View File

@@ -6,35 +6,27 @@
-->
<template>
<el-drawer
:visible="visible"
:show-close="false"
:wrapper-closable="false"
class="drawer"
custom-class="mes-drawer"
:size="size || '50%'"
@closed="$emit('destroy')">
<SmallTitle slot="title">
{{
mode.includes('detail')
? '详情'
: mode.includes('edit')
? '编辑'
: '新增'
}}
</SmallTitle>
<el-drawer :visible="visible" :show-close="false" :wrapper-closable="false" class="drawer" custom-class="mes-drawer"
:size="size || '50%'" @closed="$emit('destroy')">
<SmallTitle slot="title">
{{
mode.includes('detail')
? '详情'
: mode.includes('edit')
? '编辑'
: '新增'
}}
</SmallTitle>
<div class="drawer-body flex">
<div class="drawer-body__content">
<section v-for="(section, index) in sections" :key="section.key">
<SmallTitle v-if="index != 0">{{ section.name }}</SmallTitle>
<div class="drawer-body flex">
<div class="drawer-body__content">
<section v-for="(section, index) in sections" :key="section.key">
<SmallTitle v-if="index != 0">{{ section.name }}</SmallTitle>
<div
class="form-part"
v-if="section.key == 'base'"
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
<el-skeleton v-if="!showForm" animated />
<!-- <BaseInfoForm
<div class="form-part" v-if="section.key == 'base'"
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
<el-skeleton v-if="!showForm" animated />
<!-- <BaseInfoForm
key="drawer-dialog-form"
v-if="showForm"
ref="form"
@@ -42,141 +34,87 @@
v-model="form"
:rows="formRows" /> -->
<!-- if -->
<el-row v-if="mode.includes('detail')" style="margin-bottom: 24px">
<el-col :span="8">
<div
class="title"
style="font-weight: 700; font-size: 16px; margin: 8px 0">
设备名
</div>
<div class="value" style="font-size: 14px">
{{ form.equipmentName }}
</div>
</el-col>
<el-col :span="8">
<div
class="title"
style="font-weight: 700; font-size: 16px; margin: 8px 0">
关联表名
</div>
<div class="value" style="font-size: 14px">
{{ form.plcName }}
</div>
</el-col>
</el-row>
<!-- else -->
<el-row v-else style="margin-bottom: 24px" :gutter="20">
<el-form ref="form" :model="form">
<el-col :span="8">
<el-form-item
class="title"
label="设备名"
style="font-size: 16px; margin: 8px 0">
<el-select
v-model="form.equipmentId"
filterable
clearable
placeholder="请选择设备">
<el-option
v-for="eq in eqList"
:key="eq.id"
:label="eq.name"
:value="eq.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
class="title"
label="设备关联表名"
style="font-size: 16px; margin: 8px 0">
<el-select
v-model="form.plcId"
filterable
clearable
placeholder="请选择关联表">
<el-option
v-for="plc in plcList"
:key="plc.id"
:label="plc.plcTableName"
:value="plc.id"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-form>
</el-row>
</div>
<!-- if -->
<el-row v-if="mode.includes('detail')" style="margin-bottom: 24px">
<el-col :span="8">
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
设备名
</div>
<div class="value" style="font-size: 14px">
{{ form.equipmentName }}
</div>
</el-col>
<el-col :span="8">
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
关联表名
</div>
<div class="value" style="font-size: 14px">
{{ form.plcName }}
</div>
</el-col>
</el-row>
<!-- else -->
<el-row v-else style="margin-bottom: 24px" :gutter="20">
<el-form ref="form" :model="form">
<el-col :span="8">
<el-form-item class="title" label="设备名" style="font-size: 16px; margin: 8px 0">
<el-select v-model="form.equipmentId" filterable clearable placeholder="请选择设备">
<el-option v-for="eq in eqList" :key="eq.id" :label="eq.name" :value="eq.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item class="title" label="设备关联表名" style="font-size: 16px; margin: 8px 0">
<el-select v-model="form.plcId" filterable clearable placeholder="请选择关联表">
<el-option v-for="plc in plcList" :key="plc.id" :label="plc.plcTableName"
:value="plc.id"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-form>
</el-row>
</div>
<div
v-if="section.key == 'attrs'"
style="position: relative; margin-top: 12px">
<div
v-if="!mode.includes('detail')"
style="position: absolute; top: -40px; right: 0">
<el-button @click="handleAddAttr" type="text">
<i class="el-icon-plus"></i>
添加参数
</el-button>
</div>
<base-table
v-loading="attrListLoading"
:table-props="section.props"
:page="attrQuery?.params.pageNo || 1"
:limit="attrQuery?.params.pageSize || 10"
:table-data="list"
@emitFun="handleEmitFun">
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
<div v-if="section.key == 'attrs'" style="position: relative; margin-top: 12px">
<div v-if="!mode.includes('detail')" style="position: absolute; top: -40px; right: 0">
<el-button @click="handleAddAttr" type="text">
<i class="el-icon-plus"></i>
添加参数
</el-button>
</div>
<base-table v-loading="attrListLoading" :table-props="section.props" :page="attrQuery?.params.pageNo || 1"
:limit="attrQuery?.params.pageSize || 10" :table-data="list" @emitFun="handleEmitFun">
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
@emitButtonClick="handleAddAttr" -->
<method-btn
v-if="section.tableBtn && !mode.includes('detail')"
slot="handleBtn"
label="操作"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
<method-btn v-if="section.tableBtn && !mode.includes('detail')" slot="handleBtn" label="操作"
:method-list="tableBtn" @clickBtn="handleTableBtnClick" />
</base-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="attrQuery.params.pageNo"
:limit.sync="attrQuery.params.pageSize"
@pagination="getAttrList" />
</div>
</section>
</div>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="attrQuery.params.pageNo"
:limit.sync="attrQuery.params.pageSize" @pagination="getAttrList" />
</div>
</section>
</div>
<div class="drawer-body__footer">
<el-button style="" @click="handleCancel">取消</el-button>
<el-button
type="primary"
v-if="!mode.includes('detail')"
@click="handleSave">
保存
</el-button>
</div>
</div>
<div class="drawer-body__footer">
<el-button style="" @click="handleCancel">取消</el-button>
<el-button type="primary" v-if="!mode.includes('detail')" @click="handleSave">
保存
</el-button>
</div>
</div>
<!-- 属性对话框 -->
<base-dialog
v-if="sections[1].allowAdd"
:dialogTitle="attrTitle"
:dialogVisible="attrFormVisible"
width="45%"
:append-to-body="true"
custom-class="baseDialog"
@close="closeAttrForm"
@cancel="closeAttrForm"
@confirm="submitAttrForm">
<!-- :disabled="mode.includes('detail')" -->
<DialogForm
v-if="attrFormVisible"
ref="attrForm"
v-model="attrForm"
:rows="attrRows" />
</base-dialog>
</el-drawer>
<!-- 属性对话框 -->
<base-dialog v-if="sections[1].allowAdd" :dialogTitle="attrTitle" :dialogVisible="attrFormVisible" width="45%"
:append-to-body="true" custom-class="baseDialog" @close="closeAttrForm" @cancel="closeAttrForm"
@confirm="submitAttrForm">
<!-- :disabled="mode.includes('detail')" -->
<DialogForm v-if="attrFormVisible" ref="attrForm" v-model="attrForm" :data-form="attrForm"
:rows="attrRows"
@update="handleAttrFormUpdate"/>
</base-dialog>
</el-drawer>
</template>
<script>
@@ -232,7 +170,9 @@ export default {
defaultValue: '',
description: '',
remark: '',
alarmContent: '',
alarmContent: '',
displayTip: false,
alarmTip: false,
},
attrFormVisible: false,
attrRows: [
@@ -342,7 +282,27 @@ export default {
},
],
},
],
],
[
{
switch: true,
label: '是否展示',
prop: 'displayTip',
bind: {
'active-value': true,
'inactive-value': false,
},
},
{
switch: true,
label: '超出阈值是否报警',
prop: 'alarmTip',
bind: {
'active-value': true,
'inactive-value': false,
},
},
],
[
{
input: true,
@@ -436,7 +396,24 @@ export default {
}
}
},
methods: {
methods: {
handleAttrFormUpdate(updatedForm) {
console.log('updatedForm', updatedForm);
// 只同步需要的字段,避免覆盖其他数据
this.attrForm = {
...this.attrForm,
...updatedForm,
// 确保开关值是布尔类型(双重保险)
displayTip: Boolean(updatedForm.displayTip),
alarmTip: Boolean(updatedForm.alarmTip),
collection: Number(updatedForm.collection) // 采集开关保持数字类型
};
console.log('开关值同步:', {
displayTip: this.attrForm.displayTip,
alarmTip: this.attrForm.alarmTip
});
},
handleTableBtnClick({ type, data }) {
switch (type) {
case 'edit':
@@ -502,7 +479,8 @@ export default {
name: '',
plcParamName: '',
unit: '',
collection: 1,
collection: 1,
minValue: '',
maxValue: '',
defaultValue: '',
@@ -510,7 +488,9 @@ export default {
remark: '',
equipmentParamType: '',
productionParamType: '',
alarmContent: '',
alarmContent: '',
displayTip: false,
alarmTip: false,
};
this.attrTitle = '添加参数绑定信息';
this.attrFormVisible = true;
@@ -523,8 +503,15 @@ export default {
method: 'get',
params: { id: attrId },
});
if (res.code == 0) {
this.attrForm = res.data;
if (res.code == 0) {
console.log('res.data', res.data);
this.attrForm = {
...res.data,
// // 强制转为数字类型,避免字符串类型导致绑定失败
// displayTip: Number(res.data.displayTip) || 0,
// alarmTip: Number(res.data.alarmTip) || 0
};
this.attrTitle = '编辑参数绑定信息';
this.attrFormVisible = true;
}
@@ -563,7 +550,8 @@ export default {
this.$refs['attrForm'].validate(async (valid) => {
if (!valid) {
return;
}
}
console.log('this.attrForm', this.attrForm);
const isEdit = this.attrForm.id != null;
this.attrFormSubmitting = true;
@@ -583,8 +571,9 @@ export default {
type: 'success',
duration: 1500,
onClose: () => {
this.getAttrList();
this.shouldRefreshPageView = true;
this.shouldRefreshPageView = true;
this.getAttrList();
},
});
}

View File

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

View File

@@ -47,15 +47,15 @@ const tableProps = [
prop: 'equipmentName',
label: '设备',
},
{
prop: 'size',
label: '规格',
showOverflowtooltip: true,
},
{
prop: 'process',
label: '产品工艺',
},
// {
// prop: 'size',
// label: '规格',
// showOverflowtooltip: true,
// },
// {
// prop: 'process',
// label: '产品工艺',
// },
{
prop: 'standardCt',
label: '标准节拍pcs/min',
@@ -128,7 +128,7 @@ export default {
this.tableData = response.data;
this.dataListLoading = false;
});
},
},
handleClick(val) {
const data = {
...this.time,

View File

@@ -72,16 +72,6 @@ export default {
dateLabelList: [],
optionArrUrl: [getProductionLinePage],
formConfig: [
{
type: 'select',
label: '产线',
selectOptions: [],
param: 'lineIds',
defaultSelect: [],
multiple: true,
filterable: true,
width: 200,
},
{
type: 'datePicker',
label: '时间',
@@ -92,7 +82,18 @@ export default {
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'time',
},
},
{
type: 'select',
label: '产线',
selectOptions: [],
param: 'lineIds',
defaultSelect: [],
multiple: true,
collapseTags: true,
filterable: true,
width: 300,
},
{
type: 'button',
btnName: '查询',
@@ -113,7 +114,7 @@ export default {
};
this.optionArrUrl.forEach((item, index) => {
item(params).then((response) => {
this.formConfig[index].selectOptions = response.data.list;
this.formConfig[1].selectOptions = response.data.list;
// this.formConfig[0].defaultSelect = response.data.list[0].id
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id)
});

View File

@@ -279,7 +279,8 @@ export default {
filterable: true,
clearable: true,
},
},
},
// {
// select: true,
// label: '设备分组',

View File

@@ -92,7 +92,7 @@ export default {
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{ prop: 'name', label: '设备类型名称' },
{ prop: 'code', label: '检测类型编码' },
{ prop: 'code', label: '设备类型编码' },
{ prop: 'remark', label: '备注' },
],
searchBarFormConfig: [

View File

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

View File

@@ -1,139 +1,142 @@
<template>
<el-dialog
:visible.sync="visible"
:width="'35%'"
:append-to-body="true"
:close-on-click-modal="false"
class="dialog">
<template #title>
<slot name="title">
<div class="titleStyle">
{{ !dataForm.id ? '新增' : '编辑' }}
</div>
</slot>
</template>
<el-dialog v-loading="isLoading" loading-text="处理中..." loading-spinner="el-icon-loading"
loading-background="rgba(255, 255, 255, 0.7)" :visible.sync="visible" :width="'35%'" :append-to-body="true"
:close-on-click-modal="false" class="dialog">
<template #title>
<slot name="title">
<div class="titleStyle">
{{ !dataForm.id ? '新增' : '编辑' }}
</div>
</slot>
</template>
<el-form
ref="dataForm"
:model="dataForm"
:rules="dataRule"
label-width="100px"
@keyup.enter.native="dataFormSubmit()">
<el-form-item label="属性" prop="name">
<el-input
v-model="dataForm.name"
placeholder="请输入属性名"
clearable />
</el-form-item>
<el-form-item label="属性值" prop="value">
<el-input
v-model="dataForm.value"
placeholder="请输入属性值"
clearable />
</el-form-item>
</el-form>
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="100px"
@keyup.enter.native="dataFormSubmit()">
<el-form-item label="属性名" prop="name">
<el-input v-model="dataForm.name" placeholder="请输入属性名" clearable />
</el-form-item>
<el-form-item label="属性值" prop="value">
<el-input v-model="dataForm.value" placeholder="请输入属性" clearable />
</el-form-item>
</el-form>
<el-row style="text-align: right">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</el-row>
</el-dialog>
<el-row style="text-align: right">
<el-button @click="visible = false">取消</el-button>
<el-button :loading="isLoading" type="primary" @click="dataFormSubmit()">确定</el-button>
</el-row>
</el-dialog>
</template>
<script>
import {
createProductAttr,
updateProductAttr,
getProductAttr,
createProductAttr,
updateProductAttr,
getProductAttr,
} from '@/api/core/base/productAttr';
export default {
props: {
productId: {
type: String,
default: '',
},
},
data() {
return {
visible: false,
dataForm: {
id: 0,
name: '',
value: '',
},
dataRule: {
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
},
};
},
methods: {
init(id) {
this.dataForm.id = id || '';
this.visible = true;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
getProductAttr(this.dataForm.id).then((res) => {
const { name, value } = res.data;
this.dataForm.name = name;
this.dataForm.value = value;
});
}
});
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
// 修改的提交
if (this.dataForm.id) {
updateProductAttr({
...this.dataForm,
productId: this.productId,
}).then((response) => {
this.$modal.msgSuccess('修改成功');
this.visible = false;
this.$emit('refreshDataList');
});
return;
}
// 添加的提交
createProductAttr({
...this.dataForm,
productId: this.productId,
}).then((response) => {
this.$modal.msgSuccess('新增成功');
this.visible = false;
this.$emit('refreshDataList');
});
}
});
},
},
props: {
productId: {
type: String,
default: '',
},
},
data() {
return {
visible: false,
isLoading: false,
dataForm: {
id: 0,
name: '',
value: '',
},
dataRule: {
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
},
};
},
methods: {
init(id) {
this.dataForm.id = id || '';
this.visible = true;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
getProductAttr(this.dataForm.id).then((res) => {
const { name, value } = res.data;
this.dataForm.name = name;
this.dataForm.value = value;
}).catch(err => {
console.error('获取属性详情失败:', err);
this.$modal.msgError('获取数据失败,请重试');
});
}
});
},
// 表单提交(优化加载状态和错误处理)
async dataFormSubmit() {
// 先验证表单
const valid = await new Promise((resolve) => {
this.$refs['dataForm'].validate((isValid) => resolve(isValid));
});
if (!valid) return;
this.isLoading = true; // 开始加载
try {
if (this.dataForm.id) {
// 编辑操作
await updateProductAttr({
...this.dataForm,
productId: this.productId,
});
this.$modal.msgSuccess('修改成功');
} else {
// 新增操作
await createProductAttr({
...this.dataForm,
productId: this.productId,
});
this.$modal.msgSuccess('新增成功');
}
this.visible = false;
this.$emit('refreshDataList');
} catch (error) {
// 错误处理
console.error('提交失败:', error);
this.$modal.msgError('操作失败,请重试');
} finally {
// 无论成功失败,都关闭加载状态
this.isLoading = false;
}
},
},
};
</script>
<style scoped>
.dialog >>> .el-dialog__body {
padding: 30px 24px;
.dialog>>>.el-dialog__body {
padding: 30px 24px;
}
.dialog >>> .el-dialog__header {
font-size: 16px;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
padding: 13px 24px;
border-bottom: 1px solid #e9e9e9;
.dialog>>>.el-dialog__header {
font-size: 16px;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
padding: 13px 24px;
border-bottom: 1px solid #e9e9e9;
}
.dialog >>> .el-dialog__header .titleStyle::before {
content: '';
display: inline-block;
width: 4px;
height: 16px;
background-color: #0b58ff;
border-radius: 1px;
margin-right: 8px;
position: relative;
top: 2px;
.dialog>>>.el-dialog__header .titleStyle::before {
content: '';
display: inline-block;
width: 4px;
height: 16px;
background-color: #0b58ff;
border-radius: 1px;
margin-right: 8px;
position: relative;
top: 2px;
}
</style>

View File

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

View File

@@ -262,6 +262,14 @@ export default {
tooltip: {
valueFormatter: (value) => `${value} %`,
},
label: {
show: true,
position: 'top',
distance: 6,
fontSize: 11,
color: '#333333',
formatter: (params) => `${params.value}` // 显示单位
},
data: this.barData.map((item) => item.processingRatio),
},
],

View File

@@ -34,7 +34,7 @@
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="210" />
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph">
@@ -57,7 +57,7 @@
<el-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="210" />
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
@@ -71,9 +71,55 @@
</el-row>
</div>
</div>
<div class="content-inner" v-if="listQuery.timeType === 3">
<!-- 当班数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog">
<span class="blue-block"></span>
<span class="tip">上一班数据</span>
<el-row style="margin-top: 10px;">
<el-col class="custom-tabs">
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph">
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px"
:bar-data="tableData" />
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div>
<!-- 当天数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog">
<span class="blue-block"></span>
<span class="tip">当天数据</span>
<el-row style="margin-top: 10px;">
<el-col class="custom-tabs">
<el-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
:bar-data="tableData2" />
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div>
</div>
<!-- 3.2 时间维度为自定义时的内容两个平分高度的div -->
<div class="content-inner" v-else>
<div class="content-inner" v-if="listQuery.timeType === 2">
<div class="content-card energyOverlimitLog">
<span class="blue-block"></span>
<span class="tip" v-if="listQuery.startTime && listQuery.endTime">
@@ -86,7 +132,7 @@
<span class="tip" v-else>生产表格数据 </span>
<div class="graph">
<base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="tableProps" :max-height="210" :table-data="tableDataCustom" />
:limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" />
</div>
</div>
@@ -113,7 +159,7 @@
<span class="tip">当班数据</span>
<base-table-s ref="productCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="productTableProps" :table-data="productTableData"
:max-height="210" />
:max-height="300" />
</div>
<!-- 当天数据占1/2剩余高度 -->
@@ -122,7 +168,7 @@
<span class="tip">当天数据</span>
<base-table-s ref="productTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="productTablePropsDay" :table-data="productTableDataDay"
:max-height="210" />
:max-height="300" />
</div>
</div>
</div>
@@ -142,7 +188,7 @@
</span>
<span class="tip" v-else>生产表格数据 </span>
<base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="210" />
:limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="300" />
</div>
</div>
</div>
@@ -154,7 +200,7 @@
import { parseTime } from '@/filter/code-filter';
import {
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto,
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup
} from '@/api/core/monitoring/auto';
import { getFactoryPage } from '@/api/core/base/factory';
import * as XLSX from 'xlsx';
@@ -165,11 +211,11 @@ import ButtonNav from '@/components/ButtonNav';
import { listData } from '@/api/system/dict/data';
// 表格列配置
const tableProps = [
// {
// prop: 'factoryName',
// label: '工厂',
// fixed: true
// },
{
prop: 'factoryName',
label: '工厂',
fixed: true
},
{
prop: 'lineName',
label: '产线',
@@ -355,6 +401,7 @@ export default {
activeLabel: 'table', // 当班数据tab
activeLabelDay: 'table', // 当天数据tab
fileName: '',
headFormValue:{},
dataListLoading: false,
tableProps,
factoryColumns: [],
@@ -368,15 +415,27 @@ export default {
productTableDataDay: [],
tableDataCustom: [],
list: [], // 折线图数据
timeTypeOptions: {
productLine: [ // 按产线监控(包含上一班)
{ id: 1, name: '当天' },
{ id: 2, name: '自定义' },
{ id: 3, name: '上一班' }
],
product: [ // 按产品监控(不含上一班)
{ id: 1, name: '当天' },
{ id: 2, name: '自定义' }
]
},
formConfig: [
{
type: 'select',
label: '时间维度',
selectOptions: [
{ id: 1, name: '当天' },
{ id: 2, name: '自定义' }
{ id: 2, name: '自定义' },
{ id: 3, name: '上一班' }
],
width: 80,
width: 100,
onchange: true,
// defaultSelect: 1,
clearable: false,
@@ -437,6 +496,7 @@ export default {
{ id: 3, name: '月' },
{ id: 4, name: '年' }
],
onchange: true,
width: 80,
param: 'reportType'
},
@@ -460,6 +520,12 @@ export default {
btnName: '重置',
name: 'reset',
},
// {
// type: 'label', // 初始隐藏
// label: '刷新时间', // 自定义标识
// // slot: 'currentTimeSlot', // 自定义插槽名
// // width: 200, // 宽度适配
// },
]
};
},
@@ -467,6 +533,13 @@ export default {
productTableProps() {
// 当班数据的完整表头(基础列 + 当班动态表头)
const baseColumns = [
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{
prop: 'process',
label: '产品工艺',
@@ -475,8 +548,9 @@ export default {
{
prop: 'processType',
label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'),
fixed: true
filter: (val) => (val === 1 ? '面板' : '背板'),
fixed: true,
sortable: true,
},
{
prop: 'factoryName',
@@ -498,6 +572,7 @@ export default {
prop: 'processType',
label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'),
sortable: true,
fixed: true
},
{
@@ -513,17 +588,20 @@ export default {
this.$nextTick(() => {
if (this.$refs.buttonNav) {
this.$refs.buttonNav.currentMenu = '按产线监控';
this.formConfig[0].selectOptions = this.timeTypeOptions.productLine;
}
if (this.$refs.searchBarForm) {
// this.$refs.searchBarForm.formInline.timeVal = [
// yesterday.getTime(),
// end.getTime()
// ];
this.$refs.searchBarForm.formInline.timeType = 1
this.$refs.searchBarForm.formInline.timeType = 3
}
});
this.getDayDataList();
// this.getLastDayDataList();
this.getPdLineList();
const queryParams = {
pageNo: 1,
@@ -572,22 +650,65 @@ export default {
this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
};
// 3. 执行公共重置
resetCommon();
// if (this.activeName === 'productLine') {
// } else {
// }
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
if (isProductLine) {
// 按产线监控:显示产线,隐藏产品工艺和类型
// 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.productLine; // 恢复上一班选项
this.formConfig[3].type = 'select'; // 显示产线
this.formConfig[4].type = ''; // 隐藏产品工艺
this.formConfig[5].type = ''; // 隐藏产品类型
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 {
// 按产品监控:显示产品工艺和类型,隐藏产线
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
this.formConfig[3].type = ''; // 隐藏产线
this.formConfig[4].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();
}
},
@@ -601,6 +722,12 @@ export default {
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 1) {
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else {
// 产线-自定义:导出一个表格(自定义文件名)
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
@@ -801,31 +928,147 @@ export default {
this.formConfig[2].selectOptions = res.data.list || [];
});
},
getWeekTimeRange(date) {
const targetDate = new Date(date);
const day = targetDate.getDay() || 7; // 周日转为7
const year = targetDate.getFullYear();
const month = targetDate.getMonth();
const dateNum = targetDate.getDate();
// 本周一 00:00:00
const startDate = new Date(year, month, dateNum - day + 1);
startDate.setHours(0, 0, 0, 0);
// 本周日 23:59:59
const endDate = new Date(year, month, dateNum - day + 7);
endDate.setHours(23, 59, 59, 999);
return {
startTime: startDate.getTime(),
endTime: endDate.getTime()
};
},
// 辅助函数获取本年的开始和结束时间戳1月1日00:00:00 到 12月31日23:59:59
getYearTimeRange(date) {
const targetDate = new Date(date);
const year = targetDate.getFullYear();
// 本年1月1日 00:00:00
const startDate = new Date(year, 0, 1);
startDate.setHours(0, 0, 0, 0);
// 本年12月31日 23:59:59
const endDate = new Date(year, 11, 31);
endDate.setHours(23, 59, 59, 999);
return {
startTime: startDate.getTime(),
endTime: endDate.getTime()
};
},
// 搜索/导出按钮点击
buttonClick(val) {
this.headFormValue = val
if (this.activeName === 'productLine') {
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || undefined;
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = this.headFormValue.lineId ? this.headFormValue.lineId : [];
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType || undefined;
this.listQuery.searchType = this.headFormValue.searchType || undefined;
// 处理不同时间选择类型
if (this.headFormValue.timeVal) {
this.listQuery.startTime = this.headFormValue.timeVal[0];
this.listQuery.endTime = this.headFormValue.timeVal[1];
} else if (this.headFormValue.timeValWeek) {
// 周选择器
const { startTime, endTime } = this.getWeekTimeRange(this.headFormValue.timeValWeek);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else if (this.headFormValue.timeValMonth) {
// 月选择器
this.listQuery.startTime = this.headFormValue.timeValMonth[0];
this.listQuery.endTime = this.headFormValue.timeValMonth[1];
} else if (this.headFormValue.timeValYear) {
// 年选择器
const { startTime, endTime } = this.getYearTimeRange(this.headFormValue.timeValYear);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else {
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
}
} else {
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || []
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = undefined;
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType || undefined;
this.listQuery.searchType = this.headFormValue.searchType || undefined;
// 处理不同时间选择类型
if (this.headFormValue.timeVal) {
this.listQuery.startTime = this.headFormValue.timeVal[0];
this.listQuery.endTime = this.headFormValue.timeVal[1];
} else if (this.headFormValue.timeValWeek) {
// 周选择器
const { startTime, endTime } = this.getWeekTimeRange(this.headFormValue.timeValWeek);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else if (this.headFormValue.timeValMonth) {
// 月选择器
this.listQuery.startTime = this.headFormValue.timeValMonth[0];
this.listQuery.endTime = this.headFormValue.timeValMonth[1];
} else if (this.headFormValue.timeValYear) {
// 年选择器
const { startTime, endTime } = this.getYearTimeRange(this.headFormValue.timeValYear);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else {
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
}
}
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = val.factoryId || undefined;
this.listQuery.process = val.process ? val.process : [];
this.listQuery.lineId = val.lineId ? val.lineId : [];
this.listQuery.processType = val.processType ? val.processType : [];
this.listQuery.reportType = val.reportType || undefined;
this.listQuery.timeType = val.timeType || undefined;
this.listQuery.searchType = val.searchType || undefined;
this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined;
this.listQuery.endTime = val.timeVal ? val.timeVal[1] : undefined;
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.listQuery.timeType === 1) {
this.getDayDataList();
} else if (this.listQuery.timeType === 3) {
this.getLastDayDataList();
} else {
this.getDataList();
}
} else {
this.getProductList();
}
break;
case 'export':
@@ -833,21 +1076,34 @@ export default {
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.$refs.searchBarForm.formInline.timeType = 1;
this.$refs.searchBarForm.formInline.timeType = 3;
this.formConfig[0].selectOptions = this.activeName === 'productLine'
? this.timeTypeOptions.productLine
: this.timeTypeOptions.product;
this.listQuery = {
pageSize: 100,
pageNo: 1,
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') {
this.getDayDataList();
this.getLastDayDataList();
} else {
this.getProductList();
}
break;
default:
console.log(val);
@@ -887,7 +1143,15 @@ export default {
},
async getProductList() {
console.log('resGroup');
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || []
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = undefined;
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType || undefined;
this.listQuery.searchType = this.headFormValue.searchType || undefined
if (this.listQuery.timeType === 2) {
const resGroup = await getProcessAutoReportNew(this.listQuery);
console.log('resGroup', resGroup);
@@ -1097,6 +1361,28 @@ export default {
return [...lineColumns, totalColumn];
},
// 为当天时调用的接口
getLastDayDataList() {
getPdlAutoReportNewSearchLastGroup().then((response) => {
this.tableData = response.data.classData.map((item, index) => {
item.originalLossNum = item.original?.lossNum;
item.originalLossArea = item.original?.lossArea;
item.edgeLossNum = item.edge?.lossNum;
item.edgeLossArea = item.edge?.lossArea;
item.drillLossNum = item.drill?.lossNum;
item.drillLossArea = item.drill?.lossArea;
item.coatingLossNum = item.coating?.lossNum;
item.coatingLossArea = item.coating?.lossArea;
item.silkLossNum = item.silk?.lossNum;
item.silkLossArea = item.silk?.lossArea;
item.temperingLossNum = item.tempering?.lossNum;
item.temperingLossArea = item.tempering?.lossArea;
item.packingLossNum = item.packing?.lossNum;
item.packingLossArea = item.packing?.lossArea;
return item;
});
// console.log(this.tableData, this.tableData2);
});
},
getDayDataList() {
getPdlAutoReportNewSearchNow().then((response) => {
this.tableData = response.data.classData.map((item, index) => {
@@ -1149,32 +1435,48 @@ export default {
this.listQuery.pageNo = val;
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 }) {
if (param === 'timeType') {
console.log(value);
this.listQuery.timeType = value;
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 = '';
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 {
// 切换为“自定义”:显示查询类型和时间范围
} else if (value === 2) {
this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value;
this.$refs.searchBarForm.formInline.searchType = 1;
this.formConfig[7].type = 'datePicker';
} else {
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
}
} else if (param === 'searchType') {
if (value === 1) {
// 统计数据:显示时间范围,隐藏报表类型
@@ -1187,7 +1489,77 @@ export default {
this.formConfig[7].type = 'datePicker';
}
} else if (param === 'reportType') {
this.$refs.searchBarForm.formInline.timeVal = undefined;
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
const formInline = this.$refs.searchBarForm.formInline;
// 精准判断只有字段存在时才置为undefined不存在则不处理
if ('timeVal' in formInline) {
formInline.timeVal = undefined;
}
if ('timeValWeek' in formInline) {
formInline.timeValWeek = undefined;
}
if ('timeValMonth' in formInline) {
formInline.timeValMonth = undefined;
}
if ('timeValYear' in formInline) {
formInline.timeValYear = undefined;
}
}
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
if (value === 1) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
width: 350
};
} else if (value === 2) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'week',
placeholder: '选择日期',
format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek',
width: 250,
};
} else if (value === 3) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'monthrange',
format: 'yyyy-MM-dd',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeValMonth',
defaultTime: ['00:00:00', '23:59:59'],
width: 250,
};
} else if (value === 4) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'year',
placeholder: '选择年份',
format: 'yyyy',
valueFormat: 'timestamp',
param: 'timeValYear',
width: 250,
};
}
} else if (param === 'factoryId') {
// 切换工厂时刷新产线列表
this.listQuery.lineId = [];
@@ -1234,7 +1606,7 @@ export default {
.content-wrapper {
// flex: 1;
width: 100%;
height: calc(100vh - 303px);
height: calc(100vh - 280px);
// overflow: hidden;
}

View File

@@ -77,7 +77,7 @@ const tableProps = [
},
{
prop: 'palletNum',
label: '下片托数'
label: '一托玻璃数量/片'
},
{
prop: 'startTime',
@@ -92,7 +92,7 @@ const tableProps = [
width: 160
},
{
prop: 'outputNum',
prop: 'length',
label: '玻璃长度/mm'
},
{
@@ -204,94 +204,88 @@ export default {
);
});
},
test() {
var target = document.getElementsByClassName("right-aside")[0]
target.style.background = '#FFFFFF'
var that = this
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)
exportXlsx() {
if (!this.showData.length) {
this.$message.warning('暂无数据可导出');
return;
}
return exportTableOut
},
exportPdf() {
this.test()
setTimeout(() =>{
this.dialogVisible = false
this.showData = this.tableData
}, 600)
},
exportXlsx() {
this.exportECL()
this.dialogVisible = false
this.showData = this.tableData
},
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
.catch(_ => {});
},
this.exportLoading = true;
try {
// 1. 处理导出数据(格式化时间字段)
const exportData = this.showData.map(item => {
const formatItem = { ...item };
// 格式化时间字段
if (formatItem.startTime) formatItem.startTime = parseTime(formatItem.startTime);
if (formatItem.endTime) formatItem.endTime = parseTime(formatItem.endTime);
return formatItem;
});
// 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() {
getPdList().then((res) => {
this.formConfig[0].selectOptions = res.data || []
@@ -314,15 +308,16 @@ export default {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.productId = val.productId ? val.productId : undefined;
this.listQuery.startTime = val.timeVal ? val.timeVal[0]: undefined;
this.listQuery.endTime = val.timeVal ? val.timeVal[1]: undefined;
this.listQuery.productionLineId = val.productionLineId ? val.productionLineId : undefined;
this.listQuery.thick = val.thick ? val.thick : undefined;
this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined;
this.listQuery.endTime = val.timeVal ? val.timeVal[1] : undefined;
//this.listQuery.reportEndTime = val.timeVal ? [new Date(val.timeVal[1]).getTime()] : undefined;
this.getDataList();
break;
case 'export':
this.handleExport();
this.exportXlsx();
break;
default:
console.log(val);
@@ -350,12 +345,6 @@ export default {
this.listQuery.pageNo = val;
this.getDataList();
},
handleExport() {
if (this.selectedList.length > 0) {
this.showData = this.selectedList
}
this.dialogVisible = true
}
},
};
</script>

View File

@@ -77,7 +77,7 @@ const tableProps = [
},
{
prop: 'palletNum',
label: '下片托数'
label: '一托玻璃数量/片'
},
{
prop: 'startTime',
@@ -92,7 +92,7 @@ const tableProps = [
width: 160
},
{
prop: 'outputNum',
prop: 'length',
label: '玻璃长度/mm'
},
{

View File

@@ -262,6 +262,14 @@ export default {
tooltip: {
valueFormatter: (value) => `${value} %`,
},
label: {
show: true,
position: 'top',
distance: 6,
fontSize: 11,
color: '#333333',
formatter: (params) => `${params.value}` // 显示单位
},
data: this.barData.map((item) => item.processingRatio),
},
],

View File

@@ -34,7 +34,7 @@
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="210" />
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph">
@@ -57,7 +57,7 @@
<el-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="210" />
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
@@ -71,22 +71,68 @@
</el-row>
</div>
</div>
<div class="content-inner" v-if="listQuery.timeType === 3">
<!-- 当班数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog">
<span class="blue-block"></span>
<span class="tip">上一班数据</span>
<el-row style="margin-top: 10px;">
<el-col class="custom-tabs">
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph">
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px"
:bar-data="tableData" />
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div>
<!-- 当天数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog">
<span class="blue-block"></span>
<span class="tip">当天数据</span>
<el-row style="margin-top: 10px;">
<el-col class="custom-tabs">
<el-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
:bar-data="tableData2" />
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div>
</div>
<!-- 3.2 时间维度为自定义时的内容两个平分高度的div -->
<div class="content-inner" v-else>
<div class="content-inner" v-if="listQuery.timeType === 2">
<div class="content-card energyOverlimitLog">
<span class="blue-block"></span>
<span class="tip" v-if="listQuery.startTime && listQuery.endTime">
<span>{{ reportTypeMap[listQuery.reportType] }}</span>
<span>
{{ parseTime(listQuery.startTime) }} {{
parseTime(listQuery.endTime) }}
parseTime(listQuery.endTime) }}
</span>
</span>
<span class="tip" v-else>生产表格数据 </span>
<div class="graph">
<base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="tableProps" :max-height="210" :table-data="tableDataCustom" />
:limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" />
</div>
</div>
@@ -113,7 +159,7 @@
<span class="tip">当班数据</span>
<base-table-s ref="productCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="productTableProps" :table-data="productTableData"
:max-height="210" />
:max-height="300" />
</div>
<!-- 当天数据占1/2剩余高度 -->
@@ -122,7 +168,7 @@
<span class="tip">当天数据</span>
<base-table-s ref="productTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="productTablePropsDay" :table-data="productTableDataDay"
:max-height="210" />
:max-height="300" />
</div>
</div>
</div>
@@ -142,7 +188,7 @@
</span>
<span class="tip" v-else>生产表格数据 </span>
<base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="210" />
:limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="300" />
</div>
</div>
</div>
@@ -154,7 +200,7 @@
import { parseTime } from '@/filter/code-filter';
import {
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto,
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup
} from '@/api/core/monitoring/auto';
import { getFactoryPage } from '@/api/core/base/factory';
import * as XLSX from 'xlsx';
@@ -165,11 +211,11 @@ import ButtonNav from '@/components/ButtonNav';
import { listData } from '@/api/system/dict/data';
// 表格列配置
const tableProps = [
// {
// prop: 'factoryName',
// label: '工厂',
// fixed: true
// },
{
prop: 'factoryName',
label: '工厂',
fixed: true
},
{
prop: 'lineName',
label: '产线',
@@ -360,6 +406,7 @@ export default {
factoryColumns: [],
factoryColumnsDay: [],
activeName: 'product',
headFormValue:{},
tableBtn: [],
showData: [],
tableData: [],
@@ -368,15 +415,27 @@ export default {
productTableDataDay: [],
tableDataCustom: [],
list: [], // 折线图数据
timeTypeOptions: {
productLine: [ // 按产线监控(包含上一班)
{ id: 1, name: '当天' },
{ id: 2, name: '自定义' },
{ id: 3, name: '上一班' }
],
product: [ // 按产品监控(不含上一班)
{ id: 1, name: '当天' },
{ id: 2, name: '自定义' }
]
},
formConfig: [
{
type: 'select',
label: '时间维度',
selectOptions: [
{ id: 1, name: '当天' },
{ id: 2, name: '自定义' }
{ id: 2, name: '自定义' },
{ id: 3, name: '上一班' }
],
width: 80,
width: 100,
onchange: true,
// defaultSelect: 1,
clearable: false,
@@ -438,6 +497,7 @@ export default {
{ id: 4, name: '年' }
],
width: 80,
onchange: true,
param: 'reportType'
},
{
@@ -476,6 +536,7 @@ export default {
prop: 'processType',
label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'),
sortable: true,
fixed: true
},
{
@@ -498,6 +559,7 @@ export default {
prop: 'processType',
label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'),
sortable: true,
fixed: true
},
{
@@ -511,18 +573,34 @@ export default {
},
mounted() {
this.$nextTick(() => {
// 1. 强制设置当前激活标签为 按产品监控
this.activeName = 'product';
if (this.$refs.buttonNav) {
this.$refs.buttonNav.currentMenu = '按产品监控';
// 时间维度选项只显示 当天/自定义(无 上一班)
this.formConfig[0].selectOptions = this.timeTypeOptions.product;
}
if (this.$refs.searchBarForm) {
// this.$refs.searchBarForm.formInline.timeVal = [
// yesterday.getTime(),
// end.getTime()
// ];
this.$refs.searchBarForm.formInline.timeType = 1
// 2. 强制设置搜索表单的 timeType 为 1当天
this.$refs.searchBarForm.formInline.timeType = 1;
// 同步查询参数的 timeType
this.listQuery.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);
}
});
// 3. 初始化直接调用 按产品监控 的接口
this.getProductList();
this.getPdLineList();
const queryParams = {
@@ -535,11 +613,22 @@ export default {
});
},
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) {
// 1. 确定当前激活的类型(产线/产品)
const isProductLine = val === '按产线监控';
this.activeName = isProductLine ? 'productLine' : 'product';
console.log('isProductLine', isProductLine);
// 2. 提取公共重置逻辑(无论切换到哪个标签,都需要执行的操作)
const resetCommon = () => {
@@ -572,19 +661,61 @@ export default {
this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围
const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1);
}
};
// 3. 执行公共重置
resetCommon();
// if (this.activeName === 'productLine') {
// } else {
// }
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
if (isProductLine) {
// 按产线监控:显示产线,隐藏产品工艺和类型
// 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.productLine; // 恢复上一班选项
this.formConfig[3].type = 'select'; // 显示产线
this.formConfig[4].type = ''; // 隐藏产品工艺
this.formConfig[5].type = ''; // 隐藏产品类型
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 {
// 按产品监控:显示产品工艺和类型,隐藏产线
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[3].type = ''; // 隐藏产线
this.formConfig[4].type = 'select'; // 显示产品工艺
this.formConfig[5].type = 'select'; // 显示产品类型
@@ -596,48 +727,52 @@ export default {
// 按产线监控
if (this.activeName === 'productLine') {
if (this.listQuery.timeType === 1) {
// 产线-当天:导出当班 + 当天两个表格
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
]);
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 1) {
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else {
// 产线-自定义:导出一个表格
// 产线-自定义:导出一个表格(自定义文件名)
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
}
}
// 按产品监控
else {
if (this.listQuery.timeType === 1) {
// 产品-当天:导出当班 + 当天两个表格
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
{ ref: 'productTodayTable', name: '产品监控_当天数据' }
]);
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else {
// 产品-自定义:导出一个表格
// 产品-自定义:导出一个表格(自定义文件名)
this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
}
}
},
// 导出单个表格
// 导出单个表格(保持原有逻辑,文件名由调用方传入,已区分不同场景)
exportSingleTable(refName, fileName) {
const table = this.getTableDom(refName);
if (!table) return;
// 克隆表格并移除固定列
const clonedTable = table.cloneNode(true);
this.removeFixedColumns(clonedTable);
this.adjustTableForExport(clonedTable);
// 转换为工作簿并导出
const workbook = XLSX.utils.table_to_book(clonedTable);
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
},
// 导出多个表格(同一个Excel的不同sheet
exportMultipleTables(tables) {
// 导出多个表格(新增自定义汇总文件名参数,适配不同选项卡
exportMultipleTables(tables, customSummaryName) {
const workbook = XLSX.utils.book_new();
let hasValidTable = false;
@@ -646,11 +781,9 @@ export default {
if (!table) return;
hasValidTable = true;
// 克隆表格并移除固定列
const clonedTable = table.cloneNode(true);
this.removeFixedColumns(clonedTable);
this.adjustTableForExport(clonedTable);
// 转换为sheet并添加到工作簿
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
XLSX.utils.book_append_sheet(workbook, worksheet, name);
});
@@ -660,31 +793,128 @@ export default {
return;
}
// 导出包含多个sheet的Excel
const fullName = `生产监控数据汇总_${this.formatDate()}.xlsx`;
// 动态生成汇总文件名:自定义名称 + 日期
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
},
// 辅助方法获取表格DOM元素
// 辅助方法获取表格DOM元素包含表头
getTableDom(refName) {
const tableComponent = this.$refs[refName];
if (!tableComponent) {
this.$message.warning(`未找到${refName}表格`);
return null;
}
// 获取表格组件内部的el-table DOM
const tableDom = tableComponent.$el.querySelector('.el-table__body-wrapper table');
if (!tableDom) {
// 获取完整表格容器(包含表头和表体)
const tableContainer = tableComponent.$el.querySelector('.el-table');
if (!tableContainer) {
this.$message.warning(`${refName}表格数据为空`);
return null;
}
return tableDom;
return tableContainer;
},
// 辅助方法:移除固定列(避免重复导出
removeFixedColumns(table) {
const fixedColumns = table.querySelectorAll('.el-table__fixed, .el-table__fixed-right');
fixedColumns.forEach(col => col.remove());
// 重点修复:调整表格结构(解决表头重复问题
adjustTableForExport(tableContainer) {
// 1. 移除空表格提示和分页等无关元素
const emptyCells = tableContainer.querySelectorAll('.el-table__empty-block, .el-pagination');
emptyCells.forEach(cell => cell.remove());
// 2. 定位核心元素
const mainTable = tableContainer.querySelector('.el-table__body-wrapper table'); // 主表体
const fixedLeft = tableContainer.querySelector('.el-table__fixed'); // 左固定列容器
const fixedRight = tableContainer.querySelector('.el-table__fixed-right'); // 右固定列容器
// 3. 提取所有表头行(支持多级表头,按层级收集)
const allHeaderRows = []; // 存储所有层级的表头行(每行是一个单元格数组)
// 辅助函数:提取某个容器内的所有表头行(处理多级表头)
const extractHeaderRows = (container) => {
const headerWrapper = container?.querySelector('.el-table__header-wrapper table');
if (!headerWrapper) return [];
const thead = headerWrapper.querySelector('thead');
if (!thead) return [];
// 多级表头可能有多个tr
const headerRows = Array.from(thead.querySelectorAll('tr'));
return headerRows.map(row => Array.from(row.querySelectorAll('th'))); // 每行的单元格数组
};
// 收集左固定列的表头行(可能有多层)
const fixedLeftHeaderRows = extractHeaderRows(fixedLeft);
// 收集主表头的表头行(可能有多层)
const mainHeaderRows = extractHeaderRows(tableContainer);
// 收集右固定列的表头行(可能有多层)
const fixedRightHeaderRows = extractHeaderRows(fixedRight);
// 4. 合并表头行(按层级对齐,左固定列 → 主表头 → 右固定列)
// 确定最大表头层级(多级表头的行数)
const maxLevel = Math.max(
fixedLeftHeaderRows.length,
mainHeaderRows.length,
fixedRightHeaderRows.length
);
// 按层级合并每行的单元格
for (let i = 0; i < maxLevel; i++) {
const rowCells = [];
// 左固定列当前层级的单元格(不足则补空)
rowCells.push(...(fixedLeftHeaderRows[i] || []));
// 主表头当前层级的单元格(不足则补空)
rowCells.push(...(mainHeaderRows[i] || []));
// 右固定列当前层级的单元格(不足则补空)
rowCells.push(...(fixedRightHeaderRows[i] || []));
allHeaderRows.push(rowCells);
}
// 5. 清理所有原有表头和固定列容器(避免干扰)
tableContainer.querySelectorAll('thead').forEach(thead => thead.remove());
tableContainer.querySelectorAll('.el-table__header-wrapper').forEach(wrapper => wrapper.remove());
[fixedLeft, fixedRight].forEach(container => container?.remove());
// 6. 构建唯一表头并添加到主表体(支持多级表头)
if (mainTable && allHeaderRows.length > 0) {
const newThead = document.createElement('thead');
// 按层级添加表头行
allHeaderRows.forEach(cells => {
const newTr = document.createElement('tr');
cells.forEach(cell => {
// 复制单元格避免DOM残留引用问题
const clonedCell = cell.cloneNode(true);
newTr.appendChild(clonedCell);
});
newThead.appendChild(newTr);
});
// 将新表头插入主表体最前面
mainTable.insertBefore(newThead, mainTable.firstChild);
}
// 7. 合并固定列数据到主表体仅处理tbody数据
// 合并左固定列数据
if (fixedLeft && mainTable) {
const fixedLeftRows = fixedLeft.querySelectorAll('.el-table__body-wrapper tbody tr');
const mainRows = mainTable.querySelectorAll('tbody tr');
fixedLeftRows.forEach((fixedRow, index) => {
if (mainRows[index]) {
const fixedCells = Array.from(fixedRow.querySelectorAll('td'));
fixedCells.forEach(cell => {
mainRows[index].insertBefore(cell.cloneNode(true), mainRows[index].firstChild);
});
}
});
}
// 合并右固定列数据
if (fixedRight && mainTable) {
const fixedRightRows = fixedRight.querySelectorAll('.el-table__body-wrapper tbody tr');
const mainRows = mainTable.querySelectorAll('tbody tr');
fixedRightRows.forEach((fixedRow, index) => {
if (mainRows[index]) {
const fixedCells = Array.from(fixedRow.querySelectorAll('td'));
fixedCells.forEach(cell => {
mainRows[index].appendChild(cell.cloneNode(true));
});
}
});
}
},
// 辅助方法:格式化日期(用于文件名)
@@ -698,7 +928,6 @@ export default {
String(date.getMinutes()).padStart(2, '0')
].join('');
},
// 获取产线和工厂列表
getPdLineList() {
getPdList().then(res => {
@@ -712,28 +941,105 @@ export default {
// 搜索/导出按钮点击
buttonClick(val) {
this.headFormValue = val
if (this.activeName === 'productLine') {
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || undefined;
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = this.headFormValue.lineId ? this.headFormValue.lineId : [];
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType || undefined;
this.listQuery.searchType = this.headFormValue.searchType || undefined;
// 处理不同时间选择类型
if (this.headFormValue.timeVal) {
this.listQuery.startTime = this.headFormValue.timeVal[0];
this.listQuery.endTime = this.headFormValue.timeVal[1];
} else if (this.headFormValue.timeValWeek) {
// 周选择器
const { startTime, endTime } = this.getWeekTimeRange(this.headFormValue.timeValWeek);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else if (this.headFormValue.timeValMonth) {
// 月选择器
this.listQuery.startTime = this.headFormValue.timeValMonth[0];
this.listQuery.endTime = this.headFormValue.timeValMonth[1];
} else if (this.headFormValue.timeValYear) {
// 年选择器
const { startTime, endTime } = this.getYearTimeRange(this.headFormValue.timeValYear);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else {
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
}
} else {
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || []
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = undefined;
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType || undefined;
this.listQuery.searchType = this.headFormValue.searchType || undefined;
// 处理不同时间选择类型
if (this.headFormValue.timeVal) {
this.listQuery.startTime = this.headFormValue.timeVal[0];
this.listQuery.endTime = this.headFormValue.timeVal[1];
} else if (this.headFormValue.timeValWeek) {
// 周选择器
const { startTime, endTime } = this.getWeekTimeRange(this.headFormValue.timeValWeek);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else if (this.headFormValue.timeValMonth) {
// 月选择器
this.listQuery.startTime = this.headFormValue.timeValMonth[0];
this.listQuery.endTime = this.headFormValue.timeValMonth[1];
} else if (this.headFormValue.timeValYear) {
// 年选择器
const { startTime, endTime } = this.getYearTimeRange(this.headFormValue.timeValYear);
this.listQuery.startTime = startTime;
this.listQuery.endTime = endTime;
} else {
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
}
}
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = val.factoryId || undefined;
this.listQuery.process = val.process ? val.process : [];
this.listQuery.lineId = val.lineId ? val.lineId : [];
this.listQuery.processType = val.processType ? val.processType : [];
this.listQuery.reportType = val.reportType || undefined;
this.listQuery.timeType = val.timeType || undefined;
this.listQuery.searchType = val.searchType || undefined;
this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined;
this.listQuery.endTime = val.timeVal ? val.timeVal[1] : undefined;
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.listQuery.timeType === 1) {
this.getDayDataList();
} else if (this.listQuery.timeType === 3) {
this.getLastDayDataList();
} else {
this.getDataList();
}
} else {
this.getProductList();
this.getProductList();
}
break;
case 'export':
@@ -742,20 +1048,32 @@ export default {
case 'reset':
this.$refs.searchBarForm.resetForm();
this.$refs.searchBarForm.formInline.timeType = 1;
this.formConfig[0].selectOptions = this.activeName === 'product'
? this.timeTypeOptions.productLine
: this.timeTypeOptions.product;
this.listQuery = {
pageSize: 100,
pageNo: 1,
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') {
this.getDayDataList();
} else {
this.getProductList();
}
break;
default:
console.log(val);
@@ -763,8 +1081,8 @@ export default {
},
getDataList() {
if(!this.listQuery.startTime &&!this.listQuery.endTime ){
return this.$modal.msgError('请选择时间');
if (!this.listQuery.startTime && !this.listQuery.endTime) {
return this.$modal.msgError('请选择时间');
}
this.dataListLoading = true;
// const arr = ['日', '周', '月', '年'];
@@ -795,10 +1113,18 @@ export default {
},
async getProductList() {
console.log('resGroup');
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || []
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = undefined;
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType || undefined;
this.listQuery.searchType = this.headFormValue.searchType || undefined
if (this.listQuery.timeType === 2) {
const resGroup = await getProcessAutoReportNew(this.listQuery);
console.log('resGroup',resGroup);
console.log('resGroup', resGroup);
// 格式化数据lineDetList提取到外层键名加lineId前缀
const formatData = (rawList) => {
@@ -827,7 +1153,7 @@ export default {
// 处理当班和当天数据(分别存储)
this.productTableData = formatData(resGroup.data.list); // 当班数据
console.log(this.productTableData,'productTableData');
console.log(this.productTableData, 'productTableData');
// --------------------------
// 生成当班数据的动态表头
@@ -1005,6 +1331,28 @@ export default {
return [...lineColumns, totalColumn];
},
// 为当天时调用的接口
getLastDayDataList() {
getPdlAutoReportNewSearchLastGroup().then((response) => {
this.tableData = response.data.classData.map((item, index) => {
item.originalLossNum = item.original?.lossNum;
item.originalLossArea = item.original?.lossArea;
item.edgeLossNum = item.edge?.lossNum;
item.edgeLossArea = item.edge?.lossArea;
item.drillLossNum = item.drill?.lossNum;
item.drillLossArea = item.drill?.lossArea;
item.coatingLossNum = item.coating?.lossNum;
item.coatingLossArea = item.coating?.lossArea;
item.silkLossNum = item.silk?.lossNum;
item.silkLossArea = item.silk?.lossArea;
item.temperingLossNum = item.tempering?.lossNum;
item.temperingLossArea = item.tempering?.lossArea;
item.packingLossNum = item.packing?.lossNum;
item.packingLossArea = item.packing?.lossArea;
return item;
});
// console.log(this.tableData, this.tableData2);
});
},
getDayDataList() {
getPdlAutoReportNewSearchNow().then((response) => {
this.tableData = response.data.classData.map((item, index) => {
@@ -1060,28 +1408,35 @@ export default {
// 搜索栏下拉选择变化
handleSearchBarChanged({ param, value }) {
console.log(value, param);
if (param === 'timeType') {
console.log(value);
this.listQuery.timeType = value;
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 = '';
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 {
// 切换为“自定义”:显示查询类型和时间范围
} else if (value === 2) {
this.formConfig[1].type = 'select';
this.$refs.searchBarForm.formInline.timeType = value;
this.listQuery.timeType = value;
this.$refs.searchBarForm.formInline.searchType = 1;
this.formConfig[7].type = 'datePicker';
} else {
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
}
} else if (param === 'searchType') {
if (value === 1) {
@@ -1095,7 +1450,77 @@ export default {
this.formConfig[7].type = 'datePicker';
}
} else if (param === 'reportType') {
this.$refs.searchBarForm.formInline.timeVal = undefined;
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
const formInline = this.$refs.searchBarForm.formInline;
// 精准判断只有字段存在时才置为undefined不存在则不处理
if ('timeVal' in formInline) {
formInline.timeVal = undefined;
}
if ('timeValWeek' in formInline) {
formInline.timeValWeek = undefined;
}
if ('timeValMonth' in formInline) {
formInline.timeValMonth = undefined;
}
if ('timeValYear' in formInline) {
formInline.timeValYear = undefined;
}
}
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
if (value === 1) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
width: 350
};
} else if (value === 2) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'week',
placeholder: '选择日期',
format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek',
width: 250,
};
} else if (value === 3) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'monthrange',
format: 'yyyy-MM-dd',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeValMonth',
defaultTime: ['00:00:00', '23:59:59'],
width: 250,
};
} else if (value === 4) {
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'year',
placeholder: '选择年份',
format: 'yyyy',
valueFormat: 'timestamp',
param: 'timeValYear',
width: 250,
};
}
} else if (param === 'factoryId') {
// 切换工厂时刷新产线列表
this.listQuery.lineId = [];
@@ -1142,7 +1567,7 @@ export default {
.content-wrapper {
// flex: 1;
width: 100%;
height: calc(100vh - 303px);
height: calc(100vh - 280px);
// overflow: hidden;
}

View File

@@ -1,14 +1,8 @@
<!--
* @Author: Do not edit
* @Date: 2023-08-29 14:59:29
* @LastEditTime: 2024-12-02 13:44:47
* @LastEditors: zwq
* @Description:
-->
<template>
<div class="app-container">
<!-- :isFold="true" 控制展开 -->
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick"
@select-changed="selectType" />
<base-table v-if="tableData.length" class="right-aside" v-loading="dataListLoading" :table-props="tableProps"
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
@@ -17,34 +11,47 @@
<div v-else class="no-data-bg"></div>
<pagination :limit.sync="listQuery.pageSize" :page.sync="listQuery.pageNo" :total="listQuery.total"
@pagination="getDataList" />
<!-- <el-dialog
title="提示"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose">
<el-button type="primary" @click="exportXlsx">xlsx</el-button>
<el-button type="success" @click="exportPdf">pdf</el-button>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="dialogVisible = false"> </el-button>
</span>
</el-dialog> -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" />
</div>
</template>
<script>
import Vue from 'vue';
import AddOrUpdate from './add-or-updata';
import { parseTime } from '../../mixins/code-filter';
import { getCostOriginRadioHisData, getPdList } from '@/api/core/monitoring/index'
import * as XLSX from 'xlsx'
import FileSaver from 'file-saver'
import jsPDF from 'jspdf'
import html2canvas from 'html2canvas'
import { getCostOriginRadioHisData, getPdList } from '@/api/core/monitoring/index';
import { exportCostOriginRadioHisData } from '../../../../api/core/monitoring';
const tableProps = [
// Vue2 中注册全局方法(如果需要)
Vue.prototype.$download = Vue.prototype.$download || {
excel: (response, fileName) => {
const blob = new Blob([response.data], { type: 'application/vnd.ms-excel' });
const url = window.URL.createObjectURL(blob);
const aLink = document.createElement('a');
aLink.style.display = 'none';
aLink.href = url;
aLink.setAttribute('download', fileName);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink);
window.URL.revokeObjectURL(url);
}
};
Vue.prototype.$modal = Vue.prototype.$modal || {
confirm: (message) => {
return new Promise((resolve, reject) => {
if (window.confirm(message)) {
resolve();
} else {
reject();
}
});
}
};
const tableProps = [
{
prop: 'reportType',
label: '报表类型'
@@ -52,12 +59,11 @@ const tableProps = [
{
prop: 'time',
label: '日期',
// filter: parseTime,
width: 160
},
{
{
prop: 'bindObjectName',
label: '产线'
label: '产线'
},
{
prop: 'thick',
@@ -67,11 +73,11 @@ const tableProps = [
prop: 'speed',
label: '在线速度'
},
{
{
prop: 'width',
label: '掰边宽度'
},
{
},
{
prop: 'inArea',
label: '拉引量/㎡'
},
@@ -79,21 +85,83 @@ const tableProps = [
prop: 'outArea',
label: '下片面积/㎡'
},
{
{
prop: 'ratio',
label: '良品率'
},
label: '良品率/%'
},
];
/**
* 工具函数获取选择时间所在周的起始和结束时间Vue2 兼容)
* @param {String|Date} selectTime - 选择的时间支持格式yyyy-MM-dd、yyyy-MM-dd HH:mm:ss 或 Date 对象)
* @returns {Array} [startDate, endDate] - 所在周周一 00:00:00 至 周日 23:59:59Date 对象)
*/
function getSelectedWeekRange(selectTime) {
// 兼容 String 类型时间和 Date 对象,统一转为 Date 实例
const targetDate = new Date(selectTime);
// 处理无效日期(若传入非法时间,返回当前时间的本周范围)
// if (isNaN(targetDate.getTime())) {
// console.warn('传入的时间格式无效,将使用当前时间计算本周范围');
// return getCurrentWeekRange(); // 可根据需求改为抛出错误或返回空
// }
const day = targetDate.getDay() || 7; // 周日为 7避免周日 -0 天仍为周日)
const start = new Date(targetDate);
start.setDate(targetDate.getDate() - day + 1); // 计算所在周的周一
start.setHours(0, 0, 0, 0); // 重置时分秒为 00:00:00.000
const end = new Date(start);
end.setDate(start.getDate() + 6); // 周一 +6 天 = 周日
end.setHours(23, 59, 59, 999); // 重置时分秒为 23:59:59.999
return [start, end];
}
/**
* 工具函数获取选择时间所在年的起始和结束时间Vue2 兼容)
* @param {String|Date} selectTime - 选择的时间支持格式yyyy-MM-dd、yyyy-MM-dd HH:mm:ss 或 Date 对象)
* @returns {Array} [startDate, endDate] - 所在年 1月1日 00:00:00 至 12月31日 23:59:59Date 对象)
*/
function getSelectedYearRange(selectTime) {
// 兼容 String 类型时间和 Date 对象,统一转为 Date 实例
const targetDate = new Date(selectTime);
// 处理无效日期(若传入非法时间,返回当前时间的本年范围)
// if (isNaN(targetDate.getTime())) {
// console.warn('传入的时间格式无效,将使用当前时间计算本年范围');
// return getCurrentYearRange(); // 可根据需求改为抛出错误或返回空
// }
const year = targetDate.getFullYear(); // 获取选择时间的年份
const start = new Date(year, 0, 1); // 所在年 1月1日月份从 0 开始)
start.setHours(0, 0, 0, 0); // 重置时分秒为 00:00:00.000
const end = new Date(year, 11, 31); // 所在年 12月31日11 代表 12 月)
end.setHours(23, 59, 59, 999); // 重置时分秒为 23:59:59.999
return [start, end];
}
// 格式化时间为 yyyy-MM-dd HH:mm:ssVue2 兼容)
function formatDateTime(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 `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
export default {
components: {
AddOrUpdate
},
data() {
return {
urlOptions: {
getDataListURL: getCostOriginRadioHisData
},
data() {
return {
urlOptions: {
getDataListURL: getCostOriginRadioHisData
},
tableData: [],
listQuery: {
pageSize: 10,
@@ -101,181 +169,368 @@ export default {
total: 1,
bindObjectId: undefined,
statisticType: undefined,
startTime: undefined,
endTime: undefined
},
pdLineList:[],
pdLineList: [],
exportLoading: false,
dataListLoading: false,
selectedList: [],
dialogVisible: false,
selectedList: [],
dialogVisible: false,
addOrEditTitle: '',
addOrUpdateVisible: false,
tableProps,
tableProps,
tableBtn: [
{
type: 'edit',
btnName: '编辑',
},
].filter((v) => v),
tableData: [],
fileName: '',
].filter(v => v),
fileName: '',
formConfig: [
{
type: 'select',
label: '维度',
label: '报表类型',
onchange: true,
selectOptions: [
{
id: '0',
name:'班组'
},
{
id: '1',
name: '日'
},
{
id: '2',
name: '周'
},
{
id: '3',
name: '月'
},
{
id: '4',
name: '年'
}
{ id: '0', name: '班组' },
{ id: '1', name: '日' },
{ id: '2', name: '周' },
{ id: '3', name: '月' },
{ id: '4', name: '年' }
],
param: 'statisticType'
param: 'statisticType',
index: 1,
extraOptions: [
{
parent: 'statisticType',
type: 'datePicker',
label: '统计时间',
dateType: 'daterange',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
defaultTime: ['00:00:00', '23:59:59'],
defaultSelect: [],
width: 250,
key: 'datePicker-0', // 唯一 key触发重新渲染
appendToBody: true // 优化定位:挂载到 body 下
},
// 日 - 日期范围选择
{
parent: 'statisticType',
type: 'datePicker',
label: '统计时间',
dateType: 'daterange',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeValDay',
defaultTime: ['00:00:00', '23:59:59'],
defaultSelect: [],
width: 250,
key: 'datePicker-1', // 唯一 key触发重新渲染
appendToBody: true // 优化定位:挂载到 body 下
},
// 周 - 单个日期选择(自动获取本周范围)
{
parent: 'statisticType',
type: 'datePicker',
label: '统计时间',
dateType: 'week',
placeholder: '选择日期',
format: 'yyyy 第 WW 周',
pickerOptions: {
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天0=周日1=周一,依此类推)
},
valueFormat: 'yyyy-MM-dd',
param: 'timeValWeek',
width: 250,
key: 'datePicker-2', // 唯一 key触发重新渲染
appendToBody: true // 优化定位:挂载到 body 下
},
// 月 - 日期范围选择
{
parent: 'statisticType',
type: 'datePicker',
label: '统计时间',
dateType: 'monthrange',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeValMonth',
defaultTime: ['00:00:00', '23:59:59'],
width: 250,
key: 'datePicker-3', // 唯一 key触发重新渲染
appendToBody: true // 优化定位:挂载到 body 下
},
// 年 - 单个日期选择(自动获取本年范围)
{
parent: 'statisticType',
type: 'datePicker',
label: '统计时间',
dateType: 'year',
placeholder: '选择年份',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd',
param: 'timeValYear',
width: 250,
key: 'datePicker-4', // 唯一 key触发重新渲染
appendToBody: true // 优化定位:挂载到 body 下
}
]
},
{
type: 'select',
label: '产线',
selectOptions: [],
{
type: 'select',
label: '产线',
selectOptions: [],
param: 'bindObjectId'
},
{
type: 'datePicker',
label: '统计开始时间',
dateType: 'daterange',
format: 'yyyy-MM-dd',
valueFormat: "yyyy-MM-dd HH:mm:ss",
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
defaultTime: ['00:00:00', '23:59:59'],
defaultSelect: []
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'separate',
},
{
// type: this.$auth.hasPermi('base:factory:export') ? 'button' : '',
type: 'button',
btnName: '导出',
name: 'export',
color: 'warning',
}
],
};
},
{
type: 'separate',
},
{
type: 'button',
btnName: '导出',
name: 'export',
color: 'warning',
}
],
};
},
watch: {
// 监听报表类型变化,强制刷新日期选择器
'listQuery.statisticType'(newVal, oldVal) {
if (newVal !== oldVal && this.$refs.searchBarForm) {
// 触发 search-bar 组件重新渲染(如果 search-bar 支持)
if (this.$refs.searchBarForm.$forceUpdate) {
this.$refs.searchBarForm.$forceUpdate();
}
// 延迟重置定位,确保 DOM 已更新
setTimeout(() => {
const datePickerEl = this.$refs.searchBarForm.$el.querySelector('.el-date-picker');
if (datePickerEl) {
// 触发 Element UI 日期选择器重新计算定位(内部方法)
const datePickerInstance = datePickerEl.__vue__;
if (datePickerInstance && datePickerInstance.updatePopper) {
datePickerInstance.updatePopper();
}
}
}, 100);
}
}
},
mounted() {
this.$refs.searchBarForm.formInline.statisticType = '1';
// Vue2 中 $refs 需在 $nextTick 中访问(确保 DOM 渲染完成)
this.$nextTick(() => {
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.formInline.statisticType = '1';
}
});
this.listQuery.statisticType = '1';
this.getDataList()
this.getPdLineList()
},
this.getDataList();
this.getPdLineList();
},
methods: {
selectType(val) {
// 报表类型切换时的回调(如需扩展可在此添加逻辑)
console.log('报表类型切换:', val);
},
handleClick(val) {
console.log(val);
console.log('操作按钮点击:', val);
if (val.type === 'edit') {
this.addOrUpdateVisible= true
this.addOrUpdateVisible = true;
// Vue2 中 $nextTick 确保子组件已渲染
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data);
});
}
},
getPdLineList() {
getPdList().then((res) => {
this.formConfig[1].selectOptions = res.data || []
this.pdLineList = res.data || []; // 保存产线数据
})
},
selectChange(val) {
console.log(val)
this.selectedList = val
},
buttonClick(val) {
console.log('val', val);
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.bindObjectId = val.bindObjectId ? val.bindObjectId : undefined;
this.listQuery.statisticType = val.statisticType ? val.statisticType : undefined;
this.listQuery.startTime = val.timeVal ? val.timeVal[0]: undefined;
this.listQuery.endTime = val.timeVal ? val.timeVal[1]: undefined;
//this.listQuery.reportEndTime = val.timeVal ? [new Date(val.timeVal[1]).getTime()] : undefined;
this.getDataList();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
// 获取数据列表
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then(response => {
const arr = ['班组','日', '周', '月', '年'];
this.tableData = response.data?.list?.map((item) => {
item.reportType = arr[this.listQuery.statisticType];
item.statisticType = this.listQuery.statisticType
// 匹配 bindObjectName
const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
item.bindObjectName = targetLine ? targetLine.name : ''; // 赋值名称,无匹配则为空
return item;
});
this.listQuery.total = response.data.total;
this.dataListLoading = false;
getPdLineList() {
getPdList().then(res => {
// Vue2 中数组赋值需确保响应式
this.$set(this.formConfig[1], 'selectOptions', res.data || []);
this.pdLineList = res.data || [];
}).catch(err => {
console.error('获取产线列表失败:', err);
});
},
// 每页数
selectChange(val) {
console.log('选择变更:', val);
this.selectedList = val;
},
buttonClick(val) {
console.log('头部按钮点击:', val);
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.bindObjectId = val.bindObjectId ? val.bindObjectId : undefined;
this.listQuery.statisticType = val.statisticType ? val.statisticType : undefined;
// 处理不同时间维度的时间范围
this.handleTimeRange(val);
this.getDataList();
break;
case 'export':
this.handleExport();
break;
default:
console.log('未知按钮:', val);
}
},
// 处理不同时间维度的时间范围
handleTimeRange(val) {
const statisticType = val.statisticType;
const timeVal = val.timeVal;
const timeValDay = val.timeValDay;
const timeValWeek = val.timeValWeek;
const timeValMonth = val.timeValMonth;
const timeValYear = val.timeValYear;
// 重置时间参数
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
switch (statisticType) {
case '0': // 班组 - 沿用原时间范围
if (timeVal && timeVal.length === 2) {
this.listQuery.startTime = timeVal[0];
this.listQuery.endTime = timeVal[1];
}
break;
case '1': // 日 - 沿用原时间范围
if (timeValDay && timeValDay.length === 2) {
this.listQuery.startTime = timeValDay[0];
this.listQuery.endTime = timeValDay[1];
}
break;
case '3': // 月 - 沿用原时间范围
if (timeValMonth && timeValMonth.length === 2) {
this.listQuery.startTime = timeValMonth[0];
this.listQuery.endTime = timeValMonth[1];
}
break;
case '2': // 周 - 自动计算本周范围
if (timeValWeek) {
const [start, end] = getSelectedWeekRange(timeValWeek);
this.listQuery.startTime = formatDateTime(start);
this.listQuery.endTime = formatDateTime(end);
}
break;
case '4': // 年 - 自动计算本年范围
if (timeValYear) {
const [start, end] = getSelectedYearRange(timeValYear);
this.listQuery.startTime = formatDateTime(start);
this.listQuery.endTime = formatDateTime(end);
}
break;
}
},
// 获取数据列表
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery)
.then(response => {
const arr = ['班组', '日', '周', '月', '年'];
// Vue2 中数组赋值确保响应式
this.tableData = (response.data?.list || []).map(item => {
item.reportType = arr[this.listQuery.statisticType] || '';
item.statisticType = this.listQuery.statisticType;
// 匹配产线名称
// const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
// item.bindObjectName = targetLine ? targetLine.name : ''
return item;
})
this.listQuery.total = response.data?.total || 0;
})
.catch(err => {
console.error('获取数据失败:', err);
this.tableData = [];
this.listQuery.total = 0;
})
.finally(() => {
this.dataListLoading = false;
});
},
// 每页数变更
sizeChangeHandle(val) {
this.listQuery.pageSize = val;
this.listQuery.pageNo = 1;
this.getDataList();
},
// 当前页
// 当前页变更
currentChangeHandle(val) {
this.listQuery.pageNo = val;
this.getDataList();
},
// 导出处理
handleExport() {
// 处理查询参数
let params = { ...this.listQuery };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出原片报表?').then(() => {
this.exportLoading = true;
return exportCostOriginRadioHisData(params);
}).then(response => {
this.$download.excel(response, '原片报表.xls');
this.exportLoading = false;
}).catch(() => { });
const params = { ...this.listQuery };
// 移除分页参数
delete params.pageNo;
delete params.pageSize;
delete params.total;
this.$modal.confirm('是否确认导出原片报表?')
.then(() => {
this.exportLoading = true;
return exportCostOriginRadioHisData(params);
})
.then(response => {
this.$download.excel(response, '原片报表.xls');
})
.catch(err => {
console.error('导出失败:', err);
})
.finally(() => {
this.exportLoading = false;
});
}
},
},
// Vue2 中监听数据变化(如需)
watch: {
'listQuery.statisticType'(newVal) {
console.log('报表类型变更:', newVal);
// 可添加类型变更后的额外逻辑
}
}
};
</script>
<style scoped>
.app-container {
padding: 16px;
}
.no-data-bg {
height: 400px;
background-color: #f5f7fa;
display: flex;
align-items: center;
justify-content: center;
color: #999;
}
.right-aside {
margin-bottom: 16px;
}
</style>

View File

@@ -0,0 +1,274 @@
<template>
<div class="searchBarBox divHeight" ref="searchBarRef" :style="{ paddingRight: isFold ? '55px' : '0px' }">
<el-form :inline="true" ref="searchBarForm" :model="formInline" class="searchBar">
<span class="blue-block" v-if="removeBlue ? false : true"></span>
<template v-for="item in formConfig">
<el-form-item v-if="item.type !== ''" :key="item.param" :label="item.label ? item.label : ''"
:required="item.required ? item.required : false">
<el-input v-if="item.type === 'input'" v-model="formInline[item.param]"
:size="item.size ? item.size : 'small'" clearable :disabled="item.disabled ? item.disabled : false"
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'"
:placeholder="item.placeholder ? item.placeholder : ''" />
<el-select v-if="item.type === 'select'" v-model="formInline[item.param]"
:size="item.size ? item.size : 'small'" :filterable="item.filterable ? item.filterable : false"
:multiple="item.multiple ? item.multiple : false" :clearable="item.clearable === false ? false : true"
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'" :placeholder="item.label" @change="
item.onchange
? $emit('select-changed', {
param: item.param,
value: formInline[item.param]
})
: null
">
<el-option v-for="(sub, i) in item.selectOptions" :key="i"
:label="item.labelField ? sub[item.labelField] : sub['name']"
:value="item.valueField ? sub[item.valueField] : sub['id']" />
</el-select>
<el-date-picker v-if="item.type === 'datePicker'" :key="item.param" :size="item.size ? item.size : 'small'"
v-model="formInline[item.param]" :type="item.dateType" :format="item.format ? item.format : 'yyyy-MM-dd'"
:value-format="item.valueFormat ? item.valueFormat : null" :default-time="item.defaultTime || null"
:range-separator="item.rangeSeparator || null" :start-placeholder="item.startPlaceholder || null"
:end-placeholder="item.endPlaceholder || null" :placeholder="item.placeholder"
:picker-options="item.pickerOptions ? item.pickerOptions : null"
:clearable="item.clearable === false ? false : true"
:style="item.width ? 'width:' + item.width + 'px' : (item.dateType === 'datetimerange' ? 'width:340px' : (item.dateType === 'daterange' ? 'width:220px' : 'width:140px'))" />
<el-autocomplete v-if="item.type === 'autocomplete'" v-model="formInline[item.param]"
:value-key="item.valueKey ? item.valueKey : 'value'" :size="item.size ? item.size : 'small'"
:fetch-suggestions="item.querySearch" :placeholder="item.placeholder"
:clearable="item.clearable === false ? false : true"
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'" filterable />
<el-cascader v-if="item.type === 'cascader'" v-model="formInline[item.param]" :options="item.selectOptions"
:props="item.cascaderProps" :size="item.size ? item.size : 'small'"
:clearable="item.clearable === false ? false : true"
:show-all-levels="item.showAllLevels === false ? false : true"
:collapse-tags="item.collapseTags === true ? true : false"
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'" @change="
item.onChange
? $emit('cascader-change', {
param: item.param,
value: formInline[item.param]
})
: null
"></el-cascader>
<el-button v-if="item.type === 'button'" :type="item.color" :size="item.size ? item.size : 'small'"
:plain="item.plain ? item.plain : false" :round="item.round ? item.round : false"
@click="headBtnClick(item.name)">{{ item.btnName }}</el-button>
<span v-if="item.type === 'separate'" class="separateStyle"></span>
<!-- 可用于显示其他按钮 -->
</el-form-item>
</template>
<el-form-item>
<slot></slot>
</el-form-item>
</el-form>
<span v-if="isFold" class="foldClass" @click='switchMode'>
{{ isExpand ? '收起' : '展开' }}
<i class="iconfont" :class="isExpand ? 'icon-upward' : 'icon-downward'"></i>
</span>
</div>
</template>
<script>
export default {
name: 'SearchBar',
props: {
formConfigs: {
type: Array,
default: () => {
return []
}
},
removeBlue: {
type: Boolean,
default: false
},
isFold: {// 多行模式(默认否)
type: Boolean,
default: false
}
},
data() {
const formInline = {}
const formConfig = this.formConfigs
let hasExtraOptions = false
for (const obj of formConfig) {
if (obj.type !== 'button') {
if (obj.defaultSelect === false || obj.defaultSelect === 0) {
formInline[obj.param] = obj.defaultSelect
} else {
formInline[obj.param] = obj.defaultSelect || '' // defaultSelect下拉框默认选中项
}
}
if (obj.extraOptions) {
hasExtraOptions = true
}
}
return {
formInline,
formConfig,
hasExtraOptions,
isExpand: false // 是否展开(默认否)
}
},
watch: {
formConfig: {
handler() {
for (const obj of this.formConfig) {
if (obj.defaultSelect) {
this.formInline[obj.param] = obj.defaultSelect
} else if (obj.defaultSelect === null) {
// 需要手动从外部清除选项缓存的情况确保在外部配置项中可直接设置null
this.formInline[obj.param] = ''
}
}
},
deep: true,
immediate: true
},
formInline: {
handler: function () {
this.$forceUpdate()
},
deep: true,
immediate: true
}
},
mounted() {
this.$nextTick(() => {
this.init()
})
},
methods: {
init() {
if (this.hasExtraOptions) {
// 如果有额外参数就处理,如果没有就算了
for (const obj of this.formConfig) {
if (obj.extraOptions) {
// 注: 对obj.extraOptions的选择是互斥的!
this.$watch(
`formInline.${obj.param}`,
function (newVal) {
let deleteCount = 0
if (obj.index + 1 < this.formConfig.length) {
// 如果obj不是最后一个配置
const nextConfig = this.formConfig[obj.index + 1]
if (nextConfig.parent && nextConfig.parent === obj.param)
deleteCount = 1
}
const currentConfig = Object.assign(
{},
obj.extraOptions[newVal]
)
this.formConfig.splice(
obj.index + 1,
deleteCount,
currentConfig
)
// 修改 formInline
this.$set(this.formInline, currentConfig.param, '')
},
{ immediate: true }
)
}
}
}
},
headBtnClick(btnName) {
this.formInline.btnName = btnName
this.$emit('headBtnClick', this.formInline)
},
resetForm() {
this.$refs.searchBarForm.resetFields()
const formInline = {}
const formConfig = this.formConfigs
for (const obj of formConfig) {
if (obj.type !== 'button') {
if (obj.defaultSelect === false || obj.defaultSelect === 0) {
formInline[obj.param] = obj.defaultSelect
} else {
formInline[obj.param] = obj.defaultSelect || '' // defaultSelect下拉框默认选中项
}
}
}
this.formInline = formInline
},
switchMode() {// 展开和收起切换
this.isExpand = !this.isExpand
const element = this.$refs.searchBarRef
if (this.isExpand) {
element.classList.remove('divHeight')
} else {
element.classList.add('divHeight')
}
}
}
}
</script>
<style>
.searchBarBox {
width: 100%;
position: relative;
margin-bottom: 8px;
}
.searchBarBox::after {
content: "";
display: block;
clear: both;
}
.divHeight {
height: 45px;
overflow: hidden;
}
.searchBar .blue-block {
display: inline-block;
float: left;
width: 4px;
height: 16px;
background-color: #0B58FF;
border-radius: 1px;
margin-right: 8px;
margin-top: 12px;
}
.searchBar .el-form-item {
margin-bottom: 4px;
}
.searchBar .el-date-editor .el-range__icon {
font-size: 16px;
color: #0B58FF;
}
.searchBar .el-input__prefix .el-icon-date {
font-size: 16px;
color: #0B58FF;
}
.searchBar .el-input__prefix .el-icon-time {
font-size: 16px;
color: #0B58FF;
}
.searchBar .separateStyle {
display: inline-block;
width: 1px;
height: 24px;
background: #E8E8E8;
vertical-align: middle;
}
.searchBarBox .foldClass {
position: absolute;
top: 14px;
right: 0;
cursor: pointer;
font-size: 12px;
color: #0B58FF;
}
.searchBarBox .foldClass .iconfont {
font-size: 14px;
}
</style>

View File

@@ -1,423 +1,430 @@
<template>
<div class="home-page">
<div class="date-tabs">
<!-- @tab-click="handleClick" -->
<el-tabs v-model="activeName" @tab-click="timedayChange" :stretch="true">
<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">
<div class="app-container">
<!-- 顶部日期&筛选栏 -->
<el-row :gutter="20" class="top-bar">
<el-col :span="8">
<el-date-picker
v-model="timeday"
align="right"
type="date"
format="yyyy-MM-dd"
valueFormat="yyyy-MM-dd"
:clearable="false"
@change="timedayChange"
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>
v-model="dateRange"
type="daterange"
range-separator="~"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd" />
<el-button type="primary" style="margin-left: 10px">查询</el-button>
</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.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 :span="16">
<el-tag type="info" @click="changeTime('yesterday')">昨日</el-tag>
<el-tag type="info" @click="changeTime('week')">本周</el-tag>
<el-tag type="info" @click="changeTime('month')">本月</el-tag>
<el-tag type="info" @click="changeTime('year')">本年</el-tag>
</el-col>
</el-row>
<el-row class="main-bottom" :gutter="16" v-if="false">
<el-col :span="9">
<div class="chart-wrapper">
<line-chart :chart-data="lineChartData" />
</div>
</el-col>
<el-col :span="7">
<div class="chart-wrapper">
<pie-chart />
</div>
<!-- 成本概览卡片 -->
<el-row :gutter="20" class="card-row">
<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="80" color="#42b983" />
</div>
</el-card>
</el-col>
<el-col :span="8">
<div class="chart-wrapper">
<bar-chart />
</div>
<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-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-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>
</template>
<script>
import moment from 'moment';
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],
},
};
import * as echarts from 'echarts';
export default {
name: 'Home',
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', // 调整条纹的大小
};
},
},
name: 'CostDashboard',
data() {
return {
activeName: '日',
user: '',
lineChartData: lineChartData.newVisitis,
homeData: {},
timeday: moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD'),
startTime:
moment(new Date()).subtract(0, 'days').format('YYYY-MM-DD') +
' 00:00:00',
endTime:
moment(new Date()).subtract(-1, 'days').format('YYYY-MM-DD') +
' 00:00:00',
pickerOptions: {
disabledDate(time) {
return time.getTime() + 3600 * 1000 * 24 > Date.now();
},
shortcuts: [
{
text: '今天',
onClick(picker) {
picker.$emit('pick', new Date());
},
},
{
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);
},
},
],
},
dateRange: ['2023-05-06', '2023-05-06'],
costTab: 'raw',
itemTab: 'labor',
// 原片成本子项
rawSubCosts: [
{ name: '人工成本', val: 4.56, target: 4.32 },
{ name: '原料成本', val: 4.56, target: 4.32 },
{ name: '原片制造费用', val: 4.56, target: 4.32 },
{ name: '玻璃热耗', val: 4.56, target: 4.32 },
{ name: '原片成品率', val: 4.56, target: 4.32 },
],
// 加工成本子项
processSubCosts: [
{ name: '人工成本', val: 4.56, target: 4.32 },
{ name: '加工动力成本', val: 4.56, target: 4.32 },
{ name: '加工制造费用', val: 4.56, target: 4.32 },
{ name: '加工投入产出率', val: 4.56, target: 4.32 },
],
// 趋势图模拟数据
trendX: ['00:00', '01:00', '02:00'],
trendY: [20, 40, 50],
targetY: 12.54,
};
},
created() {
},
beforeDestroy() {
mounted() {
this.initCostPie();
this.initTotalTrend();
this.initRawProcessTrend();
this.initItemTrend();
},
methods: {
getData() {
let listQuery = {
//分页
pageSize: 10,
pageNo: 1,
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName),
startTime: this.timeday + ' 00:00:00',
};
getData(listQuery).then((response) => {
this.homeData = response.data;
for (let i in this.homeData) {
this.homeData[i] = Number(this.homeData[i]).toFixed(2);
}
// 切换时间范围(示例)
changeTime(type) {
// 实际项目中需根据type请求对应数据
console.log('切换时间:', type);
},
// 初始化成本构成饼图
initCostPie() {
const pieChart = echarts.init(document.getElementById('costPie'));
pieChart.setOption({
tooltip: { trigger: 'item' },
legend: {
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 = {
//分页
pageSize: 10,
pageNo: 1,
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName),
startTime: this.timeday + ' 00:00:00',
};
getData(listQuery).then((response) => {
this.homeData = response.data;
for (let i in this.homeData) {
this.homeData[i] = Number(this.homeData[i]).toFixed(2);
}
});
// 初始化总制造成本趋势图
initTotalTrend() {
const totalChart = echarts.init(document.getElementById('totalTrend'));
totalChart.setOption({
grid: { top: 20, bottom: 30, left: 30, 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', () => 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>
<style lang="scss" scoped>
.home-page::before {
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;
<style scoped>
.top-bar {
margin-bottom: 20px;
}
:deep(.date-tabs) {
.el-tabs__header {
margin-bottom: 8px;
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;
}
.card-row,
.composition-row {
margin-bottom: 20px;
}
.detail {
display: inline-block;
position: absolute;
left: 260px;
top: 10px;
.cost-card .card-title {
font-size: 22px;
font-weight: bold;
margin-bottom: 15px;
}
:deep(.detail) {
.el-input__inner {
background-color: transparent;
color: white;
}
}
// .current-date {
// color: #fff;
// font-size: 18px;
// position: absolute;
// left: 260px;
// top: 14px;
// }
.current-time {
color: #fff;
.cost-card .card-content {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 10px;
align-items: center;
font-size: 18px;
position: absolute;
right: 38px;
top: 14px;
}
.main-top {
width: 100%;
padding: 0 20px 0 40px;
.title {
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%);
}
}
.target-val {
color: #666;
margin-left: 5px;
font-size: 20px;
}
.main-bottom {
width: 100%;
margin-top: 20px;
.chart-wrapper {
margin-left: 10px;
height: 425px;
background: #fff;
border-radius: 5px;
box-shadow: 0 3px 3px 0 gray;
}
}
</style>
<style lang="scss">
.home-page {
.el-progress-bar__inner {
background-image: url('~@/assets/img/home-progress-bg.png');
background-size: cover;
}
.actual-val {
color: #42b983;
margin-left: 5px;
font-size: 20px;
}
.composition-card {
height: 480px;
}
.composition-card .card-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 15px;
}
.sub-cost {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
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>

View File

@@ -40,7 +40,7 @@ $pxls: (xl, 28px) (lg, 24px) (de, 20px) (md, 18px) (sm, 16px);
$mgr: 8px;
@each $size, $height in $pxls {
.#{$size}-title {
font-size: $height;
font-size: 18px;
line-height: $height;
color: #000;
font-weight: 500;

View File

@@ -0,0 +1,134 @@
<template>
<el-dialog :visible.sync="visible" width="40%">
<small-title slot="title" :no-padding="true">
{{ this.dataForm.lineId + '·' + this.dataForm.equipmentName }}
</small-title>
<div class="content">
<div class="visual-part">
<base-table :table-props="tableProps"
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
@clickBtn="handleClick" /> -->
</base-table>
</div>
</div>
<!-- <div slot="footer" class="dialog-footer">
<el-button style="" @click="goback()">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">
确定
</el-button>
</div> -->
</el-dialog>
</template>
<script>
const tableProps = [
{
prop: 'paramName',
label: '参数名称'
},
{
prop: 'paramValue',
label: '当前值',
// filter: parseTime,
// width: 160
},
];
import { getParamMonitor } from '@/api/base/equipment';
// import { parseTime } from '../../mixins/code-filter';
import SmallTitle from './SmallTitle';
export default {
components: { SmallTitle },
data() {
return {
visible: false,
tableProps,
tableData:[],
listQuery: {
pageNo: 1,
pageSize:100,
},
addOrUpdateVisible: false,
dataForm: {
equipmentId:undefined,
equipmentName: undefined,
lineId: undefined,
},
};
},
methods: {
init(data) {
console.log(data.paramMonitors,'data');
this.dataForm.equipmentId = data.equipmentId || '';
this.dataForm.equipmentName = data.equipmentName || '';
this.dataForm.lineId = data.lineId || '';
this.visible = true;
this.$nextTick(() => {
// this.$refs['dataForm'].resetFields();
// getParamMonitor({
// equipmentId:this.dataForm.equipmentId
// }).then((res) => {
this.tableData = data.paramMonitors
// })
});
}
},
};
</script>
<style scoped>
.drawer >>> .el-drawer {
border-radius: 8px 0 0 8px;
display: flex;
flex-direction: column;
}
.drawer >>> .el-form-item__label {
padding: 0;
}
.drawer >>> .el-drawer__header {
margin: 0;
padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6;
}
.drawer >>> .el-drawer__body {
flex: 1;
height: 1px;
display: flex;
flex-direction: column;
}
.drawer >>> .content {
padding: 30px 24px;
flex: 1;
display: flex;
flex-direction: column;
/* height: 100%; */
}
.drawer >>> .visual-part {
flex: 1 auto;
max-height: 76vh;
overflow: hidden;
overflow-y: scroll;
padding-right: 10px; /* 调整滚动条样式 */
}
.drawer >>> .el-form,
.drawer >>> .attr-list {
padding: 0 16px;
}
.drawer-body__footer {
display: flex;
justify-content: flex-end;
padding: 18px;
}
</style>

View File

@@ -0,0 +1,561 @@
<template>
<el-dialog :visible.sync="visible" width="80%" @close="handleClose" title-class="dialog-title">
<small-title slot="title" :no-padding="true">
{{ dataForm.lineId + '·' + dataForm.equipmentName }}
</small-title>
<search-bar removeBlue :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
<el-tabs class="custom-tabs" v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'\u3000报警时长\u3000'" name="duration"></el-tab-pane>
<el-tab-pane :label="'\u3000报警次数\u3000'" name="times"></el-tab-pane>
</el-tabs>
<div class="content">
<div class="visual-part">
<div v-if="hasData" style="display: flex; justify-content: space-around; gap: 20px; padding: 10px 0;">
<!-- 移除 v-if始终渲染两个图表容器 -->
<div id="barChart" style="width: 48%; height: 400px;"></div>
<div id="pieChart" style="width: 48%; height: 400px;"></div>
</div>
<div v-if="!hasData" class="no-data">
<el-empty description="暂无相关报警数据"></el-empty>
</div>
</div>
</div>
</el-dialog>
</template>
<script>
import { getAlarmDet } from '@/api/base/equipment';
import * as echarts from 'echarts';
import SmallTitle from './SmallTitle';
const CHART_CONFIG = {
barColor: '#288AFF',
pieColors: [
'#288AFF', '#4096FF', '#69B1FF', '#91CFFF', '#B8E0FF',
'#E0F2FF', '#1890FF', '#096DD9', '#0050B3', '#003A8C'
],
fontColor: '#333',
lightFontColor: '#666',
borderRadius: 4
};
export default {
components: { SmallTitle },
data() {
return {
visible: false,
hasData: false,
listQuery: {
pageNo: 1,
pageSize: 100,
equipmentId: undefined,
startTime: undefined,
endTime: undefined
},
formConfig: [
{
type: 'datePicker',
label: '时间段',
dateType: 'daterange',
format: 'yyyy-MM-dd',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
defaultTime: ['00:00:00', '23:59:59'],
defaultSelect: []
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary'
}
],
activeLabel: 'duration', // 默认选中「报警时长」
dataForm: {
equipmentId: undefined,
equipmentName: undefined,
lineId: undefined
},
chartInstances: {
bar: null,
pie: null
},
isDomReady: false,
originData: null // 存储原始数据
};
},
mounted() {
this.$nextTick(() => {
this.isDomReady = true;
if (this.listQuery.equipmentId) {
this.getDataList();
}
});
},
watch: {
// Tab 切换时自动刷新图表(无需额外操作,依赖 handleTabClick 触发查询)
activeLabel() {
if (this.isDomReady && this.originData) {
this.$nextTick(() => {
this.renderBothCharts(); // 切换 Tab 后重新渲染两个图表
});
}
}
},
methods: {
initDefaultDate() {
const today = new Date();
const start = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0, 0).getTime();
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 0).getTime();
this.formConfig[0].defaultSelect = [start, end];
this.listQuery.startTime = start;
this.listQuery.endTime = end;
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.form.timeVal = [start, end];
}
},
handleTabClick() {
// 切换 Tab 时重新查询数据(或直接复用已有数据渲染)
this.getDataList();
},
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.startTime = val.timeVal?.[0];
this.listQuery.endTime = val.timeVal?.[1];
this.getDataList();
break;
default:
}
},
async getDataList() {
try {
if (!this.listQuery.equipmentId) {
console.warn('设备ID不能为空');
this.hasData = false;
return;
}
const queryParams = {
equipmentId: this.listQuery.equipmentId,
startTime: this.listQuery.startTime,
endTime: this.listQuery.endTime,
};
const res = await getAlarmDet(queryParams);
const originData = res.data || [];
this.originData = originData;
this.hasData = originData.length > 0;
if (this.hasData && this.isDomReady) {
this.$nextTick(() => {
this.renderBothCharts(); // 数据查询成功后,同时渲染两个图表
});
} else {
this.destroyAllCharts();
}
} catch (error) {
console.error('获取报警数据失败:', error);
this.hasData = false;
this.destroyAllCharts();
}
},
// 核心方法:同时渲染柱状图和饼图(根据当前 Tab 类型)
renderBothCharts() {
if (this.activeLabel === 'duration') {
// 报警时长:柱状图(时长排序)+ 饼图(时长占比)
this.renderBarChart('duration');
this.renderPieChart('duration');
} else {
// 报警次数:柱状图(次数排序)+ 饼图(次数占比)
this.renderBarChart('times');
this.renderPieChart('times');
}
},
// 渲染柱状图(支持两种数据类型)
renderBarChart(type) {
this.destroyChart('bar');
const chartDom = document.getElementById('barChart');
if (!chartDom || !this.originData.length) return;
// 根据类型排序和提取数据
let sortedData, xData, seriesData, yAxisName;
if (type === 'duration') {
// 报警时长:按时长降序
sortedData = [...this.originData].sort((a, b) => b.alarmDuration - a.alarmDuration);
seriesData = sortedData.map(item => item.alarmDuration);
yAxisName = '报警时长';
} else {
// 报警次数:按次数降序
sortedData = [...this.originData].sort((a, b) => b.alarmCount - a.alarmCount);
seriesData = sortedData.map(item => item.alarmCount);
yAxisName = '报警次数';
}
xData = sortedData.map(item => this.truncateText(item.alarmContent, 8));
try {
this.chartInstances.bar = echarts.init(chartDom);
const option = {
title: {
text: `${yAxisName}统计(柱状图)`,
left: 'center',
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
},
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' },
padding: 10,
textStyle: { fontSize: 11 },
formatter: (params) => {
const index = params[0].dataIndex;
const item = sortedData[index];
return `
<div style="text-align: left;">
<div>${item.alarmContent}</div>
<div>${yAxisName}${type === 'duration' ? item.alarmDuration : item.alarmCount}</div>
<div>占比:${type === 'duration' ? item.alarmDurationRatio.toFixed(2) : item.alarmCountRatio.toFixed(2)}%</div>
</div>
`;
}
},
grid: {
left: '5%',
right: '5%',
bottom: '18%',
top: '15%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: xData,
axisTick: { alignWithLabel: true },
axisLabel: {
interval: 0,
fontSize: 12,
color: CHART_CONFIG.lightFontColor
},
axisLine: { lineStyle: { color: '#e8e8e8' } }
}
],
yAxis: [
{
type: 'value',
name: yAxisName,
nameTextStyle: { fontSize: 11, color: CHART_CONFIG.lightFontColor },
axisLabel: {
fontSize: 11,
color: CHART_CONFIG.lightFontColor,
},
axisLine: { lineStyle: { color: '#e8e8e8' } },
splitLine: { lineStyle: { color: '#f5f5f5' } },
max: (value) => value.max * 1.2
}
],
series: [
{
name: yAxisName,
type: 'bar',
itemStyle: {
color: CHART_CONFIG.barColor,
borderRadius: [CHART_CONFIG.borderRadius, CHART_CONFIG.borderRadius, 0, 0],
shadowBlur: 3,
shadowColor: 'rgba(40, 138, 255, 0.2)',
shadowOffsetY: 2
},
barWidth: '16',
data: seriesData,
label: {
show: true,
position: 'top',
distance: 6,
fontSize: 11,
color: CHART_CONFIG.fontColor,
formatter: (params) => `${params.value}`
}
}
]
};
this.chartInstances.bar.setOption(option);
this.addResizeListener('bar');
} catch (error) {
console.error(`${yAxisName}柱状图初始化失败:`, error);
setTimeout(() => this.renderBarChart(type), 200);
}
},
// 渲染饼图(支持两种数据类型)
renderPieChart(type) {
this.destroyChart('pie');
const chartDom = document.getElementById('pieChart');
if (!chartDom || !this.originData.length) return;
// 根据类型处理饼图数据
let pieData, seriesName;
if (type === 'duration') {
// 报警时长:按时长占比处理
seriesName = '报警时长';
pieData = this.handlePieData(this.originData, 'alarmDuration', 'alarmDurationRatio');
} else {
// 报警次数:按次数占比处理
seriesName = '报警次数';
pieData = this.handlePieData(this.originData, 'alarmCount', 'alarmCountRatio');
}
try {
this.chartInstances.pie = echarts.init(chartDom);
const option = {
title: {
text: `${seriesName}统计(饼图)`,
left: 'center',
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
},
tooltip: {
trigger: 'item',
padding: 10,
textStyle: { fontSize: 11 },
formatter: (params) => {
return `
<div style="text-align: left;">
<div>${params.name}</div>
<div>${seriesName}${params.value}${type === 'duration' ? '' : '次'}</div>
<div>占比:${params.percent.toFixed(2)}%</div>
</div>
`;
}
},
series: [
{
name: seriesName,
type: 'pie',
radius: ['50%', '70%'],
center: ['50%', '55%'],
color: CHART_CONFIG.pieColors,
label: {
show: true,
position: 'outside',
distance: 15,
fontSize: 11,
color: CHART_CONFIG.lightFontColor,
formatter: (params) => {
const truncatedName = this.truncateText(params.name, 8);
return `${truncatedName}(${params.value}${type === 'duration' ? '' : '次'}, ${params.percent.toFixed(1)}%)`;
},
align: 'center',
baseline: 'middle'
},
labelLine: {
show: true,
length: 15,
length2: 20,
lineStyle: {
color: '#ccc',
width: 1,
type: 'solid'
},
smooth: 0.2
},
data: pieData,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.1)'
},
label: {
color: CHART_CONFIG.fontColor,
fontSize: 12,
fontWeight: 500
},
labelLine: {
lineStyle: {
color: CHART_CONFIG.barColor,
width: 1.5
}
}
}
}
]
};
this.chartInstances.pie.setOption(option);
this.addResizeListener('pie');
} catch (error) {
console.error(`${seriesName}饼图初始化失败:`, error);
setTimeout(() => this.renderPieChart(type), 200);
}
},
// 通用饼图数据处理(支持动态字段)
handlePieData(data, valueKey, ratioKey) {
const threshold = 5; // 占比低于5%合并为「其他」
let otherCount = 0;
const mainData = data.filter(item => {
if (item[ratioKey] >= threshold) {
return true;
} else {
otherCount += item[valueKey];
return false;
}
}).map(item => ({
name: item.alarmContent,
value: item[valueKey],
ratio: item[ratioKey]
}));
if (otherCount > 0) {
mainData.push({
name: '其他',
value: otherCount,
ratio: 100 - mainData.reduce((sum, item) => sum + item.ratio, 0)
});
}
return mainData;
},
truncateText(text, maxLength) {
if (!text) return '';
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
},
addResizeListener(type) {
const chart = this.chartInstances[type];
if (chart) {
const resizeHandler = () => chart.resize();
window.addEventListener('resize', resizeHandler);
chart.resizeHandler = resizeHandler;
}
},
destroyChart(type) {
const chart = this.chartInstances[type];
if (chart) {
window.removeEventListener('resize', chart.resizeHandler);
chart.dispose();
this.chartInstances[type] = null;
}
},
destroyAllCharts() {
Object.keys(this.chartInstances).forEach(type => {
this.destroyChart(type);
});
},
handleClose() {
this.destroyAllCharts();
this.formConfig[0].defaultSelect = [];
this.listQuery.startTime = undefined;
this.listQuery.endTime = undefined;
this.originData = null;
this.hasData = true;
if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.form.timeVal = [];
}
},
init(data) {
this.dataForm = {
equipmentId: data.equipmentId || '',
equipmentName: data.equipmentName || '',
lineId: data.lineId || ''
};
this.activeLabel = 'duration'
this.listQuery.equipmentId = data.equipmentId || undefined;
this.visible = true;
this.originData = null;
this.hasData = false;
this.initDefaultDate();
this.$nextTick(() => {
this.$nextTick(() => {
this.isDomReady = true;
this.getDataList();
});
});
}
},
beforeDestroy() {
this.destroyAllCharts();
}
};
</script>
<style scoped>
/* 保持原有样式,优化图表容器布局 */
.drawer>>>.el-drawer {
border-radius: 8px 0 0 8px;
display: flex;
flex-direction: column;
}
.drawer>>>.el-form-item__label {
padding: 0;
}
.drawer>>>.el-drawer__header {
margin: 0;
padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6;
}
.drawer>>>.el-drawer__body {
flex: 1;
height: 1px;
display: flex;
flex-direction: column;
}
.drawer>>>.content {
padding: 30px 24px;
flex: 1;
display: flex;
flex-direction: column;
}
.drawer>>>.visual-part {
flex: 1 auto;
max-height: 76vh;
overflow: hidden;
padding: 10px 0;
}
/* 优化图表容器响应式布局 */
@media (max-width: 1200px) {
.visual-part>div {
flex-direction: column;
}
#barChart,
#pieChart {
width: 100% !important;
height: 350px !important;
margin-bottom: 20px;
}
}
.drawer>>>.el-form,
.drawer>>>.attr-list {
padding: 0 16px;
}
.drawer-body__footer {
display: flex;
justify-content: flex-end;
padding: 18px;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -2,14 +2,14 @@
* @Author: zwq
* @Date: 2025-10-23 13:43:55
* @LastEditors: zwq
* @LastEditTime: 2025-10-23 16:50:43
* @LastEditTime: 2025-11-14 21:13:10
* @Description:
-->
<template>
<div class="app-container">
<div class="app-container" style="padding-top: 0">
<div v-for="item in groupClassArr" :key="item.planId">
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
{{item.planName}}
{{ item.deptName + ' - ' + item.planName }}
</small-title>
<base-table
:table-props="tableProps"
@@ -59,13 +59,14 @@ export default {
},
created() {},
methods: {
init(det) {
init(det, detSort) {
this.tableData = det;
//返回计划名和id
const arr = det.map((item) => {
const obj = {
planName: item.schedulingPlanName,
planId: item.schedulingPlanId,
deptName: item.belongDeptName,
};
return obj;
});
@@ -76,7 +77,19 @@ export default {
map.set(item.planId, item);
}
});
this.groupClassArr = Array.from(map.values());
const newArr = Array.from(map.values());
// 创建B数组中id的顺序映射
const orderMap = new Map();
detSort.forEach((item, index) => {
orderMap.set(item, index);
});
// 根据B的顺序对A进行排序
this.groupClassArr = [...newArr].sort((a, b) => {
const orderA = orderMap.get(a.planId);
const orderB = orderMap.get(b.planId);
return orderA - orderB;
});
},
},
};

View File

@@ -2,212 +2,221 @@
* @Author: zwq
* @Date: 2025-10-23 13:43:55
* @LastEditors: zwq
* @LastEditTime: 2025-10-24 11:14:55
* @LastEditTime: 2025-11-25 09:39:43
* @Description:
-->
<template>
<el-row :gutter="10" style="background-color: #f2f4f9">
<!--部门数据-->
<el-col :span="4">
<div class="head-container">
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
<el-tab-pane label="部门" name="first"></el-tab-pane>
<el-tab-pane label="班组" name="second"></el-tab-pane>
</el-tabs>
<div v-if="activeName == 'first'">
<el-input
v-model="deptName"
placeholder="请输入部门名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px" />
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
highlight-current
@node-click="handleNodeClick" />
</div>
<div v-else>
<el-input
v-model="groupName"
placeholder="请输入班组名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px" />
<el-tree
:data="groupOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree1"
default-expand-all
highlight-current
@node-click="handleNodeClick1" />
</div>
<div
class="app-container"
style="
background-color: #f2f4f9;
padding: 0;
display: grid;
grid-template-columns: 1fr 5fr;
gap: 10px;
">
<div class="head-container">
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
<el-tab-pane label="部门" name="first"></el-tab-pane>
<el-tab-pane label="班组" name="second"></el-tab-pane>
</el-tabs>
<div v-if="activeName == 'first'">
<el-input
v-model="deptName"
placeholder="请输入部门名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px" />
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
default-expand-all
highlight-current
@node-click="handleNodeClick" />
</div>
</el-col>
<el-col :span="20">
<div class="groupTeamScheduling">
<div class="operationArea">
<el-form :inline="true" class="demo-form-inline">
<span class="blue-block"></span>
<el-form-item label="月份选择">
<el-date-picker
v-model="startDay"
type="month"
placeholder="选择月"
size="small"
@change="selectMonth"
:clearable="false"
style="width: 120px"></el-date-picker>
<span
style="color: #909399; font-size: 12px"
v-if="activeName == 'first'">
提示排班日历仅展示当前选中部门的节假日设置若休假日中仍有排班则表示下级组织已通过自定义假期进行排班
<div v-else>
<el-input
v-model="groupName"
placeholder="请输入班组名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px" />
<el-tree
:data="groupOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree1"
node-key="id"
default-expand-all
highlight-current
@node-click="handleNodeClick1" />
</div>
</div>
<div class="groupTeamScheduling">
<div class="operationArea">
<el-form :inline="true" class="demo-form-inline">
<span class="blue-block"></span>
<el-form-item label="月份选择">
<el-date-picker
v-model="startDay"
type="month"
placeholder="选择月"
size="small"
@change="selectMonth"
:clearable="false"
style="width: 120px"></el-date-picker>
<span
style="color: #909399; font-size: 12px"
v-if="activeName == 'first'">
提示排班日历仅展示当前选中部门的节假日设置若休假日中仍有排班则表示下级组织已通过自定义假期进行排班
</span>
<span v-else style="margin-left: 10px">
组长:
<span style="font-weight: 600; margin: 0 10px">
{{ showTeamName?.leaderName || '-' }}
</span>
<span v-else>
组长:{{ showTeamName?.leaderName || '-' }} 组长电话:{{
showTeamName?.leaderPhone || '-'
}}
组长电话:
<span style="font-weight: 600; margin: 0 10px">
{{ showTeamName?.leaderPhone || '-' }}
</span>
</el-form-item>
<el-form-item style="float: right">
<el-button
size="small"
type="primary"
@click="(startDay = new Date()), getHolidayPage()">
跳转到今天
</el-button>
</el-form-item>
</el-form>
</div>
<!-- 日历区域 -->
<div class="calenderArea">
<el-calendar v-model="startDay">
<template slot="dateCell" slot-scope="{ data }">
<div v-if="data.type === 'current-month'">
<!-- 日期 -->
<div class="dateStyle">
<el-row :gutter="20">
<!-- 公历和农历 -->
<el-col :span="18">
{{ Number(data.day.split('-')[2]) }}
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
</el-col>
<!-- 显示假或班 -->
<el-col :span="6">
<div
class="work-tip"
:style="{
backgroundColor: HolidayList[
Number(data.day.split('-')[2]) - 1
]?.isHoliday
? '#67C23A'
: '#409EFF',
}">
{{
HolidayList[Number(data.day.split('-')[2]) - 1]
?.isHoliday
? '假'
: '班'
}}
<!-- //变更节假日未更新排班计划的角标 -->
<div
class="subIcon"
v-if="
HolidayList[Number(data.day.split('-')[2]) - 1]
?.isUpdate
">
<el-tooltip
effect="dark"
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
placement="top">
<i
class="el-icon-warning"
style="color: #f56c6c"></i>
</el-tooltip>
</div>
</div>
</el-col>
<!-- 显示排班 -->
</span>
</el-form-item>
<el-form-item style="float: right">
<el-button
size="small"
type="primary"
@click="(startDay = new Date()), getHolidayPage()">
跳转到今天
</el-button>
</el-form-item>
</el-form>
</div>
<!-- 日历区域 -->
<div class="calenderArea">
<el-calendar v-model="startDay">
<template slot="dateCell" slot-scope="{ data }">
<div v-if="data.type === 'current-month'">
<!-- 日期 -->
<div class="dateStyle">
<el-row :gutter="20">
<!-- 公历和农历 -->
<el-col :span="18">
{{ Number(data.day.split('-')[2]) }}
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
</el-col>
<!-- 显示假或班 -->
<el-col :span="6">
<div
v-if="
HolidayList[Number(data.day.split('-')[2]) - 1]?.det
.length > 0
">
<el-col
:span="24"
v-for="(item, index) in HolidayList[
class="work-tip"
:style="{
backgroundColor: HolidayList[
Number(data.day.split('-')[2]) - 1
]?.det.filter(
(item) =>
item.schedulingPlanId ==
HolidayList[Number(data.day.split('-')[2]) - 1]
?.schedulingPlanId
)"
:key="index">
]?.isHoliday
? '#67C23A'
: '#409EFF',
}">
{{
HolidayList[Number(data.day.split('-')[2]) - 1]
?.isHoliday
? '假'
: '班'
}}
<!-- //变更节假日未更新排班计划的角标 -->
<div
class="subIcon"
v-if="
HolidayList[Number(data.day.split('-')[2]) - 1]
?.isUpdate
">
<el-tooltip
effect="dark"
content="点击展示全部排班计划"
placement="top-start">
<div
class="holiday-div"
:style="{
backgroundColor:
holidayDivColor[item?.classesCode],
}"
@click="
holidayLog(
HolidayList[Number(data.day.split('-')[2]) - 1]
?.det,
HolidayList[Number(data.day.split('-')[2]) - 1]
?.date
)
"
:title="
item.classesName +
' | ' +
item.teamName +
' | ' +
item.workTime
">
{{
item.classesName +
' | ' +
item.teamName +
' | ' +
item.workTime
}}
</div>
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
placement="top">
<i class="el-icon-warning" style="color: #f56c6c"></i>
</el-tooltip>
</el-col>
</div>
</div>
</el-row>
</div>
</div>
<div
v-else
style="font-size: 20px; font-weight: 500; text-align: left">
<el-row :gutter="20">
<el-col :span="24">
{{ Number(data.day.split('-')[2]) }}
<span style="font-size: 12px">
{{ getLunarDate(data.day) }}
</span>
</el-col>
<!-- 显示排班 -->
<div
v-if="
HolidayList[Number(data.day.split('-')[2]) - 1]?.det
.length > 0
">
<el-col
:span="24"
v-for="(item, index) in HolidayList[
Number(data.day.split('-')[2]) - 1
]?.det.filter(
(item) =>
item.schedulingPlanId ==
HolidayList[Number(data.day.split('-')[2]) - 1]
?.schedulingPlanId
)"
:key="index">
<el-tooltip
effect="dark"
content="点击展示全部排班计划"
placement="top-start">
<div
class="holiday-div"
:style="{
backgroundColor: holidayDivColor[item?.classesCode],
}"
@click="
holidayLog(
HolidayList[Number(data.day.split('-')[2]) - 1]
?.det,
HolidayList[Number(data.day.split('-')[2]) - 1]
?.date,
HolidayList[Number(data.day.split('-')[2]) - 1]
?.detSort
)
"
:title="
item.classesName +
' | ' +
item.teamName +
' | ' +
item.workTime
">
{{
item.classesName +
' | ' +
item.teamName +
' | ' +
item.workTime
}}
</div>
</el-tooltip>
</el-col>
</div>
</el-row>
</div>
</template>
</el-calendar>
</div>
</div>
<div
v-else
style="font-size: 20px; font-weight: 500; text-align: left">
<el-row :gutter="20">
<el-col :span="24">
{{ Number(data.day.split('-')[2]) }}
<span style="font-size: 12px">
{{ getLunarDate(data.day) }}
</span>
</el-col>
</el-row>
</div>
</template>
</el-calendar>
</div>
</el-col>
</div>
<base-dialog
:dialogTitle="dialogTitle"
:dialogVisible="logVisible"
@@ -228,7 +237,7 @@
</slot>
</template>
</base-dialog>
</el-row>
</div>
</template>
<script>
@@ -339,13 +348,43 @@ export default {
getEnableData().then((response) => {
// 处理 deptOptions 参数
this.deptOptions = [];
this.deptOptions.push(...this.handleTree(response.data, 'id'));
this.deptOptions.push(...this.handleTree1(response.data, 'id'));
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.deptId);
});
});
listByDeptId(this.topDept.id).then((response) => {
this.groupOptions = [];
this.groupOptions.push(...response.data);
});
},
//大整数精度丢失
handleTree1(data, fid) {
const id = fid || 'id';
const parentId = 'parentId';
const children = 'children';
const rootId =
data
.map((item) => item[parentId].toString())
.reduce((min, current) => {
if (current.length < min.length) return current;
if (current.length > min.length) return min;
return current < min ? current : min;
}) || 0;
//对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data));
//循环所有项
const treeData = cloneData.filter((father) => {
let branchArr = cloneData.filter((child) => {
//返回每一项的子级数组
return father[id] == child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : '';
//返回第一层
return father[parentId] == rootId;
});
return treeData !== '' ? treeData : data;
},
// 筛选节点
filterNode(value, data) {
if (!value) return true;
@@ -358,8 +397,14 @@ export default {
leaderName: this.groupOptions[0].leaderName || '-',
leaderPhone: this.groupOptions[0].leaderPhone || '-',
};
this.$nextTick(() => {
this.$refs.tree1.setCurrentKey(this.teamId);
});
} else if (this.activeName == 'first') {
this.deptId = this.topDept.id;
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.deptId);
});
}
this.getHolidayPage();
},
@@ -441,11 +486,11 @@ export default {
return '';
}
},
holidayLog(det, date) {
holidayLog(det, date, detSort) {
this.dialogTitle = this.showDeptName + '-' + date + '-排班详情';
this.logVisible = true;
this.$nextTick(() => {
this.$refs.holidayLogRef.init(det);
this.$refs.holidayLogRef.init(det, detSort);
});
},
cancelLog() {
@@ -459,8 +504,8 @@ export default {
.head-container {
padding: 20px 10px 0;
background-color: #fff;
min-height: calc(100vh - 120px - 8px);
border-radius: 8px;
height: 100%;
}
.groupTeamScheduling {
.operationArea {

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-11 14:27:37
* @LastEditors: zwq
* @LastEditTime: 2025-10-29 17:12:04
* @LastEditTime: 2025-11-14 22:00:10
* @Description:
-->
<template>
@@ -25,7 +25,7 @@
</template>
<script>
import { listByDeptId } from '@/api/group/Schedule';
import { getGroupPage } from '@/api/group/groupSetting';
const tableProps = [
{
@@ -39,7 +39,7 @@ const tableProps = [
width: 100,
},
{
prop: 'deptId',
prop: 'deptName',
label: '所属部门',
},
{
@@ -57,7 +57,7 @@ export default {
data() {
return {
urlOptions: {
getDataListURL: listByDeptId,
getDataListURL: getGroupPage,
},
tableProps,
tableData: [],
@@ -86,16 +86,16 @@ export default {
pageSize: 100,
code: '',
name: '',
deptId: undefined,
},
selectedList: [],
selectedArr: [], //已选的班组,从父组件传过来的
deptId: undefined,
};
},
created() {},
methods: {
init(id, tableData) {
this.deptId = id;
this.formInline.deptId = id;
this.selectedArr = tableData || [];
this.$nextTick(() => {
this.getDataList();
@@ -103,8 +103,9 @@ export default {
},
// 获取数据列表
getDataList() {
this.urlOptions.getDataListURL(this.deptId).then((response) => {
this.tableData = response.data;
this.urlOptions.getDataListURL(this.formInline).then((response) => {
this.tableData = response.data.list.filter(item=>item.enabled===1);
this.tableData.forEach(item=>item.teamId= item.id)
this.$nextTick(() => {
if (this.selectedArr.length > 0) {
this.setSelectedRows();
@@ -119,12 +120,12 @@ export default {
table.clearSelection();
this.selectedArr.forEach((item) => {
const rowInTable = this.tableData.find((i) => i.id === item.id);
const rowInTable = this.tableData.find((i) => i.teamId === item.teamId);
if (rowInTable) {
//这里一定要用table.tableData这样才是指向同一个数组
this.$set(table.store.states, 'selection', [
...table.store.states.selection,
table.tableData.find((i) => i.id === item.id),
table.tableData.find((i) => i.teamId === item.teamId),
]);
}
});
@@ -149,22 +150,19 @@ export default {
selectChange(val) {
this.selectedList = val;
},
// 判断两个数组是否有重复的 id
// 判断两个数组是否有重复的 id,去重
hasDuplicateIds(arr1, arr2) {
const idSet = new Set(arr1.map((item) => item.id));
return arr2.some((item) => idSet.has(item.id));
return arr2.filter(
(item2) => !arr1.some((item1) => item1.teamId === item2.teamId)
);
},
dataFormSubmit() {
if (this.selectedList && this.selectedList.length > 0) {
const haveData = this.hasDuplicateIds(
this.selectedList = this.hasDuplicateIds(
this.selectedArr,
this.selectedList
);
if (haveData) {
this.$message('请不要重复添加数组');
return;
}
this.$emit('refreshTableData', this.selectedList);
} else if (this.selectedArr.length > 0) {
this.$message('请不要重复添加数组');

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-13 15:07:24
* @LastEditors: zwq
* @LastEditTime: 2025-10-29 15:28:52
* @LastEditTime: 2025-12-03 15:48:26
* @Description:
-->
<template>
@@ -54,10 +54,11 @@
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="部门">
<el-form-item label="部门" prop="deptId">
<dept-select
style="width: 100%"
ref="deptSelect"
v-model="dataForm.deptId"
@DeptId="setDeptId"></dept-select>
</el-form-item>
</el-col>
@@ -111,7 +112,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="6" v-if="dataForm.shiftType>1">
<el-col :span="6" v-if="dataForm.shiftType > 1">
<el-form-item label="同班次连排" prop="shiftSustainedNum">
<el-input
v-model="dataForm.shiftSustainedNum"
@@ -134,6 +135,18 @@
<div v-if="stepNum == 2">
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
班次
<el-tag type="warning" style="color: black" v-if="!isClassTimePass">
<i class="el-icon-warning" style="color: #ffbd02"></i>
两班倒和三班倒的班次设置时间
<span style="color: red">不能重叠</span>
在24小时
</el-tag>
<el-tag type="warning" style="color: black" v-if="!covers24Hours">
<i class="el-icon-warning" style="color: #ffbd02"></i>
两班倒和三班倒的班次设置时间,班次时间
<span style="color: red">必须连续</span>
在24小时
</el-tag>
</small-title>
<base-table
:table-props="tableProps1"
@@ -150,6 +163,12 @@
</base-table>
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
班组
<el-tag type="warning" style="color: black">
<i class="el-icon-warning" style="color: #ffbd02"></i>
排班从计划开始时间对应的第一个班次开始
<span style="color: red">班组列表顺序</span>
依次循环执行
</el-tag>
</small-title>
<base-table
:table-props="tableProps2"
@@ -157,6 +176,7 @@
:limit="10"
:table-data="tableData2"
:add-button-show="'新增'"
@emitFun="handleSort"
@emitButtonClick="addNewGroup">
<method-btn
v-if="tableBtn2.length"
@@ -174,8 +194,7 @@
:no-padding="true">
排班计划预览
<span style="font-size: 14px; color: #ff1c15">
系统将根据以下设置按班组轮班顺序依次循环每日班次生成正式排班计划请确认
系统将根据
<el-popover
placement="right"
title="比如三班两倒同班次连排2天不休周末排班如下"
@@ -192,9 +211,10 @@
</el-table>
<i
slot="reference"
class="el-icon-warning-outline"
style="color: #ff1c15"></i>
class="el-icon-chat-dot-square"
style="color: #409eff; font-size: 18px"></i>
</el-popover>
设置按班组轮班顺序依次循环每日班次生成正式排班计划请确认
</span>
</small-title>
<el-tag>
@@ -227,7 +247,7 @@
<div style="color: rgba(0, 0, 0, 0.6)">同班次连排</div>
<div style="color: #000000">
{{
dataForm.shiftSustainedNum +
(dataForm.shiftSustainedNum ? dataForm.shiftSustainedNum : '') +
['日', '周', '月', '季'][dataForm.shiftSustainedType - 1]
}}
</div>
@@ -335,6 +355,7 @@ import { parseTime } from '@/filter/code-filter';
import editClass from './edit-class.vue';
import addGroup from './add-group.vue';
import bindLine from './bind-line.vue';
import sortSet from './sortSet.vue';
import {
getCode,
createStepOne,
@@ -374,10 +395,17 @@ const tableProps1 = [
];
const tableProps2 = [
{
prop: 'shunxu',
label: '顺序',
width: 70,
subcomponent: sortSet,
},
{
prop: 'code',
label: '班组编号',
width: 140,
showOverflowtooltip: true,
},
{
prop: 'name',
@@ -422,6 +450,7 @@ export default {
},
],
stepNum: 1, // 当前第几步
isEdit: false, //是否是编辑状态,编辑的时候,让前端上一步和取消都不用接口
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType到第二步判断dataForm.shiftType是否改变同时改变班次信息
//第一步参数
dataForm: {
@@ -476,6 +505,7 @@ export default {
name: [
{ required: true, message: '计划名称不能为空', trigger: 'blur' },
],
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
startDay: [
{ required: true, message: '开始时间不能为空', trigger: 'change' },
],
@@ -508,6 +538,8 @@ export default {
btnName: '编辑',
},
].filter((v) => v),
isClassTimePass: true, //修改班次时间后需要判断时间是否有重叠且是否在24小时内 true是没问题的
covers24Hours: true, //修改班次时间后需要判断时间是否覆盖24小时连续的时间 true是没问题的
tableData1: [],
tableProps2,
tableBtn2: [
@@ -597,8 +629,9 @@ export default {
};
},
methods: {
init(id) {
init(id, isEdit) {
this.dataForm.id = id || undefined;
this.isEdit = isEdit || false;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
@@ -609,14 +642,18 @@ export default {
this.tableData1 = res.data?.stepTwo.groupPlanClassesBaseVOList;
this.tableData2 = res.data?.stepTwo.groupPlanTeamBaseVOList;
this.tableData2.forEach((item, index) => {
let lineName = '';
lineName = this.setLineName(item.bindLineTree, lineName);
this.$set(
this.tableData2[index],
'lineName',
lineName.slice(0, -1)
);
let lineName = [];
if (item.isProduction) {
lineName = this.setLineName(item.bindLineTree);
this.$set(
this.tableData2[index],
'lineName',
lineName.join(';')
);
}
});
this.stepNum = 3;
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
});
} else {
getCode().then((res) => {
@@ -628,18 +665,33 @@ export default {
//上一步
upSubmit() {
if (this.stepNum == 2) {
returnStepOne(this.dataForm.id).then((res) => {
if (!this.isEdit) {
//编辑的时候,让前端上一步和取消都不用接口,
returnStepOne(this.dataForm.id).then((res) => {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
this.$nextTick(() => {
this.setDataForm();
});
});
} else {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
this.$nextTick(() => {
this.setDataForm();
});
});
}
} else if (this.stepNum == 3) {
returnStepTwo(this.dataForm.id).then((res) => {
if (!this.dataForm.id) {
//编辑的时候,让前端上一步和取消都不用接口,
returnStepTwo(this.dataForm.id).then((res) => {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
});
} else {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
});
}
}
},
//下一步
@@ -654,9 +706,12 @@ export default {
this.$message('部门不能为空');
return;
}
const compareDate = this.compareDates(this.dataForm.startDay,this.dataForm.endDay)
const compareDate = this.compareDates(
this.dataForm.startDay,
this.dataForm.endDay
);
if (compareDate > 0 ) {
if (compareDate > 0) {
this.$message('开始时间不能大于结束时间');
return;
}
@@ -677,6 +732,7 @@ export default {
return;
}
if (this.stepNum == 2) {
//班组验证
if (!this.tableData2 || this.tableData2.length == 0) {
this.$message('班组不能为空');
return;
@@ -684,7 +740,10 @@ export default {
let isbindLine = false;
this.tableData2.forEach((item) => {
if (!item.bindLineTree || item.bindLineTree.length == 0) {
if (
item.isProduction &&
(!item.bindLineTree || item.bindLineTree.length == 0)
) {
isbindLine = true;
}
});
@@ -711,6 +770,11 @@ export default {
return;
}
//班次验证
if (!this.isClassTimePass || !this.covers24Hours) {
this.$message('班次内时间有误,请重新填写!');
return;
}
let data = {};
data.planId = this.dataForm.id;
data.groupPlanClassesBaseVOList = []; //排班-班次信息list
@@ -722,24 +786,30 @@ export default {
startTime: item.startTime,
endTime: item.endTime,
daySpan: item.daySpan,
code: item.code,
};
data.groupPlanClassesBaseVOList.push(obj);
});
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
this.tableData2.forEach((item) => {
this.tableData2.forEach((item, index) => {
const obj = {
teamId: item.id,
sort: index + 1,
teamId: item.teamId || item.id,
name: item.name,
leaderName: item.leaderName,
leaderPhone:item.leaderPhone,
leaderName: item.leaderName,
leaderPhone: item.leaderPhone,
bindData: JSON.stringify(item.bindLineTree),
};
data.groupPlanTeamBaseVOList.push(obj);
});
createStepTwo(data).then((res) => {
this.stepNum += 1;
this.$emit('setSN', this.stepNum);
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
if (res.code === 200 || res.code === 0) {
this.stepNum += 1;
this.$emit('setSN', this.stepNum);
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
} else {
this.$message(res.msg);
}
});
return;
}
@@ -748,7 +818,7 @@ export default {
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
this.tableData2.forEach((item) => {
const obj = {
teamId: item.id,
teamId: item.teamId || item.id,
name: item.name,
bindData: JSON.stringify(item.bindLineTree),
};
@@ -756,10 +826,14 @@ export default {
});
checkPlan(data).then((RES) => {
createStepFour(this.dataForm.id).then((res) => {
this.$modal.msgSuccess('创建计划成功');
this.stepNum = 1;
this.$emit('setSN', this.stepNum);
this.$emit('refreshDataList');
if (res.code === 200 || res.code === 0) {
this.$modal.msgSuccess('创建计划成功');
this.stepNum = 1;
this.$emit('setSN', this.stepNum);
this.$emit('refreshDataList');
} else {
this.$message(res.msg);
}
});
});
return;
@@ -774,7 +848,7 @@ export default {
setDataForm() {
this.$refs.deptSelect.setID(this.dataForm.deptId);
},
//比较时间,开始时间在结束时间前
//比较时间,开始时间在结束时间前
compareDates(date1, date2) {
const d1 = date1;
const d2 = date2;
@@ -793,54 +867,156 @@ export default {
this.tableData1 = [];
if (this.dataForm.shiftType == 1) {
const obj = {
sort: 1,
name: '长白班',
startTime: '08:00:00',
endTime: '17:00:00',
daySpan: 0, //是否跨天
code: 1, //排版日历页面,根据这个字段显示颜色
code: 1, //排版日历页面,根据这个字段显示颜色
};
this.tableData1.push(obj);
} else if (this.dataForm.shiftType == 2) {
const obj1 = {
sort: 1,
name: '白班',
startTime: '08:00:00',
endTime: '20:00:00',
daySpan: 0,
code: 1,
code: 1,
};
const obj2 = {
sort: 2,
name: '夜班',
startTime: '20:00:00',
endTime: '08:00:00',
daySpan: 1,
code: 3,
code: 3,
};
this.tableData1.push(obj1, obj2);
} else if (this.dataForm.shiftType == 3) {
const obj1 = {
sort: 1,
name: '早班',
startTime: '08:00:00',
endTime: '16:00:00',
daySpan: 0,
code: 1,
code: 1,
};
const obj2 = {
sort: 2,
name: '中班',
startTime: '16:00:00',
endTime: '00:00:00',
daySpan: 1,
code: 2,
code: 2,
};
const obj3 = {
sort: 3,
name: '夜班',
startTime: '00:00:00',
endTime: '08:00:00',
daySpan: 0,
code: 3,
code: 3,
};
this.tableData1.push(obj1, obj2, obj3);
}
},
/**
* 将时间字符串转换为分钟数
* @param {string} timeStr - 时间字符串,如 "08:00:00"
* @returns {number} 分钟数
*/
timeToMinutes(timeStr) {
const [hours, minutes, s] = timeStr.split(':').map(Number);
return hours * 60 + minutes;
},
/**
* 修改班次时间后需要判断时间是否有覆盖且是否覆盖24小时
* @param {string} start1 - 开始时间1
* @param {string} end1 - 结束时间1
* @param {string} start2 - 开始时间2
* @param {string} end2 - 结束时间2
* @returns {boolean} 是否重叠 true则重叠false则可以使用
*/
isTimeOverlap(start1, end1, start2, end2) {
const start1Min = this.timeToMinutes(start1);
const end1Min = this.timeToMinutes(end1);
const start2Min = this.timeToMinutes(start2);
const end2Min = this.timeToMinutes(end2);
// 处理跨天情况
const totalMinutes = 24 * 60;
// 如果结束时间小于开始时间,说明跨天
const isEnd1NextDay = end1Min < start1Min;
const isEnd2NextDay = end2Min < start2Min;
if (isEnd1NextDay && isEnd2NextDay) {
// 两个时间段都跨天,直接比较
return true;
} else if (isEnd1NextDay) {
// 第一个时间段跨天
return start2Min < end1Min || end2Min > start1Min;
} else if (isEnd2NextDay) {
// 第二个时间段跨天
return start1Min < end2Min || end1Min > start2Min;
} else {
// 都不跨天,正常比较
return start1Min < end2Min && end1Min > start2Min;
}
},
/**
* 检查多个班次是否连续覆盖24小时
* @param {Array} shifts - 班次数组每个班次包含startTime和endTime
* @returns {boolean} 是否连续覆盖24小时
*/
isCover24Hours(shifts) {
if (!shifts || shifts.length === 0) return false;
const totalMinutes = 24 * 60;
// 将班次转换为时间段对象
const intervals = shifts.map((shift) => ({
start: this.timeToMinutes(shift.startTime),
end: this.timeToMinutes(shift.endTime),
}));
// 处理跨天情况如果结束时间小于开始时间加上24小时
const normalizedIntervals = intervals.map((interval) => {
let { start, end } = interval;
if (end < start) {
end += totalMinutes;
}
return { start, end, originalEnd: interval.end };
});
// 按开始时间排序
normalizedIntervals.sort((a, b) => a.start - b.start);
// 检查是否连续覆盖
let coveredUntil = normalizedIntervals[0].end;
let hasGap = false;
for (let i = 1; i < normalizedIntervals.length; i++) {
const current = normalizedIntervals[i];
// 如果当前班次的开始时间大于已覆盖的结束时间,说明有间隔
if (current.start > coveredUntil) {
hasGap = true;
break;
}
// 更新已覆盖的结束时间
coveredUntil = Math.max(coveredUntil, current.end);
}
// 检查是否覆盖完整的24小时
const firstStart = normalizedIntervals[0].start;
// 判断条件没有间隔且覆盖时间达到24小时
return !hasGap && coveredUntil - firstStart >= totalMinutes;
},
//编辑班次
handleClick1(val) {
this.addOrUpdateVisible1 = true;
@@ -859,11 +1035,37 @@ export default {
this.tableData2.splice(val.data._pageIndex - 1, 1);
}
},
//班组改变顺序
handleSort(val) {
if (val.type == 'up') {
const temp = this.tableData2[val.index];
this.tableData2.splice(val.index, 1);
let i = 0;
//如果是数组第一个,再向上则放到最后
if (val.index == 0) {
i = this.tableData2.length;
} else {
i = val.index - 1;
}
this.tableData2.splice(i, 0, temp);
} else {
const temp = this.tableData2[val.index];
this.tableData2.splice(val.index, 1);
let i = 0;
//如果是数组最后一个,再向下则放到第一个(因为先splice(val.index, 1)所以这里length不用-1)
if (val.index == this.tableData2.length) {
i = 0;
} else {
i = val.index + 1;
}
this.tableData2.splice(i, 0, temp);
}
},
// 新增班组
addNewGroup() {
this.addOrUpdateVisible2 = true;
this.$nextTick(() => {
this.$refs.addGroupRef.init(this.dataForm.deptId,this.tableData2);
this.$refs.addGroupRef.init(this.dataForm.deptId, this.tableData2);
});
},
cancel1() {
@@ -886,6 +1088,58 @@ export default {
},
refreshTableData1(index, val) {
this.tableData1.splice(index, 1, val);
this.tableData1.sort((a, b) => {
if (a.sort === b.sort) {
return -1; // sort相等时a排在b前面
}
return a.sort - b.sort;
});
this.tableData1.forEach((item, index) => {
item.sort = index + 1;
});
//修改班次时间后需要判断时间是否有重叠且是否在24小时内,isTimeOverlap方法返回false才是校验通过
if (this.dataForm.shiftType == 2) {
const twoClass = this.tableData1.map(({ startTime, endTime }) => ({
startTime,
endTime,
}));
this.isClassTimePass = !this.isTimeOverlap(
twoClass[0].startTime,
twoClass[0].endTime,
twoClass[1].startTime,
twoClass[1].endTime
);
} else if (this.dataForm.shiftType == 3) {
const threeClass = this.tableData1.map(({ startTime, endTime }) => ({
startTime,
endTime,
}));
const result1 = this.isTimeOverlap(
threeClass[0].startTime,
threeClass[0].endTime,
threeClass[1].startTime,
threeClass[1].endTime
);
const result2 = this.isTimeOverlap(
threeClass[1].startTime,
threeClass[1].endTime,
threeClass[2].startTime,
threeClass[2].endTime
);
const result3 = this.isTimeOverlap(
threeClass[0].startTime,
threeClass[0].endTime,
threeClass[2].startTime,
threeClass[2].endTime
);
this.isClassTimePass = !(result1 || result2 || result3);
}
//修改班次时间后两班倒和三班倒需要判断时间是否连续覆盖24小时内
if (this.dataForm.shiftType > 1) {
this.covers24Hours = this.isCover24Hours(this.tableData1);
console.log(1111, this.covers24Hours);
}
this.cancel1();
},
refreshTableData2(val) {
@@ -894,23 +1148,45 @@ export default {
},
refreshTableData3(index, val) {
this.tableData2[index].bindLineTree = val;
let lineName = '';
lineName = this.setLineName(val, lineName);
let lineName = this.setLineName(val);
if (lineName) {
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
this.$set(this.tableData2[index], 'lineName', lineName.join(';'));
}
this.cancel3();
},
//提取绑定的产线工段名展示出来
setLineName(val, lineName) {
val.forEach((item) => {
lineName += item.name + '';
if (item.children && item.children.length > 0) {
const childName = this.setLineName(item.children, lineName);
lineName = childName;
setLineName(data) {
const paths = [];
const processNode = (node, currentPath = []) => {
const newPath = [...currentPath, node.name];
if (node.children && node.children.length > 0) {
// 检查子节点是否都是叶子节点
const allChildrenAreLeaves = node.children.every(
(child) => !child.children || child.children.length === 0
);
if (allChildrenAreLeaves && node.children.length > 1) {
// 如果所有子节点都是叶子节点且多于1个用括号合并显示
const leafNames = node.children
.map((child) => child.name)
.join(' 、 ');
paths.push(`${newPath.join('/')}/(${leafNames})`);
} else if (allChildrenAreLeaves && node.children.length === 1) {
// 只有一个叶子子节点,用括号显示
paths.push(`${newPath.join('/')}/${node.children[0].name}`);
} else {
// 继续处理子节点
node.children.forEach((child) => processNode(child, newPath));
}
} else {
// 没有子节点的节点如原片产线1用括号显示
paths.push(`${currentPath.join('/')}/${node.name}`);
}
});
return lineName;
};
data.forEach((node) => processNode(node));
return paths;
},
//第三步
// 进来加载预览排班
@@ -919,6 +1195,7 @@ export default {
id: this.dataForm.id,
count: day,
};
this.period = day;
this.tableProps3 = [];
this.tableData3 = [];
getPerView(data).then((res) => {
@@ -946,6 +1223,7 @@ export default {
label: item.day,
work: item.work,
subcomponent: propSpan,
showOverflowtooltip: true,
};
this.tableProps3.push(obj);
item.det.forEach((sItem, sIndex) => {
@@ -970,7 +1248,8 @@ export default {
});
},
cancelStep() {
if (this.stepNum > 1) {
if (this.stepNum > 1 && !this.isEdit) {
//编辑的时候,让前端上一步和取消都不用接口,
cancelStepThree(this.dataForm.id).then((res) => {
this.$message('已取消计划');
this.$emit('refreshDataList');

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2025-10-30 10:47:09
* @LastEditTime: 2025-11-25 15:49:17
* @Description:
-->
<template>
@@ -13,8 +13,12 @@
:to_data="toData"
@add-btn="add"
@remove-btn="remove"
pid="pid"
:defaultProps="{ label: 'name' }"
pid="fid"
:node_key="'uniqueId'"
:defaultProps="{
label: 'name',
children: 'children',
}"
height="450px"
style="padding-bottom: 20px"
:mode="mode"
@@ -43,16 +47,34 @@ export default {
this.fromData = [];
this.toData = [];
getGroupPlanTree().then((res) => {
this.fromData = res.data;
this.fromData.forEach((item) => {
res.data.forEach((item) => {
item.productionLineId = 0;
});
this.fromData = this.generateUniqueData(res.data);
this.$nextTick(() => {
this.toData = val.bindLineTree || [];
this.getFilterLeftData(this.fromData, this.toData); //编辑时组件有bug左边相同数据不消失
});
});
},
generateUniqueData(data) {
return data.map((node) => this.processNode(node));
},
processNode(node) {
// 创建唯一ID类型-原始ID
const uniqueId = node.type+'L'+node.id;
if (node.type > 0) {
node.fid = (node.type - 1)+'L'+node.pid;
}
return {
...node,
uniqueId,
children: node.children
? node.children.map((child) => this.processNode(child))
: [],
};
},
// 监听穿梭框组件添加
add(fromData, toData, obj) {
console.log('fromData:', fromData);

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-21 14:27:23
* @LastEditors: zwq
* @LastEditTime: 2025-10-21 15:02:27
* @LastEditTime: 2025-11-25 15:14:53
* @Description:
-->
<template>
@@ -46,7 +46,7 @@
</div>
<div>
<span class="title">创建人:</span>
{{ infoData.creator }}
{{ infoData.creatorName }}
</div>
<div>
<span class="title">创建时间:</span>
@@ -73,7 +73,7 @@
:limit="10"
:table-data="tableData1"></base-table>
<base-table
v-else
v-else
:table-props="tableProps2"
:page="1"
:limit="10"
@@ -150,26 +150,45 @@ export default {
this.infoData = {};
getPlan(id).then((res) => {
this.infoData = res.data || {};
console.log(res);
this.tableData1 = res.data?.groupPlanClassesBaseVOList;
this.tableData1 = res.data?.groupPlanClassesBaseVOList.sort(
(a, b) => a.sort - b.sort
);
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
this.tableData2.forEach((item, index) => {
let lineName = '';
lineName = this.setLineName(item.bindLineTree, lineName);
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
if (item.isProduction) {
lineName = this.setLineName(item.bindLineTree);
}
this.$set(this.tableData2[index], 'lineName', lineName);
});
});
},
//提取绑定的产线工段名展示出来
setLineName(val, lineName) {
val.forEach((item) => {
lineName += item.name + '';
if (item.children && item.children.length > 0) {
const childName = this.setLineName(item.children, lineName);
lineName = childName;
setLineName(val) {
if (!val || val.length === 0) return '';
const currentLevelNames = val.map((item) => item.name);
// 处理当前层级显示
let currentDisplay = '';
if (currentLevelNames.length > 1) {
currentDisplay = `(${currentLevelNames.join(' 、 ')})`;
} else {
currentDisplay = currentLevelNames[0];
}
// 查找所有子节点(取第一个有子节点的元素)
const childNode = val.find(
(item) => item.children && item.children.length > 0
);
if (childNode) {
const childPath = this.setLineName(childNode.children);
if (childPath) {
return `${currentDisplay} / ${childPath}`;
}
});
return lineName;
}
return currentDisplay;
},
},
};

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2025-10-20 10:23:52
* @LastEditTime: 2025-11-04 14:08:47
* @Description:
-->
<template>
@@ -15,9 +15,10 @@
label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="序" prop="index">
<el-form-item label="序" prop="sort">
<el-input-number
v-model="dataForm.index"
style="width: 100%"
v-model="dataForm.sort"
:step="1"
:min="1"
step-strictly />
@@ -38,7 +39,8 @@
format="H:mm"
value-format="HH:mm:ss"
v-model="dataForm.startTime"
placeholder="选择日期时间"></el-time-picker>
@change="timeFun('start')"
placeholder="选择时间"></el-time-picker>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -48,7 +50,19 @@
format="H:mm"
value-format="HH:mm:ss"
v-model="dataForm.endTime"
placeholder="选择日期时间"></el-time-picker>
@change="timeFun('end')"
placeholder="选择时间"></el-time-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否跨天" prop="daySpan">
<el-switch
v-model="dataForm.daySpan"
disabled
:active-value="1"
:inactive-value="0"
active-text="隔天"
inactive-text="当天"></el-switch>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -70,15 +84,17 @@ export default {
return {
dataForm: {
id: undefined,
index: undefined,
sort: undefined,
name: undefined,
startTime: undefined,
endTime: undefined,
daySpan: 0,
code: 1,
remark: undefined,
},
_pageIndex: 1,
dataRule: {
index: [{ required: true, message: '序不能为空', trigger: 'blur' }],
sort: [{ required: true, message: '序不能为空', trigger: 'blur' }],
name: [
{ required: true, message: '班次名称不能为空', trigger: 'blur' },
],
@@ -93,13 +109,31 @@ export default {
},
methods: {
init(val) {
this._pageIndex = val._pageIndex-1;
this.dataForm.index = val._pageIndex || 1;
this._pageIndex = val._pageIndex - 1;
this.dataForm.sort = val._pageIndex || 1;
this.dataForm.name = val.name || undefined;
this.dataForm.startTime = val.startTime || undefined;
this.dataForm.endTime = val.endTime || undefined;
this.dataForm.remark = val.remark || undefined;
this.dataForm.daySpan = val.daySpan || 0;
this.dataForm.code = val.code || 1;
},
timeFun(val) {
if (this.dataForm.startTime && this.dataForm.endTime) {
if (this.dataForm.startTime > this.dataForm.endTime) {
this.dataForm.daySpan = 1
} else if (this.dataForm.startTime < this.dataForm.endTime) {
this.dataForm.daySpan = 0
} else {
if (val === 'start') {
this.dataForm.startTime = ''
} else {
this.dataForm.endTime = ''
}
this.$modal.msgWarning('班次开始时间和结束时间不能相同')
}
}
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {

View File

@@ -1,8 +1,8 @@
<!--
* @Author: zwq
* @Date: 2025-10-11 14:27:37
* @Date: 2025-10-13 15:07:24
* @LastEditors: zwq
* @LastEditTime: 2025-10-29 14:50:16
* @LastEditTime: 2025-11-28 09:56:09
* @Description:
-->
<template>
@@ -31,13 +31,17 @@
<el-form-item label="开始时间" prop="startDay">
<el-date-picker
v-model="formInline.startDay"
size="small"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间"></el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endDay">
<el-date-picker
v-model="formInline.endDay"
size="small"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间"></el-date-picker>
</el-form-item>
<el-form-item label="部门" prop="deptId">
@@ -46,8 +50,12 @@
ref="deptSelect"
@DeptId="setDeptId"></dept-select>
</el-form-item>
<el-form-item label="状态" prop="leaderName">
<el-select v-model="formInline.status" placeholder="请选择状态">
<el-form-item label="状态" prop="status">
<el-select
v-model="formInline.status"
size="small"
clearable
placeholder="请选择状态">
<el-option
v-for="item in options"
:key="item.value"
@@ -65,7 +73,8 @@
</el-button>
</el-form-item>
<el-form-item>
<span class="separateStyle"
<span
class="separateStyle"
v-hasPermi="['base:group-scheduling-plan:query']"></span>
</el-form-item>
<el-form-item>
@@ -74,7 +83,8 @@
</el-button>
</el-form-item>
<el-form-item>
<span class="separateStyle"
<span
class="separateStyle"
v-hasPermi="['base:group-scheduling-plan:create']"></span>
</el-form-item>
<el-form-item>
@@ -87,6 +97,17 @@
新增
</el-button>
</el-form-item>
<el-form-item>
<el-button
type="warning"
plain
size="small"
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['base:group-scheduling-plan:export']">
导出
</el-button>
</el-form-item>
</el-form>
</div>
<base-table
@@ -201,6 +222,7 @@ import {
copyPlan,
disablePlan,
updateScheduleLater,
exportExcel,
} from '@/api/group/Schedule';
const tableProps = [
@@ -268,91 +290,97 @@ export default {
},
tableProps,
tableBtn: [
this.$auth.hasPermi('base:group-scheduling-plan:update')?
{
type: 'edit',
btnName: '编辑',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 1,
this.$auth.hasPermi('base:group-scheduling-plan:update')
? {
type: 'edit',
btnName: '编辑',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 1,
},
],
},
],
},
}:undefined,
this.$auth.hasPermi('base:group-scheduling-plan:delete')?
{
type: 'delete',
btnName: '删除',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 1,
}
: undefined,
this.$auth.hasPermi('base:group-scheduling-plan:delete')
? {
type: 'delete',
btnName: '删除',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 1,
},
],
},
],
},
}:undefined,
this.$auth.hasPermi('base:group-scheduling-plan:query')?
{
type: 'detail',
btnName: '查看',
showParam: {
type: '&',
data: [
{
type: 'unequal',
name: 'status',
value: 1,
}
: undefined,
this.$auth.hasPermi('base:group-scheduling-plan:query')
? {
type: 'detail',
btnName: '查看',
showParam: {
type: '&',
data: [
{
type: 'unequal',
name: 'status',
value: 1,
},
],
},
],
},
}:undefined,
this.$auth.hasPermi('base:group-scheduling-plan:delete')?
{
type: 'cancel',
btnName: '作废',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 2,
}
: undefined,
this.$auth.hasPermi('base:group-scheduling-plan:delete')
? {
type: 'cancel',
btnName: '作废',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 2,
},
],
},
],
},
}:undefined,
this.$auth.hasPermi('base:group-holiday:update')?
{
type: 'sync',
btnName: '同步节假日',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 2,
}
: undefined,
this.$auth.hasPermi('base:group-holiday:update')
? {
type: 'sync',
btnName: '同步节假日',
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'status',
value: 2,
},
{
type: 'equal',
name: 'updateFlag',
value: true,
},
],
},
{
type: 'equal',
name: 'updateFlag',
value: true,
},
],
},
}:undefined,
this.$auth.hasPermi('base:group-scheduling-plan:create')?
{
type: 'copy',
btnName: '复制',
}:undefined,
}
: undefined,
this.$auth.hasPermi('base:group-scheduling-plan:create')
? {
type: 'copy',
btnName: '复制',
}
: undefined,
].filter((v) => v),
tableData: [],
options: [
@@ -370,50 +398,52 @@ export default {
},
],
formInline: {
code: '',
name: '',
startDay: '',
endDay: '',
deptId: '',
status: '',
code: null,
name: null,
startDay: null,
endDay: null,
deptId: null,
status: null,
},
stepNum: 1, // 新增编辑时当前第几步
detailVisible: false,
// 导出遮罩层
exportLoading: false,
};
},
components: {
AddOrUpdate,
deptSelect,
detail
detail,
},
created() {},
methods: {
buttonClick(val) {
switch (val.btnName) {
case 'search':
const date1 = new Date(this.formInline.startDay).getTime();
const date2 = new Date(this.formInline.endDay).getTime();
if (date1 > date2) {
if (this.formInline.startDay > this.formInline.endDay) {
this.$message('开始时间不得晚于结束时间');
return;
}
this.listQuery = {
pageNo: 1,
pageSize: 10,
pageSize: 20,
total: 1,
...this.formInline,
};
this.getDataList();
break;
case 'reset':
this.$refs.searchBarForm.resetFields();
this.formInline.name = null;
this.formInline.code = null;
this.formInline.deptId = null;
this.$refs.deptSelect.clear();
this.formInline.leaderName = null;
this.formInline.status = null;
this.formInline.startDay = null;
this.formInline.endDay = null;
this.listQuery = {
pageSize: 10,
pageSize: 20,
pageNo: 1,
total: 1,
};
@@ -462,7 +492,8 @@ export default {
this.addOrUpdateVisible = true;
this.addOrEditTitle = '编辑';
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id);
this.stepNum = 3;
this.$refs.addOrUpdate.init(val.data.id, true);
});
} else if (val.type === 'delete') {
this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex);
@@ -474,23 +505,62 @@ export default {
} else if (val.type === 'cancel') {
disablePlan(val.data.id).then((res) => {
this.$modal.msgSuccess('作废成功');
this.getDataList()
this.getDataList();
});
} else if (val.type === 'sync') {
updateScheduleLater({ planId: val.data.id }).then((res) => {
this.$modal.msgSuccess('同步节假日成功');
this.getDataList()
});
this.$confirm(
'当前节假日包含尚未同步节假日变更,是否立即将上述节假日同步更新到排班计划?',
'同步节假日',
{
confirmButtonText: '确认同步',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
updateScheduleLater({
planId: val.data.id,
logId: val.data.updateLogId,
}).then((res) => {
this.$modal.msgSuccess('同步节假日成功');
this.getDataList();
});
})
.catch((res) => {
this.getDataList();
this.$message({
type: 'info',
message: '已取消',
});
});
} else if (val.type === 'copy') {
copyPlan(val.data.id).then((res) => {
this.$modal.msgSuccess('复制成功');
this.getDataList()
this.getDataList();
});
}
},
detailCancel() {
this.detailVisible = false;
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = { ...this.formInline };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal
.confirm('是否确认导出所有数据项?')
.then(() => {
this.exportLoading = true;
return exportExcel(params);
})
.then((response) => {
this.$download.excel(response, '排班计划.xls');
this.exportLoading = false;
})
.catch(() => {});
},
},
};
</script>

View File

@@ -0,0 +1,44 @@
<!--
* @Author: zwq
* @Date: 2025-10-13 16:40:08
* @LastEditors: zwq
* @LastEditTime: 2025-11-04 16:08:57
* @Description:
-->
<template>
<div>
<el-button type="text" size="mini" @click="moveUp()" style="display:inline-block"></el-button>
<el-button type="text" size="mini" @click="moveDown()" style="display:inline-block;float:right"></el-button>
</div>
</template>
<script>
export default {
props: {
injectData: {
type: Object,
default: () => ({}),
},
},
data() {
return {};
},
created() {},
methods: {
moveUp() {
const val = {
type: 'up',
index: this.injectData._pageIndex - 1,
};
this.$emit('emitData', val);
},
moveDown() {
const val = {
type: 'down',
index: this.injectData._pageIndex - 1,
};
this.$emit('emitData', val);
},
},
};
</script>

View File

@@ -2,13 +2,13 @@
* @Author: zwq
* @Date: 2025-10-13 16:18:41
* @LastEditors: zwq
* @LastEditTime: 2025-10-20 10:13:26
* @LastEditTime: 2025-11-04 10:54:19
* @Description:
-->
<template>
<span>
{{
injectData.shiftSustainedNum +
(injectData.shiftSustainedNum?injectData.shiftSustainedNum:'') +
(injectData.shiftSustainedType
? ['', '日', '周', '月', '季'][injectData.shiftSustainedType]
: '')

View File

@@ -48,7 +48,6 @@ export default {
this.deptId = id;
},
clear() {
console.log(this.$refs.treeselect);
this.$refs.treeselect.clear();
},
// 格式化部门的下拉框

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2025-10-29 14:47:33
* @LastEditTime: 2025-11-27 14:49:34
* @Description:
-->
<template>
@@ -25,16 +25,18 @@
<el-col :span="8">
<el-form-item label="班组名称" prop="name">
<el-input
:disabled="nameDisable"
v-model="dataForm.name"
clearable
placeholder="请输入班组名称" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="部门">
<el-form-item label="部门" prop="deptId">
<dept-select
style="width: 100%"
ref="deptSelect"
v-model="dataForm.deptId"
@DeptId="setDeptId"></dept-select>
</el-form-item>
</el-col>
@@ -44,7 +46,7 @@
style="width: 100%"
v-model="dataForm.leaderId"
@change="setLeaderName"
filterable
filterable
placeholder="请选择组长">
<el-option
v-for="item in leaderArr"
@@ -59,7 +61,7 @@
<el-input
v-model="dataForm.leaderPhone"
clearable
maxlength="11"
maxlength="11"
placeholder="请输入组长电话" />
</el-form-item>
</el-col>
@@ -77,6 +79,7 @@
<el-form-item label="生产班组" prop="isProduction">
<el-select
style="width: 100%"
@change="setIsProduction"
v-model="dataForm.isProduction"
placeholder="请选择是否为生产班组">
<el-option
@@ -108,6 +111,7 @@ import {
updateGroup,
getGroup,
getCode,
updateIsProduction,
} from '@/api/group/groupSetting';
export default {
@@ -137,7 +141,8 @@ export default {
num: undefined,
remark: undefined,
},
setData: true,
setData: true,
nameDisable: false, //班组被使用时,班组名称不能修改
leaderArr: [],
options: [
{
@@ -156,19 +161,21 @@ export default {
name: [
{ required: true, message: '班组名称不能为空', trigger: 'blur' },
],
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
leaderId: [
{ required: true, message: '组长不能为空', trigger: 'change' },
],
isProduction: [
{ required: true, message: '生产班组不能为空', trigger: 'change' },
],
leaderPhone: [
{
pattern: /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
leaderPhone: [
{
pattern:
/^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
message: '请输入正确的手机号码',
trigger: 'blur',
},
],
},
};
},
@@ -184,9 +191,43 @@ export default {
})
.catch(() => {});
},
setDataForm(){
this.$refs.deptSelect.setID(this.dataForm.deptId)
},
setDataForm() {
this.$refs.deptSelect.setID(this.dataForm.deptId);
this.nameDisable = false;
updateIsProduction(this.dataForm.id).then(({ data }) => {
if (data) {
this.$notify({
title: '警告',
message: '当前班组仍参与排班计划或正在执行工单。班组名称不能修改',
type: 'warning',
});
this.nameDisable = true;
}
});
},
setIsProduction() {
// 修改的提交
if (this.dataForm.id && this.nameDisable) {
this.$confirm(
'当前班组仍参与排班计划或正在执行工单。<br/>修改<strong> 是否是生产班组 </strong>不会自动更新排班内容,可能导致排班信息与班组属性不一致,请注意核查!<br/>是否确认修改是否是生产班组?',
'修改是否是生产班组',
{
dangerouslyUseHTMLString: true,
confirmButtonText: '确认修改',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {})
.catch((res) => {
this.$message({
type: 'info',
message: '已取消',
});
this.dataForm.isProduction = !this.dataForm.isProduction;
});
}
},
setLeaderName(val) {
this.leaderArr.map((item) => {
if (val === item.id) {
@@ -194,33 +235,33 @@ export default {
}
});
},
// 表单提交
dataFormSubmit() {
this.$refs["dataForm"].validate((valid) => {
if (!valid) {
return false;
}
if(!this.dataForm.deptId){
this.$message('部门不能为空');
return
}
// 修改的提交
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.visible = false;
this.$emit("refreshDataList");
});
return;
}
// 添加的提交
this.urlOptions.createURL(this.dataForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false;
}
if (!this.dataForm.deptId) {
this.$message('部门不能为空');
return;
}
// 修改的提交
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then((response) => {
this.$modal.msgSuccess('修改成功');
this.visible = false;
this.$emit('refreshDataList');
});
return;
}
// 添加的提交
this.urlOptions.createURL(this.dataForm).then((response) => {
this.$modal.msgSuccess('新增成功');
this.visible = false;
this.$emit('refreshDataList');
});
});
},
},
};
</script>

View File

@@ -1,14 +1,21 @@
<!--
* @Author: zwq
* @Date: 2025-10-11 14:41:12
* @LastEditors: zwq
* @LastEditTime: 2025-11-27 14:19:39
* @Description:
-->
<template>
<el-switch
@change="changeStatus"
size="small"
v-model="list.enabled"
v-model="injectData.enabled"
:active-value="1"
:inactive-value="0"></el-switch>
</template>
<script>
import { updateGroup } from '@/api/group/groupSetting';
import { updateGroup, updateIsProduction } from '@/api/group/groupSetting';
export default {
props: {
injectData: {
@@ -17,17 +24,51 @@ export default {
},
},
data() {
return {
list: this.injectData,
};
return {};
},
created() {},
methods: {
changeStatus(val) {
const data = { ...this.injectData, enabled: val };
updateGroup(data).then((res) => {
this.$modal.msgSuccess('修改成功');
this.$emit('emitData');
const pdata = { ...this.injectData, enabled: val };
updateIsProduction(this.injectData.id).then(({ data }) => {
if (data) {
this.$confirm(
'当前班组仍参与排班计划或正在执行工单。<br/>修改<strong> 班组状态 </strong>不会自动更新排班内容,可能导致排班信息与班组属性不一致,请注意核查!<br/>是否确认修改班组状态?',
'更新班组状态',
{
dangerouslyUseHTMLString: true,
confirmButtonText: '确认修改',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
updateGroup(pdata).then((res) => {
if (res.code === 0 || res.code === 200) {
this.$modal.msgSuccess('修改成功');
this.$emit('emitData');
} else {
this.$modal.msg(res.msg);
}
});
})
.catch((res) => {
this.$emit('emitData');
this.$message({
type: 'info',
message: '已取消',
});
});
} else {
updateGroup(pdata).then((res) => {
if (res.code === 0 || res.code === 200) {
this.$modal.msgSuccess('修改成功');
this.$emit('emitData');
} else {
this.$modal.msg(res.msg);
}
});
}
});
},
},

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-11 14:27:37
* @LastEditors: zwq
* @LastEditTime: 2025-10-29 14:44:41
* @LastEditTime: 2025-11-14 21:50:40
* @Description:
-->
<template>
@@ -212,7 +212,7 @@ export default {
case 'search':
this.listQuery = {
pageNo: 1,
pageSize: 10,
pageSize: 20,
total: 1,
...this.formInline,
};
@@ -225,7 +225,7 @@ export default {
this.$refs.deptSelect.clear();
this.formInline.leaderName = null;
this.listQuery = {
pageSize: 10,
pageSize: 20,
pageNo: 1,
total: 1,
};

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2025-10-23 13:29:58
* @LastEditTime: 2025-12-11 10:47:50
* @Description:
-->
<template>
@@ -18,6 +18,7 @@
<el-col :span="12">
<el-form-item label="节假日名称" prop="name">
<el-input
ref="inputWidth"
v-model="dataForm.name"
clearable
:disabled="detail"
@@ -54,7 +55,7 @@
</el-col>
<el-col :span="12">
<el-form-item
v-if="dataForm.dateType == 1"
v-if="dataForm.dateType == 1 && dataForm.calendarType == 1"
label="日期"
prop="dateDay">
<el-date-picker
@@ -65,10 +66,14 @@
type="date"
placeholder="选择日期"
format="yyyy-MM-dd"
value-format="--MM-dd"
value-format="yyyy-MM-dd"
@blur="$forceUpdate()"
:picker-options="pickerOptions"></el-date-picker>
</el-form-item>
<el-form-item v-else label="日期" prop="dateDayArr">
<el-form-item
v-else-if="dataForm.dateType == 2 && dataForm.calendarType == 1"
label="日期"
prop="dateDayArr">
<el-date-picker
:disabled="detail"
style="width: 100%"
@@ -76,12 +81,57 @@
v-model="dataForm.dateDayArr"
type="daterange"
format="yyyy-MM-dd"
value-format="--MM-dd"
value-format="yyyy-MM-dd"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
@blur="$forceUpdate()"
:picker-options="pickerOptions"></el-date-picker>
</el-form-item>
<el-form-item
v-else-if="dataForm.dateType == 1 && dataForm.calendarType == 2"
label="日期"
prop="dateDayChinese">
<j-date-picker
ref="JDatePicker1"
style="line-height: 18px"
v-model="dataForm.dateDayChinese"
id="value1"
:width="width1"
:placeholder="placeholder"
:picker-options="pickerOptions"
:rangeSeparator="rangeSeparator"
@change="onDateChange"
:disabled="detail"
:showLunarClass="showLunarClass"
:showLunarControl="showLunarControl"
type="DATE"
:showBackYears="showBackYears"
:showLunarIcon="showLunarIcon"
:format="format"></j-date-picker>
</el-form-item>
<el-form-item
v-else-if="dataForm.dateType == 2 && dataForm.calendarType == 2"
label="日期"
prop="dateDayArrChinese">
<j-date-picker
style="line-height: 18px"
ref="JDatePicker2"
v-model="dataForm.dateDayArrChinese"
id="value2"
:width="width1"
:placeholder="placeholder"
:picker-options="pickerOptions"
:rangeSeparator="rangeSeparator"
@change="onDateChange"
:disabled="detail"
:showLunarClass="showLunarClass"
:showLunarControl="showLunarControl"
type="DATERANGE"
:showBackYears="showBackYears"
:showLunarIcon="showLunarIcon"
:format="format"></j-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否每年重复" prop="repeat">
@@ -131,6 +181,7 @@
</template>
<script>
import JDatePicker from './components/JDatePicker.vue';
import {
createHoliday,
updateHoliday,
@@ -141,7 +192,9 @@ import {
} from '@/api/group/holidaySetting';
export default {
components: {},
components: {
JDatePicker,
},
data() {
return {
dataForm: {
@@ -151,11 +204,16 @@ export default {
dateType: 1,
dateDay: undefined,
dateDayArr: [],
dateDayChinese: undefined,
dateDayArrChinese: [],
noRepeatYear: undefined,
noRepeatYearChinese: undefined,
repeat: true,
inherited: true, // 是否为继承
deptId: undefined,
},
detail: false,
inherited: true,
options1: [
{
value: 1,
@@ -202,6 +260,12 @@ export default {
dateDayArr: [
{ required: true, message: '日期不能为空', trigger: 'change' },
],
dateDayChinese: [
{ required: true, message: '日期不能为空', trigger: 'change' },
],
dateDayArrChinese: [
{ required: true, message: '日期不能为空', trigger: 'change' },
],
repeat: [
{
required: true,
@@ -216,49 +280,131 @@ export default {
},
},
dialogVisible: false,
//农历组件数据
showLunarClass: 'LUNAR', //农历日期的展示类型 MIX(混合)FULLLUNAR(全农历)LUNAR(农历)NUMBER(数字)
showBackYears: 2, //向后展示年数;见于年份列表;
showLunarIcon: true, //是否显示农历控制组件
showLunarControl: false, //是否显示农历控制组件
width1: '300', //这个设置成100%原组件写死了px需要修改
format: 'yyyy-MM-dd',
placeholder: '',
rangeSeparator: '-',
editable: true,
clearable: true,
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7;
},
},
};
},
watch: {
'dataForm.calendarType': function (newValue, oldValue) {
this.$nextTick(() => {
if (this.$refs.JDatePicker1) {
this.$refs.JDatePicker1.isLunar = true; //默认转为农历
this.$refs.JDatePicker1.onLunarChange();
}
if (this.$refs.JDatePicker2) {
this.$refs.JDatePicker2.isLunar = true;
this.$refs.JDatePicker2.onLunarChange();
}
});
},
'dataForm.dateType': function (newValue, oldValue) {
this.$nextTick(() => {
if (this.$refs.JDatePicker1) {
this.$refs.JDatePicker1.isLunar = true; //默认转为农历
this.$refs.JDatePicker1.onLunarChange();
}
if (this.$refs.JDatePicker2) {
this.$refs.JDatePicker2.isLunar = true;
this.$refs.JDatePicker2.onLunarChange();
}
});
},
},
mounted() {
this.$nextTick(() => {
this.width1 = this.$refs.inputWidth.$el.offsetWidth + '';
});
},
methods: {
init(deptId, id, detail) {
init(deptId, val, detail, inherited) {
this.dataForm.deptId = deptId || undefined;
this.dataForm.id = id || undefined;
this.dataForm.id = val.holidayId || undefined;
this.dataForm.inherited = val.isInherit || false;
this.detail = detail || false;
this.inherited = inherited; //编辑的时候该部门如果是自定义的但这个val数据是继承的修改之后则变成自定义的inherited
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
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;
if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 1
) {
this.dataForm.dateDay = this.dataForm.oneDay;
this.dataForm.dateDay =
year + '-' + this.dataForm.oneDay.slice(-5);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1
) {
let num = this.compareMonthDay(
this.dataForm.startDay.slice(-5),
this.dataForm.endDay.slice(-5)
);
this.dataForm.dateDayArr = [
this.dataForm.startDay,
this.dataForm.endDay,
year + '-' + this.dataForm.startDay.slice(-5),
(num > 0 ? year : year + 1) +
'-' +
this.dataForm.endDay.slice(-5),
];
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2
) {
this.dataForm.dateDay = this.dataForm.oneDayChinese;
this.dataForm.dateDayChinese =
'L' + year + this.dataForm.oneDayChinese.slice(-6);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2
) {
this.dataForm.dateDayArr = [
this.dataForm.startDayChinese,
this.dataForm.endDayChinese,
let num = this.compareMonthDay(
this.dataForm.startDayChinese.slice(-6),
this.dataForm.endDayChinese.slice(-6)
);
this.dataForm.dateDayArrChinese = [
'L' + year + this.dataForm.startDayChinese.slice(-6),
'L' +
(num > 0 ? year : year + 1) +
+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() {
this.detail = false;
},
@@ -307,10 +453,13 @@ export default {
this.$modal.msgSuccess('删除成功');
updateSchedule({ logId: res.data.logId }).then((res1) => {
this.$modal.msgSuccess('更新成功');
this.$emit('refreshPage');
});
this.$emit('refreshPage');
});
},
onDateChange(val) {
console.log(val);
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
@@ -318,61 +467,133 @@ export default {
return false;
}
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 (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1
) {
this.dataForm.startDay = this.dataForm.dateDayArr[0];
this.dataForm.endDay = this.dataForm.dateDayArr[1];
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
this.dataForm.startDay = `--${month}-${day}`;
const [year1, month1, day1] = this.dataForm.dateDayArr[1].split('-');
this.dataForm.endDay = `--${month1}-${day1}`;
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2
) {
this.dataForm.oneDayChinese = this.dataForm.dateDay;
this.dataForm.oneDayChinese =
'--' + this.dataForm.dateDayChinese.slice(-5);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2
) {
this.dataForm.startDayChinese = this.dataForm.dateDayArr[0];
this.dataForm.endDayChinese = this.dataForm.dateDayArr[1];
this.dataForm.startDayChinese =
'--' + this.dataForm.dateDayArrChinese[0].slice(-5);
this.dataForm.endDayChinese =
'--' + this.dataForm.dateDayArrChinese[1].slice(-5);
}
//是否每年重复,不重复的话需要传 年份
if (
this.dataForm.dateType == 1 &&
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) {
updateHoliday(this.dataForm).then((response) => {
this.$modal.msgSuccess('修改成功');
this.$emit('refreshPage');
if (!this.inherited) {
this.dataForm.inherited = false;
}
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) => {
updateSchedule;
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('新成功');
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');
});
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
});
}
} else {
this.$modal.msg(res.msg);
}
});
});

View File

@@ -0,0 +1,735 @@
<template>
<div class="full-jcalendar" :style="{width:handleWidth+'px'}">
<p class="input-icon__tip" v-show="isLunar && showLunarIcon">
<i v-if="isLeap"></i>
<i v-else></i>
</p>
<p class="input-icon" @mouseover="onInputOver" @mouseout="onInputOut">
<i class="iconfont el-icon-date" ></i>
<i class="iconfont icon-richeng" v-show="!clearVisible"></i>
<i class="iconfont icon-guanbi is-clear" v-show="clearable && clearVisible" @click="onClearInput"></i>
</p>
<input type="text" :value="inputText" :class="['input__inner',{'is-disabled':disabled}]" :placeholder="placeholder" @click="onInputFocus" :readonly="!editable || type.toUpperCase() ==='DATERANGE' || (isLunar && showLunarClass.toUpperCase()!='NUMBER')" :disabled="disabled" @input="inputText = $event.target.value" @change="handleInputChange" />
<!--日期控件弹窗主体-->
<div class="full-jcalendar__main" :class="{'is-daterange':type.toUpperCase() === 'DATERANGE'}" v-show="calendarVisible">
<!--单日期模式-->
<div v-show="type.toUpperCase() === 'DATE'">
<div class="full-jcalendar-header">
<span class="title-year" @click="showYearList">{{year}}</span>
<span style="width:10px;"></span>
<span class="title-month" @click="monthVisible = true">{{month}}</span>
<span style="width:10px;" v-if="showLunarControl"></span>
<label v-if="showLunarControl"><input type="checkbox" v-model="isLunar" @change="onLunarChange" />农历</label>
<!-- header 切换月份 -->
<p class="prev-month" @click.stop="goPrev"><i class="icon iconfont el-icon-arrow-left"></i></p>
<p class="next-month" @click.stop="goNext"><i class="icon iconfont el-icon-arrow-right"></i></p>
</div>
<!-- body 日期和事件 -->
<div class="full-jcalendar__body">
<div class="weeks">
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
</div>
<!--日期 -->
<div class="week-row" v-for="(week,index) in calendarDatas" :key="index">
<!--日期 单元格-->
<div class="day-cell" v-for="(day,index) in week" :key="index"
:class="[{'today': day.isToday,'not-optional':isNotOptional(day),'select':day.isSelect,'not-cur-month': !day.isCurMonth }]"
@click="onDateSelect(day)">
<!-- 日期 节气 农历 -->
<div class="day-number">
<p class="solar">
<!--<span class="is-leap" v-if="day.lDate.isLeap && day.lDate.lMonth>10 &&day.lDate.IDayCn==='初一'"></span>-->
<span class="is-leap" v-if="day.lDate.isLeap && day.lDate.IDayCn==='初一'"></span>
<span :class="['number',{'is-today':day.isToday,'is-empty':day.isToday && !day.lDate.isFestival && !day.lDate.isTerm}]">{{day.isToday?'今天':day.day}}</span>
</p>
<p class="lunar" v-show="!day.isToday || day.lDate.isFestival || day.lDate.isTerm">
<span class="festival" v-if="day.lDate.isFestival">{{day.lDate.festival[0]}}</span>
<span class="term" v-else-if="day.lDate.isTerm">{{day.lDate.Term}}</span>
<!--<span v-else-if="day.lDate.IDayCn==='初一'">{{day.lDate.isLeap && day.lDate.lMonth>10?day.lDate.IMonthCn.replace('闰',''):day.lDate.IMonthCn}}</span>-->
<span v-else-if="day.lDate.IDayCn==='初一'">{{day.lDate.IMonthCn.replace('','')}}</span>
<span v-else>{{day.lDate.IDayCn}}</span>
</p>
</div>
</div>
</div>
</div>
<!-- 月份切换 -->
<div class="full-jcalendar__month" v-show="monthVisible">
<div class="full-jcalendar-header">
<span>{{month}}</span>
</div>
<div class="full-jcalendar__body">
<ul class="data-list">
<li @click="onMonthSelect(m-1)" v-for="m in 12" :key="m">{{m}}</li>
</ul>
<p class="clearfix"></p>
<p class="close" @click="monthVisible=false"> </p>
</div>
</div>
<!-- 年份切换 -->
<div class="full-jcalendar__year" v-show="yearVisible">
<div class="full-jcalendar-header">
<span>{{year}}</span>
<!-- header 年份翻页 -->
<p class="prev-month" @click.stop="goYearPrevList"><i class="icon iconfont el-icon-arrow-left"></i></p>
<p class="next-month" @click.stop="goYearNextList"><i class="icon iconfont el-icon-arrow-right"></i></p>
</div>
<div class="full-jcalendar__body">
<ul class="data-list">
<li :class="{'select-year':(m + startYear -1)==year,'curr-year':(m + startYear -1)==todayYear}" @click="onYearSelect(m + startYear -1)" v-for="m in 12" :key="m">{{m + startYear -1}}</li>
</ul>
<p class="clearfix"></p>
<p class="close" @click="yearVisible=false"> </p>
</div>
</div>
</div>
<!--日期段模式-->
<div class="date-range__month leftMonth" v-if="type.toUpperCase() === 'DATERANGE'">
<div class="full-jcalendar-header">
<span class="title-year">{{year}}</span>
<span style="width:10px;"></span>
<span class="title-month">{{month}}</span>
<span style="width:10px;" v-if="showLunarControl"></span>
<label v-if="showLunarControl"><input type="checkbox" v-model="isLunar" @change="onLunarChange" />农历</label>
<!-- header 切换月份 -->
<p class="prev-year" @click.stop="goYearPrev"><i class="icon iconfont el-icon-d-arrow-left"></i></p>
<p class="prev-month" @click.stop="goPrev"><i class="icon iconfont el-icon-arrow-left"></i></p>
</div>
<!-- body 日期和事件 -->
<div class="full-jcalendar__body">
<div class="weeks">
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
</div>
<!--日期 -->
<div class="week-row" v-for="(week,index) in calendarDatas" :key="index" @mouseout="onMouseOut">
<!--日期 单元格-->
<div class="day-cell" v-for="(day,index) in week" :key="index"
:class="[{'today': day.isToday,'not-optional':isNotOptional(day),'choose':isChoose(day),'select':isSelect(day),'not-cur-month': !day.isCurMonth }]"
@click="onDateSelect(day)" @mouseover="onMouseOver(day)">
<!-- 日期 节气 农历 -->
<div class="day-number">
<p class="solar">
<!--<span class="is-leap" v-if="day.lDate.isLeap && day.lDate.lMonth>10 &&day.lDate.IDayCn==='初一'"></span>-->
<span class="is-leap" v-if="day.lDate.isLeap && day.lDate.IDayCn==='初一'"></span>
<span :class="['number',{'is-today':day.isToday,'is-empty':day.isToday && !day.lDate.isFestival && !day.lDate.isTerm}]">{{day.isToday?'今天':day.day}}</span>
</p>
<p class="lunar" v-show="!day.isToday || day.lDate.isFestival || day.lDate.isTerm">
<span class="festival" v-if="day.lDate.isFestival">{{day.lDate.festival[0]}}</span>
<span class="term" v-else-if="day.lDate.isTerm">{{day.lDate.Term}}</span>
<!--<span v-else-if="day.lDate.IDayCn==='初一'">{{day.lDate.isLeap && day.lDate.lMonth>10?day.lDate.IMonthCn.replace('闰',''):day.lDate.IMonthCn}}</span>-->
<span v-else-if="day.lDate.IDayCn==='初一'">{{day.lDate.IMonthCn.replace('','')}}</span>
<span v-else>{{day.lDate.IDayCn}}</span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="date-range__month" v-if="type.toUpperCase() === 'DATERANGE'">
<div class="full-jcalendar-header">
<span class="title-year">{{year2}}</span>
<span style="width:10px;"></span>
<span class="title-month">{{month2}}</span>
<!-- header 切换月份 -->
<p class="next-year" @click.stop="goYearNext"><i class="icon iconfont el-icon-d-arrow-right"></i></p>
<p class="next-month" @click.stop="goNext"><i class="icon iconfont el-icon-arrow-right"></i></p>
</div>
<!-- body 日期和事件 -->
<div class="full-jcalendar__body">
<div class="weeks">
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
<strong class="week"></strong>
</div>
<!--日期 -->
<div class="week-row" v-for="(week,index) in calendarDatas2" :key="index" @mouseout="onMouseOut">
<!--日期 单元格-->
<div class="day-cell" v-for="(day,index) in week" :key="index"
:class="[{'today': day.isToday,'not-optional':isNotOptional(day),'choose':isChoose(day),'select':isSelect(day),'not-cur-month': !day.isCurMonth }]"
@click="onDateSelect(day)" @mouseover="onMouseOver(day);">
<!-- 日期 节气 农历 -->
<div class="day-number">
<p class="solar">
<!--<span class="is-leap" v-if="day.lDate.isLeap && day.lDate.lMonth>10 &&day.lDate.IDayCn==='初一'"></span>-->
<span class="is-leap" v-if="day.lDate.isLeap && day.lDate.IDayCn==='初一'"></span>
<span :class="['number',{'is-today':day.isToday,'is-empty':day.isToday && !day.lDate.isFestival && !day.lDate.isTerm}]">{{day.isToday?'今天':day.day}}</span>
</p>
<p class="lunar" v-show="!day.isToday || day.lDate.isFestival || day.lDate.isTerm">
<span class="festival" v-if="day.lDate.isFestival">{{day.lDate.festival[0]}}</span>
<span class="term" v-else-if="day.lDate.isTerm">{{day.lDate.Term}}</span>
<!--<span v-else-if="day.lDate.IDayCn==='初一'">{{day.lDate.isLeap && day.lDate.lMonth>10?day.lDate.IMonthCn.replace('闰',''):day.lDate.IMonthCn}}</span>-->
<span v-else-if="day.lDate.IDayCn==='初一'">{{day.lDate.IMonthCn.replace('','')}}</span>
<span v-else>{{day.lDate.IDayCn}}</span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</template>
<script>
import moment from 'moment';
// import JDatePickerScript from './JDatePicker.js'
export default {
props: {
width: {
type: String,
default: '200',
},
value: {
type:[String,Date,Array],
default: ''
},
placeholder:{
type: String,
default: ''
},
format: {
type: String,
default: 'YYYY-MM-DD'
},
showLunarClass: {
type: String,
default: 'NUMBER',//共四种FULLLUNAR全农历格式丁酉[鸡]年己酉月乙巳日LUNAR中文格式丁酉[鸡]年七月廿三NUMBER数字格式2017-09-13MIX格式丁酉(2017)[鸡]年七月廿三;
},
showLunarIcon:{
type: Boolean,
default: false,
},
showBackYears:{
type: Number,
default: 2,
},
showLunarControl:{
type: Boolean,
default: true,
},
disabled:{
type: Boolean,
default: false,
},
editable:{
type: Boolean,
default: true,
},
clearable:{
type: Boolean,
default: true,
},
type:{
type: String,
default: "DATE",//DATE - 日期类型DATERANGE 时间段;
},
rangeSeparator:{
type: String,
default: "-",//时间段分隔符
},
pickerOptions:{
type:Object,
default:null
},
},
computed: {
handleWidth: function () {
let w = this.width.toString();
if (w == null || w == '') {
return 200;
}
if (w.indexOf('px') > -1) w = w.replace(/px/, '');
let w0 = parseInt(w) || 0;
if (w0 == 0) {
return 200;
}
return w0;
},
},
watch: {
'value': function (newValue, oldValue) {
this.inputText = '';
this.isLeap = false;
this.isLunar = false;
this.handleInputText(newValue);
},
'showLunarIcon': function (newValue, oldValue) {
},
},
data () {
return {
inputText:'',
startYear:0,//年份列表的起始年份
monthDay: '',//月份日期类型,用来比较日期
selectDay:[],//type=daterange,存放点击选中的时间值;
chooseDay:[],//type=daterange,存放鼠标移动所选时间段;
year: 0,
month: 0,
year2: 0,
month2: 0,
isCurrMonth: true,
calendarDatas: [],
calendarDatas2: [],
calendarVisible: false,//日历显示开关
yearVisible: false,//年份选择开关
monthVisible: false,//月份选择开关
clearVisible:false,//清除按钮开关
isLunar: false,//是否启用农历
isLeap: false,//是否闰月
}
},
created () {
let month = moment()
this.monthDay = month.toISOString();
this.todayYear = month.year();
this.loadCalendar();
document.addEventListener('click', (e) => {
let icon = this.$el.querySelector('.input-icon');
let input = this.$el.querySelector('.input__inner');
let main = this.$el.querySelector('.full-jcalendar__main');
if (!icon.contains(e.target) && !input.contains(e.target) && !main.contains(e.target)) {
this.calendarVisible = false;
if (this.selectDay.length > 0) {
this.monthDay = this.selectDay[0];
}
}
});
this.handleInputText(this.value,true);
},
methods: {
handleInputText(newValue,isNeedEmit){
if (newValue == undefined || newValue == null || !newValue.toString().length) return;
let valueDay = '', valueDay2 = '', result = '';
if (this.type.toUpperCase() == 'DATE') {
//单日期模式
newValue = newValue.toString();
let isLunar = newValue.indexOf('L') > -1;
this.isLunar = isLunar;
if (isLunar) {
//农历模式
let showLunarClass = this.showLunarClass.toUpperCase();
let lunarDate = JDatePickerScript.calendar.getSolar(newValue);
valueDay = new Date(lunarDate.cYear + '-' + lunarDate.cMonth + '-' + lunarDate.cDay).toISOString();
if (showLunarClass == 'NUMBER') {
result = moment(new Date(lunarDate.lYear + '-' + lunarDate.lMonth + '-' + lunarDate.lDay)).format(this.format.toUpperCase());
}
else if (showLunarClass == 'MIX') {
result = lunarDate.gzYear + '(' + lunarDate.lYear + ')[' + lunarDate.Animal + ']年 ' + lunarDate.IMonthCn + lunarDate.IDayCn;
}
else if (showLunarClass == 'FULLLUNAR') {
result = lunarDate.gzYear + '[' + lunarDate.Animal + ']年 ' + lunarDate.gzMonth + '月 ' + lunarDate.gzDay + '日';
}
else if (showLunarClass == 'LUNAR') {
result = lunarDate.gzYear + '[' + lunarDate.Animal + ']年 ' + lunarDate.IMonthCn + lunarDate.IDayCn;
}
} else {
//公历模式
let date = new Date(newValue);
valueDay = date.toISOString();
result = moment(date).format(this.format.toUpperCase());
this.$emit('input',moment(date).format('YYYY-MM-DD'))
}
this.monthDay = valueDay;
this.selectDay = [valueDay];
this.inputText = result;
this.loadCalendar();
return;
}
if (this.type.toUpperCase() == 'DATERANGE') {
//时间段模式
//判断newValue是否为数组ES2005以上支持isArray
if (Array.isArray(newValue) && newValue.length == 2) {
let beginDt = newValue[0];
let endDt = newValue[1];
//判断value是否为日期类型
if(beginDt == undefined || beginDt == null || !beginDt.toString().length) return;
if(endDt == undefined || endDt == null || !endDt.toString().length) return;
beginDt = beginDt.toString();
endDt = endDt.toString();
let isLunar = beginDt.indexOf('L') > -1;
this.isLunar = isLunar;
if (isLunar) {
//农历模式
let beginDateResult = '', endDateResult = '';
let showLunarClass = this.showLunarClass.toUpperCase();
let beginLunarDate = JDatePickerScript.calendar.getSolar(beginDt);
let endLunarDate = JDatePickerScript.calendar.getSolar(endDt);
valueDay = new Date(beginLunarDate.cYear + '-' + beginLunarDate.cMonth + '-' + beginLunarDate.cDay).toISOString();
valueDay2 = new Date(endLunarDate.cYear + '-' + endLunarDate.cMonth + '-' + endLunarDate.cDay).toISOString();
if (showLunarClass == 'NUMBER') {
beginDateResult = moment(new Date(beginLunarDate.lYear + '-' + beginLunarDate.lMonth + '-' + beginLunarDate.lDay)).format(this.format.toUpperCase());
endDateResult = moment(new Date(endLunarDate.lYear + '-' + endLunarDate.lMonth + '-' + endLunarDate.lDay)).format(this.format.toUpperCase());
}
else if (showLunarClass == 'MIX') {
beginDateResult = beginLunarDate.gzYear + '(' + beginLunarDate.lYear + ')[' + beginLunarDate.Animal + ']年 ' + beginLunarDate.IMonthCn + beginLunarDate.IDayCn;
endDateResult = endLunarDate.gzYear + '(' + endLunarDate.lYear + ')[' + endLunarDate.Animal + ']年 ' + endLunarDate.IMonthCn + endLunarDate.IDayCn;
}
else if (showLunarClass == 'FULLLUNAR') {
beginDateResult = beginLunarDate.gzYear + '[' + beginLunarDate.Animal + ']年 ' + beginLunarDate.gzMonth + '月 ' + beginLunarDate.gzDay + '日';
endDateResult = endLunarDate.gzYear + '[' + endLunarDate.Animal + ']年 ' + endLunarDate.gzMonth + '月 ' + endLunarDate.gzDay + '日';
}
else if (showLunarClass == 'LUNAR') {
beginDateResult = beginLunarDate.gzYear + '[' + beginLunarDate.Animal + ']年 ' + beginLunarDate.IMonthCn + beginLunarDate.IDayCn;
endDateResult = endLunarDate.gzYear + '[' + endLunarDate.Animal + ']年 ' + endLunarDate.IMonthCn + endLunarDate.IDayCn;
}
result = beginDateResult + ' ' + this.rangeSeparator + ' ' + endDateResult;
} else {
//公历模式
if(isNeedEmit){
this.$emit('input',[moment(new Date(beginDt)).format('YYYY-MM-DD'),moment(new Date(endDt)).format('YYYY-MM-DD')]);
return;
}
let beginDate = new Date(beginDt);
let endDate = new Date(endDt);
valueDay = beginDate.toISOString();
valueDay2 = endDate.toISOString();
result = moment(beginDate).format(this.format.toUpperCase()) + ' ' + this.rangeSeparator + ' ' + moment(endDate).format(this.format.toUpperCase());
}
this.monthDay = valueDay;
this.selectDay = [valueDay, valueDay2];
this.chooseDay = [valueDay, valueDay2];
this.inputText = result;
this.loadCalendar();
}
}
},
handleInputChange(e){
let result = e.target.value;
if(this.type.toUpperCase() == 'DATE'){
//单日期
if(this.isLunar){
//农历 NUMBER 模式
if(this.showLunarClass.toUpperCase() == 'NUMBER') {
let regex = /\d{4}[-\.\/]\d{1,2}[-\.\/]\d{1,2}/;
if (!regex.test(result)) return;
result = result.replace(/\./g, '-').replace(/\//g, '-');
result = 'L' + moment(new Date(result)).format('YYYY-MM-DD');
}
}else{
let regex = /\d{4}[-\.\/]\d{1,2}[-\.\/]\d{1,2}/;
if (!regex.test(result)) return;
result = result.replace(/\./g, '-').replace(/\//g, '-');
result = moment(new Date(result)).format('YYYY-MM-DD');
}
}
this.$emit('change',result);
this.$emit('input',result);
},
onClearInput(){
if(this.type.toUpperCase() == 'DATERANGE'){
this.$emit('change',[]);
this.$emit('input', []);
}else {
this.$emit('change', '');
this.$emit('input', '');
}
this.selectDay = [];
this.chooseDay = [];
this.monthDay = moment().toISOString();
this.clearVisible = false;
},
onInputOver(){
if(this.disabled) return;
if(this.value ==null || this.value == '')return;
this.clearVisible = true;
},
onInputOut(){
this.clearVisible = false;
},
isNotOptional(day){
if (this.pickerOptions != null && this.pickerOptions != undefined && 'disabledDate' in this.pickerOptions) {
return this.pickerOptions.disabledDate(new Date(day.date));
}
return false;
},
isChoose(day){
//是否在选中时间段区域内
if(this.type.toUpperCase() == 'DATERANGE') {
if(this.chooseDay.length == 2){
let currDay = moment(day.date);
return currDay.isSameOrAfter(this.chooseDay[0]) & currDay.isSameOrBefore(this.chooseDay[1]) & day.isCurMonth;
}
}
return false;
},
isSelect(day){
return this.chooseDay.length>0 & moment(day.date).isSame(new Date(this.chooseDay[0]),'day') & day.isCurMonth;
},
onInputFocus(){
if(this.disabled) return;
this.loadCalendar();
this.calendarVisible = true;
},
onLunarChange(){
if (this.value != null && this.value != '' && this.value.length > 0) {
if (this.type.toUpperCase() == 'DATERANGE') {
//时间段模式
if (this.isLunar) {
//由公历到农历
//判断日期结果集中日期格式是否为农历,若是不作处理直接返回。
if(this.value[0].indexOf('L')>-1) return;
let beginDay = JDatePickerScript.calendar.getLunar(this.value[0].replace(/L/,'').replace(/R/,''));
let endDay = JDatePickerScript.calendar.getLunar(this.value[1].replace(/L/,'').replace(/R/,''));
let beginDayResult = 'L' + (beginDay.isLeap ? 'R' : '') + moment(new Date(beginDay.lYear + '-' + beginDay.lMonth + '-' + beginDay.lDay)).format('YYYY-MM-DD');
let endDayResult = 'L' + (endDay.isLeap ? 'R' : '') + moment(new Date(endDay.lYear + '-' + endDay.lMonth + '-' + endDay.lDay)).format('YYYY-MM-DD');
this.$emit('change',[beginDayResult,endDayResult]);
this.$emit('input' ,[beginDayResult,endDayResult]);
} else {
//由农历到公历
//判断日期结果集中日期格式是否为农历,若不是不作处理直接返回。
if(this.value[0].indexOf('L') == -1) return;
let beginDay = JDatePickerScript.calendar.getSolar(this.value[0]);
let endDay = JDatePickerScript.calendar.getSolar(this.value[1]);
let beginDayResult = moment(new Date(beginDay.cYear + '-' + beginDay.cMonth + '-' + beginDay.cDay)).format('YYYY-MM-DD');
let endDayResult = moment(new Date(endDay.cYear + '-' + endDay.cMonth + '-' + endDay.cDay)).format('YYYY-MM-DD');
this.$emit('change',[beginDayResult,endDayResult]);
this.$emit('input' ,[beginDayResult,endDayResult]);
}
} else {
//单日期模式
let day,result = '';
if (this.isLunar) {
//由公历到农历
//判断日期结果中日期格式是否为农历,若是不作处理直接返回。
if(this.value.indexOf('L')>-1) return;
day = JDatePickerScript.calendar.getLunar(this.value.replace(/L/,'').replace(/R/,''));
result = 'L' + (day.isLeap ? 'R' : '') + moment(new Date(day.lYear + '-' + day.lMonth + '-' + day.lDay)).format('YYYY-MM-DD');
this.$emit('change', result);
this.$emit('input' , result);
} else {
//由农历到公历
//判断日期结果中日期格式是否为农历,若不是不作处理直接返回。
if(this.value.indexOf('L') == -1) return;
day = JDatePickerScript.calendar.getSolar(this.value);
result = moment(new Date(day.cYear + '-' + day.cMonth + '-' + day.cDay)).format('YYYY-MM-DD');
this.$emit('change', new Date(result));
this.$emit('input' , new Date(result));
}
}
}
},
showYearList(){
//公式A 默认当前年所在页面的起始年S 选择日期所在年份Z(pagesize) = 12; Math.ceil : 向上入有小数就向上1
// result = A - Math.ceil( (A-S) / Z ) * Z;
let A = this.todayYear + parseInt(this.showBackYears) - 11;
this.startYear = A - Math.ceil((A - this.year )/12) * 12;
this.yearVisible = true;
},
goYearPrevList(){
if(this.startYear<1912) return;
this.startYear -= 12;
},
goYearNextList(){
if(this.startYear>=this.todayYear + parseInt(this.showBackYears) - 11) return;
this.startYear += 12;
},
goYearPrev(){
this.monthDay = moment(this.monthDay).subtract(1,'years').toISOString();
this.loadCalendar();
},
goYearNext(){
this.monthDay = moment(this.monthDay).add(1,'years').toISOString();
this.loadCalendar();
},
goPrev () {
let newMonth = moment(this.monthDay).subtract(1, 'months');
this.monthDay = newMonth.toISOString();
this.loadCalendar()
},
goNext () {
let newMonth = moment(this.monthDay).add(1, 'months');
this.monthDay = newMonth.toISOString();
this.loadCalendar()
},
onMouseOver(day){
if (this.selectDay.length == 1) {
let currDay = moment(day.date);
let beginDt = this.selectDay[0];
if (currDay.isAfter(beginDt)) {
this.chooseDay = [beginDt, currDay.toISOString()];
}
}
},
onMouseOut(){
if (this.selectDay.length < 2) {
this.chooseDay = [];
}
},
onDateSelect(day){
if(this.isNotOptional(day)) return;
let dayDate = new Date(day.date).toISOString();
if(this.type.toUpperCase() == 'DATERANGE') {
if (this.selectDay.length >= 2) {
this.selectDay = [];
this.chooseDay = [];
}
//判断日期1、第一次选中直接加入结果集为时间段起始日期
// 2、小于起始日期则重置结果集所选日期为结果集起始日期
// 3、大于等于起始日期加入结果集为时间段结束日期可返回结果。
if (this.selectDay.length > 0) {
if (moment(dayDate).isSameOrAfter(this.selectDay[0])) {
this.selectDay.push(dayDate);
}else{
this.selectDay = [dayDate];
}
}else {
this.selectDay.push(dayDate);
}
//校正日历控件展示月份到起始月份或当前月份
//this.monthDay = new Date(this.selectDay[0]).toISOString();
//判断结果集是否符合条件数组selectDay.length2返回结果隐藏控件
if (this.selectDay.length == 2) {
if(this.isLunar) {
let beginLunarDateResult = '', endLunarDateResult = '';
let beginLunar = JDatePickerScript.calendar.getLunar(this.selectDay[0]);
beginLunarDateResult = 'L' + (beginLunar.isLeap ? 'R' : '') + moment(new Date(beginLunar.lYear + '-' + beginLunar.lMonth + '-' + beginLunar.lDay)).format("YYYY-MM-DD");
endLunarDateResult = 'L' + (day.lDate.isLeap ? 'R' : '') + moment(new Date(day.lDate.lYear + '-' + day.lDate.lMonth + '-' + day.lDate.lDay)).format("YYYY-MM-DD");
this.$emit('change', [beginLunarDateResult, endLunarDateResult])
this.$emit('input' , [beginLunarDateResult, endLunarDateResult])
}else{
this.$emit('change', [moment(this.selectDay[0]).format('YYYY-MM-DD'), moment(this.selectDay[1]).format('YYYY-MM-DD')])
this.$emit('input' , [moment(this.selectDay[0]).format('YYYY-MM-DD'), moment(this.selectDay[1]).format('YYYY-MM-DD')])
}
this.calendarVisible = false;
}
}else {
let result = day.date;
if (this.isLunar) {
let tip = 'L' + (day.lDate.isLeap ? 'R' : '');
let date = new Date(day.lDate.lYear + '-' + day.lDate.lMonth + '-' + day.lDate.lDay).toISOString();
result = tip + moment(date).format("YYYY-MM-DD")
}
this.monthDay = dayDate;
this.calendarVisible = false;
this.$emit('change', result);
this.$emit('input' , result);
}
},
onMonthSelect(command){
let newMonth = moment(this.monthDay).month(command)
this.monthDay = newMonth.toISOString();
this.loadCalendar();
this.monthVisible = false;
},
onYearSelect(command){
let newMonth = moment(this.monthDay).year(command)
this.monthDay = newMonth.toISOString();
this.yearVisible = false;
this.monthVisible = true;
},
loadCalendar () {
if(this.monthDay==null || this.monthDay == ''){
this.monthDay = moment().toISOString();
}
let startDate = moment(this.monthDay).startOf('month').format('YYYY-MM-DD');
let currentMonth = moment(startDate);
this.year = currentMonth.year();
this.month = currentMonth.month() + 1;
this.calendarDatas = this.handleCalendar(currentMonth);
if(this.type.toUpperCase() == 'DATERANGE'){
//时间段模式
let currentMonth2 = currentMonth.clone().add(1,'months');
this.year2 = currentMonth2.year();
this.month2 = currentMonth2.month() + 1;
this.calendarDatas2 = this.handleCalendar(currentMonth2);
}
},
handleCalendar(currentMonth){
let start = currentMonth.clone()
start.subtract(start.day(), 'd')
let calendars = [];
for (let iWeek = 0; iWeek < 6; iWeek++) {
let week = []
if (iWeek > 0 && !start.isSame(currentMonth, 'month')) {
break;
}
for (let iDay = 0; iDay < 7; iDay++) {
week.push({
day: start.date(),
isToday: start.isSame(new Date(), 'day'),
isSelect: this.selectDay.length>0 && start.isSame(new Date(this.selectDay[0]),'day'),
isCurMonth: start.isSame(currentMonth, 'month'),
weekIndex:iWeek,
week: iDay,
date: start.clone().format('YYYY-MM-DD'),
lDate: JDatePickerScript.calendar.getLunar(start.clone().format('YYYY-MM-DD')),
});
start.add(1, 'd')
}
calendars.push(week)
}
return calendars;
}
},
}
</script>
<style src="../theme/public.css" scoped>
</style>

Some files were not shown because too many files have changed in this diff Show More