|
@@ -19,8 +19,10 @@
|
|
|
</el-col>
|
|
|
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
|
|
|
<el-form-item label="部件类型">
|
|
|
- <MySelectRequest :textPla="propsType.textPla" :select="propsType.select" :code="propsType.code" @search="search"/>
|
|
|
- </el-form-item>
|
|
|
+ <el-select v-model="state.filterModel.bomType" placeholder="请选择部件类型" >
|
|
|
+ <el-option v-for="(value, key) in componentType" :key="key" :label="value[1].name" :value="Number(value[1].value)" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
|
|
|
<el-form-item>
|
|
@@ -46,15 +48,15 @@
|
|
|
<el-table-column prop="guid" label="序号" />
|
|
|
<el-table-column prop="type" label="部件类型" >
|
|
|
<template #default="{ row }">
|
|
|
- {{row.type.name}}
|
|
|
+ {{ 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="状态" >
|
|
|
<template #default="{ row }" >
|
|
|
- <div :style="{color: row.status.color}" class="bold-font">
|
|
|
- {{row.status.name}}
|
|
|
+ <div :style="{color:getComponentState(row.status).color}" class="bold-font">
|
|
|
+ {{getComponentState(row.status).name}}
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -149,71 +151,42 @@
|
|
|
class="fullscreen-image"
|
|
|
alt="放大的图片"/>
|
|
|
</el-dialog>
|
|
|
- <EditDialog v-if="mapIsExist" :mapType="mapType" :mapState="mapState" ref="editDialogRef" />
|
|
|
+ <EditDialog ref="editDialogRef" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup name="admin/product/bom">
|
|
|
-import {ref, reactive, onMounted, onBeforeMount, defineAsyncComponent} from 'vue'
|
|
|
-import { ComponentTypeApi } from '/@/api/admin/productionManagement/ComponentType'
|
|
|
-// import dayjs from 'dayjs'
|
|
|
+import {defineAsyncComponent, onBeforeMount, onMounted, reactive, ref} from 'vue'
|
|
|
+import {ComponentTypeApi} from '/@/api/admin/productionManagement/ComponentType'
|
|
|
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 {sessionStorageSet} from "/@/utils/sessionStorageSet";
|
|
|
-import {DictApi} from "/@/api/admin/Dict";
|
|
|
-//import commonFunction from '/@/utils/commonFunction'
|
|
|
+import {Picture as IconPicture} from '@element-plus/icons-vue'
|
|
|
+import {useGlobalCacheStore} from "/@/stores/globalCacheStore";
|
|
|
+
|
|
|
|
|
|
-// const { proxy } = getCurrentInstance() as any
|
|
|
|
|
|
/**引入组件*/
|
|
|
const EditDialog = defineAsyncComponent(() => import('../components/form-edit.vue'))
|
|
|
-const MySelectRequest = defineAsyncComponent(() => import('/src/components/my-select-request/index.vue'))
|
|
|
-/**
|
|
|
- * 向子组件传值,
|
|
|
- * code 字段编码
|
|
|
- * select 默认值
|
|
|
- */
|
|
|
-const propsType = reactive({
|
|
|
- code:'componentType',
|
|
|
- select:'',
|
|
|
- textPla:'请选择部件类型'
|
|
|
-})
|
|
|
+
|
|
|
+/**获取全局缓存*/
|
|
|
+const globalCacheStore = useGlobalCacheStore()
|
|
|
+/**部件类型缓存*/
|
|
|
+const componentType = ref(globalCacheStore.getGlobalStore().get('componentType'))
|
|
|
+/**获取部件类型列表状态*/
|
|
|
+const componentTypeListStatus = ref(globalCacheStore.getGlobalStore()?.get('componentTypeListStatus'))
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param val
|
|
|
+ * 根据当前环境获取后端的 域名 + 端口
|
|
|
*/
|
|
|
-const propsState = reactive({
|
|
|
- code:'componentTypeListStatus',
|
|
|
- select:'',
|
|
|
- textPla:'请选择状态'
|
|
|
-})
|
|
|
-
|
|
|
-const search = (val) => {
|
|
|
- state.filterModel.bomType = val.value
|
|
|
- propsType.select = val.value
|
|
|
-}
|
|
|
-
|
|
|
const baseUrl = import.meta.env.VITE_API_URL
|
|
|
|
|
|
-const getImg = (url) => {
|
|
|
- return baseUrl +'/' +url
|
|
|
-}
|
|
|
-
|
|
|
+/**
|
|
|
+ * 绑定EditDialog
|
|
|
+ */
|
|
|
const editDialogRef = ref()
|
|
|
|
|
|
-const mapIsExist = ref(false)
|
|
|
-
|
|
|
-/**部件类型map*/
|
|
|
-const mapType = ref(new Map)
|
|
|
-
|
|
|
-/**部件状态*/
|
|
|
-const mapState = ref(new Map)
|
|
|
-
|
|
|
// const fileUploadRef = ref()
|
|
|
|
|
|
//部件的页面对象
|
|
@@ -259,79 +232,40 @@ const showBigPic = (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).name
|
|
|
-// }else {
|
|
|
-// return state
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-//获取部件类型map
|
|
|
-const initLocalType = async () => {
|
|
|
- let localType = sessionStorageSet.getItemWithExpiration(propsType.code)
|
|
|
-
|
|
|
- if(!localType){
|
|
|
- const res = await new DictApi().getList([propsType.code] as string[])
|
|
|
- /**存一天的缓存*/
|
|
|
- sessionStorageSet.setItemWithExpiration(propsType.code as string, res?.data,1)
|
|
|
- localType = sessionStorageSet.getItemWithExpiration(propsType.code as string)
|
|
|
+/**返回部件类型*/
|
|
|
+const getComponentType = (type) =>{
|
|
|
+ type = String(type)
|
|
|
+ if(componentType.value?.has(type)){
|
|
|
+ return componentType.value.get(type).name
|
|
|
+ }else {
|
|
|
+ return type
|
|
|
}
|
|
|
-
|
|
|
- mapType.value = localType?.reduce((map, obj) => {
|
|
|
- map.set(Number(obj.value), obj);
|
|
|
- return map;
|
|
|
- },new Map());
|
|
|
}
|
|
|
|
|
|
-//获取部件状态map
|
|
|
-const initLocalState = async () => {
|
|
|
- let sessionState = sessionStorageSet.getItemWithExpiration(propsState.code)
|
|
|
-
|
|
|
- if(!sessionState){
|
|
|
- const res = await new DictApi().getList([propsState.code] as string[])
|
|
|
- /**存一天的缓存*/
|
|
|
- sessionStorageSet.setItemWithExpiration(propsState.code as string, res?.data,1)
|
|
|
- sessionState = sessionStorageSet.getItemWithExpiration(propsState.code as string)
|
|
|
+/**
|
|
|
+ * 返回部件类型 - 列表状态
|
|
|
+ * @param state
|
|
|
+ */
|
|
|
+const getComponentState = (state) => {
|
|
|
+ state = String(state)
|
|
|
+ if(componentTypeListStatus.value.has(state)){
|
|
|
+ return componentTypeListStatus.value.get(state)
|
|
|
+ }else {
|
|
|
+ return state
|
|
|
}
|
|
|
- mapState.value =sessionState?.reduce((map, obj) => {
|
|
|
- obj.color = obj.code.split("_")[1]
|
|
|
- map.set(Number(obj.value), {...obj});
|
|
|
- return map;
|
|
|
- },new Map());
|
|
|
}
|
|
|
|
|
|
-onMounted(async () => {
|
|
|
- await initLocalType()
|
|
|
- await initLocalState()
|
|
|
- await onQuery()
|
|
|
- mapIsExist.value = true
|
|
|
- eventBus.off('refreshView')
|
|
|
- eventBus.on('refreshView', async () => {
|
|
|
- await onQuery()
|
|
|
- })
|
|
|
-})
|
|
|
-
|
|
|
-onBeforeMount(() => {
|
|
|
- eventBus.off('refreshView')
|
|
|
-})
|
|
|
-
|
|
|
-// const formatterTime = (cellValue: any) => {
|
|
|
-// return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss')
|
|
|
-// }
|
|
|
-
|
|
|
-// const getInitialIndex = (imgUrl: string) => {
|
|
|
-// return previewImglist.value.indexOf(imgUrl)
|
|
|
-// }
|
|
|
+/**
|
|
|
+ * 拼接后端的 域名 + 端口
|
|
|
+ * @param url
|
|
|
+ */
|
|
|
+const getImg = (url) => {
|
|
|
+ if(url){
|
|
|
+ return baseUrl +'/' +url
|
|
|
+ }else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
/**查询*/
|
|
|
const onQuery = async () => {
|
|
@@ -339,12 +273,7 @@ const onQuery = async () => {
|
|
|
const {data} = await new ComponentTypeApi().getPage({ ...state.pageInput, filter: state.filterModel }).catch(() => {
|
|
|
state.loading = false
|
|
|
})
|
|
|
- const arr = data?.list ?? []
|
|
|
- state.bomListData = arr.map(item => ({
|
|
|
- ...item,
|
|
|
- type: mapType.value.get(item.type),
|
|
|
- status: mapState.value.get(item.status),
|
|
|
- }))
|
|
|
+ state.bomListData = data?.list ?? []
|
|
|
state.total = data?.total ?? 0
|
|
|
state.loading = false
|
|
|
}
|
|
@@ -361,29 +290,70 @@ const resetSearchForm = () => {
|
|
|
state.filterModel.bomName = ''
|
|
|
state.filterModel.bomProNo = ''
|
|
|
state.filterModel.bomMateNo = ''
|
|
|
- propsType.select = ''
|
|
|
+ state.pageInput.currentPage = 1
|
|
|
}
|
|
|
|
|
|
-/**添加*/
|
|
|
+/**
|
|
|
+ * 添加操作时直接打开弹窗表单
|
|
|
+ * */
|
|
|
const onAdd = () => {
|
|
|
editDialogRef.value.openDialog()
|
|
|
}
|
|
|
|
|
|
-/**编辑弹窗 */
|
|
|
+/**
|
|
|
+ * 编辑操作时将当前数据对象传递给编辑表单
|
|
|
+ * */
|
|
|
const editTableData = (row) => {
|
|
|
editDialogRef.value.openDialog(row)
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 页条变化
|
|
|
+ * @param val
|
|
|
+ */
|
|
|
const onSizeChange = (val: number) => {
|
|
|
state.pageInput.pageSize = val
|
|
|
onQuery()
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 页数 变化
|
|
|
+ * @param val
|
|
|
+ */
|
|
|
const onCurrentChange = (val: number) => {
|
|
|
state.pageInput.currentPage = val
|
|
|
onQuery()
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * 挂载时
|
|
|
+ */
|
|
|
+onMounted(async () => {
|
|
|
+ // await initLocalType()
|
|
|
+ // await initLocalState()
|
|
|
+ await onQuery()
|
|
|
+ eventBus.off('refreshView')
|
|
|
+ eventBus.on('refreshView', async () => {
|
|
|
+ await onQuery()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 挂载前,
|
|
|
+ */
|
|
|
+onBeforeMount(() => {
|
|
|
+ eventBus.off('refreshView')
|
|
|
+})
|
|
|
+
|
|
|
+// const formatterTime = (cellValue: any) => {
|
|
|
+// return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss')
|
|
|
+// }
|
|
|
+
|
|
|
+// const getInitialIndex = (imgUrl: string) => {
|
|
|
+// return previewImglist.value.indexOf(imgUrl)
|
|
|
+// }
|
|
|
+
|
|
|
// const onUpload = () => {
|
|
|
// fileUploadRef.value.open()
|
|
|
// }
|