提交 848c57ec 编写于 作者: 刘英杰's avatar 刘英杰

保存

上级 b6562ed5
<template>
<div style="width: 100%; height: 100%">
<!-- 右侧人员列表 -->
<div class="role-content">
<!-- 搜索和工具栏 -->
<div class="role-toolbar">
<initForm
ref="searchFormRef"
:searchCondList="init.searchList"
@on-submit="handleSearch"
@on-reset="handleReset"
/>
<!-- 表格工具栏 -->
<div class="operation-bar">
<Button type="primary" @click="handleAdd">
<Icon type="md-add"/>
新增设备
</Button>
<!-- <Button class="ivu-ml-8" @click="handleImport"><Icon type="md-cloud-upload" /> 导入设备</Button>-->
<!-- <Button-->
<!-- class="ivu-ml-8"-->
<!-- @click="handleDownloadTemplate"-->
<!-- :loading="init.downloadLoading"-->
<!-- ><Icon type="md-download" /> 下载模板</Button-->
<!-- >-->
<!-- <Button class="ivu-ml-8" @click="handleExport"><Icon type="md-download" /> 导出数据</Button>-->
</div>
</div>
<!-- 设备表格 -->
<Table :loading="loading" :columns="userColumns" :data="userList" border>
<template #action="{ row }">
<div class="action-btns" style="display: flex; align-items: center">
<a href="javascript:;" @click="handleSubmit(row, 'borrow')"
>借用记录</a
>
<Divider type="vertical"/>
<a
href="javascript:;"
@click="handleSubmit(row, 'equipmentBorrowingStatus')"
>借用状态</a
>
<Divider type="vertical"/>
<a href="javascript:;" @click="outbound(row)">出库</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="inbound(row)">归还</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="showRepair(row)">报修</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="edit(row)">编辑</a>
<Divider type="vertical"/>
<Poptip
confirm
transfer
title="确定要删除该设备吗?"
@on-ok="handleSubmit(row, 'delete')"
>
<a href="javascript:;">删除</a>
</Poptip>
</div>
</template>
<template #duty_person="{ row }">
<Tag
color="blue"
v-for="(item, index) in row.duty_persons"
:key="index"
>
{{ item.name }}
</Tag>
</template>
<template #status="{ row }">
<Tag :color="['success', 'blue', 'warning'][Number(row.status)]">
{{ ["空闲", "使用中", "维修中"][Number(row.status)] }}
</Tag>
</template>
<template #need_dept_audit="{ row }">
{{ row.need_dept_audit === 1 ? "需要" : "不需要" }}
</template>
<template #need_worth_audit="{ row }">
{{ row.need_worth_audit === 1 ? "需要" : "不需要" }}
</template>
</Table>
<!-- 分页 -->
<div class="pagination">
<Page
:key="init.pageKey"
:total="init.devices.total"
:current="init.devices.params.page_index"
:page-size="init.devices.params.page_size"
show-elevator
:show-sizer="true"
show-total
:page-size-opts="[10, 20, 50, 100]"
:transfer="true"
@on-change="handlePageChange"
@on-page-size-change="handlePageSizeChange"
/>
</div>
</div>
</div>
<!-- 添加设备对话框 -->
<Modal
v-model="init.devices.show"
title="设备信息"
width="700"
>
<Form
ref="deviceForm"
:model="init.devices.formData"
:rules="init.devices.rules"
:label-width="100"
>
<Row :gutter="16">
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备编号" prop="unique_id1">
<Input
v-model="init.devices.formData.unique_id"
placeholder="请输入设备编号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备名称" prop="name">
<Input
v-model="init.devices.formData.name"
placeholder="请输入设备名称"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备型号" prop="model1">
<Input
v-model="init.devices.formData.model"
placeholder="请输入设备型号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="生产厂家" prop="manufacturer_name1">
<Input
v-model="init.devices.formData.manufacturer_name"
placeholder="请输入生产厂家"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="采购日期" prop="purchase_date">
<DatePicker
v-model="init.devices.formData.purchase_date"
type="datetime"
placeholder="选择采购日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="入库时间" prop="storage_date">
<DatePicker
v-model="init.devices.formData.storage_date"
type="datetime"
placeholder="选择入库时间"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="责任人" prop="duty_persons">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.devices.formData.duty_persons"
:key="index"
closable
@on-close="init.devices.formData.duty_persons.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('入库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="存放位置" prop="storage_location">
<Input
v-model="init.devices.formData.storage_location"
placeholder="请输入存放位置"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备分类" prop="classification_id">
<TreeSelect
v-model="init.devices.formData.classification_id"
placeholder="请选择设备分类"
:data="init.devices.treeData"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="维护周期" prop="maintenance_cycle">
<Input
v-model="init.devices.formData.maintenance_cycle"
style="width: 60%"
clearable
/>
<Select
v-model="init.devices.formData.manitenance_cycle_unit"
style="width: 35%; margin-left: 5%"
>
<Option value="1">年</Option>
<Option value="2">月</Option>
<Option value="3">天</Option>
</Select>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备状态" prop="status">
<Select v-model="init.devices.formData.status" clearable>
<Option value="0">空闲</Option>
<Option value="1">使用中</Option>
<Option value="2">维修中</Option>
</Select>
</FormItem>
</Col>
<Col v-if="init.devices.flag == 'edit'" :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="上次维护日期" prop="last_time_maintenance_date">
<DatePicker
v-model="init.devices.formData.last_time_maintenance_date"
type="datetime"
placeholder="选择上次维护日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="部门审核" prop="need_dept_audit">
<Switch
v-model="init.devices.formData.need_dept_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="价值审核" prop="need_worth_audit">
<Switch
v-model="init.devices.formData.need_worth_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.devices.show = false">取消</Button>
<Button type="primary" @click="handleSubmitDevice">确定</Button>
</template>
</Modal>
<!-- 借用记录对话框 -->
<Modal
v-model="init.borrowRecord.show"
title="借用记录"
width="60%"
:mask-closable="false"
>
<Table
:loading="init.borrowRecord.loading"
:columns="init.borrowRecordColumns"
:data="init.borrowRecord.list"
border
>
<template #status="{ row }">
<Tag
:color="
row.status === 1
? 'success'
: row.status === 2
? 'warning'
: 'default'
"
>
{{
row.status === 1 ? "已归还" : row.status === 2 ? "使用中" : "待审核"
}}
</Tag>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:total="init.borrowRecord.total"
:current="init.borrowRecord.params.page_index"
:page-size="init.borrowRecord.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleBorrowRecordPageChange"
@on-page-size-change="handleBorrowRecordPageSizeChange"
/>
</div>
<template #footer>
<Button @click="init.borrowRecord.show = false">关闭</Button>
</template>
</Modal>
<!-- 添加用户对话框 -->
<Modal
:styles="{top:'10px'}"
v-model="addUserModal.show"
:title="'人员数据'"
width="700"
:mask-closable="false"
>
<div class="add-user-search">
<Input
v-model="addUserModal.keyword"
placeholder="输入姓名或工号搜索用户"
search
clearable
enter-button
@on-search="searchAvailableUsers"
/>
<Button v-if="addUserModal.flag == '入库责任人'" style="margin-left: 10px" type="primary" @click="batchAddUser"
>批量添加
</Button
>
</div>
<!-- 负责部门选择 - 只在角色为责任部门时显示 -->
<div class="duty-dept-select" v-if="false">
<Form>
<FormItem
label="负责部门"
:label-width="80"
:rules="[
{
required: true,
type: 'array',
min: 1,
message: '请至少选择一个负责部门',
trigger: 'change',
},
]"
>
<Select
v-model="addUserModal.dutyDepts"
multiple
filterable
placeholder="请选择负责部门(可多选)"
style="width: 100%"
>
<Option
v-for="dept in departmentOptions"
:key="dept.value"
:value="dept.value"
>
{{ dept.label }}
</Option>
</Select>
</FormItem>
</Form>
</div>
<!-- 可添加用户列表 -->
<Table
@on-selection-change="onSelectionChange"
:loading="addUserModal.loading"
:columns="addUserModal.availableUserColumns"
:data="addUserModal.userList"
border
>
<!-- 照片列 -->
<template #avatar="{ row }">
<div class="user-avatar">
<Avatar v-if="row.photo" size="large" :src="row.photo"/>
<Avatar v-else icon="ios-person" size="large"/>
</div>
</template>
<!-- 操作列 -->
<template #action="{ row }">
<div class="action-btns">
<Button type="primary" size="small" @click="confirmAddUser(row)"
>添加
</Button
>
</div>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:key="addUserModal.pageKey"
:total="addUserModal.total"
:current="addUserModal.params.page_index"
:page-size="addUserModal.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleAddUserPageChange"
@on-page-size-change="handleAddUserPageSizeChange"
/>
</div>
<template #footer>
<Button @click="addUserModal.show = false">关闭</Button>
</template>
</Modal>
<!-- 出库对话框 -->
<Modal
v-model="init.outBound.show"
:title="init.outBound.title+'-设备出库'"
width="500"
>
<Form
ref="outBoundForm"
:model="init.outBound.formDate"
:rules="init.outBound.rules"
:label-width="100"
>
<FormItem label="借用人" prop="lender_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.lender_tids"
:key="index"
closable
@on-close="init.outBound.lender_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库借用人')"
>
添加借用人
</Button>
</div>
</FormItem>
<FormItem label="预计归还日期" prop="plan_end_date">
<DatePicker
v-model="init.outBound.formDate.plan_end_date"
type="datetime"
placeholder="选择预计归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库日期" prop="out_date">
<DatePicker
v-model="init.outBound.formDate.out_date"
type="datetime"
placeholder="选择出库日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库责任人" prop="duty_person_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.duty_person_tids"
:key="index"
closable
@on-close="init.outBound.duty_person_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
<FormItem label="备注" prop="application_remark">
<Input
v-model="init.outBound.formDate.application_remark"
type="textarea"
placeholder="请输入备注信息"
:rows="4"
/>
</FormItem>
</Form>
<template #footer>
<Button @click="init.outBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.outBound.formDate,'设备出库')">确定</Button>
</template>
</Modal>
<!-- 设备归还入库 -->
<Modal
v-model="init.inBound.show"
:title="init.inBound.title+'-归还入库'"
width="500"
>
<Form
ref="inBoundForm"
:model="init.inBound.formDate"
:rules="init.inBound.rules"
:label-width="100"
>
<FormItem label="归还日期" prop="return_date">
<DatePicker
v-model="init.inBound.formDate.return_date"
type="datetime"
placeholder="选择归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="归还人" prop="returnee_ids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.inBound.returnee_ids"
:key="index"
closable
@on-close="init.inBound.returnee_ids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('归还人')"
>
添加归还人
</Button>
</div>
</FormItem>
</Form>
<template #footer>
<Button @click="init.inBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.inBound.formDate,'设备归还')">确定</Button>
</template>
</Modal>
<!--设备借用状态-->
<Drawer
:draggable="true"
:styles="{padding: '0px'}"
v-model="init.equipmentBorrowingStatus.show"
:title="init.equipmentBorrowingStatus.title+'-借用状态'"
width="70%"
placement="right"
>
<div style="width: 100%;height: calc(100% - 60px);padding: 16px">
<DatePicker
v-if="false"
v-model="init.equipmentBorrowingStatus.params.month"
type="month"
placeholder="选择月份"
style="width: 200px; margin-bottom: 16px;"
@on-change="handleSubmit(init.equipmentBorrowingStatus.itemData,'equipmentBorrowingStatus')"
/>
<Calendar
:loading="init.equipmentBorrowingStatus.loading"
v-model="init.equipmentBorrowingStatus.params.month"
hide-type
@on-change="changeClendar"
>
<template #month="{date, data}">
<div>
<Badge
:status="['','error','warning'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
:text="['','占用中','维修中'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
v-if="init.equipmentBorrowingStatus.list.map(cur=>cur.occupy_date).includes(data.day) "/>
<Badge status="success" text="空闲" v-else/>
</div>
</template>
</Calendar>
</div>
<div
style="width: 100%;height: 60px;display: flex;justify-content: center;align-items: center;box-shadow: 0 0 8px darkgray">
<Button style="width: 150px" @click="init.equipmentBorrowingStatus.show =false">关闭</Button>
</div>
</Drawer>
<!-- 设备报修表单 -->
<Modal
v-model="init.repair.show"
:title="init.repair.title +'-设备报修'"
:mask-closable="false"
:closable="true"
width="50%"
@on-cancel="init.repair.show = false"
>
<Form
:model="init.repair.formData"
:rules="init.repair.rules"
ref="repairForm"
label-width="100"
>
<Row :gutter="16" type="flex" style="flex-wrap: wrap;">
<!-- 报修人 -->
<Col :xs="24" :sm="12">
<FormItem label="报修人" prop="name">
<Input
:disabled="true"
v-model="init.repair.formData.name"
placeholder="请输入报修人"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 联系方式 -->
<Col :xs="24" :sm="12">
<FormItem label="联系方式" prop="phone">
<Input
v-model="init.repair.formData.phone"
placeholder="请输入联系电话"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 报修区域 -->
<Col :xs="24" :sm="12">
<FormItem label="报修区域" prop="area_id">
<TreeSelect
v-model="init.repair.formData.area_id"
:data="init.repair.areaTree"
placeholder="请选择报修区域"
style="width: 100%;"
:clearable="true"
@on-change="handleAreaChange"
/>
</FormItem>
</Col>
<!-- 详细地址 -->
<Col :xs="24" :sm="12">
<FormItem label="详细地址" prop="areaDetail">
<Input
v-model="init.repair.formData.areaDetail"
placeholder="请输入报修详细地址"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修项目 -->
<Col :xs="24" :sm="12">
<FormItem label="报修项目" prop="item_id">
<div style="display: flex;">
<TreeSelect
:disabled="true"
v-model="init.repair.formData.item_id"
:data="init.repair.itemTree"
placeholder="请选择报修项目"
style="width: 100%;"
:clearable="true"
/>
<Spin v-if="init.repair.loading"></Spin>
</div>
</FormItem>
</Col>
<!-- 报修详细 -->
<Col :xs="24" :sm="12">
<FormItem label="报修详细" prop="itemDetail">
<Input
v-model="init.repair.formData.itemDetail"
placeholder="请输入报修详细"
maxlength="200"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修附件 -->
<Col :xs="24" :sm="12">
<FormItem label="报修附件" prop="file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '报修附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.file_list = init.repair.formData.file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
<!-- 钥匙备注 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙备注" prop="key_remark">
<Input
v-model="init.repair.formData.key_remark"
placeholder="请输入钥匙备注"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 钥匙附件 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙附件" prop="key_file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '钥匙附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.key_file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.key_file_list = init.repair.formData.key_file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.repair.show = false">取消</Button>
<Button type="primary" @click="handleRepairSubmit">提交报修</Button>
</template>
</Modal>
</template>
<script setup>
import {deviceProjectStore} from '@/store/deviceProjectStoree'
import initForm from "@/components/initForm";
import {ref, onMounted, reactive, computed} from "vue";
import {
Badge, Button,
Calendar,
DatePicker, Drawer,
FormItem,
Message,
Modal,
Page,
Row,
Switch,
Tag, TreeSelect, Upload,
} from "view-ui-plus";
import * as api from "@/api/allApi/controller/index";
import * as hooks from "@/hook/index";
import * as bxApi from '@/api/logisticsApi/index'
import dayjs from "dayjs";
import {setAreaItemStatus, submitRepair} from "@/api/logisticsApi/index";
// 角色列表
const roleList = ref([
{
role_type: 0,
role_name: "设备审核",
count: 14,
},
{
role_type: 1,
role_name: "耗材审核",
count: 4,
},
]);
// 表单值
const formValues = ref({});
// 用户表格列定义
const userColumns = computed(() => {
const columns = [
{
title: "#",
type: "index",
width: 60,
},
{
title: "设备编号",
key: "unique_id",
minWidth: 150,
},
{
title: "设备名称",
key: "name",
minWidth: 150,
},
{
title: "设备型号",
key: "model",
minWidth: 150,
},
{
title: "设备分类",
key: "classification_name",
minWidth: 150,
},
{
title: "生产厂家",
key: "manufacturer_name",
minWidth: 150,
},
{
title: "采购日期",
key: "purchase_date",
minWidth: 150,
},
{
title: "入库时间",
key: "storage_date",
width: 150,
},
{
title: "责任人",
slot: "duty_person",
minWidth: 160,
},
{
title: "存放位置",
key: "storage_location",
minWidth: 150,
},
{
title: "维护周期",
key: "maintenance_cycle",
minWidth: 150,
render: (h, params) => {
return h('span', params.row.maintenance_cycle + ['', '年', '月', '天'][params.row.manitenance_cycle_unit])
},
},
{
title: "设备状态",
slot: "status",
minWidth: 150,
},
{
title: "部门审核",
key: "need_dept_audit",
minWidth: 100,
slot: "need_dept_audit",
},
{
title: "价值审核",
key: "need_worth_audit",
minWidth: 100,
slot: "need_worth_audit",
},
];
// 添加操作列
columns.push({
title: "操作",
slot: "action",
width: 420,
align: "center",
fixed: "right",
});
return columns;
});
// 加载状态
const loading = ref(false);
// 用户列表
const userList = ref([]);
const init = reactive({
pageKey:'',
//报修
repair: {
loading: true,
show: false,
// 表单校验规则,确保用户输入的有效性
rules: {
name: [
{required: true, message: '请输入报修人姓名', trigger: 'change'}
],
area_id: [
{required: true, message: '请选择报修区域', trigger: 'change'}
],
item_id: [
{required: true, message: '请选择报修项目', trigger: 'change'}
],
phone: [
{required: true, message: '请输入联系电话', trigger: 'blur'},
{pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号', trigger: 'blur'}
],
areaDetail: [
{required: true, message: '请输入详细地址', trigger: 'blur'}
],
},
formData: {
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
},
areaTree: [],
itemTree: [],
},
// 借用记录相关数据
equipmentBorrowingStatus: {
title: '',
itemData: {},
show: false,
loading: false,
params: {
month: dayjs().format('YYYY-MM'),
equipment_id: "",
},
list: []
},
borrowRecord: {
itemData: {},
params: {
page_index: 1,
page_size: 10,
equipment_id: "",
},
show: false,
loading: false,
list: [],
total: 0,
pageIndex: 1,
pageSize: 10,
},
// 借用记录表格列定义
borrowRecordColumns: [
{
title: "设备名称",
key: "equipment_name",
minWidth: 100,
},
{
title: "责任人",
key: "duty_person_name",
minWidth: 100,
},
{
title: "责任人工号",
key: "duty_person_card",
minWidth: 120,
},
{
title: "借出人",
key: "lender_name",
minWidth: 100,
},
{
title: "借出人工号",
key: "lender_card",
minWidth: 120,
},
{
title: "出入库类型",
key: "storage_status_shift_type",
minWidth: 120,
},
{
title: "出入库日期",
key: "storage_status_shift_date",
minWidth: 120,
},
{
title: "备注",
key: "application_remark",
minWidth: 150,
},
],
searchList: [
{
label: "设备名称",
code: "equipment_name",
search_type: "input",
is_must: 0,
option_list: null,
option_cascade_list: null,
},
{
label: "设备分类",
code: "classification_id",
search_type: "treeselect",
is_must: 0,
options: [],
},
{
label: "设备状态",
code: "status",
search_type: "select",
is_must: 0,
option_list: [
{
label: "空闲",
value: "0",
},
{
label: "使用中",
value: "1",
},
{
label: "维修中",
value: "2",
},
],
option_cascade_list: null,
},
],
inBound: {
show: false,
returnee_ids: [],
formDate: {
equipment_id: '', // 设备id
return_date: '', // 归还日期
returnee_id: '', // 归还人tid
},
rules: {
return_date: [
{
required: true,
type: "date",
message: "请选择归还日期",
trigger: "change"
}
],
returnee_ids: [
{
required: true,
type: "array",
message: "请添加一位归还人",
trigger: "change",
validator: (rule, value, callback) => {
if (!init.inBound.returnee_ids || init.inBound.returnee_ids.length === 0) {
callback(new Error("请添加一位归还人"));
} else {
callback();
}
}
}
]
},
loading: false,
list: [],
},
outBound: {
title: '',
show: false,
duty_person_tids: [],
lender_tids: [],
formDate: {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
},
rules: {
plan_end_date: [
{
required: true,
type: "date",
message: "请选择预计归还日期",
trigger: "change"
}
],
out_date: [
{
required: true,
type: "date",
message: "请选择出库日期",
trigger: "change"
}
],
duty_person_tids: [
{
required: true,
type: "array",
message: "请添加一位出库责任人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.duty_person_tids.length === 0) {
callback(new Error("请添加一位出库责任人"))
} else {
callback()
}
}
}
],
lender_tids: [
{
required: true,
type: "array",
message: "请添加一位借用人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.lender_tids.length === 0) {
callback(new Error("请添加一位借用人"))
} else {
callback()
}
}
}
],
application_remark: [
{
required: false,
type: "string",
message: "请输入备注信息",
trigger: "blur"
}
]
},
loading: false,
list: [],
},
devices: {
flag: "add",
total: 0,
params: {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
},
show: false,
treeData: [],
formData: {
name: "",
model: "",
unique_id: "",
manufacturer_name: "",
purchase_date: "",
storage_date: "",
duty_person: "",
duty_persons: [],
storage_location: "",
maintenance_cycle: 0,
manitenance_cycle_unit: "1",
classification_id: "",
last_time_maintenance_date: "",
status: "0",
need_dept_audit: 0,
need_worth_audit: 0,
},
rules: {
unique_id: [
{
required: true,
type: "string",
message: "请输入设备编号",
trigger: "blur",
},
],
name: [
{
required: true,
type: "string",
message: "请输入设备名称",
trigger: "blur",
},
],
model: [
{
required: true,
type: "string",
message: "请输入设备型号",
trigger: "blur",
},
],
manufacturer_name: [
{
required: true,
type: "string",
message: "请输入生产厂家",
trigger: "blur",
},
],
purchase_date: [
{
required: true,
type: "date",
message: "请选择采购日期",
trigger: "change",
},
],
storage_date: [
{
required: true,
type: "date",
message: "请选择入库时间",
trigger: "change",
},
],
duty_persons: [
{
required: true,
type: "array",
min: 1,
message: "请输入责任人",
trigger: "change",
},
],
storage_location: [
{
required: true,
type: "string",
message: "请输入存放位置",
trigger: "blur",
},
],
maintenance_cycle: [
{
required: true,
type: "string",
message: "请输入维护周期",
trigger: "change",
},
],
manitenance_cycle_unit: [
{
required: true,
type: "number",
message: "请选择周期单位",
trigger: "change",
},
],
classification_id: [
{
required: true,
type: "string",
message: "请选择设备分类",
trigger: "change",
},
],
last_time_maintenance_date: [
{
required: true,
type: "date",
message: "请选择上次维护日期",
trigger: "change",
},
],
status: [
{
required: true,
type: "string",
message: "请选择设备状态",
trigger: "change",
},
],
},
},
downloadLoading: false,
});
/**
* 设备借用记录
* */
// 分页改变
const handleBorrowRecordPageChange = (page) => {
init.borrowRecord.params.page_index = page;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
// 页大小改变
const handleBorrowRecordPageSizeChange = (size) => {
init.borrowRecord.params.page_size = size;
init.borrowRecord.params.page_index = 1;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
/**
* 设备借用记录
* */
/**
* 设备
* */
//切换日历视图
function changeClendar(e) {
init.equipmentBorrowingStatus.params.month = dayjs(e).format('YYYY-MM')
handleSubmit(init.equipmentBorrowingStatus.itemData, 'equipmentBorrowingStatus')
}
const outBoundForm = ref()
const inBoundForm = ref()
//提交操作
function handleSubmit(row, type) {
const strategy = {
//借用状态
equipmentBorrowingStatus: () => {
init.equipmentBorrowingStatus.title = row.name
init.equipmentBorrowingStatus.itemData = row;
init.equipmentBorrowingStatus.show = true;
init.equipmentBorrowingStatus.loading = true;
api
.getApiEquipmentEquipmentCalendar({
...init.equipmentBorrowingStatus.params,
equipment_id: row.id,
})
.then((res) => {
init.equipmentBorrowingStatus.list = res.response;
init.equipmentBorrowingStatus.loading = false;
});
},
//借用记录
borrow: () => {
init.borrowRecord.itemData = row;
init.borrowRecord.show = true;
init.borrowRecord.loading = true;
api
.getApiEquipmentEquipmentLendLsit({
...init.borrowRecord.params,
equipment_id: row.id,
})
.then((res) => {
init.borrowRecord.list = res.response.data;
init.borrowRecord.total = res.response.data_count;
init.borrowRecord.loading = false;
});
},
//删除设备
delete: () => {
console.log("删除");
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentDelete({
equipment_id: row.id,
})
.then(
(res) => {
let responseInfo = res.response
// {
// "euqipment_id": "1938161312374853632",
// "repair_item_id": 21107
// }
///api/Repair/DeleteMiddleItem
// logistics/api/repair/Area/MoidfiyStatus 细项停用0/启用1
// {"id":[1070101],"use_flag":1}
/**
* 报修细项同步
* */
//变更报修系统细项
bxApi.setAreaItemStatus({"id":[responseInfo.repair_item_id],"use_flag":0}).then(_res=>{
//删除中间表对应关系
api.getApiRepairDeleteMiddleItem({classification_equipment_id: responseInfo.euqipment_id})
})
/**
* 报修细项同步
* */
EquipmentList();
return res;
},
"提交中...",
false
);
});
},
'设备归还': () => {
console.log("🚀🚀🚀,", init.inBound.formDate)
inBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentReturn({
...init.inBound.formDate,
returnee_id: init.inBound.returnee_ids
.map((cur) => cur.tid)
.join(";"),
return_date: dayjs(row.return_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.inBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
},
'设备出库': () => {
outBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentOut({
...init.outBound.formDate,
equipment_id: row.equipment_id,
duty_person_tid: init.outBound.duty_person_tids
.map((cur) => cur.tid)
.join(";"),
lender_tid: init.outBound.lender_tids
.map((cur) => cur.tid)
.join(";"),
plan_end_date: dayjs(row.plan_end_date).format(
"YYYY-MM-DD HH:mm:ss"
),
out_date: dayjs(row.out_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.outBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
}
};
strategy[type]();
}
//出库
function outbound(row) {
init.outBound.title = row.name
init.outBound.formDate = {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
}
init.outBound.duty_person_tids = [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
]
init.outBound.lender_tids = []
init.outBound.formDate = {
...init.outBound.formDate,
equipment_id: row.id
};
init.outBound.show = true;
init.outBound.loading = true;
outBoundForm.value.resetFields()
}
//入库归还
function inbound(row) {
init.inBound.title = row.name
init.inBound.returnee_ids = []
init.inBound.formDate = {}
init.inBound.formDate = {
...init.inBound.formDate,
equipment_id: row.id
};
init.inBound.show = true;
init.inBound.loading = true;
inBoundForm.value.resetFields()
console.log("🚀🚀🚀,", init.inBound.formDate)
}
//获取设备编辑数据
function edit(row) {
console.log(row)
init.devices.show = true;
init.devices.loading = true;
init.devices.formData = {
...init.devices.formData,
...row,
status: String(row.status),
maintenance_cycle: String(row.maintenance_cycle),
manitenance_cycle_unit: String(row.manitenance_cycle_unit),
duty_person: row.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(row.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(row.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
row.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
};
init.devices.flag = "edit";
}
// 获取设备列表
const EquipmentList = async () => {
try {
loading.value = true;
// TODO: 调用接口获取角色用户列表
api.postApiEquipmentEquipmentList(init.devices.params).then((res) => {
userList.value = res.response.data;
init.devices.total = res.response.data_count;
loading.value = false;
});
} catch (error) {
loading.value = false;
Message.error("加载用户列表失败");
}
};
// 搜索用户
const handleSearch = (value) => {
init.devices.params = {
...init.devices.params,
...value,
page_index: 1,
page_size: 10,
};
EquipmentList();
};
// 重置
const handleReset = () => {
init.devices.params = {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
};
init.pageKey = Date.now();
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
searchFormRef.value.searchCondObj.classification_id = cur.options[0].id;
init.devices.params.classification_id = cur.options[0].id;
}
});
EquipmentList();
};
// 分页改变
const handlePageChange = (page) => {
init.devices.params.page_index = page;
EquipmentList();
};
// 页大小改变
const handlePageSizeChange = (size) => {
init.devices.params.page_size = size;
init.devices.params.page_index = 1;
EquipmentList();
};
// 添加设备
const handleAdd = () => {
init.devices.flag = 'add'
init.devices.formData = {
"name": "",
"model": "",
"unique_id": "",
"manufacturer_name": "",
"purchase_date": "",
"storage_date": "",
"duty_person": "",
"duty_persons": [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
],
"storage_location": "",
"maintenance_cycle": '0',
"manitenance_cycle_unit": '1',
"classification_id": "",
"last_time_maintenance_date": "",
"status": '0',
"need_dept_audit": 0,
"need_worth_audit": 0
};
init.devices.show = true;
deviceForm.value.resetFields();
};
// 下载模板
const handleDownloadTemplate = async () => {
try {
init.downloadLoading = true;
// TODO: 实现下载模板功能
init.downloadLoading = false;
} catch (error) {
init.downloadLoading = false;
Message.error("下载模板失败");
}
};
const deviceForm = ref();
// 删除用户
const handleRemoveUser = async (row) => {
try {
// TODO: 调用接口删除用户
Message.success("删除成功");
EquipmentList();
} catch (error) {
Message.error("删除失败");
}
};
// 提交设备表单
const handleSubmitDevice = () => {
const strategy = {
add: () => {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentAdd({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
// last_time_maintenance_date: dayjs(
// init.devices.formData.last_time_maintenance_date
// ).format("YYYY-MM-DD HH:mm:ss"),
})
.then(
(res) => {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
const responseInfo = res.response
//获取细项id
bxApi.GetId({parent_id: responseInfo.classification_reparir_item}).then((getAreaChildren) => {
//提交细项
bxApi.addItem({
"parent_id": responseInfo.classification_reparir_item,
"id": getAreaChildren.response,
"name": responseInfo.equipment_name
}).then(_res => {
//双系统信息,同步到中间表
api.getApiRepairAddMiddleItem({
classification_equipment_id: responseInfo.equipment_id,
repair_item: getAreaChildren.response
})
})
})
/**
* 报修细项同步
* */
return res;
},
"提交中...",
false
);
});
},
edit: () => {
console.log(init.devices.formData)
hooks.myEncapsulationFunction(() => {
return api.postApiEquipmentEquipmentUpdate({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
init.devices.formData.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
}).then((res) => {
if (res.code === 1) {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
//获取细项id
api.getApiRepairQueryById({classification_equipment_id: init.devices.formData.id}).then((getAreaChildren) => {
//提交细项
bxApi.modifyItem({
"id": getAreaChildren.response.repair_item_id,
"name": init.devices.formData.name
})
})
/**
* 报修细项同步
* */
return res;
}
});
}, false, '提交中...');
},
};
deviceForm.value.validate((valid) => {
if (valid) {
strategy[init.devices.flag]();
}
});
};
// 树格式化
function treeFormat(arr) {
return arr.map((a) => {
if (a.children && a.children.length != 0) {
a.children = treeFormat(a.children);
}
return {
...a,
title: a.name,
value: a.id,
expand: true,
selected: false,
};
});
}
const searchFormRef = ref()
function getTreeData() {
return api.getApiEquipmentGetEquipmentClassificationTree().then((res) => {
init.devices.treeData = treeFormat(res.response);
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
cur.options = treeFormat(res.response);
searchFormRef.value.searchCondObj.classification_id = res.response[0].id;
init.devices.params.classification_id = res.response[0].id;
}
});
return res
});
}
/**人员选择器 */
// 人员选择器》添加用户对话框
const addUserModal = reactive({
flag: '',
pageKey: '',
params: {
page_index: 1,
page_size: 10,
query: "",
},
total: 0,
show: false,
loading: false,
keyword: "",
batchUserList: [],
userList: [],
dutyDepts: [],
availableUserColumns: [
// {
// align: "center",
// type: "selection",
// width: 60,
// },
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
],
});
// 部门列表
const departmentOptions = ref([]);
// 人员选择器》搜索可添加的用户
const searchAvailableUsers = async () => {
loadRoleUsers();
};
//弹出人员选择器
function showAddUser(key) {
addUserModal.flag = key
setPeopleColumnsData()
addUserModal.params = {
page_index: 1,
page_size: 10,
query: "",
}
addUserModal.pageKey = new Date();
addUserModal.show = true;
addUserModal.batchUserList = [];
loadRoleUsers()
}
//批量提交选中人员
function batchAddUser() {
const strategy = {
//新增设备 批量
'入库责任人': () => {
const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
let data = []
addUserModal.batchUserList.forEach((cur, index) => {
//不包含
if (!dataId.includes(cur.tid)) {
data.push(cur)
}
})
init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
addUserModal.show = false;
},
// '出库责任人':()=>{
// const dataId = init.outBound.duty_person_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.duty_person_tids = init.outBound.duty_person_tids.concat(data);
// addUserModal.show = false;
// },
// '出库借用人':()=>{
// const dataId = init.outBound.lender_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.lender_tids = init.outBound.lender_tids.concat(data);
// addUserModal.show = false;
// },
// '归还人':()=>{
// const dataId = init.inBound.returnee_ids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.inBound.returnee_ids = init.inBound.returnee_ids.concat(data);
// addUserModal.show = false;
// },
}
strategy[addUserModal.flag]()
}
//选中人员
function onSelectionChange(e) {
console.log('e', e)
addUserModal.batchUserList = e;
}
// 人员选择器》确认添加用户
const confirmAddUser = async (user) => {
console.log("🚀🚀🚀,", user)
const strategy = {
// '入库责任人':()=>{
// const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
// console.log("🚀🚀111🚀,", init.devices.formData.duty_persons)
// addUserModal.show = false;
// },
'出库责任人': () => {
init.outBound.duty_person_tids = [user];
addUserModal.show = false;
},
'出库借用人': () => {
init.outBound.lender_tids = [user];
addUserModal.show = false;
},
'归还人': () => {
init.inBound.returnee_ids = [user];
addUserModal.show = false;
},
}
strategy[addUserModal.flag]()
};
// 加载人员选择器用户
const loadRoleUsers = () => {
addUserModal.loading = true;
try {
api
.getApiCommonUserSelect({
...addUserModal.params,
query: addUserModal.keyword,
})
.then((res) => {
addUserModal.userList = res.response.data || [];
addUserModal.total = res.response.data_count;
})
.catch((error) => {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
})
.finally(() => {
addUserModal.loading = false;
});
} catch (error) {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
addUserModal.loading = false;
}
};
// 分页改变
const handleAddUserPageChange = (page) => {
addUserModal.params.page_index = page;
loadRoleUsers()
};
// 页大小改变
const handleAddUserPageSizeChange = (size) => {
addUserModal.params.page_size = size;
addUserModal.params.page_index = 1;
loadRoleUsers()
};
//配置人员列表列数据
function setPeopleColumnsData() {
function name() {
addUserModal.availableUserColumns = [
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
]
}
const strategy = {
'入库责任人': () => {
addUserModal.availableUserColumns = [
{
align: "center",
type: "selection",
width: 60,
},
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
]
},
'出库责任人': () => name(),
'出库借用人': () => name(),
'归还人': () => name(),
}
strategy[addUserModal.flag]()
}
/**人员选择器 */
/**
* 设备报修
* */
//显示报修
function showRepair(row) {
getRepairAreaTree()
getRepairItemTree()
init.repair.formData ={
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
}
init.repair.title = row.name
init.repair.formData.name = deviceProjectStore.state.userInfo.name + '(' + deviceProjectStore.state.userInfo.card + ')'
init.repair.show = true
repairForm.value.resetFields()
init.repair.loading = true
//获取报修系统细项id
api.getApiRepairQueryById({classification_equipment_id: row.id}).then(res => {
init.repair.formData.item_id = String(res.response.repair_item_id)
}).finally(() => {
init.repair.loading = false
})
}
//遍历树形结构
function traverseTree(Array) {
return Array.map(item => {
if (item.children && item.children.length > 0) item.children = traverseTree(item.children)
return {
...item,
value: item.key
}
})
}
//获取报修区域
function getRepairAreaTree() {
bxApi.getRepairAreaTree().then(res => {
init.repair.areaTree = traverseTree(res.response)
})
}
//获取报修项目
function getRepairItemTree() {
bxApi.getRepairItemTree().then(res => {
init.repair.itemTree = traverseTree(res.response)
})
}
//附件上传
function beforeRepairFileUpload(file, type) {
console.log(file)
let f = new FormData();
f.append('file', file)
hooks.myEncapsulationFunction(() => {
return bxApi.uploadRepairImage({systemType: 0}, f, {headers: {'Content-Type': 'multipart/form-data'}}).then(res => {
if (res.code === 1) {
if (type === '报修附件') {
init.repair.formData.file_list = init.repair.formData.file_list.concat(res.response)
} else {
init.repair.formData.key_file_list = init.repair.formData.key_file_list.concat(res.response)
}
}
return res
})
}, false, '正在上传中...')
return false
}
const repairForm = ref()
//通过节点id,获取节点名称
function getAreaNameById(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.item_text = item.title
})
}
function getAreaNameById2(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.area_text = item.title
})
}
//提交报修
function handleRepairSubmit() {
getAreaNameById(init.repair.formData.item_id, init.repair.itemTree)
getAreaNameById2(init.repair.formData.area_id, init.repair.areaTree)
// console.log(111, {
// ...init.repair.formData,
// key_file_list: init.repair.formData.key_file_list.join(','),
// file_list: init.repair.formData.file_list.join(','),
//
// })
repairForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return bxApi.submitRepair({
...init.repair.formData,
key_file_list: init.repair.formData.key_file_list.map(cur => cur.id).join(','),
file_list: init.repair.formData.file_list.map(cur => cur.id).join(','),
}).then(res => {
//
api.getApiRepairRegisterRepair({
repair_item_id: init.repair.formData.item_id,
repair_out_id: res.response}
).then(()=>{
init.repair.show = false
EquipmentList()
})
return res
})
}, false, '正在提交中...')
}
})
}
/**
* 设备报修
* */
onMounted(() => {
getRepairAreaTree()
getRepairItemTree()
loading.value = true;
getTreeData().then(res => {
EquipmentList();
});
});
</script>
<style scoped>
.role-container {
display: flex;
min-height: calc(100vh - 150px);
/* border: 1px solid #e8eaec; */
border-radius: 4px;
overflow: auto;
gap: 16px;
}
.role-sidebar {
width: 300px;
border-right: 1px solid #e8eaec;
background-color: #fff;
overflow-y: auto;
height: 200px;
}
.role-title {
padding: 16px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #e8eaec;
}
.role-list {
padding: 10px 0;
}
.role-item {
display: flex;
align-items: center;
padding: 12px 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.role-item:hover {
background-color: #f0f0f0;
}
.role-item.active {
background-color: #e8f7ff;
color: #2d8cf0;
}
.role-item-icon {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
color: #fff;
}
.role-admin {
background-color: #2d8cf0;
}
.role-party-office {
background-color: #19be6b;
}
.role-entrance-dept {
background-color: #ff9900;
}
.role-responsible-dept {
background-color: #ed4014;
}
.role-item-info {
flex: 1;
}
.role-name {
font-size: 14px;
margin-bottom: 4px;
}
.role-count {
font-size: 12px;
color: #808695;
}
.role-content {
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
}
.role-toolbar {
height: 100%;
display: flex;
flex-direction: column;
gap: 20px;
top: 0;
background-color: #fff;
z-index: 1;
}
.search-box {
width: 280px;
}
.pagination {
/* margin-top: 16px; */
text-align: center;
position: sticky;
bottom: 0;
background-color: #fff;
z-index: 1;
}
.action-btns {
display: flex;
justify-content: center;
}
.user-avatar {
display: flex;
justify-content: center;
align-items: center;
}
.user-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.add-user-search {
margin-bottom: 16px;
display: flex;
}
.duty-dept-select {
margin-bottom: 16px;
}
</style>
<style lang='less' scoped>
.filelist {
cursor: pointer;
}
.filelist:hover {
color: #1e93ff;
background-color: #f7f7f7;
}
.fileddelete {
cursor: pointer;
margin-left: auto;
}
.fileddelete:hover {
color: red;
transform: scale(1.5);
}
</style>
<template>
<div style="width: 100%; height: 100%">
<!-- 右侧人员列表 -->
<div class="role-content">
<!-- 搜索和工具栏 -->
<div class="role-toolbar">
<initForm
ref="searchFormRef"
:searchCondList="init.searchList"
@on-submit="handleSearch"
@on-reset="handleReset"
/>
<!-- 表格工具栏 -->
<div class="operation-bar">
<Button type="primary" @click="handleAdd">
<Icon type="md-add"/>
新增设备
</Button>
<!-- <Button class="ivu-ml-8" @click="handleImport"><Icon type="md-cloud-upload" /> 导入设备</Button>-->
<!-- <Button-->
<!-- class="ivu-ml-8"-->
<!-- @click="handleDownloadTemplate"-->
<!-- :loading="init.downloadLoading"-->
<!-- ><Icon type="md-download" /> 下载模板</Button-->
<!-- >-->
<!-- <Button class="ivu-ml-8" @click="handleExport"><Icon type="md-download" /> 导出数据</Button>-->
</div>
</div>
<!-- 设备表格 -->
<Table :loading="loading" :columns="userColumns" :data="userList" border>
<template #action="{ row }">
<div class="action-btns" style="display: flex; align-items: center">
<a href="javascript:;" @click="handleSubmit(row, 'borrow')"
>借用记录</a
>
<Divider type="vertical"/>
<a
href="javascript:;"
@click="handleSubmit(row, 'equipmentBorrowingStatus')"
>借用状态</a
>
<Divider type="vertical"/>
<a href="javascript:;" @click="outbound(row)">出库</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="inbound(row)">归还</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="showRepair(row)">报修</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="edit(row)">编辑</a>
<Divider type="vertical"/>
<Poptip
confirm
transfer
title="确定要删除该设备吗?"
@on-ok="handleSubmit(row, 'delete')"
>
<a href="javascript:;">删除</a>
</Poptip>
</div>
</template>
<template #duty_person="{ row }">
<Tag
color="blue"
v-for="(item, index) in row.duty_persons"
:key="index"
>
{{ item.name }}
</Tag>
</template>
<template #status="{ row }">
<Tag :color="['success', 'blue', 'warning'][Number(row.status)]">
{{ ["空闲", "使用中", "维修中"][Number(row.status)] }}
</Tag>
</template>
<template #need_dept_audit="{ row }">
{{ row.need_dept_audit === 1 ? "需要" : "不需要" }}
</template>
<template #need_worth_audit="{ row }">
{{ row.need_worth_audit === 1 ? "需要" : "不需要" }}
</template>
</Table>
<!-- 分页 -->
<div class="pagination">
<Page
:key="init.pageKey"
:total="init.devices.total"
:current="init.devices.params.page_index"
:page-size="init.devices.params.page_size"
show-elevator
:show-sizer="true"
show-total
:page-size-opts="[10, 20, 50, 100]"
:transfer="true"
@on-change="handlePageChange"
@on-page-size-change="handlePageSizeChange"
/>
</div>
</div>
</div>
<!-- 添加设备对话框 -->
<Modal
v-model="init.devices.show"
title="设备信息"
width="700"
>
<Form
ref="deviceForm"
:model="init.devices.formData"
:rules="init.devices.rules"
:label-width="100"
>
<Row :gutter="16">
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备编号" prop="unique_id1">
<Input
v-model="init.devices.formData.unique_id"
placeholder="请输入设备编号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备名称" prop="name">
<Input
v-model="init.devices.formData.name"
placeholder="请输入设备名称"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备型号" prop="model1">
<Input
v-model="init.devices.formData.model"
placeholder="请输入设备型号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="生产厂家" prop="manufacturer_name1">
<Input
v-model="init.devices.formData.manufacturer_name"
placeholder="请输入生产厂家"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="采购日期" prop="purchase_date">
<DatePicker
v-model="init.devices.formData.purchase_date"
type="datetime"
placeholder="选择采购日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="入库时间" prop="storage_date">
<DatePicker
v-model="init.devices.formData.storage_date"
type="datetime"
placeholder="选择入库时间"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="责任人" prop="duty_persons">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.devices.formData.duty_persons"
:key="index"
closable
@on-close="init.devices.formData.duty_persons.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('入库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="存放位置" prop="storage_location">
<Input
v-model="init.devices.formData.storage_location"
placeholder="请输入存放位置"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备分类" prop="classification_id">
<TreeSelect
v-model="init.devices.formData.classification_id"
placeholder="请选择设备分类"
:data="init.devices.treeData"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="维护周期" prop="maintenance_cycle">
<Input
v-model="init.devices.formData.maintenance_cycle"
style="width: 60%"
clearable
/>
<Select
v-model="init.devices.formData.manitenance_cycle_unit"
style="width: 35%; margin-left: 5%"
>
<Option value="1">年</Option>
<Option value="2">月</Option>
<Option value="3">天</Option>
</Select>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备状态" prop="status">
<Select v-model="init.devices.formData.status" clearable>
<Option value="0">空闲</Option>
<Option value="1">使用中</Option>
<Option value="2">维修中</Option>
</Select>
</FormItem>
</Col>
<Col v-if="init.devices.flag == 'edit'" :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="上次维护日期" prop="last_time_maintenance_date">
<DatePicker
v-model="init.devices.formData.last_time_maintenance_date"
type="datetime"
placeholder="选择上次维护日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="部门审核" prop="need_dept_audit">
<Switch
v-model="init.devices.formData.need_dept_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="价值审核" prop="need_worth_audit">
<Switch
v-model="init.devices.formData.need_worth_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.devices.show = false">取消</Button>
<Button type="primary" @click="handleSubmitDevice">确定</Button>
</template>
</Modal>
<!-- 借用记录对话框 -->
<Modal
v-model="init.borrowRecord.show"
title="借用记录"
width="60%"
:mask-closable="false"
>
<Table
:loading="init.borrowRecord.loading"
:columns="init.borrowRecordColumns"
:data="init.borrowRecord.list"
border
>
<template #status="{ row }">
<Tag
:color="
row.status === 1
? 'success'
: row.status === 2
? 'warning'
: 'default'
"
>
{{
row.status === 1 ? "已归还" : row.status === 2 ? "使用中" : "待审核"
}}
</Tag>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:total="init.borrowRecord.total"
:current="init.borrowRecord.params.page_index"
:page-size="init.borrowRecord.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleBorrowRecordPageChange"
@on-page-size-change="handleBorrowRecordPageSizeChange"
/>
</div>
<template #footer>
<Button @click="init.borrowRecord.show = false">关闭</Button>
</template>
</Modal>
<!-- 添加用户对话框 -->
<Modal
:styles="{top:'10px'}"
v-model="addUserModal.show"
:title="'人员数据'"
width="700"
:mask-closable="false"
>
<div class="add-user-search">
<Input
v-model="addUserModal.keyword"
placeholder="输入姓名或工号搜索用户"
search
clearable
enter-button
@on-search="searchAvailableUsers"
/>
<Button v-if="addUserModal.flag == '入库责任人'" style="margin-left: 10px" type="primary" @click="batchAddUser"
>批量添加
</Button
>
</div>
<!-- 负责部门选择 - 只在角色为责任部门时显示 -->
<div class="duty-dept-select" v-if="false">
<Form>
<FormItem
label="负责部门"
:label-width="80"
:rules="[
{
required: true,
type: 'array',
min: 1,
message: '请至少选择一个负责部门',
trigger: 'change',
},
]"
>
<Select
v-model="addUserModal.dutyDepts"
multiple
filterable
placeholder="请选择负责部门(可多选)"
style="width: 100%"
>
<Option
v-for="dept in departmentOptions"
:key="dept.value"
:value="dept.value"
>
{{ dept.label }}
</Option>
</Select>
</FormItem>
</Form>
</div>
<!-- 可添加用户列表 -->
<Table
@on-selection-change="onSelectionChange"
:loading="addUserModal.loading"
:columns="addUserModal.availableUserColumns"
:data="addUserModal.userList"
border
>
<!-- 照片列 -->
<template #avatar="{ row }">
<div class="user-avatar">
<Avatar v-if="row.photo" size="large" :src="row.photo"/>
<Avatar v-else icon="ios-person" size="large"/>
</div>
</template>
<!-- 操作列 -->
<template #action="{ row }">
<div class="action-btns">
<Button type="primary" size="small" @click="confirmAddUser(row)"
>添加
</Button
>
</div>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:key="addUserModal.pageKey"
:total="addUserModal.total"
:current="addUserModal.params.page_index"
:page-size="addUserModal.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleAddUserPageChange"
@on-page-size-change="handleAddUserPageSizeChange"
/>
</div>
<template #footer>
<Button @click="addUserModal.show = false">关闭</Button>
</template>
</Modal>
<!-- 出库对话框 -->
<Modal
v-model="init.outBound.show"
:title="init.outBound.title+'-设备出库'"
width="500"
>
<Form
ref="outBoundForm"
:model="init.outBound.formDate"
:rules="init.outBound.rules"
:label-width="100"
>
<FormItem label="借用人" prop="lender_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.lender_tids"
:key="index"
closable
@on-close="init.outBound.lender_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库借用人')"
>
添加借用人
</Button>
</div>
</FormItem>
<FormItem label="预计归还日期" prop="plan_end_date">
<DatePicker
v-model="init.outBound.formDate.plan_end_date"
type="datetime"
placeholder="选择预计归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库日期" prop="out_date">
<DatePicker
v-model="init.outBound.formDate.out_date"
type="datetime"
placeholder="选择出库日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库责任人" prop="duty_person_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.duty_person_tids"
:key="index"
closable
@on-close="init.outBound.duty_person_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
<FormItem label="备注" prop="application_remark">
<Input
v-model="init.outBound.formDate.application_remark"
type="textarea"
placeholder="请输入备注信息"
:rows="4"
/>
</FormItem>
</Form>
<template #footer>
<Button @click="init.outBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.outBound.formDate,'设备出库')">确定</Button>
</template>
</Modal>
<!-- 设备归还入库 -->
<Modal
v-model="init.inBound.show"
:title="init.inBound.title+'-归还入库'"
width="500"
>
<Form
ref="inBoundForm"
:model="init.inBound.formDate"
:rules="init.inBound.rules"
:label-width="100"
>
<FormItem label="归还日期" prop="return_date">
<DatePicker
v-model="init.inBound.formDate.return_date"
type="datetime"
placeholder="选择归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="归还人" prop="returnee_ids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.inBound.returnee_ids"
:key="index"
closable
@on-close="init.inBound.returnee_ids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('归还人')"
>
添加归还人
</Button>
</div>
</FormItem>
</Form>
<template #footer>
<Button @click="init.inBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.inBound.formDate,'设备归还')">确定</Button>
</template>
</Modal>
<!--设备借用状态-->
<Drawer
:draggable="true"
:styles="{padding: '0px'}"
v-model="init.equipmentBorrowingStatus.show"
:title="init.equipmentBorrowingStatus.title+'-借用状态'"
width="70%"
placement="right"
>
<div style="width: 100%;height: calc(100% - 60px);padding: 16px">
<DatePicker
v-if="false"
v-model="init.equipmentBorrowingStatus.params.month"
type="month"
placeholder="选择月份"
style="width: 200px; margin-bottom: 16px;"
@on-change="handleSubmit(init.equipmentBorrowingStatus.itemData,'equipmentBorrowingStatus')"
/>
<Calendar
:loading="init.equipmentBorrowingStatus.loading"
v-model="init.equipmentBorrowingStatus.params.month"
hide-type
@on-change="changeClendar"
>
<template #month="{date, data}">
<div>
<Badge
:status="['','error','warning'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
:text="['','占用中','维修中'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
v-if="init.equipmentBorrowingStatus.list.map(cur=>cur.occupy_date).includes(data.day) "/>
<Badge status="success" text="空闲" v-else/>
</div>
</template>
</Calendar>
</div>
<div
style="width: 100%;height: 60px;display: flex;justify-content: center;align-items: center;box-shadow: 0 0 8px darkgray">
<Button style="width: 150px" @click="init.equipmentBorrowingStatus.show =false">关闭</Button>
</div>
</Drawer>
<!-- 设备报修表单 -->
<Modal
v-model="init.repair.show"
:title="init.repair.title +'-设备报修'"
:mask-closable="false"
:closable="true"
width="50%"
@on-cancel="init.repair.show = false"
>
<Form
:model="init.repair.formData"
:rules="init.repair.rules"
ref="repairForm"
label-width="100"
>
<Row :gutter="16" type="flex" style="flex-wrap: wrap;">
<!-- 报修人 -->
<Col :xs="24" :sm="12">
<FormItem label="报修人" prop="name">
<Input
:disabled="true"
v-model="init.repair.formData.name"
placeholder="请输入报修人"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 联系方式 -->
<Col :xs="24" :sm="12">
<FormItem label="联系方式" prop="phone">
<Input
v-model="init.repair.formData.phone"
placeholder="请输入联系电话"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 报修区域 -->
<Col :xs="24" :sm="12">
<FormItem label="报修区域" prop="area_id">
<TreeSelect
v-model="init.repair.formData.area_id"
:data="init.repair.areaTree"
placeholder="请选择报修区域"
style="width: 100%;"
:clearable="true"
@on-change="handleAreaChange"
/>
</FormItem>
</Col>
<!-- 详细地址 -->
<Col :xs="24" :sm="12">
<FormItem label="详细地址" prop="areaDetail">
<Input
v-model="init.repair.formData.areaDetail"
placeholder="请输入报修详细地址"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修项目 -->
<Col :xs="24" :sm="12">
<FormItem label="报修项目" prop="item_id">
<div style="display: flex;">
<TreeSelect
:disabled="true"
v-model="init.repair.formData.item_id"
:data="init.repair.itemTree"
placeholder="请选择报修项目"
style="width: 100%;"
:clearable="true"
/>
<Spin v-if="init.repair.loading"></Spin>
</div>
</FormItem>
</Col>
<!-- 报修详细 -->
<Col :xs="24" :sm="12">
<FormItem label="报修详细" prop="itemDetail">
<Input
v-model="init.repair.formData.itemDetail"
placeholder="请输入报修详细"
maxlength="200"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修附件 -->
<Col :xs="24" :sm="12">
<FormItem label="报修附件" prop="file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '报修附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.file_list = init.repair.formData.file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
<!-- 钥匙备注 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙备注" prop="key_remark">
<Input
v-model="init.repair.formData.key_remark"
placeholder="请输入钥匙备注"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 钥匙附件 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙附件" prop="key_file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '钥匙附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.key_file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.key_file_list = init.repair.formData.key_file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.repair.show = false">取消</Button>
<Button type="primary" @click="handleRepairSubmit">提交报修</Button>
</template>
</Modal>
</template>
<script setup>
import {deviceProjectStore} from '@/store/deviceProjectStoree'
import initForm from "@/components/initForm";
import {ref, onMounted, reactive, computed} from "vue";
import {
Badge, Button,
Calendar,
DatePicker, Drawer,
FormItem,
Message,
Modal,
Page,
Row,
Switch,
Tag, TreeSelect, Upload,
} from "view-ui-plus";
import * as api from "@/api/allApi/controller/index";
import * as hooks from "@/hook/index";
import * as bxApi from '@/api/logisticsApi/index'
import dayjs from "dayjs";
import {setAreaItemStatus, submitRepair} from "@/api/logisticsApi/index";
// 角色列表
const roleList = ref([
{
role_type: 0,
role_name: "设备审核",
count: 14,
},
{
role_type: 1,
role_name: "耗材审核",
count: 4,
},
]);
// 表单值
const formValues = ref({});
// 用户表格列定义
const userColumns = computed(() => {
const columns = [
{
title: "#",
type: "index",
width: 60,
},
{
title: "设备编号",
key: "unique_id",
minWidth: 150,
},
{
title: "设备名称",
key: "name",
minWidth: 150,
},
{
title: "设备型号",
key: "model",
minWidth: 150,
},
{
title: "设备分类",
key: "classification_name",
minWidth: 150,
},
{
title: "生产厂家",
key: "manufacturer_name",
minWidth: 150,
},
{
title: "采购日期",
key: "purchase_date",
minWidth: 150,
},
{
title: "入库时间",
key: "storage_date",
width: 150,
},
{
title: "责任人",
slot: "duty_person",
minWidth: 160,
},
{
title: "存放位置",
key: "storage_location",
minWidth: 150,
},
{
title: "维护周期",
key: "maintenance_cycle",
minWidth: 150,
render: (h, params) => {
return h('span', params.row.maintenance_cycle + ['', '年', '月', '天'][params.row.manitenance_cycle_unit])
},
},
{
title: "设备状态",
slot: "status",
minWidth: 150,
},
{
title: "部门审核",
key: "need_dept_audit",
minWidth: 100,
slot: "need_dept_audit",
},
{
title: "价值审核",
key: "need_worth_audit",
minWidth: 100,
slot: "need_worth_audit",
},
];
// 添加操作列
columns.push({
title: "操作",
slot: "action",
width: 420,
align: "center",
fixed: "right",
});
return columns;
});
// 加载状态
const loading = ref(false);
// 用户列表
const userList = ref([]);
const init = reactive({
pageKey:'',
//报修
repair: {
loading: true,
show: false,
// 表单校验规则,确保用户输入的有效性
rules: {
name: [
{required: true, message: '请输入报修人姓名', trigger: 'change'}
],
area_id: [
{required: true, message: '请选择报修区域', trigger: 'change'}
],
item_id: [
{required: true, message: '请选择报修项目', trigger: 'change'}
],
phone: [
{required: true, message: '请输入联系电话', trigger: 'blur'},
{pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号', trigger: 'blur'}
],
areaDetail: [
{required: true, message: '请输入详细地址', trigger: 'blur'}
],
},
formData: {
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
},
areaTree: [],
itemTree: [],
},
// 借用记录相关数据
equipmentBorrowingStatus: {
title: '',
itemData: {},
show: false,
loading: false,
params: {
month: dayjs().format('YYYY-MM'),
equipment_id: "",
},
list: []
},
borrowRecord: {
itemData: {},
params: {
page_index: 1,
page_size: 10,
equipment_id: "",
},
show: false,
loading: false,
list: [],
total: 0,
pageIndex: 1,
pageSize: 10,
},
// 借用记录表格列定义
borrowRecordColumns: [
{
title: "设备名称",
key: "equipment_name",
minWidth: 100,
},
{
title: "责任人",
key: "duty_person_name",
minWidth: 100,
},
{
title: "责任人工号",
key: "duty_person_card",
minWidth: 120,
},
{
title: "借出人",
key: "lender_name",
minWidth: 100,
},
{
title: "借出人工号",
key: "lender_card",
minWidth: 120,
},
{
title: "出入库类型",
key: "storage_status_shift_type",
minWidth: 120,
},
{
title: "出入库日期",
key: "storage_status_shift_date",
minWidth: 120,
},
{
title: "备注",
key: "application_remark",
minWidth: 150,
},
],
searchList: [
{
label: "设备名称",
code: "equipment_name",
search_type: "input",
is_must: 0,
option_list: null,
option_cascade_list: null,
},
{
label: "设备分类",
code: "classification_id",
search_type: "treeselect",
is_must: 0,
options: [],
},
{
label: "设备状态",
code: "status",
search_type: "select",
is_must: 0,
option_list: [
{
label: "空闲",
value: "0",
},
{
label: "使用中",
value: "1",
},
{
label: "维修中",
value: "2",
},
],
option_cascade_list: null,
},
],
inBound: {
show: false,
returnee_ids: [],
formDate: {
equipment_id: '', // 设备id
return_date: '', // 归还日期
returnee_id: '', // 归还人tid
},
rules: {
return_date: [
{
required: true,
type: "date",
message: "请选择归还日期",
trigger: "change"
}
],
returnee_ids: [
{
required: true,
type: "array",
message: "请添加一位归还人",
trigger: "change",
validator: (rule, value, callback) => {
if (!init.inBound.returnee_ids || init.inBound.returnee_ids.length === 0) {
callback(new Error("请添加一位归还人"));
} else {
callback();
}
}
}
]
},
loading: false,
list: [],
},
outBound: {
title: '',
show: false,
duty_person_tids: [],
lender_tids: [],
formDate: {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
},
rules: {
plan_end_date: [
{
required: true,
type: "date",
message: "请选择预计归还日期",
trigger: "change"
}
],
out_date: [
{
required: true,
type: "date",
message: "请选择出库日期",
trigger: "change"
}
],
duty_person_tids: [
{
required: true,
type: "array",
message: "请添加一位出库责任人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.duty_person_tids.length === 0) {
callback(new Error("请添加一位出库责任人"))
} else {
callback()
}
}
}
],
lender_tids: [
{
required: true,
type: "array",
message: "请添加一位借用人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.lender_tids.length === 0) {
callback(new Error("请添加一位借用人"))
} else {
callback()
}
}
}
],
application_remark: [
{
required: false,
type: "string",
message: "请输入备注信息",
trigger: "blur"
}
]
},
loading: false,
list: [],
},
devices: {
flag: "add",
total: 0,
params: {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
},
show: false,
treeData: [],
formData: {
name: "",
model: "",
unique_id: "",
manufacturer_name: "",
purchase_date: "",
storage_date: "",
duty_person: "",
duty_persons: [],
storage_location: "",
maintenance_cycle: 0,
manitenance_cycle_unit: "1",
classification_id: "",
last_time_maintenance_date: "",
status: "0",
need_dept_audit: 0,
need_worth_audit: 0,
},
rules: {
unique_id: [
{
required: true,
type: "string",
message: "请输入设备编号",
trigger: "blur",
},
],
name: [
{
required: true,
type: "string",
message: "请输入设备名称",
trigger: "blur",
},
],
model: [
{
required: true,
type: "string",
message: "请输入设备型号",
trigger: "blur",
},
],
manufacturer_name: [
{
required: true,
type: "string",
message: "请输入生产厂家",
trigger: "blur",
},
],
purchase_date: [
{
required: true,
type: "date",
message: "请选择采购日期",
trigger: "change",
},
],
storage_date: [
{
required: true,
type: "date",
message: "请选择入库时间",
trigger: "change",
},
],
duty_persons: [
{
required: true,
type: "array",
min: 1,
message: "请输入责任人",
trigger: "change",
},
],
storage_location: [
{
required: true,
type: "string",
message: "请输入存放位置",
trigger: "blur",
},
],
maintenance_cycle: [
{
required: true,
type: "string",
message: "请输入维护周期",
trigger: "change",
},
],
manitenance_cycle_unit: [
{
required: true,
type: "number",
message: "请选择周期单位",
trigger: "change",
},
],
classification_id: [
{
required: true,
type: "string",
message: "请选择设备分类",
trigger: "change",
},
],
last_time_maintenance_date: [
{
required: true,
type: "date",
message: "请选择上次维护日期",
trigger: "change",
},
],
status: [
{
required: true,
type: "string",
message: "请选择设备状态",
trigger: "change",
},
],
},
},
downloadLoading: false,
});
/**
* 设备借用记录
* */
// 分页改变
const handleBorrowRecordPageChange = (page) => {
init.borrowRecord.params.page_index = page;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
// 页大小改变
const handleBorrowRecordPageSizeChange = (size) => {
init.borrowRecord.params.page_size = size;
init.borrowRecord.params.page_index = 1;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
/**
* 设备借用记录
* */
/**
* 设备
* */
//切换日历视图
function changeClendar(e) {
init.equipmentBorrowingStatus.params.month = dayjs(e).format('YYYY-MM')
handleSubmit(init.equipmentBorrowingStatus.itemData, 'equipmentBorrowingStatus')
}
const outBoundForm = ref()
const inBoundForm = ref()
//提交操作
function handleSubmit(row, type) {
const strategy = {
//借用状态
equipmentBorrowingStatus: () => {
init.equipmentBorrowingStatus.title = row.name
init.equipmentBorrowingStatus.itemData = row;
init.equipmentBorrowingStatus.show = true;
init.equipmentBorrowingStatus.loading = true;
api
.getApiEquipmentEquipmentCalendar({
...init.equipmentBorrowingStatus.params,
equipment_id: row.id,
})
.then((res) => {
init.equipmentBorrowingStatus.list = res.response;
init.equipmentBorrowingStatus.loading = false;
});
},
//借用记录
borrow: () => {
init.borrowRecord.itemData = row;
init.borrowRecord.show = true;
init.borrowRecord.loading = true;
api
.getApiEquipmentEquipmentLendLsit({
...init.borrowRecord.params,
equipment_id: row.id,
})
.then((res) => {
init.borrowRecord.list = res.response.data;
init.borrowRecord.total = res.response.data_count;
init.borrowRecord.loading = false;
});
},
//删除设备
delete: () => {
console.log("删除");
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentDelete({
equipment_id: row.id,
})
.then(
(res) => {
let responseInfo = res.response
// {
// "euqipment_id": "1938161312374853632",
// "repair_item_id": 21107
// }
///api/Repair/DeleteMiddleItem
// logistics/api/repair/Area/MoidfiyStatus 细项停用0/启用1
// {"id":[1070101],"use_flag":1}
/**
* 报修细项同步
* */
//变更报修系统细项
bxApi.setAreaItemStatus({"id":[responseInfo.repair_item_id],"use_flag":0}).then(_res=>{
//删除中间表对应关系
api.getApiRepairDeleteMiddleItem({classification_equipment_id: responseInfo.euqipment_id})
})
/**
* 报修细项同步
* */
EquipmentList();
return res;
},
"提交中...",
false
);
});
},
'设备归还': () => {
console.log("🚀🚀🚀,", init.inBound.formDate)
inBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentReturn({
...init.inBound.formDate,
returnee_id: init.inBound.returnee_ids
.map((cur) => cur.tid)
.join(";"),
return_date: dayjs(row.return_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.inBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
},
'设备出库': () => {
outBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentOut({
...init.outBound.formDate,
equipment_id: row.equipment_id,
duty_person_tid: init.outBound.duty_person_tids
.map((cur) => cur.tid)
.join(";"),
lender_tid: init.outBound.lender_tids
.map((cur) => cur.tid)
.join(";"),
plan_end_date: dayjs(row.plan_end_date).format(
"YYYY-MM-DD HH:mm:ss"
),
out_date: dayjs(row.out_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.outBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
}
};
strategy[type]();
}
//出库
function outbound(row) {
init.outBound.title = row.name
init.outBound.formDate = {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
}
init.outBound.duty_person_tids = [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
]
init.outBound.lender_tids = []
init.outBound.formDate = {
...init.outBound.formDate,
equipment_id: row.id
};
init.outBound.show = true;
init.outBound.loading = true;
outBoundForm.value.resetFields()
}
//入库归还
function inbound(row) {
init.inBound.title = row.name
init.inBound.returnee_ids = []
init.inBound.formDate = {}
init.inBound.formDate = {
...init.inBound.formDate,
equipment_id: row.id
};
init.inBound.show = true;
init.inBound.loading = true;
inBoundForm.value.resetFields()
console.log("🚀🚀🚀,", init.inBound.formDate)
}
//获取设备编辑数据
function edit(row) {
console.log(row)
init.devices.show = true;
init.devices.loading = true;
init.devices.formData = {
...init.devices.formData,
...row,
status: String(row.status),
maintenance_cycle: String(row.maintenance_cycle),
manitenance_cycle_unit: String(row.manitenance_cycle_unit),
duty_person: row.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(row.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(row.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
row.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
};
init.devices.flag = "edit";
}
// 获取设备列表
const EquipmentList = async () => {
try {
loading.value = true;
// TODO: 调用接口获取角色用户列表
api.postApiEquipmentEquipmentList(init.devices.params).then((res) => {
userList.value = res.response.data;
init.devices.total = res.response.data_count;
loading.value = false;
});
} catch (error) {
loading.value = false;
Message.error("加载用户列表失败");
}
};
// 搜索用户
const handleSearch = (value) => {
init.devices.params = {
...init.devices.params,
...value,
page_index: 1,
page_size: 10,
};
EquipmentList();
};
// 重置
const handleReset = () => {
init.devices.params = {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
};
init.pageKey = Date.now();
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
searchFormRef.value.searchCondObj.classification_id = cur.options[0].id;
init.devices.params.classification_id = cur.options[0].id;
}
});
EquipmentList();
};
// 分页改变
const handlePageChange = (page) => {
init.devices.params.page_index = page;
EquipmentList();
};
// 页大小改变
const handlePageSizeChange = (size) => {
init.devices.params.page_size = size;
init.devices.params.page_index = 1;
EquipmentList();
};
// 添加设备
const handleAdd = () => {
init.devices.flag = 'add'
init.devices.formData = {
"name": "",
"model": "",
"unique_id": "",
"manufacturer_name": "",
"purchase_date": "",
"storage_date": "",
"duty_person": "",
"duty_persons": [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
],
"storage_location": "",
"maintenance_cycle": '0',
"manitenance_cycle_unit": '1',
"classification_id": "",
"last_time_maintenance_date": "",
"status": '0',
"need_dept_audit": 0,
"need_worth_audit": 0
};
init.devices.show = true;
deviceForm.value.resetFields();
};
// 下载模板
const handleDownloadTemplate = async () => {
try {
init.downloadLoading = true;
// TODO: 实现下载模板功能
init.downloadLoading = false;
} catch (error) {
init.downloadLoading = false;
Message.error("下载模板失败");
}
};
const deviceForm = ref();
// 删除用户
const handleRemoveUser = async (row) => {
try {
// TODO: 调用接口删除用户
Message.success("删除成功");
EquipmentList();
} catch (error) {
Message.error("删除失败");
}
};
// 提交设备表单
const handleSubmitDevice = () => {
const strategy = {
add: () => {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentAdd({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
// last_time_maintenance_date: dayjs(
// init.devices.formData.last_time_maintenance_date
// ).format("YYYY-MM-DD HH:mm:ss"),
})
.then(
(res) => {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
const responseInfo = res.response
//获取细项id
bxApi.GetId({parent_id: responseInfo.classification_reparir_item}).then((getAreaChildren) => {
//提交细项
bxApi.addItem({
"parent_id": responseInfo.classification_reparir_item,
"id": getAreaChildren.response,
"name": responseInfo.equipment_name
}).then(_res => {
//双系统信息,同步到中间表
api.getApiRepairAddMiddleItem({
classification_equipment_id: responseInfo.equipment_id,
repair_item: getAreaChildren.response
})
})
})
/**
* 报修细项同步
* */
return res;
},
"提交中...",
false
);
});
},
edit: () => {
console.log(init.devices.formData)
hooks.myEncapsulationFunction(() => {
return api.postApiEquipmentEquipmentUpdate({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
init.devices.formData.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
}).then((res) => {
if (res.code === 1) {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
//获取细项id
api.getApiRepairQueryById({classification_equipment_id: init.devices.formData.id}).then((getAreaChildren) => {
//提交细项
bxApi.modifyItem({
"id": getAreaChildren.response.repair_item_id,
"name": init.devices.formData.name
})
})
/**
* 报修细项同步
* */
return res;
}
});
}, false, '提交中...');
},
};
deviceForm.value.validate((valid) => {
if (valid) {
strategy[init.devices.flag]();
}
});
};
// 树格式化
function treeFormat(arr) {
return arr.map((a) => {
if (a.children && a.children.length != 0) {
a.children = treeFormat(a.children);
}
return {
...a,
title: a.name,
value: a.id,
expand: true,
selected: false,
};
});
}
const searchFormRef = ref()
function getTreeData() {
return api.getApiEquipmentGetEquipmentClassificationTree().then((res) => {
init.devices.treeData = treeFormat(res.response);
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
cur.options = treeFormat(res.response);
searchFormRef.value.searchCondObj.classification_id = res.response[0].id;
init.devices.params.classification_id = res.response[0].id;
}
});
return res
});
}
/**人员选择器 */
// 人员选择器》添加用户对话框
const addUserModal = reactive({
flag: '',
pageKey: '',
params: {
page_index: 1,
page_size: 10,
query: "",
},
total: 0,
show: false,
loading: false,
keyword: "",
batchUserList: [],
userList: [],
dutyDepts: [],
availableUserColumns: [
// {
// align: "center",
// type: "selection",
// width: 60,
// },
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
],
});
// 部门列表
const departmentOptions = ref([]);
// 人员选择器》搜索可添加的用户
const searchAvailableUsers = async () => {
loadRoleUsers();
};
//弹出人员选择器
function showAddUser(key) {
addUserModal.flag = key
setPeopleColumnsData()
addUserModal.params = {
page_index: 1,
page_size: 10,
query: "",
}
addUserModal.pageKey = new Date();
addUserModal.show = true;
addUserModal.batchUserList = [];
loadRoleUsers()
}
//批量提交选中人员
function batchAddUser() {
const strategy = {
//新增设备 批量
'入库责任人': () => {
const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
let data = []
addUserModal.batchUserList.forEach((cur, index) => {
//不包含
if (!dataId.includes(cur.tid)) {
data.push(cur)
}
})
init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
addUserModal.show = false;
},
// '出库责任人':()=>{
// const dataId = init.outBound.duty_person_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.duty_person_tids = init.outBound.duty_person_tids.concat(data);
// addUserModal.show = false;
// },
// '出库借用人':()=>{
// const dataId = init.outBound.lender_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.lender_tids = init.outBound.lender_tids.concat(data);
// addUserModal.show = false;
// },
// '归还人':()=>{
// const dataId = init.inBound.returnee_ids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.inBound.returnee_ids = init.inBound.returnee_ids.concat(data);
// addUserModal.show = false;
// },
}
strategy[addUserModal.flag]()
}
//选中人员
function onSelectionChange(e) {
console.log('e', e)
addUserModal.batchUserList = e;
}
// 人员选择器》确认添加用户
const confirmAddUser = async (user) => {
console.log("🚀🚀🚀,", user)
const strategy = {
// '入库责任人':()=>{
// const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
// console.log("🚀🚀111🚀,", init.devices.formData.duty_persons)
// addUserModal.show = false;
// },
'出库责任人': () => {
init.outBound.duty_person_tids = [user];
addUserModal.show = false;
},
'出库借用人': () => {
init.outBound.lender_tids = [user];
addUserModal.show = false;
},
'归还人': () => {
init.inBound.returnee_ids = [user];
addUserModal.show = false;
},
}
strategy[addUserModal.flag]()
};
// 加载人员选择器用户
const loadRoleUsers = () => {
addUserModal.loading = true;
try {
api
.getApiCommonUserSelect({
...addUserModal.params,
query: addUserModal.keyword,
})
.then((res) => {
addUserModal.userList = res.response.data || [];
addUserModal.total = res.response.data_count;
})
.catch((error) => {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
})
.finally(() => {
addUserModal.loading = false;
});
} catch (error) {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
addUserModal.loading = false;
}
};
// 分页改变
const handleAddUserPageChange = (page) => {
addUserModal.params.page_index = page;
loadRoleUsers()
};
// 页大小改变
const handleAddUserPageSizeChange = (size) => {
addUserModal.params.page_size = size;
addUserModal.params.page_index = 1;
loadRoleUsers()
};
//配置人员列表列数据
function setPeopleColumnsData() {
function name() {
addUserModal.availableUserColumns = [
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
]
}
const strategy = {
'入库责任人': () => {
addUserModal.availableUserColumns = [
{
align: "center",
type: "selection",
width: 60,
},
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
]
},
'出库责任人': () => name(),
'出库借用人': () => name(),
'归还人': () => name(),
}
strategy[addUserModal.flag]()
}
/**人员选择器 */
/**
* 设备报修
* */
//显示报修
function showRepair(row) {
getRepairAreaTree()
getRepairItemTree()
init.repair.formData ={
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
}
init.repair.title = row.name
init.repair.formData.name = deviceProjectStore.state.userInfo.name + '(' + deviceProjectStore.state.userInfo.card + ')'
init.repair.show = true
repairForm.value.resetFields()
init.repair.loading = true
//获取报修系统细项id
api.getApiRepairQueryById({classification_equipment_id: row.id}).then(res => {
init.repair.formData.item_id = String(res.response.repair_item_id)
}).finally(() => {
init.repair.loading = false
})
}
//遍历树形结构
function traverseTree(Array) {
return Array.map(item => {
if (item.children && item.children.length > 0) item.children = traverseTree(item.children)
return {
...item,
value: item.key
}
})
}
//获取报修区域
function getRepairAreaTree() {
bxApi.getRepairAreaTree().then(res => {
init.repair.areaTree = traverseTree(res.response)
})
}
//获取报修项目
function getRepairItemTree() {
bxApi.getRepairItemTree().then(res => {
init.repair.itemTree = traverseTree(res.response)
})
}
//附件上传
function beforeRepairFileUpload(file, type) {
console.log(file)
let f = new FormData();
f.append('file', file)
hooks.myEncapsulationFunction(() => {
return bxApi.uploadRepairImage({systemType: 0}, f, {headers: {'Content-Type': 'multipart/form-data'}}).then(res => {
if (res.code === 1) {
if (type === '报修附件') {
init.repair.formData.file_list = init.repair.formData.file_list.concat(res.response)
} else {
init.repair.formData.key_file_list = init.repair.formData.key_file_list.concat(res.response)
}
}
return res
})
}, false, '正在上传中...')
return false
}
const repairForm = ref()
//通过节点id,获取节点名称
function getAreaNameById(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.item_text = item.title
})
}
function getAreaNameById2(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.area_text = item.title
})
}
//提交报修
function handleRepairSubmit() {
getAreaNameById(init.repair.formData.item_id, init.repair.itemTree)
getAreaNameById2(init.repair.formData.area_id, init.repair.areaTree)
// console.log(111, {
// ...init.repair.formData,
// key_file_list: init.repair.formData.key_file_list.join(','),
// file_list: init.repair.formData.file_list.join(','),
//
// })
repairForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return bxApi.submitRepair({
...init.repair.formData,
key_file_list: init.repair.formData.key_file_list.map(cur => cur.id).join(','),
file_list: init.repair.formData.file_list.map(cur => cur.id).join(','),
}).then(res => {
//
api.getApiRepairRegisterRepair({
repair_item_id: init.repair.formData.item_id,
repair_out_id: res.response}
).then(()=>{
init.repair.show = false
EquipmentList()
})
return res
})
}, false, '正在提交中...')
}
})
}
/**
* 设备报修
* */
onMounted(() => {
getRepairAreaTree()
getRepairItemTree()
loading.value = true;
getTreeData().then(res => {
EquipmentList();
});
});
</script>
<style scoped>
.role-container {
display: flex;
min-height: calc(100vh - 150px);
/* border: 1px solid #e8eaec; */
border-radius: 4px;
overflow: auto;
gap: 16px;
}
.role-sidebar {
width: 300px;
border-right: 1px solid #e8eaec;
background-color: #fff;
overflow-y: auto;
height: 200px;
}
.role-title {
padding: 16px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #e8eaec;
}
.role-list {
padding: 10px 0;
}
.role-item {
display: flex;
align-items: center;
padding: 12px 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.role-item:hover {
background-color: #f0f0f0;
}
.role-item.active {
background-color: #e8f7ff;
color: #2d8cf0;
}
.role-item-icon {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
color: #fff;
}
.role-admin {
background-color: #2d8cf0;
}
.role-party-office {
background-color: #19be6b;
}
.role-entrance-dept {
background-color: #ff9900;
}
.role-responsible-dept {
background-color: #ed4014;
}
.role-item-info {
flex: 1;
}
.role-name {
font-size: 14px;
margin-bottom: 4px;
}
.role-count {
font-size: 12px;
color: #808695;
}
.role-content {
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
}
.role-toolbar {
height: 100%;
display: flex;
flex-direction: column;
gap: 20px;
top: 0;
background-color: #fff;
z-index: 1;
}
.search-box {
width: 280px;
}
.pagination {
/* margin-top: 16px; */
text-align: center;
position: sticky;
bottom: 0;
background-color: #fff;
z-index: 1;
}
.action-btns {
display: flex;
justify-content: center;
}
.user-avatar {
display: flex;
justify-content: center;
align-items: center;
}
.user-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.add-user-search {
margin-bottom: 16px;
display: flex;
}
.duty-dept-select {
margin-bottom: 16px;
}
</style>
<style lang='less' scoped>
.filelist {
cursor: pointer;
}
.filelist:hover {
color: #1e93ff;
background-color: #f7f7f7;
}
.fileddelete {
cursor: pointer;
margin-left: auto;
}
.fileddelete:hover {
color: red;
transform: scale(1.5);
}
</style>
<template>
<div style="width: 100%; height: 100%">
<!-- 右侧人员列表 -->
<div class="role-content">
<!-- 搜索和工具栏 -->
<div class="role-toolbar">
<initForm
ref="searchFormRef"
:searchCondList="init.searchList"
@on-submit="handleSearch"
@on-reset="handleReset"
/>
<!-- 表格工具栏 -->
<div class="operation-bar">
<Button type="primary" @click="handleAdd">
<Icon type="md-add"/>
新增设备
</Button>
<!-- <Button class="ivu-ml-8" @click="handleImport"><Icon type="md-cloud-upload" /> 导入设备</Button>-->
<!-- <Button-->
<!-- class="ivu-ml-8"-->
<!-- @click="handleDownloadTemplate"-->
<!-- :loading="init.downloadLoading"-->
<!-- ><Icon type="md-download" /> 下载模板</Button-->
<!-- >-->
<!-- <Button class="ivu-ml-8" @click="handleExport"><Icon type="md-download" /> 导出数据</Button>-->
</div>
</div>
<!-- 设备表格 -->
<Table :loading="loading" :columns="userColumns" :data="userList" border>
<template #action="{ row }">
<div class="action-btns" style="display: flex; align-items: center">
<a href="javascript:;" @click="handleSubmit(row, 'borrow')"
>借用记录</a
>
<Divider type="vertical"/>
<a
href="javascript:;"
@click="handleSubmit(row, 'equipmentBorrowingStatus')"
>借用状态</a
>
<Divider type="vertical"/>
<a href="javascript:;" @click="outbound(row)">出库</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="inbound(row)">归还</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="showRepair(row)">报修</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="edit(row)">编辑</a>
<Divider type="vertical"/>
<Poptip
confirm
transfer
title="确定要删除该设备吗?"
@on-ok="handleSubmit(row, 'delete')"
>
<a href="javascript:;">删除</a>
</Poptip>
</div>
</template>
<template #duty_person="{ row }">
<Tag
color="blue"
v-for="(item, index) in row.duty_persons"
:key="index"
>
{{ item.name }}
</Tag>
</template>
<template #status="{ row }">
<Tag :color="['success', 'blue', 'warning'][Number(row.status)]">
{{ ["空闲", "使用中", "维修中"][Number(row.status)] }}
</Tag>
</template>
<template #need_dept_audit="{ row }">
{{ row.need_dept_audit === 1 ? "需要" : "不需要" }}
</template>
<template #need_worth_audit="{ row }">
{{ row.need_worth_audit === 1 ? "需要" : "不需要" }}
</template>
</Table>
<!-- 分页 -->
<div class="pagination">
<Page
:key="init.pageKey"
:total="init.devices.total"
:current="init.devices.params.page_index"
:page-size="init.devices.params.page_size"
show-elevator
:show-sizer="true"
show-total
:page-size-opts="[10, 20, 50, 100]"
:transfer="true"
@on-change="handlePageChange"
@on-page-size-change="handlePageSizeChange"
/>
</div>
</div>
</div>
<!-- 添加设备对话框 -->
<Modal
v-model="init.devices.show"
title="设备信息"
width="700"
>
<Form
ref="deviceForm"
:model="init.devices.formData"
:rules="init.devices.rules"
:label-width="100"
>
<Row :gutter="16">
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备编号" prop="unique_id1">
<Input
v-model="init.devices.formData.unique_id"
placeholder="请输入设备编号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备名称" prop="name">
<Input
v-model="init.devices.formData.name"
placeholder="请输入设备名称"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备型号" prop="model1">
<Input
v-model="init.devices.formData.model"
placeholder="请输入设备型号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="生产厂家" prop="manufacturer_name1">
<Input
v-model="init.devices.formData.manufacturer_name"
placeholder="请输入生产厂家"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="采购日期" prop="purchase_date">
<DatePicker
v-model="init.devices.formData.purchase_date"
type="datetime"
placeholder="选择采购日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="入库时间" prop="storage_date">
<DatePicker
v-model="init.devices.formData.storage_date"
type="datetime"
placeholder="选择入库时间"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="责任人" prop="duty_persons">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.devices.formData.duty_persons"
:key="index"
closable
@on-close="init.devices.formData.duty_persons.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('入库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="存放位置" prop="storage_location">
<Input
v-model="init.devices.formData.storage_location"
placeholder="请输入存放位置"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备分类" prop="classification_id">
<TreeSelect
v-model="init.devices.formData.classification_id"
placeholder="请选择设备分类"
:data="init.devices.treeData"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="维护周期" prop="maintenance_cycle">
<Input
v-model="init.devices.formData.maintenance_cycle"
style="width: 60%"
clearable
/>
<Select
v-model="init.devices.formData.manitenance_cycle_unit"
style="width: 35%; margin-left: 5%"
>
<Option value="1">年</Option>
<Option value="2">月</Option>
<Option value="3">天</Option>
</Select>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备状态" prop="status">
<Select v-model="init.devices.formData.status" clearable>
<Option value="0">空闲</Option>
<Option value="1">使用中</Option>
<Option value="2">维修中</Option>
</Select>
</FormItem>
</Col>
<Col v-if="init.devices.flag == 'edit'" :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="上次维护日期" prop="last_time_maintenance_date">
<DatePicker
v-model="init.devices.formData.last_time_maintenance_date"
type="datetime"
placeholder="选择上次维护日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="部门审核" prop="need_dept_audit">
<Switch
v-model="init.devices.formData.need_dept_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="价值审核" prop="need_worth_audit">
<Switch
v-model="init.devices.formData.need_worth_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.devices.show = false">取消</Button>
<Button type="primary" @click="handleSubmitDevice">确定</Button>
</template>
</Modal>
<!-- 借用记录对话框 -->
<Modal
v-model="init.borrowRecord.show"
title="借用记录"
width="60%"
:mask-closable="false"
>
<Table
:loading="init.borrowRecord.loading"
:columns="init.borrowRecordColumns"
:data="init.borrowRecord.list"
border
>
<template #status="{ row }">
<Tag
:color="
row.status === 1
? 'success'
: row.status === 2
? 'warning'
: 'default'
"
>
{{
row.status === 1 ? "已归还" : row.status === 2 ? "使用中" : "待审核"
}}
</Tag>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:total="init.borrowRecord.total"
:current="init.borrowRecord.params.page_index"
:page-size="init.borrowRecord.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleBorrowRecordPageChange"
@on-page-size-change="handleBorrowRecordPageSizeChange"
/>
</div>
<template #footer>
<Button @click="init.borrowRecord.show = false">关闭</Button>
</template>
</Modal>
<!-- 添加用户对话框 -->
<Modal
:styles="{top:'10px'}"
v-model="addUserModal.show"
:title="'人员数据'"
width="700"
:mask-closable="false"
>
<div class="add-user-search">
<Input
v-model="addUserModal.keyword"
placeholder="输入姓名或工号搜索用户"
search
clearable
enter-button
@on-search="searchAvailableUsers"
/>
<Button v-if="addUserModal.flag == '入库责任人'" style="margin-left: 10px" type="primary" @click="batchAddUser"
>批量添加
</Button
>
</div>
<!-- 负责部门选择 - 只在角色为责任部门时显示 -->
<div class="duty-dept-select" v-if="false">
<Form>
<FormItem
label="负责部门"
:label-width="80"
:rules="[
{
required: true,
type: 'array',
min: 1,
message: '请至少选择一个负责部门',
trigger: 'change',
},
]"
>
<Select
v-model="addUserModal.dutyDepts"
multiple
filterable
placeholder="请选择负责部门(可多选)"
style="width: 100%"
>
<Option
v-for="dept in departmentOptions"
:key="dept.value"
:value="dept.value"
>
{{ dept.label }}
</Option>
</Select>
</FormItem>
</Form>
</div>
<!-- 可添加用户列表 -->
<Table
@on-selection-change="onSelectionChange"
:loading="addUserModal.loading"
:columns="addUserModal.availableUserColumns"
:data="addUserModal.userList"
border
>
<!-- 照片列 -->
<template #avatar="{ row }">
<div class="user-avatar">
<Avatar v-if="row.photo" size="large" :src="row.photo"/>
<Avatar v-else icon="ios-person" size="large"/>
</div>
</template>
<!-- 操作列 -->
<template #action="{ row }">
<div class="action-btns">
<Button type="primary" size="small" @click="confirmAddUser(row)"
>添加
</Button
>
</div>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:key="addUserModal.pageKey"
:total="addUserModal.total"
:current="addUserModal.params.page_index"
:page-size="addUserModal.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleAddUserPageChange"
@on-page-size-change="handleAddUserPageSizeChange"
/>
</div>
<template #footer>
<Button @click="addUserModal.show = false">关闭</Button>
</template>
</Modal>
<!-- 出库对话框 -->
<Modal
v-model="init.outBound.show"
:title="init.outBound.title+'-设备出库'"
width="500"
>
<Form
ref="outBoundForm"
:model="init.outBound.formDate"
:rules="init.outBound.rules"
:label-width="100"
>
<FormItem label="借用人" prop="lender_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.lender_tids"
:key="index"
closable
@on-close="init.outBound.lender_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库借用人')"
>
添加借用人
</Button>
</div>
</FormItem>
<FormItem label="预计归还日期" prop="plan_end_date">
<DatePicker
v-model="init.outBound.formDate.plan_end_date"
type="datetime"
placeholder="选择预计归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库日期" prop="out_date">
<DatePicker
v-model="init.outBound.formDate.out_date"
type="datetime"
placeholder="选择出库日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库责任人" prop="duty_person_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.duty_person_tids"
:key="index"
closable
@on-close="init.outBound.duty_person_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
<FormItem label="备注" prop="application_remark">
<Input
v-model="init.outBound.formDate.application_remark"
type="textarea"
placeholder="请输入备注信息"
:rows="4"
/>
</FormItem>
</Form>
<template #footer>
<Button @click="init.outBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.outBound.formDate,'设备出库')">确定</Button>
</template>
</Modal>
<!-- 设备归还入库 -->
<Modal
v-model="init.inBound.show"
:title="init.inBound.title+'-归还入库'"
width="500"
>
<Form
ref="inBoundForm"
:model="init.inBound.formDate"
:rules="init.inBound.rules"
:label-width="100"
>
<FormItem label="归还日期" prop="return_date">
<DatePicker
v-model="init.inBound.formDate.return_date"
type="datetime"
placeholder="选择归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="归还人" prop="returnee_ids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.inBound.returnee_ids"
:key="index"
closable
@on-close="init.inBound.returnee_ids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('归还人')"
>
添加归还人
</Button>
</div>
</FormItem>
</Form>
<template #footer>
<Button @click="init.inBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.inBound.formDate,'设备归还')">确定</Button>
</template>
</Modal>
<!--设备借用状态-->
<Drawer
:draggable="true"
:styles="{padding: '0px'}"
v-model="init.equipmentBorrowingStatus.show"
:title="init.equipmentBorrowingStatus.title+'-借用状态'"
width="70%"
placement="right"
>
<div style="width: 100%;height: calc(100% - 60px);padding: 16px">
<DatePicker
v-if="false"
v-model="init.equipmentBorrowingStatus.params.month"
type="month"
placeholder="选择月份"
style="width: 200px; margin-bottom: 16px;"
@on-change="handleSubmit(init.equipmentBorrowingStatus.itemData,'equipmentBorrowingStatus')"
/>
<Calendar
:loading="init.equipmentBorrowingStatus.loading"
v-model="init.equipmentBorrowingStatus.params.month"
hide-type
@on-change="changeClendar"
>
<template #month="{date, data}">
<div>
<Badge
:status="['','error','warning'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
:text="['','占用中','维修中'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
v-if="init.equipmentBorrowingStatus.list.map(cur=>cur.occupy_date).includes(data.day) "/>
<Badge status="success" text="空闲" v-else/>
</div>
</template>
</Calendar>
</div>
<div
style="width: 100%;height: 60px;display: flex;justify-content: center;align-items: center;box-shadow: 0 0 8px darkgray">
<Button style="width: 150px" @click="init.equipmentBorrowingStatus.show =false">关闭</Button>
</div>
</Drawer>
<!-- 设备报修表单 -->
<Modal
v-model="init.repair.show"
:title="init.repair.title +'-设备报修'"
:mask-closable="false"
:closable="true"
width="50%"
@on-cancel="init.repair.show = false"
>
<Form
:model="init.repair.formData"
:rules="init.repair.rules"
ref="repairForm"
label-width="100"
>
<Row :gutter="16" type="flex" style="flex-wrap: wrap;">
<!-- 报修人 -->
<Col :xs="24" :sm="12">
<FormItem label="报修人" prop="name">
<Input
:disabled="true"
v-model="init.repair.formData.name"
placeholder="请输入报修人"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 联系方式 -->
<Col :xs="24" :sm="12">
<FormItem label="联系方式" prop="phone">
<Input
v-model="init.repair.formData.phone"
placeholder="请输入联系电话"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 报修区域 -->
<Col :xs="24" :sm="12">
<FormItem label="报修区域" prop="area_id">
<TreeSelect
v-model="init.repair.formData.area_id"
:data="init.repair.areaTree"
placeholder="请选择报修区域"
style="width: 100%;"
:clearable="true"
/>
</FormItem>
</Col>
<!-- 详细地址 -->
<Col :xs="24" :sm="12">
<FormItem label="详细地址" prop="areaDetail">
<Input
v-model="init.repair.formData.areaDetail"
placeholder="请输入报修详细地址"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修项目 -->
<Col :xs="24" :sm="12">
<FormItem label="报修项目" prop="item_id">
<div style="display: flex;">
<TreeSelect
:disabled="true"
v-model="init.repair.formData.item_id"
:data="init.repair.itemTree"
placeholder="请选择报修项目"
style="width: 100%;"
:clearable="true"
/>
<Spin v-if="init.repair.loading"></Spin>
</div>
</FormItem>
</Col>
<!-- 报修详细 -->
<Col :xs="24" :sm="12">
<FormItem label="报修详细" prop="itemDetail">
<Input
v-model="init.repair.formData.itemDetail"
placeholder="请输入报修详细"
maxlength="200"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修附件 -->
<Col :xs="24" :sm="12">
<FormItem label="报修附件" prop="file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '报修附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.file_list = init.repair.formData.file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
<!-- 钥匙备注 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙备注" prop="key_remark">
<Input
v-model="init.repair.formData.key_remark"
placeholder="请输入钥匙备注"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 钥匙附件 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙附件" prop="key_file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '钥匙附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.key_file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.key_file_list = init.repair.formData.key_file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.repair.show = false">取消</Button>
<Button type="primary" @click="handleRepairSubmit">提交报修</Button>
</template>
</Modal>
</template>
<script setup>
import {deviceProjectStore} from '@/store/deviceProjectStoree'
import initForm from "@/components/initForm";
import {ref, onMounted, reactive, computed} from "vue";
import {
Badge, Button,
Calendar,
DatePicker, Drawer,
FormItem,
Message,
Modal,
Page,
Row,
Switch,
Tag, TreeSelect, Upload,
} from "view-ui-plus";
import * as api from "@/api/allApi/controller/index";
import * as hooks from "@/hook/index";
import * as bxApi from '@/api/logisticsApi/index'
import dayjs from "dayjs";
import {setAreaItemStatus, submitRepair} from "@/api/logisticsApi/index";
// 角色列表
const roleList = ref([
{
role_type: 0,
role_name: "设备审核",
count: 14,
},
{
role_type: 1,
role_name: "耗材审核",
count: 4,
},
]);
// 表单值
const formValues = ref({});
// 用户表格列定义
const userColumns = computed(() => {
const columns = [
{
title: "#",
type: "index",
width: 60,
},
{
title: "设备编号",
key: "unique_id",
minWidth: 150,
},
{
title: "设备名称",
key: "name",
minWidth: 150,
},
{
title: "设备型号",
key: "model",
minWidth: 150,
},
{
title: "设备分类",
key: "classification_name",
minWidth: 150,
},
{
title: "生产厂家",
key: "manufacturer_name",
minWidth: 150,
},
{
title: "采购日期",
key: "purchase_date",
minWidth: 150,
},
{
title: "入库时间",
key: "storage_date",
width: 150,
},
{
title: "责任人",
slot: "duty_person",
minWidth: 160,
},
{
title: "存放位置",
key: "storage_location",
minWidth: 150,
},
{
title: "维护周期",
key: "maintenance_cycle",
minWidth: 150,
render: (h, params) => {
return h('span', params.row.maintenance_cycle + ['', '年', '月', '天'][params.row.manitenance_cycle_unit])
},
},
{
title: "设备状态",
slot: "status",
minWidth: 150,
},
{
title: "部门审核",
key: "need_dept_audit",
minWidth: 100,
slot: "need_dept_audit",
},
{
title: "价值审核",
key: "need_worth_audit",
minWidth: 100,
slot: "need_worth_audit",
},
];
// 添加操作列
columns.push({
title: "操作",
slot: "action",
width: 420,
align: "center",
fixed: "right",
});
return columns;
});
// 加载状态
const loading = ref(false);
// 用户列表
const userList = ref([]);
const init = reactive({
pageKey:'',
//报修
repair: {
loading: true,
show: false,
// 表单校验规则,确保用户输入的有效性
rules: {
name: [
{required: true, message: '请输入报修人姓名', trigger: 'change'}
],
area_id: [
{required: true, message: '请选择报修区域', trigger: 'change'}
],
item_id: [
{required: true, message: '请选择报修项目', trigger: 'change'}
],
phone: [
{required: true, message: '请输入联系电话', trigger: 'blur'},
{pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号', trigger: 'blur'}
],
areaDetail: [
{required: true, message: '请输入详细地址', trigger: 'blur'}
],
},
formData: {
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
},
areaTree: [],
itemTree: [],
},
// 借用记录相关数据
equipmentBorrowingStatus: {
title: '',
itemData: {},
show: false,
loading: false,
params: {
month: dayjs().format('YYYY-MM'),
equipment_id: "",
},
list: []
},
borrowRecord: {
itemData: {},
params: {
page_index: 1,
page_size: 10,
equipment_id: "",
},
show: false,
loading: false,
list: [],
total: 0,
pageIndex: 1,
pageSize: 10,
},
// 借用记录表格列定义
borrowRecordColumns: [
{
title: "设备名称",
key: "equipment_name",
minWidth: 100,
},
{
title: "责任人",
key: "duty_person_name",
minWidth: 100,
},
{
title: "责任人工号",
key: "duty_person_card",
minWidth: 120,
},
{
title: "借出人",
key: "lender_name",
minWidth: 100,
},
{
title: "借出人工号",
key: "lender_card",
minWidth: 120,
},
{
title: "出入库类型",
key: "storage_status_shift_type",
minWidth: 120,
},
{
title: "出入库日期",
key: "storage_status_shift_date",
minWidth: 120,
},
{
title: "备注",
key: "application_remark",
minWidth: 150,
},
],
searchList: [
{
label: "设备名称",
code: "equipment_name",
search_type: "input",
is_must: 0,
option_list: null,
option_cascade_list: null,
},
{
label: "设备分类",
code: "classification_id",
search_type: "treeselect",
is_must: 0,
options: [],
},
{
label: "设备状态",
code: "status",
search_type: "select",
is_must: 0,
option_list: [
{
label: "空闲",
value: "0",
},
{
label: "使用中",
value: "1",
},
{
label: "维修中",
value: "2",
},
],
option_cascade_list: null,
},
],
inBound: {
show: false,
returnee_ids: [],
formDate: {
equipment_id: '', // 设备id
return_date: '', // 归还日期
returnee_id: '', // 归还人tid
},
rules: {
return_date: [
{
required: true,
type: "date",
message: "请选择归还日期",
trigger: "change"
}
],
returnee_ids: [
{
required: true,
type: "array",
message: "请添加一位归还人",
trigger: "change",
validator: (rule, value, callback) => {
if (!init.inBound.returnee_ids || init.inBound.returnee_ids.length === 0) {
callback(new Error("请添加一位归还人"));
} else {
callback();
}
}
}
]
},
loading: false,
list: [],
},
outBound: {
title: '',
show: false,
duty_person_tids: [],
lender_tids: [],
formDate: {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
},
rules: {
plan_end_date: [
{
required: true,
type: "date",
message: "请选择预计归还日期",
trigger: "change"
}
],
out_date: [
{
required: true,
type: "date",
message: "请选择出库日期",
trigger: "change"
}
],
duty_person_tids: [
{
required: true,
type: "array",
message: "请添加一位出库责任人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.duty_person_tids.length === 0) {
callback(new Error("请添加一位出库责任人"))
} else {
callback()
}
}
}
],
lender_tids: [
{
required: true,
type: "array",
message: "请添加一位借用人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.lender_tids.length === 0) {
callback(new Error("请添加一位借用人"))
} else {
callback()
}
}
}
],
application_remark: [
{
required: false,
type: "string",
message: "请输入备注信息",
trigger: "blur"
}
]
},
loading: false,
list: [],
},
devices: {
flag: "add",
total: 0,
params: {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
},
show: false,
treeData: [],
formData: {
name: "",
model: "",
unique_id: "",
manufacturer_name: "",
purchase_date: "",
storage_date: "",
duty_person: "",
duty_persons: [],
storage_location: "",
maintenance_cycle: 0,
manitenance_cycle_unit: "1",
classification_id: "",
last_time_maintenance_date: "",
status: "0",
need_dept_audit: 0,
need_worth_audit: 0,
},
rules: {
unique_id: [
{
required: true,
type: "string",
message: "请输入设备编号",
trigger: "blur",
},
],
name: [
{
required: true,
type: "string",
message: "请输入设备名称",
trigger: "blur",
},
],
model: [
{
required: true,
type: "string",
message: "请输入设备型号",
trigger: "blur",
},
],
manufacturer_name: [
{
required: true,
type: "string",
message: "请输入生产厂家",
trigger: "blur",
},
],
purchase_date: [
{
required: true,
type: "date",
message: "请选择采购日期",
trigger: "change",
},
],
storage_date: [
{
required: true,
type: "date",
message: "请选择入库时间",
trigger: "change",
},
],
duty_persons: [
{
required: true,
type: "array",
min: 1,
message: "请输入责任人",
trigger: "change",
},
],
storage_location: [
{
required: true,
type: "string",
message: "请输入存放位置",
trigger: "blur",
},
],
maintenance_cycle: [
{
required: true,
type: "string",
message: "请输入维护周期",
trigger: "change",
},
],
manitenance_cycle_unit: [
{
required: true,
type: "number",
message: "请选择周期单位",
trigger: "change",
},
],
classification_id: [
{
required: true,
type: "string",
message: "请选择设备分类",
trigger: "change",
},
],
last_time_maintenance_date: [
{
required: true,
type: "date",
message: "请选择上次维护日期",
trigger: "change",
},
],
status: [
{
required: true,
type: "string",
message: "请选择设备状态",
trigger: "change",
},
],
},
},
downloadLoading: false,
});
/**
* 设备借用记录
* */
// 分页改变
const handleBorrowRecordPageChange = (page) => {
init.borrowRecord.params.page_index = page;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
// 页大小改变
const handleBorrowRecordPageSizeChange = (size) => {
init.borrowRecord.params.page_size = size;
init.borrowRecord.params.page_index = 1;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
/**
* 设备借用记录
* */
/**
* 设备
* */
//切换日历视图
function changeClendar(e) {
init.equipmentBorrowingStatus.params.month = dayjs(e).format('YYYY-MM')
handleSubmit(init.equipmentBorrowingStatus.itemData, 'equipmentBorrowingStatus')
}
const outBoundForm = ref()
const inBoundForm = ref()
//提交操作
function handleSubmit(row, type) {
const strategy = {
//借用状态
equipmentBorrowingStatus: () => {
init.equipmentBorrowingStatus.title = row.name
init.equipmentBorrowingStatus.itemData = row;
init.equipmentBorrowingStatus.show = true;
init.equipmentBorrowingStatus.loading = true;
api
.getApiEquipmentEquipmentCalendar({
...init.equipmentBorrowingStatus.params,
equipment_id: row.id,
})
.then((res) => {
init.equipmentBorrowingStatus.list = res.response;
init.equipmentBorrowingStatus.loading = false;
});
},
//借用记录
borrow: () => {
init.borrowRecord.itemData = row;
init.borrowRecord.show = true;
init.borrowRecord.loading = true;
api
.getApiEquipmentEquipmentLendLsit({
...init.borrowRecord.params,
equipment_id: row.id,
})
.then((res) => {
init.borrowRecord.list = res.response.data;
init.borrowRecord.total = res.response.data_count;
init.borrowRecord.loading = false;
});
},
//删除设备
delete: () => {
console.log("删除");
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentDelete({
equipment_id: row.id,
})
.then(
(res) => {
let responseInfo = res.response
// {
// "euqipment_id": "1938161312374853632",
// "repair_item_id": 21107
// }
///api/Repair/DeleteMiddleItem
// logistics/api/repair/Area/MoidfiyStatus 细项停用0/启用1
// {"id":[1070101],"use_flag":1}
/**
* 报修细项同步
* */
//变更报修系统细项
bxApi.setAreaItemStatus({"id":[responseInfo.repair_item_id],"use_flag":0}).then(_res=>{
//删除中间表对应关系
api.getApiRepairDeleteMiddleItem({classification_equipment_id: responseInfo.euqipment_id})
})
/**
* 报修细项同步
* */
EquipmentList();
return res;
},
"提交中...",
false
);
});
},
'设备归还': () => {
console.log("🚀🚀🚀,", init.inBound.formDate)
inBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentReturn({
...init.inBound.formDate,
returnee_id: init.inBound.returnee_ids
.map((cur) => cur.tid)
.join(";"),
return_date: dayjs(row.return_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.inBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
},
'设备出库': () => {
outBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentOut({
...init.outBound.formDate,
equipment_id: row.equipment_id,
duty_person_tid: init.outBound.duty_person_tids
.map((cur) => cur.tid)
.join(";"),
lender_tid: init.outBound.lender_tids
.map((cur) => cur.tid)
.join(";"),
plan_end_date: dayjs(row.plan_end_date).format(
"YYYY-MM-DD HH:mm:ss"
),
out_date: dayjs(row.out_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.outBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
}
};
strategy[type]();
}
//出库
function outbound(row) {
init.outBound.title = row.name
init.outBound.formDate = {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
}
init.outBound.duty_person_tids = [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
]
init.outBound.lender_tids = []
init.outBound.formDate = {
...init.outBound.formDate,
equipment_id: row.id
};
init.outBound.show = true;
init.outBound.loading = true;
outBoundForm.value.resetFields()
}
//入库归还
function inbound(row) {
init.inBound.title = row.name
init.inBound.returnee_ids = []
init.inBound.formDate = {}
init.inBound.formDate = {
...init.inBound.formDate,
equipment_id: row.id
};
init.inBound.show = true;
init.inBound.loading = true;
inBoundForm.value.resetFields()
console.log("🚀🚀🚀,", init.inBound.formDate)
}
//获取设备编辑数据
function edit(row) {
console.log(row)
init.devices.show = true;
init.devices.loading = true;
init.devices.formData = {
...init.devices.formData,
...row,
status: String(row.status),
maintenance_cycle: String(row.maintenance_cycle),
manitenance_cycle_unit: String(row.manitenance_cycle_unit),
duty_person: row.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(row.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(row.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
row.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
};
init.devices.flag = "edit";
}
// 获取设备列表
const EquipmentList = async () => {
try {
loading.value = true;
// TODO: 调用接口获取角色用户列表
api.postApiEquipmentEquipmentList(init.devices.params).then((res) => {
userList.value = res.response.data;
init.devices.total = res.response.data_count;
loading.value = false;
});
} catch (error) {
loading.value = false;
Message.error("加载用户列表失败");
}
};
// 搜索用户
const handleSearch = (value) => {
init.devices.params = {
...init.devices.params,
...value,
page_index: 1,
page_size: 10,
};
EquipmentList();
};
// 重置
const handleReset = () => {
init.devices.params = {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
};
init.pageKey = Date.now();
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
searchFormRef.value.searchCondObj.classification_id = cur.options[0].id;
init.devices.params.classification_id = cur.options[0].id;
}
});
EquipmentList();
};
// 分页改变
const handlePageChange = (page) => {
init.devices.params.page_index = page;
EquipmentList();
};
// 页大小改变
const handlePageSizeChange = (size) => {
init.devices.params.page_size = size;
init.devices.params.page_index = 1;
EquipmentList();
};
// 添加设备
const handleAdd = () => {
init.devices.flag = 'add'
init.devices.formData = {
"name": "",
"model": "",
"unique_id": "",
"manufacturer_name": "",
"purchase_date": "",
"storage_date": "",
"duty_person": "",
"duty_persons": [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
],
"storage_location": "",
"maintenance_cycle": '0',
"manitenance_cycle_unit": '1',
"classification_id": "",
"last_time_maintenance_date": "",
"status": '0',
"need_dept_audit": 0,
"need_worth_audit": 0
};
init.devices.show = true;
deviceForm.value.resetFields();
};
// 下载模板
const handleDownloadTemplate = async () => {
try {
init.downloadLoading = true;
// TODO: 实现下载模板功能
init.downloadLoading = false;
} catch (error) {
init.downloadLoading = false;
Message.error("下载模板失败");
}
};
const deviceForm = ref();
// 删除用户
const handleRemoveUser = async (row) => {
try {
// TODO: 调用接口删除用户
Message.success("删除成功");
EquipmentList();
} catch (error) {
Message.error("删除失败");
}
};
// 提交设备表单
const handleSubmitDevice = () => {
const strategy = {
add: () => {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentAdd({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
// last_time_maintenance_date: dayjs(
// init.devices.formData.last_time_maintenance_date
// ).format("YYYY-MM-DD HH:mm:ss"),
})
.then(
(res) => {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
const responseInfo = res.response
//获取细项id
bxApi.GetId({parent_id: responseInfo.classification_reparir_item}).then((getAreaChildren) => {
//提交细项
bxApi.addItem({
"parent_id": responseInfo.classification_reparir_item,
"id": getAreaChildren.response,
"name": responseInfo.equipment_name
}).then(_res => {
//双系统信息,同步到中间表
api.getApiRepairAddMiddleItem({
classification_equipment_id: responseInfo.equipment_id,
repair_item: getAreaChildren.response
})
})
})
/**
* 报修细项同步
* */
return res;
},
"提交中...",
false
);
});
},
edit: () => {
console.log(init.devices.formData)
hooks.myEncapsulationFunction(() => {
return api.postApiEquipmentEquipmentUpdate({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
init.devices.formData.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
}).then((res) => {
if (res.code === 1) {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
//获取细项id
api.getApiRepairQueryById({classification_equipment_id: init.devices.formData.id}).then((getAreaChildren) => {
//提交细项
bxApi.modifyItem({
"id": getAreaChildren.response.repair_item_id,
"name": init.devices.formData.name
})
})
/**
* 报修细项同步
* */
return res;
}
});
}, false, '提交中...');
},
};
deviceForm.value.validate((valid) => {
if (valid) {
strategy[init.devices.flag]();
}
});
};
// 树格式化
function treeFormat(arr) {
return arr.map((a) => {
if (a.children && a.children.length != 0) {
a.children = treeFormat(a.children);
}
return {
...a,
title: a.name,
value: a.id,
expand: true,
selected: false,
};
});
}
const searchFormRef = ref()
function getTreeData() {
return api.getApiEquipmentGetEquipmentClassificationTree().then((res) => {
init.devices.treeData = treeFormat(res.response);
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
cur.options = treeFormat(res.response);
searchFormRef.value.searchCondObj.classification_id = res.response[0].id;
init.devices.params.classification_id = res.response[0].id;
}
});
return res
});
}
/**人员选择器 */
// 人员选择器》添加用户对话框
const addUserModal = reactive({
flag: '',
pageKey: '',
params: {
page_index: 1,
page_size: 10,
query: "",
},
total: 0,
show: false,
loading: false,
keyword: "",
batchUserList: [],
userList: [],
dutyDepts: [],
availableUserColumns: [
// {
// align: "center",
// type: "selection",
// width: 60,
// },
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
],
});
// 部门列表
const departmentOptions = ref([]);
// 人员选择器》搜索可添加的用户
const searchAvailableUsers = async () => {
loadRoleUsers();
};
//弹出人员选择器
function showAddUser(key) {
addUserModal.flag = key
setPeopleColumnsData()
addUserModal.params = {
page_index: 1,
page_size: 10,
query: "",
}
addUserModal.pageKey = new Date();
addUserModal.show = true;
addUserModal.batchUserList = [];
loadRoleUsers()
}
//批量提交选中人员
function batchAddUser() {
const strategy = {
//新增设备 批量
'入库责任人': () => {
const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
let data = []
addUserModal.batchUserList.forEach((cur, index) => {
//不包含
if (!dataId.includes(cur.tid)) {
data.push(cur)
}
})
init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
addUserModal.show = false;
},
// '出库责任人':()=>{
// const dataId = init.outBound.duty_person_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.duty_person_tids = init.outBound.duty_person_tids.concat(data);
// addUserModal.show = false;
// },
// '出库借用人':()=>{
// const dataId = init.outBound.lender_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.lender_tids = init.outBound.lender_tids.concat(data);
// addUserModal.show = false;
// },
// '归还人':()=>{
// const dataId = init.inBound.returnee_ids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.inBound.returnee_ids = init.inBound.returnee_ids.concat(data);
// addUserModal.show = false;
// },
}
strategy[addUserModal.flag]()
}
//选中人员
function onSelectionChange(e) {
console.log('e', e)
addUserModal.batchUserList = e;
}
// 人员选择器》确认添加用户
const confirmAddUser = async (user) => {
console.log("🚀🚀🚀,", user)
const strategy = {
// '入库责任人':()=>{
// const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
// console.log("🚀🚀111🚀,", init.devices.formData.duty_persons)
// addUserModal.show = false;
// },
'出库责任人': () => {
init.outBound.duty_person_tids = [user];
addUserModal.show = false;
},
'出库借用人': () => {
init.outBound.lender_tids = [user];
addUserModal.show = false;
},
'归还人': () => {
init.inBound.returnee_ids = [user];
addUserModal.show = false;
},
}
strategy[addUserModal.flag]()
};
// 加载人员选择器用户
const loadRoleUsers = () => {
addUserModal.loading = true;
try {
api
.getApiCommonUserSelect({
...addUserModal.params,
query: addUserModal.keyword,
})
.then((res) => {
addUserModal.userList = res.response.data || [];
addUserModal.total = res.response.data_count;
})
.catch((error) => {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
})
.finally(() => {
addUserModal.loading = false;
});
} catch (error) {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
addUserModal.loading = false;
}
};
// 分页改变
const handleAddUserPageChange = (page) => {
addUserModal.params.page_index = page;
loadRoleUsers()
};
// 页大小改变
const handleAddUserPageSizeChange = (size) => {
addUserModal.params.page_size = size;
addUserModal.params.page_index = 1;
loadRoleUsers()
};
//配置人员列表列数据
function setPeopleColumnsData() {
function name() {
addUserModal.availableUserColumns = [
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
]
}
const strategy = {
'入库责任人': () => {
addUserModal.availableUserColumns = [
{
align: "center",
type: "selection",
width: 60,
},
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
]
},
'出库责任人': () => name(),
'出库借用人': () => name(),
'归还人': () => name(),
}
strategy[addUserModal.flag]()
}
/**人员选择器 */
/**
* 设备报修
* */
//显示报修
function showRepair(row) {
getRepairAreaTree()
getRepairItemTree()
init.repair.formData ={
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
}
init.repair.title = row.name
init.repair.formData.name = deviceProjectStore.state.userInfo.name + '(' + deviceProjectStore.state.userInfo.card + ')'
init.repair.show = true
repairForm.value.resetFields()
init.repair.loading = true
//获取报修系统细项id
api.getApiRepairQueryById({classification_equipment_id: row.id}).then(res => {
init.repair.formData.item_id = String(res.response.repair_item_id)
}).finally(() => {
init.repair.loading = false
})
}
//遍历树形结构
function traverseTree(Array) {
return Array.map(item => {
if (item.children && item.children.length > 0) item.children = traverseTree(item.children)
return {
...item,
value: item.key
}
})
}
//获取报修区域
function getRepairAreaTree() {
bxApi.getRepairAreaTree().then(res => {
init.repair.areaTree = traverseTree(res.response)
})
}
//获取报修项目
function getRepairItemTree() {
bxApi.getRepairItemTree().then(res => {
init.repair.itemTree = traverseTree(res.response)
})
}
//附件上传
function beforeRepairFileUpload(file, type) {
console.log(file)
let f = new FormData();
f.append('file', file)
hooks.myEncapsulationFunction(() => {
return bxApi.uploadRepairImage({systemType: 0}, f, {headers: {'Content-Type': 'multipart/form-data'}}).then(res => {
if (res.code === 1) {
if (type === '报修附件') {
init.repair.formData.file_list = init.repair.formData.file_list.concat(res.response)
} else {
init.repair.formData.key_file_list = init.repair.formData.key_file_list.concat(res.response)
}
}
return res
})
}, false, '正在上传中...')
return false
}
const repairForm = ref()
//通过节点id,获取节点名称
function getAreaNameById(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.item_text = item.title
})
}
function getAreaNameById2(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.area_text = item.title
})
}
//提交报修
function handleRepairSubmit() {
getAreaNameById(init.repair.formData.item_id, init.repair.itemTree)
getAreaNameById2(init.repair.formData.area_id, init.repair.areaTree)
// console.log(111, {
// ...init.repair.formData,
// key_file_list: init.repair.formData.key_file_list.join(','),
// file_list: init.repair.formData.file_list.join(','),
//
// })
repairForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return bxApi.submitRepair({
...init.repair.formData,
key_file_list: init.repair.formData.key_file_list.map(cur => cur.id).join(','),
file_list: init.repair.formData.file_list.map(cur => cur.id).join(','),
}).then(res => {
//
api.getApiRepairRegisterRepair({
repair_item_id: init.repair.formData.item_id,
repair_out_id: res.response}
).then(()=>{
init.repair.show = false
EquipmentList()
})
return res
})
}, false, '正在提交中...')
}
})
}
/**
* 设备报修
* */
onMounted(() => {
getRepairAreaTree()
getRepairItemTree()
loading.value = true;
getTreeData().then(res => {
EquipmentList();
});
});
</script>
<style scoped>
.role-container {
display: flex;
min-height: calc(100vh - 150px);
/* border: 1px solid #e8eaec; */
border-radius: 4px;
overflow: auto;
gap: 16px;
}
.role-sidebar {
width: 300px;
border-right: 1px solid #e8eaec;
background-color: #fff;
overflow-y: auto;
height: 200px;
}
.role-title {
padding: 16px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #e8eaec;
}
.role-list {
padding: 10px 0;
}
.role-item {
display: flex;
align-items: center;
padding: 12px 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.role-item:hover {
background-color: #f0f0f0;
}
.role-item.active {
background-color: #e8f7ff;
color: #2d8cf0;
}
.role-item-icon {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
color: #fff;
}
.role-admin {
background-color: #2d8cf0;
}
.role-party-office {
background-color: #19be6b;
}
.role-entrance-dept {
background-color: #ff9900;
}
.role-responsible-dept {
background-color: #ed4014;
}
.role-item-info {
flex: 1;
}
.role-name {
font-size: 14px;
margin-bottom: 4px;
}
.role-count {
font-size: 12px;
color: #808695;
}
.role-content {
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
}
.role-toolbar {
height: 100%;
display: flex;
flex-direction: column;
gap: 20px;
top: 0;
background-color: #fff;
z-index: 1;
}
.search-box {
width: 280px;
}
.pagination {
/* margin-top: 16px; */
text-align: center;
position: sticky;
bottom: 0;
background-color: #fff;
z-index: 1;
}
.action-btns {
display: flex;
justify-content: center;
}
.user-avatar {
display: flex;
justify-content: center;
align-items: center;
}
.user-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.add-user-search {
margin-bottom: 16px;
display: flex;
}
.duty-dept-select {
margin-bottom: 16px;
}
</style>
<style lang='less' scoped>
.filelist {
cursor: pointer;
}
.filelist:hover {
color: #1e93ff;
background-color: #f7f7f7;
}
.fileddelete {
cursor: pointer;
margin-left: auto;
}
.fileddelete:hover {
color: red;
transform: scale(1.5);
}
</style>
<template>
<div style="width: 100%; height: 100%">
<!-- 右侧人员列表 -->
<div class="role-content">
<!-- 搜索和工具栏 -->
<div class="role-toolbar">
<initForm
ref="searchFormRef"
:searchCondList="init.searchList"
@on-submit="handleSearch"
@on-reset="handleReset"
/>
<!-- 表格工具栏 -->
<div class="operation-bar">
<Button type="primary" @click="handleAdd">
<Icon type="md-add"/>
新增设备
</Button>
<!-- <Button class="ivu-ml-8" @click="handleImport"><Icon type="md-cloud-upload" /> 导入设备</Button>-->
<!-- <Button-->
<!-- class="ivu-ml-8"-->
<!-- @click="handleDownloadTemplate"-->
<!-- :loading="init.downloadLoading"-->
<!-- ><Icon type="md-download" /> 下载模板</Button-->
<!-- >-->
<!-- <Button class="ivu-ml-8" @click="handleExport"><Icon type="md-download" /> 导出数据</Button>-->
</div>
</div>
<!-- 设备表格 -->
<Table :loading="loading" :columns="userColumns" :data="userList" border>
<template #action="{ row }">
<div class="action-btns" style="display: flex; align-items: center">
<a href="javascript:;" @click="handleSubmit(row, 'borrow')"
>借用记录</a
>
<Divider type="vertical"/>
<a
href="javascript:;"
@click="handleSubmit(row, 'equipmentBorrowingStatus')"
>借用状态</a
>
<Divider type="vertical"/>
<a href="javascript:;" @click="outbound(row)">出库</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="inbound(row)">归还</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="showRepair(row)">报修</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="edit(row)">编辑</a>
<Divider type="vertical"/>
<Poptip
confirm
transfer
title="确定要删除该设备吗?"
@on-ok="handleSubmit(row, 'delete')"
>
<a href="javascript:;">删除</a>
</Poptip>
</div>
</template>
<template #duty_person="{ row }">
<Tag
color="blue"
v-for="(item, index) in row.duty_persons"
:key="index"
>
{{ item.name }}
</Tag>
</template>
<template #status="{ row }">
<Tag :color="['success', 'blue', 'warning'][Number(row.status)]">
{{ ["空闲", "使用中", "维修中"][Number(row.status)] }}
</Tag>
</template>
<template #need_dept_audit="{ row }">
{{ row.need_dept_audit === 1 ? "需要" : "不需要" }}
</template>
<template #need_worth_audit="{ row }">
{{ row.need_worth_audit === 1 ? "需要" : "不需要" }}
</template>
</Table>
<!-- 分页 -->
<div class="pagination">
<Page
:key="init.pageKey"
:total="init.devices.total"
:current="init.devices.params.page_index"
:page-size="init.devices.params.page_size"
show-elevator
:show-sizer="true"
show-total
:page-size-opts="[10, 20, 50, 100]"
:transfer="true"
@on-change="handlePageChange"
@on-page-size-change="handlePageSizeChange"
/>
</div>
</div>
</div>
<!-- 添加设备对话框 -->
<Modal
v-model="init.devices.show"
title="设备信息"
width="700"
>
<Form
ref="deviceForm"
:model="init.devices.formData"
:rules="init.devices.rules"
:label-width="100"
>
<Row :gutter="16">
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备编号" prop="unique_id1">
<Input
v-model="init.devices.formData.unique_id"
placeholder="请输入设备编号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备名称" prop="name">
<Input
v-model="init.devices.formData.name"
placeholder="请输入设备名称"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备型号" prop="model1">
<Input
v-model="init.devices.formData.model"
placeholder="请输入设备型号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="生产厂家" prop="manufacturer_name1">
<Input
v-model="init.devices.formData.manufacturer_name"
placeholder="请输入生产厂家"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="采购日期" prop="purchase_date">
<DatePicker
v-model="init.devices.formData.purchase_date"
type="datetime"
placeholder="选择采购日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="入库时间" prop="storage_date">
<DatePicker
v-model="init.devices.formData.storage_date"
type="datetime"
placeholder="选择入库时间"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="责任人" prop="duty_persons">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.devices.formData.duty_persons"
:key="index"
closable
@on-close="init.devices.formData.duty_persons.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('入库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="存放位置" prop="storage_location">
<Input
v-model="init.devices.formData.storage_location"
placeholder="请输入存放位置"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备分类" prop="classification_id">
<TreeSelect
v-model="init.devices.formData.classification_id"
placeholder="请选择设备分类"
:data="init.devices.treeData"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="维护周期" prop="maintenance_cycle">
<Input
v-model="init.devices.formData.maintenance_cycle"
style="width: 60%"
clearable
/>
<Select
v-model="init.devices.formData.manitenance_cycle_unit"
style="width: 35%; margin-left: 5%"
>
<Option value="1">年</Option>
<Option value="2">月</Option>
<Option value="3">天</Option>
</Select>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备状态" prop="status">
<Select v-model="init.devices.formData.status" clearable>
<Option value="0">空闲</Option>
<Option value="1">使用中</Option>
<Option value="2">维修中</Option>
</Select>
</FormItem>
</Col>
<Col v-if="init.devices.flag == 'edit'" :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="上次维护日期" prop="last_time_maintenance_date">
<DatePicker
v-model="init.devices.formData.last_time_maintenance_date"
type="datetime"
placeholder="选择上次维护日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="部门审核" prop="need_dept_audit">
<Switch
v-model="init.devices.formData.need_dept_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="价值审核" prop="need_worth_audit">
<Switch
v-model="init.devices.formData.need_worth_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.devices.show = false">取消</Button>
<Button type="primary" @click="handleSubmitDevice">确定</Button>
</template>
</Modal>
<!-- 借用记录对话框 -->
<Modal
v-model="init.borrowRecord.show"
title="借用记录"
width="60%"
:mask-closable="false"
>
<Table
:loading="init.borrowRecord.loading"
:columns="init.borrowRecordColumns"
:data="init.borrowRecord.list"
border
>
<template #status="{ row }">
<Tag
:color="
row.status === 1
? 'success'
: row.status === 2
? 'warning'
: 'default'
"
>
{{
row.status === 1 ? "已归还" : row.status === 2 ? "使用中" : "待审核"
}}
</Tag>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:total="init.borrowRecord.total"
:current="init.borrowRecord.params.page_index"
:page-size="init.borrowRecord.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleBorrowRecordPageChange"
@on-page-size-change="handleBorrowRecordPageSizeChange"
/>
</div>
<template #footer>
<Button @click="init.borrowRecord.show = false">关闭</Button>
</template>
</Modal>
<!-- 添加用户对话框 -->
<Modal
:styles="{top:'10px'}"
v-model="addUserModal.show"
:title="'人员数据'"
width="700"
:mask-closable="false"
>
<div class="add-user-search">
<Input
v-model="addUserModal.keyword"
placeholder="输入姓名或工号搜索用户"
search
clearable
enter-button
@on-search="searchAvailableUsers"
/>
<Button v-if="addUserModal.flag == '入库责任人'" style="margin-left: 10px" type="primary" @click="batchAddUser"
>批量添加
</Button
>
</div>
<!-- 负责部门选择 - 只在角色为责任部门时显示 -->
<div class="duty-dept-select" v-if="false">
<Form>
<FormItem
label="负责部门"
:label-width="80"
:rules="[
{
required: true,
type: 'array',
min: 1,
message: '请至少选择一个负责部门',
trigger: 'change',
},
]"
>
<Select
v-model="addUserModal.dutyDepts"
multiple
filterable
placeholder="请选择负责部门(可多选)"
style="width: 100%"
>
<Option
v-for="dept in departmentOptions"
:key="dept.value"
:value="dept.value"
>
{{ dept.label }}
</Option>
</Select>
</FormItem>
</Form>
</div>
<!-- 可添加用户列表 -->
<Table
@on-selection-change="onSelectionChange"
:loading="addUserModal.loading"
:columns="addUserModal.availableUserColumns"
:data="addUserModal.userList"
border
>
<!-- 照片列 -->
<template #avatar="{ row }">
<div class="user-avatar">
<Avatar v-if="row.photo" size="large" :src="row.photo"/>
<Avatar v-else icon="ios-person" size="large"/>
</div>
</template>
<!-- 操作列 -->
<template #action="{ row }">
<div class="action-btns">
<Button type="primary" size="small" @click="confirmAddUser(row)"
>添加
</Button
>
</div>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:key="addUserModal.pageKey"
:total="addUserModal.total"
:current="addUserModal.params.page_index"
:page-size="addUserModal.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleAddUserPageChange"
@on-page-size-change="handleAddUserPageSizeChange"
/>
</div>
<template #footer>
<Button @click="addUserModal.show = false">关闭</Button>
</template>
</Modal>
<!-- 出库对话框 -->
<Modal
v-model="init.outBound.show"
:title="init.outBound.title+'-设备出库'"
width="500"
>
<Form
ref="outBoundForm"
:model="init.outBound.formDate"
:rules="init.outBound.rules"
:label-width="100"
>
<FormItem label="借用人" prop="lender_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.lender_tids"
:key="index"
closable
@on-close="init.outBound.lender_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库借用人')"
>
添加借用人
</Button>
</div>
</FormItem>
<FormItem label="预计归还日期" prop="plan_end_date">
<DatePicker
v-model="init.outBound.formDate.plan_end_date"
type="datetime"
placeholder="选择预计归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库日期" prop="out_date">
<DatePicker
v-model="init.outBound.formDate.out_date"
type="datetime"
placeholder="选择出库日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库责任人" prop="duty_person_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.duty_person_tids"
:key="index"
closable
@on-close="init.outBound.duty_person_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
<FormItem label="备注" prop="application_remark">
<Input
v-model="init.outBound.formDate.application_remark"
type="textarea"
placeholder="请输入备注信息"
:rows="4"
/>
</FormItem>
</Form>
<template #footer>
<Button @click="init.outBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.outBound.formDate,'设备出库')">确定</Button>
</template>
</Modal>
<!-- 设备归还入库 -->
<Modal
v-model="init.inBound.show"
:title="init.inBound.title+'-归还入库'"
width="500"
>
<Form
ref="inBoundForm"
:model="init.inBound.formDate"
:rules="init.inBound.rules"
:label-width="100"
>
<FormItem label="归还日期" prop="return_date">
<DatePicker
v-model="init.inBound.formDate.return_date"
type="datetime"
placeholder="选择归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="归还人" prop="returnee_ids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.inBound.returnee_ids"
:key="index"
closable
@on-close="init.inBound.returnee_ids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('归还人')"
>
添加归还人
</Button>
</div>
</FormItem>
</Form>
<template #footer>
<Button @click="init.inBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.inBound.formDate,'设备归还')">确定</Button>
</template>
</Modal>
<!--设备借用状态-->
<Drawer
:draggable="true"
:styles="{padding: '0px'}"
v-model="init.equipmentBorrowingStatus.show"
:title="init.equipmentBorrowingStatus.title+'-借用状态'"
width="70%"
placement="right"
>
<div style="width: 100%;height: calc(100% - 60px);padding: 16px">
<DatePicker
v-if="false"
v-model="init.equipmentBorrowingStatus.params.month"
type="month"
placeholder="选择月份"
style="width: 200px; margin-bottom: 16px;"
@on-change="handleSubmit(init.equipmentBorrowingStatus.itemData,'equipmentBorrowingStatus')"
/>
<Calendar
:loading="init.equipmentBorrowingStatus.loading"
v-model="init.equipmentBorrowingStatus.params.month"
hide-type
@on-change="changeClendar"
>
<template #month="{date, data}">
<div>
<Badge
:status="['','error','warning'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
:text="['','占用中','维修中'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
v-if="init.equipmentBorrowingStatus.list.map(cur=>cur.occupy_date).includes(data.day) "/>
<Badge status="success" text="空闲" v-else/>
</div>
</template>
</Calendar>
</div>
<div
style="width: 100%;height: 60px;display: flex;justify-content: center;align-items: center;box-shadow: 0 0 8px darkgray">
<Button style="width: 150px" @click="init.equipmentBorrowingStatus.show =false">关闭</Button>
</div>
</Drawer>
<!-- 设备报修表单 -->
<Modal
v-model="init.repair.show"
:title="init.repair.title +'-设备报修'"
:mask-closable="false"
:closable="true"
width="50%"
@on-cancel="init.repair.show = false"
>
<Form
:model="init.repair.formData"
:rules="init.repair.rules"
ref="repairForm"
label-width="100"
>
<Row :gutter="16" type="flex" style="flex-wrap: wrap;">
<!-- 报修人 -->
<Col :xs="24" :sm="12">
<FormItem label="报修人" prop="name">
<Input
:disabled="true"
v-model="init.repair.formData.name"
placeholder="请输入报修人"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 联系方式 -->
<Col :xs="24" :sm="12">
<FormItem label="联系方式" prop="phone">
<Input
v-model="init.repair.formData.phone"
placeholder="请输入联系电话"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 报修区域 -->
<Col :xs="24" :sm="12">
<FormItem label="报修区域" prop="area_id">
<TreeSelect
v-model="init.repair.formData.area_id"
:data="init.repair.areaTree"
placeholder="请选择报修区域"
style="width: 100%;"
:clearable="true"
/>
</FormItem>
</Col>
<!-- 详细地址 -->
<Col :xs="24" :sm="12">
<FormItem label="详细地址" prop="areaDetail">
<Input
v-model="init.repair.formData.areaDetail"
placeholder="请输入报修详细地址"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修项目 -->
<Col :xs="24" :sm="12">
<FormItem label="报修项目" prop="item_id">
<div style="display: flex;">
<TreeSelect
:disabled="true"
v-model="init.repair.formData.item_id"
:data="init.repair.itemTree"
placeholder="请选择报修项目"
style="width: 100%;"
:clearable="true"
/>
<Spin v-if="init.repair.loading"></Spin>
</div>
</FormItem>
</Col>
<!-- 报修详细 -->
<Col :xs="24" :sm="12">
<FormItem label="报修详细" prop="itemDetail">
<Input
v-model="init.repair.formData.itemDetail"
placeholder="请输入报修详细"
maxlength="200"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修附件 -->
<Col :xs="24" :sm="12">
<FormItem label="报修附件" prop="file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '报修附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.file_list = init.repair.formData.file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
<!-- 钥匙备注 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙备注" prop="key_remark">
<Input
v-model="init.repair.formData.key_remark"
placeholder="请输入钥匙备注"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 钥匙附件 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙附件" prop="key_file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '钥匙附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.key_file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.key_file_list = init.repair.formData.key_file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.repair.show = false">取消</Button>
<Button type="primary" @click="handleRepairSubmit">提交报修</Button>
</template>
</Modal>
</template>
<script setup>
import {deviceProjectStore} from '@/store/deviceProjectStoree'
import initForm from "@/components/initForm";
import {ref, onMounted, reactive, computed} from "vue";
import {
Badge, Button,
Calendar,
DatePicker, Drawer,
FormItem,
Message,
Modal,
Page,
Row,
Switch,
Tag, TreeSelect, Upload,
} from "view-ui-plus";
import * as api from "@/api/allApi/controller/index";
import * as hooks from "@/hook/index";
import * as bxApi from '@/api/logisticsApi/index'
import dayjs from "dayjs";
import {setAreaItemStatus, submitRepair} from "@/api/logisticsApi/index";
// 角色列表
const roleList = ref([
{
role_type: 0,
role_name: "设备审核",
count: 14,
},
{
role_type: 1,
role_name: "耗材审核",
count: 4,
},
]);
// 表单值
const formValues = ref({});
// 用户表格列定义
const userColumns = computed(() => {
const columns = [
{
title: "#",
type: "index",
width: 60,
},
{
title: "设备编号",
key: "unique_id",
minWidth: 150,
},
{
title: "设备名称",
key: "name",
minWidth: 150,
},
{
title: "设备型号",
key: "model",
minWidth: 150,
},
{
title: "设备分类",
key: "classification_name",
minWidth: 150,
},
{
title: "生产厂家",
key: "manufacturer_name",
minWidth: 150,
},
{
title: "采购日期",
key: "purchase_date",
minWidth: 150,
},
{
title: "入库时间",
key: "storage_date",
width: 150,
},
{
title: "责任人",
slot: "duty_person",
minWidth: 160,
},
{
title: "存放位置",
key: "storage_location",
minWidth: 150,
},
{
title: "维护周期",
key: "maintenance_cycle",
minWidth: 150,
render: (h, params) => {
return h('span', params.row.maintenance_cycle + ['', '年', '月', '天'][params.row.manitenance_cycle_unit])
},
},
{
title: "设备状态",
slot: "status",
minWidth: 150,
},
{
title: "部门审核",
key: "need_dept_audit",
minWidth: 100,
slot: "need_dept_audit",
},
{
title: "价值审核",
key: "need_worth_audit",
minWidth: 100,
slot: "need_worth_audit",
},
];
// 添加操作列
columns.push({
title: "操作",
slot: "action",
width: 420,
align: "center",
fixed: "right",
});
return columns;
});
// 加载状态
const loading = ref(false);
// 用户列表
const userList = ref([]);
const init = reactive({
pageKey:'',
//报修
repair: {
loading: true,
show: false,
// 表单校验规则,确保用户输入的有效性
rules: {
name: [
{required: true, message: '请输入报修人姓名', trigger: 'change'}
],
area_id: [
{required: true, message: '请选择报修区域', trigger: 'change'}
],
item_id: [
{required: true, message: '请选择报修项目', trigger: 'change'}
],
phone: [
{required: true, message: '请输入联系电话', trigger: 'blur'},
{pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号', trigger: 'blur'}
],
areaDetail: [
{required: true, message: '请输入详细地址', trigger: 'blur'}
],
},
formData: {
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
},
areaTree: [],
itemTree: [],
},
// 借用记录相关数据
equipmentBorrowingStatus: {
title: '',
itemData: {},
show: false,
loading: false,
params: {
month: dayjs().format('YYYY-MM'),
equipment_id: "",
},
list: []
},
borrowRecord: {
itemData: {},
params: {
page_index: 1,
page_size: 10,
equipment_id: "",
},
show: false,
loading: false,
list: [],
total: 0,
pageIndex: 1,
pageSize: 10,
},
// 借用记录表格列定义
borrowRecordColumns: [
{
title: "设备名称",
key: "equipment_name",
minWidth: 100,
},
{
title: "责任人",
key: "duty_person_name",
minWidth: 100,
},
{
title: "责任人工号",
key: "duty_person_card",
minWidth: 120,
},
{
title: "借出人",
key: "lender_name",
minWidth: 100,
},
{
title: "借出人工号",
key: "lender_card",
minWidth: 120,
},
{
title: "出入库类型",
key: "storage_status_shift_type",
minWidth: 120,
},
{
title: "出入库日期",
key: "storage_status_shift_date",
minWidth: 120,
},
{
title: "备注",
key: "application_remark",
minWidth: 150,
},
],
searchList: [
{
label: "设备名称",
code: "equipment_name",
search_type: "input",
is_must: 0,
option_list: null,
option_cascade_list: null,
},
{
label: "设备分类",
code: "classification_id",
search_type: "treeselect",
is_must: 0,
options: [],
},
{
label: "设备状态",
code: "status",
search_type: "select",
is_must: 0,
option_list: [
{
label: "空闲",
value: "0",
},
{
label: "使用中",
value: "1",
},
{
label: "维修中",
value: "2",
},
],
option_cascade_list: null,
},
],
inBound: {
show: false,
returnee_ids: [],
formDate: {
equipment_id: '', // 设备id
return_date: '', // 归还日期
returnee_id: '', // 归还人tid
},
rules: {
return_date: [
{
required: true,
type: "date",
message: "请选择归还日期",
trigger: "change"
}
],
returnee_ids: [
{
required: true,
type: "array",
message: "请添加一位归还人",
trigger: "change",
validator: (rule, value, callback) => {
if (!init.inBound.returnee_ids || init.inBound.returnee_ids.length === 0) {
callback(new Error("请添加一位归还人"));
} else {
callback();
}
}
}
]
},
loading: false,
list: [],
},
outBound: {
title: '',
show: false,
duty_person_tids: [],
lender_tids: [],
formDate: {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
},
rules: {
plan_end_date: [
{
required: true,
type: "date",
message: "请选择预计归还日期",
trigger: "change"
}
],
out_date: [
{
required: true,
type: "date",
message: "请选择出库日期",
trigger: "change"
}
],
duty_person_tids: [
{
required: true,
type: "array",
message: "请添加一位出库责任人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.duty_person_tids.length === 0) {
callback(new Error("请添加一位出库责任人"))
} else {
callback()
}
}
}
],
lender_tids: [
{
required: true,
type: "array",
message: "请添加一位借用人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.lender_tids.length === 0) {
callback(new Error("请添加一位借用人"))
} else {
callback()
}
}
}
],
application_remark: [
{
required: false,
type: "string",
message: "请输入备注信息",
trigger: "blur"
}
]
},
loading: false,
list: [],
},
devices: {
flag: "add",
total: 0,
params: {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
},
show: false,
treeData: [],
formData: {
name: "",
model: "",
unique_id: "",
manufacturer_name: "",
purchase_date: "",
storage_date: "",
duty_person: "",
duty_persons: [],
storage_location: "",
maintenance_cycle: 0,
manitenance_cycle_unit: "1",
classification_id: "",
last_time_maintenance_date: "",
status: "0",
need_dept_audit: 0,
need_worth_audit: 0,
},
rules: {
unique_id: [
{
required: true,
type: "string",
message: "请输入设备编号",
trigger: "blur",
},
],
name: [
{
required: true,
type: "string",
message: "请输入设备名称",
trigger: "blur",
},
],
model: [
{
required: true,
type: "string",
message: "请输入设备型号",
trigger: "blur",
},
],
manufacturer_name: [
{
required: true,
type: "string",
message: "请输入生产厂家",
trigger: "blur",
},
],
purchase_date: [
{
required: true,
type: "date",
message: "请选择采购日期",
trigger: "change",
},
],
storage_date: [
{
required: true,
type: "date",
message: "请选择入库时间",
trigger: "change",
},
],
duty_persons: [
{
required: true,
type: "array",
min: 1,
message: "请输入责任人",
trigger: "change",
},
],
storage_location: [
{
required: true,
type: "string",
message: "请输入存放位置",
trigger: "blur",
},
],
maintenance_cycle: [
{
required: true,
type: "string",
message: "请输入维护周期",
trigger: "change",
},
],
manitenance_cycle_unit: [
{
required: true,
type: "number",
message: "请选择周期单位",
trigger: "change",
},
],
classification_id: [
{
required: true,
type: "string",
message: "请选择设备分类",
trigger: "change",
},
],
last_time_maintenance_date: [
{
required: true,
type: "date",
message: "请选择上次维护日期",
trigger: "change",
},
],
status: [
{
required: true,
type: "string",
message: "请选择设备状态",
trigger: "change",
},
],
},
},
downloadLoading: false,
});
/**
* 设备借用记录
* */
// 分页改变
const handleBorrowRecordPageChange = (page) => {
init.borrowRecord.params.page_index = page;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
// 页大小改变
const handleBorrowRecordPageSizeChange = (size) => {
init.borrowRecord.params.page_size = size;
init.borrowRecord.params.page_index = 1;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
/**
* 设备借用记录
* */
/**
* 设备
* */
//切换日历视图
function changeClendar(e) {
init.equipmentBorrowingStatus.params.month = dayjs(e).format('YYYY-MM')
handleSubmit(init.equipmentBorrowingStatus.itemData, 'equipmentBorrowingStatus')
}
const outBoundForm = ref()
const inBoundForm = ref()
//提交操作
function handleSubmit(row, type) {
const strategy = {
//借用状态
equipmentBorrowingStatus: () => {
init.equipmentBorrowingStatus.title = row.name
init.equipmentBorrowingStatus.itemData = row;
init.equipmentBorrowingStatus.show = true;
init.equipmentBorrowingStatus.loading = true;
api
.getApiEquipmentEquipmentCalendar({
...init.equipmentBorrowingStatus.params,
equipment_id: row.id,
})
.then((res) => {
init.equipmentBorrowingStatus.list = res.response;
init.equipmentBorrowingStatus.loading = false;
});
},
//借用记录
borrow: () => {
init.borrowRecord.itemData = row;
init.borrowRecord.show = true;
init.borrowRecord.loading = true;
api
.getApiEquipmentEquipmentLendLsit({
...init.borrowRecord.params,
equipment_id: row.id,
})
.then((res) => {
init.borrowRecord.list = res.response.data;
init.borrowRecord.total = res.response.data_count;
init.borrowRecord.loading = false;
});
},
//删除设备
delete: () => {
console.log("删除");
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentDelete({
equipment_id: row.id,
})
.then(
(res) => {
let responseInfo = res.response
// {
// "euqipment_id": "1938161312374853632",
// "repair_item_id": 21107
// }
///api/Repair/DeleteMiddleItem
// logistics/api/repair/Area/MoidfiyStatus 细项停用0/启用1
// {"id":[1070101],"use_flag":1}
/**
* 报修细项同步
* */
//变更报修系统细项
bxApi.setAreaItemStatus({"id":[responseInfo.repair_item_id],"use_flag":0}).then(_res=>{
//删除中间表对应关系
api.getApiRepairDeleteMiddleItem({classification_equipment_id: responseInfo.euqipment_id})
})
/**
* 报修细项同步
* */
EquipmentList();
return res;
},
"提交中...",
false
);
});
},
'设备归还': () => {
console.log("🚀🚀🚀,", init.inBound.formDate)
inBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentReturn({
...init.inBound.formDate,
returnee_id: init.inBound.returnee_ids
.map((cur) => cur.tid)
.join(";"),
return_date: dayjs(row.return_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.inBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
},
'设备出库': () => {
outBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentOut({
...init.outBound.formDate,
equipment_id: row.equipment_id,
duty_person_tid: init.outBound.duty_person_tids
.map((cur) => cur.tid)
.join(";"),
lender_tid: init.outBound.lender_tids
.map((cur) => cur.tid)
.join(";"),
plan_end_date: dayjs(row.plan_end_date).format(
"YYYY-MM-DD HH:mm:ss"
),
out_date: dayjs(row.out_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.outBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
}
};
strategy[type]();
}
//出库
function outbound(row) {
init.outBound.title = row.name
init.outBound.formDate = {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
}
init.outBound.duty_person_tids = [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
]
init.outBound.lender_tids = []
init.outBound.formDate = {
...init.outBound.formDate,
equipment_id: row.id
};
init.outBound.show = true;
init.outBound.loading = true;
outBoundForm.value.resetFields()
}
//入库归还
function inbound(row) {
init.inBound.title = row.name
init.inBound.returnee_ids = []
init.inBound.formDate = {}
init.inBound.formDate = {
...init.inBound.formDate,
equipment_id: row.id
};
init.inBound.show = true;
init.inBound.loading = true;
inBoundForm.value.resetFields()
console.log("🚀🚀🚀,", init.inBound.formDate)
}
//获取设备编辑数据
function edit(row) {
console.log(row)
init.devices.show = true;
init.devices.loading = true;
init.devices.formData = {
...init.devices.formData,
...row,
status: String(row.status),
maintenance_cycle: String(row.maintenance_cycle),
manitenance_cycle_unit: String(row.manitenance_cycle_unit),
duty_person: row.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(row.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(row.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
row.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
};
init.devices.flag = "edit";
}
// 获取设备列表
const EquipmentList = async () => {
try {
loading.value = true;
// TODO: 调用接口获取角色用户列表
api.postApiEquipmentEquipmentList(init.devices.params).then((res) => {
userList.value = res.response.data;
init.devices.total = res.response.data_count;
loading.value = false;
});
} catch (error) {
loading.value = false;
Message.error("加载用户列表失败");
}
};
// 搜索用户
const handleSearch = (value) => {
init.devices.params = {
...init.devices.params,
...value,
page_index: 1,
page_size: 10,
};
EquipmentList();
};
// 重置
const handleReset = () => {
init.devices.params = {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
};
init.pageKey = Date.now();
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
searchFormRef.value.searchCondObj.classification_id = cur.options[0].id;
init.devices.params.classification_id = cur.options[0].id;
}
});
EquipmentList();
};
// 分页改变
const handlePageChange = (page) => {
init.devices.params.page_index = page;
EquipmentList();
};
// 页大小改变
const handlePageSizeChange = (size) => {
init.devices.params.page_size = size;
init.devices.params.page_index = 1;
EquipmentList();
};
// 添加设备
const handleAdd = () => {
init.devices.flag = 'add'
init.devices.formData = {
"name": "",
"model": "",
"unique_id": "",
"manufacturer_name": "",
"purchase_date": "",
"storage_date": "",
"duty_person": "",
"duty_persons": [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
],
"storage_location": "",
"maintenance_cycle": '0',
"manitenance_cycle_unit": '1',
"classification_id": "",
"last_time_maintenance_date": "",
"status": '0',
"need_dept_audit": 0,
"need_worth_audit": 0
};
init.devices.show = true;
deviceForm.value.resetFields();
};
// 下载模板
const handleDownloadTemplate = async () => {
try {
init.downloadLoading = true;
// TODO: 实现下载模板功能
init.downloadLoading = false;
} catch (error) {
init.downloadLoading = false;
Message.error("下载模板失败");
}
};
const deviceForm = ref();
// 删除用户
const handleRemoveUser = async (row) => {
try {
// TODO: 调用接口删除用户
Message.success("删除成功");
EquipmentList();
} catch (error) {
Message.error("删除失败");
}
};
// 提交设备表单
const handleSubmitDevice = () => {
const strategy = {
add: () => {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentAdd({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
// last_time_maintenance_date: dayjs(
// init.devices.formData.last_time_maintenance_date
// ).format("YYYY-MM-DD HH:mm:ss"),
})
.then(
(res) => {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
const responseInfo = res.response
//获取细项id
bxApi.GetId({parent_id: responseInfo.classification_reparir_item}).then((getAreaChildren) => {
//提交细项
bxApi.addItem({
"parent_id": responseInfo.classification_reparir_item,
"id": getAreaChildren.response,
"name": responseInfo.equipment_name
}).then(_res => {
//双系统信息,同步到中间表
api.getApiRepairAddMiddleItem({
classification_equipment_id: responseInfo.equipment_id,
repair_item: getAreaChildren.response
})
})
})
/**
* 报修细项同步
* */
return res;
},
"提交中...",
false
);
});
},
edit: () => {
console.log(init.devices.formData)
hooks.myEncapsulationFunction(() => {
return api.postApiEquipmentEquipmentUpdate({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
init.devices.formData.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
}).then((res) => {
if (res.code === 1) {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
//获取细项id
api.getApiRepairQueryById({classification_equipment_id: init.devices.formData.id}).then((getAreaChildren) => {
//提交细项
bxApi.modifyItem({
"id": getAreaChildren.response.repair_item_id,
"name": init.devices.formData.name
})
})
/**
* 报修细项同步
* */
return res;
}
});
}, false, '提交中...');
},
};
deviceForm.value.validate((valid) => {
if (valid) {
strategy[init.devices.flag]();
}
});
};
// 树格式化
function treeFormat(arr) {
return arr.map((a) => {
if (a.children && a.children.length != 0) {
a.children = treeFormat(a.children);
}
return {
...a,
title: a.name,
value: a.id,
expand: true,
selected: false,
};
});
}
const searchFormRef = ref()
function getTreeData() {
return api.getApiEquipmentGetEquipmentClassificationTree().then((res) => {
init.devices.treeData = treeFormat(res.response);
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
cur.options = treeFormat(res.response);
searchFormRef.value.searchCondObj.classification_id = res.response[0].id;
init.devices.params.classification_id = res.response[0].id;
}
});
return res
});
}
/**人员选择器 */
// 人员选择器》添加用户对话框
const addUserModal = reactive({
flag: '',
pageKey: '',
params: {
page_index: 1,
page_size: 10,
query: "",
},
total: 0,
show: false,
loading: false,
keyword: "",
batchUserList: [],
userList: [],
dutyDepts: [],
availableUserColumns: [
// {
// align: "center",
// type: "selection",
// width: 60,
// },
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
],
});
// 部门列表
const departmentOptions = ref([]);
// 人员选择器》搜索可添加的用户
const searchAvailableUsers = async () => {
loadRoleUsers();
};
//弹出人员选择器
function showAddUser(key) {
addUserModal.flag = key
setPeopleColumnsData()
addUserModal.params = {
page_index: 1,
page_size: 10,
query: "",
}
addUserModal.pageKey = new Date();
addUserModal.show = true;
addUserModal.batchUserList = [];
loadRoleUsers()
}
//批量提交选中人员
function batchAddUser() {
const strategy = {
//新增设备 批量
'入库责任人': () => {
const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
let data = []
addUserModal.batchUserList.forEach((cur, index) => {
//不包含
if (!dataId.includes(cur.tid)) {
data.push(cur)
}
})
init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
addUserModal.show = false;
},
// '出库责任人':()=>{
// const dataId = init.outBound.duty_person_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.duty_person_tids = init.outBound.duty_person_tids.concat(data);
// addUserModal.show = false;
// },
// '出库借用人':()=>{
// const dataId = init.outBound.lender_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.lender_tids = init.outBound.lender_tids.concat(data);
// addUserModal.show = false;
// },
// '归还人':()=>{
// const dataId = init.inBound.returnee_ids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.inBound.returnee_ids = init.inBound.returnee_ids.concat(data);
// addUserModal.show = false;
// },
}
strategy[addUserModal.flag]()
}
//选中人员
function onSelectionChange(e) {
console.log('e', e)
addUserModal.batchUserList = e;
}
// 人员选择器》确认添加用户
const confirmAddUser = async (user) => {
console.log("🚀🚀🚀,", user)
const strategy = {
// '入库责任人':()=>{
// const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
// console.log("🚀🚀111🚀,", init.devices.formData.duty_persons)
// addUserModal.show = false;
// },
'出库责任人': () => {
init.outBound.duty_person_tids = [user];
addUserModal.show = false;
},
'出库借用人': () => {
init.outBound.lender_tids = [user];
addUserModal.show = false;
},
'归还人': () => {
init.inBound.returnee_ids = [user];
addUserModal.show = false;
},
}
strategy[addUserModal.flag]()
};
// 加载人员选择器用户
const loadRoleUsers = () => {
addUserModal.loading = true;
try {
api
.getApiCommonUserSelect({
...addUserModal.params,
query: addUserModal.keyword,
})
.then((res) => {
addUserModal.userList = res.response.data || [];
addUserModal.total = res.response.data_count;
})
.catch((error) => {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
})
.finally(() => {
addUserModal.loading = false;
});
} catch (error) {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
addUserModal.loading = false;
}
};
// 分页改变
const handleAddUserPageChange = (page) => {
addUserModal.params.page_index = page;
loadRoleUsers()
};
// 页大小改变
const handleAddUserPageSizeChange = (size) => {
addUserModal.params.page_size = size;
addUserModal.params.page_index = 1;
loadRoleUsers()
};
//配置人员列表列数据
function setPeopleColumnsData() {
function name() {
addUserModal.availableUserColumns = [
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
]
}
const strategy = {
'入库责任人': () => {
addUserModal.availableUserColumns = [
{
align: "center",
type: "selection",
width: 60,
},
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
]
},
'出库责任人': () => name(),
'出库借用人': () => name(),
'归还人': () => name(),
}
strategy[addUserModal.flag]()
}
/**人员选择器 */
/**
* 设备报修
* */
//显示报修
function showRepair(row) {
getRepairAreaTree()
getRepairItemTree()
init.repair.formData ={
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
}
init.repair.title = row.name
init.repair.formData.name = deviceProjectStore.state.userInfo.name + '(' + deviceProjectStore.state.userInfo.card + ')'
init.repair.show = true
repairForm.value.resetFields()
init.repair.loading = true
//获取报修系统细项id
api.getApiRepairQueryById({classification_equipment_id: row.id}).then(res => {
init.repair.formData.item_id = String(res.response.repair_item_id)
}).finally(() => {
init.repair.loading = false
})
}
//遍历树形结构
function traverseTree(Array) {
return Array.map(item => {
if (item.children && item.children.length > 0) item.children = traverseTree(item.children)
return {
...item,
value: item.key
}
})
}
//获取报修区域
function getRepairAreaTree() {
bxApi.getRepairAreaTree().then(res => {
init.repair.areaTree = traverseTree(res.response)
})
}
//获取报修项目
function getRepairItemTree() {
bxApi.getRepairItemTree().then(res => {
init.repair.itemTree = traverseTree(res.response)
})
}
//附件上传
function beforeRepairFileUpload(file, type) {
console.log(file)
let f = new FormData();
f.append('file', file)
hooks.myEncapsulationFunction(() => {
return bxApi.uploadRepairImage({systemType: 0}, f, {headers: {'Content-Type': 'multipart/form-data'}}).then(res => {
if (res.code === 1) {
if (type === '报修附件') {
init.repair.formData.file_list = init.repair.formData.file_list.concat(res.response)
} else {
init.repair.formData.key_file_list = init.repair.formData.key_file_list.concat(res.response)
}
}
return res
})
}, false, '正在上传中...')
return false
}
const repairForm = ref()
//通过节点id,获取节点名称
function getAreaNameById(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.item_text = item.title
})
}
function getAreaNameById2(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.area_text = item.title
})
}
//提交报修
function handleRepairSubmit() {
getAreaNameById(init.repair.formData.item_id, init.repair.itemTree)
getAreaNameById2(init.repair.formData.area_id, init.repair.areaTree)
// console.log(111, {
// ...init.repair.formData,
// key_file_list: init.repair.formData.key_file_list.join(','),
// file_list: init.repair.formData.file_list.join(','),
//
// })
repairForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return bxApi.submitRepair({
...init.repair.formData,
key_file_list: init.repair.formData.key_file_list.map(cur => cur.id).join(','),
file_list: init.repair.formData.file_list.map(cur => cur.id).join(','),
}).then(res => {
//
api.getApiRepairRegisterRepair({
repair_item_id: init.repair.formData.item_id,
repair_out_id: res.response}
).then(()=>{
init.repair.show = false
EquipmentList()
})
return res
})
}, false, '正在提交中...')
}
})
}
/**
* 设备报修
* */
onMounted(() => {
getRepairAreaTree()
getRepairItemTree()
loading.value = true;
getTreeData().then(res => {
EquipmentList();
});
});
</script>
<style scoped>
.role-container {
display: flex;
min-height: calc(100vh - 150px);
/* border: 1px solid #e8eaec; */
border-radius: 4px;
overflow: auto;
gap: 16px;
}
.role-sidebar {
width: 300px;
border-right: 1px solid #e8eaec;
background-color: #fff;
overflow-y: auto;
height: 200px;
}
.role-title {
padding: 16px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #e8eaec;
}
.role-list {
padding: 10px 0;
}
.role-item {
display: flex;
align-items: center;
padding: 12px 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.role-item:hover {
background-color: #f0f0f0;
}
.role-item.active {
background-color: #e8f7ff;
color: #2d8cf0;
}
.role-item-icon {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
color: #fff;
}
.role-admin {
background-color: #2d8cf0;
}
.role-party-office {
background-color: #19be6b;
}
.role-entrance-dept {
background-color: #ff9900;
}
.role-responsible-dept {
background-color: #ed4014;
}
.role-item-info {
flex: 1;
}
.role-name {
font-size: 14px;
margin-bottom: 4px;
}
.role-count {
font-size: 12px;
color: #808695;
}
.role-content {
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
}
.role-toolbar {
height: 100%;
display: flex;
flex-direction: column;
gap: 20px;
top: 0;
background-color: #fff;
z-index: 1;
}
.search-box {
width: 280px;
}
.pagination {
/* margin-top: 16px; */
text-align: center;
position: sticky;
bottom: 0;
background-color: #fff;
z-index: 1;
}
.action-btns {
display: flex;
justify-content: center;
}
.user-avatar {
display: flex;
justify-content: center;
align-items: center;
}
.user-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.add-user-search {
margin-bottom: 16px;
display: flex;
}
.duty-dept-select {
margin-bottom: 16px;
}
</style>
<style lang='less' scoped>
.filelist {
cursor: pointer;
}
.filelist:hover {
color: #1e93ff;
background-color: #f7f7f7;
}
.fileddelete {
cursor: pointer;
margin-left: auto;
}
.fileddelete:hover {
color: red;
transform: scale(1.5);
}
</style>
<template>
<div style="width: 100%; height: 100%">
<!-- 右侧人员列表 -->
<div class="role-content">
<!-- 搜索和工具栏 -->
<div class="role-toolbar">
<initForm
ref="searchFormRef"
:searchCondList="init.searchList"
@on-submit="handleSearch"
@on-reset="handleReset"
/>
<!-- 表格工具栏 -->
<div class="operation-bar">
<Button type="primary" @click="handleAdd">
<Icon type="md-add"/>
新增设备
</Button>
<!-- <Button class="ivu-ml-8" @click="handleImport"><Icon type="md-cloud-upload" /> 导入设备</Button>-->
<!-- <Button-->
<!-- class="ivu-ml-8"-->
<!-- @click="handleDownloadTemplate"-->
<!-- :loading="init.downloadLoading"-->
<!-- ><Icon type="md-download" /> 下载模板</Button-->
<!-- >-->
<!-- <Button class="ivu-ml-8" @click="handleExport"><Icon type="md-download" /> 导出数据</Button>-->
</div>
</div>
<!-- 设备表格 -->
<Table :loading="loading" :columns="userColumns" :data="userList" border>
<template #action="{ row }">
<div class="action-btns" style="display: flex; align-items: center">
<a href="javascript:;" @click="handleSubmit(row, 'borrow')"
>借用记录</a
>
<Divider type="vertical"/>
<a
href="javascript:;"
@click="handleSubmit(row, 'equipmentBorrowingStatus')"
>借用状态</a
>
<Divider type="vertical"/>
<a href="javascript:;" @click="outbound(row)">出库</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="inbound(row)">归还</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="showRepair(row)">报修</a>
<Divider type="vertical"/>
<a href="javascript:;" @click="edit(row)">编辑</a>
<Divider type="vertical"/>
<Poptip
confirm
transfer
title="确定要删除该设备吗?"
@on-ok="handleSubmit(row, 'delete')"
>
<a href="javascript:;">删除</a>
</Poptip>
</div>
</template>
<template #duty_person="{ row }">
<Tag
color="blue"
v-for="(item, index) in row.duty_persons"
:key="index"
>
{{ item.name }}
</Tag>
</template>
<template #status="{ row }">
<Tag :color="['success', 'blue', 'warning'][Number(row.status)]">
{{ ["空闲", "使用中", "维修中"][Number(row.status)] }}
</Tag>
</template>
<template #need_dept_audit="{ row }">
{{ row.need_dept_audit === 1 ? "需要" : "不需要" }}
</template>
<template #need_worth_audit="{ row }">
{{ row.need_worth_audit === 1 ? "需要" : "不需要" }}
</template>
</Table>
<!-- 分页 -->
<div class="pagination">
<Page
:key="init.pageKey"
:total="init.devices.total"
:current="init.devices.params.page_index"
:page-size="init.devices.params.page_size"
show-elevator
:show-sizer="true"
show-total
:page-size-opts="[10, 20, 50, 100]"
:transfer="true"
@on-change="handlePageChange"
@on-page-size-change="handlePageSizeChange"
/>
</div>
</div>
</div>
<!-- 添加设备对话框 -->
<Modal
v-model="init.devices.show"
title="设备信息"
width="700"
>
<Form
ref="deviceForm"
:model="init.devices.formData"
:rules="init.devices.rules"
:label-width="100"
>
<Row :gutter="16">
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备编号" prop="unique_id1">
<Input
v-model="init.devices.formData.unique_id"
placeholder="请输入设备编号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备名称" prop="name">
<Input
v-model="init.devices.formData.name"
placeholder="请输入设备名称"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备型号" prop="model1">
<Input
v-model="init.devices.formData.model"
placeholder="请输入设备型号"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="生产厂家" prop="manufacturer_name1">
<Input
v-model="init.devices.formData.manufacturer_name"
placeholder="请输入生产厂家"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="采购日期" prop="purchase_date">
<DatePicker
v-model="init.devices.formData.purchase_date"
type="datetime"
placeholder="选择采购日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="入库时间" prop="storage_date">
<DatePicker
v-model="init.devices.formData.storage_date"
type="datetime"
placeholder="选择入库时间"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="责任人" prop="duty_persons">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.devices.formData.duty_persons"
:key="index"
closable
@on-close="init.devices.formData.duty_persons.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('入库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="存放位置" prop="storage_location">
<Input
v-model="init.devices.formData.storage_location"
placeholder="请输入存放位置"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备分类" prop="classification_id">
<TreeSelect
v-model="init.devices.formData.classification_id"
placeholder="请选择设备分类"
:data="init.devices.treeData"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="维护周期" prop="maintenance_cycle">
<Input
v-model="init.devices.formData.maintenance_cycle"
style="width: 60%"
clearable
/>
<Select
v-model="init.devices.formData.manitenance_cycle_unit"
style="width: 35%; margin-left: 5%"
>
<Option value="1">年</Option>
<Option value="2">月</Option>
<Option value="3">天</Option>
</Select>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="设备状态" prop="status">
<Select v-model="init.devices.formData.status" clearable>
<Option value="0">空闲</Option>
<Option value="1">使用中</Option>
<Option value="2">维修中</Option>
</Select>
</FormItem>
</Col>
<Col v-if="init.devices.flag == 'edit'" :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="上次维护日期" prop="last_time_maintenance_date">
<DatePicker
v-model="init.devices.formData.last_time_maintenance_date"
type="datetime"
placeholder="选择上次维护日期"
style="width: 100%"
clearable
/>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="部门审核" prop="need_dept_audit">
<Switch
v-model="init.devices.formData.need_dept_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
<Col :xs="24" :sm="12" :md="12" :lg="12">
<FormItem label="价值审核" prop="need_worth_audit">
<Switch
v-model="init.devices.formData.need_worth_audit"
:true-value="1"
:false-value="0"
>
<template #open>是</template>
<template #close>否</template>
</Switch>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.devices.show = false">取消</Button>
<Button type="primary" @click="handleSubmitDevice">确定</Button>
</template>
</Modal>
<!-- 借用记录对话框 -->
<Modal
v-model="init.borrowRecord.show"
title="借用记录"
width="60%"
:mask-closable="false"
>
<Table
:loading="init.borrowRecord.loading"
:columns="init.borrowRecordColumns"
:data="init.borrowRecord.list"
border
>
<template #status="{ row }">
<Tag
:color="
row.status === 1
? 'success'
: row.status === 2
? 'warning'
: 'default'
"
>
{{
row.status === 1 ? "已归还" : row.status === 2 ? "使用中" : "待审核"
}}
</Tag>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:total="init.borrowRecord.total"
:current="init.borrowRecord.params.page_index"
:page-size="init.borrowRecord.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleBorrowRecordPageChange"
@on-page-size-change="handleBorrowRecordPageSizeChange"
/>
</div>
<template #footer>
<Button @click="init.borrowRecord.show = false">关闭</Button>
</template>
</Modal>
<!-- 添加用户对话框 -->
<Modal
:styles="{top:'10px'}"
v-model="addUserModal.show"
:title="'人员数据'"
width="700"
:mask-closable="false"
>
<div class="add-user-search">
<Input
v-model="addUserModal.keyword"
placeholder="输入姓名或工号搜索用户"
search
clearable
enter-button
@on-search="searchAvailableUsers"
/>
<Button v-if="addUserModal.flag == '入库责任人'" style="margin-left: 10px" type="primary" @click="batchAddUser"
>批量添加
</Button
>
</div>
<!-- 负责部门选择 - 只在角色为责任部门时显示 -->
<div class="duty-dept-select" v-if="false">
<Form>
<FormItem
label="负责部门"
:label-width="80"
:rules="[
{
required: true,
type: 'array',
min: 1,
message: '请至少选择一个负责部门',
trigger: 'change',
},
]"
>
<Select
v-model="addUserModal.dutyDepts"
multiple
filterable
placeholder="请选择负责部门(可多选)"
style="width: 100%"
>
<Option
v-for="dept in departmentOptions"
:key="dept.value"
:value="dept.value"
>
{{ dept.label }}
</Option>
</Select>
</FormItem>
</Form>
</div>
<!-- 可添加用户列表 -->
<Table
@on-selection-change="onSelectionChange"
:loading="addUserModal.loading"
:columns="addUserModal.availableUserColumns"
:data="addUserModal.userList"
border
>
<!-- 照片列 -->
<template #avatar="{ row }">
<div class="user-avatar">
<Avatar v-if="row.photo" size="large" :src="row.photo"/>
<Avatar v-else icon="ios-person" size="large"/>
</div>
</template>
<!-- 操作列 -->
<template #action="{ row }">
<div class="action-btns">
<Button type="primary" size="small" @click="confirmAddUser(row)"
>添加
</Button
>
</div>
</template>
</Table>
<!-- 分页 -->
<div class="pagination" style="margin-top: 16px">
<Page
:key="addUserModal.pageKey"
:total="addUserModal.total"
:current="addUserModal.params.page_index"
:page-size="addUserModal.params.page_size"
show-elevator
show-sizer
show-total
@on-change="handleAddUserPageChange"
@on-page-size-change="handleAddUserPageSizeChange"
/>
</div>
<template #footer>
<Button @click="addUserModal.show = false">关闭</Button>
</template>
</Modal>
<!-- 出库对话框 -->
<Modal
v-model="init.outBound.show"
:title="init.outBound.title+'-设备出库'"
width="500"
>
<Form
ref="outBoundForm"
:model="init.outBound.formDate"
:rules="init.outBound.rules"
:label-width="100"
>
<FormItem label="借用人" prop="lender_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.lender_tids"
:key="index"
closable
@on-close="init.outBound.lender_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库借用人')"
>
添加借用人
</Button>
</div>
</FormItem>
<FormItem label="预计归还日期" prop="plan_end_date">
<DatePicker
v-model="init.outBound.formDate.plan_end_date"
type="datetime"
placeholder="选择预计归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库日期" prop="out_date">
<DatePicker
v-model="init.outBound.formDate.out_date"
type="datetime"
placeholder="选择出库日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="出库责任人" prop="duty_person_tids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.outBound.duty_person_tids"
:key="index"
closable
@on-close="init.outBound.duty_person_tids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('出库责任人')"
>
添加责任人
</Button>
</div>
</FormItem>
<FormItem label="备注" prop="application_remark">
<Input
v-model="init.outBound.formDate.application_remark"
type="textarea"
placeholder="请输入备注信息"
:rows="4"
/>
</FormItem>
</Form>
<template #footer>
<Button @click="init.outBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.outBound.formDate,'设备出库')">确定</Button>
</template>
</Modal>
<!-- 设备归还入库 -->
<Modal
v-model="init.inBound.show"
:title="init.inBound.title+'-归还入库'"
width="500"
>
<Form
ref="inBoundForm"
:model="init.inBound.formDate"
:rules="init.inBound.rules"
:label-width="100"
>
<FormItem label="归还日期" prop="return_date">
<DatePicker
v-model="init.inBound.formDate.return_date"
type="datetime"
placeholder="选择归还日期"
style="width: 100%"
clearable
/>
</FormItem>
<FormItem label="归还人" prop="returnee_ids">
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<Tag
color="primary"
v-for="(person, index) in init.inBound.returnee_ids"
:key="index"
closable
@on-close="init.inBound.returnee_ids.splice(index, 1)"
>
{{ person.name + '(' + person.card_number + ')' }}
</Tag>
</div>
<div style="gap: 8px">
<Button
icon="md-add"
type="dashed"
@click="showAddUser('归还人')"
>
添加归还人
</Button>
</div>
</FormItem>
</Form>
<template #footer>
<Button @click="init.inBound.show = false">取消</Button>
<Button type="primary" @click="handleSubmit(init.inBound.formDate,'设备归还')">确定</Button>
</template>
</Modal>
<!--设备借用状态-->
<Drawer
:draggable="true"
:styles="{padding: '0px'}"
v-model="init.equipmentBorrowingStatus.show"
:title="init.equipmentBorrowingStatus.title+'-借用状态'"
width="70%"
placement="right"
>
<div style="width: 100%;height: calc(100% - 60px);padding: 16px">
<DatePicker
v-if="false"
v-model="init.equipmentBorrowingStatus.params.month"
type="month"
placeholder="选择月份"
style="width: 200px; margin-bottom: 16px;"
@on-change="handleSubmit(init.equipmentBorrowingStatus.itemData,'equipmentBorrowingStatus')"
/>
<Calendar
:loading="init.equipmentBorrowingStatus.loading"
v-model="init.equipmentBorrowingStatus.params.month"
hide-type
@on-change="changeClendar"
>
<template #month="{date, data}">
<div>
<Badge
:status="['','error','warning'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
:text="['','占用中','维修中'][init.equipmentBorrowingStatus.list.find(cur=>cur.occupy_date===data.day).occupy_type]"
v-if="init.equipmentBorrowingStatus.list.map(cur=>cur.occupy_date).includes(data.day) "/>
<Badge status="success" text="空闲" v-else/>
</div>
</template>
</Calendar>
</div>
<div
style="width: 100%;height: 60px;display: flex;justify-content: center;align-items: center;box-shadow: 0 0 8px darkgray">
<Button style="width: 150px" @click="init.equipmentBorrowingStatus.show =false">关闭</Button>
</div>
</Drawer>
<!-- 设备报修表单 -->
<Modal
v-model="init.repair.show"
:title="init.repair.title +'-设备报修'"
:mask-closable="false"
:closable="true"
width="50%"
@on-cancel="init.repair.show = false"
>
<Form
:model="init.repair.formData"
:rules="init.repair.rules"
ref="repairForm"
label-width="100"
>
<Row :gutter="16" type="flex" style="flex-wrap: wrap;">
<!--报修人-->
<Col :xs="24" :sm="12">
<FormItem label="报修人" prop="name">
<Input
:disabled="true"
v-model="init.repair.formData.name"
placeholder="请输入报修人"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 联系方式 -->
<Col :xs="24" :sm="12">
<FormItem label="联系方式" prop="phone">
<Input
v-model="init.repair.formData.phone"
placeholder="请输入联系电话"
maxlength="20"
/>
</FormItem>
</Col>
<!-- 报修区域 -->
<Col :xs="24" :sm="12">
<FormItem label="报修区域" prop="area_id">
<TreeSelect
v-model="init.repair.formData.area_id"
:data="init.repair.areaTree"
placeholder="请选择报修区域"
style="width: 100%;"
:clearable="true"
/>
</FormItem>
</Col>
<!-- 详细地址 -->
<Col :xs="24" :sm="12">
<FormItem label="详细地址" prop="areaDetail">
<Input
v-model="init.repair.formData.areaDetail"
placeholder="请输入报修详细地址"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修项目 -->
<Col :xs="24" :sm="12">
<FormItem label="报修项目" prop="item_id">
<div style="display: flex;">
<TreeSelect
:disabled="true"
v-model="init.repair.formData.item_id"
:data="init.repair.itemTree"
placeholder="请选择报修项目"
style="width: 100%;"
:clearable="true"
/>
<Spin v-if="init.repair.loading"></Spin>
</div>
</FormItem>
</Col>
<!-- 报修详细 -->
<Col :xs="24" :sm="12">
<FormItem label="报修详细" prop="itemDetail">
<Input
v-model="init.repair.formData.itemDetail"
placeholder="请输入报修详细"
maxlength="200"
show-word-limit
/>
</FormItem>
</Col>
<!-- 报修附件 -->
<Col :xs="24" :sm="12">
<FormItem label="报修附件" prop="file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '报修附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.file_list = init.repair.formData.file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
<!-- 钥匙备注 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙备注" prop="key_remark">
<Input
v-model="init.repair.formData.key_remark"
placeholder="请输入钥匙备注"
maxlength="100"
show-word-limit
/>
</FormItem>
</Col>
<!-- 钥匙附件 -->
<Col :xs="24" :sm="12">
<FormItem label="钥匙附件" prop="key_file_list">
<Upload
:before-upload="(file) => beforeRepairFileUpload(file, '钥匙附件')"
:show-upload-list="false"
accept="image/*"
>
<Button icon="ios-cloud-upload-outline">上传附件</Button>
</Upload>
<div
v-for="(item_, index_) in init.repair.formData.key_file_list"
:key="index_"
class="filelist"
style="display: flex; width: 100%;"
>
<div style="display: flex; width: 100%; height: 32px; align-items: center;">
<img v-if="item_.extension === '.file'" src="@/assets/icon/file.png" width="15px"/>
<img v-if="item_.extension === '.word'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.excel'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.ppt'" src="@/assets/icon/ppt.png" width="15px"/>
<img v-if="item_.extension === '.pdf'" src="@/assets/icon/pdf.png" width="15px"/>
<img v-if="item_.extension === '.image'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.png'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.jpeg'" src="@/assets/icon/image.png" width="15px"/>
<img v-if="item_.extension === '.doc'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.docx'" src="@/assets/icon/word.png" width="15px"/>
<img v-if="item_.extension === '.xlsx'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.xls'" src="@/assets/icon/excel.png" width="15px"/>
<img v-if="item_.extension === '.zip'" src="@/assets/icon/zip.png" width="15px"/>
<a class="ivu-ml-8 file-title">
附件{{ index_ + 1 }}
</a>
<Poptip
class="fileddelete"
:transfer="true"
confirm
title="是否继续?"
@on-ok="() => init.repair.formData.key_file_list = init.repair.formData.key_file_list.filter((_, i) => i !== index_)"
ok-text="是"
cancel-text="否"
>
<Icon size="20" type="ios-close" style="cursor: pointer;"/>
</Poptip>
</div>
</div>
</FormItem>
</Col>
</Row>
</Form>
<template #footer>
<Button @click="init.repair.show = false">取消</Button>
<Button type="primary" @click="handleRepairSubmit">提交报修</Button>
</template>
</Modal>
</template>
<script setup>
import {deviceProjectStore} from '@/store/deviceProjectStoree'
import initForm from "@/components/initForm";
import {ref, onMounted, reactive, computed} from "vue";
import {
Badge, Button,
Calendar,
DatePicker, Drawer,
FormItem,
Message,
Modal,
Page,
Row,
Switch,
Tag, TreeSelect, Upload,
} from "view-ui-plus";
import * as api from "@/api/allApi/controller/index";
import * as hooks from "@/hook/index";
import * as bxApi from '@/api/logisticsApi/index'
import dayjs from "dayjs";
import {setAreaItemStatus, submitRepair} from "@/api/logisticsApi/index";
// 角色列表
const roleList = ref([
{
role_type: 0,
role_name: "设备审核",
count: 14,
},
{
role_type: 1,
role_name: "耗材审核",
count: 4,
},
]);
// 表单值
const formValues = ref({});
// 用户表格列定义
const userColumns = computed(() => {
const columns = [
{
title: "#",
type: "index",
width: 60,
},
{
title: "设备编号",
key: "unique_id",
minWidth: 150,
},
{
title: "设备名称",
key: "name",
minWidth: 150,
},
{
title: "设备型号",
key: "model",
minWidth: 150,
},
{
title: "设备分类",
key: "classification_name",
minWidth: 150,
},
{
title: "生产厂家",
key: "manufacturer_name",
minWidth: 150,
},
{
title: "采购日期",
key: "purchase_date",
minWidth: 150,
},
{
title: "入库时间",
key: "storage_date",
width: 150,
},
{
title: "责任人",
slot: "duty_person",
minWidth: 160,
},
{
title: "存放位置",
key: "storage_location",
minWidth: 150,
},
{
title: "维护周期",
key: "maintenance_cycle",
minWidth: 150,
render: (h, params) => {
return h('span', params.row.maintenance_cycle + ['', '年', '月', '天'][params.row.manitenance_cycle_unit])
},
},
{
title: "设备状态",
slot: "status",
minWidth: 150,
},
{
title: "部门审核",
key: "need_dept_audit",
minWidth: 100,
slot: "need_dept_audit",
},
{
title: "价值审核",
key: "need_worth_audit",
minWidth: 100,
slot: "need_worth_audit",
},
];
// 添加操作列
columns.push({
title: "操作",
slot: "action",
width: 420,
align: "center",
fixed: "right",
});
return columns;
});
// 加载状态
const loading = ref(false);
// 用户列表
const userList = ref([]);
const init = reactive({
pageKey:'',
//报修
repair: {
loading: true,
show: false,
// 表单校验规则,确保用户输入的有效性
rules: {
name: [
{required: true, message: '请输入报修人姓名', trigger: 'change'}
],
area_id: [
{required: true, message: '请选择报修区域', trigger: 'change'}
],
item_id: [
{required: true, message: '请选择报修项目', trigger: 'change'}
],
phone: [
{required: true, message: '请输入联系电话', trigger: 'blur'},
{pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号', trigger: 'blur'}
],
areaDetail: [
{required: true, message: '请输入详细地址', trigger: 'blur'}
],
},
formData: {
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
},
areaTree: [],
itemTree: [],
},
// 借用记录相关数据
equipmentBorrowingStatus: {
title: '',
itemData: {},
show: false,
loading: false,
params: {
month: dayjs().format('YYYY-MM'),
equipment_id: "",
},
list: []
},
borrowRecord: {
itemData: {},
params: {
page_index: 1,
page_size: 10,
equipment_id: "",
},
show: false,
loading: false,
list: [],
total: 0,
pageIndex: 1,
pageSize: 10,
},
// 借用记录表格列定义
borrowRecordColumns: [
{
title: "设备名称",
key: "equipment_name",
minWidth: 100,
},
{
title: "责任人",
key: "duty_person_name",
minWidth: 100,
},
{
title: "责任人工号",
key: "duty_person_card",
minWidth: 120,
},
{
title: "借出人",
key: "lender_name",
minWidth: 100,
},
{
title: "借出人工号",
key: "lender_card",
minWidth: 120,
},
{
title: "出入库类型",
key: "storage_status_shift_type",
minWidth: 120,
},
{
title: "出入库日期",
key: "storage_status_shift_date",
minWidth: 120,
},
{
title: "备注",
key: "application_remark",
minWidth: 150,
},
],
searchList: [
{
label: "设备名称",
code: "equipment_name",
search_type: "input",
is_must: 0,
option_list: null,
option_cascade_list: null,
},
{
label: "设备分类",
code: "classification_id",
search_type: "treeselect",
is_must: 0,
options: [],
},
{
label: "设备状态",
code: "status",
search_type: "select",
is_must: 0,
option_list: [
{
label: "空闲",
value: "0",
},
{
label: "使用中",
value: "1",
},
{
label: "维修中",
value: "2",
},
],
option_cascade_list: null,
},
],
inBound: {
show: false,
returnee_ids: [],
formDate: {
equipment_id: '', // 设备id
return_date: '', // 归还日期
returnee_id: '', // 归还人tid
},
rules: {
return_date: [
{
required: true,
type: "date",
message: "请选择归还日期",
trigger: "change"
}
],
returnee_ids: [
{
required: true,
type: "array",
message: "请添加一位归还人",
trigger: "change",
validator: (rule, value, callback) => {
if (!init.inBound.returnee_ids || init.inBound.returnee_ids.length === 0) {
callback(new Error("请添加一位归还人"));
} else {
callback();
}
}
}
]
},
loading: false,
list: [],
},
outBound: {
title: '',
show: false,
duty_person_tids: [],
lender_tids: [],
formDate: {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
},
rules: {
plan_end_date: [
{
required: true,
type: "date",
message: "请选择预计归还日期",
trigger: "change"
}
],
out_date: [
{
required: true,
type: "date",
message: "请选择出库日期",
trigger: "change"
}
],
duty_person_tids: [
{
required: true,
type: "array",
message: "请添加一位出库责任人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.duty_person_tids.length === 0) {
callback(new Error("请添加一位出库责任人"))
} else {
callback()
}
}
}
],
lender_tids: [
{
required: true,
type: "array",
message: "请添加一位借用人",
trigger: "change",
validator: (rule, value, callback) => {
if (init.outBound.lender_tids.length === 0) {
callback(new Error("请添加一位借用人"))
} else {
callback()
}
}
}
],
application_remark: [
{
required: false,
type: "string",
message: "请输入备注信息",
trigger: "blur"
}
]
},
loading: false,
list: [],
},
devices: {
flag: "add",
total: 0,
params: {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
},
show: false,
treeData: [],
formData: {
name: "",
model: "",
unique_id: "",
manufacturer_name: "",
purchase_date: "",
storage_date: "",
duty_person: "",
duty_persons: [],
storage_location: "",
maintenance_cycle: 0,
manitenance_cycle_unit: "1",
classification_id: "",
last_time_maintenance_date: "",
status: "0",
need_dept_audit: 0,
need_worth_audit: 0,
},
rules: {
unique_id: [
{
required: true,
type: "string",
message: "请输入设备编号",
trigger: "blur",
},
],
name: [
{
required: true,
type: "string",
message: "请输入设备名称",
trigger: "blur",
},
],
model: [
{
required: true,
type: "string",
message: "请输入设备型号",
trigger: "blur",
},
],
manufacturer_name: [
{
required: true,
type: "string",
message: "请输入生产厂家",
trigger: "blur",
},
],
purchase_date: [
{
required: true,
type: "date",
message: "请选择采购日期",
trigger: "change",
},
],
storage_date: [
{
required: true,
type: "date",
message: "请选择入库时间",
trigger: "change",
},
],
duty_persons: [
{
required: true,
type: "array",
min: 1,
message: "请输入责任人",
trigger: "change",
},
],
storage_location: [
{
required: true,
type: "string",
message: "请输入存放位置",
trigger: "blur",
},
],
maintenance_cycle: [
{
required: true,
type: "string",
message: "请输入维护周期",
trigger: "change",
},
],
manitenance_cycle_unit: [
{
required: true,
type: "number",
message: "请选择周期单位",
trigger: "change",
},
],
classification_id: [
{
required: true,
type: "string",
message: "请选择设备分类",
trigger: "change",
},
],
last_time_maintenance_date: [
{
required: true,
type: "date",
message: "请选择上次维护日期",
trigger: "change",
},
],
status: [
{
required: true,
type: "string",
message: "请选择设备状态",
trigger: "change",
},
],
},
},
downloadLoading: false,
});
/**
* 设备借用记录
* */
// 分页改变
const handleBorrowRecordPageChange = (page) => {
init.borrowRecord.params.page_index = page;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
// 页大小改变
const handleBorrowRecordPageSizeChange = (size) => {
init.borrowRecord.params.page_size = size;
init.borrowRecord.params.page_index = 1;
handleSubmit(init.borrowRecord.itemData, 'borrow');
};
/**
* 设备借用记录
* */
/**
* 设备
* */
//切换日历视图
function changeClendar(e) {
init.equipmentBorrowingStatus.params.month = dayjs(e).format('YYYY-MM')
handleSubmit(init.equipmentBorrowingStatus.itemData, 'equipmentBorrowingStatus')
}
const outBoundForm = ref()
const inBoundForm = ref()
//提交操作
function handleSubmit(row, type) {
const strategy = {
//借用状态
equipmentBorrowingStatus: () => {
init.equipmentBorrowingStatus.title = row.name
init.equipmentBorrowingStatus.itemData = row;
init.equipmentBorrowingStatus.show = true;
init.equipmentBorrowingStatus.loading = true;
api
.getApiEquipmentEquipmentCalendar({
...init.equipmentBorrowingStatus.params,
equipment_id: row.id,
})
.then((res) => {
init.equipmentBorrowingStatus.list = res.response;
init.equipmentBorrowingStatus.loading = false;
});
},
//借用记录
borrow: () => {
init.borrowRecord.itemData = row;
init.borrowRecord.show = true;
init.borrowRecord.loading = true;
api
.getApiEquipmentEquipmentLendLsit({
...init.borrowRecord.params,
equipment_id: row.id,
})
.then((res) => {
init.borrowRecord.list = res.response.data;
init.borrowRecord.total = res.response.data_count;
init.borrowRecord.loading = false;
});
},
//删除设备
delete: () => {
console.log("删除");
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentDelete({
equipment_id: row.id,
})
.then(
(res) => {
let responseInfo = res.response
// {
// "euqipment_id": "1938161312374853632",
// "repair_item_id": 21107
// }
///api/Repair/DeleteMiddleItem
// logistics/api/repair/Area/MoidfiyStatus 细项停用0/启用1
// {"id":[1070101],"use_flag":1}
/**
* 报修细项同步
* */
//变更报修系统细项
bxApi.setAreaItemStatus({"id":[responseInfo.repair_item_id],"use_flag":0}).then(_res=>{
//删除中间表对应关系
api.getApiRepairDeleteMiddleItem({classification_equipment_id: responseInfo.euqipment_id})
})
/**
* 报修细项同步
* */
EquipmentList();
return res;
},
"提交中...",
false
);
});
},
'设备归还': () => {
console.log("🚀🚀🚀,", init.inBound.formDate)
inBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.getApiEquipmentEquipmentReturn({
...init.inBound.formDate,
returnee_id: init.inBound.returnee_ids
.map((cur) => cur.tid)
.join(";"),
return_date: dayjs(row.return_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.inBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
},
'设备出库': () => {
outBoundForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentOut({
...init.outBound.formDate,
equipment_id: row.equipment_id,
duty_person_tid: init.outBound.duty_person_tids
.map((cur) => cur.tid)
.join(";"),
lender_tid: init.outBound.lender_tids
.map((cur) => cur.tid)
.join(";"),
plan_end_date: dayjs(row.plan_end_date).format(
"YYYY-MM-DD HH:mm:ss"
),
out_date: dayjs(row.out_date).format(
"YYYY-MM-DD HH:mm:ss"
),
})
.then(
(res) => {
EquipmentList();
init.outBound.show = false;
return res;
},
"提交中...",
false
);
});
}
})
}
};
strategy[type]();
}
//出库
function outbound(row) {
init.outBound.title = row.name
init.outBound.formDate = {
plan_end_date: '',
equipment_id: '',
out_date: '',
duty_person_tid: '',
lender_tid: '',
application_remark: '',
application_id: ''
}
init.outBound.duty_person_tids = [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
]
init.outBound.lender_tids = []
init.outBound.formDate = {
...init.outBound.formDate,
equipment_id: row.id
};
init.outBound.show = true;
init.outBound.loading = true;
outBoundForm.value.resetFields()
}
//入库归还
function inbound(row) {
init.inBound.title = row.name
init.inBound.returnee_ids = []
init.inBound.formDate = {}
init.inBound.formDate = {
...init.inBound.formDate,
equipment_id: row.id
};
init.inBound.show = true;
init.inBound.loading = true;
inBoundForm.value.resetFields()
console.log("🚀🚀🚀,", init.inBound.formDate)
}
//获取设备编辑数据
function edit(row) {
console.log(row)
init.devices.show = true;
init.devices.loading = true;
init.devices.formData = {
...init.devices.formData,
...row,
status: String(row.status),
maintenance_cycle: String(row.maintenance_cycle),
manitenance_cycle_unit: String(row.manitenance_cycle_unit),
duty_person: row.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(row.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(row.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
row.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
};
init.devices.flag = "edit";
}
// 获取设备列表
const EquipmentList = async () => {
try {
loading.value = true;
// TODO: 调用接口获取角色用户列表
api.postApiEquipmentEquipmentList(init.devices.params).then((res) => {
userList.value = res.response.data;
init.devices.total = res.response.data_count;
loading.value = false;
});
} catch (error) {
loading.value = false;
Message.error("加载用户列表失败");
}
};
// 搜索用户
const handleSearch = (value) => {
init.devices.params = {
...init.devices.params,
...value,
page_index: 1,
page_size: 10,
};
EquipmentList();
};
// 重置
const handleReset = () => {
init.devices.params = {
status: "",
classification_id: "",
equipment_name: "",
page_index: 1,
page_size: 10,
};
init.pageKey = Date.now();
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
searchFormRef.value.searchCondObj.classification_id = cur.options[0].id;
init.devices.params.classification_id = cur.options[0].id;
}
});
EquipmentList();
};
// 分页改变
const handlePageChange = (page) => {
init.devices.params.page_index = page;
EquipmentList();
};
// 页大小改变
const handlePageSizeChange = (size) => {
init.devices.params.page_size = size;
init.devices.params.page_index = 1;
EquipmentList();
};
// 添加设备
const handleAdd = () => {
init.devices.flag = 'add'
init.devices.formData = {
"name": "",
"model": "",
"unique_id": "",
"manufacturer_name": "",
"purchase_date": "",
"storage_date": "",
"duty_person": "",
"duty_persons": [
{
card_number: deviceProjectStore.state.userInfo.card,
name: deviceProjectStore.state.userInfo.name,
tid: deviceProjectStore.state.userInfo.tid,
}
],
"storage_location": "",
"maintenance_cycle": '0',
"manitenance_cycle_unit": '1',
"classification_id": "",
"last_time_maintenance_date": "",
"status": '0',
"need_dept_audit": 0,
"need_worth_audit": 0
};
init.devices.show = true;
deviceForm.value.resetFields();
};
// 下载模板
const handleDownloadTemplate = async () => {
try {
init.downloadLoading = true;
// TODO: 实现下载模板功能
init.downloadLoading = false;
} catch (error) {
init.downloadLoading = false;
Message.error("下载模板失败");
}
};
const deviceForm = ref();
// 删除用户
const handleRemoveUser = async (row) => {
try {
// TODO: 调用接口删除用户
Message.success("删除成功");
EquipmentList();
} catch (error) {
Message.error("删除失败");
}
};
// 提交设备表单
const handleSubmitDevice = () => {
const strategy = {
add: () => {
hooks.myEncapsulationFunction(() => {
return api
.postApiEquipmentEquipmentAdd({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
// last_time_maintenance_date: dayjs(
// init.devices.formData.last_time_maintenance_date
// ).format("YYYY-MM-DD HH:mm:ss"),
})
.then(
(res) => {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
const responseInfo = res.response
//获取细项id
bxApi.GetId({parent_id: responseInfo.classification_reparir_item}).then((getAreaChildren) => {
//提交细项
bxApi.addItem({
"parent_id": responseInfo.classification_reparir_item,
"id": getAreaChildren.response,
"name": responseInfo.equipment_name
}).then(_res => {
//双系统信息,同步到中间表
api.getApiRepairAddMiddleItem({
classification_equipment_id: responseInfo.equipment_id,
repair_item: getAreaChildren.response
})
})
})
/**
* 报修细项同步
* */
return res;
},
"提交中...",
false
);
});
},
edit: () => {
console.log(init.devices.formData)
hooks.myEncapsulationFunction(() => {
return api.postApiEquipmentEquipmentUpdate({
...init.devices.formData,
duty_person: init.devices.formData.duty_persons
.map((cur) => cur.tid)
.join(";"),
purchase_date: dayjs(init.devices.formData.purchase_date).format(
"YYYY-MM-DD HH:mm:ss"
),
storage_date: dayjs(init.devices.formData.storage_date).format(
"YYYY-MM-DD HH:mm:ss"
),
last_time_maintenance_date: dayjs(
init.devices.formData.last_time_maintenance_date
).format("YYYY-MM-DD HH:mm:ss"),
}).then((res) => {
if (res.code === 1) {
EquipmentList();
init.devices.show = false;
/**
* 报修细项同步
* */
//获取细项id
api.getApiRepairQueryById({classification_equipment_id: init.devices.formData.id}).then((getAreaChildren) => {
//提交细项
bxApi.modifyItem({
"id": getAreaChildren.response.repair_item_id,
"name": init.devices.formData.name
})
})
/**
* 报修细项同步
* */
return res;
}
});
}, false, '提交中...');
},
};
deviceForm.value.validate((valid) => {
if (valid) {
strategy[init.devices.flag]();
}
});
};
// 树格式化
function treeFormat(arr) {
return arr.map((a) => {
if (a.children && a.children.length != 0) {
a.children = treeFormat(a.children);
}
return {
...a,
title: a.name,
value: a.id,
expand: true,
selected: false,
};
});
}
const searchFormRef = ref()
function getTreeData() {
return api.getApiEquipmentGetEquipmentClassificationTree().then((res) => {
init.devices.treeData = treeFormat(res.response);
init.searchList.forEach((cur) => {
if (cur.code === "classification_id") {
cur.options = treeFormat(res.response);
searchFormRef.value.searchCondObj.classification_id = res.response[0].id;
init.devices.params.classification_id = res.response[0].id;
}
});
return res
});
}
/**人员选择器 */
// 人员选择器》添加用户对话框
const addUserModal = reactive({
flag: '',
pageKey: '',
params: {
page_index: 1,
page_size: 10,
query: "",
},
total: 0,
show: false,
loading: false,
keyword: "",
batchUserList: [],
userList: [],
dutyDepts: [],
availableUserColumns: [
// {
// align: "center",
// type: "selection",
// width: 60,
// },
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
],
});
// 部门列表
const departmentOptions = ref([]);
// 人员选择器》搜索可添加的用户
const searchAvailableUsers = async () => {
loadRoleUsers();
};
//弹出人员选择器
function showAddUser(key) {
addUserModal.flag = key
setPeopleColumnsData()
addUserModal.params = {
page_index: 1,
page_size: 10,
query: "",
}
addUserModal.pageKey = new Date();
addUserModal.show = true;
addUserModal.batchUserList = [];
loadRoleUsers()
}
//批量提交选中人员
function batchAddUser() {
const strategy = {
//新增设备 批量
'入库责任人': () => {
const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
let data = []
addUserModal.batchUserList.forEach((cur, index) => {
//不包含
if (!dataId.includes(cur.tid)) {
data.push(cur)
}
})
init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
addUserModal.show = false;
},
// '出库责任人':()=>{
// const dataId = init.outBound.duty_person_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.duty_person_tids = init.outBound.duty_person_tids.concat(data);
// addUserModal.show = false;
// },
// '出库借用人':()=>{
// const dataId = init.outBound.lender_tids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.outBound.lender_tids = init.outBound.lender_tids.concat(data);
// addUserModal.show = false;
// },
// '归还人':()=>{
// const dataId = init.inBound.returnee_ids.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.inBound.returnee_ids = init.inBound.returnee_ids.concat(data);
// addUserModal.show = false;
// },
}
strategy[addUserModal.flag]()
}
//选中人员
function onSelectionChange(e) {
console.log('e', e)
addUserModal.batchUserList = e;
}
// 人员选择器》确认添加用户
const confirmAddUser = async (user) => {
console.log("🚀🚀🚀,", user)
const strategy = {
// '入库责任人':()=>{
// const dataId = init.devices.formData.duty_persons.map(cur => cur.tid)
// let data = []
// addUserModal.batchUserList.forEach((cur, index) => {
// //不包含
// if (!dataId.includes(cur.tid)) {
// data.push(cur)
// }
// })
// init.devices.formData.duty_persons = init.devices.formData.duty_persons.concat(data);
// console.log("🚀🚀111🚀,", init.devices.formData.duty_persons)
// addUserModal.show = false;
// },
'出库责任人': () => {
init.outBound.duty_person_tids = [user];
addUserModal.show = false;
},
'出库借用人': () => {
init.outBound.lender_tids = [user];
addUserModal.show = false;
},
'归还人': () => {
init.inBound.returnee_ids = [user];
addUserModal.show = false;
},
}
strategy[addUserModal.flag]()
};
// 加载人员选择器用户
const loadRoleUsers = () => {
addUserModal.loading = true;
try {
api
.getApiCommonUserSelect({
...addUserModal.params,
query: addUserModal.keyword,
})
.then((res) => {
addUserModal.userList = res.response.data || [];
addUserModal.total = res.response.data_count;
})
.catch((error) => {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
})
.finally(() => {
addUserModal.loading = false;
});
} catch (error) {
console.error("获取角色用户列表失败:", error);
Message.error("获取角色用户列表失败");
addUserModal.loading = false;
}
};
// 分页改变
const handleAddUserPageChange = (page) => {
addUserModal.params.page_index = page;
loadRoleUsers()
};
// 页大小改变
const handleAddUserPageSizeChange = (size) => {
addUserModal.params.page_size = size;
addUserModal.params.page_index = 1;
loadRoleUsers()
};
//配置人员列表列数据
function setPeopleColumnsData() {
function name() {
addUserModal.availableUserColumns = [
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
{
title: '操作',
slot: 'action',
width: 80,
align: 'center'
}
]
}
const strategy = {
'入库责任人': () => {
addUserModal.availableUserColumns = [
{
align: "center",
type: "selection",
width: 60,
},
{
title: "照片",
slot: "avatar",
width: 80,
},
{
title: "工号",
key: "card_number",
width: 120,
},
{
title: "姓名",
key: "name",
minWidth: 120,
},
{
title: "部门",
key: "dept_name",
minWidth: 150,
},
{
title: "性别",
key: "gender",
width: 80,
},
]
},
'出库责任人': () => name(),
'出库借用人': () => name(),
'归还人': () => name(),
}
strategy[addUserModal.flag]()
}
/**人员选择器 */
/**
* 设备报修
* */
//显示报修
function showRepair(row) {
getRepairAreaTree()
getRepairItemTree()
init.repair.formData ={
"name": "",
"area_id": "",
"area_text": "",
"areaDetail": "",
"item_id": "",
"item_text": "",
"itemDetail": "",
"phone": "",
"detail": "",
"file_list": [],
"relationContentId": "",
"contentLinkId": "",
"key_file_list": [],
"key_remark": ""
}
init.repair.title = row.name
init.repair.formData.name = deviceProjectStore.state.userInfo.name + '(' + deviceProjectStore.state.userInfo.card + ')'
init.repair.show = true
repairForm.value.resetFields()
init.repair.loading = true
//获取报修系统细项id
api.getApiRepairQueryById({classification_equipment_id: row.id}).then(res => {
init.repair.formData.item_id = String(res.response.repair_item_id)
}).finally(() => {
init.repair.loading = false
})
}
//遍历树形结构
function traverseTree(Array) {
return Array.map(item => {
if (item.children && item.children.length > 0) item.children = traverseTree(item.children)
return {
...item,
value: item.key
}
})
}
//获取报修区域
function getRepairAreaTree() {
bxApi.getRepairAreaTree().then(res => {
init.repair.areaTree = traverseTree(res.response)
})
}
//获取报修项目
function getRepairItemTree() {
bxApi.getRepairItemTree().then(res => {
init.repair.itemTree = traverseTree(res.response)
})
}
//附件上传
function beforeRepairFileUpload(file, type) {
console.log(file)
let f = new FormData();
f.append('file', file)
hooks.myEncapsulationFunction(() => {
return bxApi.uploadRepairImage({systemType: 0}, f, {headers: {'Content-Type': 'multipart/form-data'}}).then(res => {
if (res.code === 1) {
if (type === '报修附件') {
init.repair.formData.file_list = init.repair.formData.file_list.concat(res.response)
} else {
init.repair.formData.key_file_list = init.repair.formData.key_file_list.concat(res.response)
}
}
return res
})
}, false, '正在上传中...')
return false
}
const repairForm = ref()
//通过节点id,获取节点名称
function getAreaNameById(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.item_text = item.title
})
}
function getAreaNameById2(id, data) {
data.forEach(item => {
if (item.children != undefined && item.children.length > 0) getAreaNameById(id, item.children)
if (item.value == id) init.repair.formData.area_text = item.title
})
}
//提交报修
function handleRepairSubmit() {
getAreaNameById(init.repair.formData.item_id, init.repair.itemTree)
getAreaNameById2(init.repair.formData.area_id, init.repair.areaTree)
// console.log(111, {
// ...init.repair.formData,
// key_file_list: init.repair.formData.key_file_list.join(','),
// file_list: init.repair.formData.file_list.join(','),
//
// })
repairForm.value.validate(validate => {
if (validate) {
hooks.myEncapsulationFunction(() => {
return bxApi.submitRepair({
...init.repair.formData,
key_file_list: init.repair.formData.key_file_list.map(cur => cur.id).join(','),
file_list: init.repair.formData.file_list.map(cur => cur.id).join(','),
}).then(res => {
//
api.getApiRepairRegisterRepair({
repair_item_id: init.repair.formData.item_id,
repair_out_id: res.response}
).then(()=>{
init.repair.show = false
EquipmentList()
})
return res
})
}, false, '正在提交中...')
}
})
}
/**
* 设备报修
* */
onMounted(() => {
getRepairAreaTree()
getRepairItemTree()
loading.value = true;
getTreeData().then(res => {
EquipmentList();
});
});
</script>
<style scoped>
.role-container {
display: flex;
min-height: calc(100vh - 150px);
/* border: 1px solid #e8eaec; */
border-radius: 4px;
overflow: auto;
gap: 16px;
}
.role-sidebar {
width: 300px;
border-right: 1px solid #e8eaec;
background-color: #fff;
overflow-y: auto;
height: 200px;
}
.role-title {
padding: 16px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #e8eaec;
}
.role-list {
padding: 10px 0;
}
.role-item {
display: flex;
align-items: center;
padding: 12px 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.role-item:hover {
background-color: #f0f0f0;
}
.role-item.active {
background-color: #e8f7ff;
color: #2d8cf0;
}
.role-item-icon {
width: 36px;
height: 36px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
color: #fff;
}
.role-admin {
background-color: #2d8cf0;
}
.role-party-office {
background-color: #19be6b;
}
.role-entrance-dept {
background-color: #ff9900;
}
.role-responsible-dept {
background-color: #ed4014;
}
.role-item-info {
flex: 1;
}
.role-name {
font-size: 14px;
margin-bottom: 4px;
}
.role-count {
font-size: 12px;
color: #808695;
}
.role-content {
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
}
.role-toolbar {
height: 100%;
display: flex;
flex-direction: column;
gap: 20px;
top: 0;
background-color: #fff;
z-index: 1;
}
.search-box {
width: 280px;
}
.pagination {
/* margin-top: 16px; */
text-align: center;
position: sticky;
bottom: 0;
background-color: #fff;
z-index: 1;
}
.action-btns {
display: flex;
justify-content: center;
}
.user-avatar {
display: flex;
justify-content: center;
align-items: center;
}
.user-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.add-user-search {
margin-bottom: 16px;
display: flex;
}
.duty-dept-select {
margin-bottom: 16px;
}
</style>
<style lang='less' scoped>
.filelist {
cursor: pointer;
}
.filelist:hover {
color: #1e93ff;
background-color: #f7f7f7;
}
.fileddelete {
cursor: pointer;
margin-left: auto;
}
.fileddelete:hover {
color: red;
transform: scale(1.5);
}
</style>
import { type AxiosRequestConfig } from "axios";
import { type ParaTestRequest } from "../../interface";
/**
* /api/Common/ParaTest
*/
export declare function postApiCommonParaTest(input?: ParaTestRequest, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: string;
}, any>>;
import request from "@/plugins/request";
/**
* /api/Common/ParaTest
*/
export function postApiCommonParaTest(input, config) {
return request.post(`/api/Common/ParaTest`, input, config);
}
import { type AxiosRequestConfig } from "axios";
/**
* 管理员领用记录导出
* /api/ConsumaMeterial/LendRecordListOutPut
*/
export declare function getApiConsumaMeterialLendRecordListOutPut(params: GetApiConsumaMeterialLendRecordListOutPutParams, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: string;
}, any>>;
export interface GetApiConsumaMeterialLendRecordListOutPutParams {
/** 查询开始时间 */
start_date?: string;
/** 查询结束时间 */
end_date?: string;
/** 关键字:领用人卡号/领用人名称 */
query?: string;
}
import request from "@/plugins/request";
/**
* 管理员领用记录导出
* /api/ConsumaMeterial/LendRecordListOutPut
*/
export function getApiConsumaMeterialLendRecordListOutPut(params, config) {
const paramsInput = {
start_date: params.start_date,
end_date: params.end_date,
query: params.query,
};
return request.get(`/api/ConsumaMeterial/LendRecordListOutPut`, {
params: paramsInput,
...config,
});
}
import { type AxiosRequestConfig } from "axios";
/**
* 批量导入批次入库模板
* /api/ConsumaMeterial/MaterialBatchImportBaseFile
*/
export declare function getApiConsumaMeterialMaterialBatchImportBaseFile(config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: string;
}, any>>;
import request from "@/plugins/request";
/**
* 批量导入批次入库模板
* /api/ConsumaMeterial/MaterialBatchImportBaseFile
*/
export function getApiConsumaMeterialMaterialBatchImportBaseFile(config) {
return request.get(`/api/ConsumaMeterial/MaterialBatchImportBaseFile`, config);
}
import { type AxiosRequestConfig } from "axios";
/**
* 批量导入批次入库
* /api/ConsumaMeterial/MaterialBatchImport
*/
export declare function postApiConsumaMeterialMaterialBatchImport(input?: PostApiConsumaMeterialMaterialBatchImportInput, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: string;
}, any>>;
export interface PostApiConsumaMeterialMaterialBatchImportInput {
file: File;
}
import request from "@/plugins/request";
/**
* 批量导入批次入库
* /api/ConsumaMeterial/MaterialBatchImport
*/
export function postApiConsumaMeterialMaterialBatchImport(input, config) {
return request.post(`/api/ConsumaMeterial/MaterialBatchImport`, input, config);
}
import { type AxiosRequestConfig } from "axios";
import { type MaterialBatchListRequest } from "../../interface";
/**
* 导出批次列表
* /api/ConsumaMeterial/MaterialBatchListExport
*/
export declare function postApiConsumaMeterialMaterialBatchListExport(input?: MaterialBatchListRequest, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: string;
}, any>>;
import request from "@/plugins/request";
/**
* 导出批次列表
* /api/ConsumaMeterial/MaterialBatchListExport
*/
export function postApiConsumaMeterialMaterialBatchListExport(input, config) {
return request.post(`/api/ConsumaMeterial/MaterialBatchListExport`, input, config);
}
import { type AxiosRequestConfig } from "axios";
/**
* 出库单导出
* /api/Equipment/EquipmentLendToPdf
*/
export declare function postApiEquipmentEquipmentLendToPdf(input?: string[], config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>;
import request from "@/plugins/request";
/**
* 出库单导出
* /api/Equipment/EquipmentLendToPdf
*/
export function postApiEquipmentEquipmentLendToPdf(input, config) {
return request.post(`/api/Equipment/EquipmentLendToPdf`, input, config);
}
import { type AxiosRequestConfig } from "axios";
/**
* 报修列表
* /api/Repair/RepairList
*/
export declare function getApiRepairRepairList(params: GetApiRepairRepairListParams, config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<{
code: number;
status: string;
msg: string;
msg_detail: string;
response: {
pageIndex: number;
pageSize: number;
pageCount: number;
dataCount: number;
title: {
field_id: string;
show_name: string;
show_type: string;
width: number;
order_by_flag: number;
default_hide_flag: number;
fixed_flag: number;
code: string;
option: {
label: string;
value: string;
}[];
children: any[];
}[];
data: {
repair_id: string;
repair_out_id: string;
equipment_id: string;
repair_date: string;
duty_tid: string;
duty_name: string;
equipment_name: string;
equipment_model: string;
equipment_unique_id: string;
status: number;
}[];
query: {
[x: string]: any;
};
};
}, any>>;
export interface GetApiRepairRepairListParams {
/** 设备名称关键字 */
query?: string;
/** 报修时间查询起始 */
start_date?: string;
/** 报修时间查询结束 */
end_date?: string;
page_index?: number;
page_size?: number;
}
import request from "@/plugins/request";
/**
* 报修列表
* /api/Repair/RepairList
*/
export function getApiRepairRepairList(params, config) {
const paramsInput = {
query: params.query,
start_date: params.start_date,
end_date: params.end_date,
page_index: params.page_index,
page_size: params.page_size,
};
return request.get(`/api/Repair/RepairList`, {
params: paramsInput,
...config,
});
}
export interface Para {
firstPara?: string;
secondPara?: number;
}
import { type Para } from "../../interface";
export interface ParaTestRequest {
data?: Para[];
mode?: string;
}
export interface RepairListResponse {
/**
* Desc:维修id,本系统生成
* Default:
* Nullable:True
*/
repair_id?: string;
/**
* Desc:维修Id,报修系统生成
* Default:
* Nullable:True
*/
repair_out_id?: string;
/**
* Desc:设备id
* Default:
* Nullable:True
*/
equipment_id?: string;
/**
* Desc:报修日期
* Default:
* Nullable:True
*/
repair_date?: string;
/**
* Desc:报修人tid
* Default:
* Nullable:True
*/
duty_tid?: string;
/** Desc:报修人姓名 */
duty_name?: string;
/**
* Desc:设备名称
* Default:
* Nullable:True
*/
equipment_name?: string;
/**
* Desc:设备型号
* Default:
* Nullable:True
*/
equipment_model?: string;
/**
* Desc:唯一Id
* Default:
* Nullable:True
*/
equipment_unique_id?: string;
/** Desc:报修状态,0-维修中,1-维修完成 */
status?: number;
}
import { type TableTitle, type RepairListResponse } from "../../interface";
export interface RepairListResponsePageModel {
pageIndex?: number;
pageSize?: number;
pageCount?: number;
dataCount?: number;
title?: TableTitle[];
data?: RepairListResponse[];
query?: RepairListResponsePageModelQuery;
}
export interface RepairListResponsePageModelQuery {
[key: string]: any;
}
import { type RepairListResponsePageModel } from "../../interface";
export interface RepairListResponsePageModelMessageModel {
code?: number;
status?: string;
msg?: string;
msg_detail?: string;
response?: RepairListResponsePageModel;
}
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或