You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

272 lines
7.2 KiB

2 years ago
<template>
<div>
2 years ago
<div class="select-content">
2 years ago
<el-date-picker
size="small"
:clearable="false"
v-model="date"
value-format="yyyy-MM-dd"
placeholder="日期选择"
format="yyyy-MM-dd"
style="width: 130px;"
></el-date-picker>
<Select clearable v-model="select.filter[2].value" placeholder="请选择类别" style="width: 140px;margin-left: 6px;">
2 years ago
<Option v-for="item in abilities" :value="item.value">{{ item.key }}</Option>
</Select>
<Select clearable v-model="select.filter[1].value" placeholder="请选择范围" style="width: 140px;margin-left: 6px;">
<Option v-for="item in areas" :value="item.value">{{ item.key }}</Option>
</Select>
<Input style="width: 140px;margin-left: 6px;" clearable v-model="select.filter[0].value" placeholder="搜索内容"/>
<Button style="margin-left: 6px;" type="primary" @click="getDispatches"></Button>
</div>
2 years ago
<Table
2 years ago
style="margin-top: 16px;"
border
:loading="loading"
2 years ago
:columns="columns"
:data="mergeData"
stripe
:span-method="objectSpanMethod"
></Table>
2 years ago
<!-- <el-pagination-->
<!-- class="pagination"-->
<!-- @size-change="e => {-->
<!-- select.page_size = e;-->
<!-- select.page = 1;-->
<!-- getDispatches();-->
<!-- }"-->
<!-- @current-change="e => {-->
<!-- select.page = e;-->
<!-- getDispatches();-->
<!-- }"-->
<!-- :current-page="select.page"-->
<!-- :page-sizes="[10, 20, 30, 40]"-->
<!-- :page-size="select.page_size"-->
<!-- layout="total, prev, pager, next, jumper, sizes"-->
<!-- :total="total">-->
<!-- </el-pagination>-->
2 years ago
</div>
</template>
<script>
import { deepCopy } from "@/utils";
2 years ago
import { index,destroy } from "@/api/system/baseForm";
2 years ago
import { mergeTableRow } from "@/utils/mergeTableRow";
2 years ago
export default {
inject: ["equipments"],
data() {
return {
2 years ago
loading: false,
areas: [],
2 years ago
abilities: [],
2 years ago
date: this.$moment().format("YYYY-MM-DD"),
2 years ago
select: {
table_name: 'transfers',
page: 1,
2 years ago
page_size: 999,
2 years ago
sort_name: 'equipment_id',
filter: [
{
key: "content",
op: "like",
value: ""
},
{
key: "area",
op: "eq",
value: ""
},
{
key: "leibie",
op: "eq",
value: ""
}
]
2 years ago
},
total: 0,
data: [],
columns: [
2 years ago
{
2 years ago
title: "范围",
width: 140,
key: "area",
align: "center",
render: (h, { row, index }) => {
let area = row.equipment_id_equipments_id_relation ? row.equipment_id_equipments_id_relation.area : "";
let text = this.areas.find(i => i.value === area)?.key
return h('span',text)
}
},
2 years ago
{
title: "点位",
width: 240,
key: "equipment_id",
align: "center",
render: (h, { row, index }) => {
let text = row.equipment_id_equipments_id_relation ? row.equipment_id_equipments_id_relation.name : "";
return h('span',text);
},
},
2 years ago
{
title: '类别',
2 years ago
width: 100,
2 years ago
key: 'leibie',
2 years ago
align: 'center',
2 years ago
render: (h,{ row }) => h('span', (this.abilities.find(i => i.value === row.leibie))?.key)
2 years ago
},
2 years ago
{
title: "开启时间",
width: 180,
align: "center",
key: "start_time",
},
{
title: "结束时间",
width: 180,
align: "center",
key: "end_time",
},
{
title: "调令内容",
minWidth: 200,
key: "content",
align: "left",
},
{
title: "调令等级",
width: 140,
key: "level",
align: "center",
render: (h, { row }) => {
let type = new Map([
[1,'一般'],
[2,'紧急']
])
return h('span',type.get(row.level));
},
},
{
title: "操作",
width: 140,
key: "operate",
render: (h, { row, index }) => {
return h(
"Poptip",
{
props: {
title: "确认要删除吗?",
confirm: true,
transfer: true,
},
on: {
["on-ok"]: (e) => {
2 years ago
destroy({
table_name: 'transfers',
id: row.id
}).then(res => {
this.$message({
type: 'success',
message: '删除成功'
})
this.getDispatches();
})
2 years ago
},
},
},
[
h(
"Button",
{
props: {
type: "primary",
size: "small",
},
},
"删除"
),
]
);
},
},
]
}
},
methods: {
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
const span = column["key"] + "-span";
if (row[span]) {
return row[span];
}
},
async getDispatches () {
2 years ago
try {
this.loading = true;
2 years ago
this.select.filter.push({
key: "start_time",
op: "like",
value: this.date
})
2 years ago
const res = await index(this.select);
this.data = res.data;
this.total = res.total;
this.loading = false;
2 years ago
this.$bus.$emit('getDispatches', this.data)
2 years ago
} catch (e) {
this.loading = false;
}
2 years ago
}
},
computed: {
mergeData() {
return mergeTableRow({
data: this.data.map((i) => {
delete i["equipment_id-span"];
2 years ago
delete i["area-span"]
2 years ago
return i;
}),
2 years ago
mergeColNames: ["equipment_id","area"], // 需要合并的列,默认合并列相同的数据
2 years ago
firstMergeColNames: ["equipment_id"], // 受影响的列只合并以firstMerge为首的同类型数据
firstMerge: "equipment_id", // 以哪列为基础进行合并,一般为第一列
});
},
equipmentList() {
return this.equipments() || [];
},
},
watch: {
},
created() {
this.getDispatches()
2 years ago
this.$bus.$on('pickDate',e => (this.date = e))
2 years ago
this.$bus.$on('yinpaishui',e => (this.abilities = e))
2 years ago
this.$bus.$on('areas',e => (this.areas = e))
2 years ago
this.$bus.$on('createdTransfer',_ => (this.getDispatches()))
},
destroyed() {
2 years ago
this.$bus.$off('pickDate')
2 years ago
this.$bus.$off('areas')
2 years ago
this.$bus.$off('yinpaishui')
this.$bus.$off('createdTransfer')
2 years ago
}
}
</script>
<style scoped lang="scss">
2 years ago
.select-content {
width: 100%;
2 years ago
display: flex;
align-items: center;
2 years ago
}
2 years ago
.pagination {
display: flex;
justify-content: center;
padding: 20px 0;
}
</style>