parent
80dc7f55db
commit
f655894f94
@ -0,0 +1,558 @@
|
||||
<template>
|
||||
<div id="mobile-dispatch-list">
|
||||
<div class="select">
|
||||
<div style="display:flex;align-items: center;">
|
||||
<span style="margin-right: 10px;">是否显示所有调令</span>
|
||||
<el-switch v-model="temp" @change="isShowAlreadyDistribute"></el-switch>
|
||||
</div>
|
||||
<el-date-picker
|
||||
size="small"
|
||||
:clearable="false"
|
||||
v-model="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="日期选择"
|
||||
format="yyyy-MM-dd"
|
||||
></el-date-picker>
|
||||
<Select clearable v-model="select.filter[2].value" placeholder="请选择类别">
|
||||
<Option v-for="item in abilities" :value="item.value">{{ item.key }}</Option>
|
||||
</Select>
|
||||
<Select clearable v-model="select.filter[1].value" placeholder="请选择范围">
|
||||
<Option v-for="item in areas" :value="item.value">{{ item.key }}</Option>
|
||||
</Select>
|
||||
<Select clearable v-model="select.filter[3].value" placeholder="请选择点位">
|
||||
<Option v-for="item in equipmentsFormat" :value="item.id">{{ item.name }}</Option>
|
||||
</Select>
|
||||
<Input clearable v-model="select.filter[0].value" placeholder="搜索内容"/>
|
||||
|
||||
<div>
|
||||
<Button type="primary" @click="getDispatches">搜索</Button>
|
||||
<Button type="primary" @click="pickNoDistribute">勾选当日未下发</Button>
|
||||
<Button type="primary" @click="distributeTransfers">批量下发</Button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<Table
|
||||
size="small"
|
||||
ref="listTable"
|
||||
style="margin-top: 16px;"
|
||||
border
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
stripe
|
||||
></Table>
|
||||
|
||||
<div class="page">
|
||||
<Page :total="total"
|
||||
:page-size="select.page_size"
|
||||
@on-change="e => {
|
||||
select.page = e;
|
||||
getDispatches();
|
||||
}"/>
|
||||
</div>
|
||||
<mobileCallback ref="mobileCallback"></mobileCallback>
|
||||
<adjust :abilities="abilities" :areas="areas" :fullscreen="true" ref="adjust" @refresh="getDispatches"></adjust>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {destroy, index, save} from "@/api/system/baseForm";
|
||||
import {getOaToken} from "@/api/other";
|
||||
import {show} from "@/api/system/customFormField";
|
||||
import {deepCopy} from "@/utils";
|
||||
import mobileCallback from "@/views/order/component/mobileCallback.vue";
|
||||
import adjust from "@/views/order/component/adjust.vue";
|
||||
export default {
|
||||
components: {
|
||||
mobileCallback,
|
||||
adjust
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
temp: false,
|
||||
typeMap: new Map([
|
||||
[0,'取消'],
|
||||
[1, "待下发"],
|
||||
[2, "已下发"],
|
||||
[3, "确认接收"],
|
||||
[4, "已通知开启"],
|
||||
[5, "确认开启"],
|
||||
[6, "已通知关机"],
|
||||
[7, "确认关机"]
|
||||
]),
|
||||
abilities: [],
|
||||
areas: [],
|
||||
equipmentList: [],
|
||||
|
||||
total: 0,
|
||||
data: [],
|
||||
loading: false,
|
||||
columns: [
|
||||
{
|
||||
type: "expand",
|
||||
width: 50,
|
||||
align: "center",
|
||||
render: (h,{ row, index }) => {
|
||||
return h('el-descriptions',{
|
||||
props: {
|
||||
column: 2,
|
||||
size: 'mini',
|
||||
border: true,
|
||||
direction: "vertical"
|
||||
}
|
||||
},[
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "范围",
|
||||
span: 2
|
||||
}
|
||||
},this.areas.find(i => i.value === (row.equipment_id_equipments_id_relation ? row.equipment_id_equipments_id_relation.area : ""))?.key),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "序号",
|
||||
span: 2
|
||||
}
|
||||
},row.xuhao),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "状态"
|
||||
}
|
||||
},this.typeMap.get(row.status)),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "类别"
|
||||
}
|
||||
},(this.abilities.find(i => i.value === row.leibie))?.key),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "开启闸门数量"
|
||||
}
|
||||
},row.kaiqishuliang ?? 0),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "开启水泵数量"
|
||||
}
|
||||
},row.kaiqishuliang1 ?? 0),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "持续时间"
|
||||
}
|
||||
},(row.start_time && row.end_time) ? (this.$moment(row.end_time).diff(this.$moment(row.start_time),'hours',true).toFixed(2) + '小时') : "-"),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "开启时间"
|
||||
}
|
||||
},this.$moment(row.start_time).format('YYYY-MM-DD HH:mm')),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "结束时间"
|
||||
}
|
||||
}, row.end_time ? this.$moment(row.end_time).format('HH:mm') : "-"),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "调令等级"
|
||||
}
|
||||
},(() => {
|
||||
let type = new Map([
|
||||
[1,'一般'],
|
||||
[2,'紧急']
|
||||
])
|
||||
return type.get(row.level);
|
||||
})()),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "调令内容",
|
||||
span: 2
|
||||
}
|
||||
},row.content),
|
||||
h('el-descriptions-item',{
|
||||
props: {
|
||||
label: "操作",
|
||||
span: 2
|
||||
}
|
||||
},(() => {
|
||||
const btnMap = new Map([
|
||||
['adjust',h(
|
||||
"Button",
|
||||
{
|
||||
style: {
|
||||
'margin-left': "6px"
|
||||
},
|
||||
props: {
|
||||
type: "primary",
|
||||
},
|
||||
on: {
|
||||
'click': () => {
|
||||
this.$refs['adjust'].setId(row.id);
|
||||
this.$refs['adjust'].setType('editor');
|
||||
this.$refs['adjust'].show();
|
||||
}
|
||||
}
|
||||
},
|
||||
"调整"
|
||||
)],
|
||||
['callback',h(
|
||||
"Button",
|
||||
{
|
||||
style: {
|
||||
'margin-left': "6px"
|
||||
},
|
||||
props: {
|
||||
type: "primary",
|
||||
},
|
||||
on: {
|
||||
'click': () => {
|
||||
this.$refs['mobileCallback'].setId(row.id);
|
||||
this.$refs['mobileCallback'].setRow(row);
|
||||
this.$refs['mobileCallback'].show();
|
||||
}
|
||||
}
|
||||
},
|
||||
"反馈"
|
||||
)],
|
||||
['delete',h(
|
||||
"Poptip",
|
||||
{
|
||||
props: {
|
||||
title: "确认要删除吗?",
|
||||
confirm: true,
|
||||
transfer: true,
|
||||
},
|
||||
on: {
|
||||
["on-ok"]: (e) => {
|
||||
destroy({
|
||||
table_name: 'transfers',
|
||||
id: row.id
|
||||
}).then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功'
|
||||
})
|
||||
this.getDispatches();
|
||||
})
|
||||
},
|
||||
},
|
||||
},
|
||||
[
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
style: {
|
||||
'margin-left': "6px"
|
||||
},
|
||||
props: {
|
||||
type: "error",
|
||||
},
|
||||
},
|
||||
"删除"
|
||||
),
|
||||
]
|
||||
)],
|
||||
['oa',h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "primary",
|
||||
},
|
||||
on: {
|
||||
'click': async () => {
|
||||
if (!this.oaToken) {
|
||||
this.oaToken = (await getOaToken()).oatoken
|
||||
}
|
||||
let jsonInfo = {
|
||||
'title': row.equipment_id_equipments_id_relation?.name,
|
||||
'65aa1a59e408c': row.start_time,
|
||||
'65aa1a7e4109d': row.level,
|
||||
'65aa1a442705f': row.content
|
||||
}
|
||||
let url =
|
||||
`${process.env.VUE_APP_OA_URL}/admin/flow/create/34?diaoling_oatoken=${this.oaToken}&out_diaoling_id=${row.id}&default_json=${JSON.stringify(jsonInfo)}`
|
||||
window.open(url, 'diaoling')
|
||||
}
|
||||
}
|
||||
},
|
||||
"发起流程"
|
||||
)],
|
||||
['distribute',h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "primary",
|
||||
},
|
||||
on: {
|
||||
'click': () => {
|
||||
this.$confirm('确认下发?','提示').then(_ => {
|
||||
this.setTransferStatus(2,row)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
"下发"
|
||||
)],
|
||||
['cancel',h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "primary",
|
||||
ghost: true,
|
||||
},
|
||||
on: {
|
||||
'click': () => {
|
||||
this.$confirm('确认下发?','提示').then(_ => {
|
||||
this.setTransferStatus(0,row)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
"取消"
|
||||
)]
|
||||
])
|
||||
const auths = ['adjust','distribute','cancel','oa','delete','callback'].filter(item => {
|
||||
if (row.status === 0) {
|
||||
if (item === 'oa') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if ([2,3,4,5,6,7].find(i => i === row.status)) {
|
||||
if (item === 'delete' || item === 'oa' || item === 'distribute') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if ([3,4,5,6,7].find(i => i === row.status)) {
|
||||
if (item === 'edit') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if ([0,1,7].find(i => i === row.status)) {
|
||||
if (item === 'adjust') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (row.liuchengzhuangtai === 2 || row.liuchengzhuangtai === 3) {
|
||||
if (item === 'delete' || item === 'edit') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (row.status !== 2) {
|
||||
if (item === 'cancel') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
return [h('div',{
|
||||
style: {
|
||||
'display': 'flex'
|
||||
}
|
||||
},auths.map(i => (btnMap.get(i))))]
|
||||
})())
|
||||
])
|
||||
}
|
||||
},
|
||||
{
|
||||
width: 53,
|
||||
type: "selection"
|
||||
},
|
||||
{
|
||||
title: "点位",
|
||||
minWidth: 120,
|
||||
key: "equipment_id",
|
||||
align: "center",
|
||||
render: (h, { row, index }) => {
|
||||
let text = "";
|
||||
text += row.is_adjust === -1 ? '' : '[调整]'
|
||||
text += row.equipment_id_equipments_id_relation ? row.equipment_id_equipments_id_relation.name : "";
|
||||
return h('span',text);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "开始时间",
|
||||
width: 90,
|
||||
align: 'center',
|
||||
render: (h,{ row }) => h('span', this.$moment(row.start_time).format('HH:mm'))
|
||||
},
|
||||
],
|
||||
date: this.$moment().format("YYYY-MM-DD"),
|
||||
select: {
|
||||
table_name: 'transfers',
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
sort_name: 'equipment_id',
|
||||
filter: [
|
||||
{
|
||||
key: "content",
|
||||
op: "like",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
key: "area",
|
||||
op: "eq",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
key: "leibie",
|
||||
op: "eq",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
key: "equipment_id",
|
||||
op: "eq",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
op: "eq",
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getEquipments () {
|
||||
this.equipmentList = (await index({
|
||||
table_name: 'equipments',
|
||||
page: 1,
|
||||
page_size: 9999
|
||||
},false))?.data || []
|
||||
},
|
||||
async getAbility() {
|
||||
const obj = (await show({ id: 31 }, false))?.select_item;
|
||||
if (obj && typeof obj === "object") {
|
||||
let keys = Object.keys(obj);
|
||||
if (keys.length > 0) {
|
||||
this.abilities = keys.map((key) => {
|
||||
return {
|
||||
key,
|
||||
value: /^\d*$/.test(obj[key]) ? Number(obj[key]) : obj[key],
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
async getArea() {
|
||||
const obj = (await show({ id: 4 }, false))?.select_item;
|
||||
if (obj && typeof obj === "object") {
|
||||
let keys = Object.keys(obj);
|
||||
if (keys.length > 0) {
|
||||
this.areas = keys.map((key) => {
|
||||
return {
|
||||
key,
|
||||
value: /^\d*$/.test(obj[key]) ? Number(obj[key]) : obj[key],
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async distributeTransfers () {
|
||||
let promiseAll = this.$refs['listTable']?.getSelection().map(i => {
|
||||
for (let key in i) {
|
||||
if (/_relation/g.test(key)) {
|
||||
delete i[key]
|
||||
}
|
||||
}
|
||||
i.status = 2;
|
||||
return save({
|
||||
table_name: 'transfers',
|
||||
...i
|
||||
})
|
||||
})
|
||||
const res = await Promise.all(promiseAll)
|
||||
await this.getDispatches();
|
||||
},
|
||||
|
||||
async getDispatches () {
|
||||
try {
|
||||
this.loading = true;
|
||||
if (this.select.filter.find(i => i.key === 'start_time')) {
|
||||
this.select.filter.pop();
|
||||
}
|
||||
this.select.filter.push({
|
||||
key: "start_time",
|
||||
op: "like",
|
||||
value: this.date
|
||||
})
|
||||
const res = await index(this.select);
|
||||
this.data = res.data;
|
||||
this.total = res.total;
|
||||
this.loading = false;
|
||||
} catch (e) {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
setTransferStatus (status,row) {
|
||||
let copyRow = deepCopy(row);
|
||||
copyRow.status = status;
|
||||
for (let key in copyRow) {
|
||||
if (/_relation/g.test(key)) {
|
||||
delete copyRow[key]
|
||||
}
|
||||
}
|
||||
save({
|
||||
table_name: 'transfers',
|
||||
...copyRow
|
||||
}).then(_ => this.getDispatches())
|
||||
},
|
||||
|
||||
pickNoDistribute () {
|
||||
this.data = this.data.map(i => {
|
||||
i._checked = i.status === 1
|
||||
return i
|
||||
})
|
||||
},
|
||||
|
||||
isShowAlreadyDistribute (e) {
|
||||
if (e) {
|
||||
this.select.filter.find(item => item.key === 'status').value = ""
|
||||
} else {
|
||||
this.select.filter.find(item => item.key === 'status').value = "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
equipmentsFormat () {
|
||||
let area = this.select.filter[1].value;
|
||||
|
||||
return area ? this.equipmentList.filter(i => i.area === area) : this.equipmentList;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getEquipments();
|
||||
this.getArea();
|
||||
this.getAbility();
|
||||
this.getDispatches();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.select {
|
||||
& > * {
|
||||
width: 100%;
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
.page {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
::v-deep td.ivu-table-expanded-cell {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss">
|
||||
html:has(#mobile-dispatch-list) {
|
||||
.el-message-box {
|
||||
width: 90vw;
|
||||
}
|
||||
.ivu-modal-body {
|
||||
max-height: inherit !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue