Compare commits
8 Commits
70a0fbb170
...
projects/s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ade2dfcdc | ||
|
|
852a3f17a0 | ||
| cba14b1f61 | |||
|
|
33c00785df | ||
|
|
d8acff21e3 | ||
|
|
c0a38c568f | ||
| 6a8a9ed28d | |||
| a2213f4f7e |
6
.env.dev
@@ -12,10 +12,8 @@ ENV = 'development'
|
|||||||
VUE_APP_TITLE = 智能监控分析系统
|
VUE_APP_TITLE = 智能监控分析系统
|
||||||
|
|
||||||
# 芋道管理系统/开发环境
|
# 芋道管理系统/开发环境
|
||||||
# VUE_APP_BASE_API = 'http://172.16.33.187:48082'
|
VUE_APP_BASE_API = 'http://172.16.32.76:48080'
|
||||||
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": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --mode dev",
|
"dev": "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",
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
"bpmn-js-token-simulation": "0.10.0",
|
"bpmn-js-token-simulation": "0.10.0",
|
||||||
"chinese-lunar": "^0.1.4",
|
"chinese-lunar": "^0.1.4",
|
||||||
"clipboard": "2.0.8",
|
"clipboard": "2.0.8",
|
||||||
"code-brick-zj": "^1.1.1",
|
"code-brick-zj": "^1.0.2",
|
||||||
"core-js": "^3.26.0",
|
"core-js": "^3.26.0",
|
||||||
"crypto-js": "^4.0.0",
|
"crypto-js": "^4.0.0",
|
||||||
"diagram-js": "^12.3.0",
|
"diagram-js": "^12.3.0",
|
||||||
|
|||||||
@@ -59,34 +59,3 @@ export function getEquipmentAll() {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTree(query) {
|
|
||||||
return request({
|
|
||||||
url: '/base/factory/getTreeSimple',
|
|
||||||
method: 'get',
|
|
||||||
params: query,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getEquipmentOverall(data) {
|
|
||||||
return request({
|
|
||||||
url: '/monitoring/equipment-overall/get',
|
|
||||||
method: 'post',
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getParamMonitor(data) {
|
|
||||||
return request({
|
|
||||||
url: '/monitoring/equipment-monitor/paramMonitor',
|
|
||||||
method: 'post',
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
export function getAlarmDet(data) {
|
|
||||||
return request({
|
|
||||||
url: 'monitoring/equipment-overall/alarmDet',
|
|
||||||
method: 'post',
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -52,5 +52,3 @@ export function exportEquipmentTypeExcel(query) {
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,15 +50,6 @@ 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) {
|
||||||
@@ -102,17 +93,3 @@ export function getProcessAutoReportNew(data) {
|
|||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export function getPLlistByFactory(data) {
|
|
||||||
return request({
|
|
||||||
url: 'base/production-line/listByFactory',
|
|
||||||
method: 'post',
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
export function getProcessAutoReportLastGroup(data) {
|
|
||||||
return request({
|
|
||||||
url: '/monitoring/production-monitor/getProcessAutoReportLastGroup',
|
|
||||||
method: 'post',
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -141,13 +141,3 @@ 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,13 +26,6 @@ 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,29 +90,3 @@ 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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* @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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
9
src/api/visualization/visualization.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getLineEdgeLibraryList(data) {
|
||||||
|
return request({
|
||||||
|
url: '/wms/line-edge-library/list',
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
BIN
src/assets/img/ABN.png
Normal file
|
After Width: | Height: | Size: 461 B |
BIN
src/assets/img/ABNScale.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
src/assets/img/DIS.png
Normal file
|
After Width: | Height: | Size: 312 B |
BIN
src/assets/img/DISScale.png
Normal file
|
After Width: | Height: | Size: 244 B |
BIN
src/assets/img/EP.png
Normal file
|
After Width: | Height: | Size: 137 B |
BIN
src/assets/img/EPScale.png
Normal file
|
After Width: | Height: | Size: 165 B |
BIN
src/assets/img/FP.png
Normal file
|
After Width: | Height: | Size: 139 B |
BIN
src/assets/img/FPScale.png
Normal file
|
After Width: | Height: | Size: 170 B |
BIN
src/assets/img/IDL.png
Normal file
|
After Width: | Height: | Size: 929 B |
BIN
src/assets/img/IDLScale.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
src/assets/img/IT.png
Normal file
|
After Width: | Height: | Size: 320 B |
BIN
src/assets/img/ITScale.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
src/assets/img/LCK.png
Normal file
|
After Width: | Height: | Size: 416 B |
BIN
src/assets/img/LCKScale.png
Normal file
|
After Width: | Height: | Size: 305 B |
BIN
src/assets/img/OCC.png
Normal file
|
After Width: | Height: | Size: 325 B |
BIN
src/assets/img/OCCScale.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
src/assets/img/RES.png
Normal file
|
After Width: | Height: | Size: 420 B |
BIN
src/assets/img/RESScale.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
src/assets/img/Top1.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
src/assets/img/Top2.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
src/assets/img/Top3.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
src/assets/img/Top4.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
src/assets/img/Top5.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
src/assets/img/agvCar.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/assets/img/agvItemBg.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
src/assets/img/alarmItemBg.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
src/assets/img/chargeBg.png
Normal file
|
After Width: | Height: | Size: 326 B |
BIN
src/assets/img/chargeCircle.png
Normal file
|
After Width: | Height: | Size: 622 B |
BIN
src/assets/img/leftTable.png
Normal file
|
After Width: | Height: | Size: 220 B |
BIN
src/assets/img/recycle.png
Normal file
|
After Width: | Height: | Size: 379 B |
BIN
src/assets/img/rightTable.png
Normal file
|
After Width: | Height: | Size: 355 B |
BIN
src/assets/img/runBg.png
Normal file
|
After Width: | Height: | Size: 325 B |
BIN
src/assets/img/runCircle.png
Normal file
|
After Width: | Height: | Size: 562 B |
BIN
src/assets/img/ssdlLeftTitle.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/img/ssdlTitle.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
src/assets/img/standbyCircle.png
Normal file
|
After Width: | Height: | Size: 611 B |
BIN
src/assets/img/threeDimensionalChartBg.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
@@ -54,7 +54,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// this.currentMenu = this.menus[0];
|
this.currentMenu = this.menus[0];
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentMenu(val) {
|
currentMenu(val) {
|
||||||
|
|||||||
@@ -6,48 +6,104 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-form ref="form" :model="form" :label-width="`${labelWidth}px`" :size="size" :label-position="labelPosition"
|
<el-form
|
||||||
v-loading="formLoading">
|
ref="form"
|
||||||
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
|
:model="form"
|
||||||
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
|
:label-width="`${labelWidth}px`"
|
||||||
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
|
:size="size"
|
||||||
<el-input v-if="col.input" v-model="form[col.prop]" @change="$emit('update', form)"
|
:label-position="labelPosition"
|
||||||
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
|
v-loading="formLoading">
|
||||||
<el-input v-if="col.textarea" type="textarea" v-model="form[col.prop]" @change="$emit('update', form)"
|
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
|
||||||
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
|
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
|
||||||
<el-select v-if="col.select" v-model="form[col.prop]" :placeholder="`请选择${col.label}`"
|
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
|
||||||
@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.input"
|
||||||
</el-select>
|
v-model="form[col.prop]"
|
||||||
<el-date-picker v-if="col.datetime" v-model="form[col.prop]" type="datetime" :placeholder="`请选择${col.label}`"
|
@change="$emit('update', form)"
|
||||||
value-format="timestamp" v-bind="col.bind"></el-date-picker>
|
:placeholder="`请输入${col.label}`"
|
||||||
<el-switch v-if="col.switch" v-model="form[col.prop]" active-color="#0b58ff" inactive-color="#e1e1e1"
|
v-bind="col.bind" />
|
||||||
v-bind="col.bind" @change="handleSwitchChange(col.prop)"></el-switch>
|
<el-input
|
||||||
<component v-if="col.subcomponent" :key="col.key" :is="col.subcomponent" :inlineStyle="col.style"></component>
|
v-if="col.textarea"
|
||||||
|
type="textarea"
|
||||||
|
v-model="form[col.prop]"
|
||||||
|
@change="$emit('update', form)"
|
||||||
|
:placeholder="`请输入${col.label}`"
|
||||||
|
v-bind="col.bind" />
|
||||||
|
<el-select
|
||||||
|
v-if="col.select"
|
||||||
|
v-model="form[col.prop]"
|
||||||
|
:placeholder="`请选择${col.label}`"
|
||||||
|
@change="$emit('update', form)"
|
||||||
|
v-bind="col.bind">
|
||||||
|
<el-option
|
||||||
|
v-for="opt in optionListOf[col.prop]"
|
||||||
|
:key="opt.value"
|
||||||
|
:label="opt.label"
|
||||||
|
:value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
<el-date-picker
|
||||||
|
v-if="col.datetime"
|
||||||
|
v-model="form[col.prop]"
|
||||||
|
type="datetime"
|
||||||
|
:placeholder="`请选择${col.label}`"
|
||||||
|
value-format="timestamp"
|
||||||
|
v-bind="col.bind"></el-date-picker>
|
||||||
|
<el-switch
|
||||||
|
v-if="col.switch"
|
||||||
|
v-model="form[col.prop]"
|
||||||
|
active-color="#0b58ff"
|
||||||
|
inactive-color="#e1e1e1"
|
||||||
|
v-bind="col.bind"></el-switch>
|
||||||
|
<component
|
||||||
|
v-if="col.subcomponent"
|
||||||
|
:key="col.key"
|
||||||
|
:is="col.subcomponent"
|
||||||
|
:inlineStyle="col.style"></component>
|
||||||
|
|
||||||
<div class="upload-area" :class="uploadOpen ? '' : 'height-48'" ref="uploadArea" v-if="col.upload">
|
<div
|
||||||
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
|
class="upload-area"
|
||||||
<el-button type="text" icon="el-icon-arrow-right" @click="handleFilesOpen" />
|
:class="uploadOpen ? '' : 'height-48'"
|
||||||
</span>
|
ref="uploadArea"
|
||||||
<!-- :file-list="uploadedFileList" -->
|
v-if="col.upload">
|
||||||
<el-upload class="upload-in-dialog" v-if="col.upload" :action="uploadUrl" :headers="uploadHeaders"
|
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
|
||||||
:show-file-list="false" icon="el-icon-upload2" :before-upload="beforeUpload"
|
<el-button
|
||||||
:on-success="handleUploadSuccess" v-bind="col.bind">
|
type="text"
|
||||||
<el-button size="mini" :disabled="col.bind?.disabled || false">
|
icon="el-icon-arrow-right"
|
||||||
<svg-icon icon-class="icon-upload" style="color: inherit"></svg-icon>
|
@click="handleFilesOpen" />
|
||||||
上传文件
|
</span>
|
||||||
</el-button>
|
<!-- :file-list="uploadedFileList" -->
|
||||||
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
|
<el-upload
|
||||||
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
|
class="upload-in-dialog"
|
||||||
</div>
|
v-if="col.upload"
|
||||||
</el-upload>
|
:action="uploadUrl"
|
||||||
<uploadedFile class="file" v-for="file in form[col.prop] || []" :file="file" :key="file.fileUrl"
|
:headers="uploadHeaders"
|
||||||
@delete="handleDeleteFile(file)" @Preview="handlePreview(file)" />
|
:show-file-list="false"
|
||||||
</div>
|
icon="el-icon-upload2"
|
||||||
</el-form-item>
|
:before-upload="beforeUpload"
|
||||||
</el-col>
|
:on-success="handleUploadSuccess"
|
||||||
</el-row>
|
v-bind="col.bind">
|
||||||
</el-form>
|
<el-button size="mini" :disabled="col.bind?.disabled || false">
|
||||||
|
<svg-icon
|
||||||
|
icon-class="icon-upload"
|
||||||
|
style="color: inherit"></svg-icon>
|
||||||
|
上传文件
|
||||||
|
</el-button>
|
||||||
|
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
|
||||||
|
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
<uploadedFile
|
||||||
|
class="file"
|
||||||
|
v-for="file in form[col.prop] || []"
|
||||||
|
:file="file"
|
||||||
|
:key="file.fileUrl"
|
||||||
|
@delete="handleDeleteFile(file)"
|
||||||
|
@Preview="handlePreview(file)" />
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -78,8 +134,7 @@ const uploadedFile = {
|
|||||||
data() {
|
data() {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
handleDelete() {
|
handleDelete() {
|
||||||
this.$emit('delete', this.file);
|
this.$emit('delete', this.file);
|
||||||
},
|
},
|
||||||
@@ -196,12 +251,7 @@ export default {
|
|||||||
// 处理 options
|
// 处理 options
|
||||||
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: 20,
|
pageSize: 10,
|
||||||
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', '/auth-redirect', '/bind', '/register', '/oauthLogin/gitee']
|
const whiteList = ['/login', '/social-login','screenbg', '/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(() => {
|
store.dispatch('GetInfo').then(userInfo => {
|
||||||
isRelogin.show = false
|
isRelogin.show = false
|
||||||
store.dispatch('GenerateRoutes').then(accessRoutes => {
|
store.dispatch('GenerateRoutes', userInfo.menus).then(accessRoutes => {
|
||||||
// 根据 roles 权限生成可访问的路由表
|
// 根据 roles 权限生成可访问的路由表
|
||||||
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
||||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||||
|
|||||||
@@ -28,223 +28,277 @@ Vue.use(Router)
|
|||||||
|
|
||||||
// 公共路由
|
// 公共路由
|
||||||
export const constantRoutes = [
|
export const constantRoutes = [
|
||||||
{
|
{
|
||||||
path: '/redirect',
|
path: '/redirect',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
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',
|
{
|
||||||
component: (resolve) => require(['@/views/sso'], resolve),
|
path: '/sso',
|
||||||
hidden: true
|
component: (resolve) => require(['@/views/sso'], resolve),
|
||||||
},
|
hidden: true,
|
||||||
{
|
},
|
||||||
path: '/social-login',
|
{
|
||||||
component: (resolve) => require(['@/views/socialLogin'], resolve),
|
path: '/social-login',
|
||||||
hidden: true
|
component: (resolve) => require(['@/views/socialLogin'], resolve),
|
||||||
},
|
hidden: true,
|
||||||
{
|
},
|
||||||
path: '/404',
|
{
|
||||||
component: (resolve) => require(['@/views/error/404'], resolve),
|
path: '/404',
|
||||||
hidden: true
|
component: (resolve) => require(['@/views/error/404'], resolve),
|
||||||
},
|
hidden: true,
|
||||||
{
|
},
|
||||||
path: '/401',
|
{
|
||||||
component: (resolve) => require(['@/views/error/401'], resolve),
|
path: '/401',
|
||||||
hidden: true
|
component: (resolve) => require(['@/views/error/401'], resolve),
|
||||||
},
|
hidden: true,
|
||||||
{
|
},
|
||||||
path: '/print-design',
|
{
|
||||||
component: (resolve) => require(['@/views/print/design'], resolve),
|
path: '/print-design',
|
||||||
hidden: true
|
component: (resolve) => require(['@/views/print/design'], resolve),
|
||||||
},
|
hidden: true,
|
||||||
{
|
},
|
||||||
path: "",
|
{
|
||||||
component: Layout,
|
path: '',
|
||||||
redirect: "index",
|
component: Layout,
|
||||||
children: [
|
redirect: 'index',
|
||||||
{
|
children: [
|
||||||
path: "index",
|
{
|
||||||
component: (resolve) => require(["@/views/home/index"], resolve),
|
path: 'index',
|
||||||
name: "首页",
|
component: (resolve) => require(['@/views/home/index'], resolve),
|
||||||
meta: { title: "首页", icon: "dashboard", affix: true },
|
name: '首页',
|
||||||
hidden: true
|
meta: { title: '首页', icon: 'dashboard', affix: true },
|
||||||
},
|
hidden: true,
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
{
|
},
|
||||||
path: '/user',
|
{
|
||||||
component: Layout,
|
path: '/screenbg',
|
||||||
hidden: true,
|
component: () =>
|
||||||
redirect: 'noredirect',
|
import(
|
||||||
children: [{
|
/* webpackChunkName: "about" */ '@/views/productionVisualization/equipmentBoard'
|
||||||
path: 'profile',
|
),
|
||||||
component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
|
name: 'screenbg',
|
||||||
name: 'Profile',
|
meta: { title: '大屏', icon: 'chart' },
|
||||||
meta: { title: '个人中心', icon: 'user' }
|
},
|
||||||
}, {
|
{
|
||||||
path: 'notify-message',
|
path: '/user',
|
||||||
component: (resolve) => require(['@/views/system/notify/my/index'], resolve),
|
component: Layout,
|
||||||
name: 'MyNotifyMessage',
|
hidden: true,
|
||||||
meta: { title: '我的站内信', icon: 'message' },
|
redirect: 'noredirect',
|
||||||
}]
|
children: [
|
||||||
},
|
{
|
||||||
{
|
path: 'profile',
|
||||||
path: '/dict',
|
component: (resolve) =>
|
||||||
component: Layout,
|
require(['@/views/system/user/profile/index'], resolve),
|
||||||
hidden: true,
|
name: 'Profile',
|
||||||
children: [{
|
meta: { title: '个人中心', icon: 'user' },
|
||||||
path: 'type/data/:dictId(\\d+)',
|
},
|
||||||
component: (resolve) => require(['@/views/system/dict/data'], resolve),
|
{
|
||||||
name: 'SystemDictData',
|
path: 'notify-message',
|
||||||
meta: { title: '字典数据', icon: '', activeMenu: '/system/dict' }
|
component: (resolve) =>
|
||||||
}
|
require(['@/views/system/notify/my/index'], resolve),
|
||||||
]
|
name: 'MyNotifyMessage',
|
||||||
},
|
meta: { title: '我的站内信', icon: 'message' },
|
||||||
{
|
},
|
||||||
path: '/job',
|
],
|
||||||
component: Layout,
|
},
|
||||||
hidden: true,
|
{
|
||||||
children: [{
|
path: '/dict',
|
||||||
path: 'log',
|
component: Layout,
|
||||||
component: (resolve) => require(['@/views/infra/job/log'], resolve),
|
hidden: true,
|
||||||
name: 'InfraJobLog',
|
children: [
|
||||||
meta: { title: '调度日志', activeMenu: '/infra/job' }
|
{
|
||||||
}
|
path: 'type/data/:dictId(\\d+)',
|
||||||
]
|
component: (resolve) => require(['@/views/system/dict/data'], resolve),
|
||||||
}, {
|
name: 'SystemDictData',
|
||||||
path: '/codegen',
|
meta: { title: '字典数据', icon: '', activeMenu: '/system/dict' },
|
||||||
component: Layout,
|
},
|
||||||
hidden: true,
|
],
|
||||||
children: [{
|
},
|
||||||
path: 'edit/:tableId(\\d+)',
|
{
|
||||||
component: (resolve) => require(['@/views/infra/codegen/editTable'], resolve),
|
path: '/job',
|
||||||
name: 'InfraCodegenEditTable',
|
component: Layout,
|
||||||
meta: { title: '修改生成配置', activeMenu: '/infra/codegen' }
|
hidden: true,
|
||||||
}
|
children: [
|
||||||
]
|
{
|
||||||
},
|
path: 'log',
|
||||||
{
|
component: (resolve) => require(['@/views/infra/job/log'], resolve),
|
||||||
path: '/bpm',
|
name: 'InfraJobLog',
|
||||||
component: Layout,
|
meta: { title: '调度日志', activeMenu: '/infra/job' },
|
||||||
hidden: true,
|
},
|
||||||
redirect: 'noredirect',
|
],
|
||||||
children: [{
|
},
|
||||||
path: 'oa/leave/create',
|
{
|
||||||
component: (resolve) => require(['@/views/bpm/oa/leave/create'], resolve),
|
path: '/codegen',
|
||||||
name: 'BpmOALeaveCreate',
|
component: Layout,
|
||||||
meta: { title: '发起 OA 请假', icon: 'form', activeMenu: '/bpm/oa/leave' }
|
hidden: true,
|
||||||
}, {
|
children: [
|
||||||
path: 'oa/leave/detail',
|
{
|
||||||
component: (resolve) => require(['@/views/bpm/oa/leave/detail'], resolve),
|
path: 'edit/:tableId(\\d+)',
|
||||||
name: 'BpmOALeaveDetail',
|
component: (resolve) =>
|
||||||
meta: { title: '查看 OA 请假', icon: 'view', activeMenu: '/bpm/oa/leave' }
|
require(['@/views/infra/codegen/editTable'], resolve),
|
||||||
}
|
name: 'InfraCodegenEditTable',
|
||||||
]
|
meta: { title: '修改生成配置', activeMenu: '/infra/codegen' },
|
||||||
},
|
},
|
||||||
{
|
],
|
||||||
path: '/bpm',
|
},
|
||||||
component: Layout,
|
{
|
||||||
hidden: true,
|
path: '/bpm',
|
||||||
children: [{
|
component: Layout,
|
||||||
path: 'manager/form/edit',
|
hidden: true,
|
||||||
component: (resolve) => require(['@/views/bpm/form/formEditor'], resolve),
|
redirect: 'noredirect',
|
||||||
name: 'BpmFormEditor',
|
children: [
|
||||||
meta: { title: '流程表单-编辑', activeMenu: '/bpm/manager/form' }
|
{
|
||||||
}, {
|
path: 'oa/leave/create',
|
||||||
path: 'manager/definition',
|
component: (resolve) =>
|
||||||
component: (resolve) => require(['@/views/bpm/definition/index'], resolve),
|
require(['@/views/bpm/oa/leave/create'], resolve),
|
||||||
name: 'BpmProcessDefinition',
|
name: 'BpmOALeaveCreate',
|
||||||
meta: { title: '流程定义', activeMenu: '/bpm/manager/model' }
|
meta: {
|
||||||
}, {
|
title: '发起 OA 请假',
|
||||||
path: 'manager/model/design',
|
icon: 'form',
|
||||||
component: (resolve) => require(['@/views/bpm/model/modelEditor'], resolve),
|
activeMenu: '/bpm/oa/leave',
|
||||||
name: 'BpmModelEditor',
|
},
|
||||||
meta: { title: '设计流程', activeMenu: '/bpm/manager/model' }
|
},
|
||||||
}, {
|
{
|
||||||
path: 'process-instance/create',
|
path: 'oa/leave/detail',
|
||||||
component: (resolve) => require(['@/views/bpm/processInstance/create'], resolve),
|
component: (resolve) =>
|
||||||
name: 'BpmProcessInstanceCreate',
|
require(['@/views/bpm/oa/leave/detail'], resolve),
|
||||||
meta: { title: '发起流程', activeMenu: '/bpm/task/my' }
|
name: 'BpmOALeaveDetail',
|
||||||
}, {
|
meta: {
|
||||||
path: 'process-instance/detail',
|
title: '查看 OA 请假',
|
||||||
component: (resolve) => require(['@/views/bpm/processInstance/detail'], resolve),
|
icon: 'view',
|
||||||
name: 'BpmProcessInstanceDetail',
|
activeMenu: '/bpm/oa/leave',
|
||||||
meta: { title: '流程详情', activeMenu: '/bpm/task/my' }
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/property',
|
path: '/bpm',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [{
|
children: [
|
||||||
path: 'value/:propertyId(\\d+)',
|
{
|
||||||
component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
|
path: 'manager/form/edit',
|
||||||
name: 'ProductPropertyValue',
|
component: (resolve) =>
|
||||||
meta: { title: '商品属性值', icon: '', activeMenu: '/product/property' }
|
require(['@/views/bpm/form/formEditor'], resolve),
|
||||||
}
|
name: 'BpmFormEditor',
|
||||||
]
|
meta: { title: '流程表单-编辑', activeMenu: '/bpm/manager/form' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/spu',
|
path: 'manager/definition',
|
||||||
component: Layout,
|
component: (resolve) =>
|
||||||
hidden: true,
|
require(['@/views/bpm/definition/index'], resolve),
|
||||||
children: [{
|
name: 'BpmProcessDefinition',
|
||||||
path: 'edit/:spuId(\\d+)',
|
meta: { title: '流程定义', activeMenu: '/bpm/manager/model' },
|
||||||
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
|
},
|
||||||
name: 'ProductSpuUpdate',
|
{
|
||||||
meta: { title: '修改商品', activeMenu: '/product/spu' }
|
path: 'manager/model/design',
|
||||||
},
|
component: (resolve) =>
|
||||||
{
|
require(['@/views/bpm/model/modelEditor'], resolve),
|
||||||
path: 'add',
|
name: 'BpmModelEditor',
|
||||||
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
|
meta: { title: '设计流程', activeMenu: '/bpm/manager/model' },
|
||||||
name: 'ProductSpuCreate',
|
},
|
||||||
meta: { title: '添加商品', activeMenu: '/product/spu' }
|
{
|
||||||
}
|
path: 'process-instance/create',
|
||||||
]
|
component: (resolve) =>
|
||||||
},
|
require(['@/views/bpm/processInstance/create'], resolve),
|
||||||
{
|
name: 'BpmProcessInstanceCreate',
|
||||||
path: '/trade/order',
|
meta: { title: '发起流程', activeMenu: '/bpm/task/my' },
|
||||||
component: Layout,
|
},
|
||||||
hidden: true,
|
{
|
||||||
children: [
|
path: 'process-instance/detail',
|
||||||
{
|
component: (resolve) =>
|
||||||
path: 'detail',
|
require(['@/views/bpm/processInstance/detail'], resolve),
|
||||||
name: 'TradeOrderDetail',
|
name: 'BpmProcessInstanceDetail',
|
||||||
hidden: true,
|
meta: { title: '流程详情', activeMenu: '/bpm/task/my' },
|
||||||
meta: { title: '订单详情' },
|
},
|
||||||
component: (resolve) => require(['@/views/mall/trade/order/detail'], resolve)
|
],
|
||||||
}
|
},
|
||||||
]
|
{
|
||||||
},
|
path: '/property',
|
||||||
{
|
component: Layout,
|
||||||
path: '/pay',
|
hidden: true,
|
||||||
component: Layout,
|
children: [
|
||||||
hidden: true,
|
{
|
||||||
children: [{
|
path: 'value/:propertyId(\\d+)',
|
||||||
path: 'order/submit',
|
component: (resolve) =>
|
||||||
name: 'PayOrderSubmit',
|
require(['@/views/mall/product/property/value'], resolve),
|
||||||
hidden: true,
|
name: 'ProductPropertyValue',
|
||||||
meta: {
|
meta: {
|
||||||
title: '收银台',
|
title: '商品属性值',
|
||||||
noCache: true
|
icon: '',
|
||||||
},
|
activeMenu: '/product/property',
|
||||||
component: (resolve) => require(['@/views/pay/order/submit'], resolve)
|
},
|
||||||
}]
|
},
|
||||||
}
|
],
|
||||||
]
|
},
|
||||||
|
{
|
||||||
|
path: '/spu',
|
||||||
|
component: Layout,
|
||||||
|
hidden: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'edit/:spuId(\\d+)',
|
||||||
|
component: (resolve) =>
|
||||||
|
require(['@/views/mall/product/spu/save'], resolve),
|
||||||
|
name: 'ProductSpuUpdate',
|
||||||
|
meta: { title: '修改商品', activeMenu: '/product/spu' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'add',
|
||||||
|
component: (resolve) =>
|
||||||
|
require(['@/views/mall/product/spu/save'], resolve),
|
||||||
|
name: 'ProductSpuCreate',
|
||||||
|
meta: { title: '添加商品', activeMenu: '/product/spu' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/trade/order',
|
||||||
|
component: Layout,
|
||||||
|
hidden: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'detail',
|
||||||
|
name: 'TradeOrderDetail',
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '订单详情' },
|
||||||
|
component: (resolve) =>
|
||||||
|
require(['@/views/mall/trade/order/detail'], resolve),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/pay',
|
||||||
|
component: Layout,
|
||||||
|
hidden: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'order/submit',
|
||||||
|
name: 'PayOrderSubmit',
|
||||||
|
hidden: true,
|
||||||
|
meta: {
|
||||||
|
title: '收银台',
|
||||||
|
noCache: true,
|
||||||
|
},
|
||||||
|
component: (resolve) => require(['@/views/pay/order/submit'], resolve),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// 防止连续点击多次路由报错
|
// 防止连续点击多次路由报错
|
||||||
let routerPush = Router.prototype.push;
|
let routerPush = Router.prototype.push;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
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";
|
||||||
@@ -27,22 +26,25 @@ const permission = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
// 生成路由
|
/**
|
||||||
GenerateRoutes({commit}) {
|
* 生成路由
|
||||||
|
*
|
||||||
|
* @param commit commit 函数
|
||||||
|
* @param menus 路由参数
|
||||||
|
*/
|
||||||
|
GenerateRoutes({commit}, menus) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
// 向后端请求路由数据(菜单)
|
// 将 menus 菜单,转换为 route 路由数组
|
||||||
getRouters().then(res => {
|
const sdata = JSON.parse(JSON.stringify(menus)) // 【重要】用于菜单中的数据
|
||||||
const sdata = JSON.parse(JSON.stringify(res.data)) // 【重要】用于菜单中的数据
|
const rdata = JSON.parse(JSON.stringify(menus)) // 用于最后添加到 Router 中的数据
|
||||||
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})
|
commit('SET_ROUTES', rewriteRoutes)
|
||||||
commit('SET_ROUTES', rewriteRoutes)
|
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
|
||||||
commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
|
commit('SET_DEFAULT_ROUTES', sidebarRoutes)
|
||||||
commit('SET_DEFAULT_ROUTES', sidebarRoutes)
|
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 + ']';
|
||||||
@@ -104,9 +104,9 @@ service.interceptors.request.use(config => {
|
|||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
tryHideFullScreenLoading()
|
tryHideFullScreenLoading()
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
@@ -176,38 +176,36 @@ 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 {
|
||||||
//【班组管理】【排班计划】提交的校验按照原型图补充完整,排班计划是否重叠code400 有两个不同的返回信息
|
Notification.error({
|
||||||
return res.data
|
title: msg
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return Promise.reject('error')
|
return Promise.reject('error')
|
||||||
} else {
|
} else {
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
}, 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")) {
|
||||||
message = "系统接口请求超时";
|
message = "系统接口请求超时";
|
||||||
} else if (message.includes("Request failed with status code")) {
|
} else if (message.includes("Request failed with status code")) {
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
|
}
|
||||||
|
Message({
|
||||||
|
message: message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 5 * 1000
|
||||||
|
})
|
||||||
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
Message({
|
|
||||||
message: message,
|
|
||||||
type: 'error',
|
|
||||||
duration: 5 * 1000
|
|
||||||
})
|
|
||||||
return Promise.reject(error)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
export function getBaseHeader() {
|
export function getBaseHeader() {
|
||||||
@@ -221,10 +219,10 @@ function handleAuthorized() {
|
|||||||
if (!isRelogin.show) {
|
if (!isRelogin.show) {
|
||||||
isRelogin.show = true;
|
isRelogin.show = true;
|
||||||
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||||
confirmButtonText: '重新登录',
|
confirmButtonText: '重新登录',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}
|
}
|
||||||
).then(() => {
|
).then(() => {
|
||||||
isRelogin.show = false;
|
isRelogin.show = false;
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
|
|||||||
@@ -6,27 +6,35 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-drawer :visible="visible" :show-close="false" :wrapper-closable="false" class="drawer" custom-class="mes-drawer"
|
<el-drawer
|
||||||
:size="size || '50%'" @closed="$emit('destroy')">
|
:visible="visible"
|
||||||
<SmallTitle slot="title">
|
:show-close="false"
|
||||||
{{
|
:wrapper-closable="false"
|
||||||
mode.includes('detail')
|
class="drawer"
|
||||||
? '详情'
|
custom-class="mes-drawer"
|
||||||
: mode.includes('edit')
|
:size="size || '50%'"
|
||||||
? '编辑'
|
@closed="$emit('destroy')">
|
||||||
: '新增'
|
<SmallTitle slot="title">
|
||||||
}}
|
{{
|
||||||
</SmallTitle>
|
mode.includes('detail')
|
||||||
|
? '详情'
|
||||||
|
: mode.includes('edit')
|
||||||
|
? '编辑'
|
||||||
|
: '新增'
|
||||||
|
}}
|
||||||
|
</SmallTitle>
|
||||||
|
|
||||||
<div class="drawer-body flex">
|
<div class="drawer-body flex">
|
||||||
<div class="drawer-body__content">
|
<div class="drawer-body__content">
|
||||||
<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 class="form-part" v-if="section.key == 'base'"
|
<div
|
||||||
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
class="form-part"
|
||||||
<el-skeleton v-if="!showForm" animated />
|
v-if="section.key == 'base'"
|
||||||
<!-- <BaseInfoForm
|
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
||||||
|
<el-skeleton v-if="!showForm" animated />
|
||||||
|
<!-- <BaseInfoForm
|
||||||
key="drawer-dialog-form"
|
key="drawer-dialog-form"
|
||||||
v-if="showForm"
|
v-if="showForm"
|
||||||
ref="form"
|
ref="form"
|
||||||
@@ -34,87 +42,141 @@
|
|||||||
v-model="form"
|
v-model="form"
|
||||||
:rows="formRows" /> -->
|
:rows="formRows" /> -->
|
||||||
|
|
||||||
<!-- 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 class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
<div
|
||||||
设备名
|
class="title"
|
||||||
</div>
|
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||||
<div class="value" style="font-size: 14px">
|
设备名
|
||||||
{{ form.equipmentName }}
|
</div>
|
||||||
</div>
|
<div class="value" style="font-size: 14px">
|
||||||
</el-col>
|
{{ form.equipmentName }}
|
||||||
<el-col :span="8">
|
</div>
|
||||||
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
</el-col>
|
||||||
关联表名
|
<el-col :span="8">
|
||||||
</div>
|
<div
|
||||||
<div class="value" style="font-size: 14px">
|
class="title"
|
||||||
{{ form.plcName }}
|
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||||
</div>
|
关联表名
|
||||||
</el-col>
|
</div>
|
||||||
</el-row>
|
<div class="value" style="font-size: 14px">
|
||||||
<!-- else -->
|
{{ form.plcName }}
|
||||||
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
</div>
|
||||||
<el-form ref="form" :model="form">
|
</el-col>
|
||||||
<el-col :span="8">
|
</el-row>
|
||||||
<el-form-item class="title" label="设备名" style="font-size: 16px; margin: 8px 0">
|
<!-- else -->
|
||||||
<el-select v-model="form.equipmentId" filterable clearable placeholder="请选择设备">
|
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
||||||
<el-option v-for="eq in eqList" :key="eq.id" :label="eq.name" :value="eq.id"></el-option>
|
<el-form ref="form" :model="form">
|
||||||
</el-select>
|
<el-col :span="8">
|
||||||
</el-form-item>
|
<el-form-item
|
||||||
</el-col>
|
class="title"
|
||||||
<el-col :span="8">
|
label="设备名"
|
||||||
<el-form-item class="title" label="设备关联表名" style="font-size: 16px; margin: 8px 0">
|
style="font-size: 16px; margin: 8px 0">
|
||||||
<el-select v-model="form.plcId" filterable clearable placeholder="请选择关联表">
|
<el-select
|
||||||
<el-option v-for="plc in plcList" :key="plc.id" :label="plc.plcTableName"
|
v-model="form.equipmentId"
|
||||||
:value="plc.id"></el-option>
|
filterable
|
||||||
</el-select>
|
clearable
|
||||||
</el-form-item>
|
placeholder="请选择设备">
|
||||||
</el-col>
|
<el-option
|
||||||
</el-form>
|
v-for="eq in eqList"
|
||||||
</el-row>
|
:key="eq.id"
|
||||||
</div>
|
:label="eq.name"
|
||||||
|
:value="eq.id"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item
|
||||||
|
class="title"
|
||||||
|
label="设备关联表名"
|
||||||
|
style="font-size: 16px; margin: 8px 0">
|
||||||
|
<el-select
|
||||||
|
v-model="form.plcId"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="请选择关联表">
|
||||||
|
<el-option
|
||||||
|
v-for="plc in plcList"
|
||||||
|
:key="plc.id"
|
||||||
|
:label="plc.plcTableName"
|
||||||
|
:value="plc.id"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="section.key == 'attrs'" style="position: relative; margin-top: 12px">
|
<div
|
||||||
<div v-if="!mode.includes('detail')" style="position: absolute; top: -40px; right: 0">
|
v-if="section.key == 'attrs'"
|
||||||
<el-button @click="handleAddAttr" type="text">
|
style="position: relative; margin-top: 12px">
|
||||||
<i class="el-icon-plus"></i>
|
<div
|
||||||
添加参数
|
v-if="!mode.includes('detail')"
|
||||||
</el-button>
|
style="position: absolute; top: -40px; right: 0">
|
||||||
</div>
|
<el-button @click="handleAddAttr" type="text">
|
||||||
<base-table v-loading="attrListLoading" :table-props="section.props" :page="attrQuery?.params.pageNo || 1"
|
<i class="el-icon-plus"></i>
|
||||||
:limit="attrQuery?.params.pageSize || 10" :table-data="list" @emitFun="handleEmitFun">
|
添加参数
|
||||||
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<base-table
|
||||||
|
v-loading="attrListLoading"
|
||||||
|
:table-props="section.props"
|
||||||
|
:page="attrQuery?.params.pageNo || 1"
|
||||||
|
:limit="attrQuery?.params.pageSize || 10"
|
||||||
|
:table-data="list"
|
||||||
|
@emitFun="handleEmitFun">
|
||||||
|
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
|
||||||
@emitButtonClick="handleAddAttr" -->
|
@emitButtonClick="handleAddAttr" -->
|
||||||
<method-btn v-if="section.tableBtn && !mode.includes('detail')" slot="handleBtn" label="操作"
|
<method-btn
|
||||||
:method-list="tableBtn" @clickBtn="handleTableBtnClick" />
|
v-if="section.tableBtn && !mode.includes('detail')"
|
||||||
</base-table>
|
slot="handleBtn"
|
||||||
|
label="操作"
|
||||||
|
:method-list="tableBtn"
|
||||||
|
@clickBtn="handleTableBtnClick" />
|
||||||
|
</base-table>
|
||||||
|
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<pagination v-show="total > 0" :total="total" :page.sync="attrQuery.params.pageNo"
|
<pagination
|
||||||
:limit.sync="attrQuery.params.pageSize" @pagination="getAttrList" />
|
v-show="total > 0"
|
||||||
</div>
|
:total="total"
|
||||||
</section>
|
:page.sync="attrQuery.params.pageNo"
|
||||||
</div>
|
:limit.sync="attrQuery.params.pageSize"
|
||||||
|
@pagination="getAttrList" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</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 type="primary" v-if="!mode.includes('detail')" @click="handleSave">
|
<el-button
|
||||||
保存
|
type="primary"
|
||||||
</el-button>
|
v-if="!mode.includes('detail')"
|
||||||
</div>
|
@click="handleSave">
|
||||||
</div>
|
保存
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 属性对话框 -->
|
<!-- 属性对话框 -->
|
||||||
<base-dialog v-if="sections[1].allowAdd" :dialogTitle="attrTitle" :dialogVisible="attrFormVisible" width="45%"
|
<base-dialog
|
||||||
:append-to-body="true" custom-class="baseDialog" @close="closeAttrForm" @cancel="closeAttrForm"
|
v-if="sections[1].allowAdd"
|
||||||
@confirm="submitAttrForm">
|
:dialogTitle="attrTitle"
|
||||||
<!-- :disabled="mode.includes('detail')" -->
|
:dialogVisible="attrFormVisible"
|
||||||
<DialogForm v-if="attrFormVisible" ref="attrForm" v-model="attrForm" :data-form="attrForm"
|
width="45%"
|
||||||
:rows="attrRows"
|
:append-to-body="true"
|
||||||
@update="handleAttrFormUpdate"/>
|
custom-class="baseDialog"
|
||||||
</base-dialog>
|
@close="closeAttrForm"
|
||||||
</el-drawer>
|
@cancel="closeAttrForm"
|
||||||
|
@confirm="submitAttrForm">
|
||||||
|
<!-- :disabled="mode.includes('detail')" -->
|
||||||
|
<DialogForm
|
||||||
|
v-if="attrFormVisible"
|
||||||
|
ref="attrForm"
|
||||||
|
v-model="attrForm"
|
||||||
|
:rows="attrRows" />
|
||||||
|
</base-dialog>
|
||||||
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -170,9 +232,7 @@ export default {
|
|||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
description: '',
|
description: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
alarmContent: '',
|
alarmContent: '',
|
||||||
displayTip: false,
|
|
||||||
alarmTip: false,
|
|
||||||
},
|
},
|
||||||
attrFormVisible: false,
|
attrFormVisible: false,
|
||||||
attrRows: [
|
attrRows: [
|
||||||
@@ -282,27 +342,7 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
|
||||||
{
|
|
||||||
switch: true,
|
|
||||||
label: '是否展示',
|
|
||||||
prop: 'displayTip',
|
|
||||||
bind: {
|
|
||||||
'active-value': true,
|
|
||||||
'inactive-value': false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
switch: true,
|
|
||||||
label: '超出阈值是否报警',
|
|
||||||
prop: 'alarmTip',
|
|
||||||
bind: {
|
|
||||||
'active-value': true,
|
|
||||||
'inactive-value': false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
input: true,
|
input: true,
|
||||||
@@ -396,24 +436,7 @@ 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':
|
||||||
@@ -479,8 +502,7 @@ export default {
|
|||||||
name: '',
|
name: '',
|
||||||
plcParamName: '',
|
plcParamName: '',
|
||||||
unit: '',
|
unit: '',
|
||||||
collection: 1,
|
collection: 1,
|
||||||
|
|
||||||
minValue: '',
|
minValue: '',
|
||||||
maxValue: '',
|
maxValue: '',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
@@ -488,9 +510,7 @@ export default {
|
|||||||
remark: '',
|
remark: '',
|
||||||
equipmentParamType: '',
|
equipmentParamType: '',
|
||||||
productionParamType: '',
|
productionParamType: '',
|
||||||
alarmContent: '',
|
alarmContent: '',
|
||||||
displayTip: false,
|
|
||||||
alarmTip: false,
|
|
||||||
};
|
};
|
||||||
this.attrTitle = '添加参数绑定信息';
|
this.attrTitle = '添加参数绑定信息';
|
||||||
this.attrFormVisible = true;
|
this.attrFormVisible = true;
|
||||||
@@ -503,15 +523,8 @@ export default {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
params: { id: attrId },
|
params: { id: attrId },
|
||||||
});
|
});
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
console.log('res.data', res.data);
|
this.attrForm = 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;
|
||||||
}
|
}
|
||||||
@@ -550,8 +563,7 @@ export default {
|
|||||||
this.$refs['attrForm'].validate(async (valid) => {
|
this.$refs['attrForm'].validate(async (valid) => {
|
||||||
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;
|
||||||
@@ -571,9 +583,8 @@ export default {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 1500,
|
duration: 1500,
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
this.shouldRefreshPageView = true;
|
this.getAttrList();
|
||||||
this.getAttrList();
|
this.shouldRefreshPageView = true;
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
style="width: 75%"
|
style="width: 75%"
|
||||||
v-model="dataForm.price"
|
v-model="dataForm.price"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请输入单价" />
|
placeholder="请输入允许留存时间" />
|
||||||
{{ unit }}
|
{{ unit }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -103,7 +103,7 @@ export default {
|
|||||||
id: null,
|
id: null,
|
||||||
code: '',
|
code: '',
|
||||||
materialId: '',
|
materialId: '',
|
||||||
price: undefined,
|
price: '',
|
||||||
startTime: new Date().getTime(),
|
startTime: new Date().getTime(),
|
||||||
endTime: null,
|
endTime: null,
|
||||||
remark: '',
|
remark: '',
|
||||||
@@ -140,15 +140,13 @@ export default {
|
|||||||
setTimeout(this.setCode(), 1000);
|
setTimeout(this.setCode(), 1000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCode() {
|
setCode() {
|
||||||
console.log('this.MaterialList', this.urlOptions.dictArr.dict0);
|
|
||||||
|
|
||||||
this.MaterialList.forEach((item) => {
|
this.MaterialList.forEach((item) => {
|
||||||
if (item.id === this.dataForm.materialId) {
|
if (item.id === this.dataForm.materialId) {
|
||||||
this.dataForm.code = item.code;
|
this.dataForm.code = item.code;
|
||||||
this.unit =
|
this.unit =
|
||||||
'元/' +
|
'元/' +
|
||||||
this.urlOptions.dictArr.dict0.find((d) => d.value == item.unit)
|
this.urlOptions.dictArr.dict0.find((d) => d.value === item.unit)
|
||||||
.label;
|
.label;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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',
|
||||||
@@ -128,7 +128,7 @@ export default {
|
|||||||
this.tableData = response.data;
|
this.tableData = response.data;
|
||||||
this.dataListLoading = false;
|
this.dataListLoading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleClick(val) {
|
handleClick(val) {
|
||||||
const data = {
|
const data = {
|
||||||
...this.time,
|
...this.time,
|
||||||
|
|||||||
@@ -141,8 +141,7 @@ export default {
|
|||||||
type: 'select',
|
type: 'select',
|
||||||
label: '产线',
|
label: '产线',
|
||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'lineId',
|
param: 'lineId',
|
||||||
collapseTags: true,
|
|
||||||
multiple: true,
|
multiple: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,261 +1,273 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
<search-bar
|
||||||
<div v-if="tableData.length">
|
:formConfigs="formConfig"
|
||||||
<base-table v-loading="dataListLoading" :table-props="tableProps" :max-height="tableH" :table-data="tableData" />
|
ref="searchBarForm"
|
||||||
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
|
@headBtnClick="buttonClick" />
|
||||||
<line-chart ref="lineChart" />
|
<div v-if="tableData.length">
|
||||||
</div>
|
<base-table
|
||||||
<div v-else class="no-data-bg"></div>
|
v-loading="dataListLoading"
|
||||||
</div>
|
:table-props="tableProps"
|
||||||
|
:max-height="tableH"
|
||||||
|
:table-data="tableData" />
|
||||||
|
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
|
||||||
|
<line-chart ref="lineChart" />
|
||||||
|
</div>
|
||||||
|
<div v-else class="no-data-bg"></div>
|
||||||
|
<!-- <pagination
|
||||||
|
:limit.sync="listQuery.pageSize"
|
||||||
|
:page.sync="listQuery.pageNo"
|
||||||
|
:total="listQuery.total"
|
||||||
|
@pagination="getDataList" /> -->
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// import basicPage from '../../mixins/basic-page';
|
||||||
import { parseTime } from '../../mixins/code-filter';
|
import { parseTime } from '../../mixins/code-filter';
|
||||||
import { getYieldAnalysisPageData } from '@/api/core/analysis/index';
|
import { getYieldAnalysisPageData } from '@/api/core/analysis/index';
|
||||||
import { getProductionLinePage } from '@/api/core/base/productionLine';
|
import { getProductionLinePage } from '@/api/core/base/productionLine';
|
||||||
import lineChart from '../LineChart';
|
import lineChart from '../LineChart';
|
||||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||||
|
// import { getWorkshopSectionPage } from '@/api/core/base/workshopSection';
|
||||||
|
|
||||||
|
// const tableProps = [
|
||||||
|
// // {
|
||||||
|
// // prop: 'lineName',
|
||||||
|
// // label: '产线',
|
||||||
|
// // align: 'center',
|
||||||
|
// // },
|
||||||
|
// // {
|
||||||
|
// // prop: 'sum',
|
||||||
|
// // label: '合计',
|
||||||
|
// // align: 'center',
|
||||||
|
// // },
|
||||||
|
// // {
|
||||||
|
// // prop: 'dynamicValue',
|
||||||
|
// // label: 'dynamicName',
|
||||||
|
// // align: 'center',
|
||||||
|
// // children:[
|
||||||
|
|
||||||
|
// // ]
|
||||||
|
// // }
|
||||||
|
// ];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
lineChart,
|
lineChart,
|
||||||
},
|
},
|
||||||
mixins: [tableHeightMixin],
|
mixins: [tableHeightMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
urlOptions: {
|
urlOptions: {
|
||||||
getDataListURL: getYieldAnalysisPageData,
|
getDataListURL: getYieldAnalysisPageData,
|
||||||
},
|
},
|
||||||
tableProps: [],
|
tableProps: [],
|
||||||
dataListLoading: false,
|
dataListLoading: false,
|
||||||
tableData: [],
|
tableData: [],
|
||||||
listQuery: {
|
listQuery: {
|
||||||
lineIds: [],
|
lineIds: [],
|
||||||
time: '', // 存储时间选择器的选中值(时间戳/格式化字符串,根据接口要求调整)
|
time: '',
|
||||||
},
|
},
|
||||||
dateLabelList: [],
|
dateLabelList: [],
|
||||||
optionArrUrl: [getProductionLinePage],
|
optionArrUrl: [getProductionLinePage],
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'datePicker',
|
type: 'select',
|
||||||
label: '时间',
|
label: '产线',
|
||||||
dateType: 'month', // 单个月份选择
|
selectOptions: [],
|
||||||
format: 'yyyy-MM', // 显示格式
|
param: 'lineIds',
|
||||||
valueFormat: 'yyyy-MM-dd HH:mm:ss', // 绑定值的格式
|
defaultSelect: [],
|
||||||
param: 'time',
|
multiple: true,
|
||||||
defaultSelect: '', // 新增:默认月份值
|
filterable: true,
|
||||||
},
|
width: 200,
|
||||||
{
|
},
|
||||||
type: 'select',
|
{
|
||||||
label: '产线',
|
type: 'datePicker',
|
||||||
selectOptions: [],
|
label: '时间',
|
||||||
param: 'lineIds',
|
dateType: 'month',
|
||||||
defaultSelect: [], // 产线默认选择值(多选数组)
|
format: 'yyyy-MM',
|
||||||
multiple: true,
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
collapseTags: true,
|
rangeSeparator: '-',
|
||||||
filterable: true,
|
startPlaceholder: '开始时间',
|
||||||
width: 300,
|
endPlaceholder: '结束时间',
|
||||||
},
|
param: 'time',
|
||||||
{
|
},
|
||||||
type: 'button',
|
{
|
||||||
btnName: '查询',
|
type: 'button',
|
||||||
name: 'search',
|
btnName: '查询',
|
||||||
color: 'primary',
|
name: 'search',
|
||||||
},
|
color: 'primary',
|
||||||
],
|
},
|
||||||
};
|
],
|
||||||
},
|
};
|
||||||
mounted() {
|
},
|
||||||
// 1. 初始化默认当月时间
|
created() {
|
||||||
this.initDefaultMonth();
|
this.getArr();
|
||||||
// 2. 获取产线数据
|
},
|
||||||
this.getArr();
|
methods: {
|
||||||
},
|
getArr() {
|
||||||
methods: {
|
const params = {
|
||||||
/**
|
page: 1,
|
||||||
* 初始化默认当月时间(单个月份)
|
limit: 500,
|
||||||
*/
|
};
|
||||||
initDefaultMonth() {
|
this.optionArrUrl.forEach((item, index) => {
|
||||||
const now = new Date();
|
item(params).then((response) => {
|
||||||
const year = now.getFullYear();
|
this.formConfig[index].selectOptions = response.data.list;
|
||||||
const month = now.getMonth(); // 月份从0开始,直接使用(取当月1号)
|
// this.formConfig[0].defaultSelect = response.data.list[0].id
|
||||||
// 创建当月1号0点0分0秒的日期对象
|
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id)
|
||||||
const firstDayOfMonth = new Date(year, month, 1, 0, 0, 0);
|
});
|
||||||
// 转换为时间戳(毫秒级)
|
});
|
||||||
const defaultTimeStamp = firstDayOfMonth.getTime();
|
},
|
||||||
// 给时间选择器赋值默认值
|
getData() {
|
||||||
this.formConfig[0].defaultSelect = firstDayOfMonth;
|
// this.listQuery.lineIds = ['1672847052717821953']
|
||||||
// this.listQuery.time = defaultTimeStamp;
|
// this.listQuery.productId = val.productId;
|
||||||
},
|
// this.listQuery.time = '1694486098000';
|
||||||
/**
|
this.urlOptions.getDataListURL(this.listQuery).then((res) => {
|
||||||
* 获取产线数据
|
let arr = [
|
||||||
*/
|
{
|
||||||
getArr() {
|
prop: 'lineName',
|
||||||
const params = {
|
label: '产线',
|
||||||
page: 1,
|
fixed: 'left',
|
||||||
limit: 500,
|
},
|
||||||
};
|
{
|
||||||
// 原代码forEach遍历冗余,直接调用第一个方法即可
|
prop: 'sum',
|
||||||
this.optionArrUrl[0](params)
|
label: '合计[片]',
|
||||||
.then((response) => {
|
fixed: 'left',
|
||||||
const lineList = response.data.list;
|
},
|
||||||
this.formConfig[1].selectOptions = lineList;
|
{
|
||||||
// 产线默认选择第一条数据(多选需用数组格式)
|
prop: res.data ? res.data.nameData[0].name : undefined,
|
||||||
if (lineList.length > 0) {
|
label: res.data ? res.data.nameData[0].name : undefined,
|
||||||
const firstLineId = lineList[0].id;
|
align: 'center',
|
||||||
this.formConfig[1].defaultSelect = [firstLineId];
|
children: [],
|
||||||
// 给查询参数赋值
|
},
|
||||||
this.listQuery.lineIds = [firstLineId];
|
];
|
||||||
}
|
// console.log(res.data.nameData.slice(1))
|
||||||
})
|
let xData = [];
|
||||||
.catch((err) => {
|
let yAllData = [];
|
||||||
console.error('获取产线数据失败:', err);
|
let lineName = [];
|
||||||
});
|
if (res.data) {
|
||||||
},
|
let tempDateList = [];
|
||||||
/**
|
res.data.nameData.forEach((date) => {
|
||||||
* 获取产量分析数据
|
tempDateList.push(date.name);
|
||||||
*/
|
});
|
||||||
getData() {
|
this.dateLabelList = Array.from(new Set(tempDateList));
|
||||||
this.dataListLoading = true; // 开启加载状态
|
|
||||||
this.urlOptions.getDataListURL(this.listQuery)
|
|
||||||
.then((res) => {
|
|
||||||
let arr = [
|
|
||||||
{
|
|
||||||
prop: 'lineName',
|
|
||||||
label: '产线',
|
|
||||||
fixed: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'sum',
|
|
||||||
label: '合计[片]',
|
|
||||||
fixed: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: res.data ? res.data.nameData[0].name : undefined,
|
|
||||||
label: res.data ? res.data.nameData[0].name : undefined,
|
|
||||||
align: 'center',
|
|
||||||
children: [],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
let xData = [];
|
this.dateLabelList.forEach((item) => {
|
||||||
let yAllData = [];
|
if (item.indexOf('年') === -1) {
|
||||||
let lineName = [];
|
// 构造表头
|
||||||
if (res.data) {
|
const props = {
|
||||||
// 处理日期标签去重
|
prop: item,
|
||||||
let tempDateList = [];
|
label: item,
|
||||||
res.data.nameData.forEach((date) => {
|
};
|
||||||
tempDateList.push(date.name);
|
arr[2].children.push(props);
|
||||||
});
|
|
||||||
this.dateLabelList = Array.from(new Set(tempDateList));
|
|
||||||
|
|
||||||
// 构造表头children和echarts横坐标
|
// 构造echarts横坐标
|
||||||
this.dateLabelList.forEach((item) => {
|
xData.push(item);
|
||||||
if (item.indexOf('年') === -1) {
|
}
|
||||||
arr[2].children.push({
|
});
|
||||||
prop: item,
|
// res.data.nameData.slice(1).forEach(item => {
|
||||||
label: item,
|
// const props = {
|
||||||
});
|
// 'prop': item.name,
|
||||||
xData.push(item);
|
// 'label': item.name,
|
||||||
}
|
// 'align': 'center'
|
||||||
});
|
// }
|
||||||
|
// arr[2].children.push(props)
|
||||||
|
// })
|
||||||
|
let tableDataArr = [];
|
||||||
|
res.data.data.forEach((item) => {
|
||||||
|
let obj = {};
|
||||||
|
(obj.lineName = item.lineName),
|
||||||
|
(obj.sum = item.sum),
|
||||||
|
item.data.forEach((ele, index) => {
|
||||||
|
// console.log(ele)
|
||||||
|
ele.children.forEach((e) => {
|
||||||
|
console.log(e.dynamicName);
|
||||||
|
obj['' + e.dynamicName + ''] = e.dynamicValue;
|
||||||
|
console.log(obj['' + e.dynamicName + '']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
tableDataArr.push(obj);
|
||||||
|
});
|
||||||
|
this.tableData = tableDataArr;
|
||||||
|
this.tableProps = arr;
|
||||||
|
|
||||||
// 构造表格数据
|
// let tempList = []
|
||||||
let tableDataArr = [];
|
// res.data.nameData.slice(1).forEach(item => {
|
||||||
res.data.data.forEach((item) => {
|
// tempList.push(item.name)
|
||||||
let obj = {
|
// // arr[2].children.push(props)
|
||||||
lineName: item.lineName,
|
// })
|
||||||
sum: item.sum,
|
// xData = Array.from(new Set(tempList))
|
||||||
};
|
|
||||||
item.data.forEach((ele) => {
|
|
||||||
ele.children.forEach((e) => {
|
|
||||||
obj[e.dynamicName] = e.dynamicValue;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
tableDataArr.push(obj);
|
|
||||||
});
|
|
||||||
this.tableData = tableDataArr;
|
|
||||||
this.tableProps = arr;
|
|
||||||
|
|
||||||
// 构造图表数据
|
res.data.data.forEach((item) => {
|
||||||
res.data.data.forEach((item) => {
|
let yData = [];
|
||||||
let yData = [];
|
lineName.push(item.lineName);
|
||||||
lineName.push(item.lineName);
|
// let obj = {}
|
||||||
item.data.forEach((ele) => {
|
// obj.lineName = item.lineName,
|
||||||
ele.children.forEach((e) => {
|
// obj.sum = item.sum,
|
||||||
yData.push(e.dynamicValue);
|
item.data.forEach((ele, index) => {
|
||||||
});
|
// console.log(ele)
|
||||||
});
|
ele.children.forEach((e) => {
|
||||||
yAllData.push(yData);
|
// let yData = []
|
||||||
});
|
yData.push(e.dynamicValue);
|
||||||
} else {
|
});
|
||||||
this.tableProps = arr;
|
});
|
||||||
this.tableData = [];
|
yAllData.push(yData);
|
||||||
xData = [];
|
});
|
||||||
yAllData = [];
|
console.log(lineName);
|
||||||
lineName = [];
|
} else {
|
||||||
}
|
this.tableProps = arr;
|
||||||
|
this.tableData = [];
|
||||||
// 初始化图表
|
xData = [];
|
||||||
this.$nextTick(() => {
|
yAllData = [];
|
||||||
this.$refs.lineChart.initChart(xData, yAllData, lineName);
|
lineName = [];
|
||||||
});
|
}
|
||||||
})
|
// res.data.data[0].data[0].children.forEach((item, index) => {
|
||||||
.catch((err) => {
|
// // console.log(item)
|
||||||
console.error('获取产量数据失败:', err);
|
// yData.push(item.dynamicValue)
|
||||||
this.tableData = [];
|
// // let data = 'data' + Number(index+1)
|
||||||
})
|
// // obj['' + item.dynamicName + ''] = item.dynamicValue
|
||||||
.finally(() => {
|
// })
|
||||||
this.dataListLoading = false; // 关闭加载状态
|
// console.log(this.yData)
|
||||||
});
|
this.$nextTick(() => {
|
||||||
},
|
this.$refs.lineChart.initChart(xData, yAllData, lineName);
|
||||||
/**
|
});
|
||||||
* 搜索栏按钮点击事件
|
// this.total = response.data.total;
|
||||||
* @param {Object} val - 按钮/表单传递的参数
|
// this.dataListLoading = false;
|
||||||
*/
|
});
|
||||||
buttonClick(val) {
|
},
|
||||||
switch (val.btnName) {
|
buttonClick(val) {
|
||||||
case 'search':
|
switch (val.btnName) {
|
||||||
// 处理产线参数(避免undefined,空值设为空数组)
|
case 'search':
|
||||||
this.listQuery.lineIds = val.lineIds || [];
|
this.listQuery.lineIds = val.lineIds ? val.lineIds : undefined;
|
||||||
// 处理时间参数:如果是时间字符串,可转换为时间戳(根据接口要求调整)
|
// this.listQuery.productId = val.productId;
|
||||||
if (val.time) {
|
this.listQuery.time = val.time
|
||||||
// this.listQuery.time = val.time;
|
? new Date(val.time).getTime()
|
||||||
// 若接口需要时间戳,取消下面注释:
|
: undefined;
|
||||||
this.listQuery.time = new Date(val.time).getTime();
|
// this.listQuery.pageNo = 1;
|
||||||
} else {
|
// this.listQuery.pageSize = 10;
|
||||||
this.$message({
|
if (val.time) {
|
||||||
message: '请选择时间',
|
this.getData();
|
||||||
type: 'warning',
|
} else {
|
||||||
});
|
this.$message({
|
||||||
return;
|
message: '请选择时间',
|
||||||
}
|
type: 'warning',
|
||||||
|
});
|
||||||
// 验证产线是否选择(可选,根据业务需求调整)
|
}
|
||||||
if (this.listQuery.lineIds.length === 0) {
|
break;
|
||||||
this.$message({
|
case 'reset':
|
||||||
message: '请选择至少一条产线',
|
this.$refs.searchBarForm.resetForm();
|
||||||
type: 'warning',
|
this.listQuery = {
|
||||||
});
|
pageSize: 10,
|
||||||
return;
|
pageNo: 1,
|
||||||
}
|
total: 1,
|
||||||
|
};
|
||||||
this.getData();
|
this.getDataList();
|
||||||
break;
|
break;
|
||||||
case 'reset':
|
default:
|
||||||
// 重置表单
|
console.log(val);
|
||||||
this.$refs.searchBarForm.resetForm();
|
}
|
||||||
// 恢复默认值
|
},
|
||||||
this.listQuery = {
|
},
|
||||||
lineIds: this.formConfig[1].defaultSelect || [],
|
|
||||||
time: this.formConfig[0].defaultValue || '',
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log(val);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -279,8 +279,7 @@ export default {
|
|||||||
filterable: true,
|
filterable: true,
|
||||||
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,30 +66,20 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="完成单位产品用时(S)" prop="processTime">
|
<el-form-item label="完成单位产品用时" prop="processTime">
|
||||||
<el-input :disabled="isdetail" v-model="dataForm.processTime" placeholder="请输入完成单位产品用时(S)" />
|
<el-input :disabled="isdetail" v-model="dataForm.processTime" placeholder="请输入完成单位产品用时" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label=" 产品工艺" prop="processTypes">
|
<el-form-item label=" 加工属性" prop="processType">
|
||||||
<el-select :disabled="isdetail" collapse-tags multiple v-model="dataForm.processTypes" clearable
|
<el-select v-model="dataForm.processType" clearable style="width: 100%" :disabled="isdetail"
|
||||||
style="width: 100%" placeholder="请选择产品工艺">
|
placeholder="请选择加工属性">
|
||||||
<el-option v-for="dict in processTypeList" :key="dict.value" :label="dict.label"
|
<el-option v-for="dict in processTypeList" :key="dict.id" :label="dict.label"
|
||||||
:value="dict.value" />
|
:value="dict.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<!-- <el-row :gutter="20">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label=" 基板类型" prop="typeDictValue">
|
|
||||||
<el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable
|
|
||||||
style="width: 100%" placeholder="请选择基板类型">
|
|
||||||
<el-option v-for="dict in typeList" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row> -->
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
|
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
|
||||||
@@ -141,361 +131,317 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
deleteProductAttr,
|
deleteProductAttr,
|
||||||
getProductAttrPage,
|
getProductAttrPage,
|
||||||
} from '@/api/core/base/productAttr';
|
} from '@/api/core/base/productAttr';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createProduct,
|
createProduct,
|
||||||
updateProduct,
|
updateProduct,
|
||||||
getProduct,
|
getProduct,
|
||||||
getCode,
|
getCode,
|
||||||
} from '@/api/core/base/product';
|
} from '@/api/core/base/product';
|
||||||
import productAttrAdd from './attr-add';
|
import productAttrAdd from './attr-add';
|
||||||
import { parseTime } from '../../mixins/code-filter';
|
import { parseTime } from '../../mixins/code-filter';
|
||||||
import SmallTitle from './SmallTitle';
|
import SmallTitle from './SmallTitle';
|
||||||
import { listData } from "@/api/system/dict/data"; //数据字典接口
|
|
||||||
const tableBtn = [
|
const tableBtn = [
|
||||||
{
|
{
|
||||||
type: 'edit',
|
type: 'edit',
|
||||||
btnName: '编辑',
|
btnName: '编辑',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'delete',
|
type: 'delete',
|
||||||
btnName: '删除',
|
btnName: '删除',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
{
|
{
|
||||||
prop: 'createTime',
|
prop: 'createTime',
|
||||||
label: '添加时间',
|
label: '添加时间',
|
||||||
filter: parseTime,
|
filter: parseTime,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'name',
|
prop: 'name',
|
||||||
label: '属性名',
|
label: '属性名',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'value',
|
prop: 'value',
|
||||||
label: '属性值',
|
label: '属性值',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { productAttrAdd, SmallTitle },
|
components: { productAttrAdd, SmallTitle },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
addOrUpdateVisible: false,
|
addOrUpdateVisible: false,
|
||||||
tableBtn,
|
tableBtn,
|
||||||
tableProps,
|
tableProps,
|
||||||
productAttributeList: [],
|
productAttributeList: [],
|
||||||
dataForm: {
|
dataForm: {
|
||||||
id: null,
|
id: null,
|
||||||
name: '', // 产品名称
|
name: '', // 产品名称
|
||||||
code: '', // 产品编码
|
code: '', // 产品编码
|
||||||
area: 0, // 深加工单位平方数(float only)
|
area: 0, // 深加工单位平方数(float only)
|
||||||
typeDictValue: null, // 产品类型id
|
typeDictValue: null, // 产品类型id
|
||||||
processTime: null, // 单位产品用时 (s)
|
processTime: null, // 单位产品用时 (s)
|
||||||
specifications: '', // 深加工规格
|
specifications: '', // 深加工规格
|
||||||
unitDictValue: '', // 单位id
|
unitDictValue: '', // 单位id
|
||||||
originalSpecifications: '', // 原片规格
|
originalSpecifications: '', // 原片规格
|
||||||
originalArea: 0, // 原片单位平方数
|
originalArea: 0, // 原片单位平方数
|
||||||
processTypes: [],
|
processType:undefined,
|
||||||
typeDictValue: null,
|
},
|
||||||
},
|
listQuery: {
|
||||||
typeList:[],
|
pageSize: 10,
|
||||||
listQuery: {
|
pageNo: 1,
|
||||||
pageSize: 10,
|
total: 0,
|
||||||
pageNo: 1,
|
|
||||||
total: 0,
|
|
||||||
},
|
},
|
||||||
processTypeList: [
|
processTypeList: [
|
||||||
// {
|
{
|
||||||
// value: '1',
|
id: '0',
|
||||||
// label: '压花丝印'
|
label:'压花丝印'
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// value: '2',
|
id: '1',
|
||||||
// label: '无印打孔'
|
label: '无印打孔'
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// value: '3',
|
id: '2',
|
||||||
// label: '单层镀膜'
|
label: '单层镀膜'
|
||||||
// }, {
|
}, {
|
||||||
// value: '4',
|
id: '3',
|
||||||
// label: '双层镀膜'
|
label: '双层镀膜'
|
||||||
// }
|
}
|
||||||
],
|
],
|
||||||
dataRule: {
|
dataRule: {
|
||||||
code: [
|
code: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '产品编码不能为空',
|
message: '产品编码不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// type: 'number',
|
// type: 'number',
|
||||||
// message: '产品编码为数字类型',
|
// message: '产品编码为数字类型',
|
||||||
// trigger: 'blur',
|
// trigger: 'blur',
|
||||||
// transfom: 'val => Number(val)',
|
// transfom: 'val => Number(val)',
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
name: [
|
name: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '产品名称不能为空',
|
message: '产品名称不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
typeDictValue: [
|
typeDictValue: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '产品类型不能为空',
|
message: '产品类型不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
area: [
|
area: [
|
||||||
{
|
{
|
||||||
type: 'number',
|
type: 'number',
|
||||||
message: '请输入正确的数值',
|
message: '请输入正确的数值',
|
||||||
trigger: 'change',
|
trigger: 'change',
|
||||||
transform: (val) => Number(val),
|
transform: (val) => Number(val),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
processTime: [
|
processTime: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '完成单位产品用时不能为空',
|
message: '完成单位产品用时不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'number',
|
type: 'number',
|
||||||
message: '请输入正确的数值',
|
message: '请输入正确的数值',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
transform: (val) => Number(val),
|
transform: (val) => Number(val),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
isdetail: false,
|
isdetail: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async initData() {
|
initData() {
|
||||||
this.productAttributeList.splice(0);
|
this.productAttributeList.splice(0);
|
||||||
this.listQuery.total = 0;
|
this.listQuery.total = 0;
|
||||||
const typeRes = await listData({
|
},
|
||||||
pageNo:
|
init(id, isdetail) {
|
||||||
1,
|
this.initData();
|
||||||
pageSize
|
this.isdetail = isdetail || false;
|
||||||
: 10,
|
this.dataForm.id = id || null;
|
||||||
dictType
|
this.visible = true;
|
||||||
: 'product_type'
|
|
||||||
})
|
|
||||||
|
|
||||||
this.typeList = typeRes.data.list
|
this.$nextTick(() => {
|
||||||
console.log('typeRes', this.typeList);
|
this.$refs['dataForm'].resetFields();
|
||||||
const processTypeRes = await listData({
|
|
||||||
pageNo:
|
|
||||||
1,
|
|
||||||
pageSize
|
|
||||||
: 10,
|
|
||||||
dictType
|
|
||||||
: 'process_type'
|
|
||||||
})
|
|
||||||
|
|
||||||
this.processTypeList = processTypeRes.data.list
|
if (this.dataForm.id) {
|
||||||
console.log('typeRes', this.typeList);
|
// 获取产品详情
|
||||||
},
|
getProduct(id).then((response) => {
|
||||||
init(id, isdetail) {
|
this.dataForm = response.data;
|
||||||
this.initData();
|
});
|
||||||
this.isdetail = isdetail || false;
|
// 获取产品的属性列表
|
||||||
this.dataForm.id = id || null;
|
this.getList();
|
||||||
// this.dataForm.processTypes = [] // 清空工艺选择
|
} else {
|
||||||
this.visible = true;
|
getCode().then((res) => {
|
||||||
|
this.dataForm.code = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
this.$nextTick(() => {
|
getList() {
|
||||||
this.$refs['dataForm'].resetFields();
|
// 获取产品的属性列表
|
||||||
|
getProductAttrPage({
|
||||||
if (this.dataForm.id) {
|
...this.listQuery,
|
||||||
// 获取产品详情
|
productId: this.dataForm.id,
|
||||||
getProduct(id).then((res) => {
|
}).then((response) => {
|
||||||
const resData = res.data || {};
|
this.productAttributeList = response.data.list;
|
||||||
// 逐个字段赋值(保留响应式)
|
this.listQuery.total = response.data.total;
|
||||||
this.dataForm.name = resData.name || '';
|
});
|
||||||
this.dataForm.code = resData.code || '';
|
},
|
||||||
this.dataForm.area = resData.area || 0;
|
handleClick(raw) {
|
||||||
this.dataForm.typeDictValue = resData.typeDictValue || null;
|
if (raw.type === 'delete') {
|
||||||
this.dataForm.processTime = resData.processTime || null;
|
this.$confirm(
|
||||||
this.dataForm.specifications = resData.specifications || '';
|
`确定对${
|
||||||
this.dataForm.unitDictValue = resData.unitDictValue || '';
|
raw.data.name
|
||||||
this.dataForm.originalSpecifications = resData.originalSpecifications || '';
|
? '[名称=' + raw.data.name + ']'
|
||||||
this.dataForm.originalArea = resData.originalArea || 0;
|
: '[序号=' + raw.data._pageIndex + ']'
|
||||||
|
}进行删除操作?`,
|
||||||
// 处理工艺列表:确保是数组,过滤空值
|
'提示',
|
||||||
this.dataForm.processTypes = resData.processType
|
{
|
||||||
? resData.processType.split(',').filter(Boolean)
|
confirmButtonText: '确定',
|
||||||
: [];
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式
|
}
|
||||||
});
|
)
|
||||||
// 获取产品的属性列表
|
.then(() => {
|
||||||
this.getList();
|
deleteProductAttr(raw.data.id).then(({ data }) => {
|
||||||
} else {
|
this.$message({
|
||||||
getCode().then((res) => {
|
message: '操作成功',
|
||||||
this.dataForm.code = res.data;
|
type: 'success',
|
||||||
});
|
duration: 1500,
|
||||||
}
|
onClose: () => {
|
||||||
});
|
this.getList();
|
||||||
},
|
},
|
||||||
|
});
|
||||||
getList() {
|
});
|
||||||
// 获取产品的属性列表
|
})
|
||||||
getProductAttrPage({
|
.catch(() => {});
|
||||||
...this.listQuery,
|
} else {
|
||||||
productId: this.dataForm.id,
|
this.addNew(raw.data.id);
|
||||||
}).then((response) => {
|
}
|
||||||
this.productAttributeList = response.data.list;
|
},
|
||||||
this.listQuery.total = response.data.total;
|
// 表单提交
|
||||||
});
|
dataFormSubmit() {
|
||||||
},
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
handleClick(raw) {
|
if (valid) {
|
||||||
if (raw.type === 'delete') {
|
// 修改的提交
|
||||||
this.$confirm(
|
if (this.dataForm.id) {
|
||||||
`确定对${raw.data.name
|
updateProduct(this.dataForm).then((response) => {
|
||||||
? '[名称=' + raw.data.name + ']'
|
this.$modal.msgSuccess('修改成功');
|
||||||
: '[序号=' + raw.data._pageIndex + ']'
|
this.visible = false;
|
||||||
}进行删除操作?`,
|
this.$emit('refreshDataList');
|
||||||
'提示',
|
});
|
||||||
{
|
return;
|
||||||
confirmButtonText: '确定',
|
}
|
||||||
cancelButtonText: '取消',
|
// 添加的提交
|
||||||
type: 'warning',
|
createProduct(this.dataForm).then((response) => {
|
||||||
}
|
this.$modal.msgSuccess('新增成功');
|
||||||
)
|
this.$confirm(`是否新增产品属性?`, '系统提示', {
|
||||||
.then(() => {
|
confirmButtonText: '确定',
|
||||||
deleteProductAttr(raw.data.id).then(({ data }) => {
|
cancelButtonText: '取消',
|
||||||
this.$message({
|
type: 'warning',
|
||||||
message: '操作成功',
|
})
|
||||||
type: 'success',
|
.then(() => {
|
||||||
duration: 1500,
|
|
||||||
onClose: () => {
|
|
||||||
this.getList();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => { });
|
|
||||||
} else {
|
|
||||||
this.addNew(raw.data.id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 表单提交
|
|
||||||
dataFormSubmit() {
|
|
||||||
this.$refs['dataForm'].validate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
|
|
||||||
// 修改的提交
|
|
||||||
if (this.dataForm.id) {
|
|
||||||
updateProduct(this.dataForm).then((response) => {
|
|
||||||
this.$modal.msgSuccess('修改成功');
|
|
||||||
this.visible = false;
|
|
||||||
this.$emit('refreshDataList');
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 添加的提交
|
|
||||||
createProduct(this.dataForm).then((response) => {
|
|
||||||
this.$modal.msgSuccess('新增成功');
|
|
||||||
this.$confirm(`是否新增产品属性?`, '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.dataForm.id = response.data
|
this.dataForm.id = response.data
|
||||||
this.addNew();
|
this.addNew();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.$emit('refreshDataList');
|
this.$emit('refreshDataList');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
goEdit() {
|
goEdit() {
|
||||||
this.isdetail = false;
|
this.isdetail = false;
|
||||||
},
|
},
|
||||||
// 新增 / 修改
|
// 新增 / 修改
|
||||||
addNew(id) {
|
addNew(id) {
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
this.addOrUpdateVisible = true;
|
this.addOrUpdateVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdate.init(id);
|
this.$refs.addOrUpdate.init(id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$message('请先创建产品!');
|
this.$message('请先创建产品!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
goback() {
|
goback() {
|
||||||
this.$emit('refreshDataList');
|
this.$emit('refreshDataList');
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.initData();
|
this.initData();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.drawer>>>.el-drawer {
|
.drawer >>> .el-drawer {
|
||||||
border-radius: 8px 0 0 8px;
|
border-radius: 8px 0 0 8px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer>>>.el-form-item__label {
|
.drawer >>> .el-form-item__label {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer>>>.el-drawer__header {
|
.drawer >>> .el-drawer__header {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 32px 32px 24px;
|
padding: 32px 32px 24px;
|
||||||
border-bottom: 1px solid #dcdfe6;
|
border-bottom: 1px solid #dcdfe6;
|
||||||
|
}
|
||||||
|
.drawer >>> .el-drawer__body {
|
||||||
|
flex: 1;
|
||||||
|
height: 1px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer>>>.el-drawer__body {
|
.drawer >>> .content {
|
||||||
flex: 1;
|
padding: 30px 24px;
|
||||||
height: 1px;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
/* height: 100%; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer>>>.content {
|
.drawer >>> .visual-part {
|
||||||
padding: 30px 24px;
|
flex: 1 auto;
|
||||||
flex: 1;
|
max-height: 76vh;
|
||||||
display: flex;
|
overflow: hidden;
|
||||||
flex-direction: column;
|
overflow-y: scroll;
|
||||||
/* height: 100%; */
|
padding-right: 10px; /* 调整滚动条样式 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer>>>.visual-part {
|
.drawer >>> .el-form,
|
||||||
flex: 1 auto;
|
.drawer >>> .attr-list {
|
||||||
max-height: 76vh;
|
padding: 0 16px;
|
||||||
overflow: hidden;
|
|
||||||
overflow-y: scroll;
|
|
||||||
padding-right: 10px;
|
|
||||||
/* 调整滚动条样式 */
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer>>>.el-form,
|
|
||||||
.drawer>>>.attr-list {
|
|
||||||
padding: 0 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer-body__footer {
|
.drawer-body__footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,142 +1,139 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-loading="isLoading" loading-text="处理中..." loading-spinner="el-icon-loading"
|
<el-dialog
|
||||||
loading-background="rgba(255, 255, 255, 0.7)" :visible.sync="visible" :width="'35%'" :append-to-body="true"
|
:visible.sync="visible"
|
||||||
:close-on-click-modal="false" class="dialog">
|
:width="'35%'"
|
||||||
<template #title>
|
:append-to-body="true"
|
||||||
<slot name="title">
|
:close-on-click-modal="false"
|
||||||
<div class="titleStyle">
|
class="dialog">
|
||||||
{{ !dataForm.id ? '新增' : '编辑' }}
|
<template #title>
|
||||||
</div>
|
<slot name="title">
|
||||||
</slot>
|
<div class="titleStyle">
|
||||||
</template>
|
{{ !dataForm.id ? '新增' : '编辑' }}
|
||||||
|
</div>
|
||||||
|
</slot>
|
||||||
|
</template>
|
||||||
|
|
||||||
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="100px"
|
<el-form
|
||||||
@keyup.enter.native="dataFormSubmit()">
|
ref="dataForm"
|
||||||
<el-form-item label="属性名" prop="name">
|
:model="dataForm"
|
||||||
<el-input v-model="dataForm.name" placeholder="请输入属性名" clearable />
|
:rules="dataRule"
|
||||||
</el-form-item>
|
label-width="100px"
|
||||||
<el-form-item label="属性值" prop="value">
|
@keyup.enter.native="dataFormSubmit()">
|
||||||
<el-input v-model="dataForm.value" placeholder="请输入属性值" clearable />
|
<el-form-item label="属性名" prop="name">
|
||||||
</el-form-item>
|
<el-input
|
||||||
</el-form>
|
v-model="dataForm.name"
|
||||||
|
placeholder="请输入属性名"
|
||||||
|
clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="属性值" prop="value">
|
||||||
|
<el-input
|
||||||
|
v-model="dataForm.value"
|
||||||
|
placeholder="请输入属性值"
|
||||||
|
clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
<el-row style="text-align: right">
|
<el-row style="text-align: right">
|
||||||
<el-button @click="visible = false">取消</el-button>
|
<el-button @click="visible = false">取消</el-button>
|
||||||
<el-button :loading="isLoading" type="primary" @click="dataFormSubmit()">确定</el-button>
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
createProductAttr,
|
createProductAttr,
|
||||||
updateProductAttr,
|
updateProductAttr,
|
||||||
getProductAttr,
|
getProductAttr,
|
||||||
} from '@/api/core/base/productAttr';
|
} from '@/api/core/base/productAttr';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
productId: {
|
productId: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
isLoading: false,
|
dataForm: {
|
||||||
dataForm: {
|
id: 0,
|
||||||
id: 0,
|
name: '',
|
||||||
name: '',
|
value: '',
|
||||||
value: '',
|
},
|
||||||
},
|
dataRule: {
|
||||||
dataRule: {
|
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
|
||||||
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
|
},
|
||||||
},
|
};
|
||||||
};
|
},
|
||||||
},
|
methods: {
|
||||||
methods: {
|
init(id) {
|
||||||
init(id) {
|
this.dataForm.id = id || '';
|
||||||
this.dataForm.id = id || '';
|
this.visible = true;
|
||||||
this.visible = true;
|
this.$nextTick(() => {
|
||||||
this.$nextTick(() => {
|
this.$refs['dataForm'].resetFields();
|
||||||
this.$refs['dataForm'].resetFields();
|
if (this.dataForm.id) {
|
||||||
if (this.dataForm.id) {
|
getProductAttr(this.dataForm.id).then((res) => {
|
||||||
getProductAttr(this.dataForm.id).then((res) => {
|
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() {
|
||||||
});
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
},
|
if (valid) {
|
||||||
// 表单提交(优化加载状态和错误处理)
|
// 修改的提交
|
||||||
async dataFormSubmit() {
|
if (this.dataForm.id) {
|
||||||
// 先验证表单
|
updateProductAttr({
|
||||||
const valid = await new Promise((resolve) => {
|
...this.dataForm,
|
||||||
this.$refs['dataForm'].validate((isValid) => resolve(isValid));
|
productId: this.productId,
|
||||||
});
|
}).then((response) => {
|
||||||
|
this.$modal.msgSuccess('修改成功');
|
||||||
if (!valid) return;
|
this.visible = false;
|
||||||
|
this.$emit('refreshDataList');
|
||||||
this.isLoading = true; // 开始加载
|
});
|
||||||
|
return;
|
||||||
try {
|
}
|
||||||
if (this.dataForm.id) {
|
// 添加的提交
|
||||||
// 编辑操作
|
createProductAttr({
|
||||||
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({
|
}
|
||||||
...this.dataForm,
|
});
|
||||||
productId: this.productId,
|
},
|
||||||
});
|
},
|
||||||
this.$modal.msgSuccess('新增成功');
|
|
||||||
}
|
|
||||||
this.visible = false;
|
|
||||||
this.$emit('refreshDataList');
|
|
||||||
} catch (error) {
|
|
||||||
// 错误处理
|
|
||||||
console.error('提交失败:', error);
|
|
||||||
this.$modal.msgError('操作失败,请重试');
|
|
||||||
} finally {
|
|
||||||
// 无论成功失败,都关闭加载状态
|
|
||||||
this.isLoading = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</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;
|
height: 16px;
|
||||||
height: 16px;
|
background-color: #0b58ff;
|
||||||
background-color: #0b58ff;
|
border-radius: 1px;
|
||||||
border-radius: 1px;
|
margin-right: 8px;
|
||||||
margin-right: 8px;
|
position: relative;
|
||||||
position: relative;
|
top: 2px;
|
||||||
top: 2px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -104,11 +104,7 @@ export default {
|
|||||||
getDataListURL: getProductionLinePage,
|
getDataListURL: getProductionLinePage,
|
||||||
deleteURL: deleteProductionLine,
|
deleteURL: deleteProductionLine,
|
||||||
exportURL: exportProductionLineExcel,
|
exportURL: exportProductionLineExcel,
|
||||||
},
|
},
|
||||||
listQuery: {
|
|
||||||
pageSize: 20,
|
|
||||||
pageNo:1
|
|
||||||
},
|
|
||||||
tableProps,
|
tableProps,
|
||||||
tableBtn: [
|
tableBtn: [
|
||||||
this.$auth.hasPermi(`base:production-line:update`)
|
this.$auth.hasPermi(`base:production-line:update`)
|
||||||
@@ -216,7 +212,7 @@ export default {
|
|||||||
switch (val.btnName) {
|
switch (val.btnName) {
|
||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 20;
|
this.listQuery.pageSize = 10;
|
||||||
this.listQuery.factoryId = val.factoryId || undefined;
|
this.listQuery.factoryId = val.factoryId || undefined;
|
||||||
this.listQuery.name = val.name;
|
this.listQuery.name = val.name;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
@@ -224,7 +220,7 @@ export default {
|
|||||||
case 'reset':
|
case 'reset':
|
||||||
this.$refs.searchBarForm.resetForm();
|
this.$refs.searchBarForm.resetForm();
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 20,
|
pageSize: 10,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -262,14 +262,6 @@ 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,9 +34,9 @@
|
|||||||
<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="220" />
|
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="210" />
|
||||||
</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">
|
||||||
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px"
|
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px"
|
||||||
:bar-data="tableData" />
|
:bar-data="tableData" />
|
||||||
@@ -57,9 +57,9 @@
|
|||||||
<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="300" />
|
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="210" />
|
||||||
</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">
|
||||||
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
|
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
|
||||||
:bar-data="tableData2" />
|
:bar-data="tableData2" />
|
||||||
@@ -71,7 +71,9 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-inner" v-if="listQuery.timeType === 3">
|
|
||||||
|
<!-- 3.2 时间维度为“自定义”时的内容(两个平分高度的div) -->
|
||||||
|
<div class="content-inner" v-else>
|
||||||
<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">
|
||||||
@@ -81,38 +83,10 @@
|
|||||||
parseTime(listQuery.endTime) }}
|
parseTime(listQuery.endTime) }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<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="300" :table-data="tableDataCustom" />
|
:limit="100" :table-props="tableProps" :max-height="210" :table-data="tableDataCustom" />
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-card energyOverlimitLog">
|
|
||||||
<span class="blue-block"></span>
|
|
||||||
<span class="tip">生产折线图</span>
|
|
||||||
<div style="width: 100%;height: 100%;" class="graph">
|
|
||||||
<barChart v-if="tableDataCustom && tableDataCustom.length > 0" ref="barChart"
|
|
||||||
:bar-data="tableDataCustom" />
|
|
||||||
<div v-else class="no-data-bg"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- 3.2 时间维度为“自定义”时的内容(两个平分高度的div) -->
|
|
||||||
<div class="content-inner" v-if="listQuery.timeType === 2">
|
|
||||||
<div class="content-card energyOverlimitLog">
|
|
||||||
<span class="blue-block"></span>
|
|
||||||
<span class="tip" v-if="listQuery.startTime && listQuery.endTime">
|
|
||||||
<span>{{ reportTypeMap[listQuery.reportType] }}</span>
|
|
||||||
<span>
|
|
||||||
{{ parseTime(listQuery.startTime) }} 至{{
|
|
||||||
parseTime(listQuery.endTime) }}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span class="tip" v-else>生产数据 </span>
|
|
||||||
<div class="graph">
|
|
||||||
<base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
|
|
||||||
:limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -139,7 +113,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="300" />
|
:max-height="210" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 当天数据(占1/2剩余高度) -->
|
<!-- 当天数据(占1/2剩余高度) -->
|
||||||
@@ -148,7 +122,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="300" />
|
:max-height="210" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -163,12 +137,12 @@
|
|||||||
<span>{{ reportTypeMap[listQuery.reportType] }}</span>
|
<span>{{ reportTypeMap[listQuery.reportType] }}</span>
|
||||||
<span>
|
<span>
|
||||||
{{ parseTime(listQuery.startTime) }} 至{{
|
{{ parseTime(listQuery.startTime) }} 至{{
|
||||||
parseTime(listQuery.endTime) }}
|
parseTime(listQuery.endTime) }}
|
||||||
</span>
|
</span>
|
||||||
</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="300" />
|
:limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="210" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -179,8 +153,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { parseTime } from '@/filter/code-filter';
|
import { parseTime } from '@/filter/code-filter';
|
||||||
import {
|
import {
|
||||||
getLineAuto, getPLlistByFactory, getPdlAutoReportNewSearchNow, getProcessAutoReportLastGroup,
|
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto,
|
||||||
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup
|
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew
|
||||||
} 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';
|
||||||
@@ -191,11 +165,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: '产线',
|
||||||
@@ -381,7 +355,6 @@ export default {
|
|||||||
activeLabel: 'table', // 当班数据tab
|
activeLabel: 'table', // 当班数据tab
|
||||||
activeLabelDay: 'table', // 当天数据tab
|
activeLabelDay: 'table', // 当天数据tab
|
||||||
fileName: '',
|
fileName: '',
|
||||||
headFormValue:{},
|
|
||||||
dataListLoading: false,
|
dataListLoading: false,
|
||||||
tableProps,
|
tableProps,
|
||||||
factoryColumns: [],
|
factoryColumns: [],
|
||||||
@@ -395,28 +368,15 @@ 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: '自定义' },
|
|
||||||
{ id: 3, 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: 100,
|
width: 80,
|
||||||
onchange: true,
|
onchange: true,
|
||||||
// defaultSelect: 1,
|
// defaultSelect: 1,
|
||||||
clearable: false,
|
clearable: false,
|
||||||
@@ -477,7 +437,6 @@ export default {
|
|||||||
{ id: 3, name: '月' },
|
{ id: 3, name: '月' },
|
||||||
{ id: 4, name: '年' }
|
{ id: 4, name: '年' }
|
||||||
],
|
],
|
||||||
onchange: true,
|
|
||||||
width: 80,
|
width: 80,
|
||||||
param: 'reportType'
|
param: 'reportType'
|
||||||
},
|
},
|
||||||
@@ -501,12 +460,6 @@ export default {
|
|||||||
btnName: '重置',
|
btnName: '重置',
|
||||||
name: 'reset',
|
name: 'reset',
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// type: 'label', // 初始隐藏
|
|
||||||
// label: '刷新时间', // 自定义标识
|
|
||||||
// // slot: 'currentTimeSlot', // 自定义插槽名
|
|
||||||
// // width: 200, // 宽度适配
|
|
||||||
// },
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -514,13 +467,6 @@ export default {
|
|||||||
productTableProps() {
|
productTableProps() {
|
||||||
// 当班数据的完整表头(基础列 + 当班动态表头)
|
// 当班数据的完整表头(基础列 + 当班动态表头)
|
||||||
const baseColumns = [
|
const baseColumns = [
|
||||||
{
|
|
||||||
prop: 'sizes',
|
|
||||||
label: '规格',
|
|
||||||
width: 105,
|
|
||||||
showOverflowtooltip: true,
|
|
||||||
fixed: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
prop: 'process',
|
prop: 'process',
|
||||||
label: '产品工艺',
|
label: '产品工艺',
|
||||||
@@ -529,9 +475,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',
|
||||||
@@ -544,13 +489,6 @@ export default {
|
|||||||
productTablePropsDay() {
|
productTablePropsDay() {
|
||||||
// 当天数据的完整表头(基础列 + 当天动态表头)
|
// 当天数据的完整表头(基础列 + 当天动态表头)
|
||||||
const baseColumns = [
|
const baseColumns = [
|
||||||
{
|
|
||||||
prop: 'sizes',
|
|
||||||
label: '规格',
|
|
||||||
width: 105,
|
|
||||||
showOverflowtooltip: true,
|
|
||||||
fixed: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
prop: 'process',
|
prop: 'process',
|
||||||
label: '产品工艺',
|
label: '产品工艺',
|
||||||
@@ -559,8 +497,7 @@ export default {
|
|||||||
{
|
{
|
||||||
prop: 'processType',
|
prop: 'processType',
|
||||||
label: '产品类型',
|
label: '产品类型',
|
||||||
filter: (val) => (val === 1 ? '面板' : '背板'),
|
filter: (val) => (val != 1 ? '面板' : '背板'),
|
||||||
sortable: true,
|
|
||||||
fixed: true
|
fixed: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -576,20 +513,17 @@ 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 = 3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.getLastDayDataList();
|
this.getDayDataList();
|
||||||
this.getPdLineList();
|
this.getPdLineList();
|
||||||
const queryParams = {
|
const queryParams = {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
@@ -638,69 +572,22 @@ export default {
|
|||||||
this.formConfig[1].type = ''; // 隐藏查询类型
|
this.formConfig[1].type = ''; // 隐藏查询类型
|
||||||
this.formConfig[6].type = ''; // 隐藏报表类型
|
this.formConfig[6].type = ''; // 隐藏报表类型
|
||||||
this.formConfig[7].type = ''; // 隐藏时间范围
|
this.formConfig[7].type = ''; // 隐藏时间范围
|
||||||
const timeItemIndex = this.formConfig.findIndex(item =>
|
|
||||||
item.label?.includes('刷新时间')
|
|
||||||
);
|
|
||||||
if (timeItemIndex > -1) {
|
|
||||||
this.formConfig.splice(timeItemIndex, 1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 3. 执行公共重置
|
// 3. 执行公共重置
|
||||||
resetCommon();
|
resetCommon();
|
||||||
// if (this.activeName === 'productLine') {
|
|
||||||
// } else {
|
|
||||||
// }
|
|
||||||
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
|
// 4. 根据类型设置差异化的表单配置(仅处理不同的部分)
|
||||||
if (isProductLine) {
|
if (isProductLine) {
|
||||||
// 按产线监控:显示产线,隐藏产品工艺和类型,时间维度包含上一班
|
// 按产线监控:显示产线,隐藏产品工艺和类型
|
||||||
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.listQuery.timeType = 3;
|
|
||||||
if (this.$refs.searchBarForm) {
|
|
||||||
this.$refs.searchBarForm.formInline.timeType = 3;
|
|
||||||
}
|
|
||||||
// 主动调用上一班数据接口
|
|
||||||
this.getLastDayDataList();
|
|
||||||
const timeItemIndex = this.formConfig.findIndex(item =>
|
|
||||||
item.label?.includes('刷新时间')
|
|
||||||
);
|
|
||||||
const timeLabel = {
|
|
||||||
type: 'label',
|
|
||||||
label: `刷新时间: ${this.formatCurrentTime()}`,
|
|
||||||
};
|
|
||||||
if (timeItemIndex > -1) {
|
|
||||||
this.formConfig.splice(timeItemIndex, 1, timeLabel);
|
|
||||||
} else {
|
|
||||||
this.formConfig.push(timeLabel);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
// 按产品监控:显示产品工艺和类型,隐藏产线
|
||||||
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
|
|
||||||
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
|
|
||||||
this.formConfig[3].type = ''; // 隐藏产线
|
this.formConfig[3].type = ''; // 隐藏产线
|
||||||
this.formConfig[4].type = 'select'; // 显示产品工艺
|
this.formConfig[4].type = 'select'; // 显示产品工艺
|
||||||
this.formConfig[5].type = 'select'; // 显示产品类型
|
this.formConfig[5].type = 'select'; // 显示产品类型
|
||||||
const timeItemIndex = this.formConfig.findIndex(item =>
|
|
||||||
item.label?.includes('刷新时间')
|
|
||||||
);
|
|
||||||
const timeLabel = {
|
|
||||||
type: 'label',
|
|
||||||
label: `刷新时间: ${this.formatCurrentTime()}`,
|
|
||||||
};
|
|
||||||
this.listQuery.timeType = 3;
|
|
||||||
if (this.$refs.searchBarForm) {
|
|
||||||
this.$refs.searchBarForm.formInline.timeType = 3;
|
|
||||||
}
|
|
||||||
if (timeItemIndex > -1) {
|
|
||||||
this.formConfig.splice(timeItemIndex, 1, timeLabel);
|
|
||||||
} else {
|
|
||||||
this.formConfig.push(timeLabel);
|
|
||||||
}
|
|
||||||
this.getProductLastList();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -714,12 +601,6 @@ 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', '产线监控_自定义时间数据');
|
||||||
@@ -912,9 +793,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取产线和工厂列表
|
// 获取产线和工厂列表
|
||||||
getPdLineList() {
|
getPdLineList() {
|
||||||
getPLlistByFactory({
|
getPdList().then(res => {
|
||||||
factoryIds:this.listQuery.factoryIds
|
|
||||||
}).then(res => {
|
|
||||||
this.formConfig[3].selectOptions = res.data || [];
|
this.formConfig[3].selectOptions = res.data || [];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -922,151 +801,31 @@ 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) {
|
||||||
this.headFormValue = val
|
|
||||||
if (this.activeName === 'productLine') {
|
|
||||||
this.listQuery.pageNo = 1;
|
|
||||||
this.listQuery.pageSize = 10;
|
|
||||||
this.listQuery.factoryId = this.headFormValue.factoryId || undefined;
|
|
||||||
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
|
|
||||||
this.listQuery.lineId = this.headFormValue.lineId ? this.headFormValue.lineId : [];
|
|
||||||
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
|
|
||||||
this.listQuery.reportType = this.headFormValue.reportType || undefined;
|
|
||||||
this.listQuery.timeType = this.headFormValue.timeType || undefined;
|
|
||||||
this.listQuery.searchType = this.headFormValue.searchType || undefined;
|
|
||||||
|
|
||||||
// 处理不同时间选择类型
|
|
||||||
if (this.headFormValue.timeVal) {
|
|
||||||
this.listQuery.startTime = this.headFormValue.timeVal[0];
|
|
||||||
this.listQuery.endTime = this.headFormValue.timeVal[1];
|
|
||||||
} else if (this.headFormValue.timeValWeek) {
|
|
||||||
// 周选择器
|
|
||||||
const { startTime, endTime } = this.getWeekTimeRange(this.headFormValue.timeValWeek);
|
|
||||||
this.listQuery.startTime = startTime;
|
|
||||||
this.listQuery.endTime = endTime;
|
|
||||||
} else if (this.headFormValue.timeValMonth) {
|
|
||||||
// 月选择器
|
|
||||||
this.listQuery.startTime = this.headFormValue.timeValMonth[0];
|
|
||||||
this.listQuery.endTime = this.headFormValue.timeValMonth[1];
|
|
||||||
} else if (this.headFormValue.timeValYear) {
|
|
||||||
// 年选择器
|
|
||||||
const { startTime, endTime } = this.getYearTimeRange(this.headFormValue.timeValYear);
|
|
||||||
this.listQuery.startTime = startTime;
|
|
||||||
this.listQuery.endTime = endTime;
|
|
||||||
} else {
|
|
||||||
this.listQuery.startTime = undefined;
|
|
||||||
this.listQuery.endTime = undefined;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.listQuery.pageNo = 1;
|
|
||||||
this.listQuery.pageSize = 10;
|
|
||||||
this.listQuery.factoryId = this.headFormValue.factoryId || []
|
|
||||||
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
|
|
||||||
this.listQuery.lineId = undefined;
|
|
||||||
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
|
|
||||||
this.listQuery.reportType = this.headFormValue.reportType || undefined;
|
|
||||||
this.listQuery.timeType = this.headFormValue.timeType || undefined;
|
|
||||||
this.listQuery.searchType = this.headFormValue.searchType || undefined;
|
|
||||||
|
|
||||||
// 处理不同时间选择类型
|
|
||||||
if (this.headFormValue.timeVal) {
|
|
||||||
this.listQuery.startTime = this.headFormValue.timeVal[0];
|
|
||||||
this.listQuery.endTime = this.headFormValue.timeVal[1];
|
|
||||||
} else if (this.headFormValue.timeValWeek) {
|
|
||||||
// 周选择器
|
|
||||||
const { startTime, endTime } = this.getWeekTimeRange(this.headFormValue.timeValWeek);
|
|
||||||
this.listQuery.startTime = startTime;
|
|
||||||
this.listQuery.endTime = endTime;
|
|
||||||
} else if (this.headFormValue.timeValMonth) {
|
|
||||||
// 月选择器
|
|
||||||
this.listQuery.startTime = this.headFormValue.timeValMonth[0];
|
|
||||||
this.listQuery.endTime = this.headFormValue.timeValMonth[1];
|
|
||||||
} else if (this.headFormValue.timeValYear) {
|
|
||||||
// 年选择器
|
|
||||||
const { startTime, endTime } = this.getYearTimeRange(this.headFormValue.timeValYear);
|
|
||||||
this.listQuery.startTime = startTime;
|
|
||||||
this.listQuery.endTime = endTime;
|
|
||||||
} else {
|
|
||||||
this.listQuery.startTime = undefined;
|
|
||||||
this.listQuery.endTime = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (val.btnName) {
|
switch (val.btnName) {
|
||||||
case 'search':
|
case 'search':
|
||||||
const timeItemIndex = this.formConfig.findIndex(item =>
|
this.listQuery.pageNo = 1;
|
||||||
item.label?.includes('刷新时间')
|
this.listQuery.pageSize = 10;
|
||||||
);
|
this.listQuery.factoryId = val.factoryId || undefined;
|
||||||
|
this.listQuery.process = val.process ? val.process : [];
|
||||||
// 仅当时间维度为【当天】时,添加/更新刷新时间
|
this.listQuery.lineId = val.lineId ? val.lineId : [];
|
||||||
if (this.listQuery.timeType === 1 || this.listQuery.timeType === 3) {
|
this.listQuery.processType = val.processType ? val.processType : [];
|
||||||
const timeLabel = {
|
this.listQuery.reportType = val.reportType || undefined;
|
||||||
type: 'label',
|
this.listQuery.timeType = val.timeType || undefined;
|
||||||
label: `刷新时间: ${this.formatCurrentTime()}`,
|
this.listQuery.searchType = val.searchType || undefined;
|
||||||
};
|
this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined;
|
||||||
if (timeItemIndex > -1) {
|
this.listQuery.endTime = val.timeVal ? val.timeVal[1] : undefined;
|
||||||
this.formConfig.splice(timeItemIndex, 1, timeLabel);
|
|
||||||
} else {
|
|
||||||
this.formConfig.push(timeLabel);
|
|
||||||
}
|
|
||||||
} else if (timeItemIndex > -1) {
|
|
||||||
// 非当天时,移除刷新时间
|
|
||||||
this.formConfig.splice(timeItemIndex, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
if (this.listQuery.timeType === 1) {
|
if (this.listQuery.timeType === 1) {
|
||||||
this.getDayDataList();
|
this.getDayDataList();
|
||||||
} else if (this.listQuery.timeType === 3) {
|
|
||||||
this.getLastDayDataList();
|
|
||||||
} else {
|
} else {
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.listQuery.timeType === 3) {
|
this.getProductList();
|
||||||
this.getProductLastList();
|
|
||||||
} else {
|
|
||||||
this.getProductList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
@@ -1074,34 +833,21 @@ export default {
|
|||||||
break;
|
break;
|
||||||
case 'reset':
|
case 'reset':
|
||||||
this.$refs.searchBarForm.resetForm();
|
this.$refs.searchBarForm.resetForm();
|
||||||
this.$refs.searchBarForm.formInline.timeType = 3;
|
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,
|
||||||
total: 0,
|
total: 0,
|
||||||
timeType: this.activeName === 'productLine' ? 3 : 1,
|
timeType: 1,
|
||||||
};
|
};
|
||||||
// 重置后默认是当天,添加刷新时间
|
|
||||||
const resetTimeIndex = this.formConfig.findIndex(item =>
|
|
||||||
item.label?.includes('刷新时间')
|
|
||||||
);
|
|
||||||
const resetTimeLabel = {
|
|
||||||
type: 'label',
|
|
||||||
label: `刷新时间: ${this.formatCurrentTime()}`,
|
|
||||||
};
|
|
||||||
if (resetTimeIndex > -1) {
|
|
||||||
this.formConfig.splice(resetTimeIndex, 1, resetTimeLabel);
|
|
||||||
} else {
|
|
||||||
this.formConfig.push(resetTimeLabel);
|
|
||||||
}
|
|
||||||
if (this.activeName === 'productLine') {
|
if (this.activeName === 'productLine') {
|
||||||
this.getLastDayDataList();
|
this.getDayDataList();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.getProductList();
|
this.getProductList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(val);
|
console.log(val);
|
||||||
@@ -1141,24 +887,13 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getProductList() {
|
async getProductList() {
|
||||||
this.listQuery.pageNo = 1;
|
console.log('resGroup');
|
||||||
this.listQuery.pageSize = 10;
|
|
||||||
this.listQuery.factoryId = this.headFormValue.factoryId || []
|
|
||||||
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
|
|
||||||
this.listQuery.lineId = undefined;
|
|
||||||
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
|
|
||||||
this.listQuery.reportType = this.headFormValue.reportType || undefined;
|
|
||||||
this.listQuery.timeType = this.headFormValue.timeType ? this.headFormValue.timeType : this.listQuery.timeType;
|
|
||||||
this.listQuery.searchType = this.headFormValue.searchType || undefined
|
|
||||||
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) => {
|
||||||
if (!Array.isArray(rawList) || rawList.length === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return rawList.map(item => {
|
return rawList.map(item => {
|
||||||
// 解构出 lineDetList 和其他字段(rest)
|
// 解构出 lineDetList 和其他字段(rest)
|
||||||
const { lineDetList = [], ...rest } = item;
|
const { lineDetList = [], ...rest } = item;
|
||||||
@@ -1207,9 +942,6 @@ export default {
|
|||||||
|
|
||||||
// 格式化数据:lineDetList提取到外层,键名加lineId前缀
|
// 格式化数据:lineDetList提取到外层,键名加lineId前缀
|
||||||
const formatData = (rawList) => {
|
const formatData = (rawList) => {
|
||||||
if (!Array.isArray(rawList) || rawList.length === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return rawList.map(item => {
|
return rawList.map(item => {
|
||||||
// 解构出 lineDetList 和其他字段(rest)
|
// 解构出 lineDetList 和其他字段(rest)
|
||||||
const { lineDetList = [], ...rest } = item;
|
const { lineDetList = [], ...rest } = item;
|
||||||
@@ -1270,72 +1002,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
async getProductLastList() {
|
|
||||||
console.log('last');
|
|
||||||
|
|
||||||
this.listQuery.pageNo = 1;
|
|
||||||
this.listQuery.pageSize = 10;
|
|
||||||
this.listQuery.factoryId = this.headFormValue.factoryId || []
|
|
||||||
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
|
|
||||||
this.listQuery.lineId = undefined;
|
|
||||||
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
|
|
||||||
this.listQuery.reportType = this.headFormValue.reportType || undefined;
|
|
||||||
this.listQuery.timeType = this.headFormValue.timeType ? this.headFormValue.timeType : this.listQuery.timeType;
|
|
||||||
this.listQuery.searchType = this.headFormValue.searchType || undefined
|
|
||||||
if (this.listQuery.timeType === 3) {
|
|
||||||
const resGroup = await getProcessAutoReportLastGroup(this.listQuery);
|
|
||||||
console.log('resGroup', resGroup);
|
|
||||||
|
|
||||||
// 格式化数据:lineDetList提取到外层,键名加lineId前缀
|
|
||||||
const formatData = (rawList) => {
|
|
||||||
if (!Array.isArray(rawList) || rawList.length === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return rawList.map(item => {
|
|
||||||
// 解构出 lineDetList 和其他字段(rest)
|
|
||||||
const { lineDetList = [], ...rest } = item;
|
|
||||||
|
|
||||||
// 遍历 lineDetList 中的每一项,逐个格式化并合并
|
|
||||||
const formattedLineData = lineDetList.reduce((acc, lineData) => {
|
|
||||||
// 取当前 lineData 的 lineId 作为前缀(确保存在,否则用空字符串)
|
|
||||||
const lineIdPrefix = lineData.lineId ? String(lineData.lineId) : '';
|
|
||||||
|
|
||||||
// 为当前 lineData 的每个字段添加 lineId 前缀,合并到累加器中
|
|
||||||
Object.entries(lineData).forEach(([key, value]) => {
|
|
||||||
const newKey = lineIdPrefix ? `${lineIdPrefix}${key}` : key;
|
|
||||||
acc[newKey] = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {}); // 初始值为空对象
|
|
||||||
|
|
||||||
// 合并外层字段和所有格式化后的 lineDetList 字段
|
|
||||||
return { ...rest, ...formattedLineData };
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 处理当班和当天数据(分别存储)
|
|
||||||
this.productTableData = formatData(resGroup.data.list); // 当班数据
|
|
||||||
console.log(this.productTableData, 'productTableData');
|
|
||||||
|
|
||||||
// --------------------------
|
|
||||||
// 生成当班数据的动态表头
|
|
||||||
// --------------------------
|
|
||||||
const groupLineDatas = [];
|
|
||||||
resGroup.data.list.forEach(item => {
|
|
||||||
if (item.lineDetList && item.lineDetList.length) {
|
|
||||||
groupLineDatas.push(...item.lineDetList);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 去重当班数据的产线(按lineId)
|
|
||||||
const uniqueGroupLines = Array.from(
|
|
||||||
new Map(groupLineDatas.map(line => [line.lineId, line])).values()
|
|
||||||
);
|
|
||||||
// 生成当班数据的表头(一级:产线名,二级:指标)
|
|
||||||
this.factoryColumns = this.generateLineColumns(uniqueGroupLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
// 生成动态表头:一级为产线名,二级为产线数据指标
|
// 生成动态表头:一级为产线名,二级为产线数据指标
|
||||||
generateLineColumns(lines) {
|
generateLineColumns(lines) {
|
||||||
// lines为去重后的产线列表(单个元素为一条产线数据)
|
// lines为去重后的产线列表(单个元素为一条产线数据)
|
||||||
@@ -1430,30 +1097,8 @@ export default {
|
|||||||
return [...lineColumns, totalColumn];
|
return [...lineColumns, totalColumn];
|
||||||
},
|
},
|
||||||
// 为当天时调用的接口
|
// 为当天时调用的接口
|
||||||
getLastDayDataList() {
|
|
||||||
getPdlAutoReportNewSearchLastGroup(this.listQuery).then((response) => {
|
|
||||||
this.tableDataCustom = 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(this.listQuery).then((response) => {
|
getPdlAutoReportNewSearchNow().then((response) => {
|
||||||
this.tableData = response.data.classData.map((item, index) => {
|
this.tableData = response.data.classData.map((item, index) => {
|
||||||
item.originalLossNum = item.original?.lossNum;
|
item.originalLossNum = item.original?.lossNum;
|
||||||
item.originalLossArea = item.original?.lossArea;
|
item.originalLossArea = item.original?.lossArea;
|
||||||
@@ -1504,85 +1149,32 @@ export default {
|
|||||||
this.listQuery.pageNo = val;
|
this.listQuery.pageNo = val;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
formatCurrentTime() {
|
|
||||||
const date = new Date();
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
||||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
||||||
return `${hours}:${minutes}:${seconds} ${year}.${month}.${day}`;
|
|
||||||
},
|
|
||||||
// 搜索栏下拉选择变化
|
// 搜索栏下拉选择变化
|
||||||
handleSearchBarChanged({ param, value }) {
|
handleSearchBarChanged({ param, value }) {
|
||||||
if (param === 'timeType') {
|
if (param === 'timeType') {
|
||||||
this.tableData2 = []
|
console.log(value);
|
||||||
this.tableDataCustom = []
|
|
||||||
this.tableData = []
|
|
||||||
const resetCommon = () => {
|
|
||||||
// 重置搜索表单的筛选条件
|
|
||||||
if (this.$refs.searchBarForm) {
|
|
||||||
const form = this.$refs.searchBarForm.formInline;
|
|
||||||
form.timeVal = undefined;
|
|
||||||
form.timeType = 1;
|
|
||||||
form.reportType = undefined;
|
|
||||||
form.searchType = undefined;
|
|
||||||
form.lineId = undefined;
|
|
||||||
form.factoryId = undefined;
|
|
||||||
form.process = undefined;
|
|
||||||
form.processType = undefined;
|
|
||||||
}
|
|
||||||
// 重置查询参数
|
|
||||||
this.listQuery = {
|
|
||||||
...this.listQuery, // 保留分页等基础参数
|
|
||||||
factoryId: undefined,
|
|
||||||
process: undefined,
|
|
||||||
lineId: undefined,
|
|
||||||
processType: undefined,
|
|
||||||
reportType: undefined,
|
|
||||||
timeType: 1,
|
|
||||||
searchType: undefined,
|
|
||||||
startTime: undefined,
|
|
||||||
endTime: undefined
|
|
||||||
};
|
|
||||||
// 重置表单配置中公共隐藏的项
|
|
||||||
this.formConfig[1].type = ''; // 隐藏查询类型
|
|
||||||
this.formConfig[6].type = ''; // 隐藏报表类型
|
|
||||||
this.formConfig[7].type = ''; // 隐藏时间范围
|
|
||||||
};
|
|
||||||
|
|
||||||
// 3. 执行公共重置
|
|
||||||
resetCommon();
|
|
||||||
this.listQuery.timeType = value;
|
this.listQuery.timeType = value;
|
||||||
const timeItemIndex = this.formConfig.findIndex(item =>
|
|
||||||
item.label?.includes('刷新时间')
|
|
||||||
);
|
|
||||||
|
|
||||||
// 仅移除,不添加(查询时才添加)
|
|
||||||
if (value !== 1 && value !== 3 && timeItemIndex > -1) {
|
|
||||||
this.formConfig.splice(timeItemIndex, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$refs.searchBarForm.formInline.timeType = value;
|
|
||||||
this.$refs.searchBarForm.formInline.searchType = undefined;
|
|
||||||
this.$refs.searchBarForm.formInline.reportType = undefined;
|
|
||||||
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
|
||||||
|
|
||||||
if (value === 1) {
|
if (value === 1) {
|
||||||
|
// 切换为“当天”:隐藏查询类型、报表类型、时间范围
|
||||||
this.formConfig[1].type = '';
|
this.formConfig[1].type = '';
|
||||||
this.formConfig[6].type = '';
|
this.formConfig[6].type = '';
|
||||||
this.formConfig[7].type = '';
|
this.formConfig[7].type = '';
|
||||||
} else if (value === 2) {
|
this.$refs.searchBarForm.formInline.timeType = value;
|
||||||
this.formConfig[1].type = 'select';
|
this.listQuery.timeType = value;
|
||||||
this.$refs.searchBarForm.formInline.searchType = 1;
|
|
||||||
this.formConfig[7].type = 'datePicker';
|
|
||||||
} else {
|
|
||||||
this.formConfig[1].type = '';
|
|
||||||
this.formConfig[6].type = '';
|
|
||||||
this.formConfig[7].type = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
this.$refs.searchBarForm.formInline.searchType = undefined;
|
||||||
|
this.$refs.searchBarForm.formInline.reportType = 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) {
|
||||||
// 统计数据:显示时间范围,隐藏报表类型
|
// 统计数据:显示时间范围,隐藏报表类型
|
||||||
@@ -1595,84 +1187,12 @@ export default {
|
|||||||
this.formConfig[7].type = 'datePicker';
|
this.formConfig[7].type = 'datePicker';
|
||||||
}
|
}
|
||||||
} else if (param === 'reportType') {
|
} else if (param === 'reportType') {
|
||||||
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
|
this.$refs.searchBarForm.formInline.timeVal = undefined;
|
||||||
const formInline = this.$refs.searchBarForm.formInline;
|
|
||||||
// 精准判断:只有字段存在时,才置为undefined(不存在则不处理)
|
|
||||||
if ('timeVal' in formInline) {
|
|
||||||
formInline.timeVal = undefined;
|
|
||||||
}
|
|
||||||
if ('timeValWeek' in formInline) {
|
|
||||||
formInline.timeValWeek = undefined;
|
|
||||||
}
|
|
||||||
if ('timeValMonth' in formInline) {
|
|
||||||
formInline.timeValMonth = undefined;
|
|
||||||
}
|
|
||||||
if ('timeValYear' in formInline) {
|
|
||||||
formInline.timeValYear = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.listQuery.startTime = undefined;
|
|
||||||
this.listQuery.endTime = undefined;
|
|
||||||
if (value === 1) {
|
|
||||||
this.formConfig[7] = {
|
|
||||||
type: 'datePicker',
|
|
||||||
label: '时间范围',
|
|
||||||
dateType: 'datetimerange',
|
|
||||||
format: 'yyyy-MM-dd HH:mm:ss',
|
|
||||||
valueFormat: 'timestamp',
|
|
||||||
rangeSeparator: '-',
|
|
||||||
startPlaceholder: '开始时间',
|
|
||||||
endPlaceholder: '结束时间',
|
|
||||||
param: 'timeVal',
|
|
||||||
width: 350
|
|
||||||
};
|
|
||||||
} else if (value === 2) {
|
|
||||||
this.formConfig[7] = {
|
|
||||||
type: 'datePicker',
|
|
||||||
label: '时间范围',
|
|
||||||
dateType: 'week',
|
|
||||||
placeholder: '选择日期',
|
|
||||||
format: 'yyyy 第 WW 周',
|
|
||||||
pickerOptions: {
|
|
||||||
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天(0=周日,1=周一,依此类推)
|
|
||||||
},
|
|
||||||
valueFormat: 'yyyy-MM-dd',
|
|
||||||
param: 'timeValWeek',
|
|
||||||
width: 250,
|
|
||||||
};
|
|
||||||
} else if (value === 3) {
|
|
||||||
this.formConfig[7] = {
|
|
||||||
type: 'datePicker',
|
|
||||||
label: '时间范围',
|
|
||||||
dateType: 'monthrange',
|
|
||||||
format: 'yyyy-MM-dd',
|
|
||||||
valueFormat: 'timestamp',
|
|
||||||
rangeSeparator: '-',
|
|
||||||
startPlaceholder: '开始时间',
|
|
||||||
endPlaceholder: '结束时间',
|
|
||||||
param: 'timeValMonth',
|
|
||||||
defaultTime: ['00:00:00', '23:59:59'],
|
|
||||||
width: 250,
|
|
||||||
};
|
|
||||||
} else if (value === 4) {
|
|
||||||
this.formConfig[7] = {
|
|
||||||
type: 'datePicker',
|
|
||||||
label: '时间范围',
|
|
||||||
dateType: 'year',
|
|
||||||
placeholder: '选择年份',
|
|
||||||
format: 'yyyy',
|
|
||||||
valueFormat: 'timestamp',
|
|
||||||
param: 'timeValYear',
|
|
||||||
width: 250,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else if (param === 'factoryId') {
|
} else if (param === 'factoryId') {
|
||||||
// 切换工厂时刷新产线列表
|
// 切换工厂时刷新产线列表
|
||||||
this.listQuery.lineId = [];
|
this.listQuery.lineId = [];
|
||||||
this.$refs.searchBarForm.formInline.lineId = undefined;
|
this.$refs.searchBarForm.formInline.lineId = undefined;
|
||||||
getPLlistByFactory({
|
getPdList(value).then(res => {
|
||||||
factoryIds:value
|
|
||||||
}).then(res => {
|
|
||||||
this.formConfig[3].selectOptions = res.data || [];
|
this.formConfig[3].selectOptions = res.data || [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1714,7 +1234,7 @@ export default {
|
|||||||
.content-wrapper {
|
.content-wrapper {
|
||||||
// flex: 1;
|
// flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100vh - 280px);
|
height: calc(100vh - 303px);
|
||||||
// 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: 'length',
|
prop: 'outputNum',
|
||||||
label: '玻璃长度/mm'
|
label: '玻璃长度/mm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ const tableProps = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'thick',
|
prop: 'thick',
|
||||||
label: '玻璃厚度/mm'
|
label: '玻璃长度/mm'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -204,88 +204,94 @@ export default {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
exportXlsx() {
|
test() {
|
||||||
if (!this.showData.length) {
|
var target = document.getElementsByClassName("right-aside")[0]
|
||||||
this.$message.warning('暂无数据可导出');
|
target.style.background = '#FFFFFF'
|
||||||
return;
|
var that = this
|
||||||
}
|
setTimeout(() => {
|
||||||
|
html2canvas(target).then(function(canvas) {
|
||||||
|
var contentWidth = canvas.width
|
||||||
|
var contentHeight = canvas.height
|
||||||
|
|
||||||
this.exportLoading = true;
|
// 一页pdf显示html页面生成的canvas高度
|
||||||
|
var pageHeight = contentHeight / 592.28 * 841.89
|
||||||
|
// 未生成pdf的html页面高度
|
||||||
|
var leftHeight = contentHeight
|
||||||
|
// 页面偏移
|
||||||
|
var position = 0
|
||||||
|
// a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的高度
|
||||||
|
var imgWidth = 595.28
|
||||||
|
var imgHeight = 592.28 / contentWidth * contentHeight
|
||||||
|
|
||||||
|
var pageData = canvas.toDataURL('image/jpeg', 1.0)
|
||||||
|
|
||||||
|
console.log('nihc URL', leftHeight, pageHeight)
|
||||||
|
|
||||||
|
var pdf = new jsPDF('', 'pt', 'a4')
|
||||||
|
|
||||||
|
if (leftHeight < pageHeight) {
|
||||||
|
pdf.addImage(pageData, 'JPEG', 0, 20, imgWidth, imgHeight)
|
||||||
|
} else {
|
||||||
|
while(leftHeight > 0) {
|
||||||
|
pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
|
||||||
|
leftHeight -= pageHeight
|
||||||
|
position -= 841.89
|
||||||
|
// 避免空白页
|
||||||
|
if (leftHeight > 0) {
|
||||||
|
pdf.addPage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pdf.save(that.fileName + '工段统计.pdf')
|
||||||
|
})
|
||||||
|
}, 300)
|
||||||
|
},
|
||||||
|
exportECL() {
|
||||||
|
let tables = document.querySelector('.el-table').cloneNode(true)
|
||||||
|
const fix = tables.querySelector('.el-table__fixed')
|
||||||
|
const fixRight = tables.querySelector('.el-table__fixed-right')
|
||||||
|
if (fix) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed'))
|
||||||
|
}
|
||||||
|
if (fixRight) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
|
||||||
|
}
|
||||||
|
let exportTable = XLSX.utils.table_to_book(tables)
|
||||||
|
|
||||||
|
var exportTableOut = XLSX.write(exportTable, {
|
||||||
|
bookType: 'xlsx', bookSST: true, type: 'array'
|
||||||
|
})
|
||||||
|
// sheetjs.xlsx为导出表格的标题名称
|
||||||
try {
|
try {
|
||||||
// 1. 处理导出数据(格式化时间字段)
|
FileSaver.saveAs(new Blob([exportTableOut], {
|
||||||
const exportData = this.showData.map(item => {
|
type: 'application/octet-stream'
|
||||||
const formatItem = { ...item };
|
}), this.fileName + '工段统计.xlsx')
|
||||||
// 格式化时间字段
|
} catch (e) {
|
||||||
if (formatItem.startTime) formatItem.startTime = parseTime(formatItem.startTime);
|
if (typeof console !== 'undefined') console.log(e, exportTableOut)
|
||||||
if (formatItem.endTime) formatItem.endTime = parseTime(formatItem.endTime);
|
|
||||||
return formatItem;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 2. 构建表头映射:{ prop: label },只保留表格配置中存在的列
|
|
||||||
const headerMap = {};
|
|
||||||
this.tableProps.forEach(col => {
|
|
||||||
if (col.prop && col.label) {
|
|
||||||
headerMap[col.prop] = col.label;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3. 转换数据:将prop键名替换为label,按tableProps顺序排列列
|
|
||||||
const formattedData = exportData.map(item => {
|
|
||||||
const newItem = {};
|
|
||||||
// 按表格配置顺序遍历列,确保Excel列顺序与表格一致
|
|
||||||
this.tableProps.forEach(col => {
|
|
||||||
const prop = col.prop;
|
|
||||||
const label = col.label;
|
|
||||||
if (prop && label) {
|
|
||||||
// 处理可能的undefined值,避免导出为空字符串
|
|
||||||
newItem[label] = item[prop] ?? '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return newItem;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 4. 创建工作表(使用处理后的带label表头的数据)
|
|
||||||
const worksheet = XLSX.utils.json_to_sheet(formattedData);
|
|
||||||
|
|
||||||
// 5. 创建工作簿并添加工作表
|
|
||||||
const workbook = XLSX.utils.book_new();
|
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, '下片日志数据');
|
|
||||||
|
|
||||||
// 6. 生成Excel文件
|
|
||||||
const excelBuffer = XLSX.write(workbook, {
|
|
||||||
bookType: 'xlsx',
|
|
||||||
type: 'array'
|
|
||||||
});
|
|
||||||
|
|
||||||
// 7. 保存文件
|
|
||||||
const blob = new Blob([excelBuffer], {
|
|
||||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
||||||
});
|
|
||||||
|
|
||||||
// 8. 生成文件名(包含查询条件信息)
|
|
||||||
let fileName = '下片历史';
|
|
||||||
if (this.listQuery.productionLineId) {
|
|
||||||
const lineItem = this.formConfig[0].selectOptions.find(
|
|
||||||
item => item.id === this.listQuery.productionLineId
|
|
||||||
);
|
|
||||||
if (lineItem) fileName += lineItem.name + '_';
|
|
||||||
}
|
|
||||||
if (this.listQuery.thick) {
|
|
||||||
fileName += this.listQuery.thick + '_';
|
|
||||||
}
|
|
||||||
// 添加时间戳避免文件名重复
|
|
||||||
fileName + '.xlsx';
|
|
||||||
|
|
||||||
FileSaver.saveAs(blob, fileName);
|
|
||||||
this.$message.success('导出成功');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('导出失败:', error);
|
|
||||||
this.$message.error('导出失败,请重试');
|
|
||||||
} finally {
|
|
||||||
this.exportLoading = false;
|
|
||||||
}
|
}
|
||||||
|
return exportTableOut
|
||||||
},
|
},
|
||||||
|
exportPdf() {
|
||||||
|
this.test()
|
||||||
|
setTimeout(() =>{
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.showData = this.tableData
|
||||||
|
}, 600)
|
||||||
|
|
||||||
|
},
|
||||||
|
exportXlsx() {
|
||||||
|
this.exportECL()
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.showData = this.tableData
|
||||||
|
},
|
||||||
|
handleClose(done) {
|
||||||
|
this.$confirm('确认关闭?')
|
||||||
|
.then(_ => {
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(_ => {});
|
||||||
|
},
|
||||||
getPdLineList() {
|
getPdLineList() {
|
||||||
getPdList().then((res) => {
|
getPdList().then((res) => {
|
||||||
this.formConfig[0].selectOptions = res.data || []
|
this.formConfig[0].selectOptions = res.data || []
|
||||||
@@ -308,16 +314,15 @@ export default {
|
|||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageSize = 10;
|
||||||
this.listQuery.productionLineId = val.productionLineId ? val.productionLineId : undefined;
|
this.listQuery.productId = val.productId ? val.productId : undefined;
|
||||||
this.listQuery.thick = val.thick ? val.thick : undefined;
|
this.listQuery.startTime = val.timeVal ? val.timeVal[0]: undefined;
|
||||||
this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined;
|
this.listQuery.endTime = val.timeVal ? val.timeVal[1]: 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();
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
this.exportXlsx();
|
this.handleExport();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(val);
|
console.log(val);
|
||||||
@@ -345,6 +350,12 @@ export default {
|
|||||||
this.listQuery.pageNo = val;
|
this.listQuery.pageNo = val;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
|
handleExport() {
|
||||||
|
if (this.selectedList.length > 0) {
|
||||||
|
this.showData = this.selectedList
|
||||||
|
}
|
||||||
|
this.dialogVisible = true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -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: 'length',
|
prop: 'outputNum',
|
||||||
label: '玻璃长度/mm'
|
label: '玻璃长度/mm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -358,6 +358,8 @@ export default {
|
|||||||
handleExport() {
|
handleExport() {
|
||||||
// 处理查询参数
|
// 处理查询参数
|
||||||
let params = { ...this.listQuery };
|
let params = { ...this.listQuery };
|
||||||
|
params.pageNo = undefined;
|
||||||
|
params.pageSize = undefined;
|
||||||
this.$modal.confirm('是否确认导出下片日志?').then(() => {
|
this.$modal.confirm('是否确认导出下片日志?').then(() => {
|
||||||
this.exportLoading = true;
|
this.exportLoading = true;
|
||||||
return exportDownLogData(params);
|
return exportDownLogData(params);
|
||||||
|
|||||||
@@ -262,14 +262,6 @@ 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),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
|
<!--
|
||||||
|
* @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"
|
||||||
@@ -11,47 +17,34 @@
|
|||||||
<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';
|
||||||
|
|
||||||
// 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 = [
|
const tableProps = [
|
||||||
|
|
||||||
{
|
{
|
||||||
prop: 'reportType',
|
prop: 'reportType',
|
||||||
label: '报表类型'
|
label: '报表类型'
|
||||||
@@ -59,11 +52,12 @@ const tableProps = [
|
|||||||
{
|
{
|
||||||
prop: 'time',
|
prop: 'time',
|
||||||
label: '日期',
|
label: '日期',
|
||||||
|
// filter: parseTime,
|
||||||
width: 160
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'bindObjectName',
|
prop: 'bindObjectName',
|
||||||
label: '产线'
|
label: '产线'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'thick',
|
prop: 'thick',
|
||||||
@@ -73,11 +67,11 @@ const tableProps = [
|
|||||||
prop: 'speed',
|
prop: 'speed',
|
||||||
label: '在线速度'
|
label: '在线速度'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'width',
|
prop: 'width',
|
||||||
label: '掰边宽度'
|
label: '掰边宽度'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'inArea',
|
prop: 'inArea',
|
||||||
label: '拉引量/㎡'
|
label: '拉引量/㎡'
|
||||||
},
|
},
|
||||||
@@ -85,83 +79,21 @@ const tableProps = [
|
|||||||
prop: 'outArea',
|
prop: 'outArea',
|
||||||
label: '下片面积/㎡'
|
label: '下片面积/㎡'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
urlOptions: {
|
urlOptions: {
|
||||||
getDataListURL: getCostOriginRadioHisData
|
getDataListURL: getCostOriginRadioHisData
|
||||||
},
|
},
|
||||||
tableData: [],
|
tableData: [],
|
||||||
listQuery: {
|
listQuery: {
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -169,368 +101,181 @@ 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: [],
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
addOrEditTitle: '',
|
addOrEditTitle: '',
|
||||||
addOrUpdateVisible: false,
|
addOrUpdateVisible: false,
|
||||||
tableProps,
|
tableProps,
|
||||||
tableBtn: [
|
tableBtn: [
|
||||||
{
|
{
|
||||||
type: 'edit',
|
type: 'edit',
|
||||||
btnName: '编辑',
|
btnName: '编辑',
|
||||||
},
|
},
|
||||||
].filter(v => v),
|
].filter((v) => v),
|
||||||
fileName: '',
|
tableData: [],
|
||||||
|
fileName: '',
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '报表类型',
|
label: '维度',
|
||||||
onchange: true,
|
|
||||||
selectOptions: [
|
selectOptions: [
|
||||||
{ id: '0', name: '班组' },
|
|
||||||
{ id: '1', name: '日' },
|
|
||||||
{ id: '2', name: '周' },
|
|
||||||
{ id: '3', name: '月' },
|
|
||||||
{ id: '4', name: '年' }
|
|
||||||
],
|
|
||||||
param: 'statisticType',
|
|
||||||
index: 1,
|
|
||||||
extraOptions: [
|
|
||||||
{
|
{
|
||||||
parent: 'statisticType',
|
id: '0',
|
||||||
type: 'datePicker',
|
name:'班组'
|
||||||
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',
|
id: '1',
|
||||||
type: 'datePicker',
|
name: '日'
|
||||||
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',
|
id: '2',
|
||||||
type: 'datePicker',
|
name: '周'
|
||||||
label: '统计时间',
|
|
||||||
dateType: 'week',
|
|
||||||
placeholder: '选择日期',
|
|
||||||
format: 'yyyy 第 WW 周',
|
|
||||||
pickerOptions: {
|
|
||||||
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天(0=周日,1=周一,依此类推)
|
|
||||||
},
|
|
||||||
valueFormat: 'yyyy-MM-dd',
|
|
||||||
param: 'timeValWeek',
|
|
||||||
width: 250,
|
|
||||||
key: 'datePicker-2', // 唯一 key,触发重新渲染
|
|
||||||
appendToBody: true // 优化定位:挂载到 body 下
|
|
||||||
},
|
},
|
||||||
// 月 - 日期范围选择
|
|
||||||
{
|
{
|
||||||
parent: 'statisticType',
|
id: '3',
|
||||||
type: 'datePicker',
|
name: '月'
|
||||||
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',
|
id: '4',
|
||||||
type: 'datePicker',
|
name: '年'
|
||||||
label: '统计时间',
|
|
||||||
dateType: 'year',
|
|
||||||
placeholder: '选择年份',
|
|
||||||
format: 'yyyy-MM-dd',
|
|
||||||
valueFormat: 'yyyy-MM-dd',
|
|
||||||
param: 'timeValYear',
|
|
||||||
width: 250,
|
|
||||||
key: 'datePicker-4', // 唯一 key,触发重新渲染
|
|
||||||
appendToBody: true // 优化定位:挂载到 body 下
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
param: 'statisticType'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '产线',
|
label: '产线',
|
||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'bindObjectId'
|
param: 'bindObjectId'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
type: 'button',
|
{
|
||||||
btnName: '查询',
|
type: 'datePicker',
|
||||||
name: 'search',
|
label: '统计开始时间',
|
||||||
color: 'primary',
|
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: 'separate',
|
type: 'button',
|
||||||
},
|
btnName: '查询',
|
||||||
{
|
name: 'search',
|
||||||
type: 'button',
|
color: 'primary',
|
||||||
btnName: '导出',
|
},
|
||||||
name: 'export',
|
{
|
||||||
color: 'warning',
|
type: 'separate',
|
||||||
}
|
},
|
||||||
],
|
{
|
||||||
};
|
// type: this.$auth.hasPermi('base:factory:export') ? 'button' : '',
|
||||||
},
|
type: 'button',
|
||||||
watch: {
|
btnName: '导出',
|
||||||
// 监听报表类型变化,强制刷新日期选择器
|
name: 'export',
|
||||||
'listQuery.statisticType'(newVal, oldVal) {
|
color: 'warning',
|
||||||
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.$refs.searchBarForm.formInline.statisticType = '1';
|
||||||
this.$nextTick(() => {
|
|
||||||
if (this.$refs.searchBarForm) {
|
|
||||||
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() {
|
|
||||||
getPdList().then(res => {
|
getPdLineList() {
|
||||||
// Vue2 中数组赋值需确保响应式
|
getPdList().then((res) => {
|
||||||
this.$set(this.formConfig[1], 'selectOptions', res.data || []);
|
this.formConfig[1].selectOptions = res.data || []
|
||||||
this.pdLineList = res.data || [];
|
this.pdLineList = res.data || []; // 保存产线数据
|
||||||
}).catch(err => {
|
})
|
||||||
console.error('获取产线列表失败:', err);
|
},
|
||||||
});
|
selectChange(val) {
|
||||||
},
|
console.log(val)
|
||||||
selectChange(val) {
|
this.selectedList = val
|
||||||
console.log('选择变更:', val);
|
|
||||||
this.selectedList = val;
|
|
||||||
},
|
},
|
||||||
buttonClick(val) {
|
buttonClick(val) {
|
||||||
console.log('头部按钮点击:', val);
|
console.log('val', val);
|
||||||
switch (val.btnName) {
|
|
||||||
case 'search':
|
switch (val.btnName) {
|
||||||
this.listQuery.pageNo = 1;
|
case 'search':
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageNo = 1;
|
||||||
|
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();
|
||||||
|
break;
|
||||||
this.getDataList();
|
case 'export':
|
||||||
break;
|
this.handleExport();
|
||||||
case 'export':
|
break;
|
||||||
this.handleExport();
|
default:
|
||||||
break;
|
console.log(val);
|
||||||
default:
|
}
|
||||||
console.log('未知按钮:', val);
|
},
|
||||||
}
|
// 获取数据列表
|
||||||
},
|
|
||||||
// 处理不同时间维度的时间范围
|
|
||||||
handleTimeRange(val) {
|
|
||||||
const statisticType = val.statisticType;
|
|
||||||
const timeVal = val.timeVal;
|
|
||||||
|
|
||||||
const timeValDay = val.timeValDay;
|
|
||||||
|
|
||||||
const timeValWeek = val.timeValWeek;
|
|
||||||
const timeValMonth = val.timeValMonth;
|
|
||||||
const timeValYear = val.timeValYear;
|
|
||||||
|
|
||||||
|
|
||||||
// 重置时间参数
|
|
||||||
this.listQuery.startTime = undefined;
|
|
||||||
this.listQuery.endTime = undefined;
|
|
||||||
|
|
||||||
switch (statisticType) {
|
|
||||||
case '0': // 班组 - 沿用原时间范围
|
|
||||||
if (timeVal && timeVal.length === 2) {
|
|
||||||
this.listQuery.startTime = timeVal[0];
|
|
||||||
this.listQuery.endTime = timeVal[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '1': // 日 - 沿用原时间范围
|
|
||||||
if (timeValDay && timeValDay.length === 2) {
|
|
||||||
this.listQuery.startTime = timeValDay[0];
|
|
||||||
this.listQuery.endTime = timeValDay[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '3': // 月 - 沿用原时间范围
|
|
||||||
if (timeValMonth && timeValMonth.length === 2) {
|
|
||||||
this.listQuery.startTime = timeValMonth[0];
|
|
||||||
this.listQuery.endTime = timeValMonth[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '2': // 周 - 自动计算本周范围
|
|
||||||
if (timeValWeek) {
|
|
||||||
const [start, end] = getSelectedWeekRange(timeValWeek);
|
|
||||||
this.listQuery.startTime = formatDateTime(start);
|
|
||||||
this.listQuery.endTime = formatDateTime(end);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '4': // 年 - 自动计算本年范围
|
|
||||||
if (timeValYear) {
|
|
||||||
const [start, end] = getSelectedYearRange(timeValYear);
|
|
||||||
this.listQuery.startTime = formatDateTime(start);
|
|
||||||
this.listQuery.endTime = formatDateTime(end);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 获取数据列表
|
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.dataListLoading = true;
|
this.dataListLoading = true;
|
||||||
this.urlOptions.getDataListURL(this.listQuery)
|
this.urlOptions.getDataListURL(this.listQuery).then(response => {
|
||||||
.then(response => {
|
const arr = ['班组','日', '周', '月', '年'];
|
||||||
const arr = ['班组', '日', '周', '月', '年'];
|
this.tableData = response.data?.list?.map((item) => {
|
||||||
// Vue2 中数组赋值确保响应式
|
item.reportType = arr[this.listQuery.statisticType];
|
||||||
this.tableData = (response.data?.list || []).map(item => {
|
item.statisticType = this.listQuery.statisticType
|
||||||
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 || 0;
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error('获取数据失败:', err);
|
|
||||||
this.tableData = [];
|
|
||||||
this.listQuery.total = 0;
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.dataListLoading = false;
|
|
||||||
});
|
});
|
||||||
|
this.listQuery.total = response.data.total;
|
||||||
|
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 };
|
||||||
delete params.pageNo;
|
params.pageNo = undefined;
|
||||||
delete params.pageSize;
|
params.pageSize = undefined;
|
||||||
delete params.total;
|
this.$modal.confirm('是否确认导出原片报表?').then(() => {
|
||||||
|
this.exportLoading = true;
|
||||||
this.$modal.confirm('是否确认导出原片报表?')
|
return exportCostOriginRadioHisData(params);
|
||||||
.then(() => {
|
}).then(response => {
|
||||||
this.exportLoading = true;
|
this.$download.excel(response, '原片报表.xls');
|
||||||
return exportCostOriginRadioHisData(params);
|
this.exportLoading = false;
|
||||||
})
|
}).catch(() => { });
|
||||||
.then(response => {
|
|
||||||
this.$download.excel(response, '原片报表.xls');
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error('导出失败:', err);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.exportLoading = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Vue2 中监听数据变化(如需)
|
|
||||||
watch: {
|
|
||||||
'listQuery.statisticType'(newVal) {
|
|
||||||
console.log('报表类型变更:', newVal);
|
|
||||||
// 可添加类型变更后的额外逻辑
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</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>
|
|
||||||
|
|||||||
@@ -1,274 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,430 +1,423 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="home-page">
|
||||||
<!-- 顶部日期&筛选栏 -->
|
<div class="date-tabs">
|
||||||
<el-row :gutter="20" class="top-bar">
|
<!-- @tab-click="handleClick" -->
|
||||||
<el-col :span="8">
|
<el-tabs v-model="activeName" @tab-click="timedayChange" :stretch="true">
|
||||||
|
<el-tab-pane
|
||||||
|
:label="'\u2002\u2002日\u2002\u2002'"
|
||||||
|
name="日"></el-tab-pane>
|
||||||
|
<el-tab-pane
|
||||||
|
:label="'\u2002\u2002周\u2002\u2002'"
|
||||||
|
name="周"></el-tab-pane>
|
||||||
|
<el-tab-pane
|
||||||
|
:label="'\u2002\u2002月\u2002\u2002'"
|
||||||
|
name="月"></el-tab-pane>
|
||||||
|
<el-tab-pane
|
||||||
|
:label="'\u2002\u2002年\u2002\u2002'"
|
||||||
|
name="年"></el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<div class="detail">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="dateRange"
|
v-model="timeday"
|
||||||
type="daterange"
|
align="right"
|
||||||
range-separator="~"
|
type="date"
|
||||||
start-placeholder="开始日期"
|
format="yyyy-MM-dd"
|
||||||
end-placeholder="结束日期"
|
valueFormat="yyyy-MM-dd"
|
||||||
value-format="yyyy-MM-dd" />
|
:clearable="false"
|
||||||
<el-button type="primary" style="margin-left: 10px">查询</el-button>
|
@change="timedayChange"
|
||||||
|
placeholder="选择日期"
|
||||||
|
:picker-options="pickerOptions"></el-date-picker>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-row class="main-top" :gutter="16">
|
||||||
|
<el-col :span="24" style="position: relative">
|
||||||
|
<div class="title">
|
||||||
|
<svg-icon icon-class="home-produce" />
|
||||||
|
<span class="title-inner">生产总成本</span>
|
||||||
|
</div>
|
||||||
|
<el-row class="box">
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.priceS }}万元</div>
|
||||||
|
<div class="unit-style">总计成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.matPriceS }}万元</div>
|
||||||
|
<div class="unit-style">原料成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.energyPriceS }}万元</div>
|
||||||
|
<div class="unit-style">能源成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.otherPriceS }}万元</div>
|
||||||
|
<div class="unit-style">其他成本</div>
|
||||||
|
</el-col>
|
||||||
|
<!-- <el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.ratioS }}</div>
|
||||||
|
<div class="unit-style">综合良品率/%</div>
|
||||||
|
</el-col> -->
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.areaPriceS }}元</div>
|
||||||
|
<div class="unit-style">综合每平米成本</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="16">
|
<el-col :span="24" style="position: relative">
|
||||||
<el-tag type="info" @click="changeTime('yesterday')">昨日</el-tag>
|
<div class="title">
|
||||||
<el-tag type="info" @click="changeTime('week')">本周</el-tag>
|
<svg-icon icon-class="home-produce" />
|
||||||
<el-tag type="info" @click="changeTime('month')">本月</el-tag>
|
<span class="title-inner">原片成本</span>
|
||||||
<el-tag type="info" @click="changeTime('year')">本年</el-tag>
|
</div>
|
||||||
|
<el-row class="box">
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.priceO }}万元</div>
|
||||||
|
<div class="unit-style">原片总成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.matPriceO }}万元</div>
|
||||||
|
<div class="unit-style">原料成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.energyPriceO }}万元</div>
|
||||||
|
<div class="unit-style">能源成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.otherPriceO }}万元</div>
|
||||||
|
<div class="unit-style">其他成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.ratioO }}</div>
|
||||||
|
<div class="unit-style">原片良品率/%</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.areaPriceO }}元</div>
|
||||||
|
<div class="unit-style">原片每平米成本</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24" style="position: relative">
|
||||||
|
<div class="title">
|
||||||
|
<svg-icon icon-class="home-produce" />
|
||||||
|
<span class="title-inner">深加工成本</span>
|
||||||
|
</div>
|
||||||
|
<el-row class="box">
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.priceD }}万元</div>
|
||||||
|
<div class="unit-style">深加工总成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.energyPriceD }}万元</div>
|
||||||
|
<div class="unit-style">能源成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.otherPriceD }}万元</div>
|
||||||
|
<div class="unit-style">其他成本</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.ratioD }}</div>
|
||||||
|
<div class="unit-style">深加工良品率/%</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="num-box shadow">
|
||||||
|
<div class="num-style">{{ homeData.areaPriceD }}元</div>
|
||||||
|
<div class="unit-style">深加工每平米成本</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row class="main-bottom" :gutter="16" v-if="false">
|
||||||
<!-- 成本概览卡片 -->
|
<el-col :span="9">
|
||||||
<el-row :gutter="20" class="card-row">
|
<div class="chart-wrapper">
|
||||||
<el-col :span="8">
|
<line-chart :chart-data="lineChartData" />
|
||||||
<el-card class="cost-card">
|
</div>
|
||||||
<div class="card-title">总制造成本(元/平米)</div>
|
</el-col>
|
||||||
<div class="card-content">
|
<el-col :span="7">
|
||||||
<div>
|
<div class="chart-wrapper">
|
||||||
目标
|
<pie-chart />
|
||||||
<span class="target-val">16</span>
|
</div>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
实际
|
|
||||||
<span class="actual-val">12.8</span>
|
|
||||||
</div>
|
|
||||||
<el-progress :stroke-width="13" :percentage="80" color="#42b983" />
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-card class="cost-card">
|
<div class="chart-wrapper">
|
||||||
<div class="card-title">原片成本(元/平米)</div>
|
<bar-chart />
|
||||||
<div class="card-content">
|
</div>
|
||||||
<div>
|
|
||||||
目标
|
|
||||||
<span class="target-val">16</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
实际
|
|
||||||
<span class="actual-val">12.8</span>
|
|
||||||
</div>
|
|
||||||
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-card class="cost-card">
|
|
||||||
<div class="card-title">加工成本(元/平米)</div>
|
|
||||||
<div class="card-content">
|
|
||||||
<div>
|
|
||||||
目标
|
|
||||||
<span class="target-val">16</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
实际
|
|
||||||
<span class="actual-val">12.8</span>
|
|
||||||
</div>
|
|
||||||
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<!-- 成本构成区域 -->
|
|
||||||
<el-row :gutter="20" class="composition-row">
|
|
||||||
<!-- 饼图 -->
|
|
||||||
<el-col :span="6">
|
|
||||||
<el-card class="composition-card">
|
|
||||||
<div class="card-title">成本构成</div>
|
|
||||||
<div id="costPie" class="chart" style="height: 350px"></div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
<!-- 原片/加工成本子项 -->
|
|
||||||
<el-col :span="18">
|
|
||||||
<el-card class="composition-card">
|
|
||||||
<div class="card-title">成本构成</div>
|
|
||||||
|
|
||||||
<!-- 原片成本子项 -->
|
|
||||||
<div class="sub-cost-group">
|
|
||||||
<div class="sub-cost-title">原片成本</div>
|
|
||||||
<div class="sub-cost">
|
|
||||||
<div
|
|
||||||
v-for="(item, idx) in rawSubCosts"
|
|
||||||
:key="idx"
|
|
||||||
class="sub-cost-div">
|
|
||||||
<div class="sub-cost-name">
|
|
||||||
{{ item.name }}
|
|
||||||
<div class="sub-cost-val">{{ item.val }}</div>
|
|
||||||
</div>
|
|
||||||
<div style="text-align: center">
|
|
||||||
<el-progress
|
|
||||||
type="circle"
|
|
||||||
:percentage="89"
|
|
||||||
:width="60"
|
|
||||||
:stroke-width="10"
|
|
||||||
:show-text="false"
|
|
||||||
color="#e74c3c" />
|
|
||||||
</div>
|
|
||||||
<div class="sub-cost-name">
|
|
||||||
目标
|
|
||||||
<span class="red-text">{{ item.target }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="sub-cost-name">
|
|
||||||
完成率
|
|
||||||
<span class="red-text">89%</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-divider></el-divider>
|
|
||||||
<!-- 加工成本子项 -->
|
|
||||||
<div class="sub-cost-group" style="margin-top: 20px">
|
|
||||||
<div class="sub-cost-title">加工成本</div>
|
|
||||||
<div class="sub-cost">
|
|
||||||
<div
|
|
||||||
v-for="(item, idx) in processSubCosts"
|
|
||||||
:key="idx"
|
|
||||||
class="sub-cost-div">
|
|
||||||
<div class="sub-cost-name">
|
|
||||||
{{ item.name }}
|
|
||||||
<div class="sub-cost-val">{{ item.val }}</div>
|
|
||||||
</div>
|
|
||||||
<div style="text-align: center">
|
|
||||||
<el-progress
|
|
||||||
type="circle"
|
|
||||||
:percentage="89"
|
|
||||||
:width="60"
|
|
||||||
:stroke-width="10"
|
|
||||||
:show-text="false"
|
|
||||||
color="#e74c3c" />
|
|
||||||
</div>
|
|
||||||
<div class="sub-cost-name">
|
|
||||||
目标
|
|
||||||
<span class="red-text">{{ item.target }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="sub-cost-name">
|
|
||||||
完成率
|
|
||||||
<span class="red-text">89%</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<!-- 趋势图区域 -->
|
|
||||||
<el-row :gutter="20" class="trend-row">
|
|
||||||
<!-- 总制造成本趋势 -->
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-card class="trend-card">
|
|
||||||
<div class="card-title">总制造成本趋势</div>
|
|
||||||
<div id="totalTrend" class="chart" style="height: 300px"></div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
<!-- 原片/加工成本趋势 -->
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-card class="trend-card">
|
|
||||||
<div class="card-title">原片/加工成本趋势</div>
|
|
||||||
<el-tabs v-model="costTab" type="card" style="margin-bottom: 10px">
|
|
||||||
<el-tab-pane label="原片成本" name="raw"></el-tab-pane>
|
|
||||||
<el-tab-pane label="加工成本" name="process"></el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
<div id="rawProcessTrend" class="chart" style="height: 300px"></div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
<!-- 单项成本趋势 -->
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-card class="trend-card">
|
|
||||||
<div class="card-title">单项成本趋势</div>
|
|
||||||
<el-tabs v-model="itemTab" type="card" style="margin-bottom: 10px">
|
|
||||||
<el-tab-pane label="人工成本" name="labor"></el-tab-pane>
|
|
||||||
<el-tab-pane label="原料成本" name="material"></el-tab-pane>
|
|
||||||
<el-tab-pane label="制造费用" name="expense"></el-tab-pane>
|
|
||||||
<el-tab-pane label="玻璃热耗" name="heat"></el-tab-pane>
|
|
||||||
<el-tab-pane label="原片成品率" name="yield"></el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
<div id="itemTrend" class="chart" style="height: 300px"></div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<div
|
||||||
|
class="main-footer"
|
||||||
|
style="
|
||||||
|
color: #c7c7c7;
|
||||||
|
user-select: none;
|
||||||
|
font-size: 14px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
height: 30px;
|
||||||
|
display: grid;
|
||||||
|
place-content: center;
|
||||||
|
">
|
||||||
|
© 中建材智能自动化研究院有限公司
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as echarts from 'echarts';
|
import moment from 'moment';
|
||||||
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||||
|
import LineChart from '../dashboard/LineChart';
|
||||||
|
import PieChart from '../dashboard/PieChart';
|
||||||
|
import BarChart from '../dashboard/BarChart';
|
||||||
|
import PanelGroup from '../dashboard/PanelGroup';
|
||||||
|
import { getData } from '@/api/cost/allCost';
|
||||||
|
import { getUserProfile } from '@/api/system/user';
|
||||||
|
|
||||||
|
const lineChartData = {
|
||||||
|
newVisitis: {
|
||||||
|
expectedData: [100, 120, 161, 134, 105, 160, 165],
|
||||||
|
actualData: [120, 82, 91, 154, 162, 140, 145],
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
expectedData: [200, 192, 120, 144, 160, 130, 140],
|
||||||
|
actualData: [180, 160, 151, 106, 145, 150, 130],
|
||||||
|
},
|
||||||
|
purchases: {
|
||||||
|
expectedData: [80, 100, 121, 104, 105, 90, 100],
|
||||||
|
actualData: [120, 90, 100, 138, 142, 130, 130],
|
||||||
|
},
|
||||||
|
shoppings: {
|
||||||
|
expectedData: [130, 140, 141, 142, 145, 150, 160],
|
||||||
|
actualData: [120, 82, 91, 154, 162, 140, 130],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CostDashboard',
|
name: 'Home',
|
||||||
|
mixins: [tableHeightMixin],
|
||||||
|
components: {
|
||||||
|
LineChart,
|
||||||
|
PieChart,
|
||||||
|
PanelGroup,
|
||||||
|
BarChart,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
gradientBackground() {
|
||||||
|
return {
|
||||||
|
'background-image':
|
||||||
|
'linear-gradient(90deg, #f0f0f0 25%, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0) 50%, #f0f0f0 50%, #f0f0f0 75%, rgba(255, 255, 255, 0) 75%, rgba(255, 255, 255, 0))',
|
||||||
|
'background-size': '100px 100px', // 调整条纹的大小
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dateRange: ['2023-05-06', '2023-05-06'],
|
activeName: '日',
|
||||||
costTab: 'raw',
|
user: '',
|
||||||
itemTab: 'labor',
|
lineChartData: lineChartData.newVisitis,
|
||||||
// 原片成本子项
|
homeData: {},
|
||||||
rawSubCosts: [
|
timeday: moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD'),
|
||||||
{ name: '人工成本', val: 4.56, target: 4.32 },
|
startTime:
|
||||||
{ name: '原料成本', val: 4.56, target: 4.32 },
|
moment(new Date()).subtract(0, 'days').format('YYYY-MM-DD') +
|
||||||
{ name: '原片制造费用', val: 4.56, target: 4.32 },
|
' 00:00:00',
|
||||||
{ name: '玻璃热耗', val: 4.56, target: 4.32 },
|
endTime:
|
||||||
{ name: '原片成品率', val: 4.56, target: 4.32 },
|
moment(new Date()).subtract(-1, 'days').format('YYYY-MM-DD') +
|
||||||
],
|
' 00:00:00',
|
||||||
// 加工成本子项
|
|
||||||
processSubCosts: [
|
pickerOptions: {
|
||||||
{ name: '人工成本', val: 4.56, target: 4.32 },
|
disabledDate(time) {
|
||||||
{ name: '加工动力成本', val: 4.56, target: 4.32 },
|
return time.getTime() + 3600 * 1000 * 24 > Date.now();
|
||||||
{ name: '加工制造费用', val: 4.56, target: 4.32 },
|
},
|
||||||
{ name: '加工投入产出率', val: 4.56, target: 4.32 },
|
shortcuts: [
|
||||||
],
|
{
|
||||||
// 趋势图模拟数据
|
text: '今天',
|
||||||
trendX: ['00:00', '01:00', '02:00'],
|
onClick(picker) {
|
||||||
trendY: [20, 40, 50],
|
picker.$emit('pick', new Date());
|
||||||
targetY: 12.54,
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '昨天',
|
||||||
|
onClick(picker) {
|
||||||
|
const date = new Date();
|
||||||
|
date.setTime(date.getTime() - 3600 * 1000 * 24);
|
||||||
|
picker.$emit('pick', date);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '一周前',
|
||||||
|
onClick(picker) {
|
||||||
|
const date = new Date();
|
||||||
|
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
||||||
|
picker.$emit('pick', date);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
created() {
|
||||||
this.initCostPie();
|
},
|
||||||
this.initTotalTrend();
|
beforeDestroy() {
|
||||||
this.initRawProcessTrend();
|
|
||||||
this.initItemTrend();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 切换时间范围(示例)
|
getData() {
|
||||||
changeTime(type) {
|
let listQuery = {
|
||||||
// 实际项目中需根据type请求对应数据
|
//分页
|
||||||
console.log('切换时间:', type);
|
pageSize: 10,
|
||||||
},
|
pageNo: 1,
|
||||||
// 初始化成本构成饼图
|
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName),
|
||||||
initCostPie() {
|
startTime: this.timeday + ' 00:00:00',
|
||||||
const pieChart = echarts.init(document.getElementById('costPie'));
|
};
|
||||||
pieChart.setOption({
|
getData(listQuery).then((response) => {
|
||||||
tooltip: { trigger: 'item' },
|
this.homeData = response.data;
|
||||||
legend: {
|
for (let i in this.homeData) {
|
||||||
orient: 'horizontal', // 水平排列
|
this.homeData[i] = Number(this.homeData[i]).toFixed(2);
|
||||||
bottom: 0, // 放在底部
|
}
|
||||||
icon: 'circle',
|
|
||||||
left: 'center',
|
|
||||||
formatter: function (name) {
|
|
||||||
return name;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
type: 'pie',
|
|
||||||
data: [
|
|
||||||
{ name: '原料成本(4.2元)', value: 29.9 },
|
|
||||||
{ name: '动力成本(2.1元)', value: 24 },
|
|
||||||
{ name: '人工成本(1.5元)', value: 24 },
|
|
||||||
{ name: '辅料成本(0.5元)', value: 21.2 },
|
|
||||||
{ name: '制造费用(0.5元)', value: 21.2 },
|
|
||||||
],
|
|
||||||
label: { show: false },
|
|
||||||
labelLine: { show: false },
|
|
||||||
bottom: 10,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
window.addEventListener('resize', () => pieChart.resize());
|
|
||||||
},
|
},
|
||||||
// 初始化总制造成本趋势图
|
timedayChange() {
|
||||||
initTotalTrend() {
|
let listQuery = {
|
||||||
const totalChart = echarts.init(document.getElementById('totalTrend'));
|
//分页
|
||||||
totalChart.setOption({
|
pageSize: 10,
|
||||||
grid: { top: 20, bottom: 30, left: 30, right: 10 },
|
pageNo: 1,
|
||||||
xAxis: { type: 'category', data: this.trendX },
|
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName),
|
||||||
yAxis: { type: 'value', min: -20, max: 60 },
|
startTime: this.timeday + ' 00:00:00',
|
||||||
series: [
|
};
|
||||||
{
|
getData(listQuery).then((response) => {
|
||||||
name: '实际值',
|
this.homeData = response.data;
|
||||||
type: 'line',
|
for (let i in this.homeData) {
|
||||||
data: this.trendY,
|
this.homeData[i] = Number(this.homeData[i]).toFixed(2);
|
||||||
lineStyle: { color: '#409eff' },
|
}
|
||||||
},
|
});
|
||||||
{
|
|
||||||
name: '目标值',
|
|
||||||
type: 'line',
|
|
||||||
data: [this.targetY, this.targetY, this.targetY],
|
|
||||||
lineStyle: { type: 'dashed', color: '#e6a23c' },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
window.addEventListener('resize', () => totalChart.resize());
|
|
||||||
},
|
},
|
||||||
// 初始化原片/加工成本趋势图
|
goDetail() {
|
||||||
initRawProcessTrend() {
|
this.$router.push({ path: 'indexDetail' });
|
||||||
const rpChart = echarts.init(document.getElementById('rawProcessTrend'));
|
|
||||||
rpChart.setOption({
|
|
||||||
grid: { top: 10, bottom: 20, left: 20, right: 10 },
|
|
||||||
xAxis: { type: 'category', data: this.trendX },
|
|
||||||
yAxis: { type: 'value', min: -20, max: 60 },
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: '实际值',
|
|
||||||
type: 'line',
|
|
||||||
data: this.trendY,
|
|
||||||
lineStyle: { color: '#409eff' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '目标值',
|
|
||||||
type: 'line',
|
|
||||||
data: [this.targetY, this.targetY, this.targetY],
|
|
||||||
lineStyle: { type: 'dashed', color: '#e6a23c' },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
window.addEventListener('resize', () => rpChart.resize());
|
|
||||||
},
|
|
||||||
// 初始化单项成本趋势图
|
|
||||||
initItemTrend() {
|
|
||||||
const itemChart = echarts.init(document.getElementById('itemTrend'));
|
|
||||||
itemChart.setOption({
|
|
||||||
grid: { top: 10, bottom: 20, left: 20, right: 10 },
|
|
||||||
xAxis: { type: 'category', data: this.trendX },
|
|
||||||
yAxis: { type: 'value', min: -20, max: 60 },
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: '实际值',
|
|
||||||
type: 'line',
|
|
||||||
data: this.trendY,
|
|
||||||
lineStyle: { color: '#409eff' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '目标值',
|
|
||||||
type: 'line',
|
|
||||||
data: [this.targetY, this.targetY, this.targetY],
|
|
||||||
lineStyle: { type: 'dashed', color: '#e6a23c' },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
window.addEventListener('resize', () => itemChart.resize());
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style lang="scss" scoped>
|
||||||
.top-bar {
|
.home-page::before {
|
||||||
|
background-image: url('~@/assets/img/home-bg.png');
|
||||||
|
background-size: cover;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
.date-tabs {
|
||||||
|
padding-left: 40px;
|
||||||
|
padding-top: 20px;
|
||||||
|
position: relative;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
.card-row,
|
:deep(.date-tabs) {
|
||||||
.composition-row {
|
.el-tabs__header {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 8px;
|
||||||
|
display: inline-block;
|
||||||
|
transform: translateY(-12px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs__content {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
font-size: 18px;
|
||||||
|
color: #fff;
|
||||||
|
padding-left: 0 !important;
|
||||||
|
padding-right: 0 !important;
|
||||||
|
line-height: 36px !important;
|
||||||
|
height: 36px;
|
||||||
|
}
|
||||||
|
.el-tabs__item.is-active {
|
||||||
|
color: #0b58ff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.cost-card .card-title {
|
.detail {
|
||||||
font-size: 22px;
|
display: inline-block;
|
||||||
font-weight: bold;
|
position: absolute;
|
||||||
margin-bottom: 15px;
|
left: 260px;
|
||||||
|
top: 10px;
|
||||||
}
|
}
|
||||||
.cost-card .card-content {
|
:deep(.detail) {
|
||||||
display: grid;
|
.el-input__inner {
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
background-color: transparent;
|
||||||
gap: 10px;
|
color: white;
|
||||||
align-items: center;
|
}
|
||||||
|
}
|
||||||
|
// .current-date {
|
||||||
|
// color: #fff;
|
||||||
|
// font-size: 18px;
|
||||||
|
// position: absolute;
|
||||||
|
// left: 260px;
|
||||||
|
// top: 14px;
|
||||||
|
// }
|
||||||
|
.current-time {
|
||||||
|
color: #fff;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
|
position: absolute;
|
||||||
|
right: 38px;
|
||||||
|
top: 14px;
|
||||||
}
|
}
|
||||||
.target-val {
|
.main-top {
|
||||||
color: #666;
|
width: 100%;
|
||||||
margin-left: 5px;
|
padding: 0 20px 0 40px;
|
||||||
font-size: 20px;
|
.title {
|
||||||
|
position: absolute;
|
||||||
|
left: 34px;
|
||||||
|
top: 20px;
|
||||||
|
width: 180px;
|
||||||
|
font-size: 32px;
|
||||||
|
z-index: 10;
|
||||||
|
.title-inner {
|
||||||
|
position: absolute;
|
||||||
|
left: 42px;
|
||||||
|
top: 5px;
|
||||||
|
font-size: calc(100vw * 20 / 1920);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.box {
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 24px;
|
||||||
|
height: 192px;
|
||||||
|
padding: 40px 24px 32px 24px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
box-shadow: 0 8px 8px 0 gray;
|
||||||
|
.num-box {
|
||||||
|
height: 120px;
|
||||||
|
padding-top: 26px;
|
||||||
|
text-align: center;
|
||||||
|
.num-style {
|
||||||
|
color: #000;
|
||||||
|
font-size: calc(100vw * 40 / 1920);
|
||||||
|
}
|
||||||
|
.unit-style {
|
||||||
|
color: rgba(0, 0, 0, 0.7);
|
||||||
|
font-size: calc(100vw * 18 / 1920);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.shadow {
|
||||||
|
background: linear-gradient(90deg, #ffffff 80%, #f2f4f9 100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.actual-val {
|
.main-bottom {
|
||||||
color: #42b983;
|
width: 100%;
|
||||||
margin-left: 5px;
|
margin-top: 20px;
|
||||||
font-size: 20px;
|
.chart-wrapper {
|
||||||
}
|
margin-left: 10px;
|
||||||
.composition-card {
|
height: 425px;
|
||||||
height: 480px;
|
background: #fff;
|
||||||
}
|
border-radius: 5px;
|
||||||
.composition-card .card-title {
|
box-shadow: 0 3px 3px 0 gray;
|
||||||
font-size: 18px;
|
}
|
||||||
font-weight: bold;
|
}
|
||||||
margin-bottom: 15px;
|
</style>
|
||||||
}
|
<style lang="scss">
|
||||||
.sub-cost {
|
.home-page {
|
||||||
display: grid;
|
.el-progress-bar__inner {
|
||||||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
|
background-image: url('~@/assets/img/home-progress-bg.png');
|
||||||
gap: 10px;
|
background-size: cover;
|
||||||
align-items: center;
|
}
|
||||||
}
|
|
||||||
.sub-cost-group .sub-cost-title {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.sub-cost-group .sub-cost-div {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
border: 1px solid rgb(220, 220, 220, 0.5);
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
.sub-cost-name {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 5px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.sub-cost-val {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.completion {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
.red-text {
|
|
||||||
color: #e74c3c;
|
|
||||||
}
|
|
||||||
.trend-card {
|
|
||||||
height: 450px;
|
|
||||||
}
|
|
||||||
.trend-card .card-title {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog :visible.sync="visible" width="40%">
|
|
||||||
<small-title slot="title" :no-padding="true">
|
|
||||||
{{ this.dataForm.lineId + '·' + this.dataForm.equipmentName }}
|
|
||||||
</small-title>
|
|
||||||
|
|
||||||
<div class="content">
|
|
||||||
<div class="visual-part">
|
|
||||||
<base-table :table-props="tableProps"
|
|
||||||
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
|
|
||||||
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
|
|
||||||
@clickBtn="handleClick" /> -->
|
|
||||||
</base-table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- <div slot="footer" class="dialog-footer">
|
|
||||||
<el-button style="" @click="goback()">取消</el-button>
|
|
||||||
<el-button type="primary" @click="dataFormSubmit()">
|
|
||||||
确定
|
|
||||||
</el-button>
|
|
||||||
</div> -->
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const tableProps = [
|
|
||||||
|
|
||||||
{
|
|
||||||
prop: 'paramName',
|
|
||||||
label: '参数名称'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'paramValue',
|
|
||||||
label: '当前值',
|
|
||||||
// filter: parseTime,
|
|
||||||
// width: 160
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
import { getParamMonitor } from '@/api/base/equipment';
|
|
||||||
// import { parseTime } from '../../mixins/code-filter';
|
|
||||||
import SmallTitle from './SmallTitle';
|
|
||||||
export default {
|
|
||||||
components: { SmallTitle },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
tableProps,
|
|
||||||
tableData:[],
|
|
||||||
listQuery: {
|
|
||||||
pageNo: 1,
|
|
||||||
pageSize:100,
|
|
||||||
},
|
|
||||||
addOrUpdateVisible: false,
|
|
||||||
dataForm: {
|
|
||||||
equipmentId:undefined,
|
|
||||||
equipmentName: undefined,
|
|
||||||
lineId: undefined,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
init(data) {
|
|
||||||
console.log(data.paramMonitors,'data');
|
|
||||||
|
|
||||||
this.dataForm.equipmentId = data.equipmentId || '';
|
|
||||||
this.dataForm.equipmentName = data.equipmentName || '';
|
|
||||||
this.dataForm.lineId = data.lineId || '';
|
|
||||||
|
|
||||||
|
|
||||||
this.visible = true;
|
|
||||||
this.$nextTick(() => {
|
|
||||||
// this.$refs['dataForm'].resetFields();
|
|
||||||
// getParamMonitor({
|
|
||||||
// equipmentId:this.dataForm.equipmentId
|
|
||||||
// }).then((res) => {
|
|
||||||
this.tableData = data.paramMonitors
|
|
||||||
// })
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.drawer >>> .el-drawer {
|
|
||||||
border-radius: 8px 0 0 8px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer >>> .el-form-item__label {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer >>> .el-drawer__header {
|
|
||||||
margin: 0;
|
|
||||||
padding: 32px 32px 24px;
|
|
||||||
border-bottom: 1px solid #dcdfe6;
|
|
||||||
}
|
|
||||||
.drawer >>> .el-drawer__body {
|
|
||||||
flex: 1;
|
|
||||||
height: 1px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer >>> .content {
|
|
||||||
padding: 30px 24px;
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
/* height: 100%; */
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer >>> .visual-part {
|
|
||||||
flex: 1 auto;
|
|
||||||
max-height: 76vh;
|
|
||||||
overflow: hidden;
|
|
||||||
overflow-y: scroll;
|
|
||||||
padding-right: 10px; /* 调整滚动条样式 */
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer >>> .el-form,
|
|
||||||
.drawer >>> .attr-list {
|
|
||||||
padding: 0 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer-body__footer {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
padding: 18px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,561 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog :visible.sync="visible" width="80%" @close="handleClose" title-class="dialog-title">
|
|
||||||
<small-title slot="title" :no-padding="true">
|
|
||||||
{{ dataForm.lineId + '·' + dataForm.equipmentName }}
|
|
||||||
</small-title>
|
|
||||||
<search-bar removeBlue :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
|
||||||
<el-tabs class="custom-tabs" v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
|
|
||||||
<el-tab-pane :label="'\u3000报警时长\u3000'" name="duration"></el-tab-pane>
|
|
||||||
<el-tab-pane :label="'\u3000报警次数\u3000'" name="times"></el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
<div class="content">
|
|
||||||
<div class="visual-part">
|
|
||||||
<div v-if="hasData" style="display: flex; justify-content: space-around; gap: 20px; padding: 10px 0;">
|
|
||||||
<!-- 移除 v-if,始终渲染两个图表容器 -->
|
|
||||||
<div id="barChart" style="width: 48%; height: 400px;"></div>
|
|
||||||
<div id="pieChart" style="width: 48%; height: 400px;"></div>
|
|
||||||
</div>
|
|
||||||
<div v-if="!hasData" class="no-data">
|
|
||||||
<el-empty description="暂无相关报警数据"></el-empty>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { getAlarmDet } from '@/api/base/equipment';
|
|
||||||
import * as echarts from 'echarts';
|
|
||||||
import SmallTitle from './SmallTitle';
|
|
||||||
|
|
||||||
const CHART_CONFIG = {
|
|
||||||
barColor: '#288AFF',
|
|
||||||
pieColors: [
|
|
||||||
'#288AFF', '#4096FF', '#69B1FF', '#91CFFF', '#B8E0FF',
|
|
||||||
'#E0F2FF', '#1890FF', '#096DD9', '#0050B3', '#003A8C'
|
|
||||||
],
|
|
||||||
fontColor: '#333',
|
|
||||||
lightFontColor: '#666',
|
|
||||||
borderRadius: 4
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: { SmallTitle },
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
hasData: false,
|
|
||||||
listQuery: {
|
|
||||||
pageNo: 1,
|
|
||||||
pageSize: 100,
|
|
||||||
equipmentId: undefined,
|
|
||||||
startTime: undefined,
|
|
||||||
endTime: undefined
|
|
||||||
},
|
|
||||||
formConfig: [
|
|
||||||
{
|
|
||||||
type: 'datePicker',
|
|
||||||
label: '时间段',
|
|
||||||
dateType: 'daterange',
|
|
||||||
format: 'yyyy-MM-dd',
|
|
||||||
valueFormat: 'timestamp',
|
|
||||||
rangeSeparator: '-',
|
|
||||||
startPlaceholder: '开始时间',
|
|
||||||
endPlaceholder: '结束时间',
|
|
||||||
param: 'timeVal',
|
|
||||||
defaultTime: ['00:00:00', '23:59:59'],
|
|
||||||
defaultSelect: []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'button',
|
|
||||||
btnName: '查询',
|
|
||||||
name: 'search',
|
|
||||||
color: 'primary'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
activeLabel: 'duration', // 默认选中「报警时长」
|
|
||||||
dataForm: {
|
|
||||||
equipmentId: undefined,
|
|
||||||
equipmentName: undefined,
|
|
||||||
lineId: undefined
|
|
||||||
},
|
|
||||||
chartInstances: {
|
|
||||||
bar: null,
|
|
||||||
pie: null
|
|
||||||
},
|
|
||||||
isDomReady: false,
|
|
||||||
originData: null // 存储原始数据
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.isDomReady = true;
|
|
||||||
if (this.listQuery.equipmentId) {
|
|
||||||
this.getDataList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
// Tab 切换时自动刷新图表(无需额外操作,依赖 handleTabClick 触发查询)
|
|
||||||
activeLabel() {
|
|
||||||
if (this.isDomReady && this.originData) {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.renderBothCharts(); // 切换 Tab 后重新渲染两个图表
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
initDefaultDate() {
|
|
||||||
const today = new Date();
|
|
||||||
const start = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0, 0).getTime();
|
|
||||||
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 0).getTime();
|
|
||||||
|
|
||||||
this.formConfig[0].defaultSelect = [start, end];
|
|
||||||
this.listQuery.startTime = start;
|
|
||||||
this.listQuery.endTime = end;
|
|
||||||
|
|
||||||
if (this.$refs.searchBarForm) {
|
|
||||||
this.$refs.searchBarForm.form.timeVal = [start, end];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
handleTabClick() {
|
|
||||||
// 切换 Tab 时重新查询数据(或直接复用已有数据渲染)
|
|
||||||
this.getDataList();
|
|
||||||
},
|
|
||||||
|
|
||||||
buttonClick(val) {
|
|
||||||
switch (val.btnName) {
|
|
||||||
case 'search':
|
|
||||||
this.listQuery.startTime = val.timeVal?.[0];
|
|
||||||
this.listQuery.endTime = val.timeVal?.[1];
|
|
||||||
this.getDataList();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async getDataList() {
|
|
||||||
try {
|
|
||||||
if (!this.listQuery.equipmentId) {
|
|
||||||
console.warn('设备ID不能为空');
|
|
||||||
this.hasData = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryParams = {
|
|
||||||
equipmentId: this.listQuery.equipmentId,
|
|
||||||
startTime: this.listQuery.startTime,
|
|
||||||
endTime: this.listQuery.endTime,
|
|
||||||
};
|
|
||||||
|
|
||||||
const res = await getAlarmDet(queryParams);
|
|
||||||
const originData = res.data || [];
|
|
||||||
this.originData = originData;
|
|
||||||
this.hasData = originData.length > 0;
|
|
||||||
|
|
||||||
if (this.hasData && this.isDomReady) {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.renderBothCharts(); // 数据查询成功后,同时渲染两个图表
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.destroyAllCharts();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取报警数据失败:', error);
|
|
||||||
this.hasData = false;
|
|
||||||
this.destroyAllCharts();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 核心方法:同时渲染柱状图和饼图(根据当前 Tab 类型)
|
|
||||||
renderBothCharts() {
|
|
||||||
if (this.activeLabel === 'duration') {
|
|
||||||
// 报警时长:柱状图(时长排序)+ 饼图(时长占比)
|
|
||||||
this.renderBarChart('duration');
|
|
||||||
this.renderPieChart('duration');
|
|
||||||
} else {
|
|
||||||
// 报警次数:柱状图(次数排序)+ 饼图(次数占比)
|
|
||||||
this.renderBarChart('times');
|
|
||||||
this.renderPieChart('times');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 渲染柱状图(支持两种数据类型)
|
|
||||||
renderBarChart(type) {
|
|
||||||
this.destroyChart('bar');
|
|
||||||
const chartDom = document.getElementById('barChart');
|
|
||||||
if (!chartDom || !this.originData.length) return;
|
|
||||||
|
|
||||||
// 根据类型排序和提取数据
|
|
||||||
let sortedData, xData, seriesData, yAxisName;
|
|
||||||
if (type === 'duration') {
|
|
||||||
// 报警时长:按时长降序
|
|
||||||
sortedData = [...this.originData].sort((a, b) => b.alarmDuration - a.alarmDuration);
|
|
||||||
seriesData = sortedData.map(item => item.alarmDuration);
|
|
||||||
yAxisName = '报警时长';
|
|
||||||
} else {
|
|
||||||
// 报警次数:按次数降序
|
|
||||||
sortedData = [...this.originData].sort((a, b) => b.alarmCount - a.alarmCount);
|
|
||||||
seriesData = sortedData.map(item => item.alarmCount);
|
|
||||||
yAxisName = '报警次数';
|
|
||||||
}
|
|
||||||
|
|
||||||
xData = sortedData.map(item => this.truncateText(item.alarmContent, 8));
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.chartInstances.bar = echarts.init(chartDom);
|
|
||||||
const option = {
|
|
||||||
title: {
|
|
||||||
text: `${yAxisName}统计(柱状图)`,
|
|
||||||
left: 'center',
|
|
||||||
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis',
|
|
||||||
axisPointer: { type: 'shadow' },
|
|
||||||
padding: 10,
|
|
||||||
textStyle: { fontSize: 11 },
|
|
||||||
formatter: (params) => {
|
|
||||||
const index = params[0].dataIndex;
|
|
||||||
const item = sortedData[index];
|
|
||||||
return `
|
|
||||||
<div style="text-align: left;">
|
|
||||||
<div>${item.alarmContent}</div>
|
|
||||||
<div>${yAxisName}:${type === 'duration' ? item.alarmDuration : item.alarmCount}</div>
|
|
||||||
<div>占比:${type === 'duration' ? item.alarmDurationRatio.toFixed(2) : item.alarmCountRatio.toFixed(2)}%</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
grid: {
|
|
||||||
left: '5%',
|
|
||||||
right: '5%',
|
|
||||||
bottom: '18%',
|
|
||||||
top: '15%',
|
|
||||||
containLabel: true
|
|
||||||
},
|
|
||||||
xAxis: [
|
|
||||||
{
|
|
||||||
type: 'category',
|
|
||||||
data: xData,
|
|
||||||
axisTick: { alignWithLabel: true },
|
|
||||||
axisLabel: {
|
|
||||||
interval: 0,
|
|
||||||
fontSize: 12,
|
|
||||||
color: CHART_CONFIG.lightFontColor
|
|
||||||
},
|
|
||||||
axisLine: { lineStyle: { color: '#e8e8e8' } }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
yAxis: [
|
|
||||||
{
|
|
||||||
type: 'value',
|
|
||||||
name: yAxisName,
|
|
||||||
nameTextStyle: { fontSize: 11, color: CHART_CONFIG.lightFontColor },
|
|
||||||
axisLabel: {
|
|
||||||
fontSize: 11,
|
|
||||||
color: CHART_CONFIG.lightFontColor,
|
|
||||||
},
|
|
||||||
axisLine: { lineStyle: { color: '#e8e8e8' } },
|
|
||||||
splitLine: { lineStyle: { color: '#f5f5f5' } },
|
|
||||||
max: (value) => value.max * 1.2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: yAxisName,
|
|
||||||
type: 'bar',
|
|
||||||
itemStyle: {
|
|
||||||
color: CHART_CONFIG.barColor,
|
|
||||||
borderRadius: [CHART_CONFIG.borderRadius, CHART_CONFIG.borderRadius, 0, 0],
|
|
||||||
shadowBlur: 3,
|
|
||||||
shadowColor: 'rgba(40, 138, 255, 0.2)',
|
|
||||||
shadowOffsetY: 2
|
|
||||||
},
|
|
||||||
barWidth: '16',
|
|
||||||
data: seriesData,
|
|
||||||
label: {
|
|
||||||
show: true,
|
|
||||||
position: 'top',
|
|
||||||
distance: 6,
|
|
||||||
fontSize: 11,
|
|
||||||
color: CHART_CONFIG.fontColor,
|
|
||||||
formatter: (params) => `${params.value}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
this.chartInstances.bar.setOption(option);
|
|
||||||
this.addResizeListener('bar');
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`${yAxisName}柱状图初始化失败:`, error);
|
|
||||||
setTimeout(() => this.renderBarChart(type), 200);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 渲染饼图(支持两种数据类型)
|
|
||||||
renderPieChart(type) {
|
|
||||||
this.destroyChart('pie');
|
|
||||||
const chartDom = document.getElementById('pieChart');
|
|
||||||
if (!chartDom || !this.originData.length) return;
|
|
||||||
|
|
||||||
// 根据类型处理饼图数据
|
|
||||||
let pieData, seriesName;
|
|
||||||
if (type === 'duration') {
|
|
||||||
// 报警时长:按时长占比处理
|
|
||||||
seriesName = '报警时长';
|
|
||||||
pieData = this.handlePieData(this.originData, 'alarmDuration', 'alarmDurationRatio');
|
|
||||||
} else {
|
|
||||||
// 报警次数:按次数占比处理
|
|
||||||
seriesName = '报警次数';
|
|
||||||
pieData = this.handlePieData(this.originData, 'alarmCount', 'alarmCountRatio');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.chartInstances.pie = echarts.init(chartDom);
|
|
||||||
const option = {
|
|
||||||
title: {
|
|
||||||
text: `${seriesName}统计(饼图)`,
|
|
||||||
left: 'center',
|
|
||||||
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'item',
|
|
||||||
padding: 10,
|
|
||||||
textStyle: { fontSize: 11 },
|
|
||||||
formatter: (params) => {
|
|
||||||
return `
|
|
||||||
<div style="text-align: left;">
|
|
||||||
<div>${params.name}</div>
|
|
||||||
<div>${seriesName}:${params.value}${type === 'duration' ? '' : '次'}</div>
|
|
||||||
<div>占比:${params.percent.toFixed(2)}%</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: seriesName,
|
|
||||||
type: 'pie',
|
|
||||||
radius: ['50%', '70%'],
|
|
||||||
center: ['50%', '55%'],
|
|
||||||
color: CHART_CONFIG.pieColors,
|
|
||||||
label: {
|
|
||||||
show: true,
|
|
||||||
position: 'outside',
|
|
||||||
distance: 15,
|
|
||||||
fontSize: 11,
|
|
||||||
color: CHART_CONFIG.lightFontColor,
|
|
||||||
formatter: (params) => {
|
|
||||||
const truncatedName = this.truncateText(params.name, 8);
|
|
||||||
return `${truncatedName}(${params.value}${type === 'duration' ? '' : '次'}, ${params.percent.toFixed(1)}%)`;
|
|
||||||
},
|
|
||||||
align: 'center',
|
|
||||||
baseline: 'middle'
|
|
||||||
},
|
|
||||||
labelLine: {
|
|
||||||
show: true,
|
|
||||||
length: 15,
|
|
||||||
length2: 20,
|
|
||||||
lineStyle: {
|
|
||||||
color: '#ccc',
|
|
||||||
width: 1,
|
|
||||||
type: 'solid'
|
|
||||||
},
|
|
||||||
smooth: 0.2
|
|
||||||
},
|
|
||||||
data: pieData,
|
|
||||||
emphasis: {
|
|
||||||
itemStyle: {
|
|
||||||
shadowBlur: 10,
|
|
||||||
shadowColor: 'rgba(0, 0, 0, 0.1)'
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
color: CHART_CONFIG.fontColor,
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: 500
|
|
||||||
},
|
|
||||||
labelLine: {
|
|
||||||
lineStyle: {
|
|
||||||
color: CHART_CONFIG.barColor,
|
|
||||||
width: 1.5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
this.chartInstances.pie.setOption(option);
|
|
||||||
this.addResizeListener('pie');
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`${seriesName}饼图初始化失败:`, error);
|
|
||||||
setTimeout(() => this.renderPieChart(type), 200);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 通用饼图数据处理(支持动态字段)
|
|
||||||
handlePieData(data, valueKey, ratioKey) {
|
|
||||||
const threshold = 5; // 占比低于5%合并为「其他」
|
|
||||||
let otherCount = 0;
|
|
||||||
const mainData = data.filter(item => {
|
|
||||||
if (item[ratioKey] >= threshold) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
otherCount += item[valueKey];
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).map(item => ({
|
|
||||||
name: item.alarmContent,
|
|
||||||
value: item[valueKey],
|
|
||||||
ratio: item[ratioKey]
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (otherCount > 0) {
|
|
||||||
mainData.push({
|
|
||||||
name: '其他',
|
|
||||||
value: otherCount,
|
|
||||||
ratio: 100 - mainData.reduce((sum, item) => sum + item.ratio, 0)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mainData;
|
|
||||||
},
|
|
||||||
|
|
||||||
truncateText(text, maxLength) {
|
|
||||||
if (!text) return '';
|
|
||||||
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
|
|
||||||
},
|
|
||||||
|
|
||||||
addResizeListener(type) {
|
|
||||||
const chart = this.chartInstances[type];
|
|
||||||
if (chart) {
|
|
||||||
const resizeHandler = () => chart.resize();
|
|
||||||
window.addEventListener('resize', resizeHandler);
|
|
||||||
chart.resizeHandler = resizeHandler;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
destroyChart(type) {
|
|
||||||
const chart = this.chartInstances[type];
|
|
||||||
if (chart) {
|
|
||||||
window.removeEventListener('resize', chart.resizeHandler);
|
|
||||||
chart.dispose();
|
|
||||||
this.chartInstances[type] = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
destroyAllCharts() {
|
|
||||||
Object.keys(this.chartInstances).forEach(type => {
|
|
||||||
this.destroyChart(type);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleClose() {
|
|
||||||
this.destroyAllCharts();
|
|
||||||
this.formConfig[0].defaultSelect = [];
|
|
||||||
this.listQuery.startTime = undefined;
|
|
||||||
this.listQuery.endTime = undefined;
|
|
||||||
this.originData = null;
|
|
||||||
this.hasData = true;
|
|
||||||
if (this.$refs.searchBarForm) {
|
|
||||||
// this.$refs.searchBarForm.form.timeVal = [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
init(data) {
|
|
||||||
this.dataForm = {
|
|
||||||
equipmentId: data.equipmentId || '',
|
|
||||||
equipmentName: data.equipmentName || '',
|
|
||||||
lineId: data.lineId || ''
|
|
||||||
};
|
|
||||||
this.activeLabel = 'duration'
|
|
||||||
this.listQuery.equipmentId = data.equipmentId || undefined;
|
|
||||||
this.visible = true;
|
|
||||||
this.originData = null;
|
|
||||||
this.hasData = false;
|
|
||||||
|
|
||||||
this.initDefaultDate();
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.isDomReady = true;
|
|
||||||
this.getDataList();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeDestroy() {
|
|
||||||
this.destroyAllCharts();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
/* 保持原有样式,优化图表容器布局 */
|
|
||||||
.drawer>>>.el-drawer {
|
|
||||||
border-radius: 8px 0 0 8px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer>>>.el-form-item__label {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer>>>.el-drawer__header {
|
|
||||||
margin: 0;
|
|
||||||
padding: 32px 32px 24px;
|
|
||||||
border-bottom: 1px solid #dcdfe6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer>>>.el-drawer__body {
|
|
||||||
flex: 1;
|
|
||||||
height: 1px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer>>>.content {
|
|
||||||
padding: 30px 24px;
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer>>>.visual-part {
|
|
||||||
flex: 1 auto;
|
|
||||||
max-height: 76vh;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 10px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 优化图表容器响应式布局 */
|
|
||||||
@media (max-width: 1200px) {
|
|
||||||
.visual-part>div {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
#barChart,
|
|
||||||
#pieChart {
|
|
||||||
width: 100% !important;
|
|
||||||
height: 350px !important;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer>>>.el-form,
|
|
||||||
.drawer>>>.attr-list {
|
|
||||||
padding: 0 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drawer-body__footer {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
padding: 18px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -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-11-14 21:13:10
|
* @LastEditTime: 2025-10-23 16:50:43
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container" style="padding-top: 0">
|
<div class="app-container">
|
||||||
<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.deptName + ' - ' + item.planName }}
|
{{item.planName}}
|
||||||
</small-title>
|
</small-title>
|
||||||
<base-table
|
<base-table
|
||||||
:table-props="tableProps"
|
:table-props="tableProps"
|
||||||
@@ -59,14 +59,13 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
init(det, detSort) {
|
init(det) {
|
||||||
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;
|
||||||
});
|
});
|
||||||
@@ -77,19 +76,7 @@ export default {
|
|||||||
map.set(item.planId, item);
|
map.set(item.planId, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const newArr = Array.from(map.values());
|
this.groupClassArr = 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,221 +2,212 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-23 13:43:55
|
* @Date: 2025-10-23 13:43:55
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-11-25 09:39:43
|
* @LastEditTime: 2025-10-24 11:14:55
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div
|
<el-row :gutter="10" style="background-color: #f2f4f9">
|
||||||
class="app-container"
|
<!--部门数据-->
|
||||||
style="
|
<el-col :span="4">
|
||||||
background-color: #f2f4f9;
|
<div class="head-container">
|
||||||
padding: 0;
|
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
|
||||||
display: grid;
|
<el-tab-pane label="部门" name="first"></el-tab-pane>
|
||||||
grid-template-columns: 1fr 5fr;
|
<el-tab-pane label="班组" name="second"></el-tab-pane>
|
||||||
gap: 10px;
|
</el-tabs>
|
||||||
">
|
<div v-if="activeName == 'first'">
|
||||||
<div class="head-container">
|
<el-input
|
||||||
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
|
v-model="deptName"
|
||||||
<el-tab-pane label="部门" name="first"></el-tab-pane>
|
placeholder="请输入部门名称"
|
||||||
<el-tab-pane label="班组" name="second"></el-tab-pane>
|
clearable
|
||||||
</el-tabs>
|
size="small"
|
||||||
<div v-if="activeName == 'first'">
|
prefix-icon="el-icon-search"
|
||||||
<el-input
|
style="margin-bottom: 20px" />
|
||||||
v-model="deptName"
|
<el-tree
|
||||||
placeholder="请输入部门名称"
|
:data="deptOptions"
|
||||||
clearable
|
:props="defaultProps"
|
||||||
size="small"
|
:expand-on-click-node="false"
|
||||||
prefix-icon="el-icon-search"
|
:filter-node-method="filterNode"
|
||||||
style="margin-bottom: 20px" />
|
ref="tree"
|
||||||
<el-tree
|
default-expand-all
|
||||||
:data="deptOptions"
|
highlight-current
|
||||||
:props="defaultProps"
|
@node-click="handleNodeClick" />
|
||||||
:expand-on-click-node="false"
|
</div>
|
||||||
:filter-node-method="filterNode"
|
<div v-else>
|
||||||
ref="tree"
|
<el-input
|
||||||
node-key="id"
|
v-model="groupName"
|
||||||
default-expand-all
|
placeholder="请输入班组名称"
|
||||||
highlight-current
|
clearable
|
||||||
@node-click="handleNodeClick" />
|
size="small"
|
||||||
|
prefix-icon="el-icon-search"
|
||||||
|
style="margin-bottom: 20px" />
|
||||||
|
<el-tree
|
||||||
|
:data="groupOptions"
|
||||||
|
:props="defaultProps"
|
||||||
|
:expand-on-click-node="false"
|
||||||
|
:filter-node-method="filterNode"
|
||||||
|
ref="tree1"
|
||||||
|
default-expand-all
|
||||||
|
highlight-current
|
||||||
|
@node-click="handleNodeClick1" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
</el-col>
|
||||||
<el-input
|
<el-col :span="20">
|
||||||
v-model="groupName"
|
<div class="groupTeamScheduling">
|
||||||
placeholder="请输入班组名称"
|
<div class="operationArea">
|
||||||
clearable
|
<el-form :inline="true" class="demo-form-inline">
|
||||||
size="small"
|
<span class="blue-block"></span>
|
||||||
prefix-icon="el-icon-search"
|
<el-form-item label="月份选择">
|
||||||
style="margin-bottom: 20px" />
|
<el-date-picker
|
||||||
<el-tree
|
v-model="startDay"
|
||||||
:data="groupOptions"
|
type="month"
|
||||||
:props="defaultProps"
|
placeholder="选择月"
|
||||||
:expand-on-click-node="false"
|
size="small"
|
||||||
:filter-node-method="filterNode"
|
@change="selectMonth"
|
||||||
ref="tree1"
|
:clearable="false"
|
||||||
node-key="id"
|
style="width: 120px"></el-date-picker>
|
||||||
default-expand-all
|
<span
|
||||||
highlight-current
|
style="color: #909399; font-size: 12px"
|
||||||
@node-click="handleNodeClick1" />
|
v-if="activeName == 'first'">
|
||||||
</div>
|
提示:排班日历仅展示当前选中部门的节假日设置,若休假日中仍有排班,则表示下级组织已通过自定义假期进行排班。
|
||||||
</div>
|
|
||||||
<div class="groupTeamScheduling">
|
|
||||||
<div class="operationArea">
|
|
||||||
<el-form :inline="true" class="demo-form-inline">
|
|
||||||
<span class="blue-block"></span>
|
|
||||||
<el-form-item label="月份选择">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="startDay"
|
|
||||||
type="month"
|
|
||||||
placeholder="选择月"
|
|
||||||
size="small"
|
|
||||||
@change="selectMonth"
|
|
||||||
:clearable="false"
|
|
||||||
style="width: 120px"></el-date-picker>
|
|
||||||
<span
|
|
||||||
style="color: #909399; font-size: 12px"
|
|
||||||
v-if="activeName == 'first'">
|
|
||||||
提示:排班日历仅展示当前选中部门的节假日设置,若休假日中仍有排班,则表示下级组织已通过自定义假期进行排班。
|
|
||||||
</span>
|
|
||||||
<span v-else style="margin-left: 10px">
|
|
||||||
组长:
|
|
||||||
<span style="font-weight: 600; margin: 0 10px">
|
|
||||||
{{ showTeamName?.leaderName || '-' }}
|
|
||||||
</span>
|
</span>
|
||||||
组长电话:
|
<span v-else>
|
||||||
<span style="font-weight: 600; margin: 0 10px">
|
组长:{{ showTeamName?.leaderName || '-' }} 组长电话:{{
|
||||||
{{ showTeamName?.leaderPhone || '-' }}
|
showTeamName?.leaderPhone || '-'
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item style="float: right">
|
||||||
<el-form-item style="float: right">
|
<el-button
|
||||||
<el-button
|
size="small"
|
||||||
size="small"
|
type="primary"
|
||||||
type="primary"
|
@click="(startDay = new Date()), getHolidayPage()">
|
||||||
@click="(startDay = new Date()), getHolidayPage()">
|
跳转到今天
|
||||||
跳转到今天
|
</el-button>
|
||||||
</el-button>
|
</el-form-item>
|
||||||
</el-form-item>
|
</el-form>
|
||||||
</el-form>
|
</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">
|
<el-row :gutter="20">
|
||||||
<el-row :gutter="20">
|
<!-- 公历和农历 -->
|
||||||
<!-- 公历和农历 -->
|
<el-col :span="18">
|
||||||
<el-col :span="18">
|
{{ Number(data.day.split('-')[2]) }}
|
||||||
{{ Number(data.day.split('-')[2]) }}
|
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
|
||||||
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
|
</el-col>
|
||||||
</el-col>
|
<!-- 显示假或班 -->
|
||||||
<!-- 显示假或班 -->
|
<el-col :span="6">
|
||||||
<el-col :span="6">
|
|
||||||
<div
|
|
||||||
class="work-tip"
|
|
||||||
:style="{
|
|
||||||
backgroundColor: HolidayList[
|
|
||||||
Number(data.day.split('-')[2]) - 1
|
|
||||||
]?.isHoliday
|
|
||||||
? '#67C23A'
|
|
||||||
: '#409EFF',
|
|
||||||
}">
|
|
||||||
{{
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.isHoliday
|
|
||||||
? '假'
|
|
||||||
: '班'
|
|
||||||
}}
|
|
||||||
<!-- //变更节假日未更新排班计划的角标 -->
|
|
||||||
<div
|
<div
|
||||||
class="subIcon"
|
class="work-tip"
|
||||||
v-if="
|
:style="{
|
||||||
|
backgroundColor: HolidayList[
|
||||||
|
Number(data.day.split('-')[2]) - 1
|
||||||
|
]?.isHoliday
|
||||||
|
? '#67C23A'
|
||||||
|
: '#409EFF',
|
||||||
|
}">
|
||||||
|
{{
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
?.isUpdate
|
?.isHoliday
|
||||||
">
|
? '假'
|
||||||
|
: '班'
|
||||||
|
}}
|
||||||
|
<!-- //变更节假日未更新排班计划的角标 -->
|
||||||
|
<div
|
||||||
|
class="subIcon"
|
||||||
|
v-if="
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
|
?.isUpdate
|
||||||
|
">
|
||||||
|
<el-tooltip
|
||||||
|
effect="dark"
|
||||||
|
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
|
||||||
|
placement="top">
|
||||||
|
<i
|
||||||
|
class="el-icon-warning"
|
||||||
|
style="color: #f56c6c"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<!-- 显示排班 -->
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]?.det
|
||||||
|
.length > 0
|
||||||
|
">
|
||||||
|
<el-col
|
||||||
|
:span="24"
|
||||||
|
v-for="(item, index) in HolidayList[
|
||||||
|
Number(data.day.split('-')[2]) - 1
|
||||||
|
]?.det.filter(
|
||||||
|
(item) =>
|
||||||
|
item.schedulingPlanId ==
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
|
?.schedulingPlanId
|
||||||
|
)"
|
||||||
|
:key="index">
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
effect="dark"
|
effect="dark"
|
||||||
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
|
content="点击展示全部排班计划"
|
||||||
placement="top">
|
placement="top-start">
|
||||||
<i class="el-icon-warning" style="color: #f56c6c"></i>
|
<div
|
||||||
|
class="holiday-div"
|
||||||
|
:style="{
|
||||||
|
backgroundColor:
|
||||||
|
holidayDivColor[item?.classesCode],
|
||||||
|
}"
|
||||||
|
@click="
|
||||||
|
holidayLog(
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
|
?.det,
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
|
?.date
|
||||||
|
)
|
||||||
|
"
|
||||||
|
:title="
|
||||||
|
item.classesName +
|
||||||
|
' | ' +
|
||||||
|
item.teamName +
|
||||||
|
' | ' +
|
||||||
|
item.workTime
|
||||||
|
">
|
||||||
|
{{
|
||||||
|
item.classesName +
|
||||||
|
' | ' +
|
||||||
|
item.teamName +
|
||||||
|
' | ' +
|
||||||
|
item.workTime
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</el-col>
|
||||||
</div>
|
</div>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
style="font-size: 20px; font-weight: 500; text-align: left">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="24">
|
||||||
|
{{ Number(data.day.split('-')[2]) }}
|
||||||
|
<span style="font-size: 12px">
|
||||||
|
{{ getLunarDate(data.day) }}
|
||||||
|
</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- 显示排班 -->
|
|
||||||
<div
|
|
||||||
v-if="
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]?.det
|
|
||||||
.length > 0
|
|
||||||
">
|
|
||||||
<el-col
|
|
||||||
:span="24"
|
|
||||||
v-for="(item, index) in HolidayList[
|
|
||||||
Number(data.day.split('-')[2]) - 1
|
|
||||||
]?.det.filter(
|
|
||||||
(item) =>
|
|
||||||
item.schedulingPlanId ==
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.schedulingPlanId
|
|
||||||
)"
|
|
||||||
:key="index">
|
|
||||||
<el-tooltip
|
|
||||||
effect="dark"
|
|
||||||
content="点击展示全部排班计划"
|
|
||||||
placement="top-start">
|
|
||||||
<div
|
|
||||||
class="holiday-div"
|
|
||||||
:style="{
|
|
||||||
backgroundColor: holidayDivColor[item?.classesCode],
|
|
||||||
}"
|
|
||||||
@click="
|
|
||||||
holidayLog(
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.det,
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.date,
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.detSort
|
|
||||||
)
|
|
||||||
"
|
|
||||||
:title="
|
|
||||||
item.classesName +
|
|
||||||
' | ' +
|
|
||||||
item.teamName +
|
|
||||||
' | ' +
|
|
||||||
item.workTime
|
|
||||||
">
|
|
||||||
{{
|
|
||||||
item.classesName +
|
|
||||||
' | ' +
|
|
||||||
item.teamName +
|
|
||||||
' | ' +
|
|
||||||
item.workTime
|
|
||||||
}}
|
|
||||||
</div>
|
|
||||||
</el-tooltip>
|
|
||||||
</el-col>
|
|
||||||
</div>
|
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
<div
|
</el-calendar>
|
||||||
v-else
|
</div>
|
||||||
style="font-size: 20px; font-weight: 500; text-align: left">
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span="24">
|
|
||||||
{{ Number(data.day.split('-')[2]) }}
|
|
||||||
<span style="font-size: 12px">
|
|
||||||
{{ getLunarDate(data.day) }}
|
|
||||||
</span>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-calendar>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</el-col>
|
||||||
<base-dialog
|
<base-dialog
|
||||||
:dialogTitle="dialogTitle"
|
:dialogTitle="dialogTitle"
|
||||||
:dialogVisible="logVisible"
|
:dialogVisible="logVisible"
|
||||||
@@ -237,7 +228,7 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</base-dialog>
|
</base-dialog>
|
||||||
</div>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -348,43 +339,13 @@ export default {
|
|||||||
getEnableData().then((response) => {
|
getEnableData().then((response) => {
|
||||||
// 处理 deptOptions 参数
|
// 处理 deptOptions 参数
|
||||||
this.deptOptions = [];
|
this.deptOptions = [];
|
||||||
this.deptOptions.push(...this.handleTree1(response.data, 'id'));
|
this.deptOptions.push(...this.handleTree(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;
|
||||||
@@ -397,14 +358,8 @@ 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();
|
||||||
},
|
},
|
||||||
@@ -486,11 +441,11 @@ export default {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
holidayLog(det, date, detSort) {
|
holidayLog(det, date) {
|
||||||
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, detSort);
|
this.$refs.holidayLogRef.init(det);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelLog() {
|
cancelLog() {
|
||||||
@@ -504,8 +459,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-11-14 22:00:10
|
* @LastEditTime: 2025-10-29 17:12:04
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getGroupPage } from '@/api/group/groupSetting';
|
import { listByDeptId } from '@/api/group/Schedule';
|
||||||
|
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ const tableProps = [
|
|||||||
width: 100,
|
width: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'deptName',
|
prop: 'deptId',
|
||||||
label: '所属部门',
|
label: '所属部门',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
urlOptions: {
|
urlOptions: {
|
||||||
getDataListURL: getGroupPage,
|
getDataListURL: listByDeptId,
|
||||||
},
|
},
|
||||||
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.formInline.deptId = id;
|
this.deptId = id;
|
||||||
this.selectedArr = tableData || [];
|
this.selectedArr = tableData || [];
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
@@ -103,9 +103,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.urlOptions.getDataListURL(this.formInline).then((response) => {
|
this.urlOptions.getDataListURL(this.deptId).then((response) => {
|
||||||
this.tableData = response.data.list.filter(item=>item.enabled===1);
|
this.tableData = response.data;
|
||||||
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();
|
||||||
@@ -120,12 +119,12 @@ export default {
|
|||||||
table.clearSelection();
|
table.clearSelection();
|
||||||
|
|
||||||
this.selectedArr.forEach((item) => {
|
this.selectedArr.forEach((item) => {
|
||||||
const rowInTable = this.tableData.find((i) => i.teamId === item.teamId);
|
const rowInTable = this.tableData.find((i) => i.id === item.id);
|
||||||
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.teamId === item.teamId),
|
table.tableData.find((i) => i.id === item.id),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -150,19 +149,22 @@ export default {
|
|||||||
selectChange(val) {
|
selectChange(val) {
|
||||||
this.selectedList = val;
|
this.selectedList = val;
|
||||||
},
|
},
|
||||||
// 判断两个数组是否有重复的 id,去重
|
// 判断两个数组是否有重复的 id
|
||||||
hasDuplicateIds(arr1, arr2) {
|
hasDuplicateIds(arr1, arr2) {
|
||||||
return arr2.filter(
|
const idSet = new Set(arr1.map((item) => item.id));
|
||||||
(item2) => !arr1.some((item1) => item1.teamId === item2.teamId)
|
return arr2.some((item) => idSet.has(item.id));
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
dataFormSubmit() {
|
dataFormSubmit() {
|
||||||
if (this.selectedList && this.selectedList.length > 0) {
|
if (this.selectedList && this.selectedList.length > 0) {
|
||||||
this.selectedList = this.hasDuplicateIds(
|
const haveData = 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-12-03 15:48:26
|
* @LastEditTime: 2025-10-29 15:28:52
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -54,11 +54,10 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="部门" prop="deptId">
|
<el-form-item label="部门">
|
||||||
<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>
|
||||||
@@ -112,7 +111,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"
|
||||||
@@ -135,18 +134,6 @@
|
|||||||
<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"
|
||||||
@@ -163,12 +150,6 @@
|
|||||||
</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"
|
||||||
@@ -176,7 +157,6 @@
|
|||||||
: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"
|
||||||
@@ -194,7 +174,8 @@
|
|||||||
: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天,不休周末排班如下"
|
||||||
@@ -211,10 +192,9 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
<i
|
<i
|
||||||
slot="reference"
|
slot="reference"
|
||||||
class="el-icon-chat-dot-square"
|
class="el-icon-warning-outline"
|
||||||
style="color: #409eff; font-size: 18px"></i>
|
style="color: #ff1c15"></i>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
设置,按班组轮班顺序依次循环每日班次,生成正式排班计划,请确认。
|
|
||||||
</span>
|
</span>
|
||||||
</small-title>
|
</small-title>
|
||||||
<el-tag>
|
<el-tag>
|
||||||
@@ -247,7 +227,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>
|
||||||
@@ -355,7 +335,6 @@ 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,
|
||||||
@@ -395,17 +374,10 @@ 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',
|
||||||
@@ -450,7 +422,6 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
stepNum: 1, // 当前第几步
|
stepNum: 1, // 当前第几步
|
||||||
isEdit: false, //是否是编辑状态,编辑的时候,让前端上一步和取消都不用接口
|
|
||||||
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType,到第二步,判断dataForm.shiftType是否改变,同时改变班次信息
|
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType,到第二步,判断dataForm.shiftType是否改变,同时改变班次信息
|
||||||
//第一步参数
|
//第一步参数
|
||||||
dataForm: {
|
dataForm: {
|
||||||
@@ -505,7 +476,6 @@ 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' },
|
||||||
],
|
],
|
||||||
@@ -538,8 +508,6 @@ export default {
|
|||||||
btnName: '编辑',
|
btnName: '编辑',
|
||||||
},
|
},
|
||||||
].filter((v) => v),
|
].filter((v) => v),
|
||||||
isClassTimePass: true, //修改班次时间后,需要判断时间是否有重叠,且是否在24小时内 true是没问题的
|
|
||||||
covers24Hours: true, //修改班次时间后,需要判断时间是否覆盖24小时连续的时间 true是没问题的
|
|
||||||
tableData1: [],
|
tableData1: [],
|
||||||
tableProps2,
|
tableProps2,
|
||||||
tableBtn2: [
|
tableBtn2: [
|
||||||
@@ -629,9 +597,8 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init(id, isEdit) {
|
init(id) {
|
||||||
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) {
|
||||||
@@ -642,18 +609,14 @@ 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 = '';
|
||||||
if (item.isProduction) {
|
lineName = this.setLineName(item.bindLineTree, lineName);
|
||||||
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) => {
|
||||||
@@ -665,33 +628,18 @@ 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.$emit('setSN', this.stepNum);
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.setDataForm();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.stepNum -= 1;
|
this.stepNum -= 1;
|
||||||
this.$emit('setSN', this.stepNum);
|
this.$emit('setSN', this.stepNum);
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.setDataForm();
|
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.$emit('setSN', this.stepNum);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.stepNum -= 1;
|
this.stepNum -= 1;
|
||||||
this.$emit('setSN', this.stepNum);
|
this.$emit('setSN', this.stepNum);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//下一步
|
//下一步
|
||||||
@@ -706,12 +654,9 @@ export default {
|
|||||||
this.$message('部门不能为空');
|
this.$message('部门不能为空');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const compareDate = this.compareDates(
|
const compareDate = this.compareDates(this.dataForm.startDay,this.dataForm.endDay)
|
||||||
this.dataForm.startDay,
|
|
||||||
this.dataForm.endDay
|
|
||||||
);
|
|
||||||
|
|
||||||
if (compareDate > 0) {
|
if (compareDate > 0 ) {
|
||||||
this.$message('开始时间不能大于结束时间');
|
this.$message('开始时间不能大于结束时间');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -732,7 +677,6 @@ 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;
|
||||||
@@ -740,10 +684,7 @@ export default {
|
|||||||
|
|
||||||
let isbindLine = false;
|
let isbindLine = false;
|
||||||
this.tableData2.forEach((item) => {
|
this.tableData2.forEach((item) => {
|
||||||
if (
|
if (!item.bindLineTree || item.bindLineTree.length == 0) {
|
||||||
item.isProduction &&
|
|
||||||
(!item.bindLineTree || item.bindLineTree.length == 0)
|
|
||||||
) {
|
|
||||||
isbindLine = true;
|
isbindLine = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -770,11 +711,6 @@ 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
|
||||||
@@ -786,30 +722,24 @@ 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, index) => {
|
this.tableData2.forEach((item) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
sort: index + 1,
|
teamId: item.id,
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -818,7 +748,7 @@ export default {
|
|||||||
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
||||||
this.tableData2.forEach((item) => {
|
this.tableData2.forEach((item) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
teamId: item.teamId || item.id,
|
teamId: item.id,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
bindData: JSON.stringify(item.bindLineTree),
|
bindData: JSON.stringify(item.bindLineTree),
|
||||||
};
|
};
|
||||||
@@ -826,14 +756,10 @@ export default {
|
|||||||
});
|
});
|
||||||
checkPlan(data).then((RES) => {
|
checkPlan(data).then((RES) => {
|
||||||
createStepFour(this.dataForm.id).then((res) => {
|
createStepFour(this.dataForm.id).then((res) => {
|
||||||
if (res.code === 200 || res.code === 0) {
|
this.$modal.msgSuccess('创建计划成功');
|
||||||
this.$modal.msgSuccess('创建计划成功');
|
this.stepNum = 1;
|
||||||
this.stepNum = 1;
|
this.$emit('setSN', this.stepNum);
|
||||||
this.$emit('setSN', this.stepNum);
|
this.$emit('refreshDataList');
|
||||||
this.$emit('refreshDataList');
|
|
||||||
} else {
|
|
||||||
this.$message(res.msg);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -848,7 +774,7 @@ export default {
|
|||||||
setDataForm() {
|
setDataForm() {
|
||||||
this.$refs.deptSelect.setID(this.dataForm.deptId);
|
this.$refs.deptSelect.setID(this.dataForm.deptId);
|
||||||
},
|
},
|
||||||
//比较时间,开始时间在结束时间前
|
//比较时间,开始时间在结束时间前
|
||||||
compareDates(date1, date2) {
|
compareDates(date1, date2) {
|
||||||
const d1 = date1;
|
const d1 = date1;
|
||||||
const d2 = date2;
|
const d2 = date2;
|
||||||
@@ -867,156 +793,54 @@ 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',
|
||||||
daySpan: 0, //是否跨天
|
daySpan: 0, //是否跨天
|
||||||
code: 1, //排版日历页面,根据这个字段显示颜色
|
code: 1, //排版日历页面,根据这个字段显示颜色
|
||||||
};
|
};
|
||||||
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',
|
||||||
daySpan: 0,
|
daySpan: 0,
|
||||||
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',
|
||||||
daySpan: 1,
|
daySpan: 1,
|
||||||
code: 3,
|
code: 3,
|
||||||
};
|
};
|
||||||
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',
|
||||||
daySpan: 0,
|
daySpan: 0,
|
||||||
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',
|
||||||
daySpan: 1,
|
daySpan: 1,
|
||||||
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',
|
||||||
daySpan: 0,
|
daySpan: 0,
|
||||||
code: 3,
|
code: 3,
|
||||||
};
|
};
|
||||||
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;
|
||||||
@@ -1035,37 +859,11 @@ 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() {
|
||||||
@@ -1088,58 +886,6 @@ 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) {
|
||||||
@@ -1148,45 +894,23 @@ export default {
|
|||||||
},
|
},
|
||||||
refreshTableData3(index, val) {
|
refreshTableData3(index, val) {
|
||||||
this.tableData2[index].bindLineTree = val;
|
this.tableData2[index].bindLineTree = val;
|
||||||
let lineName = this.setLineName(val);
|
let lineName = '';
|
||||||
|
lineName = this.setLineName(val, lineName);
|
||||||
if (lineName) {
|
if (lineName) {
|
||||||
this.$set(this.tableData2[index], 'lineName', lineName.join(';'));
|
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
|
||||||
}
|
}
|
||||||
this.cancel3();
|
this.cancel3();
|
||||||
},
|
},
|
||||||
//提取绑定的产线工段名展示出来
|
//提取绑定的产线工段名展示出来
|
||||||
setLineName(data) {
|
setLineName(val, lineName) {
|
||||||
const paths = [];
|
val.forEach((item) => {
|
||||||
|
lineName += item.name + ':';
|
||||||
const processNode = (node, currentPath = []) => {
|
if (item.children && item.children.length > 0) {
|
||||||
const newPath = [...currentPath, node.name];
|
const childName = this.setLineName(item.children, lineName);
|
||||||
|
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 {
|
|
||||||
// 没有子节点的节点(如原片产线1),用括号显示
|
|
||||||
paths.push(`${currentPath.join('/')}/(${node.name})`);
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
data.forEach((node) => processNode(node));
|
return lineName;
|
||||||
return paths;
|
|
||||||
},
|
},
|
||||||
//第三步
|
//第三步
|
||||||
// 进来加载预览排班
|
// 进来加载预览排班
|
||||||
@@ -1195,7 +919,6 @@ 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) => {
|
||||||
@@ -1223,7 +946,6 @@ 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) => {
|
||||||
@@ -1248,8 +970,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelStep() {
|
cancelStep() {
|
||||||
if (this.stepNum > 1 && !this.isEdit) {
|
if (this.stepNum > 1) {
|
||||||
//编辑的时候,让前端上一步和取消都不用接口,
|
|
||||||
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-11-25 15:49:17
|
* @LastEditTime: 2025-10-30 10:47:09
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -13,12 +13,8 @@
|
|||||||
:to_data="toData"
|
:to_data="toData"
|
||||||
@add-btn="add"
|
@add-btn="add"
|
||||||
@remove-btn="remove"
|
@remove-btn="remove"
|
||||||
pid="fid"
|
pid="pid"
|
||||||
:node_key="'uniqueId'"
|
:defaultProps="{ label: 'name' }"
|
||||||
:defaultProps="{
|
|
||||||
label: 'name',
|
|
||||||
children: 'children',
|
|
||||||
}"
|
|
||||||
height="450px"
|
height="450px"
|
||||||
style="padding-bottom: 20px"
|
style="padding-bottom: 20px"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
@@ -47,34 +43,16 @@ export default {
|
|||||||
this.fromData = [];
|
this.fromData = [];
|
||||||
this.toData = [];
|
this.toData = [];
|
||||||
getGroupPlanTree().then((res) => {
|
getGroupPlanTree().then((res) => {
|
||||||
res.data.forEach((item) => {
|
this.fromData = res.data;
|
||||||
|
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-11-25 15:14:53
|
* @LastEditTime: 2025-10-21 15:02:27
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="title">创建人:</span>
|
<span class="title">创建人:</span>
|
||||||
{{ infoData.creatorName }}
|
{{ infoData.creator }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="title">创建时间:</span>
|
<span class="title">创建时间:</span>
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
:limit="10"
|
:limit="10"
|
||||||
:table-data="tableData1"></base-table>
|
:table-data="tableData1"></base-table>
|
||||||
<base-table
|
<base-table
|
||||||
v-else
|
v-else
|
||||||
:table-props="tableProps2"
|
:table-props="tableProps2"
|
||||||
:page="1"
|
:page="1"
|
||||||
:limit="10"
|
:limit="10"
|
||||||
@@ -150,45 +150,26 @@ export default {
|
|||||||
this.infoData = {};
|
this.infoData = {};
|
||||||
getPlan(id).then((res) => {
|
getPlan(id).then((res) => {
|
||||||
this.infoData = res.data || {};
|
this.infoData = res.data || {};
|
||||||
this.tableData1 = res.data?.groupPlanClassesBaseVOList.sort(
|
console.log(res);
|
||||||
(a, b) => a.sort - b.sort
|
this.tableData1 = res.data?.groupPlanClassesBaseVOList;
|
||||||
);
|
|
||||||
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
|
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
|
||||||
this.tableData2.forEach((item, index) => {
|
this.tableData2.forEach((item, index) => {
|
||||||
let lineName = '';
|
let lineName = '';
|
||||||
if (item.isProduction) {
|
lineName = this.setLineName(item.bindLineTree, lineName);
|
||||||
lineName = this.setLineName(item.bindLineTree);
|
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
|
||||||
}
|
|
||||||
this.$set(this.tableData2[index], 'lineName', lineName);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//提取绑定的产线工段名展示出来
|
//提取绑定的产线工段名展示出来
|
||||||
setLineName(val) {
|
setLineName(val, lineName) {
|
||||||
if (!val || val.length === 0) return '';
|
val.forEach((item) => {
|
||||||
|
lineName += item.name + ':';
|
||||||
const currentLevelNames = val.map((item) => item.name);
|
if (item.children && item.children.length > 0) {
|
||||||
|
const childName = this.setLineName(item.children, lineName);
|
||||||
// 处理当前层级显示
|
lineName = childName;
|
||||||
let currentDisplay = '';
|
|
||||||
if (currentLevelNames.length > 1) {
|
|
||||||
currentDisplay = `(${currentLevelNames.join(' 、 ')})`;
|
|
||||||
} else {
|
|
||||||
currentDisplay = currentLevelNames[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查找所有子节点(取第一个有子节点的元素)
|
|
||||||
const childNode = val.find(
|
|
||||||
(item) => item.children && item.children.length > 0
|
|
||||||
);
|
|
||||||
if (childNode) {
|
|
||||||
const childPath = this.setLineName(childNode.children);
|
|
||||||
if (childPath) {
|
|
||||||
return `${currentDisplay} / ${childPath}`;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
return lineName;
|
||||||
return currentDisplay;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2021-11-18 14:16:25
|
* @Date: 2021-11-18 14:16:25
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-11-04 14:08:47
|
* @LastEditTime: 2025-10-20 10:23:52
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -15,10 +15,9 @@
|
|||||||
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="sort">
|
<el-form-item label="序号" prop="index">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
style="width: 100%"
|
v-model="dataForm.index"
|
||||||
v-model="dataForm.sort"
|
|
||||||
:step="1"
|
:step="1"
|
||||||
:min="1"
|
:min="1"
|
||||||
step-strictly />
|
step-strictly />
|
||||||
@@ -39,8 +38,7 @@
|
|||||||
format="H:mm"
|
format="H:mm"
|
||||||
value-format="HH:mm:ss"
|
value-format="HH:mm:ss"
|
||||||
v-model="dataForm.startTime"
|
v-model="dataForm.startTime"
|
||||||
@change="timeFun('start')"
|
placeholder="选择日期时间"></el-time-picker>
|
||||||
placeholder="选择时间"></el-time-picker>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
@@ -50,19 +48,7 @@
|
|||||||
format="H:mm"
|
format="H:mm"
|
||||||
value-format="HH:mm:ss"
|
value-format="HH:mm:ss"
|
||||||
v-model="dataForm.endTime"
|
v-model="dataForm.endTime"
|
||||||
@change="timeFun('end')"
|
placeholder="选择日期时间"></el-time-picker>
|
||||||
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">
|
||||||
@@ -84,17 +70,15 @@ export default {
|
|||||||
return {
|
return {
|
||||||
dataForm: {
|
dataForm: {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
sort: undefined,
|
index: 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: {
|
||||||
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
|
index: [{ required: true, message: '序号不能为空', trigger: 'blur' }],
|
||||||
name: [
|
name: [
|
||||||
{ required: true, message: '班次名称不能为空', trigger: 'blur' },
|
{ required: true, message: '班次名称不能为空', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
@@ -109,31 +93,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init(val) {
|
init(val) {
|
||||||
this._pageIndex = val._pageIndex - 1;
|
this._pageIndex = val._pageIndex-1;
|
||||||
this.dataForm.sort = val._pageIndex || 1;
|
this.dataForm.index = 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() {
|
||||||
this.$refs['dataForm'].validate((valid) => {
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<!--
|
<!--
|
||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-13 15:07:24
|
* @Date: 2025-10-11 14:27:37
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-11-28 09:56:09
|
* @LastEditTime: 2025-10-29 14:50:16
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -31,17 +31,13 @@
|
|||||||
<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">
|
||||||
@@ -50,12 +46,8 @@
|
|||||||
ref="deptSelect"
|
ref="deptSelect"
|
||||||
@DeptId="setDeptId"></dept-select>
|
@DeptId="setDeptId"></dept-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="leaderName">
|
||||||
<el-select
|
<el-select v-model="formInline.status" placeholder="请选择状态">
|
||||||
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"
|
||||||
@@ -73,8 +65,7 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<span
|
<span class="separateStyle"
|
||||||
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>
|
||||||
@@ -83,8 +74,7 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<span
|
<span class="separateStyle"
|
||||||
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>
|
||||||
@@ -97,17 +87,6 @@
|
|||||||
新增
|
新增
|
||||||
</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
|
||||||
@@ -222,7 +201,6 @@ import {
|
|||||||
copyPlan,
|
copyPlan,
|
||||||
disablePlan,
|
disablePlan,
|
||||||
updateScheduleLater,
|
updateScheduleLater,
|
||||||
exportExcel,
|
|
||||||
} from '@/api/group/Schedule';
|
} from '@/api/group/Schedule';
|
||||||
|
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
@@ -290,97 +268,91 @@ 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: {
|
||||||
type: '&',
|
type: '&',
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
type: 'equal',
|
type: 'equal',
|
||||||
name: 'status',
|
name: 'status',
|
||||||
value: 1,
|
value: 1,
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
],
|
||||||
: undefined,
|
},
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:delete')
|
}:undefined,
|
||||||
? {
|
this.$auth.hasPermi('base:group-scheduling-plan:delete')?
|
||||||
type: 'delete',
|
{
|
||||||
btnName: '删除',
|
type: 'delete',
|
||||||
showParam: {
|
btnName: '删除',
|
||||||
type: '&',
|
showParam: {
|
||||||
data: [
|
type: '&',
|
||||||
{
|
data: [
|
||||||
type: 'equal',
|
{
|
||||||
name: 'status',
|
type: 'equal',
|
||||||
value: 1,
|
name: 'status',
|
||||||
},
|
value: 1,
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
],
|
||||||
: undefined,
|
},
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:query')
|
}:undefined,
|
||||||
? {
|
this.$auth.hasPermi('base:group-scheduling-plan:query')?
|
||||||
type: 'detail',
|
{
|
||||||
btnName: '查看',
|
type: 'detail',
|
||||||
showParam: {
|
btnName: '查看',
|
||||||
type: '&',
|
showParam: {
|
||||||
data: [
|
type: '&',
|
||||||
{
|
data: [
|
||||||
type: 'unequal',
|
{
|
||||||
name: 'status',
|
type: 'unequal',
|
||||||
value: 1,
|
name: 'status',
|
||||||
},
|
value: 1,
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
],
|
||||||
: undefined,
|
},
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:delete')
|
}:undefined,
|
||||||
? {
|
this.$auth.hasPermi('base:group-scheduling-plan:delete')?
|
||||||
type: 'cancel',
|
{
|
||||||
btnName: '作废',
|
type: 'cancel',
|
||||||
showParam: {
|
btnName: '作废',
|
||||||
type: '&',
|
showParam: {
|
||||||
data: [
|
type: '&',
|
||||||
{
|
data: [
|
||||||
type: 'equal',
|
{
|
||||||
name: 'status',
|
type: 'equal',
|
||||||
value: 2,
|
name: 'status',
|
||||||
},
|
value: 2,
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
],
|
||||||
: undefined,
|
},
|
||||||
this.$auth.hasPermi('base:group-holiday:update')
|
}:undefined,
|
||||||
? {
|
this.$auth.hasPermi('base:group-holiday:update')?
|
||||||
type: 'sync',
|
{
|
||||||
btnName: '同步节假日',
|
type: 'sync',
|
||||||
showParam: {
|
btnName: '同步节假日',
|
||||||
type: '&',
|
showParam: {
|
||||||
data: [
|
type: '&',
|
||||||
{
|
data: [
|
||||||
type: 'equal',
|
{
|
||||||
name: 'status',
|
type: 'equal',
|
||||||
value: 2,
|
name: 'status',
|
||||||
},
|
value: 2,
|
||||||
{
|
|
||||||
type: 'equal',
|
|
||||||
name: 'updateFlag',
|
|
||||||
value: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
: undefined,
|
type: 'equal',
|
||||||
this.$auth.hasPermi('base:group-scheduling-plan:create')
|
name: 'updateFlag',
|
||||||
? {
|
value: true,
|
||||||
type: 'copy',
|
},
|
||||||
btnName: '复制',
|
],
|
||||||
}
|
},
|
||||||
: undefined,
|
}:undefined,
|
||||||
|
this.$auth.hasPermi('base:group-scheduling-plan:create')?
|
||||||
|
{
|
||||||
|
type: 'copy',
|
||||||
|
btnName: '复制',
|
||||||
|
}:undefined,
|
||||||
].filter((v) => v),
|
].filter((v) => v),
|
||||||
tableData: [],
|
tableData: [],
|
||||||
options: [
|
options: [
|
||||||
@@ -398,52 +370,50 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
formInline: {
|
formInline: {
|
||||||
code: null,
|
code: '',
|
||||||
name: null,
|
name: '',
|
||||||
startDay: null,
|
startDay: '',
|
||||||
endDay: null,
|
endDay: '',
|
||||||
deptId: null,
|
deptId: '',
|
||||||
status: null,
|
status: '',
|
||||||
},
|
},
|
||||||
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':
|
||||||
if (this.formInline.startDay > this.formInline.endDay) {
|
const date1 = new Date(this.formInline.startDay).getTime();
|
||||||
|
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: 20,
|
pageSize: 10,
|
||||||
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.status = null;
|
this.formInline.leaderName = null;
|
||||||
this.formInline.startDay = null;
|
|
||||||
this.formInline.endDay = null;
|
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 20,
|
pageSize: 10,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
};
|
};
|
||||||
@@ -492,8 +462,7 @@ export default {
|
|||||||
this.addOrUpdateVisible = true;
|
this.addOrUpdateVisible = true;
|
||||||
this.addOrEditTitle = '编辑';
|
this.addOrEditTitle = '编辑';
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.stepNum = 3;
|
this.$refs.addOrUpdate.init(val.data.id);
|
||||||
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);
|
||||||
@@ -505,62 +474,23 @@ 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') {
|
||||||
this.$confirm(
|
updateScheduleLater({ planId: val.data.id }).then((res) => {
|
||||||
'当前节假日包含尚未同步的节假日变更,是否立即将上述节假日同步更新到排班计划?',
|
this.$modal.msgSuccess('同步节假日成功');
|
||||||
'同步节假日',
|
this.getDataList()
|
||||||
{
|
});
|
||||||
confirmButtonText: '确认同步',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
updateScheduleLater({
|
|
||||||
planId: val.data.id,
|
|
||||||
logId: val.data.updateLogId,
|
|
||||||
}).then((res) => {
|
|
||||||
this.$modal.msgSuccess('同步节假日成功');
|
|
||||||
this.getDataList();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((res) => {
|
|
||||||
this.getDataList();
|
|
||||||
this.$message({
|
|
||||||
type: 'info',
|
|
||||||
message: '已取消',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else if (val.type === 'copy') {
|
} 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>
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
<!--
|
|
||||||
* @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-11-04 10:54:19
|
* @LastEditTime: 2025-10-20 10:13:26
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<span>
|
<span>
|
||||||
{{
|
{{
|
||||||
(injectData.shiftSustainedNum?injectData.shiftSustainedNum:'') +
|
injectData.shiftSustainedNum +
|
||||||
(injectData.shiftSustainedType
|
(injectData.shiftSustainedType
|
||||||
? ['', '日', '周', '月', '季'][injectData.shiftSustainedType]
|
? ['', '日', '周', '月', '季'][injectData.shiftSustainedType]
|
||||||
: '')
|
: '')
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ 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-11-27 14:49:34
|
* @LastEditTime: 2025-10-29 14:47:33
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -25,18 +25,16 @@
|
|||||||
<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="部门" prop="deptId">
|
<el-form-item label="部门">
|
||||||
<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>
|
||||||
@@ -46,7 +44,7 @@
|
|||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
v-model="dataForm.leaderId"
|
v-model="dataForm.leaderId"
|
||||||
@change="setLeaderName"
|
@change="setLeaderName"
|
||||||
filterable
|
filterable
|
||||||
placeholder="请选择组长">
|
placeholder="请选择组长">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in leaderArr"
|
v-for="item in leaderArr"
|
||||||
@@ -61,7 +59,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model="dataForm.leaderPhone"
|
v-model="dataForm.leaderPhone"
|
||||||
clearable
|
clearable
|
||||||
maxlength="11"
|
maxlength="11"
|
||||||
placeholder="请输入组长电话" />
|
placeholder="请输入组长电话" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -79,7 +77,6 @@
|
|||||||
<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
|
||||||
@@ -111,7 +108,6 @@ import {
|
|||||||
updateGroup,
|
updateGroup,
|
||||||
getGroup,
|
getGroup,
|
||||||
getCode,
|
getCode,
|
||||||
updateIsProduction,
|
|
||||||
} from '@/api/group/groupSetting';
|
} from '@/api/group/groupSetting';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -141,8 +137,7 @@ export default {
|
|||||||
num: undefined,
|
num: undefined,
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
},
|
},
|
||||||
setData: true,
|
setData: true,
|
||||||
nameDisable: false, //班组被使用时,班组名称不能修改
|
|
||||||
leaderArr: [],
|
leaderArr: [],
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
@@ -161,21 +156,19 @@ 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' },
|
||||||
],
|
],
|
||||||
isProduction: [
|
isProduction: [
|
||||||
{ required: true, message: '生产班组不能为空', trigger: 'change' },
|
{ required: true, message: '生产班组不能为空', trigger: 'change' },
|
||||||
],
|
],
|
||||||
leaderPhone: [
|
leaderPhone: [
|
||||||
{
|
{
|
||||||
pattern:
|
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}$/,
|
||||||
/^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
|
message: "请输入正确的手机号码",
|
||||||
message: '请输入正确的手机号码',
|
trigger: "blur"
|
||||||
trigger: 'blur',
|
}
|
||||||
},
|
]
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -191,43 +184,9 @@ 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) => {
|
||||||
if (val === item.id) {
|
if (val === item.id) {
|
||||||
@@ -235,33 +194,33 @@ 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");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,21 +1,14 @@
|
|||||||
<!--
|
|
||||||
* @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="injectData.enabled"
|
v-model="list.enabled"
|
||||||
:active-value="1"
|
:active-value="1"
|
||||||
:inactive-value="0"></el-switch>
|
:inactive-value="0"></el-switch>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { updateGroup, updateIsProduction } from '@/api/group/groupSetting';
|
import { updateGroup } from '@/api/group/groupSetting';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
injectData: {
|
injectData: {
|
||||||
@@ -24,51 +17,17 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {};
|
return {
|
||||||
|
list: this.injectData,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
changeStatus(val) {
|
changeStatus(val) {
|
||||||
const pdata = { ...this.injectData, enabled: val };
|
const data = { ...this.injectData, enabled: val };
|
||||||
updateIsProduction(this.injectData.id).then(({ data }) => {
|
updateGroup(data).then((res) => {
|
||||||
if (data) {
|
this.$modal.msgSuccess('修改成功');
|
||||||
this.$confirm(
|
this.$emit('emitData');
|
||||||
'当前班组仍参与排班计划或正在执行工单。<br/>修改<strong> 班组状态 </strong>不会自动更新排班内容,可能导致排班信息与班组属性不一致,请注意核查!<br/>是否确认修改班组状态?',
|
|
||||||
'更新班组状态',
|
|
||||||
{
|
|
||||||
dangerouslyUseHTMLString: true,
|
|
||||||
confirmButtonText: '确认修改',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
updateGroup(pdata).then((res) => {
|
|
||||||
if (res.code === 0 || res.code === 200) {
|
|
||||||
this.$modal.msgSuccess('修改成功');
|
|
||||||
this.$emit('emitData');
|
|
||||||
} else {
|
|
||||||
this.$modal.msg(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((res) => {
|
|
||||||
this.$emit('emitData');
|
|
||||||
this.$message({
|
|
||||||
type: 'info',
|
|
||||||
message: '已取消',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
updateGroup(pdata).then((res) => {
|
|
||||||
if (res.code === 0 || res.code === 200) {
|
|
||||||
this.$modal.msgSuccess('修改成功');
|
|
||||||
this.$emit('emitData');
|
|
||||||
} else {
|
|
||||||
this.$modal.msg(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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-11-14 21:50:40
|
* @LastEditTime: 2025-10-29 14:44:41
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -212,7 +212,7 @@ export default {
|
|||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 20,
|
pageSize: 10,
|
||||||
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: 20,
|
pageSize: 10,
|
||||||
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-12-11 10:47:50
|
* @LastEditTime: 2025-10-23 13:29:58
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
<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"
|
||||||
@@ -55,7 +54,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="dataForm.dateType == 1 && dataForm.calendarType == 1"
|
v-if="dataForm.dateType == 1"
|
||||||
label="日期"
|
label="日期"
|
||||||
prop="dateDay">
|
prop="dateDay">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
@@ -66,14 +65,10 @@
|
|||||||
type="date"
|
type="date"
|
||||||
placeholder="选择日期"
|
placeholder="选择日期"
|
||||||
format="yyyy-MM-dd"
|
format="yyyy-MM-dd"
|
||||||
value-format="yyyy-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
|
<el-form-item v-else label="日期" prop="dateDayArr">
|
||||||
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%"
|
||||||
@@ -81,57 +76,12 @@
|
|||||||
v-model="dataForm.dateDayArr"
|
v-model="dataForm.dateDayArr"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
format="yyyy-MM-dd"
|
format="yyyy-MM-dd"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="--MM-dd"
|
||||||
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">
|
||||||
@@ -181,7 +131,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import JDatePicker from './components/JDatePicker.vue';
|
|
||||||
import {
|
import {
|
||||||
createHoliday,
|
createHoliday,
|
||||||
updateHoliday,
|
updateHoliday,
|
||||||
@@ -192,9 +141,7 @@ import {
|
|||||||
} from '@/api/group/holidaySetting';
|
} from '@/api/group/holidaySetting';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {},
|
||||||
JDatePicker,
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dataForm: {
|
dataForm: {
|
||||||
@@ -204,16 +151,11 @@ 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,
|
||||||
@@ -260,12 +202,6 @@ 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,
|
||||||
@@ -280,131 +216,49 @@ 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, val, detail, inherited) {
|
init(deptId, id, detail) {
|
||||||
this.dataForm.deptId = deptId || undefined;
|
this.dataForm.deptId = deptId || undefined;
|
||||||
this.dataForm.id = val.holidayId || undefined;
|
this.dataForm.id = id || 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) {
|
||||||
getHoliday(this.dataForm.id).then((res) => {
|
getHoliday(this.dataForm.id).then((res) => {
|
||||||
//设置年份,不重复的直接用返回的年份,重复的直接用当年年份
|
|
||||||
let year = new Date().getFullYear();
|
|
||||||
if (res.data.calendarType == 1 && !res.data.repeat) {
|
|
||||||
year = res.data.noRepeatYear;
|
|
||||||
} else if (res.data.calendarType == 2 && !res.data.repeat) {
|
|
||||||
year = res.data.noRepeatYearChinese;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dataForm = res.data;
|
this.dataForm = res.data;
|
||||||
if (
|
if (
|
||||||
this.dataForm.dateType == 1 &&
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.calendarType == 1
|
this.dataForm.calendarType == 1
|
||||||
) {
|
) {
|
||||||
this.dataForm.dateDay =
|
this.dataForm.dateDay = this.dataForm.oneDay;
|
||||||
year + '-' + this.dataForm.oneDay.slice(-5);
|
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 1
|
this.dataForm.calendarType == 1
|
||||||
) {
|
) {
|
||||||
let num = this.compareMonthDay(
|
|
||||||
this.dataForm.startDay.slice(-5),
|
|
||||||
this.dataForm.endDay.slice(-5)
|
|
||||||
);
|
|
||||||
this.dataForm.dateDayArr = [
|
this.dataForm.dateDayArr = [
|
||||||
year + '-' + this.dataForm.startDay.slice(-5),
|
this.dataForm.startDay,
|
||||||
(num > 0 ? year : year + 1) +
|
this.dataForm.endDay,
|
||||||
'-' +
|
|
||||||
this.dataForm.endDay.slice(-5),
|
|
||||||
];
|
];
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 1 &&
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
this.dataForm.dateDayChinese =
|
this.dataForm.dateDay = this.dataForm.oneDayChinese;
|
||||||
'L' + year + this.dataForm.oneDayChinese.slice(-6);
|
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
let num = this.compareMonthDay(
|
this.dataForm.dateDayArr = [
|
||||||
this.dataForm.startDayChinese.slice(-6),
|
this.dataForm.startDayChinese,
|
||||||
this.dataForm.endDayChinese.slice(-6)
|
this.dataForm.endDayChinese,
|
||||||
);
|
|
||||||
this.dataForm.dateDayArrChinese = [
|
|
||||||
'L' + year + this.dataForm.startDayChinese.slice(-6),
|
|
||||||
'L' +
|
|
||||||
(num > 0 ? year : year + 1) +
|
|
||||||
+this.dataForm.endDayChinese.slice(-6),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//用于比较日期大小,判断年份是否要加1
|
|
||||||
compareMonthDay(dateStr1, dateStr2) {
|
|
||||||
const [month1, day1] = dateStr1.split('-').map(Number);
|
|
||||||
const [month2, day2] = dateStr2.split('-').map(Number);
|
|
||||||
|
|
||||||
if (month1 !== month2) {
|
|
||||||
return month2 - month1;
|
|
||||||
}
|
|
||||||
return day2 - day1;
|
|
||||||
},
|
|
||||||
editHoliday() {
|
editHoliday() {
|
||||||
this.detail = false;
|
this.detail = false;
|
||||||
},
|
},
|
||||||
@@ -453,13 +307,10 @@ 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() {
|
||||||
this.$refs['dataForm'].validate((valid) => {
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
@@ -467,133 +318,61 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
|
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
|
||||||
const [year, month, day] = this.dataForm.dateDay.split('-');
|
this.dataForm.oneDay = this.dataForm.dateDay;
|
||||||
this.dataForm.oneDay = `--${month}-${day}`;
|
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 1
|
this.dataForm.calendarType == 1
|
||||||
) {
|
) {
|
||||||
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
|
this.dataForm.startDay = this.dataForm.dateDayArr[0];
|
||||||
this.dataForm.startDay = `--${month}-${day}`;
|
this.dataForm.endDay = this.dataForm.dateDayArr[1];
|
||||||
const [year1, month1, day1] = this.dataForm.dateDayArr[1].split('-');
|
|
||||||
this.dataForm.endDay = `--${month1}-${day1}`;
|
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 1 &&
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
this.dataForm.oneDayChinese =
|
this.dataForm.oneDayChinese = this.dataForm.dateDay;
|
||||||
'--' + 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.startDayChinese = this.dataForm.dateDayArr[0];
|
||||||
'--' + this.dataForm.dateDayArrChinese[0].slice(-5);
|
this.dataForm.endDayChinese = this.dataForm.dateDayArr[1];
|
||||||
this.dataForm.endDayChinese =
|
|
||||||
'--' + this.dataForm.dateDayArrChinese[1].slice(-5);
|
|
||||||
}
|
|
||||||
//是否每年重复,不重复的话需要传 年份
|
|
||||||
if (
|
|
||||||
this.dataForm.dateType == 1 &&
|
|
||||||
this.dataForm.calendarType == 1 &&
|
|
||||||
!this.dataForm.repeat
|
|
||||||
) {
|
|
||||||
const [year, month, day] = this.dataForm.dateDay.split('-');
|
|
||||||
this.dataForm.noRepeatYear = year;
|
|
||||||
} else if (
|
|
||||||
this.dataForm.dateType == 2 &&
|
|
||||||
this.dataForm.calendarType == 1 &&
|
|
||||||
!this.dataForm.repeat
|
|
||||||
) {
|
|
||||||
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
|
|
||||||
this.dataForm.noRepeatYear = year;
|
|
||||||
} else if (
|
|
||||||
this.dataForm.dateType == 1 &&
|
|
||||||
this.dataForm.calendarType == 2 &&
|
|
||||||
!this.dataForm.repeat
|
|
||||||
) {
|
|
||||||
this.dataForm.noRepeatYearChinese =
|
|
||||||
this.dataForm.dateDayChinese.slice(1, 5);
|
|
||||||
} else if (
|
|
||||||
this.dataForm.dateType == 2 &&
|
|
||||||
this.dataForm.calendarType == 2 &&
|
|
||||||
!this.dataForm.repeat
|
|
||||||
) {
|
|
||||||
this.dataForm.noRepeatYearChinese =
|
|
||||||
this.dataForm.dateDayArrChinese[0].slice(1, 5);
|
|
||||||
}
|
}
|
||||||
// 修改的提交
|
// 修改的提交
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
if (!this.inherited) {
|
updateHoliday(this.dataForm).then((response) => {
|
||||||
this.dataForm.inherited = false;
|
this.$modal.msgSuccess('修改成功');
|
||||||
}
|
this.$emit('refreshPage');
|
||||||
updateHoliday(this.dataForm).then((res) => {
|
|
||||||
if (res.code === 0 || res.code === 200) {
|
|
||||||
if (!res.data.updateFlag) {
|
|
||||||
this.$modal.msgSuccess('修改成功');
|
|
||||||
this.$emit('refreshPage');
|
|
||||||
} else {
|
|
||||||
this.$confirm(
|
|
||||||
'新增节假日影响已有排班计划,是否立即更新?',
|
|
||||||
'更新排班',
|
|
||||||
{
|
|
||||||
confirmButtonText: '立即更新',
|
|
||||||
cancelButtonText: '暂不更新',
|
|
||||||
type: 'warning',
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
|
||||||
this.$modal.msgSuccess('更新成功');
|
|
||||||
});
|
|
||||||
this.$emit('refreshPage');
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
|
||||||
type: 'info',
|
|
||||||
message: '已取消',
|
|
||||||
});
|
|
||||||
this.$emit('refreshPage');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.$modal.msg(res.msg);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 添加的提交
|
// 添加的提交
|
||||||
createHoliday(this.dataForm).then((res) => {
|
createHoliday(this.dataForm).then((res) => {
|
||||||
if (res.code === 0 || res.code === 200) {
|
updateSchedule;
|
||||||
if (!res.data.updateFlag) {
|
if (!res.data.updateFlag) {
|
||||||
this.$modal.msgSuccess('新增成功');
|
this.$modal.msgSuccess('新增成功');
|
||||||
this.$emit('refreshPage');
|
this.$emit('refreshPage');
|
||||||
} else {
|
} else {
|
||||||
this.$confirm(
|
this.$confirm(
|
||||||
'新增节假日影响已有排班计划,是否立即更新?',
|
'新增节假日影响已有排班计划,是否立即更新?',
|
||||||
'更新排班',
|
'更新排班',
|
||||||
{
|
{
|
||||||
confirmButtonText: '立即更新',
|
confirmButtonText: '立即更新',
|
||||||
cancelButtonText: '暂不更新',
|
cancelButtonText: '暂不更新',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.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');
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
|
||||||
type: 'info',
|
|
||||||
message: '已取消',
|
|
||||||
});
|
|
||||||
this.$emit('refreshPage');
|
this.$emit('refreshPage');
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
} else {
|
.catch(() => {
|
||||||
this.$modal.msg(res.msg);
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,735 +0,0 @@
|
|||||||
<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>
|
|
||||||