Initial commit
This commit is contained in:
@@ -0,0 +1,697 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<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="name">
|
||||
<DictSelect
|
||||
dict-code="DeviceAssignment"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="出厂编号" name="factoryNo">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入出厂编号"
|
||||
v-model:value="form.factoryNo"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="自编号" name="equipmentNo">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入设备编号"
|
||||
v-model:value="form.equipmentNo"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="剩余使用年限" name="surplusYear">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入插件名称"
|
||||
disabled
|
||||
v-model:value="form.surplusYear"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 8, sm: 24, xs: 24 } : { span: 8 }"
|
||||
>
|
||||
<a-form-item label="设备型号" name="model">
|
||||
<DictSelect
|
||||
dict-code="EquipmentModel"
|
||||
placeholder="请选择设备型号"
|
||||
v-model:value="form.model"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="出厂日期" name="factoryDate">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择日期"
|
||||
v-model:value="form.factoryDate"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="使用年限" name="lifeYear">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入使用年限"
|
||||
v-model:value="form.lifeYear"
|
||||
@change="onLifeYaer"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="产权单位" name="company">
|
||||
<TowerCompany
|
||||
:placeholder="`请选择租赁单位`"
|
||||
v-model:value="form.company"
|
||||
:customer-type="`产权单位`"
|
||||
@done="chooseCompanyName"
|
||||
/>
|
||||
<!-- <DictSelect-->
|
||||
<!-- dict-code="propertyCompany"-->
|
||||
<!-- placeholder="请选择产权单位"-->
|
||||
<!-- v-model:value="form.company"-->
|
||||
<!-- />-->
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 8, sm: 24, xs: 24 } : { span: 8 }"
|
||||
>
|
||||
<a-form-item label="备案编号" name="filingNo">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入备案编号"
|
||||
v-model:value="form.filingNo"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="制造厂家" name="manufactor">
|
||||
<DictSelect
|
||||
dict-code="Manufacturer"
|
||||
placeholder="请选择制造厂家"
|
||||
v-model:value="form.manufactor"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="报废日期" name="scrapDate">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择日期"
|
||||
v-model:value="form.scrapDate"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备案许可证号" name="licenceNo">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入插件名称"
|
||||
v-model:value="form.licenceNo"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
|
||||
<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="warehouse">
|
||||
<SelectWarehouse
|
||||
:placeholder="`请选择仓库`"
|
||||
v-model:value="form.warehouse"
|
||||
@done="chooseWarehouse"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="采购日期" name="title">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择日期"
|
||||
v-model:value="form.buyDate"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="当前位置" name="currentLocation">
|
||||
<a-input
|
||||
allow-clear
|
||||
disabled
|
||||
placeholder="请输入当前位置"
|
||||
v-model:value="form.currentLocation"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 8, sm: 24, xs: 24 } : { span: 8 }"
|
||||
>
|
||||
<a-form-item label="所属人员" name="users">
|
||||
<SelectUser
|
||||
:placeholder="`请选择所属人员`"
|
||||
v-model:value="form.users"
|
||||
@done="chooseUsers"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="安全管理部门" name="organization">
|
||||
<SelectOrganization
|
||||
:placeholder="`请选择所属部门`"
|
||||
v-model:value="form.organization"
|
||||
@done="chooseOrganization"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 8, sm: 24, xs: 24 } : { span: 8 }"
|
||||
>
|
||||
<a-form-item label="设备来源" name="source">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入设备来源"
|
||||
v-model:value="form.source"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="机号" name="machineNo">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入插件名称"
|
||||
v-model:value="form.machineNo"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否外协标识" name="isOutOrg">
|
||||
<a-switch v-model:checked="form.isOutOrg" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<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="designHeight">
|
||||
<a-input-number
|
||||
allow-clear
|
||||
:min="0"
|
||||
style="width: 200px"
|
||||
placeholder="请输入设计高度"
|
||||
v-model:value="form.designHeight"
|
||||
/>
|
||||
<span class="ml-10">m</span>
|
||||
</a-form-item>
|
||||
<a-form-item label="独立高度" name="height">
|
||||
<a-input-number
|
||||
allow-clear
|
||||
:min="0"
|
||||
style="width: 200px"
|
||||
placeholder="请输入独立高度"
|
||||
v-model:value="form.height"
|
||||
/>
|
||||
<span class="ml-10">m</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 16 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="额定载重" name="ratedLoad">
|
||||
<a-input-number
|
||||
allow-clear
|
||||
:min="0"
|
||||
style="width: 200px"
|
||||
placeholder="请输入额定载重"
|
||||
v-model:value="form.ratedLoad"
|
||||
/>
|
||||
<span class="ml-10">T</span>
|
||||
</a-form-item>
|
||||
<a-form-item label="最大幅度处额定载重" name="maxRatedLoad">
|
||||
<a-input-number
|
||||
allow-clear
|
||||
:min="0"
|
||||
style="width: 200px"
|
||||
placeholder="请输入最大幅度处额定载重"
|
||||
v-model:value="form.maxRatedLoad"
|
||||
/>
|
||||
<span class="ml-10">T</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 6, sm: 24, xs: 24 } : { span: 8 }"
|
||||
/>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-form
|
||||
:label-col="{ md: { span: 2 }, sm: { span: 4 }, xs: { span: 24 } }"
|
||||
:wrapper-col="{
|
||||
md: { span: 17 },
|
||||
sm: { span: 20 },
|
||||
xs: { span: 24 }
|
||||
}"
|
||||
>
|
||||
<a-card title="附件信息" :bordered="false">
|
||||
<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-form-item label="备案证书" name="parentId">
|
||||
<a-upload
|
||||
v-model:file-list="file5"
|
||||
name="file"
|
||||
action="https://file.wsdns.cn/api/file/image"
|
||||
:headers="{ Authorization: token }"
|
||||
@change="onFile5"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined />
|
||||
上传
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="整机性能参数表" name="parentId">
|
||||
<a-upload
|
||||
v-model:file-list="file6"
|
||||
name="file"
|
||||
action="https://file.wsdns.cn/api/file/image"
|
||||
:headers="{ Authorization: token }"
|
||||
@change="onFile6"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined />
|
||||
上传
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="其他" name="parentId">
|
||||
<a-upload
|
||||
v-model:file-list="file7"
|
||||
name="file"
|
||||
action="https://file.wsdns.cn/api/file/image"
|
||||
:headers="{ Authorization: token }"
|
||||
@change="onFile7"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined />
|
||||
上传
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</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 {
|
||||
addTowerEquipment,
|
||||
updateTowerEquipment
|
||||
} from '@/api/tower/equipment';
|
||||
import { TowerEquipment } from '@/api/tower/equipment/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?: TowerEquipment | 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[]>();
|
||||
|
||||
// 日期范围选择
|
||||
const token = localStorage.getItem(TOKEN_STORE_NAME);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<TowerEquipment>({
|
||||
equipmentId: undefined,
|
||||
name: undefined,
|
||||
model: undefined,
|
||||
equipmentNo: '',
|
||||
factoryNo: '',
|
||||
factoryDate: '',
|
||||
manufactor: undefined,
|
||||
company: '',
|
||||
lifeYear: undefined,
|
||||
surplusYear: 3,
|
||||
scrapDate: '',
|
||||
licenceNo: '',
|
||||
organization: undefined,
|
||||
warehouse: undefined,
|
||||
source: undefined,
|
||||
buyDate: '',
|
||||
currentLocation: '',
|
||||
designHeight: undefined,
|
||||
height: undefined,
|
||||
ratedLoad: '',
|
||||
files: '[]',
|
||||
file1: '[]',
|
||||
file2: '[]',
|
||||
file3: '[]',
|
||||
file4: '[]',
|
||||
file5: '[]',
|
||||
file6: '[]',
|
||||
file7: '[]',
|
||||
filingNo: '',
|
||||
machineNo: '',
|
||||
users: '',
|
||||
isOutOrg: false,
|
||||
status: undefined,
|
||||
comments: '',
|
||||
userId: undefined,
|
||||
deleted: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
maxRatedLoad: ''
|
||||
});
|
||||
|
||||
/* 更新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'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
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 onFile5 = (info: FileInfo) => {
|
||||
let resFileList = [...info.fileList];
|
||||
file5.value = resFileList.map((file) => {
|
||||
if (file.response) {
|
||||
// Component will show file.url as link
|
||||
file.url = file.response.url;
|
||||
}
|
||||
return file;
|
||||
});
|
||||
form.file5 = JSON.stringify(file5.value);
|
||||
};
|
||||
const onFile6 = (info: FileInfo) => {
|
||||
let resFileList = [...info.fileList];
|
||||
file6.value = resFileList.map((file) => {
|
||||
if (file.response) {
|
||||
// Component will show file.url as link
|
||||
file.url = file.response.url;
|
||||
}
|
||||
return file;
|
||||
});
|
||||
form.file6 = JSON.stringify(file6.value);
|
||||
};
|
||||
const onFile7 = (info: FileInfo) => {
|
||||
let resFileList = [...info.fileList];
|
||||
file7.value = resFileList.map((file) => {
|
||||
if (file.response) {
|
||||
// Component will show file.url as link
|
||||
file.url = file.response.url;
|
||||
}
|
||||
return file;
|
||||
});
|
||||
form.file7 = JSON.stringify(file7.value);
|
||||
};
|
||||
|
||||
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
|
||||
? updateTowerEquipment
|
||||
: addTowerEquipment;
|
||||
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>
|
||||
@@ -0,0 +1,95 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<QrcodeOutlined />
|
||||
</template>
|
||||
<span>批量生产二维码</span>
|
||||
</a-button>
|
||||
<a-alert type="success" style="margin-left: 105px">
|
||||
<template #icon><smile-outlined /></template>
|
||||
<template #message>
|
||||
<a-space>
|
||||
<span>设备总数:4</span>
|
||||
<span>在用数:1</span>
|
||||
<span>闲置数:1</span>
|
||||
<span>报废数:1</span>
|
||||
<span>转卖数:1</span>
|
||||
<span>注销数:0</span>
|
||||
<span>自有设备:3</span>
|
||||
<span>租赁设备:1</span>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-alert>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { QrcodeOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { TowerEquipmentParam } from '@/api/tower/equipment/model';
|
||||
|
||||
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: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<TowerEquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
name: undefined,
|
||||
keywords: ''
|
||||
});
|
||||
// 下来选项
|
||||
const type = ref('keywords');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
// 日期范围选择
|
||||
// const dateRange = ref<[string, string]>(['', '']);
|
||||
// 状态
|
||||
const status = ref<number>();
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
resetFields();
|
||||
// const [d1, d2] = dateRange.value ?? [];
|
||||
if (type.value == 'keywords') {
|
||||
where.keywords = searchText.value;
|
||||
}
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
// 发布设备
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
const handleStatus = () => {
|
||||
emit('update', status.value);
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
@@ -0,0 +1,281 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="equipmentId"
|
||||
: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>一机一档</a>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 编辑弹窗 -->
|
||||
<EquipmentEdit 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 EquipmentEdit from './components/equipment-edit.vue';
|
||||
import {
|
||||
pageTowerEquipment,
|
||||
removeBatchTowerEquipment,
|
||||
statusBatchTowerEquipment, updateBatchTowerEquipment,
|
||||
updateTowerEquipment
|
||||
} from "@/api/tower/equipment";
|
||||
import {
|
||||
TowerEquipment,
|
||||
TowerEquipmentParam
|
||||
} from '@/api/tower/equipment/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: 'name',
|
||||
key: 'name'
|
||||
},
|
||||
{
|
||||
title: '设备型号',
|
||||
dataIndex: 'model',
|
||||
key: 'model'
|
||||
},
|
||||
{
|
||||
title: '制造厂商',
|
||||
dataIndex: 'manufactor',
|
||||
key: 'manufactor'
|
||||
},
|
||||
{
|
||||
title: '当前位置',
|
||||
dataIndex: 'currentLocation',
|
||||
key: 'currentLocation'
|
||||
},
|
||||
{
|
||||
title: '产权单位(个人)',
|
||||
dataIndex: 'company',
|
||||
key: 'company'
|
||||
},
|
||||
{
|
||||
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<TowerEquipment[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<TowerEquipment | 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 pageTowerEquipment({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: TowerEquipmentParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: TowerEquipment) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 批量修改 */
|
||||
const handleStatus = (status) => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
const data = selection.value.map((d) => {
|
||||
return {
|
||||
equipmentId: d.equipmentId,
|
||||
status
|
||||
};
|
||||
});
|
||||
console.log(data);
|
||||
updateBatchTowerEquipment(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);
|
||||
removeBatchTowerEquipment(selection.value.map((d) => d.equipmentId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: TowerEquipment) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'TowerEquipmentIndex'
|
||||
};
|
||||
</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