From 06c8aa18a41393b564f48b42fe49db9fa761336c Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期日, 23 四月 2023 13:19:21 +0800
Subject: [PATCH] 1.MES产品对接云平台
---
src/components/DatePicker/index.vue | 263 +++++++++++++++++++++++++++++++--------------------
1 files changed, 159 insertions(+), 104 deletions(-)
diff --git a/src/components/DatePicker/index.vue b/src/components/DatePicker/index.vue
index 71d22b0..ef96a55 100644
--- a/src/components/DatePicker/index.vue
+++ b/src/components/DatePicker/index.vue
@@ -1,5 +1,5 @@
<template>
- <div v-click-outside onselectstart="return false" style="-moz-user-select : none">
+ <div v-click-outside onselectstart="return false" style="-moz-user-select : none;">
<input type="text" :value="value" :rowData="rowData" class="input__inner">
<div v-if="isVisible" :class="[{pannel:true},{top_yes:topStyle}]">
<div class="pannel-nav">
@@ -42,11 +42,14 @@
:disabled="!isDblDate(visibleDays[(i-1)*7+(j-1)])"
>
+
<div class="pop_style">{{ callbackTxt(visibleDays[(i - 1) * 7 + (j - 1)]) }}</div>
+ <!-- <div class="pop_style">123</div>-->
<span
slot="reference"
:class="[{select:isSelect(visibleDays[(i-1)*7+(j-1)])},
{dblDateStyle:isDblDate(visibleDays[(i-1)*7+(j-1)])}]"
+ :style="{background: isSelect(visibleDays[(i-1)*7+(j-1)])?$store.state.settings.theme:''}"
>{{ visibleDays[(i - 1) * 7 + (j - 1)].getDate() }}</span>
</el-popover>
@@ -64,6 +67,7 @@
}}骞磠{ dblTime.month + 1 }}鏈�</span><span class="samllText">鏄熸湡{{ getweekday(handleDatetime(dblDate)) }}</span>
</div>
<div class="pannelTo_nav">
+
<el-select v-model="schemeDate" size="small" style="width:240px;" @change="changeScheme">
<el-option v-for="item in projectList" :key="item.CapCode" :value="item.CapCode" :label="item.CapName" />
</el-select>
@@ -120,7 +124,14 @@
</template>
<script>
import * as funsdates from '@/utils/funsdate'
-// import capacityPlanning from '@/api/capacityPlanning'
+import {
+ CapacityPlanningCalendar,
+ CapacityPlanningGivePlanSubmit,
+ CapacityPlanningOnclickSelect,
+ CapacityPlanningSetupSearch
+} from '@/api/produceManager'
+import { handleDatetime } from '@/utils/global'
+
var time = null
export default {
directives: {
@@ -147,20 +158,24 @@
},
props: {
value: {
- // type:Date,
- // default:()=> new Date
- type: String,
+ type: Array,
default: null
},
+ defArr: {
+ type: Array,
+ default: Array
+ },
rowData: {
- type: String,
+ type: Object,
default: null
},
CapacityPlanningSearch: {
type: Function,
default: null
}
+
},
+
data() {
const { year, month } = funsdates.getYearMonthDay(new Date())
return {
@@ -181,14 +196,15 @@
weekDays: ['鏃�', '涓�', '浜�', '涓�', '鍥�', '浜�', '鍏�'],
changeTime: '',
changeTimeArr: [],
- defArr: [],
+ // defArr: [],
dm_top: '',
topStyle: false,
form: {
- rows: 100,
+ rows: 1000,
page: 1
},
projectDef: []
+
}
},
computed: {
@@ -210,7 +226,6 @@
}
},
mounted() {
-
},
methods: {
getDblTime() {
@@ -227,17 +242,16 @@
let name = ''
if (this.isDblDate(date)) {
for (const i in this.defArr) {
- if (this.defArr[i].name == this.handleDatetime(date)) {
+ if (this.defArr[i].name === this.handleDatetime(date)) {
code = this.defArr[i].key
}
}
}
for (const i in this.projectDef) {
- if (this.projectDef[i].CapSetupCode == code) {
- name = this.projectDef[i].CapSetupName
+ if (this.projectDef[i].code === code) {
+ name = this.projectDef[i].name
}
}
-
return name
},
getHeight() {
@@ -249,6 +263,7 @@
}
const e = event || window.event
+
const nowHeigth = e.clientY
if (nowHeigth >= 500) {
this.topStyle = true
@@ -273,13 +288,13 @@
changeScheme() {
let toList = []
for (const i in this.projectList) {
- if (this.schemeDate == this.projectList[i].CapCode) {
+ if (this.schemeDate === this.projectList[i].CapCode) {
toList = this.projectList[i].list
}
}
for (const i in this.defArr) {
- if (this.defArr[i].name == this.changeTime) {
+ if (this.defArr[i].name === this.changeTime) {
this.defArr[i].key = this.schemeDate
}
}
@@ -288,13 +303,16 @@
},
focus() {
this.isVisible = true
- this.CapacityPlanningCalendar()
+
+ this.getCapacityPlanningCalendar()
this.getHeight()
- this.CapacityPlanningSetupSearch()
+ this.getCapacityPlanningSetupSearch()
this.CapacityPlanningSearch()
},
blur() {
- this.isVisible = false
+ this.isDbl = false // 鍙充晶闈㈡澘鍏抽棴
+ this.isVisible = false// 涓婚潰鏉垮叧闂�
+ this.$emit('over', true)// 缁欑埗缁勪欢鍙戝嚭璇锋眰锛屽憡璇変粬宸茬粡瀹屾垚鎿嶄綔锛屽彲璋冪敤鑾峰彇鍒楄〃鎺ュ彛
},
isCurrentMonth(date) {
const { year, month } = funsdates.getYearMonthDay(new Date(this.time.year,
@@ -310,33 +328,30 @@
// 杩囨湡鏃堕棿
isPastDue(date) {
const newDate = this.handleDatetime(new Date())
- if (new Date(newDate) > date && this.handleDatetime(date) != newDate) {
- return true
- } else {
- return false
- }
+ return new Date(newDate) > date && this.handleDatetime(date) !== newDate
},
chooseDate(date) {
clearTimeout(time) // 棣栧厛娓呴櫎璁℃椂鍣�
time = setTimeout(() => {
this.time = funsdates.getYearMonthDay(date)
- const timeDate = ''
+ if (typeof this.value === 'string') {
+ this.value = this.value.split(',')
+ }
this.isDbl = false
// 鍙互鐐瑰嚮鐨勬棩鏈�
if (!this.isPastDue(date)) {
- if ((this.value.indexOf(this.handleDatetime(date)) < 0 && this.value != '') || this.value == '') { // 鏁扮粍娣诲姞
+ if ((this.value.indexOf(this.handleDatetime(date)) < 0 && this.value !== '') || this.value === '') { // 鏁扮粍娣诲姞
this.value.push(this.handleDatetime(date)) // 鏂板鍒癷nput閲�
const data = {
name: this.handleDatetime(date),
key: this.rowData.CaptPlanWorkShiftCode
}
-
this.defArr.push(data) // 鏂板鍒� 榛樿鏁扮粍閲�
} else if (this.value.indexOf(this.handleDatetime(date)) >= 0) { // 鏁扮粍鍑忓幓
const indexV = this.value.indexOf(this.handleDatetime(date))
this.value.splice(indexV, 1)
for (const i in this.defArr) {
- if (this.defArr[i].name == this.handleDatetime(date)) {
+ if (this.defArr[i].name === this.handleDatetime(date)) {
this.defArr.splice(i, 1)
}
}
@@ -348,17 +363,63 @@
dblChooseDate(date) {
if (!this.isPastDue(date)) {
clearTimeout(time)
- this.dblDate = date
- this.isDbl = true
- this.changeTime = this.handleDatetime(date)
- this.CapacityPlanningOnclickSelect({ CaptPlanId: this.rowData.CaptPlanId, DateTime: this.handleDatetime(date) })
- this.getDblTime()
+ time = setTimeout(() => {
+ this.time = funsdates.getYearMonthDay(date)
+ if (typeof this.value === 'string') {
+ this.value = this.value.split(',')
+ }
+ // 鍙互鐐瑰嚮鐨勬棩鏈�
+ if (!this.isPastDue(date)) {
+ if ((this.value.indexOf(this.handleDatetime(date)) < 0 && this.value !== '') || this.value === '') { // 鏁扮粍娣诲姞
+ this.value.push(this.handleDatetime(date)) // 鏂板鍒癷nput閲�
+ const data = {
+ name: this.handleDatetime(date),
+ key: this.rowData.CaptPlanWorkShiftCode
+ }
+ this.defArr.push(data) // 鏂板鍒� 榛樿鏁扮粍閲�
+ this.dblDate = date
+ this.isDbl = true // 鍙充晶灞曞紑
+
+ this.changeTime = this.handleDatetime(date)
+
+ const DATA = {
+ CaptPlanWorkShiftCode: this.defArr.find(item => item.name === this.changeTime).key,
+ captplanid: this.rowData.CaptPlanId,
+ datetime: this.handleDatetime(date)
+ }
+ this.getCapacityPlanningOnclickSelect(DATA)
+ this.getDblTime()
+ } else if (this.value.indexOf(this.handleDatetime(date)) >= 0) {
+ this.dblDate = date
+ this.isDbl = true // 鍙充晶灞曞紑
+
+ this.changeTime = this.handleDatetime(date)
+
+ const DATA = {
+ CaptPlanWorkShiftCode: this.defArr.find(item => item.name === this.changeTime).key,
+ captplanid: this.rowData.CaptPlanId,
+ datetime: this.handleDatetime(date)
+ }
+ this.getCapacityPlanningOnclickSelect(DATA)
+ this.getDblTime()
+
+ // const indexV = this.value.indexOf(this.handleDatetime(date))
+ // this.value.splice(indexV, 1)
+ // for (const i in this.defArr) {
+ // if (this.defArr[i].name === this.handleDatetime(date)) {
+ // this.defArr.splice(i, 1)
+ // }
+ // }
+ }
+ }
+ this.$emit('input', this.value)
+ }, 300)
}
},
isDblDate(date) {
for (const i in this.defArr) {
- if (this.defArr[i].key != '') {
- if (this.defArr[i].name == this.handleDatetime(date) && this.defArr[i].key != this.rowData.CaptPlanWorkShiftCode) {
+ if (this.defArr[i].key !== '') {
+ if (this.defArr[i].name === this.handleDatetime(date) && this.defArr[i].key !== this.rowData.CaptPlanWorkShiftCode) {
return true
}
}
@@ -417,76 +478,67 @@
// }
// },
// 鍙屽嚮璇锋眰鏁版嵁
- CapacityPlanningOnclickSelect(data) {
- // capacityPlanning.CapacityPlanningOnclickSelect(data).then((res) =>{
- // this.projectList = res.List
- // for(let i in this.defArr){
- // if(this.defArr[i].name == data.DateTime){
- // this.schemeDate = this.defArr[i].key
- // }
- // }
- // this.changeScheme()
- // })
+ getCapacityPlanningOnclickSelect(data) {
+ CapacityPlanningOnclickSelect(data).then((res) => {
+ this.projectList = res.data
+
+ // for (const i in this.defArr) {
+ // console.log(this.defArr[i].name === data.DateTime, 6)
+ // if (this.defArr[i].name === data.DateTime) {
+ // this.schemeDate = this.defArr[i].key
+ // }
+ // }
+
+ this.schemeDate = data.CaptPlanWorkShiftCode
+
+ this.changeScheme()
+ })
},
+ // 宸ヤ綔鏃ュ巻鎻愪氦
CapacityPlanningGivePlanSubmit() {
- const data = {
- CaptPlanId: this.rowData.CaptPlanId,
- WkshopCode: this.rowData.CaptPlanWorkShopid,
- CapUnitCode: this.rowData.CaptPlanDeviceTypeid,
- CapSetupCode: this.rowData.CaptPlanWorkShiftCode,
- CaptPlanType: this.rowData.CaptPlanType,
- WorkList: JSON.stringify(this.defArr)
- }
- // capacityPlanning.CapacityPlanningGivePlanSubmit(data).then((res) =>{
- // if (res.statusCode == 300) {
- // this.$message({
- // showClose:true,
- // message: res.message,
- // type: "error"
- // });
- // } else {
- // this.$message({
- // showClose:true,
- // message: res.message,
- // type: "success"
- // });
- // this.blur()
- // this.CapacityPlanningSearch()
- // }
- // })
+ const formData = new FormData()
+ formData.append('wkshopcode', this.rowData.CaptPlanWorkShopid)// 杞﹂棿缂栫爜
+ formData.append('capunitcode', this.rowData.CaptPlanDeviceTypeid)// 鐢熶骇鍗曞厓缂栫爜锛堜骇绾跨紪鐮侊級
+ formData.append('captplanid', this.rowData.CaptPlanId)// 浜ц兘璧勬簮id
+ formData.append('capsetupcode', this.rowData.CaptPlanWorkShiftCode) // 榛樿鏂规缂栫爜
+ formData.append('captplantype', this.rowData.CaptPlanType)// 璧勬簮绫诲瀷
+ formData.append('worklist', JSON.stringify(this.defArr))// 宸ヤ綔鏃ュ巻鏁版嵁闆�
+ // for (const [a, b] of formData.entries()) {
+ // console.log(a, ':', b)
+ // }
+ CapacityPlanningGivePlanSubmit(formData).then(res => {
+ if (res.code === '200') {
+ this.$message.success('淇濆瓨鎴愬姛锛�')
+ this.blur()
+ this.CapacityPlanningSearch()
+ }
+ })
},
- CapacityPlanningCalendar() {
- // capacityPlanning.CapacityPlanningCalendar({CaptPlanId:this.rowData.CaptPlanId}).then((res) =>{
- //
- // for(let i in res.List){
- //
- // if(res.List[i].key == ''){
- // res.List[i].key = this.rowData.CaptPlanWorkShiftCode
- // }
- // }
- // this.defArr = res.List
- // })
+ getCapacityPlanningCalendar() {
+ CapacityPlanningCalendar({ captplanid: this.rowData.CaptPlanId }).then((res) => {
+ const currentDate = handleDatetime(new Date())
+ this.defArr = res.data.filter(i => i.name >= currentDate)
+ })
},
closeCapacityPlanningCalendar() {
- // capacityPlanning.CapacityPlanningCalendar({CaptPlanId:this.rowData.CaptPlanId}).then((res) =>{
- // let nameList = []
- // for(let i in res.List){
- // nameList.push(res.List[i].name)
- // if(res.List[i].key == ''){
- // res.List[i].key = this.rowData.CaptPlanWorkShiftCode
- // }
- // }
- // for(let i in this.defArr){
- // for(let j in res.List){
- // if(this.defArr[i].name == this.changeTime && res.List[j].name == this.changeTime){
- // this.defArr[i].key = res.List[j].key
- // } else if(this.defArr[i].name == this.changeTime && nameList.indexOf(this.changeTime)==-1){
- // this.defArr[i].key = this.rowData.CaptPlanWorkShiftCode
- // }
- // }
- //
- // }
- // })
+ CapacityPlanningCalendar({ captplanid: this.rowData.CaptPlanId }).then((res) => {
+ const nameList = []
+ for (const i in res.data) {
+ nameList.push(res.data[i].name)
+ if (res.data[i].key === '') {
+ res.data[i].key = this.rowData.CaptPlanWorkShiftCode
+ }
+ }
+ for (const i in this.defArr) {
+ for (const j in res.data) {
+ if (this.defArr[i].name === this.changeTime && res.data[j].name === this.changeTime) {
+ this.defArr[i].key = res.data[j].key
+ } else if (this.defArr[i].name === this.changeTime && nameList.indexOf(this.changeTime) === -1) {
+ this.defArr[i].key = this.rowData.CaptPlanWorkShiftCode
+ }
+ }
+ }
+ })
},
close() {
setTimeout(() => {
@@ -494,10 +546,10 @@
this.closeCapacityPlanningCalendar()
}, 300)
},
- CapacityPlanningSetupSearch() {
- // capacityPlanning.CapacityPlanningSetupSearch(this.form).then((res) => {
- // this.projectDef = res.rows
- // })
+ getCapacityPlanningSetupSearch() {
+ CapacityPlanningSetupSearch(this.form).then((res) => {
+ this.projectDef = res.data
+ })
}
}
@@ -572,6 +624,8 @@
border-radius: 4px;
line-height: 30px;
margin: 5px 0;
+ //overflow: visible !important;
+ //box-sizing: border-box;
.pannel-nav {
position: relative;
@@ -643,7 +697,8 @@
border-top: 1px solid #E7E7EA;
padding: 10px;
overflow: hidden;
- height: 58px;;
+ height: 58px;
+
}
}
--
Gitblit v1.9.3