Compare commits
30 Commits
0e76fe7dbf
...
projects/l
| Author | SHA1 | Date | |
|---|---|---|---|
| 00393f76c7 | |||
|
|
35fb0d8bfb | ||
|
|
0c52306cc6 | ||
| a5fba28ff7 | |||
|
|
1f8b994218 | ||
|
|
ccfa73f3bc | ||
|
|
89ff79bfd7 | ||
| 70a0fbb170 | |||
|
|
c86d94ac92 | ||
|
|
484ba6ca53 | ||
|
|
f403375594 | ||
| 1cd0b13aae | |||
|
|
d2b0565cd1 | ||
|
|
7661dc5691 | ||
| 1d698848c2 | |||
|
|
6d367b121c | ||
|
|
e2385cf813 | ||
| 552b1e6d6a | |||
| 4383067eb1 | |||
| f80644e07c | |||
|
|
1e12b653d6 | ||
|
|
b7ba173ca3 | ||
| c203f1e1dd | |||
|
|
ccb925003e | ||
|
|
b9f286005c | ||
| 0e343279ac | |||
| 00ac3dec45 | |||
| a84f765e73 | |||
| ffa0b2e8dd | |||
| 1e6c6c5656 |
6
.env.dev
6
.env.dev
@@ -12,8 +12,10 @@ ENV = 'development'
|
|||||||
VUE_APP_TITLE = 智能监控分析系统
|
VUE_APP_TITLE = 智能监控分析系统
|
||||||
|
|
||||||
# 芋道管理系统/开发环境
|
# 芋道管理系统/开发环境
|
||||||
# VUE_APP_BASE_API = 'http://192.168.8.22:48080'
|
# VUE_APP_BASE_API = 'http://172.16.33.187:48082'
|
||||||
VUE_APP_BASE_API = 'http://172.16.33.65:48082'
|
VUE_APP_BASE_API = 'http://line.kszny.picaiba.com'
|
||||||
|
# VUE_APP_BASE_API = 'http://172.16.32.79:48082'
|
||||||
|
|
||||||
|
|
||||||
# 路由懒加载
|
# 路由懒加载
|
||||||
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
||||||
|
|||||||
@@ -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.0.2",
|
"code-brick-zj": "^1.1.1",
|
||||||
"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,3 +59,34 @@ 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,3 +52,5 @@ export function exportEquipmentTypeExcel(query) {
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,15 @@ export function getPdlAutoReportNewSearchNow(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPdlAutoReportNewSearchLastGroup(data) {
|
||||||
|
return request({
|
||||||
|
url: '/monitoring/production-monitor/getPdlAutoReportNewSearchLastGroup',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
timeout: 60000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 班组自动报表分页
|
// 班组自动报表分页
|
||||||
export function getTeamReportPage(data) {
|
export function getTeamReportPage(data) {
|
||||||
@@ -93,3 +102,17 @@ 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ export function getGroup(id) {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 检查更新-生产班组
|
||||||
|
export function updateIsProduction(id) {
|
||||||
|
return request({
|
||||||
|
url: '/base/group-team/updateIsProduction?id=' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 获得班组基础信息分页
|
// 获得班组基础信息分页
|
||||||
export function getGroupPage(query) {
|
export function getGroupPage(query) {
|
||||||
|
|||||||
56
src/api/monitoring/defectSummary.js
Normal file
56
src/api/monitoring/defectSummary.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 创建能源监控配置
|
||||||
|
export function getDefectSummaryTable(data) {
|
||||||
|
return request({
|
||||||
|
url: '/extend/check-gaozhun-record/defectSummaryTable',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function getTranslucentPage(data) {
|
||||||
|
return request({
|
||||||
|
url: '/monitoring/translucent/page',
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exportTranslucent(data) {
|
||||||
|
return request({
|
||||||
|
url: '/monitoring/translucent/export-excel',
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDefectAnalysis(data) {
|
||||||
|
return request({
|
||||||
|
url: '/extend/check-gaozhun-record/defectAnalysis',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSectionDefect(data) {
|
||||||
|
return request({
|
||||||
|
url: '/extend/check-gaozhun-record/sectionDefect',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function getDefectSummaryChart(data) {
|
||||||
|
return request({
|
||||||
|
url: '/extend/check-gaozhun-record/defectSummaryChart',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function getDefectSummaryDet(data) {
|
||||||
|
return request({
|
||||||
|
url: '/extend/check-gaozhun-record/defectSummaryDet',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
63
src/api/monitoring/qualityIsra.js
Normal file
63
src/api/monitoring/qualityIsra.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* @Author: zhp
|
||||||
|
* @Date: 2023-12-08 15:26:59
|
||||||
|
* @LastEditTime: 2023-12-11 15:21:44
|
||||||
|
* @LastEditors: zhp
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
import request from '@/utils/request'
|
||||||
|
export function getQualityIsraPage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/extend/check-isra-statistics/getIsraData',
|
||||||
|
method: 'get',
|
||||||
|
params: query,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQualityIsraDayMap(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/quality-isra-statistics/dayMap',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQualityIsraWeekMap(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/quality-isra-statistics/weekMap',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQualityIsraMonthMap(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/quality-isra-statistics/monthMap',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQualityIsraDayList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/quality-isra-statistics/dayList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQualityIsraWeekList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/quality-isra-statistics/weekList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQualityIsraMonthList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/base/quality-isra-statistics/monthList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
BIN
src/assets/images/equipmentNum.png
Normal file
BIN
src/assets/images/equipmentNum.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/images/equipmentNumImg.png
Normal file
BIN
src/assets/images/equipmentNumImg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
BIN
src/assets/images/runNum.png
Normal file
BIN
src/assets/images/runNum.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
src/assets/images/runNumImg.png
Normal file
BIN
src/assets/images/runNumImg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
BIN
src/assets/images/stopNum.png
Normal file
BIN
src/assets/images/stopNum.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/images/stopNumImg.png
Normal file
BIN
src/assets/images/stopNumImg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
@@ -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,104 +6,48 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-form
|
<el-form ref="form" :model="form" :label-width="`${labelWidth}px`" :size="size" :label-position="labelPosition"
|
||||||
ref="form"
|
v-loading="formLoading">
|
||||||
:model="form"
|
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
|
||||||
:label-width="`${labelWidth}px`"
|
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
|
||||||
:size="size"
|
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
|
||||||
:label-position="labelPosition"
|
<el-input v-if="col.input" v-model="form[col.prop]" @change="$emit('update', form)"
|
||||||
v-loading="formLoading">
|
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
|
||||||
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
|
<el-input v-if="col.textarea" type="textarea" v-model="form[col.prop]" @change="$emit('update', form)"
|
||||||
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
|
:placeholder="`请输入${col.label}`" v-bind="col.bind" />
|
||||||
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
|
<el-select v-if="col.select" v-model="form[col.prop]" :placeholder="`请选择${col.label}`"
|
||||||
<el-input
|
@change="$emit('update', form)" v-bind="col.bind">
|
||||||
v-if="col.input"
|
<el-option v-for="opt in optionListOf[col.prop]" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||||
v-model="form[col.prop]"
|
</el-select>
|
||||||
@change="$emit('update', form)"
|
<el-date-picker v-if="col.datetime" v-model="form[col.prop]" type="datetime" :placeholder="`请选择${col.label}`"
|
||||||
:placeholder="`请输入${col.label}`"
|
value-format="timestamp" v-bind="col.bind"></el-date-picker>
|
||||||
v-bind="col.bind" />
|
<el-switch v-if="col.switch" v-model="form[col.prop]" active-color="#0b58ff" inactive-color="#e1e1e1"
|
||||||
<el-input
|
v-bind="col.bind" @change="handleSwitchChange(col.prop)"></el-switch>
|
||||||
v-if="col.textarea"
|
<component v-if="col.subcomponent" :key="col.key" :is="col.subcomponent" :inlineStyle="col.style"></component>
|
||||||
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
|
<div class="upload-area" :class="uploadOpen ? '' : 'height-48'" ref="uploadArea" v-if="col.upload">
|
||||||
class="upload-area"
|
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
|
||||||
:class="uploadOpen ? '' : 'height-48'"
|
<el-button type="text" icon="el-icon-arrow-right" @click="handleFilesOpen" />
|
||||||
ref="uploadArea"
|
</span>
|
||||||
v-if="col.upload">
|
<!-- :file-list="uploadedFileList" -->
|
||||||
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
|
<el-upload class="upload-in-dialog" v-if="col.upload" :action="uploadUrl" :headers="uploadHeaders"
|
||||||
<el-button
|
:show-file-list="false" icon="el-icon-upload2" :before-upload="beforeUpload"
|
||||||
type="text"
|
:on-success="handleUploadSuccess" v-bind="col.bind">
|
||||||
icon="el-icon-arrow-right"
|
<el-button size="mini" :disabled="col.bind?.disabled || false">
|
||||||
@click="handleFilesOpen" />
|
<svg-icon icon-class="icon-upload" style="color: inherit"></svg-icon>
|
||||||
</span>
|
上传文件
|
||||||
<!-- :file-list="uploadedFileList" -->
|
</el-button>
|
||||||
<el-upload
|
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
|
||||||
class="upload-in-dialog"
|
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
|
||||||
v-if="col.upload"
|
</div>
|
||||||
:action="uploadUrl"
|
</el-upload>
|
||||||
:headers="uploadHeaders"
|
<uploadedFile class="file" v-for="file in form[col.prop] || []" :file="file" :key="file.fileUrl"
|
||||||
:show-file-list="false"
|
@delete="handleDeleteFile(file)" @Preview="handlePreview(file)" />
|
||||||
icon="el-icon-upload2"
|
</div>
|
||||||
:before-upload="beforeUpload"
|
</el-form-item>
|
||||||
:on-success="handleUploadSuccess"
|
</el-col>
|
||||||
v-bind="col.bind">
|
</el-row>
|
||||||
<el-button size="mini" :disabled="col.bind?.disabled || false">
|
</el-form>
|
||||||
<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>
|
||||||
@@ -134,7 +78,8 @@ const uploadedFile = {
|
|||||||
data() {
|
data() {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
handleDelete() {
|
handleDelete() {
|
||||||
this.$emit('delete', this.file);
|
this.$emit('delete', this.file);
|
||||||
},
|
},
|
||||||
@@ -251,7 +196,12 @@ 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: 10,
|
pageSize: 20,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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,36 +176,38 @@ service.interceptors.response.use(async res => {
|
|||||||
+ '<div>5 分钟搭建本地环境</div>',
|
+ '<div>5 分钟搭建本地环境</div>',
|
||||||
})
|
})
|
||||||
return Promise.reject(new Error(msg))
|
return Promise.reject(new Error(msg))
|
||||||
|
} else if (code === 400) {
|
||||||
|
//【班组管理】【排班计划】提交的校验按照原型图补充完整,排班计划是否重叠code400 有两个不同的返回信息
|
||||||
|
return res.data
|
||||||
} else if (code !== 200) {
|
} else if (code !== 200) {
|
||||||
if (msg === '无效的刷新令牌') { // hard coding:忽略这个提示,直接登出
|
if (msg === '无效的刷新令牌') { // hard coding:忽略这个提示,直接登出
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
} else {
|
} else {
|
||||||
Notification.error({
|
//【班组管理】【排班计划】提交的校验按照原型图补充完整,排班计划是否重叠code400 有两个不同的返回信息
|
||||||
title: msg
|
return res.data
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return Promise.reject('error')
|
return Promise.reject('error')
|
||||||
} else {
|
} else {
|
||||||
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() {
|
||||||
@@ -219,10 +221,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,35 +6,27 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-drawer
|
<el-drawer :visible="visible" :show-close="false" :wrapper-closable="false" class="drawer" custom-class="mes-drawer"
|
||||||
:visible="visible"
|
:size="size || '50%'" @closed="$emit('destroy')">
|
||||||
:show-close="false"
|
<SmallTitle slot="title">
|
||||||
:wrapper-closable="false"
|
{{
|
||||||
class="drawer"
|
mode.includes('detail')
|
||||||
custom-class="mes-drawer"
|
? '详情'
|
||||||
:size="size || '50%'"
|
: mode.includes('edit')
|
||||||
@closed="$emit('destroy')">
|
? '编辑'
|
||||||
<SmallTitle slot="title">
|
: '新增'
|
||||||
{{
|
}}
|
||||||
mode.includes('detail')
|
</SmallTitle>
|
||||||
? '详情'
|
|
||||||
: 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
|
<div class="form-part" v-if="section.key == 'base'"
|
||||||
class="form-part"
|
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
||||||
v-if="section.key == 'base'"
|
<el-skeleton v-if="!showForm" animated />
|
||||||
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
<!-- <BaseInfoForm
|
||||||
<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"
|
||||||
@@ -42,141 +34,87 @@
|
|||||||
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
|
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||||
class="title"
|
设备名
|
||||||
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
</div>
|
||||||
设备名
|
<div class="value" style="font-size: 14px">
|
||||||
</div>
|
{{ form.equipmentName }}
|
||||||
<div class="value" style="font-size: 14px">
|
</div>
|
||||||
{{ form.equipmentName }}
|
</el-col>
|
||||||
</div>
|
<el-col :span="8">
|
||||||
</el-col>
|
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||||
<el-col :span="8">
|
关联表名
|
||||||
<div
|
</div>
|
||||||
class="title"
|
<div class="value" style="font-size: 14px">
|
||||||
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
{{ form.plcName }}
|
||||||
关联表名
|
</div>
|
||||||
</div>
|
</el-col>
|
||||||
<div class="value" style="font-size: 14px">
|
</el-row>
|
||||||
{{ form.plcName }}
|
<!-- else -->
|
||||||
</div>
|
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
||||||
</el-col>
|
<el-form ref="form" :model="form">
|
||||||
</el-row>
|
<el-col :span="8">
|
||||||
<!-- else -->
|
<el-form-item class="title" label="设备名" style="font-size: 16px; margin: 8px 0">
|
||||||
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
<el-select v-model="form.equipmentId" filterable clearable placeholder="请选择设备">
|
||||||
<el-form ref="form" :model="form">
|
<el-option v-for="eq in eqList" :key="eq.id" :label="eq.name" :value="eq.id"></el-option>
|
||||||
<el-col :span="8">
|
</el-select>
|
||||||
<el-form-item
|
</el-form-item>
|
||||||
class="title"
|
</el-col>
|
||||||
label="设备名"
|
<el-col :span="8">
|
||||||
style="font-size: 16px; margin: 8px 0">
|
<el-form-item class="title" label="设备关联表名" style="font-size: 16px; margin: 8px 0">
|
||||||
<el-select
|
<el-select v-model="form.plcId" filterable clearable placeholder="请选择关联表">
|
||||||
v-model="form.equipmentId"
|
<el-option v-for="plc in plcList" :key="plc.id" :label="plc.plcTableName"
|
||||||
filterable
|
:value="plc.id"></el-option>
|
||||||
clearable
|
</el-select>
|
||||||
placeholder="请选择设备">
|
</el-form-item>
|
||||||
<el-option
|
</el-col>
|
||||||
v-for="eq in eqList"
|
</el-form>
|
||||||
:key="eq.id"
|
</el-row>
|
||||||
:label="eq.name"
|
</div>
|
||||||
: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
|
<div v-if="section.key == 'attrs'" style="position: relative; margin-top: 12px">
|
||||||
v-if="section.key == 'attrs'"
|
<div v-if="!mode.includes('detail')" style="position: absolute; top: -40px; right: 0">
|
||||||
style="position: relative; margin-top: 12px">
|
<el-button @click="handleAddAttr" type="text">
|
||||||
<div
|
<i class="el-icon-plus"></i>
|
||||||
v-if="!mode.includes('detail')"
|
添加参数
|
||||||
style="position: absolute; top: -40px; right: 0">
|
</el-button>
|
||||||
<el-button @click="handleAddAttr" type="text">
|
</div>
|
||||||
<i class="el-icon-plus"></i>
|
<base-table v-loading="attrListLoading" :table-props="section.props" :page="attrQuery?.params.pageNo || 1"
|
||||||
添加参数
|
:limit="attrQuery?.params.pageSize || 10" :table-data="list" @emitFun="handleEmitFun">
|
||||||
</el-button>
|
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
|
||||||
</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
|
<method-btn v-if="section.tableBtn && !mode.includes('detail')" slot="handleBtn" label="操作"
|
||||||
v-if="section.tableBtn && !mode.includes('detail')"
|
:method-list="tableBtn" @clickBtn="handleTableBtnClick" />
|
||||||
slot="handleBtn"
|
</base-table>
|
||||||
label="操作"
|
|
||||||
:method-list="tableBtn"
|
|
||||||
@clickBtn="handleTableBtnClick" />
|
|
||||||
</base-table>
|
|
||||||
|
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<pagination
|
<pagination v-show="total > 0" :total="total" :page.sync="attrQuery.params.pageNo"
|
||||||
v-show="total > 0"
|
:limit.sync="attrQuery.params.pageSize" @pagination="getAttrList" />
|
||||||
:total="total"
|
</div>
|
||||||
:page.sync="attrQuery.params.pageNo"
|
</section>
|
||||||
:limit.sync="attrQuery.params.pageSize"
|
</div>
|
||||||
@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
|
<el-button type="primary" v-if="!mode.includes('detail')" @click="handleSave">
|
||||||
type="primary"
|
保存
|
||||||
v-if="!mode.includes('detail')"
|
</el-button>
|
||||||
@click="handleSave">
|
</div>
|
||||||
保存
|
</div>
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 属性对话框 -->
|
<!-- 属性对话框 -->
|
||||||
<base-dialog
|
<base-dialog v-if="sections[1].allowAdd" :dialogTitle="attrTitle" :dialogVisible="attrFormVisible" width="45%"
|
||||||
v-if="sections[1].allowAdd"
|
:append-to-body="true" custom-class="baseDialog" @close="closeAttrForm" @cancel="closeAttrForm"
|
||||||
:dialogTitle="attrTitle"
|
@confirm="submitAttrForm">
|
||||||
:dialogVisible="attrFormVisible"
|
<!-- :disabled="mode.includes('detail')" -->
|
||||||
width="45%"
|
<DialogForm v-if="attrFormVisible" ref="attrForm" v-model="attrForm" :data-form="attrForm"
|
||||||
:append-to-body="true"
|
:rows="attrRows"
|
||||||
custom-class="baseDialog"
|
@update="handleAttrFormUpdate"/>
|
||||||
@close="closeAttrForm"
|
</base-dialog>
|
||||||
@cancel="closeAttrForm"
|
</el-drawer>
|
||||||
@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>
|
||||||
@@ -232,7 +170,9 @@ export default {
|
|||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
description: '',
|
description: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
alarmContent: '',
|
alarmContent: '',
|
||||||
|
displayTip: false,
|
||||||
|
alarmTip: false,
|
||||||
},
|
},
|
||||||
attrFormVisible: false,
|
attrFormVisible: false,
|
||||||
attrRows: [
|
attrRows: [
|
||||||
@@ -342,7 +282,27 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
switch: true,
|
||||||
|
label: '是否展示',
|
||||||
|
prop: 'displayTip',
|
||||||
|
bind: {
|
||||||
|
'active-value': true,
|
||||||
|
'inactive-value': false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
switch: true,
|
||||||
|
label: '超出阈值是否报警',
|
||||||
|
prop: 'alarmTip',
|
||||||
|
bind: {
|
||||||
|
'active-value': true,
|
||||||
|
'inactive-value': false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
input: true,
|
input: true,
|
||||||
@@ -436,7 +396,24 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleAttrFormUpdate(updatedForm) {
|
||||||
|
console.log('updatedForm', updatedForm);
|
||||||
|
|
||||||
|
// 只同步需要的字段,避免覆盖其他数据
|
||||||
|
this.attrForm = {
|
||||||
|
...this.attrForm,
|
||||||
|
...updatedForm,
|
||||||
|
// 确保开关值是布尔类型(双重保险)
|
||||||
|
displayTip: Boolean(updatedForm.displayTip),
|
||||||
|
alarmTip: Boolean(updatedForm.alarmTip),
|
||||||
|
collection: Number(updatedForm.collection) // 采集开关保持数字类型
|
||||||
|
};
|
||||||
|
console.log('开关值同步:', {
|
||||||
|
displayTip: this.attrForm.displayTip,
|
||||||
|
alarmTip: this.attrForm.alarmTip
|
||||||
|
});
|
||||||
|
},
|
||||||
handleTableBtnClick({ type, data }) {
|
handleTableBtnClick({ type, data }) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
@@ -502,7 +479,8 @@ export default {
|
|||||||
name: '',
|
name: '',
|
||||||
plcParamName: '',
|
plcParamName: '',
|
||||||
unit: '',
|
unit: '',
|
||||||
collection: 1,
|
collection: 1,
|
||||||
|
|
||||||
minValue: '',
|
minValue: '',
|
||||||
maxValue: '',
|
maxValue: '',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
@@ -510,7 +488,9 @@ export default {
|
|||||||
remark: '',
|
remark: '',
|
||||||
equipmentParamType: '',
|
equipmentParamType: '',
|
||||||
productionParamType: '',
|
productionParamType: '',
|
||||||
alarmContent: '',
|
alarmContent: '',
|
||||||
|
displayTip: false,
|
||||||
|
alarmTip: false,
|
||||||
};
|
};
|
||||||
this.attrTitle = '添加参数绑定信息';
|
this.attrTitle = '添加参数绑定信息';
|
||||||
this.attrFormVisible = true;
|
this.attrFormVisible = true;
|
||||||
@@ -523,8 +503,15 @@ export default {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
params: { id: attrId },
|
params: { id: attrId },
|
||||||
});
|
});
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.attrForm = res.data;
|
console.log('res.data', res.data);
|
||||||
|
|
||||||
|
this.attrForm = {
|
||||||
|
...res.data,
|
||||||
|
// // 强制转为数字类型,避免字符串类型导致绑定失败
|
||||||
|
// displayTip: Number(res.data.displayTip) || 0,
|
||||||
|
// alarmTip: Number(res.data.alarmTip) || 0
|
||||||
|
};
|
||||||
this.attrTitle = '编辑参数绑定信息';
|
this.attrTitle = '编辑参数绑定信息';
|
||||||
this.attrFormVisible = true;
|
this.attrFormVisible = true;
|
||||||
}
|
}
|
||||||
@@ -563,7 +550,8 @@ 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;
|
||||||
@@ -583,8 +571,9 @@ export default {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 1500,
|
duration: 1500,
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
this.getAttrList();
|
this.shouldRefreshPageView = true;
|
||||||
this.shouldRefreshPageView = true;
|
this.getAttrList();
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,32 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
|
dataFormSubmit() {
|
||||||
|
this.$refs["dataForm"].validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
if (this.dataForm.id) {
|
||||||
|
this.urlOptions.updateURL(this.dataForm).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
this.urlOptions.createURL(this.dataForm).then(response => {
|
||||||
|
if (response.code === 1001033 || response.code === 1001034) {
|
||||||
|
return this.$modal.msgError(response.msg);
|
||||||
|
}
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -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: '',
|
price: undefined,
|
||||||
startTime: new Date().getTime(),
|
startTime: new Date().getTime(),
|
||||||
endTime: null,
|
endTime: null,
|
||||||
remark: '',
|
remark: '',
|
||||||
@@ -140,17 +140,42 @@ 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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
dataFormSubmit() {
|
||||||
|
this.$refs["dataForm"].validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
if (this.dataForm.id) {
|
||||||
|
this.urlOptions.updateURL(this.dataForm).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
this.urlOptions.createURL(this.dataForm).then(response => {
|
||||||
|
// console.log('response',);
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import eqDetail from './eq-detail';
|
import eqDetail from './eq-detail';
|
||||||
import { parseTime } from '../../mixins/code-filter';
|
import { parseTime } from '../../mixins/code-filter';
|
||||||
import { getPdList } from '@/api/core/monitoring/auto';
|
import { getPLlistByFactory } from '@/api/core/monitoring/auto';
|
||||||
import { getNewCTNow, getNewCTCharts } from '@/api/core/analysis/index';
|
import { getNewCTNow, getNewCTCharts } from '@/api/core/analysis/index';
|
||||||
import { getFactoryPage } from '@/api/core/base/factory';
|
import { getFactoryPage } from '@/api/core/base/factory';
|
||||||
// import codeFilter from '../../mixins/code-filter'
|
// import codeFilter from '../../mixins/code-filter'
|
||||||
@@ -134,14 +134,17 @@ export default {
|
|||||||
type: 'select',
|
type: 'select',
|
||||||
label: '工厂',
|
label: '工厂',
|
||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'factoryId',
|
param: 'factoryId',
|
||||||
|
collapseTags: true,
|
||||||
|
multiple: true,
|
||||||
onchange: true,
|
onchange: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '产线',
|
label: '产线',
|
||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'lineId',
|
param: 'lineId',
|
||||||
|
collapseTags: true,
|
||||||
multiple: true,
|
multiple: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -232,9 +235,9 @@ export default {
|
|||||||
return exportTableOut;
|
return exportTableOut;
|
||||||
},
|
},
|
||||||
getPdLineList() {
|
getPdLineList() {
|
||||||
getPdList().then((res) => {
|
// getPLlistByFactory().then((res) => {
|
||||||
this.formConfig[1].selectOptions = res.data || [];
|
// this.formConfig[1].selectOptions = res.data || [];
|
||||||
});
|
// });
|
||||||
const params = {
|
const params = {
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
@@ -274,7 +277,7 @@ export default {
|
|||||||
handleSearchBarChanged({ param, value }) {
|
handleSearchBarChanged({ param, value }) {
|
||||||
this.listQuery.lineId = [];
|
this.listQuery.lineId = [];
|
||||||
this.$refs.searchBarForm.formInline.lineId = undefined;
|
this.$refs.searchBarForm.formInline.lineId = undefined;
|
||||||
getPdList(value).then((res) => {
|
getPLlistByFactory({ factoryIds: this.$refs.searchBarForm.formInline.factoryId }).then((res) => {
|
||||||
this.formConfig[1].selectOptions = res.data || [];
|
this.formConfig[1].selectOptions = res.data || [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,273 +1,261 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<search-bar
|
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||||
:formConfigs="formConfig"
|
<div v-if="tableData.length">
|
||||||
ref="searchBarForm"
|
<base-table v-loading="dataListLoading" :table-props="tableProps" :max-height="tableH" :table-data="tableData" />
|
||||||
@headBtnClick="buttonClick" />
|
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
|
||||||
<div v-if="tableData.length">
|
<line-chart ref="lineChart" />
|
||||||
<base-table
|
</div>
|
||||||
v-loading="dataListLoading"
|
<div v-else class="no-data-bg"></div>
|
||||||
:table-props="tableProps"
|
</div>
|
||||||
: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: 'select',
|
type: 'datePicker',
|
||||||
label: '产线',
|
label: '时间',
|
||||||
selectOptions: [],
|
dateType: 'month', // 单个月份选择
|
||||||
param: 'lineIds',
|
format: 'yyyy-MM', // 显示格式
|
||||||
defaultSelect: [],
|
valueFormat: 'yyyy-MM-dd HH:mm:ss', // 绑定值的格式
|
||||||
multiple: true,
|
param: 'time',
|
||||||
filterable: true,
|
defaultSelect: '', // 新增:默认月份值
|
||||||
width: 200,
|
},
|
||||||
},
|
{
|
||||||
{
|
type: 'select',
|
||||||
type: 'datePicker',
|
label: '产线',
|
||||||
label: '时间',
|
selectOptions: [],
|
||||||
dateType: 'month',
|
param: 'lineIds',
|
||||||
format: 'yyyy-MM',
|
defaultSelect: [], // 产线默认选择值(多选数组)
|
||||||
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
multiple: true,
|
||||||
rangeSeparator: '-',
|
collapseTags: true,
|
||||||
startPlaceholder: '开始时间',
|
filterable: true,
|
||||||
endPlaceholder: '结束时间',
|
width: 300,
|
||||||
param: 'time',
|
},
|
||||||
},
|
{
|
||||||
{
|
type: 'button',
|
||||||
type: 'button',
|
btnName: '查询',
|
||||||
btnName: '查询',
|
name: 'search',
|
||||||
name: 'search',
|
color: 'primary',
|
||||||
color: 'primary',
|
},
|
||||||
},
|
],
|
||||||
],
|
};
|
||||||
};
|
},
|
||||||
},
|
mounted() {
|
||||||
created() {
|
// 1. 初始化默认当月时间
|
||||||
this.getArr();
|
this.initDefaultMonth();
|
||||||
},
|
// 2. 获取产线数据
|
||||||
methods: {
|
this.getArr();
|
||||||
getArr() {
|
},
|
||||||
const params = {
|
methods: {
|
||||||
page: 1,
|
/**
|
||||||
limit: 500,
|
* 初始化默认当月时间(单个月份)
|
||||||
};
|
*/
|
||||||
this.optionArrUrl.forEach((item, index) => {
|
initDefaultMonth() {
|
||||||
item(params).then((response) => {
|
const now = new Date();
|
||||||
this.formConfig[index].selectOptions = response.data.list;
|
const year = now.getFullYear();
|
||||||
// this.formConfig[0].defaultSelect = response.data.list[0].id
|
const month = now.getMonth(); // 月份从0开始,直接使用(取当月1号)
|
||||||
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id)
|
// 创建当月1号0点0分0秒的日期对象
|
||||||
});
|
const firstDayOfMonth = new Date(year, month, 1, 0, 0, 0);
|
||||||
});
|
// 转换为时间戳(毫秒级)
|
||||||
},
|
const defaultTimeStamp = firstDayOfMonth.getTime();
|
||||||
getData() {
|
// 给时间选择器赋值默认值
|
||||||
// this.listQuery.lineIds = ['1672847052717821953']
|
this.formConfig[0].defaultSelect = firstDayOfMonth;
|
||||||
// this.listQuery.productId = val.productId;
|
// this.listQuery.time = defaultTimeStamp;
|
||||||
// this.listQuery.time = '1694486098000';
|
},
|
||||||
this.urlOptions.getDataListURL(this.listQuery).then((res) => {
|
/**
|
||||||
let arr = [
|
* 获取产线数据
|
||||||
{
|
*/
|
||||||
prop: 'lineName',
|
getArr() {
|
||||||
label: '产线',
|
const params = {
|
||||||
fixed: 'left',
|
page: 1,
|
||||||
},
|
limit: 500,
|
||||||
{
|
};
|
||||||
prop: 'sum',
|
// 原代码forEach遍历冗余,直接调用第一个方法即可
|
||||||
label: '合计[片]',
|
this.optionArrUrl[0](params)
|
||||||
fixed: 'left',
|
.then((response) => {
|
||||||
},
|
const lineList = response.data.list;
|
||||||
{
|
this.formConfig[1].selectOptions = lineList;
|
||||||
prop: res.data ? res.data.nameData[0].name : undefined,
|
// 产线默认选择第一条数据(多选需用数组格式)
|
||||||
label: res.data ? res.data.nameData[0].name : undefined,
|
if (lineList.length > 0) {
|
||||||
align: 'center',
|
const firstLineId = lineList[0].id;
|
||||||
children: [],
|
this.formConfig[1].defaultSelect = [firstLineId];
|
||||||
},
|
// 给查询参数赋值
|
||||||
];
|
this.listQuery.lineIds = [firstLineId];
|
||||||
// console.log(res.data.nameData.slice(1))
|
}
|
||||||
let xData = [];
|
})
|
||||||
let yAllData = [];
|
.catch((err) => {
|
||||||
let lineName = [];
|
console.error('获取产线数据失败:', err);
|
||||||
if (res.data) {
|
});
|
||||||
let tempDateList = [];
|
},
|
||||||
res.data.nameData.forEach((date) => {
|
/**
|
||||||
tempDateList.push(date.name);
|
* 获取产量分析数据
|
||||||
});
|
*/
|
||||||
this.dateLabelList = Array.from(new Set(tempDateList));
|
getData() {
|
||||||
|
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: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
this.dateLabelList.forEach((item) => {
|
let xData = [];
|
||||||
if (item.indexOf('年') === -1) {
|
let yAllData = [];
|
||||||
// 构造表头
|
let lineName = [];
|
||||||
const props = {
|
if (res.data) {
|
||||||
prop: item,
|
// 处理日期标签去重
|
||||||
label: item,
|
let tempDateList = [];
|
||||||
};
|
res.data.nameData.forEach((date) => {
|
||||||
arr[2].children.push(props);
|
tempDateList.push(date.name);
|
||||||
|
});
|
||||||
|
this.dateLabelList = Array.from(new Set(tempDateList));
|
||||||
|
|
||||||
// 构造echarts横坐标
|
// 构造表头children和echarts横坐标
|
||||||
xData.push(item);
|
this.dateLabelList.forEach((item) => {
|
||||||
}
|
if (item.indexOf('年') === -1) {
|
||||||
});
|
arr[2].children.push({
|
||||||
// res.data.nameData.slice(1).forEach(item => {
|
prop: item,
|
||||||
// const props = {
|
label: item,
|
||||||
// 'prop': item.name,
|
});
|
||||||
// 'label': item.name,
|
xData.push(item);
|
||||||
// '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 = []
|
// 构造表格数据
|
||||||
// res.data.nameData.slice(1).forEach(item => {
|
let tableDataArr = [];
|
||||||
// tempList.push(item.name)
|
res.data.data.forEach((item) => {
|
||||||
// // arr[2].children.push(props)
|
let obj = {
|
||||||
// })
|
lineName: item.lineName,
|
||||||
// xData = Array.from(new Set(tempList))
|
sum: item.sum,
|
||||||
|
};
|
||||||
|
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) => {
|
// 构造图表数据
|
||||||
let yData = [];
|
res.data.data.forEach((item) => {
|
||||||
lineName.push(item.lineName);
|
let yData = [];
|
||||||
// let obj = {}
|
lineName.push(item.lineName);
|
||||||
// obj.lineName = item.lineName,
|
item.data.forEach((ele) => {
|
||||||
// obj.sum = item.sum,
|
ele.children.forEach((e) => {
|
||||||
item.data.forEach((ele, index) => {
|
yData.push(e.dynamicValue);
|
||||||
// console.log(ele)
|
});
|
||||||
ele.children.forEach((e) => {
|
});
|
||||||
// let yData = []
|
yAllData.push(yData);
|
||||||
yData.push(e.dynamicValue);
|
});
|
||||||
});
|
} else {
|
||||||
});
|
this.tableProps = arr;
|
||||||
yAllData.push(yData);
|
this.tableData = [];
|
||||||
});
|
xData = [];
|
||||||
console.log(lineName);
|
yAllData = [];
|
||||||
} else {
|
lineName = [];
|
||||||
this.tableProps = arr;
|
}
|
||||||
this.tableData = [];
|
|
||||||
xData = [];
|
// 初始化图表
|
||||||
yAllData = [];
|
this.$nextTick(() => {
|
||||||
lineName = [];
|
this.$refs.lineChart.initChart(xData, yAllData, lineName);
|
||||||
}
|
});
|
||||||
// res.data.data[0].data[0].children.forEach((item, index) => {
|
})
|
||||||
// // console.log(item)
|
.catch((err) => {
|
||||||
// yData.push(item.dynamicValue)
|
console.error('获取产量数据失败:', err);
|
||||||
// // let data = 'data' + Number(index+1)
|
this.tableData = [];
|
||||||
// // obj['' + item.dynamicName + ''] = item.dynamicValue
|
})
|
||||||
// })
|
.finally(() => {
|
||||||
// console.log(this.yData)
|
this.dataListLoading = false; // 关闭加载状态
|
||||||
this.$nextTick(() => {
|
});
|
||||||
this.$refs.lineChart.initChart(xData, yAllData, lineName);
|
},
|
||||||
});
|
/**
|
||||||
// this.total = response.data.total;
|
* 搜索栏按钮点击事件
|
||||||
// this.dataListLoading = false;
|
* @param {Object} val - 按钮/表单传递的参数
|
||||||
});
|
*/
|
||||||
},
|
buttonClick(val) {
|
||||||
buttonClick(val) {
|
switch (val.btnName) {
|
||||||
switch (val.btnName) {
|
case 'search':
|
||||||
case 'search':
|
// 处理产线参数(避免undefined,空值设为空数组)
|
||||||
this.listQuery.lineIds = val.lineIds ? val.lineIds : undefined;
|
this.listQuery.lineIds = val.lineIds || [];
|
||||||
// this.listQuery.productId = val.productId;
|
// 处理时间参数:如果是时间字符串,可转换为时间戳(根据接口要求调整)
|
||||||
this.listQuery.time = val.time
|
if (val.time) {
|
||||||
? new Date(val.time).getTime()
|
// this.listQuery.time = val.time;
|
||||||
: undefined;
|
// 若接口需要时间戳,取消下面注释:
|
||||||
// this.listQuery.pageNo = 1;
|
this.listQuery.time = new Date(val.time).getTime();
|
||||||
// this.listQuery.pageSize = 10;
|
} else {
|
||||||
if (val.time) {
|
this.$message({
|
||||||
this.getData();
|
message: '请选择时间',
|
||||||
} else {
|
type: 'warning',
|
||||||
this.$message({
|
});
|
||||||
message: '请选择时间',
|
return;
|
||||||
type: 'warning',
|
}
|
||||||
});
|
|
||||||
}
|
// 验证产线是否选择(可选,根据业务需求调整)
|
||||||
break;
|
if (this.listQuery.lineIds.length === 0) {
|
||||||
case 'reset':
|
this.$message({
|
||||||
this.$refs.searchBarForm.resetForm();
|
message: '请选择至少一条产线',
|
||||||
this.listQuery = {
|
type: 'warning',
|
||||||
pageSize: 10,
|
});
|
||||||
pageNo: 1,
|
return;
|
||||||
total: 1,
|
}
|
||||||
};
|
|
||||||
this.getDataList();
|
this.getData();
|
||||||
break;
|
break;
|
||||||
default:
|
case 'reset':
|
||||||
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,7 +279,8 @@ 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,20 +66,30 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="完成单位产品用时" prop="processTime">
|
<el-form-item label="完成单位产品用时(S)" prop="processTime">
|
||||||
<el-input :disabled="isdetail" v-model="dataForm.processTime" placeholder="请输入完成单位产品用时" />
|
<el-input :disabled="isdetail" v-model="dataForm.processTime" placeholder="请输入完成单位产品用时(S)" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label=" 加工属性" prop="processType">
|
<el-form-item label=" 产品工艺" prop="processTypes">
|
||||||
<el-select v-model="dataForm.processType" clearable style="width: 100%" :disabled="isdetail"
|
<el-select :disabled="isdetail" collapse-tags multiple v-model="dataForm.processTypes" clearable
|
||||||
placeholder="请选择加工属性">
|
style="width: 100%" placeholder="请选择产品工艺">
|
||||||
<el-option v-for="dict in processTypeList" :key="dict.id" :label="dict.label"
|
<el-option v-for="dict in processTypeList" :key="dict.value" :label="dict.label"
|
||||||
:value="dict.id" />
|
:value="dict.value" />
|
||||||
</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">
|
||||||
@@ -131,317 +141,361 @@
|
|||||||
|
|
||||||
<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, // 原片单位平方数
|
||||||
processType:undefined,
|
processTypes: [],
|
||||||
},
|
typeDictValue: null,
|
||||||
listQuery: {
|
},
|
||||||
pageSize: 10,
|
typeList:[],
|
||||||
pageNo: 1,
|
listQuery: {
|
||||||
total: 0,
|
pageSize: 10,
|
||||||
|
pageNo: 1,
|
||||||
|
total: 0,
|
||||||
},
|
},
|
||||||
processTypeList: [
|
processTypeList: [
|
||||||
{
|
// {
|
||||||
id: '0',
|
// value: '1',
|
||||||
label:'压花丝印'
|
// label: '压花丝印'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
id: '1',
|
// value: '2',
|
||||||
label: '无印打孔'
|
// label: '无印打孔'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
id: '2',
|
// value: '3',
|
||||||
label: '单层镀膜'
|
// label: '单层镀膜'
|
||||||
}, {
|
// }, {
|
||||||
id: '3',
|
// value: '4',
|
||||||
label: '双层镀膜'
|
// label: '双层镀膜'
|
||||||
}
|
// }
|
||||||
],
|
],
|
||||||
dataRule: {
|
dataRule: {
|
||||||
code: [
|
code: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '产品编码不能为空',
|
message: '产品编码不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// type: 'number',
|
// type: 'number',
|
||||||
// message: '产品编码为数字类型',
|
// message: '产品编码为数字类型',
|
||||||
// trigger: 'blur',
|
// trigger: 'blur',
|
||||||
// transfom: 'val => Number(val)',
|
// transfom: 'val => Number(val)',
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
name: [
|
name: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '产品名称不能为空',
|
message: '产品名称不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
typeDictValue: [
|
typeDictValue: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '产品类型不能为空',
|
message: '产品类型不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
area: [
|
area: [
|
||||||
{
|
{
|
||||||
type: 'number',
|
type: 'number',
|
||||||
message: '请输入正确的数值',
|
message: '请输入正确的数值',
|
||||||
trigger: 'change',
|
trigger: 'change',
|
||||||
transform: (val) => Number(val),
|
transform: (val) => Number(val),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
processTime: [
|
processTime: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '完成单位产品用时不能为空',
|
message: '完成单位产品用时不能为空',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'number',
|
type: 'number',
|
||||||
message: '请输入正确的数值',
|
message: '请输入正确的数值',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
transform: (val) => Number(val),
|
transform: (val) => Number(val),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
isdetail: false,
|
isdetail: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initData() {
|
async initData() {
|
||||||
this.productAttributeList.splice(0);
|
this.productAttributeList.splice(0);
|
||||||
this.listQuery.total = 0;
|
this.listQuery.total = 0;
|
||||||
},
|
const typeRes = await listData({
|
||||||
init(id, isdetail) {
|
pageNo:
|
||||||
this.initData();
|
1,
|
||||||
this.isdetail = isdetail || false;
|
pageSize
|
||||||
this.dataForm.id = id || null;
|
: 10,
|
||||||
this.visible = true;
|
dictType
|
||||||
|
: 'product_type'
|
||||||
|
})
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.typeList = typeRes.data.list
|
||||||
this.$refs['dataForm'].resetFields();
|
console.log('typeRes', this.typeList);
|
||||||
|
const processTypeRes = await listData({
|
||||||
|
pageNo:
|
||||||
|
1,
|
||||||
|
pageSize
|
||||||
|
: 10,
|
||||||
|
dictType
|
||||||
|
: 'process_type'
|
||||||
|
})
|
||||||
|
|
||||||
if (this.dataForm.id) {
|
this.processTypeList = processTypeRes.data.list
|
||||||
// 获取产品详情
|
console.log('typeRes', this.typeList);
|
||||||
getProduct(id).then((response) => {
|
},
|
||||||
this.dataForm = response.data;
|
init(id, isdetail) {
|
||||||
});
|
this.initData();
|
||||||
// 获取产品的属性列表
|
this.isdetail = isdetail || false;
|
||||||
this.getList();
|
this.dataForm.id = id || null;
|
||||||
} else {
|
// this.dataForm.processTypes = [] // 清空工艺选择
|
||||||
getCode().then((res) => {
|
this.visible = true;
|
||||||
this.dataForm.code = res.data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
getList() {
|
this.$nextTick(() => {
|
||||||
// 获取产品的属性列表
|
this.$refs['dataForm'].resetFields();
|
||||||
getProductAttrPage({
|
|
||||||
...this.listQuery,
|
if (this.dataForm.id) {
|
||||||
productId: this.dataForm.id,
|
// 获取产品详情
|
||||||
}).then((response) => {
|
getProduct(id).then((res) => {
|
||||||
this.productAttributeList = response.data.list;
|
const resData = res.data || {};
|
||||||
this.listQuery.total = response.data.total;
|
// 逐个字段赋值(保留响应式)
|
||||||
});
|
this.dataForm.name = resData.name || '';
|
||||||
},
|
this.dataForm.code = resData.code || '';
|
||||||
handleClick(raw) {
|
this.dataForm.area = resData.area || 0;
|
||||||
if (raw.type === 'delete') {
|
this.dataForm.typeDictValue = resData.typeDictValue || null;
|
||||||
this.$confirm(
|
this.dataForm.processTime = resData.processTime || null;
|
||||||
`确定对${
|
this.dataForm.specifications = resData.specifications || '';
|
||||||
raw.data.name
|
this.dataForm.unitDictValue = resData.unitDictValue || '';
|
||||||
? '[名称=' + raw.data.name + ']'
|
this.dataForm.originalSpecifications = resData.originalSpecifications || '';
|
||||||
: '[序号=' + raw.data._pageIndex + ']'
|
this.dataForm.originalArea = resData.originalArea || 0;
|
||||||
}进行删除操作?`,
|
|
||||||
'提示',
|
// 处理工艺列表:确保是数组,过滤空值
|
||||||
{
|
this.dataForm.processTypes = resData.processType
|
||||||
confirmButtonText: '确定',
|
? resData.processType.split(',').filter(Boolean)
|
||||||
cancelButtonText: '取消',
|
: [];
|
||||||
type: 'warning',
|
|
||||||
}
|
console.log('工艺列表(编辑时):', this.dataForm.processTypes); // 验证是否为 ["1","2"] 格式
|
||||||
)
|
});
|
||||||
.then(() => {
|
// 获取产品的属性列表
|
||||||
deleteProductAttr(raw.data.id).then(({ data }) => {
|
this.getList();
|
||||||
this.$message({
|
} else {
|
||||||
message: '操作成功',
|
getCode().then((res) => {
|
||||||
type: 'success',
|
this.dataForm.code = res.data;
|
||||||
duration: 1500,
|
});
|
||||||
onClose: () => {
|
}
|
||||||
this.getList();
|
});
|
||||||
},
|
},
|
||||||
});
|
|
||||||
});
|
getList() {
|
||||||
})
|
// 获取产品的属性列表
|
||||||
.catch(() => {});
|
getProductAttrPage({
|
||||||
} else {
|
...this.listQuery,
|
||||||
this.addNew(raw.data.id);
|
productId: this.dataForm.id,
|
||||||
}
|
}).then((response) => {
|
||||||
},
|
this.productAttributeList = response.data.list;
|
||||||
// 表单提交
|
this.listQuery.total = response.data.total;
|
||||||
dataFormSubmit() {
|
});
|
||||||
this.$refs['dataForm'].validate((valid) => {
|
},
|
||||||
if (valid) {
|
handleClick(raw) {
|
||||||
// 修改的提交
|
if (raw.type === 'delete') {
|
||||||
if (this.dataForm.id) {
|
this.$confirm(
|
||||||
updateProduct(this.dataForm).then((response) => {
|
`确定对${raw.data.name
|
||||||
this.$modal.msgSuccess('修改成功');
|
? '[名称=' + raw.data.name + ']'
|
||||||
this.visible = false;
|
: '[序号=' + raw.data._pageIndex + ']'
|
||||||
this.$emit('refreshDataList');
|
}进行删除操作?`,
|
||||||
});
|
'提示',
|
||||||
return;
|
{
|
||||||
}
|
confirmButtonText: '确定',
|
||||||
// 添加的提交
|
cancelButtonText: '取消',
|
||||||
createProduct(this.dataForm).then((response) => {
|
type: 'warning',
|
||||||
this.$modal.msgSuccess('新增成功');
|
}
|
||||||
this.$confirm(`是否新增产品属性?`, '系统提示', {
|
)
|
||||||
confirmButtonText: '确定',
|
.then(() => {
|
||||||
cancelButtonText: '取消',
|
deleteProductAttr(raw.data.id).then(({ data }) => {
|
||||||
type: 'warning',
|
this.$message({
|
||||||
})
|
message: '操作成功',
|
||||||
.then(() => {
|
type: 'success',
|
||||||
|
duration: 1500,
|
||||||
|
onClose: () => {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => { });
|
||||||
|
} else {
|
||||||
|
this.addNew(raw.data.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 表单提交
|
||||||
|
dataFormSubmit() {
|
||||||
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
|
||||||
|
// 修改的提交
|
||||||
|
if (this.dataForm.id) {
|
||||||
|
updateProduct(this.dataForm).then((response) => {
|
||||||
|
this.$modal.msgSuccess('修改成功');
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit('refreshDataList');
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
createProduct(this.dataForm).then((response) => {
|
||||||
|
this.$modal.msgSuccess('新增成功');
|
||||||
|
this.$confirm(`是否新增产品属性?`, '系统提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
this.dataForm.id = response.data
|
this.dataForm.id = response.data
|
||||||
this.addNew();
|
this.addNew();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.$emit('refreshDataList');
|
this.$emit('refreshDataList');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
goEdit() {
|
goEdit() {
|
||||||
this.isdetail = false;
|
this.isdetail = false;
|
||||||
},
|
},
|
||||||
// 新增 / 修改
|
// 新增 / 修改
|
||||||
addNew(id) {
|
addNew(id) {
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
this.addOrUpdateVisible = true;
|
this.addOrUpdateVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdate.init(id);
|
this.$refs.addOrUpdate.init(id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$message('请先创建产品!');
|
this.$message('请先创建产品!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
goback() {
|
goback() {
|
||||||
this.$emit('refreshDataList');
|
this.$emit('refreshDataList');
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.initData();
|
this.initData();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.drawer >>> .el-drawer {
|
.drawer>>>.el-drawer {
|
||||||
border-radius: 8px 0 0 8px;
|
border-radius: 8px 0 0 8px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer >>> .el-form-item__label {
|
.drawer>>>.el-form-item__label {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer >>> .el-drawer__header {
|
.drawer>>>.el-drawer__header {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 32px 32px 24px;
|
padding: 32px 32px 24px;
|
||||||
border-bottom: 1px solid #dcdfe6;
|
border-bottom: 1px solid #dcdfe6;
|
||||||
}
|
|
||||||
.drawer >>> .el-drawer__body {
|
|
||||||
flex: 1;
|
|
||||||
height: 1px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer >>> .content {
|
.drawer>>>.el-drawer__body {
|
||||||
padding: 30px 24px;
|
flex: 1;
|
||||||
flex: 1;
|
height: 1px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
/* height: 100%; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer >>> .visual-part {
|
.drawer>>>.content {
|
||||||
flex: 1 auto;
|
padding: 30px 24px;
|
||||||
max-height: 76vh;
|
flex: 1;
|
||||||
overflow: hidden;
|
display: flex;
|
||||||
overflow-y: scroll;
|
flex-direction: column;
|
||||||
padding-right: 10px; /* 调整滚动条样式 */
|
/* height: 100%; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer >>> .el-form,
|
.drawer>>>.visual-part {
|
||||||
.drawer >>> .attr-list {
|
flex: 1 auto;
|
||||||
padding: 0 16px;
|
max-height: 76vh;
|
||||||
|
overflow: hidden;
|
||||||
|
overflow-y: scroll;
|
||||||
|
padding-right: 10px;
|
||||||
|
/* 调整滚动条样式 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer>>>.el-form,
|
||||||
|
.drawer>>>.attr-list {
|
||||||
|
padding: 0 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer-body__footer {
|
.drawer-body__footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,139 +1,142 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog v-loading="isLoading" loading-text="处理中..." loading-spinner="el-icon-loading"
|
||||||
:visible.sync="visible"
|
loading-background="rgba(255, 255, 255, 0.7)" :visible.sync="visible" :width="'35%'" :append-to-body="true"
|
||||||
:width="'35%'"
|
:close-on-click-modal="false" class="dialog">
|
||||||
:append-to-body="true"
|
<template #title>
|
||||||
:close-on-click-modal="false"
|
<slot name="title">
|
||||||
class="dialog">
|
<div class="titleStyle">
|
||||||
<template #title>
|
{{ !dataForm.id ? '新增' : '编辑' }}
|
||||||
<slot name="title">
|
</div>
|
||||||
<div class="titleStyle">
|
</slot>
|
||||||
{{ !dataForm.id ? '新增' : '编辑' }}
|
</template>
|
||||||
</div>
|
|
||||||
</slot>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-form
|
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="100px"
|
||||||
ref="dataForm"
|
@keyup.enter.native="dataFormSubmit()">
|
||||||
:model="dataForm"
|
<el-form-item label="属性名" prop="name">
|
||||||
:rules="dataRule"
|
<el-input v-model="dataForm.name" placeholder="请输入属性名" clearable />
|
||||||
label-width="100px"
|
</el-form-item>
|
||||||
@keyup.enter.native="dataFormSubmit()">
|
<el-form-item label="属性值" prop="value">
|
||||||
<el-form-item label="属性名" prop="name">
|
<el-input v-model="dataForm.value" placeholder="请输入属性值" clearable />
|
||||||
<el-input
|
</el-form-item>
|
||||||
v-model="dataForm.name"
|
</el-form>
|
||||||
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 type="primary" @click="dataFormSubmit()">确定</el-button>
|
<el-button :loading="isLoading" type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<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,
|
||||||
dataForm: {
|
isLoading: false,
|
||||||
id: 0,
|
dataForm: {
|
||||||
name: '',
|
id: 0,
|
||||||
value: '',
|
name: '',
|
||||||
},
|
value: '',
|
||||||
dataRule: {
|
},
|
||||||
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
|
dataRule: {
|
||||||
},
|
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
|
||||||
};
|
},
|
||||||
},
|
};
|
||||||
methods: {
|
},
|
||||||
init(id) {
|
methods: {
|
||||||
this.dataForm.id = id || '';
|
init(id) {
|
||||||
this.visible = true;
|
this.dataForm.id = id || '';
|
||||||
this.$nextTick(() => {
|
this.visible = true;
|
||||||
this.$refs['dataForm'].resetFields();
|
this.$nextTick(() => {
|
||||||
if (this.dataForm.id) {
|
this.$refs['dataForm'].resetFields();
|
||||||
getProductAttr(this.dataForm.id).then((res) => {
|
if (this.dataForm.id) {
|
||||||
const { name, value } = res.data;
|
getProductAttr(this.dataForm.id).then((res) => {
|
||||||
this.dataForm.name = name;
|
const { name, value } = res.data;
|
||||||
this.dataForm.value = value;
|
this.dataForm.name = name;
|
||||||
});
|
this.dataForm.value = value;
|
||||||
}
|
}).catch(err => {
|
||||||
});
|
console.error('获取属性详情失败:', err);
|
||||||
},
|
this.$modal.msgError('获取数据失败,请重试');
|
||||||
// 表单提交
|
});
|
||||||
dataFormSubmit() {
|
}
|
||||||
this.$refs['dataForm'].validate((valid) => {
|
});
|
||||||
if (valid) {
|
},
|
||||||
// 修改的提交
|
// 表单提交(优化加载状态和错误处理)
|
||||||
if (this.dataForm.id) {
|
async dataFormSubmit() {
|
||||||
updateProductAttr({
|
// 先验证表单
|
||||||
...this.dataForm,
|
const valid = await new Promise((resolve) => {
|
||||||
productId: this.productId,
|
this.$refs['dataForm'].validate((isValid) => resolve(isValid));
|
||||||
}).then((response) => {
|
});
|
||||||
this.$modal.msgSuccess('修改成功');
|
|
||||||
this.visible = false;
|
if (!valid) return;
|
||||||
this.$emit('refreshDataList');
|
|
||||||
});
|
this.isLoading = true; // 开始加载
|
||||||
return;
|
|
||||||
}
|
try {
|
||||||
// 添加的提交
|
if (this.dataForm.id) {
|
||||||
createProductAttr({
|
// 编辑操作
|
||||||
...this.dataForm,
|
await updateProductAttr({
|
||||||
productId: this.productId,
|
...this.dataForm,
|
||||||
}).then((response) => {
|
productId: this.productId,
|
||||||
this.$modal.msgSuccess('新增成功');
|
});
|
||||||
this.visible = false;
|
this.$modal.msgSuccess('修改成功');
|
||||||
this.$emit('refreshDataList');
|
} else {
|
||||||
});
|
// 新增操作
|
||||||
}
|
await createProductAttr({
|
||||||
});
|
...this.dataForm,
|
||||||
},
|
productId: this.productId,
|
||||||
},
|
});
|
||||||
|
this.$modal.msgSuccess('新增成功');
|
||||||
|
}
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit('refreshDataList');
|
||||||
|
} catch (error) {
|
||||||
|
// 错误处理
|
||||||
|
console.error('提交失败:', error);
|
||||||
|
this.$modal.msgError('操作失败,请重试');
|
||||||
|
} finally {
|
||||||
|
// 无论成功失败,都关闭加载状态
|
||||||
|
this.isLoading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.dialog >>> .el-dialog__body {
|
.dialog>>>.el-dialog__body {
|
||||||
padding: 30px 24px;
|
padding: 30px 24px;
|
||||||
}
|
}
|
||||||
.dialog >>> .el-dialog__header {
|
|
||||||
font-size: 16px;
|
.dialog>>>.el-dialog__header {
|
||||||
color: rgba(0, 0, 0, 0.85);
|
font-size: 16px;
|
||||||
font-weight: 500;
|
color: rgba(0, 0, 0, 0.85);
|
||||||
padding: 13px 24px;
|
font-weight: 500;
|
||||||
border-bottom: 1px solid #e9e9e9;
|
padding: 13px 24px;
|
||||||
|
border-bottom: 1px solid #e9e9e9;
|
||||||
}
|
}
|
||||||
.dialog >>> .el-dialog__header .titleStyle::before {
|
|
||||||
content: '';
|
.dialog>>>.el-dialog__header .titleStyle::before {
|
||||||
display: inline-block;
|
content: '';
|
||||||
width: 4px;
|
display: inline-block;
|
||||||
height: 16px;
|
width: 4px;
|
||||||
background-color: #0b58ff;
|
height: 16px;
|
||||||
border-radius: 1px;
|
background-color: #0b58ff;
|
||||||
margin-right: 8px;
|
border-radius: 1px;
|
||||||
position: relative;
|
margin-right: 8px;
|
||||||
top: 2px;
|
position: relative;
|
||||||
|
top: 2px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -104,7 +104,11 @@ export default {
|
|||||||
getDataListURL: getProductionLinePage,
|
getDataListURL: getProductionLinePage,
|
||||||
deleteURL: deleteProductionLine,
|
deleteURL: deleteProductionLine,
|
||||||
exportURL: exportProductionLineExcel,
|
exportURL: exportProductionLineExcel,
|
||||||
},
|
},
|
||||||
|
listQuery: {
|
||||||
|
pageSize: 20,
|
||||||
|
pageNo:1
|
||||||
|
},
|
||||||
tableProps,
|
tableProps,
|
||||||
tableBtn: [
|
tableBtn: [
|
||||||
this.$auth.hasPermi(`base:production-line:update`)
|
this.$auth.hasPermi(`base:production-line:update`)
|
||||||
@@ -212,7 +216,7 @@ export default {
|
|||||||
switch (val.btnName) {
|
switch (val.btnName) {
|
||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageSize = 20;
|
||||||
this.listQuery.factoryId = val.factoryId || undefined;
|
this.listQuery.factoryId = val.factoryId || undefined;
|
||||||
this.listQuery.name = val.name;
|
this.listQuery.name = val.name;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
@@ -220,7 +224,7 @@ export default {
|
|||||||
case 'reset':
|
case 'reset':
|
||||||
this.$refs.searchBarForm.resetForm();
|
this.$refs.searchBarForm.resetForm();
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -262,6 +262,14 @@ export default {
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
valueFormatter: (value) => `${value} %`,
|
valueFormatter: (value) => `${value} %`,
|
||||||
},
|
},
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
position: 'top',
|
||||||
|
distance: 6,
|
||||||
|
fontSize: 11,
|
||||||
|
color: '#333333',
|
||||||
|
formatter: (params) => `${params.value}` // 显示单位
|
||||||
|
},
|
||||||
data: this.barData.map((item) => item.processingRatio),
|
data: this.barData.map((item) => item.processingRatio),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -77,7 +77,7 @@ const tableProps = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'palletNum',
|
prop: 'palletNum',
|
||||||
label: '下片托数'
|
label: '一托玻璃数量/片'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'startTime',
|
prop: 'startTime',
|
||||||
@@ -92,7 +92,7 @@ const tableProps = [
|
|||||||
width: 160
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'outputNum',
|
prop: 'length',
|
||||||
label: '玻璃长度/mm'
|
label: '玻璃长度/mm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ const tableProps = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'thick',
|
prop: 'thick',
|
||||||
label: '玻璃长度/mm'
|
label: '玻璃厚度/mm'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -204,94 +204,88 @@ export default {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
test() {
|
exportXlsx() {
|
||||||
var target = document.getElementsByClassName("right-aside")[0]
|
if (!this.showData.length) {
|
||||||
target.style.background = '#FFFFFF'
|
this.$message.warning('暂无数据可导出');
|
||||||
var that = this
|
return;
|
||||||
setTimeout(() => {
|
|
||||||
html2canvas(target).then(function(canvas) {
|
|
||||||
var contentWidth = canvas.width
|
|
||||||
var contentHeight = canvas.height
|
|
||||||
|
|
||||||
// 一页pdf显示html页面生成的canvas高度
|
|
||||||
var pageHeight = contentHeight / 592.28 * 841.89
|
|
||||||
// 未生成pdf的html页面高度
|
|
||||||
var leftHeight = contentHeight
|
|
||||||
// 页面偏移
|
|
||||||
var position = 0
|
|
||||||
// a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的高度
|
|
||||||
var imgWidth = 595.28
|
|
||||||
var imgHeight = 592.28 / contentWidth * contentHeight
|
|
||||||
|
|
||||||
var pageData = canvas.toDataURL('image/jpeg', 1.0)
|
|
||||||
|
|
||||||
console.log('nihc URL', leftHeight, pageHeight)
|
|
||||||
|
|
||||||
var pdf = new jsPDF('', 'pt', 'a4')
|
|
||||||
|
|
||||||
if (leftHeight < pageHeight) {
|
|
||||||
pdf.addImage(pageData, 'JPEG', 0, 20, imgWidth, imgHeight)
|
|
||||||
} else {
|
|
||||||
while(leftHeight > 0) {
|
|
||||||
pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
|
|
||||||
leftHeight -= pageHeight
|
|
||||||
position -= 841.89
|
|
||||||
// 避免空白页
|
|
||||||
if (leftHeight > 0) {
|
|
||||||
pdf.addPage()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pdf.save(that.fileName + '工段统计.pdf')
|
|
||||||
})
|
|
||||||
}, 300)
|
|
||||||
},
|
|
||||||
exportECL() {
|
|
||||||
let tables = document.querySelector('.el-table').cloneNode(true)
|
|
||||||
const fix = tables.querySelector('.el-table__fixed')
|
|
||||||
const fixRight = tables.querySelector('.el-table__fixed-right')
|
|
||||||
if (fix) {
|
|
||||||
tables.removeChild(tables.querySelector('.el-table__fixed'))
|
|
||||||
}
|
|
||||||
if (fixRight) {
|
|
||||||
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
|
|
||||||
}
|
|
||||||
let exportTable = XLSX.utils.table_to_book(tables)
|
|
||||||
|
|
||||||
var exportTableOut = XLSX.write(exportTable, {
|
|
||||||
bookType: 'xlsx', bookSST: true, type: 'array'
|
|
||||||
})
|
|
||||||
// sheetjs.xlsx为导出表格的标题名称
|
|
||||||
try {
|
|
||||||
FileSaver.saveAs(new Blob([exportTableOut], {
|
|
||||||
type: 'application/octet-stream'
|
|
||||||
}), this.fileName + '工段统计.xlsx')
|
|
||||||
} catch (e) {
|
|
||||||
if (typeof console !== 'undefined') console.log(e, exportTableOut)
|
|
||||||
}
|
}
|
||||||
return exportTableOut
|
|
||||||
},
|
|
||||||
exportPdf() {
|
|
||||||
this.test()
|
|
||||||
setTimeout(() =>{
|
|
||||||
this.dialogVisible = false
|
|
||||||
this.showData = this.tableData
|
|
||||||
}, 600)
|
|
||||||
|
|
||||||
},
|
this.exportLoading = true;
|
||||||
exportXlsx() {
|
|
||||||
this.exportECL()
|
try {
|
||||||
this.dialogVisible = false
|
// 1. 处理导出数据(格式化时间字段)
|
||||||
this.showData = this.tableData
|
const exportData = this.showData.map(item => {
|
||||||
},
|
const formatItem = { ...item };
|
||||||
handleClose(done) {
|
// 格式化时间字段
|
||||||
this.$confirm('确认关闭?')
|
if (formatItem.startTime) formatItem.startTime = parseTime(formatItem.startTime);
|
||||||
.then(_ => {
|
if (formatItem.endTime) formatItem.endTime = parseTime(formatItem.endTime);
|
||||||
done();
|
return formatItem;
|
||||||
})
|
});
|
||||||
.catch(_ => {});
|
|
||||||
},
|
// 2. 构建表头映射:{ prop: label },只保留表格配置中存在的列
|
||||||
|
const headerMap = {};
|
||||||
|
this.tableProps.forEach(col => {
|
||||||
|
if (col.prop && col.label) {
|
||||||
|
headerMap[col.prop] = col.label;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. 转换数据:将prop键名替换为label,按tableProps顺序排列列
|
||||||
|
const formattedData = exportData.map(item => {
|
||||||
|
const newItem = {};
|
||||||
|
// 按表格配置顺序遍历列,确保Excel列顺序与表格一致
|
||||||
|
this.tableProps.forEach(col => {
|
||||||
|
const prop = col.prop;
|
||||||
|
const label = col.label;
|
||||||
|
if (prop && label) {
|
||||||
|
// 处理可能的undefined值,避免导出为空字符串
|
||||||
|
newItem[label] = item[prop] ?? '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return newItem;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 4. 创建工作表(使用处理后的带label表头的数据)
|
||||||
|
const worksheet = XLSX.utils.json_to_sheet(formattedData);
|
||||||
|
|
||||||
|
// 5. 创建工作簿并添加工作表
|
||||||
|
const workbook = XLSX.utils.book_new();
|
||||||
|
XLSX.utils.book_append_sheet(workbook, worksheet, '下片日志数据');
|
||||||
|
|
||||||
|
// 6. 生成Excel文件
|
||||||
|
const excelBuffer = XLSX.write(workbook, {
|
||||||
|
bookType: 'xlsx',
|
||||||
|
type: 'array'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 7. 保存文件
|
||||||
|
const blob = new Blob([excelBuffer], {
|
||||||
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 8. 生成文件名(包含查询条件信息)
|
||||||
|
let fileName = '下片历史';
|
||||||
|
if (this.listQuery.productionLineId) {
|
||||||
|
const lineItem = this.formConfig[0].selectOptions.find(
|
||||||
|
item => item.id === this.listQuery.productionLineId
|
||||||
|
);
|
||||||
|
if (lineItem) fileName += lineItem.name + '_';
|
||||||
|
}
|
||||||
|
if (this.listQuery.thick) {
|
||||||
|
fileName += this.listQuery.thick + '_';
|
||||||
|
}
|
||||||
|
// 添加时间戳避免文件名重复
|
||||||
|
fileName + '.xlsx';
|
||||||
|
|
||||||
|
FileSaver.saveAs(blob, fileName);
|
||||||
|
this.$message.success('导出成功');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('导出失败:', error);
|
||||||
|
this.$message.error('导出失败,请重试');
|
||||||
|
} finally {
|
||||||
|
this.exportLoading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
getPdLineList() {
|
getPdLineList() {
|
||||||
getPdList().then((res) => {
|
getPdList().then((res) => {
|
||||||
this.formConfig[0].selectOptions = res.data || []
|
this.formConfig[0].selectOptions = res.data || []
|
||||||
@@ -314,15 +308,16 @@ export default {
|
|||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.listQuery.pageSize = 10;
|
this.listQuery.pageSize = 10;
|
||||||
this.listQuery.productId = val.productId ? val.productId : undefined;
|
this.listQuery.productionLineId = val.productionLineId ? val.productionLineId : undefined;
|
||||||
this.listQuery.startTime = val.timeVal ? val.timeVal[0]: undefined;
|
this.listQuery.thick = val.thick ? val.thick : undefined;
|
||||||
this.listQuery.endTime = val.timeVal ? val.timeVal[1]: undefined;
|
this.listQuery.startTime = val.timeVal ? val.timeVal[0] : undefined;
|
||||||
|
this.listQuery.endTime = val.timeVal ? val.timeVal[1] : undefined;
|
||||||
|
|
||||||
//this.listQuery.reportEndTime = val.timeVal ? [new Date(val.timeVal[1]).getTime()] : undefined;
|
//this.listQuery.reportEndTime = val.timeVal ? [new Date(val.timeVal[1]).getTime()] : undefined;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
this.handleExport();
|
this.exportXlsx();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(val);
|
console.log(val);
|
||||||
@@ -350,12 +345,6 @@ export default {
|
|||||||
this.listQuery.pageNo = val;
|
this.listQuery.pageNo = val;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
handleExport() {
|
|
||||||
if (this.selectedList.length > 0) {
|
|
||||||
this.showData = this.selectedList
|
|
||||||
}
|
|
||||||
this.dialogVisible = true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const tableProps = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'palletNum',
|
prop: 'palletNum',
|
||||||
label: '下片托数'
|
label: '一托玻璃数量/片'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'startTime',
|
prop: 'startTime',
|
||||||
@@ -92,7 +92,7 @@ const tableProps = [
|
|||||||
width: 160
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'outputNum',
|
prop: 'length',
|
||||||
label: '玻璃长度/mm'
|
label: '玻璃长度/mm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -358,8 +358,6 @@ 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,6 +262,14 @@ export default {
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
valueFormatter: (value) => `${value} %`,
|
valueFormatter: (value) => `${value} %`,
|
||||||
},
|
},
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
position: 'top',
|
||||||
|
distance: 6,
|
||||||
|
fontSize: 11,
|
||||||
|
color: '#333333',
|
||||||
|
formatter: (params) => `${params.value}` // 显示单位
|
||||||
|
},
|
||||||
data: this.barData.map((item) => item.processingRatio),
|
data: this.barData.map((item) => item.processingRatio),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,8 @@
|
|||||||
<!--
|
|
||||||
* @Author: Do not edit
|
|
||||||
* @Date: 2023-08-29 14:59:29
|
|
||||||
* @LastEditTime: 2024-12-02 13:44:47
|
|
||||||
* @LastEditors: zwq
|
|
||||||
* @Description:
|
|
||||||
-->
|
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<!-- :isFold="true" 控制展开 -->
|
<!-- :isFold="true" 控制展开 -->
|
||||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick"
|
||||||
|
@select-changed="selectType" />
|
||||||
<base-table v-if="tableData.length" class="right-aside" v-loading="dataListLoading" :table-props="tableProps"
|
<base-table v-if="tableData.length" class="right-aside" v-loading="dataListLoading" :table-props="tableProps"
|
||||||
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
|
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
|
||||||
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
|
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
|
||||||
@@ -17,34 +11,47 @@
|
|||||||
<div v-else class="no-data-bg"></div>
|
<div v-else class="no-data-bg"></div>
|
||||||
<pagination :limit.sync="listQuery.pageSize" :page.sync="listQuery.pageNo" :total="listQuery.total"
|
<pagination :limit.sync="listQuery.pageSize" :page.sync="listQuery.pageNo" :total="listQuery.total"
|
||||||
@pagination="getDataList" />
|
@pagination="getDataList" />
|
||||||
<!-- <el-dialog
|
|
||||||
title="提示"
|
|
||||||
:visible.sync="dialogVisible"
|
|
||||||
width="30%"
|
|
||||||
:before-close="handleClose">
|
|
||||||
<el-button type="primary" @click="exportXlsx">xlsx</el-button>
|
|
||||||
<el-button type="success" @click="exportPdf">pdf</el-button>
|
|
||||||
<span slot="footer" class="dialog-footer">
|
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
||||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
|
||||||
</span>
|
|
||||||
</el-dialog> -->
|
|
||||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" />
|
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Vue from 'vue';
|
||||||
import AddOrUpdate from './add-or-updata';
|
import AddOrUpdate from './add-or-updata';
|
||||||
|
|
||||||
import { parseTime } from '../../mixins/code-filter';
|
import { parseTime } from '../../mixins/code-filter';
|
||||||
import { getCostOriginRadioHisData, getPdList } from '@/api/core/monitoring/index'
|
import { getCostOriginRadioHisData, getPdList } from '@/api/core/monitoring/index';
|
||||||
import * as XLSX from 'xlsx'
|
|
||||||
import FileSaver from 'file-saver'
|
|
||||||
import jsPDF from 'jspdf'
|
|
||||||
import html2canvas from 'html2canvas'
|
|
||||||
import { exportCostOriginRadioHisData } from '../../../../api/core/monitoring';
|
import { exportCostOriginRadioHisData } from '../../../../api/core/monitoring';
|
||||||
|
|
||||||
const tableProps = [
|
// Vue2 中注册全局方法(如果需要)
|
||||||
|
Vue.prototype.$download = Vue.prototype.$download || {
|
||||||
|
excel: (response, fileName) => {
|
||||||
|
const blob = new Blob([response.data], { type: 'application/vnd.ms-excel' });
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const aLink = document.createElement('a');
|
||||||
|
aLink.style.display = 'none';
|
||||||
|
aLink.href = url;
|
||||||
|
aLink.setAttribute('download', fileName);
|
||||||
|
document.body.appendChild(aLink);
|
||||||
|
aLink.click();
|
||||||
|
document.body.removeChild(aLink);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Vue.prototype.$modal = Vue.prototype.$modal || {
|
||||||
|
confirm: (message) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (window.confirm(message)) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const tableProps = [
|
||||||
{
|
{
|
||||||
prop: 'reportType',
|
prop: 'reportType',
|
||||||
label: '报表类型'
|
label: '报表类型'
|
||||||
@@ -52,12 +59,11 @@ const tableProps = [
|
|||||||
{
|
{
|
||||||
prop: 'time',
|
prop: 'time',
|
||||||
label: '日期',
|
label: '日期',
|
||||||
// filter: parseTime,
|
|
||||||
width: 160
|
width: 160
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'bindObjectName',
|
prop: 'bindObjectName',
|
||||||
label: '产线'
|
label: '产线'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'thick',
|
prop: 'thick',
|
||||||
@@ -67,11 +73,11 @@ const tableProps = [
|
|||||||
prop: 'speed',
|
prop: 'speed',
|
||||||
label: '在线速度'
|
label: '在线速度'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'width',
|
prop: 'width',
|
||||||
label: '掰边宽度'
|
label: '掰边宽度'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'inArea',
|
prop: 'inArea',
|
||||||
label: '拉引量/㎡'
|
label: '拉引量/㎡'
|
||||||
},
|
},
|
||||||
@@ -79,21 +85,83 @@ 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,
|
||||||
@@ -101,181 +169,368 @@ 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),
|
||||||
tableData: [],
|
fileName: '',
|
||||||
fileName: '',
|
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '维度',
|
label: '报表类型',
|
||||||
|
onchange: true,
|
||||||
selectOptions: [
|
selectOptions: [
|
||||||
{
|
{ id: '0', name: '班组' },
|
||||||
id: '0',
|
{ id: '1', name: '日' },
|
||||||
name:'班组'
|
{ id: '2', name: '周' },
|
||||||
},
|
{ id: '3', name: '月' },
|
||||||
{
|
{ id: '4', name: '年' }
|
||||||
id: '1',
|
|
||||||
name: '日'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: '周'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
name: '月'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '4',
|
|
||||||
name: '年'
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
param: 'statisticType'
|
param: 'statisticType',
|
||||||
|
index: 1,
|
||||||
|
extraOptions: [
|
||||||
|
{
|
||||||
|
parent: 'statisticType',
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '统计时间',
|
||||||
|
dateType: 'daterange',
|
||||||
|
format: 'yyyy-MM-dd',
|
||||||
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
defaultTime: ['00:00:00', '23:59:59'],
|
||||||
|
defaultSelect: [],
|
||||||
|
width: 250,
|
||||||
|
key: 'datePicker-0', // 唯一 key,触发重新渲染
|
||||||
|
appendToBody: true // 优化定位:挂载到 body 下
|
||||||
|
},
|
||||||
|
// 日 - 日期范围选择
|
||||||
|
{
|
||||||
|
parent: 'statisticType',
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '统计时间',
|
||||||
|
dateType: 'daterange',
|
||||||
|
format: 'yyyy-MM-dd',
|
||||||
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeValDay',
|
||||||
|
defaultTime: ['00:00:00', '23:59:59'],
|
||||||
|
defaultSelect: [],
|
||||||
|
width: 250,
|
||||||
|
key: 'datePicker-1', // 唯一 key,触发重新渲染
|
||||||
|
appendToBody: true // 优化定位:挂载到 body 下
|
||||||
|
},
|
||||||
|
// 周 - 单个日期选择(自动获取本周范围)
|
||||||
|
{
|
||||||
|
parent: 'statisticType',
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '统计时间',
|
||||||
|
dateType: 'week',
|
||||||
|
placeholder: '选择日期',
|
||||||
|
format: 'yyyy 第 WW 周',
|
||||||
|
pickerOptions: {
|
||||||
|
firstDayOfWeek: 1 // 数字1表示周一作为周的第一天(0=周日,1=周一,依此类推)
|
||||||
|
},
|
||||||
|
valueFormat: 'yyyy-MM-dd',
|
||||||
|
param: 'timeValWeek',
|
||||||
|
width: 250,
|
||||||
|
key: 'datePicker-2', // 唯一 key,触发重新渲染
|
||||||
|
appendToBody: true // 优化定位:挂载到 body 下
|
||||||
|
},
|
||||||
|
// 月 - 日期范围选择
|
||||||
|
{
|
||||||
|
parent: 'statisticType',
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '统计时间',
|
||||||
|
dateType: 'monthrange',
|
||||||
|
format: 'yyyy-MM-dd',
|
||||||
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeValMonth',
|
||||||
|
defaultTime: ['00:00:00', '23:59:59'],
|
||||||
|
width: 250,
|
||||||
|
key: 'datePicker-3', // 唯一 key,触发重新渲染
|
||||||
|
appendToBody: true // 优化定位:挂载到 body 下
|
||||||
|
},
|
||||||
|
// 年 - 单个日期选择(自动获取本年范围)
|
||||||
|
{
|
||||||
|
parent: 'statisticType',
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '统计时间',
|
||||||
|
dateType: 'year',
|
||||||
|
placeholder: '选择年份',
|
||||||
|
format: 'yyyy-MM-dd',
|
||||||
|
valueFormat: 'yyyy-MM-dd',
|
||||||
|
param: 'timeValYear',
|
||||||
|
width: 250,
|
||||||
|
key: 'datePicker-4', // 唯一 key,触发重新渲染
|
||||||
|
appendToBody: true // 优化定位:挂载到 body 下
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '产线',
|
label: '产线',
|
||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'bindObjectId'
|
param: 'bindObjectId'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
{
|
type: 'button',
|
||||||
type: 'datePicker',
|
btnName: '查询',
|
||||||
label: '统计开始时间',
|
name: 'search',
|
||||||
dateType: 'daterange',
|
color: 'primary',
|
||||||
format: 'yyyy-MM-dd',
|
|
||||||
valueFormat: "yyyy-MM-dd HH:mm:ss",
|
|
||||||
rangeSeparator: '-',
|
|
||||||
startPlaceholder: '开始时间',
|
|
||||||
endPlaceholder: '结束时间',
|
|
||||||
param: 'timeVal',
|
|
||||||
defaultTime: ['00:00:00', '23:59:59'],
|
|
||||||
defaultSelect: []
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'separate',
|
||||||
btnName: '查询',
|
},
|
||||||
name: 'search',
|
{
|
||||||
color: 'primary',
|
type: 'button',
|
||||||
},
|
btnName: '导出',
|
||||||
{
|
name: 'export',
|
||||||
type: 'separate',
|
color: 'warning',
|
||||||
},
|
}
|
||||||
{
|
],
|
||||||
// type: this.$auth.hasPermi('base:factory:export') ? 'button' : '',
|
};
|
||||||
type: 'button',
|
},
|
||||||
btnName: '导出',
|
watch: {
|
||||||
name: 'export',
|
// 监听报表类型变化,强制刷新日期选择器
|
||||||
color: 'warning',
|
'listQuery.statisticType'(newVal, oldVal) {
|
||||||
}
|
if (newVal !== oldVal && this.$refs.searchBarForm) {
|
||||||
],
|
// 触发 search-bar 组件重新渲染(如果 search-bar 支持)
|
||||||
};
|
if (this.$refs.searchBarForm.$forceUpdate) {
|
||||||
},
|
this.$refs.searchBarForm.$forceUpdate();
|
||||||
|
}
|
||||||
|
// 延迟重置定位,确保 DOM 已更新
|
||||||
|
setTimeout(() => {
|
||||||
|
const datePickerEl = this.$refs.searchBarForm.$el.querySelector('.el-date-picker');
|
||||||
|
if (datePickerEl) {
|
||||||
|
// 触发 Element UI 日期选择器重新计算定位(内部方法)
|
||||||
|
const datePickerInstance = datePickerEl.__vue__;
|
||||||
|
if (datePickerInstance && datePickerInstance.updatePopper) {
|
||||||
|
datePickerInstance.updatePopper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$refs.searchBarForm.formInline.statisticType = '1';
|
// Vue2 中 $refs 需在 $nextTick 中访问(确保 DOM 渲染完成)
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.searchBarForm) {
|
||||||
|
this.$refs.searchBarForm.formInline.statisticType = '1';
|
||||||
|
}
|
||||||
|
});
|
||||||
this.listQuery.statisticType = '1';
|
this.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) => {
|
|
||||||
this.formConfig[1].selectOptions = res.data || []
|
|
||||||
this.pdLineList = res.data || []; // 保存产线数据
|
|
||||||
})
|
|
||||||
},
|
|
||||||
selectChange(val) {
|
|
||||||
console.log(val)
|
|
||||||
this.selectedList = val
|
|
||||||
},
|
},
|
||||||
buttonClick(val) {
|
getPdLineList() {
|
||||||
console.log('val', val);
|
getPdList().then(res => {
|
||||||
|
// Vue2 中数组赋值需确保响应式
|
||||||
switch (val.btnName) {
|
this.$set(this.formConfig[1], 'selectOptions', res.data || []);
|
||||||
case 'search':
|
this.pdLineList = res.data || [];
|
||||||
this.listQuery.pageNo = 1;
|
}).catch(err => {
|
||||||
this.listQuery.pageSize = 10;
|
console.error('获取产线列表失败:', err);
|
||||||
this.listQuery.bindObjectId = val.bindObjectId ? val.bindObjectId : undefined;
|
|
||||||
this.listQuery.statisticType = val.statisticType ? val.statisticType : undefined;
|
|
||||||
this.listQuery.startTime = val.timeVal ? val.timeVal[0]: undefined;
|
|
||||||
this.listQuery.endTime = val.timeVal ? val.timeVal[1]: undefined;
|
|
||||||
|
|
||||||
//this.listQuery.reportEndTime = val.timeVal ? [new Date(val.timeVal[1]).getTime()] : undefined;
|
|
||||||
this.getDataList();
|
|
||||||
break;
|
|
||||||
case 'export':
|
|
||||||
this.handleExport();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log(val);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 获取数据列表
|
|
||||||
getDataList() {
|
|
||||||
this.dataListLoading = true;
|
|
||||||
this.urlOptions.getDataListURL(this.listQuery).then(response => {
|
|
||||||
const arr = ['班组','日', '周', '月', '年'];
|
|
||||||
this.tableData = response.data?.list?.map((item) => {
|
|
||||||
item.reportType = arr[this.listQuery.statisticType];
|
|
||||||
item.statisticType = this.listQuery.statisticType
|
|
||||||
|
|
||||||
// 匹配 bindObjectName
|
|
||||||
const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
|
|
||||||
item.bindObjectName = targetLine ? targetLine.name : ''; // 赋值名称,无匹配则为空
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
this.listQuery.total = response.data.total;
|
|
||||||
this.dataListLoading = false;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 每页数
|
selectChange(val) {
|
||||||
|
console.log('选择变更:', val);
|
||||||
|
this.selectedList = val;
|
||||||
|
},
|
||||||
|
buttonClick(val) {
|
||||||
|
console.log('头部按钮点击:', val);
|
||||||
|
switch (val.btnName) {
|
||||||
|
case 'search':
|
||||||
|
this.listQuery.pageNo = 1;
|
||||||
|
this.listQuery.pageSize = 10;
|
||||||
|
this.listQuery.bindObjectId = val.bindObjectId ? val.bindObjectId : undefined;
|
||||||
|
this.listQuery.statisticType = val.statisticType ? val.statisticType : undefined;
|
||||||
|
|
||||||
|
// 处理不同时间维度的时间范围
|
||||||
|
this.handleTimeRange(val);
|
||||||
|
|
||||||
|
this.getDataList();
|
||||||
|
break;
|
||||||
|
case 'export':
|
||||||
|
this.handleExport();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('未知按钮:', val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 处理不同时间维度的时间范围
|
||||||
|
handleTimeRange(val) {
|
||||||
|
const statisticType = val.statisticType;
|
||||||
|
const timeVal = val.timeVal;
|
||||||
|
|
||||||
|
const timeValDay = val.timeValDay;
|
||||||
|
|
||||||
|
const timeValWeek = val.timeValWeek;
|
||||||
|
const timeValMonth = val.timeValMonth;
|
||||||
|
const timeValYear = val.timeValYear;
|
||||||
|
|
||||||
|
|
||||||
|
// 重置时间参数
|
||||||
|
this.listQuery.startTime = undefined;
|
||||||
|
this.listQuery.endTime = undefined;
|
||||||
|
|
||||||
|
switch (statisticType) {
|
||||||
|
case '0': // 班组 - 沿用原时间范围
|
||||||
|
if (timeVal && timeVal.length === 2) {
|
||||||
|
this.listQuery.startTime = timeVal[0];
|
||||||
|
this.listQuery.endTime = timeVal[1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '1': // 日 - 沿用原时间范围
|
||||||
|
if (timeValDay && timeValDay.length === 2) {
|
||||||
|
this.listQuery.startTime = timeValDay[0];
|
||||||
|
this.listQuery.endTime = timeValDay[1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '3': // 月 - 沿用原时间范围
|
||||||
|
if (timeValMonth && timeValMonth.length === 2) {
|
||||||
|
this.listQuery.startTime = timeValMonth[0];
|
||||||
|
this.listQuery.endTime = timeValMonth[1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '2': // 周 - 自动计算本周范围
|
||||||
|
if (timeValWeek) {
|
||||||
|
const [start, end] = getSelectedWeekRange(timeValWeek);
|
||||||
|
this.listQuery.startTime = formatDateTime(start);
|
||||||
|
this.listQuery.endTime = formatDateTime(end);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '4': // 年 - 自动计算本年范围
|
||||||
|
if (timeValYear) {
|
||||||
|
const [start, end] = getSelectedYearRange(timeValYear);
|
||||||
|
this.listQuery.startTime = formatDateTime(start);
|
||||||
|
this.listQuery.endTime = formatDateTime(end);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 获取数据列表
|
||||||
|
getDataList() {
|
||||||
|
this.dataListLoading = true;
|
||||||
|
this.urlOptions.getDataListURL(this.listQuery)
|
||||||
|
.then(response => {
|
||||||
|
const arr = ['班组', '日', '周', '月', '年'];
|
||||||
|
// Vue2 中数组赋值确保响应式
|
||||||
|
this.tableData = (response.data?.list || []).map(item => {
|
||||||
|
item.reportType = arr[this.listQuery.statisticType] || '';
|
||||||
|
item.statisticType = this.listQuery.statisticType;
|
||||||
|
|
||||||
|
// 匹配产线名称
|
||||||
|
// const targetLine = this.pdLineList.find(line => line.id === item.bindObjectId);
|
||||||
|
// item.bindObjectName = targetLine ? targetLine.name : ''
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
this.listQuery.total = response.data?.total || 0;
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('获取数据失败:', err);
|
||||||
|
this.tableData = [];
|
||||||
|
this.listQuery.total = 0;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.dataListLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 每页数变更
|
||||||
sizeChangeHandle(val) {
|
sizeChangeHandle(val) {
|
||||||
this.listQuery.pageSize = val;
|
this.listQuery.pageSize = val;
|
||||||
this.listQuery.pageNo = 1;
|
this.listQuery.pageNo = 1;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
// 当前页
|
// 当前页变更
|
||||||
currentChangeHandle(val) {
|
currentChangeHandle(val) {
|
||||||
this.listQuery.pageNo = val;
|
this.listQuery.pageNo = val;
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
|
// 导出处理
|
||||||
handleExport() {
|
handleExport() {
|
||||||
// 处理查询参数
|
const params = { ...this.listQuery };
|
||||||
let params = { ...this.listQuery };
|
// 移除分页参数
|
||||||
params.pageNo = undefined;
|
delete params.pageNo;
|
||||||
params.pageSize = undefined;
|
delete params.pageSize;
|
||||||
this.$modal.confirm('是否确认导出原片报表?').then(() => {
|
delete params.total;
|
||||||
this.exportLoading = true;
|
|
||||||
return exportCostOriginRadioHisData(params);
|
this.$modal.confirm('是否确认导出原片报表?')
|
||||||
}).then(response => {
|
.then(() => {
|
||||||
this.$download.excel(response, '原片报表.xls');
|
this.exportLoading = true;
|
||||||
this.exportLoading = false;
|
return exportCostOriginRadioHisData(params);
|
||||||
}).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>
|
||||||
|
|||||||
274
src/views/core/monitoring/rawFilmReport/searchBar.vue
Normal file
274
src/views/core/monitoring/rawFilmReport/searchBar.vue
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
<template>
|
||||||
|
<div class="searchBarBox divHeight" ref="searchBarRef" :style="{ paddingRight: isFold ? '55px' : '0px' }">
|
||||||
|
<el-form :inline="true" ref="searchBarForm" :model="formInline" class="searchBar">
|
||||||
|
<span class="blue-block" v-if="removeBlue ? false : true"></span>
|
||||||
|
<template v-for="item in formConfig">
|
||||||
|
<el-form-item v-if="item.type !== ''" :key="item.param" :label="item.label ? item.label : ''"
|
||||||
|
:required="item.required ? item.required : false">
|
||||||
|
<el-input v-if="item.type === 'input'" v-model="formInline[item.param]"
|
||||||
|
:size="item.size ? item.size : 'small'" clearable :disabled="item.disabled ? item.disabled : false"
|
||||||
|
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'"
|
||||||
|
:placeholder="item.placeholder ? item.placeholder : ''" />
|
||||||
|
<el-select v-if="item.type === 'select'" v-model="formInline[item.param]"
|
||||||
|
:size="item.size ? item.size : 'small'" :filterable="item.filterable ? item.filterable : false"
|
||||||
|
:multiple="item.multiple ? item.multiple : false" :clearable="item.clearable === false ? false : true"
|
||||||
|
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'" :placeholder="item.label" @change="
|
||||||
|
item.onchange
|
||||||
|
? $emit('select-changed', {
|
||||||
|
param: item.param,
|
||||||
|
value: formInline[item.param]
|
||||||
|
})
|
||||||
|
: null
|
||||||
|
">
|
||||||
|
<el-option v-for="(sub, i) in item.selectOptions" :key="i"
|
||||||
|
:label="item.labelField ? sub[item.labelField] : sub['name']"
|
||||||
|
:value="item.valueField ? sub[item.valueField] : sub['id']" />
|
||||||
|
</el-select>
|
||||||
|
<el-date-picker v-if="item.type === 'datePicker'" :key="item.param" :size="item.size ? item.size : 'small'"
|
||||||
|
v-model="formInline[item.param]" :type="item.dateType" :format="item.format ? item.format : 'yyyy-MM-dd'"
|
||||||
|
:value-format="item.valueFormat ? item.valueFormat : null" :default-time="item.defaultTime || null"
|
||||||
|
:range-separator="item.rangeSeparator || null" :start-placeholder="item.startPlaceholder || null"
|
||||||
|
:end-placeholder="item.endPlaceholder || null" :placeholder="item.placeholder"
|
||||||
|
:picker-options="item.pickerOptions ? item.pickerOptions : null"
|
||||||
|
:clearable="item.clearable === false ? false : true"
|
||||||
|
:style="item.width ? 'width:' + item.width + 'px' : (item.dateType === 'datetimerange' ? 'width:340px' : (item.dateType === 'daterange' ? 'width:220px' : 'width:140px'))" />
|
||||||
|
<el-autocomplete v-if="item.type === 'autocomplete'" v-model="formInline[item.param]"
|
||||||
|
:value-key="item.valueKey ? item.valueKey : 'value'" :size="item.size ? item.size : 'small'"
|
||||||
|
:fetch-suggestions="item.querySearch" :placeholder="item.placeholder"
|
||||||
|
:clearable="item.clearable === false ? false : true"
|
||||||
|
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'" filterable />
|
||||||
|
<el-cascader v-if="item.type === 'cascader'" v-model="formInline[item.param]" :options="item.selectOptions"
|
||||||
|
:props="item.cascaderProps" :size="item.size ? item.size : 'small'"
|
||||||
|
:clearable="item.clearable === false ? false : true"
|
||||||
|
:show-all-levels="item.showAllLevels === false ? false : true"
|
||||||
|
:collapse-tags="item.collapseTags === true ? true : false"
|
||||||
|
:style="item.width ? 'width:' + item.width + 'px' : 'width:200px'" @change="
|
||||||
|
item.onChange
|
||||||
|
? $emit('cascader-change', {
|
||||||
|
param: item.param,
|
||||||
|
value: formInline[item.param]
|
||||||
|
})
|
||||||
|
: null
|
||||||
|
"></el-cascader>
|
||||||
|
<el-button v-if="item.type === 'button'" :type="item.color" :size="item.size ? item.size : 'small'"
|
||||||
|
:plain="item.plain ? item.plain : false" :round="item.round ? item.round : false"
|
||||||
|
@click="headBtnClick(item.name)">{{ item.btnName }}</el-button>
|
||||||
|
<span v-if="item.type === 'separate'" class="separateStyle"></span>
|
||||||
|
<!-- 可用于显示其他按钮 -->
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
<el-form-item>
|
||||||
|
<slot></slot>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<span v-if="isFold" class="foldClass" @click='switchMode'>
|
||||||
|
{{ isExpand ? '收起' : '展开' }}
|
||||||
|
<i class="iconfont" :class="isExpand ? 'icon-upward' : 'icon-downward'"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'SearchBar',
|
||||||
|
props: {
|
||||||
|
formConfigs: {
|
||||||
|
type: Array,
|
||||||
|
default: () => {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeBlue: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
isFold: {// 多行模式(默认否)
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
const formInline = {}
|
||||||
|
const formConfig = this.formConfigs
|
||||||
|
let hasExtraOptions = false
|
||||||
|
for (const obj of formConfig) {
|
||||||
|
if (obj.type !== 'button') {
|
||||||
|
if (obj.defaultSelect === false || obj.defaultSelect === 0) {
|
||||||
|
formInline[obj.param] = obj.defaultSelect
|
||||||
|
} else {
|
||||||
|
formInline[obj.param] = obj.defaultSelect || '' // defaultSelect下拉框默认选中项
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj.extraOptions) {
|
||||||
|
hasExtraOptions = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
formInline,
|
||||||
|
formConfig,
|
||||||
|
hasExtraOptions,
|
||||||
|
isExpand: false // 是否展开(默认否)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
formConfig: {
|
||||||
|
handler() {
|
||||||
|
for (const obj of this.formConfig) {
|
||||||
|
if (obj.defaultSelect) {
|
||||||
|
this.formInline[obj.param] = obj.defaultSelect
|
||||||
|
} else if (obj.defaultSelect === null) {
|
||||||
|
// 需要手动从外部清除选项缓存的情况,确保在外部配置项中可直接设置null
|
||||||
|
this.formInline[obj.param] = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
formInline: {
|
||||||
|
handler: function () {
|
||||||
|
this.$forceUpdate()
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.init()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init() {
|
||||||
|
if (this.hasExtraOptions) {
|
||||||
|
// 如果有额外参数就处理,如果没有就算了
|
||||||
|
for (const obj of this.formConfig) {
|
||||||
|
if (obj.extraOptions) {
|
||||||
|
// 注: 对obj.extraOptions的选择是互斥的!
|
||||||
|
this.$watch(
|
||||||
|
`formInline.${obj.param}`,
|
||||||
|
function (newVal) {
|
||||||
|
let deleteCount = 0
|
||||||
|
if (obj.index + 1 < this.formConfig.length) {
|
||||||
|
// 如果obj不是最后一个配置
|
||||||
|
const nextConfig = this.formConfig[obj.index + 1]
|
||||||
|
if (nextConfig.parent && nextConfig.parent === obj.param)
|
||||||
|
deleteCount = 1
|
||||||
|
}
|
||||||
|
const currentConfig = Object.assign(
|
||||||
|
{},
|
||||||
|
obj.extraOptions[newVal]
|
||||||
|
)
|
||||||
|
this.formConfig.splice(
|
||||||
|
obj.index + 1,
|
||||||
|
deleteCount,
|
||||||
|
currentConfig
|
||||||
|
)
|
||||||
|
// 修改 formInline
|
||||||
|
this.$set(this.formInline, currentConfig.param, '')
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headBtnClick(btnName) {
|
||||||
|
this.formInline.btnName = btnName
|
||||||
|
this.$emit('headBtnClick', this.formInline)
|
||||||
|
},
|
||||||
|
resetForm() {
|
||||||
|
this.$refs.searchBarForm.resetFields()
|
||||||
|
const formInline = {}
|
||||||
|
const formConfig = this.formConfigs
|
||||||
|
for (const obj of formConfig) {
|
||||||
|
if (obj.type !== 'button') {
|
||||||
|
if (obj.defaultSelect === false || obj.defaultSelect === 0) {
|
||||||
|
formInline[obj.param] = obj.defaultSelect
|
||||||
|
} else {
|
||||||
|
formInline[obj.param] = obj.defaultSelect || '' // defaultSelect下拉框默认选中项
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.formInline = formInline
|
||||||
|
},
|
||||||
|
switchMode() {// 展开和收起切换
|
||||||
|
this.isExpand = !this.isExpand
|
||||||
|
const element = this.$refs.searchBarRef
|
||||||
|
if (this.isExpand) {
|
||||||
|
element.classList.remove('divHeight')
|
||||||
|
} else {
|
||||||
|
element.classList.add('divHeight')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.searchBarBox {
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBarBox::after {
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.divHeight {
|
||||||
|
height: 45px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBar .blue-block {
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
width: 4px;
|
||||||
|
height: 16px;
|
||||||
|
background-color: #0B58FF;
|
||||||
|
border-radius: 1px;
|
||||||
|
margin-right: 8px;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBar .el-form-item {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBar .el-date-editor .el-range__icon {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #0B58FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBar .el-input__prefix .el-icon-date {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #0B58FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBar .el-input__prefix .el-icon-time {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #0B58FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBar .separateStyle {
|
||||||
|
display: inline-block;
|
||||||
|
width: 1px;
|
||||||
|
height: 24px;
|
||||||
|
background: #E8E8E8;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBarBox .foldClass {
|
||||||
|
position: absolute;
|
||||||
|
top: 14px;
|
||||||
|
right: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #0B58FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBarBox .foldClass .iconfont {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,423 +1,430 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="home-page">
|
<div class="app-container">
|
||||||
<div class="date-tabs">
|
<!-- 顶部日期&筛选栏 -->
|
||||||
<!-- @tab-click="handleClick" -->
|
<el-row :gutter="20" class="top-bar">
|
||||||
<el-tabs v-model="activeName" @tab-click="timedayChange" :stretch="true">
|
<el-col :span="8">
|
||||||
<el-tab-pane
|
|
||||||
:label="'\u2002\u2002日\u2002\u2002'"
|
|
||||||
name="日"></el-tab-pane>
|
|
||||||
<el-tab-pane
|
|
||||||
:label="'\u2002\u2002周\u2002\u2002'"
|
|
||||||
name="周"></el-tab-pane>
|
|
||||||
<el-tab-pane
|
|
||||||
:label="'\u2002\u2002月\u2002\u2002'"
|
|
||||||
name="月"></el-tab-pane>
|
|
||||||
<el-tab-pane
|
|
||||||
:label="'\u2002\u2002年\u2002\u2002'"
|
|
||||||
name="年"></el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
<div class="detail">
|
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="timeday"
|
v-model="dateRange"
|
||||||
align="right"
|
type="daterange"
|
||||||
type="date"
|
range-separator="~"
|
||||||
format="yyyy-MM-dd"
|
start-placeholder="开始日期"
|
||||||
valueFormat="yyyy-MM-dd"
|
end-placeholder="结束日期"
|
||||||
:clearable="false"
|
value-format="yyyy-MM-dd" />
|
||||||
@change="timedayChange"
|
<el-button type="primary" style="margin-left: 10px">查询</el-button>
|
||||||
placeholder="选择日期"
|
|
||||||
:picker-options="pickerOptions"></el-date-picker>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<el-row class="main-top" :gutter="16">
|
|
||||||
<el-col :span="24" style="position: relative">
|
|
||||||
<div class="title">
|
|
||||||
<svg-icon icon-class="home-produce" />
|
|
||||||
<span class="title-inner">生产总成本</span>
|
|
||||||
</div>
|
|
||||||
<el-row class="box">
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.priceS }}万元</div>
|
|
||||||
<div class="unit-style">总计成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.matPriceS }}万元</div>
|
|
||||||
<div class="unit-style">原料成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.energyPriceS }}万元</div>
|
|
||||||
<div class="unit-style">能源成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.otherPriceS }}万元</div>
|
|
||||||
<div class="unit-style">其他成本</div>
|
|
||||||
</el-col>
|
|
||||||
<!-- <el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.ratioS }}</div>
|
|
||||||
<div class="unit-style">综合良品率/%</div>
|
|
||||||
</el-col> -->
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.areaPriceS }}元</div>
|
|
||||||
<div class="unit-style">综合每平米成本</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24" style="position: relative">
|
<el-col :span="16">
|
||||||
<div class="title">
|
<el-tag type="info" @click="changeTime('yesterday')">昨日</el-tag>
|
||||||
<svg-icon icon-class="home-produce" />
|
<el-tag type="info" @click="changeTime('week')">本周</el-tag>
|
||||||
<span class="title-inner">原片成本</span>
|
<el-tag type="info" @click="changeTime('month')">本月</el-tag>
|
||||||
</div>
|
<el-tag type="info" @click="changeTime('year')">本年</el-tag>
|
||||||
<el-row class="box">
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.priceO }}万元</div>
|
|
||||||
<div class="unit-style">原片总成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.matPriceO }}万元</div>
|
|
||||||
<div class="unit-style">原料成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.energyPriceO }}万元</div>
|
|
||||||
<div class="unit-style">能源成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.otherPriceO }}万元</div>
|
|
||||||
<div class="unit-style">其他成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.ratioO }}</div>
|
|
||||||
<div class="unit-style">原片良品率/%</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.areaPriceO }}元</div>
|
|
||||||
<div class="unit-style">原片每平米成本</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24" style="position: relative">
|
|
||||||
<div class="title">
|
|
||||||
<svg-icon icon-class="home-produce" />
|
|
||||||
<span class="title-inner">深加工成本</span>
|
|
||||||
</div>
|
|
||||||
<el-row class="box">
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.priceD }}万元</div>
|
|
||||||
<div class="unit-style">深加工总成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.energyPriceD }}万元</div>
|
|
||||||
<div class="unit-style">能源成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.otherPriceD }}万元</div>
|
|
||||||
<div class="unit-style">其他成本</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.ratioD }}</div>
|
|
||||||
<div class="unit-style">深加工良品率/%</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4" class="num-box shadow">
|
|
||||||
<div class="num-style">{{ homeData.areaPriceD }}元</div>
|
|
||||||
<div class="unit-style">深加工每平米成本</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row class="main-bottom" :gutter="16" v-if="false">
|
|
||||||
<el-col :span="9">
|
<!-- 成本概览卡片 -->
|
||||||
<div class="chart-wrapper">
|
<el-row :gutter="20" class="card-row">
|
||||||
<line-chart :chart-data="lineChartData" />
|
<el-col :span="8">
|
||||||
</div>
|
<el-card class="cost-card">
|
||||||
</el-col>
|
<div class="card-title">总制造成本(元/平米)</div>
|
||||||
<el-col :span="7">
|
<div class="card-content">
|
||||||
<div class="chart-wrapper">
|
<div>
|
||||||
<pie-chart />
|
目标
|
||||||
</div>
|
<span class="target-val">16</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
实际
|
||||||
|
<span class="actual-val">12.8</span>
|
||||||
|
</div>
|
||||||
|
<el-progress :stroke-width="13" :percentage="80" color="#42b983" />
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div class="chart-wrapper">
|
<el-card class="cost-card">
|
||||||
<bar-chart />
|
<div class="card-title">原片成本(元/平米)</div>
|
||||||
</div>
|
<div class="card-content">
|
||||||
|
<div>
|
||||||
|
目标
|
||||||
|
<span class="target-val">16</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
实际
|
||||||
|
<span class="actual-val">12.8</span>
|
||||||
|
</div>
|
||||||
|
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-card class="cost-card">
|
||||||
|
<div class="card-title">加工成本(元/平米)</div>
|
||||||
|
<div class="card-content">
|
||||||
|
<div>
|
||||||
|
目标
|
||||||
|
<span class="target-val">16</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
实际
|
||||||
|
<span class="actual-val">12.8</span>
|
||||||
|
</div>
|
||||||
|
<el-progress :stroke-width="13" :percentage="99" color="#42b983" />
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 成本构成区域 -->
|
||||||
|
<el-row :gutter="20" class="composition-row">
|
||||||
|
<!-- 饼图 -->
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-card class="composition-card">
|
||||||
|
<div class="card-title">成本构成</div>
|
||||||
|
<div id="costPie" class="chart" style="height: 350px"></div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<!-- 原片/加工成本子项 -->
|
||||||
|
<el-col :span="18">
|
||||||
|
<el-card class="composition-card">
|
||||||
|
<div class="card-title">成本构成</div>
|
||||||
|
|
||||||
|
<!-- 原片成本子项 -->
|
||||||
|
<div class="sub-cost-group">
|
||||||
|
<div class="sub-cost-title">原片成本</div>
|
||||||
|
<div class="sub-cost">
|
||||||
|
<div
|
||||||
|
v-for="(item, idx) in rawSubCosts"
|
||||||
|
:key="idx"
|
||||||
|
class="sub-cost-div">
|
||||||
|
<div class="sub-cost-name">
|
||||||
|
{{ item.name }}
|
||||||
|
<div class="sub-cost-val">{{ item.val }}</div>
|
||||||
|
</div>
|
||||||
|
<div style="text-align: center">
|
||||||
|
<el-progress
|
||||||
|
type="circle"
|
||||||
|
:percentage="89"
|
||||||
|
:width="60"
|
||||||
|
:stroke-width="10"
|
||||||
|
:show-text="false"
|
||||||
|
color="#e74c3c" />
|
||||||
|
</div>
|
||||||
|
<div class="sub-cost-name">
|
||||||
|
目标
|
||||||
|
<span class="red-text">{{ item.target }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="sub-cost-name">
|
||||||
|
完成率
|
||||||
|
<span class="red-text">89%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-divider></el-divider>
|
||||||
|
<!-- 加工成本子项 -->
|
||||||
|
<div class="sub-cost-group" style="margin-top: 20px">
|
||||||
|
<div class="sub-cost-title">加工成本</div>
|
||||||
|
<div class="sub-cost">
|
||||||
|
<div
|
||||||
|
v-for="(item, idx) in processSubCosts"
|
||||||
|
:key="idx"
|
||||||
|
class="sub-cost-div">
|
||||||
|
<div class="sub-cost-name">
|
||||||
|
{{ item.name }}
|
||||||
|
<div class="sub-cost-val">{{ item.val }}</div>
|
||||||
|
</div>
|
||||||
|
<div style="text-align: center">
|
||||||
|
<el-progress
|
||||||
|
type="circle"
|
||||||
|
:percentage="89"
|
||||||
|
:width="60"
|
||||||
|
:stroke-width="10"
|
||||||
|
:show-text="false"
|
||||||
|
color="#e74c3c" />
|
||||||
|
</div>
|
||||||
|
<div class="sub-cost-name">
|
||||||
|
目标
|
||||||
|
<span class="red-text">{{ item.target }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="sub-cost-name">
|
||||||
|
完成率
|
||||||
|
<span class="red-text">89%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 趋势图区域 -->
|
||||||
|
<el-row :gutter="20" class="trend-row">
|
||||||
|
<!-- 总制造成本趋势 -->
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-card class="trend-card">
|
||||||
|
<div class="card-title">总制造成本趋势</div>
|
||||||
|
<div id="totalTrend" class="chart" style="height: 300px"></div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<!-- 原片/加工成本趋势 -->
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-card class="trend-card">
|
||||||
|
<div class="card-title">原片/加工成本趋势</div>
|
||||||
|
<el-tabs v-model="costTab" type="card" style="margin-bottom: 10px">
|
||||||
|
<el-tab-pane label="原片成本" name="raw"></el-tab-pane>
|
||||||
|
<el-tab-pane label="加工成本" name="process"></el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<div id="rawProcessTrend" class="chart" style="height: 300px"></div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<!-- 单项成本趋势 -->
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-card class="trend-card">
|
||||||
|
<div class="card-title">单项成本趋势</div>
|
||||||
|
<el-tabs v-model="itemTab" type="card" style="margin-bottom: 10px">
|
||||||
|
<el-tab-pane label="人工成本" name="labor"></el-tab-pane>
|
||||||
|
<el-tab-pane label="原料成本" name="material"></el-tab-pane>
|
||||||
|
<el-tab-pane label="制造费用" name="expense"></el-tab-pane>
|
||||||
|
<el-tab-pane label="玻璃热耗" name="heat"></el-tab-pane>
|
||||||
|
<el-tab-pane label="原片成品率" name="yield"></el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<div id="itemTrend" class="chart" style="height: 300px"></div>
|
||||||
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div
|
|
||||||
class="main-footer"
|
|
||||||
style="
|
|
||||||
color: #c7c7c7;
|
|
||||||
user-select: none;
|
|
||||||
font-size: 14px;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
height: 30px;
|
|
||||||
display: grid;
|
|
||||||
place-content: center;
|
|
||||||
">
|
|
||||||
© 中建材智能自动化研究院有限公司
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment';
|
import * as echarts from 'echarts';
|
||||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
|
||||||
import LineChart from '../dashboard/LineChart';
|
|
||||||
import PieChart from '../dashboard/PieChart';
|
|
||||||
import BarChart from '../dashboard/BarChart';
|
|
||||||
import PanelGroup from '../dashboard/PanelGroup';
|
|
||||||
import { getData } from '@/api/cost/allCost';
|
|
||||||
import { getUserProfile } from '@/api/system/user';
|
|
||||||
|
|
||||||
const lineChartData = {
|
|
||||||
newVisitis: {
|
|
||||||
expectedData: [100, 120, 161, 134, 105, 160, 165],
|
|
||||||
actualData: [120, 82, 91, 154, 162, 140, 145],
|
|
||||||
},
|
|
||||||
messages: {
|
|
||||||
expectedData: [200, 192, 120, 144, 160, 130, 140],
|
|
||||||
actualData: [180, 160, 151, 106, 145, 150, 130],
|
|
||||||
},
|
|
||||||
purchases: {
|
|
||||||
expectedData: [80, 100, 121, 104, 105, 90, 100],
|
|
||||||
actualData: [120, 90, 100, 138, 142, 130, 130],
|
|
||||||
},
|
|
||||||
shoppings: {
|
|
||||||
expectedData: [130, 140, 141, 142, 145, 150, 160],
|
|
||||||
actualData: [120, 82, 91, 154, 162, 140, 130],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Home',
|
name: 'CostDashboard',
|
||||||
mixins: [tableHeightMixin],
|
|
||||||
components: {
|
|
||||||
LineChart,
|
|
||||||
PieChart,
|
|
||||||
PanelGroup,
|
|
||||||
BarChart,
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
gradientBackground() {
|
|
||||||
return {
|
|
||||||
'background-image':
|
|
||||||
'linear-gradient(90deg, #f0f0f0 25%, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0) 50%, #f0f0f0 50%, #f0f0f0 75%, rgba(255, 255, 255, 0) 75%, rgba(255, 255, 255, 0))',
|
|
||||||
'background-size': '100px 100px', // 调整条纹的大小
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeName: '日',
|
dateRange: ['2023-05-06', '2023-05-06'],
|
||||||
user: '',
|
costTab: 'raw',
|
||||||
lineChartData: lineChartData.newVisitis,
|
itemTab: 'labor',
|
||||||
homeData: {},
|
// 原片成本子项
|
||||||
timeday: moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD'),
|
rawSubCosts: [
|
||||||
startTime:
|
{ name: '人工成本', val: 4.56, target: 4.32 },
|
||||||
moment(new Date()).subtract(0, 'days').format('YYYY-MM-DD') +
|
{ name: '原料成本', val: 4.56, target: 4.32 },
|
||||||
' 00:00:00',
|
{ name: '原片制造费用', val: 4.56, target: 4.32 },
|
||||||
endTime:
|
{ name: '玻璃热耗', val: 4.56, target: 4.32 },
|
||||||
moment(new Date()).subtract(-1, 'days').format('YYYY-MM-DD') +
|
{ name: '原片成品率', val: 4.56, target: 4.32 },
|
||||||
' 00:00:00',
|
],
|
||||||
|
// 加工成本子项
|
||||||
pickerOptions: {
|
processSubCosts: [
|
||||||
disabledDate(time) {
|
{ name: '人工成本', val: 4.56, target: 4.32 },
|
||||||
return time.getTime() + 3600 * 1000 * 24 > Date.now();
|
{ name: '加工动力成本', val: 4.56, target: 4.32 },
|
||||||
},
|
{ name: '加工制造费用', val: 4.56, target: 4.32 },
|
||||||
shortcuts: [
|
{ name: '加工投入产出率', val: 4.56, target: 4.32 },
|
||||||
{
|
],
|
||||||
text: '今天',
|
// 趋势图模拟数据
|
||||||
onClick(picker) {
|
trendX: ['00:00', '01:00', '02:00'],
|
||||||
picker.$emit('pick', new Date());
|
trendY: [20, 40, 50],
|
||||||
},
|
targetY: 12.54,
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '昨天',
|
|
||||||
onClick(picker) {
|
|
||||||
const date = new Date();
|
|
||||||
date.setTime(date.getTime() - 3600 * 1000 * 24);
|
|
||||||
picker.$emit('pick', date);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '一周前',
|
|
||||||
onClick(picker) {
|
|
||||||
const date = new Date();
|
|
||||||
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
|
||||||
picker.$emit('pick', date);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
mounted() {
|
||||||
},
|
this.initCostPie();
|
||||||
beforeDestroy() {
|
this.initTotalTrend();
|
||||||
|
this.initRawProcessTrend();
|
||||||
|
this.initItemTrend();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getData() {
|
// 切换时间范围(示例)
|
||||||
let listQuery = {
|
changeTime(type) {
|
||||||
//分页
|
// 实际项目中需根据type请求对应数据
|
||||||
pageSize: 10,
|
console.log('切换时间:', type);
|
||||||
pageNo: 1,
|
},
|
||||||
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName),
|
// 初始化成本构成饼图
|
||||||
startTime: this.timeday + ' 00:00:00',
|
initCostPie() {
|
||||||
};
|
const pieChart = echarts.init(document.getElementById('costPie'));
|
||||||
getData(listQuery).then((response) => {
|
pieChart.setOption({
|
||||||
this.homeData = response.data;
|
tooltip: { trigger: 'item' },
|
||||||
for (let i in this.homeData) {
|
legend: {
|
||||||
this.homeData[i] = Number(this.homeData[i]).toFixed(2);
|
orient: 'horizontal', // 水平排列
|
||||||
}
|
bottom: 0, // 放在底部
|
||||||
|
icon: 'circle',
|
||||||
|
left: 'center',
|
||||||
|
formatter: function (name) {
|
||||||
|
return name;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
type: 'pie',
|
||||||
|
data: [
|
||||||
|
{ name: '原料成本(4.2元)', value: 29.9 },
|
||||||
|
{ name: '动力成本(2.1元)', value: 24 },
|
||||||
|
{ name: '人工成本(1.5元)', value: 24 },
|
||||||
|
{ name: '辅料成本(0.5元)', value: 21.2 },
|
||||||
|
{ name: '制造费用(0.5元)', value: 21.2 },
|
||||||
|
],
|
||||||
|
label: { show: false },
|
||||||
|
labelLine: { show: false },
|
||||||
|
bottom: 10,
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
window.addEventListener('resize', () => pieChart.resize());
|
||||||
},
|
},
|
||||||
timedayChange() {
|
// 初始化总制造成本趋势图
|
||||||
let listQuery = {
|
initTotalTrend() {
|
||||||
//分页
|
const totalChart = echarts.init(document.getElementById('totalTrend'));
|
||||||
pageSize: 10,
|
totalChart.setOption({
|
||||||
pageNo: 1,
|
grid: { top: 20, bottom: 30, left: 30, right: 10 },
|
||||||
statisticType: ['', '日', '周', '月', '年'].indexOf(this.activeName),
|
xAxis: { type: 'category', data: this.trendX },
|
||||||
startTime: this.timeday + ' 00:00:00',
|
yAxis: { type: 'value', min: -20, max: 60 },
|
||||||
};
|
series: [
|
||||||
getData(listQuery).then((response) => {
|
{
|
||||||
this.homeData = response.data;
|
name: '实际值',
|
||||||
for (let i in this.homeData) {
|
type: 'line',
|
||||||
this.homeData[i] = Number(this.homeData[i]).toFixed(2);
|
data: this.trendY,
|
||||||
}
|
lineStyle: { color: '#409eff' },
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
name: '目标值',
|
||||||
|
type: 'line',
|
||||||
|
data: [this.targetY, this.targetY, this.targetY],
|
||||||
|
lineStyle: { type: 'dashed', color: '#e6a23c' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
window.addEventListener('resize', () => totalChart.resize());
|
||||||
},
|
},
|
||||||
goDetail() {
|
// 初始化原片/加工成本趋势图
|
||||||
this.$router.push({ path: 'indexDetail' });
|
initRawProcessTrend() {
|
||||||
|
const rpChart = echarts.init(document.getElementById('rawProcessTrend'));
|
||||||
|
rpChart.setOption({
|
||||||
|
grid: { top: 10, bottom: 20, left: 20, right: 10 },
|
||||||
|
xAxis: { type: 'category', data: this.trendX },
|
||||||
|
yAxis: { type: 'value', min: -20, max: 60 },
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '实际值',
|
||||||
|
type: 'line',
|
||||||
|
data: this.trendY,
|
||||||
|
lineStyle: { color: '#409eff' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '目标值',
|
||||||
|
type: 'line',
|
||||||
|
data: [this.targetY, this.targetY, this.targetY],
|
||||||
|
lineStyle: { type: 'dashed', color: '#e6a23c' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
window.addEventListener('resize', () => rpChart.resize());
|
||||||
|
},
|
||||||
|
// 初始化单项成本趋势图
|
||||||
|
initItemTrend() {
|
||||||
|
const itemChart = echarts.init(document.getElementById('itemTrend'));
|
||||||
|
itemChart.setOption({
|
||||||
|
grid: { top: 10, bottom: 20, left: 20, right: 10 },
|
||||||
|
xAxis: { type: 'category', data: this.trendX },
|
||||||
|
yAxis: { type: 'value', min: -20, max: 60 },
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '实际值',
|
||||||
|
type: 'line',
|
||||||
|
data: this.trendY,
|
||||||
|
lineStyle: { color: '#409eff' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '目标值',
|
||||||
|
type: 'line',
|
||||||
|
data: [this.targetY, this.targetY, this.targetY],
|
||||||
|
lineStyle: { type: 'dashed', color: '#e6a23c' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
window.addEventListener('resize', () => itemChart.resize());
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped>
|
||||||
.home-page::before {
|
.top-bar {
|
||||||
background-image: url('~@/assets/img/home-bg.png');
|
|
||||||
background-size: cover;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
transform: rotate(180deg);
|
|
||||||
}
|
|
||||||
.date-tabs {
|
|
||||||
padding-left: 40px;
|
|
||||||
padding-top: 20px;
|
|
||||||
position: relative;
|
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
:deep(.date-tabs) {
|
.card-row,
|
||||||
.el-tabs__header {
|
.composition-row {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 20px;
|
||||||
display: inline-block;
|
|
||||||
transform: translateY(-12px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-tabs__content {
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-tabs__item {
|
|
||||||
font-size: 18px;
|
|
||||||
color: #fff;
|
|
||||||
padding-left: 0 !important;
|
|
||||||
padding-right: 0 !important;
|
|
||||||
line-height: 36px !important;
|
|
||||||
height: 36px;
|
|
||||||
}
|
|
||||||
.el-tabs__item.is-active {
|
|
||||||
color: #0b58ff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.detail {
|
.cost-card .card-title {
|
||||||
display: inline-block;
|
font-size: 22px;
|
||||||
position: absolute;
|
font-weight: bold;
|
||||||
left: 260px;
|
margin-bottom: 15px;
|
||||||
top: 10px;
|
|
||||||
}
|
}
|
||||||
:deep(.detail) {
|
.cost-card .card-content {
|
||||||
.el-input__inner {
|
display: grid;
|
||||||
background-color: transparent;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
color: white;
|
gap: 10px;
|
||||||
}
|
align-items: center;
|
||||||
}
|
|
||||||
// .current-date {
|
|
||||||
// color: #fff;
|
|
||||||
// font-size: 18px;
|
|
||||||
// position: absolute;
|
|
||||||
// left: 260px;
|
|
||||||
// top: 14px;
|
|
||||||
// }
|
|
||||||
.current-time {
|
|
||||||
color: #fff;
|
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
position: absolute;
|
|
||||||
right: 38px;
|
|
||||||
top: 14px;
|
|
||||||
}
|
}
|
||||||
.main-top {
|
.target-val {
|
||||||
width: 100%;
|
color: #666;
|
||||||
padding: 0 20px 0 40px;
|
margin-left: 5px;
|
||||||
.title {
|
font-size: 20px;
|
||||||
position: absolute;
|
|
||||||
left: 34px;
|
|
||||||
top: 20px;
|
|
||||||
width: 180px;
|
|
||||||
font-size: 32px;
|
|
||||||
z-index: 10;
|
|
||||||
.title-inner {
|
|
||||||
position: absolute;
|
|
||||||
left: 42px;
|
|
||||||
top: 5px;
|
|
||||||
font-size: calc(100vw * 20 / 1920);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.box {
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 24px;
|
|
||||||
height: 192px;
|
|
||||||
padding: 40px 24px 32px 24px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
box-shadow: 0 8px 8px 0 gray;
|
|
||||||
.num-box {
|
|
||||||
height: 120px;
|
|
||||||
padding-top: 26px;
|
|
||||||
text-align: center;
|
|
||||||
.num-style {
|
|
||||||
color: #000;
|
|
||||||
font-size: calc(100vw * 40 / 1920);
|
|
||||||
}
|
|
||||||
.unit-style {
|
|
||||||
color: rgba(0, 0, 0, 0.7);
|
|
||||||
font-size: calc(100vw * 18 / 1920);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.shadow {
|
|
||||||
background: linear-gradient(90deg, #ffffff 80%, #f2f4f9 100%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.main-bottom {
|
.actual-val {
|
||||||
width: 100%;
|
color: #42b983;
|
||||||
margin-top: 20px;
|
margin-left: 5px;
|
||||||
.chart-wrapper {
|
font-size: 20px;
|
||||||
margin-left: 10px;
|
}
|
||||||
height: 425px;
|
.composition-card {
|
||||||
background: #fff;
|
height: 480px;
|
||||||
border-radius: 5px;
|
}
|
||||||
box-shadow: 0 3px 3px 0 gray;
|
.composition-card .card-title {
|
||||||
}
|
font-size: 18px;
|
||||||
}
|
font-weight: bold;
|
||||||
</style>
|
margin-bottom: 15px;
|
||||||
<style lang="scss">
|
}
|
||||||
.home-page {
|
.sub-cost {
|
||||||
.el-progress-bar__inner {
|
display: grid;
|
||||||
background-image: url('~@/assets/img/home-progress-bg.png');
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
|
||||||
background-size: cover;
|
gap: 10px;
|
||||||
}
|
align-items: center;
|
||||||
|
}
|
||||||
|
.sub-cost-group .sub-cost-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.sub-cost-group .sub-cost-div {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid rgb(220, 220, 220, 0.5);
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.sub-cost-name {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.sub-cost-val {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.completion {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.red-text {
|
||||||
|
color: #e74c3c;
|
||||||
|
}
|
||||||
|
.trend-card {
|
||||||
|
height: 450px;
|
||||||
|
}
|
||||||
|
.trend-card .card-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
65
src/views/equipment/equipmentOverview/SmallTitle.vue
Normal file
65
src/views/equipment/equipmentOverview/SmallTitle.vue
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<!--
|
||||||
|
* @Author: zwq
|
||||||
|
* @Date: 2023-08-01 15:27:31
|
||||||
|
* @LastEditors: zwq
|
||||||
|
* @LastEditTime: 2023-08-01 16:25:54
|
||||||
|
* @Description:
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<div :class="[className, { 'p-0': noPadding }]">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
size: {
|
||||||
|
// 取值范围: xl lg md sm
|
||||||
|
type: String,
|
||||||
|
default: 'de',
|
||||||
|
validator: function (val) {
|
||||||
|
return ['xl', 'lg', 'de', 'md', 'sm'].indexOf(val) !== -1;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
noPadding: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
className: function () {
|
||||||
|
return `${this.size}-title`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
$pxls: (xl, 28px) (lg, 24px) (de, 20px) (md, 18px) (sm, 16px);
|
||||||
|
$mgr: 8px;
|
||||||
|
@each $size, $height in $pxls {
|
||||||
|
.#{$size}-title {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: $height;
|
||||||
|
color: #000;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: '微软雅黑', 'Microsoft YaHei', Arial, Helvetica, sans-serif;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
width: 4px;
|
||||||
|
height: $height + 2px;
|
||||||
|
border-radius: 1px;
|
||||||
|
margin-right: $mgr;
|
||||||
|
background-color: #0b58ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-0 {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
134
src/views/equipment/equipmentOverview/add-or-updata.vue
Normal file
134
src/views/equipment/equipmentOverview/add-or-updata.vue
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :visible.sync="visible" width="40%">
|
||||||
|
<small-title slot="title" :no-padding="true">
|
||||||
|
{{ this.dataForm.lineId + '·' + this.dataForm.equipmentName }}
|
||||||
|
</small-title>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="visual-part">
|
||||||
|
<base-table :table-props="tableProps"
|
||||||
|
:page="listQuery.pageNo" :limit="listQuery.pageSize" :table-data="tableData">
|
||||||
|
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
|
||||||
|
@clickBtn="handleClick" /> -->
|
||||||
|
</base-table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <div slot="footer" class="dialog-footer">
|
||||||
|
<el-button style="" @click="goback()">取消</el-button>
|
||||||
|
<el-button type="primary" @click="dataFormSubmit()">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</div> -->
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const tableProps = [
|
||||||
|
|
||||||
|
{
|
||||||
|
prop: 'paramName',
|
||||||
|
label: '参数名称'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'paramValue',
|
||||||
|
label: '当前值',
|
||||||
|
// filter: parseTime,
|
||||||
|
// width: 160
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
import { getParamMonitor } from '@/api/base/equipment';
|
||||||
|
// import { parseTime } from '../../mixins/code-filter';
|
||||||
|
import SmallTitle from './SmallTitle';
|
||||||
|
export default {
|
||||||
|
components: { SmallTitle },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
tableProps,
|
||||||
|
tableData:[],
|
||||||
|
listQuery: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize:100,
|
||||||
|
},
|
||||||
|
addOrUpdateVisible: false,
|
||||||
|
dataForm: {
|
||||||
|
equipmentId:undefined,
|
||||||
|
equipmentName: undefined,
|
||||||
|
lineId: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init(data) {
|
||||||
|
console.log(data.paramMonitors,'data');
|
||||||
|
|
||||||
|
this.dataForm.equipmentId = data.equipmentId || '';
|
||||||
|
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>
|
||||||
561
src/views/equipment/equipmentOverview/alarm-or-updata.vue
Normal file
561
src/views/equipment/equipmentOverview/alarm-or-updata.vue
Normal file
@@ -0,0 +1,561 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :visible.sync="visible" width="80%" @close="handleClose" title-class="dialog-title">
|
||||||
|
<small-title slot="title" :no-padding="true">
|
||||||
|
{{ dataForm.lineId + '·' + dataForm.equipmentName }}
|
||||||
|
</small-title>
|
||||||
|
<search-bar removeBlue :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||||
|
<el-tabs class="custom-tabs" v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
|
||||||
|
<el-tab-pane :label="'\u3000报警时长\u3000'" name="duration"></el-tab-pane>
|
||||||
|
<el-tab-pane :label="'\u3000报警次数\u3000'" name="times"></el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<div class="content">
|
||||||
|
<div class="visual-part">
|
||||||
|
<div v-if="hasData" style="display: flex; justify-content: space-around; gap: 20px; padding: 10px 0;">
|
||||||
|
<!-- 移除 v-if,始终渲染两个图表容器 -->
|
||||||
|
<div id="barChart" style="width: 48%; height: 400px;"></div>
|
||||||
|
<div id="pieChart" style="width: 48%; height: 400px;"></div>
|
||||||
|
</div>
|
||||||
|
<div v-if="!hasData" class="no-data">
|
||||||
|
<el-empty description="暂无相关报警数据"></el-empty>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getAlarmDet } from '@/api/base/equipment';
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import SmallTitle from './SmallTitle';
|
||||||
|
|
||||||
|
const CHART_CONFIG = {
|
||||||
|
barColor: '#288AFF',
|
||||||
|
pieColors: [
|
||||||
|
'#288AFF', '#4096FF', '#69B1FF', '#91CFFF', '#B8E0FF',
|
||||||
|
'#E0F2FF', '#1890FF', '#096DD9', '#0050B3', '#003A8C'
|
||||||
|
],
|
||||||
|
fontColor: '#333',
|
||||||
|
lightFontColor: '#666',
|
||||||
|
borderRadius: 4
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: { SmallTitle },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
hasData: false,
|
||||||
|
listQuery: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 100,
|
||||||
|
equipmentId: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined
|
||||||
|
},
|
||||||
|
formConfig: [
|
||||||
|
{
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间段',
|
||||||
|
dateType: 'daterange',
|
||||||
|
format: 'yyyy-MM-dd',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
defaultTime: ['00:00:00', '23:59:59'],
|
||||||
|
defaultSelect: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '查询',
|
||||||
|
name: 'search',
|
||||||
|
color: 'primary'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
activeLabel: 'duration', // 默认选中「报警时长」
|
||||||
|
dataForm: {
|
||||||
|
equipmentId: undefined,
|
||||||
|
equipmentName: undefined,
|
||||||
|
lineId: undefined
|
||||||
|
},
|
||||||
|
chartInstances: {
|
||||||
|
bar: null,
|
||||||
|
pie: null
|
||||||
|
},
|
||||||
|
isDomReady: false,
|
||||||
|
originData: null // 存储原始数据
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.isDomReady = true;
|
||||||
|
if (this.listQuery.equipmentId) {
|
||||||
|
this.getDataList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// Tab 切换时自动刷新图表(无需额外操作,依赖 handleTabClick 触发查询)
|
||||||
|
activeLabel() {
|
||||||
|
if (this.isDomReady && this.originData) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.renderBothCharts(); // 切换 Tab 后重新渲染两个图表
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initDefaultDate() {
|
||||||
|
const today = new Date();
|
||||||
|
const start = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0, 0).getTime();
|
||||||
|
const end = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 0).getTime();
|
||||||
|
|
||||||
|
this.formConfig[0].defaultSelect = [start, end];
|
||||||
|
this.listQuery.startTime = start;
|
||||||
|
this.listQuery.endTime = end;
|
||||||
|
|
||||||
|
if (this.$refs.searchBarForm) {
|
||||||
|
this.$refs.searchBarForm.form.timeVal = [start, end];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleTabClick() {
|
||||||
|
// 切换 Tab 时重新查询数据(或直接复用已有数据渲染)
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
|
||||||
|
buttonClick(val) {
|
||||||
|
switch (val.btnName) {
|
||||||
|
case 'search':
|
||||||
|
this.listQuery.startTime = val.timeVal?.[0];
|
||||||
|
this.listQuery.endTime = val.timeVal?.[1];
|
||||||
|
this.getDataList();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getDataList() {
|
||||||
|
try {
|
||||||
|
if (!this.listQuery.equipmentId) {
|
||||||
|
console.warn('设备ID不能为空');
|
||||||
|
this.hasData = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParams = {
|
||||||
|
equipmentId: this.listQuery.equipmentId,
|
||||||
|
startTime: this.listQuery.startTime,
|
||||||
|
endTime: this.listQuery.endTime,
|
||||||
|
};
|
||||||
|
|
||||||
|
const res = await getAlarmDet(queryParams);
|
||||||
|
const originData = res.data || [];
|
||||||
|
this.originData = originData;
|
||||||
|
this.hasData = originData.length > 0;
|
||||||
|
|
||||||
|
if (this.hasData && this.isDomReady) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.renderBothCharts(); // 数据查询成功后,同时渲染两个图表
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.destroyAllCharts();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取报警数据失败:', error);
|
||||||
|
this.hasData = false;
|
||||||
|
this.destroyAllCharts();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 核心方法:同时渲染柱状图和饼图(根据当前 Tab 类型)
|
||||||
|
renderBothCharts() {
|
||||||
|
if (this.activeLabel === 'duration') {
|
||||||
|
// 报警时长:柱状图(时长排序)+ 饼图(时长占比)
|
||||||
|
this.renderBarChart('duration');
|
||||||
|
this.renderPieChart('duration');
|
||||||
|
} else {
|
||||||
|
// 报警次数:柱状图(次数排序)+ 饼图(次数占比)
|
||||||
|
this.renderBarChart('times');
|
||||||
|
this.renderPieChart('times');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 渲染柱状图(支持两种数据类型)
|
||||||
|
renderBarChart(type) {
|
||||||
|
this.destroyChart('bar');
|
||||||
|
const chartDom = document.getElementById('barChart');
|
||||||
|
if (!chartDom || !this.originData.length) return;
|
||||||
|
|
||||||
|
// 根据类型排序和提取数据
|
||||||
|
let sortedData, xData, seriesData, yAxisName;
|
||||||
|
if (type === 'duration') {
|
||||||
|
// 报警时长:按时长降序
|
||||||
|
sortedData = [...this.originData].sort((a, b) => b.alarmDuration - a.alarmDuration);
|
||||||
|
seriesData = sortedData.map(item => item.alarmDuration);
|
||||||
|
yAxisName = '报警时长';
|
||||||
|
} else {
|
||||||
|
// 报警次数:按次数降序
|
||||||
|
sortedData = [...this.originData].sort((a, b) => b.alarmCount - a.alarmCount);
|
||||||
|
seriesData = sortedData.map(item => item.alarmCount);
|
||||||
|
yAxisName = '报警次数';
|
||||||
|
}
|
||||||
|
|
||||||
|
xData = sortedData.map(item => this.truncateText(item.alarmContent, 8));
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.chartInstances.bar = echarts.init(chartDom);
|
||||||
|
const option = {
|
||||||
|
title: {
|
||||||
|
text: `${yAxisName}统计(柱状图)`,
|
||||||
|
left: 'center',
|
||||||
|
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis',
|
||||||
|
axisPointer: { type: 'shadow' },
|
||||||
|
padding: 10,
|
||||||
|
textStyle: { fontSize: 11 },
|
||||||
|
formatter: (params) => {
|
||||||
|
const index = params[0].dataIndex;
|
||||||
|
const item = sortedData[index];
|
||||||
|
return `
|
||||||
|
<div style="text-align: left;">
|
||||||
|
<div>${item.alarmContent}</div>
|
||||||
|
<div>${yAxisName}:${type === 'duration' ? item.alarmDuration : item.alarmCount}</div>
|
||||||
|
<div>占比:${type === 'duration' ? item.alarmDurationRatio.toFixed(2) : item.alarmCountRatio.toFixed(2)}%</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '5%',
|
||||||
|
right: '5%',
|
||||||
|
bottom: '18%',
|
||||||
|
top: '15%',
|
||||||
|
containLabel: true
|
||||||
|
},
|
||||||
|
xAxis: [
|
||||||
|
{
|
||||||
|
type: 'category',
|
||||||
|
data: xData,
|
||||||
|
axisTick: { alignWithLabel: true },
|
||||||
|
axisLabel: {
|
||||||
|
interval: 0,
|
||||||
|
fontSize: 12,
|
||||||
|
color: CHART_CONFIG.lightFontColor
|
||||||
|
},
|
||||||
|
axisLine: { lineStyle: { color: '#e8e8e8' } }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: yAxisName,
|
||||||
|
nameTextStyle: { fontSize: 11, color: CHART_CONFIG.lightFontColor },
|
||||||
|
axisLabel: {
|
||||||
|
fontSize: 11,
|
||||||
|
color: CHART_CONFIG.lightFontColor,
|
||||||
|
},
|
||||||
|
axisLine: { lineStyle: { color: '#e8e8e8' } },
|
||||||
|
splitLine: { lineStyle: { color: '#f5f5f5' } },
|
||||||
|
max: (value) => value.max * 1.2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: yAxisName,
|
||||||
|
type: 'bar',
|
||||||
|
itemStyle: {
|
||||||
|
color: CHART_CONFIG.barColor,
|
||||||
|
borderRadius: [CHART_CONFIG.borderRadius, CHART_CONFIG.borderRadius, 0, 0],
|
||||||
|
shadowBlur: 3,
|
||||||
|
shadowColor: 'rgba(40, 138, 255, 0.2)',
|
||||||
|
shadowOffsetY: 2
|
||||||
|
},
|
||||||
|
barWidth: '16',
|
||||||
|
data: seriesData,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
position: 'top',
|
||||||
|
distance: 6,
|
||||||
|
fontSize: 11,
|
||||||
|
color: CHART_CONFIG.fontColor,
|
||||||
|
formatter: (params) => `${params.value}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
this.chartInstances.bar.setOption(option);
|
||||||
|
this.addResizeListener('bar');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`${yAxisName}柱状图初始化失败:`, error);
|
||||||
|
setTimeout(() => this.renderBarChart(type), 200);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 渲染饼图(支持两种数据类型)
|
||||||
|
renderPieChart(type) {
|
||||||
|
this.destroyChart('pie');
|
||||||
|
const chartDom = document.getElementById('pieChart');
|
||||||
|
if (!chartDom || !this.originData.length) return;
|
||||||
|
|
||||||
|
// 根据类型处理饼图数据
|
||||||
|
let pieData, seriesName;
|
||||||
|
if (type === 'duration') {
|
||||||
|
// 报警时长:按时长占比处理
|
||||||
|
seriesName = '报警时长';
|
||||||
|
pieData = this.handlePieData(this.originData, 'alarmDuration', 'alarmDurationRatio');
|
||||||
|
} else {
|
||||||
|
// 报警次数:按次数占比处理
|
||||||
|
seriesName = '报警次数';
|
||||||
|
pieData = this.handlePieData(this.originData, 'alarmCount', 'alarmCountRatio');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.chartInstances.pie = echarts.init(chartDom);
|
||||||
|
const option = {
|
||||||
|
title: {
|
||||||
|
text: `${seriesName}统计(饼图)`,
|
||||||
|
left: 'center',
|
||||||
|
textStyle: { fontSize: 14, color: CHART_CONFIG.fontColor }
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'item',
|
||||||
|
padding: 10,
|
||||||
|
textStyle: { fontSize: 11 },
|
||||||
|
formatter: (params) => {
|
||||||
|
return `
|
||||||
|
<div style="text-align: left;">
|
||||||
|
<div>${params.name}</div>
|
||||||
|
<div>${seriesName}:${params.value}${type === 'duration' ? '' : '次'}</div>
|
||||||
|
<div>占比:${params.percent.toFixed(2)}%</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: seriesName,
|
||||||
|
type: 'pie',
|
||||||
|
radius: ['50%', '70%'],
|
||||||
|
center: ['50%', '55%'],
|
||||||
|
color: CHART_CONFIG.pieColors,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
position: 'outside',
|
||||||
|
distance: 15,
|
||||||
|
fontSize: 11,
|
||||||
|
color: CHART_CONFIG.lightFontColor,
|
||||||
|
formatter: (params) => {
|
||||||
|
const truncatedName = this.truncateText(params.name, 8);
|
||||||
|
return `${truncatedName}(${params.value}${type === 'duration' ? '' : '次'}, ${params.percent.toFixed(1)}%)`;
|
||||||
|
},
|
||||||
|
align: 'center',
|
||||||
|
baseline: 'middle'
|
||||||
|
},
|
||||||
|
labelLine: {
|
||||||
|
show: true,
|
||||||
|
length: 15,
|
||||||
|
length2: 20,
|
||||||
|
lineStyle: {
|
||||||
|
color: '#ccc',
|
||||||
|
width: 1,
|
||||||
|
type: 'solid'
|
||||||
|
},
|
||||||
|
smooth: 0.2
|
||||||
|
},
|
||||||
|
data: pieData,
|
||||||
|
emphasis: {
|
||||||
|
itemStyle: {
|
||||||
|
shadowBlur: 10,
|
||||||
|
shadowColor: 'rgba(0, 0, 0, 0.1)'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
color: CHART_CONFIG.fontColor,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: 500
|
||||||
|
},
|
||||||
|
labelLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: CHART_CONFIG.barColor,
|
||||||
|
width: 1.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
this.chartInstances.pie.setOption(option);
|
||||||
|
this.addResizeListener('pie');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`${seriesName}饼图初始化失败:`, error);
|
||||||
|
setTimeout(() => this.renderPieChart(type), 200);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 通用饼图数据处理(支持动态字段)
|
||||||
|
handlePieData(data, valueKey, ratioKey) {
|
||||||
|
const threshold = 5; // 占比低于5%合并为「其他」
|
||||||
|
let otherCount = 0;
|
||||||
|
const mainData = data.filter(item => {
|
||||||
|
if (item[ratioKey] >= threshold) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
otherCount += item[valueKey];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).map(item => ({
|
||||||
|
name: item.alarmContent,
|
||||||
|
value: item[valueKey],
|
||||||
|
ratio: item[ratioKey]
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (otherCount > 0) {
|
||||||
|
mainData.push({
|
||||||
|
name: '其他',
|
||||||
|
value: otherCount,
|
||||||
|
ratio: 100 - mainData.reduce((sum, item) => sum + item.ratio, 0)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mainData;
|
||||||
|
},
|
||||||
|
|
||||||
|
truncateText(text, maxLength) {
|
||||||
|
if (!text) return '';
|
||||||
|
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
|
||||||
|
},
|
||||||
|
|
||||||
|
addResizeListener(type) {
|
||||||
|
const chart = this.chartInstances[type];
|
||||||
|
if (chart) {
|
||||||
|
const resizeHandler = () => chart.resize();
|
||||||
|
window.addEventListener('resize', resizeHandler);
|
||||||
|
chart.resizeHandler = resizeHandler;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
destroyChart(type) {
|
||||||
|
const chart = this.chartInstances[type];
|
||||||
|
if (chart) {
|
||||||
|
window.removeEventListener('resize', chart.resizeHandler);
|
||||||
|
chart.dispose();
|
||||||
|
this.chartInstances[type] = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
destroyAllCharts() {
|
||||||
|
Object.keys(this.chartInstances).forEach(type => {
|
||||||
|
this.destroyChart(type);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleClose() {
|
||||||
|
this.destroyAllCharts();
|
||||||
|
this.formConfig[0].defaultSelect = [];
|
||||||
|
this.listQuery.startTime = undefined;
|
||||||
|
this.listQuery.endTime = undefined;
|
||||||
|
this.originData = null;
|
||||||
|
this.hasData = true;
|
||||||
|
if (this.$refs.searchBarForm) {
|
||||||
|
// this.$refs.searchBarForm.form.timeVal = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
init(data) {
|
||||||
|
this.dataForm = {
|
||||||
|
equipmentId: data.equipmentId || '',
|
||||||
|
equipmentName: data.equipmentName || '',
|
||||||
|
lineId: data.lineId || ''
|
||||||
|
};
|
||||||
|
this.activeLabel = 'duration'
|
||||||
|
this.listQuery.equipmentId = data.equipmentId || undefined;
|
||||||
|
this.visible = true;
|
||||||
|
this.originData = null;
|
||||||
|
this.hasData = false;
|
||||||
|
|
||||||
|
this.initDefaultDate();
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.isDomReady = true;
|
||||||
|
this.getDataList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
this.destroyAllCharts();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* 保持原有样式,优化图表容器布局 */
|
||||||
|
.drawer>>>.el-drawer {
|
||||||
|
border-radius: 8px 0 0 8px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer>>>.el-form-item__label {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer>>>.el-drawer__header {
|
||||||
|
margin: 0;
|
||||||
|
padding: 32px 32px 24px;
|
||||||
|
border-bottom: 1px solid #dcdfe6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer>>>.el-drawer__body {
|
||||||
|
flex: 1;
|
||||||
|
height: 1px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer>>>.content {
|
||||||
|
padding: 30px 24px;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer>>>.visual-part {
|
||||||
|
flex: 1 auto;
|
||||||
|
max-height: 76vh;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 优化图表容器响应式布局 */
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.visual-part>div {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
#barChart,
|
||||||
|
#pieChart {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 350px !important;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer>>>.el-form,
|
||||||
|
.drawer>>>.attr-list {
|
||||||
|
padding: 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-body__footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
1309
src/views/equipment/equipmentOverview/index.vue
Normal file
1309
src/views/equipment/equipmentOverview/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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-10 10:39:33
|
* @LastEditTime: 2025-11-14 21:13:10
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container" style="padding-top:0">
|
<div class="app-container" style="padding-top: 0">
|
||||||
<div v-for="item in groupClassArr" :key="item.planId">
|
<div v-for="item in groupClassArr" :key="item.planId">
|
||||||
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
|
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
|
||||||
{{item.deptName + ' - ' +item.planName}}
|
{{ item.deptName + ' - ' + item.planName }}
|
||||||
</small-title>
|
</small-title>
|
||||||
<base-table
|
<base-table
|
||||||
:table-props="tableProps"
|
:table-props="tableProps"
|
||||||
@@ -59,7 +59,7 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
init(det) {
|
init(det, detSort) {
|
||||||
this.tableData = det;
|
this.tableData = det;
|
||||||
//返回计划名和id
|
//返回计划名和id
|
||||||
const arr = det.map((item) => {
|
const arr = det.map((item) => {
|
||||||
@@ -77,7 +77,19 @@ export default {
|
|||||||
map.set(item.planId, item);
|
map.set(item.planId, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.groupClassArr = Array.from(map.values());
|
const newArr = Array.from(map.values());
|
||||||
|
// 创建B数组中id的顺序映射
|
||||||
|
const orderMap = new Map();
|
||||||
|
detSort.forEach((item, index) => {
|
||||||
|
orderMap.set(item, index);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 根据B的顺序对A进行排序
|
||||||
|
this.groupClassArr = [...newArr].sort((a, b) => {
|
||||||
|
const orderA = orderMap.get(a.planId);
|
||||||
|
const orderB = orderMap.get(b.planId);
|
||||||
|
return orderA - orderB;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,212 +2,221 @@
|
|||||||
* @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-10 10:40:13
|
* @LastEditTime: 2025-11-25 09:39:43
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<el-row :gutter="10" style="background-color: #f2f4f9">
|
<div
|
||||||
<!--部门数据-->
|
class="app-container"
|
||||||
<el-col :span="4">
|
style="
|
||||||
<div class="head-container">
|
background-color: #f2f4f9;
|
||||||
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
|
padding: 0;
|
||||||
<el-tab-pane label="部门" name="first"></el-tab-pane>
|
display: grid;
|
||||||
<el-tab-pane label="班组" name="second"></el-tab-pane>
|
grid-template-columns: 1fr 5fr;
|
||||||
</el-tabs>
|
gap: 10px;
|
||||||
<div v-if="activeName == 'first'">
|
">
|
||||||
<el-input
|
<div class="head-container">
|
||||||
v-model="deptName"
|
<el-tabs v-model="activeName" stretch @tab-click="tabsClick">
|
||||||
placeholder="请输入部门名称"
|
<el-tab-pane label="部门" name="first"></el-tab-pane>
|
||||||
clearable
|
<el-tab-pane label="班组" name="second"></el-tab-pane>
|
||||||
size="small"
|
</el-tabs>
|
||||||
prefix-icon="el-icon-search"
|
<div v-if="activeName == 'first'">
|
||||||
style="margin-bottom: 20px" />
|
<el-input
|
||||||
<el-tree
|
v-model="deptName"
|
||||||
:data="deptOptions"
|
placeholder="请输入部门名称"
|
||||||
:props="defaultProps"
|
clearable
|
||||||
:expand-on-click-node="false"
|
size="small"
|
||||||
:filter-node-method="filterNode"
|
prefix-icon="el-icon-search"
|
||||||
ref="tree"
|
style="margin-bottom: 20px" />
|
||||||
default-expand-all
|
<el-tree
|
||||||
highlight-current
|
:data="deptOptions"
|
||||||
@node-click="handleNodeClick" />
|
:props="defaultProps"
|
||||||
</div>
|
:expand-on-click-node="false"
|
||||||
<div v-else>
|
:filter-node-method="filterNode"
|
||||||
<el-input
|
ref="tree"
|
||||||
v-model="groupName"
|
node-key="id"
|
||||||
placeholder="请输入班组名称"
|
default-expand-all
|
||||||
clearable
|
highlight-current
|
||||||
size="small"
|
@node-click="handleNodeClick" />
|
||||||
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>
|
||||||
</el-col>
|
<div v-else>
|
||||||
<el-col :span="20">
|
<el-input
|
||||||
<div class="groupTeamScheduling">
|
v-model="groupName"
|
||||||
<div class="operationArea">
|
placeholder="请输入班组名称"
|
||||||
<el-form :inline="true" class="demo-form-inline">
|
clearable
|
||||||
<span class="blue-block"></span>
|
size="small"
|
||||||
<el-form-item label="月份选择">
|
prefix-icon="el-icon-search"
|
||||||
<el-date-picker
|
style="margin-bottom: 20px" />
|
||||||
v-model="startDay"
|
<el-tree
|
||||||
type="month"
|
:data="groupOptions"
|
||||||
placeholder="选择月"
|
:props="defaultProps"
|
||||||
size="small"
|
:expand-on-click-node="false"
|
||||||
@change="selectMonth"
|
:filter-node-method="filterNode"
|
||||||
:clearable="false"
|
ref="tree1"
|
||||||
style="width: 120px"></el-date-picker>
|
node-key="id"
|
||||||
<span
|
default-expand-all
|
||||||
style="color: #909399; font-size: 12px"
|
highlight-current
|
||||||
v-if="activeName == 'first'">
|
@node-click="handleNodeClick1" />
|
||||||
提示:排班日历仅展示当前选中部门的节假日设置,若休假日中仍有排班,则表示下级组织已通过自定义假期进行排班。
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="groupTeamScheduling">
|
||||||
|
<div class="operationArea">
|
||||||
|
<el-form :inline="true" class="demo-form-inline">
|
||||||
|
<span class="blue-block"></span>
|
||||||
|
<el-form-item label="月份选择">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="startDay"
|
||||||
|
type="month"
|
||||||
|
placeholder="选择月"
|
||||||
|
size="small"
|
||||||
|
@change="selectMonth"
|
||||||
|
:clearable="false"
|
||||||
|
style="width: 120px"></el-date-picker>
|
||||||
|
<span
|
||||||
|
style="color: #909399; font-size: 12px"
|
||||||
|
v-if="activeName == 'first'">
|
||||||
|
提示:排班日历仅展示当前选中部门的节假日设置,若休假日中仍有排班,则表示下级组织已通过自定义假期进行排班。
|
||||||
|
</span>
|
||||||
|
<span v-else style="margin-left: 10px">
|
||||||
|
组长:
|
||||||
|
<span style="font-weight: 600; margin: 0 10px">
|
||||||
|
{{ showTeamName?.leaderName || '-' }}
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
组长电话:
|
||||||
组长:{{ showTeamName?.leaderName || '-' }} 组长电话:{{
|
<span style="font-weight: 600; margin: 0 10px">
|
||||||
showTeamName?.leaderPhone || '-'
|
{{ showTeamName?.leaderPhone || '-' }}
|
||||||
}}
|
|
||||||
</span>
|
</span>
|
||||||
</el-form-item>
|
</span>
|
||||||
<el-form-item style="float: right">
|
</el-form-item>
|
||||||
<el-button
|
<el-form-item style="float: right">
|
||||||
size="small"
|
<el-button
|
||||||
type="primary"
|
size="small"
|
||||||
@click="(startDay = new Date()), getHolidayPage()">
|
type="primary"
|
||||||
跳转到今天
|
@click="(startDay = new Date()), getHolidayPage()">
|
||||||
</el-button>
|
跳转到今天
|
||||||
</el-form-item>
|
</el-button>
|
||||||
</el-form>
|
</el-form-item>
|
||||||
</div>
|
</el-form>
|
||||||
<!-- 日历区域 -->
|
</div>
|
||||||
<div class="calenderArea">
|
<!-- 日历区域 -->
|
||||||
<el-calendar v-model="startDay">
|
<div class="calenderArea">
|
||||||
<template slot="dateCell" slot-scope="{ data }">
|
<el-calendar v-model="startDay">
|
||||||
<div v-if="data.type === 'current-month'">
|
<template slot="dateCell" slot-scope="{ data }">
|
||||||
<!-- 日期 -->
|
<div v-if="data.type === 'current-month'">
|
||||||
<div class="dateStyle">
|
<!-- 日期 -->
|
||||||
<el-row :gutter="20">
|
<div class="dateStyle">
|
||||||
<!-- 公历和农历 -->
|
<el-row :gutter="20">
|
||||||
<el-col :span="18">
|
<!-- 公历和农历 -->
|
||||||
{{ Number(data.day.split('-')[2]) }}
|
<el-col :span="18">
|
||||||
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
|
{{ Number(data.day.split('-')[2]) }}
|
||||||
</el-col>
|
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
|
||||||
<!-- 显示假或班 -->
|
</el-col>
|
||||||
<el-col :span="6">
|
<!-- 显示假或班 -->
|
||||||
<div
|
<el-col :span="6">
|
||||||
class="work-tip"
|
|
||||||
:style="{
|
|
||||||
backgroundColor: HolidayList[
|
|
||||||
Number(data.day.split('-')[2]) - 1
|
|
||||||
]?.isHoliday
|
|
||||||
? '#67C23A'
|
|
||||||
: '#409EFF',
|
|
||||||
}">
|
|
||||||
{{
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.isHoliday
|
|
||||||
? '假'
|
|
||||||
: '班'
|
|
||||||
}}
|
|
||||||
<!-- //变更节假日未更新排班计划的角标 -->
|
|
||||||
<div
|
|
||||||
class="subIcon"
|
|
||||||
v-if="
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.isUpdate
|
|
||||||
">
|
|
||||||
<el-tooltip
|
|
||||||
effect="dark"
|
|
||||||
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
|
|
||||||
placement="top">
|
|
||||||
<i
|
|
||||||
class="el-icon-warning"
|
|
||||||
style="color: #f56c6c"></i>
|
|
||||||
</el-tooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
<!-- 显示排班 -->
|
|
||||||
<div
|
<div
|
||||||
v-if="
|
class="work-tip"
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]?.det
|
:style="{
|
||||||
.length > 0
|
backgroundColor: HolidayList[
|
||||||
">
|
|
||||||
<el-col
|
|
||||||
:span="24"
|
|
||||||
v-for="(item, index) in HolidayList[
|
|
||||||
Number(data.day.split('-')[2]) - 1
|
Number(data.day.split('-')[2]) - 1
|
||||||
]?.det.filter(
|
]?.isHoliday
|
||||||
(item) =>
|
? '#67C23A'
|
||||||
item.schedulingPlanId ==
|
: '#409EFF',
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
}">
|
||||||
?.schedulingPlanId
|
{{
|
||||||
)"
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
:key="index">
|
?.isHoliday
|
||||||
|
? '假'
|
||||||
|
: '班'
|
||||||
|
}}
|
||||||
|
<!-- //变更节假日未更新排班计划的角标 -->
|
||||||
|
<div
|
||||||
|
class="subIcon"
|
||||||
|
v-if="
|
||||||
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
|
?.isUpdate
|
||||||
|
">
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
effect="dark"
|
effect="dark"
|
||||||
content="点击展示全部排班计划"
|
content="本日节假日变更已影响当前排班计划,但尚未同步,请及时处理。"
|
||||||
placement="top-start">
|
placement="top">
|
||||||
<div
|
<i class="el-icon-warning" style="color: #f56c6c"></i>
|
||||||
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>
|
||||||
</el-col>
|
</div>
|
||||||
</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>
|
||||||
</template>
|
</div>
|
||||||
</el-calendar>
|
<div
|
||||||
</div>
|
v-else
|
||||||
|
style="font-size: 20px; font-weight: 500; text-align: left">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="24">
|
||||||
|
{{ Number(data.day.split('-')[2]) }}
|
||||||
|
<span style="font-size: 12px">
|
||||||
|
{{ getLunarDate(data.day) }}
|
||||||
|
</span>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-calendar>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</div>
|
||||||
<base-dialog
|
<base-dialog
|
||||||
:dialogTitle="dialogTitle"
|
:dialogTitle="dialogTitle"
|
||||||
:dialogVisible="logVisible"
|
:dialogVisible="logVisible"
|
||||||
@@ -228,7 +237,7 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</base-dialog>
|
</base-dialog>
|
||||||
</el-row>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -339,13 +348,43 @@ export default {
|
|||||||
getEnableData().then((response) => {
|
getEnableData().then((response) => {
|
||||||
// 处理 deptOptions 参数
|
// 处理 deptOptions 参数
|
||||||
this.deptOptions = [];
|
this.deptOptions = [];
|
||||||
this.deptOptions.push(...this.handleTree(response.data, 'id'));
|
this.deptOptions.push(...this.handleTree1(response.data, 'id'));
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.tree.setCurrentKey(this.deptId);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
listByDeptId(this.topDept.id).then((response) => {
|
listByDeptId(this.topDept.id).then((response) => {
|
||||||
this.groupOptions = [];
|
this.groupOptions = [];
|
||||||
this.groupOptions.push(...response.data);
|
this.groupOptions.push(...response.data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
//大整数精度丢失
|
||||||
|
handleTree1(data, fid) {
|
||||||
|
const id = fid || 'id';
|
||||||
|
const parentId = 'parentId';
|
||||||
|
const children = 'children';
|
||||||
|
const rootId =
|
||||||
|
data
|
||||||
|
.map((item) => item[parentId].toString())
|
||||||
|
.reduce((min, current) => {
|
||||||
|
if (current.length < min.length) return current;
|
||||||
|
if (current.length > min.length) return min;
|
||||||
|
return current < min ? current : min;
|
||||||
|
}) || 0;
|
||||||
|
//对源数据深度克隆
|
||||||
|
const cloneData = JSON.parse(JSON.stringify(data));
|
||||||
|
//循环所有项
|
||||||
|
const treeData = cloneData.filter((father) => {
|
||||||
|
let branchArr = cloneData.filter((child) => {
|
||||||
|
//返回每一项的子级数组
|
||||||
|
return father[id] == child[parentId];
|
||||||
|
});
|
||||||
|
branchArr.length > 0 ? (father.children = branchArr) : '';
|
||||||
|
//返回第一层
|
||||||
|
return father[parentId] == rootId;
|
||||||
|
});
|
||||||
|
return treeData !== '' ? treeData : data;
|
||||||
|
},
|
||||||
// 筛选节点
|
// 筛选节点
|
||||||
filterNode(value, data) {
|
filterNode(value, data) {
|
||||||
if (!value) return true;
|
if (!value) return true;
|
||||||
@@ -358,8 +397,14 @@ export default {
|
|||||||
leaderName: this.groupOptions[0].leaderName || '-',
|
leaderName: this.groupOptions[0].leaderName || '-',
|
||||||
leaderPhone: this.groupOptions[0].leaderPhone || '-',
|
leaderPhone: this.groupOptions[0].leaderPhone || '-',
|
||||||
};
|
};
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.tree1.setCurrentKey(this.teamId);
|
||||||
|
});
|
||||||
} else if (this.activeName == 'first') {
|
} else if (this.activeName == 'first') {
|
||||||
this.deptId = this.topDept.id;
|
this.deptId = this.topDept.id;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.tree.setCurrentKey(this.deptId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.getHolidayPage();
|
this.getHolidayPage();
|
||||||
},
|
},
|
||||||
@@ -441,11 +486,11 @@ export default {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
holidayLog(det, date) {
|
holidayLog(det, date, detSort) {
|
||||||
this.dialogTitle = this.showDeptName + '-' + date + '-排班详情';
|
this.dialogTitle = this.showDeptName + '-' + date + '-排班详情';
|
||||||
this.logVisible = true;
|
this.logVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.holidayLogRef.init(det);
|
this.$refs.holidayLogRef.init(det, detSort);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelLog() {
|
cancelLog() {
|
||||||
@@ -459,8 +504,8 @@ export default {
|
|||||||
.head-container {
|
.head-container {
|
||||||
padding: 20px 10px 0;
|
padding: 20px 10px 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
min-height: calc(100vh - 120px - 8px);
|
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
.groupTeamScheduling {
|
.groupTeamScheduling {
|
||||||
.operationArea {
|
.operationArea {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-11 14:27:37
|
* @Date: 2025-10-11 14:27:37
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-11-10 16:20:13
|
* @LastEditTime: 2025-11-14 22:00:10
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -104,7 +104,7 @@ export default {
|
|||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.urlOptions.getDataListURL(this.formInline).then((response) => {
|
this.urlOptions.getDataListURL(this.formInline).then((response) => {
|
||||||
this.tableData = response.data.list;
|
this.tableData = response.data.list.filter(item=>item.enabled===1);
|
||||||
this.tableData.forEach(item=>item.teamId= item.id)
|
this.tableData.forEach(item=>item.teamId= item.id)
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.selectedArr.length > 0) {
|
if (this.selectedArr.length > 0) {
|
||||||
|
|||||||
@@ -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-11-11 15:32:04
|
* @LastEditTime: 2025-12-03 15:48:26
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -138,7 +138,14 @@
|
|||||||
<el-tag type="warning" style="color: black" v-if="!isClassTimePass">
|
<el-tag type="warning" style="color: black" v-if="!isClassTimePass">
|
||||||
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
||||||
两班倒和三班倒的班次设置时间
|
两班倒和三班倒的班次设置时间
|
||||||
<span style="color: red">不能重叠,且必须连续覆盖24小时。</span>
|
<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>
|
</el-tag>
|
||||||
</small-title>
|
</small-title>
|
||||||
<base-table
|
<base-table
|
||||||
@@ -443,7 +450,7 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
stepNum: 1, // 当前第几步
|
stepNum: 1, // 当前第几步
|
||||||
isEdit: false, //是否是编辑状态,编辑的时候,让前端上一步和取消都不用接口
|
isEdit: false, //是否是编辑状态,编辑的时候,让前端上一步和取消都不用接口
|
||||||
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType,到第二步,判断dataForm.shiftType是否改变,同时改变班次信息
|
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType,到第二步,判断dataForm.shiftType是否改变,同时改变班次信息
|
||||||
//第一步参数
|
//第一步参数
|
||||||
dataForm: {
|
dataForm: {
|
||||||
@@ -531,7 +538,8 @@ export default {
|
|||||||
btnName: '编辑',
|
btnName: '编辑',
|
||||||
},
|
},
|
||||||
].filter((v) => v),
|
].filter((v) => v),
|
||||||
isClassTimePass: true, //修改班次时间后,需要判断时间是否有覆盖,且是否覆盖24小时
|
isClassTimePass: true, //修改班次时间后,需要判断时间是否有重叠,且是否在24小时内 true是没问题的
|
||||||
|
covers24Hours: true, //修改班次时间后,需要判断时间是否覆盖24小时连续的时间 true是没问题的
|
||||||
tableData1: [],
|
tableData1: [],
|
||||||
tableProps2,
|
tableProps2,
|
||||||
tableBtn2: [
|
tableBtn2: [
|
||||||
@@ -621,9 +629,9 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init(id,isEdit) {
|
init(id, isEdit) {
|
||||||
this.dataForm.id = id || undefined;
|
this.dataForm.id = id || undefined;
|
||||||
this.isEdit = isEdit || false
|
this.isEdit = isEdit || false;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs['dataForm'].resetFields();
|
this.$refs['dataForm'].resetFields();
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
@@ -634,12 +642,18 @@ export default {
|
|||||||
this.tableData1 = res.data?.stepTwo.groupPlanClassesBaseVOList;
|
this.tableData1 = res.data?.stepTwo.groupPlanClassesBaseVOList;
|
||||||
this.tableData2 = res.data?.stepTwo.groupPlanTeamBaseVOList;
|
this.tableData2 = res.data?.stepTwo.groupPlanTeamBaseVOList;
|
||||||
this.tableData2.forEach((item, index) => {
|
this.tableData2.forEach((item, index) => {
|
||||||
let lineName = '';
|
let lineName = [];
|
||||||
if (item.isProduction) {
|
if (item.isProduction) {
|
||||||
lineName = this.setLineName(item.bindLineTree);
|
lineName = this.setLineName(item.bindLineTree);
|
||||||
|
this.$set(
|
||||||
|
this.tableData2[index],
|
||||||
|
'lineName',
|
||||||
|
lineName.join(';')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this.$set(this.tableData2[index], 'lineName', lineName);
|
|
||||||
});
|
});
|
||||||
|
this.stepNum = 3;
|
||||||
|
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getCode().then((res) => {
|
getCode().then((res) => {
|
||||||
@@ -757,7 +771,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//班次验证
|
//班次验证
|
||||||
if (!this.isClassTimePass) {
|
if (!this.isClassTimePass || !this.covers24Hours) {
|
||||||
this.$message('班次内时间有误,请重新填写!');
|
this.$message('班次内时间有误,请重新填写!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -777,9 +791,10 @@ export default {
|
|||||||
data.groupPlanClassesBaseVOList.push(obj);
|
data.groupPlanClassesBaseVOList.push(obj);
|
||||||
});
|
});
|
||||||
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
||||||
this.tableData2.forEach((item) => {
|
this.tableData2.forEach((item, index) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
teamId: item.id,
|
sort: index + 1,
|
||||||
|
teamId: item.teamId || item.id,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
leaderName: item.leaderName,
|
leaderName: item.leaderName,
|
||||||
leaderPhone: item.leaderPhone,
|
leaderPhone: item.leaderPhone,
|
||||||
@@ -788,9 +803,13 @@ export default {
|
|||||||
data.groupPlanTeamBaseVOList.push(obj);
|
data.groupPlanTeamBaseVOList.push(obj);
|
||||||
});
|
});
|
||||||
createStepTwo(data).then((res) => {
|
createStepTwo(data).then((res) => {
|
||||||
this.stepNum += 1;
|
if (res.code === 200 || res.code === 0) {
|
||||||
this.$emit('setSN', this.stepNum);
|
this.stepNum += 1;
|
||||||
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
|
this.$emit('setSN', this.stepNum);
|
||||||
|
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
|
||||||
|
} else {
|
||||||
|
this.$message(res.msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -799,7 +818,7 @@ export default {
|
|||||||
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
||||||
this.tableData2.forEach((item) => {
|
this.tableData2.forEach((item) => {
|
||||||
const obj = {
|
const obj = {
|
||||||
teamId: item.id,
|
teamId: item.teamId || item.id,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
bindData: JSON.stringify(item.bindLineTree),
|
bindData: JSON.stringify(item.bindLineTree),
|
||||||
};
|
};
|
||||||
@@ -807,10 +826,14 @@ export default {
|
|||||||
});
|
});
|
||||||
checkPlan(data).then((RES) => {
|
checkPlan(data).then((RES) => {
|
||||||
createStepFour(this.dataForm.id).then((res) => {
|
createStepFour(this.dataForm.id).then((res) => {
|
||||||
this.$modal.msgSuccess('创建计划成功');
|
if (res.code === 200 || res.code === 0) {
|
||||||
this.stepNum = 1;
|
this.$modal.msgSuccess('创建计划成功');
|
||||||
this.$emit('setSN', this.stepNum);
|
this.stepNum = 1;
|
||||||
this.$emit('refreshDataList');
|
this.$emit('setSN', this.stepNum);
|
||||||
|
this.$emit('refreshDataList');
|
||||||
|
} else {
|
||||||
|
this.$message(res.msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -943,6 +966,57 @@ export default {
|
|||||||
return start1Min < end2Min && end1Min > start2Min;
|
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;
|
||||||
@@ -1023,7 +1097,7 @@ export default {
|
|||||||
this.tableData1.forEach((item, index) => {
|
this.tableData1.forEach((item, index) => {
|
||||||
item.sort = index + 1;
|
item.sort = index + 1;
|
||||||
});
|
});
|
||||||
//修改班次时间后,需要判断时间是否有覆盖,且是否覆盖24小时,isTimeOverlap方法返回false才是校验通过
|
//修改班次时间后,需要判断时间是否有重叠,且是否在24小时内,isTimeOverlap方法返回false才是校验通过
|
||||||
if (this.dataForm.shiftType == 2) {
|
if (this.dataForm.shiftType == 2) {
|
||||||
const twoClass = this.tableData1.map(({ startTime, endTime }) => ({
|
const twoClass = this.tableData1.map(({ startTime, endTime }) => ({
|
||||||
startTime,
|
startTime,
|
||||||
@@ -1061,6 +1135,11 @@ export default {
|
|||||||
);
|
);
|
||||||
this.isClassTimePass = !(result1 || result2 || result3);
|
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) {
|
||||||
@@ -1069,39 +1148,45 @@ export default {
|
|||||||
},
|
},
|
||||||
refreshTableData3(index, val) {
|
refreshTableData3(index, val) {
|
||||||
this.tableData2[index].bindLineTree = val;
|
this.tableData2[index].bindLineTree = val;
|
||||||
let lineName = '';
|
let lineName = this.setLineName(val);
|
||||||
lineName = this.setLineName(val);
|
|
||||||
if (lineName) {
|
if (lineName) {
|
||||||
this.$set(this.tableData2[index], 'lineName', lineName);
|
this.$set(this.tableData2[index], 'lineName', lineName.join(';'));
|
||||||
}
|
}
|
||||||
this.cancel3();
|
this.cancel3();
|
||||||
},
|
},
|
||||||
//提取绑定的产线工段名展示出来
|
//提取绑定的产线工段名展示出来
|
||||||
setLineName(val) {
|
setLineName(data) {
|
||||||
if (!val || val.length === 0) return '';
|
const paths = [];
|
||||||
|
|
||||||
const currentLevelNames = val.map((item) => item.name);
|
const processNode = (node, currentPath = []) => {
|
||||||
|
const newPath = [...currentPath, node.name];
|
||||||
|
|
||||||
// 处理当前层级显示
|
if (node.children && node.children.length > 0) {
|
||||||
let currentDisplay = '';
|
// 检查子节点是否都是叶子节点
|
||||||
if (currentLevelNames.length > 1) {
|
const allChildrenAreLeaves = node.children.every(
|
||||||
currentDisplay = `(${currentLevelNames.join(' 、 ')})`;
|
(child) => !child.children || child.children.length === 0
|
||||||
} else {
|
);
|
||||||
currentDisplay = currentLevelNames[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查找所有子节点(取第一个有子节点的元素)
|
if (allChildrenAreLeaves && node.children.length > 1) {
|
||||||
const childNode = val.find(
|
// 如果所有子节点都是叶子节点且多于1个,用括号合并显示
|
||||||
(item) => item.children && item.children.length > 0
|
const leafNames = node.children
|
||||||
);
|
.map((child) => child.name)
|
||||||
if (childNode) {
|
.join(' 、 ');
|
||||||
const childPath = this.setLineName(childNode.children);
|
paths.push(`${newPath.join('/')}/(${leafNames})`);
|
||||||
if (childPath) {
|
} else if (allChildrenAreLeaves && node.children.length === 1) {
|
||||||
return `${currentDisplay} / ${childPath}`;
|
// 只有一个叶子子节点,用括号显示
|
||||||
|
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 currentDisplay;
|
return paths;
|
||||||
},
|
},
|
||||||
//第三步
|
//第三步
|
||||||
// 进来加载预览排班
|
// 进来加载预览排班
|
||||||
|
|||||||
@@ -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-10 16:07:01
|
* @LastEditTime: 2025-11-25 15:49:17
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -62,9 +62,9 @@ export default {
|
|||||||
},
|
},
|
||||||
processNode(node) {
|
processNode(node) {
|
||||||
// 创建唯一ID:类型-原始ID
|
// 创建唯一ID:类型-原始ID
|
||||||
const uniqueId = node.id + node.type;
|
const uniqueId = node.type+'L'+node.id;
|
||||||
if (node.type > 0) {
|
if (node.type > 0) {
|
||||||
node.fid = node.pid + node.type - 1;
|
node.fid = (node.type - 1)+'L'+node.pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -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-10 17:07:54
|
* @LastEditTime: 2025-11-25 15:14:53
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -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,25 +150,45 @@ 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((a, b) => a.sort - b.sort);
|
this.tableData1 = res.data?.groupPlanClassesBaseVOList.sort(
|
||||||
|
(a, b) => a.sort - b.sort
|
||||||
|
);
|
||||||
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
|
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
|
||||||
this.tableData2.forEach((item, index) => {
|
this.tableData2.forEach((item, index) => {
|
||||||
let lineName = '';
|
let lineName = '';
|
||||||
lineName = this.setLineName(item.bindLineTree, lineName);
|
if (item.isProduction) {
|
||||||
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
|
lineName = this.setLineName(item.bindLineTree);
|
||||||
|
}
|
||||||
|
this.$set(this.tableData2[index], 'lineName', lineName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//提取绑定的产线工段名展示出来
|
//提取绑定的产线工段名展示出来
|
||||||
setLineName(val, lineName) {
|
setLineName(val) {
|
||||||
val.forEach((item) => {
|
if (!val || val.length === 0) return '';
|
||||||
lineName += item.name + ':';
|
|
||||||
if (item.children && item.children.length > 0) {
|
const currentLevelNames = val.map((item) => item.name);
|
||||||
const childName = this.setLineName(item.children, lineName);
|
|
||||||
lineName = childName;
|
// 处理当前层级显示
|
||||||
|
let currentDisplay = '';
|
||||||
|
if (currentLevelNames.length > 1) {
|
||||||
|
currentDisplay = `(${currentLevelNames.join(' 、 ')})`;
|
||||||
|
} else {
|
||||||
|
currentDisplay = currentLevelNames[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找所有子节点(取第一个有子节点的元素)
|
||||||
|
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: 2025-10-13 15:07:24
|
* @Date: 2025-10-13 15:07:24
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-11-05 08:51:13
|
* @LastEditTime: 2025-11-28 09:56:09
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
v-model="formInline.startDay"
|
v-model="formInline.startDay"
|
||||||
size="small"
|
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">
|
||||||
@@ -40,6 +41,7 @@
|
|||||||
v-model="formInline.endDay"
|
v-model="formInline.endDay"
|
||||||
size="small"
|
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">
|
||||||
@@ -396,12 +398,12 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
formInline: {
|
formInline: {
|
||||||
code: '',
|
code: null,
|
||||||
name: '',
|
name: null,
|
||||||
startDay: '',
|
startDay: null,
|
||||||
endDay: '',
|
endDay: null,
|
||||||
deptId: '',
|
deptId: null,
|
||||||
status: '',
|
status: null,
|
||||||
},
|
},
|
||||||
stepNum: 1, // 新增编辑时当前第几步
|
stepNum: 1, // 新增编辑时当前第几步
|
||||||
detailVisible: false,
|
detailVisible: false,
|
||||||
@@ -419,29 +421,29 @@ export default {
|
|||||||
buttonClick(val) {
|
buttonClick(val) {
|
||||||
switch (val.btnName) {
|
switch (val.btnName) {
|
||||||
case 'search':
|
case 'search':
|
||||||
const date1 = new Date(this.formInline.startDay).getTime();
|
if (this.formInline.startDay > this.formInline.endDay) {
|
||||||
const date2 = new Date(this.formInline.endDay).getTime();
|
|
||||||
|
|
||||||
if (date1 > date2) {
|
|
||||||
this.$message('开始时间不得晚于结束时间');
|
this.$message('开始时间不得晚于结束时间');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
total: 1,
|
total: 1,
|
||||||
...this.formInline,
|
...this.formInline,
|
||||||
};
|
};
|
||||||
this.getDataList();
|
this.getDataList();
|
||||||
break;
|
break;
|
||||||
case 'reset':
|
case 'reset':
|
||||||
|
this.$refs.searchBarForm.resetFields();
|
||||||
this.formInline.name = null;
|
this.formInline.name = null;
|
||||||
this.formInline.code = null;
|
this.formInline.code = null;
|
||||||
this.formInline.deptId = null;
|
this.formInline.deptId = null;
|
||||||
this.$refs.deptSelect.clear();
|
this.$refs.deptSelect.clear();
|
||||||
this.formInline.status = null;
|
this.formInline.status = null;
|
||||||
|
this.formInline.startDay = null;
|
||||||
|
this.formInline.endDay = null;
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
};
|
};
|
||||||
@@ -490,7 +492,8 @@ export default {
|
|||||||
this.addOrUpdateVisible = true;
|
this.addOrUpdateVisible = true;
|
||||||
this.addOrEditTitle = '编辑';
|
this.addOrEditTitle = '编辑';
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdate.init(val.data.id,true);
|
this.stepNum = 3;
|
||||||
|
this.$refs.addOrUpdate.init(val.data.id, true);
|
||||||
});
|
});
|
||||||
} else if (val.type === 'delete') {
|
} else if (val.type === 'delete') {
|
||||||
this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex);
|
this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex);
|
||||||
@@ -505,13 +508,31 @@ export default {
|
|||||||
this.getDataList();
|
this.getDataList();
|
||||||
});
|
});
|
||||||
} else if (val.type === 'sync') {
|
} else if (val.type === 'sync') {
|
||||||
updateScheduleLater({
|
this.$confirm(
|
||||||
planId: val.data.id,
|
'当前节假日包含尚未同步的节假日变更,是否立即将上述节假日同步更新到排班计划?',
|
||||||
logId: val.data.updateLogId,
|
'同步节假日',
|
||||||
}).then((res) => {
|
{
|
||||||
this.$modal.msgSuccess('同步节假日成功');
|
confirmButtonText: '确认同步',
|
||||||
this.getDataList();
|
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('复制成功');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2021-11-18 14:16:25
|
* @Date: 2021-11-18 14:16:25
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-31 15:47:16
|
* @LastEditTime: 2025-11-27 14:49:34
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
<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="请输入班组名称" />
|
||||||
@@ -78,6 +79,7 @@
|
|||||||
<el-form-item label="生产班组" prop="isProduction">
|
<el-form-item label="生产班组" prop="isProduction">
|
||||||
<el-select
|
<el-select
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
@change="setIsProduction"
|
||||||
v-model="dataForm.isProduction"
|
v-model="dataForm.isProduction"
|
||||||
placeholder="请选择是否为生产班组">
|
placeholder="请选择是否为生产班组">
|
||||||
<el-option
|
<el-option
|
||||||
@@ -109,6 +111,7 @@ import {
|
|||||||
updateGroup,
|
updateGroup,
|
||||||
getGroup,
|
getGroup,
|
||||||
getCode,
|
getCode,
|
||||||
|
updateIsProduction,
|
||||||
} from '@/api/group/groupSetting';
|
} from '@/api/group/groupSetting';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -139,6 +142,7 @@ export default {
|
|||||||
remark: undefined,
|
remark: undefined,
|
||||||
},
|
},
|
||||||
setData: true,
|
setData: true,
|
||||||
|
nameDisable: false, //班组被使用时,班组名称不能修改
|
||||||
leaderArr: [],
|
leaderArr: [],
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
@@ -157,9 +161,7 @@ export default {
|
|||||||
name: [
|
name: [
|
||||||
{ required: true, message: '班组名称不能为空', trigger: 'blur' },
|
{ required: true, message: '班组名称不能为空', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
deptId: [
|
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
|
||||||
{ required: true, message: '部门不能为空', trigger: 'blur' },
|
|
||||||
],
|
|
||||||
leaderId: [
|
leaderId: [
|
||||||
{ required: true, message: '组长不能为空', trigger: 'change' },
|
{ required: true, message: '组长不能为空', trigger: 'change' },
|
||||||
],
|
],
|
||||||
@@ -191,6 +193,40 @@ export default {
|
|||||||
},
|
},
|
||||||
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) => {
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
|
<!--
|
||||||
|
* @Author: zwq
|
||||||
|
* @Date: 2025-10-11 14:41:12
|
||||||
|
* @LastEditors: zwq
|
||||||
|
* @LastEditTime: 2025-11-27 14:19:39
|
||||||
|
* @Description:
|
||||||
|
-->
|
||||||
<template>
|
<template>
|
||||||
<el-switch
|
<el-switch
|
||||||
@change="changeStatus"
|
@change="changeStatus"
|
||||||
size="small"
|
size="small"
|
||||||
v-model="list.enabled"
|
v-model="injectData.enabled"
|
||||||
:active-value="1"
|
:active-value="1"
|
||||||
:inactive-value="0"></el-switch>
|
:inactive-value="0"></el-switch>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { updateGroup } from '@/api/group/groupSetting';
|
import { updateGroup, updateIsProduction } from '@/api/group/groupSetting';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
injectData: {
|
injectData: {
|
||||||
@@ -17,17 +24,51 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {};
|
||||||
list: this.injectData,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
changeStatus(val) {
|
changeStatus(val) {
|
||||||
const data = { ...this.injectData, enabled: val };
|
const pdata = { ...this.injectData, enabled: val };
|
||||||
updateGroup(data).then((res) => {
|
updateIsProduction(this.injectData.id).then(({ data }) => {
|
||||||
this.$modal.msgSuccess('修改成功');
|
if (data) {
|
||||||
this.$emit('emitData');
|
this.$confirm(
|
||||||
|
'当前班组仍参与排班计划或正在执行工单。<br/>修改<strong> 班组状态 </strong>不会自动更新排班内容,可能导致排班信息与班组属性不一致,请注意核查!<br/>是否确认修改班组状态?',
|
||||||
|
'更新班组状态',
|
||||||
|
{
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
confirmButtonText: '确认修改',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
updateGroup(pdata).then((res) => {
|
||||||
|
if (res.code === 0 || res.code === 200) {
|
||||||
|
this.$modal.msgSuccess('修改成功');
|
||||||
|
this.$emit('emitData');
|
||||||
|
} else {
|
||||||
|
this.$modal.msg(res.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((res) => {
|
||||||
|
this.$emit('emitData');
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
updateGroup(pdata).then((res) => {
|
||||||
|
if (res.code === 0 || res.code === 200) {
|
||||||
|
this.$modal.msgSuccess('修改成功');
|
||||||
|
this.$emit('emitData');
|
||||||
|
} else {
|
||||||
|
this.$modal.msg(res.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2025-10-11 14:27:37
|
* @Date: 2025-10-11 14:27:37
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-10-29 14:44:41
|
* @LastEditTime: 2025-11-14 21:50:40
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -212,7 +212,7 @@ export default {
|
|||||||
case 'search':
|
case 'search':
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
total: 1,
|
total: 1,
|
||||||
...this.formInline,
|
...this.formInline,
|
||||||
};
|
};
|
||||||
@@ -225,7 +225,7 @@ export default {
|
|||||||
this.$refs.deptSelect.clear();
|
this.$refs.deptSelect.clear();
|
||||||
this.formInline.leaderName = null;
|
this.formInline.leaderName = null;
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
pageSize: 10,
|
pageSize: 20,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
total: 1,
|
total: 1,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2021-11-18 14:16:25
|
* @Date: 2021-11-18 14:16:25
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-11-11 10:29:18
|
* @LastEditTime: 2025-12-11 10:47:50
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
type="date"
|
type="date"
|
||||||
placeholder="选择日期"
|
placeholder="选择日期"
|
||||||
format="yyyy-MM-dd"
|
format="yyyy-MM-dd"
|
||||||
value-format="--MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
@blur="$forceUpdate()"
|
@blur="$forceUpdate()"
|
||||||
:picker-options="pickerOptions"></el-date-picker>
|
:picker-options="pickerOptions"></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
v-model="dataForm.dateDayArr"
|
v-model="dataForm.dateDayArr"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
format="yyyy-MM-dd"
|
format="yyyy-MM-dd"
|
||||||
value-format="--MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
range-separator="至"
|
range-separator="至"
|
||||||
start-placeholder="开始日期"
|
start-placeholder="开始日期"
|
||||||
end-placeholder="结束日期"
|
end-placeholder="结束日期"
|
||||||
@@ -213,6 +213,7 @@ export default {
|
|||||||
deptId: undefined,
|
deptId: undefined,
|
||||||
},
|
},
|
||||||
detail: false,
|
detail: false,
|
||||||
|
inherited: true,
|
||||||
options1: [
|
options1: [
|
||||||
{
|
{
|
||||||
value: 1,
|
value: 1,
|
||||||
@@ -330,54 +331,80 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init(deptId, val, detail) {
|
init(deptId, val, detail, inherited) {
|
||||||
this.dataForm.deptId = deptId || undefined;
|
this.dataForm.deptId = deptId || undefined;
|
||||||
this.dataForm.id = val.holidayId || undefined;
|
this.dataForm.id = val.holidayId || undefined;
|
||||||
this.dataForm.inherited = val.isInherit || false;
|
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.oneDay;
|
this.dataForm.dateDay =
|
||||||
|
year + '-' + this.dataForm.oneDay.slice(-5);
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 1
|
this.dataForm.calendarType == 1
|
||||||
) {
|
) {
|
||||||
|
let num = this.compareMonthDay(
|
||||||
|
this.dataForm.startDay.slice(-5),
|
||||||
|
this.dataForm.endDay.slice(-5)
|
||||||
|
);
|
||||||
this.dataForm.dateDayArr = [
|
this.dataForm.dateDayArr = [
|
||||||
this.dataForm.startDay,
|
year + '-' + this.dataForm.startDay.slice(-5),
|
||||||
this.dataForm.endDay,
|
(num > 0 ? year : year + 1) +
|
||||||
|
'-' +
|
||||||
|
this.dataForm.endDay.slice(-5),
|
||||||
];
|
];
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 1 &&
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
this.dataForm.dateDayChinese =
|
this.dataForm.dateDayChinese =
|
||||||
'L' +
|
'L' + year + this.dataForm.oneDayChinese.slice(-6);
|
||||||
new Date().getFullYear() +
|
|
||||||
this.dataForm.oneDayChinese.slice(-6);
|
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
) {
|
) {
|
||||||
|
let num = this.compareMonthDay(
|
||||||
|
this.dataForm.startDayChinese.slice(-6),
|
||||||
|
this.dataForm.endDayChinese.slice(-6)
|
||||||
|
);
|
||||||
this.dataForm.dateDayArrChinese = [
|
this.dataForm.dateDayArrChinese = [
|
||||||
|
'L' + year + this.dataForm.startDayChinese.slice(-6),
|
||||||
'L' +
|
'L' +
|
||||||
new Date().getFullYear() +
|
(num > 0 ? year : year + 1) +
|
||||||
this.dataForm.startDayChinese.slice(-6),
|
+this.dataForm.endDayChinese.slice(-6),
|
||||||
'L' +
|
|
||||||
new Date().getFullYear() +
|
|
||||||
this.dataForm.endDayChinese.slice(-6),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
//用于比较日期大小,判断年份是否要加1
|
||||||
|
compareMonthDay(dateStr1, dateStr2) {
|
||||||
|
const [month1, day1] = dateStr1.split('-').map(Number);
|
||||||
|
const [month2, day2] = dateStr2.split('-').map(Number);
|
||||||
|
|
||||||
|
if (month1 !== month2) {
|
||||||
|
return month2 - month1;
|
||||||
|
}
|
||||||
|
return day2 - day1;
|
||||||
|
},
|
||||||
editHoliday() {
|
editHoliday() {
|
||||||
this.detail = false;
|
this.detail = false;
|
||||||
},
|
},
|
||||||
@@ -440,13 +467,16 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
|
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
|
||||||
this.dataForm.oneDay = this.dataForm.dateDay;
|
const [year, month, day] = this.dataForm.dateDay.split('-');
|
||||||
|
this.dataForm.oneDay = `--${month}-${day}`;
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 2 &&
|
this.dataForm.dateType == 2 &&
|
||||||
this.dataForm.calendarType == 1
|
this.dataForm.calendarType == 1
|
||||||
) {
|
) {
|
||||||
this.dataForm.startDay = this.dataForm.dateDayArr[0];
|
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
|
||||||
this.dataForm.endDay = this.dataForm.dateDayArr[1];
|
this.dataForm.startDay = `--${month}-${day}`;
|
||||||
|
const [year1, month1, day1] = this.dataForm.dateDayArr[1].split('-');
|
||||||
|
this.dataForm.endDay = `--${month1}-${day1}`;
|
||||||
} else if (
|
} else if (
|
||||||
this.dataForm.dateType == 1 &&
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.calendarType == 2
|
this.dataForm.calendarType == 2
|
||||||
@@ -462,16 +492,81 @@ export default {
|
|||||||
this.dataForm.endDayChinese =
|
this.dataForm.endDayChinese =
|
||||||
'--' + this.dataForm.dateDayArrChinese[1].slice(-5);
|
'--' + this.dataForm.dateDayArrChinese[1].slice(-5);
|
||||||
}
|
}
|
||||||
if (this.dataForm.calendarType == 1 && !this.dataForm.repeat) {
|
//是否每年重复,不重复的话需要传 年份
|
||||||
this.dataForm.noRepeatYear = new Date().getFullYear();
|
if (
|
||||||
} else if (this.dataForm.calendarType == 2 && !this.dataForm.repeat) {
|
this.dataForm.dateType == 1 &&
|
||||||
this.dataForm.noRepeatYearChinese = new Date().getFullYear();
|
this.dataForm.calendarType == 1 &&
|
||||||
|
!this.dataForm.repeat
|
||||||
|
) {
|
||||||
|
const [year, month, day] = this.dataForm.dateDay.split('-');
|
||||||
|
this.dataForm.noRepeatYear = year;
|
||||||
|
} else if (
|
||||||
|
this.dataForm.dateType == 2 &&
|
||||||
|
this.dataForm.calendarType == 1 &&
|
||||||
|
!this.dataForm.repeat
|
||||||
|
) {
|
||||||
|
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
|
||||||
|
this.dataForm.noRepeatYear = year;
|
||||||
|
} else if (
|
||||||
|
this.dataForm.dateType == 1 &&
|
||||||
|
this.dataForm.calendarType == 2 &&
|
||||||
|
!this.dataForm.repeat
|
||||||
|
) {
|
||||||
|
this.dataForm.noRepeatYearChinese =
|
||||||
|
this.dataForm.dateDayChinese.slice(1, 5);
|
||||||
|
} else if (
|
||||||
|
this.dataForm.dateType == 2 &&
|
||||||
|
this.dataForm.calendarType == 2 &&
|
||||||
|
!this.dataForm.repeat
|
||||||
|
) {
|
||||||
|
this.dataForm.noRepeatYearChinese =
|
||||||
|
this.dataForm.dateDayArrChinese[0].slice(1, 5);
|
||||||
}
|
}
|
||||||
// 修改的提交
|
// 修改的提交
|
||||||
if (this.dataForm.id) {
|
if (this.dataForm.id) {
|
||||||
|
if (!this.inherited) {
|
||||||
|
this.dataForm.inherited = false;
|
||||||
|
}
|
||||||
updateHoliday(this.dataForm).then((res) => {
|
updateHoliday(this.dataForm).then((res) => {
|
||||||
|
if (res.code === 0 || res.code === 200) {
|
||||||
|
if (!res.data.updateFlag) {
|
||||||
|
this.$modal.msgSuccess('修改成功');
|
||||||
|
this.$emit('refreshPage');
|
||||||
|
} else {
|
||||||
|
this.$confirm(
|
||||||
|
'新增节假日影响已有排班计划,是否立即更新?',
|
||||||
|
'更新排班',
|
||||||
|
{
|
||||||
|
confirmButtonText: '立即更新',
|
||||||
|
cancelButtonText: '暂不更新',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
||||||
|
this.$modal.msgSuccess('更新成功');
|
||||||
|
});
|
||||||
|
this.$emit('refreshPage');
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消',
|
||||||
|
});
|
||||||
|
this.$emit('refreshPage');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$modal.msg(res.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
createHoliday(this.dataForm).then((res) => {
|
||||||
|
if (res.code === 0 || res.code === 200) {
|
||||||
if (!res.data.updateFlag) {
|
if (!res.data.updateFlag) {
|
||||||
this.$modal.msgSuccess('修改成功');
|
this.$modal.msgSuccess('新增成功');
|
||||||
this.$emit('refreshPage');
|
this.$emit('refreshPage');
|
||||||
} else {
|
} else {
|
||||||
this.$confirm(
|
this.$confirm(
|
||||||
@@ -497,37 +592,8 @@ export default {
|
|||||||
this.$emit('refreshPage');
|
this.$emit('refreshPage');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 添加的提交
|
|
||||||
createHoliday(this.dataForm).then((res) => {
|
|
||||||
if (!res.data.updateFlag) {
|
|
||||||
this.$modal.msgSuccess('新增成功');
|
|
||||||
this.$emit('refreshPage');
|
|
||||||
} else {
|
} else {
|
||||||
this.$confirm(
|
this.$modal.msg(res.msg);
|
||||||
'新增节假日影响已有排班计划,是否立即更新?',
|
|
||||||
'更新排班',
|
|
||||||
{
|
|
||||||
confirmButtonText: '立即更新',
|
|
||||||
cancelButtonText: '暂不更新',
|
|
||||||
type: 'warning',
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
updateSchedule({ logId: res.data.logId }).then((res1) => {
|
|
||||||
this.$modal.msgSuccess('更新成功');
|
|
||||||
});
|
|
||||||
this.$emit('refreshPage');
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
|
||||||
type: 'info',
|
|
||||||
message: '已取消',
|
|
||||||
});
|
|
||||||
this.$emit('refreshPage');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -210,7 +210,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import JDatePickerScript from './jDatePicker.js'
|
// import JDatePickerScript from './JDatePicker.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -2,283 +2,284 @@
|
|||||||
* @Author: zwq
|
* @Author: zwq
|
||||||
* @Date: 2024-07-01 14:54:06
|
* @Date: 2024-07-01 14:54:06
|
||||||
* @LastEditors: zwq
|
* @LastEditors: zwq
|
||||||
* @LastEditTime: 2025-11-11 14:29:10
|
* @LastEditTime: 2025-11-24 16:11:20
|
||||||
* @Description:
|
* @Description:
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<el-row :gutter="10" style="background-color: #f2f4f9">
|
<div
|
||||||
<!--部门数据-->
|
class="app-container"
|
||||||
<el-col :span="4">
|
style="
|
||||||
<div class="head-container">
|
background-color: #f2f4f9;
|
||||||
<el-input
|
padding: 0;
|
||||||
v-model="deptName"
|
display: grid;
|
||||||
placeholder="请输入部门名称"
|
grid-template-columns: 1fr 5fr;
|
||||||
clearable
|
gap: 10px;
|
||||||
size="small"
|
">
|
||||||
prefix-icon="el-icon-search"
|
<div class="head-container">
|
||||||
style="margin-bottom: 20px" />
|
<el-input
|
||||||
<el-tree
|
v-model="deptName"
|
||||||
:data="deptOptions"
|
placeholder="请输入部门名称"
|
||||||
:props="defaultProps"
|
clearable
|
||||||
:expand-on-click-node="false"
|
size="small"
|
||||||
:filter-node-method="filterNode"
|
prefix-icon="el-icon-search"
|
||||||
ref="tree"
|
style="margin-bottom: 20px" />
|
||||||
default-expand-all
|
<el-tree
|
||||||
highlight-current
|
:data="deptOptions"
|
||||||
@node-click="handleNodeClick" />
|
:props="defaultProps"
|
||||||
</div>
|
:expand-on-click-node="false"
|
||||||
</el-col>
|
:filter-node-method="filterNode"
|
||||||
<el-col :span="20">
|
ref="tree"
|
||||||
<div class="groupTeamScheduling">
|
node-key="id"
|
||||||
<div class="operationArea">
|
default-expand-all
|
||||||
<el-row>
|
highlight-current
|
||||||
<el-col :span="6">
|
@node-click="handleNodeClick" />
|
||||||
<div style="height: 40px; font-size: 16px">
|
</div>
|
||||||
<span style="color: #409eff; font-weight: 600">
|
<div class="groupTeamScheduling">
|
||||||
{{ showDeptName }}
|
<div class="operationArea">
|
||||||
</span>
|
<el-row>
|
||||||
节假日设置
|
<el-col :span="6">
|
||||||
<span
|
<div style="height: 40px; font-size: 16px">
|
||||||
:style="{
|
<span style="color: #409eff; font-weight: 600">
|
||||||
color: inherited ? '#67c23a' : '#b5b839',
|
{{ showDeptName }}
|
||||||
fontSize: '12px',
|
</span>
|
||||||
fontWeight: 600,
|
节假日设置
|
||||||
}"
|
<span
|
||||||
v-show="ishasParent">
|
:style="{
|
||||||
{{ inherited ? '继承模式' : '自定义模式' }}
|
color: inherited ? '#67c23a' : '#b5b839',
|
||||||
</span>
|
fontSize: '12px',
|
||||||
</div>
|
fontWeight: 600,
|
||||||
</el-col>
|
}"
|
||||||
<el-col :span="18" v-if="!ishasParent">
|
v-show="ishasParent">
|
||||||
<div style="float: right">
|
{{ inherited ? '继承模式' : '自定义模式' }}
|
||||||
<el-button
|
</span>
|
||||||
size="small"
|
</div>
|
||||||
type="primary"
|
</el-col>
|
||||||
style="margin-right: 10px"
|
<el-col :span="18" v-if="!ishasParent">
|
||||||
v-hasPermi="['base:group-holiday:create']"
|
<div style="float: right">
|
||||||
@click="addHoliday">
|
|
||||||
新增节假日
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
size="small"
|
|
||||||
v-hasPermi="['base:group-holiday-log:query']"
|
|
||||||
@click="holidayLog">
|
|
||||||
节假日变更记录
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="18" v-else style="text-align: right">
|
|
||||||
<el-button
|
<el-button
|
||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
:disabled="inherited"
|
style="margin-right: 10px"
|
||||||
v-hasPermi="['base:group-holiday:create']"
|
v-hasPermi="['base:group-holiday:create']"
|
||||||
@click="addHoliday">
|
@click="addHoliday">
|
||||||
新增节假日
|
新增节假日
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
size="small"
|
size="small"
|
||||||
type="success"
|
|
||||||
:disabled="inherited"
|
|
||||||
v-hasPermi="['base:group-holiday:update']"
|
|
||||||
@click="reExtends">
|
|
||||||
恢复继承
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
size="small"
|
|
||||||
type="warning"
|
|
||||||
:disabled="!inherited"
|
|
||||||
v-hasPermi="['base:group-holiday:update']"
|
|
||||||
@click="disExtends">
|
|
||||||
解除继承
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
size="small"
|
|
||||||
:disabled="inherited"
|
|
||||||
v-hasPermi="['base:group-holiday-log:query']"
|
v-hasPermi="['base:group-holiday-log:query']"
|
||||||
@click="holidayLog">
|
@click="holidayLog">
|
||||||
节假日变更记录
|
节假日变更记录
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</div>
|
||||||
</el-row>
|
</el-col>
|
||||||
|
<el-col :span="18" v-else style="text-align: right">
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
:disabled="inherited"
|
||||||
|
v-hasPermi="['base:group-holiday:create']"
|
||||||
|
@click="addHoliday">
|
||||||
|
新增节假日
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="success"
|
||||||
|
:disabled="inherited"
|
||||||
|
v-hasPermi="['base:group-holiday:update']"
|
||||||
|
@click="reExtends">
|
||||||
|
恢复继承
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="warning"
|
||||||
|
:disabled="!inherited"
|
||||||
|
v-hasPermi="['base:group-holiday:update']"
|
||||||
|
@click="disExtends">
|
||||||
|
解除继承
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
:disabled="inherited"
|
||||||
|
v-hasPermi="['base:group-holiday-log:query']"
|
||||||
|
@click="holidayLog">
|
||||||
|
节假日变更记录
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="继承上一级的节假日" v-show="ishasParent">
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
background-color: #67c23a;
|
||||||
|
border-radius: 3px;
|
||||||
|
"></div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="本级自定义的节假日" v-show="ishasParent">
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
background-color: #b5b839;
|
||||||
|
border-radius: 3px;
|
||||||
|
"></div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item style="float: right">
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
@click="(startDay = new Date()), getHolidayPage()">
|
||||||
|
跳转到今天
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div v-if="!ishasParent">
|
||||||
|
<el-tag
|
||||||
|
type="warning"
|
||||||
|
closable
|
||||||
|
v-if="showTag1"
|
||||||
|
@close="handleClose(1)"
|
||||||
|
style="margin-bottom: 10px; color: black">
|
||||||
|
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
||||||
|
当前节假日设置为组织架构中最高层级配置,默认自动继承至下属部门。子部门可选择
|
||||||
|
<span style="color: red">解除继承</span>
|
||||||
|
设置后进行独立修改,解除后不再继承上级设置
|
||||||
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<div class="operationArea">
|
<div v-else>
|
||||||
<el-form :inline="true" class="demo-form-inline">
|
<div v-if="inherited">
|
||||||
<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>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="继承上一级的节假日" v-show="ishasParent">
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
width: 36px;
|
|
||||||
height: 36px;
|
|
||||||
background-color: #67c23a;
|
|
||||||
border-radius: 3px;
|
|
||||||
"></div>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="本级自定义的节假日" v-show="ishasParent">
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
width: 36px;
|
|
||||||
height: 36px;
|
|
||||||
background-color: #b5b839;
|
|
||||||
border-radius: 3px;
|
|
||||||
"></div>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item style="float: right">
|
|
||||||
<el-button
|
|
||||||
size="small"
|
|
||||||
type="primary"
|
|
||||||
@click="(startDay = new Date()), getHolidayPage()">
|
|
||||||
跳转到今天
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div v-if="!ishasParent">
|
|
||||||
<el-tag
|
<el-tag
|
||||||
type="warning"
|
type="warning"
|
||||||
closable
|
closable
|
||||||
v-if="showTag1"
|
v-if="showTag2"
|
||||||
@close="handleClose(1)"
|
@close="handleClose(2)"
|
||||||
style="margin-bottom: 10px; color: black">
|
style="margin-bottom: 10px; color: black">
|
||||||
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
||||||
当前节假日设置为组织架构中最高层级配置,默认自动继承至下属部门。子部门可选择
|
当前部门继承上级节假日设置,默认不可修改。可通过
|
||||||
<span style="color: red">解除继承</span>
|
<span style="color: red">解除继承</span>
|
||||||
设置后进行独立修改,解除后不再继承上级设置
|
进行自定义,解除后将不再继承。
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div v-if="inherited">
|
<el-tag
|
||||||
<el-tag
|
type="warning"
|
||||||
type="warning"
|
closable
|
||||||
closable
|
v-if="showTag3"
|
||||||
v-if="showTag2"
|
@close="handleClose(3)"
|
||||||
@close="handleClose(2)"
|
style="margin-bottom: 10px; color: black">
|
||||||
style="margin-bottom: 10px; color: black">
|
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
||||||
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
当前部门已解除继承,节假日可自由配置。点击
|
||||||
当前部门继承上级节假日设置,默认不可修改。可通过
|
<span style="color: red">恢复继承</span>
|
||||||
<span style="color: red">解除继承</span>
|
将清空当前设置并同步上级节假日。
|
||||||
进行自定义,解除后将不再继承。
|
</el-tag>
|
||||||
</el-tag>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<el-tag
|
|
||||||
type="warning"
|
|
||||||
closable
|
|
||||||
v-if="showTag3"
|
|
||||||
@close="handleClose(3)"
|
|
||||||
style="margin-bottom: 10px; color: black">
|
|
||||||
<i class="el-icon-warning" style="color: #ffbd02"></i>
|
|
||||||
当前部门已解除继承,节假日可自由配置。点击
|
|
||||||
<span style="color: red">恢复继承</span>
|
|
||||||
将清空当前设置并同步上级节假日。
|
|
||||||
</el-tag>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 日历区域 -->
|
</div>
|
||||||
<div class="calenderArea">
|
<!-- 日历区域 -->
|
||||||
<el-calendar v-model="startDay">
|
<div class="calenderArea">
|
||||||
<template slot="dateCell" slot-scope="{ data }">
|
<el-calendar v-model="startDay">
|
||||||
<div v-if="data.type === 'current-month'">
|
<template slot="dateCell" slot-scope="{ data }">
|
||||||
<!-- 日期 -->
|
<div v-if="data.type === 'current-month'">
|
||||||
<div
|
<!-- 日期 -->
|
||||||
class="dateStyle"
|
<div
|
||||||
@click="
|
class="dateStyle"
|
||||||
new Date(data.day).getTime() >=
|
@click="
|
||||||
new Date().setHours(0, 0, 0, 0) &&
|
new Date(data.day).getTime() >=
|
||||||
(!ishasParent || !inherited) &&
|
new Date().setHours(0, 0, 0, 0) &&
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
(!ishasParent || !inherited) &&
|
||||||
?.isHoliday &&
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
showDetail(
|
?.isHoliday &&
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
showDetail(HolidayList[Number(data.day.split('-')[2]) - 1])
|
||||||
)
|
">
|
||||||
">
|
<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
|
||||||
<div
|
class="work-tip"
|
||||||
class="work-tip"
|
:style="{
|
||||||
:style="{
|
backgroundColor: HolidayList[
|
||||||
backgroundColor: HolidayList[
|
Number(data.day.split('-')[2]) - 1
|
||||||
Number(data.day.split('-')[2]) - 1
|
]?.isHoliday
|
||||||
]?.isHoliday
|
? '#67C23A'
|
||||||
? '#67C23A'
|
: '#409EFF',
|
||||||
: '#409EFF',
|
}">
|
||||||
}">
|
{{
|
||||||
{{
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
|
||||||
?.isHoliday
|
|
||||||
? '假'
|
|
||||||
: '班'
|
|
||||||
}}
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
<!-- 显示假期名和操作 -->
|
|
||||||
<el-col
|
|
||||||
:span="24"
|
|
||||||
v-if="
|
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
?.isHoliday
|
?.isHoliday
|
||||||
">
|
? '假'
|
||||||
<div
|
: '班'
|
||||||
class="holiday-div"
|
}}
|
||||||
:style="{
|
</div>
|
||||||
backgroundColor: ishasParent
|
</el-col>
|
||||||
? HolidayList[Number(data.day.split('-')[2]) - 1]
|
<!-- 显示假期名和操作 -->
|
||||||
.isInherit
|
<el-col
|
||||||
? '#67c23a'
|
:span="24"
|
||||||
: '#b5b839'
|
v-if="
|
||||||
: '',
|
HolidayList[Number(data.day.split('-')[2]) - 1]?.isHoliday
|
||||||
}">
|
">
|
||||||
{{
|
<div
|
||||||
HolidayList[Number(data.day.split('-')[2]) - 1]
|
class="holiday-div"
|
||||||
?.holidayName
|
:style="{
|
||||||
}}
|
backgroundColor: ishasParent
|
||||||
<span
|
? HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
class="holiday-div-btn"
|
.isInherit
|
||||||
v-if="
|
? '#67c23a'
|
||||||
(!ishasParent || !inherited) &&
|
: '#b5b839'
|
||||||
new Date(data.day).getTime() >=
|
: '',
|
||||||
new Date().setHours(0, 0, 0, 0)
|
}">
|
||||||
">
|
{{
|
||||||
<i class="el-icon-more" style="color: #fff"></i>
|
HolidayList[Number(data.day.split('-')[2]) - 1]
|
||||||
</span>
|
?.holidayName
|
||||||
</div>
|
}}
|
||||||
</el-col>
|
<span
|
||||||
</el-row>
|
class="holiday-div-btn"
|
||||||
</div>
|
v-if="
|
||||||
</div>
|
(!ishasParent || !inherited) &&
|
||||||
<div
|
new Date(data.day).getTime() >=
|
||||||
v-else
|
new Date().setHours(0, 0, 0, 0)
|
||||||
style="font-size: 20px; font-weight: 500; text-align: left">
|
">
|
||||||
<el-row :gutter="20">
|
<i class="el-icon-more" style="color: #fff"></i>
|
||||||
<el-col :span="24">
|
</span>
|
||||||
{{ Number(data.day.split('-')[2]) }}
|
</div>
|
||||||
<span style="font-size: 12px">
|
|
||||||
{{ getLunarDate(data.day) }}
|
|
||||||
</span>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</div>
|
||||||
</el-calendar>
|
<div
|
||||||
</div>
|
v-else
|
||||||
|
style="font-size: 20px; font-weight: 500; text-align: left">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="24">
|
||||||
|
{{ Number(data.day.split('-')[2]) }}
|
||||||
|
<span style="font-size: 12px">
|
||||||
|
{{ getLunarDate(data.day) }}
|
||||||
|
</span>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-calendar>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</div>
|
||||||
<base-dialog
|
<base-dialog
|
||||||
:dialogTitle="dialogTitle"
|
:dialogTitle="dialogTitle"
|
||||||
:dialogVisible="addOrUpdateVisible"
|
:dialogVisible="addOrUpdateVisible"
|
||||||
@@ -352,7 +353,7 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</base-dialog>
|
</base-dialog>
|
||||||
</el-row>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -453,13 +454,43 @@ export default {
|
|||||||
// 遍历部门,判断当前帐号的部门是否有为最上级
|
// 遍历部门,判断当前帐号的部门是否有为最上级
|
||||||
const nowDept = response.data.filter((i) => i.id == this.topDeptId);
|
const nowDept = response.data.filter((i) => i.id == this.topDeptId);
|
||||||
this.ishasParent = nowDept[0].hasParent;
|
this.ishasParent = nowDept[0].hasParent;
|
||||||
this.parentId = nowDept.parentId;
|
this.parentId = nowDept[0].parentId;
|
||||||
|
|
||||||
// 处理 deptOptions 参数
|
// 处理 deptOptions 参数
|
||||||
this.deptOptions = [];
|
this.deptOptions = [];
|
||||||
this.deptOptions.push(...this.handleTree(response.data, 'id'));
|
this.deptOptions.push(...this.handleTree1(response.data, 'id'));
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.tree.setCurrentKey(this.deptId);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
//大整数精度丢失
|
||||||
|
handleTree1(data, fid) {
|
||||||
|
const id = fid || 'id';
|
||||||
|
const parentId = 'parentId';
|
||||||
|
const children = 'children';
|
||||||
|
const rootId =
|
||||||
|
data
|
||||||
|
.map((item) => item[parentId].toString())
|
||||||
|
.reduce((min, current) => {
|
||||||
|
if (current.length < min.length) return current;
|
||||||
|
if (current.length > min.length) return min;
|
||||||
|
return current < min ? current : min;
|
||||||
|
}) || 0;
|
||||||
|
//对源数据深度克隆
|
||||||
|
const cloneData = JSON.parse(JSON.stringify(data));
|
||||||
|
//循环所有项
|
||||||
|
const treeData = cloneData.filter((father) => {
|
||||||
|
let branchArr = cloneData.filter((child) => {
|
||||||
|
//返回每一项的子级数组
|
||||||
|
return father[id] == child[parentId];
|
||||||
|
});
|
||||||
|
branchArr.length > 0 ? (father.children = branchArr) : '';
|
||||||
|
//返回第一层
|
||||||
|
return father[parentId] == rootId;
|
||||||
|
});
|
||||||
|
return treeData !== '' ? treeData : data;
|
||||||
|
},
|
||||||
// 根据部门id查询该部门是否是继承
|
// 根据部门id查询该部门是否是继承
|
||||||
getSet() {
|
getSet() {
|
||||||
getSet({ id: this.deptId }).then((res) => {
|
getSet({ id: this.deptId }).then((res) => {
|
||||||
@@ -643,6 +674,7 @@ export default {
|
|||||||
type: 'info',
|
type: 'info',
|
||||||
message: '已取消',
|
message: '已取消',
|
||||||
});
|
});
|
||||||
|
this.getSet();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -676,7 +708,7 @@ export default {
|
|||||||
this.detail = true;
|
this.detail = true;
|
||||||
this.dialogTitle = '节假日详情';
|
this.dialogTitle = '节假日详情';
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrUpdataRef.init(this.deptId, val, true);
|
this.$refs.addOrUpdataRef.init(this.deptId, val, true, this.inherited); //编辑的时候,该部门如果是自定义的,但这个val数据是继承的,修改之后,则变成自定义的inherited
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
editHoliday() {
|
editHoliday() {
|
||||||
@@ -709,7 +741,7 @@ export default {
|
|||||||
.head-container {
|
.head-container {
|
||||||
padding: 20px 10px 0;
|
padding: 20px 10px 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
min-height: calc(100vh - 120px - 8px);
|
height: 100%;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
.groupTeamScheduling {
|
.groupTeamScheduling {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
src="/static/videos/login.webm"
|
src="/static/videos/login.webm"
|
||||||
muted
|
muted
|
||||||
autoplay
|
autoplay
|
||||||
|
id="video"
|
||||||
loop
|
loop
|
||||||
style="
|
style="
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@@ -338,7 +339,8 @@ export default {
|
|||||||
SysUserSocialTypeEnum: SystemUserSocialTypeEnum,
|
SysUserSocialTypeEnum: SystemUserSocialTypeEnum,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
||||||
// 租户开关
|
// 租户开关
|
||||||
this.tenantEnable = getTenantEnable();
|
this.tenantEnable = getTenantEnable();
|
||||||
if (this.tenantEnable) {
|
if (this.tenantEnable) {
|
||||||
@@ -356,8 +358,15 @@ export default {
|
|||||||
this.redirect = this.$route.query.redirect
|
this.redirect = this.$route.query.redirect
|
||||||
? decodeURIComponent(this.$route.query.redirect)
|
? decodeURIComponent(this.$route.query.redirect)
|
||||||
: undefined;
|
: undefined;
|
||||||
this.getCookie();
|
this.getCookie();
|
||||||
},
|
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
const video = document.getElementById('video');
|
||||||
|
// 设置为0.5倍速,数值越小速度越慢(0.5为半速,0.75为0.75倍速等)
|
||||||
|
video.playbackRate = 0.2;
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getCode() {
|
getCode() {
|
||||||
// 情况一,未开启:则直接登录
|
// 情况一,未开启:则直接登录
|
||||||
|
|||||||
355
src/views/quality/dpdda/defectAnalysis.vue
Normal file
355
src/views/quality/dpdda/defectAnalysis.vue
Normal file
@@ -0,0 +1,355 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list"
|
||||||
|
@emitFun="handleEmitFun">
|
||||||
|
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn"
|
||||||
|
@clickBtn="handleTableBtnClick" /> -->
|
||||||
|
</base-table>
|
||||||
|
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList" />
|
||||||
|
|
||||||
|
<!-- 对话框(添加 / 修改) -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getPdList,
|
||||||
|
} from '@/api/core/monitoring/auto';
|
||||||
|
import { getFactoryPage } from '@/api/core/base/factory';
|
||||||
|
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||||
|
import { getDefectAnalysis } from '@/api/monitoring/defectSummary';
|
||||||
|
import * as XLSX from 'xlsx'
|
||||||
|
import FileSaver from 'file-saver'
|
||||||
|
export default {
|
||||||
|
name: 'QualityInspectionType',
|
||||||
|
mixins: [basicPageMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// tableBtn: [
|
||||||
|
// this.$auth.hasPermi('base:quality-inspection-type:update')
|
||||||
|
// ? {
|
||||||
|
// type: 'edit',
|
||||||
|
// btnName: '修改',
|
||||||
|
// }
|
||||||
|
// : undefined,
|
||||||
|
// this.$auth.hasPermi('base:quality-inspection-type:delete')
|
||||||
|
// ? {
|
||||||
|
// type: 'delete',
|
||||||
|
// btnName: '删除',
|
||||||
|
// }
|
||||||
|
// : undefined,
|
||||||
|
// ].filter((v) => v),
|
||||||
|
tableProps: [
|
||||||
|
// {
|
||||||
|
// prop: 'createTime',
|
||||||
|
// label: '添加时间',
|
||||||
|
// fixed: true,
|
||||||
|
// width: 180,
|
||||||
|
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||||
|
// },
|
||||||
|
{ prop: 'factoryName', label: '工厂' },
|
||||||
|
{ prop: 'lineName', label: '产线' },
|
||||||
|
{ prop: 'remark', label: '玻璃编号' },
|
||||||
|
{
|
||||||
|
prop: 'checkTime',
|
||||||
|
label: '检测时间',
|
||||||
|
fixed: true,
|
||||||
|
width: 180,
|
||||||
|
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||||
|
},
|
||||||
|
{ prop: 'checkNum', label: '缺陷数' },
|
||||||
|
{
|
||||||
|
prop: 'glassGrade',
|
||||||
|
label: '等级',
|
||||||
|
filter: (val) => val === 0 ? '合格' : val === 1 ? '提示' : val === 2 ? '返修' : val === 3 ? '报废' : ''
|
||||||
|
},
|
||||||
|
{ prop: 'reason', label: '判等原因' },
|
||||||
|
{ prop: 'specifications', label: '规格' },
|
||||||
|
|
||||||
|
|
||||||
|
// {
|
||||||
|
// label: '操作',
|
||||||
|
// alignt: 'center',
|
||||||
|
// subcomponent: {
|
||||||
|
// render: function (h) {
|
||||||
|
// return h('div', null, [
|
||||||
|
// h(
|
||||||
|
// 'el-button',
|
||||||
|
// {
|
||||||
|
// props: {
|
||||||
|
// icon: 'el-icon-edit',
|
||||||
|
// size: 'mini',
|
||||||
|
// type: 'text',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ' 修改'
|
||||||
|
// ),
|
||||||
|
// h(
|
||||||
|
// 'el-button',
|
||||||
|
// {
|
||||||
|
// props: {
|
||||||
|
// icon: 'el-icon-edit',
|
||||||
|
// size: 'mini',
|
||||||
|
// type: 'text',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ' 修改'
|
||||||
|
// ),
|
||||||
|
// ]);
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
//
|
||||||
|
searchBarFormConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '工厂',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'factoryId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
multiple: true,
|
||||||
|
param: 'lineId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'input',
|
||||||
|
label: '缺陷数>',
|
||||||
|
// selectOptions: [],
|
||||||
|
param: 'checkNum',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
// valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350,
|
||||||
|
defaultSelect: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '查询',
|
||||||
|
name: 'search',
|
||||||
|
color: 'primary',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: 'button',
|
||||||
|
// btnName: '重置',
|
||||||
|
// name: 'reset',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: 'separate',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: this.$auth.hasPermi('base:quality-inspection-type:create')
|
||||||
|
// ? 'button'
|
||||||
|
// : '',
|
||||||
|
// btnName: '新增',
|
||||||
|
// name: 'add',
|
||||||
|
// plain: true,
|
||||||
|
// color: 'success',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: this.$auth.hasPermi('base:quality-inspection-type:export')
|
||||||
|
? 'button'
|
||||||
|
: '',
|
||||||
|
btnName: '导出',
|
||||||
|
name: 'export',
|
||||||
|
color: 'warning',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 表单配置
|
||||||
|
// formRows: [
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// input: true,
|
||||||
|
// label: '检测类型名称',
|
||||||
|
// prop: 'name',
|
||||||
|
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
|
||||||
|
// // bind: {
|
||||||
|
// // disabled: true, // some condition, like detail mode...
|
||||||
|
// // }
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// [{ input: true, label: '检测类型编码', prop: 'code' }],
|
||||||
|
// [{ input: true, label: '备注', prop: 'remark' }],
|
||||||
|
// ],
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
lineId: undefined,
|
||||||
|
factoryId: undefined,
|
||||||
|
checkNum: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// watch: {
|
||||||
|
// form: {
|
||||||
|
// handler: (val) => {
|
||||||
|
// console.log('form changed', val);
|
||||||
|
// },
|
||||||
|
// deep: true
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
mounted() {
|
||||||
|
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
|
||||||
|
// 找到时间范围的配置项并赋值(对应你代码中的timeVal参数)
|
||||||
|
this.searchBarFormConfig[3].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
|
||||||
|
this.queryParams.startTime = startTimestamp;
|
||||||
|
this.queryParams.endTime = endTimestamp;
|
||||||
|
this.getList();
|
||||||
|
this.getDict()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getThreeDaysAgoThisTimeToNowTimeStamps() {
|
||||||
|
const now = new Date();
|
||||||
|
// 1. 计算三天前的当前时刻(使用setDate直接修改日期,保留时分秒等信息)
|
||||||
|
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
|
||||||
|
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天,时分秒保持和当前一致
|
||||||
|
|
||||||
|
// 2. 获取时间戳(毫秒级和秒级)
|
||||||
|
// 开始时间戳:三天前的当前时刻
|
||||||
|
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
|
||||||
|
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
|
||||||
|
// 结束时间戳:当前时刻
|
||||||
|
const endTimestamp = now.getTime(); // 毫秒级
|
||||||
|
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
|
||||||
|
|
||||||
|
// 封装日期格式化函数,转换为yyyy-MM-dd HH:mm:ss格式
|
||||||
|
const formatDateTime = (date) => {
|
||||||
|
const y = date.getFullYear();
|
||||||
|
// 月份是从0开始的,所以要+1;补零确保是两位
|
||||||
|
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const d = String(date.getDate()).padStart(2, '0');
|
||||||
|
const h = String(date.getHours()).padStart(2, '0');
|
||||||
|
const min = String(date.getMinutes()).padStart(2, '0');
|
||||||
|
const s = String(date.getSeconds()).padStart(2, '0');
|
||||||
|
return `${y}-${m}-${d} ${h}:${min}:${s}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
|
||||||
|
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
|
||||||
|
const endDateTimeStr = formatDateTime(now);
|
||||||
|
|
||||||
|
return {
|
||||||
|
startTimestamp, // 三天前当前时刻的毫秒级时间戳
|
||||||
|
endTimestamp, // 当前时刻的毫秒级时间戳
|
||||||
|
startTimestampSec, // 三天前当前时刻的秒级时间戳
|
||||||
|
endTimestampSec, // 当前时刻的秒级时间戳
|
||||||
|
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
|
||||||
|
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getDict() {
|
||||||
|
getPdList().then(res => {
|
||||||
|
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||||
|
});
|
||||||
|
|
||||||
|
getFactoryPage({ pageSize: 100, pageNo: 1 }).then(res => {
|
||||||
|
this.searchBarFormConfig[0].selectOptions = res.data.list || [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** base table related */
|
||||||
|
handleTableBtnClick({ data, type }) {
|
||||||
|
switch (type) {
|
||||||
|
case 'edit':
|
||||||
|
this.handleUpdate(data);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
this.handleDelete(data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** search bar related */
|
||||||
|
handleSearchBarBtnClick(btn) {
|
||||||
|
// const keys = ['name'];
|
||||||
|
switch (btn.btnName) {
|
||||||
|
case 'search':
|
||||||
|
this.queryParams.lineId = btn.lineId ? btn.lineId : undefined
|
||||||
|
this.queryParams.factoryId = btn.factoryId ? btn.factoryId : undefined
|
||||||
|
this.queryParams.startTime = btn.timeVal ? btn.timeVal[0] : undefined
|
||||||
|
this.queryParams.endTime = btn.timeVal ? btn.timeVal[1] : undefined
|
||||||
|
this.queryParams.checkNum = btn.checkNum ? btn.checkNum : undefined
|
||||||
|
|
||||||
|
|
||||||
|
// keys.forEach((key) => {
|
||||||
|
// this.queryParams[key] = btn[key] || null;
|
||||||
|
// });
|
||||||
|
this.getList();
|
||||||
|
break;
|
||||||
|
case 'add':
|
||||||
|
this.handleAdd();
|
||||||
|
break;
|
||||||
|
case 'export':
|
||||||
|
this.handleExport();
|
||||||
|
break;
|
||||||
|
// case 'reset':
|
||||||
|
// this.$refs['search-bar'].resetForm();
|
||||||
|
// this.resetQuery();
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 执行查询
|
||||||
|
getDefectAnalysis(this.queryParams).then((response) => {
|
||||||
|
this.list = response.data.list;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let tables = document.querySelector('.el-table').cloneNode(true)
|
||||||
|
const fix = tables.querySelector('.el-table__fixed')
|
||||||
|
const fixRight = tables.querySelector('.el-table__fixed-right')
|
||||||
|
if (fix) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed'))
|
||||||
|
}
|
||||||
|
if (fixRight) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
|
||||||
|
}
|
||||||
|
let exportTable = XLSX.utils.table_to_book(tables)
|
||||||
|
|
||||||
|
var exportTableOut = XLSX.write(exportTable, {
|
||||||
|
bookType: 'xlsx', bookSST: true, type: 'array'
|
||||||
|
})
|
||||||
|
// sheetjs.xlsx为导出表格的标题名称
|
||||||
|
try {
|
||||||
|
FileSaver.saveAs(new Blob([exportTableOut], {
|
||||||
|
type: 'application/octet-stream'
|
||||||
|
}),'缺陷分析.xlsx')
|
||||||
|
} catch (e) {
|
||||||
|
if (typeof console !== 'undefined') console.log(e, exportTableOut)
|
||||||
|
}
|
||||||
|
return exportTableOut
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
606
src/views/quality/dpdda/defectSummary.vue
Normal file
606
src/views/quality/dpdda/defectSummary.vue
Normal file
@@ -0,0 +1,606 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list"
|
||||||
|
@emitFun="handleEmitFun">
|
||||||
|
<method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn"
|
||||||
|
@clickBtn="handleTableBtnClick" />
|
||||||
|
</base-table>
|
||||||
|
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList" />
|
||||||
|
<div v-if="chartData" class="charts-container">
|
||||||
|
<div v-for="(lineData, lineName) in chartData" :key="lineName" class="chart-wrapper">
|
||||||
|
<div class="blue-block"></div>
|
||||||
|
<h3 class="chart-title">{{ lineName }}</h3>
|
||||||
|
<div :id="`chart-${lineName}`" class="chart" style="width: 100%; height: 300px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<defect-summary-det ref="defectSummaryDetRef" v-if="defectVis" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getPdList,
|
||||||
|
} from '@/api/core/monitoring/auto';
|
||||||
|
import { getFactoryPage } from '@/api/core/base/factory';
|
||||||
|
import { getDefectSummaryTable, getDefectSummaryChart } from '@/api/monitoring/defectSummary';
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||||
|
import defectSummaryDet from './defectSummaryDet.vue'
|
||||||
|
export default {
|
||||||
|
name: 'QualityInspectionType',
|
||||||
|
mixins: [basicPageMixin],
|
||||||
|
components: {
|
||||||
|
defectSummaryDet
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tableBtn: [
|
||||||
|
this.$auth.hasPermi('base:quality-inspection-type:update')
|
||||||
|
? {
|
||||||
|
type: 'detail',
|
||||||
|
btnName: '缺陷详情',
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
// this.$auth.hasPermi('base:quality-inspection-type:delete')
|
||||||
|
// ? {
|
||||||
|
// type: 'delete',
|
||||||
|
// btnName: '删除',
|
||||||
|
// }
|
||||||
|
// : undefined,
|
||||||
|
].filter((v) => v),
|
||||||
|
tableProps: [
|
||||||
|
// {
|
||||||
|
// prop: 'createTime',
|
||||||
|
// label: '添加时间',
|
||||||
|
// fixed: true,
|
||||||
|
// width: 180,
|
||||||
|
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||||
|
// },
|
||||||
|
{ prop: 'factoryName', label: '工厂' },
|
||||||
|
{ prop: 'lineName', label: '产线' },
|
||||||
|
{ prop: 'glassNum', label: '玻璃总数' },
|
||||||
|
{
|
||||||
|
prop: 'okNum',
|
||||||
|
label: '合格品数',
|
||||||
|
},
|
||||||
|
{ prop: 'okRate', label: '合格百分比' },
|
||||||
|
{ prop: 'repairNum', label: '返修品数' },
|
||||||
|
{ prop: 'repairRate', label: '返修百分比' },
|
||||||
|
{ prop: 'ngNum', label: '废片数' },
|
||||||
|
{ prop: 'ngRate', label: '废片百分比' },
|
||||||
|
{ prop: 'oneNgNum', label: '1类缺陷玻璃数量' },
|
||||||
|
{ prop: 'twoNgNum', label: '2类缺陷玻璃数量' },
|
||||||
|
{ prop: 'threeNgNum', label: '3类缺陷玻璃数量' },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// {
|
||||||
|
// label: '操作',
|
||||||
|
// alignt: 'center',
|
||||||
|
// subcomponent: {
|
||||||
|
// render: function (h) {
|
||||||
|
// return h('div', null, [
|
||||||
|
// h(
|
||||||
|
// 'el-button',
|
||||||
|
// {
|
||||||
|
// props: {
|
||||||
|
// icon: 'el-icon-edit',
|
||||||
|
// size: 'mini',
|
||||||
|
// type: 'text',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ' 修改'
|
||||||
|
// ),
|
||||||
|
// h(
|
||||||
|
// 'el-button',
|
||||||
|
// {
|
||||||
|
// props: {
|
||||||
|
// icon: 'el-icon-edit',
|
||||||
|
// size: 'mini',
|
||||||
|
// type: 'text',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ' 修改'
|
||||||
|
// ),
|
||||||
|
// ]);
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
//
|
||||||
|
searchBarFormConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '工厂',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'factoryId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
multiple: true,
|
||||||
|
param: 'lineId',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: 'input',
|
||||||
|
// label: '缺陷数>',
|
||||||
|
// // selectOptions: [],
|
||||||
|
// param: 'number',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
// valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
defaultTime: ['00:00:00', '23:59:59'],
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350,
|
||||||
|
defaultSelect: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '查询',
|
||||||
|
name: 'search',
|
||||||
|
color: 'primary',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: 'button',
|
||||||
|
// btnName: '重置',
|
||||||
|
// name: 'reset',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: 'separate',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: this.$auth.hasPermi('base:quality-inspection-type:create')
|
||||||
|
// ? 'button'
|
||||||
|
// : '',
|
||||||
|
// btnName: '新增',
|
||||||
|
// name: 'add',
|
||||||
|
// plain: true,
|
||||||
|
// color: 'success',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: this.$auth.hasPermi('base:quality-inspection-type:export')
|
||||||
|
? 'button'
|
||||||
|
: '',
|
||||||
|
btnName: '导出',
|
||||||
|
name: 'export',
|
||||||
|
color: 'warning',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 表单配置
|
||||||
|
// formRows: [
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// input: true,
|
||||||
|
// label: '检测类型名称',
|
||||||
|
// prop: 'name',
|
||||||
|
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
|
||||||
|
// // bind: {
|
||||||
|
// // disabled: true, // some condition, like detail mode...
|
||||||
|
// // }
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// [{ input: true, label: '检测类型编码', prop: 'code' }],
|
||||||
|
// [{ input: true, label: '备注', prop: 'remark' }],
|
||||||
|
// ],
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
chartData: {},
|
||||||
|
charts: {},
|
||||||
|
defectVis:false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
lineId: undefined,
|
||||||
|
factoryId: undefined,
|
||||||
|
checkNum: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// watch: {
|
||||||
|
// form: {
|
||||||
|
// handler: (val) => {
|
||||||
|
// console.log('form changed', val);
|
||||||
|
// },
|
||||||
|
// deep: true
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
mounted() {
|
||||||
|
|
||||||
|
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
|
||||||
|
// 找到时间范围的配置项并赋值(对应你代码中的timeVal参数)
|
||||||
|
this.searchBarFormConfig[2].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
|
||||||
|
this.queryParams.startTime = startTimestamp;
|
||||||
|
this.queryParams.endTime = endTimestamp;
|
||||||
|
this.getList();
|
||||||
|
this.getDict()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getThreeDaysAgoThisTimeToNowTimeStamps() {
|
||||||
|
const now = new Date();
|
||||||
|
// 1. 计算三天前的当前时刻(使用setDate直接修改日期,保留时分秒等信息)
|
||||||
|
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
|
||||||
|
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天,时分秒保持和当前一致
|
||||||
|
|
||||||
|
// 2. 获取时间戳(毫秒级和秒级)
|
||||||
|
// 开始时间戳:三天前的当前时刻
|
||||||
|
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
|
||||||
|
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
|
||||||
|
// 结束时间戳:当前时刻
|
||||||
|
const endTimestamp = now.getTime(); // 毫秒级
|
||||||
|
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
|
||||||
|
|
||||||
|
// 封装日期格式化函数,转换为yyyy-MM-dd HH:mm:ss格式
|
||||||
|
const formatDateTime = (date) => {
|
||||||
|
const y = date.getFullYear();
|
||||||
|
// 月份是从0开始的,所以要+1;补零确保是两位
|
||||||
|
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const d = String(date.getDate()).padStart(2, '0');
|
||||||
|
const h = String(date.getHours()).padStart(2, '0');
|
||||||
|
const min = String(date.getMinutes()).padStart(2, '0');
|
||||||
|
const s = String(date.getSeconds()).padStart(2, '0');
|
||||||
|
return `${y}-${m}-${d} ${h}:${min}:${s}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
|
||||||
|
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
|
||||||
|
const endDateTimeStr = formatDateTime(now);
|
||||||
|
|
||||||
|
return {
|
||||||
|
startTimestamp, // 三天前当前时刻的毫秒级时间戳
|
||||||
|
endTimestamp, // 当前时刻的毫秒级时间戳
|
||||||
|
startTimestampSec, // 三天前当前时刻的秒级时间戳
|
||||||
|
endTimestampSec, // 当前时刻的秒级时间戳
|
||||||
|
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
|
||||||
|
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getDict() {
|
||||||
|
getPdList().then(res => {
|
||||||
|
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||||
|
});
|
||||||
|
|
||||||
|
getFactoryPage({ pageSize: 100, pageNo: 1 }).then(res => {
|
||||||
|
this.searchBarFormConfig[0].selectOptions = res.data.list || [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** base table related */
|
||||||
|
handleTableBtnClick({ data, type }) {
|
||||||
|
switch (type) {
|
||||||
|
case 'detail':
|
||||||
|
this.defectVis = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.defectSummaryDetRef.init({
|
||||||
|
factoryId:data.factoryId,
|
||||||
|
lineId: [data.lineId],
|
||||||
|
factoryName: data.factoryName,
|
||||||
|
lineName: data.lineName,
|
||||||
|
startTime: this.queryParams.startTime,
|
||||||
|
endTime: this.queryParams.endTime,
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
this.handleDelete(data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
// 销毁所有 ECharts 实例
|
||||||
|
Object.values(this.charts).forEach(chart => {
|
||||||
|
if (chart && chart.dispose) {
|
||||||
|
chart.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.charts = {};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始化单个图表
|
||||||
|
* @param {string} lineName - 产线名称
|
||||||
|
* @param {Array} lineData - 该产线的原始数据
|
||||||
|
*/
|
||||||
|
initSingleChart(lineName, lineData) {
|
||||||
|
// 如果已有实例,先销毁
|
||||||
|
if (this.charts[lineName]) {
|
||||||
|
this.charts[lineName].dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
const chartDom = document.getElementById(`chart-${lineName}`);
|
||||||
|
if (!chartDom || !lineData || lineData.length === 0) {
|
||||||
|
console.warn(`图表容器 chart-${lineName} 未找到或数据为空`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const myChart = echarts.init(chartDom);
|
||||||
|
|
||||||
|
// --- 动态处理数据逻辑 ---
|
||||||
|
const startTime = this.queryParams.startTime;
|
||||||
|
const endTime = this.queryParams.endTime;
|
||||||
|
|
||||||
|
if (!startTime || !endTime) {
|
||||||
|
console.error("起始时间或结束时间为空,无法计算时间差。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const durationDays = (endTime - startTime) / (1000 * 60 * 60 * 24);
|
||||||
|
const isHourly = durationDays < 7;
|
||||||
|
|
||||||
|
// 使用Map来保证顺序,并能存储聚合后的数据和原始显示标签
|
||||||
|
const aggregatedMap = new Map();
|
||||||
|
|
||||||
|
lineData.forEach(item => {
|
||||||
|
let groupKey; // 用于分组的键
|
||||||
|
let displayLabel; // 用于显示的标签
|
||||||
|
|
||||||
|
if (isHourly) {
|
||||||
|
// --- 方法一:使用字符串分割 ---
|
||||||
|
const timePart = item.timePoint.split('T')[1];
|
||||||
|
groupKey = timePart ? timePart : item.timePoint; // 安全处理
|
||||||
|
|
||||||
|
displayLabel = item.timePoint.replace('T', ' ');
|
||||||
|
} else {
|
||||||
|
// 按天聚合:分组键和显示标签都到天
|
||||||
|
groupKey = item.timePoint.split('T')[0];
|
||||||
|
displayLabel = groupKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aggregatedMap.has(groupKey)) {
|
||||||
|
aggregatedMap.set(groupKey, {
|
||||||
|
displayLabel: displayLabel,
|
||||||
|
okNum: 0,
|
||||||
|
repairNum: 0,
|
||||||
|
ngNum: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const aggregatedItem = aggregatedMap.get(groupKey);
|
||||||
|
aggregatedItem.okNum += item.okNum || 0;
|
||||||
|
aggregatedItem.repairNum += item.repairNum || 0;
|
||||||
|
aggregatedItem.ngNum += item.ngNum || 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 准备 ECharts 所需的数据格式
|
||||||
|
const xAxisData = [];
|
||||||
|
const okNumData = [];
|
||||||
|
const repairNumData = [];
|
||||||
|
const ngNumData = [];
|
||||||
|
|
||||||
|
aggregatedMap.forEach(item => {
|
||||||
|
xAxisData.push(item.displayLabel);
|
||||||
|
okNumData.push(item.okNum);
|
||||||
|
repairNumData.push(item.repairNum);
|
||||||
|
ngNumData.push(item.ngNum);
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- ECharts 配置项 ---
|
||||||
|
const option = {
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis',
|
||||||
|
axisPointer: { type: 'cross' },
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
data: ['合格品数', '返修品数', '废片数'],
|
||||||
|
itemHeight: 2,
|
||||||
|
itemWidth: 20,
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '3%',
|
||||||
|
right: '4%',
|
||||||
|
bottom: '20%',
|
||||||
|
containLabel: true
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
boundaryGap: false,
|
||||||
|
data: xAxisData,
|
||||||
|
axisLabel: {
|
||||||
|
rotate: 45,
|
||||||
|
interval: 0, // 强制显示所有标签
|
||||||
|
formatter: function (value) {
|
||||||
|
if (isHourly) {
|
||||||
|
// 从 "2025-10-30 00:00" 中提取 "00:00" 进行显示
|
||||||
|
return value.split(' ')[1];
|
||||||
|
} else {
|
||||||
|
// 天级别,显示 "MM-DD"
|
||||||
|
const dateParts = value.split('-');
|
||||||
|
return `${dateParts[1]}-${dateParts[2]}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
type: 'value',
|
||||||
|
min: 0
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '合格品数',
|
||||||
|
type: 'line',
|
||||||
|
showSymbol: false,
|
||||||
|
data: okNumData,
|
||||||
|
itemStyle: { color: 'rgba(40, 138, 255, 1)' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '返修品数',
|
||||||
|
type: 'line',
|
||||||
|
showSymbol: false,
|
||||||
|
data: repairNumData,
|
||||||
|
itemStyle: { color: 'rgba(115, 222, 147, 1)' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '废片数',
|
||||||
|
type: 'line',
|
||||||
|
showSymbol: false,
|
||||||
|
data: ngNumData,
|
||||||
|
itemStyle: { color: 'rgba(255, 206, 106, 1)' },
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
myChart.setOption(option);
|
||||||
|
this.charts[lineName] = myChart;
|
||||||
|
|
||||||
|
// 监听容器大小变化
|
||||||
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
|
myChart.resize();
|
||||||
|
});
|
||||||
|
resizeObserver.observe(chartDom);
|
||||||
|
myChart._resizeObserver = resizeObserver;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据获取到的 chartData 更新所有图表
|
||||||
|
*/
|
||||||
|
updateAllCharts() {
|
||||||
|
if (!this.chartData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用 nextTick 确保 v-for 生成的 DOM 已存在
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const lineNames = Object.keys(this.chartData);
|
||||||
|
lineNames.forEach(lineName => {
|
||||||
|
this.initSingleChart(lineName, this.chartData[lineName]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** search bar related */
|
||||||
|
handleSearchBarBtnClick(btn) {
|
||||||
|
switch (btn.btnName) {
|
||||||
|
case 'search':
|
||||||
|
this.queryParams.lineId = btn.lineId ? btn.lineId : undefined
|
||||||
|
this.queryParams.factoryId = btn.factoryId ? btn.factoryId : undefined
|
||||||
|
this.queryParams.startTime = btn.timeVal ? btn.timeVal[0] : undefined
|
||||||
|
this.queryParams.endTime = btn.timeVal ? btn.timeVal[1] : undefined
|
||||||
|
this.getList();
|
||||||
|
break;
|
||||||
|
case 'add':
|
||||||
|
this.handleAdd();
|
||||||
|
break;
|
||||||
|
case 'export':
|
||||||
|
this.handleExport();
|
||||||
|
break;
|
||||||
|
// case 'reset':
|
||||||
|
// this.$refs['search-bar'].resetForm();
|
||||||
|
// this.resetQuery();
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 执行查询
|
||||||
|
getDefectSummaryTable(this.queryParams).then((response) => {
|
||||||
|
this.list = response.data;
|
||||||
|
// this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
})
|
||||||
|
getDefectSummaryChart(this.queryParams).then((res) => {
|
||||||
|
console.log('res.data', res.data);
|
||||||
|
|
||||||
|
this.chartData = res.data || {};
|
||||||
|
// 手动调用更新图表的方法
|
||||||
|
this.updateAllCharts();
|
||||||
|
// // this.total = response.data.total;
|
||||||
|
// this.loading = false;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 表单重置 */
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
name: undefined,
|
||||||
|
code: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
};
|
||||||
|
this.resetForm('form');
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let tables = document.querySelector('.el-table').cloneNode(true)
|
||||||
|
const fix = tables.querySelector('.el-table__fixed')
|
||||||
|
const fixRight = tables.querySelector('.el-table__fixed-right')
|
||||||
|
if (fix) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed'))
|
||||||
|
}
|
||||||
|
if (fixRight) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
|
||||||
|
}
|
||||||
|
let exportTable = XLSX.utils.table_to_book(tables)
|
||||||
|
|
||||||
|
var exportTableOut = XLSX.write(exportTable, {
|
||||||
|
bookType: 'xlsx', bookSST: true, type: 'array'
|
||||||
|
})
|
||||||
|
// sheetjs.xlsx为导出表格的标题名称
|
||||||
|
try {
|
||||||
|
FileSaver.saveAs(new Blob([exportTableOut], {
|
||||||
|
type: 'application/octet-stream'
|
||||||
|
}), '缺陷汇总.xlsx')
|
||||||
|
} catch (e) {
|
||||||
|
if (typeof console !== 'undefined') console.log(e, exportTableOut)
|
||||||
|
}
|
||||||
|
return exportTableOut
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.charts-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 300px;
|
||||||
|
margin-top: 10px;
|
||||||
|
/* 最小宽度,防止缩得太小 */
|
||||||
|
/* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 4px; */
|
||||||
|
/* padding: 10px; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.blue-block {
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
width: 4px;
|
||||||
|
height: 16px;
|
||||||
|
background-color: #0B58FF;
|
||||||
|
border-radius: 1px;
|
||||||
|
margin-right: 8px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-title {
|
||||||
|
text-align: left;
|
||||||
|
color: #333;
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
224
src/views/quality/dpdda/defectSummaryDet.vue
Normal file
224
src/views/quality/dpdda/defectSummaryDet.vue
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-drawer title="详情" :visible.sync="visible" size="70%" @close='closeD'>
|
||||||
|
<div class="box">
|
||||||
|
<!-- 顶部信息展示区域 -->
|
||||||
|
<div class="info-header">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">工厂:</span>
|
||||||
|
<span class="value">{{ factoryName }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">产线:</span>
|
||||||
|
<span class="value">{{ lineName }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">时间范围:</span>
|
||||||
|
<span class="value">{{ timeRange }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<el-button type="primary" @click="handleExport">导出</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 表格 -->
|
||||||
|
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps"
|
||||||
|
:table-data="tableData" :span-method="spanMethod" :max-height="tableH">
|
||||||
|
</base-table>
|
||||||
|
</div>
|
||||||
|
</el-drawer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import moment from 'moment';
|
||||||
|
import * as XLSX from 'xlsx';
|
||||||
|
import { getDefectSummaryDet } from '@/api/monitoring/defectSummary';
|
||||||
|
// import { publicFormatter } from '@/utils/dict'
|
||||||
|
|
||||||
|
const tableProps = [
|
||||||
|
{ prop: 'defectLevel', label: '缺陷等级' },
|
||||||
|
{ prop: 'defectName', label: '缺陷类型' },
|
||||||
|
{ prop: 'defectNum', label: '玻璃数量' }
|
||||||
|
]
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'EnergyStatisticsDet',
|
||||||
|
props: {},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
tableProps,
|
||||||
|
tableData: [],
|
||||||
|
tableBtn: [],
|
||||||
|
tableH: this.tableHeight(115),
|
||||||
|
total: 0,
|
||||||
|
queryParams: { pageNo: 1, pageSize: 30 },
|
||||||
|
factoryName: '',
|
||||||
|
lineName: '',
|
||||||
|
timeRange: '',
|
||||||
|
name: '',
|
||||||
|
energyType: '',
|
||||||
|
energyTypeId: '',
|
||||||
|
addOrEditTitle: "",
|
||||||
|
centervisible: false,
|
||||||
|
collectionList: [
|
||||||
|
{ value: 0, label: '否' },
|
||||||
|
{ value: 1, label: '是' }
|
||||||
|
],
|
||||||
|
showBtn: true,
|
||||||
|
selectedList: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
this.tableH = this.tableHeight(115)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
spanMethod({ row, column, rowIndex, columnIndex }) {
|
||||||
|
const fields = ['defectLevel']
|
||||||
|
const cellValue = row[column.property]
|
||||||
|
if (cellValue && fields.includes(column.property)) {
|
||||||
|
const prevRow = this.tableData[rowIndex - 1]
|
||||||
|
let nextRow = this.tableData[rowIndex + 1]
|
||||||
|
if (prevRow && prevRow[column.property] === cellValue) {
|
||||||
|
return { rowspan: 0, colspan: 0 }
|
||||||
|
} else {
|
||||||
|
let countRowspan = 1
|
||||||
|
while (nextRow && nextRow[column.property] === cellValue) {
|
||||||
|
nextRow = this.tableData[++countRowspan + rowIndex]
|
||||||
|
}
|
||||||
|
if (countRowspan > 1) {
|
||||||
|
return { rowspan: countRowspan, colspan: 1 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
init(data) {
|
||||||
|
this.visible = true;
|
||||||
|
this.factoryName = data.factoryName || '未知工厂';
|
||||||
|
this.lineName = data.lineName || '未知产线';
|
||||||
|
|
||||||
|
if (data.startTime && data.endTime) {
|
||||||
|
const start = moment(data.startTime).format('yyyy-MM-DD HH:mm:ss');
|
||||||
|
const end = moment(data.endTime).format('yyyy-MM-DD HH:mm:ss');
|
||||||
|
this.timeRange = `${start} - ${end}`;
|
||||||
|
} else {
|
||||||
|
this.timeRange = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.queryParams.factoryId = data.factoryId;
|
||||||
|
this.queryParams.lineId = data.lineId;
|
||||||
|
this.queryParams.startTime = data.startTime;
|
||||||
|
this.queryParams.endTime = data.endTime;
|
||||||
|
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
|
||||||
|
getList() {
|
||||||
|
getDefectSummaryDet({ ...this.queryParams }).then((res) => {
|
||||||
|
this.tableData = res.data || [];
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
closeD() {
|
||||||
|
this.$emit('closeDrawer');
|
||||||
|
},
|
||||||
|
|
||||||
|
closeDet() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
|
||||||
|
// --- 重写的导出方法 ---
|
||||||
|
// --- 修改后的导出方法 ---
|
||||||
|
handleExport() {
|
||||||
|
console.log("开始执行导出...");
|
||||||
|
this.$modal.confirm('确定要导出表格数据吗?').then(() => {
|
||||||
|
console.log("用户确认导出");
|
||||||
|
|
||||||
|
// 1. 准备数据
|
||||||
|
console.log("tableProps:", this.tableProps);
|
||||||
|
console.log("tableData:", this.tableData);
|
||||||
|
|
||||||
|
// 1.1 准备表头 (新增了 '工厂', '产线', '时间范围')
|
||||||
|
const headers = ['工厂', '产线', '时间范围', ...this.tableProps.map(prop => prop.label)];
|
||||||
|
console.log("生成的表头:", headers);
|
||||||
|
|
||||||
|
// 1.2 准备表格数据
|
||||||
|
const exportData = [];
|
||||||
|
this.tableData.forEach((row) => {
|
||||||
|
const newRow = [];
|
||||||
|
// 先添加顶部信息列
|
||||||
|
newRow.push(this.factoryName);
|
||||||
|
newRow.push(this.lineName);
|
||||||
|
newRow.push(this.timeRange);
|
||||||
|
|
||||||
|
// 再添加表格数据列
|
||||||
|
this.tableProps.forEach((prop) => {
|
||||||
|
// 直接填入所有数据,不再对 defectLevel 进行合并判断
|
||||||
|
newRow.push(row[prop.prop] !== undefined ? row[prop.prop] : '');
|
||||||
|
});
|
||||||
|
exportData.push(newRow);
|
||||||
|
});
|
||||||
|
console.log("处理后的数据:", exportData);
|
||||||
|
|
||||||
|
// 2. 创建工作簿和工作表
|
||||||
|
try {
|
||||||
|
const worksheet = XLSX.utils.aoa_to_sheet([headers, ...exportData]);
|
||||||
|
console.log("工作表创建成功");
|
||||||
|
const workbook = XLSX.utils.book_new();
|
||||||
|
XLSX.utils.book_append_sheet(workbook, worksheet, '缺陷详情数据');
|
||||||
|
console.log("工作簿创建成功");
|
||||||
|
|
||||||
|
// 3. 触发下载
|
||||||
|
const fileName = `${this.factoryName}-${this.lineName}-缺陷汇总详情-${moment().format('YYYYMMDDHHmmss')}.xlsx`;
|
||||||
|
console.log("准备下载文件:", fileName);
|
||||||
|
XLSX.writeFile(workbook, fileName);
|
||||||
|
console.log("下载触发成功");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("生成Excel文件时出错:", error);
|
||||||
|
this.$modal.msgError('导出失败,生成文件时出错!');
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log("用户取消导出或发生错误:", error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.box {
|
||||||
|
padding: 0 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-header {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-around;
|
||||||
|
padding: 16px 0;
|
||||||
|
border-bottom: 1px solid #ebeef5;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
|
||||||
|
.info-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 32px;
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
|
||||||
|
.label {
|
||||||
|
color: #606266;
|
||||||
|
margin-right: 8px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
462
src/views/quality/dpdda/sectionDefect.vue
Normal file
462
src/views/quality/dpdda/sectionDefect.vue
Normal file
@@ -0,0 +1,462 @@
|
|||||||
|
<template>
|
||||||
|
<div style="background: #f2f4f9; flex: 1; display: flex; flex-direction: column">
|
||||||
|
<el-row class="" style="
|
||||||
|
margin-bottom: 12px;
|
||||||
|
background: #fff;
|
||||||
|
padding: 16px 16px 0;
|
||||||
|
border-radius: 8px;
|
||||||
|
">
|
||||||
|
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
|
||||||
|
<base-table :max-height="tableH" :table-props="tableProps" :page="queryParams.pageNo"
|
||||||
|
:limit="queryParams.pageSize" :table-data="list" @emitFun="handleEmitFun" />
|
||||||
|
</el-row>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
|
||||||
|
<!-- 用一个 div 包裹表格和图表,并使用 flex 布局 -->
|
||||||
|
<el-row class="" style="
|
||||||
|
height: 1px;
|
||||||
|
flex: 1;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
background: #fff;
|
||||||
|
padding: 16px 16px 32px;
|
||||||
|
border-radius: 8px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="24">
|
||||||
|
<div id="chart" style="width: 100%; height: 300px;"></div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getPdList,
|
||||||
|
} from '@/api/core/monitoring/auto';
|
||||||
|
import { getFactoryPage } from '@/api/core/base/factory';
|
||||||
|
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||||
|
import { getSectionDefect } from '@/api/monitoring/defectSummary';
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||||
|
export default {
|
||||||
|
name: 'QualityInspectionType',
|
||||||
|
mixins: [basicPageMixin, tableHeightMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tableBtn: [
|
||||||
|
this.$auth.hasPermi('base:quality-inspection-type:update')
|
||||||
|
? {
|
||||||
|
type: 'edit',
|
||||||
|
btnName: '修改',
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
this.$auth.hasPermi('base:quality-inspection-type:delete')
|
||||||
|
? {
|
||||||
|
type: 'delete',
|
||||||
|
btnName: '删除',
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
].filter((v) => v),
|
||||||
|
tableProps: [
|
||||||
|
// {
|
||||||
|
// prop: 'createTime',
|
||||||
|
// label: '添加时间',
|
||||||
|
// fixed: true,
|
||||||
|
// width: 180,
|
||||||
|
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||||
|
// },
|
||||||
|
{ prop: 'factoryName', label: '工厂' },
|
||||||
|
{ prop: 'lineName', label: '产线' },
|
||||||
|
{ prop: 'checkCount', label: '检测片数' },
|
||||||
|
{
|
||||||
|
prop: 'ngCount',
|
||||||
|
label: '不良合计',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'ngRate',
|
||||||
|
label: '不良率',
|
||||||
|
},
|
||||||
|
{ prop: 'originalNgCount', label: '原片不良' },
|
||||||
|
{ prop: 'edgeNgCount', label: '磨边不良' },
|
||||||
|
{ prop: 'silkNgCount', label: '丝印不良' },
|
||||||
|
{ prop: 'drillNgCount', label: '打孔不良' },
|
||||||
|
{ prop: 'coatingNgCount', label: '镀膜不良' },
|
||||||
|
{ prop: 'packNgCount', label: '钢包不良' },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// {
|
||||||
|
// label: '操作',
|
||||||
|
// alignt: 'center',
|
||||||
|
// subcomponent: {
|
||||||
|
// render: function (h) {
|
||||||
|
// return h('div', null, [
|
||||||
|
// h(
|
||||||
|
// 'el-button',
|
||||||
|
// {
|
||||||
|
// props: {
|
||||||
|
// icon: 'el-icon-edit',
|
||||||
|
// size: 'mini',
|
||||||
|
// type: 'text',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ' 修改'
|
||||||
|
// ),
|
||||||
|
// h(
|
||||||
|
// 'el-button',
|
||||||
|
// {
|
||||||
|
// props: {
|
||||||
|
// icon: 'el-icon-edit',
|
||||||
|
// size: 'mini',
|
||||||
|
// type: 'text',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ' 修改'
|
||||||
|
// ),
|
||||||
|
// ]);
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
//
|
||||||
|
searchBarFormConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '工厂',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'factoryId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
multiple: true,
|
||||||
|
param: 'lineId',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: 'input',
|
||||||
|
// label: '缺陷数>',
|
||||||
|
// // selectOptions: [],
|
||||||
|
// param: 'number',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'timestamp',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350,
|
||||||
|
defaultSelect: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '查询',
|
||||||
|
name: 'search',
|
||||||
|
color: 'primary',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: 'button',
|
||||||
|
// btnName: '重置',
|
||||||
|
// name: 'reset',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: 'separate',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: this.$auth.hasPermi('base:quality-inspection-type:create')
|
||||||
|
// ? 'button'
|
||||||
|
// : '',
|
||||||
|
// btnName: '新增',
|
||||||
|
// name: 'add',
|
||||||
|
// plain: true,
|
||||||
|
// color: 'success',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: this.$auth.hasPermi('base:quality-inspection-type:export')
|
||||||
|
? 'button'
|
||||||
|
: '',
|
||||||
|
btnName: '导出',
|
||||||
|
name: 'export',
|
||||||
|
color: 'warning',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 表单配置
|
||||||
|
// formRows: [
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// input: true,
|
||||||
|
// label: '检测类型名称',
|
||||||
|
// prop: 'name',
|
||||||
|
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
|
||||||
|
// // bind: {
|
||||||
|
// // disabled: true, // some condition, like detail mode...
|
||||||
|
// // }
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// [{ input: true, label: '检测类型编码', prop: 'code' }],
|
||||||
|
// [{ input: true, label: '备注', prop: 'remark' }],
|
||||||
|
// ],
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
lineId: undefined,
|
||||||
|
factoryId: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// watch: {
|
||||||
|
// form: {
|
||||||
|
// handler: (val) => {
|
||||||
|
// console.log('form changed', val);
|
||||||
|
// },
|
||||||
|
// deep: true
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
mounted() {
|
||||||
|
|
||||||
|
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
|
||||||
|
// 找到时间范围的配置项并赋值(对应你代码中的timeVal参数)
|
||||||
|
this.searchBarFormConfig[2].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
|
||||||
|
this.queryParams.startTime = startTimestamp;
|
||||||
|
this.queryParams.endTime = endTimestamp;
|
||||||
|
this.getList();
|
||||||
|
this.getDict()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getThreeDaysAgoThisTimeToNowTimeStamps() {
|
||||||
|
const now = new Date();
|
||||||
|
// 1. 计算三天前的当前时刻(使用setDate直接修改日期,保留时分秒等信息)
|
||||||
|
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
|
||||||
|
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天,时分秒保持和当前一致
|
||||||
|
|
||||||
|
// 2. 获取时间戳(毫秒级和秒级)
|
||||||
|
// 开始时间戳:三天前的当前时刻
|
||||||
|
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
|
||||||
|
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
|
||||||
|
// 结束时间戳:当前时刻
|
||||||
|
const endTimestamp = now.getTime(); // 毫秒级
|
||||||
|
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
|
||||||
|
|
||||||
|
// 封装日期格式化函数,转换为yyyy-MM-dd HH:mm:ss格式
|
||||||
|
const formatDateTime = (date) => {
|
||||||
|
const y = date.getFullYear();
|
||||||
|
// 月份是从0开始的,所以要+1;补零确保是两位
|
||||||
|
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const d = String(date.getDate()).padStart(2, '0');
|
||||||
|
const h = String(date.getHours()).padStart(2, '0');
|
||||||
|
const min = String(date.getMinutes()).padStart(2, '0');
|
||||||
|
const s = String(date.getSeconds()).padStart(2, '0');
|
||||||
|
return `${y}-${m}-${d} ${h}:${min}:${s}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
|
||||||
|
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
|
||||||
|
const endDateTimeStr = formatDateTime(now);
|
||||||
|
|
||||||
|
return {
|
||||||
|
startTimestamp, // 三天前当前时刻的毫秒级时间戳
|
||||||
|
endTimestamp, // 当前时刻的毫秒级时间戳
|
||||||
|
startTimestampSec, // 三天前当前时刻的秒级时间戳
|
||||||
|
endTimestampSec, // 当前时刻的秒级时间戳
|
||||||
|
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
|
||||||
|
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getDict() {
|
||||||
|
getPdList().then(res => {
|
||||||
|
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||||
|
});
|
||||||
|
|
||||||
|
getFactoryPage({ pageSize: 100, pageNo: 1 }).then(res => {
|
||||||
|
this.searchBarFormConfig[0].selectOptions = res.data.list || [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** base table related */
|
||||||
|
handleTableBtnClick({ data, type }) {
|
||||||
|
switch (type) {
|
||||||
|
case 'edit':
|
||||||
|
this.handleUpdate(data);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
this.handleDelete(data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** search bar related */
|
||||||
|
handleSearchBarBtnClick(btn) {
|
||||||
|
switch (btn.btnName) {
|
||||||
|
case 'search':
|
||||||
|
this.queryParams.lineId = btn.lineId ? btn.lineId : undefined
|
||||||
|
this.queryParams.factoryId = btn.factoryId ? btn.factoryId : undefined
|
||||||
|
this.queryParams.startTime = btn.timeVal ? btn.timeVal[0] : undefined
|
||||||
|
this.queryParams.endTime = btn.timeVal ? btn.timeVal[1] : undefined
|
||||||
|
this.getList();
|
||||||
|
break;
|
||||||
|
case 'add':
|
||||||
|
this.handleAdd();
|
||||||
|
break;
|
||||||
|
case 'export':
|
||||||
|
this.handleExport();
|
||||||
|
break;
|
||||||
|
case 'reset':
|
||||||
|
this.$refs['search-bar'].resetForm();
|
||||||
|
this.resetQuery();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 执行查询
|
||||||
|
getSectionDefect(this.queryParams).then((response) => {
|
||||||
|
this.list = response.data;
|
||||||
|
// 定义颜色数组,与你提供的顺序一致
|
||||||
|
const colors = [
|
||||||
|
'rgba(99, 189, 255, 1)',
|
||||||
|
'rgba(113, 100, 255, 1)',
|
||||||
|
'rgba(255, 104, 96, 1)',
|
||||||
|
'rgba(255, 151, 71, 1)',
|
||||||
|
'rgba(176, 235, 66, 1)',
|
||||||
|
'rgba(214, 128, 255, 1)',
|
||||||
|
'rgba(0, 67, 210, 1)'
|
||||||
|
];
|
||||||
|
|
||||||
|
const series = response.data.map((item, index) => {
|
||||||
|
// 为每个系列分配颜色,index 从 0 开始,依次对应 colors 数组
|
||||||
|
const color = colors[index % colors.length]; // 使用取模确保不越界
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: item.lineName,
|
||||||
|
type: 'bar',
|
||||||
|
stack: 'Ad',
|
||||||
|
barWidth: '20',
|
||||||
|
emphasis: {
|
||||||
|
focus: 'series'
|
||||||
|
},
|
||||||
|
itemStyle: {
|
||||||
|
color: color // 指定当前系列的颜色
|
||||||
|
},
|
||||||
|
data: [
|
||||||
|
item.originalNgCount,
|
||||||
|
item.edgeNgCount,
|
||||||
|
item.silkNgCount,
|
||||||
|
item.drillNgCount,
|
||||||
|
item.coatingNgCount,
|
||||||
|
item.packNgCount
|
||||||
|
]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.loading = false;
|
||||||
|
this.getChart(series);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getChart(series) {
|
||||||
|
var chartDom = document.getElementById('chart');
|
||||||
|
var myChart = echarts.init(chartDom);
|
||||||
|
var option;
|
||||||
|
option = {
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis',
|
||||||
|
axisPointer: {
|
||||||
|
type: 'shadow'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: 30,
|
||||||
|
top: 20,
|
||||||
|
right: 30,
|
||||||
|
bottom:20
|
||||||
|
},
|
||||||
|
legend: {},
|
||||||
|
xAxis: [
|
||||||
|
{
|
||||||
|
type: 'category',
|
||||||
|
data: ['原片不良', '磨边不良', '丝印不良', '打孔不良', '镀膜不良', ' 钢包不良']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
type: 'value'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
series: series
|
||||||
|
};
|
||||||
|
|
||||||
|
option && myChart.setOption(option);
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let tables = document.querySelector('.el-table').cloneNode(true)
|
||||||
|
const fix = tables.querySelector('.el-table__fixed')
|
||||||
|
const fixRight = tables.querySelector('.el-table__fixed-right')
|
||||||
|
if (fix) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed'))
|
||||||
|
}
|
||||||
|
if (fixRight) {
|
||||||
|
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
|
||||||
|
}
|
||||||
|
let exportTable = XLSX.utils.table_to_book(tables)
|
||||||
|
|
||||||
|
var exportTableOut = XLSX.write(exportTable, {
|
||||||
|
bookType: 'xlsx', bookSST: true, type: 'array'
|
||||||
|
})
|
||||||
|
// sheetjs.xlsx为导出表格的标题名称
|
||||||
|
try {
|
||||||
|
FileSaver.saveAs(new Blob([exportTableOut], {
|
||||||
|
type: 'application/octet-stream'
|
||||||
|
}), '工段不良.xlsx')
|
||||||
|
} catch (e) {
|
||||||
|
if (typeof console !== 'undefined') console.log(e, exportTableOut)
|
||||||
|
}
|
||||||
|
return exportTableOut
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
/* 添加 scoped 以避免样式污染 */
|
||||||
|
.app-container {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
/* 垂直排列 */
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
.table-container,
|
||||||
|
.chart-container {
|
||||||
|
flex: 1;
|
||||||
|
/* 让两个容器平分父容器的空间 */
|
||||||
|
min-height: 300px;
|
||||||
|
/* 设置最小高度,防止内容过少时变形 */
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
/* 添加一个边框,方便看清分隔 */
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 确保图表容器的父元素也有高度,ECharts 才能正确渲染 */
|
||||||
|
.chart-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
674
src/views/quality/qualityIsra/defectVisualization.vue
Normal file
674
src/views/quality/qualityIsra/defectVisualization.vue
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
<template>
|
||||||
|
<div class="status-timegraph-container" style="background: #f2f4f9; flex: 1; display: flex; flex-direction: column">
|
||||||
|
<el-row class="" style="
|
||||||
|
height: 1px;
|
||||||
|
flex: 1;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
background: #fff;
|
||||||
|
padding: 16px 16px 32px;
|
||||||
|
border-radius: 8px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="24">
|
||||||
|
<div class="blue-title">
|
||||||
|
图表时间维度
|
||||||
|
<div style="position: relative; display: flex; align-items: center; gap: 10px; margin-top: 10px;">
|
||||||
|
<el-button type="primary" @click="handleExport"
|
||||||
|
style="position: absolute;top: 0px;right: 10px;z-index: 9999;">
|
||||||
|
导出
|
||||||
|
</el-button>
|
||||||
|
<el-tabs v-model="activeName" type="card" @tab-click="handleClick" style="flex: 1;">
|
||||||
|
|
||||||
|
<!-- 班组标签页 -->
|
||||||
|
<el-tab-pane label="班组" name="group">
|
||||||
|
<!-- 修改:使用四宫格布局容器 -->
|
||||||
|
<div class="chart-grid">
|
||||||
|
<div id="mapGroupMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="mapGroupMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listGroupMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listGroupMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- 日标签页 -->
|
||||||
|
<el-tab-pane label="日" name="day">
|
||||||
|
<!-- 修改:使用四宫格布局容器 -->
|
||||||
|
<div class="chart-grid">
|
||||||
|
<div id="mapDayMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="mapDayMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listDayMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listDayMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- 周标签页 -->
|
||||||
|
<el-tab-pane label="周" name="week">
|
||||||
|
<!-- 修改:使用四宫格布局容器 -->
|
||||||
|
<div class="chart-grid">
|
||||||
|
<div id="mapWeekMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="mapWeekMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listWeekMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listWeekMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- 月标签页 -->
|
||||||
|
<el-tab-pane label="月" name="month">
|
||||||
|
<!-- 修改:使用四宫格布局容器 -->
|
||||||
|
<div class="chart-grid">
|
||||||
|
<div id="mapMonthMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="mapMonthMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listMonthMain" class="chart-container" style="height: 400px;"></div>
|
||||||
|
<div id="listMonthMainScrap" class="chart-container" style="height: 400px;"></div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
</el-tabs>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getQualityIsraPage,
|
||||||
|
} from '@/api/monitoring/qualityIsra';
|
||||||
|
import moment from 'moment';
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||||
|
import { parseTime } from '@/utils/ruoyi';
|
||||||
|
import { getPdList } from '@/api/core/monitoring/auto';
|
||||||
|
import html2canvas from 'html2canvas';
|
||||||
|
export default {
|
||||||
|
name: 'QualityIsra',
|
||||||
|
mixins: [tableHeightMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isFold: false,
|
||||||
|
list: [],
|
||||||
|
dynamicProps: [],
|
||||||
|
activeName: 'group', // 默认激活“日”标签页
|
||||||
|
// 新增:班组图表接口URL(与后端确认一致)
|
||||||
|
groupMapUrl: '/extend/check-isra-statistics/groupMap',
|
||||||
|
groupListUrl: '/extend/check-isra-statistics/groupList',
|
||||||
|
// 原有接口URL:保持不变
|
||||||
|
dayMapUrl: '/extend/check-isra-statistics/dayMap',
|
||||||
|
weekMapUrl: '/extend/check-isra-statistics/weekMap',
|
||||||
|
monthMapUrl: '/extend/check-isra-statistics/monthMap',
|
||||||
|
dayListUrl: '/extend/check-isra-statistics/dayList',
|
||||||
|
weekListUrl: '/extend/check-isra-statistics/weekList',
|
||||||
|
monthListUrl: '/extend/check-isra-statistics/monthList',
|
||||||
|
searchBarFormConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '是否报废',
|
||||||
|
placeholder: '请选择是否报废',
|
||||||
|
param: 'checkDiscard',
|
||||||
|
selectOptions: [
|
||||||
|
{ name: '否', id: 0 },
|
||||||
|
{ name: '是', id: 1 }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '缺陷类型',
|
||||||
|
placeholder: '请选择缺陷类型',
|
||||||
|
param: 'checkType',
|
||||||
|
selectOptions: [],
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'name',
|
||||||
|
defaultSelect: [],
|
||||||
|
filterable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'name',
|
||||||
|
param: 'lineName',
|
||||||
|
filterable: true,
|
||||||
|
defaultSelect: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间段',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始日期',
|
||||||
|
endPlaceholder: '结束日期',
|
||||||
|
defaultTime: ['00:00:00', '23:59:59'],
|
||||||
|
param: 'checkTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '查询',
|
||||||
|
name: 'search',
|
||||||
|
color: 'primary',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
checkDiscard: undefined,
|
||||||
|
// checkType: undefined,
|
||||||
|
// lineName: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// 初始化折叠状态(如需使用可取消注释)
|
||||||
|
// this.isFold = this.searchBarWidth('QualityIsraBox', 1198);
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
tableProps() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
prop: 'checkType',
|
||||||
|
label: '缺陷类型',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'sumNum',
|
||||||
|
label: '缺陷总数',
|
||||||
|
},
|
||||||
|
...this.dynamicProps,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 从路由参数获取产线信息并回显
|
||||||
|
if (this.$route.query.lineName) {
|
||||||
|
this.queryParams.lineName = this.$route.query.lineName;
|
||||||
|
this.searchBarFormConfig[2].defaultSelect = this.$route.query.lineName;
|
||||||
|
}
|
||||||
|
// 从路由参数获取时间信息并回显
|
||||||
|
if (this.$route.query.originalGlassOutputTime) {
|
||||||
|
const time = new Date(Number(this.$route.query.originalGlassOutputTime));
|
||||||
|
this.queryParams.startTime = parseTime(time);
|
||||||
|
this.queryParams.endTime = parseTime(time);
|
||||||
|
this.searchBarFormConfig[3].defaultSelect = [
|
||||||
|
this.queryParams.startTime,
|
||||||
|
this.queryParams.endTime,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// 初始化数据
|
||||||
|
this.getData();
|
||||||
|
this.getDict();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 标签页切换事件 */
|
||||||
|
handleClick() {
|
||||||
|
this.getData();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 核心:获取并渲染图表数据(支持班组/日/周/月) */
|
||||||
|
getData() {
|
||||||
|
// 1. 根据当前激活的标签页,选择对应的接口URL和图表容器ID
|
||||||
|
let mapUrl, listUrl, mapDomId, listDomId, mapDomIdScrap, listDomIdScrap;
|
||||||
|
switch (this.activeName) {
|
||||||
|
case 'group':
|
||||||
|
mapUrl = this.groupMapUrl;
|
||||||
|
listUrl = this.groupListUrl;
|
||||||
|
mapDomId = 'mapGroupMain';
|
||||||
|
listDomId = 'listGroupMain';
|
||||||
|
mapDomIdScrap = 'mapGroupMainScrap';
|
||||||
|
listDomIdScrap = 'listGroupMainScrap';
|
||||||
|
break;
|
||||||
|
case 'day':
|
||||||
|
mapUrl = this.dayMapUrl;
|
||||||
|
listUrl = this.dayListUrl;
|
||||||
|
mapDomId = 'mapDayMain';
|
||||||
|
listDomId = 'listDayMain';
|
||||||
|
mapDomIdScrap = 'mapGroupDayScrap';
|
||||||
|
listDomIdScrap = 'listGroupDayScrap';
|
||||||
|
break;
|
||||||
|
case 'week':
|
||||||
|
mapUrl = this.weekMapUrl;
|
||||||
|
listUrl = this.weekListUrl;
|
||||||
|
mapDomId = 'mapWeekMain';
|
||||||
|
listDomId = 'listWeekMain';
|
||||||
|
mapDomIdScrap = 'mapGroupWeekScrap';
|
||||||
|
listDomIdScrap = 'listGroupWeekScrap';
|
||||||
|
break;
|
||||||
|
case 'month':
|
||||||
|
mapUrl = this.monthMapUrl;
|
||||||
|
listUrl = this.monthListUrl;
|
||||||
|
mapDomId = 'mapMonthMain';
|
||||||
|
listDomId = 'listMonthMain';
|
||||||
|
mapDomIdScrap = 'mapGroupMonthScrap';
|
||||||
|
listDomIdScrap = 'listGroupMonthScrap';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 请求“各类型缺陷对比图”数据
|
||||||
|
this.$axios({
|
||||||
|
url: mapUrl,
|
||||||
|
method: 'get',
|
||||||
|
params: this.queryParams
|
||||||
|
}).then((res) => {
|
||||||
|
const mapArr = [];
|
||||||
|
const mapLegendData = [];
|
||||||
|
// 处理接口返回数据(确保与后端数据格式匹配)
|
||||||
|
for (const type in res.data) {
|
||||||
|
const dataArr = [];
|
||||||
|
const xAxisData = [];
|
||||||
|
res.data[type].forEach(ele => {
|
||||||
|
dataArr.push(ele.num); // 缺陷数量
|
||||||
|
// 班组标签页使用“班组名称”作为X轴,其他标签页使用“时间”
|
||||||
|
xAxisData.push(ele.checkTime);
|
||||||
|
});
|
||||||
|
mapArr.push({
|
||||||
|
name: type, // 缺陷类型名称
|
||||||
|
type: 'line', // 折线图
|
||||||
|
data: dataArr,
|
||||||
|
xAxisData: xAxisData // 存储当前系列的X轴数据
|
||||||
|
});
|
||||||
|
mapLegendData.push(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渲染“各类型缺陷对比图”
|
||||||
|
const mapChartDom = document.getElementById(mapDomId);
|
||||||
|
if (mapChartDom) {
|
||||||
|
const myChart = echarts.init(mapChartDom);
|
||||||
|
myChart.clear(); // 清除原有图表
|
||||||
|
myChart.setOption({
|
||||||
|
title: { text: '所有缺陷对比图' },
|
||||||
|
tooltip: { trigger: 'axis' },
|
||||||
|
legend: { data: mapLegendData, top: '10%', y: 'top', x: 'left' },
|
||||||
|
grid: { left: '3%', right: '4%', bottom: '3%', top: '20%', containLabel: true },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
data: mapArr.length > 0 ? mapArr[0].xAxisData : [] // 使用第一个系列的X轴数据
|
||||||
|
},
|
||||||
|
yAxis: { type: 'value', name: '缺陷数量' },
|
||||||
|
series: mapArr
|
||||||
|
});
|
||||||
|
// 监听窗口 resize,自动调整图表大小
|
||||||
|
window.addEventListener('resize', () => myChart.resize());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$axios({
|
||||||
|
url: mapUrl,
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
startTime: this.queryParams.startTime,
|
||||||
|
endTime: this.queryParams.endTime,
|
||||||
|
checkDiscard:true
|
||||||
|
}
|
||||||
|
}).then((res) => {
|
||||||
|
const mapArr = [];
|
||||||
|
const mapLegendData = [];
|
||||||
|
// 处理接口返回数据(确保与后端数据格式匹配)
|
||||||
|
for (const type in res.data) {
|
||||||
|
const dataArr = [];
|
||||||
|
const xAxisData = [];
|
||||||
|
res.data[type].forEach(ele => {
|
||||||
|
dataArr.push(ele.num); // 缺陷数量
|
||||||
|
// 班组标签页使用“班组名称”作为X轴,其他标签页使用“时间”
|
||||||
|
xAxisData.push(ele.checkTime);
|
||||||
|
});
|
||||||
|
mapArr.push({
|
||||||
|
name: type, // 缺陷类型名称
|
||||||
|
type: 'line', // 折线图
|
||||||
|
data: dataArr,
|
||||||
|
xAxisData: xAxisData // 存储当前系列的X轴数据
|
||||||
|
});
|
||||||
|
mapLegendData.push(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渲染“各类型缺陷对比图”
|
||||||
|
const mapChartDom = document.getElementById(mapDomIdScrap);
|
||||||
|
if (mapChartDom) {
|
||||||
|
const myChart = echarts.init(mapChartDom);
|
||||||
|
myChart.clear(); // 清除原有图表
|
||||||
|
myChart.setOption({
|
||||||
|
title: { text: '所有缺陷对比图' },
|
||||||
|
tooltip: { trigger: 'axis' },
|
||||||
|
legend: { data: mapLegendData, top: '10%', y: 'top', x: 'left' },
|
||||||
|
grid: { left: '3%', right: '4%', bottom: '3%', top: '20%', containLabel: true },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
data: mapArr.length > 0 ? mapArr[0].xAxisData : [] // 使用第一个系列的X轴数据
|
||||||
|
},
|
||||||
|
yAxis: { type: 'value', name: '缺陷数量' },
|
||||||
|
series: mapArr
|
||||||
|
});
|
||||||
|
// 监听窗口 resize,自动调整图表大小
|
||||||
|
window.addEventListener('resize', () => myChart.resize());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. 请求“缺陷率趋势图”数据
|
||||||
|
this.$axios({
|
||||||
|
url: listUrl,
|
||||||
|
method: 'get',
|
||||||
|
params: this.queryParams
|
||||||
|
}).then((res) => {
|
||||||
|
const listNumArr = []; // 缺陷数量
|
||||||
|
const listRatioArr = []; // 缺陷率
|
||||||
|
const listXAxisData = []; // X轴数据
|
||||||
|
|
||||||
|
// 处理接口返回数据(确保与后端数据格式匹配)
|
||||||
|
res.data.forEach(ele => {
|
||||||
|
listNumArr.push(ele.num);
|
||||||
|
listRatioArr.push(ele.ratio); // 缺陷率(百分比)
|
||||||
|
// 班组标签页使用“班组名称”作为X轴,其他标签页使用“时间”
|
||||||
|
listXAxisData.push(this.activeName === 'group' ? ele.groupName : ele.checkTime);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 渲染“缺陷率趋势图”
|
||||||
|
const listChartDom = document.getElementById(listDomId);
|
||||||
|
if (listChartDom) {
|
||||||
|
const myChart = echarts.init(listChartDom);
|
||||||
|
myChart.clear(); // 清除原有图表
|
||||||
|
myChart.setOption({
|
||||||
|
title: { text: '所有缺陷率趋势图' },
|
||||||
|
tooltip: { trigger: 'axis' },
|
||||||
|
legend: { data: ['缺陷数量', '缺陷率'], top: '10%' },
|
||||||
|
grid: { left: '3%', right: '4%', bottom: '3%', top: '20%', containLabel: true },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
data: listXAxisData
|
||||||
|
},
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: '缺陷数量',
|
||||||
|
axisLabel: { formatter: '{value}' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: '缺陷率',
|
||||||
|
axisLabel: { formatter: '{value} %' },
|
||||||
|
position: 'right' // 缺陷率Y轴放在右侧
|
||||||
|
}
|
||||||
|
],
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '缺陷数量',
|
||||||
|
type: 'bar',
|
||||||
|
barWidth: '3%',
|
||||||
|
data: listNumArr,
|
||||||
|
itemStyle: { color: 'rgba(40, 138, 255, 1)' } // 柱状图颜色
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '缺陷率',
|
||||||
|
type: 'line',
|
||||||
|
yAxisIndex: 1, // 关联右侧Y轴
|
||||||
|
data: listRatioArr,
|
||||||
|
itemStyle: { color: 'rgba(115, 222, 147, 1)' }, // 折线图颜色
|
||||||
|
symbol: 'circle', // 标记点样式
|
||||||
|
symbolSize: 6
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
// 监听窗口 resize,自动调整图表大小
|
||||||
|
window.addEventListener('resize', () => myChart.resize());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$axios({
|
||||||
|
url: listUrl,
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
startTime: this.queryParams.startTime,
|
||||||
|
endTime: this.queryParams.endTime,
|
||||||
|
checkDiscard: true
|
||||||
|
}
|
||||||
|
}).then((res) => {
|
||||||
|
const listNumArr = []; // 缺陷数量
|
||||||
|
const listRatioArr = []; // 缺陷率
|
||||||
|
const listXAxisData = []; // X轴数据
|
||||||
|
|
||||||
|
// 处理接口返回数据(确保与后端数据格式匹配)
|
||||||
|
res.data.forEach(ele => {
|
||||||
|
listNumArr.push(ele.num);
|
||||||
|
listRatioArr.push(ele.ratio); // 缺陷率(百分比)
|
||||||
|
// 班组标签页使用“班组名称”作为X轴,其他标签页使用“时间”
|
||||||
|
listXAxisData.push(this.activeName === 'group' ? ele.groupName : ele.checkTime);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 渲染“缺陷率趋势图”
|
||||||
|
const listChartDom = document.getElementById(listDomIdScrap);
|
||||||
|
if (listChartDom) {
|
||||||
|
const myChart = echarts.init(listChartDom);
|
||||||
|
myChart.clear(); // 清除原有图表
|
||||||
|
myChart.setOption({
|
||||||
|
title: { text: '所有缺陷率趋势图' },
|
||||||
|
tooltip: { trigger: 'axis' },
|
||||||
|
legend: { data: ['缺陷数量', '缺陷率'], top: '10%' },
|
||||||
|
grid: { left: '3%', right: '4%', bottom: '3%', top: '20%', containLabel: true },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
data: listXAxisData
|
||||||
|
},
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: '缺陷数量',
|
||||||
|
axisLabel: { formatter: '{value}' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: '缺陷率',
|
||||||
|
axisLabel: { formatter: '{value} %' },
|
||||||
|
position: 'right' // 缺陷率Y轴放在右侧
|
||||||
|
}
|
||||||
|
],
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '缺陷数量',
|
||||||
|
type: 'bar',
|
||||||
|
barWidth: '3%',
|
||||||
|
data: listNumArr,
|
||||||
|
itemStyle: { color: 'rgba(40, 138, 255, 1)' } // 柱状图颜色
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '缺陷率',
|
||||||
|
type: 'line',
|
||||||
|
yAxisIndex: 1, // 关联右侧Y轴
|
||||||
|
data: listRatioArr,
|
||||||
|
itemStyle: { color: 'rgba(115, 222, 147, 1)' }, // 折线图颜色
|
||||||
|
symbol: 'circle', // 标记点样式
|
||||||
|
symbolSize: 6
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
// 监听窗口 resize,自动调整图表大小
|
||||||
|
window.addEventListener('resize', () => myChart.resize());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 新增:导出数据功能 */
|
||||||
|
handleExport() {
|
||||||
|
// 1. 找到当前激活标签页内的 .chart-wrapper 容器
|
||||||
|
const container = document.querySelector(`.el-tab-pane[aria-selected="true"] .chart-wrapper`);
|
||||||
|
|
||||||
|
if (!container) {
|
||||||
|
this.$message.warning('未找到图表容器');
|
||||||
|
console.error('导出失败:未找到 .chart-wrapper 容器');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$message.info('正在生成图片,请稍候...');
|
||||||
|
|
||||||
|
// 2. 获取当前标签页的两个图表实例,并强制刷新它们
|
||||||
|
// 这是解决问题的关键步骤
|
||||||
|
const chartIds = this.getChartIdsByActiveName();
|
||||||
|
chartIds.forEach(id => {
|
||||||
|
const chartDom = document.getElementById(id);
|
||||||
|
if (chartDom) {
|
||||||
|
const chartInstance = echarts.getInstanceByDom(chartDom);
|
||||||
|
if (chartInstance) {
|
||||||
|
chartInstance.resize(); // 强制图表重新渲染
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. 使用 setTimeout 等待图表渲染完成后再进行截图
|
||||||
|
// 延迟时间可以根据你的图表复杂度调整,一般 100-300ms 足够
|
||||||
|
setTimeout(() => {
|
||||||
|
html2canvas(container, {
|
||||||
|
scale: 2,
|
||||||
|
useCORS: true,
|
||||||
|
logging: false,
|
||||||
|
backgroundColor: null,
|
||||||
|
// 增加一个配置,确保能捕获到所有元素
|
||||||
|
windowWidth: container.scrollWidth,
|
||||||
|
windowHeight: container.scrollHeight
|
||||||
|
}).then(canvas => {
|
||||||
|
const imgBase64 = canvas.toDataURL('image/png');
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = imgBase64;
|
||||||
|
|
||||||
|
const titleMap = { group: '班组', day: '日', week: '周', month: '月' };
|
||||||
|
const title = titleMap[this.activeName] || '数据';
|
||||||
|
link.download = `${title}度缺陷分析报告.png`;
|
||||||
|
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
|
||||||
|
this.$message.success('图表导出成功!');
|
||||||
|
}).catch(error => {
|
||||||
|
this.$message.error('图表导出失败!');
|
||||||
|
console.error('html2canvas 截图失败:', error);
|
||||||
|
});
|
||||||
|
}, 200); // 等待 200 毫秒
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增一个辅助方法,根据当前激活的标签页获取对应的图表 ID
|
||||||
|
getChartIdsByActiveName() {
|
||||||
|
switch (this.activeName) {
|
||||||
|
case 'group':
|
||||||
|
return ['mapGroupMain', 'listGroupMain'];
|
||||||
|
case 'day':
|
||||||
|
return ['mapDayMain', 'listDayMain'];
|
||||||
|
case 'week':
|
||||||
|
return ['mapWeekMain', 'listWeekMain'];
|
||||||
|
case 'month':
|
||||||
|
return ['mapMonthMain', 'listMonthMain'];
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 获取搜索栏的字典数据(缺陷类型、产线列表) */
|
||||||
|
async getDict() {
|
||||||
|
// 获取缺陷类型列表
|
||||||
|
const defectRes = await this.$axios({
|
||||||
|
url: '/extend/check-isra-standards/page',
|
||||||
|
method: 'get',
|
||||||
|
params: { pageSize: 100, pageNo: 1 }
|
||||||
|
});
|
||||||
|
this.searchBarFormConfig[1].selectOptions = defectRes.data.list || [];
|
||||||
|
|
||||||
|
// 获取产线列表
|
||||||
|
const lineRes = await getPdList();
|
||||||
|
this.searchBarFormConfig[2].selectOptions = lineRes.data || [];
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 查询列表数据(如需使用表格可取消注释) */
|
||||||
|
// getList() {
|
||||||
|
// this.getDataList();
|
||||||
|
// },
|
||||||
|
|
||||||
|
/** 表格数据查询(如需使用表格可取消注释) */
|
||||||
|
// async getDataList() {
|
||||||
|
// this.loading = true;
|
||||||
|
// try {
|
||||||
|
// const { data } = await getQualityIsraPage(this.queryParams);
|
||||||
|
// this.dynamicProps = this.filterNameData(data.nameData);
|
||||||
|
// this.list = this.filterData(data.data);
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error('获取表格数据失败:', error);
|
||||||
|
// } finally {
|
||||||
|
// this.loading = false;
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
|
||||||
|
/** 过滤动态表格列名(如需使用表格可取消注释) */
|
||||||
|
// filterNameData(nameData) {
|
||||||
|
// const nameSet = new Set(nameData.map(nd => nd.name));
|
||||||
|
// return Array.from(nameSet).sort().map(name => ({ prop: name, label: name }));
|
||||||
|
// },
|
||||||
|
|
||||||
|
/** 过滤表格数据(如需使用表格可取消注释) */
|
||||||
|
// filterData(data) {
|
||||||
|
// return data.map(item => {
|
||||||
|
// const keyValuePairs = {};
|
||||||
|
// item.data.forEach(d => {
|
||||||
|
// keyValuePairs[d.dynamicName] = d.dynamicValue;
|
||||||
|
// });
|
||||||
|
// return { ...keyValuePairs, sumNum: item.sumNum, checkType: item.checkType };
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
|
||||||
|
/** 搜索按钮点击事件(如需使用搜索栏可取消注释) */
|
||||||
|
// handleSearchBarBtnClick(val) {
|
||||||
|
// if (val.btnName === 'search') {
|
||||||
|
// this.queryParams.checkDiscard = (val?.checkDiscard === 0 || val?.checkDiscard === 1) ? val?.checkDiscard : undefined;
|
||||||
|
// this.queryParams.lineName = val.lineName ? val.lineName : undefined;
|
||||||
|
// this.queryParams.checkType = val.checkType ? val.checkType : undefined;
|
||||||
|
// this.queryParams.startTime = val.checkTime ? val.checkTime[0] : undefined;
|
||||||
|
// this.queryParams.endTime = val.checkTime ? val.checkTime[1] : undefined;
|
||||||
|
|
||||||
|
// this.getList();
|
||||||
|
// this.getData();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.blue-title {
|
||||||
|
position: relative;
|
||||||
|
padding: 4px 0;
|
||||||
|
padding-left: 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #606266;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 6px;
|
||||||
|
height: 16px;
|
||||||
|
width: 4px;
|
||||||
|
border-radius: 1px;
|
||||||
|
background: #0b58ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 新增:四宫格布局样式 */
|
||||||
|
.chart-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
/* 创建两列,宽度相等 */
|
||||||
|
grid-template-rows: repeat(2, auto);
|
||||||
|
/* 创建两行,高度自适应内容 */
|
||||||
|
gap: 20px;
|
||||||
|
/* 图表之间的间距 */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-container {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #f0f0f0;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
270
src/views/quality/qualityIsra/dialogForm.vue
Normal file
270
src/views/quality/qualityIsra/dialogForm.vue
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
<!--
|
||||||
|
filename: dialogForm.vue
|
||||||
|
author: liubin
|
||||||
|
date: 2023-09-11 15:55:13
|
||||||
|
description: DialogForm for qualityInspectionRecord only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-form
|
||||||
|
ref="form"
|
||||||
|
:model="innerDataForm"
|
||||||
|
label-width="100px"
|
||||||
|
v-loading="formLoading">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item
|
||||||
|
label="检测内容"
|
||||||
|
prop="inspectionDetId"
|
||||||
|
:rules="[{ required: true, message: '检测内容不能为空', trigger: 'blur' }]">
|
||||||
|
<el-select
|
||||||
|
v-model="innerDataForm.inspectionDetId"
|
||||||
|
placeholder="请选择检测内容"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
@change="handleInspectionDetChange">
|
||||||
|
<el-option
|
||||||
|
v-for="opt in inspectionDetList"
|
||||||
|
:key="opt.value"
|
||||||
|
:label="opt.label"
|
||||||
|
:value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item
|
||||||
|
label="来源"
|
||||||
|
prop="source"
|
||||||
|
:rules="[{ required: true, message: '来源不能为空', trigger: 'blur' }]">
|
||||||
|
<el-select
|
||||||
|
v-model="innerDataForm.source"
|
||||||
|
placeholder="请选择来源"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
@change="$emit('update', innerDataForm)">
|
||||||
|
<el-option
|
||||||
|
v-for="opt in [
|
||||||
|
{ label: '手动', value: 1 },
|
||||||
|
{ label: '自动', value: 2 },
|
||||||
|
]"
|
||||||
|
:key="opt.value"
|
||||||
|
:label="opt.label"
|
||||||
|
:value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item
|
||||||
|
label="产线"
|
||||||
|
prop="productionLineId"
|
||||||
|
:rules="[{ required: true, message: '产线不能为空', trigger: 'blur' }]">
|
||||||
|
<el-select
|
||||||
|
v-model="innerDataForm.productionLineId"
|
||||||
|
placeholder="请选择产线"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
@change="handleProductlineChange">
|
||||||
|
<el-option
|
||||||
|
v-for="opt in productionLineList"
|
||||||
|
:key="opt.value"
|
||||||
|
:label="opt.label"
|
||||||
|
:value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item
|
||||||
|
label="工段"
|
||||||
|
prop="sectionId"
|
||||||
|
:rules="[{ required: true, message: '工段不能为空', trigger: 'blur' }]">
|
||||||
|
<el-select
|
||||||
|
v-model="innerDataForm.sectionId"
|
||||||
|
placeholder="请选择工段"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
@change="$emit('update', innerDataForm)">
|
||||||
|
<el-option
|
||||||
|
v-for="opt in sectionList"
|
||||||
|
:key="opt.value"
|
||||||
|
:label="opt.label"
|
||||||
|
:value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="检测人员" prop="checkPerson">
|
||||||
|
<el-input
|
||||||
|
v-model="innerDataForm.checkPerson"
|
||||||
|
clearable
|
||||||
|
@change="$emit('update', innerDataForm)"
|
||||||
|
placeholder="请输入检测人员" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item
|
||||||
|
label="检测时间"
|
||||||
|
prop="checkTime"
|
||||||
|
:rules="[{ required: true, message: '检测时间不能为空', trigger: 'blur' }]">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="innerDataForm.checkTime"
|
||||||
|
type="datetime"
|
||||||
|
placeholder="请选择检测时间"
|
||||||
|
value-format="timestamp"
|
||||||
|
@change="$emit('update', innerDataForm)"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col>
|
||||||
|
<el-form-item label="描述" prop="explainText">
|
||||||
|
<el-input
|
||||||
|
v-model="innerDataForm.explainText"
|
||||||
|
placeholder="请输入描述信息"
|
||||||
|
@change="$emit('update', innerDataForm)"
|
||||||
|
type="textarea"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="innerDataForm.remark"
|
||||||
|
@change="$emit('update', innerDataForm)"
|
||||||
|
placeholder="请输入备注"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'DialogForm',
|
||||||
|
model: {
|
||||||
|
prop: 'dataForm',
|
||||||
|
event: 'update',
|
||||||
|
},
|
||||||
|
emits: ['update'],
|
||||||
|
components: {},
|
||||||
|
props: {
|
||||||
|
dataForm: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
formLoading: true,
|
||||||
|
inspectionDetList: [],
|
||||||
|
productionLineList: [],
|
||||||
|
sectionList: [],
|
||||||
|
innerDataForm: {},
|
||||||
|
cacheInspectionDetList: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
Promise.all([this.getProductLineList(), this.getInspectionDetList()]).then(
|
||||||
|
() => {
|
||||||
|
this.formLoading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// 'innerDataForm.productionLineId': {
|
||||||
|
// handler: async function (plId) {
|
||||||
|
// if (plId) await this.getWorksectionList(plId);
|
||||||
|
// },
|
||||||
|
// immediate: true,
|
||||||
|
// },
|
||||||
|
dataForm: {
|
||||||
|
handler: function (dataForm) {
|
||||||
|
this.innerDataForm = Object.assign({}, dataForm);
|
||||||
|
|
||||||
|
if (dataForm.productionLineId)
|
||||||
|
this.getWorksectionList(dataForm.productionLineId);
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 模拟透传 ref */
|
||||||
|
validate(cb) {
|
||||||
|
return this.$refs.form.validate(cb);
|
||||||
|
},
|
||||||
|
resetFields(args) {
|
||||||
|
return this.$refs.form.resetFields(args);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleInspectionDetChange(value) {
|
||||||
|
const { id, content } = this.cacheInspectionDetList.find(
|
||||||
|
(item) => item.id == value
|
||||||
|
);
|
||||||
|
this.innerDataForm.inspectionDetId = id;
|
||||||
|
this.innerDataForm.inspectionDetContent = content;
|
||||||
|
this.$emit('update', this.innerDataForm);
|
||||||
|
},
|
||||||
|
|
||||||
|
async handleProductlineChange(id) {
|
||||||
|
// await this.getWorksectionList(id);
|
||||||
|
this.innerDataForm.sectionId = null;
|
||||||
|
this.$emit('update', this.innerDataForm);
|
||||||
|
},
|
||||||
|
|
||||||
|
// getCode
|
||||||
|
async getCode(url) {
|
||||||
|
const response = await this.$axios(url);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取产线列表
|
||||||
|
async getProductLineList() {
|
||||||
|
const response = await this.$axios('/base/core-production-line/listAll');
|
||||||
|
this.productionLineList = response.data.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取检测内容列表
|
||||||
|
async getInspectionDetList() {
|
||||||
|
const response = await this.$axios(
|
||||||
|
'/base/quality-inspection-det/listAll'
|
||||||
|
);
|
||||||
|
this.cacheInspectionDetList = response.data;
|
||||||
|
this.inspectionDetList = response.data.map((item) => ({
|
||||||
|
label: item.content,
|
||||||
|
value: item.id,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取工段列表
|
||||||
|
async getWorksectionList(plId) {
|
||||||
|
const response = await this.$axios(
|
||||||
|
'/base/workshop-section/listByParentId',
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
id: plId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.sectionList = response.data.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.el-date-editor,
|
||||||
|
.el-select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
468
src/views/quality/qualityIsra/index.vue
Normal file
468
src/views/quality/qualityIsra/index.vue
Normal file
@@ -0,0 +1,468 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!-- <div class="blue-title">生产节拍时序图</div> -->
|
||||||
|
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<base-table :max-height="tableH" :table-props="tableProps" :page="1" :limit="20" :table-data="list">
|
||||||
|
</base-table>
|
||||||
|
<!-- </el-row> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getQualityIsraPage,
|
||||||
|
// getQualityIsraDayMap,
|
||||||
|
// getQualityIsraWeekMap,
|
||||||
|
// getQualityIsraMonthMap,
|
||||||
|
// getQualityIsraDayList,
|
||||||
|
// getQualityIsraWeekList,
|
||||||
|
// getQualityIsraMonthList,
|
||||||
|
} from '@/api/monitoring/qualityIsra';
|
||||||
|
// import Editor from '@/components/Editor';
|
||||||
|
import moment from 'moment';
|
||||||
|
// import DialogForm from './dialogForm.vue';
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||||
|
// import { getPdList } from '@/api/base/coreProductionLine';
|
||||||
|
import { parseTime } from '@/utils/ruoyi';
|
||||||
|
import { getPdList, } from '@/api/core/monitoring/auto';
|
||||||
|
// import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||||
|
export default {
|
||||||
|
name: 'QualityIsra',
|
||||||
|
// components: {
|
||||||
|
// DialogForm,
|
||||||
|
// },
|
||||||
|
mixins: [tableHeightMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isFold: false,
|
||||||
|
list: [],
|
||||||
|
dynamicProps: [],
|
||||||
|
activeName: 'day',
|
||||||
|
dayMapUrl: '/extend/check-isra-statistics/dayMap',
|
||||||
|
weekMapUrl: '/extend/check-isra-statistics/weekMap',
|
||||||
|
monthMapUrl: '/extend/check-isra-statistics/monthMap',
|
||||||
|
dayListUrl: '/extend/check-isra-statistics/dayList',
|
||||||
|
weekListUrl: '/extend/check-isra-statistics/weekList',
|
||||||
|
monthListUrl: '/extend/check-isra-statistics/monthList',
|
||||||
|
searchBarFormConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '是否报废',
|
||||||
|
placeholder: '请选择是否报废',
|
||||||
|
param: 'checkDiscard',
|
||||||
|
selectOptions: [
|
||||||
|
{ name: '否', id: 0 },
|
||||||
|
{ name: '是', id: 1 }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '缺陷类型',
|
||||||
|
placeholder: '请选择缺陷类型',
|
||||||
|
param: 'checkType',
|
||||||
|
selectOptions: [],
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'name',
|
||||||
|
defaultSelect: [],
|
||||||
|
filterable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'name',
|
||||||
|
param: 'lineName',
|
||||||
|
filterable: true,
|
||||||
|
defaultSelect: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间段',
|
||||||
|
dateType: 'datetimerange', // datetimerange
|
||||||
|
// format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始日期',
|
||||||
|
endPlaceholder: '结束日期',
|
||||||
|
defaultTime: ['00:00:00', '23:59:59'],
|
||||||
|
param: 'checkTime',
|
||||||
|
// width: 350,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type:'button',
|
||||||
|
btnName: '查询',
|
||||||
|
name: 'search',
|
||||||
|
color: 'primary',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
checkDiscard: undefined,
|
||||||
|
checkType:undefined,
|
||||||
|
lineName: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
// productionLineId: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// this.getProductLineList();
|
||||||
|
// this.isFold = this.searchBarWidth('QualityIsraBox', 1198);
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
tableProps() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
// width: 128,
|
||||||
|
prop: 'checkType',
|
||||||
|
label: '缺陷类型',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// width: 128,
|
||||||
|
prop: 'sumNum',
|
||||||
|
label: '缺陷总数',
|
||||||
|
},
|
||||||
|
...this.dynamicProps,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$route.query.lineName) {
|
||||||
|
// console.log('打印看看产线', this.$route.query.lineName)
|
||||||
|
this.queryParams.lineName = this.$route.query.lineName
|
||||||
|
this.searchBarFormConfig[2].defaultSelect = this.$route.query.lineName
|
||||||
|
}
|
||||||
|
if (this.$route.query.originalGlassOutputTime) {
|
||||||
|
console.log('你好', this.$route.query.originalGlassOutputTime)
|
||||||
|
this.queryParams.startTime = parseTime(new Date(Number(this.$route.query.originalGlassOutputTime)))
|
||||||
|
this.queryParams.endTime = parseTime(new Date(Number(this.$route.query.originalGlassOutputTime)))
|
||||||
|
this.searchBarFormConfig[3].defaultSelect = [
|
||||||
|
this.queryParams.startTime,
|
||||||
|
this.queryParams.endTime,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
this.getList()
|
||||||
|
this.getData()
|
||||||
|
this.getDict()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleClick() {
|
||||||
|
this.getData()
|
||||||
|
},
|
||||||
|
getData() {
|
||||||
|
this.$axios({
|
||||||
|
url: this.activeName === 'day' ? this.dayMapUrl : this.activeName === 'week' ? this.weekMapUrl : this.monthMapUrl,
|
||||||
|
method: 'get',
|
||||||
|
params: this.queryParams
|
||||||
|
}).then((res) => {
|
||||||
|
let mapArr= []
|
||||||
|
let mapLegendData = []
|
||||||
|
let obj = {
|
||||||
|
name: '',
|
||||||
|
type: 'line',
|
||||||
|
// stack: 'Total',
|
||||||
|
data: [],
|
||||||
|
mapXAxisData: [],
|
||||||
|
}
|
||||||
|
// let mapXAxisData = []
|
||||||
|
for (let i in res.data) {
|
||||||
|
|
||||||
|
// console.log(i)
|
||||||
|
let dataArr = []
|
||||||
|
res.data[i].forEach(ele => {
|
||||||
|
dataArr.push(ele.num)
|
||||||
|
obj.mapXAxisData.push(ele.checkTime)
|
||||||
|
})
|
||||||
|
obj.name = i
|
||||||
|
obj.data = dataArr
|
||||||
|
mapLegendData.push(i)
|
||||||
|
mapArr.push(obj)
|
||||||
|
}
|
||||||
|
console.log(mapArr);
|
||||||
|
// console.log(res.data[res]);
|
||||||
|
var chartDom = this.activeName === 'day' ? document.getElementById('mapDayMain') : this.activeName === 'week' ? document.getElementById('mapWeekMain') : document.getElementById('mapMonthMain')
|
||||||
|
var myChart = echarts.init(chartDom);
|
||||||
|
var option;
|
||||||
|
option = {
|
||||||
|
title: {
|
||||||
|
text: '各类型缺陷对比图',
|
||||||
|
// top:'5px'
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis'
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
data: mapLegendData,
|
||||||
|
top: "10%",
|
||||||
|
y: 'top',
|
||||||
|
x:'left'
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '3%',
|
||||||
|
right: '4%',
|
||||||
|
bottom: '3%',
|
||||||
|
top:'20%',
|
||||||
|
containLabel: true
|
||||||
|
},
|
||||||
|
// toolbox: {
|
||||||
|
// feature: {
|
||||||
|
// saveAsImage: {}
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
// boundaryGap: false,
|
||||||
|
data: mapArr[0].mapXAxisData
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
type: 'value'
|
||||||
|
},
|
||||||
|
series: mapArr
|
||||||
|
}
|
||||||
|
myChart.clear()
|
||||||
|
option && myChart.setOption(option);
|
||||||
|
})
|
||||||
|
this.$axios({
|
||||||
|
url: this.activeName === 'day' ? this.dayListUrl : this.activeName === 'week' ? this.weekListUrl : this.monthListUrl,
|
||||||
|
method: 'get',
|
||||||
|
params: this.queryParams
|
||||||
|
}).then((res) => {
|
||||||
|
// console.log(res);
|
||||||
|
let listNumArr = []
|
||||||
|
let listRatioArr = []
|
||||||
|
// let listLegendData = []
|
||||||
|
let listXAxisData = []
|
||||||
|
// for (let i in res.data) {
|
||||||
|
// console.log(i)
|
||||||
|
// let dataArr = []
|
||||||
|
res.data.forEach(ele => {;
|
||||||
|
listNumArr.push(ele.num)
|
||||||
|
listRatioArr.push(ele.ratio)
|
||||||
|
listXAxisData.push(ele.checkTime)
|
||||||
|
})
|
||||||
|
console.log(listNumArr);
|
||||||
|
// obj.name = i
|
||||||
|
// obj.data = dataArr
|
||||||
|
// listLegendData.push(i)
|
||||||
|
// listArr.push(obj)
|
||||||
|
// }
|
||||||
|
// console.log(res.data[res]);
|
||||||
|
var chartDom = this.activeName === 'day' ? document.getElementById('listDayMain') : this.activeName === 'week' ? document.getElementById('listWeekMain') : document.getElementById('listMonthMain')
|
||||||
|
var myChart = echarts.init(chartDom);
|
||||||
|
var option;
|
||||||
|
option = {
|
||||||
|
title: {
|
||||||
|
text: '缺陷率趋势图'
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis'
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
data: ['缺陷数量', '缺陷率'],
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '3%',
|
||||||
|
right: '4%',
|
||||||
|
bottom: '3%',
|
||||||
|
containLabel: true
|
||||||
|
},
|
||||||
|
// toolbox: {
|
||||||
|
// feature: {
|
||||||
|
// saveAsImage: {}
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
// boundaryGap: false,
|
||||||
|
data: listXAxisData
|
||||||
|
},
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: '缺陷数量',
|
||||||
|
// min: 0,
|
||||||
|
// max: 250,
|
||||||
|
// interval: 50,
|
||||||
|
// axisLabel: {
|
||||||
|
// formatter: '{value} ml'
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: '缺陷率',
|
||||||
|
// min: 0,
|
||||||
|
// max: 25,
|
||||||
|
// interval: 5,
|
||||||
|
axisLabel: {
|
||||||
|
formatter: '{value} %'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '缺陷数量',
|
||||||
|
type: 'bar',
|
||||||
|
barWidth: '3%',
|
||||||
|
data: listNumArr,
|
||||||
|
// label: {
|
||||||
|
// show: true, //开启显示
|
||||||
|
// position: 'top', //在上方显示
|
||||||
|
// // formatter: '{c}%',//显示百分号
|
||||||
|
// textStyle: { //数值样式
|
||||||
|
// color: 'black',//字体颜色
|
||||||
|
// fontSize: 12//字体大小
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '缺陷率',
|
||||||
|
type: 'line',
|
||||||
|
yAxisIndex: 1,
|
||||||
|
tooltip: {
|
||||||
|
valueFormatter: function (value) {
|
||||||
|
return value + '%';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: listRatioArr
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
myChart.clear()
|
||||||
|
option && myChart.setOption(option);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 获取搜索栏的产线列表 */
|
||||||
|
async getDict() {
|
||||||
|
// const res = await getProductList()
|
||||||
|
// const result = await getWorkOrderList()
|
||||||
|
const res = await this.$axios({
|
||||||
|
url: '/extend/check-isra-standards/page',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
pageSize: 100,
|
||||||
|
pageNo:1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// console.log(res)
|
||||||
|
this.searchBarFormConfig[1].selectOptions = res.data.list
|
||||||
|
await getPdList().then((res) => {
|
||||||
|
// console.log(res);
|
||||||
|
this.searchBarFormConfig[2].selectOptions = res.data;
|
||||||
|
})
|
||||||
|
// this.searchBarFormConfig[1].selectOptions = res.data.map((item) => {
|
||||||
|
// return {
|
||||||
|
// name: item.name,
|
||||||
|
// id:item.id
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// this.searchBarFormConfig[0].selectOptions = result.data.map((item) => {
|
||||||
|
// return {
|
||||||
|
// name: item.name,
|
||||||
|
// id: item.id
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
},
|
||||||
|
// getProductLineList() {
|
||||||
|
// this.$axios('/base/production-line/listAll').then((response) => {
|
||||||
|
// this.searchBarFormConfig[0].selectOptions = response.data.map(
|
||||||
|
// (item) => {
|
||||||
|
// return {
|
||||||
|
// name: item.name,
|
||||||
|
// id: item.id,
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
getList() {
|
||||||
|
this.getDataList()
|
||||||
|
},
|
||||||
|
/** 查询列表 */
|
||||||
|
async getDataList() {
|
||||||
|
console.log('查询条件', this.queryParams);
|
||||||
|
this.loading = true;
|
||||||
|
// 执行查询
|
||||||
|
const {
|
||||||
|
data: { data, otherList, otherMap, nameData },
|
||||||
|
} = await getQualityIsraPage(this.queryParams)
|
||||||
|
console.log(this.queryParams);
|
||||||
|
this.dynamicProps = this.filterNameData(nameData)
|
||||||
|
this.list = this.filterData(data);
|
||||||
|
},
|
||||||
|
filterNameData(nameData) {
|
||||||
|
const ndSet = new Set();
|
||||||
|
nameData.forEach((nd) => {
|
||||||
|
ndSet.add(nd.name);
|
||||||
|
});
|
||||||
|
return Array.from(ndSet.values())
|
||||||
|
.sort()
|
||||||
|
.map((name) => ({
|
||||||
|
prop: name,
|
||||||
|
label: name,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
filterData(data) {
|
||||||
|
return data.map((item) => {
|
||||||
|
const { data: innerData } = item;
|
||||||
|
const keyValuePairs = {};
|
||||||
|
innerData.map((d) => {
|
||||||
|
keyValuePairs[d.dynamicName] = d.dynamicValue;
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
// inspectionContent: item.inspectionContent,
|
||||||
|
...keyValuePairs,
|
||||||
|
sumNum: item.sumNum,
|
||||||
|
// sumInput: item.sumInput,
|
||||||
|
// productionName: item.productionName,
|
||||||
|
checkType: item.checkType,
|
||||||
|
// scrapRatio: item.scrapRatio,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
handleSearchBarBtnClick(val) {
|
||||||
|
console.log('11111', val)
|
||||||
|
if (val.btnName === 'search') {
|
||||||
|
this.queryParams.checkDiscard = (val?.checkDiscard === 0 || val?.checkDiscard === 1) ? val?.checkDiscard : undefined
|
||||||
|
this.queryParams.lineName = val.lineName ? val.lineName : undefined
|
||||||
|
this.queryParams.checkType = val.checkType ? val.checkType : undefined
|
||||||
|
// this.queryParams.productionId = val.productionId ? val.productionId : undefined
|
||||||
|
this.queryParams.startTime = val.checkTime ? val.checkTime[0] : undefined
|
||||||
|
this.queryParams.endTime = val.checkTime ? val.checkTime[1] : undefined
|
||||||
|
|
||||||
|
this.getList()
|
||||||
|
this.getData()
|
||||||
|
}
|
||||||
|
console.log(val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style lang="scss">
|
||||||
|
.blue-title {
|
||||||
|
position: relative;
|
||||||
|
padding: 4px 0;
|
||||||
|
padding-left: 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #606266;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 6px;
|
||||||
|
height: 16px;
|
||||||
|
width: 4px;
|
||||||
|
border-radius: 1px;
|
||||||
|
background: #0b58ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
305
src/views/quality/transmittanceTesting.vue
Normal file
305
src/views/quality/transmittanceTesting.vue
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<base-table :max-height="tableH" :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize"
|
||||||
|
:table-data="list" @emitFun="handleEmitFun">
|
||||||
|
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn"
|
||||||
|
@clickBtn="handleTableBtnClick" /> -->
|
||||||
|
</base-table>
|
||||||
|
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList" />
|
||||||
|
|
||||||
|
<!-- 对话框(添加 / 修改) -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import moment from 'moment';
|
||||||
|
import { getPdList,} from '@/api/core/monitoring/auto';
|
||||||
|
import { getFactoryPage } from '@/api/core/base/factory';
|
||||||
|
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||||
|
import { getTranslucentPage, exportTranslucent } from '@/api/monitoring/defectSummary';
|
||||||
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||||
|
export default {
|
||||||
|
name: 'QualityInspectionType',
|
||||||
|
mixins: [basicPageMixin, tableHeightMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// tableBtn: [
|
||||||
|
// this.$auth.hasPermi('base:quality-inspection-type:update')
|
||||||
|
// ? {
|
||||||
|
// type: 'edit',
|
||||||
|
// btnName: '修改',
|
||||||
|
// }
|
||||||
|
// : undefined,
|
||||||
|
// this.$auth.hasPermi('base:quality-inspection-type:delete')
|
||||||
|
// ? {
|
||||||
|
// type: 'delete',
|
||||||
|
// btnName: '删除',
|
||||||
|
// }
|
||||||
|
// : undefined,
|
||||||
|
// ].filter((v) => v),
|
||||||
|
tableProps: [
|
||||||
|
// {
|
||||||
|
// prop: 'createTime',
|
||||||
|
// label: '添加时间',
|
||||||
|
// fixed: true,
|
||||||
|
// width: 180,
|
||||||
|
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
|
||||||
|
// },
|
||||||
|
{ prop: 'factoryName', label: '工厂' },
|
||||||
|
{ prop: 'lineName', label: '产线' },
|
||||||
|
{ prop: 'timeVal', label: '时间段' },
|
||||||
|
{ prop: 'totalNum', label: '玻璃总数' },
|
||||||
|
{ prop: 'goodNum', label: '一等品数量' },
|
||||||
|
{ prop: 'passNum', label: '二等品数量' },
|
||||||
|
{ prop: 'scrapNum', label: '废片数' },
|
||||||
|
{ prop: 'passRate', label: '合格率' },
|
||||||
|
],
|
||||||
|
//
|
||||||
|
searchBarFormConfig: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '工厂',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'factoryId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
label: '产线',
|
||||||
|
selectOptions: [],
|
||||||
|
param: 'lineId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'datePicker',
|
||||||
|
label: '时间范围',
|
||||||
|
dateType: 'datetimerange',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
rangeSeparator: '-',
|
||||||
|
startPlaceholder: '开始时间',
|
||||||
|
endPlaceholder: '结束时间',
|
||||||
|
param: 'timeVal',
|
||||||
|
width: 350
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
btnName: '查询',
|
||||||
|
name: 'search',
|
||||||
|
color: 'primary',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: 'button',
|
||||||
|
// btnName: '重置',
|
||||||
|
// name: 'reset',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: 'separate',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// type: this.$auth.hasPermi('base:quality-inspection-type:create')
|
||||||
|
// ? 'button'
|
||||||
|
// : '',
|
||||||
|
// btnName: '新增',
|
||||||
|
// name: 'add',
|
||||||
|
// plain: true,
|
||||||
|
// color: 'success',
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
type: this.$auth.hasPermi('monitoring:translucent:export')
|
||||||
|
? 'button'
|
||||||
|
: '',
|
||||||
|
btnName: '导出',
|
||||||
|
name: 'export',
|
||||||
|
color: 'warning',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 表单配置
|
||||||
|
// formRows: [
|
||||||
|
// [
|
||||||
|
// {
|
||||||
|
// input: true,
|
||||||
|
// label: '检测类型名称',
|
||||||
|
// prop: 'name',
|
||||||
|
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
|
||||||
|
// // bind: {
|
||||||
|
// // disabled: true, // some condition, like detail mode...
|
||||||
|
// // }
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// [{ input: true, label: '检测类型编码', prop: 'code' }],
|
||||||
|
// [{ input: true, label: '备注', prop: 'remark' }],
|
||||||
|
// ],
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
lineId: undefined,
|
||||||
|
factoryId: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// watch: {
|
||||||
|
// form: {
|
||||||
|
// handler: (val) => {
|
||||||
|
// console.log('form changed', val);
|
||||||
|
// },
|
||||||
|
// deep: true
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
this.getDict()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getDict() {
|
||||||
|
getPdList().then(res => {
|
||||||
|
this.searchBarFormConfig[1].selectOptions = res.data || [];
|
||||||
|
});
|
||||||
|
getFactoryPage({ pageSize: 100, pageNo: 1 }).then(res => {
|
||||||
|
this.searchBarFormConfig[0].selectOptions = res.data.list || [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** base table related */
|
||||||
|
handleTableBtnClick({ data, type }) {
|
||||||
|
switch (type) {
|
||||||
|
case 'edit':
|
||||||
|
this.handleUpdate(data);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
this.handleDelete(data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** search bar related */
|
||||||
|
handleSearchBarBtnClick(btn) {
|
||||||
|
console.log('btn',btn);
|
||||||
|
|
||||||
|
// const keys = ['name'];
|
||||||
|
switch (btn.btnName) {
|
||||||
|
case 'search':
|
||||||
|
this.queryParams.lineId = btn.lineId ? btn.lineId : undefined
|
||||||
|
this.queryParams.factoryId = btn.factoryId ? btn.factoryId : undefined
|
||||||
|
this.queryParams.startTime = btn.timeVal ? btn.timeVal[0] : undefined
|
||||||
|
this.queryParams.endTime = btn.timeVal ? btn.timeVal[1] : undefined
|
||||||
|
// keys.forEach((key) => {
|
||||||
|
// this.queryParams[key] = btn[key] || null;
|
||||||
|
// });
|
||||||
|
this.getList();
|
||||||
|
break;
|
||||||
|
case 'add':
|
||||||
|
this.handleAdd();
|
||||||
|
break;
|
||||||
|
case 'export':
|
||||||
|
this.handleExport();
|
||||||
|
break;
|
||||||
|
case 'reset':
|
||||||
|
this.$refs['search-bar'].resetForm();
|
||||||
|
this.resetQuery();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 执行查询
|
||||||
|
getTranslucentPage(this.queryParams).then((res) => {
|
||||||
|
this.list = res.data.list ? res.data.list.map((item) => {
|
||||||
|
const startTime = item.startTime ? moment(item.startTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||||
|
const endTime = item.endTime ? moment(item.endTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||||
|
|
||||||
|
// 拼接开始时间和结束时间,中间用“至”连接
|
||||||
|
const timeVal = startTime && endTime ? `${startTime} 至 ${endTime}` : '';
|
||||||
|
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
timeVal: timeVal
|
||||||
|
};
|
||||||
|
}) :[]
|
||||||
|
this.total = res.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 表单重置 */
|
||||||
|
// reset() {
|
||||||
|
// this.form = {
|
||||||
|
// id: undefined,
|
||||||
|
// name: undefined,
|
||||||
|
// code: undefined,
|
||||||
|
// remark: undefined,
|
||||||
|
// };
|
||||||
|
// this.resetForm('form');
|
||||||
|
// },
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
// handleAdd() {
|
||||||
|
// this.reset();
|
||||||
|
// this.open = true;
|
||||||
|
// this.title = '添加质量检测类型基础';
|
||||||
|
// },
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
// handleUpdate(row) {
|
||||||
|
// this.reset();
|
||||||
|
// const id = row.id;
|
||||||
|
// getQualityInspectionType(id).then((response) => {
|
||||||
|
// this.form = response.data;
|
||||||
|
// this.open = true;
|
||||||
|
// this.title = '修改质量检测类型基础';
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
/** 提交按钮 */
|
||||||
|
// submitForm() {
|
||||||
|
// // console.log('this.$refs.form', this.$refs.form);
|
||||||
|
// // return;
|
||||||
|
// this.$refs['form'].validate((valid) => {
|
||||||
|
// if (!valid) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// console.log('final form', JSON.stringify(this.form));
|
||||||
|
// // 修改的提交
|
||||||
|
// if (this.form.id != null) {
|
||||||
|
// updateQualityInspectionType(this.form).then((response) => {
|
||||||
|
// this.$modal.msgSuccess('修改成功');
|
||||||
|
// this.open = false;
|
||||||
|
// this.getList();
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// // 添加的提交
|
||||||
|
// createQualityInspectionType(this.form).then((response) => {
|
||||||
|
// this.$modal.msgSuccess('新增成功');
|
||||||
|
// this.open = false;
|
||||||
|
// this.getList();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
handleExport() {
|
||||||
|
// 处理查询参数
|
||||||
|
let params = { ...this.queryParams };
|
||||||
|
// params.pageNo = undefined;
|
||||||
|
// params.pageSize = undefined;
|
||||||
|
this.$modal
|
||||||
|
.confirm('是否确认导出透光率检测?')
|
||||||
|
.then(() => {
|
||||||
|
this.exportLoading = true;
|
||||||
|
return exportTranslucent(params);
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
this.$download.excel(response, '透光率检测.xls');
|
||||||
|
this.exportLoading = false;
|
||||||
|
})
|
||||||
|
.catch(() => { });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user