yejiaxing 10 months ago
parent
commit
db0e6512c4
  1. 203
      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. 32
      src/views/eam/device/deviceAccounts/index.vue

203
src/components/Detail/src/DetailDeviceLedger.vue

@ -25,7 +25,7 @@
/> />
</ContentWrap> </ContentWrap>
<Tabs :tabsList="tabsList" :current="current" @change="change" :key="tabsKay"/> <Tabs :tabsList="tabsList" :current="current" @change="change" :key="tabsKay" />
<div class="flex"> <div class="flex">
<!-- 详情 --> <!-- 详情 -->
<ContentWrap class="w-[100%]"> <ContentWrap class="w-[100%]">
@ -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-tab-pane <el-tabs class="demo-tabs" v-model="imageParmas.fileBusiType" @tab-change="handleTabsChange">
v-for="(item,index) in subTabsList" <el-tab-pane
:key="item.value" v-for="item in subTabsList"
:label="item.label" :key="item.value"
:name="item.value" :label="item.label"
> :name="item.value"
<Form />
:ref="'fileFormRef'" </el-tabs>
:rules="upFileRules" <el-form ref="fileFormRef" :model="fileFormData" :key="formKey">
:schema="fileFormSchemas" <el-form-item label="文件上传">
:is-col="true" <UploadFile v-model="fileFormData.filePathList" :limit="20" />
/> </el-form-item>
<el-button type="primary" @click="uploadFile(index)">点击修改</el-button> </el-form>
</el-tab-pane> <el-button type="primary" @click="uploadFile">点击修改</el-button>
</el-tabs> </div>
<!-- 单表切换tabs 展现table --> <!-- 单表切换tabs 展现table -->
<Table <Table
v-if="isBasic && tabsExtend == 3" v-if="isBasic && tabsExtend == 3"
@ -157,9 +150,11 @@ import * as defaultButtons from '@/utils/disposition/defaultButtons'
import BasicForm from '@/components/BasicForm/src/BasicForm.vue' import BasicForm from '@/components/BasicForm/src/BasicForm.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue' 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,21 +307,24 @@ 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)
const imageParmas=ref({ const imageParmas = ref({
funcCode: 'device_mould_picture', // funcCode: 'device_mould_picture', //
fileBusiType: '' // fileBusiType: '' //
}) })
@ -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'
} else{ imageParmas.value.fileBusiType = 'A'
imageParmas.value.funcCode = '' subIndex.value = 'A'
formKey.value += 1
getImage()
} else {
imageParmas.value.funcCode = ''
imageParmas.value.fileBusiType = ''
} }
emit('changeTabs', item) emit('changeTabs', item)
} }
// //
const masterParmas = ref({ const masterParmas = ref({
number: '' ,//id number: '' //id
}) })
// //
@ -376,12 +360,12 @@ const buttondata = ref()
const detailData = ref() const detailData = ref()
const titleNameRef = ref() const titleNameRef = ref()
const titleValueRef = ref() const titleValueRef = ref()
const tabsKay =ref(0)//tabskey const tabsKay = ref(0) //tabskey
const openDetail = async (row: any, titleName: any, titleValue: any, tableName: any) => { const openDetail = async (row: any, titleName: any, titleValue: any, tableName: any) => {
titleNameRef.value = titleName titleNameRef.value = titleName
titleValueRef.value = titleValue titleValueRef.value = titleValue
current.value = 0 current.value = 0
tabsKay.value+=1 tabsKay.value += 1
// //
if (!props.isBasic || (props.isBasic && props.tabsExtend)) { if (!props.isBasic || (props.isBasic && props.tabsExtend)) {
// id // id
@ -394,11 +378,13 @@ 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()
detailData.value = row detailData.value = row
// //
if (routeName.value.indexOf('Job') > -1) { if (routeName.value.indexOf('Job') > -1) {
@ -470,19 +456,24 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
defineExpose({ openDetail }) // open defineExpose({ openDetail }) // open
// //
const getImage=()=>{ const formKey = ref(0)
props.getImageApi({ const getImage = () => {
number:masterParmas.value.number, props
funcCode:imageParmas.value.funcCode, .getImageApi({
fileBusiType:imageParmas.value.fileBusiType number: masterParmas.value.number,
}).then((res)=>{ funcCode: imageParmas.value.funcCode,
console.log(res) fileBusiType: imageParmas.value.fileBusiType
nextTick(() => { })
imageFormRef.value.setValues({ .then((res) => {
filePathList:res nextTick(() => {
}) if (imageParmas.value.funcCode == 'device_mould_picture') {
imageFormData.value.filePathList = res
} else {
fileFormData.value.filePathList = res
formKey.value += 1
}
}) })
}) })
} }
const tableObjectRef = ref() const tableObjectRef = ref()
@ -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) => {
@ -640,17 +630,18 @@ 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 : ''
} }
props.uploadImage(data).then((res) => { props.uploadImage(data).then((res) => {
message.success('修改成功') message.success('修改成功')
@ -659,23 +650,29 @@ 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
}
}
},
]))

32
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'
@ -322,7 +313,7 @@ const changeTabs = (item) => {
// detailAllSchemas.value = DeviceRepair.allSchemas // detailAllSchemas.value = DeviceRepair.allSchemas
} else if (item.prop == 'DeviceReportRecord') { } else if (item.prop == 'DeviceReportRecord') {
tabsExtend.value = 3 tabsExtend.value = 3
apiPage.value = deviceRepairApi.getDeviceRepairPage apiPage.value = deviceRepairApi.getDeviceRepairPage
detailAllSchemas.value = DeviceRepair.allSchemas detailAllSchemas.value = DeviceRepair.allSchemas
} else if (item.prop == 'RepairRecord') { } else if (item.prop == 'RepairRecord') {
tabsExtend.value = 3 tabsExtend.value = 3
@ -346,23 +337,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