|
@@ -19,23 +19,25 @@
|
|
|
</el-col>
|
|
|
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
|
|
|
<el-form-item label="部件类型">
|
|
|
- <MySelectRequest :textPla="props.textPla" :select="props.select" :code="props.code" @search="search"/>
|
|
|
+ <MySelectRequest :textPla="propsType.textPla" :select="propsType.select" :code="propsType.code" @search="search"/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
|
|
|
<el-button type="primary" icon="ele-Delete" @click="onReset"> 重置 </el-button>
|
|
|
- <el-button type="primary" icon="ele-Plus" @click="onAdd"> 添加 </el-button>
|
|
|
-<!-- <el-button v-auth="'api:admin:file:upload-file'" type="primary" icon="ele-Upload" @click="onUpload"> 上传 </el-button>-->
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <div class="my-flex my-flex-end" style="margin: 30px 30px 0 0">
|
|
|
- <el-button type="primary" icon="ele-UploadFilled" @click="uploadFiles"> 批量导入 </el-button>
|
|
|
- <el-button type="primary" icon="ele-Document" @click="exportTable"> 导出表格 </el-button>
|
|
|
- </div>
|
|
|
+ <div class="my-flex my-flex-start">
|
|
|
+ <el-button type="primary" icon="ele-Plus" @click="onAdd"> 添加 </el-button>
|
|
|
+ </div>
|
|
|
+ <div class="my-flex my-flex-end">
|
|
|
+ <el-button type="primary" icon="ele-UploadFilled" @click="uploadFiles"> 批量导入 </el-button>
|
|
|
+ <el-button type="primary" icon="ele-Document" @click="exportTable"> 导出表格 </el-button>
|
|
|
+ </div>
|
|
|
</el-card>
|
|
|
</el-col>
|
|
|
<!--表格-->
|
|
@@ -43,38 +45,50 @@
|
|
|
<el-card style="height: 70vh" class="my-fill mt8" shadow="hover">
|
|
|
<el-table v-loading="state.loading" :data="state.bomListData" row-key="id" style="width: 100%">
|
|
|
<el-table-column prop="guid" label="序号" />
|
|
|
- <el-table-column prop="type" label="部件类型" />
|
|
|
+ <el-table-column prop="type" label="部件类型" >
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{getComponentType(row.type)}}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="bomName" label="部件名称" />
|
|
|
<el-table-column prop="bomNo" label="物料号" />
|
|
|
- <el-table-column prop="status" label="状态" />
|
|
|
+ <el-table-column prop="status" label="状态" >
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{getComponentState(row.status)}}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="remark" label="备注" />
|
|
|
<el-table-column prop="bom_Image" label="部件图片" >
|
|
|
-
|
|
|
<template #default="{ row }">
|
|
|
- <div class="my-flex">
|
|
|
+ <div class="my-flex" @click="showBigPic(row.img)">
|
|
|
<el-image
|
|
|
- v-if="isImage(row.extension)"
|
|
|
- :src="row.linkUrl"
|
|
|
+ :src="getImg(row.img)"
|
|
|
:preview-src-list="previewImglist"
|
|
|
:initial-index="getInitialIndex(row.linkUrl)"
|
|
|
:lazy="true"
|
|
|
+ class="img"
|
|
|
:hide-on-click-modal="true"
|
|
|
fit="scale-down"
|
|
|
preview-teleported
|
|
|
- style="width: 80px; height: 80px"
|
|
|
- />
|
|
|
- <div class="ml10 my-flex-fill my-flex-y-center">
|
|
|
- <div>{{ (row.fileName || '') + (row.extension || '') }}</div>
|
|
|
- </div>
|
|
|
+ >
|
|
|
+ <template #error>
|
|
|
+ <div class="image-slot">
|
|
|
+ <el-icon><icon-picture /></el-icon>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-image>
|
|
|
+<!-- <div class="ml10 my-flex-fill my-flex-y-center">-->
|
|
|
+<!-- <div>{{ (row.fileName || '') + (row.extension || '') }}</div>-->
|
|
|
+<!-- </div>-->
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
|
|
|
- <el-table-column prop="createdTime" label="更新时间" >
|
|
|
- <template #default="{ row }">
|
|
|
- {{ formatterTime(row.modifiedTime || row.createdTime || '') }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
+<!-- <el-table-column prop="createdTime" label="更新时间" >-->
|
|
|
+<!-- <template #default="{ row }">-->
|
|
|
+<!-- {{ formatterTime(row.modifiedTime || row.createdTime || '') }}-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- </el-table-column>-->
|
|
|
<el-table-column label="操作" fixed="right" header-align="center" align="center">
|
|
|
<template #default="{ row }">
|
|
|
<!-- <el-popover :width="220">
|
|
@@ -125,19 +139,33 @@
|
|
|
</el-card>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <EditDialog ref="editDialogRef" />
|
|
|
+ <el-dialog
|
|
|
+ v-model="state.showBig"
|
|
|
+ :close-on-click-modal="true"
|
|
|
+ :show-close="false"
|
|
|
+ width="80%"
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ :src="getImg(state.imageUrl)"
|
|
|
+ class="fullscreen-image"
|
|
|
+ alt="放大的图片"/>
|
|
|
+ </el-dialog>
|
|
|
+ <EditDialog :mapType="mapType" :mapState="mapState" ref="editDialogRef" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup name="admin/product/bom">
|
|
|
-import {ref, reactive, onMounted, onBeforeMount, computed, defineAsyncComponent, watch} from 'vue'
|
|
|
+import {ref, reactive, onMounted, onBeforeMount, computed, defineAsyncComponent} from 'vue'
|
|
|
import { ComponentTypeApi } from '/@/api/admin/productionManagement/ComponentType'
|
|
|
-import dayjs from 'dayjs'
|
|
|
+// import dayjs from 'dayjs'
|
|
|
import eventBus from '/@/utils/mitt'
|
|
|
import { isImage } from '/@/utils/test'
|
|
|
import {FileGetPageOutput} from "/@/api/admin/data-contracts";
|
|
|
import {PageInputFileGetPageDto} from "/@/api/admin/productionManagement/ComopnentDto";
|
|
|
import {ComponentGetPageDto} from "/@/api/admin/productionManagement/ComponentTypeDto";
|
|
|
+import { Picture as IconPicture } from '@element-plus/icons-vue'
|
|
|
+import {localStorageSet} from "/@/utils/localStorageSet";
|
|
|
+import {DictApi} from "/@/api/admin/Dict";
|
|
|
//import commonFunction from '/@/utils/commonFunction'
|
|
|
|
|
|
// const { proxy } = getCurrentInstance() as any
|
|
@@ -150,25 +178,50 @@ const MySelectRequest = defineAsyncComponent(() => import('/@/components/my-sele
|
|
|
* code 字段编码
|
|
|
* select 默认值
|
|
|
*/
|
|
|
-const props = reactive({
|
|
|
+const propsType = reactive({
|
|
|
code:'componentType',
|
|
|
select:'',
|
|
|
textPla:'请选择部件类型'
|
|
|
})
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param val
|
|
|
+ */
|
|
|
+const propsState = reactive({
|
|
|
+ code:'componentTypeListStatus',
|
|
|
+ select:'',
|
|
|
+ textPla:'请选择状态'
|
|
|
+})
|
|
|
+
|
|
|
const search = (val) => {
|
|
|
state.filterModel.bomType = val.value
|
|
|
- props.select = val.value
|
|
|
+ propsType.select = val.value
|
|
|
}
|
|
|
|
|
|
+const baseUrl = import.meta.env.VITE_API_URL
|
|
|
+
|
|
|
+const getImg = (url) => {
|
|
|
+ return baseUrl +'/' +url
|
|
|
+}
|
|
|
|
|
|
const editDialogRef = ref()
|
|
|
|
|
|
-const fileUploadRef = ref()
|
|
|
+/**部件类型map*/
|
|
|
+const mapType = ref(new Map)
|
|
|
+
|
|
|
+/**部件状态*/
|
|
|
+const mapState = ref(new Map)
|
|
|
+
|
|
|
+// const fileUploadRef = ref()
|
|
|
|
|
|
//部件的页面对象
|
|
|
const state = reactive({
|
|
|
loading: false,
|
|
|
fileFormTitle: '',
|
|
|
+ showBig: false,
|
|
|
+ /**放大图片的url */
|
|
|
+ imageUrl: "",
|
|
|
filterModel: {
|
|
|
// fileName: '',
|
|
|
bomType: '',
|
|
@@ -197,21 +250,80 @@ const previewImglist = computed(() => {
|
|
|
return imgList
|
|
|
})
|
|
|
|
|
|
+/**查看大图*/
|
|
|
+const showBigPic = (val) => {
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ console.log(val)
|
|
|
+ state.imageUrl = val
|
|
|
+ state.showBig = true
|
|
|
+}
|
|
|
+
|
|
|
+/**返回部件类型*/
|
|
|
+const getComponentType = (type) =>{
|
|
|
+ if(mapType.value?.has(type)){
|
|
|
+ return mapType.value.get(type)
|
|
|
+ }else {
|
|
|
+ return type
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const getComponentState = (state) => {
|
|
|
+ if(mapState.value.has(state)){
|
|
|
+ return mapState.value.get(state)
|
|
|
+ }else {
|
|
|
+ return state
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//获取部件类型map
|
|
|
+const initLocalType = async () => {
|
|
|
+ let localType = localStorageSet.getItemWithExpiration(propsType.code)
|
|
|
+
|
|
|
+ if(!localType){
|
|
|
+ const res = await new DictApi().getList([propsType.code] as string[])
|
|
|
+ /**存一天的缓存*/
|
|
|
+ localStorageSet.setItemWithExpiration(propsType.code as string, res?.data,1)
|
|
|
+ localType = localStorageSet.getItemWithExpiration(propsType.code as string)
|
|
|
+ }
|
|
|
+
|
|
|
+ mapType.value = localType?.reduce((map, obj) => {
|
|
|
+ map.set(Number(obj.value), obj.name);
|
|
|
+ return map;
|
|
|
+ },new Map());
|
|
|
+}
|
|
|
+
|
|
|
+//获取部件状态map
|
|
|
+const initLocalState = async () => {
|
|
|
+ let localState = localStorageSet.getItemWithExpiration(propsState.code)
|
|
|
+
|
|
|
+ if(!localState){
|
|
|
+ const res = await new DictApi().getList([propsState.code] as string[])
|
|
|
+ /**存一天的缓存*/
|
|
|
+ localStorageSet.setItemWithExpiration(propsState.code as string, res?.data,1)
|
|
|
+ localState = localStorageSet.getItemWithExpiration(propsState.code as string)
|
|
|
+ }
|
|
|
+
|
|
|
+ mapState.value = localState?.reduce((map, obj) => {
|
|
|
+ map.set(Number(obj.value), obj.name);
|
|
|
+ return map;
|
|
|
+ },new Map());
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
onQuery()
|
|
|
- eventBus.off('refreshFile')
|
|
|
- eventBus.on('refreshFile', async () => {
|
|
|
+ eventBus.off('refreshView')
|
|
|
+ eventBus.on('refreshView', async () => {
|
|
|
await onQuery()
|
|
|
})
|
|
|
})
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
- eventBus.off('refreshFile')
|
|
|
+ eventBus.off('refreshView')
|
|
|
})
|
|
|
|
|
|
-const formatterTime = (cellValue: any) => {
|
|
|
- return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss')
|
|
|
-}
|
|
|
+// const formatterTime = (cellValue: any) => {
|
|
|
+// return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss')
|
|
|
+// }
|
|
|
|
|
|
const getInitialIndex = (imgUrl: string) => {
|
|
|
return previewImglist.value.indexOf(imgUrl)
|
|
@@ -219,6 +331,8 @@ const getInitialIndex = (imgUrl: string) => {
|
|
|
|
|
|
/**查询*/
|
|
|
const onQuery = async () => {
|
|
|
+ await initLocalType()
|
|
|
+ await initLocalState()
|
|
|
state.loading = true
|
|
|
const res = await new ComponentTypeApi().getPage({ ...state.pageInput, filter: state.filterModel }).catch(() => {
|
|
|
state.loading = false
|
|
@@ -241,7 +355,7 @@ const resetSearchForm = () => {
|
|
|
state.filterModel.bomName = ''
|
|
|
state.filterModel.bomProNo = ''
|
|
|
state.filterModel.bomMateNo = ''
|
|
|
- props.select = ''
|
|
|
+ propsType.select = ''
|
|
|
}
|
|
|
|
|
|
/**添加*/
|
|
@@ -286,4 +400,27 @@ const onCurrentChange = (val: number) => {
|
|
|
.el-form .el-col.mb20 {
|
|
|
margin: 0 !important;
|
|
|
}
|
|
|
+.img {
|
|
|
+ width: 100px;
|
|
|
+ height: 80px;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+.image-slot {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background: var(--el-fill-color-light);
|
|
|
+ color: var(--el-text-color-secondary);
|
|
|
+ font-size: 30px;
|
|
|
+}
|
|
|
+.image-slot .el-icon {
|
|
|
+ font-size: 30px;
|
|
|
+}
|
|
|
+.fullscreen-image {
|
|
|
+ width: 100%;
|
|
|
+ max-height: 80vh;
|
|
|
+ object-fit: contain;
|
|
|
+}
|
|
|
</style>
|