heli-mes/mes-ui/mes-ui-admin-vue3/src/views/heli/materialplan/boom.vue

135 lines
5.0 KiB
Vue
Raw Normal View History

2025-01-09 18:29:48 +08:00
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="80%">
<ContentWrap class="borderxx">
<el-form class="-mb-15px" :model="queryReqVo" :inline="true" label-width="108px">
<el-form-item label=" 零件名称:" label-width="150px">
<el-input v-model="queryReqVo.materialName" placeholder="零件名称" class="!w-240px" />
</el-form-item>
<el-form-item label=" 子项目编号:" label-width="150px">
<el-input v-model="queryReqVo.projectSubCode" placeholder="子项目编号" class="!w-240px" />
</el-form-item>
<el-form-item>
<el-button @click="handleQuery" type="primary" >
<Icon icon="ep:search" class="mr-5px" /> 搜索
</el-button><el-button @click="resetQuery" >
<Icon icon="ep:refresh" class="mr-5px" /> 重置
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<el-card class="hl-table">
<el-table ref="multipleTable" :data="list" v-loading="formLoading" class="hl-table" @selection-change="handleSelectionChange" :row-key="getRowKeys" min-width="1800" @row-click="clickRow">
<el-table-column type="selection" width="55" :reserve-selection="true" :selectable="row=>chkboxEnable" />
<!-- <el-table-column prop="no" label="序号" min-width="120" align="center" /> -->
<el-table-column label="序号" type="index" min-width="120" align="center" />
<el-table-column prop="materialName" label="零件名称" min-width="120" align="center" />
<el-table-column prop="boomSpec" label="规格型号" min-width="140" align="center" />
<el-table-column prop="compositionName" label="材质" min-width="120" align="center" />
<el-table-column prop="amount" label="需求数量" min-width="120" align="center" />
<el-table-column prop="boomUnit" label="系统单位" min-width="120" align="center" >
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_MATERIAL_UNIT" :value="scope.row.boomUnit" />
</template>
</el-table-column>
<el-table-column prop="projectSubCode" label="子项目编号" min-width="120" align="center" />
</el-table>
<!-- 分页 -->
<Pagination :total="total" v-model:page="queryReqVo.pageNo" v-model:limit="queryReqVo.pageSize" @pagination="handleQuery" />
</el-card>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import * as MaterialPlanBoomApi from '@/api/heli/materialplanboom'
import { ElTable } from 'element-plus'
const chkboxEnable = ref(true)
const { t } = useI18n() // 国际化
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中1修改时的数据加载2提交的按钮禁用
const list = ref([]) // 列表的数据
const total = ref(0) // 列表的总页数
const planIdInit = ref()
const multipleTable = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref([])
const handleSelectionChange = (val: []) => {
multipleSelection.value = val
}
const clickRow = (row: any) => {
if (chkboxEnable.value) {
if (row) {
multipleTable.value!.toggleRowSelection(row, undefined)
} else {
multipleTable.value!.clearSelection()
}
}
}
//指定key值,数据更新之后保留之前选中的数据
const getRowKeys = (row) => {
return row.matId
}
const queryReqVo: any = reactive({
pageNo: 1,
pageSize: 10,
projectSubCode:undefined,
materialName:undefined,
planId:planIdInit.value
})
/** 搜索按钮操作 */
const handleQuery = async () => {
const data = await MaterialPlanBoomApi.getBoomDetailList(queryReqVo)
list.value = data.list
total.value = data.total
}
/** 重置按钮操作 */
const resetQuery = () => {
queryReqVo.pageNo = 1
queryReqVo.pageSize = 10
queryReqVo.projectSubCode = ''
queryReqVo.materialName = ''
handleQuery()
}
/** 打开弹窗 */
const open = async (planId: number) => {
dialogVisible.value = true
dialogTitle.value = '加工件列表'
planIdInit.value = planId
queryReqVo.planId = planId
formLoading.value = true
const data = await MaterialPlanBoomApi.getBoomDetailList(queryReqVo)
list.value = data.list
total.value = data.total
formLoading.value = false
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
// 提交请求
formLoading.value = true
try {
dialogVisible.value = false
// 发送操作成功的事件
multipleSelection.value.forEach(item=> item.boomAmount = item.amount)
emit('success', multipleSelection.value)
} finally {
formLoading.value = false
}
}
</script>