From dd159ea51a7a77bd8cc00c70c0e900f472fb3395 Mon Sep 17 00:00:00 2001 From: 张诺 <zhang_12370@163.com> Date: 星期四, 05 六月 2025 18:00:17 +0800 Subject: [PATCH] 完善基础管理 供应商、客户、煤种等功能 --- src/views/production/components/ProductionDialog.vue | 289 ++++++++++++++++++++------------------------------------- 1 files changed, 100 insertions(+), 189 deletions(-) diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue index 2787bb2..dedb7b3 100644 --- a/src/views/production/components/ProductionDialog.vue +++ b/src/views/production/components/ProductionDialog.vue @@ -1,22 +1,11 @@ <template> - <el-dialog - v-model="dialogVisible" - :title="dialogType === 'add' ? '鏂板鐢熶骇鍔犲伐' : '缂栬緫鐢熶骇鍔犲伐'" - width="800px" - :close-on-click-modal="false" - @close="handleClose" - > - <el-form - ref="formRef" - :model="formData" - :rules="rules" - label-width="120px" - class="production-form" - > - <el-row :gutter="20"> - <el-col :span="12"> + <el-dialog v-model="dialogVisible" :title="dialogType === 'add' ? '鏂板鐢熶骇鍔犲伐' : '缂栬緫鐢熶骇鍔犲伐'" width="1200px" + :close-on-click-modal="false" @close="handleClose"> + <el-form ref="formRef" :model="formData" :rules="rules" class="production-form"> + <el-row :gutter="24"> + <el-col :span="6"> <el-form-item label="鐓ょ" prop="category"> - <el-select v-model="formData.category" placeholder="璇烽�夋嫨鐓ょ" clearable style="width: 100%"> + <el-select v-model="formData.category" placeholder="璇烽�夋嫨鐓ょ" clearable style="width: 100%" @change="selectChange"> <el-option label="鐐肩劍" value="鐐肩劍" /> <el-option label="姘旂叅" value="姘旂叅" /> <el-option label="鏃犵儫鐓�" value="鏃犵儫鐓�" /> @@ -25,137 +14,53 @@ </el-select> </el-form-item> </el-col> - <el-col :span="12"> - <el-form-item label="鍗曚綅" prop="unit"> - <el-select v-model="formData.unit" placeholder="璇烽�夋嫨鍗曚綅" clearable style="width: 100%"> - <el-option label="鍚ㄤ綅" value="鍚ㄤ綅" /> - <el-option label="鍗冨厠" value="鍗冨厠" /> - </el-select> + <el-col :span="6"> + <el-form-item label="鐑��" prop="Calorific"> + <el-input v-model="formData.Calorific" placeholder="璇疯緭鍏ョ儹鍊�" clearable /> </el-form-item> </el-col> - </el-row> - - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="鐢熶骇鏁伴噺" prop="productionVolume"> - <el-input-number - v-model="formData.productionVolume" - :min="0" - :precision="2" - style="width: 100%" - @change="calculateTotal" - /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="浜哄伐鎴愭湰" prop="laborCost"> - <el-input-number - v-model="formData.laborCost" - :min="0" - :precision="2" - style="width: 100%" - @change="calculateTotal" - /> - </el-form-item> - </el-col> - </el-row> - - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="鍘熸枡鎴愭湰" prop="materialCost"> - <el-input-number - v-model="formData.materialCost" - :min="0" - :precision="2" - style="width: 100%" - @change="calculateTotal" - /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="璁惧璐圭敤" prop="equipmentCost"> - <el-input-number - v-model="formData.equipmentCost" - :min="0" - :precision="2" - style="width: 100%" - @change="calculateTotal" - /> - </el-form-item> - </el-col> - </el-row> - - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="鎬绘垚鏈�" prop="totalCost"> - <el-input-number - v-model="formData.totalCost" - :min="0" - :precision="2" - style="width: 100%" - disabled - /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="鎬讳环鏍�" prop="totalPrice"> - <el-input-number - v-model="formData.totalPrice" - :min="0" - :precision="2" - style="width: 100%" - @change="calculateProfit" - /> - </el-form-item> - </el-col> - </el-row> - - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="鍒╂鼎" prop="profit"> - <el-input-number - v-model="formData.profit" - :min="0" - :precision="2" - style="width: 100%" - disabled - /> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="澶嶈浜�" prop="reviewer"> - <el-input v-model="formData.reviewer" placeholder="璇疯緭鍏ュ璁颁汉" /> - </el-form-item> - </el-col> - </el-row> - - <el-row :gutter="20"> - <el-col :span="12"> - <el-form-item label="鏃ユ湡" prop="date"> - <el-date-picker - v-model="formData.date" - type="date" - placeholder="璇烽�夋嫨鏃ユ湡" - style="width: 100%" - value-format="YYYY-MM-DD" - /> - </el-form-item> + <el-col :span="4" :offset="8"> + <el-button type="primary" @click="search">鏌ヨ</el-button> + <el-button @click="reset">閲嶇疆</el-button> </el-col> </el-row> </el-form> - + <ETable :columns="columns" height="200" @cell-edit="handleCellEdit" :showOperations="false" :tableData="tableData" @row-click="handleRowClick" :editableColumns="['used']" /> + <el-row :gutter="10"> + <el-col :span="4"> + <h1>鐢熶骇鏄庣粏</h1> + </el-col> + </el-row> + <el-row :gutter="10"> + <el-col :span="2"> + <el-button type="primary"> + <el-icon><Plus /></el-icon> 鏂板 + </el-button> + </el-col> + <el-col :span="2"><el-button type="danger"> + <el-icon><Delete /></el-icon> 鍒犻櫎 + </el-button></el-col> + <el-col :span="2"> + <el-button type="warning"> + <el-icon><Warning /></el-icon> 淇敼 + </el-button> + </el-col> + </el-row> <template #footer> <div class="dialog-footer"> <el-button @click="handleClose">鍙� 娑�</el-button> <el-button type="primary" :loading="loading" @click="handleSubmit">纭� 瀹�</el-button> </div> + </template> </el-dialog> </template> <script setup> import { ref, reactive, watch } from 'vue' +import ETable from '@/components/Table/ETable.vue' import { ElMessage } from 'element-plus' +import { Delete, Warning } from '@element-plus/icons-vue' const props = defineProps({ visible: { @@ -171,14 +76,28 @@ default: () => ({}) } }) - +const dialogVisible = defineModel('visible', { + type: Boolean, + default: false +}) const emit = defineEmits(['update:visible', 'success']) -const dialogVisible = ref(false) const dialogType = ref('add') const loading = ref(false) const formRef = ref(null) +const tableData = ref([]) +const currentRow = ref(null) +const columns = [ + { label: '鐓ょ', prop: 'category' }, + { label: '鐑��', prop: 'Calorific' }, + { label: '搴撳瓨鏁伴噺', prop: 'stock' }, + { label: '鏈浣跨敤鏁伴噺', prop: 'used' }, +] +const handleRowClick = (row) => { + currentRow.value = row + console.log('褰撳墠琛屾暟鎹�:', currentRow.value) +} // 琛ㄥ崟鏁版嵁 const formData = reactive({ category: '', @@ -197,51 +116,43 @@ // 琛ㄥ崟楠岃瘉瑙勫垯 const rules = { category: [{ required: true, message: '璇烽�夋嫨鐓ょ', trigger: 'change' }], - unit: [{ required: true, message: '璇烽�夋嫨鍗曚綅', trigger: 'change' }], - productionVolume: [{ required: true, message: '璇疯緭鍏ョ敓浜ф暟閲�', trigger: 'blur' }], - laborCost: [{ required: true, message: '璇疯緭鍏ヤ汉宸ユ垚鏈�', trigger: 'blur' }], - materialCost: [{ required: true, message: '璇疯緭鍏ュ師鏂欐垚鏈�', trigger: 'blur' }], - equipmentCost: [{ required: true, message: '璇疯緭鍏ヨ澶囪垂鐢�', trigger: 'blur' }], - totalPrice: [{ required: true, message: '璇疯緭鍏ユ�讳环鏍�', trigger: 'blur' }], - reviewer: [{ required: true, message: '璇疯緭鍏ュ璁颁汉', trigger: 'blur' }], - date: [{ required: true, message: '璇烽�夋嫨鏃ユ湡', trigger: 'change' }] } -// 鐩戝惉visible鍙樺寲 -watch(() => props.visible, (val) => { - dialogVisible.value = val - if (val) { - dialogType.value = props.type - if (props.type === 'edit') { - Object.assign(formData, props.rowData) - } +const search = () => { + // 鏌ヨ閫昏緫 + if (!formData.category) { + return this.$message.error('璇烽�夋嫨鐓ょ') } -}) - -// 鐩戝惉dialogVisible鍙樺寲 -watch(() => dialogVisible.value, (val) => { - emit('update:visible', val) -}) - -// 璁$畻鎬绘垚鏈� -const calculateTotal = () => { - formData.totalCost = ( - formData.laborCost + - formData.materialCost + - formData.equipmentCost - ) - calculateProfit() + loading.value = true + // 妯℃嫙鏌ヨ鏁版嵁 + setTimeout(() => { + // 鍋囨暟鎹� + tableData.value = [ + { category: '鐐肩劍', Calorific: '6000', stock: 100, used: 20 }, + { category: '姘旂叅', Calorific: '5500', stock: 80, used: 15 }, + { category: '姘旂叅', Calorific: '5500', stock: 80, used: 15 }, + { category: '姘旂叅', Calorific: '5500', stock: 80, used: 15 }, + { category: '姘旂叅', Calorific: '5500', stock: 80, used: 15 }, + { category: '姘旂叅', Calorific: '5500', stock: 80, used: 15 }, + { category: '姘旂叅', Calorific: '5500', stock: 80, used: 15 }, + { category: '鏃犵儫鐓�', Calorific: '7000', stock: 120, used: 30 } + ] + loading.value = false + }, 1000) } -// 璁$畻鍒╂鼎 -const calculateProfit = () => { - formData.profit = formData.totalPrice - formData.totalCost +const reset = () => { + // formRef + formRef.value?.resetFields() +} + +const selectChange = (value) => { } // 鎻愪氦琛ㄥ崟 const handleSubmit = async () => { if (!formRef.value) return - + await formRef.value.validate((valid) => { if (valid) { loading.value = true @@ -271,28 +182,28 @@ date: '' }) } + +// 娣诲姞鍗曞厓鏍肩紪杈戝鐞嗗嚱鏁� +const handleCellEdit = (row, prop, value) => { + console.log('鍗曞厓鏍肩紪杈�:', prop) + // console.log('鍗曞厓鏍肩紪杈戝畬鎴�:', row, prop, value) + // 杩欓噷鍙互娣诲姞楠岃瘉閫昏緫锛屼緥濡傛鏌ヤ娇鐢ㄩ噺鏄惁澶т簬搴撳瓨 + if (prop === 'used' && Number(value) > Number(row.stock)) { + ElMessage.warning('浣跨敤鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺锛�') + // 鍙互鍦ㄨ繖閲岄噸缃�� + row.used = row.stock + } +} </script> -<style scoped> -.production-form { - padding: 20px; +<style scoped lang="scss"> +.el-form{ + .el-row { + padding-top: 20px; + background: rgba($color: #F8FAFB, $alpha: 0.5) ; + } } - -.dialog-footer { - display: flex; - justify-content: flex-end; - gap: 10px; +.el-row>.el-col>h1{ + font-weight: bolder; } - -:deep(.el-form-item__label) { - font-weight: bold; -} - -:deep(.el-input-number) { - width: 100%; -} - -:deep(.el-select) { - width: 100%; -} -</style> \ No newline at end of file +</style> \ No newline at end of file -- Gitblit v1.9.3