Compare commits
2 Commits
60bf53c6a6
...
5bec7eb5ee
Author | SHA1 | Date |
---|---|---|
|
5bec7eb5ee | |
|
8c5bdc47e0 |
|
@ -5,6 +5,8 @@ enum Api {
|
|||
registerList = '/zh/hy/queryHyRegisterList',
|
||||
xzList = '/zh/hy/queryHyXzList',
|
||||
tdcsList = '/zh/hy/queryHyTdcsList',
|
||||
allTdcsList = '/zh/hy/queryAllHyTdcsList',
|
||||
queryHyjlList = '/zh/hy/queryHyjlList',
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,3 +29,13 @@ export const xzList = (params) => defHttp.get({ url: Api.xzList, params });
|
|||
* @param params
|
||||
*/
|
||||
export const tdcsList = (params) => defHttp.get({ url: Api.tdcsList, params });
|
||||
/**
|
||||
* 所有会员投递次数排行榜
|
||||
* @param params
|
||||
*/
|
||||
export const allTdcsList = (params) => defHttp.get({ url: Api.allTdcsList, params });
|
||||
/**
|
||||
* 查询会员投递历史
|
||||
* @param params
|
||||
*/
|
||||
export const queryHyjlList = (params) => defHttp.get({ url: Api.queryHyjlList, params });
|
|
@ -2,7 +2,7 @@
|
|||
<div class="p-4">
|
||||
<a-card :bordered="false" style="height: 100%">
|
||||
<a-row>
|
||||
<a-col :span="20">
|
||||
<a-col :span="21" v-show="!izList">
|
||||
<a-radio-group v-model:value="parmas.type" @change="changeType">
|
||||
<a-radio-button value="1">当天</a-radio-button>
|
||||
<a-radio-button value="2">近3天</a-radio-button>
|
||||
|
@ -10,75 +10,204 @@
|
|||
<a-radio-button value="4">近30天</a-radio-button>
|
||||
<a-radio-button value="5">自定义</a-radio-button>
|
||||
</a-radio-group>
|
||||
<span v-show="parmas.type=='5'" style="margin-left: 5px;">
|
||||
<span v-show="parmas.type == '5'" style="margin-left: 5px;">
|
||||
<a-range-picker :value-format="valueFormat" @change="changeDate" />
|
||||
</span>
|
||||
<a-select ref="select"
|
||||
placeholder="请选区域"
|
||||
v-model:value="parmas.housingestateId"
|
||||
style="width: 200px;margin-left: 5px;"
|
||||
@change="handleHousinges">
|
||||
<a-select-option value="" >全部</a-select-option>
|
||||
<a-select-option :value="item.housingestateId" v-for="item in housingestates" :key="item.housingestateId">{{item.housingestateName}}</a-select-option>
|
||||
<a-select ref="select" placeholder="请选区域" v-model:value="parmas.housingestateId"
|
||||
style="width: 200px;margin-left: 5px;" @change="handleHousinges">
|
||||
<a-select-option value="">全部</a-select-option>
|
||||
<a-select-option :value="item.housingestateId" v-for="item in housingestates" :key="item.housingestateId">{{
|
||||
item.housingestateName }}</a-select-option>
|
||||
</a-select>
|
||||
</a-col>
|
||||
<a-col :span="21" v-show="izList">
|
||||
<a-form layout="inline" :model="parmas" :labelCol="{ style: { width: 'auto', paddingRight: '90px' } }"
|
||||
:wrapperCol="{ style: { display: 'flex', alignItems: 'center' } }">
|
||||
<a-form-item label="投递次数">
|
||||
<a-input-number v-model:value="parmas.countMin" placeholder="最小次数" :min="0" />
|
||||
<span class="ant-form-text" style="margin: 0 8px;">至</span>
|
||||
<a-input-number v-model:value="parmas.countMax" placeholder="最大次数" :min="0" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<a-button type="link" @click="loadListDate">查询</a-button>
|
||||
<a-button type="link" @click="resetListData">重置</a-button>
|
||||
</a-col>
|
||||
<a-col :span="3">
|
||||
<a-radio-group v-model:value="izList" button-style="solid">
|
||||
<a-radio-button :value="false">统计图</a-radio-button>
|
||||
<a-radio-button :value="true">列表页</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<Bar :chartData="dataSource" height="80vh" :option="{ title: { text: '会员投递次数排行榜', left: 'center' }}" :itemStyle="{ normal: {label : {show: true, position: 'top'}}}" :seriesName="'投递次数'"></Bar>
|
||||
<Bar v-show="!izList" :chartData="dataSource" height="80vh"
|
||||
:option="{ title: { text: '会员投递次数排行榜', left: 'center' } }"
|
||||
:itemStyle="{ normal: { label: { show: true, position: 'top' } } }" :seriesName="'投递次数'"></Bar>
|
||||
<a-table v-show="izList" :dataSource="tableData" :columns="columns">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-button type="link" @click="handleView(record)">查看</a-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
<!-- 查看详情弹窗 -->
|
||||
<a-modal v-model:visible="detailVisible" title="会员投递详情" width="80%" :footer="null">
|
||||
<a-table :dataSource="detailData" :columns="detailColumns" rowKey="phone">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button type="link" @click="handleMark(record)">标记</a-button>
|
||||
<a-button type="link" danger @click="handleBlock(record)">屏蔽</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, unref, reactive, onMounted} from 'vue';
|
||||
import Bar from '/@/components/chart/Bar.vue';
|
||||
import { tdcsList,housingestateList } from '../hy.api';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
const valueFormat = 'YYYY-MM-DD';
|
||||
const dataSource = ref([]);
|
||||
const dateValue = ref();
|
||||
const housingestates = ref();
|
||||
import { ref, unref, reactive, onMounted } from 'vue';
|
||||
import Bar from '/@/components/chart/Bar.vue';
|
||||
import { tdcsList, allTdcsList, housingestateList, queryHyjlList } from '../hy.api';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
async function getHousingestates(){
|
||||
housingestates.value = await housingestateList();
|
||||
const valueFormat = 'YYYY-MM-DD';
|
||||
const dataSource = ref([]);
|
||||
const dateValue = ref();
|
||||
const housingestates = ref();
|
||||
const izList = ref(false)
|
||||
const tableData = ref([])
|
||||
const detailVisible = ref(false);
|
||||
const detailData = ref([]);
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: '会员',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '投递次数',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'center',
|
||||
width: '150px',
|
||||
}
|
||||
])
|
||||
|
||||
const parmas = reactive<any>({
|
||||
const detailColumns = ref([
|
||||
{
|
||||
title: '会员手机号',
|
||||
dataIndex: 'phone',
|
||||
key: 'phone',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '金额',
|
||||
dataIndex: 'money',
|
||||
key: 'money',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '重量',
|
||||
dataIndex: 'weight',
|
||||
key: 'weight',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '投递时间',
|
||||
dataIndex: 'addTime',
|
||||
key: 'addTime',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '订单是否有效',
|
||||
dataIndex: 'invalid',
|
||||
key: 'invalid',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '订单开始重量',
|
||||
dataIndex: 'startWeight',
|
||||
key: 'startWeight',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '订单结束重量',
|
||||
dataIndex: 'endWeight',
|
||||
key: 'endWeight',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '厂家更新时间',
|
||||
dataIndex: 'updatedAt',
|
||||
key: 'updatedAt',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '扣除金额',
|
||||
dataIndex: 'deductMoney',
|
||||
key: 'deductMoney',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'center',
|
||||
width: '200px',
|
||||
}
|
||||
]);
|
||||
|
||||
async function getHousingestates() {
|
||||
housingestates.value = await housingestateList();
|
||||
}
|
||||
|
||||
const parmas = reactive<any>({
|
||||
beginTime: '',
|
||||
endTime: '',
|
||||
type: '1',
|
||||
})
|
||||
countMin: null,
|
||||
countMax: null,
|
||||
})
|
||||
|
||||
function changeType (){
|
||||
parmas.endTime=getPreviousDate(0)+' 23:59:59';
|
||||
function changeType() {
|
||||
parmas.endTime = getPreviousDate(0) + ' 23:59:59';
|
||||
if (parmas.type === '1') {
|
||||
parmas.beginTime=getPreviousDate(0)+' 00:00:00';
|
||||
parmas.beginTime = getPreviousDate(0) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
if (parmas.type === '2') {
|
||||
parmas.beginTime=getPreviousDate(2)+' 00:00:00';
|
||||
parmas.beginTime = getPreviousDate(2) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
if (parmas.type === '3') {
|
||||
parmas.beginTime=getPreviousDate(6)+' 00:00:00';
|
||||
parmas.beginTime = getPreviousDate(6) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
if (parmas.type === '4') {
|
||||
parmas.beginTime=getPreviousDate(29)+' 00:00:00';
|
||||
parmas.beginTime = getPreviousDate(29) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const changeDate = (date, dateString) => {
|
||||
parmas.beginTime=dateString[0]+' 00:00:00';
|
||||
parmas.endTime=dateString[1]+' 23:59:59';
|
||||
const changeDate = (date, dateString) => {
|
||||
parmas.beginTime = dateString[0] + ' 00:00:00';
|
||||
parmas.endTime = dateString[1] + ' 23:59:59';
|
||||
loadDate();
|
||||
};
|
||||
};
|
||||
|
||||
function handleHousinges(){
|
||||
function handleHousinges() {
|
||||
loadDate();
|
||||
};
|
||||
};
|
||||
|
||||
async function loadDate() {
|
||||
async function loadDate() {
|
||||
const res = await tdcsList(parmas);
|
||||
dataSource.value = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
|
@ -87,9 +216,38 @@
|
|||
value: res[i].cn,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPreviousDate(days){
|
||||
async function loadListDate() {
|
||||
const res = await allTdcsList({ countMin: parmas.countMin, countMax: parmas.countMax });
|
||||
tableData.value = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
tableData.value.push({
|
||||
name: `${res[i].phone}`,
|
||||
value: res[i].cn,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//重置
|
||||
function resetListData() {
|
||||
parmas.countMin = null
|
||||
parmas.countMax = null
|
||||
loadListDate()
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleView = async (record) => {
|
||||
try {
|
||||
const res = await queryHyjlList({ phone: record.name });
|
||||
detailData.value = res;
|
||||
detailVisible.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取详情失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
function getPreviousDate(days) {
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() - days);
|
||||
const year = date.getFullYear();
|
||||
|
@ -97,15 +255,30 @@
|
|||
const day = String(date.getDate()).padStart(2, '0'); // 日期补零
|
||||
const formattedDate = `${year}-${month}-${day}`;
|
||||
return formattedDate;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 新增的方法
|
||||
const handleMark = (record) => {
|
||||
console.log('标记记录:', record);
|
||||
// 这里可以添加标记逻辑,如调用API等
|
||||
// 示例: markRecord(record.phone);
|
||||
};
|
||||
|
||||
const handleBlock = (record) => {
|
||||
console.log('屏蔽记录:', record);
|
||||
// 这里可以添加屏蔽逻辑,如调用API等
|
||||
// 示例: blockRecord(record.phone);
|
||||
};
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getHousingestates();
|
||||
if(parmas.type=='1'){
|
||||
parmas.beginTime=getPreviousDate(0)+' 00:00:00';
|
||||
parmas.endTime=getPreviousDate(0)+' 23:59:59';
|
||||
if (parmas.type == '1') {
|
||||
parmas.beginTime = getPreviousDate(0) + ' 00:00:00';
|
||||
parmas.endTime = getPreviousDate(0) + ' 23:59:59';
|
||||
}
|
||||
loadDate();
|
||||
})
|
||||
loadListDate();
|
||||
})
|
||||
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
housingestateList = '/zh/hy/queryHousingestateList',
|
||||
registerList = '/zh/hy/queryHyRegisterList',
|
||||
xzList = '/zh/hy/queryHyXzList',
|
||||
tdcsList = '/zh/hy/querySheBeiTdcsList',
|
||||
allTdcsList = '/zh/hy/queryAllSheBeiTdcsList',
|
||||
queryHyjlList = '/zh/hy/queryHyjlList',
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小区
|
||||
* @param params
|
||||
*/
|
||||
export const housingestateList = (params) => defHttp.get({ url: Api.housingestateList, params });
|
||||
/**
|
||||
* 会员注册时间段统计
|
||||
* @param params
|
||||
*/
|
||||
export const registerList = (params) => defHttp.get({ url: Api.registerList, params });
|
||||
/**
|
||||
* 新增会员统计
|
||||
* @param params
|
||||
*/
|
||||
export const xzList = (params) => defHttp.get({ url: Api.xzList, params });
|
||||
/**
|
||||
* 会员投递次数排行榜
|
||||
* @param params
|
||||
*/
|
||||
export const tdcsList = (params) => defHttp.get({ url: Api.tdcsList, params });
|
||||
/**
|
||||
* 所有会员投递次数排行榜
|
||||
* @param params
|
||||
*/
|
||||
export const allTdcsList = (params) => defHttp.get({ url: Api.allTdcsList, params });
|
||||
/**
|
||||
* 查询会员投递历史
|
||||
* @param params
|
||||
*/
|
||||
export const queryHyjlList = (params) => defHttp.get({ url: Api.queryHyjlList, params });
|
|
@ -0,0 +1,284 @@
|
|||
<template>
|
||||
<div class="p-4">
|
||||
<a-card :bordered="false" style="height: 100%">
|
||||
<a-row>
|
||||
<a-col :span="21">
|
||||
<a-radio-group v-model:value="parmas.type" @change="changeType">
|
||||
<a-radio-button value="1">当天</a-radio-button>
|
||||
<a-radio-button value="2">近3天</a-radio-button>
|
||||
<a-radio-button value="3">近7天</a-radio-button>
|
||||
<a-radio-button value="4">近30天</a-radio-button>
|
||||
<a-radio-button value="5">自定义</a-radio-button>
|
||||
</a-radio-group>
|
||||
<span v-show="parmas.type == '5'" style="margin-left: 5px;">
|
||||
<a-range-picker :value-format="valueFormat" @change="changeDate" />
|
||||
</span>
|
||||
<a-select ref="select" placeholder="请选区域" v-model:value="parmas.housingestateId"
|
||||
style="width: 200px;margin-left: 5px;" @change="handleHousinges">
|
||||
<a-select-option value="">全部</a-select-option>
|
||||
<a-select-option :value="item.housingestateId" v-for="item in housingestates" :key="item.housingestateId">{{
|
||||
item.housingestateName }}</a-select-option>
|
||||
</a-select>
|
||||
</a-col>
|
||||
<a-col :span="21" v-show="izList">
|
||||
<a-form layout="inline" :model="parmas" :labelCol="{ style: { width: 'auto', paddingRight: '90px' } }"
|
||||
:wrapperCol="{ style: { display: 'flex', alignItems: 'center' } }">
|
||||
<a-form-item label="投递次数">
|
||||
<a-input-number v-model:value="parmas.countMin" placeholder="最小次数" :min="0" />
|
||||
<span class="ant-form-text" style="margin: 0 8px;">至</span>
|
||||
<a-input-number v-model:value="parmas.countMax" placeholder="最大次数" :min="0" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<a-button type="link" @click="loadListDate">查询</a-button>
|
||||
<a-button type="link" @click="resetListData">重置</a-button>
|
||||
</a-col>
|
||||
<a-col :span="3">
|
||||
<a-radio-group v-model:value="izList" button-style="solid">
|
||||
<a-radio-button :value="false">统计图</a-radio-button>
|
||||
<a-radio-button :value="true">列表页</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<Bar v-show="!izList" :chartData="dataSource" height="80vh"
|
||||
:option="{ title: { text: '设备投递次数排行榜', left: 'center' } }"
|
||||
:itemStyle="{ normal: { label: { show: true, position: 'top' } } }" :seriesName="'投递次数'"></Bar>
|
||||
<a-table v-show="izList" :dataSource="tableData" :columns="columns">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-button type="link" @click="handleView(record)">查看</a-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
<!-- 查看详情弹窗 -->
|
||||
<a-modal v-model:visible="detailVisible" title="会员投递详情" width="80%" :footer="null">
|
||||
<a-table :dataSource="detailData" :columns="detailColumns" rowKey="phone">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button type="link" @click="handleMark(record)">标记</a-button>
|
||||
<a-button type="link" danger @click="handleBlock(record)">屏蔽</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, unref, reactive, onMounted } from 'vue';
|
||||
import Bar from '/@/components/chart/Bar.vue';
|
||||
import { tdcsList, allTdcsList, housingestateList, queryHyjlList } from '../shebei.api';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
const valueFormat = 'YYYY-MM-DD';
|
||||
const dataSource = ref([]);
|
||||
const dateValue = ref();
|
||||
const housingestates = ref();
|
||||
const izList = ref(false)
|
||||
const tableData = ref([])
|
||||
const detailVisible = ref(false);
|
||||
const detailData = ref([]);
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: '会员',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '投递次数',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'center',
|
||||
width: '150px',
|
||||
}
|
||||
])
|
||||
|
||||
const detailColumns = ref([
|
||||
{
|
||||
title: '会员手机号',
|
||||
dataIndex: 'phone',
|
||||
key: 'phone',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '金额',
|
||||
dataIndex: 'money',
|
||||
key: 'money',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '重量',
|
||||
dataIndex: 'weight',
|
||||
key: 'weight',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '投递时间',
|
||||
dataIndex: 'addTime',
|
||||
key: 'addTime',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '订单是否有效',
|
||||
dataIndex: 'invalid',
|
||||
key: 'invalid',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '订单开始重量',
|
||||
dataIndex: 'startWeight',
|
||||
key: 'startWeight',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '订单结束重量',
|
||||
dataIndex: 'endWeight',
|
||||
key: 'endWeight',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '厂家更新时间',
|
||||
dataIndex: 'updatedAt',
|
||||
key: 'updatedAt',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '扣除金额',
|
||||
dataIndex: 'deductMoney',
|
||||
key: 'deductMoney',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'center',
|
||||
width: '200px',
|
||||
}
|
||||
]);
|
||||
|
||||
async function getHousingestates() {
|
||||
housingestates.value = await housingestateList();
|
||||
}
|
||||
|
||||
const parmas = reactive<any>({
|
||||
beginTime: '',
|
||||
endTime: '',
|
||||
type: '1',
|
||||
countMin: null,
|
||||
countMax: null,
|
||||
})
|
||||
|
||||
function changeType() {
|
||||
parmas.endTime = getPreviousDate(0) + ' 23:59:59';
|
||||
if (parmas.type === '1') {
|
||||
parmas.beginTime = getPreviousDate(0) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
if (parmas.type === '2') {
|
||||
parmas.beginTime = getPreviousDate(2) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
if (parmas.type === '3') {
|
||||
parmas.beginTime = getPreviousDate(6) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
if (parmas.type === '4') {
|
||||
parmas.beginTime = getPreviousDate(29) + ' 00:00:00';
|
||||
loadDate();
|
||||
}
|
||||
}
|
||||
|
||||
const changeDate = (date, dateString) => {
|
||||
parmas.beginTime = dateString[0] + ' 00:00:00';
|
||||
parmas.endTime = dateString[1] + ' 23:59:59';
|
||||
loadDate();
|
||||
};
|
||||
|
||||
function handleHousinges() {
|
||||
loadDate();
|
||||
};
|
||||
|
||||
async function loadDate() {
|
||||
const res = await tdcsList(parmas);
|
||||
dataSource.value = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
dataSource.value.push({
|
||||
name: `${res[i].imei}`,
|
||||
value: res[i].cn,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function loadListDate() {
|
||||
const res = await allTdcsList(parmas);
|
||||
tableData.value = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
tableData.value.push({
|
||||
name: `${res[i].imei}`,
|
||||
value: res[i].cn,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//重置
|
||||
function resetListData() {
|
||||
parmas.countMin = null
|
||||
parmas.countMax = null
|
||||
loadListDate()
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleView = async (record) => {
|
||||
try {
|
||||
const res = await queryHyjlList({ phone: record.name });
|
||||
detailData.value = res;
|
||||
detailVisible.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取详情失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
function getPreviousDate(days) {
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() - days);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份+1(0-indexed)并补零
|
||||
const day = String(date.getDate()).padStart(2, '0'); // 日期补零
|
||||
const formattedDate = `${year}-${month}-${day}`;
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
// 新增的方法
|
||||
const handleMark = (record) => {
|
||||
console.log('标记记录:', record);
|
||||
// 这里可以添加标记逻辑,如调用API等
|
||||
// 示例: markRecord(record.phone);
|
||||
};
|
||||
|
||||
const handleBlock = (record) => {
|
||||
console.log('屏蔽记录:', record);
|
||||
// 这里可以添加屏蔽逻辑,如调用API等
|
||||
// 示例: blockRecord(record.phone);
|
||||
};
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getHousingestates();
|
||||
if (parmas.type == '1') {
|
||||
parmas.beginTime = getPreviousDate(0) + ' 00:00:00';
|
||||
parmas.endTime = getPreviousDate(0) + ' 23:59:59';
|
||||
}
|
||||
loadDate();
|
||||
loadListDate();
|
||||
})
|
||||
|
||||
</script>
|
|
@ -0,0 +1,72 @@
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/deviceinfo/deviceInfo/list',
|
||||
save='/deviceinfo/deviceInfo/add',
|
||||
edit='/deviceinfo/deviceInfo/edit',
|
||||
deleteOne = '/deviceinfo/deviceInfo/delete',
|
||||
deleteBatch = '/deviceinfo/deviceInfo/deleteBatch',
|
||||
importExcel = '/deviceinfo/deviceInfo/importExcel',
|
||||
exportXls = '/deviceinfo/deviceInfo/exportXls',
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出api
|
||||
* @param params
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
/**
|
||||
* 导入api
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
/**
|
||||
* 列表接口
|
||||
* @param params
|
||||
*/
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
/**
|
||||
* 删除单个
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const deleteOne = (params,handleSuccess) => {
|
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
* @param isUpdate
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params }, { isTransformResponse: false });
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
import { BasicColumn } from '/@/components/Table';
|
||||
import { FormSchema } from '/@/components/Table';
|
||||
import { rules } from '/@/utils/helper/validator';
|
||||
import { render } from '/@/utils/common/renderUtils';
|
||||
import { getWeekMonthQuarterYear } from '/@/utils';
|
||||
//列表数据
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '设备编码',
|
||||
align: 'center',
|
||||
dataIndex: 'imei',
|
||||
},
|
||||
{
|
||||
title: 'ICCID',
|
||||
align: 'center',
|
||||
dataIndex: 'iccid',
|
||||
},
|
||||
{
|
||||
title: '是否在线',
|
||||
align: 'center',
|
||||
dataIndex: 'isOnline',
|
||||
format(text, record, index) {
|
||||
console.log("🌊 ~ format ~ text:", text)
|
||||
|
||||
if (text == 'true') {
|
||||
return '在线';
|
||||
} else {
|
||||
return '离线';
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '区域名称',
|
||||
align: 'center',
|
||||
dataIndex: 'housingestateName',
|
||||
},
|
||||
{
|
||||
title: '设备点位',
|
||||
align: 'center',
|
||||
dataIndex: 'content',
|
||||
},
|
||||
{
|
||||
title: '桶数量',
|
||||
align: 'center',
|
||||
dataIndex: 'boxNum',
|
||||
},
|
||||
{
|
||||
title: '是否在仓库中',
|
||||
align: 'center',
|
||||
dataIndex: 'inWarehouse',
|
||||
format(text, record, index) {
|
||||
if (text == 0) {
|
||||
return '0待翻译';
|
||||
} else {
|
||||
return '1待翻译';
|
||||
}
|
||||
},
|
||||
},
|
||||
// {
|
||||
// title: '区域ID',
|
||||
// align: 'center',
|
||||
// dataIndex: 'housingestateId',
|
||||
// },
|
||||
];
|
||||
|
||||
// 高级查询数据
|
||||
export const superQuerySchema = {
|
||||
imei: { title: '设备编码', order: 0, view: 'text', type: 'string' },
|
||||
iccid: { title: 'ICCID', order: 1, view: 'text', type: 'string' },
|
||||
isOnline: { title: '是否在线', order: 2, view: 'text', type: 'string' },
|
||||
content: { title: '设备点位', order: 3, view: 'text', type: 'string' },
|
||||
boxNum: { title: '桶数量', order: 4, view: 'text', type: 'string' },
|
||||
inWarehouse: { title: '是否在仓库中', order: 5, view: 'text', type: 'string' },
|
||||
housingestateId: { title: '区域ID', order: 6, view: 'text', type: 'string' },
|
||||
};
|
|
@ -0,0 +1,296 @@
|
|||
<template>
|
||||
<div class="p-2">
|
||||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol"
|
||||
:wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="imei">
|
||||
<template #label><span title="设备编码">设备编码</span></template>
|
||||
<a-input placeholder="请输入设备编码" v-model:value="queryParam.imei" allow-clear></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="iccid">
|
||||
<template #label><span title="ICCID">ICCI</span></template>
|
||||
<a-input placeholder="请输入ICCID" v-model:value="queryParam.iccid" allow-clear></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="isOnline">
|
||||
<template #label><span title="是否在线">是否在线</span></template>
|
||||
<a-select ref="select" v-model:value="queryParam.isOnline" style="width: 120px" placeholder="请选择是否在线">
|
||||
<a-select-option :value="true">在线</a-select-option>
|
||||
<a-select-option :value="false">离线</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="inWarehouse">
|
||||
<template #label><span title="是否在仓库中">是否在仓</span></template>
|
||||
<a-select ref="select" v-model:value="queryParam.inWarehouse" style="width: 120px" placeholder="请选择是否在仓库中">
|
||||
<a-select-option :value="0">0待翻译</a-select-option>
|
||||
<a-select-option :value="1">1待翻译</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="housingestateId">
|
||||
<template #label><span title="区域名称">区域名称</span></template>
|
||||
<a-input placeholder="请输入区域名称" v-model:value="queryParam.housingestateName" allow-clear></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||
<a-col :lg="6">
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset"
|
||||
style="margin-left: 8px">重置</a-button>
|
||||
</a-col>
|
||||
</span>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction />
|
||||
</template>
|
||||
<template v-slot:bodyCell="{ column, record, index, text }">
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<DeviceInfoModal ref="registerModal" @success="handleSuccess"></DeviceInfoModal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="deviceinfo-deviceInfo" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns, superQuerySchema } from './DeviceInfo.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './DeviceInfo.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import DeviceInfoModal from './components/DeviceInfoModal.vue'
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { cloneDeep } from "lodash-es";
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const registerModal = ref();
|
||||
const userStore = useUserStore();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '设备信息',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: false,
|
||||
useSearchForm: false,
|
||||
showActionColumn: false,
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: async (params) => {
|
||||
let rangerQuery = await setRangeQuery();
|
||||
return Object.assign(params, rangerQuery);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: "设备信息",
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const labelCol = reactive({
|
||||
xs: 24,
|
||||
sm: 4,
|
||||
xl: 6,
|
||||
xxl: 4
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: 24,
|
||||
sm: 20,
|
||||
});
|
||||
|
||||
// 高级查询配置
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
/**
|
||||
* 高级查询事件
|
||||
*/
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).map((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
searchQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
function handleAdd() {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.add();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit(record: Recordable) {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
function handleDetail(record: Recordable) {
|
||||
registerModal.value.disableSubmit = true;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除事件
|
||||
*/
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'deviceinfo:bl_device_info:edit'
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉操作栏
|
||||
*/
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
}, {
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
placement: 'topLeft',
|
||||
},
|
||||
auth: 'deviceinfo:bl_device_info:delete'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
formRef.value.resetFields();
|
||||
selectedRowKeys.value = [];
|
||||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let rangeField = ''
|
||||
|
||||
/**
|
||||
* 设置范围查询条件
|
||||
*/
|
||||
async function setRangeQuery() {
|
||||
let queryParamClone = cloneDeep(queryParam);
|
||||
if (rangeField) {
|
||||
let fieldsValue = rangeField.split(',');
|
||||
fieldsValue.forEach(item => {
|
||||
if (queryParamClone[item]) {
|
||||
let range = queryParamClone[item];
|
||||
queryParamClone[item + '_begin'] = range[0];
|
||||
queryParamClone[item + '_end'] = range[1];
|
||||
delete queryParamClone[item];
|
||||
} else {
|
||||
queryParamClone[item + '_begin'] = '';
|
||||
queryParamClone[item + '_end'] = '';
|
||||
}
|
||||
})
|
||||
}
|
||||
return queryParamClone;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.jeecg-basic-table-form-container {
|
||||
padding: 0;
|
||||
|
||||
.table-page-search-submitButtons {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.query-group-cust {
|
||||
min-width: 100px !important;
|
||||
}
|
||||
|
||||
.query-group-split-cust {
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
}
|
||||
|
||||
.ant-form-item:not(.ant-form-item-with-help) {
|
||||
margin-bottom: 16px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
:deep(.ant-picker),
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,181 @@
|
|||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<JFormContainer :disabled="disabled">
|
||||
<template #detail>
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="DeviceInfoForm">
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备编码" v-bind="validateInfos.imei" id="DeviceInfoForm-imei" name="imei">
|
||||
<a-input v-model:value="formData.imei" placeholder="请输入设备编码" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="ICCID" v-bind="validateInfos.iccid" id="DeviceInfoForm-iccid" name="iccid">
|
||||
<a-input v-model:value="formData.iccid" placeholder="请输入ICCID" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="是否在线" v-bind="validateInfos.isOnline" id="DeviceInfoForm-isOnline" name="isOnline">
|
||||
<a-input v-model:value="formData.isOnline" placeholder="请输入是否在线" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备点位" v-bind="validateInfos.content" id="DeviceInfoForm-content" name="content">
|
||||
<a-input v-model:value="formData.content" placeholder="请输入设备点位" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="桶数量" v-bind="validateInfos.boxNum" id="DeviceInfoForm-boxNum" name="boxNum">
|
||||
<a-input v-model:value="formData.boxNum" placeholder="请输入桶数量" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="是否在仓库中" v-bind="validateInfos.inWarehouse" id="DeviceInfoForm-inWarehouse" name="inWarehouse">
|
||||
<a-input v-model:value="formData.inWarehouse" placeholder="请输入是否在仓库中" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="区域ID" v-bind="validateInfos.housingestateId" id="DeviceInfoForm-housingestateId" name="housingestateId">
|
||||
<a-input v-model:value="formData.housingestateId" placeholder="请输入区域ID" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</JFormContainer>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getValueType } from '/@/utils';
|
||||
import { saveOrUpdate } from '../DeviceInfo.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
const props = defineProps({
|
||||
formDisabled: { type: Boolean, default: false },
|
||||
formData: { type: Object, default: () => ({})},
|
||||
formBpm: { type: Boolean, default: true }
|
||||
});
|
||||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: '',
|
||||
imei: '',
|
||||
iccid: '',
|
||||
isOnline: '',
|
||||
content: '',
|
||||
boxNum: '',
|
||||
inWarehouse: '',
|
||||
housingestateId: '',
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
//表单验证
|
||||
const validatorRules = reactive({
|
||||
});
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||
|
||||
// 表单禁用
|
||||
const disabled = computed(()=>{
|
||||
if(props.formBpm === true){
|
||||
if(props.formData.disabled === false){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return props.formDisabled;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add() {
|
||||
edit({});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function edit(record) {
|
||||
nextTick(() => {
|
||||
resetFields();
|
||||
const tmpData = {};
|
||||
Object.keys(formData).forEach((key) => {
|
||||
if(record.hasOwnProperty(key)){
|
||||
tmpData[key] = record[key]
|
||||
}
|
||||
})
|
||||
//赋值
|
||||
Object.assign(formData, tmpData);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
try {
|
||||
// 触发表单验证
|
||||
await validate();
|
||||
} catch ({ errorFields }) {
|
||||
if (errorFields) {
|
||||
const firstField = errorFields[0];
|
||||
if (firstField) {
|
||||
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
return Promise.reject(errorFields);
|
||||
}
|
||||
confirmLoading.value = true;
|
||||
const isUpdate = ref<boolean>(false);
|
||||
//时间格式化
|
||||
let model = formData;
|
||||
if (model.id) {
|
||||
isUpdate.value = true;
|
||||
}
|
||||
//循环数据
|
||||
for (let data in model) {
|
||||
//如果该数据是数组并且是字符串类型
|
||||
if (model[data] instanceof Array) {
|
||||
let valueType = getValueType(formRef.value.getProps, data);
|
||||
//如果是字符串类型的需要变成以逗号分割的字符串
|
||||
if (valueType === 'string') {
|
||||
model[data] = model[data].join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
await saveOrUpdate(model, isUpdate.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
createMessage.success(res.message);
|
||||
emit('ok');
|
||||
} else {
|
||||
createMessage.warning(res.message);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
confirmLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
submitForm,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.antd-modal-form {
|
||||
padding: 14px;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,77 @@
|
|||
<template>
|
||||
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<DeviceInfoForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></DeviceInfoForm>
|
||||
</j-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import DeviceInfoForm from './DeviceInfoForm.vue'
|
||||
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
||||
|
||||
const title = ref<string>('');
|
||||
const width = ref<number>(800);
|
||||
const visible = ref<boolean>(false);
|
||||
const disableSubmit = ref<boolean>(false);
|
||||
const registerForm = ref();
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add() {
|
||||
title.value = '新增';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.add();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function edit(record) {
|
||||
title.value = disableSubmit.value ? '详情' : '编辑';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.edit(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定按钮点击事件
|
||||
*/
|
||||
function handleOk() {
|
||||
registerForm.value.submitForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* form保存回调事件
|
||||
*/
|
||||
function submitCallback() {
|
||||
handleCancel();
|
||||
emit('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮回调事件
|
||||
*/
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
disableSubmit,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
/**隐藏样式-modal确定按钮 */
|
||||
.jee-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
Loading…
Reference in New Issue