Browse Source

设备台账

master
zhang_li 10 months ago
parent
commit
d2e4ac01e2
  1. 153
      src/components/Detail/src/DetailDeviceLedger.vue
  2. 4
      src/components/UploadFile/src/UploadFile.vue
  3. 22
      src/views/eam/device/deviceAccounts/deviceAccounts.data.ts
  4. 31
      src/views/eam/device/deviceAccounts/index.vue

153
src/components/Detail/src/DetailDeviceLedger.vue

@ -39,37 +39,30 @@
@searchFormClick="searchFormClick" @searchFormClick="searchFormClick"
:allSchemas="detailAllSchemas" :allSchemas="detailAllSchemas"
/> />
<!-- 默认单表展现 -->
<!-- <Descriptions
v-if="isBasic && !tabsExtend"
:data="detailData"
:schema="allSchemas.detailSchema"
:columns="2"
/> -->
<div v-if="isBasic && tabsExtend == 1"> <div v-if="isBasic && tabsExtend == 1">
<Form <el-form ref="imageFormRef" :model="imageFormData" :key="formKey">
ref="imageFormRef" <el-form-item label="文件上传">
:rules="upImageRules" <UploadImgs v-model="imageFormData.filePathList" />
:schema="imageFormSchemas" </el-form-item>
/> </el-form>
<el-button type="primary" @click="uploadImage">点击修改</el-button> <el-button type="primary" @click="uploadImage">点击修改</el-button>
</div> </div>
<el-tabs type="border-card" class="demo-tabs" v-model="subIndex" v-if="isBasic && tabsExtend == 2" @tab-change="handleTabsChange"> <div v-if="isBasic && tabsExtend == 2">
<el-tabs class="demo-tabs" v-model="imageParmas.fileBusiType" @tab-change="handleTabsChange">
<el-tab-pane <el-tab-pane
v-for="(item,index) in subTabsList" v-for="item in subTabsList"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:name="item.value" :name="item.value"
>
<Form
:ref="'fileFormRef'"
:rules="upFileRules"
:schema="fileFormSchemas"
:is-col="true"
/> />
<el-button type="primary" @click="uploadFile(index)">点击修改</el-button>
</el-tab-pane>
</el-tabs> </el-tabs>
<el-form ref="fileFormRef" :model="fileFormData" :key="formKey">
<el-form-item label="文件上传">
<UploadFile v-model="fileFormData.filePathList" :limit="20" />
</el-form-item>
</el-form>
<el-button type="primary" @click="uploadFile">点击修改</el-button>
</div>
<!-- 单表切换tabs 展现table --> <!-- 单表切换tabs 展现table -->
<Table <Table
v-if="isBasic && tabsExtend == 3" v-if="isBasic && tabsExtend == 3"
@ -159,7 +152,9 @@ import TableHead from '@/components/TableHead/src/TableHead.vue'
import DetailTable from '@/components/DetailTable/src/DetailTable.vue' import DetailTable from '@/components/DetailTable/src/DetailTable.vue'
import { getCurrentInstance } from 'vue' import { getCurrentInstance } from 'vue'
import { get } from 'http' import { get } from 'http'
import { findIndex } from '@/utils'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const changeFile = () => {}
defineOptions({ name: 'Detail' }) defineOptions({ name: 'Detail' })
@ -295,33 +290,12 @@ const props = defineProps({
required: false, required: false,
default: false default: false
}, },
//
upImageRules: {
type: Array,
required: false,
default: null
},
imageFormAllSchemas: {
type: Object,
required: true,
default: null
},
// //
upFileRules: { upFileRules: {
type: Array, type: Array,
required: false, required: false,
default: null default: null
}, },
fileFormAllSchemas: {
type: Object,
required: true,
default: null
},
subIndex: {
type: String,
required: false,
default: 'A'
},
// //
getImageApi: { getImageApi: {
type: Function, type: Function,
@ -333,17 +307,20 @@ const props = defineProps({
type: Function, type: Function,
required: false, required: false,
default: null default: null
}, }
}) })
const subIndex = ref(props.subIndex) const imageFormData = ref({
filePathList: []
})
const fileFormData = ref({
filePathList: []
})
const subIndex = ref('A')
const isShowDrawer = ref(false) const isShowDrawer = ref(false)
const detailLoading = ref(false) const detailLoading = ref(false)
const tabsList = ref(JSON.parse(JSON.stringify(props.tabs ? props.tabs : ''))) const tabsList = ref(JSON.parse(JSON.stringify(props.tabs ? props.tabs : '')))
const subTabsList = ref(JSON.parse(JSON.stringify(props.subTabs ? props.subTabs : ''))) const subTabsList = ref(JSON.parse(JSON.stringify(props.subTabs ? props.subTabs : '')))
const imageFormSchemas = ref(props.imageFormAllSchemas?.formSchema)
const fileFormSchemas = ref(props.fileFormAllSchemas?.formSchema)
console.log('imageFormSchemas', imageFormSchemas.value)
// Tabs // Tabs
const current = ref(0) const current = ref(0)
@ -355,17 +332,24 @@ const change = (item, index) => {
current.value = index current.value = index
if (item.prop == 'Image') { if (item.prop == 'Image') {
imageParmas.value.funcCode = 'device_mould_picture' imageParmas.value.funcCode = 'device_mould_picture'
imageParmas.value.fileBusiType = ''
getImage()
} else if (item.prop == 'Word') { } else if (item.prop == 'Word') {
imageParmas.value.funcCode = 'device_mould_attachment' imageParmas.value.funcCode = 'device_mould_attachment'
imageParmas.value.fileBusiType = 'A'
subIndex.value = 'A'
formKey.value += 1
getImage()
} else { } else {
imageParmas.value.funcCode = '' imageParmas.value.funcCode = ''
imageParmas.value.fileBusiType = ''
} }
emit('changeTabs', item) emit('changeTabs', item)
} }
// //
const masterParmas = ref({ const masterParmas = ref({
number: '' ,//id number: '' //id
}) })
// //
@ -394,8 +378,10 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
} }
} }
isShowDrawer.value = true isShowDrawer.value = true
imageParmas.value.funcCode = 'device_mould_picture'
if (row) { if (row) {
console.log(row)
detailLoading.value = true detailLoading.value = true
try { try {
await getImage() await getImage()
@ -470,17 +456,22 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
defineExpose({ openDetail }) // open defineExpose({ openDetail }) // open
// //
const formKey = ref(0)
const getImage = () => { const getImage = () => {
props.getImageApi({ props
.getImageApi({
number: masterParmas.value.number, number: masterParmas.value.number,
funcCode: imageParmas.value.funcCode, funcCode: imageParmas.value.funcCode,
fileBusiType: imageParmas.value.fileBusiType fileBusiType: imageParmas.value.fileBusiType
}).then((res)=>{
console.log(res)
nextTick(() => {
imageFormRef.value.setValues({
filePathList:res
}) })
.then((res) => {
nextTick(() => {
if (imageParmas.value.funcCode == 'device_mould_picture') {
imageFormData.value.filePathList = res
} else {
fileFormData.value.filePathList = res
formKey.value += 1
}
}) })
}) })
} }
@ -588,8 +579,7 @@ const emit = defineEmits([
'detailOpenForm', 'detailOpenForm',
'tableFormButton', 'tableFormButton',
'openImage', 'openImage',
'subTabsChick', 'subTabsChick'
'uploadFile'
]) ])
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
@ -641,14 +631,15 @@ const openImage = (item) => {
const imageFormRef = ref() const imageFormRef = ref()
// //
const uploadImage = async () => { const uploadImage = async () => {
const elForm = unref(imageFormRef)?.getElFormRef() // const elForm = unref(imageFormRef)?.getElFormRef()
// // //
if (!elForm) return // if (!elForm) return
const valid = await elForm.validate() // const valid = await elForm.validate()
if (!valid) return // if (!valid) return
imageFormData
let data = { let data = {
number: masterParmas.value.number, number: masterParmas.value.number,
filePathList: imageFormRef.value.formModel.filePathList.map((item) => item.url), filePathList: imageFormData.value.filePathList.map((item) => item.url),
funcCode: imageParmas.value.funcCode, funcCode: imageParmas.value.funcCode,
fileBusiType: imageParmas.value.fileBusiType ? imageParmas.value.fileBusiType : '' fileBusiType: imageParmas.value.fileBusiType ? imageParmas.value.fileBusiType : ''
} }
@ -660,22 +651,28 @@ const uploadImage =async () => {
// tabs // tabs
const fileFormRef = ref() const fileFormRef = ref()
const handleTabsChange = (e) => { const handleTabsChange = (e) => {
emit('subTabsChick',e) imageParmas.value.fileBusiType = e
getImage()
} }
// //
const uploadFile=async(index)=>{ const uploadFile = async () => {
let _lists = fileFormRef.value?.map(v => unref(v)?.getElFormRef()) console.log(fileFormData.value.filePathList)
const elForm = _lists[index] // const elForm = unref(fileFormRef)?.getElFormRef()
// // //
if (!elForm) return // if (!elForm) return
const valid = await elForm.validate() // const valid = await elForm.validate()
if (!valid) return // if (!valid) return
console.log(fileFormRef.value.formModel) // console.log(fileFormRef.value?.formModel.filePathList)
emit( let data = {
'uploadFile', number: masterParmas.value.number,
masterParmas.value.number, filePathList: fileFormData.value.filePathList.map((item) => item.url),
fileFormRef.value.formModel.filePathList.map((item) => item.url) funcCode: imageParmas.value.funcCode,
) fileBusiType: imageParmas.value.fileBusiType ? imageParmas.value.fileBusiType : ''
}
props.uploadImage(data).then((res) => {
message.success('修改成功')
getImage()
})
} }
// //
watch( watch(

4
src/components/UploadFile/src/UploadFile.vue

@ -69,6 +69,7 @@ const props = defineProps({
const valueRef = ref(props.modelValue) const valueRef = ref(props.modelValue)
const uploadRef = ref<UploadInstance>() const uploadRef = ref<UploadInstance>()
const uploadList = ref<UploadUserFile[]>([]) const uploadList = ref<UploadUserFile[]>([])
console.log('88',props.modelValue)
const fileList = props.modelValue && props.modelValue.length > 0 ? ref<UploadUserFile[]>(props.modelValue) : ref<UploadUserFile[]>([]) const fileList = props.modelValue && props.modelValue.length > 0 ? ref<UploadUserFile[]>(props.modelValue) : ref<UploadUserFile[]>([])
const uploadNumber = ref<number>(0) const uploadNumber = ref<number>(0)
const uploadHeaders = ref({ const uploadHeaders = ref({
@ -116,7 +117,7 @@ const handleFileSuccess: UploadProps['onSuccess'] = (res: any): void => {
fileList.value = fileList.value.concat(uploadList.value) fileList.value = fileList.value.concat(uploadList.value)
uploadList.value = [] uploadList.value = []
uploadNumber.value = 0 uploadNumber.value = 0
emit('update:modelValue', listToString(fileList.value)) emit('update:modelValue', fileList.value)
} }
} }
// //
@ -137,6 +138,7 @@ const handleRemove = (file) => {
} }
const handlePreview: UploadProps['onPreview'] = (uploadFile) => { const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
console.log(uploadFile) console.log(uploadFile)
window.open(uploadFile.url)
} }
// //
const listToString = (list: UploadUserFile[], separator?: string) => { const listToString = (list: UploadUserFile[], separator?: string) => {

22
src/views/eam/device/deviceAccounts/deviceAccounts.data.ts

@ -157,21 +157,7 @@ export const UpImage = useCrudSchemas(reactive<CrudSchema[]>([
} }
}, },
])) ]))
// 表单校验 // // 表单校验
export const UpFileRules = reactive({ // export const UpFileRules = reactive({
filePath: [required], // filePath: [required],
}) // })
export const UploadFile = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '上传文件',
field: 'filePathList',
sort: 'custom',
isForm: true,
form:{
component:'UploadFile',
componentProps:{
limit:10
}
}
},
]))

