smart-switch-ui/src/views/ss/suit/component/SuitTable.vue

213 lines
7.3 KiB
Vue
Raw Normal View History

2024-10-15 17:57:59 +08:00
<template>
<div>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="设备名称" prop="deviceId" v-if="notHasView(views.device)">
<el-input
v-model="queryParams.deviceName"
placeholder="请输入设备名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
2024-10-22 08:53:39 +08:00
<el-form-item label="用户手机" prop="userMobile">
<el-input
v-model="queryParams.userMobile"
placeholder="请输入用户手机号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
2024-10-15 17:57:59 +08:00
<el-form-item label="套餐名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入套餐名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="收费模式" prop="feeMode">
<el-select v-model="queryParams.feeMode" placeholder="请选择收费模式" clearable @change="handleQuery">
<el-option v-for="dict in dict.type.suit_fee_mode" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="收费类型" prop="feeType">
<el-select v-model="queryParams.feeType" placeholder="请选择收费类型" clearable @change="handleQuery">
<el-option v-for="dict in dict.type.suit_fee_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<slot name="table-operator"/>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="suitList" v-on="$listeners">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="套餐ID" align="center" prop="suitId" width="80"/>
<el-table-column label="套餐名称" align="center" prop="name" width="100"/>
2024-10-22 08:53:39 +08:00
<el-table-column label="所属用户" align="center" prop="mobileOrUserName" width="100">
<user-link slot-scope="d" :id="d.row.userId" :name="d.row.mobileOrUserName"/>
2024-10-15 17:57:59 +08:00
</el-table-column>
<el-table-column label="收费模式" align="center" prop="feeMode" width="100">
<dict-tag slot-scope="d" :value="d.row.feeMode" :options="dict.type.suit_fee_mode"/>
</el-table-column>
<el-table-column label="收费类型" align="center" prop="feeType" width="120">
<dict-tag slot-scope="d" :value="d.row.feeType" :options="dict.type.suit_fee_type"/>
</el-table-column>
<el-table-column label="价格" align="center" prop="price" width="180">
<template slot-scope="d">
<template v-if="SuitFeeType.TIMING === d.row.feeType">
{{d.row.price | money}} / {{d.row.value}} {{suitTimeUnit(d.row.timeUnit)}}
</template>
<template v-else-if="SuitFeeType.COUNT === d.row.feeType">
{{d.row.price | money}} / {{d.row.value}}
</template>
<template v-else>动态计算</template>
</template>
</el-table-column>
<el-table-column label="押金" align="center" prop="deposit" width="100">
<template slot-scope="d">{{d.row.deposit | money}} </template>
</el-table-column>
<el-table-column label="详细说明" align="center" prop="description" show-overflow-tooltip/>
<el-table-column label="应用设备" align="center" prop="deviceList" min-width="200">
<template slot-scope="d">
<template v-for="(item, index) in d.row.deviceList" >
<device-link type="tag" style="margin-right: 4px" :key="index" :id="item.deviceId" :text="`${item.deviceName}(${item.deviceNo})`"/>
</template>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="100"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200" fixed="right">
<template slot-scope="scope">
<slot name="row-operator" :row="scope.row"/>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import { listSuit, getSuit, delSuit, addSuit, updateSuit } from "@/api/ss/suit";
import DeviceInput from '@/components/Business/Device/DeviceInput.vue'
import { findLabel, isEmpty } from '@/utils'
import UserLink from '@/components/Business/SmUser/UserLink.vue'
import UserInput from '@/components/Business/SmUser/UserInput.vue'
import { $view } from '@/utils/mixins'
import DeviceLink from '@/components/Business/Device/DeviceLink.vue'
import { SuitFeeMode, SuitFeeType } from '@/utils/constants'
import SuitEditDialog from '@/views/ss/suit/component/SuitEditDialog.vue'
export default {
name: "SuitTable",
mixins: [$view],
dicts: ['time_unit', 'suit_fee_mode', 'suit_fee_type'],
computed: {
SuitFeeType() {
return SuitFeeType
},
// 时长单位
suitTimeUnit() {
return (unit) => {
return findLabel(this.dict.type.time_unit, unit);
}
},
},
components: { SuitEditDialog, DeviceLink, UserInput, UserLink, DeviceInput },
props: {
query: {
type: Object,
default: () => {
return {}
}
},
listApi: {
type: Function,
default: listSuit
}
},
data() {
return {
row: {},
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 套餐表格数据
suitList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
deviceId: null,
name: null,
feeType: null,
value: null,
price: null,
description: null,
deleted: null
},
};
},
created() {
this.queryParams = {
...this.queryParams,
...this.query
}
this.getList();
},
methods: {
/** 查询套餐列表 */
getList() {
this.loading = true;
this.listApi(this.queryParams).then(response => {
this.suitList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
}
};
</script>