Compare commits
10 Commits
projects/s
...
ccb925003e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccb925003e | ||
|
|
b9f286005c | ||
| 0e343279ac | |||
| 00ac3dec45 | |||
| a84f765e73 | |||
| ffa0b2e8dd | |||
| 1e6c6c5656 | |||
| 0e76fe7dbf | |||
| 399e2bc965 | |||
| 7bee1f7863 |
4
.env.dev
@@ -12,8 +12,10 @@ ENV = 'development'
|
|||||||
VUE_APP_TITLE = 智能监控分析系统
|
VUE_APP_TITLE = 智能监控分析系统
|
||||||
|
|
||||||
# 芋道管理系统/开发环境
|
# 芋道管理系统/开发环境
|
||||||
VUE_APP_BASE_API = 'http://172.16.32.76:48080'
|
# VUE_APP_BASE_API = 'http://172.16.33.187:48082'
|
||||||
# VUE_APP_BASE_API = 'http://line.kszny.picaiba.com'
|
# VUE_APP_BASE_API = 'http://line.kszny.picaiba.com'
|
||||||
|
VUE_APP_BASE_API = 'http://172.16.32.79:48082'
|
||||||
|
|
||||||
|
|
||||||
# 路由懒加载
|
# 路由懒加载
|
||||||
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"local": "vue-cli-service serve --mode local",
|
"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",
|
"front": "vue-cli-service serve --mode front",
|
||||||
"build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --mode prod",
|
"build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --mode prod",
|
||||||
"build:stage": "vue-cli-service build --mode stage",
|
"build:stage": "vue-cli-service build --mode stage",
|
||||||
|
|||||||
@@ -59,3 +59,34 @@ export function getEquipmentAll() {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTree(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/factory/getTree',
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,3 +52,5 @@ export function exportEquipmentTypeExcel(query) {
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
export function getTeamReportPage(data) {
|
||||||
|
|||||||
@@ -141,3 +141,13 @@ export function getPerView(data) {
|
|||||||
data:data
|
data:data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 导出 Excel
|
||||||
|
export function exportExcel(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/group-scheduling-plan/export-excel',
|
||||||
|
method: 'get',
|
||||||
|
params: query,
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ export function getGroup(id) {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 检查更新-生产班组
|
||||||
|
export function updateIsProduction(id) {
|
||||||
|
return request({
|
||||||
|
url: '/base/group-team/updateIsProduction?id=' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 获得班组基础信息分页
|
// 获得班组基础信息分页
|
||||||
export function getGroupPage(query) {
|
export function getGroupPage(query) {
|
||||||
|
|||||||
@@ -90,3 +90,29 @@ export function getEnableData() {
|
|||||||
method: 'get',
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
56
src/api/monitoring/defectSummary.js
Normal 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
63
src/api/monitoring/qualityIsra.js
Normal 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
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
BIN
src/assets/images/equipmentNum.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/images/equipmentNumImg.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
src/assets/images/runNum.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
src/assets/images/runNumImg.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
src/assets/images/stopNum.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/images/stopNumImg.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 461 B |
|
Before Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 312 B |
|
Before Width: | Height: | Size: 244 B |
|
Before Width: | Height: | Size: 137 B |
|
Before Width: | Height: | Size: 165 B |
|
Before Width: | Height: | Size: 139 B |
|
Before Width: | Height: | Size: 170 B |
|
Before Width: | Height: | Size: 929 B |
|
Before Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 320 B |
|
Before Width: | Height: | Size: 261 B |
|
Before Width: | Height: | Size: 416 B |
|
Before Width: | Height: | Size: 305 B |
|
Before Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 259 B |
|
Before Width: | Height: | Size: 420 B |
|
Before Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 326 B |
|
Before Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 355 B |
|
Before Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 562 B |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 1.9 MiB |
@@ -6,99 +6,43 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-form
|
<el-form ref="form" :model="form" :label-width="`${labelWidth}px`" :size="size" :label-position="labelPosition"
|
||||||
ref="form"
|
|
||||||
:model="form"
|
|
||||||
:label-width="`${labelWidth}px`"
|
|
||||||
:size="size"
|
|
||||||
:label-position="labelPosition"
|
|
||||||
v-loading="formLoading">
|
v-loading="formLoading">
|
||||||
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
|
<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-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-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
|
||||||
<el-input
|
<el-input v-if="col.input" v-model="form[col.prop]" @change="$emit('update', form)"
|
||||||
v-if="col.input"
|
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
|
||||||
v-model="form[col.prop]"
|
<el-input v-if="col.textarea" type="textarea" v-model="form[col.prop]" @change="$emit('update', form)"
|
||||||
@change="$emit('update', form)"
|
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
|
||||||
:placeholder="`请输入${col.label}`"
|
<el-select v-if="col.select" v-model="form[col.prop]" :placeholder="`请选择${col.label}`"
|
||||||
v-bind="col.bind" />
|
@change="$emit('update', form)" v-bind="col.bind">
|
||||||
<el-input
|
<el-option v-for="opt in optionListOf[col.prop]" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||||
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-select>
|
||||||
<el-date-picker
|
<el-date-picker v-if="col.datetime" v-model="form[col.prop]" type="datetime" :placeholder="`请选择${col.label}`"
|
||||||
v-if="col.datetime"
|
value-format="timestamp" v-bind="col.bind"></el-date-picker>
|
||||||
v-model="form[col.prop]"
|
<el-switch v-if="col.switch" v-model="form[col.prop]" active-color="#0b58ff" inactive-color="#e1e1e1"
|
||||||
type="datetime"
|
v-bind="col.bind" @change="handleSwitchChange(col.prop)"></el-switch>
|
||||||
:placeholder="`请选择${col.label}`"
|
<component v-if="col.subcomponent" :key="col.key" :is="col.subcomponent" :inlineStyle="col.style"></component>
|
||||||
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>
|
|
||||||
|
|
||||||
<div
|
<div class="upload-area" :class="uploadOpen ? '' : 'height-48'" ref="uploadArea" v-if="col.upload">
|
||||||
class="upload-area"
|
|
||||||
:class="uploadOpen ? '' : 'height-48'"
|
|
||||||
ref="uploadArea"
|
|
||||||
v-if="col.upload">
|
|
||||||
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
|
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
|
||||||
<el-button
|
<el-button type="text" icon="el-icon-arrow-right" @click="handleFilesOpen" />
|
||||||
type="text"
|
|
||||||
icon="el-icon-arrow-right"
|
|
||||||
@click="handleFilesOpen" />
|
|
||||||
</span>
|
</span>
|
||||||
<!-- :file-list="uploadedFileList" -->
|
<!-- :file-list="uploadedFileList" -->
|
||||||
<el-upload
|
<el-upload class="upload-in-dialog" v-if="col.upload" :action="uploadUrl" :headers="uploadHeaders"
|
||||||
class="upload-in-dialog"
|
:show-file-list="false" icon="el-icon-upload2" :before-upload="beforeUpload"
|
||||||
v-if="col.upload"
|
:on-success="handleUploadSuccess" v-bind="col.bind">
|
||||||
: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">
|
<el-button size="mini" :disabled="col.bind?.disabled || false">
|
||||||
<svg-icon
|
<svg-icon icon-class="icon-upload" style="color: inherit"></svg-icon>
|
||||||
icon-class="icon-upload"
|
|
||||||
style="color: inherit"></svg-icon>
|
|
||||||
上传文件
|
上传文件
|
||||||
</el-button>
|
</el-button>
|
||||||
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
|
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
|
||||||
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
|
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
|
||||||
</div>
|
</div>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<uploadedFile
|
<uploadedFile class="file" v-for="file in form[col.prop] || []" :file="file" :key="file.fileUrl"
|
||||||
class="file"
|
@delete="handleDeleteFile(file)" @Preview="handlePreview(file)" />
|
||||||
v-for="file in form[col.prop] || []"
|
|
||||||
:file="file"
|
|
||||||
:key="file.fileUrl"
|
|
||||||
@delete="handleDeleteFile(file)"
|
|
||||||
@Preview="handlePreview(file)" />
|
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -135,6 +79,7 @@ const uploadedFile = {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
handleDelete() {
|
handleDelete() {
|
||||||
this.$emit('delete', this.file);
|
this.$emit('delete', this.file);
|
||||||
},
|
},
|
||||||
@@ -252,6 +197,11 @@ export default {
|
|||||||
this.handleOptions();
|
this.handleOptions();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleSwitchChange(prop) {
|
||||||
|
// 触发 update 事件,将最新的 form 数据传递给父组件
|
||||||
|
this.$emit('update', { ...this.form });
|
||||||
|
console.log(`switch ${prop} 变化:`, this.form[prop]);
|
||||||
|
},
|
||||||
/** 模拟透传 ref */
|
/** 模拟透传 ref */
|
||||||
validate(cb) {
|
validate(cb) {
|
||||||
return this.$refs.form.validate(cb);
|
return this.$refs.form.validate(cb);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default {
|
|||||||
},
|
},
|
||||||
tableData: [], //table数据
|
tableData: [], //table数据
|
||||||
listQuery: { //分页
|
listQuery: { //分页
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { isRelogin } from '@/utils/request'
|
|||||||
NProgress.configure({ showSpinner: false })
|
NProgress.configure({ showSpinner: false })
|
||||||
|
|
||||||
// 增加三方登陆 update by 芋艿
|
// 增加三方登陆 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) => {
|
router.beforeEach((to, from, next) => {
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
@@ -25,9 +25,9 @@ router.beforeEach((to, from, next) => {
|
|||||||
// 获取字典数据 add by 芋艿
|
// 获取字典数据 add by 芋艿
|
||||||
store.dispatch('dict/loadDictDatas')
|
store.dispatch('dict/loadDictDatas')
|
||||||
// 判断当前用户是否已拉取完 user_info 信息
|
// 判断当前用户是否已拉取完 user_info 信息
|
||||||
store.dispatch('GetInfo').then(userInfo => {
|
store.dispatch('GetInfo').then(() => {
|
||||||
isRelogin.show = false
|
isRelogin.show = false
|
||||||
store.dispatch('GenerateRoutes', userInfo.menus).then(accessRoutes => {
|
store.dispatch('GenerateRoutes').then(accessRoutes => {
|
||||||
// 根据 roles 权限生成可访问的路由表
|
// 根据 roles 权限生成可访问的路由表
|
||||||
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
||||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||||
|
|||||||
@@ -35,236 +35,185 @@ export const constantRoutes = [
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/redirect/:path(.*)',
|
path: '/redirect/:path(.*)',
|
||||||
component: (resolve) => require(['@/views/redirect'], resolve),
|
component: (resolve) => require(['@/views/redirect'], resolve)
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
component: (resolve) => require(['@/views/login'], resolve),
|
component: (resolve) => require(['@/views/login'], resolve),
|
||||||
// hidden: true,
|
hidden: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/sso',
|
path: '/sso',
|
||||||
component: (resolve) => require(['@/views/sso'], resolve),
|
component: (resolve) => require(['@/views/sso'], resolve),
|
||||||
hidden: true,
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/social-login',
|
path: '/social-login',
|
||||||
component: (resolve) => require(['@/views/socialLogin'], resolve),
|
component: (resolve) => require(['@/views/socialLogin'], resolve),
|
||||||
hidden: true,
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/404',
|
path: '/404',
|
||||||
component: (resolve) => require(['@/views/error/404'], resolve),
|
component: (resolve) => require(['@/views/error/404'], resolve),
|
||||||
hidden: true,
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/401',
|
path: '/401',
|
||||||
component: (resolve) => require(['@/views/error/401'], resolve),
|
component: (resolve) => require(['@/views/error/401'], resolve),
|
||||||
hidden: true,
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/print-design',
|
path: '/print-design',
|
||||||
component: (resolve) => require(['@/views/print/design'], resolve),
|
component: (resolve) => require(['@/views/print/design'], resolve),
|
||||||
hidden: true,
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: "",
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: 'index',
|
redirect: "index",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'index',
|
path: "index",
|
||||||
component: (resolve) => require(['@/views/home/index'], resolve),
|
component: (resolve) => require(["@/views/home/index"], resolve),
|
||||||
name: '首页',
|
name: "首页",
|
||||||
meta: { title: '首页', icon: 'dashboard', affix: true },
|
meta: { title: "首页", icon: "dashboard", affix: true },
|
||||||
hidden: true,
|
hidden: true
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/screenbg',
|
|
||||||
component: () =>
|
|
||||||
import(
|
|
||||||
/* webpackChunkName: "about" */ '@/views/productionVisualization/equipmentBoard'
|
|
||||||
),
|
|
||||||
name: 'screenbg',
|
|
||||||
meta: { title: '大屏', icon: 'chart' },
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/user',
|
path: '/user',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
redirect: 'noredirect',
|
redirect: 'noredirect',
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'profile',
|
path: 'profile',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
|
||||||
require(['@/views/system/user/profile/index'], resolve),
|
|
||||||
name: 'Profile',
|
name: 'Profile',
|
||||||
meta: { title: '个人中心', icon: 'user' },
|
meta: { title: '个人中心', icon: 'user' }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
path: 'notify-message',
|
path: 'notify-message',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/system/notify/my/index'], resolve),
|
||||||
require(['@/views/system/notify/my/index'], resolve),
|
|
||||||
name: 'MyNotifyMessage',
|
name: 'MyNotifyMessage',
|
||||||
meta: { title: '我的站内信', icon: 'message' },
|
meta: { title: '我的站内信', icon: 'message' },
|
||||||
},
|
}]
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/dict',
|
path: '/dict',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'type/data/:dictId(\\d+)',
|
path: 'type/data/:dictId(\\d+)',
|
||||||
component: (resolve) => require(['@/views/system/dict/data'], resolve),
|
component: (resolve) => require(['@/views/system/dict/data'], resolve),
|
||||||
name: 'SystemDictData',
|
name: 'SystemDictData',
|
||||||
meta: { title: '字典数据', icon: '', activeMenu: '/system/dict' },
|
meta: { title: '字典数据', icon: '', activeMenu: '/system/dict' }
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/job',
|
path: '/job',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'log',
|
path: 'log',
|
||||||
component: (resolve) => require(['@/views/infra/job/log'], resolve),
|
component: (resolve) => require(['@/views/infra/job/log'], resolve),
|
||||||
name: 'InfraJobLog',
|
name: 'InfraJobLog',
|
||||||
meta: { title: '调度日志', activeMenu: '/infra/job' },
|
meta: { title: '调度日志', activeMenu: '/infra/job' }
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
path: '/codegen',
|
path: '/codegen',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'edit/:tableId(\\d+)',
|
path: 'edit/:tableId(\\d+)',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/infra/codegen/editTable'], resolve),
|
||||||
require(['@/views/infra/codegen/editTable'], resolve),
|
|
||||||
name: 'InfraCodegenEditTable',
|
name: 'InfraCodegenEditTable',
|
||||||
meta: { title: '修改生成配置', activeMenu: '/infra/codegen' },
|
meta: { title: '修改生成配置', activeMenu: '/infra/codegen' }
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/bpm',
|
path: '/bpm',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
redirect: 'noredirect',
|
redirect: 'noredirect',
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'oa/leave/create',
|
path: 'oa/leave/create',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/bpm/oa/leave/create'], resolve),
|
||||||
require(['@/views/bpm/oa/leave/create'], resolve),
|
|
||||||
name: 'BpmOALeaveCreate',
|
name: 'BpmOALeaveCreate',
|
||||||
meta: {
|
meta: { title: '发起 OA 请假', icon: 'form', activeMenu: '/bpm/oa/leave' }
|
||||||
title: '发起 OA 请假',
|
}, {
|
||||||
icon: 'form',
|
|
||||||
activeMenu: '/bpm/oa/leave',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'oa/leave/detail',
|
path: 'oa/leave/detail',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/bpm/oa/leave/detail'], resolve),
|
||||||
require(['@/views/bpm/oa/leave/detail'], resolve),
|
|
||||||
name: 'BpmOALeaveDetail',
|
name: 'BpmOALeaveDetail',
|
||||||
meta: {
|
meta: { title: '查看 OA 请假', icon: 'view', activeMenu: '/bpm/oa/leave' }
|
||||||
title: '查看 OA 请假',
|
}
|
||||||
icon: 'view',
|
]
|
||||||
activeMenu: '/bpm/oa/leave',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/bpm',
|
path: '/bpm',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'manager/form/edit',
|
path: 'manager/form/edit',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/bpm/form/formEditor'], resolve),
|
||||||
require(['@/views/bpm/form/formEditor'], resolve),
|
|
||||||
name: 'BpmFormEditor',
|
name: 'BpmFormEditor',
|
||||||
meta: { title: '流程表单-编辑', activeMenu: '/bpm/manager/form' },
|
meta: { title: '流程表单-编辑', activeMenu: '/bpm/manager/form' }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
path: 'manager/definition',
|
path: 'manager/definition',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/bpm/definition/index'], resolve),
|
||||||
require(['@/views/bpm/definition/index'], resolve),
|
|
||||||
name: 'BpmProcessDefinition',
|
name: 'BpmProcessDefinition',
|
||||||
meta: { title: '流程定义', activeMenu: '/bpm/manager/model' },
|
meta: { title: '流程定义', activeMenu: '/bpm/manager/model' }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
path: 'manager/model/design',
|
path: 'manager/model/design',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/bpm/model/modelEditor'], resolve),
|
||||||
require(['@/views/bpm/model/modelEditor'], resolve),
|
|
||||||
name: 'BpmModelEditor',
|
name: 'BpmModelEditor',
|
||||||
meta: { title: '设计流程', activeMenu: '/bpm/manager/model' },
|
meta: { title: '设计流程', activeMenu: '/bpm/manager/model' }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
path: 'process-instance/create',
|
path: 'process-instance/create',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/bpm/processInstance/create'], resolve),
|
||||||
require(['@/views/bpm/processInstance/create'], resolve),
|
|
||||||
name: 'BpmProcessInstanceCreate',
|
name: 'BpmProcessInstanceCreate',
|
||||||
meta: { title: '发起流程', activeMenu: '/bpm/task/my' },
|
meta: { title: '发起流程', activeMenu: '/bpm/task/my' }
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
path: 'process-instance/detail',
|
path: 'process-instance/detail',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/bpm/processInstance/detail'], resolve),
|
||||||
require(['@/views/bpm/processInstance/detail'], resolve),
|
|
||||||
name: 'BpmProcessInstanceDetail',
|
name: 'BpmProcessInstanceDetail',
|
||||||
meta: { title: '流程详情', activeMenu: '/bpm/task/my' },
|
meta: { title: '流程详情', activeMenu: '/bpm/task/my' }
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/property',
|
path: '/property',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'value/:propertyId(\\d+)',
|
path: 'value/:propertyId(\\d+)',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
|
||||||
require(['@/views/mall/product/property/value'], resolve),
|
|
||||||
name: 'ProductPropertyValue',
|
name: 'ProductPropertyValue',
|
||||||
meta: {
|
meta: { title: '商品属性值', icon: '', activeMenu: '/product/property' }
|
||||||
title: '商品属性值',
|
}
|
||||||
icon: '',
|
]
|
||||||
activeMenu: '/product/property',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/spu',
|
path: '/spu',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'edit/:spuId(\\d+)',
|
path: 'edit/:spuId(\\d+)',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
|
||||||
require(['@/views/mall/product/spu/save'], resolve),
|
|
||||||
name: 'ProductSpuUpdate',
|
name: 'ProductSpuUpdate',
|
||||||
meta: { title: '修改商品', activeMenu: '/product/spu' },
|
meta: { title: '修改商品', activeMenu: '/product/spu' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'add',
|
path: 'add',
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
|
||||||
require(['@/views/mall/product/spu/save'], resolve),
|
|
||||||
name: 'ProductSpuCreate',
|
name: 'ProductSpuCreate',
|
||||||
meta: { title: '添加商品', activeMenu: '/product/spu' },
|
meta: { title: '添加商品', activeMenu: '/product/spu' }
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/trade/order',
|
path: '/trade/order',
|
||||||
@@ -276,29 +225,26 @@ export const constantRoutes = [
|
|||||||
name: 'TradeOrderDetail',
|
name: 'TradeOrderDetail',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
meta: { title: '订单详情' },
|
meta: { title: '订单详情' },
|
||||||
component: (resolve) =>
|
component: (resolve) => require(['@/views/mall/trade/order/detail'], resolve)
|
||||||
require(['@/views/mall/trade/order/detail'], resolve),
|
}
|
||||||
},
|
]
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/pay',
|
path: '/pay',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [{
|
||||||
{
|
|
||||||
path: 'order/submit',
|
path: 'order/submit',
|
||||||
name: 'PayOrderSubmit',
|
name: 'PayOrderSubmit',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
meta: {
|
meta: {
|
||||||
title: '收银台',
|
title: '收银台',
|
||||||
noCache: true,
|
noCache: true
|
||||||
},
|
},
|
||||||
component: (resolve) => require(['@/views/pay/order/submit'], resolve),
|
component: (resolve) => require(['@/views/pay/order/submit'], resolve)
|
||||||
},
|
}]
|
||||||
],
|
}
|
||||||
},
|
]
|
||||||
];
|
|
||||||
|
|
||||||
// 防止连续点击多次路由报错
|
// 防止连续点击多次路由报错
|
||||||
let routerPush = Router.prototype.push;
|
let routerPush = Router.prototype.push;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {constantRoutes} from '@/router'
|
import {constantRoutes} from '@/router'
|
||||||
|
import {getRouters} from '@/api/menu'
|
||||||
import Layout from '@/layout/index'
|
import Layout from '@/layout/index'
|
||||||
import ParentView from '@/components/ParentView';
|
import ParentView from '@/components/ParentView';
|
||||||
import {toCamelCase} from "@/utils";
|
import {toCamelCase} from "@/utils";
|
||||||
@@ -26,17 +27,13 @@ const permission = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
/**
|
// 生成路由
|
||||||
* 生成路由
|
GenerateRoutes({commit}) {
|
||||||
*
|
|
||||||
* @param commit commit 函数
|
|
||||||
* @param menus 路由参数
|
|
||||||
*/
|
|
||||||
GenerateRoutes({commit}, menus) {
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
// 将 menus 菜单,转换为 route 路由数组
|
// 向后端请求路由数据(菜单)
|
||||||
const sdata = JSON.parse(JSON.stringify(menus)) // 【重要】用于菜单中的数据
|
getRouters().then(res => {
|
||||||
const rdata = JSON.parse(JSON.stringify(menus)) // 用于最后添加到 Router 中的数据
|
const sdata = JSON.parse(JSON.stringify(res.data)) // 【重要】用于菜单中的数据
|
||||||
|
const rdata = JSON.parse(JSON.stringify(res.data)) // 用于最后添加到 Router 中的数据
|
||||||
const sidebarRoutes = filterAsyncRouter(sdata)
|
const sidebarRoutes = filterAsyncRouter(sdata)
|
||||||
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
||||||
rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
|
rewriteRoutes.push({path: '*', redirect: '/404', hidden: true})
|
||||||
@@ -46,6 +43,7 @@ const permission = {
|
|||||||
commit('SET_TOPBAR_ROUTES', sidebarRoutes)
|
commit('SET_TOPBAR_ROUTES', sidebarRoutes)
|
||||||
resolve(rewriteRoutes)
|
resolve(rewriteRoutes)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import axios from 'axios'
|
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 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 errorCode from '@/utils/errorCode'
|
||||||
import {getPath, getTenantEnable} from "@/utils/ruoyi";
|
import { getPath, getTenantEnable } from "@/utils/ruoyi";
|
||||||
import {refreshToken} from "@/api/login";
|
import { refreshToken } from "@/api/login";
|
||||||
|
|
||||||
// 需要忽略的提示。忽略后,自动 Promise.reject('error')
|
// 需要忽略的提示。忽略后,自动 Promise.reject('error')
|
||||||
const ignoreMsgs = [
|
const ignoreMsgs = [
|
||||||
@@ -86,7 +86,7 @@ service.interceptors.request.use(config => {
|
|||||||
for (const propName of Object.keys(config.params)) {
|
for (const propName of Object.keys(config.params)) {
|
||||||
const value = config.params[propName];
|
const value = config.params[propName];
|
||||||
const part = encodeURIComponent(propName) + '='
|
const part = encodeURIComponent(propName) + '='
|
||||||
if (value !== null && typeof(value) !== "undefined") {
|
if (value !== null && typeof (value) !== "undefined") {
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
for (const key of Object.keys(value)) {
|
for (const key of Object.keys(value)) {
|
||||||
let params = propName + '[' + key + ']';
|
let params = propName + '[' + key + ']';
|
||||||
@@ -176,13 +176,15 @@ service.interceptors.response.use(async res => {
|
|||||||
+ '<div>5 分钟搭建本地环境</div>',
|
+ '<div>5 分钟搭建本地环境</div>',
|
||||||
})
|
})
|
||||||
return Promise.reject(new Error(msg))
|
return Promise.reject(new Error(msg))
|
||||||
|
} else if (code === 400) {
|
||||||
|
//【班组管理】【排班计划】提交的校验按照原型图补充完整,排班计划是否重叠code400 有两个不同的返回信息
|
||||||
|
return res.data
|
||||||
} else if (code !== 200) {
|
} else if (code !== 200) {
|
||||||
if (msg === '无效的刷新令牌') { // hard coding:忽略这个提示,直接登出
|
if (msg === '无效的刷新令牌') { // hard coding:忽略这个提示,直接登出
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
} else {
|
} else {
|
||||||
Notification.error({
|
//【班组管理】【排班计划】提交的校验按照原型图补充完整,排班计划是否重叠code400 有两个不同的返回信息
|
||||||
title: msg
|
return res.data
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return Promise.reject('error')
|
return Promise.reject('error')
|
||||||
} else {
|
} else {
|
||||||
@@ -191,7 +193,7 @@ service.interceptors.response.use(async res => {
|
|||||||
}, error => {
|
}, error => {
|
||||||
tryHideFullScreenLoading()
|
tryHideFullScreenLoading()
|
||||||
console.log('err' + error)
|
console.log('err' + error)
|
||||||
let {message} = error;
|
let { message } = error;
|
||||||
if (message === "Network Error") {
|
if (message === "Network Error") {
|
||||||
message = "后端接口连接异常";
|
message = "后端接口连接异常";
|
||||||
} else if (message.includes("timeout")) {
|
} else if (message.includes("timeout")) {
|
||||||
@@ -205,7 +207,7 @@ service.interceptors.response.use(async res => {
|
|||||||
duration: 5 * 1000
|
duration: 5 * 1000
|
||||||
})
|
})
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
export function getBaseHeader() {
|
export function getBaseHeader() {
|
||||||
|
|||||||
@@ -6,14 +6,8 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-drawer
|
<el-drawer :visible="visible" :show-close="false" :wrapper-closable="false" class="drawer" custom-class="mes-drawer"
|
||||||
:visible="visible"
|
:size="size || '50%'" @closed="$emit('destroy')">
|
||||||
:show-close="false"
|
|
||||||
:wrapper-closable="false"
|
|
||||||
class="drawer"
|
|
||||||
custom-class="mes-drawer"
|
|
||||||
:size="size || '50%'"
|
|
||||||
@closed="$emit('destroy')">
|
|
||||||
<SmallTitle slot="title">
|
<SmallTitle slot="title">
|
||||||
{{
|
{{
|
||||||
mode.includes('detail')
|
mode.includes('detail')
|
||||||
@@ -29,9 +23,7 @@
|
|||||||
<section v-for="(section, index) in sections" :key="section.key">
|
<section v-for="(section, index) in sections" :key="section.key">
|
||||||
<SmallTitle v-if="index != 0">{{ section.name }}</SmallTitle>
|
<SmallTitle v-if="index != 0">{{ section.name }}</SmallTitle>
|
||||||
|
|
||||||
<div
|
<div class="form-part" v-if="section.key == 'base'"
|
||||||
class="form-part"
|
|
||||||
v-if="section.key == 'base'"
|
|
||||||
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
||||||
<el-skeleton v-if="!showForm" animated />
|
<el-skeleton v-if="!showForm" animated />
|
||||||
<!-- <BaseInfoForm
|
<!-- <BaseInfoForm
|
||||||
@@ -45,9 +37,7 @@
|
|||||||
<!-- if -->
|
<!-- if -->
|
||||||
<el-row v-if="mode.includes('detail')" style="margin-bottom: 24px">
|
<el-row v-if="mode.includes('detail')" style="margin-bottom: 24px">
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div
|
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||||
class="title"
|
|
||||||
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
|
||||||
设备名
|
设备名
|
||||||
</div>
|
</div>
|
||||||
<div class="value" style="font-size: 14px">
|
<div class="value" style="font-size: 14px">
|
||||||
@@ -55,9 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div
|
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||||
class="title"
|
|
||||||
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
|
||||||
关联表名
|
关联表名
|
||||||
</div>
|
</div>
|
||||||
<div class="value" style="font-size: 14px">
|
<div class="value" style="font-size: 14px">
|
||||||
@@ -69,37 +57,16 @@
|
|||||||
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
||||||
<el-form ref="form" :model="form">
|
<el-form ref="form" :model="form">
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item
|
<el-form-item class="title" label="设备名" style="font-size: 16px; margin: 8px 0">
|
||||||
class="title"
|
<el-select v-model="form.equipmentId" filterable clearable placeholder="请选择设备">
|
||||||
label="设备名"
|
<el-option v-for="eq in eqList" :key="eq.id" :label="eq.name" :value="eq.id"></el-option>
|
||||||
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-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item
|
<el-form-item class="title" label="设备关联表名" style="font-size: 16px; margin: 8px 0">
|
||||||
class="title"
|
<el-select v-model="form.plcId" filterable clearable placeholder="请选择关联表">
|
||||||
label="设备关联表名"
|
<el-option v-for="plc in plcList" :key="plc.id" :label="plc.plcTableName"
|
||||||
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>
|
:value="plc.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -108,73 +75,44 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div v-if="section.key == 'attrs'" style="position: relative; margin-top: 12px">
|
||||||
v-if="section.key == 'attrs'"
|
<div v-if="!mode.includes('detail')" style="position: absolute; top: -40px; right: 0">
|
||||||
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">
|
<el-button @click="handleAddAttr" type="text">
|
||||||
<i class="el-icon-plus"></i>
|
<i class="el-icon-plus"></i>
|
||||||
添加参数
|
添加参数
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<base-table
|
<base-table v-loading="attrListLoading" :table-props="section.props" :page="attrQuery?.params.pageNo || 1"
|
||||||
v-loading="attrListLoading"
|
:limit="attrQuery?.params.pageSize || 10" :table-data="list" @emitFun="handleEmitFun">
|
||||||
: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 : '添加属性'"
|
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
|
||||||
@emitButtonClick="handleAddAttr" -->
|
@emitButtonClick="handleAddAttr" -->
|
||||||
<method-btn
|
<method-btn v-if="section.tableBtn && !mode.includes('detail')" slot="handleBtn" label="操作"
|
||||||
v-if="section.tableBtn && !mode.includes('detail')"
|
:method-list="tableBtn" @clickBtn="handleTableBtnClick" />
|
||||||
slot="handleBtn"
|
|
||||||
label="操作"
|
|
||||||
:method-list="tableBtn"
|
|
||||||
@clickBtn="handleTableBtnClick" />
|
|
||||||
</base-table>
|
</base-table>
|
||||||
|
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<pagination
|
<pagination v-show="total > 0" :total="total" :page.sync="attrQuery.params.pageNo"
|
||||||
v-show="total > 0"
|
:limit.sync="attrQuery.params.pageSize" @pagination="getAttrList" />
|
||||||
:total="total"
|
|
||||||
:page.sync="attrQuery.params.pageNo"
|
|
||||||
:limit.sync="attrQuery.params.pageSize"
|
|
||||||
@pagination="getAttrList" />
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="drawer-body__footer">
|
<div class="drawer-body__footer">
|
||||||
<el-button style="" @click="handleCancel">取消</el-button>
|
<el-button style="" @click="handleCancel">取消</el-button>
|
||||||
<el-button
|
<el-button type="primary" v-if="!mode.includes('detail')" @click="handleSave">
|
||||||
type="primary"
|
|
||||||
v-if="!mode.includes('detail')"
|
|
||||||
@click="handleSave">
|
|
||||||
保存
|
保存
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 属性对话框 -->
|
<!-- 属性对话框 -->
|
||||||
<base-dialog
|
<base-dialog v-if="sections[1].allowAdd" :dialogTitle="attrTitle" :dialogVisible="attrFormVisible" width="45%"
|
||||||
v-if="sections[1].allowAdd"
|
:append-to-body="true" custom-class="baseDialog" @close="closeAttrForm" @cancel="closeAttrForm"
|
||||||
:dialogTitle="attrTitle"
|
|
||||||
:dialogVisible="attrFormVisible"
|
|
||||||
width="45%"
|
|
||||||
:append-to-body="true"
|
|
||||||
custom-class="baseDialog"
|
|
||||||
@close="closeAttrForm"
|
|
||||||
@cancel="closeAttrForm"
|
|
||||||
@confirm="submitAttrForm">
|
@confirm="submitAttrForm">
|
||||||
<!-- :disabled="mode.includes('detail')" -->
|
<!-- :disabled="mode.includes('detail')" -->
|
||||||
<DialogForm
|
<DialogForm v-if="attrFormVisible" ref="attrForm" v-model="attrForm" :data-form="attrForm"
|
||||||
v-if="attrFormVisible"
|
:rows="attrRows"
|
||||||
ref="attrForm"
|
@update="handleAttrFormUpdate"/>
|
||||||
v-model="attrForm"
|
|
||||||
:rows="attrRows" />
|
|
||||||
</base-dialog>
|
</base-dialog>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
@@ -233,6 +171,8 @@ export default {
|
|||||||
description: '',
|
description: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
alarmContent: '',
|
alarmContent: '',
|
||||||
|
displayTip: false,
|
||||||
|
alarmTip: false,
|
||||||
},
|
},
|
||||||
attrFormVisible: false,
|
attrFormVisible: false,
|
||||||
attrRows: [
|
attrRows: [
|
||||||
@@ -342,6 +282,26 @@ 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,
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@@ -437,6 +397,23 @@ 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 }) {
|
handleTableBtnClick({ type, data }) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
@@ -503,6 +480,7 @@ export default {
|
|||||||
plcParamName: '',
|
plcParamName: '',
|
||||||
unit: '',
|
unit: '',
|
||||||
collection: 1,
|
collection: 1,
|
||||||
|
|
||||||
minValue: '',
|
minValue: '',
|
||||||
maxValue: '',
|
maxValue: '',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
@@ -511,6 +489,8 @@ export default {
|
|||||||
equipmentParamType: '',
|
equipmentParamType: '',
|
||||||
productionParamType: '',
|
productionParamType: '',
|
||||||
alarmContent: '',
|
alarmContent: '',
|
||||||
|
displayTip: false,
|
||||||
|
alarmTip: false,
|
||||||
};
|
};
|
||||||
this.attrTitle = '添加参数绑定信息';
|
this.attrTitle = '添加参数绑定信息';
|
||||||
this.attrFormVisible = true;
|
this.attrFormVisible = true;
|
||||||
@@ -524,7 +504,14 @@ export default {
|
|||||||
params: { id: attrId },
|
params: { id: attrId },
|
||||||
});
|
});
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.attrForm = res.data;
|
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.attrTitle = '编辑参数绑定信息';
|
||||||
this.attrFormVisible = true;
|
this.attrFormVisible = true;
|
||||||
}
|
}
|
||||||
@@ -564,6 +551,7 @@ export default {
|
|||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log('this.attrForm', this.attrForm);
|
||||||
|
|
||||||
const isEdit = this.attrForm.id != null;
|
const isEdit = this.attrForm.id != null;
|
||||||
this.attrFormSubmitting = true;
|
this.attrFormSubmitting = true;
|
||||||
@@ -583,8 +571,9 @@ export default {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 1500,
|
duration: 1500,
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
this.getAttrList();
|
|
||||||
this.shouldRefreshPageView = true;
|
this.shouldRefreshPageView = true;
|
||||||
|
this.getAttrList();
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export default {
|
|||||||
id: null,
|
id: null,
|
||||||
code: '',
|
code: '',
|
||||||
materialId: '',
|
materialId: '',
|
||||||
price: '',
|
price: undefined,
|
||||||
startTime: new Date().getTime(),
|
startTime: new Date().getTime(),
|
||||||
endTime: null,
|
endTime: null,
|
||||||
remark: '',
|
remark: '',
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ const tableProps = [
|
|||||||
prop: 'equipmentName',
|
prop: 'equipmentName',
|
||||||
label: '设备',
|
label: '设备',
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
prop: 'size',
|
// prop: 'size',
|
||||||
label: '规格',
|
// label: '规格',
|
||||||
showOverflowtooltip: true,
|
// showOverflowtooltip: true,
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
prop: 'process',
|
// prop: 'process',
|
||||||
label: '产品工艺',
|
// label: '产品工艺',
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
prop: 'standardCt',
|
prop: 'standardCt',
|
||||||
label: '标准节拍pcs/min',
|
label: '标准节拍pcs/min',
|
||||||
|
|||||||
@@ -72,16 +72,6 @@ export default {
|
|||||||
dateLabelList: [],
|
dateLabelList: [],
|
||||||
optionArrUrl: [getProductionLinePage],
|
optionArrUrl: [getProductionLinePage],
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
|
||||||
type: 'select',
|
|
||||||
label: '产线',
|
|
||||||
selectOptions: [],
|
|
||||||
param: 'lineIds',
|
|
||||||
defaultSelect: [],
|
|
||||||
multiple: true,
|
|
||||||
filterable: true,
|
|
||||||
width: 200,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'datePicker',
|
type: 'datePicker',
|
||||||
label: '时间',
|
label: '时间',
|
||||||
@@ -92,6 +82,16 @@ export default {
|
|||||||
startPlaceholder: '开始时间',
|
startPlaceholder: '开始时间',
|
||||||
endPlaceholder: '结束时间',
|
endPlaceholder: '结束时间',
|
||||||
param: 'time',
|
param: 'time',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'lineIds',
|
||||||
|
defaultSelect: [],
|
||||||
|
multiple: true,
|
||||||
|
filterable: true,
|
||||||
|
width: 300,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
@@ -113,7 +113,7 @@ export default {
|
|||||||
};
|
};
|
||||||
this.optionArrUrl.forEach((item, index) => {
|
this.optionArrUrl.forEach((item, index) => {
|
||||||
item(params).then((response) => {
|
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.formConfig[0].defaultSelect = response.data.list[0].id
|
||||||
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id)
|
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ export default {
|
|||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// select: true,
|
// select: true,
|
||||||
// label: '设备分组',
|
// label: '设备分组',
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export default {
|
|||||||
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||||
},
|
},
|
||||||
{ prop: 'name', label: '设备类型名称' },
|
{ prop: 'name', label: '设备类型名称' },
|
||||||
{ prop: 'code', label: '检测类型编码' },
|
{ prop: 'code', label: '设备类型编码' },
|
||||||
{ prop: 'remark', label: '备注' },
|
{ prop: 'remark', label: '备注' },
|
||||||
],
|
],
|
||||||
searchBarFormConfig: [
|
searchBarFormConfig: [
|
||||||
|
|||||||
@@ -66,16 +66,15 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="完成单位产品用时" prop="processTime">
|
<el-form-item label="完成单位产品用时(S)" prop="processTime">
|
||||||
<el-input :disabled="isdetail" v-model="dataForm.processTime" placeholder="请输入完成单位产品用时" />
|
<el-input :disabled="isdetail" v-model="dataForm.processTime" placeholder="请输入完成单位产品用时(S)" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label=" 加工属性" prop="processType">
|
<el-form-item label=" 产品工艺" prop="processType">
|
||||||
<el-select v-model="dataForm.processType" clearable style="width: 100%" :disabled="isdetail"
|
<el-select multiple v-model="dataForm.processType" clearable style="width: 100%" :disabled="isdetail"
|
||||||
placeholder="请选择加工属性">
|
placeholder="请选择产品工艺">
|
||||||
<el-option v-for="dict in processTypeList" :key="dict.id" :label="dict.label"
|
<el-option v-for="dict in processTypeList" :key="dict.id" :label="dict.label" :value="dict.id" />
|
||||||
:value="dict.id" />
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog v-loading="isLoading" loading-text="处理中..." loading-spinner="el-icon-loading"
|
||||||
:visible.sync="visible"
|
loading-background="rgba(255, 255, 255, 0.7)" :visible.sync="visible" :width="'35%'" :append-to-body="true"
|
||||||
:width="'35%'"
|
:close-on-click-modal="false" class="dialog">
|
||||||
:append-to-body="true"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
class="dialog">
|
|
||||||
<template #title>
|
<template #title>
|
||||||
<slot name="title">
|
<slot name="title">
|
||||||
<div class="titleStyle">
|
<div class="titleStyle">
|
||||||
@@ -13,29 +10,19 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-form
|
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="100px"
|
||||||
ref="dataForm"
|
|
||||||
:model="dataForm"
|
|
||||||
:rules="dataRule"
|
|
||||||
label-width="100px"
|
|
||||||
@keyup.enter.native="dataFormSubmit()">
|
@keyup.enter.native="dataFormSubmit()">
|
||||||
<el-form-item label="属性名" prop="name">
|
<el-form-item label="属性名" prop="name">
|
||||||
<el-input
|
<el-input v-model="dataForm.name" placeholder="请输入属性名" clearable />
|
||||||
v-model="dataForm.name"
|
|
||||||
placeholder="请输入属性名"
|
|
||||||
clearable />
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="属性值" prop="value">
|
<el-form-item label="属性值" prop="value">
|
||||||
<el-input
|
<el-input v-model="dataForm.value" placeholder="请输入属性值" clearable />
|
||||||
v-model="dataForm.value"
|
|
||||||
placeholder="请输入属性值"
|
|
||||||
clearable />
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row style="text-align: right">
|
<el-row style="text-align: right">
|
||||||
<el-button @click="visible = false">取消</el-button>
|
<el-button @click="visible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
<el-button :loading="isLoading" type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -57,6 +44,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
isLoading: false,
|
||||||
dataForm: {
|
dataForm: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: '',
|
name: '',
|
||||||
@@ -78,54 +66,69 @@ export default {
|
|||||||
const { name, value } = res.data;
|
const { name, value } = res.data;
|
||||||
this.dataForm.name = name;
|
this.dataForm.name = name;
|
||||||
this.dataForm.value = value;
|
this.dataForm.value = value;
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('获取属性详情失败:', err);
|
||||||
|
this.$modal.msgError('获取数据失败,请重试');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 表单提交
|
// 表单提交(优化加载状态和错误处理)
|
||||||
dataFormSubmit() {
|
async dataFormSubmit() {
|
||||||
this.$refs['dataForm'].validate((valid) => {
|
// 先验证表单
|
||||||
if (valid) {
|
const valid = await new Promise((resolve) => {
|
||||||
// 修改的提交
|
this.$refs['dataForm'].validate((isValid) => resolve(isValid));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
|
this.isLoading = true; // 开始加载
|
||||||
|
|
||||||
|
try {
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
updateProductAttr({
|
// 编辑操作
|
||||||
|
await updateProductAttr({
|
||||||
...this.dataForm,
|
...this.dataForm,
|
||||||
productId: this.productId,
|
productId: this.productId,
|
||||||
}).then((response) => {
|
});
|
||||||
this.$modal.msgSuccess('修改成功');
|
this.$modal.msgSuccess('修改成功');
|
||||||
this.visible = false;
|
} else {
|
||||||
this.$emit('refreshDataList');
|
// 新增操作
|
||||||
});
|
await createProductAttr({
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 添加的提交
|
|
||||||
createProductAttr({
|
|
||||||
...this.dataForm,
|
...this.dataForm,
|
||||||
productId: this.productId,
|
productId: this.productId,
|
||||||
}).then((response) => {
|
});
|
||||||
this.$modal.msgSuccess('新增成功');
|
this.$modal.msgSuccess('新增成功');
|
||||||
|
}
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.$emit('refreshDataList');
|
this.$emit('refreshDataList');
|
||||||
});
|
} catch (error) {
|
||||||
|
// 错误处理
|
||||||
|
console.error('提交失败:', error);
|
||||||
|
this.$modal.msgError('操作失败,请重试');
|
||||||
|
} finally {
|
||||||
|
// 无论成功失败,都关闭加载状态
|
||||||
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.dialog >>> .el-dialog__body {
|
.dialog>>>.el-dialog__body {
|
||||||
padding: 30px 24px;
|
padding: 30px 24px;
|
||||||
}
|
}
|
||||||
.dialog >>> .el-dialog__header {
|
|
||||||
|
.dialog>>>.el-dialog__header {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: rgba(0, 0, 0, 0.85);
|
color: rgba(0, 0, 0, 0.85);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
padding: 13px 24px;
|
padding: 13px 24px;
|
||||||
border-bottom: 1px solid #e9e9e9;
|
border-bottom: 1px solid #e9e9e9;
|
||||||
}
|
}
|
||||||
.dialog >>> .el-dialog__header .titleStyle::before {
|
|
||||||
|
.dialog>>>.el-dialog__header .titleStyle::before {
|
||||||
content: '';
|
content: '';
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 4px;
|
width: 4px;
|
||||||
|
|||||||
@@ -262,6 +262,14 @@ export default {
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
valueFormatter: (value) => `${value} %`,
|
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),
|
data: this.barData.map((item) => item.processingRatio),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
|
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
|
||||||
<el-tab-pane :label="'全部数据'" name="table">
|
<el-tab-pane :label="'全部数据'" name="table">
|
||||||
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == '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>
|
||||||
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
||||||
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="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-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick">
|
||||||
<el-tab-pane :label="'全部数据'" name="table">
|
<el-tab-pane :label="'全部数据'" name="table">
|
||||||
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == '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>
|
||||||
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
||||||
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
|
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
|
||||||
@@ -71,9 +71,55 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</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) -->
|
<!-- 3.2 时间维度为“自定义”时的内容(两个平分高度的div) -->
|
||||||
<div class="content-inner" v-else>
|
<div class="content-inner" v-if="listQuery.timeType === 2">
|
||||||
<div class="content-card energyOverlimitLog">
|
<div class="content-card energyOverlimitLog">
|
||||||
<span class="blue-block"></span>
|
<span class="blue-block"></span>
|
||||||
<span class="tip" v-if="listQuery.startTime && listQuery.endTime">
|
<span class="tip" v-if="listQuery.startTime && listQuery.endTime">
|
||||||
@@ -86,7 +132,7 @@
|
|||||||
<span class="tip" v-else>生产表格数据 </span>
|
<span class="tip" v-else>生产表格数据 </span>
|
||||||
<div class="graph">
|
<div class="graph">
|
||||||
<base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -113,7 +159,7 @@
|
|||||||
<span class="tip">当班数据</span>
|
<span class="tip">当班数据</span>
|
||||||
<base-table-s ref="productCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
|
<base-table-s ref="productCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
|
||||||
:page="1" :limit="100" :table-props="productTableProps" :table-data="productTableData"
|
:page="1" :limit="100" :table-props="productTableProps" :table-data="productTableData"
|
||||||
:max-height="210" />
|
:max-height="300" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 当天数据(占1/2剩余高度) -->
|
<!-- 当天数据(占1/2剩余高度) -->
|
||||||
@@ -122,7 +168,7 @@
|
|||||||
<span class="tip">当天数据</span>
|
<span class="tip">当天数据</span>
|
||||||
<base-table-s ref="productTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
|
<base-table-s ref="productTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
|
||||||
:page="1" :limit="100" :table-props="productTablePropsDay" :table-data="productTableDataDay"
|
:page="1" :limit="100" :table-props="productTablePropsDay" :table-data="productTableDataDay"
|
||||||
:max-height="210" />
|
:max-height="300" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -142,7 +188,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="tip" v-else>生产表格数据 </span>
|
<span class="tip" v-else>生产表格数据 </span>
|
||||||
<base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,7 +200,7 @@
|
|||||||
import { parseTime } from '@/filter/code-filter';
|
import { parseTime } from '@/filter/code-filter';
|
||||||
import {
|
import {
|
||||||
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto,
|
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto,
|
||||||
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew
|
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup
|
||||||
} from '@/api/core/monitoring/auto';
|
} from '@/api/core/monitoring/auto';
|
||||||
import { getFactoryPage } from '@/api/core/base/factory';
|
import { getFactoryPage } from '@/api/core/base/factory';
|
||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
@@ -165,11 +211,11 @@ import ButtonNav from '@/components/ButtonNav';
|
|||||||
import { listData } from '@/api/system/dict/data';
|
import { listData } from '@/api/system/dict/data';
|
||||||
// 表格列配置
|
// 表格列配置
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
// {
|
{
|
||||||
// prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
// label: '工厂',
|
label: '工厂',
|
||||||
// fixed: true
|
fixed: true
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
prop: 'lineName',
|
prop: 'lineName',
|
||||||
label: '产线',
|
label: '产线',
|
||||||
@@ -368,15 +414,27 @@ export default {
|
|||||||
productTableDataDay: [],
|
productTableDataDay: [],
|
||||||
tableDataCustom: [],
|
tableDataCustom: [],
|
||||||
list: [], // 折线图数据
|
list: [], // 折线图数据
|
||||||
|
timeTypeOptions: {
|
||||||
|
productLine: [ // 按产线监控(包含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
],
|
||||||
|
product: [ // 按产品监控(不含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' }
|
||||||
|
]
|
||||||
|
},
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '时间维度',
|
label: '时间维度',
|
||||||
selectOptions: [
|
selectOptions: [
|
||||||
{ id: 1, name: '当天' },
|
{ id: 1, name: '当天' },
|
||||||
{ id: 2, name: '自定义' }
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
],
|
],
|
||||||
width: 80,
|
width: 100,
|
||||||
onchange: true,
|
onchange: true,
|
||||||
// defaultSelect: 1,
|
// defaultSelect: 1,
|
||||||
clearable: false,
|
clearable: false,
|
||||||
@@ -437,6 +495,7 @@ export default {
|
|||||||
{ id: 3, name: '月' },
|
{ id: 3, name: '月' },
|
||||||
{ id: 4, name: '年' }
|
{ id: 4, name: '年' }
|
||||||
],
|
],
|
||||||
|
onchange: true,
|
||||||
width: 80,
|
width: 80,
|
||||||
param: 'reportType'
|
param: 'reportType'
|
||||||
},
|
},
|
||||||
@@ -467,6 +526,13 @@ export default {
|
|||||||
productTableProps() {
|
productTableProps() {
|
||||||
// 当班数据的完整表头(基础列 + 当班动态表头)
|
// 当班数据的完整表头(基础列 + 当班动态表头)
|
||||||
const baseColumns = [
|
const baseColumns = [
|
||||||
|
{
|
||||||
|
prop: 'sizes',
|
||||||
|
label: '规格',
|
||||||
|
width: 105,
|
||||||
|
showOverflowtooltip: true,
|
||||||
|
fixed: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prop: 'process',
|
prop: 'process',
|
||||||
label: '产品工艺',
|
label: '产品工艺',
|
||||||
@@ -476,7 +542,8 @@ export default {
|
|||||||
prop: 'processType',
|
prop: 'processType',
|
||||||
label: '产品类型',
|
label: '产品类型',
|
||||||
filter: (val) => (val != 1 ? '面板' : '背板'),
|
filter: (val) => (val != 1 ? '面板' : '背板'),
|
||||||
fixed: true
|
fixed: true,
|
||||||
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
@@ -513,13 +580,16 @@ export default {
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.$refs.buttonNav) {
|
if (this.$refs.buttonNav) {
|
||||||
this.$refs.buttonNav.currentMenu = '按产线监控';
|
this.$refs.buttonNav.currentMenu = '按产线监控';
|
||||||
|
this.formConfig[0].selectOptions = this.timeTypeOptions.productLine;
|
||||||
}
|
}
|
||||||
if (this.$refs.searchBarForm) {
|
if (this.$refs.searchBarForm) {
|
||||||
// this.$refs.searchBarForm.formInline.timeVal = [
|
// this.$refs.searchBarForm.formInline.timeVal = [
|
||||||
// yesterday.getTime(),
|
// yesterday.getTime(),
|
||||||
// end.getTime()
|
// end.getTime()
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
this.$refs.searchBarForm.formInline.timeType = 1
|
this.$refs.searchBarForm.formInline.timeType = 1
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -576,18 +646,26 @@ export default {
|
|||||||
|
|
||||||
// 3. 执行公共重置
|
// 3. 执行公共重置
|
||||||
resetCommon();
|
resetCommon();
|
||||||
|
// if (this.activeName === 'productLine') {
|
||||||
|
// } else {
|
||||||
|
// }
|
||||||
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
|
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
|
||||||
if (isProductLine) {
|
if (isProductLine) {
|
||||||
// 按产线监控:显示产线,隐藏产品工艺和类型
|
// 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班
|
||||||
|
this.formConfig[0].selectOptions = this.timeTypeOptions.productLine; // 恢复上一班选项
|
||||||
this.formConfig[3].type = 'select'; // 显示产线
|
this.formConfig[3].type = 'select'; // 显示产线
|
||||||
this.formConfig[4].type = ''; // 隐藏产品工艺
|
this.formConfig[4].type = ''; // 隐藏产品工艺
|
||||||
this.formConfig[5].type = ''; // 隐藏产品类型
|
this.formConfig[5].type = ''; // 隐藏产品类型
|
||||||
|
this.getDayDataList();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 按产品监控:显示产品工艺和类型,隐藏产线
|
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
|
||||||
|
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
|
||||||
this.formConfig[3].type = ''; // 隐藏产线
|
this.formConfig[3].type = ''; // 隐藏产线
|
||||||
this.formConfig[4].type = 'select'; // 显示产品工艺
|
this.formConfig[4].type = 'select'; // 显示产品工艺
|
||||||
this.formConfig[5].type = 'select'; // 显示产品类型
|
this.formConfig[5].type = 'select'; // 显示产品类型
|
||||||
|
this.getProductList();
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -601,6 +679,12 @@ export default {
|
|||||||
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
||||||
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
||||||
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
|
} else if (this.listQuery.timeType === 1) {
|
||||||
|
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
|
this.exportMultipleTables([
|
||||||
|
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
|
||||||
|
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
||||||
|
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
} else {
|
} else {
|
||||||
// 产线-自定义:导出一个表格(自定义文件名)
|
// 产线-自定义:导出一个表格(自定义文件名)
|
||||||
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
||||||
@@ -801,11 +885,48 @@ export default {
|
|||||||
this.formConfig[2].selectOptions = res.data.list || [];
|
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) {
|
buttonClick(val) {
|
||||||
switch (val.btnName) {
|
if (this.activeName === 'productLine') {
|
||||||
case 'search':
|
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageSize = 10;
|
||||||
this.listQuery.factoryId = val.factoryId || undefined;
|
this.listQuery.factoryId = val.factoryId || undefined;
|
||||||
@@ -815,17 +936,75 @@ export default {
|
|||||||
this.listQuery.reportType = val.reportType || undefined;
|
this.listQuery.reportType = val.reportType || undefined;
|
||||||
this.listQuery.timeType = val.timeType || undefined;
|
this.listQuery.timeType = val.timeType || undefined;
|
||||||
this.listQuery.searchType = val.searchType || 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;
|
// 处理不同时间选择类型
|
||||||
|
if (val.timeVal) {
|
||||||
|
this.listQuery.startTime = val.timeVal[0];
|
||||||
|
this.listQuery.endTime = val.timeVal[1];
|
||||||
|
} else if (val.timeValWeek) {
|
||||||
|
// 周选择器
|
||||||
|
const { startTime, endTime } = this.getWeekTimeRange(val.timeValWeek);
|
||||||
|
this.listQuery.startTime = startTime;
|
||||||
|
this.listQuery.endTime = endTime;
|
||||||
|
} else if (val.timeValMonth) {
|
||||||
|
// 月选择器
|
||||||
|
this.listQuery.startTime = val.timeValMonth[0];
|
||||||
|
this.listQuery.endTime = val.timeValMonth[1];
|
||||||
|
} else if (val.timeValYear) {
|
||||||
|
// 年选择器
|
||||||
|
const { startTime, endTime } = this.getYearTimeRange(val.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 = val.factoryId || []
|
||||||
|
this.listQuery.process = val.process ? val.process : [];
|
||||||
|
this.listQuery.lineId = undefined;
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 处理不同时间选择类型
|
||||||
|
if (val.timeVal) {
|
||||||
|
this.listQuery.startTime = val.timeVal[0];
|
||||||
|
this.listQuery.endTime = val.timeVal[1];
|
||||||
|
} else if (val.timeValWeek) {
|
||||||
|
// 周选择器
|
||||||
|
const { startTime, endTime } = this.getWeekTimeRange(val.timeValWeek);
|
||||||
|
this.listQuery.startTime = startTime;
|
||||||
|
this.listQuery.endTime = endTime;
|
||||||
|
} else if (val.timeValMonth) {
|
||||||
|
// 月选择器
|
||||||
|
this.listQuery.startTime = val.timeValMonth[0];
|
||||||
|
this.listQuery.endTime = val.timeValMonth[1];
|
||||||
|
} else if (val.timeValYear) {
|
||||||
|
// 年选择器
|
||||||
|
const { startTime, endTime } = this.getYearTimeRange(val.timeValYear);
|
||||||
|
this.listQuery.startTime = startTime;
|
||||||
|
this.listQuery.endTime = endTime;
|
||||||
|
} else {
|
||||||
|
this.listQuery.startTime = undefined;
|
||||||
|
this.listQuery.endTime = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (val.btnName) {
|
||||||
|
case 'search':
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
this.getDayDataList();
|
this.getDayDataList();
|
||||||
|
} else if (this.listQuery.timeType === 3) {
|
||||||
|
this.getLastDayDataList();
|
||||||
} else {
|
} else {
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.getProductList();
|
this.getProductList();
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
@@ -834,6 +1013,9 @@ export default {
|
|||||||
case 'reset':
|
case 'reset':
|
||||||
this.$refs.searchBarForm.resetForm();
|
this.$refs.searchBarForm.resetForm();
|
||||||
this.$refs.searchBarForm.formInline.timeType = 1;
|
this.$refs.searchBarForm.formInline.timeType = 1;
|
||||||
|
this.formConfig[0].selectOptions = this.activeName === 'productLine'
|
||||||
|
? this.timeTypeOptions.productLine
|
||||||
|
: this.timeTypeOptions.product;
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
@@ -842,12 +1024,9 @@ export default {
|
|||||||
};
|
};
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
this.getDayDataList();
|
this.getDayDataList();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.getProductList();
|
this.getProductList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(val);
|
console.log(val);
|
||||||
@@ -1097,6 +1276,28 @@ export default {
|
|||||||
return [...lineColumns, totalColumn];
|
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() {
|
getDayDataList() {
|
||||||
getPdlAutoReportNewSearchNow().then((response) => {
|
getPdlAutoReportNewSearchNow().then((response) => {
|
||||||
this.tableData = response.data.classData.map((item, index) => {
|
this.tableData = response.data.classData.map((item, index) => {
|
||||||
@@ -1156,24 +1357,21 @@ export default {
|
|||||||
console.log(value);
|
console.log(value);
|
||||||
|
|
||||||
this.listQuery.timeType = value;
|
this.listQuery.timeType = value;
|
||||||
if (value === 1) {
|
if (value === 2) {
|
||||||
// 切换为“当天”:隐藏查询类型、报表类型、时间范围
|
// 切换为“自定义”:显示查询类型和时间范围
|
||||||
|
this.formConfig[1].type = 'select';
|
||||||
|
this.$refs.searchBarForm.formInline.timeType = value;
|
||||||
|
this.listQuery.timeType = value;
|
||||||
|
this.formConfig[7].type = 'datePicker';
|
||||||
|
} else {
|
||||||
this.formConfig[1].type = '';
|
this.formConfig[1].type = '';
|
||||||
this.formConfig[6].type = '';
|
this.formConfig[6].type = '';
|
||||||
this.formConfig[7].type = '';
|
this.formConfig[7].type = '';
|
||||||
this.$refs.searchBarForm.formInline.timeType = value;
|
this.$refs.searchBarForm.formInline.timeType = value;
|
||||||
this.listQuery.timeType = value;
|
this.listQuery.timeType = value;
|
||||||
|
|
||||||
this.$refs.searchBarForm.formInline.searchType = undefined;
|
this.$refs.searchBarForm.formInline.searchType = undefined;
|
||||||
this.$refs.searchBarForm.formInline.reportType = undefined;
|
this.$refs.searchBarForm.formInline.reportType = undefined;
|
||||||
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
||||||
} else {
|
|
||||||
// 切换为“自定义”:显示查询类型和时间范围
|
|
||||||
this.formConfig[1].type = 'select';
|
|
||||||
this.$refs.searchBarForm.formInline.timeType = value;
|
|
||||||
this.listQuery.timeType = value;
|
|
||||||
|
|
||||||
this.formConfig[7].type = 'datePicker';
|
|
||||||
}
|
}
|
||||||
} else if (param === 'searchType') {
|
} else if (param === 'searchType') {
|
||||||
if (value === 1) {
|
if (value === 1) {
|
||||||
@@ -1187,7 +1385,74 @@ export default {
|
|||||||
this.formConfig[7].type = 'datePicker';
|
this.formConfig[7].type = 'datePicker';
|
||||||
}
|
}
|
||||||
} else if (param === 'reportType') {
|
} 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-MM-dd',
|
||||||
|
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') {
|
} else if (param === 'factoryId') {
|
||||||
// 切换工厂时刷新产线列表
|
// 切换工厂时刷新产线列表
|
||||||
this.listQuery.lineId = [];
|
this.listQuery.lineId = [];
|
||||||
@@ -1234,7 +1499,7 @@ export default {
|
|||||||
.content-wrapper {
|
.content-wrapper {
|
||||||
// flex: 1;
|
// flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100vh - 303px);
|
height: calc(100vh - 280px);
|
||||||
// overflow: hidden;
|
// overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const tableProps = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'palletNum',
|
prop: 'palletNum',
|
||||||
label: '下片托数'
|
label: '一托玻璃数量/片'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'startTime',
|
prop: 'startTime',
|
||||||
@@ -92,7 +92,7 @@ const tableProps = [
|
|||||||
width: 160
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'outputNum',
|
prop: 'length',
|
||||||
label: '玻璃长度/mm'
|
label: '玻璃长度/mm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -314,9 +314,10 @@ export default {
|
|||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageSize = 10;
|
||||||
this.listQuery.productId = val.productId ? val.productId : undefined;
|
this.listQuery.productionLineId = val.productionLineId ? val.productionLineId : undefined;
|
||||||
this.listQuery.startTime = val.timeVal ? val.timeVal[0]: undefined;
|
this.listQuery.thick = val.thick ? val.thick : undefined;
|
||||||
this.listQuery.endTime = val.timeVal ? val.timeVal[1]: 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.listQuery.reportEndTime = val.timeVal ? [new Date(val.timeVal[1]).getTime()] : undefined;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const tableProps = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'palletNum',
|
prop: 'palletNum',
|
||||||
label: '下片托数'
|
label: '一托玻璃数量/片'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'startTime',
|
prop: 'startTime',
|
||||||
@@ -92,7 +92,7 @@ const tableProps = [
|
|||||||
width: 160
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'outputNum',
|
prop: 'length',
|
||||||
label: '玻璃长度/mm'
|
label: '玻璃长度/mm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -262,6 +262,14 @@ export default {
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
valueFormatter: (value) => `${value} %`,
|
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),
|
data: this.barData.map((item) => item.processingRatio),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
|
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
|
||||||
<el-tab-pane :label="'全部数据'" name="table">
|
<el-tab-pane :label="'全部数据'" name="table">
|
||||||
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == '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>
|
||||||
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
||||||
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="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-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick">
|
||||||
<el-tab-pane :label="'全部数据'" name="table">
|
<el-tab-pane :label="'全部数据'" name="table">
|
||||||
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == '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>
|
||||||
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
|
||||||
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
|
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
|
||||||
@@ -71,9 +71,55 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</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) -->
|
<!-- 3.2 时间维度为“自定义”时的内容(两个平分高度的div) -->
|
||||||
<div class="content-inner" v-else>
|
<div class="content-inner" v-if="listQuery.timeType === 2">
|
||||||
<div class="content-card energyOverlimitLog">
|
<div class="content-card energyOverlimitLog">
|
||||||
<span class="blue-block"></span>
|
<span class="blue-block"></span>
|
||||||
<span class="tip" v-if="listQuery.startTime && listQuery.endTime">
|
<span class="tip" v-if="listQuery.startTime && listQuery.endTime">
|
||||||
@@ -86,7 +132,7 @@
|
|||||||
<span class="tip" v-else>生产表格数据 </span>
|
<span class="tip" v-else>生产表格数据 </span>
|
||||||
<div class="graph">
|
<div class="graph">
|
||||||
<base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -113,7 +159,7 @@
|
|||||||
<span class="tip">当班数据</span>
|
<span class="tip">当班数据</span>
|
||||||
<base-table-s ref="productCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
|
<base-table-s ref="productCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
|
||||||
:page="1" :limit="100" :table-props="productTableProps" :table-data="productTableData"
|
:page="1" :limit="100" :table-props="productTableProps" :table-data="productTableData"
|
||||||
:max-height="210" />
|
:max-height="300" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 当天数据(占1/2剩余高度) -->
|
<!-- 当天数据(占1/2剩余高度) -->
|
||||||
@@ -122,7 +168,7 @@
|
|||||||
<span class="tip">当天数据</span>
|
<span class="tip">当天数据</span>
|
||||||
<base-table-s ref="productTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
|
<base-table-s ref="productTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
|
||||||
:page="1" :limit="100" :table-props="productTablePropsDay" :table-data="productTableDataDay"
|
:page="1" :limit="100" :table-props="productTablePropsDay" :table-data="productTableDataDay"
|
||||||
:max-height="210" />
|
:max-height="300" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -142,7 +188,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="tip" v-else>生产表格数据 </span>
|
<span class="tip" v-else>生产表格数据 </span>
|
||||||
<base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,7 +200,7 @@
|
|||||||
import { parseTime } from '@/filter/code-filter';
|
import { parseTime } from '@/filter/code-filter';
|
||||||
import {
|
import {
|
||||||
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto,
|
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto,
|
||||||
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew
|
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup
|
||||||
} from '@/api/core/monitoring/auto';
|
} from '@/api/core/monitoring/auto';
|
||||||
import { getFactoryPage } from '@/api/core/base/factory';
|
import { getFactoryPage } from '@/api/core/base/factory';
|
||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
@@ -165,11 +211,11 @@ import ButtonNav from '@/components/ButtonNav';
|
|||||||
import { listData } from '@/api/system/dict/data';
|
import { listData } from '@/api/system/dict/data';
|
||||||
// 表格列配置
|
// 表格列配置
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
// {
|
{
|
||||||
// prop: 'factoryName',
|
prop: 'factoryName',
|
||||||
// label: '工厂',
|
label: '工厂',
|
||||||
// fixed: true
|
fixed: true
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
prop: 'lineName',
|
prop: 'lineName',
|
||||||
label: '产线',
|
label: '产线',
|
||||||
@@ -368,15 +414,27 @@ export default {
|
|||||||
productTableDataDay: [],
|
productTableDataDay: [],
|
||||||
tableDataCustom: [],
|
tableDataCustom: [],
|
||||||
list: [], // 折线图数据
|
list: [], // 折线图数据
|
||||||
|
timeTypeOptions: {
|
||||||
|
productLine: [ // 按产线监控(包含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
|
],
|
||||||
|
product: [ // 按产品监控(不含上一班)
|
||||||
|
{ id: 1, name: '当天' },
|
||||||
|
{ id: 2, name: '自定义' }
|
||||||
|
]
|
||||||
|
},
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '时间维度',
|
label: '时间维度',
|
||||||
selectOptions: [
|
selectOptions: [
|
||||||
{ id: 1, name: '当天' },
|
{ id: 1, name: '当天' },
|
||||||
{ id: 2, name: '自定义' }
|
{ id: 2, name: '自定义' },
|
||||||
|
{ id: 3, name: '上一班' }
|
||||||
],
|
],
|
||||||
width: 80,
|
width: 100,
|
||||||
onchange: true,
|
onchange: true,
|
||||||
// defaultSelect: 1,
|
// defaultSelect: 1,
|
||||||
clearable: false,
|
clearable: false,
|
||||||
@@ -438,6 +496,7 @@ export default {
|
|||||||
{ id: 4, name: '年' }
|
{ id: 4, name: '年' }
|
||||||
],
|
],
|
||||||
width: 80,
|
width: 80,
|
||||||
|
onchange: true,
|
||||||
param: 'reportType'
|
param: 'reportType'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -513,17 +572,20 @@ export default {
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.$refs.buttonNav) {
|
if (this.$refs.buttonNav) {
|
||||||
this.$refs.buttonNav.currentMenu = '按产品监控';
|
this.$refs.buttonNav.currentMenu = '按产品监控';
|
||||||
|
this.formConfig[0].selectOptions = this.timeTypeOptions.product;
|
||||||
}
|
}
|
||||||
if (this.$refs.searchBarForm) {
|
if (this.$refs.searchBarForm) {
|
||||||
// this.$refs.searchBarForm.formInline.timeVal = [
|
// this.$refs.searchBarForm.formInline.timeVal = [
|
||||||
// yesterday.getTime(),
|
// yesterday.getTime(),
|
||||||
// end.getTime()
|
// end.getTime()
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
this.$refs.searchBarForm.formInline.timeType = 1
|
this.$refs.searchBarForm.formInline.timeType = 1
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getProductList();
|
this.getDayDataList();
|
||||||
this.getPdLineList();
|
this.getPdLineList();
|
||||||
const queryParams = {
|
const queryParams = {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
@@ -579,15 +641,21 @@ export default {
|
|||||||
|
|
||||||
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
|
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
|
||||||
if (isProductLine) {
|
if (isProductLine) {
|
||||||
// 按产线监控:显示产线,隐藏产品工艺和类型
|
// 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班
|
||||||
|
this.formConfig[0].selectOptions = this.timeTypeOptions.productLine; // 恢复上一班选项
|
||||||
this.formConfig[3].type = 'select'; // 显示产线
|
this.formConfig[3].type = 'select'; // 显示产线
|
||||||
this.formConfig[4].type = ''; // 隐藏产品工艺
|
this.formConfig[4].type = ''; // 隐藏产品工艺
|
||||||
this.formConfig[5].type = ''; // 隐藏产品类型
|
this.formConfig[5].type = ''; // 隐藏产品类型
|
||||||
|
this.getDayDataList();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 按产品监控:显示产品工艺和类型,隐藏产线
|
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
|
||||||
|
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
|
||||||
this.formConfig[3].type = ''; // 隐藏产线
|
this.formConfig[3].type = ''; // 隐藏产线
|
||||||
this.formConfig[4].type = 'select'; // 显示产品工艺
|
this.formConfig[4].type = 'select'; // 显示产品工艺
|
||||||
this.formConfig[5].type = 'select'; // 显示产品类型
|
this.formConfig[5].type = 'select'; // 显示产品类型
|
||||||
|
this.getProductList();
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -596,48 +664,52 @@ export default {
|
|||||||
// 按产线监控
|
// 按产线监控
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
// 产线-当天:导出当班 + 当天两个表格
|
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
this.exportMultipleTables([
|
this.exportMultipleTables([
|
||||||
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
|
||||||
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
||||||
]);
|
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
|
} else if (this.listQuery.timeType === 1) {
|
||||||
|
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
|
this.exportMultipleTables([
|
||||||
|
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
|
||||||
|
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
|
||||||
|
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
} else {
|
} else {
|
||||||
// 产线-自定义:导出一个表格
|
// 产线-自定义:导出一个表格(自定义文件名)
|
||||||
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 按产品监控
|
// 按产品监控
|
||||||
else {
|
else {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
// 产品-当天:导出当班 + 当天两个表格
|
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
|
||||||
this.exportMultipleTables([
|
this.exportMultipleTables([
|
||||||
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
|
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
|
||||||
{ ref: 'productTodayTable', name: '产品监控_当天数据' }
|
{ ref: 'productTodayTable', name: '产品监控_当天数据' }
|
||||||
]);
|
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
|
||||||
} else {
|
} else {
|
||||||
// 产品-自定义:导出一个表格
|
// 产品-自定义:导出一个表格(自定义文件名)
|
||||||
this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
|
this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出单个表格
|
// 导出单个表格(保持原有逻辑,文件名由调用方传入,已区分不同场景)
|
||||||
exportSingleTable(refName, fileName) {
|
exportSingleTable(refName, fileName) {
|
||||||
const table = this.getTableDom(refName);
|
const table = this.getTableDom(refName);
|
||||||
if (!table) return;
|
if (!table) return;
|
||||||
|
|
||||||
// 克隆表格并移除固定列
|
|
||||||
const clonedTable = table.cloneNode(true);
|
const clonedTable = table.cloneNode(true);
|
||||||
this.removeFixedColumns(clonedTable);
|
this.adjustTableForExport(clonedTable);
|
||||||
|
|
||||||
// 转换为工作簿并导出
|
|
||||||
const workbook = XLSX.utils.table_to_book(clonedTable);
|
const workbook = XLSX.utils.table_to_book(clonedTable);
|
||||||
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
|
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
|
||||||
XLSX.writeFile(workbook, fullName);
|
XLSX.writeFile(workbook, fullName);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出多个表格(同一个Excel的不同sheet)
|
// 导出多个表格(新增自定义汇总文件名参数,适配不同选项卡)
|
||||||
exportMultipleTables(tables) {
|
exportMultipleTables(tables, customSummaryName) {
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
let hasValidTable = false;
|
let hasValidTable = false;
|
||||||
|
|
||||||
@@ -646,11 +718,9 @@ export default {
|
|||||||
if (!table) return;
|
if (!table) return;
|
||||||
|
|
||||||
hasValidTable = true;
|
hasValidTable = true;
|
||||||
// 克隆表格并移除固定列
|
|
||||||
const clonedTable = table.cloneNode(true);
|
const clonedTable = table.cloneNode(true);
|
||||||
this.removeFixedColumns(clonedTable);
|
this.adjustTableForExport(clonedTable);
|
||||||
|
|
||||||
// 转换为sheet并添加到工作簿
|
|
||||||
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
|
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, name);
|
XLSX.utils.book_append_sheet(workbook, worksheet, name);
|
||||||
});
|
});
|
||||||
@@ -660,31 +730,128 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出包含多个sheet的Excel
|
// 动态生成汇总文件名:自定义名称 + 日期
|
||||||
const fullName = `生产监控数据汇总_${this.formatDate()}.xlsx`;
|
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
|
||||||
XLSX.writeFile(workbook, fullName);
|
XLSX.writeFile(workbook, fullName);
|
||||||
},
|
},
|
||||||
|
// 辅助方法:获取表格DOM元素(包含表头)
|
||||||
// 辅助方法:获取表格DOM元素
|
|
||||||
getTableDom(refName) {
|
getTableDom(refName) {
|
||||||
const tableComponent = this.$refs[refName];
|
const tableComponent = this.$refs[refName];
|
||||||
if (!tableComponent) {
|
if (!tableComponent) {
|
||||||
this.$message.warning(`未找到${refName}表格`);
|
this.$message.warning(`未找到${refName}表格`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 获取表格组件内部的el-table DOM
|
// 获取完整表格容器(包含表头和表体)
|
||||||
const tableDom = tableComponent.$el.querySelector('.el-table__body-wrapper table');
|
const tableContainer = tableComponent.$el.querySelector('.el-table');
|
||||||
if (!tableDom) {
|
if (!tableContainer) {
|
||||||
this.$message.warning(`${refName}表格数据为空`);
|
this.$message.warning(`${refName}表格数据为空`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return tableDom;
|
return tableContainer;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 辅助方法:移除固定列(避免重复导出)
|
// 重点修复:调整表格结构(解决表头重复问题)
|
||||||
removeFixedColumns(table) {
|
adjustTableForExport(tableContainer) {
|
||||||
const fixedColumns = table.querySelectorAll('.el-table__fixed, .el-table__fixed-right');
|
// 1. 移除空表格提示和分页等无关元素
|
||||||
fixedColumns.forEach(col => col.remove());
|
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 +865,6 @@ export default {
|
|||||||
String(date.getMinutes()).padStart(2, '0')
|
String(date.getMinutes()).padStart(2, '0')
|
||||||
].join('');
|
].join('');
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取产线和工厂列表
|
// 获取产线和工厂列表
|
||||||
getPdLineList() {
|
getPdLineList() {
|
||||||
getPdList().then(res => {
|
getPdList().then(res => {
|
||||||
@@ -712,8 +878,7 @@ export default {
|
|||||||
|
|
||||||
// 搜索/导出按钮点击
|
// 搜索/导出按钮点击
|
||||||
buttonClick(val) {
|
buttonClick(val) {
|
||||||
switch (val.btnName) {
|
if (this.activeName === 'productLine') {
|
||||||
case 'search':
|
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageSize = 10;
|
||||||
this.listQuery.factoryId = val.factoryId || undefined;
|
this.listQuery.factoryId = val.factoryId || undefined;
|
||||||
@@ -723,17 +888,75 @@ export default {
|
|||||||
this.listQuery.reportType = val.reportType || undefined;
|
this.listQuery.reportType = val.reportType || undefined;
|
||||||
this.listQuery.timeType = val.timeType || undefined;
|
this.listQuery.timeType = val.timeType || undefined;
|
||||||
this.listQuery.searchType = val.searchType || 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;
|
// 处理不同时间选择类型
|
||||||
|
if (val.timeVal) {
|
||||||
|
this.listQuery.startTime = val.timeVal[0];
|
||||||
|
this.listQuery.endTime = val.timeVal[1];
|
||||||
|
} else if (val.timeValWeek) {
|
||||||
|
// 周选择器
|
||||||
|
const { startTime, endTime } = this.getWeekTimeRange(val.timeValWeek);
|
||||||
|
this.listQuery.startTime = startTime;
|
||||||
|
this.listQuery.endTime = endTime;
|
||||||
|
} else if (val.timeValMonth) {
|
||||||
|
// 月选择器
|
||||||
|
this.listQuery.startTime = val.timeValMonth[0];
|
||||||
|
this.listQuery.endTime = val.timeValMonth[1];
|
||||||
|
} else if (val.timeValYear) {
|
||||||
|
// 年选择器
|
||||||
|
const { startTime, endTime } = this.getYearTimeRange(val.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 = val.factoryId || []
|
||||||
|
this.listQuery.process = val.process ? val.process : [];
|
||||||
|
this.listQuery.lineId = undefined;
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 处理不同时间选择类型
|
||||||
|
if (val.timeVal) {
|
||||||
|
this.listQuery.startTime = val.timeVal[0];
|
||||||
|
this.listQuery.endTime = val.timeVal[1];
|
||||||
|
} else if (val.timeValWeek) {
|
||||||
|
// 周选择器
|
||||||
|
const { startTime, endTime } = this.getWeekTimeRange(val.timeValWeek);
|
||||||
|
this.listQuery.startTime = startTime;
|
||||||
|
this.listQuery.endTime = endTime;
|
||||||
|
} else if (val.timeValMonth) {
|
||||||
|
// 月选择器
|
||||||
|
this.listQuery.startTime = val.timeValMonth[0];
|
||||||
|
this.listQuery.endTime = val.timeValMonth[1];
|
||||||
|
} else if (val.timeValYear) {
|
||||||
|
// 年选择器
|
||||||
|
const { startTime, endTime } = this.getYearTimeRange(val.timeValYear);
|
||||||
|
this.listQuery.startTime = startTime;
|
||||||
|
this.listQuery.endTime = endTime;
|
||||||
|
} else {
|
||||||
|
this.listQuery.startTime = undefined;
|
||||||
|
this.listQuery.endTime = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (val.btnName) {
|
||||||
|
case 'search':
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
this.getDayDataList();
|
this.getDayDataList();
|
||||||
|
} else if (this.listQuery.timeType === 3) {
|
||||||
|
this.getLastDayDataList();
|
||||||
} else {
|
} else {
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.getProductList();
|
this.getProductList();
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
@@ -742,6 +965,9 @@ export default {
|
|||||||
case 'reset':
|
case 'reset':
|
||||||
this.$refs.searchBarForm.resetForm();
|
this.$refs.searchBarForm.resetForm();
|
||||||
this.$refs.searchBarForm.formInline.timeType = 1;
|
this.$refs.searchBarForm.formInline.timeType = 1;
|
||||||
|
this.formConfig[0].selectOptions = this.activeName === 'productLine'
|
||||||
|
? this.timeTypeOptions.productLine
|
||||||
|
: this.timeTypeOptions.product;
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
@@ -750,12 +976,9 @@ export default {
|
|||||||
};
|
};
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
this.getDayDataList();
|
this.getDayDataList();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.getProductList();
|
this.getProductList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(val);
|
console.log(val);
|
||||||
@@ -763,7 +986,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getDataList() {
|
getDataList() {
|
||||||
if(!this.listQuery.startTime &&!this.listQuery.endTime ){
|
if (!this.listQuery.startTime && !this.listQuery.endTime) {
|
||||||
return this.$modal.msgError('请选择时间');
|
return this.$modal.msgError('请选择时间');
|
||||||
}
|
}
|
||||||
this.dataListLoading = true;
|
this.dataListLoading = true;
|
||||||
@@ -798,7 +1021,7 @@ export default {
|
|||||||
console.log('resGroup');
|
console.log('resGroup');
|
||||||
if (this.listQuery.timeType === 2) {
|
if (this.listQuery.timeType === 2) {
|
||||||
const resGroup = await getProcessAutoReportNew(this.listQuery);
|
const resGroup = await getProcessAutoReportNew(this.listQuery);
|
||||||
console.log('resGroup',resGroup);
|
console.log('resGroup', resGroup);
|
||||||
|
|
||||||
// 格式化数据:lineDetList提取到外层,键名加lineId前缀
|
// 格式化数据:lineDetList提取到外层,键名加lineId前缀
|
||||||
const formatData = (rawList) => {
|
const formatData = (rawList) => {
|
||||||
@@ -827,7 +1050,7 @@ export default {
|
|||||||
|
|
||||||
// 处理当班和当天数据(分别存储)
|
// 处理当班和当天数据(分别存储)
|
||||||
this.productTableData = formatData(resGroup.data.list); // 当班数据
|
this.productTableData = formatData(resGroup.data.list); // 当班数据
|
||||||
console.log(this.productTableData,'productTableData');
|
console.log(this.productTableData, 'productTableData');
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// 生成当班数据的动态表头
|
// 生成当班数据的动态表头
|
||||||
@@ -1005,6 +1228,28 @@ export default {
|
|||||||
return [...lineColumns, totalColumn];
|
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() {
|
getDayDataList() {
|
||||||
getPdlAutoReportNewSearchNow().then((response) => {
|
getPdlAutoReportNewSearchNow().then((response) => {
|
||||||
this.tableData = response.data.classData.map((item, index) => {
|
this.tableData = response.data.classData.map((item, index) => {
|
||||||
@@ -1060,28 +1305,26 @@ export default {
|
|||||||
|
|
||||||
// 搜索栏下拉选择变化
|
// 搜索栏下拉选择变化
|
||||||
handleSearchBarChanged({ param, value }) {
|
handleSearchBarChanged({ param, value }) {
|
||||||
|
console.log(value, param);
|
||||||
if (param === 'timeType') {
|
if (param === 'timeType') {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
|
|
||||||
this.listQuery.timeType = value;
|
this.listQuery.timeType = value;
|
||||||
if (value === 1) {
|
if (value === 2) {
|
||||||
// 切换为“当天”:隐藏查询类型、报表类型、时间范围
|
// 切换为“自定义”:显示查询类型和时间范围
|
||||||
|
this.formConfig[1].type = 'select';
|
||||||
|
this.$refs.searchBarForm.formInline.timeType = value;
|
||||||
|
this.listQuery.timeType = value;
|
||||||
|
this.formConfig[7].type = 'datePicker';
|
||||||
|
} else {
|
||||||
this.formConfig[1].type = '';
|
this.formConfig[1].type = '';
|
||||||
this.formConfig[6].type = '';
|
this.formConfig[6].type = '';
|
||||||
this.formConfig[7].type = '';
|
this.formConfig[7].type = '';
|
||||||
this.$refs.searchBarForm.formInline.timeType = value;
|
this.$refs.searchBarForm.formInline.timeType = value;
|
||||||
this.listQuery.timeType = value;
|
this.listQuery.timeType = value;
|
||||||
|
|
||||||
this.$refs.searchBarForm.formInline.searchType = undefined;
|
this.$refs.searchBarForm.formInline.searchType = undefined;
|
||||||
this.$refs.searchBarForm.formInline.reportType = undefined;
|
this.$refs.searchBarForm.formInline.reportType = undefined;
|
||||||
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
||||||
} else {
|
|
||||||
// 切换为“自定义”:显示查询类型和时间范围
|
|
||||||
this.formConfig[1].type = 'select';
|
|
||||||
this.$refs.searchBarForm.formInline.timeType = value;
|
|
||||||
this.listQuery.timeType = value;
|
|
||||||
|
|
||||||
this.formConfig[7].type = 'datePicker';
|
|
||||||
}
|
}
|
||||||
} else if (param === 'searchType') {
|
} else if (param === 'searchType') {
|
||||||
if (value === 1) {
|
if (value === 1) {
|
||||||
@@ -1095,7 +1338,74 @@ export default {
|
|||||||
this.formConfig[7].type = 'datePicker';
|
this.formConfig[7].type = 'datePicker';
|
||||||
}
|
}
|
||||||
} else if (param === 'reportType') {
|
} 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-MM-dd',
|
||||||
|
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') {
|
} else if (param === 'factoryId') {
|
||||||
// 切换工厂时刷新产线列表
|
// 切换工厂时刷新产线列表
|
||||||
this.listQuery.lineId = [];
|
this.listQuery.lineId = [];
|
||||||
@@ -1142,7 +1452,7 @@ export default {
|
|||||||
.content-wrapper {
|
.content-wrapper {
|
||||||
// flex: 1;
|
// flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100vh - 303px);
|
height: calc(100vh - 280px);
|
||||||
// overflow: hidden;
|
// overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<!-- :isFold="true" 控制展开 -->
|
<!-- :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"
|
<base-table v-if="tableData.length" class="right-aside" v-loading="dataListLoading" :table-props="tableProps"
|
||||||
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
|
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
|
||||||
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
|
<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>
|
<div v-else class="no-data-bg"></div>
|
||||||
<pagination :limit.sync="listQuery.pageSize" :page.sync="listQuery.pageNo" :total="listQuery.total"
|
<pagination :limit.sync="listQuery.pageSize" :page.sync="listQuery.pageNo" :total="listQuery.total"
|
||||||
@pagination="getDataList" />
|
@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" />
|
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Vue from 'vue';
|
||||||
import AddOrUpdate from './add-or-updata';
|
import AddOrUpdate from './add-or-updata';
|
||||||
|
|
||||||
import { parseTime } from '../../mixins/code-filter';
|
import { parseTime } from '../../mixins/code-filter';
|
||||||
import { getCostOriginRadioHisData, getPdList } from '@/api/core/monitoring/index'
|
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 { exportCostOriginRadioHisData } from '../../../../api/core/monitoring';
|
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',
|
prop: 'reportType',
|
||||||
label: '报表类型'
|
label: '报表类型'
|
||||||
@@ -52,7 +59,6 @@ const tableProps = [
|
|||||||
{
|
{
|
||||||
prop: 'time',
|
prop: 'time',
|
||||||
label: '日期',
|
label: '日期',
|
||||||
// filter: parseTime,
|
|
||||||
width: 160
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -81,10 +87,72 @@ const tableProps = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'ratio',
|
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:59(Date 对象)
|
||||||
|
*/
|
||||||
|
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:59(Date 对象)
|
||||||
|
*/
|
||||||
|
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:ss(Vue2 兼容)
|
||||||
|
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 {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
AddOrUpdate
|
AddOrUpdate
|
||||||
@@ -101,8 +169,10 @@ export default {
|
|||||||
total: 1,
|
total: 1,
|
||||||
bindObjectId: undefined,
|
bindObjectId: undefined,
|
||||||
statisticType: undefined,
|
statisticType: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined
|
||||||
},
|
},
|
||||||
pdLineList:[],
|
pdLineList: [],
|
||||||
exportLoading: false,
|
exportLoading: false,
|
||||||
dataListLoading: false,
|
dataListLoading: false,
|
||||||
selectedList: [],
|
selectedList: [],
|
||||||
@@ -115,36 +185,104 @@ export default {
|
|||||||
type: 'edit',
|
type: 'edit',
|
||||||
btnName: '编辑',
|
btnName: '编辑',
|
||||||
},
|
},
|
||||||
].filter((v) => v),
|
].filter(v => v),
|
||||||
tableData: [],
|
|
||||||
fileName: '',
|
fileName: '',
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '维度',
|
label: '报表类型',
|
||||||
|
onchange: true,
|
||||||
selectOptions: [
|
selectOptions: [
|
||||||
{
|
{ id: '0', name: '班组' },
|
||||||
id: '0',
|
{ id: '1', name: '日' },
|
||||||
name:'班组'
|
{ id: '2', name: '周' },
|
||||||
},
|
{ id: '3', name: '月' },
|
||||||
{
|
{ id: '4', 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-MM-dd',
|
||||||
|
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',
|
type: 'select',
|
||||||
@@ -152,20 +290,6 @@ export default {
|
|||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'bindObjectId'
|
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',
|
type: 'button',
|
||||||
btnName: '查询',
|
btnName: '查询',
|
||||||
@@ -176,7 +300,6 @@ export default {
|
|||||||
type: 'separate',
|
type: 'separate',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// type: this.$auth.hasPermi('base:factory:export') ? 'button' : '',
|
|
||||||
type: 'button',
|
type: 'button',
|
||||||
btnName: '导出',
|
btnName: '导出',
|
||||||
name: 'export',
|
name: 'export',
|
||||||
@@ -185,97 +308,227 @@ export default {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
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() {
|
mounted() {
|
||||||
|
// Vue2 中 $refs 需在 $nextTick 中访问(确保 DOM 渲染完成)
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.searchBarForm) {
|
||||||
this.$refs.searchBarForm.formInline.statisticType = '1';
|
this.$refs.searchBarForm.formInline.statisticType = '1';
|
||||||
|
}
|
||||||
|
});
|
||||||
this.listQuery.statisticType = '1';
|
this.listQuery.statisticType = '1';
|
||||||
this.getDataList()
|
this.getDataList();
|
||||||
this.getPdLineList()
|
this.getPdLineList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
selectType(val) {
|
||||||
|
// 报表类型切换时的回调(如需扩展可在此添加逻辑)
|
||||||
|
console.log('报表类型切换:', val);
|
||||||
|
},
|
||||||
handleClick(val) {
|
handleClick(val) {
|
||||||
console.log(val);
|
console.log('操作按钮点击:', val);
|
||||||
if (val.type === 'edit') {
|
if (val.type === 'edit') {
|
||||||
this.addOrUpdateVisible= true
|
this.addOrUpdateVisible = true;
|
||||||
|
// Vue2 中 $nextTick 确保子组件已渲染
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdate.init(val.data);
|
this.$refs.addOrUpdate.init(val.data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getPdLineList() {
|
getPdLineList() {
|
||||||
getPdList().then((res) => {
|
getPdList().then(res => {
|
||||||
this.formConfig[1].selectOptions = res.data || []
|
// Vue2 中数组赋值需确保响应式
|
||||||
this.pdLineList = res.data || []; // 保存产线数据
|
this.$set(this.formConfig[1], 'selectOptions', res.data || []);
|
||||||
})
|
this.pdLineList = res.data || [];
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('获取产线列表失败:', err);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
selectChange(val) {
|
selectChange(val) {
|
||||||
console.log(val)
|
console.log('选择变更:', val);
|
||||||
this.selectedList = val
|
this.selectedList = val;
|
||||||
},
|
},
|
||||||
buttonClick(val) {
|
buttonClick(val) {
|
||||||
console.log('val', val);
|
console.log('头部按钮点击:', val);
|
||||||
|
|
||||||
switch (val.btnName) {
|
switch (val.btnName) {
|
||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageSize = 10;
|
||||||
this.listQuery.bindObjectId = val.bindObjectId ? val.bindObjectId : undefined;
|
this.listQuery.bindObjectId = val.bindObjectId ? val.bindObjectId : undefined;
|
||||||
this.listQuery.statisticType = val.statisticType ? val.statisticType : 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.handleTimeRange(val);
|
||||||
|
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
this.handleExport();
|
this.handleExport();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(val);
|
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() {
|
getDataList() {
|
||||||
this.dataListLoading = true;
|
this.dataListLoading = true;
|
||||||
this.urlOptions.getDataListURL(this.listQuery).then(response => {
|
this.urlOptions.getDataListURL(this.listQuery)
|
||||||
const arr = ['班组','日', '周', '月', '年'];
|
.then(response => {
|
||||||
this.tableData = response.data?.list?.map((item) => {
|
const arr = ['班组', '日', '周', '月', '年'];
|
||||||
item.reportType = arr[this.listQuery.statisticType];
|
// Vue2 中数组赋值确保响应式
|
||||||
item.statisticType = this.listQuery.statisticType
|
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);
|
const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
|
||||||
item.bindObjectName = targetLine ? targetLine.name : ''; // 赋值名称,无匹配则为空
|
item.bindObjectName = targetLine ? targetLine.name : '';
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
this.listQuery.total = response.data.total;
|
this.listQuery.total = response.data?.total || 0;
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('获取数据失败:', err);
|
||||||
|
this.tableData = [];
|
||||||
|
this.listQuery.total = 0;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.dataListLoading = false;
|
this.dataListLoading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 每页数
|
// 每页数变更
|
||||||
sizeChangeHandle(val) {
|
sizeChangeHandle(val) {
|
||||||
this.listQuery.pageSize = val;
|
this.listQuery.pageSize = val;
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
// 当前页
|
// 当前页变更
|
||||||
currentChangeHandle(val) {
|
currentChangeHandle(val) {
|
||||||
this.listQuery.pageNo = val;
|
this.listQuery.pageNo = val;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
|
// 导出处理
|
||||||
handleExport() {
|
handleExport() {
|
||||||
// 处理查询参数
|
const params = { ...this.listQuery };
|
||||||
let params = { ...this.listQuery };
|
// 移除分页参数
|
||||||
params.pageNo = undefined;
|
delete params.pageNo;
|
||||||
params.pageSize = undefined;
|
delete params.pageSize;
|
||||||
this.$modal.confirm('是否确认导出原片报表?').then(() => {
|
delete params.total;
|
||||||
|
|
||||||
|
this.$modal.confirm('是否确认导出原片报表?')
|
||||||
|
.then(() => {
|
||||||
this.exportLoading = true;
|
this.exportLoading = true;
|
||||||
return exportCostOriginRadioHisData(params);
|
return exportCostOriginRadioHisData(params);
|
||||||
}).then(response => {
|
})
|
||||||
|
.then(response => {
|
||||||
this.$download.excel(response, '原片报表.xls');
|
this.$download.excel(response, '原片报表.xls');
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('导出失败:', err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.exportLoading = false;
|
this.exportLoading = false;
|
||||||
}).catch(() => { });
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// Vue2 中监听数据变化(如需)
|
||||||
|
watch: {
|
||||||
|
'listQuery.statisticType'(newVal) {
|
||||||
|
console.log('报表类型变更:', newVal);
|
||||||
|
// 可添加类型变更后的额外逻辑
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</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>
|
||||||
|
|||||||
274
src/views/core/monitoring/rawFilmReport/searchBar.vue
Normal 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>
|
||||||
@@ -40,7 +40,7 @@ $pxls: (xl, 28px) (lg, 24px) (de, 20px) (md, 18px) (sm, 16px);
|
|||||||
$mgr: 8px;
|
$mgr: 8px;
|
||||||
@each $size, $height in $pxls {
|
@each $size, $height in $pxls {
|
||||||
.#{$size}-title {
|
.#{$size}-title {
|
||||||
font-size: $height;
|
font-size: 18px;
|
||||||
line-height: $height;
|
line-height: $height;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
134
src/views/equipment/equipmentOverview/add-or-updata.vue
Normal 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 || undefined;
|
||||||
|
this.dataForm.equipmentName = data.equipmentName || undefined;
|
||||||
|
this.dataForm.lineId = data.lineId || undefined;
|
||||||
|
|
||||||
|
|
||||||
|
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>
|
||||||
498
src/views/equipment/equipmentOverview/alarm-or-updata.vue
Normal file
@@ -0,0 +1,498 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :visible.sync="visible" width="40%" @close="destroyAllCharts" 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">
|
||||||
|
<div v-show="activeLabel === 'duration'" id="barChart" style="width: 100%; height: 400px;"></div>
|
||||||
|
<!-- 报警次数-饼图 -->
|
||||||
|
<div v-show="activeLabel === 'times'" id="pieChart" style="width: 100%; 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';
|
||||||
|
// import { ElEmpty } from 'element-plus';
|
||||||
|
|
||||||
|
// 图表颜色配置(统一风格)
|
||||||
|
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: true, // 是否有数据标识
|
||||||
|
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', // 默认激活时长tab
|
||||||
|
dataForm: {
|
||||||
|
equipmentId: undefined,
|
||||||
|
equipmentName: undefined,
|
||||||
|
lineId: undefined
|
||||||
|
},
|
||||||
|
// 存储图表实例,用于销毁
|
||||||
|
chartInstances: {
|
||||||
|
bar: null,
|
||||||
|
pie: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 初始化默认日期(当天)
|
||||||
|
this.initDefaultDate();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 初始化默认日期(当天零点到23:59:59)
|
||||||
|
initDefaultDate() {
|
||||||
|
const today = new Date();
|
||||||
|
const start = new Date(today.setHours(0, 0, 0, 0)).getTime();
|
||||||
|
const end = new Date(today.setHours(23, 59, 59, 999)).getTime();
|
||||||
|
this.formConfig[0].defaultSelect = [start, end];
|
||||||
|
this.listQuery.startTime = start;
|
||||||
|
this.listQuery.endTime = end;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 切换Tab时加载对应图表
|
||||||
|
handleTabClick() {
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 搜索按钮点击事件
|
||||||
|
buttonClick(val) {
|
||||||
|
switch (val.btnName) {
|
||||||
|
case 'search':
|
||||||
|
this.listQuery.startTime = val.timeVal?.[0];
|
||||||
|
this.listQuery.endTime = val.timeVal?.[1];
|
||||||
|
this.getDataList();
|
||||||
|
break;
|
||||||
|
case 'link':
|
||||||
|
this.disabled = true;
|
||||||
|
this.connectSSEBatch(this.listQuery.equipmentIds);
|
||||||
|
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.hasData = originData.length > 0;
|
||||||
|
|
||||||
|
if (this.hasData) {
|
||||||
|
// 根据当前Tab渲染对应图表
|
||||||
|
this.activeLabel === 'duration'
|
||||||
|
? this.renderBarChart(originData)
|
||||||
|
: this.renderPieChart(originData);
|
||||||
|
} else {
|
||||||
|
// 无数据时销毁已有图表
|
||||||
|
this.destroyAllCharts();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取报警数据失败:', error);
|
||||||
|
this.hasData = false;
|
||||||
|
this.destroyAllCharts();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 渲染报警时长-柱状图
|
||||||
|
renderBarChart(originData) {
|
||||||
|
// 先销毁原有图表
|
||||||
|
this.destroyChart('chart');
|
||||||
|
|
||||||
|
// 按报警时长降序排序
|
||||||
|
const sortedData = [...originData].sort((a, b) => b.alarmDuration - a.alarmDuration);
|
||||||
|
|
||||||
|
// 处理图表数据
|
||||||
|
const xData = sortedData.map(item => this.truncateText(item.alarmContent, 8)); // 文本截断(最多8字)
|
||||||
|
const seriesData = sortedData.map(item => item.alarmDuration);
|
||||||
|
|
||||||
|
const chartDom = document.getElementById('barChart');
|
||||||
|
this.chartInstances.bar = echarts.init(chartDom);
|
||||||
|
|
||||||
|
const option = {
|
||||||
|
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>报警时长:${item.alarmDuration}</div>
|
||||||
|
<div>占比:${item.alarmDurationRatio.toFixed(2)}%</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '5%',
|
||||||
|
right: '5%',
|
||||||
|
bottom: '18%', // 底部留足空间显示x轴标签
|
||||||
|
top: '10%',
|
||||||
|
containLabel: true
|
||||||
|
},
|
||||||
|
xAxis: [
|
||||||
|
{
|
||||||
|
type: 'category',
|
||||||
|
data: xData,
|
||||||
|
axisTick: { alignWithLabel: true },
|
||||||
|
axisLabel: {
|
||||||
|
interval: 0,
|
||||||
|
// rotate: 35, // 标签旋转
|
||||||
|
fontSize: 12,
|
||||||
|
color: CHART_CONFIG.lightFontColor
|
||||||
|
},
|
||||||
|
axisLine: { lineStyle: { color: '#e8e8e8' } }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
axisLabel: {
|
||||||
|
fontSize: 11,
|
||||||
|
color: CHART_CONFIG.lightFontColor,
|
||||||
|
// formatter: '{value}s' // 显示单位
|
||||||
|
},
|
||||||
|
axisLine: { lineStyle: { color: '#e8e8e8' } },
|
||||||
|
splitLine: { lineStyle: { color: '#f5f5f5' } },
|
||||||
|
// 扩展y轴最大值,避免label超出
|
||||||
|
max: (value) => value.max * 1.2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '报警时长',
|
||||||
|
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);
|
||||||
|
// 监听窗口 resize
|
||||||
|
this.addResizeListener('bar');
|
||||||
|
},
|
||||||
|
|
||||||
|
// 渲染报警次数-饼图
|
||||||
|
renderPieChart(originData) {
|
||||||
|
// 先销毁原有图表
|
||||||
|
this.destroyChart('pie');
|
||||||
|
|
||||||
|
// 按报警次数降序排序
|
||||||
|
const sortedData = [...originData].sort((a, b) => b.alarmCount - a.alarmCount);
|
||||||
|
|
||||||
|
// 处理图表数据(合并占比过小的项为"其他")
|
||||||
|
const pieData = this.handlePieData(sortedData);
|
||||||
|
|
||||||
|
const chartDom = document.getElementById('pieChart');
|
||||||
|
this.chartInstances.pie = echarts.init(chartDom);
|
||||||
|
|
||||||
|
const option = {
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'item',
|
||||||
|
padding: 10,
|
||||||
|
textStyle: { fontSize: 11 },
|
||||||
|
formatter: (params) => {
|
||||||
|
return `
|
||||||
|
<div style="text-align: left;">
|
||||||
|
<div>${params.name}</div>
|
||||||
|
<div>报警次数:${params.value} 次</div>
|
||||||
|
<div>占比:${params.percent.toFixed(2)}%</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '报警次数',
|
||||||
|
type: 'pie',
|
||||||
|
radius: ['50%', '70%'], // 环形饼图
|
||||||
|
center: ['50%', '50%'], // 饼图居中显示
|
||||||
|
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); // 最多8字
|
||||||
|
return `${truncatedName}(${params.value}次, ${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,
|
||||||
|
// 高亮样式(hover时)
|
||||||
|
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);
|
||||||
|
// 监听窗口 resize
|
||||||
|
this.addResizeListener('pie');
|
||||||
|
},
|
||||||
|
// 处理饼图数据(合并占比<5%的项)
|
||||||
|
handlePieData(data) {
|
||||||
|
const threshold = 5; // 阈值:5%
|
||||||
|
let otherCount = 0;
|
||||||
|
const mainData = data.filter(item => {
|
||||||
|
if (item.alarmCountRatio >= threshold) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
otherCount += item.alarmCount;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).map(item => ({
|
||||||
|
name: item.alarmContent,
|
||||||
|
value: item.alarmCount,
|
||||||
|
ratio: item.alarmCountRatio
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 如果有"其他"项,添加到数据中
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 添加窗口resize监听
|
||||||
|
addResizeListener(type) {
|
||||||
|
const chart = this.chartInstances[type];
|
||||||
|
if (chart) {
|
||||||
|
const resizeHandler = () => chart.resize();
|
||||||
|
window.addEventListener('resize', resizeHandler);
|
||||||
|
// 存储resize处理器,用于后续移除
|
||||||
|
chart.resizeHandler = resizeHandler;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 销毁单个图表
|
||||||
|
destroyChart(type) {
|
||||||
|
const chart = this.chartInstances[type];
|
||||||
|
if (chart) {
|
||||||
|
// 移除resize监听
|
||||||
|
window.removeEventListener('resize', chart.resizeHandler);
|
||||||
|
chart.dispose();
|
||||||
|
this.chartInstances[type] = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 销毁所有图表
|
||||||
|
destroyAllCharts() {
|
||||||
|
Object.keys(this.chartInstances).forEach(type => {
|
||||||
|
this.destroyChart(type);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 初始化弹窗数据
|
||||||
|
init(data) {
|
||||||
|
this.dataForm = {
|
||||||
|
equipmentId: data.equipmentId || undefined,
|
||||||
|
equipmentName: data.equipmentName || '未知设备',
|
||||||
|
lineId: data.lineId || '未知产线'
|
||||||
|
};
|
||||||
|
this.listQuery.equipmentId = data.equipmentId || undefined;
|
||||||
|
this.visible = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
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;
|
||||||
|
/* 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>
|
||||||
1252
src/views/equipment/equipmentOverview/index.vue
Normal file
@@ -2,14 +2,14 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-23 13:43:55
|
* @Date: 2025-10-23 13:43:55
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-23 16:50:43
|
* @LastEditTime: 2025-11-14 21:13:10
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container" style="padding-top: 0">
|
||||||
<div v-for="item in groupClassArr" :key="item.planId">
|
<div v-for="item in groupClassArr" :key="item.planId">
|
||||||
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
|
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
|
||||||
{{item.planName}}
|
{{ item.deptName + ' - ' + item.planName }}
|
||||||
</small-title>
|
</small-title>
|
||||||
<base-table
|
<base-table
|
||||||
:table-props="tableProps"
|
:table-props="tableProps"
|
||||||
@@ -59,13 +59,14 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
init(det) {
|
init(det, detSort) {
|
||||||
this.tableData = det;
|
this.tableData = det;
|
||||||
//返回计划名和id
|
//返回计划名和id
|
||||||
const arr = det.map((item) => {
|
const arr = det.map((item) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
planName: item.schedulingPlanName,
|
planName: item.schedulingPlanName,
|
||||||
planId: item.schedulingPlanId,
|
planId: item.schedulingPlanId,
|
||||||
|
deptName: item.belongDeptName,
|
||||||
};
|
};
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
@@ -76,7 +77,19 @@ export default {
|
|||||||
map.set(item.planId, item);
|
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;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,13 +2,19 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-23 13:43:55
|
* @Date: 2025-10-23 13:43:55
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-24 11:14:55
|
* @LastEditTime: 2025-11-25 09:39:43
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<el-row :gutter="10" style="background-color: #f2f4f9">
|
<div
|
||||||
<!--部门数据-->
|
class="app-container"
|
||||||
<el-col :span="4">
|
style="
|
||||||
|
background-color: #f2f4f9;
|
||||||
|
padding: 0;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 5fr;
|
||||||
|
gap: 10px;
|
||||||
|
">
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
|
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
|
||||||
<el-tab-pane label="部门" name="first"></el-tab-pane>
|
<el-tab-pane label="部门" name="first"></el-tab-pane>
|
||||||
@@ -28,6 +34,7 @@
|
|||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
:filter-node-method="filterNode"
|
:filter-node-method="filterNode"
|
||||||
ref="tree"
|
ref="tree"
|
||||||
|
node-key="id"
|
||||||
default-expand-all
|
default-expand-all
|
||||||
highlight-current
|
highlight-current
|
||||||
@node-click="handleNodeClick" />
|
@node-click="handleNodeClick" />
|
||||||
@@ -46,13 +53,12 @@
|
|||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
:filter-node-method="filterNode"
|
:filter-node-method="filterNode"
|
||||||
ref="tree1"
|
ref="tree1"
|
||||||
|
node-key="id"
|
||||||
default-expand-all
|
default-expand-all
|
||||||
highlight-current
|
highlight-current
|
||||||
@node-click="handleNodeClick1" />
|
@node-click="handleNodeClick1" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
|
||||||
<el-col :span="20">
|
|
||||||
<div class="groupTeamScheduling">
|
<div class="groupTeamScheduling">
|
||||||
<div class="operationArea">
|
<div class="operationArea">
|
||||||
<el-form :inline="true" class="demo-form-inline">
|
<el-form :inline="true" class="demo-form-inline">
|
||||||
@@ -71,10 +77,15 @@
|
|||||||
v-if="activeName == 'first'">
|
v-if="activeName == 'first'">
|
||||||
提示:排班日历仅展示当前选中部门的节假日设置,若休假日中仍有排班,则表示下级组织已通过自定义假期进行排班。
|
提示:排班日历仅展示当前选中部门的节假日设置,若休假日中仍有排班,则表示下级组织已通过自定义假期进行排班。
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else style="margin-left: 10px">
|
||||||
组长:{{ showTeamName?.leaderName || '-' }} 组长电话:{{
|
组长:
|
||||||
showTeamName?.leaderPhone || '-'
|
<span style="font-weight: 600; margin: 0 10px">
|
||||||
}}
|
{{ showTeamName?.leaderName || '-' }}
|
||||||
|
</span>
|
||||||
|
组长电话:
|
||||||
|
<span style="font-weight: 600; margin: 0 10px">
|
||||||
|
{{ showTeamName?.leaderPhone || '-' }}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item style="float: right">
|
<el-form-item style="float: right">
|
||||||
@@ -128,9 +139,7 @@
|
|||||||
effect="dark"
|
effect="dark"
|
||||||
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
|
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
|
||||||
placement="top">
|
placement="top">
|
||||||
<i
|
<i class="el-icon-warning" style="color: #f56c6c"></i>
|
||||||
class="el-icon-warning"
|
|
||||||
style="color: #f56c6c"></i>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -159,15 +168,16 @@
|
|||||||
<div
|
<div
|
||||||
class="holiday-div"
|
class="holiday-div"
|
||||||
:style="{
|
:style="{
|
||||||
backgroundColor:
|
backgroundColor: holidayDivColor[item?.classesCode],
|
||||||
holidayDivColor[item?.classesCode],
|
|
||||||
}"
|
}"
|
||||||
@click="
|
@click="
|
||||||
holidayLog(
|
holidayLog(
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
?.det,
|
?.det,
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
?.date
|
?.date,
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
|
?.detSort
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
:title="
|
:title="
|
||||||
@@ -207,7 +217,6 @@
|
|||||||
</el-calendar>
|
</el-calendar>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
|
||||||
<base-dialog
|
<base-dialog
|
||||||
:dialogTitle="dialogTitle"
|
:dialogTitle="dialogTitle"
|
||||||
:dialogVisible="logVisible"
|
:dialogVisible="logVisible"
|
||||||
@@ -228,7 +237,7 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</base-dialog>
|
</base-dialog>
|
||||||
</el-row>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -339,13 +348,43 @@ export default {
|
|||||||
getEnableData().then((response) => {
|
getEnableData().then((response) => {
|
||||||
// 处理 deptOptions 参数
|
// 处理 deptOptions 参数
|
||||||
this.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) => {
|
listByDeptId(this.topDept.id).then((response) => {
|
||||||
this.groupOptions = [];
|
this.groupOptions = [];
|
||||||
this.groupOptions.push(...response.data);
|
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) {
|
filterNode(value, data) {
|
||||||
if (!value) return true;
|
if (!value) return true;
|
||||||
@@ -358,8 +397,14 @@ export default {
|
|||||||
leaderName: this.groupOptions[0].leaderName || '-',
|
leaderName: this.groupOptions[0].leaderName || '-',
|
||||||
leaderPhone: this.groupOptions[0].leaderPhone || '-',
|
leaderPhone: this.groupOptions[0].leaderPhone || '-',
|
||||||
};
|
};
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.tree1.setCurrentKey(this.teamId);
|
||||||
|
});
|
||||||
} else if (this.activeName == 'first') {
|
} else if (this.activeName == 'first') {
|
||||||
this.deptId = this.topDept.id;
|
this.deptId = this.topDept.id;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.tree.setCurrentKey(this.deptId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.getHolidayPage();
|
this.getHolidayPage();
|
||||||
},
|
},
|
||||||
@@ -441,11 +486,11 @@ export default {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
holidayLog(det, date) {
|
holidayLog(det, date, detSort) {
|
||||||
this.dialogTitle = this.showDeptName + '-' + date + '-排班详情';
|
this.dialogTitle = this.showDeptName + '-' + date + '-排班详情';
|
||||||
this.logVisible = true;
|
this.logVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.holidayLogRef.init(det);
|
this.$refs.holidayLogRef.init(det, detSort);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelLog() {
|
cancelLog() {
|
||||||
@@ -459,8 +504,8 @@ export default {
|
|||||||
.head-container {
|
.head-container {
|
||||||
padding: 20px 10px 0;
|
padding: 20px 10px 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
min-height: calc(100vh - 120px - 8px);
|
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
.groupTeamScheduling {
|
.groupTeamScheduling {
|
||||||
.operationArea {
|
.operationArea {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-11 14:27:37
|
* @Date: 2025-10-11 14:27:37
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-29 17:12:04
|
* @LastEditTime: 2025-11-14 22:00:10
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listByDeptId } from '@/api/group/Schedule';
|
import { getGroupPage } from '@/api/group/groupSetting';
|
||||||
|
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ const tableProps = [
|
|||||||
width: 100,
|
width: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'deptId',
|
prop: 'deptName',
|
||||||
label: '所属部门',
|
label: '所属部门',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
urlOptions: {
|
urlOptions: {
|
||||||
getDataListURL: listByDeptId,
|
getDataListURL: getGroupPage,
|
||||||
},
|
},
|
||||||
tableProps,
|
tableProps,
|
||||||
tableData: [],
|
tableData: [],
|
||||||
@@ -86,16 +86,16 @@ export default {
|
|||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
code: '',
|
code: '',
|
||||||
name: '',
|
name: '',
|
||||||
|
deptId: undefined,
|
||||||
},
|
},
|
||||||
selectedList: [],
|
selectedList: [],
|
||||||
selectedArr: [], //已选的班组,从父组件传过来的
|
selectedArr: [], //已选的班组,从父组件传过来的
|
||||||
deptId: undefined,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
init(id, tableData) {
|
init(id, tableData) {
|
||||||
this.deptId = id;
|
this.formInline.deptId = id;
|
||||||
this.selectedArr = tableData || [];
|
this.selectedArr = tableData || [];
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
@@ -103,8 +103,9 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.urlOptions.getDataListURL(this.deptId).then((response) => {
|
this.urlOptions.getDataListURL(this.formInline).then((response) => {
|
||||||
this.tableData = response.data;
|
this.tableData = response.data.list.filter(item=>item.enabled===1);
|
||||||
|
this.tableData.forEach(item=>item.teamId= item.id)
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.selectedArr.length > 0) {
|
if (this.selectedArr.length > 0) {
|
||||||
this.setSelectedRows();
|
this.setSelectedRows();
|
||||||
@@ -119,12 +120,12 @@ export default {
|
|||||||
table.clearSelection();
|
table.clearSelection();
|
||||||
|
|
||||||
this.selectedArr.forEach((item) => {
|
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) {
|
if (rowInTable) {
|
||||||
//这里一定要用table.tableData,这样才是指向同一个数组
|
//这里一定要用table.tableData,这样才是指向同一个数组
|
||||||
this.$set(table.store.states, 'selection', [
|
this.$set(table.store.states, 'selection', [
|
||||||
...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) {
|
selectChange(val) {
|
||||||
this.selectedList = val;
|
this.selectedList = val;
|
||||||
},
|
},
|
||||||
// 判断两个数组是否有重复的 id
|
// 判断两个数组是否有重复的 id,去重
|
||||||
hasDuplicateIds(arr1, arr2) {
|
hasDuplicateIds(arr1, arr2) {
|
||||||
const idSet = new Set(arr1.map((item) => item.id));
|
return arr2.filter(
|
||||||
return arr2.some((item) => idSet.has(item.id));
|
(item2) => !arr1.some((item1) => item1.teamId === item2.teamId)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
dataFormSubmit() {
|
dataFormSubmit() {
|
||||||
if (this.selectedList && this.selectedList.length > 0) {
|
if (this.selectedList && this.selectedList.length > 0) {
|
||||||
const haveData = this.hasDuplicateIds(
|
this.selectedList = this.hasDuplicateIds(
|
||||||
this.selectedArr,
|
this.selectedArr,
|
||||||
this.selectedList
|
this.selectedList
|
||||||
);
|
);
|
||||||
if (haveData) {
|
|
||||||
this.$message('请不要重复添加数组');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$emit('refreshTableData', this.selectedList);
|
this.$emit('refreshTableData', this.selectedList);
|
||||||
} else if (this.selectedArr.length > 0) {
|
} else if (this.selectedArr.length > 0) {
|
||||||
this.$message('请不要重复添加数组');
|
this.$message('请不要重复添加数组');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-13 15:07:24
|
* @Date: 2025-10-13 15:07:24
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-29 15:28:52
|
* @LastEditTime: 2025-12-01 14:40:46
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -54,10 +54,11 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="部门">
|
<el-form-item label="部门" prop="deptId">
|
||||||
<dept-select
|
<dept-select
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
ref="deptSelect"
|
ref="deptSelect"
|
||||||
|
v-model="dataForm.deptId"
|
||||||
@DeptId="setDeptId"></dept-select>
|
@DeptId="setDeptId"></dept-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -111,7 +112,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</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-form-item label="同班次连排" prop="shiftSustainedNum">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="dataForm.shiftSustainedNum"
|
v-model="dataForm.shiftSustainedNum"
|
||||||
@@ -134,6 +135,18 @@
|
|||||||
<div v-if="stepNum == 2">
|
<div v-if="stepNum == 2">
|
||||||
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
|
<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>
|
</small-title>
|
||||||
<base-table
|
<base-table
|
||||||
:table-props="tableProps1"
|
:table-props="tableProps1"
|
||||||
@@ -150,6 +163,12 @@
|
|||||||
</base-table>
|
</base-table>
|
||||||
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
|
<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>
|
</small-title>
|
||||||
<base-table
|
<base-table
|
||||||
:table-props="tableProps2"
|
:table-props="tableProps2"
|
||||||
@@ -157,6 +176,7 @@
|
|||||||
:limit="10"
|
:limit="10"
|
||||||
:table-data="tableData2"
|
:table-data="tableData2"
|
||||||
:add-button-show="'新增'"
|
:add-button-show="'新增'"
|
||||||
|
@emitFun="handleSort"
|
||||||
@emitButtonClick="addNewGroup">
|
@emitButtonClick="addNewGroup">
|
||||||
<method-btn
|
<method-btn
|
||||||
v-if="tableBtn2.length"
|
v-if="tableBtn2.length"
|
||||||
@@ -174,8 +194,7 @@
|
|||||||
:no-padding="true">
|
:no-padding="true">
|
||||||
排班计划预览
|
排班计划预览
|
||||||
<span style="font-size: 14px; color: #ff1c15">
|
<span style="font-size: 14px; color: #ff1c15">
|
||||||
系统将根据以下设置,按班组轮班顺序依次循环每日班次,生成正式排班计划,请确认。
|
系统将根据
|
||||||
|
|
||||||
<el-popover
|
<el-popover
|
||||||
placement="right"
|
placement="right"
|
||||||
title="比如三班两倒,同班次连排2天,不休周末排班如下"
|
title="比如三班两倒,同班次连排2天,不休周末排班如下"
|
||||||
@@ -192,9 +211,10 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
<i
|
<i
|
||||||
slot="reference"
|
slot="reference"
|
||||||
class="el-icon-warning-outline"
|
class="el-icon-chat-dot-square"
|
||||||
style="color: #ff1c15"></i>
|
style="color: #409eff; font-size: 18px"></i>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
|
设置,按班组轮班顺序依次循环每日班次,生成正式排班计划,请确认。
|
||||||
</span>
|
</span>
|
||||||
</small-title>
|
</small-title>
|
||||||
<el-tag>
|
<el-tag>
|
||||||
@@ -227,7 +247,7 @@
|
|||||||
<div style="color: rgba(0, 0, 0, 0.6)">同班次连排</div>
|
<div style="color: rgba(0, 0, 0, 0.6)">同班次连排</div>
|
||||||
<div style="color: #000000">
|
<div style="color: #000000">
|
||||||
{{
|
{{
|
||||||
dataForm.shiftSustainedNum +
|
(dataForm.shiftSustainedNum ? dataForm.shiftSustainedNum : '') +
|
||||||
['日', '周', '月', '季'][dataForm.shiftSustainedType - 1]
|
['日', '周', '月', '季'][dataForm.shiftSustainedType - 1]
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
@@ -335,6 +355,7 @@ import { parseTime } from '@/filter/code-filter';
|
|||||||
import editClass from './edit-class.vue';
|
import editClass from './edit-class.vue';
|
||||||
import addGroup from './add-group.vue';
|
import addGroup from './add-group.vue';
|
||||||
import bindLine from './bind-line.vue';
|
import bindLine from './bind-line.vue';
|
||||||
|
import sortSet from './sortSet.vue';
|
||||||
import {
|
import {
|
||||||
getCode,
|
getCode,
|
||||||
createStepOne,
|
createStepOne,
|
||||||
@@ -374,10 +395,17 @@ const tableProps1 = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const tableProps2 = [
|
const tableProps2 = [
|
||||||
|
{
|
||||||
|
prop: 'shunxu',
|
||||||
|
label: '顺序',
|
||||||
|
width: 70,
|
||||||
|
subcomponent: sortSet,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prop: 'code',
|
prop: 'code',
|
||||||
label: '班组编号',
|
label: '班组编号',
|
||||||
width: 140,
|
width: 140,
|
||||||
|
showOverflowtooltip: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'name',
|
prop: 'name',
|
||||||
@@ -422,6 +450,7 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
stepNum: 1, // 当前第几步
|
stepNum: 1, // 当前第几步
|
||||||
|
isEdit: false, //是否是编辑状态,编辑的时候,让前端上一步和取消都不用接口
|
||||||
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType,到第二步,判断dataForm.shiftType是否改变,同时改变班次信息
|
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType,到第二步,判断dataForm.shiftType是否改变,同时改变班次信息
|
||||||
//第一步参数
|
//第一步参数
|
||||||
dataForm: {
|
dataForm: {
|
||||||
@@ -476,6 +505,7 @@ export default {
|
|||||||
name: [
|
name: [
|
||||||
{ required: true, message: '计划名称不能为空', trigger: 'blur' },
|
{ required: true, message: '计划名称不能为空', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
|
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
|
||||||
startDay: [
|
startDay: [
|
||||||
{ required: true, message: '开始时间不能为空', trigger: 'change' },
|
{ required: true, message: '开始时间不能为空', trigger: 'change' },
|
||||||
],
|
],
|
||||||
@@ -508,6 +538,8 @@ export default {
|
|||||||
btnName: '编辑',
|
btnName: '编辑',
|
||||||
},
|
},
|
||||||
].filter((v) => v),
|
].filter((v) => v),
|
||||||
|
isClassTimePass: true, //修改班次时间后,需要判断时间是否有重叠,且是否在24小时内 true是没问题的
|
||||||
|
covers24Hours: true, //修改班次时间后,需要判断时间是否覆盖24小时连续的时间 true是没问题的
|
||||||
tableData1: [],
|
tableData1: [],
|
||||||
tableProps2,
|
tableProps2,
|
||||||
tableBtn2: [
|
tableBtn2: [
|
||||||
@@ -597,8 +629,9 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init(id) {
|
init(id, isEdit) {
|
||||||
this.dataForm.id = id || undefined;
|
this.dataForm.id = id || undefined;
|
||||||
|
this.isEdit = isEdit || false;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs['dataForm'].resetFields();
|
this.$refs['dataForm'].resetFields();
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
@@ -609,14 +642,18 @@ export default {
|
|||||||
this.tableData1 = res.data?.stepTwo.groupPlanClassesBaseVOList;
|
this.tableData1 = res.data?.stepTwo.groupPlanClassesBaseVOList;
|
||||||
this.tableData2 = res.data?.stepTwo.groupPlanTeamBaseVOList;
|
this.tableData2 = res.data?.stepTwo.groupPlanTeamBaseVOList;
|
||||||
this.tableData2.forEach((item, index) => {
|
this.tableData2.forEach((item, index) => {
|
||||||
let lineName = '';
|
let lineName = [];
|
||||||
lineName = this.setLineName(item.bindLineTree, lineName);
|
if (item.isProduction) {
|
||||||
|
lineName = this.setLineName(item.bindLineTree);
|
||||||
this.$set(
|
this.$set(
|
||||||
this.tableData2[index],
|
this.tableData2[index],
|
||||||
'lineName',
|
'lineName',
|
||||||
lineName.slice(0, -1)
|
lineName.join(';')
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
this.stepNum = 3;
|
||||||
|
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getCode().then((res) => {
|
getCode().then((res) => {
|
||||||
@@ -628,6 +665,8 @@ export default {
|
|||||||
//上一步
|
//上一步
|
||||||
upSubmit() {
|
upSubmit() {
|
||||||
if (this.stepNum == 2) {
|
if (this.stepNum == 2) {
|
||||||
|
if (!this.isEdit) {
|
||||||
|
//编辑的时候,让前端上一步和取消都不用接口,
|
||||||
returnStepOne(this.dataForm.id).then((res) => {
|
returnStepOne(this.dataForm.id).then((res) => {
|
||||||
this.stepNum -= 1;
|
this.stepNum -= 1;
|
||||||
this.$emit('setSN', this.stepNum);
|
this.$emit('setSN', this.stepNum);
|
||||||
@@ -635,11 +674,24 @@ export default {
|
|||||||
this.setDataForm();
|
this.setDataForm();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.stepNum -= 1;
|
||||||
|
this.$emit('setSN', this.stepNum);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.setDataForm();
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (this.stepNum == 3) {
|
} else if (this.stepNum == 3) {
|
||||||
|
if (!this.dataForm.id) {
|
||||||
|
//编辑的时候,让前端上一步和取消都不用接口,
|
||||||
returnStepTwo(this.dataForm.id).then((res) => {
|
returnStepTwo(this.dataForm.id).then((res) => {
|
||||||
this.stepNum -= 1;
|
this.stepNum -= 1;
|
||||||
this.$emit('setSN', this.stepNum);
|
this.$emit('setSN', this.stepNum);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.stepNum -= 1;
|
||||||
|
this.$emit('setSN', this.stepNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//下一步
|
//下一步
|
||||||
@@ -654,9 +706,12 @@ export default {
|
|||||||
this.$message('部门不能为空');
|
this.$message('部门不能为空');
|
||||||
return;
|
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('开始时间不能大于结束时间');
|
this.$message('开始时间不能大于结束时间');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -677,6 +732,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.stepNum == 2) {
|
if (this.stepNum == 2) {
|
||||||
|
//班组验证
|
||||||
if (!this.tableData2 || this.tableData2.length == 0) {
|
if (!this.tableData2 || this.tableData2.length == 0) {
|
||||||
this.$message('班组不能为空');
|
this.$message('班组不能为空');
|
||||||
return;
|
return;
|
||||||
@@ -684,7 +740,10 @@ export default {
|
|||||||
|
|
||||||
let isbindLine = false;
|
let isbindLine = false;
|
||||||
this.tableData2.forEach((item) => {
|
this.tableData2.forEach((item) => {
|
||||||
if (!item.bindLineTree || item.bindLineTree.length == 0) {
|
if (
|
||||||
|
item.isProduction &&
|
||||||
|
(!item.bindLineTree || item.bindLineTree.length == 0)
|
||||||
|
) {
|
||||||
isbindLine = true;
|
isbindLine = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -711,6 +770,11 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//班次验证
|
||||||
|
if (!this.isClassTimePass || !this.covers24Hours) {
|
||||||
|
this.$message('班次内时间有误,请重新填写!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
let data = {};
|
let data = {};
|
||||||
data.planId = this.dataForm.id;
|
data.planId = this.dataForm.id;
|
||||||
data.groupPlanClassesBaseVOList = []; //排班-班次信息list
|
data.groupPlanClassesBaseVOList = []; //排班-班次信息list
|
||||||
@@ -722,24 +786,30 @@ export default {
|
|||||||
startTime: item.startTime,
|
startTime: item.startTime,
|
||||||
endTime: item.endTime,
|
endTime: item.endTime,
|
||||||
daySpan: item.daySpan,
|
daySpan: item.daySpan,
|
||||||
|
code: item.code,
|
||||||
};
|
};
|
||||||
data.groupPlanClassesBaseVOList.push(obj);
|
data.groupPlanClassesBaseVOList.push(obj);
|
||||||
});
|
});
|
||||||
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
||||||
this.tableData2.forEach((item) => {
|
this.tableData2.forEach((item, index) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
teamId: item.id,
|
sort: index + 1,
|
||||||
|
teamId: item.teamId || item.id,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
leaderName: item.leaderName,
|
leaderName: item.leaderName,
|
||||||
leaderPhone:item.leaderPhone,
|
leaderPhone: item.leaderPhone,
|
||||||
bindData: JSON.stringify(item.bindLineTree),
|
bindData: JSON.stringify(item.bindLineTree),
|
||||||
};
|
};
|
||||||
data.groupPlanTeamBaseVOList.push(obj);
|
data.groupPlanTeamBaseVOList.push(obj);
|
||||||
});
|
});
|
||||||
createStepTwo(data).then((res) => {
|
createStepTwo(data).then((res) => {
|
||||||
|
if (res.code === 200 || res.code === 0) {
|
||||||
this.stepNum += 1;
|
this.stepNum += 1;
|
||||||
this.$emit('setSN', this.stepNum);
|
this.$emit('setSN', this.stepNum);
|
||||||
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
|
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
|
||||||
|
} else {
|
||||||
|
this.$message(res.msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -748,7 +818,7 @@ export default {
|
|||||||
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
||||||
this.tableData2.forEach((item) => {
|
this.tableData2.forEach((item) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
teamId: item.id,
|
teamId: item.teamId || item.id,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
bindData: JSON.stringify(item.bindLineTree),
|
bindData: JSON.stringify(item.bindLineTree),
|
||||||
};
|
};
|
||||||
@@ -793,6 +863,7 @@ export default {
|
|||||||
this.tableData1 = [];
|
this.tableData1 = [];
|
||||||
if (this.dataForm.shiftType == 1) {
|
if (this.dataForm.shiftType == 1) {
|
||||||
const obj = {
|
const obj = {
|
||||||
|
sort: 1,
|
||||||
name: '长白班',
|
name: '长白班',
|
||||||
startTime: '08:00:00',
|
startTime: '08:00:00',
|
||||||
endTime: '17:00:00',
|
endTime: '17:00:00',
|
||||||
@@ -802,6 +873,7 @@ export default {
|
|||||||
this.tableData1.push(obj);
|
this.tableData1.push(obj);
|
||||||
} else if (this.dataForm.shiftType == 2) {
|
} else if (this.dataForm.shiftType == 2) {
|
||||||
const obj1 = {
|
const obj1 = {
|
||||||
|
sort: 1,
|
||||||
name: '白班',
|
name: '白班',
|
||||||
startTime: '08:00:00',
|
startTime: '08:00:00',
|
||||||
endTime: '20:00:00',
|
endTime: '20:00:00',
|
||||||
@@ -809,6 +881,7 @@ export default {
|
|||||||
code: 1,
|
code: 1,
|
||||||
};
|
};
|
||||||
const obj2 = {
|
const obj2 = {
|
||||||
|
sort: 2,
|
||||||
name: '夜班',
|
name: '夜班',
|
||||||
startTime: '20:00:00',
|
startTime: '20:00:00',
|
||||||
endTime: '08:00:00',
|
endTime: '08:00:00',
|
||||||
@@ -818,6 +891,7 @@ export default {
|
|||||||
this.tableData1.push(obj1, obj2);
|
this.tableData1.push(obj1, obj2);
|
||||||
} else if (this.dataForm.shiftType == 3) {
|
} else if (this.dataForm.shiftType == 3) {
|
||||||
const obj1 = {
|
const obj1 = {
|
||||||
|
sort: 1,
|
||||||
name: '早班',
|
name: '早班',
|
||||||
startTime: '08:00:00',
|
startTime: '08:00:00',
|
||||||
endTime: '16:00:00',
|
endTime: '16:00:00',
|
||||||
@@ -825,6 +899,7 @@ export default {
|
|||||||
code: 1,
|
code: 1,
|
||||||
};
|
};
|
||||||
const obj2 = {
|
const obj2 = {
|
||||||
|
sort: 2,
|
||||||
name: '中班',
|
name: '中班',
|
||||||
startTime: '16:00:00',
|
startTime: '16:00:00',
|
||||||
endTime: '00:00:00',
|
endTime: '00:00:00',
|
||||||
@@ -832,6 +907,7 @@ export default {
|
|||||||
code: 2,
|
code: 2,
|
||||||
};
|
};
|
||||||
const obj3 = {
|
const obj3 = {
|
||||||
|
sort: 3,
|
||||||
name: '夜班',
|
name: '夜班',
|
||||||
startTime: '00:00:00',
|
startTime: '00:00:00',
|
||||||
endTime: '08:00:00',
|
endTime: '08:00:00',
|
||||||
@@ -841,6 +917,102 @@ export default {
|
|||||||
this.tableData1.push(obj1, obj2, obj3);
|
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) {
|
handleClick1(val) {
|
||||||
this.addOrUpdateVisible1 = true;
|
this.addOrUpdateVisible1 = true;
|
||||||
@@ -859,11 +1031,37 @@ export default {
|
|||||||
this.tableData2.splice(val.data._pageIndex - 1, 1);
|
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() {
|
addNewGroup() {
|
||||||
this.addOrUpdateVisible2 = true;
|
this.addOrUpdateVisible2 = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addGroupRef.init(this.dataForm.deptId,this.tableData2);
|
this.$refs.addGroupRef.init(this.dataForm.deptId, this.tableData2);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancel1() {
|
cancel1() {
|
||||||
@@ -886,6 +1084,58 @@ export default {
|
|||||||
},
|
},
|
||||||
refreshTableData1(index, val) {
|
refreshTableData1(index, val) {
|
||||||
this.tableData1.splice(index, 1, 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();
|
this.cancel1();
|
||||||
},
|
},
|
||||||
refreshTableData2(val) {
|
refreshTableData2(val) {
|
||||||
@@ -894,23 +1144,45 @@ export default {
|
|||||||
},
|
},
|
||||||
refreshTableData3(index, val) {
|
refreshTableData3(index, val) {
|
||||||
this.tableData2[index].bindLineTree = val;
|
this.tableData2[index].bindLineTree = val;
|
||||||
let lineName = '';
|
let lineName = this.setLineName(val);
|
||||||
lineName = this.setLineName(val, lineName);
|
|
||||||
if (lineName) {
|
if (lineName) {
|
||||||
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
|
this.$set(this.tableData2[index], 'lineName', lineName.join(';'));
|
||||||
}
|
}
|
||||||
this.cancel3();
|
this.cancel3();
|
||||||
},
|
},
|
||||||
//提取绑定的产线工段名展示出来
|
//提取绑定的产线工段名展示出来
|
||||||
setLineName(val, lineName) {
|
setLineName(data) {
|
||||||
val.forEach((item) => {
|
const paths = [];
|
||||||
lineName += item.name + ':';
|
|
||||||
if (item.children && item.children.length > 0) {
|
const processNode = (node, currentPath = []) => {
|
||||||
const childName = this.setLineName(item.children, lineName);
|
const newPath = [...currentPath, node.name];
|
||||||
lineName = childName;
|
|
||||||
|
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 {
|
||||||
return lineName;
|
// 没有子节点的节点(如原片产线1),用括号显示
|
||||||
|
paths.push(`${currentPath.join('/')}/(${node.name})`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
data.forEach((node) => processNode(node));
|
||||||
|
return paths;
|
||||||
},
|
},
|
||||||
//第三步
|
//第三步
|
||||||
// 进来加载预览排班
|
// 进来加载预览排班
|
||||||
@@ -919,6 +1191,7 @@ export default {
|
|||||||
id: this.dataForm.id,
|
id: this.dataForm.id,
|
||||||
count: day,
|
count: day,
|
||||||
};
|
};
|
||||||
|
this.period = day;
|
||||||
this.tableProps3 = [];
|
this.tableProps3 = [];
|
||||||
this.tableData3 = [];
|
this.tableData3 = [];
|
||||||
getPerView(data).then((res) => {
|
getPerView(data).then((res) => {
|
||||||
@@ -946,6 +1219,7 @@ export default {
|
|||||||
label: item.day,
|
label: item.day,
|
||||||
work: item.work,
|
work: item.work,
|
||||||
subcomponent: propSpan,
|
subcomponent: propSpan,
|
||||||
|
showOverflowtooltip: true,
|
||||||
};
|
};
|
||||||
this.tableProps3.push(obj);
|
this.tableProps3.push(obj);
|
||||||
item.det.forEach((sItem, sIndex) => {
|
item.det.forEach((sItem, sIndex) => {
|
||||||
@@ -970,7 +1244,8 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelStep() {
|
cancelStep() {
|
||||||
if (this.stepNum > 1) {
|
if (this.stepNum > 1 && !this.isEdit) {
|
||||||
|
//编辑的时候,让前端上一步和取消都不用接口,
|
||||||
cancelStepThree(this.dataForm.id).then((res) => {
|
cancelStepThree(this.dataForm.id).then((res) => {
|
||||||
this.$message('已取消计划');
|
this.$message('已取消计划');
|
||||||
this.$emit('refreshDataList');
|
this.$emit('refreshDataList');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2021-11-18 14:16:25
|
* @Date: 2021-11-18 14:16:25
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-30 10:47:09
|
* @LastEditTime: 2025-11-25 15:49:17
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -13,8 +13,12 @@
|
|||||||
:to_data="toData"
|
:to_data="toData"
|
||||||
@add-btn="add"
|
@add-btn="add"
|
||||||
@remove-btn="remove"
|
@remove-btn="remove"
|
||||||
pid="pid"
|
pid="fid"
|
||||||
:defaultProps="{ label: 'name' }"
|
:node_key="'uniqueId'"
|
||||||
|
:defaultProps="{
|
||||||
|
label: 'name',
|
||||||
|
children: 'children',
|
||||||
|
}"
|
||||||
height="450px"
|
height="450px"
|
||||||
style="padding-bottom: 20px"
|
style="padding-bottom: 20px"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
@@ -43,16 +47,34 @@ export default {
|
|||||||
this.fromData = [];
|
this.fromData = [];
|
||||||
this.toData = [];
|
this.toData = [];
|
||||||
getGroupPlanTree().then((res) => {
|
getGroupPlanTree().then((res) => {
|
||||||
this.fromData = res.data;
|
res.data.forEach((item) => {
|
||||||
this.fromData.forEach((item) => {
|
|
||||||
item.productionLineId = 0;
|
item.productionLineId = 0;
|
||||||
});
|
});
|
||||||
|
this.fromData = this.generateUniqueData(res.data);
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.toData = val.bindLineTree || [];
|
this.toData = val.bindLineTree || [];
|
||||||
this.getFilterLeftData(this.fromData, this.toData); //编辑时组件有bug,左边相同数据不消失
|
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) {
|
add(fromData, toData, obj) {
|
||||||
console.log('fromData:', fromData);
|
console.log('fromData:', fromData);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-21 14:27:23
|
* @Date: 2025-10-21 14:27:23
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-21 15:02:27
|
* @LastEditTime: 2025-11-25 15:14:53
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="title">创建人:</span>
|
<span class="title">创建人:</span>
|
||||||
{{ infoData.creator }}
|
{{ infoData.creatorName }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="title">创建时间:</span>
|
<span class="title">创建时间:</span>
|
||||||
@@ -150,26 +150,45 @@ export default {
|
|||||||
this.infoData = {};
|
this.infoData = {};
|
||||||
getPlan(id).then((res) => {
|
getPlan(id).then((res) => {
|
||||||
this.infoData = res.data || {};
|
this.infoData = res.data || {};
|
||||||
console.log(res);
|
this.tableData1 = res.data?.groupPlanClassesBaseVOList.sort(
|
||||||
this.tableData1 = res.data?.groupPlanClassesBaseVOList;
|
(a, b) => a.sort - b.sort
|
||||||
|
);
|
||||||
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
|
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
|
||||||
this.tableData2.forEach((item, index) => {
|
this.tableData2.forEach((item, index) => {
|
||||||
let lineName = '';
|
let lineName = '';
|
||||||
lineName = this.setLineName(item.bindLineTree, lineName);
|
if (item.isProduction) {
|
||||||
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
|
lineName = this.setLineName(item.bindLineTree);
|
||||||
|
}
|
||||||
|
this.$set(this.tableData2[index], 'lineName', lineName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//提取绑定的产线工段名展示出来
|
//提取绑定的产线工段名展示出来
|
||||||
setLineName(val, lineName) {
|
setLineName(val) {
|
||||||
val.forEach((item) => {
|
if (!val || val.length === 0) return '';
|
||||||
lineName += item.name + ':';
|
|
||||||
if (item.children && item.children.length > 0) {
|
const currentLevelNames = val.map((item) => item.name);
|
||||||
const childName = this.setLineName(item.children, lineName);
|
|
||||||
lineName = childName;
|
// 处理当前层级显示
|
||||||
|
let currentDisplay = '';
|
||||||
|
if (currentLevelNames.length > 1) {
|
||||||
|
currentDisplay = `(${currentLevelNames.join(' 、 ')})`;
|
||||||
|
} else {
|
||||||
|
currentDisplay = currentLevelNames[0];
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return lineName;
|
// 查找所有子节点(取第一个有子节点的元素)
|
||||||
|
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 currentDisplay;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2021-11-18 14:16:25
|
* @Date: 2021-11-18 14:16:25
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-20 10:23:52
|
* @LastEditTime: 2025-11-04 14:08:47
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -15,9 +15,10 @@
|
|||||||
label-width="80px">
|
label-width="80px">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="序号" prop="index">
|
<el-form-item label="排序" prop="sort">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="dataForm.index"
|
style="width: 100%"
|
||||||
|
v-model="dataForm.sort"
|
||||||
:step="1"
|
:step="1"
|
||||||
:min="1"
|
:min="1"
|
||||||
step-strictly />
|
step-strictly />
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
format="H:mm"
|
format="H:mm"
|
||||||
value-format="HH:mm:ss"
|
value-format="HH:mm:ss"
|
||||||
v-model="dataForm.startTime"
|
v-model="dataForm.startTime"
|
||||||
placeholder="选择日期时间"></el-time-picker>
|
@change="timeFun('start')"
|
||||||
|
placeholder="选择时间"></el-time-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
@@ -48,7 +50,19 @@
|
|||||||
format="H:mm"
|
format="H:mm"
|
||||||
value-format="HH:mm:ss"
|
value-format="HH:mm:ss"
|
||||||
v-model="dataForm.endTime"
|
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-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
@@ -70,15 +84,17 @@ export default {
|
|||||||
return {
|
return {
|
||||||
dataForm: {
|
dataForm: {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
index: undefined,
|
sort: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
startTime: undefined,
|
startTime: undefined,
|
||||||
endTime: undefined,
|
endTime: undefined,
|
||||||
|
daySpan: 0,
|
||||||
|
code: 1,
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
},
|
},
|
||||||
_pageIndex: 1,
|
_pageIndex: 1,
|
||||||
dataRule: {
|
dataRule: {
|
||||||
index: [{ required: true, message: '序号不能为空', trigger: 'blur' }],
|
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
|
||||||
name: [
|
name: [
|
||||||
{ required: true, message: '班次名称不能为空', trigger: 'blur' },
|
{ required: true, message: '班次名称不能为空', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
@@ -93,12 +109,30 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init(val) {
|
init(val) {
|
||||||
this._pageIndex = val._pageIndex-1;
|
this._pageIndex = val._pageIndex - 1;
|
||||||
this.dataForm.index = val._pageIndex || 1;
|
this.dataForm.sort = val._pageIndex || 1;
|
||||||
this.dataForm.name = val.name || undefined;
|
this.dataForm.name = val.name || undefined;
|
||||||
this.dataForm.startTime = val.startTime || undefined;
|
this.dataForm.startTime = val.startTime || undefined;
|
||||||
this.dataForm.endTime = val.endTime || undefined;
|
this.dataForm.endTime = val.endTime || undefined;
|
||||||
this.dataForm.remark = val.remark || 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() {
|
dataFormSubmit() {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<!--
|
<!--
|
||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-11 14:27:37
|
* @Date: 2025-10-13 15:07:24
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-29 14:50:16
|
* @LastEditTime: 2025-11-28 09:56:09
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -31,13 +31,17 @@
|
|||||||
<el-form-item label="开始时间" prop="startDay">
|
<el-form-item label="开始时间" prop="startDay">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="formInline.startDay"
|
v-model="formInline.startDay"
|
||||||
|
size="small"
|
||||||
type="datetime"
|
type="datetime"
|
||||||
|
value-format="yyyy-MM-dd HH:mm:ss"
|
||||||
placeholder="选择日期时间"></el-date-picker>
|
placeholder="选择日期时间"></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="结束时间" prop="endDay">
|
<el-form-item label="结束时间" prop="endDay">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="formInline.endDay"
|
v-model="formInline.endDay"
|
||||||
|
size="small"
|
||||||
type="datetime"
|
type="datetime"
|
||||||
|
value-format="yyyy-MM-dd HH:mm:ss"
|
||||||
placeholder="选择日期时间"></el-date-picker>
|
placeholder="选择日期时间"></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="部门" prop="deptId">
|
<el-form-item label="部门" prop="deptId">
|
||||||
@@ -46,8 +50,12 @@
|
|||||||
ref="deptSelect"
|
ref="deptSelect"
|
||||||
@DeptId="setDeptId"></dept-select>
|
@DeptId="setDeptId"></dept-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="leaderName">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="formInline.status" placeholder="请选择状态">
|
<el-select
|
||||||
|
v-model="formInline.status"
|
||||||
|
size="small"
|
||||||
|
clearable
|
||||||
|
placeholder="请选择状态">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in options"
|
v-for="item in options"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
@@ -65,7 +73,8 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<span class="separateStyle"
|
<span
|
||||||
|
class="separateStyle"
|
||||||
v-hasPermi="['base:group-scheduling-plan:query']"></span>
|
v-hasPermi="['base:group-scheduling-plan:query']"></span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@@ -74,7 +83,8 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<span class="separateStyle"
|
<span
|
||||||
|
class="separateStyle"
|
||||||
v-hasPermi="['base:group-scheduling-plan:create']"></span>
|
v-hasPermi="['base:group-scheduling-plan:create']"></span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@@ -87,6 +97,17 @@
|
|||||||
新增
|
新增
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</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>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<base-table
|
<base-table
|
||||||
@@ -201,6 +222,7 @@ import {
|
|||||||
copyPlan,
|
copyPlan,
|
||||||
disablePlan,
|
disablePlan,
|
||||||
updateScheduleLater,
|
updateScheduleLater,
|
||||||
|
exportExcel,
|
||||||
} from '@/api/group/Schedule';
|
} from '@/api/group/Schedule';
|
||||||
|
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
@@ -268,8 +290,8 @@ export default {
|
|||||||
},
|
},
|
||||||
tableProps,
|
tableProps,
|
||||||
tableBtn: [
|
tableBtn: [
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:update')?
|
this.$auth.hasPermi('base:group-scheduling-plan:update')
|
||||||
{
|
? {
|
||||||
type: 'edit',
|
type: 'edit',
|
||||||
btnName: '编辑',
|
btnName: '编辑',
|
||||||
showParam: {
|
showParam: {
|
||||||
@@ -282,9 +304,10 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}:undefined,
|
}
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:delete')?
|
: undefined,
|
||||||
{
|
this.$auth.hasPermi('base:group-scheduling-plan:delete')
|
||||||
|
? {
|
||||||
type: 'delete',
|
type: 'delete',
|
||||||
btnName: '删除',
|
btnName: '删除',
|
||||||
showParam: {
|
showParam: {
|
||||||
@@ -297,9 +320,10 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}:undefined,
|
}
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:query')?
|
: undefined,
|
||||||
{
|
this.$auth.hasPermi('base:group-scheduling-plan:query')
|
||||||
|
? {
|
||||||
type: 'detail',
|
type: 'detail',
|
||||||
btnName: '查看',
|
btnName: '查看',
|
||||||
showParam: {
|
showParam: {
|
||||||
@@ -312,9 +336,10 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}:undefined,
|
}
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:delete')?
|
: undefined,
|
||||||
{
|
this.$auth.hasPermi('base:group-scheduling-plan:delete')
|
||||||
|
? {
|
||||||
type: 'cancel',
|
type: 'cancel',
|
||||||
btnName: '作废',
|
btnName: '作废',
|
||||||
showParam: {
|
showParam: {
|
||||||
@@ -327,9 +352,10 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}:undefined,
|
}
|
||||||
this.$auth.hasPermi('base:group-holiday:update')?
|
: undefined,
|
||||||
{
|
this.$auth.hasPermi('base:group-holiday:update')
|
||||||
|
? {
|
||||||
type: 'sync',
|
type: 'sync',
|
||||||
btnName: '同步节假日',
|
btnName: '同步节假日',
|
||||||
showParam: {
|
showParam: {
|
||||||
@@ -347,12 +373,14 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}:undefined,
|
}
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:create')?
|
: undefined,
|
||||||
{
|
this.$auth.hasPermi('base:group-scheduling-plan:create')
|
||||||
|
? {
|
||||||
type: 'copy',
|
type: 'copy',
|
||||||
btnName: '复制',
|
btnName: '复制',
|
||||||
}:undefined,
|
}
|
||||||
|
: undefined,
|
||||||
].filter((v) => v),
|
].filter((v) => v),
|
||||||
tableData: [],
|
tableData: [],
|
||||||
options: [
|
options: [
|
||||||
@@ -370,50 +398,52 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
formInline: {
|
formInline: {
|
||||||
code: '',
|
code: null,
|
||||||
name: '',
|
name: null,
|
||||||
startDay: '',
|
startDay: null,
|
||||||
endDay: '',
|
endDay: null,
|
||||||
deptId: '',
|
deptId: null,
|
||||||
status: '',
|
status: null,
|
||||||
},
|
},
|
||||||
stepNum: 1, // 新增编辑时当前第几步
|
stepNum: 1, // 新增编辑时当前第几步
|
||||||
detailVisible: false,
|
detailVisible: false,
|
||||||
|
// 导出遮罩层
|
||||||
|
exportLoading: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
AddOrUpdate,
|
AddOrUpdate,
|
||||||
deptSelect,
|
deptSelect,
|
||||||
detail
|
detail,
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
buttonClick(val) {
|
buttonClick(val) {
|
||||||
switch (val.btnName) {
|
switch (val.btnName) {
|
||||||
case 'search':
|
case 'search':
|
||||||
const date1 = new Date(this.formInline.startDay).getTime();
|
if (this.formInline.startDay > this.formInline.endDay) {
|
||||||
const date2 = new Date(this.formInline.endDay).getTime();
|
|
||||||
|
|
||||||
if (date1 > date2) {
|
|
||||||
this.$message('开始时间不得晚于结束时间');
|
this.$message('开始时间不得晚于结束时间');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
total: 1,
|
total: 1,
|
||||||
...this.formInline,
|
...this.formInline,
|
||||||
};
|
};
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
break;
|
break;
|
||||||
case 'reset':
|
case 'reset':
|
||||||
|
this.$refs.searchBarForm.resetFields();
|
||||||
this.formInline.name = null;
|
this.formInline.name = null;
|
||||||
this.formInline.code = null;
|
this.formInline.code = null;
|
||||||
this.formInline.deptId = null;
|
this.formInline.deptId = null;
|
||||||
this.$refs.deptSelect.clear();
|
this.$refs.deptSelect.clear();
|
||||||
this.formInline.leaderName = null;
|
this.formInline.status = null;
|
||||||
|
this.formInline.startDay = null;
|
||||||
|
this.formInline.endDay = null;
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
};
|
};
|
||||||
@@ -462,7 +492,8 @@ export default {
|
|||||||
this.addOrUpdateVisible = true;
|
this.addOrUpdateVisible = true;
|
||||||
this.addOrEditTitle = '编辑';
|
this.addOrEditTitle = '编辑';
|
||||||
this.$nextTick(() => {
|
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') {
|
} else if (val.type === 'delete') {
|
||||||
this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex);
|
this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex);
|
||||||
@@ -474,23 +505,62 @@ export default {
|
|||||||
} else if (val.type === 'cancel') {
|
} else if (val.type === 'cancel') {
|
||||||
disablePlan(val.data.id).then((res) => {
|
disablePlan(val.data.id).then((res) => {
|
||||||
this.$modal.msgSuccess('作废成功');
|
this.$modal.msgSuccess('作废成功');
|
||||||
this.getDataList()
|
this.getDataList();
|
||||||
});
|
});
|
||||||
} else if (val.type === 'sync') {
|
} else if (val.type === 'sync') {
|
||||||
updateScheduleLater({ planId: val.data.id }).then((res) => {
|
this.$confirm(
|
||||||
|
'当前节假日包含尚未同步的节假日变更,是否立即将上述节假日同步更新到排班计划?',
|
||||||
|
'同步节假日',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确认同步',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
updateScheduleLater({
|
||||||
|
planId: val.data.id,
|
||||||
|
logId: val.data.updateLogId,
|
||||||
|
}).then((res) => {
|
||||||
this.$modal.msgSuccess('同步节假日成功');
|
this.$modal.msgSuccess('同步节假日成功');
|
||||||
this.getDataList()
|
this.getDataList();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((res) => {
|
||||||
|
this.getDataList();
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else if (val.type === 'copy') {
|
} else if (val.type === 'copy') {
|
||||||
copyPlan(val.data.id).then((res) => {
|
copyPlan(val.data.id).then((res) => {
|
||||||
this.$modal.msgSuccess('复制成功');
|
this.$modal.msgSuccess('复制成功');
|
||||||
this.getDataList()
|
this.getDataList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
detailCancel() {
|
detailCancel() {
|
||||||
this.detailVisible = false;
|
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>
|
</script>
|
||||||
|
|||||||
44
src/views/group/Schedule/sortSet.vue
Normal 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>
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-13 16:18:41
|
* @Date: 2025-10-13 16:18:41
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-20 10:13:26
|
* @LastEditTime: 2025-11-04 10:54:19
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<span>
|
<span>
|
||||||
{{
|
{{
|
||||||
injectData.shiftSustainedNum +
|
(injectData.shiftSustainedNum?injectData.shiftSustainedNum:'') +
|
||||||
(injectData.shiftSustainedType
|
(injectData.shiftSustainedType
|
||||||
? ['', '日', '周', '月', '季'][injectData.shiftSustainedType]
|
? ['', '日', '周', '月', '季'][injectData.shiftSustainedType]
|
||||||
: '')
|
: '')
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ export default {
|
|||||||
this.deptId = id;
|
this.deptId = id;
|
||||||
},
|
},
|
||||||
clear() {
|
clear() {
|
||||||
console.log(this.$refs.treeselect);
|
|
||||||
this.$refs.treeselect.clear();
|
this.$refs.treeselect.clear();
|
||||||
},
|
},
|
||||||
// 格式化部门的下拉框
|
// 格式化部门的下拉框
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2021-11-18 14:16:25
|
* @Date: 2021-11-18 14:16:25
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-29 14:47:33
|
* @LastEditTime: 2025-11-27 14:49:34
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -25,16 +25,18 @@
|
|||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="班组名称" prop="name">
|
<el-form-item label="班组名称" prop="name">
|
||||||
<el-input
|
<el-input
|
||||||
|
:disabled="nameDisable"
|
||||||
v-model="dataForm.name"
|
v-model="dataForm.name"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请输入班组名称" />
|
placeholder="请输入班组名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="部门">
|
<el-form-item label="部门" prop="deptId">
|
||||||
<dept-select
|
<dept-select
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
ref="deptSelect"
|
ref="deptSelect"
|
||||||
|
v-model="dataForm.deptId"
|
||||||
@DeptId="setDeptId"></dept-select>
|
@DeptId="setDeptId"></dept-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -77,6 +79,7 @@
|
|||||||
<el-form-item label="生产班组" prop="isProduction">
|
<el-form-item label="生产班组" prop="isProduction">
|
||||||
<el-select
|
<el-select
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
@change="setIsProduction"
|
||||||
v-model="dataForm.isProduction"
|
v-model="dataForm.isProduction"
|
||||||
placeholder="请选择是否为生产班组">
|
placeholder="请选择是否为生产班组">
|
||||||
<el-option
|
<el-option
|
||||||
@@ -108,6 +111,7 @@ import {
|
|||||||
updateGroup,
|
updateGroup,
|
||||||
getGroup,
|
getGroup,
|
||||||
getCode,
|
getCode,
|
||||||
|
updateIsProduction,
|
||||||
} from '@/api/group/groupSetting';
|
} from '@/api/group/groupSetting';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -138,6 +142,7 @@ export default {
|
|||||||
remark: undefined,
|
remark: undefined,
|
||||||
},
|
},
|
||||||
setData: true,
|
setData: true,
|
||||||
|
nameDisable: false, //班组被使用时,班组名称不能修改
|
||||||
leaderArr: [],
|
leaderArr: [],
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
@@ -156,6 +161,7 @@ export default {
|
|||||||
name: [
|
name: [
|
||||||
{ required: true, message: '班组名称不能为空', trigger: 'blur' },
|
{ required: true, message: '班组名称不能为空', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
|
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
|
||||||
leaderId: [
|
leaderId: [
|
||||||
{ required: true, message: '组长不能为空', trigger: 'change' },
|
{ required: true, message: '组长不能为空', trigger: 'change' },
|
||||||
],
|
],
|
||||||
@@ -164,11 +170,12 @@ export default {
|
|||||||
],
|
],
|
||||||
leaderPhone: [
|
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}$/,
|
pattern:
|
||||||
message: "请输入正确的手机号码",
|
/^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
|
||||||
trigger: "blur"
|
message: '请输入正确的手机号码',
|
||||||
}
|
trigger: 'blur',
|
||||||
]
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -184,8 +191,42 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
setDataForm(){
|
setDataForm() {
|
||||||
this.$refs.deptSelect.setID(this.dataForm.deptId)
|
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) {
|
setLeaderName(val) {
|
||||||
this.leaderArr.map((item) => {
|
this.leaderArr.map((item) => {
|
||||||
@@ -196,28 +237,28 @@ export default {
|
|||||||
},
|
},
|
||||||
// 表单提交
|
// 表单提交
|
||||||
dataFormSubmit() {
|
dataFormSubmit() {
|
||||||
this.$refs["dataForm"].validate((valid) => {
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!this.dataForm.deptId){
|
if (!this.dataForm.deptId) {
|
||||||
this.$message('部门不能为空');
|
this.$message('部门不能为空');
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
// 修改的提交
|
// 修改的提交
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
this.urlOptions.updateURL(this.dataForm).then(response => {
|
this.urlOptions.updateURL(this.dataForm).then((response) => {
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess('修改成功');
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.$emit("refreshDataList");
|
this.$emit('refreshDataList');
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 添加的提交
|
// 添加的提交
|
||||||
this.urlOptions.createURL(this.dataForm).then(response => {
|
this.urlOptions.createURL(this.dataForm).then((response) => {
|
||||||
this.$modal.msgSuccess("新增成功");
|
this.$modal.msgSuccess('新增成功');
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.$emit("refreshDataList");
|
this.$emit('refreshDataList');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
|
<!--
|
||||||
|
* @Author: zwq
|
||||||
|
* @Date: 2025-10-11 14:41:12
|
||||||
|
* @LastEditors: zwq
|
||||||
|
* @LastEditTime: 2025-11-27 14:19:39
|
||||||
|
* @Description:
|
||||||
|
-->
|
||||||
<template>
|
<template>
|
||||||
<el-switch
|
<el-switch
|
||||||
@change="changeStatus"
|
@change="changeStatus"
|
||||||
size="small"
|
size="small"
|
||||||
v-model="list.enabled"
|
v-model="injectData.enabled"
|
||||||
:active-value="1"
|
:active-value="1"
|
||||||
:inactive-value="0"></el-switch>
|
:inactive-value="0"></el-switch>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { updateGroup } from '@/api/group/groupSetting';
|
import { updateGroup, updateIsProduction } from '@/api/group/groupSetting';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
injectData: {
|
injectData: {
|
||||||
@@ -17,17 +24,51 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {};
|
||||||
list: this.injectData,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
changeStatus(val) {
|
changeStatus(val) {
|
||||||
const data = { ...this.injectData, enabled: val };
|
const pdata = { ...this.injectData, enabled: val };
|
||||||
updateGroup(data).then((res) => {
|
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.$modal.msgSuccess('修改成功');
|
||||||
this.$emit('emitData');
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-11 14:27:37
|
* @Date: 2025-10-11 14:27:37
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-29 14:44:41
|
* @LastEditTime: 2025-11-14 21:50:40
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -212,7 +212,7 @@ export default {
|
|||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
total: 1,
|
total: 1,
|
||||||
...this.formInline,
|
...this.formInline,
|
||||||
};
|
};
|
||||||
@@ -225,7 +225,7 @@ export default {
|
|||||||
this.$refs.deptSelect.clear();
|
this.$refs.deptSelect.clear();
|
||||||
this.formInline.leaderName = null;
|
this.formInline.leaderName = null;
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2021-11-18 14:16:25
|
* @Date: 2021-11-18 14:16:25
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-23 13:29:58
|
* @LastEditTime: 2025-11-27 14:06:11
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="节假日名称" prop="name">
|
<el-form-item label="节假日名称" prop="name">
|
||||||
<el-input
|
<el-input
|
||||||
|
ref="inputWidth"
|
||||||
v-model="dataForm.name"
|
v-model="dataForm.name"
|
||||||
clearable
|
clearable
|
||||||
:disabled="detail"
|
:disabled="detail"
|
||||||
@@ -54,7 +55,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="dataForm.dateType == 1"
|
v-if="dataForm.dateType == 1 && dataForm.calendarType == 1"
|
||||||
label="日期"
|
label="日期"
|
||||||
prop="dateDay">
|
prop="dateDay">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
@@ -66,9 +67,13 @@
|
|||||||
placeholder="选择日期"
|
placeholder="选择日期"
|
||||||
format="yyyy-MM-dd"
|
format="yyyy-MM-dd"
|
||||||
value-format="--MM-dd"
|
value-format="--MM-dd"
|
||||||
|
@blur="$forceUpdate()"
|
||||||
:picker-options="pickerOptions"></el-date-picker>
|
:picker-options="pickerOptions"></el-date-picker>
|
||||||
</el-form-item>
|
</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
|
<el-date-picker
|
||||||
:disabled="detail"
|
:disabled="detail"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@@ -80,8 +85,53 @@
|
|||||||
range-separator="至"
|
range-separator="至"
|
||||||
start-placeholder="开始日期"
|
start-placeholder="开始日期"
|
||||||
end-placeholder="结束日期"
|
end-placeholder="结束日期"
|
||||||
|
@blur="$forceUpdate()"
|
||||||
:picker-options="pickerOptions"></el-date-picker>
|
:picker-options="pickerOptions"></el-date-picker>
|
||||||
</el-form-item>
|
</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>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="是否每年重复" prop="repeat">
|
<el-form-item label="是否每年重复" prop="repeat">
|
||||||
@@ -131,6 +181,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import JDatePicker from './components/JDatePicker.vue';
|
||||||
import {
|
import {
|
||||||
createHoliday,
|
createHoliday,
|
||||||
updateHoliday,
|
updateHoliday,
|
||||||
@@ -141,7 +192,9 @@ import {
|
|||||||
} from '@/api/group/holidaySetting';
|
} from '@/api/group/holidaySetting';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
components: {
|
||||||
|
JDatePicker,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dataForm: {
|
dataForm: {
|
||||||
@@ -151,11 +204,16 @@ export default {
|
|||||||
dateType: 1,
|
dateType: 1,
|
||||||
dateDay: undefined,
|
dateDay: undefined,
|
||||||
dateDayArr: [],
|
dateDayArr: [],
|
||||||
|
dateDayChinese: undefined,
|
||||||
|
dateDayArrChinese: [],
|
||||||
|
noRepeatYear: undefined,
|
||||||
|
noRepeatYearChinese: undefined,
|
||||||
repeat: true,
|
repeat: true,
|
||||||
inherited: true, // 是否为继承
|
inherited: true, // 是否为继承
|
||||||
deptId: undefined,
|
deptId: undefined,
|
||||||
},
|
},
|
||||||
detail: false,
|
detail: false,
|
||||||
|
inherited: true,
|
||||||
options1: [
|
options1: [
|
||||||
{
|
{
|
||||||
value: 1,
|
value: 1,
|
||||||
@@ -202,6 +260,12 @@ export default {
|
|||||||
dateDayArr: [
|
dateDayArr: [
|
||||||
{ required: true, message: '日期不能为空', trigger: 'change' },
|
{ required: true, message: '日期不能为空', trigger: 'change' },
|
||||||
],
|
],
|
||||||
|
dateDayChinese: [
|
||||||
|
{ required: true, message: '日期不能为空', trigger: 'change' },
|
||||||
|
],
|
||||||
|
dateDayArrChinese: [
|
||||||
|
{ required: true, message: '日期不能为空', trigger: 'change' },
|
||||||
|
],
|
||||||
repeat: [
|
repeat: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
@@ -216,13 +280,63 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
dialogVisible: false,
|
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: {
|
methods: {
|
||||||
init(deptId, id, detail) {
|
init(deptId, val, detail, inherited) {
|
||||||
this.dataForm.deptId = deptId || undefined;
|
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.detail = detail || false;
|
||||||
|
this.inherited = inherited; //编辑的时候,该部门如果是自定义的,但这个val数据是继承的,修改之后,则变成自定义的inherited
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs['dataForm'].resetFields();
|
this.$refs['dataForm'].resetFields();
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
@@ -245,14 +359,21 @@ export default {
|
|||||||
this.dataForm.dateType == 1 &&
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
this.dataForm.dateDay = this.dataForm.oneDayChinese;
|
this.dataForm.dateDayChinese =
|
||||||
|
'L' +
|
||||||
|
new Date().getFullYear() +
|
||||||
|
this.dataForm.oneDayChinese.slice(-6);
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
this.dataForm.dateDayArr = [
|
this.dataForm.dateDayArrChinese = [
|
||||||
this.dataForm.startDayChinese,
|
'L' +
|
||||||
this.dataForm.endDayChinese,
|
new Date().getFullYear() +
|
||||||
|
this.dataForm.startDayChinese.slice(-6),
|
||||||
|
'L' +
|
||||||
|
new Date().getFullYear() +
|
||||||
|
this.dataForm.endDayChinese.slice(-6),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -307,9 +428,12 @@ export default {
|
|||||||
this.$modal.msgSuccess('删除成功');
|
this.$modal.msgSuccess('删除成功');
|
||||||
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
||||||
this.$modal.msgSuccess('更新成功');
|
this.$modal.msgSuccess('更新成功');
|
||||||
|
});
|
||||||
this.$emit('refreshPage');
|
this.$emit('refreshPage');
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
onDateChange(val) {
|
||||||
|
console.log(val);
|
||||||
},
|
},
|
||||||
// 表单提交
|
// 表单提交
|
||||||
dataFormSubmit() {
|
dataFormSubmit() {
|
||||||
@@ -329,25 +453,60 @@ export default {
|
|||||||
this.dataForm.dateType == 1 &&
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
this.dataForm.oneDayChinese = this.dataForm.dateDay;
|
this.dataForm.oneDayChinese =
|
||||||
|
'--' + this.dataForm.dateDayChinese.slice(-5);
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
this.dataForm.startDayChinese = this.dataForm.dateDayArr[0];
|
this.dataForm.startDayChinese =
|
||||||
this.dataForm.endDayChinese = this.dataForm.dateDayArr[1];
|
'--' + this.dataForm.dateDayArrChinese[0].slice(-5);
|
||||||
|
this.dataForm.endDayChinese =
|
||||||
|
'--' + this.dataForm.dateDayArrChinese[1].slice(-5);
|
||||||
|
}
|
||||||
|
if (this.dataForm.calendarType == 1 && !this.dataForm.repeat) {
|
||||||
|
this.dataForm.noRepeatYear = new Date().getFullYear();
|
||||||
|
} else if (this.dataForm.calendarType == 2 && !this.dataForm.repeat) {
|
||||||
|
this.dataForm.noRepeatYearChinese = new Date().getFullYear();
|
||||||
}
|
}
|
||||||
// 修改的提交
|
// 修改的提交
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
updateHoliday(this.dataForm).then((response) => {
|
if (!this.inherited) {
|
||||||
|
this.dataForm.inherited = false;
|
||||||
|
}
|
||||||
|
updateHoliday(this.dataForm).then((res) => {
|
||||||
|
if (!res.data.updateFlag) {
|
||||||
this.$modal.msgSuccess('修改成功');
|
this.$modal.msgSuccess('修改成功');
|
||||||
this.$emit('refreshPage');
|
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');
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 添加的提交
|
// 添加的提交
|
||||||
createHoliday(this.dataForm).then((res) => {
|
createHoliday(this.dataForm).then((res) => {
|
||||||
updateSchedule;
|
|
||||||
if (!res.data.updateFlag) {
|
if (!res.data.updateFlag) {
|
||||||
this.$modal.msgSuccess('新增成功');
|
this.$modal.msgSuccess('新增成功');
|
||||||
this.$emit('refreshPage');
|
this.$emit('refreshPage');
|
||||||
@@ -363,15 +522,16 @@ export default {
|
|||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
||||||
this.$modal.msgSuccess('新增成功');
|
this.$modal.msgSuccess('更新成功');
|
||||||
this.$emit('refreshPage');
|
|
||||||
});
|
});
|
||||||
|
this.$emit('refreshPage');
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$message({
|
this.$message({
|
||||||
type: 'info',
|
type: 'info',
|
||||||
message: '已取消',
|
message: '已取消',
|
||||||
});
|
});
|
||||||
|
this.$emit('refreshPage');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
735
src/views/group/holidaySetting/components/JDatePicker.vue
Normal 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-13;MIX格式:丁酉(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.length==2;返回结果;隐藏控件;
|
||||||
|
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>
|
||||||
13
src/views/group/holidaySetting/components/index.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import jDatePicker from './JDatePicker.vue' // 导入组件
|
||||||
|
const jLunarDatePicker = {
|
||||||
|
install(Vue, options) {
|
||||||
|
Vue.component(jDatePicker.name, jDatePicker) // vuePayKeyboard.name 组件的name属性
|
||||||
|
// 类似通过 this.$xxx 方式调用插件的 其实只是挂载到原型上而已
|
||||||
|
// Vue.prototype.$xxx // 最终可以在任何地方通过 this.$xxx 调用
|
||||||
|
// 虽然没有明确规定用$开头 但是大家都默认遵守这个规定
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof window !== 'undefined' && window.Vue) {
|
||||||
|
window.Vue.use(jLunarDatePicker);
|
||||||
|
}
|
||||||
|
export default jLunarDatePicker // 导出..
|
||||||
626
src/views/group/holidaySetting/components/jDatePicker.js
Normal file
@@ -0,0 +1,626 @@
|
|||||||
|
/**
|
||||||
|
* @1900-2100区间内的公历、农历互转
|
||||||
|
* @charset UTF-8
|
||||||
|
* @公历转农历:calendar.solar2lunar(1987,11,01); //[you can ignore params of prefix 0]
|
||||||
|
*/
|
||||||
|
const calendar = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 农历1900-2100的润大小信息表
|
||||||
|
* @Array Of Property
|
||||||
|
* @return Hex
|
||||||
|
*/
|
||||||
|
lunarInfo:[0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,//1900-1909
|
||||||
|
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,//1910-1919
|
||||||
|
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,//1920-1929
|
||||||
|
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,//1930-1939
|
||||||
|
0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,//1940-1949
|
||||||
|
0x06ca0,0x0b550,0x15355,0x04da0,0x0a5b0,0x14573,0x052b0,0x0a9a8,0x0e950,0x06aa0,//1950-1959
|
||||||
|
0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,//1960-1969
|
||||||
|
0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b6a0,0x195a6,//1970-1979
|
||||||
|
0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,//1980-1989
|
||||||
|
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,//1990-1999
|
||||||
|
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,//2000-2009
|
||||||
|
0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,//2010-2019
|
||||||
|
0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,//2020-2029
|
||||||
|
0x05aa0,0x076a3,0x096d0,0x04afb,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,//2030-2039
|
||||||
|
0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0,//2040-2049
|
||||||
|
/**Add By JJonline@JJonline.Cn**/
|
||||||
|
0x14b63,0x09370,0x049f8,0x04970,0x064b0,0x168a6,0x0ea50, 0x06b20,0x1a6c4,0x0aae0,//2050-2059
|
||||||
|
0x0a2e0,0x0d2e3,0x0c960,0x0d557,0x0d4a0,0x0da50,0x05d55,0x056a0,0x0a6d0,0x055d4,//2060-2069
|
||||||
|
0x052d0,0x0a9b8,0x0a950,0x0b4a0,0x0b6a6,0x0ad50,0x055a0,0x0aba4,0x0a5b0,0x052b0,//2070-2079
|
||||||
|
0x0b273,0x06930,0x07337,0x06aa0,0x0ad50,0x14b55,0x04b60,0x0a570,0x054e4,0x0d160,//2080-2089
|
||||||
|
0x0e968,0x0d520,0x0daa0,0x16aa6,0x056d0,0x04ae0,0x0a9d4,0x0a2d0,0x0d150,0x0f252,//2090-2099
|
||||||
|
0x0d520],//2100
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公历每个月份的天数普通表
|
||||||
|
* @Array Of Property
|
||||||
|
* @return Number
|
||||||
|
*/
|
||||||
|
solarMonth:[31,28,31,30,31,30,31,31,30,31,30,31],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天干地支之天干速查表
|
||||||
|
* @Array Of Property trans["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"]
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
Gan:["\u7532","\u4e59","\u4e19","\u4e01","\u620a","\u5df1","\u5e9a","\u8f9b","\u58ec","\u7678"],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天干地支之地支速查表
|
||||||
|
* @Array Of Property
|
||||||
|
* @trans["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"]
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
Zhi:["\u5b50","\u4e11","\u5bc5","\u536f","\u8fb0","\u5df3","\u5348","\u672a","\u7533","\u9149","\u620c","\u4ea5"],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天干地支之地支速查表<=>生肖
|
||||||
|
* @Array Of Property
|
||||||
|
* @trans["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"]
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
Animals:["\u9f20","\u725b","\u864e","\u5154","\u9f99","\u86c7","\u9a6c","\u7f8a","\u7334","\u9e21","\u72d7","\u732a"],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 24节气速查表
|
||||||
|
* @Array Of Property
|
||||||
|
* @trans["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"]
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
solarTerm:["\u5c0f\u5bd2","\u5927\u5bd2","\u7acb\u6625","\u96e8\u6c34","\u60ca\u86f0","\u6625\u5206","\u6e05\u660e","\u8c37\u96e8","\u7acb\u590f","\u5c0f\u6ee1","\u8292\u79cd","\u590f\u81f3","\u5c0f\u6691","\u5927\u6691","\u7acb\u79cb","\u5904\u6691","\u767d\u9732","\u79cb\u5206","\u5bd2\u9732","\u971c\u964d","\u7acb\u51ac","\u5c0f\u96ea","\u5927\u96ea","\u51ac\u81f3"],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1900-2100各年的24节气日期速查表
|
||||||
|
* @Array Of Property
|
||||||
|
* @return 0x string For splice
|
||||||
|
*/
|
||||||
|
sTermInfo:['9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c3598082c95f8c965cc920f',
|
||||||
|
'97bd0b06bdb0722c965ce1cfcc920f','b027097bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e',
|
||||||
|
'97bcf97c359801ec95f8c965cc920f','97bd0b06bdb0722c965ce1cfcc920f','b027097bd097c36b0b6fc9274c91aa',
|
||||||
|
'97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f','97bd0b06bdb0722c965ce1cfcc920f',
|
||||||
|
'b027097bd097c36b0b6fc9274c91aa','9778397bd19801ec9210c965cc920e','97b6b97bd19801ec95f8c965cc920f',
|
||||||
|
'97bd09801d98082c95f8e1cfcc920f','97bd097bd097c36b0b6fc9210c8dc2','9778397bd197c36c9210c9274c91aa',
|
||||||
|
'97b6b97bd19801ec95f8c965cc920e','97bd09801d98082c95f8e1cfcc920f','97bd097bd097c36b0b6fc9210c8dc2',
|
||||||
|
'9778397bd097c36c9210c9274c91aa','97b6b97bd19801ec95f8c965cc920e','97bcf97c3598082c95f8e1cfcc920f',
|
||||||
|
'97bd097bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c91aa','97b6b97bd19801ec9210c965cc920e',
|
||||||
|
'97bcf97c3598082c95f8c965cc920f','97bd097bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa',
|
||||||
|
'97b6b97bd19801ec9210c965cc920e','97bcf97c3598082c95f8c965cc920f','97bd097bd097c35b0b6fc920fb0722',
|
||||||
|
'9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f',
|
||||||
|
'97bd097bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e',
|
||||||
|
'97bcf97c359801ec95f8c965cc920f','97bd097bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa',
|
||||||
|
'97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f','97bd097bd07f595b0b6fc920fb0722',
|
||||||
|
'9778397bd097c36b0b6fc9210c8dc2','9778397bd19801ec9210c9274c920e','97b6b97bd19801ec95f8c965cc920f',
|
||||||
|
'97bd07f5307f595b0b0bc920fb0722','7f0e397bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c920e',
|
||||||
|
'97b6b97bd19801ec95f8c965cc920f','97bd07f5307f595b0b0bc920fb0722','7f0e397bd097c36b0b6fc9210c8dc2',
|
||||||
|
'9778397bd097c36c9210c9274c91aa','97b6b97bd19801ec9210c965cc920e','97bd07f1487f595b0b0bc920fb0722',
|
||||||
|
'7f0e397bd097c36b0b6fc9210c8dc2','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e',
|
||||||
|
'97bcf7f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa',
|
||||||
|
'97b6b97bd19801ec9210c965cc920e','97bcf7f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722',
|
||||||
|
'9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf7f1487f531b0b0bb0b6fb0722',
|
||||||
|
'7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e',
|
||||||
|
'97bcf7f1487f531b0b0bb0b6fb0722','7f0e397bd07f595b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa',
|
||||||
|
'97b6b97bd19801ec9210c9274c920e','97bcf7f0e47f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722',
|
||||||
|
'9778397bd097c36b0b6fc9210c91aa','97b6b97bd197c36c9210c9274c920e','97bcf7f0e47f531b0b0bb0b6fb0722',
|
||||||
|
'7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c920e',
|
||||||
|
'97b6b7f0e47f531b0723b0b6fb0722','7f0e37f5307f595b0b0bc920fb0722','7f0e397bd097c36b0b6fc9210c8dc2',
|
||||||
|
'9778397bd097c36b0b70c9274c91aa','97b6b7f0e47f531b0723b0b6fb0721','7f0e37f1487f595b0b0bb0b6fb0722',
|
||||||
|
'7f0e397bd097c35b0b6fc9210c8dc2','9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0b6fb0721',
|
||||||
|
'7f0e27f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa',
|
||||||
|
'97b6b7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722',
|
||||||
|
'9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722',
|
||||||
|
'7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0b6fb0721',
|
||||||
|
'7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9274c91aa',
|
||||||
|
'97b6b7f0e47f531b0723b0787b0721','7f0e27f0e47f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722',
|
||||||
|
'9778397bd097c36b0b6fc9210c91aa','97b6b7f0e47f149b0723b0787b0721','7f0e27f0e47f531b0723b0b6fb0722',
|
||||||
|
'7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9210c8dc2','977837f0e37f149b0723b0787b0721',
|
||||||
|
'7f07e7f0e47f531b0723b0b6fb0722','7f0e37f5307f595b0b0bc920fb0722','7f0e397bd097c35b0b6fc9210c8dc2',
|
||||||
|
'977837f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0721','7f0e37f1487f595b0b0bb0b6fb0722',
|
||||||
|
'7f0e397bd097c35b0b6fc9210c8dc2','977837f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721',
|
||||||
|
'7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','977837f0e37f14998082b0787b06bd',
|
||||||
|
'7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722',
|
||||||
|
'977837f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722',
|
||||||
|
'7f0e397bd07f595b0b0bc920fb0722','977837f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721',
|
||||||
|
'7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','977837f0e37f14998082b0787b06bd',
|
||||||
|
'7f07e7f0e47f149b0723b0787b0721','7f0e27f0e47f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722',
|
||||||
|
'977837f0e37f14998082b0723b06bd','7f07e7f0e37f149b0723b0787b0721','7f0e27f0e47f531b0723b0b6fb0722',
|
||||||
|
'7f0e397bd07f595b0b0bc920fb0722','977837f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b0721',
|
||||||
|
'7f07e7f0e47f531b0723b0b6fb0722','7f0e37f1487f595b0b0bb0b6fb0722','7f0e37f0e37f14898082b0723b02d5',
|
||||||
|
'7ec967f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0722','7f0e37f1487f531b0b0bb0b6fb0722',
|
||||||
|
'7f0e37f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721',
|
||||||
|
'7f0e37f1487f531b0b0bb0b6fb0722','7f0e37f0e37f14898082b072297c35','7ec967f0e37f14998082b0787b06bd',
|
||||||
|
'7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e37f0e37f14898082b072297c35',
|
||||||
|
'7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722',
|
||||||
|
'7f0e37f0e366aa89801eb072297c35','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f149b0723b0787b0721',
|
||||||
|
'7f0e27f1487f531b0b0bb0b6fb0722','7f0e37f0e366aa89801eb072297c35','7ec967f0e37f14998082b0723b06bd',
|
||||||
|
'7f07e7f0e47f149b0723b0787b0721','7f0e27f0e47f531b0723b0b6fb0722','7f0e37f0e366aa89801eb072297c35',
|
||||||
|
'7ec967f0e37f14998082b0723b06bd','7f07e7f0e37f14998083b0787b0721','7f0e27f0e47f531b0723b0b6fb0722',
|
||||||
|
'7f0e37f0e366aa89801eb072297c35','7ec967f0e37f14898082b0723b02d5','7f07e7f0e37f14998082b0787b0721',
|
||||||
|
'7f07e7f0e47f531b0723b0b6fb0722','7f0e36665b66aa89801e9808297c35','665f67f0e37f14898082b0723b02d5',
|
||||||
|
'7ec967f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0722','7f0e36665b66a449801e9808297c35',
|
||||||
|
'665f67f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721',
|
||||||
|
'7f0e36665b66a449801e9808297c35','665f67f0e37f14898082b072297c35','7ec967f0e37f14998082b0787b06bd',
|
||||||
|
'7f07e7f0e47f531b0723b0b6fb0721','7f0e26665b66a449801e9808297c35','665f67f0e37f1489801eb072297c35',
|
||||||
|
'7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722'],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字转中文速查表
|
||||||
|
* @Array Of Property
|
||||||
|
* @trans ['日','一','二','三','四','五','六','七','八','九','十']
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
nStr1:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341"],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期转农历称呼速查表
|
||||||
|
* @Array Of Property
|
||||||
|
* @trans ['初','十','廿','卅']
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
nStr2:["\u521d","\u5341","\u5eff","\u5345"],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月份转农历称呼速查表
|
||||||
|
* @Array Of Property
|
||||||
|
* @trans ['正','一','二','三','四','五','六','七','八','九','十','冬','腊']
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
nStr3:["\u6b63","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u51ac","\u814a"],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 农历节日
|
||||||
|
*/
|
||||||
|
lunarFestival:{"1-1":"春节","1-15":"上元节","2-2":"龙抬头","5-5":"端午","7-7":"七夕","7-15":"中元节","8-15":"中秋","9-9":"重阳","10-15":"下元节","12-8":"腊八","12-23":"小年"},
|
||||||
|
/**
|
||||||
|
* 公历节日
|
||||||
|
*/
|
||||||
|
solarFestival:{"1-1":"元旦","2-14":"情人节","3-8":"妇女节","3-12":"植树节","4-1":"愚人节","5-1":"劳动节","5-4":"青年节","6-1":"儿童节","7-1":"建党节","8-1":"建军节","9-10":"教师节","10-1":"国庆节","11-1":"万圣节","12-24":"平安夜","12-25":"圣诞节"},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回农历y年一整年的总天数
|
||||||
|
* @param lunar Year
|
||||||
|
* @return Number
|
||||||
|
* @eg:var count = calendar.lYearDays(1987) ;//count=387
|
||||||
|
*/
|
||||||
|
lYearDays:function(y) {
|
||||||
|
var i, sum = 348;
|
||||||
|
for(i=0x8000; i>0x8; i>>=1) { sum += (calendar.lunarInfo[y-1900] & i)? 1: 0; }
|
||||||
|
return(sum+calendar.leapDays(y));
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回农历y年闰月是哪个月;若y年没有闰月 则返回0
|
||||||
|
* @param lunar Year
|
||||||
|
* @return Number (0-12)
|
||||||
|
* @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6
|
||||||
|
*/
|
||||||
|
leapMonth:function(y) { //闰字编码 \u95f0
|
||||||
|
return(calendar.lunarInfo[y-1900] & 0xf);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回农历y年闰月的天数 若该年没有闰月则返回0
|
||||||
|
* @param lunar Year
|
||||||
|
* @return Number (0、29、30)
|
||||||
|
* @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29
|
||||||
|
*/
|
||||||
|
leapDays:function(y) {
|
||||||
|
if(calendar.leapMonth(y)) {
|
||||||
|
return((calendar.lunarInfo[y-1900] & 0x10000)? 30: 29);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法
|
||||||
|
* @param lunar Year
|
||||||
|
* @return Number (-1、29、30)
|
||||||
|
* @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29
|
||||||
|
*/
|
||||||
|
monthDays:function(y,m) {
|
||||||
|
if(m>12 || m<1) {return -1}//月份参数从1至12,参数错误返回-1
|
||||||
|
return( (calendar.lunarInfo[y-1900] & (0x10000>>m))? 30: 29 );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回公历(!)y年m月的天数
|
||||||
|
* @param solar Year
|
||||||
|
* @return Number (-1、28、29、30、31)
|
||||||
|
* @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30
|
||||||
|
*/
|
||||||
|
solarDays:function(y,m) {
|
||||||
|
if(m>12 || m<1) {return -1} //若参数错误 返回-1
|
||||||
|
var ms = m-1;
|
||||||
|
if(ms==1) { //2月份的闰平规律测算后确认返回28或29
|
||||||
|
return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28);
|
||||||
|
}else {
|
||||||
|
return(calendar.solarMonth[ms]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 农历年份转换为干支纪年
|
||||||
|
* @param lYear 农历年的年份数
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
toGanZhiYear:function(lYear) {
|
||||||
|
var ganKey = (lYear - 3) % 10;
|
||||||
|
var zhiKey = (lYear - 3) % 12;
|
||||||
|
if(ganKey == 0) ganKey = 10;//如果余数为0则为最后一个天干
|
||||||
|
if(zhiKey == 0) zhiKey = 12;//如果余数为0则为最后一个地支
|
||||||
|
return calendar.Gan[ganKey-1] + calendar.Zhi[zhiKey-1];
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公历月、日判断所属星座
|
||||||
|
* @param cMonth [description]
|
||||||
|
* @param cDay [description]
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
toAstro:function(cMonth,cDay) {
|
||||||
|
var s = "\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf";
|
||||||
|
var arr = [20,19,21,21,21,22,23,23,23,23,22,22];
|
||||||
|
return s.substr(cMonth*2 - (cDay < arr[cMonth-1] ? 2 : 0),2) + "\u5ea7";//座
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入offset偏移量返回干支
|
||||||
|
* @param offset 相对甲子的偏移量
|
||||||
|
* @return Cn string
|
||||||
|
*/
|
||||||
|
toGanZhi:function(offset) {
|
||||||
|
return calendar.Gan[offset%10] + calendar.Zhi[offset%12];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入公历(!)y年获得该年第n个节气的公历日期
|
||||||
|
* @param y公历年(1900-2100);n二十四节气中的第几个节气(1~24);从n=1(小寒)算起
|
||||||
|
* @return day Number
|
||||||
|
* @eg:var _24 = calendar.getTerm(1987,3) ;//_24=4;意即1987年2月4日立春
|
||||||
|
*/
|
||||||
|
getTerm:function(y,n) {
|
||||||
|
if(y<1900 || y>2100) {return -1;}
|
||||||
|
if(n<1 || n>24) {return -1;}
|
||||||
|
var _table = calendar.sTermInfo[y-1900];
|
||||||
|
var _info = [
|
||||||
|
parseInt('0x'+_table.substr(0,5)).toString() ,
|
||||||
|
parseInt('0x'+_table.substr(5,5)).toString(),
|
||||||
|
parseInt('0x'+_table.substr(10,5)).toString(),
|
||||||
|
parseInt('0x'+_table.substr(15,5)).toString(),
|
||||||
|
parseInt('0x'+_table.substr(20,5)).toString(),
|
||||||
|
parseInt('0x'+_table.substr(25,5)).toString()
|
||||||
|
];
|
||||||
|
var _calday = [
|
||||||
|
_info[0].substr(0,1),
|
||||||
|
_info[0].substr(1,2),
|
||||||
|
_info[0].substr(3,1),
|
||||||
|
_info[0].substr(4,2),
|
||||||
|
|
||||||
|
_info[1].substr(0,1),
|
||||||
|
_info[1].substr(1,2),
|
||||||
|
_info[1].substr(3,1),
|
||||||
|
_info[1].substr(4,2),
|
||||||
|
|
||||||
|
_info[2].substr(0,1),
|
||||||
|
_info[2].substr(1,2),
|
||||||
|
_info[2].substr(3,1),
|
||||||
|
_info[2].substr(4,2),
|
||||||
|
|
||||||
|
_info[3].substr(0,1),
|
||||||
|
_info[3].substr(1,2),
|
||||||
|
_info[3].substr(3,1),
|
||||||
|
_info[3].substr(4,2),
|
||||||
|
|
||||||
|
_info[4].substr(0,1),
|
||||||
|
_info[4].substr(1,2),
|
||||||
|
_info[4].substr(3,1),
|
||||||
|
_info[4].substr(4,2),
|
||||||
|
|
||||||
|
_info[5].substr(0,1),
|
||||||
|
_info[5].substr(1,2),
|
||||||
|
_info[5].substr(3,1),
|
||||||
|
_info[5].substr(4,2),
|
||||||
|
];
|
||||||
|
return parseInt(_calday[n-1]);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入农历数字月份返回汉语通俗表示法
|
||||||
|
* @param lunar month
|
||||||
|
* @return Cn string
|
||||||
|
* @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='腊月'
|
||||||
|
*/
|
||||||
|
toChinaMonth:function(m) { // 月 => \u6708
|
||||||
|
if(m>12 || m<1) {return -1} //若参数错误 返回-1
|
||||||
|
var s = calendar.nStr3[m-1];
|
||||||
|
s+= "\u6708";//加上月字
|
||||||
|
return s;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入年份月份返回第n个星期日的日期数字
|
||||||
|
* @param y 年份
|
||||||
|
* @param m 月份
|
||||||
|
* @param n 第几个星期日 ( 5>n>0的数字 一个月一般就4个星期日,最多5个)
|
||||||
|
* @return 日期数字;3 = getSunday(2017,9,1); 九月的第一个星期日是3号;超出返回-1
|
||||||
|
*/
|
||||||
|
getSunday(y,m,n){
|
||||||
|
var d = new Date(y+'-' + m + '-1');
|
||||||
|
var d2= new Date(y+'-'+(m+1)+'-1');
|
||||||
|
d2.setDate(0);
|
||||||
|
var maxDay = d2.getDate();//传入月份的最后一天
|
||||||
|
|
||||||
|
var week = d.getDay();
|
||||||
|
var first = 1;
|
||||||
|
if(week>0) first = d.getDate() + (7 - week);
|
||||||
|
var result = (n-1)*7 + first;
|
||||||
|
if(result>maxDay) return -1;
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 传入农历日期数字返回汉字表示法
|
||||||
|
* @param lunar day
|
||||||
|
* @return Cn string
|
||||||
|
* @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿一'
|
||||||
|
*/
|
||||||
|
toChinaDay:function(d){ //日 => \u65e5
|
||||||
|
var s;
|
||||||
|
switch (d) {
|
||||||
|
case 10:
|
||||||
|
s = '\u521d\u5341'; break;
|
||||||
|
case 20:
|
||||||
|
s = '\u4e8c\u5341'; break;
|
||||||
|
break;
|
||||||
|
case 30:
|
||||||
|
s = '\u4e09\u5341'; break;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
s = calendar.nStr2[Math.floor(d/10)];
|
||||||
|
s += calendar.nStr1[d%10];
|
||||||
|
}
|
||||||
|
return(s);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年份转生肖[!仅能大致转换] => 精确划分生肖分界线是“立春”
|
||||||
|
* @param y year
|
||||||
|
* @return Cn string
|
||||||
|
* @eg:var animal = calendar.getAnimal(1987) ;//animal='兔'
|
||||||
|
*/
|
||||||
|
getAnimal: function(y) {
|
||||||
|
return calendar.Animals[(y - 4) % 12]
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 判断 当天为 此年的第几天
|
||||||
|
* @param date
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
getCyclical:function(date){
|
||||||
|
var nowDate = new Date(date);
|
||||||
|
var initTime = new Date(date);
|
||||||
|
initTime.setMonth(0); // 本年初始月份
|
||||||
|
initTime.setDate(1); // 本年初始时间
|
||||||
|
var differenceVal = nowDate - initTime ; // 今天的时间减去本年开始时间,获得相差的时间
|
||||||
|
return Math.ceil(differenceVal/(24*60*60*1000));
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 传入阳历年月日获得详细的公历、农历object信息 <=>JSON
|
||||||
|
* @param y solar year
|
||||||
|
* @param m solar month
|
||||||
|
* @param d solar day
|
||||||
|
* @return JSON object
|
||||||
|
* @eg:console.log(calendar.solar2lunar(1987,11,01));
|
||||||
|
*/
|
||||||
|
solar2lunar:function (y,m,d) { //参数区间1900.1.31~2100.12.31
|
||||||
|
//年份限定、上限
|
||||||
|
if(y<1900 || y>2100) {
|
||||||
|
return -1;// undefined转换为数字变为NaN
|
||||||
|
}
|
||||||
|
//公历传参最下限
|
||||||
|
if(y==1900&&m==1&&d<31) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//未传参 获得当天
|
||||||
|
if(!y) {
|
||||||
|
var objDate = new Date();
|
||||||
|
}else {
|
||||||
|
var objDate = new Date(y,parseInt(m)-1,d)
|
||||||
|
}
|
||||||
|
var i, leap=0, temp=0;
|
||||||
|
//修正ymd参数
|
||||||
|
var y = objDate.getFullYear(),
|
||||||
|
m = objDate.getMonth()+1,
|
||||||
|
d = objDate.getDate();
|
||||||
|
var offset = (Date.UTC(objDate.getFullYear(),objDate.getMonth(),objDate.getDate()) - Date.UTC(1900,0,31))/86400000;
|
||||||
|
for(i=1900; i<2101 && offset>0; i++) {
|
||||||
|
temp = calendar.lYearDays(i);
|
||||||
|
offset -= temp;
|
||||||
|
}
|
||||||
|
if(offset<0) {
|
||||||
|
offset+=temp; i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
//是否今天
|
||||||
|
var isTodayObj = new Date(),
|
||||||
|
isToday = false;
|
||||||
|
if(isTodayObj.getFullYear()==y && isTodayObj.getMonth()+1==m && isTodayObj.getDate()==d) {
|
||||||
|
isToday = true;
|
||||||
|
}
|
||||||
|
//星期几
|
||||||
|
var nWeek = objDate.getDay(),
|
||||||
|
cWeek = calendar.nStr1[nWeek];
|
||||||
|
//数字表示周几顺应天朝周一开始的惯例
|
||||||
|
if(nWeek==0) {
|
||||||
|
nWeek = 7;
|
||||||
|
}
|
||||||
|
//农历年
|
||||||
|
var year = i;
|
||||||
|
var leap = calendar.leapMonth(i); //闰哪个月
|
||||||
|
var isLeap = false;
|
||||||
|
|
||||||
|
//效验闰月
|
||||||
|
for(i=1; i<13 && offset>0; i++) {
|
||||||
|
//闰月
|
||||||
|
if(leap>0 && i==(leap+1) && isLeap==false){
|
||||||
|
--i;
|
||||||
|
isLeap = true; temp = calendar.leapDays(year); //计算农历闰月天数
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
temp = calendar.monthDays(year, i);//计算农历普通月天数
|
||||||
|
}
|
||||||
|
//解除闰月
|
||||||
|
if(isLeap==true && i==(leap+1)) { isLeap = false; }
|
||||||
|
offset -= temp;
|
||||||
|
}
|
||||||
|
// 闰月导致数组下标重叠取反
|
||||||
|
if(offset==0 && leap>0 && i==leap+1)
|
||||||
|
{
|
||||||
|
if(isLeap){
|
||||||
|
isLeap = false;
|
||||||
|
}else{
|
||||||
|
isLeap = true; --i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(offset<0)
|
||||||
|
{
|
||||||
|
offset += temp;
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
//农历月
|
||||||
|
var month = i;
|
||||||
|
//农历日
|
||||||
|
var day = offset +1;
|
||||||
|
//天干地支处理
|
||||||
|
var sm = m-1;
|
||||||
|
var gzY = calendar.toGanZhiYear(year);
|
||||||
|
|
||||||
|
// 当月的两个节气
|
||||||
|
// bugfix-2017-7-24 11:03:38 use lunar Year Param `y` Not `year`
|
||||||
|
var firstNode = calendar.getTerm(y,(m*2-1));//返回当月「节」为几日开始
|
||||||
|
var secondNode = calendar.getTerm(y,(m*2));//返回当月「节」为几日开始
|
||||||
|
|
||||||
|
// 依据12节气修正干支月
|
||||||
|
var gzM = calendar.toGanZhi((y-1900)*12+m+11);
|
||||||
|
if(d>=firstNode) {
|
||||||
|
gzM = calendar.toGanZhi((y-1900)*12+m+12);
|
||||||
|
}
|
||||||
|
|
||||||
|
//传入的日期的节气与否
|
||||||
|
var isTerm = false;
|
||||||
|
var Term = null;
|
||||||
|
if(firstNode==d) {
|
||||||
|
isTerm = true;
|
||||||
|
Term = calendar.solarTerm[m*2-2];
|
||||||
|
}
|
||||||
|
if(secondNode==d) {
|
||||||
|
isTerm = true;
|
||||||
|
Term = calendar.solarTerm[m*2-1];
|
||||||
|
}
|
||||||
|
//日柱 当月一日与 1900/1/1 相差天数
|
||||||
|
var dayCyclical = Date.UTC(y,sm,1,0,0,0,0)/86400000+25567+10;
|
||||||
|
var gzD = calendar.toGanZhi(dayCyclical+d-1);
|
||||||
|
//(年-1900) * 5 + (年-1900+3) / 4 + 9 + 当年年初起累积日数
|
||||||
|
// var dayCyclical = (y-1900)*5 + (y-1900+3)/4 + 9 +(this.getCyclical(y+'-'+m+'-'+d))
|
||||||
|
// var gzD = calendar.toGanZhi(dayCyclical-1);
|
||||||
|
//该日期所属的星座
|
||||||
|
var astro = calendar.toAstro(m,d);
|
||||||
|
//该日期所有的节日
|
||||||
|
var festival = [];
|
||||||
|
//农历传统节日
|
||||||
|
var lf = calendar.lunarFestival[month+'-'+day];
|
||||||
|
if(lf != undefined && lf != null && lf != '') festival.push(lf);
|
||||||
|
if(month==12 && (isLeap?day == calendar.leapDays(year):calendar.monthDays(month-1)==29?day == 30:day == 29)) festival.push('除夕');
|
||||||
|
|
||||||
|
//公历节日
|
||||||
|
var sf = calendar.solarFestival[m+'-'+d];
|
||||||
|
if(sf != undefined && sf != null && sf != '') festival.push(sf);
|
||||||
|
if(m==5 && d==calendar.getSunday(y,m,2)) festival.push('母亲节');
|
||||||
|
if(m==6 && d==calendar.getSunday(y,m,3)) festival.push('父亲节');
|
||||||
|
|
||||||
|
return {'lYear':year,'lMonth':month,'lDay':day,'isFestival':festival.length>0,'festival':festival,'Animal':calendar.getAnimal(year),'IMonthCn':(isLeap?"\u95f0":'')+calendar.toChinaMonth(month),'IDayCn':calendar.toChinaDay(day),'cYear':y,'cMonth':m,'cDay':d,'gzYear':gzY,'gzMonth':gzM,'gzDay':gzD,'isToday':isToday,'isLeap':isLeap,'nWeek':nWeek,'ncWeek':"\u661f\u671f"+cWeek,'isTerm':isTerm,'Term':Term,'astro':astro};
|
||||||
|
},
|
||||||
|
|
||||||
|
getLunar:function (date) {
|
||||||
|
var D;
|
||||||
|
if(date==undefined){
|
||||||
|
D = new Date();
|
||||||
|
}else{
|
||||||
|
D = new Date(date);
|
||||||
|
}
|
||||||
|
D.setHours(D.getHours()+8)//根据国际UTC标准,中国时区应为:UTC+8
|
||||||
|
var cY = D.getUTCFullYear();
|
||||||
|
var cM = D.getUTCMonth()+1;
|
||||||
|
var cD = D.getUTCDate();
|
||||||
|
//console.log('getLunar:月'+cM+'--'+cD+'日')
|
||||||
|
return calendar.solar2lunar(cY,cM,cD);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息 <=>JSON
|
||||||
|
* @param y lunar year
|
||||||
|
* @param m lunar month
|
||||||
|
* @param d lunar day
|
||||||
|
* @param isLeapMonth lunar month is leap or not.[如果是农历闰月第四个参数赋值true即可]
|
||||||
|
* @return JSON object
|
||||||
|
* @eg:console.log(calendar.lunar2solar(1987,9,10));
|
||||||
|
*/
|
||||||
|
lunar2solar:function(y,m,d,isLeapMonth) { //参数区间1900.1.31~2100.12.1
|
||||||
|
var isLeapMonth = !!isLeapMonth;
|
||||||
|
var leapOffset = 0;
|
||||||
|
var leapMonth = calendar.leapMonth(y);
|
||||||
|
var leapDay = calendar.leapDays(y);
|
||||||
|
if(isLeapMonth&&(leapMonth!=m)) {return -1;}//传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同
|
||||||
|
if(y==2100&&m==12&&d>1 || y==1900&&m==1&&d<31) {return -1;}//超出了最大极限值
|
||||||
|
var day = calendar.monthDays(y,m);
|
||||||
|
var _day = day;
|
||||||
|
//bugFix 2016-9-25
|
||||||
|
//if month is leap, _day use leapDays method
|
||||||
|
if(isLeapMonth) {
|
||||||
|
_day = calendar.leapDays(y,m);
|
||||||
|
}
|
||||||
|
if(y < 1900 || y > 2100 || d > _day) {return -1;}//参数合法性效验
|
||||||
|
|
||||||
|
//计算农历的时间差
|
||||||
|
var offset = 0;
|
||||||
|
for(var i=1900;i<y;i++) {
|
||||||
|
offset+=calendar.lYearDays(i);
|
||||||
|
}
|
||||||
|
var leap = 0,isAdd= false;
|
||||||
|
for(var i=1;i<m;i++) {
|
||||||
|
leap = calendar.leapMonth(y);
|
||||||
|
if(!isAdd) {//处理闰月
|
||||||
|
if(leap<=i && leap>0) {
|
||||||
|
offset+=calendar.leapDays(y);isAdd = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
offset+=calendar.monthDays(y,i);
|
||||||
|
}
|
||||||
|
//转换闰月农历 需补充该年闰月的前一个月的时差
|
||||||
|
if(isLeapMonth) {offset+=day;}
|
||||||
|
//1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点)
|
||||||
|
var stmap = Date.UTC(1900,1,30,0,0,0);
|
||||||
|
var calObj = new Date((offset+d-31)*86400000+stmap);
|
||||||
|
var cY = calObj.getUTCFullYear();
|
||||||
|
var cM = calObj.getUTCMonth()+1;
|
||||||
|
var cD = calObj.getUTCDate();
|
||||||
|
|
||||||
|
return calendar.solar2lunar(cY,cM,cD);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 传入农历日期
|
||||||
|
* @param date 类型String,格式:L2017-01-02;闰月:LR2017-06-03
|
||||||
|
* @returns {*|JSON}
|
||||||
|
*/
|
||||||
|
getSolar(date) {
|
||||||
|
if(date == undefined || date == null || date == '' || date.indexOf('L') == -1) return null;
|
||||||
|
var isLeapMonth = date.indexOf('R')>-1;
|
||||||
|
var D = date.replace(/L/,'').replace(/R/,'').split('-');
|
||||||
|
var cY = parseInt(D[0]);
|
||||||
|
var cM = parseInt(D[1]);
|
||||||
|
var cD = parseInt(D[2]);
|
||||||
|
return calendar.lunar2solar(cY,cM,cD,isLeapMonth);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default { calendar }
|
||||||
@@ -33,6 +33,10 @@ const tableProps = [
|
|||||||
prop: 'opPeopleName',
|
prop: 'opPeopleName',
|
||||||
label: '操作人'
|
label: '操作人'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
prop: 'deptName',
|
||||||
|
label: '部门'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prop: 'opType',
|
prop: 'opType',
|
||||||
label: '操作类型',
|
label: '操作类型',
|
||||||
|
|||||||
@@ -2,13 +2,19 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2024-07-01 14:54:06
|
* @Date: 2024-07-01 14:54:06
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-27 10:18:54
|
* @LastEditTime: 2025-11-24 16:11:20
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<el-row :gutter="10" style="background-color: #f2f4f9">
|
<div
|
||||||
<!--部门数据-->
|
class="app-container"
|
||||||
<el-col :span="4">
|
style="
|
||||||
|
background-color: #f2f4f9;
|
||||||
|
padding: 0;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 5fr;
|
||||||
|
gap: 10px;
|
||||||
|
">
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="deptName"
|
v-model="deptName"
|
||||||
@@ -23,24 +29,32 @@
|
|||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
:filter-node-method="filterNode"
|
:filter-node-method="filterNode"
|
||||||
ref="tree"
|
ref="tree"
|
||||||
|
node-key="id"
|
||||||
default-expand-all
|
default-expand-all
|
||||||
highlight-current
|
highlight-current
|
||||||
@node-click="handleNodeClick" />
|
@node-click="handleNodeClick" />
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
|
||||||
<el-col :span="20">
|
|
||||||
<div class="groupTeamScheduling">
|
<div class="groupTeamScheduling">
|
||||||
<div class="operationArea">
|
<div class="operationArea">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="16">
|
<el-col :span="6">
|
||||||
<div style="height: 40px; font-size: 16px">
|
<div style="height: 40px; font-size: 16px">
|
||||||
<span style="color: #409eff; font-weight: 600">
|
<span style="color: #409eff; font-weight: 600">
|
||||||
{{ showDeptName }}
|
{{ showDeptName }}
|
||||||
</span>
|
</span>
|
||||||
节假日设置
|
节假日设置
|
||||||
|
<span
|
||||||
|
:style="{
|
||||||
|
color: inherited ? '#67c23a' : '#b5b839',
|
||||||
|
fontSize: '12px',
|
||||||
|
fontWeight: 600,
|
||||||
|
}"
|
||||||
|
v-show="ishasParent">
|
||||||
|
{{ inherited ? '继承模式' : '自定义模式' }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="18" v-if="!ishasParent">
|
||||||
<div style="float: right">
|
<div style="float: right">
|
||||||
<el-button
|
<el-button
|
||||||
size="small"
|
size="small"
|
||||||
@@ -58,6 +72,39 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="18" v-else style="text-align: right">
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
:disabled="inherited"
|
||||||
|
v-hasPermi="['base:group-holiday:create']"
|
||||||
|
@click="addHoliday">
|
||||||
|
新增节假日
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="success"
|
||||||
|
:disabled="inherited"
|
||||||
|
v-hasPermi="['base:group-holiday:update']"
|
||||||
|
@click="reExtends">
|
||||||
|
恢复继承
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="warning"
|
||||||
|
:disabled="!inherited"
|
||||||
|
v-hasPermi="['base:group-holiday:update']"
|
||||||
|
@click="disExtends">
|
||||||
|
解除继承
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
:disabled="inherited"
|
||||||
|
v-hasPermi="['base:group-holiday-log:query']"
|
||||||
|
@click="holidayLog">
|
||||||
|
节假日变更记录
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<div class="operationArea">
|
<div class="operationArea">
|
||||||
@@ -73,6 +120,24 @@
|
|||||||
:clearable="false"
|
:clearable="false"
|
||||||
style="width: 120px"></el-date-picker>
|
style="width: 120px"></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="继承上一级的节假日" v-show="ishasParent">
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
background-color: #67c23a;
|
||||||
|
border-radius: 3px;
|
||||||
|
"></div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="本级自定义的节假日" v-show="ishasParent">
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
background-color: #b5b839;
|
||||||
|
border-radius: 3px;
|
||||||
|
"></div>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item style="float: right">
|
<el-form-item style="float: right">
|
||||||
<el-button
|
<el-button
|
||||||
size="small"
|
size="small"
|
||||||
@@ -82,24 +147,64 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
<div v-if="!ishasParent">
|
||||||
<el-tag
|
<el-tag
|
||||||
v-if="topDeptId == deptId"
|
|
||||||
type="warning"
|
type="warning"
|
||||||
closable
|
closable
|
||||||
|
v-if="showTag1"
|
||||||
|
@close="handleClose(1)"
|
||||||
style="margin-bottom: 10px; color: black">
|
style="margin-bottom: 10px; color: black">
|
||||||
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
||||||
当前节假日设置为组织架构中最高层级配置,默认自动继承至下属部门。子部门可选择
|
当前节假日设置为组织架构中最高层级配置,默认自动继承至下属部门。子部门可选择
|
||||||
<span style="color: red">解除继承</span>
|
<span style="color: red">解除继承</span>
|
||||||
设置后进行独立修改,复制后不再继承上级设置
|
设置后进行独立修改,解除后不再继承上级设置
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div v-if="inherited">
|
||||||
|
<el-tag
|
||||||
|
type="warning"
|
||||||
|
closable
|
||||||
|
v-if="showTag2"
|
||||||
|
@close="handleClose(2)"
|
||||||
|
style="margin-bottom: 10px; color: black">
|
||||||
|
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
||||||
|
当前部门继承上级节假日设置,默认不可修改。可通过
|
||||||
|
<span style="color: red">解除继承</span>
|
||||||
|
进行自定义,解除后将不再继承。
|
||||||
|
</el-tag>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<el-tag
|
||||||
|
type="warning"
|
||||||
|
closable
|
||||||
|
v-if="showTag3"
|
||||||
|
@close="handleClose(3)"
|
||||||
|
style="margin-bottom: 10px; color: black">
|
||||||
|
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
||||||
|
当前部门已解除继承,节假日可自由配置。点击
|
||||||
|
<span style="color: red">恢复继承</span>
|
||||||
|
将清空当前设置并同步上级节假日。
|
||||||
|
</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- 日历区域 -->
|
<!-- 日历区域 -->
|
||||||
<div class="calenderArea">
|
<div class="calenderArea">
|
||||||
<el-calendar v-model="startDay">
|
<el-calendar v-model="startDay">
|
||||||
<template slot="dateCell" slot-scope="{ data }">
|
<template slot="dateCell" slot-scope="{ data }">
|
||||||
<div v-if="data.type === 'current-month'">
|
<div v-if="data.type === 'current-month'">
|
||||||
<!-- 日期 -->
|
<!-- 日期 -->
|
||||||
<div class="dateStyle">
|
<div
|
||||||
|
class="dateStyle"
|
||||||
|
@click="
|
||||||
|
new Date(data.day).getTime() >=
|
||||||
|
new Date().setHours(0, 0, 0, 0) &&
|
||||||
|
(!ishasParent || !inherited) &&
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
|
?.isHoliday &&
|
||||||
|
showDetail(HolidayList[Number(data.day.split('-')[2]) - 1])
|
||||||
|
">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<!-- 公历和农历 -->
|
<!-- 公历和农历 -->
|
||||||
<el-col :span="18">
|
<el-col :span="18">
|
||||||
@@ -129,25 +234,29 @@
|
|||||||
<el-col
|
<el-col
|
||||||
:span="24"
|
:span="24"
|
||||||
v-if="
|
v-if="
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
HolidayList[Number(data.day.split('-')[2]) - 1]?.isHoliday
|
||||||
?.isHoliday
|
|
||||||
">
|
">
|
||||||
<div
|
<div
|
||||||
class="holiday-div"
|
class="holiday-div"
|
||||||
@click="
|
:style="{
|
||||||
new Date(data.day).getTime() > Date.now() &&
|
backgroundColor: ishasParent
|
||||||
showDetail(
|
? HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
.isInherit
|
||||||
.holidayId
|
? '#67c23a'
|
||||||
)
|
: '#b5b839'
|
||||||
">
|
: '',
|
||||||
|
}">
|
||||||
{{
|
{{
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
?.holidayName
|
?.holidayName
|
||||||
}}
|
}}
|
||||||
<span
|
<span
|
||||||
class="holiday-div-btn"
|
class="holiday-div-btn"
|
||||||
v-if="new Date(data.day).getTime() > Date.now()">
|
v-if="
|
||||||
|
(!ishasParent || !inherited) &&
|
||||||
|
new Date(data.day).getTime() >=
|
||||||
|
new Date().setHours(0, 0, 0, 0)
|
||||||
|
">
|
||||||
<i class="el-icon-more" style="color: #fff"></i>
|
<i class="el-icon-more" style="color: #fff"></i>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -171,7 +280,6 @@
|
|||||||
</el-calendar>
|
</el-calendar>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
|
||||||
<base-dialog
|
<base-dialog
|
||||||
:dialogTitle="dialogTitle"
|
:dialogTitle="dialogTitle"
|
||||||
:dialogVisible="addOrUpdateVisible"
|
:dialogVisible="addOrUpdateVisible"
|
||||||
@@ -179,6 +287,7 @@
|
|||||||
@confirm="handleConfirm"
|
@confirm="handleConfirm"
|
||||||
:before-close="cancel"
|
:before-close="cancel"
|
||||||
:destroy-on-close="true"
|
:destroy-on-close="true"
|
||||||
|
class="addDialog"
|
||||||
width="40%">
|
width="40%">
|
||||||
<add-or-updata
|
<add-or-updata
|
||||||
ref="addOrUpdataRef"
|
ref="addOrUpdataRef"
|
||||||
@@ -244,7 +353,7 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</base-dialog>
|
</base-dialog>
|
||||||
</el-row>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -252,7 +361,14 @@ import moment from 'moment';
|
|||||||
import { solarToLunar } from 'chinese-lunar';
|
import { solarToLunar } from 'chinese-lunar';
|
||||||
|
|
||||||
import { getUserProfile } from '@/api/system/user';
|
import { getUserProfile } from '@/api/system/user';
|
||||||
import { deptHolidayList, getEnableData } from '@/api/group/holidaySetting';
|
import {
|
||||||
|
deptHolidayList,
|
||||||
|
getEnableData,
|
||||||
|
disExtends,
|
||||||
|
reExtends,
|
||||||
|
updateSchedule,
|
||||||
|
getSet,
|
||||||
|
} from '@/api/group/holidaySetting';
|
||||||
|
|
||||||
import addOrUpdata from './add-or-updata.vue';
|
import addOrUpdata from './add-or-updata.vue';
|
||||||
import holidayLog from './holidayLog';
|
import holidayLog from './holidayLog';
|
||||||
@@ -274,7 +390,9 @@ export default {
|
|||||||
// 选择的部门名称
|
// 选择的部门名称
|
||||||
showDeptName: undefined,
|
showDeptName: undefined,
|
||||||
topDeptId: undefined, // 保存当前用户的部门id为最高级部门id
|
topDeptId: undefined, // 保存当前用户的部门id为最高级部门id
|
||||||
|
parentId: undefined, // 保存部门点击时对象的父id,用于解除和恢复继承
|
||||||
deptId: undefined,
|
deptId: undefined,
|
||||||
|
ishasParent: false, // 判断是否有上级,false,则表示为最高级
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
label: 'name',
|
label: 'name',
|
||||||
@@ -283,6 +401,10 @@ export default {
|
|||||||
addOrUpdateVisible: false,
|
addOrUpdateVisible: false,
|
||||||
detail: false,
|
detail: false,
|
||||||
logVisible: false,
|
logVisible: false,
|
||||||
|
inherited: true, //该部门是否为继承状态
|
||||||
|
showTag1: true, //tag标签是否显示的
|
||||||
|
showTag2: true,
|
||||||
|
showTag3: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -298,9 +420,9 @@ export default {
|
|||||||
this.showDeptName = response.data.dept.name || '';
|
this.showDeptName = response.data.dept.name || '';
|
||||||
this.topDeptId = response.data.dept.id || ''; // 保存当前用户的部门id为最高级部门id
|
this.topDeptId = response.data.dept.id || ''; // 保存当前用户的部门id为最高级部门id
|
||||||
this.deptId = response.data.dept.id || '';
|
this.deptId = response.data.dept.id || '';
|
||||||
this.getHolidayPage();
|
|
||||||
});
|
|
||||||
this.getTreeselect();
|
this.getTreeselect();
|
||||||
|
this.getSet();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getHolidayPage() {
|
getHolidayPage() {
|
||||||
@@ -329,10 +451,52 @@ export default {
|
|||||||
/** 查询部门下拉树结构 */
|
/** 查询部门下拉树结构 */
|
||||||
getTreeselect() {
|
getTreeselect() {
|
||||||
getEnableData().then((response) => {
|
getEnableData().then((response) => {
|
||||||
|
// 遍历部门,判断当前帐号的部门是否有为最上级
|
||||||
|
const nowDept = response.data.filter((i) => i.id == this.topDeptId);
|
||||||
|
this.ishasParent = nowDept[0].hasParent;
|
||||||
|
this.parentId = nowDept[0].parentId;
|
||||||
|
|
||||||
// 处理 deptOptions 参数
|
// 处理 deptOptions 参数
|
||||||
this.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);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//大整数精度丢失
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
// 根据部门id查询该部门是否是继承
|
||||||
|
getSet() {
|
||||||
|
getSet({ id: this.deptId }).then((res) => {
|
||||||
|
this.inherited = res.data;
|
||||||
|
});
|
||||||
|
this.getHolidayPage();
|
||||||
},
|
},
|
||||||
// 筛选节点
|
// 筛选节点
|
||||||
filterNode(value, data) {
|
filterNode(value, data) {
|
||||||
@@ -343,6 +507,11 @@ export default {
|
|||||||
handleNodeClick(data) {
|
handleNodeClick(data) {
|
||||||
this.deptId = data.id;
|
this.deptId = data.id;
|
||||||
this.showDeptName = data.name;
|
this.showDeptName = data.name;
|
||||||
|
this.ishasParent = data.hasParent;
|
||||||
|
this.parentId = data.parentId;
|
||||||
|
this.getSet();
|
||||||
|
this.showTag1 = true;
|
||||||
|
this.showTag2 = true;
|
||||||
this.getHolidayPage();
|
this.getHolidayPage();
|
||||||
},
|
},
|
||||||
//获取农历
|
//获取农历
|
||||||
@@ -414,7 +583,107 @@ export default {
|
|||||||
this.detail = false;
|
this.detail = false;
|
||||||
this.dialogTitle = '新增节假日';
|
this.dialogTitle = '新增节假日';
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdataRef.init(this.deptId);
|
this.$refs.addOrUpdataRef.init(this.deptId, {
|
||||||
|
inherited: this.inherited,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
disExtends() {
|
||||||
|
this.$confirm(
|
||||||
|
'当前节假日设置继承自上级部门,解除继承后将不再自动同步上级设置。<br/>系统将保留当前节假日配置作为初始数据,您可以自定义修改。<br/>是否确认解除继承?',
|
||||||
|
'解除继承',
|
||||||
|
{
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
confirmButtonText: '确认解除',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
disExtends({ id: this.deptId, pid: this.parentId }).then((res) => {
|
||||||
|
if (!res.data.updateFlag) {
|
||||||
|
this.$modal.msgSuccess('操作成功');
|
||||||
|
this.getSet();
|
||||||
|
} else {
|
||||||
|
this.$confirm(
|
||||||
|
'新增节假日影响已有排班计划,是否立即更新?',
|
||||||
|
'更新排班',
|
||||||
|
{
|
||||||
|
confirmButtonText: '立即更新',
|
||||||
|
cancelButtonText: '暂不更新',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
||||||
|
this.$modal.msgSuccess('更新成功');
|
||||||
|
this.getSet();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
reExtends() {
|
||||||
|
this.$confirm(
|
||||||
|
'恢复继承后,当前部门将重新同步未来时间的上级部门的节假日设置,现有自定义配置将被清空并替换为上级设置,不可恢复。<br/>是否确认继续?',
|
||||||
|
'恢复继承',
|
||||||
|
{
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
confirmButtonText: '确认恢复继承',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
reExtends({ id: this.deptId, pid: this.parentId }).then((res) => {
|
||||||
|
if (!res.data.updateFlag) {
|
||||||
|
this.$modal.msgSuccess('操作成功');
|
||||||
|
this.getSet();
|
||||||
|
} else {
|
||||||
|
this.$confirm(
|
||||||
|
'新增节假日影响已有排班计划,是否立即更新?',
|
||||||
|
'更新排班',
|
||||||
|
{
|
||||||
|
confirmButtonText: '立即更新',
|
||||||
|
cancelButtonText: '暂不更新',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
||||||
|
this.$modal.msgSuccess('更新成功');
|
||||||
|
this.getSet();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
|
this.getSet();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
holidayLog() {
|
holidayLog() {
|
||||||
@@ -434,12 +703,12 @@ export default {
|
|||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
this.$refs.addOrUpdataRef.dataFormSubmit();
|
this.$refs.addOrUpdataRef.dataFormSubmit();
|
||||||
},
|
},
|
||||||
showDetail(id) {
|
showDetail(val) {
|
||||||
this.addOrUpdateVisible = true;
|
this.addOrUpdateVisible = true;
|
||||||
this.detail = true;
|
this.detail = true;
|
||||||
this.dialogTitle = '节假日详情';
|
this.dialogTitle = '节假日详情';
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdataRef.init(this.deptId, id, true);
|
this.$refs.addOrUpdataRef.init(this.deptId, val, true, this.inherited); //编辑的时候,该部门如果是自定义的,但这个val数据是继承的,修改之后,则变成自定义的inherited
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
editHoliday() {
|
editHoliday() {
|
||||||
@@ -456,6 +725,15 @@ export default {
|
|||||||
cancelLog() {
|
cancelLog() {
|
||||||
this.logVisible = false;
|
this.logVisible = false;
|
||||||
},
|
},
|
||||||
|
handleClose(val) {
|
||||||
|
if (val == 1) {
|
||||||
|
this.showTag1 = false;
|
||||||
|
} else if (val == 2) {
|
||||||
|
this.showTag2 = false;
|
||||||
|
} else {
|
||||||
|
this.showTag3 = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -463,7 +741,7 @@ export default {
|
|||||||
.head-container {
|
.head-container {
|
||||||
padding: 20px 10px 0;
|
padding: 20px 10px 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
min-height: calc(100vh - 120px - 8px);
|
height: 100%;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
.groupTeamScheduling {
|
.groupTeamScheduling {
|
||||||
@@ -561,4 +839,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.addDialog {
|
||||||
|
.el-dialog__body {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||