31
src/views/eam/device/deviceAccounts/index.vue

@ -68,12 +68,6 @@
:apiPage="apiPage" :apiPage="apiPage"
:tabsExtend="tabsExtend" :tabsExtend="tabsExtend"
:tableObjectExtend="tableObjectExtend" :tableObjectExtend="tableObjectExtend"
:imageFormAllSchemas="UpImage.allSchemas"
:upImageRules="UpImageRules"
:fileFormAllSchemas="UploadFile.allSchemas"
:upFileRules="UpFileRules"
@subTabsChick="subTabsChick"
@uploadFile="uploadFile"
:getImageApi="uploadApi.getImage" :getImageApi="uploadApi.getImage"
:uploadImage="uploadApi.uploadImage" :uploadImage="uploadApi.uploadImage"
/> />
@ -92,10 +86,7 @@ import download from '@/utils/download'
import { import {
DeviceAccounts, DeviceAccounts,
DeviceAccountsRules, DeviceAccountsRules,
UpImage, UpImage
UpImageRules,
UploadFile,
UpFileRules
} from './deviceAccounts.data' } from './deviceAccounts.data'
import { Item } from '@/views/eam/basic/item/item.data' import { Item } from '@/views/eam/basic/item/item.data'
import * as ItemApi from '@/api/eam/basic/item' import * as ItemApi from '@/api/eam/basic/item'
@ -321,6 +312,7 @@ const changeTabs = (item) => {
// apiPage.value = deviceRepairApi.getDeviceRepairPage // apiPage.value = deviceRepairApi.getDeviceRepairPage
// detailAllSchemas.value = DeviceRepair.allSchemas // detailAllSchemas.value = DeviceRepair.allSchemas
} else if (item.prop == 'DeviceReportRecord') { } else if (item.prop == 'DeviceReportRecord') {
console.log(item.prop)
tabsExtend.value = 3 tabsExtend.value = 3
apiPage.value = deviceRepairApi.getDeviceRepairPage apiPage.value = deviceRepairApi.getDeviceRepairPage
detailAllSchemas.value = DeviceRepair.allSchemas detailAllSchemas.value = DeviceRepair.allSchemas
@ -346,23 +338,8 @@ const changeTabs = (item) => {
} }
] ]
} }
//
const fileBusiType = ref()
const subTabsChick = (e) => {
fileBusiType.value = e
}
//
const uploadFile = (number, filePath) => {
let data = {
number,
filePathList: filePath,
funcCode: funcCode.value,
fileBusiType: fileBusiType.value ? fileBusiType.value : ''
}
uploadApi.uploadImage(data).then((res) => {
console.log(res)
})
}
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
getList() getList()

Loading…
Cancel
Save