xy 2 years ago
parent 7f8f826384
commit c83d5b3646

@ -1,6 +1,30 @@
<template> <template>
<div> <div>
<div class="select"> <div class="select">
<div class="date">
<el-date-picker
size="small"
v-model="date"
:type="createType === 1 ? 'date' : 'week'"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions"
placeholder="日期选择"
:format="createType === 1 ? 'yyyy-MM-dd' : 'yyyy第WW周'"
style="width: 160px;"
@input="pickDate"
></el-date-picker>
<p style="margin-left: 14px">
您正在为
<span style="color: red">{{ date }}</span>
创建
<span style="color: red;"> {{ abilities.find(i => i.value === ability) ? abilities.find(i => i.value === ability).key : '' }} </span>
调令
</p>
<!-- <el-radio-group size="small" style="margin-left: 14px;" v-model="createType">-->
<!-- <el-radio-button :label="1"></el-radio-button>-->
<!-- <el-radio-button :label="2"></el-radio-button>-->
<!-- </el-radio-group>-->
</div>
<div class="select-item"> <div class="select-item">
<div class="select-item__title">选择范围</div> <div class="select-item__title">选择范围</div>
@ -34,34 +58,10 @@
>清空筛选</Button >清空筛选</Button
> >
</div> </div>
<div class="date">
<p>
您正在为
<span style="color: red">{{ date }}</span>
创建
<span style="color: red;"> {{ abilities.find(i => i.value === ability) ? abilities.find(i => i.value === ability).key : '' }} </span>
调令
</p>
<!-- <el-radio-group size="small" style="margin-left: 14px;" v-model="createType">-->
<!-- <el-radio-button :label="1"></el-radio-button>-->
<!-- <el-radio-button :label="2"></el-radio-button>-->
<!-- </el-radio-group>-->
<el-date-picker
size="small"
v-model="date"
:type="createType === 1 ? 'date' : 'week'"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions"
placeholder="日期选择"
:format="createType === 1 ? 'yyyy-MM-dd' : 'yyyy第WW周'"
style="width: 160px; margin-left: 14px"
@input="pickDate"
></el-date-picker>
</div>
</div> </div>
<Table <Table
style="margin-top: 20px"
:columns="columns" :columns="columns"
:data="mergeData" :data="mergeData"
stripe stripe
@ -71,6 +71,7 @@
<div class="btns"> <div class="btns">
<Button type="primary" @click="submit"></Button> <Button type="primary" @click="submit"></Button>
<Button type="primary" ghost @click="reset"></Button> <Button type="primary" ghost @click="reset"></Button>
<Button type="primary" ghost @click="clone"></Button>
</div> </div>
</div> </div>
</template> </template>
@ -88,6 +89,8 @@ export default {
}, },
data() { data() {
return { return {
dispatches: [],
transferDispatches: [],
createType: 1, createType: 1,
pickerOptions: { pickerOptions: {
firstDayOfWeek: 1, firstDayOfWeek: 1,
@ -149,6 +152,68 @@ export default {
render: (h, { row, index }) => { render: (h, { row, index }) => {
let text = row.equipment ? row.equipment.name : ""; let text = row.equipment ? row.equipment.name : "";
return h("div", [ return h("div", [
h('el-popover',{
props: {
title: "今日调令",
width: "400px"
},
on: {
show: _ => {
this.transferDispatches = this.dispatches.filter(i => (i.equipment_id === row.equipment_id))
}
}
},[
h('span',{
slot: 'reference',
// props: {
// type: "ios-list-box"
// },
style: {
'border-radius': '100%',
'margin-right': '4px',
'cursor': 'pointer',
'width': '20px',
'height': '20px',
'display': 'inline-block',
'background': '#367bc7',
'color': '#fff'
}
},this.dispatches.reduce((pre,cur) => {
return cur.equipment_id === row.equipment_id ? ++pre : pre
},0)),
h('Table',{
style: {
'width': "480px"
},
props: {
size: "small",
data: this.transferDispatches,
columns: [
{
title: " ",
type: "index",
width: 46
},
{
title: '开始时间',
key: 'start_time',
align: 'center',
render:(h, { row }) => (h('span',this.$moment(row.start_time).format('YYYY-MM-DD HH:mm')))
},
{
title: '结束时间',
key: 'end_time',
align: 'center',
render:(h, { row }) => (h('span',this.$moment(row.end_time).format('YYYY-MM-DD HH:mm')))
},
{
title: '内容',
key: 'content'
}
]
}
})
]),
h('span',text), h('span',text),
h('Button',{ h('Button',{
props: { props: {
@ -216,11 +281,58 @@ export default {
format: "HH:mm" format: "HH:mm"
}, },
on: { on: {
["on-change"]: (e) => (this.data[index].start_time = e), ["on-change"]: (e) => {
this.data[index].start_time = e
if (this.data[index]._last) {
const [hour,min] = this.data[index].start_time.split(':').map(i => Number(i))
let addTime = {
hour: Math.floor(this.data[index]._last),
min: (this.data[index]._last % 1) * 60
}
let resTime = {
hour: hour + addTime.hour + ((min + addTime.min) >= 60 ? 1 : 0),
min: (min + addTime.min) % 60
}
this.data[index].end_time = `${resTime.hour}:${resTime.min}`
}
},
}, },
}); });
}, },
}, },
{
title: "持续时间(时)",
width: 140,
align: "center",
key: "last",
render: (h,{ row, index }) => {
return h('InputNumber',{
props: {
value: 0,
min: 0,
step: 0.5,
size: "small",
precision: 1
},
on: {
['on-change']:e => {
this.data[index]._last = e
const [hour,min] = this.data[index].start_time.split(':').map(i => Number(i))
let addTime = {
hour: Math.floor(e),
min: (e % 1) * 60
}
let resTime = {
hour: hour + addTime.hour + ((min + addTime.min) >= 60 ? 1 : 0),
min: (min + addTime.min) % 60
}
this.data[index].end_time = `${resTime.hour}:${resTime.min}`
}
}
})
}
},
{ {
title: "结束时间", title: "结束时间",
width: 140, width: 140,
@ -339,6 +451,29 @@ export default {
}; };
}, },
methods: { methods: {
clone () {
let verify = true;
const submitData = this.data.filter(i => (i.start_time || i.end_time || i.content));
submitData.forEach(item => {
if (!item.start_time || !item.end_time || !item.level) {
verify = false;
}
})
if (!verify) {
this.$message({
type: 'warning',
message: '请填写完整信息'
})
return
}
submitData.forEach(i => {
delete i['equipment_id-span']
delete i['_index']
delete i['_rowKey']
})
console.log(JSON.stringify(submitData))
},
clear () { clear () {
this.select = { this.select = {
area: [], area: [],
@ -498,7 +633,7 @@ export default {
}, },
equipmentList() { equipmentList() {
return this.equipments() || []; return this.equipments() || [];
}, }
}, },
watch: { watch: {
equipmentList(val) { equipmentList(val) {
@ -551,10 +686,14 @@ export default {
}, },
mounted() {}, mounted() {},
created() { created() {
this.$bus.$on("getDispatches", dispatches => (this.dispatches = dispatches))
this.getArea(); this.getArea();
this.getType(); this.getType();
this.getAbility(); this.getAbility();
}, },
destroyed() {
this.$bus.$off("getDispatches")
}
}; };
</script> </script>

@ -214,6 +214,8 @@ export default {
this.data = res.data; this.data = res.data;
this.total = res.total; this.total = res.total;
this.loading = false; this.loading = false;
this.$bus.$emit('getDispatches', this.data)
} catch (e) { } catch (e) {
this.loading = false; this.loading = false;
} }

Loading…
Cancel
Save