| | |
| | | "axios": "0.28.1", |
| | | "clipboard": "2.0.11", |
| | | "echarts": "5.5.1", |
| | | "default-passive-events": "^4.0.0", |
| | | "element-china-area-data": "^6.1.0", |
| | | "element-plus": "2.7.6", |
| | | "file-saver": "2.0.5", |
| | |
| | | import 'element-plus/dist/index.css' |
| | | import 'element-plus/theme-chalk/dark/css-vars.css' |
| | | import locale from 'element-plus/es/locale/lang/zh-cn' |
| | | import "default-passive-events"; |
| | | |
| | | import '@/assets/styles/index.scss' // global css |
| | | |
| | |
| | | <template> |
| | | <div> <el-form :inline="true" :model="queryParams" class="search-form" > |
| | | <div> <el-form :inline="true" :model="queryParams" class="search-form"> |
| | | <el-form-item label="æç´¢" v-if="tabName === 'supplier' || tabName === 'customer'"> |
| | | <el-input v-model="queryParams.searchAll" placeholder="ä¾åºå/è¯å«ç /详ç»å°å" clearable /> |
| | | </el-form-item> |
| | |
| | | <el-tabs v-model="activeTab" class="info-tabs" @tab-click="handleTabClick"> |
| | | <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="tab.label" :name="tab.name" /> |
| | | </el-tabs> |
| | | |
| | | |
| | | <!-- æä½æé®åº --> |
| | | <el-row :gutter="24" class="table-toolbar"> |
| | | <el-button type="primary" :icon="Plus" @click="handleAdd">æ°å»º</el-button> |
| | |
| | | <data-table :loading="loading" :table-data="tableData" :columns="columns" |
| | | @selection-change="handleSelectionChange" @edit="handleEdit" :show-selection="true" :border="true" /> |
| | | </div> |
| | | <pagination v-if="total>0" :page="pageNum" :limit="pageSizes" :total="total" @pagination="handPagination" |
| | | <pagination v-if="total > 0" :page="pageNum" :limit="pageSizes" :total="total" @pagination="handPagination" |
| | | :layout="'total, prev, pager, next, jumper'" /> |
| | | <Supplier v-if="tabName === 'supplier'" v-model:copyForm="copyForm" v-model:supplierDialogFormVisible="dialogFormVisible" :form="form" |
| | | :title="title" @submit="handleSubmit" @beforeClose="handleBeforeClose" |
| | | @update:dialogFormVisible="handleDialogFormVisible" :addOrEdit="addOrEdit" /> |
| | | <Customer v-if="tabName === 'customer'" v-model:copyForm="copyForm" v-model:customerDialogFormVisible="dialogFormVisible" :form="form" |
| | | :title="title" @submit="handleSubmit" :addOrEdit="addOrEdit" @beforeClose="handleBeforeClose" /> |
| | | <Coal v-if="tabName === 'coal'" v-model:copyForm="copyForm" v-model:coalDialogFormVisible="dialogFormVisible" :form="form" :title="title" |
| | | :addOrEdit="addOrEdit" @submit="handleSubmit" /> |
| | | <Supplier v-if="tabName === 'supplier'" v-model:copyForm="copyForm" |
| | | v-model:supplierDialogFormVisible="dialogFormVisible" :form="form" :title="title" @submit="handleSubmit" |
| | | @beforeClose="handleBeforeClose" @update:dialogFormVisible="handleDialogFormVisible" :addOrEdit="addOrEdit" /> |
| | | <Customer v-if="tabName === 'customer'" v-model:copyForm="copyForm" |
| | | v-model:customerDialogFormVisible="dialogFormVisible" :form="form" :title="title" @submit="handleSubmit" |
| | | :addOrEdit="addOrEdit" @beforeClose="handleBeforeClose" /> |
| | | <Coal v-if="tabName === 'coal'" v-model:copyForm="copyForm" v-model:coalDialogFormVisible="dialogFormVisible" |
| | | :form="form" :title="title" :addOrEdit="addOrEdit" @submit="handleSubmit" /> |
| | | <coalQualityMaintenance v-if="tabName === 'coalQualityMaintenance'" |
| | | v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible" :form="form" :title="title" |
| | | :addOrEdit="addOrEdit" @submit="handleSubmit" /> |
| | | <coalMeiZhiZiDuanWeiHu v-if="tabName === 'coalMeiZhiZiDuanWeiHu'" |
| | | v-model:coalMaintenanceFieldDialogVisible="dialogFormVisible" :form="form" :title="title" |
| | | :addOrEdit="addOrEdit" @submit="handleSubmit" /> |
| | | </el-card> |
| | | </div> |
| | |
| | | import Customer from "./mould/customer.vue"; |
| | | import Coal from "./mould/coal.vue"; |
| | | import coalQualityMaintenance from "./mould/coalQualityMaintenance.vue"; |
| | | import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue"; |
| | | const { proxy } = getCurrentInstance() |
| | | import { getSupply, addOrEditSupply, delSupply } from "@/api/basicInformation/supplier.js"; |
| | | import { getCoalInfo, delCoalInfo } from "@/api/basicInformation/coal.js"; |
| | |
| | | import { getCustomerList, delCustomer } from "@/api/basicInformation/customer.js"; |
| | | |
| | | // å¼¹çª |
| | | const coalMaintenanceFieldDialogVisible = ref(false); |
| | | const coalQualityMaintenanceDialogFormVisible = ref(false); |
| | | const customerDialogFormVisible = ref(false); |
| | | const coalDialogFormVisible = ref(false); |
| | |
| | | // å°åæ ¼å¼å彿° |
| | | const formatAddressArray = (addressIds) => { |
| | | // 妿å°åæ å°è¡¨è¿æ²¡æåå¤å¥½ï¼æ¾ç¤º -- |
| | | if (!addressMap.value || Object.keys(addressMap.value).length === 0||!addressIds || !Array.isArray(addressIds) || addressIds.length === 0 || addressIds.every(id => !id)) { |
| | | if (!addressMap.value || Object.keys(addressMap.value).length === 0 || !addressIds || !Array.isArray(addressIds) || addressIds.length === 0 || addressIds.every(id => !id)) { |
| | | return '--'; |
| | | } |
| | | |
| | | const addressNames = addressIds.map(id => { |
| | | return addressMap.value[id]?.name || '--'; |
| | | }); |
| | | |
| | | // 妿ææå°ååç§°é½æ¯ '--'ï¼åè¿å '--' |
| | | if (addressNames.every(name => name === '--')) { |
| | | return '--'; |
| | | } |
| | | |
| | | return addressNames.filter(name => name !== '--').join(' / '); |
| | | }; |
| | | // è·åç¨æ·åè¡¨æ°æ® |
| | |
| | | console.error('è·åç¨æ·å表失败:', error); |
| | | } |
| | | }; |
| | | |
| | | onMounted(async () => { |
| | | await handleTabClick({ props: { name: "supplier" } }); |
| | | await fetchAreaOptions(); // å
è·åå°åéæ©æ°æ®å¹¶æå»ºæ å°è¡¨ |
| | |
| | | { name: "supplier", label: "ä¾åºåä¿¡æ¯" }, |
| | | { name: "customer", label: "客æ·ä¿¡æ¯" }, |
| | | { name: "coal", label: "ç
¤ç§ä¿¡æ¯" }, |
| | | { name: "coalQualityMaintenance", label: "ç
¤è´¨ç»´æ¤" }, |
| | | { name: "coalQualityMaintenance", label: "ç
¤è´¨æ¹æ¡" }, |
| | | { name: "coalMeiZhiZiDuanWeiHu", label: "ç
¤è´¨å段" } |
| | | ]); |
| | | // æ¯å¦ç¼è¾ |
| | | const addOrEdit = ref("add"); |
| | |
| | | // supplier ä¾åºåæ°æ® |
| | | const supplierColumns = ref([ |
| | | { prop: "supplierName", label: "ä¾åºååç§°", minWidth: 100 }, |
| | | { prop: "taxpayerId", label: "ç»ä¸äººè¯å«å·", minWidth: 170 }, { |
| | | prop: "bids", |
| | | label: "ç»è¥å°å", |
| | | { prop: "taxpayerId", label: "ç»ä¸äººè¯å«å·", minWidth: 170 }, { |
| | | prop: "bids", |
| | | label: "ç»è¥å°å", |
| | | minWidth: 150, |
| | | showOverflowTooltip: true, |
| | | formatter: (row, column, cellValue) => { |
| | |
| | | { prop: "businessAddress", label: "ç»è¥è¯¦ç»å°å", minWidth: 150 }, |
| | | { prop: "bankAccount", label: "弿·è¡", minWidth: 120 }, |
| | | { prop: "bankName", label: "é¶è¡è´¦å·", minWidth: 150 }, |
| | | { prop: "contactPerson", label: "è系人", minWidth: 100 }, |
| | | { |
| | | prop: "cids", |
| | | label: "è系人å°å", |
| | | { prop: "contactPerson", label: "è系人", minWidth: 100 }, |
| | | { |
| | | prop: "cids", |
| | | label: "è系人å°å", |
| | | minWidth: 150, |
| | | showOverflowTooltip: true, |
| | | formatter: (row, column, cellValue) => { |
| | |
| | | ] |
| | | return formatAddressArray(arr); |
| | | } |
| | | },{ prop: "contactAddress", label: "è系人详ç»å°å", minWidth: 120 }, |
| | | }, { prop: "contactAddress", label: "è系人详ç»å°å", minWidth: 120 }, |
| | | // { |
| | | // prop: "maintainerId", |
| | | // label: "ç»´æ¤äºº", |
| | |
| | | const customerColumns = ref([ |
| | | { prop: "customerName", label: "客æ·åç§°", minWidth: 100 }, |
| | | { prop: "taxpayerId", label: "ç»ä¸äººè¯å«å·", minWidth: 120 }, |
| | | { |
| | | prop: "bids", |
| | | label: "ç»è¥å°å", |
| | | { |
| | | prop: "bids", |
| | | label: "ç»è¥å°å", |
| | | minWidth: 150, |
| | | showOverflowTooltip: true, |
| | | formatter: (row, column, cellValue) => { |
| | |
| | | }, |
| | | { prop: "businessAddress", label: "详ç»å°å", minWidth: 150 }, |
| | | { prop: "bankName", label: "弿·è¡", minWidth: 120 }, |
| | | { prop: "bankAccount", label: "é¶è¡è´¦å·", minWidth: 150 }, |
| | | { prop: "bankAccount", label: "é¶è¡è´¦å·", minWidth: 150 }, |
| | | { prop: "contactPerson", label: "è系人", minWidth: 100 }, |
| | | { prop: "contactPhone", label: "è系人çµè¯", minWidth: 100 }, |
| | | { |
| | | prop: "cids", |
| | | label: "è系人å°å", |
| | | { |
| | | prop: "cids", |
| | | label: "è系人å°å", |
| | | minWidth: 150, |
| | | showOverflowTooltip: true, |
| | | formatter: (row, column, cellValue) => { |
| | |
| | | ]); |
| | | // coal ç
¤ç§æ°æ® |
| | | const coalColumns = ref([ |
| | | { prop: "coal", label: "ç
¤ç§åç§°", minWidth: 200 }, { |
| | | prop: "maintainerId", |
| | | label: "ç»´æ¤äºº", |
| | | { prop: "coal", label: "ç
¤ç§åç§°", minWidth: 200 }, { |
| | | prop: "maintainerId", |
| | | label: "ç»´æ¤äºº", |
| | | minWidth: 120, |
| | | formatter: (row, column, cellValue) => { |
| | | // å¦æç¨æ·æ å°è¡¨è¿æ²¡æåå¤å¥½ï¼æ¾ç¤º -- |
| | |
| | | ]); |
| | | // coalQualityMaintenance ç
¤è´¨ç»´æ¤æ°æ® |
| | | const coalQualityMaintenanceColumns = ref([ |
| | | { prop: "supplierName", label: "å
¨æ°´(<)", minWidth: 200 }, |
| | | { prop: "identifyNumber", label: "æ°´åæ(<)", minWidth: 120 }, |
| | | { prop: "address", label: "ç°å", minWidth: 150 }, |
| | | { prop: "bank", label: "æ¥å(>)", minWidth: 100 }, |
| | | { prop: "bankAccount", label: "ç¡«(<)", minWidth: 100 }, |
| | | { prop: "contacts", label: "åºå®ç¢³", minWidth: 100 }, |
| | | { prop: "coal", label: "ç
¤ç§åç§°", minWidth: 200 }, |
| | | { prop: "totalMoisture", label: "å
¨æ°´å«éç¾åæ¯ (%)", minWidth: 200 }, |
| | | { prop: "analysisMoisture", label: "åææ°´å«éç¾åæ¯ (%)", minWidth: 200 }, |
| | | { prop: "volatileMatter", label: "æ¥ååç¾åæ¯ (%)", minWidth: 100 }, |
| | | { prop: "sulfurContent", label: "ç¡«å«éç¾åæ¯ (%)", minWidth: 100 }, |
| | | { prop: "contacts", label: "åºå®ç¢³ç¾åæ¯ (%)", minWidth: 100 }, |
| | | { prop: "contactAddress", label: "é«ä½åçé", minWidth: 100 }, |
| | | { prop: "maintainer", label: "ä½ä½åçé", minWidth: 100 }, |
| | | ]); |
| | | const coalMeiZhiZiDuanWeiHuColumns = ref([ |
| | | { prop: "fieldName", label: "åæ®µåç§°", minWidth: 200 }, |
| | | { prop: "fieldDescription", label: "åæ®µæè¿°", minWidth: 200 }, |
| | | ]); |
| | | // æ ç¾é¡µç¹å» |
| | | const handleTabClick = (tab) => { |
| | |
| | | columns.value = customerColumns.value; |
| | | dialogFormVisible.value = customerDialogFormVisible.value; |
| | | getList("customer"); |
| | | |
| | | break; |
| | | case "coal": |
| | | columns.value = coalColumns.value; |
| | |
| | | columns.value = coalQualityMaintenanceColumns.value; |
| | | dialogFormVisible.value = coalQualityMaintenanceDialogFormVisible.value; |
| | | getList("coalQualityMaintenance"); |
| | | break; |
| | | case "coalMeiZhiZiDuanWeiHu": |
| | | columns.value = coalMeiZhiZiDuanWeiHuColumns.value; |
| | | dialogFormVisible.value = coalMaintenanceFieldDialogVisible.value; |
| | | getList("coalMeiZhiZiDuanWeiHu"); |
| | | break; |
| | | } |
| | | }; |
| | |
| | | openDialog(); |
| | | } else if (tabName === "coalQualityMaintenance") { |
| | | dialogFormVisible.value = true; |
| | | title.value = title.value + "ç
¤è´¨ç»´æ¤"; |
| | | title.value = title.value + "ç
¤è´¨æ¹æ¡ç»´æ¤"; |
| | | openDialog(); |
| | | } else if (tabName === "coalMeiZhiZiDuanWeiHu") { |
| | | dialogFormVisible.value = true; |
| | | title.value = title.value + "ç
¤è´¨å段维æ¤"; |
| | | openDialog(); |
| | | } |
| | | }; |
| | |
| | | // ç¼è¾ |
| | | const handleEdit = (row) => { |
| | | form.value = JSON.parse(JSON.stringify(row)); |
| | | if(form.value.bprovinceId && form.value.bdistrictId && form.value.bcityId ){ |
| | | if (form.value.bprovinceId && form.value.bdistrictId && form.value.bcityId) { |
| | | form.value.bids = [ |
| | | row.bprovinceId, |
| | | row.bcityId, |
| | | row.bdistrictId, |
| | | ]; |
| | | row.bprovinceId, |
| | | row.bcityId, |
| | | row.bdistrictId, |
| | | ]; |
| | | } |
| | | if(form.value.cprovinceId && form.value.cdistrictId && form.value.ccityId ){ |
| | | if (form.value.cprovinceId && form.value.cdistrictId && form.value.ccityId) { |
| | | form.value.cids = [ |
| | | row.cprovinceId, |
| | | row.ccityId, |
| | | row.cdistrictId, |
| | | ]; |
| | | row.cprovinceId, |
| | | row.ccityId, |
| | | row.cdistrictId, |
| | | ]; |
| | | } |
| | | if(form.value.businessCityId && form.value.businessDistrictId && form.value.businessProvinceId) { |
| | | if (form.value.businessCityId && form.value.businessDistrictId && form.value.businessProvinceId) { |
| | | form.value.bids = [ |
| | | row.businessProvinceId, |
| | | row.businessCityId, |
| | | row.businessDistrictId, |
| | | ]; |
| | | } |
| | | if(form.value.cityId && form.value.districtId && form.value.provinceId) { |
| | | if (form.value.cityId && form.value.districtId && form.value.provinceId) { |
| | | form.value.cids = [ |
| | | row.provinceId, |
| | | row.cityId, |
| | |
| | | .then(async () => { |
| | | try { |
| | | let res; |
| | | if( tabName.value === "supplier" ) { |
| | | if (tabName.value === "supplier") { |
| | | res = await delSupply(arr); |
| | | } else if (tabName.value === "coal") { |
| | | res = await delCoalInfo(arr); |
| | | } else if (tabName.value === "coalQualityMaintenance") { |
| | | res = await delCoalQuality(arr); |
| | | } else if( tabName.value === "customer") { |
| | | } else if (tabName.value === "customer") { |
| | | res = await delCustomer(arr); |
| | | } |
| | | if(res.code !== 200 && res.meg == "æä½æå") { |
| | | if (res.code !== 200 && res.meg == "æä½æå") { |
| | | ElMessage.error("å é¤å¤±è´¥ï¼" + res.msg); |
| | | return; |
| | | } |
| | | ElMessage.success("å 餿å"); |
| | | await getList(); |
| | | await getList(); |
| | | } catch (e) { |
| | | console.error(e); |
| | | ElMessage.error("å é¤å¤±è´¥ï¼è¯·ç¨ååè¯"); |
| | |
| | | form.value = {}; |
| | | }; |
| | | const handleExport = () => { |
| | | if(tabName.value === "supplier") { |
| | | if (tabName.value === "supplier") { |
| | | Export("/supply/export", "ä¾åºåä¿¡æ¯"); |
| | | } else if (tabName.value === "customer") { |
| | | Export("/customer/export", "客æ·ä¿¡æ¯"); |
| | |
| | | |
| | | } |
| | | } |
| | | const Export = (api,name) => { |
| | | const Export = (api, name) => { |
| | | proxy.download(api, { |
| | | ...queryParams.value |
| | | }, `${name}${new Date().getTime()}.xlsx`) |
| | |
| | | pageSize: pageSizes.value, |
| | | searchAll: queryParams.searchAll, |
| | | }); |
| | | } else if (tabName.value === "coalMeiZhiZiDuanWeiHu") { |
| | | return { |
| | | code: 200, |
| | | data: { |
| | | records: [ |
| | | { fieldName: "åæ®µ1", fieldDescription: "æè¿°1" }, |
| | | { fieldName: "åæ®µ2", fieldDescription: "æè¿°2" }, |
| | | { fieldName: "åæ®µ3", fieldDescription: "æè¿°3" } |
| | | ], |
| | | total: 10 |
| | | } |
| | | }; |
| | | // return getCoalQuality({ |
| | | // current: pageNum.value, |
| | | // pageSize: pageSizes.value, |
| | | // searchAll: queryParams.searchAll, |
| | | // }); |
| | | } |
| | | } |
| | | const search = () => { |
| | |
| | | await fetchAreaOptions(); |
| | | } */ |
| | | let { data, code } = await selectInterface() |
| | | if(code !== 200) { |
| | | console.log("è·åæ°æ®ï¼", code, data); |
| | | if (code !== 200) { |
| | | ElMessage.error("è·åæ°æ®å¤±è´¥ï¼" + data.msg); |
| | | loading.value = false; |
| | | return; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogVisible" |
| | | :title="title" |
| | | width="600" |
| | | :close-on-click-modal="false" |
| | | :before-close="handleClose" |
| | | > |
| | | <el-form |
| | | ref="formRef" |
| | | style="max-width: 400px; margin: 0 auto" |
| | | :model="formData" |
| | | :rules="rules" |
| | | label-width="auto" |
| | | > |
| | | <el-form-item label="åæ®µåç§°" prop="fieldName"> |
| | | <el-input |
| | | v-model="formData.fieldName" |
| | | placeholder="请è¾å
¥å段åç§°" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="Activity form" props="dielDescription"> |
| | | <el-input v-model="formData.fieldDescription" type="textarea" placeholder="请è¾å
¥å段æè¿°" /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="submitForm"> ç¡®å® </el-button> |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm" |
| | | >éç½®</el-button |
| | | > |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm" |
| | | >åæ¶</el-button |
| | | > |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, watch, defineProps, onMounted } from "vue"; |
| | | import addressList from "@/api/jsonApi/areaList.json"; |
| | | const props = defineProps({ |
| | | beforeClose: { |
| | | type: Function, |
| | | default: () => {}, |
| | | }, |
| | | form: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | addOrEdit: { |
| | | type: String, |
| | | default: "add", |
| | | }, |
| | | title: { |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | }); |
| | | |
| | | const emit = defineEmits(["submit", "handleBeforeClose"]); |
| | | // è¡¨åæ°æ® |
| | | const formData = ref({ ...props.form }); |
| | | // å¼¹çªå¯è§æ§ |
| | | const dialogVisible = defineModel("coalMaintenanceFieldDialogVisible", { |
| | | required: true, |
| | | type: Boolean, |
| | | }); |
| | | // æäº¤è¡¨å |
| | | const submitForm = async () => { |
| | | if (!formRef.value) return; |
| | | await formRef.value.validate(async (valid, fields) => { |
| | | if (valid) { |
| | | } |
| | | }); |
| | | }; |
| | | // åæ¶è¡¨å |
| | | const cancelForm = () => { |
| | | emit("update:coalMaintenanceFieldDialogVisible", false); |
| | | formData.value = {}; |
| | | }; |
| | | // é置表å |
| | | const resetForm = () => { |
| | | |
| | | |
| | | }; |
| | | // å
³éå¼¹çª |
| | | const handleClose = () => { |
| | | // 触åç¶ç»ä»¶çå
³é彿° |
| | | emit("handleBeforeClose"); |
| | | emit("update:coalMaintenanceFieldDialogVisible", false); |
| | | }; |
| | | const rules = reactive({ |
| | | coal: [ |
| | | { required: true, message: "请è¾å
¥ç
¤ç§åç§°", trigger: "blur" }, |
| | | ], |
| | | }); |
| | | </script> |
| | | <style lang="sass" scoped> |
| | | </style> |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogVisible" |
| | | :title="title" |
| | | width="600" |
| | | :close-on-click-modal="false" |
| | | :before-close="handleClose" |
| | | > |
| | | <el-form |
| | | ref="formRef" |
| | | style="max-width: 400px; margin: 0 auto" |
| | | :model="formData" |
| | | :rules="rules" |
| | | label-width="auto" |
| | | > |
| | | <el-form-item label="ç
¤ç§ç±»å" prop="coal"> |
| | | <el-input |
| | | v-model="formData.coal" |
| | | placeholder="请è¾å
¥ä¾è´§ååç§°" |
| | | /> |
| | | <el-dialog v-model="dialogVisible" :title="title" width="600" :close-on-click-modal="false" |
| | | :before-close="handleClose"> |
| | | <el-form ref="formRef" style="max-width: 400px; margin: 0 auto" :model="formData" :rules="rules" |
| | | label-width="auto"> |
| | | <el-form-item label="æ¹æ¡åç§°" prop="schemeName"> |
| | | <el-input v-model="formData.schemeName" placeholder="请è¾å
¥æ¹æ¡åç§°" prop="schemeName" /> |
| | | </el-form-item> |
| | | <el-form-item label="å
¨æ°´å«éç¾åæ¯ (%)" prop="totalMoisture"> |
| | | <el-input |
| | | v-model="formData.totalMoisture" |
| | | placeholder="请è¾å
¥å
¨æ°´å«éç¾åæ¯" |
| | | /> |
| | | <el-form-item label="æ¹æ¡ç±»å" props="fieldName"> |
| | | <el-select v-model="formData.fieldName" placeholder="Select" style="width: 240px" clearable multiple> |
| | | <template #label="{ label }"> |
| | | <span>{{ label }}: </span> |
| | | <span style="font-weight: bold">{{ value }}</span> |
| | | </template> |
| | | <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="å
¨æ°´å«éç¾åæ¯ (%)" prop="analysisMoisture"> |
| | | <el-input |
| | | v-model="formData.analysisMoisture" |
| | | placeholder="请è¾å
¥å
¨æ°´å«éç¾åæ¯" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="å
¨æ°´å«éç¾åæ¯ (%)" prop="volatileMatter"> |
| | | <el-input |
| | | v-model="formData.volatileMatter" |
| | | placeholder="请è¾å
¥å
¨æ°´å«éç¾åæ¯" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="åºå®ç¢³ç¾åæ¯ (%)" prop="fixedCarbon"> |
| | | <el-input |
| | | v-model="formData.fixedCarbon" |
| | | placeholder="请è¾å
¥å®¢æ·è¯¦ç»å°å" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="ä½ä½åçéï¼åä½ï¼åå¡/åå
ï¼" prop="lowerHeatValue"> |
| | | <el-input |
| | | v-model="formData.lowerHeatValue" |
| | | placeholder="请è¾å
¥é¶è¡è´¦æ·" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="é«ä½åçéï¼åä½ï¼åå¡/åå
ï¼" prop="higherHeatValue"> |
| | | <el-input v-model="formData.higherHeatValue" placeholder="请è¾å
¥å¼æ·è¡" /> |
| | | </el-form-item> |
| | | <el-form-item label="ç°åç¾åæ¯ (%)" prop="ashContent"> |
| | | <el-input v-model="formData.ashContent" placeholder="请è¾å
¥è系人" /> |
| | | </el-form-item> |
| | | <el-form-item label="ç¡«å«éç¾åæ¯ (%)" prop="sulfurContent"> |
| | | <el-input |
| | | v-model="formData.sulfurContent" |
| | | placeholder="请è¾å
¥è系人çµè¯" |
| | | /> |
| | | </el-form-item> |
| | | <template #footer> |
| | | <el-form-item label="åæ®µæè¿°" prop="fieldDescription"> |
| | | <el-input v-model="formData.fieldDescription" type="textarea" placeholder="请è¾å
¥å段æè¿°" /> |
| | | </el-form-item> |
| | | |
| | | </template> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="submitForm"> ç¡®å® </el-button> |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm" |
| | | >éç½®</el-button |
| | | > |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm" |
| | | >åæ¶</el-button |
| | | > |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm">éç½®</el-button> |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm">åæ¶</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | |
| | | <script setup> |
| | | import { ref, watch, defineProps, onMounted } from "vue"; |
| | | import addressList from "@/api/jsonApi/areaList.json"; |
| | | import { addOrEditCoalQuality } from "@/api/basicInformation/coalQualityMaintenance.js"; |
| | | const props = defineProps({ |
| | | beforeClose: { |
| | | type: Function, |
| | | default: () => {}, |
| | | default: () => { }, |
| | | }, |
| | | form: { |
| | | type: Object, |
| | |
| | | default: "", |
| | | }, |
| | | }); |
| | | |
| | | const options = [ |
| | | { |
| | | value: 'Option1', |
| | | label: 'Label1', |
| | | }, |
| | | { |
| | | value: 'Option2', |
| | | label: 'Label2', |
| | | }, |
| | | { |
| | | value: 'Option3', |
| | | label: 'Label3', |
| | | }, |
| | | { |
| | | value: 'Option4', |
| | | label: 'Label4', |
| | | }, |
| | | { |
| | | value: 'Option5', |
| | | label: 'Label5', |
| | | }, |
| | | ] |
| | | const emit = defineEmits(["submit", "handleBeforeClose"]); |
| | | |
| | | onMounted(()=>{ |
| | | addressSelectOptions.value = mapAddress(addressList); |
| | | }) |
| | | // å°åéæ©æ°æ® |
| | | const addressSelectOptions = ref([]); |
| | | // å¤çå°åæ°æ®è½¬æ¢ |
| | | function mapAddress(list) { |
| | | return list.map(item => ({ |
| | | value: item.no, |
| | | label: item.name, |
| | | children: item.children ? mapAddress(item.children) : undefined |
| | | })); |
| | | } |
| | | // 表åå¼ç¨ |
| | | const formRef = ref(null); |
| | | // è¡¨åæ°æ® |
| | | const formData = ref({ ...props.form }); |
| | | // å¼¹çªå¯è§æ§ |
| | |
| | | required: true, |
| | | type: Boolean, |
| | | }); |
| | | // çå¬å¤é¨ä¼ å
¥çè¡¨åæ°æ®åå |
| | | watch( |
| | | () => props.form, |
| | | (newVal) => { |
| | | formData.value = { ...newVal }; |
| | | }, |
| | | { deep: true } |
| | | ); |
| | | |
| | | // çå¬å
é¨å¼¹çªç¶æåå |
| | | watch( |
| | | () => dialogVisible.value, |
| | | (newVal) => { |
| | | emit("update:coalQualityMaintenanceDialogFormVisible", newVal); |
| | | } |
| | | ); |
| | | // å¤çå°åéæ©åå |
| | | const handleChange = (value) => { |
| | | console.log(value); |
| | | }; |
| | | // æäº¤è¡¨å |
| | | const submitForm = async () => { |
| | | if (!formRef.value) return; |
| | | await formRef.value.validate(async (valid, fields) => { |
| | | if (valid) { |
| | | |
| | | let result = await addOrEditCoalQuality({...formData.value}); |
| | | console.log(result); |
| | | // let result = await addOrEditCoalQuality({...formData.value}); |
| | | // console.log(result); |
| | | // emit("submit", formData.value); |
| | | } |
| | | }); |
| | |
| | | <el-input v-model="form.supplierName" placeholder="请è¾å
¥" /> |
| | | </el-form-item> |
| | | <el-form-item label="ç
¤ç§" prop="coal"> |
| | | <el-input v-model="form.coal" placeholder="请è¾å
¥" /> |
| | | </el-form-item> |
| | | <el-select v-model="form.coal" placeholder="è¯·éæ©ç
¤ç§" clearable style="width: 100%"> |
| | | <el-option label="ç¦ç
¤" value="ç¦ç
¤" /> |
| | | <el-option label="æ°ç
¤" value="æ°ç
¤" /> |
| | | <el-option label="æ çç
¤" value="æ çç
¤" /> |
| | | <el-option label="é¿ç°ç
¤" value="é¿ç°ç
¤" /> |
| | | <el-option label="è´«ç
¤" value="è´«ç
¤" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="åä½" prop="unit"> |
| | | <el-input v-model="form.unit" placeholder="请è¾å
¥" /> |
| | | <el-select v-model="form.unit" placeholder="è¯·éæ©åä½" clearable style="width: 100%"> |
| | | <el-option label="å¨" value="å¨" /> |
| | | <el-option label="åå
" value="åå
" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="éè´æ°é" prop="purchaseQuantity"> |
| | | <el-input v-model="form.purchaseQuantity" placeholder="请è¾å
¥" /> |
| | | <el-input v-model.number="form.purchaseQuantity" placeholder="请è¾å
¥" > |
| | | <template v-slot:suffix> |
| | | <i style="font-style:normal;">{{form.unit?form.unit:''}}</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="åä»·(ä¸å«ç¨)" prop="priceExcludingTax"> |
| | | <el-input v-model="form.priceExcludingTax" placeholder="请è¾å
¥" > |
| | | <el-input v-model.number="form.priceExcludingTax" placeholder="请è¾å
¥" > |
| | | <template v-slot:suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="æ»ä»·(ä¸å«ç¨)" prop="totalPriceExcludingTax"> |
| | | <el-input v-model="form.totalPriceExcludingTax" placeholder="请è¾å
¥" > |
| | | <el-input v-model.number="form.totalPriceExcludingTax" placeholder="请è¾å
¥" > |
| | | <template v-slot:suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="åä»·(å«ç¨)" prop="priceIncludingTax"> |
| | | <el-input v-model="form.priceIncludingTax" placeholder="请è¾å
¥" > |
| | | <el-input v-model.number="form.priceIncludingTax" placeholder="请è¾å
¥" > |
| | | <template v-slot:suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="æ»ä»·(å«ç¨)" prop="totalPriceIncludingTax"> |
| | | <el-input v-model="form.totalPriceIncludingTax" placeholder="请è¾å
¥" > |
| | | <el-input v-model.number="form.totalPriceIncludingTax" placeholder="请è¾å
¥" > |
| | | <template v-slot:suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç¨ç" prop="taxRate"> |
| | | <el-input v-model="form.taxRate" placeholder="请è¾å
¥" /> |
| | | <el-input v-model="form.taxRate" placeholder="请è¾å
¥ç¨ç" > |
| | | <template v-slot:suffix> |
| | | <i style="font-style:normal;">%</i> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç»è®°äºº" prop="registrantId"> |
| | | <el-input v-model="form.registrantId" disabled placeholder="请è¾å
¥" /> |
| | |
| | | unit: [{ required: true, message: "请è¾å
¥åä½", trigger: "blur" }], |
| | | purchaseQuantity: [ |
| | | { required: true, message: "请è¾å
¥éè´æ°é", trigger: "blur" }, |
| | | { type: "number", message: "éè´æ°éå¿
须为æ°å", trigger: "blur" }, |
| | | ], |
| | | priceExcludingTax: [{ required: true, message: "请è¾å
¥åä»·", trigger: "blur" }], |
| | | totalPriceExcludingTax: [{ required: true, message: "请è¾å
¥æ»ä»·", trigger: "blur" }], |
| | |
| | | if (formRef.value) { |
| | | formRef.value.clearValidate(); |
| | | } |
| | | console.log(form.value); |
| | | }; |
| | | const formRef = ref(null); |
| | | // æäº¤è¡¨å |
| | |
| | | if (!formRef.value) return; |
| | | await formRef.value.validate(async (valid) => { |
| | | if (valid) { |
| | | console.log("表åéªè¯éè¿", form.value); |
| | | const obj = ref({}); |
| | | if (props.title.includes('æ°å¢')) { |
| | | let result = await addOrEditPR({ |
| | |
| | | <el-row :gutter="24" class="table-toolbar"> |
| | | <el-button type="primary" :icon="Plus" @click="handleAdd">æ°å»º</el-button> |
| | | <el-button type="danger" :icon="Delete" @click="handleDelete">å é¤</el-button> |
| | | <el-button type="info" :icon="Download" @click="handleExport">导åº</el-button> |
| | | <!-- <el-button type="info" :icon="Download" @click="handleExport">导åº</el-button> --> |
| | | </el-row> |
| | | <!-- è¡¨æ ¼ç»ä»¶ --> |
| | | <data-table :loading="loading" :table-data="tableData" :columns="columns" @selection-change="handleSelectionChange" |
| | |
| | | getList(); |
| | | }; |
| | | const userStore = useUserStore(); |
| | | // è·åç¨æ·ä¿¡æ¯ |
| | | const userInfo = ref({}); |
| | | onMounted(async() => { |
| | | let res = await userStore.getInfo() |
| | | form.value.registrantId = res.user.userName; // 设置ç»è®°äººID |
| | | userInfo.value = res.user; |
| | | }); |
| | | // å页å¤ç |
| | | const handlePagination = (val) => { |
| | |
| | | priceIncludingTax: "", |
| | | totalPriceIncludingTax: "", |
| | | taxRate: "", |
| | | registrantId: "", |
| | | registrantId: userInfo.value.userName, |
| | | registrationDate: new Date().toISOString().split('T')[0] |
| | | }; |
| | | // æ°å»ºæ¶ä¹éè¦è®¾ç½® copyForm ç¨äºéç½®åè½ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-table :data="tableData" :border="border" style="width: 100%"> |
| | | <el-table-column label="ç
¤ç§" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.coalType" |
| | | placeholder="请è¾å
¥ç
¤ç§" |
| | | @input="handleInput('coalType', $index, $event)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="çå¼" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.calorificValue" |
| | | placeholder="请è¾å
¥çå¼" |
| | | @input="handleInput('calorificValue', $index, $event)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="ç产æ°é" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.productionQuantity" |
| | | placeholder="请è¾å
¥ç产æ°é" |
| | | type="number" |
| | | @input="handleInput('productionQuantity', $index, $event)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="äººå·¥ææ¬" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.laborCost" |
| | | placeholder="请è¾å
¥äººå·¥ææ¬" |
| | | type="number" |
| | | @input="handleInput('laborCost', $index, $event)" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="è½èææ¬" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.energyCost" |
| | | placeholder="请è¾å
¥è½èææ¬" |
| | | type="number" |
| | | @input="handleInput('energyCost', $index, $event)" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="è®¾å¤ææ§" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.equipmentDepreciation" |
| | | placeholder="请è¾å
¥è®¾å¤ææ§" |
| | | type="number" |
| | | @input="handleInput('equipmentDepreciation', $index, $event)" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="éè´åä»·" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.purchasePrice" |
| | | placeholder="请è¾å
¥éè´åä»·" |
| | | type="number" |
| | | @input="handleInput('purchasePrice', $index, $event)" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="æ»ææ¬" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-input |
| | | v-model="row.totalCost" |
| | | placeholder="æ»ææ¬" |
| | | type="number" |
| | | :readonly="autoCalculate" |
| | | @input="handleInput('totalCost', $index, $event)" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style:normal;">å
</i> |
| | | </template> |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="showOperations" label="æä½" width="120" fixed="right"> |
| | | <template #default="{ $index }"> |
| | | <el-button |
| | | type="danger" |
| | | size="small" |
| | | @click="handleDelete($index)" |
| | | :icon="Delete" |
| | | > |
| | | å é¤ |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </template> |
| | | |
| | | <script setup name="ProductionDetailsTable"> |
| | | import { ref, computed, watch } from 'vue' |
| | | import { Delete } from '@element-plus/icons-vue' |
| | | |
| | | const props = defineProps({ |
| | | modelValue: { |
| | | type: Array, |
| | | default: () => [] |
| | | }, |
| | | border: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | showOperations: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | autoCalculate: { |
| | | type: Boolean, |
| | | default: true |
| | | } |
| | | }) |
| | | |
| | | const emit = defineEmits(['update:modelValue', 'input-change', 'delete-row']) |
| | | |
| | | // ä½¿ç¨ v-model è¿è¡ååç»å® |
| | | const tableData = computed({ |
| | | get() { |
| | | return props.modelValue |
| | | }, |
| | | set(value) { |
| | | emit('update:modelValue', value) |
| | | } |
| | | }) |
| | | |
| | | // å¤çè¾å
¥åå |
| | | const handleInput = (field, index, value) => { |
| | | const newData = [...tableData.value] |
| | | newData[index][field] = value |
| | | |
| | | // 妿å¼å¯èªå¨è®¡ç®æ»ææ¬ |
| | | if (props.autoCalculate && ['laborCost', 'energyCost', 'equipmentDepreciation', 'purchasePrice'].includes(field)) { |
| | | calculateTotalCost(newData[index]) |
| | | } |
| | | |
| | | tableData.value = newData |
| | | emit('input-change', { field, index, value, row: newData[index] }) |
| | | } |
| | | |
| | | // è®¡ç®æ»ææ¬ |
| | | const calculateTotalCost = (row) => { |
| | | const laborCost = parseFloat(row.laborCost) || 0 |
| | | const energyCost = parseFloat(row.energyCost) || 0 |
| | | const equipmentDepreciation = parseFloat(row.equipmentDepreciation) || 0 |
| | | const purchasePrice = parseFloat(row.purchasePrice) || 0 |
| | | |
| | | row.totalCost = (laborCost + energyCost + equipmentDepreciation + purchasePrice).toFixed(2) |
| | | } |
| | | |
| | | // å é¤è¡ |
| | | const handleDelete = (index) => { |
| | | const newData = [...tableData.value] |
| | | newData.splice(index, 1) |
| | | tableData.value = newData |
| | | emit('delete-row', index) |
| | | } |
| | | |
| | | // æ´é²æ¹æ³ç»ç¶ç»ä»¶ä½¿ç¨ |
| | | defineExpose({ |
| | | calculateTotalCost, |
| | | addRow: (rowData = {}) => { |
| | | const defaultRow = { |
| | | coalType: '', |
| | | calorificValue: '', |
| | | productionQuantity: '', |
| | | laborCost: '', |
| | | energyCost: '', |
| | | equipmentDepreciation: '', |
| | | purchasePrice: '', |
| | | totalCost: '', |
| | | ...rowData |
| | | } |
| | | tableData.value = [...tableData.value, defaultRow] |
| | | }, |
| | | clearData: () => { |
| | | tableData.value = [] |
| | | } |
| | | }) |
| | | </script> |
| | | |
| | | <style scoped> |
| | | :deep(.el-input__inner) { |
| | | text-align: center; |
| | | } |
| | | |
| | | :deep(.el-table .el-table__cell) { |
| | | padding: 8px 0; |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- 使ç¨ç¤ºä¾ --> |
| | | <template> |
| | | <div> |
| | | <!-- åºæ¬ä½¿ç¨ --> |
| | | <ProductionDetailsTable v-model="tableData" /> |
| | | |
| | | <!-- èªå®ä¹é
ç½® --> |
| | | <ProductionDetailsTable |
| | | v-model="tableData" |
| | | :border="true" |
| | | :show-operations="false" |
| | | :auto-calculate="false" |
| | | @input-change="handleChange" |
| | | @delete-row="handleDelete" |
| | | /> |
| | | |
| | | <!-- æä½æé® --> |
| | | <el-row :gutter="10" style="margin-top: 20px;"> |
| | | <el-col :span="4"> |
| | | <el-button type="primary" @click="addRow">æ°å¢è¡</el-button> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-button type="danger" @click="clearData">æ¸
ç©ºæ°æ®</el-button> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-button type="success" @click="submitData">æäº¤æ°æ®</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref } from 'vue' |
| | | import ProductionDetailsTable from './ProductionDetailsTable.vue' |
| | | |
| | | // è¡¨æ ¼æ°æ® |
| | | const tableData = ref([ |
| | | { |
| | | coalType: 'å¨åç
¤', |
| | | calorificValue: '5000', |
| | | productionQuantity: '100', |
| | | laborCost: '1000', |
| | | energyCost: '800', |
| | | equipmentDepreciation: '500', |
| | | purchasePrice: '2000', |
| | | totalCost: '4300' |
| | | } |
| | | ]) |
| | | |
| | | // è·åç»ä»¶å®ä¾å¼ç¨ |
| | | const tableRef = ref(null) |
| | | |
| | | // äºä»¶å¤ç |
| | | const handleChange = (data) => { |
| | | console.log('æ°æ®åå:', data) |
| | | } |
| | | |
| | | const handleDelete = (index) => { |
| | | console.log('å é¤è¡:', index) |
| | | } |
| | | |
| | | // æä½æ¹æ³ |
| | | const addRow = () => { |
| | | if (tableRef.value) { |
| | | tableRef.value.addRow({ |
| | | coalType: 'æ°ç
¤ç§', |
| | | calorificValue: '0', |
| | | productionQuantity: '0', |
| | | laborCost: '0', |
| | | energyCost: '0', |
| | | equipmentDepreciation: '0', |
| | | purchasePrice: '0', |
| | | totalCost: '0' |
| | | }) |
| | | } |
| | | } |
| | | |
| | | const clearData = () => { |
| | | if (tableRef.value) { |
| | | tableRef.value.clearData() |
| | | } |
| | | } |
| | | |
| | | const submitData = () => { |
| | | console.log('æäº¤çæ°æ®:', tableData.value) |
| | | // è¿éå¯ä»¥è°ç¨APIæäº¤æ°æ® |
| | | } |
| | | </script> |
| | |
| | | <template> |
| | | <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%" @change="selectChange"> |
| | | <el-option label="ç¼ç¦" value="ç¼ç¦" /> |
| | | <el-option label="æ°ç
¤" value="æ°ç
¤" /> |
| | | <el-option label="æ çç
¤" value="æ çç
¤" /> |
| | | <el-option label="é¿ç°ç
¤" value="é¿ç°ç
¤" /> |
| | | <el-option label="è´«ç
¤" value="è´«ç
¤" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="çå¼" prop="Calorific"> |
| | | <el-input v-model="formData.Calorific" placeholder="请è¾å
¥çå¼" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <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-dialog |
| | | v-model="dialogVisible" |
| | | :title="dialogType === 'add' ? 'æ°å¢ç产å å·¥' : 'ç¼è¾ç产å å·¥'" |
| | | width="1200px" |
| | | :close-on-click-modal="false" |
| | | @close="handleClose" |
| | | > |
| | | <el-button type="primary" @click="handlData">éæ©æ°æ®</el-button> |
| | | <ETable |
| | | v-if="tableData.length > 0" |
| | | :columns="columns" |
| | | height="200" |
| | | @cell-edit="handleCellEdit" |
| | | :showOperations="false" |
| | | :tableData="tableData" |
| | | @row-click="handleRowClick" |
| | | :editableColumns="['used']" |
| | | /> |
| | | <div v-if="tableData.length > 0" class="empty-table"> |
| | | <h1>ç产æç»</h1> |
| | | <el-row :gutter="10"> |
| | | <el-col :span="2"> |
| | | <el-button type="primary" @click="addNewRow"> |
| | | <el-icon> |
| | | <Plus /> |
| | | </el-icon> |
| | | æ°å¢ |
| | | </el-button> |
| | | </el-col> |
| | | <el-col :span="2"> |
| | | <el-button type="danger" @click="clearAllRows"> |
| | | <el-icon> |
| | | <Delete /> |
| | | </el-icon> |
| | | æ¸
空 |
| | | </el-button> |
| | | </el-col> |
| | | <!-- <el-col :span="2"> |
| | | <el-button type="warning" @click="calculateAllCosts"> |
| | | <el-icon> |
| | | <Warning /> |
| | | </el-icon> éæ°è®¡ç® |
| | | </el-button> |
| | | </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> |
| | | <ProductionDetailsTable |
| | | v-model="detailsTableData" |
| | | :border="false" |
| | | :show-operations="true" |
| | | :auto-calculate="true" |
| | | @input-change="handleDetailsChange" |
| | | @delete-row="handleDeleteRow" |
| | | /> |
| | | </div> |
| | | <div style="margin-top: 20px;" v-else>ææ æ°æ®ï¼è¯·éæ©é
ç½®æ°æ®</div> |
| | | |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="handleClose">å æ¶</el-button> |
| | | <el-button type="primary" :loading="loading" @click="handleSubmit">ç¡® å®</el-button> |
| | | <el-button type="primary" :loading="loading" @click="handleSubmit" |
| | | >ç¡® å®</el-button |
| | | > |
| | | </div> |
| | | |
| | | </template> |
| | | </el-dialog> |
| | | <el-dialog |
| | | v-model="innerVisible" |
| | | width="1000" |
| | | title="éæ©é
ç½®æ°æ®" |
| | | append-to-body |
| | | > |
| | | <ETable |
| | | @selection-change="handleSelectionChange" |
| | | :showOperations="false" |
| | | :columns="formalDatabaseDataColumns" |
| | | :tableData="formalDatabaseData" |
| | | height="400" |
| | | @cell-edit="handleCellEdit" |
| | | :show-selection="true" |
| | | /> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="2" :offset="22"> |
| | | <el-button type="primary" @click="handleSelectData">ç¡®å®</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </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' |
| | | import { ref, reactive, watch } from "vue"; |
| | | import ETable from "@/components/Table/EtableModify.vue"; |
| | | import ProductionDetailsTable from "./ProductionDetailsTable.vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { Delete, Warning, Plus } from "@element-plus/icons-vue"; |
| | | |
| | | const props = defineProps({ |
| | | visible: { |
| | | type: Boolean, |
| | | default: false |
| | | default: false, |
| | | }, |
| | | type: { |
| | | type: String, |
| | | default: 'add' // 'add' æ 'edit' |
| | | default: "add", // 'add' æ 'edit' |
| | | }, |
| | | rowData: { |
| | | type: Object, |
| | | default: () => ({}) |
| | | } |
| | | }) |
| | | const dialogVisible = defineModel('visible', { |
| | | default: () => ({}), |
| | | }, |
| | | }); |
| | | const dialogVisible = defineModel("visible", { |
| | | type: Boolean, |
| | | default: false |
| | | }) |
| | | const emit = defineEmits(['update:visible', 'success']) |
| | | default: false, |
| | | }); |
| | | const emit = defineEmits(["update:visible", "success"]); |
| | | |
| | | const dialogType = ref('add') |
| | | const loading = ref(false) |
| | | const formRef = ref(null) |
| | | |
| | | const tableData = ref([]) |
| | | const currentRow = ref(null) |
| | | const innerVisible = 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' }, |
| | | ] |
| | | { label: "ç
¤ç§", prop: "category" }, |
| | | { label: "çå¼", prop: "Calorific" }, |
| | | { label: "åºåæ°é", prop: "stock" }, |
| | | { label: "æ¬æ¬¡ä½¿ç¨æ°é", prop: "used" }, |
| | | ]; |
| | | const detailsTableData = ref([ |
| | | { |
| | | coalType: "", |
| | | calorificValue: "", |
| | | productionQuantity: "", |
| | | laborCost: "", |
| | | energyCost: "", |
| | | equipmentDepreciation: "", |
| | | purchasePrice: "", |
| | | totalCost: "", |
| | | }, |
| | | ]); |
| | | const handleRowClick = (row) => { |
| | | currentRow.value = row |
| | | console.log('å½åè¡æ°æ®:', currentRow.value) |
| | | } |
| | | currentRow.value = row; |
| | | }; |
| | | const formalDatabaseDataColumns = ref([ |
| | | { prop: "name", label: "ä¾åºååç§°", width: 150 }, |
| | | { prop: "type", label: "ç
¤ç§ç±»å", width: 120 }, |
| | | { prop: "unit", label: "åä½", width: 100 }, |
| | | { prop: "number", label: "éè´æ°é", width: 100 }, |
| | | { prop: "money", label: "åä»·ï¼å«ç¨ï¼", width: 120 }, |
| | | { prop: "money1", label: "æ»ä»·ï¼å«ç¨ï¼", width: 120 }, |
| | | { prop: "money2", label: "ç¨ç", width: 80 }, |
| | | { prop: "money3", label: "ä¸å«ç¨åä»·", width: 120 }, |
| | | { prop: "createUser", label: "ç»è®°äºº", width: 100 }, |
| | | { prop: "createTime", label: "ç»è®°æ¥æ", width: 150 }, |
| | | ]); |
| | | // è¡¨åæ°æ® |
| | | const formData = reactive({ |
| | | category: '', |
| | | unit: '', |
| | | category: "", |
| | | unit: "", |
| | | productionVolume: 0, |
| | | laborCost: 0, |
| | | materialCost: 0, |
| | |
| | | totalCost: 0, |
| | | totalPrice: 0, |
| | | profit: 0, |
| | | reviewer: '', |
| | | date: '' |
| | | }) |
| | | reviewer: "", |
| | | date: "", |
| | | }); |
| | | const handlData = () => { |
| | | innerVisible.value = true; |
| | | }; |
| | | const formalDatabaseData = ref([]); |
| | | const formalDatabaseSelectedData = ref([]); |
| | | formalDatabaseData.value = [ |
| | | { |
| | | id: 1, |
| | | name: "ä¾åºåA", |
| | | type: "å¨åç
¤", |
| | | unit: "å¨", |
| | | number: 120, |
| | | money: 500, |
| | | money1: 200, |
| | | money2: 200, |
| | | money3: 300, |
| | | money4: "é«ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 2, |
| | | name: "ä¾åºåA", |
| | | type: "å¨åç
¤", |
| | | unit: "å¨", |
| | | number: 100, |
| | | money: 600, |
| | | money1: 300, |
| | | money2: 300, |
| | | money3: 300, |
| | | money4: "ä½ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 3, |
| | | name: "ä¾åºåB", |
| | | type: "ç¦ç
¤", |
| | | unit: "å¨", |
| | | number: 300, |
| | | money: 789, |
| | | money1: 400, |
| | | money2: 400, |
| | | money3: 400, |
| | | money4: "é«ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 4, |
| | | name: "ä¾åºåB", |
| | | type: "ç¦ç
¤", |
| | | unit: "å¨", |
| | | number: 256, |
| | | money: 800, |
| | | money1: 420, |
| | | money2: 420, |
| | | money3: 420, |
| | | money4: "ä½ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 5, |
| | | name: "ä¾åºåC", |
| | | type: "æ çç
¤", |
| | | unit: "å¨", |
| | | number: 256, |
| | | money: 700, |
| | | money1: 300, |
| | | money2: 300, |
| | | money3: 300, |
| | | money4: "é«ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 6, |
| | | name: "ä¾åºåA", |
| | | type: "å¨åç
¤", |
| | | unit: "å¨", |
| | | number: 120, |
| | | money: 500, |
| | | money1: 200, |
| | | money2: 200, |
| | | money3: 300, |
| | | money4: "é«ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 7, |
| | | name: "ä¾åºåA", |
| | | type: "å¨åç
¤", |
| | | unit: "å¨", |
| | | number: 100, |
| | | money: 600, |
| | | money1: 300, |
| | | money2: 300, |
| | | money3: 300, |
| | | money4: "ä½ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 8, |
| | | name: "ä¾åºåB", |
| | | type: "ç¦ç
¤", |
| | | unit: "å¨", |
| | | number: 300, |
| | | money: 789, |
| | | money1: 400, |
| | | money2: 400, |
| | | money3: 400, |
| | | money4: "é«ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 9, |
| | | name: "ä¾åºåB", |
| | | type: "ç¦ç
¤", |
| | | unit: "å¨", |
| | | number: 256, |
| | | money: 800, |
| | | money1: 420, |
| | | money2: 420, |
| | | money3: 420, |
| | | money4: "ä½ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | { |
| | | id: 10, |
| | | name: "ä¾åºåC", |
| | | type: "æ çç
¤", |
| | | unit: "å¨", |
| | | number: 256, |
| | | money: 700, |
| | | money1: 300, |
| | | money2: 300, |
| | | money3: 300, |
| | | money4: "é«ä½", |
| | | createUser: "admin", |
| | | createTime: "2025-06-01", |
| | | }, |
| | | ]; |
| | | |
| | | // 表åéªè¯è§å |
| | | const rules = { |
| | | category: [{ required: true, message: 'è¯·éæ©ç
¤ç§', trigger: 'change' }], |
| | | } |
| | | category: [{ required: true, message: "è¯·éæ©ç
¤ç§", trigger: "change" }], |
| | | }; |
| | | |
| | | const search = () => { |
| | | // æ¥è¯¢é»è¾ |
| | | if (!formData.category) { |
| | | return this.$message.error('è¯·éæ©ç
¤ç§') |
| | | // åå§å |
| | | const Initialization = () => { |
| | | console.log("åå§åæ°æ®"); |
| | | tableData.value = []; |
| | | }; |
| | | defineExpose({ |
| | | Initialization |
| | | }); |
| | | const handleSelectData = (row) => { |
| | | if (!innerVisible.value) return; |
| | | // è·åéä¸çæ°æ® |
| | | const selectedData = formalDatabaseSelectedData.value; |
| | | if (selectedData.length === 0) { |
| | | ElMessage.warning("请è³å°éæ©ä¸æ¡æ°æ®"); |
| | | return; |
| | | } |
| | | 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) |
| | | } |
| | | |
| | | // å°éä¸çæ°æ®æ ¹æ®éè¦çéå°è¡¨æ ¼ä¸ |
| | | selectedData.forEach((item) => { |
| | | const existingItem = tableData.value.find( |
| | | (row) => row.id === item.id |
| | | ); |
| | | if (!existingItem) { |
| | | tableData.value.push({ |
| | | id: item.id, |
| | | category: item.type, |
| | | Calorific: item.money4, |
| | | stock: item.number, |
| | | used: 0, // åå§ä½¿ç¨æ°é为0 |
| | | }); |
| | | } |
| | | }); |
| | | innerVisible.value = false; |
| | | }; |
| | | const handleSelectionChange = (selection) => { |
| | | formalDatabaseSelectedData.value = selection; |
| | | }; |
| | | const reset = () => { |
| | | // formRef |
| | | formRef.value?.resetFields() |
| | | } |
| | | formRef.value?.resetFields(); |
| | | }; |
| | | |
| | | const selectChange = (value) => { |
| | | } |
| | | const selectChange = (value) => {}; |
| | | |
| | | // æäº¤è¡¨å |
| | | const handleSubmit = async () => { |
| | | if (!formRef.value) return |
| | | |
| | | await formRef.value.validate((valid) => { |
| | | if (valid) { |
| | | loading.value = true |
| | | // 触åæåäºä»¶ï¼ä¼ éè¡¨åæ°æ® |
| | | emit('success', { ...formData }) |
| | | loading.value = false |
| | | handleClose() |
| | | } |
| | | }) |
| | | } |
| | | console.log(detailsTableData.value); |
| | | // dialogVisible.value = false; |
| | | }; |
| | | |
| | | // å
³éå¼¹çª |
| | | const handleClose = () => { |
| | | dialogVisible.value = false |
| | | formRef.value?.resetFields() |
| | | dialogVisible.value = false; |
| | | formRef.value?.resetFields(); |
| | | Object.assign(formData, { |
| | | category: '', |
| | | unit: '', |
| | | category: "", |
| | | unit: "", |
| | | productionVolume: 0, |
| | | laborCost: 0, |
| | | materialCost: 0, |
| | |
| | | totalCost: 0, |
| | | totalPrice: 0, |
| | | profit: 0, |
| | | reviewer: '', |
| | | date: '' |
| | | }) |
| | | } |
| | | reviewer: "", |
| | | 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 |
| | | if (prop === "used" && Number(value) > Number(row.stock)) { |
| | | ElMessage.warning("ä½¿ç¨æ°éä¸è½å¤§äºåºåæ°éï¼"); |
| | | row.used = row.stock; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // å¤çç产æç»è¡¨æ ¼çæä½ |
| | | const addNewRow = () => { |
| | | detailsTableData.value.push({ |
| | | coalType: "", |
| | | calorificValue: "", |
| | | productionQuantity: "", |
| | | laborCost: "", |
| | | energyCost: "", |
| | | equipmentDepreciation: "", |
| | | purchasePrice: "", |
| | | totalCost: "", |
| | | }); |
| | | }; |
| | | |
| | | const clearAllRows = () => { |
| | | detailsTableData.value = []; |
| | | ElMessage.success("å·²æ¸
ç©ºæææ°æ®"); |
| | | }; |
| | | |
| | | const calculateAllCosts = () => { |
| | | detailsTableData.value.forEach((row) => { |
| | | const laborCost = parseFloat(row.laborCost) || 0; |
| | | const energyCost = parseFloat(row.energyCost) || 0; |
| | | const equipmentDepreciation = parseFloat(row.equipmentDepreciation) || 0; |
| | | const purchasePrice = parseFloat(row.purchasePrice) || 0; |
| | | |
| | | row.totalCost = ( |
| | | laborCost + |
| | | energyCost + |
| | | equipmentDepreciation + |
| | | purchasePrice |
| | | ).toFixed(2); |
| | | }); |
| | | ElMessage.success("éæ°è®¡ç®å®æ"); |
| | | }; |
| | | |
| | | const handleDetailsChange = (data) => { |
| | | console.log("ç产æç»æ°æ®åå:", data); |
| | | }; |
| | | |
| | | const handleDeleteRow = (index) => { |
| | | ElMessage.success(`å·²å é¤ç¬¬ ${index + 1} è¡æ°æ®`); |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .el-form{ |
| | | <style scoped lang="scss"> |
| | | .el-form { |
| | | .el-row { |
| | | padding-top: 20px; |
| | | background: rgba($color: #F8FAFB, $alpha: 0.5) ; |
| | | background: rgba($color: #f8fafb, $alpha: 0.5); |
| | | } |
| | | } |
| | | .el-row>.el-col>h1{ |
| | | |
| | | .el-row > .el-col > h1 { |
| | | font-weight: bolder; |
| | | } |
| | | </style> |
| | | </style> |
| | |
| | | <template> |
| | | <div class="production-container"> |
| | | <div class="search-bar"> |
| | | <el-input v-model="searchForm.keyword" placeholder="请è¾å
¥å
³é®è¯" clearable /> |
| | | <el-input v-model="searchForm.addUser" placeholder="请è¾å
¥äºº" clearable /> |
| | | <el-button type="primary" @click="handleSearch">æ¥è¯¢</el-button> |
| | | <el-button @click="handleReset">éç½®</el-button> |
| | | </div> |
| | | |
| | | <div class="operation-bar"> |
| | | <!-- <el-button type="primary" @click="handleAdd">æ°å¢é
项</el-button> --> |
| | | <el-form :inline="true" :model="searchForm" class="search-form" style="width: 100%"> |
| | | <el-form-item label="æç´¢"> |
| | | <el-input v-model="searchForm.searchAll" placeholder="请è¾å
¥å
³é®è¯" clearable /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="handleSearch">æ¥è¯¢</el-button> |
| | | <el-button @click="handleReset">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-card> |
| | | <el-button type="success" :icon="Plus" @click="handleAddBatch">æ°å¢å å·¥</el-button> |
| | | <el-button type="danger" :icon="Delete">å é¤</el-button> |
| | | <el-button type="info" :icon="Download">导åº</el-button> |
| | | </div> |
| | | |
| | | <el-table :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="sequence" label="åºå·" width="80" /> |
| | | <el-table-column prop="category" label="ç
¤ç§" width="120" /> |
| | | <el-table-column prop="unit" label="åä½" width="100" /> |
| | | <el-table-column prop="productionVolume" label="ç产æ°é" width="120" /> |
| | | <el-table-column prop="laborCost" label="äººå·¥ææ¬" width="120" /> |
| | | <el-table-column prop="materialCost" label="åæææ¬" width="120" /> |
| | | <el-table-column prop="equipmentCost" label="设å¤è´¹ç¨" width="120" /> |
| | | <el-table-column prop="totalCost" label="æ»ææ¬" width="120" /> |
| | | <el-table-column prop="totalPrice" label="æ»ææ¬" width="120" /> |
| | | <el-table-column prop="profit" label="婿¶¦" width="100" /> |
| | | <el-table-column prop="reviewer" label="å¤è®°äºº" width="120" /> |
| | | <el-table-column prop="date" label="æ¥æ" width="120" /> |
| | | <el-table-column label="æä½" fixed="right" width="220"> |
| | | <template #default="scope"> |
| | | <el-button type="primary" link @click="handleEdit(scope.row)">ç»è®°</el-button> |
| | | <el-button type="success" link @click="handleEdit(scope.row)">ç¼è¾</el-button> |
| | | <el-button type="danger" link @click="handleDelete(scope.row)">å é¤</el-button> |
| | | <el-button type="warning" link @click="handleExport(scope.row)">导åº</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <div class="pagination"> |
| | | <el-pagination |
| | | v-model:current-page="pagination.currentPage" |
| | | v-model:page-size="pagination.pageSize" |
| | | :page-sizes="[10, 20, 30, 50]" |
| | | :total="pagination.total" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | /> |
| | | </div> |
| | | |
| | | <!-- å¼¹çªç»ä»¶ --> |
| | | <ProductionDialog |
| | | v-model:visible="dialogVisible" |
| | | :type="dialogType" |
| | | :row-data="currentRow" |
| | | @success="handleDialogSuccess" |
| | | /> |
| | | <ETable :loading="loading" :table-data="tableData" :columns="columns" @selection-change="handleSelectionChange" |
| | | @edit="handleEdit" @view-detail="handleViewDetail" :show-selection="true" :border="true" :maxHeight="480" /> |
| | | <Pagination v-model:currentPage="pagination.currentPage" v-model:pageSize="pagination.pageSize" |
| | | :total="pagination.total" @current-change="handleCurrentChange" @size-change="handleSizeChange" /> |
| | | </el-card> |
| | | <ProductionDialog v-model:visible="dialogVisible" ref="childRef" :type="dialogType" |
| | | @success="handleDialogSuccess" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, onMounted } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { Plus, Delete, Download } from "@element-plus/icons-vue"; |
| | | import ProductionDialog from './components/ProductionDialog.vue' |
| | | import { ref, reactive, onMounted } from "vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import { Plus, Delete, Download, List } from "@element-plus/icons-vue"; |
| | | import ProductionDialog from "./components/ProductionDialog.vue"; |
| | | import ETable from "@/components/Table/ETable.vue"; |
| | | import Pagination from "@/components/Pagination/index.vue"; |
| | | const childRef = ref(null); |
| | | const columns = [ |
| | | { prop: "category", label: "ç
¤ç§", width: 150 }, |
| | | { prop: "unit", label: "åä½", width: 120 }, |
| | | { prop: "productionVolume", label: "ç产æ°é", width: 150 }, |
| | | { prop: "laborCost", label: "äººå·¥ææ¬", width: 150 }, |
| | | { prop: "materialCost", label: "åæææ¬", width: 120 }, |
| | | { prop: "equipmentCost", label: "设å¤è´¹ç¨", width: 143 }, |
| | | { prop: "totalCost", label: "æ»ææ¬", width: 150 }, |
| | | { prop: "totalPrice", label: "æ»å®ä»·", width: 150 }, |
| | | { prop: "profit", label: "婿¶¦", width: 100 }, |
| | | { prop: "reviewer", label: "å¤è®°äºº", width: 120 }, |
| | | { prop: "date", label: "æ¥æ", width: 150 }, |
| | | ]; |
| | | |
| | | // æç´¢è¡¨åæ°æ® |
| | | const searchForm = reactive({ |
| | | keyword: '', |
| | | addUser: '' |
| | | }) |
| | | searchAll:"" |
| | | }); |
| | | |
| | | // è¡¨æ ¼æ°æ® |
| | | const tableData = ref([]) |
| | | const loading = ref(false) |
| | | const tableData = ref([]); |
| | | const loading = ref(false); |
| | | |
| | | // åé¡µæ°æ® |
| | | const pagination = reactive({ |
| | | currentPage: 1, |
| | | pageSize: 10, |
| | | total: 0 |
| | | }) |
| | | total: 0, |
| | | }); |
| | | |
| | | // éä¸çè¡æ°æ® |
| | | const selectedRows = ref([]) |
| | | const selectedRows = ref([]); |
| | | |
| | | // å¼¹çªç¸å
³ |
| | | const dialogVisible = ref(false) |
| | | const dialogType = ref('add') |
| | | const currentRow = ref(null) |
| | | const dialogVisible = ref(false); |
| | | const dialogType = ref("add"); |
| | | const currentRow = ref(null); |
| | | |
| | | // ç产æç»å¯¹è¯æ¡æ§å¶ |
| | | const detailDialogVisible = ref(false); |
| | | const currentDetailRow = ref(null); |
| | | |
| | | // è·åè¡¨æ ¼æ°æ® |
| | | const getList = async () => { |
| | | loading.value = true |
| | | loading.value = true; |
| | | try { |
| | | const params = { |
| | | ...searchForm, |
| | | pageNum: pagination.currentPage, |
| | | pageSize: pagination.pageSize |
| | | } |
| | | pageSize: pagination.pageSize, |
| | | }; |
| | | // const res = await getProductionList(params) |
| | | // åæ°æ® |
| | | const res = { |
| | | data: { |
| | | list: [{ |
| | | sequence: 1, |
| | | category: 'ç
¤ç§', |
| | | unit: 'åä½', |
| | | productionVolume: 'ç产æ°é', |
| | | laborCost: 'äººå·¥ææ¬', |
| | | materialCost: 'åæææ¬', |
| | | equipmentCost: '设å¤è´¹ç¨', |
| | | totalCost: 'æ»ææ¬', |
| | | totalPrice: 'æ»ææ¬', |
| | | profit: '婿¶¦', |
| | | reviewer: 'å¤è®°äºº', |
| | | date: 'æ¥æ' |
| | | }], |
| | | total: 0 |
| | | } |
| | | } |
| | | |
| | | list: [ |
| | | { |
| | | sequence: 1, |
| | | category: "æ çç
¤", |
| | | unit: "å¨", |
| | | productionVolume: 100, |
| | | laborCost: "300", |
| | | materialCost: "200", |
| | | equipmentCost: "100", |
| | | totalCost: "600", |
| | | totalPrice: "800", |
| | | profit: "200", |
| | | reviewer: "å¼ ä¸", |
| | | date: "2023-10-01", |
| | | }, |
| | | { |
| | | sequence: 12, |
| | | category: "æ çç
¤", |
| | | unit: "å¨", |
| | | productionVolume: 100, |
| | | laborCost: "3100", |
| | | materialCost: "2020", |
| | | equipmentCost: "1300", |
| | | totalCost: "6030", |
| | | totalPrice: "8300", |
| | | profit: "2300", |
| | | reviewer: "å¼ ä¸", |
| | | date: "2025-10-02", |
| | | }, |
| | | ], |
| | | total: 2, |
| | | }, |
| | | }; |
| | | |
| | | tableData.value = res.data.list |
| | | pagination.total = res.data.total |
| | | tableData.value = res.data.list; |
| | | pagination.total = res.data.total; |
| | | } catch (error) { |
| | | ElMessage.error('è·åæ°æ®å¤±è´¥') |
| | | ElMessage.error("è·åæ°æ®å¤±è´¥"); |
| | | } finally { |
| | | loading.value = false |
| | | loading.value = false; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // å¤çè¡¨æ ¼éæ©åå |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection |
| | | } |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | // æç´¢æ¹æ³ |
| | | const handleSearch = () => { |
| | | pagination.currentPage = 1 |
| | | getList() |
| | | } |
| | | pagination.currentPage = 1; |
| | | getList(); |
| | | }; |
| | | |
| | | // éç½®æç´¢ |
| | | const handleReset = () => { |
| | | searchForm.keyword = '' |
| | | searchForm.addUser = '' |
| | | handleSearch() |
| | | } |
| | | |
| | | // æ°å¢é
项 |
| | | const handleAdd = () => { |
| | | dialogType.value = 'add' |
| | | dialogVisible.value = true |
| | | } |
| | | searchForm.keyword = ""; |
| | | searchForm.addUser = ""; |
| | | handleSearch(); |
| | | }; |
| | | |
| | | // æ°å¢å å·¥ |
| | | const handleAddBatch = () => { |
| | | dialogType.value = 'add' |
| | | dialogVisible.value = true |
| | | } |
| | | dialogType.value = "add"; |
| | | dialogVisible.value = true; |
| | | childRef.value.Initialization(); |
| | | }; |
| | | |
| | | // ç¼è¾ |
| | | const handleEdit = (row) => { |
| | | currentRow.value = row |
| | | dialogType.value = 'edit' |
| | | dialogVisible.value = true |
| | | } |
| | | currentRow.value = row; |
| | | dialogType.value = "edit"; |
| | | dialogVisible.value = true; |
| | | }; |
| | | |
| | | // æå¼ç产æç»å¯¹è¯æ¡ |
| | | const handleViewDetail = (row) => { |
| | | currentDetailRow.value = row; |
| | | detailDialogVisible.value = true; |
| | | }; |
| | | |
| | | // å¤çå¼¹çªæäº¤ |
| | | const handleDialogSuccess = async (formData) => { |
| | | try { |
| | | if (dialogType.value === 'add') { |
| | | await addProduction(formData) |
| | | ElMessage.success('æ°å¢æå') |
| | | if (dialogType.value === "add") { |
| | | await addProduction(formData); |
| | | ElMessage.success("æ°å¢æå"); |
| | | } else { |
| | | await updateProduction({ |
| | | ...formData, |
| | | id: currentRow.value.id |
| | | }) |
| | | ElMessage.success('æ´æ°æå') |
| | | id: currentRow.value.id, |
| | | }); |
| | | ElMessage.success("æ´æ°æå"); |
| | | } |
| | | getList() |
| | | getList(); |
| | | } catch (error) { |
| | | ElMessage.error(dialogType.value === 'add' ? 'æ°å¢å¤±è´¥' : 'æ´æ°å¤±è´¥') |
| | | ElMessage.error(dialogType.value === "add" ? "æ°å¢å¤±è´¥" : "æ´æ°å¤±è´¥"); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // å¤çç产æç»å¼¹çªæäº¤ |
| | | const handleDetailDialogSuccess = async (formData) => { |
| | | try { |
| | | ElMessage.success("ä¿åæå"); |
| | | getList(); |
| | | } catch (error) { |
| | | ElMessage.error("ä¿å失败"); |
| | | } |
| | | }; |
| | | |
| | | // å é¤ |
| | | const handleDelete = (row) => { |
| | | ElMessageBox.confirm('确认å é¤è¯¥è®°å½åï¼', 'æç¤º', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | }).then(async () => { |
| | | try { |
| | | await deleteProduction(row.id) |
| | | ElMessage.success('å 餿å') |
| | | getList() |
| | | } catch (error) { |
| | | console.error('å é¤å¤±è´¥:', error) |
| | | ElMessage.error('å é¤å¤±è´¥') |
| | | } |
| | | }).catch(() => { |
| | | ElMessage.info('已忶å é¤') |
| | | ElMessageBox.confirm("确认å é¤è¯¥è®°å½åï¼", "æç¤º", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }) |
| | | } |
| | | .then(async () => { |
| | | try { |
| | | await deleteProduction(row.id); |
| | | ElMessage.success("å 餿å"); |
| | | getList(); |
| | | } catch (error) { |
| | | console.error("å é¤å¤±è´¥:", error); |
| | | ElMessage.error("å é¤å¤±è´¥"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.info("已忶å é¤"); |
| | | }); |
| | | }; |
| | | |
| | | // å¯¼åº |
| | | const handleExport = async (row) => { |
| | | try { |
| | | const res = await exportProduction({ id: row.id }) |
| | | const blob = new Blob([res], { type: 'application/vnd.ms-excel' }) |
| | | const fileName = `ç产å 工记å½_${new Date().getTime()}.xlsx` |
| | | if ('download' in document.createElement('a')) { |
| | | const elink = document.createElement('a') |
| | | elink.download = fileName |
| | | elink.style.display = 'none' |
| | | elink.href = URL.createObjectURL(blob) |
| | | document.body.appendChild(elink) |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) |
| | | document.body.removeChild(elink) |
| | | const res = await exportProduction({ id: row.id }); |
| | | const blob = new Blob([res], { type: "application/vnd.ms-excel" }); |
| | | const fileName = `ç产å 工记å½_${new Date().getTime()}.xlsx`; |
| | | if ("download" in document.createElement("a")) { |
| | | const elink = document.createElement("a"); |
| | | elink.download = fileName; |
| | | elink.style.display = "none"; |
| | | elink.href = URL.createObjectURL(blob); |
| | | document.body.appendChild(elink); |
| | | elink.click(); |
| | | URL.revokeObjectURL(elink.href); |
| | | document.body.removeChild(elink); |
| | | } else { |
| | | navigator.msSaveBlob(blob, fileName) |
| | | navigator.msSaveBlob(blob, fileName); |
| | | } |
| | | } catch (error) { |
| | | ElMessage.error('导åºå¤±è´¥') |
| | | ElMessage.error("导åºå¤±è´¥"); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // å¤çæ¯é¡µæ¾ç¤ºæ°éåå |
| | | const handleSizeChange = (val) => { |
| | | pagination.pageSize = val |
| | | getList() |
| | | } |
| | | pagination.pageSize = val; |
| | | getList(); |
| | | }; |
| | | |
| | | // å¤ç页ç åå |
| | | const handleCurrentChange = (val) => { |
| | | pagination.currentPage = val |
| | | getList() |
| | | } |
| | | pagination.currentPage = val; |
| | | getList(); |
| | | }; |
| | | |
| | | // ç»ä»¶æè½½æ¶å è½½æ°æ® |
| | | onMounted(() => { |
| | | getList() |
| | | }) |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | <style scoped lang="scss"> |
| | | .production-container { |
| | | padding: 20px; |
| | | |
| | | .el-card:nth-child(1) { |
| | | margin-bottom: 20px; |
| | | } |
| | | } |
| | | |
| | | .search-bar { |
| | | margin-bottom: 20px; |
| | | display: flex; |
| | | gap: 10px; |
| | | } |
| | | |
| | | .operation-bar { |
| | | .el-input { |
| | | width: 20%; |
| | | } |
| | | } |
| | | .search-form{ |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | margin-bottom: 20px; |
| | | display: flex; |
| | | gap: 10px; |
| | | } |
| | | |
| | | .pagination { |
| | | margin-top: 20px; |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | .el-form-item { |
| | | margin-right: 10px; |
| | | } |
| | | |
| | | .el-button { |
| | | margin-left: 10px; |
| | | } |
| | | } |
| | | </style> |
| | | </style> |