<template>
|
<div>
|
<div class="body" :style="{height:mainHeight+'px'}">
|
<div class="bodyTopButtonGroup" style="justify-content: space-between">
|
<el-button type="primary" icon="el-icon-setting" @click="setting('setting')">设置</el-button>
|
</div>
|
|
<div class="bodyTopFormGroup">
|
<el-form
|
ref="form"
|
:model="form"
|
label-width="100px"
|
inline
|
style="display: flex;justify-content: space-between"
|
>
|
<div class="elForm">
|
<el-form-item label-width="70px" label="生产车间" style=" display: flex;">
|
<el-select
|
v-model="form.workshop"
|
style="width: 200px"
|
placeholder="请选择"
|
@change="getWhkspIsEqpSearch"
|
>
|
<el-option
|
v-for="item in workshopArr"
|
:key="item.code"
|
:label="item.name"
|
:value="item.code"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="生产单元" style=" display: flex;">
|
<el-select
|
v-model="form.devicetype"
|
style="width: 200px"
|
placeholder="请选择"
|
:disabled="form.workshop===''"
|
>
|
<el-option
|
v-for="item in devicetypeArr"
|
:key="item.eqp_code"
|
:label="item.eqp_name"
|
:value="item.eqp_code"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="有效状态" style=" display: flex;">
|
<el-select v-model="form.stustype" style="width: 200px" placeholder="请选择">
|
<el-option
|
v-for="item in stustypeArr"
|
:key="item.code"
|
:label="item.name"
|
:value="item.code"
|
/>
|
</el-select>
|
</el-form-item>
|
|
</div>
|
<div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened?'5%':'10%'}">
|
<el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
|
<el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
|
</div>
|
</el-form>
|
<div
|
class="bodyTopFormExpand"
|
/>
|
</div>
|
|
<div class="elTableDiv">
|
<el-table
|
ref="tableDataRef"
|
class="tableFixed table_only"
|
:data="tableData"
|
:style="{width: 100+'%',height:tableHeight+'px'}"
|
border
|
:height="tableHeight+'px'"
|
:row-class-name="tableRowClassName"
|
highlight-current-row
|
:header-cell-style="this.$headerCellStyle"
|
:cell-style="this.$cellStyle"
|
@sort-change="sortChange"
|
>
|
<el-table-column
|
prop="RowNum"
|
width="50"
|
fixed
|
label="序号"
|
/>
|
<el-table-column
|
prop="CaptPlanWorkShop"
|
label="生产车间"
|
sortable="custom"
|
width="160"
|
/>
|
<el-table-column
|
prop="CaptPlanDeviceType"
|
label="生产单元"
|
width="160"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="CaptPlanWorkShift"
|
label="默认方案"
|
sortable="custom"
|
width="240"
|
>
|
<template slot-scope="{row}">
|
<div style="display: flex;" @click="mrfaSearch(row,'mrfaSearch')">
|
<el-input
|
v-model="row.CaptPlanWorkShift"
|
readonly
|
/>
|
<el-button
|
type="primary"
|
style="padding: 0 10px;margin-left: 5px"
|
class="el-icon-search"
|
/>
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="CaptPlanShopCalendarList"
|
label="工作日历"
|
sortable="custom"
|
min-width="300"
|
>
|
<template slot-scope="{row}">
|
<el-input v-if="row.CaptPlanWorkShift===null" :disabled="row.CaptPlanWorkShift===null" />
|
<date-picker
|
v-else
|
v-model="row.CaptPlanShopCalendarList"
|
:row-data="row"
|
style="width: 100%;"
|
:capacity-planning-search="CapacityPlanningSearch"
|
@over="over"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="CaptPlanUser"
|
label="创建人员"
|
sortable="custom"
|
width="120"
|
/>
|
<el-table-column
|
prop="CaptPlanDate"
|
width="160"
|
label="创建时间"
|
sortable="custom"
|
/>
|
|
<el-table-column
|
prop="CaptPlanStus"
|
width="120"
|
label="有效状态"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.CaptPlanStus==='Y'">
|
<svg-icon icon-class="circleYes" style="margin-right: 2px" />
|
有效
|
</div>
|
<div v-else-if="row.CaptPlanStus==='N'">
|
<svg-icon icon-class="circleNo" style="margin-right: 2px" />
|
无效
|
</div>
|
<div v-else>/</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<!--分页-->
|
<pagination
|
:total="total"
|
:page.sync="form.page"
|
:limit.sync="form.rows"
|
align="right"
|
layout="total,prev, pager, next,sizes"
|
popper-class="select_bottom"
|
@pagination="getCapacityPlanningSearch"
|
/>
|
</div>
|
|
<el-dialog
|
:title="operation==='setting'?'设置':'默认方案'"
|
:visible.sync="dialogVisible"
|
width="1360px"
|
:close-on-click-modal="false"
|
top="10vh"
|
@closed="handleClose"
|
@close="handleClose"
|
>
|
<el-button v-if="operation==='setting'" type="primary" @click="addRow">新增</el-button>
|
<div class="elTableDiv">
|
<!-- 选择默认方案的时候是这个table-->
|
<el-table
|
v-if="operation!=='setting'"
|
ref="tableDataDialogRef"
|
class="tableFixedDialog"
|
:data="tableDataDialog"
|
:style="{width: 100+'%',height:(tableHeight-200)+'px'}"
|
border
|
:height="(tableHeight-200)+'px'"
|
:row-class-name="tableRowClassName"
|
highlight-current-row
|
:header-cell-style="this.$headerCellStyle"
|
:cell-style="this.$cellStyle"
|
@row-click="rowClick"
|
>
|
|
<el-table-column
|
width="50"
|
fixed
|
>
|
<template slot-scope="{row}">
|
<el-radio
|
v-model="radioSelectedCode"
|
:label="row.code"
|
style="padding-left: 10px;"
|
/>
|
<!-- @change.native="getCurrentRowSource(row.code)"-->
|
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="code"
|
label="方案编码"
|
width="100"
|
show-tooltip-when-overflow
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">{{ row.code }}</div>
|
<el-input v-else v-model="row.code" placeholder="请输入" type="text" />
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="name"
|
label="方案名称"
|
width="150"
|
fixed
|
show-tooltip-when-overflow
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">{{ row.name }}</div>
|
<el-input v-else v-model="row.name" placeholder="请输入" type="text" />
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="duration"
|
label="工作时长"
|
width="100"
|
show-tooltip-when-overflow
|
>
|
<template slot-scope="{row}">
|
<div>{{ row.duration ? parseFloat(row.duration.toFixed(2)) : '0' }} 小时</div>
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
prop="wktme1_start"
|
label="工作时间一"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme1_start">{{ row.wktme1_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else
|
v-model="row.wktme1_start"
|
is-range
|
:editable="false"
|
:clearable="false"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
format="HH:mm"
|
@focus="val=>getTime(val,row,'wktme1_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme2_start"
|
label="工作时间二"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme2_start">{{ row.wktme2_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme2_start"
|
is-range
|
:disabled="row.wktme1_start.length===0"
|
:editable="false"
|
:clearable="false"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
format="HH:mm"
|
@focus="val=>getTime(val,row,'wktme2_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme3_start"
|
label="工作时间三"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme3_start">{{ row.wktme3_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme3_start"
|
is-range
|
:disabled="row.wktme2_start.length===0"
|
:editable="false"
|
:clearable="false"
|
format="HH:mm"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
@focus="val=>getTime(val,row,'wktme3_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme4_start"
|
label="工作时间四"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme4_start">{{ row.wktme4_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme4_start"
|
is-range
|
:disabled="row.wktme3_start.length===0"
|
format="HH:mm"
|
:clearable="false"
|
:editable="false"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
@focus="val=>getTime(val,row,'wktme4_start')"
|
/>
|
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme5_start"
|
label="工作时间五"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme5_start">{{ row.wktme5_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme5_start"
|
is-range
|
:disabled="row.wktme4_start.length===0"
|
:clearable="false"
|
:editable="false"
|
format="HH:mm"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
@focus="val=>getTime(val,row,'wktme5_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
v-if="operation==='setting'"
|
width="100"
|
fixed="right"
|
label="操作"
|
>
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<el-button v-if="row.isVisible===0" type="text" @click="delRow(row)">删除</el-button>
|
<el-button v-if="row.isVisible===1" type="text" @click="saveRow(row)">保存</el-button>
|
<el-button v-if="row.isVisible===1" type="text" @click="cancelRow(row)">取消</el-button>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!-- 设置的时候是这个table-->
|
<el-table
|
v-else
|
ref="tableDataDialogRef"
|
class="tableFixedDialog"
|
:data="tableDataDialog"
|
:style="{width: 100+'%',height:(tableHeight-200)+'px'}"
|
border
|
:height="(tableHeight-200)+'px'"
|
:row-class-name="tableRowClassName"
|
highlight-current-row
|
:header-cell-style="this.$headerCellStyle"
|
:cell-style="this.$cellStyle"
|
>
|
<el-table-column
|
prop="code"
|
label="方案编码"
|
width="100"
|
fixed
|
show-tooltip-when-overflow
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">{{ row.code }}</div>
|
<el-input v-else v-model="row.code" placeholder="请输入" type="text" />
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="name"
|
label="方案名称"
|
width="150"
|
fixed
|
show-tooltip-when-overflow
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">{{ row.name }}</div>
|
<el-input v-else v-model="row.name" placeholder="请输入" type="text" />
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="duration"
|
label="工作时长"
|
width="100"
|
show-tooltip-when-overflow
|
>
|
<template slot-scope="{row}">
|
<div>{{ row.duration ? parseFloat(row.duration.toFixed(2)) : '0' }} 小时</div>
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
prop="wktme1_start"
|
label="工作时间一"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme1_start">{{ row.wktme1_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else
|
v-model="row.wktme1_start"
|
is-range
|
:editable="false"
|
:clearable="false"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
format="HH:mm"
|
@blur="val=>getTime(val,row,'wktme1_start')"
|
@focus="val=>getTime(val,row,'wktme1_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme2_start"
|
label="工作时间二"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme2_start">{{ row.wktme2_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme2_start"
|
is-range
|
:disabled="row.wktme1_start.length===0"
|
:editable="false"
|
:clearable="false"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
format="HH:mm"
|
@blur="val=>getTime(val,row,'wktme2_start')"
|
@focus="val=>getTime(val,row,'wktme2_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme3_start"
|
label="工作时间三"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme3_start">{{ row.wktme3_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme3_start"
|
is-range
|
:disabled="row.wktme2_start.length===0"
|
:editable="false"
|
:clearable="false"
|
format="HH:mm"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
@blur="val=>getTime(val,row,'wktme3_start')"
|
@focus="val=>getTime(val,row,'wktme3_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme4_start"
|
label="工作时间四"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme4_start">{{ row.wktme4_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme4_start"
|
is-range
|
:disabled="row.wktme3_start.length===0"
|
format="HH:mm"
|
:clearable="false"
|
:editable="false"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
@blur="val=>getTime(val,row,'wktme4_start')"
|
@focus="val=>getTime(val,row,'wktme4_start')"
|
/>
|
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wktme5_start"
|
label="工作时间五"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.isVisible===0">
|
<div v-if="row.wktme5_start">{{ row.wktme5_start }}</div>
|
<div v-else>/</div>
|
</div>
|
<el-time-picker
|
v-else-if="row.isVisible===1"
|
v-model="row.wktme5_start"
|
is-range
|
:disabled="row.wktme4_start.length===0"
|
:clearable="false"
|
:editable="false"
|
format="HH:mm"
|
range-separator="~"
|
start-placeholder="开始"
|
end-placeholder="结束"
|
@blur="val=>getTime(val,row,'wktme5_start')"
|
@focus="val=>getTime(val,row,'wktme5_start')"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
v-if="operation==='setting'"
|
width="100"
|
fixed="right"
|
label="操作"
|
>
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<el-button v-if="row.isVisible===0" type="text" @click="delRow(row)">删除</el-button>
|
<el-button v-if="row.isVisible===1" type="text" @click="saveRow(row)">保存</el-button>
|
<el-button v-if="row.isVisible===1" type="text" @click="cancelRow(row)">取消</el-button>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<div class="footerButton">
|
<el-button @click="dialogVisibleCancel">返 回</el-button>
|
<el-button
|
v-if="operation!=='setting'"
|
type="primary"
|
:loading="$store.state.app.buttonIsDisabled"
|
:disabled="$store.state.app.buttonIsDisabled"
|
@click="dialogVisibleConfirm"
|
>确 定</el-button>
|
</div>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import Pagination from '@/components/Pagination'
|
import DatePicker from '@/components/DatePicker'
|
import {
|
CapacityPlanningSearch,
|
CapacityPlanningSetupAddUpdate,
|
CapacityPlanningSetupDelete,
|
CapacityPlanningSetupSearch, CapacityPlanSubmit
|
} from '@/api/scgl'
|
import { DeviceTypeSelect, WorkShopSelect } from '@/api/sbgl'
|
import { handleDatetime3 } from '@/utils/global'
|
import { WhkspIsEqpSearch } from '@/api/jcsz'
|
|
export default {
|
name: 'Zzjg',
|
components: {
|
Pagination, DatePicker
|
},
|
data() {
|
return {
|
mouseHoverType: 'mouseout',
|
isExpandForm: false,
|
mainHeight: 0,
|
tableHeight: 0,
|
form: {
|
workshop: '', // 车间编码
|
devicetype: '', // 生产单元
|
stustype: '', // 有效状态
|
prop: 'CaptPlanDate', // 排序字段
|
order: 'desc', // 排序字段
|
page: 1, // 第几页
|
rows: 20 // 每页多少条
|
},
|
stustypeArr: [
|
{ name: '有效', code: 'Y' },
|
{ name: '无效', code: 'N' }
|
],
|
workshopArr: [],
|
devicetypeArr: [],
|
total: 10,
|
tableData: [],
|
dialogVisible: false,
|
operation: '',
|
pickerOptions: {
|
disabledDate(time) {
|
// return time.getTime() > Date.now(); // 可选历史天、可选当前天、不可选未来天
|
// return time.getTime() > Date.now() - 8.64e7; // 可选历史天、不可选当前天、不可选未来天
|
return time.getTime() < Date.now() - 8.64e7 // 不可选历史天、可选当前天、可选未来天
|
// return time.getTime() < Date.now(); // 不可选历史天、不可选当前天、可选未来天
|
}
|
},
|
tableDataDialog: [],
|
radioSelectedCode: '',
|
tempObj: {} // 临时对象,默认方案提交时使用
|
|
}
|
},
|
|
created() {
|
this.handleRequest()
|
},
|
mounted() {
|
window.addEventListener('resize', this.getHeight)
|
this.getHeight()
|
},
|
methods: {
|
// 行点击事件
|
rowClick(row, event, column) {
|
this.radioSelectedCode = row.code
|
},
|
// 子组件失焦时执行
|
over(val) {
|
if (val) {
|
// console.log(val)
|
this.getCapacityPlanningSearch()
|
}
|
},
|
getCurrentRowSource(code) {
|
this.radioSelectedCode = code
|
},
|
async getDialogData() {
|
const { data: res } = await CapacityPlanningSetupSearch()
|
this.tableDataDialog = res
|
|
this.tableDataDialog.forEach(item => {
|
let number = Math.random() * Math.random()// 作为删除时的标识符
|
number = number === 0 ? (10 + Math.random()) : number
|
item.number = number
|
item.isVisible = 0
|
item.duration = this.computingTime(item.wktme1_start, item.wktme2_start, item.wktme3_start, item.wktme4_start, item.wktme5_start)
|
})
|
},
|
// 计算时间的方法 返回 多少小时
|
computingTime(time1, time2, time3, time4, time5) {
|
// 转成分钟计算
|
const second1 = time1 ? calcTime(time1) : null
|
const second2 = time2 ? calcTime(time2) : null
|
const second3 = time3 ? calcTime(time3) : null
|
const second4 = time4 ? calcTime(time4) : null
|
const second5 = time5 ? calcTime(time5) : null
|
return (second1 + second2 + second3 + second4 + second5) / 60
|
|
// 两个时间差值 转化为分钟数
|
function calcTime(val) {
|
return (parseInt(val.split('~')[1].split(':')[0]) * 60 + parseInt(val.split('~')[1].split(':')[1])) - (parseInt(val.split('~')[0].split(':')[0]) * 60 + parseInt(val.split('~')[0].split(':')[1]))
|
}
|
},
|
getTime(val, row, belong) {
|
// const res = this.getDt()
|
if (belong === 'wktme1_start') {
|
// row.wktme1_start.push(new Date(res.yyyy, res.MM, res.dd, '00', '00'))
|
row.wktme1_start = row.wktme1_start.length > 0 ? row.wktme1_start : row.wktme1_start.push(new Date())
|
} else if (belong === 'wktme2_start') {
|
row.wktme2_start = row.wktme2_start.length > 0 ? row.wktme2_start : row.wktme2_start.push(new Date())
|
} else if (belong === 'wktme3_start') {
|
row.wktme3_start = row.wktme3_start.length > 0 ? row.wktme3_start : row.wktme3_start.push(new Date())
|
} else if (belong === 'wktme4_start') {
|
row.wktme4_start = row.wktme4_start.length > 0 ? row.wktme4_start : row.wktme4_start.push(new Date())
|
} else if (belong === 'wktme5_start') {
|
row.wktme5_start = row.wktme5_start.length > 0 ? row.wktme5_start : row.wktme5_start.push(new Date())
|
}
|
|
const duration = this.computingTime(handleDatetime3(row.wktme1_start[0]) + '~' + handleDatetime3(row.wktme1_start[1]),
|
row.wktme2_start.length !== 0 ? handleDatetime3(row.wktme2_start[0]) + '~' + handleDatetime3(row.wktme2_start[1]) : null,
|
row.wktme3_start.length !== 0 ? handleDatetime3(row.wktme3_start[0]) + '~' + handleDatetime3(row.wktme3_start[1]) : null,
|
row.wktme4_start.length !== 0 ? handleDatetime3(row.wktme4_start[0]) + '~' + handleDatetime3(row.wktme4_start[1]) : null,
|
row.wktme5_start.length !== 0 ? handleDatetime3(row.wktme5_start[0]) + '~' + handleDatetime3(row.wktme5_start[1]) : null)
|
row.duration = parseFloat(duration.toFixed(2))
|
console.log(row.duration)
|
},
|
getDt() {
|
const dt = new Date()
|
|
const y = dt.getFullYear()
|
const m = (dt.getMonth() + 1 + '').padStart(2, '0')
|
const d = (dt.getDate() + '').padStart(2, '0')
|
|
const hh = (dt.getHours() + '').padStart(2, '0')
|
const mm = (dt.getMinutes() + '').padStart(2, '0')
|
const ss = (dt.getSeconds() + '').padStart(2, '0')
|
|
return { yyyy: y, MM: m, dd: d, hh, mm }
|
},
|
addRow() {
|
const temp = this.tableDataDialog.find(item => item.isVisible === 1)
|
if (temp) {
|
return this.$message.info('请先保存上一条记录!')
|
}
|
|
let number = Math.random() * Math.random()// 作为删除时的标识符
|
number = number === 0 ? (10 + Math.random()) : number
|
this.tableDataDialog.push(
|
{
|
RowNum: 2,
|
code: '',
|
name: '',
|
duration: '',
|
wktme1_start: [],
|
wktme2_start: [],
|
wktme3_start: [],
|
wktme4_start: [],
|
wktme5_start: [],
|
isVisible: 1,
|
number
|
}
|
)
|
},
|
cancelRow(row) {
|
this.tableDataDialog.forEach((item, index) => {
|
if (row.number === item.number) {
|
this.tableDataDialog.splice(index, 1)
|
}
|
})
|
},
|
async saveRow(row) {
|
if (row.code.trim().toString().length === 0) {
|
return this.$message.info('方案编码不能为空!')
|
}
|
if (row.name.trim().toString().length === 0) {
|
return this.$message.info('方案名称不能为空!')
|
}
|
if (row.wktme1_start.length === 0) {
|
return this.$message.info('工作时间不能为空,保存失败!')
|
}
|
// 保存时需要先判断工作时间后面的不能小于前面的
|
// 先取出来存转化成分钟存成数组进行大小对比
|
if (calcTime(handleDatetime3(row.wktme1_start[1]), handleDatetime3(row.wktme2_start[0]))) {
|
return this.$message.info('工作时间二的开始时间小于了工作时间一的结束时间,保存失败!')
|
}
|
if (calcTime(handleDatetime3(row.wktme2_start[1]), handleDatetime3(row.wktme3_start[0]))) {
|
return this.$message.info('工作时间三的开始时间小于了工作时间二的结束时间,保存失败!')
|
}
|
if (calcTime(handleDatetime3(row.wktme3_start[1]), handleDatetime3(row.wktme4_start[0]))) {
|
return this.$message.info('工作时间四的开始时间小于了工作时间三的结束时间,保存失败!')
|
}
|
if (calcTime(handleDatetime3(row.wktme4_start[1]), handleDatetime3(row.wktme5_start[0]))) {
|
return this.$message.info('工作时间五的开始时间小于了工作时间四的结束时间,保存失败!')
|
}
|
const Duration = this.computingTime(handleDatetime3(row.wktme1_start[0]) + '~' + handleDatetime3(row.wktme1_start[1]),
|
row.wktme2_start.length !== 0 ? handleDatetime3(row.wktme2_start[0]) + '~' + handleDatetime3(row.wktme2_start[1]) : null,
|
row.wktme3_start.length !== 0 ? handleDatetime3(row.wktme3_start[0]) + '~' + handleDatetime3(row.wktme3_start[1]) : null,
|
row.wktme4_start.length !== 0 ? handleDatetime3(row.wktme4_start[0]) + '~' + handleDatetime3(row.wktme4_start[1]) : null,
|
row.wktme5_start.length !== 0 ? handleDatetime3(row.wktme5_start[0]) + '~' + handleDatetime3(row.wktme5_start[1]) : null)
|
const data = {
|
CapSetupCode: row.code,
|
CapSetupName: row.name,
|
OneStartDate: row.wktme1_start.length !== 0 ? handleDatetime3(row.wktme1_start[0]) + '~' + handleDatetime3(row.wktme1_start[1]) : '',
|
TwoStartDate: row.wktme2_start.length !== 0 ? handleDatetime3(row.wktme2_start[0]) + '~' + handleDatetime3(row.wktme2_start[1]) : '',
|
ThreeStartDate: row.wktme3_start.length !== 0 ? handleDatetime3(row.wktme3_start[0]) + '~' + handleDatetime3(row.wktme3_start[1]) : '',
|
FourStartDate: row.wktme4_start.length !== 0 ? handleDatetime3(row.wktme4_start[0]) + '~' + handleDatetime3(row.wktme4_start[1]) : '',
|
FiveStartDate: row.wktme5_start.length !== 0 ? handleDatetime3(row.wktme5_start[0]) + '~' + handleDatetime3(row.wktme5_start[1]) : '',
|
Duration: parseFloat(Duration.toFixed(2))
|
}
|
const res = await CapacityPlanningSetupAddUpdate({ capacitylist: [data] })
|
if (res.code === '200') {
|
await this.getDialogData()
|
}
|
|
// 如果时间段二的开始时间小于时间段一的结束时间 则返回true,并且提示用户保存不了
|
function calcTime(time1, time2) {
|
const temp1 = parseInt(time1.split(':')[0]) * 60 + parseInt(time1.split(':')[1])
|
const temp2 = parseInt(time2.split(':')[0]) * 60 + parseInt(time2.split(':')[1])
|
return temp2 < temp1
|
}
|
},
|
async delRow(row) {
|
const res = await CapacityPlanningSetupDelete({ capsetupcode: row.code })
|
if (res.code === '200') {
|
await this.getDialogData()
|
}
|
},
|
async CapacityPlanningSearch() {
|
|
},
|
handleRequest() {
|
this.getCapacityPlanningSearch().then(res => {
|
if (res.code === '200') {
|
this.getWorkShopSelect()
|
// this.getDeviceTypeSelect()
|
}
|
})
|
},
|
async getCapacityPlanningSearch() {
|
const res = await CapacityPlanningSearch(this.form)
|
this.total = res.count
|
this.tableData = res.data
|
this.tableData.forEach(item => {
|
item.CaptPlanShopCalendarList = item.CaptPlanShopCalendarList ? item.CaptPlanShopCalendarList : []
|
})
|
|
return { code: res.code }
|
},
|
async getWorkShopSelect() {
|
const { data: res } = await WorkShopSelect()
|
this.workshopArr = res
|
},
|
// async getDeviceTypeSelect() {
|
// const { data: res } = await DeviceTypeSelect()
|
// this.devicetypeArr = res
|
// },
|
async getWhkspIsEqpSearch(val) {
|
this.form.devicetype = ''
|
const { data: res } = await WhkspIsEqpSearch({ wkshpcode: val })
|
this.devicetypeArr = res
|
},
|
mrfaSearch(row, operation) {
|
this.operation = operation
|
this.dialogVisible = true
|
this.tempObj = row
|
this.radioSelectedCode = row.CaptPlanWorkShiftCode
|
this.getDialogData()
|
this.$nextTick(() => {
|
this.$refs.tableDataDialogRef.doLayout()
|
})
|
},
|
// 排序改变时
|
sortChange({ column, prop, order }) {
|
if (order === 'descending') {
|
order = 'desc'
|
} else if (order === 'ascending') {
|
order = 'asc'
|
} else {
|
order = 'desc'
|
}
|
this.form.order = order
|
this.form.prop = prop
|
this.getCapacityPlanningSearch()
|
},
|
// 查询
|
search() {
|
this.getCapacityPlanningSearch()
|
},
|
// 重置
|
reset() {
|
this.form.workshop = ''
|
this.form.devicetype = ''
|
this.form.stustype = ''
|
this.getCapacityPlanningSearch()
|
},
|
setting(operation) {
|
this.operation = operation
|
this.dialogVisible = true
|
this.getDialogData()
|
this.$nextTick(() => {
|
this.$refs.tableDataDialogRef.doLayout()
|
})
|
},
|
// 对话框关闭事件
|
handleClose() {
|
this.radioSelectedCode = ''
|
this.tempObj = {}
|
this.tableDataDialog = []
|
},
|
// 对话框取消
|
dialogVisibleCancel() {
|
this.dialogVisible = false
|
},
|
// 对话框确认
|
dialogVisibleConfirm() {
|
const data = {
|
wkshopcode: this.tempObj.CaptPlanWorkShopid,
|
capunitcode: this.tempObj.CaptPlanDeviceTypeid,
|
captplanid: this.tempObj.CaptPlanId ? this.tempObj.CaptPlanId : '',
|
capsetupcode: this.radioSelectedCode,
|
captplantype: this.tempObj.CaptPlanType
|
}
|
this.$store.state.app.buttonIsDisabled = true
|
CapacityPlanSubmit(data).then(res => {
|
if (res.code === '200') {
|
this.dialogVisible = false
|
this.$store.state.app.buttonIsDisabled = false
|
this.getCapacityPlanningSearch()
|
}
|
})
|
},
|
// 获取页面高度
|
getHeight() {
|
this.$nextTick(() => {
|
this.mainHeight = window.innerHeight - 85
|
this.tableHeight = this.mainHeight - 195
|
this.$refs.tableDataRef.doLayout()
|
})
|
},
|
tableRowClassName({ row, rowIndex }) {
|
return 'custom-row'
|
}
|
}
|
}
|
</script>
|
|
<!--公共页面样式-->
|
<style lang="scss" scoped>
|
$main_color: #42b983;
|
::v-deep .el-button--text {
|
font-size: 14px;
|
cursor: pointer;
|
}
|
|
.el-icon-share, .el-icon-delete, .el-icon-edit-outline {
|
color: $main_color;
|
cursor: pointer;
|
}
|
|
.el-icon-edit-outline {
|
margin-right: 15px;
|
}
|
|
::v-deep .el-button--primary, .el-button--default, .el-button--info {
|
height: 34px;
|
display: flex;
|
align-items: center;
|
padding: 0 15px;
|
}
|
|
::v-deep .el-button--primary {
|
//background-color: $main_color !important;
|
}
|
|
::v-deep .el-button--default {
|
background-color: #f8f8fa;
|
border: none;
|
}
|
|
::v-deep .el-input__inner {
|
height: 34px;
|
line-height: 34px;
|
//color: #a7a7a7;
|
}
|
|
::v-deep .el-dialog__body {
|
//padding: 20px 100px !important;
|
padding: 20px !important;
|
}
|
|
::v-deep .dialogVisibleRoles .el-dialog__body {
|
padding: 20px 20px !important;
|
}
|
|
::v-deep .importPickerClass .el-dialog__body {
|
padding: 20px 20px !important;
|
}
|
|
::v-deep .el-dialog__footer {
|
display: flex;
|
justify-content: flex-end;
|
}
|
|
::v-deep .el-table .caret-wrapper {
|
transform: scale(0.8);
|
}
|
|
::v-deep .cell {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
|
::v-deep .el-table::before {
|
height: 0;
|
}
|
|
::v-deep .el-table__body-wrapper {
|
background-color: #f8f8fa;
|
}
|
|
::v-deep .el-table__body .el-table__row.hover-row td {
|
background-color: #eaecef;
|
}
|
|
::v-deep .el-form--inline .el-form-item__label {
|
color: #a7a7a7;
|
}
|
|
.body ::v-deep .el-divider {
|
border: 1px solid #eee;
|
width: 99%;
|
margin: 10px auto;
|
}
|
|
.body ::v-deep .el-form-item {
|
margin-bottom: 0;
|
}
|
|
.userDialogVisible ::v-deep .el-form-item {
|
margin-bottom: 0;
|
}
|
|
::v-deep .el-select__caret {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.tableFixed {
|
::v-deep .el-table__fixed-right {
|
height: 100% !important;
|
}
|
|
::v-deep .el-table__fixed {
|
height: 100% !important;
|
}
|
|
::v-deep .el-input__icon {
|
line-height: 35px;
|
}
|
|
}
|
|
.tableFixedDialog {
|
::v-deep .el-input__icon {
|
line-height: 27px;
|
}
|
|
::v-deep .el-range-separator {
|
line-height: 27px;
|
}
|
|
::v-deep .el-radio__label {
|
display: none;
|
}
|
}
|
</style>
|
<style lang="scss">
|
|
.el-table .custom-row {
|
background: #f8f8fa;
|
}
|
.table_only{
|
overflow: visible !important;
|
.el-table__body-wrapper{
|
overflow: visible !important
|
}
|
}
|
/*为了让面板在超出区域可显示*/
|
/*.el-table__body-wrapper{*/
|
/* overflow: visible !important*/
|
/*}*/
|
/*.table_only{*/
|
/*overflow: visible !important*/
|
/*}*/
|
</style>
|