| | |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | // /pendingInventory/addPending |
| | | // 添加待入库数据 |
| | | export function addPendingInventory(data) { |
| | | return request({ |
| | | url: '/pendingInventory/addPending', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | |
| | | ElMessage.success(successText); |
| | | return true; |
| | | } else { |
| | | ElMessage.error("删除失败:" + (res.msg || "未知错误")); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | if (error !== "cancel") { |
| | | console.error("删除操作失败:", error); |
| | | ElMessage.error("删除失败:" + (error.message || "请稍后重试")); |
| | | } else { |
| | | ElMessage.info("已取消删除"); |
| | | } |
| | |
| | | <el-form-item :label="'煤种' + (index + 1)"> |
| | | <div class="input-wrapper"> |
| | | <el-input |
| | | v-model="item.name" |
| | | v-model="item.coalId" |
| | | v-show="item.type !== '已有煤'" |
| | | placeholder="请输入" |
| | | style="width: 100%" |
| | | /> |
| | | |
| | | <el-select |
| | | v-model="item.name" |
| | | v-model="item.coalId" |
| | | v-show="item.type === '已有煤'" |
| | | placeholder="请选择" |
| | | style="width: 100%" |
| | | @change="handleCoalSelectChange(index, item.coalId)" |
| | | > |
| | | <el-option |
| | | v-for="ele in coalInfoList" |
| | | v-for="ele in infoCoals" |
| | | :key="ele.key" |
| | | :label="ele.value" |
| | | :value="ele.key" |
| | |
| | | <el-col :span="6"> |
| | | <el-form-item label="发热量"> |
| | | <el-input |
| | | v-if="item.type !== '未知煤'" |
| | | :value=" |
| | | infoCoals.find((coal) => coal.key === item.coalId) |
| | | ?.item.coalValues.find((value) => value.fieldName === '发热量')?.coalValue || '0' |
| | | " |
| | | type="number" |
| | | style="width: 100%" |
| | | :disabled="true" |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">kcal</i> |
| | | </template> |
| | | </el-input> |
| | | <el-input |
| | | v-else |
| | | v-model="item.cv" |
| | | type="number" |
| | | placeholder="请输入发热量" |
| | | style="width: 100%" |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">kcal/kg</i> |
| | | <i style="font-style: normal">kcal</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | |
| | | <el-col :span="6"> |
| | | <el-form-item label="价格"> |
| | | <el-input |
| | | v-if="item.type !== '未知煤'" |
| | | |
| | | :value=" |
| | | infoCoals.find((coal) => coal.key === item.coalId) |
| | | ?.item.priceExcludingTax || 0 |
| | | " |
| | | type="number" |
| | | style="width: 100%" |
| | | :disabled="item.type === '已有煤'" |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">元/吨</i> |
| | | </template> |
| | | </el-input> |
| | | <el-input |
| | | v-else |
| | | v-model="item.price" |
| | | placeholder="请输入价格" |
| | | type="number" |
| | | style="width: 100%" |
| | | > |
| | |
| | | <el-col :span="6"> |
| | | <el-form-item label="硫分"> |
| | | <el-input |
| | | v-if="item.type !== '未知煤'" |
| | | :disabled="item.type === '已有煤'" |
| | | v-model="item.sulfur" |
| | | :value=" |
| | | infoCoals.find((coal) => coal.key === item.coalId) |
| | | ?.item.coalValues.find((value) => value.fieldName === '硫分')?.coalValue || '0' |
| | | " |
| | | type="number" |
| | | placeholder="可选" |
| | | style="width: 100%" |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">%</i> |
| | | </template> |
| | | </el-input> |
| | | <el-input |
| | | v-else |
| | | v-model="item.sulfur" |
| | | type="number" |
| | | placeholder="可选" |
| | |
| | | <el-col :span="6"> |
| | | <el-form-item label="灰分"> |
| | | <el-input |
| | | v-if="item.type !== '未知煤'" |
| | | :disabled="item.type === '已有煤'" |
| | | v-model="item.ash" |
| | | :value=" |
| | | infoCoals.find((coal) => coal.key === item.coalId) |
| | | ?.item.coalValues.find((value) => value.fieldName === '灰分')?.coalValue || '0' |
| | | " |
| | | type="number" |
| | | placeholder="可选" |
| | | style="width: 100%" |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">%</i> |
| | | </template> |
| | | </el-input> |
| | | <el-input |
| | | v-else |
| | | v-model="item.ash" |
| | | type="number" |
| | | placeholder="可选" |
| | |
| | | <el-col :span="6"> |
| | | <el-form-item label="水分"> |
| | | <el-input |
| | | v-if="item.type !== '未知煤'" |
| | | :disabled="item.type === '已有煤'" |
| | | v-model="item.moisture" |
| | | :value=" |
| | | infoCoals.find((coal) => coal.key === item.coalId) |
| | | ?.item.coalValues.find((value) => value.fieldName === '水分')?.coalValue || '0' |
| | | " |
| | | type="number" |
| | | placeholder="可选" |
| | | style="width: 100%" |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">%</i> |
| | | </template> |
| | | </el-input> |
| | | <el-input |
| | | v-else |
| | | v-model="item.moisture" |
| | | type="number" |
| | | placeholder="可选" |
| | |
| | | style="width: 100%" |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">kcal/kg</i> |
| | | <i style="font-style: normal">kcal</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | |
| | | class="result-table" |
| | | style="width: 100%" |
| | | > |
| | | <el-table-column prop="name" label="煤种" min-width="80"> |
| | | <el-table-column prop="coalId" label="煤种" min-width="80"> |
| | | <template #default="scope"> |
| | | {{ matchCoalName(scope.row.name) }} |
| | | {{ |
| | | infoCoals.find((coal) => coal.key === scope.row.coalId) |
| | | ?.value || |
| | | "" || |
| | | matchCoalName(scope.row.coalId) |
| | | }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="ratio" label="配比" min-width="80"> |
| | | <template #default="scope"> {{ scope.row.ratio }}% </template> |
| | | </el-table-column> |
| | | <el-table-column prop="tonnage" label="吨数" min-width="80"> |
| | | <el-table-column prop="quantity" label="吨数" min-width="80"> |
| | | <template #default="scope"> |
| | | {{ scope.row.tonnage }}吨 |
| | | {{ scope.row.quantity }}吨 |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="scoops" label="铲数" min-width="80"> |
| | |
| | | <div class="prop-item"> |
| | | <span class="prop-label">发热量:</span> |
| | | <span class="prop-value" |
| | | >{{ result.optimal.props.cv.toFixed(2) }} kcal/kg</span |
| | | >{{ result.optimal.props.cv.toFixed(2) }} kcal</span |
| | | > |
| | | </div> |
| | | <div class="prop-item"> |
| | |
| | | class="alt-table" |
| | | style="width: 100%" |
| | | > |
| | | <el-table-column prop="name" label="煤种" min-width="80" /> |
| | | <el-table-column prop="coalId" label="煤种" min-width="80"> |
| | | <template #default="scope"> |
| | | {{ |
| | | infoCoals.find((coal) => coal.key === scope.row.coalId) |
| | | ?.value || |
| | | "" || |
| | | matchCoalName(scope.row.coalId) |
| | | }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="ratio" label="配比" min-width="80"> |
| | | <template #default="scope"> |
| | | {{ scope.row.ratio }}% |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="tonnage" label="吨数" min-width="80"> |
| | | <el-table-column prop="quantity" label="吨数" min-width="80"> |
| | | <template #default="scope"> |
| | | {{ scope.row.tonnage }}吨 |
| | | {{ scope.row.quantity }}吨 |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="scoops" label="铲数" min-width="80"> |
| | |
| | | </div> |
| | | |
| | | <div class="alt-props"> |
| | | <span>发热量: {{ alt.props.cv.toFixed(2) }} kcal/kg,</span> |
| | | <span>发热量: {{ alt.props.cv.toFixed(2) }} kcal,</span> |
| | | <span>硫分: {{ alt.props.sulfur.toFixed(2) }}%,</span> |
| | | <span>灰分: {{ alt.props.ash.toFixed(2) }}%,</span> |
| | | <span>水分: {{ alt.props.moisture.toFixed(2) }}%,</span> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { reactive, toRefs, nextTick, onMounted } from "vue"; |
| | | import { reactive, toRefs, nextTick, onMounted, ref } from "vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import { getCoalInfoList } from "@/api/procureMent"; // 假设有一个API获取煤种信息 |
| | | import { getCoalBlendingList,addPendingInventory } from "@/api/calculator/index.js"; |
| | | |
| | | const data = reactive({ |
| | | formInline: { |
| | |
| | | coalForms: [ |
| | | { |
| | | type: "未知煤", |
| | | name: "煤A", |
| | | coalId: "煤A", |
| | | cv: 6200, // 发热量 |
| | | price: 450, // 价格 |
| | | sulfur: 0.6, // 硫分 |
| | |
| | | }, |
| | | { |
| | | type: "未知煤", |
| | | name: "煤B", |
| | | coalId: "煤B", |
| | | cv: 5800, |
| | | price: 380, |
| | | sulfur: 1.0, |
| | |
| | | }, |
| | | { |
| | | type: "未知煤", |
| | | name: "煤C", |
| | | coalId: "煤C", |
| | | cv: 5400, |
| | | price: 320, |
| | | sulfur: 1.4, |
| | |
| | | createCoal: null, |
| | | }, |
| | | }); |
| | | const handleCoalSelectChange = (index, coalId) => { |
| | | const selectedCoal = infoCoals.value.find(item => item.key === coalId); |
| | | |
| | | if (selectedCoal && selectedCoal.item && selectedCoal.item.coalValues) { |
| | | console.log('选中的煤种:', selectedCoal); |
| | | |
| | | // 安全地获取各项煤质参数 |
| | | const getCoalValue = (fieldName) => { |
| | | const coalValue = selectedCoal.item.coalValues.find( |
| | | (value) => value.fieldName === fieldName |
| | | ); |
| | | return coalValue ? coalValue.coalValue : ''; |
| | | }; |
| | | |
| | | // 更新表单数据 |
| | | data.coalForms[index].price = selectedCoal.item.priceExcludingTax || 0; |
| | | data.coalForms[index].cv = getCoalValue("发热量") || 0; |
| | | data.coalForms[index].sulfur = getCoalValue("硫分") || 0; |
| | | data.coalForms[index].ash = getCoalValue("灰分") || 0; |
| | | data.coalForms[index].moisture = getCoalValue("水分") || 0; |
| | | |
| | | // 设置价格(如果有的话) |
| | | if (selectedCoal.item.priceExcludingTax) { |
| | | data.coalForms[index].price = selectedCoal.item.priceExcludingTax; |
| | | } |
| | | |
| | | console.log('更新后的表单数据:', data.coalForms[index]); |
| | | } else { |
| | | console.warn('未找到选中的煤种数据或数据格式不正确'); |
| | | } |
| | | }; |
| | | const coalInfoList = ref([]); |
| | | // onMounted |
| | | const getCoalInfo = async () => { |
| | |
| | | }; |
| | | // 表格展示用:优先用 key 匹配中文名,再用 value 匹配,最后原样返回 |
| | | const matchCoalName = (name) => { |
| | | if (!name || !Array.isArray(coalInfoList.value) || coalInfoList.value.length === 0) return name; |
| | | if ( |
| | | !name || |
| | | !Array.isArray(coalInfoList.value) || |
| | | coalInfoList.value.length === 0 |
| | | ) |
| | | return name; |
| | | // key 匹配 |
| | | const byKey = coalInfoList.value.find(item => String(item.key) === String(name)); |
| | | const byKey = coalInfoList.value.find( |
| | | (item) => String(item.key) === String(name) |
| | | ); |
| | | if (byKey) return byKey.value; |
| | | // value 匹配 |
| | | const byValue = coalInfoList.value.find(item => item.value === name); |
| | | const byValue = coalInfoList.value.find((item) => item.value === name); |
| | | if (byValue) return byValue.value; |
| | | // 原样返回 |
| | | return name; |
| | |
| | | result.value.optimal.props.createCoal = found ? found.key : val; |
| | | // 新增:如果匹配成功,留一个id字段 |
| | | if (found) { |
| | | result.value.optimal.props.createCoalId = found.key; |
| | | result.value.optimal.props.coalId = found.key; |
| | | } else { |
| | | result.value.optimal.props.createCoalId = null; |
| | | result.value.optimal.props.coalId = null; |
| | | } |
| | | let match = matchCoalName(result.value.optimal.props.createCoal); |
| | | if (match && match !== result.value.optimal.props.createCoal) { |
| | |
| | | }; |
| | | onMounted(async () => { |
| | | getCoalInfo(); |
| | | geInfoCoals(); |
| | | }); |
| | | const infoCoals = ref([]); |
| | | // 初始化煤种字段 |
| | | const geInfoCoals = async () => { |
| | | let res = await getCoalBlendingList(); |
| | | if (res.code === 200) { |
| | | infoCoals.value = res.data.map((item) => ({ |
| | | value: item.supplierCoal, |
| | | key: item.coalId, |
| | | item, |
| | | })); |
| | | console.log(infoCoals.value); |
| | | } else { |
| | | ElMessage.error("获取煤种信息失败,请稍后重试"); |
| | | } |
| | | }; |
| | | // 线性规划求解函数 |
| | | const solveBlend = (coals, constraints) => { |
| | | // 数据验证 |
| | |
| | | return coals |
| | | .map((coal, i) => { |
| | | if (ratios[i] < 1e-6) return null; |
| | | let tonnage = ratios[i] * total; |
| | | let scoops = tonnage / scoop; |
| | | let quantity = ratios[i] * total; |
| | | let scoops = quantity / scoop; |
| | | return { |
| | | name: coal.name, |
| | | coalId: coal.coalId, |
| | | ratio: (ratios[i] * 100).toFixed(2), |
| | | tonnage: tonnage.toFixed(1), |
| | | quantity: quantity.toFixed(1), |
| | | scoops: scoops.toFixed(1), |
| | | }; |
| | | }) |
| | |
| | | data.coalForms = [ |
| | | { |
| | | type: "未知煤", |
| | | name: "煤A", |
| | | coalId: "煤A", |
| | | cv: 6200, |
| | | price: 450, |
| | | sulfur: 0.6, |
| | |
| | | }, |
| | | { |
| | | type: "未知煤", |
| | | name: "煤B", |
| | | coalId: "煤B", |
| | | cv: 5800, |
| | | price: 380, |
| | | sulfur: 1.0, |
| | |
| | | }, |
| | | { |
| | | type: "未知煤", |
| | | name: "煤C", |
| | | coalId: "煤C", |
| | | cv: 5400, |
| | | price: 320, |
| | | sulfur: 1.4, |
| | |
| | | ElMessage.success("表单已重置"); |
| | | }; |
| | | const addWarehoused = () => { |
| | | console.log(coalInfoList.value); |
| | | |
| | | if (!result.value) { |
| | | ElMessage.error("请先计算最优配比后再添加至待入库"); |
| | | return; |
| | |
| | | ElMessage.error("请先选择生成煤种"); |
| | | return; |
| | | } |
| | | const coals = result.value.optimal.instructions.map((item) => item.name); |
| | | const coals = result.value.optimal.instructions.map((item) => item.coalId); |
| | | let allFound = true; |
| | | for (const element of coals) { |
| | | let found = false; |
| | |
| | | } |
| | | let createCoalFound = false; |
| | | for (const item of coalInfoList.value) { |
| | | if (item.key === result.value.optimal.props.createCoalId) { |
| | | console.log("生成煤种已存在"); |
| | | if (item.key === result.value.optimal.props.coalId) { |
| | | createCoalFound = true; |
| | | break; |
| | | } |
| | |
| | | ElMessage.warning("生成煤种是未知煤种,无法添加至待入库"); |
| | | return; |
| | | } |
| | | // result.value.optimal.props fieldsResultList |
| | | // result.value.optimal.instructions 表格数据coalResultList |
| | | console.log("添加至待入库数据:", result.value.optimal); |
| | | // cost保留两位小数 |
| | | result.value.optimal.props.totalTonnage = formInline.value.totalTonnage; |
| | | result.value.optimal.instructions.forEach((item) => { |
| | | item.officialId = item.coalId; // 添加官方ID字段 |
| | | }); |
| | | result.value.optimal.props.cost = parseFloat( |
| | | result.value.optimal.props.cost.toFixed(2) |
| | | ); |
| | | result.value.optimal.props.totalTonnage = formInline.value.totalTonnage; |
| | | let arr = [result.value.optimal.props, [...result.value.optimal.instructions]]; |
| | | let params = { |
| | | fieldsResultList: arr[0], |
| | | coalResultList: arr[1], |
| | | }; |
| | | addPendingInventory(params).then((res)=>{ |
| | | if(res.code === 200 && res.data== true){ |
| | | ElMessage.success("添加至待入库成功"); |
| | | } |
| | | }) |
| | | }; |
| | | const submitForm = () => { |
| | | console.log("煤种信息:", coalForms.value); |
| | | // 数据验证 |
| | | let validCoals = coalForms.value.filter( |
| | | (coal) => coal.name && coal.cv && coal.price |
| | | (coal) => coal.coalId && coal.cv && coal.price |
| | | ); |
| | | |
| | | if (validCoals.length < 2) { |
| | |
| | | while (coalForms.value.length < num) { |
| | | coalForms.value.push({ |
| | | type: "未知煤", |
| | | name: `煤${String.fromCharCode(65 + coalForms.value.length)}`, |
| | | coalId: `煤${String.fromCharCode(65 + coalForms.value.length)}`, |
| | | cv: 0, |
| | | price: 0, |
| | | sulfur: "", |
| | |
| | | // 处理煤种类型变化 |
| | | const handleCoalTypeChange = (index) => { |
| | | // 当煤种类型改变时,清空煤种名称,避免数据混乱 |
| | | coalForms.value[index].name = ""; |
| | | coalForms.value[index].coalId = ""; |
| | | }; |
| | | </script> |
| | | |
| | |
| | | |
| | | <!-- 操作按钮区 --> |
| | | <el-row :gutter="24" class="table-toolbar"> |
| | | <el-button :icon="Plus" type="primary" v-show="activeTab === 'management'" @click="handleAdd" |
| | | <el-button |
| | | :icon="Plus" |
| | | type="primary" |
| | | v-show="activeTab === 'management'" |
| | | @click="handleAdd" |
| | | >设备新增</el-button |
| | | > |
| | | <el-button :icon="Plus" type="primary" v-show="activeTab === 'equipmentRequisition'" @click="handleAdd" |
| | | <el-button |
| | | :icon="Plus" |
| | | type="primary" |
| | | v-show="activeTab === 'equipmentRequisition'" |
| | | @click="handleAdd" |
| | | >领用</el-button |
| | | > |
| | | <el-button :icon="Delete" type="danger" @click="handleDelete" |
| | | <el-button |
| | | :icon="Delete" |
| | | type="danger" |
| | | v-show="activeTab === 'management'" |
| | | @click="handleDelete" |
| | | >删除</el-button |
| | | > |
| | | </el-row> |
| | |
| | | @selection-change="handleSelectionChange" |
| | | :operations="['edit', 'viewRow']" |
| | | :operationsWidth="200" |
| | | |
| | | > |
| | | <!-- 字段名称列的自定义插槽 - 显示为标签 --> |
| | | <template |
| | |
| | | </el-tag> |
| | | </template> |
| | | <template v-else> |
| | | <el-tag size="small" type="primary"> |
| | | </el-tag> |
| | | <el-tag size="small" type="primary"> </el-tag> |
| | | </template> |
| | | </template> |
| | | </data-table> |
| | |
| | | @pagination="handPagination" |
| | | /> |
| | | <managementDialog |
| | | v-if="activeTab == 'management'" |
| | | v-if="activeTab == 'management'" |
| | | v-model:copyForm="copyForm" |
| | | v-model:managementFormDialog="manaDialog" |
| | | :addOrEdit="addOrEdit" |
| | |
| | | :formData="form" |
| | | :maxQuantity="getMaxQuantity()" |
| | | :addOrEdit="addOrEdit" |
| | | :equipmentStatus="form.equipmentStatus" |
| | | @submit="onEquipmentRequisitionSubmit" |
| | | /> |
| | | <!-- <UsageRecord |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed, onMounted, reactive, ref } from "vue"; |
| | | import { computed, onMounted, reactive, ref, nextTick } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { Delete, Plus } from "@element-plus/icons-vue"; |
| | | |
| | |
| | | |
| | | // API 服务导入 |
| | | import { useDelete } from "@/hooks/useDelete.js"; |
| | | import { getManagementList, delEquipment } from "@/api/equipment/management/index.js"; |
| | | import { |
| | | getManagementList, |
| | | delEquipment, |
| | | } from "@/api/equipment/management/index.js"; |
| | | import { getUsageRecordList } from "@/api/equipment/requisition/index.js"; |
| | | |
| | | // 响应式状态管理 |
| | |
| | | |
| | | // 查询参数 |
| | | const queryParams = reactive({ |
| | | searchAll: "" |
| | | searchAll: "", |
| | | }); |
| | | |
| | | // 标签页配置 - 便于后续扩展 |
| | |
| | | { prop: "specification", label: "规格型号", minWidth: 100 }, |
| | | { prop: "purchaseDate", label: "采购日期", minWidth: 100 }, |
| | | { prop: "purchasePrice", label: "采购价格", minWidth: 100 }, |
| | | ] |
| | | ], |
| | | }, |
| | | equipmentRequisition:{ |
| | | equipmentRequisition: { |
| | | label: "设备领用", |
| | | searchPlaceholder: "设备编号/设备名称/规格型号", |
| | | showSearch: true, |
| | |
| | | { prop: "equipmentNo", label: "设备编号", minWidth: 100 }, |
| | | { prop: "equipmentName", label: "设备名称", minWidth: 100 }, |
| | | { prop: "usageQuantity", label: "领用数量", minWidth: 100 }, |
| | | { |
| | | prop: "equipmentStatus", |
| | | label: "使用状态", |
| | | { |
| | | prop: "equipmentStatus", |
| | | label: "使用状态", |
| | | minWidth: 100, |
| | | formatter: (row) => row.usageStatus == 1 ? "使用中" : "已归还" |
| | | formatter: (row) => (row.equipmentStatus == "0" ? "使用中" : "已归还"), |
| | | }, |
| | | { prop: "usageStartTime", label: "使用开始时间", minWidth: 100 }, |
| | | { prop: "usageEndTime", label: "使用结束时间", minWidth: 100 }, |
| | | { prop: "remarks", label: "备注", minWidth: 100 }, |
| | | ] |
| | | ], |
| | | }, |
| | | // usageRecord:{ |
| | | // label: "领用记录", |
| | |
| | | // { prop: "equipmentName", label: "设备名称", minWidth: 100 }, |
| | | // { prop: "quantity", label: "数量", minWidth: 100 }, |
| | | // { prop: "specification", label: "规格型号", minWidth: 100 }, |
| | | // { |
| | | // prop: "usageStatus", |
| | | // label: "使用状态", |
| | | // { |
| | | // prop: "usageStatus", |
| | | // label: "使用状态", |
| | | // minWidth: 100, |
| | | // formatter: (row) => row.usageStatus == 1 ? "启用" : "禁用" |
| | | // }, |
| | |
| | | const tabs = reactive( |
| | | Object.entries(tabsConfig).map(([name, config]) => ({ |
| | | name, |
| | | label: config.label |
| | | label: config.label, |
| | | })) |
| | | ); |
| | | |
| | |
| | | const currentTabConfig = computed(() => tabsConfig[activeTab.value]); |
| | | |
| | | // 计算属性 |
| | | const searchPlaceholder = computed(() => currentTabConfig.value?.searchPlaceholder || "请输入搜索信息"); |
| | | const shouldShowSearch = computed(() => currentTabConfig.value?.showSearch || false); |
| | | const searchPlaceholder = computed( |
| | | () => currentTabConfig.value?.searchPlaceholder || "请输入搜索信息" |
| | | ); |
| | | const shouldShowSearch = computed( |
| | | () => currentTabConfig.value?.showSearch || false |
| | | ); |
| | | const columns = computed(() => currentTabConfig.value?.columns || []); |
| | | const selectedCount = computed(() => selectedRows.value.length); |
| | | |
| | |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | |
| | | // 删除处理 |
| | | const { handleDeleteBatch: handleDelete } = useDelete({ |
| | | deleteApi: () => currentTabConfig.value.deleteApi, |
| | |
| | | // 获取设备最大可领用数量 |
| | | const getMaxQuantity = () => { |
| | | if (form.value.equipmentId) { |
| | | const equipment = tableData.value.find(item => item.equipmentId === form.value.equipmentId); |
| | | const equipment = tableData.value.find( |
| | | (item) => item.equipmentId === form.value.equipmentId |
| | | ); |
| | | return equipment ? equipment.quantity : null; |
| | | } |
| | | return null; |
| | |
| | | |
| | | // 设备领用弹窗提交处理 |
| | | const onEquipmentRequisitionSubmit = (formData) => { |
| | | ElMessage.success('设备领用成功'); |
| | | console.log("设备领用提交数据:", formData); |
| | | if (formData.equipmentStatus == "1") { |
| | | ElMessage.success("设备归还成功"); |
| | | } else { |
| | | ElMessage.success("设备领用成功"); |
| | | } |
| | | equipmentRequisitionDialog.value = false; |
| | | getList(); |
| | | nextTick(() => { |
| | | form.value = {}; |
| | | getList(); |
| | | }); |
| | | }; |
| | | |
| | | // 数据获取 |
| | |
| | | const { data, code } = await currentTabConfig.value.api(apiParams); |
| | | |
| | | if (code !== 200) { |
| | | ElMessage.error("获取数据失败:" + (data?.msg || "未知错误")); |
| | | // ElMessage.error("获取数据失败:" + (data?.msg || "未知错误")); |
| | | return; |
| | | } |
| | | |
| | |
| | | flex-wrap: wrap; |
| | | gap: 10px; |
| | | } |
| | | .app-container{ |
| | | .app-container { |
| | | padding: 18px !important; |
| | | } |
| | | /* 响应式表格 */ |
| | |
| | | > |
| | | </el-form-item> |
| | | <el-form-item label="使用状态" prop="equipmentStatus"> |
| | | <!-- 编辑的时候自动匹配 --> |
| | | <el-select v-model="form.equipmentStatus" placeholder="请选择" :disabled="isViewMode"> |
| | | <el-option label="使用中" :value="1" /> |
| | | <el-option label="已归还" :value="0" /> |
| | | <el-option label="使用中" value="0" /> |
| | | <el-option label="已归还" value="1" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="使用开始时间" prop="usageStartTime"> |
| | |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | equipmentStatus:{ |
| | | type: String, |
| | | default: "0" |
| | | } |
| | | }); |
| | | const maxQuantity = computed(() => { |
| | | if (!form.value.equipmentId) return 0; |
| | |
| | | get: () => props.modelValue, |
| | | set: (v) => emit("update:modelValue", v), |
| | | }); |
| | | const isViewMode = computed(() => props.addOrEdit === "view" || props.addOrEdit === "viewRow"); |
| | | const isViewMode = computed(() => props.addOrEdit === "view" || props.addOrEdit === "viewRow" || props.equipmentStatus ==="1"); |
| | | |
| | | const isEdit = computed(() => !!props.formData?.id); |
| | | const formRef = ref(); |
| | |
| | | > |
| | | <el-row :gutter="20"> |
| | | <el-col :span="11"> |
| | | <el-form-item label="设备编号" prop="equipmentName"> |
| | | <el-form-item label="设备编号" prop="equipmentNo"> |
| | | <el-input |
| | | v-model="formData.equipmentName" |
| | | v-model="formData.equipmentNo" |
| | | placeholder="请输入设备编号" |
| | | :disabled="isViewMode" |
| | | style="width: 100%" |
| | |
| | | <script setup> |
| | | import { ref, watch, computed, reactive } from "vue"; |
| | | import { addOrEditEquipment } from "@/api/equipment/management/index.js"; |
| | | import { ElMessage } from "element-plus"; |
| | | |
| | | const props = defineProps({ |
| | | beforeClose: { |
| | |
| | | try { |
| | | const result = await addOrEditEquipment({ ...formData.value }); |
| | | const title = props.title.includes("新增") ? "新增" : "编辑"; |
| | | |
| | | console.log(result) |
| | | if (result.code === 200 && result.msg) { |
| | | ElMessage.success(`${title}成功:${result.msg}`); |
| | | emit("submit", { title, ...formData.value, result }); |
| | |
| | | } |
| | | } catch (error) { |
| | | console.error("提交失败:", error); |
| | | ElMessage.error("提交失败,请重试"); |
| | | } |
| | | }); |
| | | }; |
| | |
| | | closeDialog(); |
| | | }; |
| | | const rules = reactive({ |
| | | equipmentNo: [ |
| | | { required: true, message: "请输入供货商名称", trigger: "blur" }, |
| | | ], |
| | | equipmentName: [ |
| | | { required: true, message: "请输入供货商名称", trigger: "blur" }, |
| | | ], |
| | |
| | | priceExcludingTax: [ |
| | | {required: true, message: "请输入单价", trigger: "blur"}, |
| | | ], |
| | | totalPriceExcludingTax: [ |
| | | {required: true, message: "请输入总价", trigger: "blur"}, |
| | | ], |
| | | priceIncludingTax: [ |
| | | {required: true, message: "请输入含税单价", trigger: "blur"}, |
| | | ], |
| | | totalPriceIncludingTax: [ |
| | | {required: true, message: "请输入含税总价", trigger: "blur"}, |
| | | ], |
| | | taxRate: [{required: true, message: "请输入税率", trigger: "blur"}], |
| | | registrantId: [{required: true, message: "请输入登记人", trigger: "blur"}], |
| | | registrationDate: [ |
| | | {required: true, message: "请选择登记日期", trigger: "change"}, |
| | | ], |
| | | taxRate:[ |
| | | {required: true, message: "请输入税率", trigger: "blur"}, |
| | | {type: "number", message: "税率必须为数字", trigger: "blur"}, |
| | | ] |
| | | }; |
| | | // 关闭弹窗 |
| | | const handleClose = () => { |
| | |
| | | totalPriceExcludingTax: "", |
| | | priceIncludingTax: "", |
| | | totalPriceIncludingTax: "", |
| | | taxRate: "", |
| | | taxRate: "13", |
| | | registrantId: userInfo.value.userId, |
| | | registrationDate: new Date().toISOString().split("T")[0], |
| | | }; |
| | |
| | | coal: [{ required: true, message: "请输入煤种", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请输入单位", trigger: "blur" }], |
| | | coalPlanId: [{ required: true, message: "请选择", trigger: "change" }], |
| | | supplierId: [{ required: true, message: "请选择供应商", trigger: "change" }], |
| | | }, |
| | | mergeRules: { |
| | | supplierName: [{ required: true, message: "请输入供应商名称", trigger: "blur" }], |
| | | coal: [{ required: true, message: "请输入煤种", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请输入单位", trigger: "blur" }], |
| | | coalPlanId: [{ required: true, message: "请选择", trigger: "change" }], |
| | | supplierId: [{ required: true, message: "请选择供应商", trigger: "change" }], |
| | | } |
| | | }) |
| | | |