| | |
| | | <template> |
| | | <el-dialog v-model="visible" :title="dialogTitle" @closed="handleClosed" destroy-on-close> |
| | | <el-form ref="formRef" :model="formData" :rules="rules" :disabled="dialogReadonly" label-width="100px"> |
| | | <div v-if="dialogReadonly"> |
| | | <h3>设备详情</h3> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <div>设备信息: {{ formData.deviceName }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>设备类型: {{ formData.deviceType }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>设备属性: {{ formData.deviceAtt }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>型号: {{ formData.deviceModel }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>规格: {{ formData.deviceSpecification }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>生产厂商: {{ formData.manufacturer }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>来源: {{ formData.source }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>用途: {{ formData.purpose }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>所属部门: {{ formData.belongDeptName }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>负责人: {{ formData.charger }}</div> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <div>联系电话: {{ formData.contactPhone }}</div> |
| | | </el-col> |
| | | </el-row> |
| | | <h3>出库去向详情</h3> |
| | | <el-table v-loading="loading" :data="list"> |
| | | <el-table-column type="index" width="60" label="序号" /> |
| | | <el-table-column prop="charger" label="用户" /> |
| | | <el-table-column prop="contactPhone" label="电话" /> |
| | | <el-table-column prop="outTarget" label="出库去向" /> |
| | | <el-table-column prop="outTime" label="出库时间" /> |
| | | <el-table-column prop="purpose" label="用途" /> |
| | | </el-table> |
| | | <el-pagination |
| | | v-model:current-page="searchParams.current" |
| | | v-model:page-size="searchParams.size" |
| | | :total="total" |
| | | @change="getList" |
| | | /> |
| | | </div> |
| | | |
| | | <el-form v-else ref="formRef" :model="formData" :rules="rules" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备名称" prop="deviceName"> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备类型" prop="deviceType"> |
| | | <el-input v-model="formData.deviceType" maxlength="50" placeholder="请输入" clearable /> |
| | | <el-select v-model="formData.deviceType" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in dictObj.deviceType" |
| | | :key="item.dictKey" |
| | | :label="item.dictValue" |
| | | :value="item.dictKey" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备属性" prop="deviceAtt"> |
| | | <el-select v-model="formData.deviceAtt" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in dictObj.deviceAtt" |
| | | :key="item.dictKey" |
| | | :label="item.dictValue" |
| | | :value="item.dictKey" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="型号" prop="deviceModel"> |
| | | <el-input v-model="formData.deviceModel" maxlength="50" placeholder="请输入" clearable /> |
| | |
| | | <el-input v-model="formData.deviceSpecification" maxlength="50" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="生产厂商" prop="manufacturer"> |
| | | <el-input v-model="formData.manufacturer" maxlength="50" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="出库去向" prop="stockOutDestination"> |
| | | <el-input v-model="formData.stockOutDestination" maxlength="50" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="来源" prop="source"> |
| | | <el-input v-model="formData.source" maxlength="50" placeholder="请输入" clearable /> |
| | |
| | | <el-input v-model="formData.purpose" maxlength="50" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="所属部门" prop="ownerDept"> |
| | | <el-input v-model="formData.ownerDept" maxlength="50" placeholder="请输入" clearable /> |
| | | <el-form-item label="所属部门" prop="belongDept"> |
| | | <el-tree-select |
| | | v-model="formData.belongDept" |
| | | node-key="id" |
| | | :data="deptTree" |
| | | :props="treeProps" |
| | | check-strictly |
| | | @change="belongDeptChange" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="负责人" prop="ownerUser"> |
| | | <el-input v-model="formData.ownerUser" maxlength="50" placeholder="请输入" clearable /> |
| | | <el-form-item label="负责人" prop="charger"> |
| | | <el-select v-model="formData.charger" placeholder="请选择" :disabled="!formData.belongDept" clearable> |
| | | <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.name" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系电话" prop="contactPhone"> |
| | | <el-input v-model="formData.contactPhone" maxlength="50" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | <script setup> |
| | | import { computed, ref } from 'vue' |
| | | import { ElMessage } from 'element-plus' |
| | | import { fwDeviceDetailApi, fwDeviceSaveApi, fwDeviceUpdateApi } from '@/views/basicManage/deviceStock/fwDevice' |
| | | import { fwDeviceDetailApi, fwDeviceSubmitApi } from '@/views/basicManage/deviceStock/fwDevice' |
| | | import { getUserListApi } from '@/api/system/user' |
| | | import { fieldRules, getDictLabel } from '@ztzf/utils' |
| | | import { fwDeviceTrackPageApi } from '@/views/basicManage/deviceStock/fwDeviceTrackApi' |
| | | |
| | | const initForm = () => ({ |
| | | // 表单默认值 |
| | | deviceModel: '', // 型号 |
| | | deviceName: '', // 设备名称 |
| | | deviceSpecification: '', // 规格 |
| | | belongDept: '', // 所属部门 |
| | | charger: '', // 负责人 |
| | | contactPhone: '', // 联系电话 |
| | | deviceAtt: '', // 设备属性 |
| | | deviceType: '', // 设备类型 |
| | | deviceModel: '', // 型号 |
| | | deviceSpecification: '', // 规格 |
| | | deviceName: '', // 设备名称 |
| | | manufacturer: '', // 生产厂商 |
| | | ownerDept: '', // 所属部门 |
| | | ownerUser: '', // 负责人 |
| | | purpose: '', // 用途 |
| | | source: '', // 来源 |
| | | stockOutDestination: '', // 出库去向 |
| | | }) |
| | | const treeProps = { |
| | | label: 'name', |
| | | children: 'children', |
| | | } |
| | | |
| | | const initSearchParams = () => ({ |
| | | current: 1, // 当前页 |
| | | size: 10, // 每页大小 |
| | | }) |
| | | const searchParams = ref(initSearchParams()) |
| | | |
| | | const dictObj = inject('dictObj') |
| | | const deptTree = inject('deptTree') |
| | | const emit = defineEmits(['success']) |
| | | const formRef = ref(null) // 表单实例 |
| | | const formData = ref(initForm()) // 表单数据 |
| | |
| | | } |
| | | }) |
| | | |
| | | function verify(required, max, messageType = 1) { |
| | | return [ |
| | | required ? { required: true, message: messageType ? '请输入' : '请选择', trigger: ['blur', 'change'] } : {}, |
| | | { max, message: `长度不超过${max}`, trigger: ['blur', 'change'] }, |
| | | ] |
| | | const rules = { |
| | | deviceName: fieldRules(true, 50), |
| | | deviceType: fieldRules(true, 0), |
| | | deviceAtt: fieldRules(true, 0), |
| | | deviceModel: fieldRules(true, 50), |
| | | deviceSpecification: fieldRules(true, 50), |
| | | manufacturer: fieldRules(true, 50), |
| | | source: fieldRules(true, 50), |
| | | purpose: fieldRules(true, 50), |
| | | belongDept: fieldRules(true, 50), |
| | | contactPhone: fieldRules(true, 50), |
| | | charger: fieldRules(true, 0), |
| | | } |
| | | |
| | | const rules = { |
| | | deviceName: verify(true, 50), |
| | | deviceType: verify(true, 50), |
| | | deviceModel: verify(true, 50), |
| | | deviceSpecification: verify(true, 50), |
| | | manufacturer: verify(true, 50), |
| | | stockOutDestination: verify(true, 50), |
| | | source: verify(true, 50), |
| | | purpose: verify(true, 50), |
| | | ownerDept: verify(true, 50), |
| | | ownerUser: verify(true, 50), |
| | | const userList = ref([]) |
| | | |
| | | function belongDeptChange() { |
| | | formData.value.charger = '' |
| | | } |
| | | |
| | | function getUserList() { |
| | | getUserListApi(formData.value.belongDept).then(res => { |
| | | userList.value = res.data.data.records |
| | | }) |
| | | } |
| | | |
| | | watch(() => formData.value.belongDept, getUserList) |
| | | |
| | | // 关闭弹框 |
| | | function handleCancel() { |
| | |
| | | if (!isValid) return |
| | | submitting.value = true |
| | | try { |
| | | dialogMode.value === 'add' ? await fwDeviceSaveApi(formData.value) : await fwDeviceUpdateApi(formData.value) |
| | | await fwDeviceSubmitApi(formData.value) |
| | | ElMessage.success(dialogMode.value === 'add' ? '新增成功' : '更新成功') |
| | | visible.value = false |
| | | emit('success') |
| | |
| | | function handleClosed() { |
| | | formData.value = initForm() |
| | | } |
| | | const total = ref(0) // 总条数 |
| | | const loading = ref(false) // 列表加载中 |
| | | const list = ref([]) // 列表数据 |
| | | async function getList() { |
| | | loading.value = true |
| | | try { |
| | | const params = { ...searchParams.value, deviceId: formData.value.id } |
| | | const res = await fwDeviceTrackPageApi(params) |
| | | list.value = res?.data?.data?.records ?? [] |
| | | total.value = res?.data?.data?.total ?? 0 |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | | } |
| | | |
| | | // 打开弹框 |
| | | async function open({ mode, row } = {}) { |
| | | dialogMode.value = mode || 'add' |
| | | formData.value = row |
| | | visible.value = true |
| | | if (dialogMode.value === 'add') { |
| | | formData.value = initForm() |
| | | } else { |
| | | formData.value = row |
| | | await loadDetail() |
| | | getList() |
| | | } |
| | | } |
| | | |