防坠器
This commit is contained in:
124
src/api/tower/fall/index.ts
Normal file
124
src/api/tower/fall/index.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { TowerFall, TowerFallParam } from '@/api/tower/fall/model';
|
||||
/**
|
||||
* 分页查询防坠器
|
||||
*/
|
||||
export async function pageTowerFall(params: TowerFallParam) {
|
||||
const res = await request.get<ApiResult<PageResult<TowerFall>>>(
|
||||
'/tower/tower-fall/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询防坠器列表
|
||||
*/
|
||||
export async function listTowerFall(params?: TowerFallParam) {
|
||||
const res = await request.get<ApiResult<TowerFall[]>>('/tower/tower-fall', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加防坠器
|
||||
*/
|
||||
export async function addTowerFall(data: TowerFall) {
|
||||
const res = await request.post<ApiResult<unknown>>('/tower/tower-fall', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改防坠器
|
||||
*/
|
||||
export async function updateTowerFall(data: TowerFall) {
|
||||
const res = await request.put<ApiResult<unknown>>('/tower/tower-fall', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定防坠器
|
||||
*/
|
||||
export async function bindTowerFall(data: TowerFall) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/tower/tower-fall/bind',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除防坠器
|
||||
*/
|
||||
export async function removeTowerFall(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/tower/tower-fall/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加防坠器
|
||||
*/
|
||||
export async function addBatchTowerFall(data: TowerFall[]) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/tower/tower-fall/batch',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改防坠器状态
|
||||
*/
|
||||
export async function updateBatchTowerFall(data: TowerFall[]) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/tower/tower-fall/status',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除防坠器
|
||||
*/
|
||||
export async function removeBatchTowerFall(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/tower/tower-fall/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
31
src/api/tower/fall/model/index.ts
Normal file
31
src/api/tower/fall/model/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
export interface TowerFall {
|
||||
id?: number;
|
||||
code?: string;
|
||||
model?: string;
|
||||
factory?: string;
|
||||
factoryDate?: string;
|
||||
discardDate?: string;
|
||||
file1?: string;
|
||||
file2?: string;
|
||||
file3?: string;
|
||||
file4?: string;
|
||||
users?: string;
|
||||
status?: number;
|
||||
comments?: string;
|
||||
userId?: number;
|
||||
deleted?: number;
|
||||
tenantId?: number;
|
||||
createTime?: number;
|
||||
maxRatedLoad?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索条件
|
||||
*/
|
||||
export interface TowerFallParam extends PageParam {
|
||||
id?: number;
|
||||
name?: string;
|
||||
status?: number;
|
||||
}
|
||||
112
src/api/tower/provider/index.ts
Normal file
112
src/api/tower/provider/index.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { TowerProvider, TowerProviderParam } from './model';
|
||||
// const merchantCode = String(localStorage.getItem('merchantCode'));
|
||||
|
||||
/**
|
||||
* 分页查询设备型号
|
||||
*/
|
||||
export async function pageTowerProvider(params: TowerProviderParam) {
|
||||
const res = await request.get<ApiResult<PageResult<TowerProvider>>>(
|
||||
'/tower/tower-provider/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备型号列表
|
||||
*/
|
||||
export async function listTowerProvider(params?: TowerProviderParam) {
|
||||
const res = await request.get<ApiResult<TowerProvider[]>>(
|
||||
'/tower/tower-provider',
|
||||
{
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加设备型号
|
||||
*/
|
||||
export async function addTowerProvider(data: TowerProvider) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/tower/tower-provider',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备型号
|
||||
*/
|
||||
export async function updateTowerProvider(data: TowerProvider) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/tower/tower-provider',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备型号
|
||||
*/
|
||||
export async function removeTowerProvider(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/tower/tower-provider/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除设备型号
|
||||
*/
|
||||
export async function removeBatchTowerProvider(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/tower/tower-model/provider',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查IP是否存在
|
||||
*/
|
||||
export async function checkExistence(
|
||||
field: string,
|
||||
value: string,
|
||||
id?: number
|
||||
) {
|
||||
const res = await request.get<ApiResult<unknown>>(
|
||||
'/tower/tower-model/provider',
|
||||
{
|
||||
params: { field, value, id }
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
55
src/api/tower/provider/model/index.ts
Normal file
55
src/api/tower/provider/model/index.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 型号分类
|
||||
*/
|
||||
export interface TowerProvider {
|
||||
// 型号分类id
|
||||
id?: number;
|
||||
// 所属设备
|
||||
equipment: string;
|
||||
// 型号分类
|
||||
title?: string;
|
||||
// 型号分类图片
|
||||
image?: string;
|
||||
// 使用年限
|
||||
yearLife?: number;
|
||||
// 上级分类
|
||||
parentId?: number;
|
||||
// 是否隐藏
|
||||
hide?: number;
|
||||
// 封面图
|
||||
avatar?: string;
|
||||
// 用户ID
|
||||
userId?: string;
|
||||
// 所属门店ID
|
||||
shopId?: string;
|
||||
// 排序
|
||||
sortNumber?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 状态
|
||||
status?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 更新时间
|
||||
updateTime?: string;
|
||||
//
|
||||
key?: number;
|
||||
//
|
||||
merchantCode?: string;
|
||||
value?: number;
|
||||
// 子菜单
|
||||
children?: TowerProvider[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 型号分类搜索条件
|
||||
*/
|
||||
export interface TowerProviderParam extends PageParam {
|
||||
title?: string;
|
||||
categoryId?: string;
|
||||
yearLife?: number;
|
||||
// 商户编号
|
||||
merchantCode?: string;
|
||||
}
|
||||
155
src/components/TowerModel/components/select-data.vue
Normal file
155
src/components/TowerModel/components/select-data.vue
Normal file
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="750"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:title="title"
|
||||
:footer="null"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="companyId"
|
||||
:datasource="datasource"
|
||||
:columns="columns"
|
||||
:customRow="customRow"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
style="width: 200px"
|
||||
@search="reload"
|
||||
@pressEnter="reload"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'companyLogo'">
|
||||
<a-image
|
||||
v-if="record.companyLogo"
|
||||
:src="FILE_THUMBNAIL + record.companyLogo"
|
||||
:preview="false"
|
||||
:width="45"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="column.key === 'companyType'">
|
||||
<a-tag v-if="record.companyType === 10">企业</a-tag>
|
||||
<a-tag v-if="record.companyType === 20">政府单位</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button type="link">选择</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import {
|
||||
ColumnItem,
|
||||
DatasourceFunction
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { pageCompany } from '@/api/system/company';
|
||||
import { FILE_THUMBNAIL } from '@/config/setting';
|
||||
import { EleProTable } from 'ele-admin-pro';
|
||||
import { Company, CompanyParam } from '@/api/system/company/model';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 标题
|
||||
title?: string;
|
||||
// 企业类型
|
||||
companyType?: string;
|
||||
// 修改回显的数据
|
||||
data?: Company | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done', data: Company): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 搜索内容
|
||||
const searchText = ref(null);
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id'
|
||||
},
|
||||
{
|
||||
title: '设备名称',
|
||||
dataIndex: 'equipment',
|
||||
key: 'equipment',
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '设备型号',
|
||||
key: 'title',
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '使用年限',
|
||||
dataIndex: 'yearLife',
|
||||
key: 'yearLife',
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where = {};
|
||||
// 搜索条件
|
||||
if (searchText.value) {
|
||||
where.keywords = searchText.value;
|
||||
}
|
||||
if (props.companyType == 'empty') {
|
||||
where.emptyType = true;
|
||||
} else {
|
||||
where.companyType = props.companyType;
|
||||
}
|
||||
where.isStaff = true;
|
||||
return pageCompany({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: CompanyParam) => {
|
||||
tableRef?.value?.reload({ page: 1, where });
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Company) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
updateVisible(false);
|
||||
emit('done', record);
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
61
src/components/TowerModel/index.vue
Normal file
61
src/components/TowerModel/index.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-input-group compact>
|
||||
<a-input
|
||||
disabled
|
||||
style="width: calc(100% - 32px)"
|
||||
v-model:value="value"
|
||||
:placeholder="placeholder"
|
||||
/>
|
||||
<a-button @click="openEdit">
|
||||
<template #icon><BulbOutlined class="ele-text-warning" /></template>
|
||||
</a-button>
|
||||
</a-input-group>
|
||||
<!-- 选择弹窗 -->
|
||||
<SelectData
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
:title="placeholder"
|
||||
:customer-type="customerType"
|
||||
@done="onChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { BulbOutlined } from '@ant-design/icons-vue';
|
||||
import { ref } from 'vue';
|
||||
import SelectData from './components/select-data.vue';
|
||||
import { Customer } from '@/api/oa/customer/model';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
value?: any;
|
||||
customerType?: string;
|
||||
placeholder?: string;
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择数据'
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done', Customer): void;
|
||||
(e: 'clear'): void;
|
||||
}>();
|
||||
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 当前编辑数据
|
||||
const current = ref<Customer | null>(null);
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Customer) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const onChange = (row) => {
|
||||
emit('done', row);
|
||||
};
|
||||
</script>
|
||||
426
src/views/tower/fall/components/fall-edit.vue
Normal file
426
src/views/tower/fall/components/fall-edit.vue
Normal file
@@ -0,0 +1,426 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="80%"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑设备' : '添加设备'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<div style="background-color: #f3f3f3; padding: 8px">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ md: { span: 7 }, sm: { span: 4 }, xs: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 17 }, sm: { span: 20 }, xs: { span: 24 } }"
|
||||
>
|
||||
<a-card title="基本信息" :bordered="false">
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 8, sm: 24, xs: 24 } : { span: 8 }"
|
||||
>
|
||||
<a-form-item label="防坠器编号" name="code">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入防坠器编号"
|
||||
v-model:value="form.code"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="防坠器型号" name="model">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入防坠器型号"
|
||||
v-model:value="form.model"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="制造厂家" name="factory">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="factory"
|
||||
v-model:value="form.factory"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="产权单位" name="company">
|
||||
<TowerCompany
|
||||
:placeholder="`请选择产权单位`"
|
||||
v-model:value="form.company"
|
||||
:customer-type="`产权单位`"
|
||||
@done="chooseCompanyName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="出厂日期" name="factoryDate">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
value-format="YYYY-MM-DD 00:00:00"
|
||||
placeholder="请选择日期"
|
||||
v-model:value="form.factoryDate"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="报废日期" name="discardDate">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
value-format="YYYY-MM-DD 00:00:00"
|
||||
placeholder="请选择日期"
|
||||
v-model:value="form.discardDate"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-divider style="height: 8px" />
|
||||
<a-card title="附件信息" :bordered="false">
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 8, sm: 24, xs: 24 } : { span: 8 }"
|
||||
>
|
||||
<a-form-item label="出厂报告" name="parentId">
|
||||
<a-upload
|
||||
v-model:file-list="file1"
|
||||
name="file"
|
||||
action="https://file.wsdns.cn/api/file/image"
|
||||
:headers="{ Authorization: token }"
|
||||
@change="onFile1"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined />
|
||||
上传
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="合格证" name="parentId">
|
||||
<a-upload
|
||||
v-model:file-list="file2"
|
||||
name="file"
|
||||
action="https://file.wsdns.cn/api/file/image"
|
||||
:headers="{ Authorization: token }"
|
||||
@change="onFile2"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined />
|
||||
上传
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="出厂铭牌" name="parentId">
|
||||
<a-upload
|
||||
v-model:file-list="file3"
|
||||
name="file"
|
||||
action="https://file.wsdns.cn/api/file/image"
|
||||
:headers="{ Authorization: token }"
|
||||
@change="onFile3"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined />
|
||||
上传
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="发票" name="parentId">
|
||||
<a-upload
|
||||
v-model:file-list="file4"
|
||||
name="file"
|
||||
action="https://file.wsdns.cn/api/file/image"
|
||||
:headers="{ Authorization: token }"
|
||||
@change="onFile4"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined />
|
||||
上传
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</div>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { addTowerFall, updateTowerFall } from '@/api/tower/fall';
|
||||
import { TowerFall } from '@/api/tower/fall/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { UploadOutlined } from '@ant-design/icons-vue';
|
||||
import DictSelect from '@/views/search/components/dict-select.vue';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { TOKEN_STORE_NAME } from '@/config/setting';
|
||||
import { Warehouse } from '@/api/tower/warehouse/model';
|
||||
import { User } from '@/api/user/model';
|
||||
import { Organization } from '@/api/system/organization/model';
|
||||
import { Customer } from '@/api/oa/customer/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: TowerFall | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
interface FileItem {
|
||||
uid: string;
|
||||
name?: string;
|
||||
status?: string;
|
||||
response?: Response;
|
||||
thumbUrl?: string;
|
||||
downloadUrl?: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface FileInfo {
|
||||
file: FileItem;
|
||||
fileList: FileItem[];
|
||||
}
|
||||
|
||||
// 文件上传
|
||||
const file1 = ref<FileItem[]>();
|
||||
const file2 = ref<FileItem[]>();
|
||||
const file3 = ref<FileItem[]>();
|
||||
const file4 = ref<FileItem[]>();
|
||||
const file5 = ref<FileItem[]>();
|
||||
const file6 = ref<FileItem[]>();
|
||||
const file7 = ref<FileItem[]>();
|
||||
|
||||
// token
|
||||
const token = localStorage.getItem(TOKEN_STORE_NAME);
|
||||
|
||||
// 表单信息
|
||||
const form = reactive<TowerFall>({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
model: undefined,
|
||||
factory: '',
|
||||
factoryDate: '',
|
||||
discardDate: undefined,
|
||||
file1: '[]',
|
||||
file2: '[]',
|
||||
file3: '[]',
|
||||
file4: '[]',
|
||||
users: '',
|
||||
status: undefined,
|
||||
comments: '',
|
||||
userId: undefined,
|
||||
deleted: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入设备',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
model: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入设备型号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
factoryNo: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入出厂编号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
const onLifeYaer = () => {
|
||||
form.surplusYear = form.lifeYear;
|
||||
};
|
||||
// const onFactoryDate = () => {
|
||||
// form.scrapDate = form.factoryDate;
|
||||
// };
|
||||
|
||||
const onFile1 = (info: FileInfo) => {
|
||||
let resFileList = [...info.fileList];
|
||||
file1.value = resFileList.map((file) => {
|
||||
if (file.response) {
|
||||
// Component will show file.url as link
|
||||
file.url = file.response.url;
|
||||
}
|
||||
return file;
|
||||
});
|
||||
form.file1 = JSON.stringify(file1.value);
|
||||
};
|
||||
const onFile2 = (info: FileInfo) => {
|
||||
let resFileList = [...info.fileList];
|
||||
file2.value = resFileList.map((file) => {
|
||||
if (file.response) {
|
||||
// Component will show file.url as link
|
||||
file.url = file.response.url;
|
||||
}
|
||||
return file;
|
||||
});
|
||||
form.file2 = JSON.stringify(file2.value);
|
||||
};
|
||||
const onFile3 = (info: FileInfo) => {
|
||||
let resFileList = [...info.fileList];
|
||||
file3.value = resFileList.map((file) => {
|
||||
if (file.response) {
|
||||
// Component will show file.url as link
|
||||
file.url = file.response.url;
|
||||
}
|
||||
return file;
|
||||
});
|
||||
form.file3 = JSON.stringify(file3.value);
|
||||
};
|
||||
const onFile4 = (info: FileInfo) => {
|
||||
let resFileList = [...info.fileList];
|
||||
file4.value = resFileList.map((file) => {
|
||||
if (file.response) {
|
||||
// Component will show file.url as link
|
||||
file.url = file.response.url;
|
||||
}
|
||||
return file;
|
||||
});
|
||||
form.file4 = JSON.stringify(file4.value);
|
||||
};
|
||||
|
||||
const chooseFallName = (data) => {
|
||||
form.name = data.name;
|
||||
form.model = data.model;
|
||||
};
|
||||
|
||||
const chooseFallModel = (data) => {
|
||||
form.name = data.name;
|
||||
form.model = data.model;
|
||||
};
|
||||
|
||||
const chooseWarehouse = (data: Warehouse) => {
|
||||
console.log(data);
|
||||
form.warehouse = data.warehouseName;
|
||||
form.currentLocation = data.address;
|
||||
};
|
||||
|
||||
const chooseUsers = (data: User) => {
|
||||
form.users = data.nickname;
|
||||
};
|
||||
|
||||
const chooseOrganization = (data: Organization) => {
|
||||
form.organization = data.organizationName;
|
||||
};
|
||||
|
||||
const chooseCompanyName = (data: Customer) => {
|
||||
form.company = data.customerName;
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateTowerFall : addTowerFall;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
if (props.data.file1) {
|
||||
file1.value = JSON.parse(props.data.file1);
|
||||
}
|
||||
if (props.data.file2) {
|
||||
file2.value = JSON.parse(props.data.file2);
|
||||
}
|
||||
if (props.data.file3) {
|
||||
file3.value = JSON.parse(props.data.file3);
|
||||
}
|
||||
if (props.data.file4) {
|
||||
file4.value = JSON.parse(props.data.file4);
|
||||
}
|
||||
if (props.data.file5) {
|
||||
file5.value = JSON.parse(props.data.file5);
|
||||
}
|
||||
if (props.data.file6) {
|
||||
file6.value = JSON.parse(props.data.file6);
|
||||
}
|
||||
if (props.data.file7) {
|
||||
file7.value = JSON.parse(props.data.file7);
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.upload-text {
|
||||
margin-right: 70px;
|
||||
}
|
||||
</style>
|
||||
111
src/views/tower/fall/components/import.vue
Normal file
111
src/views/tower/fall/components/import.vue
Normal file
@@ -0,0 +1,111 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:title="`导入设备`"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
:footer="null"
|
||||
>
|
||||
<a-upload-dragger
|
||||
name="file"
|
||||
:show-upload-list="false"
|
||||
accept=".xls,.xlsx"
|
||||
:before-upload="handleImport"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<InboxOutlined />
|
||||
</p>
|
||||
<p class="ant-upload-text">单击或拖动文件到此区域进行上传</p>
|
||||
<p class="ant-upload-hint" style="max-width: 550px">
|
||||
提示:附件上传中,请不要做任何操作! 支持的文件类型为*.xls, *.xlsx!
|
||||
</p>
|
||||
</a-upload-dragger>
|
||||
<div style="margin: 20px auto; display: flex; justify-content: center">
|
||||
<a
|
||||
href="https://file.wsdns.cn/download/20230523/2f5ffa06b0684e138184c6786f6fbb68.xlsx"
|
||||
target="_blank"
|
||||
>下载设备导入模板</a
|
||||
>
|
||||
</div>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { InboxOutlined } from '@ant-design/icons-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { addBatchTowerEquipment } from '@/api/tower/equipment';
|
||||
import { TowerEquipment } from '@/api/tower/equipment/model';
|
||||
import { read, utils } from 'xlsx';
|
||||
import { ref } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 导入的数据
|
||||
const importData = ref<TowerEquipment[]>([]);
|
||||
const handleImport = (file: File) => {
|
||||
if (
|
||||
![
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
].includes(file.type)
|
||||
) {
|
||||
message.error('只能选择 excel 文件');
|
||||
return false;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 20) {
|
||||
message.error('大小不能超过 20MB');
|
||||
return false;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
const data = new Uint8Array(e.target?.result as any);
|
||||
const workbook = read(data, { type: 'array' });
|
||||
const sheetNames = workbook.SheetNames;
|
||||
const worksheet = workbook.Sheets[sheetNames[0]];
|
||||
// 解析成二维数组
|
||||
const aoa = utils.sheet_to_json<string[]>(worksheet, { header: 1 });
|
||||
console.log(aoa);
|
||||
aoa.slice(1).map((d) => {
|
||||
const array = ['闲置', '报废', '注销', '转卖'];
|
||||
importData.value.push({
|
||||
status: array.indexOf(d[0]),
|
||||
name: d[1],
|
||||
factoryNo: d[2],
|
||||
model: d[3],
|
||||
manufactor: d[4],
|
||||
buyDate: d[5],
|
||||
filingNo: d[6],
|
||||
factoryDate: d[7],
|
||||
company: d[8],
|
||||
source: d[9],
|
||||
warehouse: d[10],
|
||||
users: d[11],
|
||||
equipmentNo: d[12],
|
||||
ratedLoad: d[13],
|
||||
maxLiftingHeight: d[14],
|
||||
armLength: d[15],
|
||||
currentLocation: d[16],
|
||||
machineNo: d[17]
|
||||
});
|
||||
});
|
||||
addBatchTowerEquipment(importData.value).then(() => {
|
||||
message.success('导入成功');
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
});
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
return false;
|
||||
};
|
||||
</script>
|
||||
203
src/views/tower/fall/components/search.vue
Normal file
203
src/views/tower/fall/components/search.vue
Normal file
@@ -0,0 +1,203 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加防坠器</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-button class="ele-btn-icon" @click="openImport">
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
<span>导入设备</span>
|
||||
</a-button>
|
||||
<a-button class="ele-btn-icon" @click="handleExport">
|
||||
<template #icon>
|
||||
<DownloadOutlined />
|
||||
</template>
|
||||
<span>导出设备</span>
|
||||
</a-button>
|
||||
<a-radio-group v-model:value="status" @change="handleStatus">
|
||||
<a-radio-button :value="1">报废</a-radio-button>
|
||||
<a-radio-button :value="2">注销</a-radio-button>
|
||||
<a-radio-button :value="0">恢复</a-radio-button>
|
||||
<a-radio-button :value="3">转卖</a-radio-button>
|
||||
</a-radio-group>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
v-model:value="searchText"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
/>
|
||||
<!-- 导入弹窗 -->
|
||||
<Import v-model:visible="showImport" @done="search" />
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
UploadOutlined,
|
||||
DownloadOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import { TowerEquipment } from '@/api/tower/equipment/model';
|
||||
import { TowerEquipmentParam } from '@/api/tower/equipment/model';
|
||||
import Import from './import.vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: TowerEquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'update', status?: number): void;
|
||||
(e: 'import'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<TowerEquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
name: undefined,
|
||||
keywords: ''
|
||||
});
|
||||
// 下来选项
|
||||
const type = ref('keywords');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
// 状态
|
||||
const status = ref<number>();
|
||||
// 是否显示导入弹窗
|
||||
const showImport = ref(false);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
resetFields();
|
||||
if (type.value == 'keywords') {
|
||||
where.keywords = searchText.value;
|
||||
}
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = () => {
|
||||
if (!props.selection?.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'设备状态',
|
||||
'设备名称',
|
||||
'出厂编号',
|
||||
'设备型号',
|
||||
'制造厂商',
|
||||
'采购日期',
|
||||
'备案编号',
|
||||
'出厂日期',
|
||||
'产权单位',
|
||||
'设备来源',
|
||||
'所属仓库',
|
||||
'所属人员',
|
||||
'自编号',
|
||||
'额定载重',
|
||||
'最大起升高度(m)',
|
||||
'臂长',
|
||||
'当前位置',
|
||||
'楼号'
|
||||
]
|
||||
];
|
||||
|
||||
props.selection?.forEach((d: TowerEquipment) => {
|
||||
array.push([
|
||||
`${['闲置', '报废', '注销', '转卖'][Number(d.status)]}`,
|
||||
`${d.name}`,
|
||||
`${d.factoryNo}`,
|
||||
`${d.model}`,
|
||||
`${d.manufactor}`,
|
||||
`${d.buyDate ? d.buyDate : ''}`,
|
||||
`${d.filingNo}`,
|
||||
`${d.factoryDate ? d.factoryDate : ''}`,
|
||||
`${d.company}`,
|
||||
`${d.source}`,
|
||||
`${d.warehouse}`,
|
||||
`${d.users}`,
|
||||
`${d.equipmentNo}`,
|
||||
`${d.ratedLoad}`,
|
||||
`${d.maxLiftingHeight}`,
|
||||
`${d.armLength}`,
|
||||
`${d.currentLocation}`,
|
||||
`${d.machineNo}`
|
||||
]);
|
||||
});
|
||||
const sheetName = '设备导出列表';
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 },
|
||||
{ wch: 40 },
|
||||
{ wch: 10 }
|
||||
];
|
||||
writeFile(workbook, '导出设备管理表.xlsx');
|
||||
};
|
||||
|
||||
// 发布设备
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 导入
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
const handleStatus = () => {
|
||||
emit('update', status.value);
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
302
src/views/tower/fall/index.vue
Normal file
302
src/views/tower/fall/index.vue
Normal file
@@ -0,0 +1,302 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="fallId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 1200 }"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@update="handleStatus"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'nickname'">
|
||||
{{ record.nickname }}
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">闲置</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">报废</a-tag>
|
||||
<a-tag v-if="record.status === 2" color="purple">注销</a-tag>
|
||||
<a-tag v-if="record.status === 3" color="orange">转卖</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 编辑弹窗 -->
|
||||
<FallEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import FallEdit from './components/fall-edit.vue';
|
||||
import {
|
||||
pageTowerFall,
|
||||
removeBatchTowerFall,
|
||||
updateBatchTowerFall
|
||||
} from '@/api/tower/fall';
|
||||
import { TowerFall, TowerFallParam } from '@/api/tower/fall/model';
|
||||
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
// {
|
||||
// title: '设备状态',
|
||||
// dataIndex: 'status',
|
||||
// key: 'status',
|
||||
// customRender: ({ text }) => ['闲置', '报废', '注销', '转卖'][text]
|
||||
// },
|
||||
{
|
||||
title: '防坠器编号',
|
||||
dataIndex: 'code',
|
||||
key: 'code'
|
||||
},
|
||||
{
|
||||
title: '防坠器型号',
|
||||
dataIndex: 'model',
|
||||
key: 'model'
|
||||
},
|
||||
{
|
||||
title: '制造厂商',
|
||||
dataIndex: 'factory',
|
||||
key: 'factory'
|
||||
},
|
||||
{
|
||||
title: '产权单位',
|
||||
dataIndex: 'company',
|
||||
key: 'company'
|
||||
},
|
||||
{
|
||||
title: '出厂日期',
|
||||
dataIndex: 'factoryDate',
|
||||
key: 'factoryDate'
|
||||
},
|
||||
{
|
||||
title: '报废日期',
|
||||
dataIndex: 'discardDate',
|
||||
key: 'discardDate'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<TowerFall[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<TowerFall | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payMethod) {
|
||||
where.payMethod = filters.payMethod;
|
||||
}
|
||||
if (filters.deliveryType) {
|
||||
where.deliveryType = filters.deliveryType;
|
||||
}
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.orderSource) {
|
||||
where.orderSource = filters.orderSource;
|
||||
}
|
||||
where.tenantId = localStorage.getItem('tenantId');
|
||||
where.payStatus = 20;
|
||||
return pageTowerFall({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: TowerFallParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: TowerFall) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
/* 删除单个 */
|
||||
const remove = (row: TowerFall) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchTowerFall([row.id])
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
/* 批量修改 */
|
||||
const handleStatus = (status) => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
const data = selection.value.map((d) => {
|
||||
return {
|
||||
fallId: d.id,
|
||||
status
|
||||
};
|
||||
});
|
||||
console.log(data);
|
||||
updateBatchTowerFall(data).then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchTowerFall(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: TowerFall) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'TowerFallIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-edit {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.comments {
|
||||
max-width: 200px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user