From 237f95b05e0f122ee9ec7beaf82ba366a8b220ed Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期六, 15 二月 2025 14:50:59 +0800 Subject: [PATCH] 修改设备模块bug --- src/components/equipment/quantity-value-traceability-plan.vue | 774 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 533 insertions(+), 241 deletions(-) diff --git a/src/components/equipment/quantity-value-traceability-plan.vue b/src/components/equipment/quantity-value-traceability-plan.vue index 8e78d1c..845a295 100644 --- a/src/components/equipment/quantity-value-traceability-plan.vue +++ b/src/components/equipment/quantity-value-traceability-plan.vue @@ -2,130 +2,352 @@ <div> <div> <div style="margin: 10px 0;text-align: right"> - <el-button size="small" type="primary" @click="getYearTableDetailData">鍒锋柊</el-button> - <el-button size="small" type="primary" @click="handleForm('add')">鏂板</el-button> + <el-button size="small" type="primary" @click="getYearTableDetailData" + >鍒锋柊</el-button + > + <el-button size="small" type="primary" @click="handleForm('add')" + >鏂板</el-button + > </div> <div> - <el-table ref="yearTable" v-loading="yearTableDetailDataLoading" :data="yearTableDetailData" - height="calc(100vh - 18em)" - style="width: 100% ;"> + <el-table + ref="yearTable" + v-loading="yearTableDetailDataLoading" + :data="yearTableDetailData" + height="calc(100vh - 18em)" + style="width: 100% ;" + > <!-- 琛ㄦ牸鍒� --> - <el-table-column align="center" header-align="center" label="搴忓彿" prop="prop" type="index" width="70"></el-table-column> - <el-table-column label="骞翠唤" min-width="80" prop="planYear"></el-table-column> - <el-table-column label="鏂囦欢鍚嶇О" min-width="120" prop="compiler"></el-table-column> - <el-table-column label="缂栧埗浜�" min-width="150" prop="compiler"></el-table-column> - <el-table-column label="缂栧埗鏃堕棿" min-width="150" prop="datePreparation"></el-table-column> - <el-table-column label="鎵瑰噯浜�" min-width="180" prop="audit"></el-table-column> + <el-table-column + align="center" + header-align="center" + label="搴忓彿" + prop="prop" + type="index" + width="70" + ></el-table-column> + <el-table-column + label="骞翠唤" + min-width="80" + prop="planYear" + ></el-table-column> + <el-table-column + label="鏂囦欢鍚嶇О" + min-width="120" + prop="compiler" + ></el-table-column> + <el-table-column + label="缂栧埗浜�" + min-width="150" + prop="compiler" + ></el-table-column> + <el-table-column + label="缂栧埗鏃堕棿" + min-width="150" + prop="datePreparation" + ></el-table-column> + <el-table-column + label="鎵瑰噯浜�" + min-width="180" + prop="audit" + ></el-table-column> <el-table-column label="鎵瑰噯鐘舵��" min-width="180" prop="status"> <template slot-scope="scope"> - <el-tag v-if="scope.row.status === 1" type="success">鎵� 鍑�</el-tag> - <el-tag v-if="scope.row.status === 0" type="danger">涓嶆壒鍑�</el-tag> + <el-tag v-if="scope.row.status === 1" type="success" + >鎵� 鍑�</el-tag + > + <el-tag v-if="scope.row.status === 0" type="danger" + >涓嶆壒鍑�</el-tag + > </template> </el-table-column> - <el-table-column label="鎵瑰噯鏃堕棿" min-width="180" prop="auditDate"></el-table-column> + <el-table-column + label="鎵瑰噯鏃堕棿" + min-width="180" + prop="auditDate" + ></el-table-column> <!-- 鎿嶄綔鎸夐挳 --> - <el-table-column align="center" fixed="right" label="鎿嶄綔" min-width="180"> + <el-table-column + align="center" + fixed="right" + label="鎿嶄綔" + min-width="180" + > <template slot-scope="scope"> - <el-button :disabled="scope.row.status === 1" size="small" type="text" @click="handleForm('edit', scope.row)">缂栬緫</el-button> - <el-button :disabled="scope.row.status === 1" size="small" type="text" @click="handleForm('check', scope.row)">鎵瑰噯</el-button> - <el-button size="small" type="text" @click="handleDownOne(scope.row.traceabilityManagementId)">瀵煎嚭</el-button> - <el-button :disabled="scope.row.status === 1" size="small" style="color: #f56c6c" type="text" @click="deleteFun(scope.row.traceabilityManagementId)">鍒犻櫎</el-button> + <el-button + :disabled="scope.row.status === 1" + size="small" + type="text" + @click="handleForm('edit', scope.row)" + >缂栬緫</el-button + > + <el-button + :disabled="scope.row.status === 1" + size="small" + type="text" + @click="handleForm('check', scope.row)" + >鎵瑰噯</el-button + > + <el-button + size="small" + type="text" + @click="handleDownOne(scope.row.traceabilityManagementId)" + >瀵煎嚭</el-button + > + <el-button + :disabled="scope.row.status === 1" + size="small" + style="color: #f56c6c" + type="text" + @click="deleteFun(scope.row.traceabilityManagementId)" + >鍒犻櫎</el-button + > </template> </el-table-column> </el-table> - <el-pagination :current-page="1" :page-size="pagination1.size" :page-sizes="[10, 20, 30, 50, 100]" - :total="pagination1.total" layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange1" - @current-change="handleCurrentChange1"> + <el-pagination + :current-page="1" + :page-size="pagination1.size" + :page-sizes="[10, 20, 30, 50, 100]" + :total="pagination1.total" + layout="->,total, sizes, prev, pager, next, jumper" + @size-change="handleSizeChange1" + @current-change="handleCurrentChange1" + > </el-pagination> </div> </div> - <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" - :visible.sync="applicationForm" title="浠櫒璁惧閲忓�兼函婧愮鐞嗘�讳綋璁″垝" - width="80%" @close="closeDialog"> + <el-dialog + :close-on-click-modal="false" + :close-on-press-escape="false" + :visible.sync="applicationForm" + title="浠櫒璁惧閲忓�兼函婧愮鐞嗘�讳綋璁″垝" + width="80%" + @close="closeDialog" + > <div style="display: flex;align-items: center;"> - <el-button v-if="operationType !== 'check'" size="small" type="primary" @click="addTableRow">娣诲姞</el-button> + <el-button + v-if="operationType !== 'check'" + size="small" + type="primary" + @click="addTableRow" + >娣诲姞</el-button + > <span style="width: 60px">骞翠唤锛�</span> <el-date-picker v-model="form.planYear" type="year" value-format="yyyy" + :disabled="operationType === 'check'" clearable size="small" format="yyyy" - placeholder="閫夋嫨骞�"> + placeholder="閫夋嫨骞�" + > </el-date-picker> </div> <div style="margin: 10px 0"> - <el-table ref="yearTable" :data="deviceTraceabilityManagementDetails" - height="300px" id="templateParamTable" row-key="deviceId" - style="width: 100% ;"> - <el-table-column align="center" header-align="center" label="搴忓彿" type="index" width="60"></el-table-column> + <el-table + ref="yearTable" + :data="deviceTraceabilityManagementDetails" + height="300px" + id="templateParamTable" + row-key="deviceId" + style="width: 100% ;" + > + <el-table-column + align="center" + header-align="center" + label="搴忓彿" + type="index" + width="60" + ></el-table-column> <el-table-column label="璁惧鍚嶇О" min-width="170" prop="deviceId"> <template slot-scope="scope"> - <el-input v-model="scope.row.deviceName" :disabled="operationType === 'check'" clearable size="small"></el-input> + <el-input + v-model="scope.row.deviceName" + :disabled="operationType === 'check'" + clearable + size="small" + ></el-input> </template> </el-table-column> - <el-table-column label="鍨嬪彿" min-width="140" prop="specificationModel"> + <el-table-column + label="鍨嬪彿" + min-width="140" + prop="specificationModel" + > <template slot-scope="scope"> - <el-input v-model="scope.row.specificationModel" :disabled="operationType === 'check'" clearable size="small"></el-input> + <el-input + v-model="scope.row.specificationModel" + :disabled="operationType === 'check'" + clearable + size="small" + ></el-input> </template> </el-table-column> - <el-table-column label="璁惧缂栧彿" min-width="140" prop="managementNumber"> + <el-table-column + label="璁惧缂栧彿" + min-width="140" + prop="managementNumber" + > <template slot-scope="scope"> - <el-input v-model="scope.row.managementNumber" :disabled="operationType === 'check'" clearable size="small"></el-input> + <el-input + v-model="scope.row.managementNumber" + :disabled="operationType === 'check'" + clearable + size="small" + ></el-input> </template> </el-table-column> - <el-table-column label="鎶�鏈寚鏍囧弬鏁�" min-width="120" prop="technicalIndexParameters"> + <el-table-column + label="鎶�鏈寚鏍囧弬鏁�" + min-width="120" + prop="technicalIndexParameters" + > <template slot-scope="scope"> - <el-input v-model="scope.row.technicalIndexParameters" :disabled="operationType === 'check'" clearable size="small" type="textarea"></el-input> + <el-input + v-model="scope.row.technicalIndexParameters" + :disabled="operationType === 'check'" + clearable + size="small" + type="textarea" + ></el-input> </template> </el-table-column> - <el-table-column label="鎶�鏈寚鏍囪姹�" min-width="120" prop="technicalRequirements"> + <el-table-column + label="鎶�鏈寚鏍囪姹�" + min-width="120" + prop="technicalRequirements" + > <template slot-scope="scope"> - <el-input v-model="scope.row.technicalRequirements" :disabled="operationType === 'check'" clearable size="small" type="textarea"></el-input> + <el-input + v-model="scope.row.technicalRequirements" + :disabled="operationType === 'check'" + clearable + size="small" + type="textarea" + ></el-input> </template> </el-table-column> - <el-table-column label="妫�瀹氬懆鏈�" min-width="120" prop="verificationCycle"> + <el-table-column + label="妫�瀹氬懆鏈�" + min-width="120" + prop="verificationCycle" + > <template slot-scope="scope"> - <el-input v-model="scope.row.verificationCycle" :disabled="operationType === 'check'" clearable size="small" type="textarea"></el-input> + <el-input + v-model="scope.row.verificationCycle" + :disabled="operationType === 'check'" + clearable + size="small" + type="textarea" + ></el-input> </template> </el-table-column> - <el-table-column label="妫�瀹氬崟浣�" min-width="90" prop="verificationUnit"> + <el-table-column + label="妫�瀹氬崟浣�" + min-width="90" + prop="verificationUnit" + > <template slot-scope="scope"> - <el-input v-model="scope.row.verificationUnit" :disabled="operationType === 'check'" clearable size="small" type="textarea"></el-input> + <el-input + v-model="scope.row.verificationUnit" + :disabled="operationType === 'check'" + clearable + size="small" + type="textarea" + ></el-input> </template> </el-table-column> <el-table-column label="澶囨敞" min-width="90" prop="remark"> <template slot-scope="scope"> - <el-input v-model="scope.row.remark" :disabled="operationType === 'check'" clearable size="small" type="textarea"></el-input> + <el-input + v-model="scope.row.remark" + :disabled="operationType === 'check'" + clearable + size="small" + type="textarea" + ></el-input> </template> </el-table-column> <el-table-column fixed="right" label="鎿嶄綔" width="80" align="center"> <template slot-scope="scope"> - <el-button style="color: #f56c6c" type="text" @click="deleteRow(scope.$index)">鍒犻櫎</el-button> + <el-button + style="color: #f56c6c" + type="text" + @click="deleteRow(scope.$index)" + >鍒犻櫎</el-button + > </template> </el-table-column> </el-table> </div> <span slot="footer" class="dialog-footer"> <el-button @click="closeDialog">鍙� 娑�</el-button> - <el-button v-if="operationType !=='check'" :loading="submitFormLoading" type="primary" @click="submitForm">纭� 璁�</el-button> - <el-button v-if="operationType ==='check'" :loading="submitFormLoading" type="primary" @click="checkStatus(0)">涓嶉�氳繃</el-button> - <el-button v-if="operationType ==='check'" :loading="submitFormLoading" type="primary" @click="checkStatus(1)">閫� 杩�</el-button> + <el-button + v-if="operationType !== 'check'" + :loading="submitFormLoading" + type="primary" + @click="submitForm" + >纭� 璁�</el-button + > + <el-button + v-if="operationType === 'check'" + :loading="submitFormLoading" + type="primary" + @click="checkStatus(0)" + >涓嶉�氳繃</el-button + > + <el-button + v-if="operationType === 'check'" + :loading="submitFormLoading" + type="primary" + @click="checkStatus(1)" + >閫� 杩�</el-button + > </span> </el-dialog> - <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" - :visible.sync="addEquipDia" title="娣诲姞璁惧" width="50%"> - <el-table ref="multipleTable" :data="equipOptions" tooltip-effect="dark" height="500" - style="width: 100%" @selection-change="handleSelectionChange"> + <el-dialog + :close-on-click-modal="false" + :close-on-press-escape="false" + :visible.sync="addEquipDia" + title="娣诲姞璁惧" + width="50%" + > + <el-table + ref="multipleTable" + :data="equipOptions" + tooltip-effect="dark" + height="500" + style="width: 100%" + @selection-change="handleSelectionChange" + > <el-table-column type="selection" width="55"></el-table-column> - <el-table-column label="璁惧鍚嶇О" prop="label" width="190"></el-table-column> - <el-table-column prop="specificationModel" label="鍨嬪彿" width="120"></el-table-column> - <el-table-column prop="managementNumber" label="璁惧缂栧彿"></el-table-column> + <el-table-column + label="璁惧鍚嶇О" + prop="label" + width="190" + ></el-table-column> + <el-table-column + prop="specificationModel" + label="鍨嬪彿" + width="120" + ></el-table-column> + <el-table-column + prop="managementNumber" + label="璁惧缂栧彿" + ></el-table-column> </el-table> <span slot="footer" class="dialog-footer"> <el-button @click="addEquipDia = false">鍙� 娑�</el-button> - <el-button v-if="operationType !=='check'" :loading="submitFormLoading" type="primary" @click="changeMachineName">纭� 璁�</el-button> + <el-button + v-if="operationType !== 'check'" + :loading="submitFormLoading" + type="primary" + @click="changeMachineName" + >纭� 璁�</el-button + > </span> </el-dialog> </div> @@ -141,8 +363,7 @@ props: { clickNodeVal: { type: Object, - default: () => { - } + default: () => {} } }, data() { @@ -151,7 +372,7 @@ pagination1: { size: 10, current: 1, - total: 0, + total: 0 }, yearTableDetailDataLoading: false, yearTableDetailData: [], @@ -160,146 +381,190 @@ deviceIds: [], applicationForm: false, submitFormLoading: false, - operationType: '', + operationType: "", equipOptions: [], form: { - planYear: '', + planYear: "", deviceTraceabilityManagementDetails: [] }, - addEquipDia: false, - } + addEquipDia: false + }; }, mounted() { - this.getYearTableDetailData() + this.getYearTableDetailData(); }, // 鏂规硶闆嗗悎 methods: { // 鏌ヨ getYearTableDetailData() { - this.yearTableDetailDataLoading = true - this.$axios.post(this.$api.deviceTraceabilityManagement.selectDeviceTraceabilityManagementByPage, { - page: { - current: this.pagination1.current, - size: this.pagination1.size, - }, - entity: {} - }, { - headers: { - 'Content-Type': 'application/json' - }, - noQs: true - }).then(res => { - if (res.code == 200) { - this.yearTableDetailData = res.data.records - this.pagination1.total = res.data.total - } - this.yearTableDetailDataLoading = false - }).catch(err => { - this.yearTableDetailDataLoading = false - }) + this.yearTableDetailDataLoading = true; + this.$axios + .post( + this.$api.deviceTraceabilityManagement + .selectDeviceTraceabilityManagementByPage, + { + page: { + current: this.pagination1.current, + size: this.pagination1.size + }, + entity: {} + }, + { + headers: { + "Content-Type": "application/json" + }, + noQs: true + } + ) + .then(res => { + if (res.code == 200) { + this.yearTableDetailData = res.data.records; + this.pagination1.total = res.data.total; + } + this.yearTableDetailDataLoading = false; + }) + .catch(err => { + this.yearTableDetailDataLoading = false; + }); }, // 鎵撳紑鏂板鍜岀紪杈戝脊妗� handleForm(type, row) { - this.operationType = type - this.applicationForm = true - this.form = { - planYear: '', - deviceTraceabilityManagementDetails: [] - }, - this.deviceTraceabilityManagementDetails = [] + this.operationType = type; + this.applicationForm = true; + (this.form = { + planYear: "", + deviceTraceabilityManagementDetails: [] + }), + (this.deviceTraceabilityManagementDetails = []); if (row) { - this.traceabilityManagementId = row.traceabilityManagementId - this.$axios.get(this.$api.deviceTraceabilityManagement.getTraceabilityManagementDetail + '?traceabilityManagementId=' + this.traceabilityManagementId).then(res => { - if (res.code === 200) { - this.form = res.data - this.deviceTraceabilityManagementDetails = this.form.deviceTraceabilityManagementDetails - } - }).catch(error => { - console.error(error) - }) + this.traceabilityManagementId = row.traceabilityManagementId; + this.$axios + .get( + this.$api.deviceTraceabilityManagement + .getTraceabilityManagementDetail + + "?traceabilityManagementId=" + + this.traceabilityManagementId + ) + .then(res => { + if (res.code === 200) { + this.form = res.data; + this.deviceTraceabilityManagementDetails = this.form.deviceTraceabilityManagementDetails; + } + }) + .catch(error => { + console.error(error); + }); } }, // 娣诲姞璁惧 - addTableRow () { - this.addEquipDia = true - this.getEquipOptions() + addTableRow() { + this.addEquipDia = true; + this.getEquipOptions(); }, - handleSelectionChange (selection) { - this.selectionRows = selection + handleSelectionChange(selection) { + this.selectionRows = selection; }, // 璧嬪�间华鍣ㄧ紪鍙� changeMachineName() { - this.deviceTraceabilityManagementDetails = [] + this.deviceTraceabilityManagementDetails = []; this.selectionRows.map(val => { - this.deviceTraceabilityManagementDetails.push({deviceId: val.id,managementNumber: val.value, deviceName: val.label, specificationModel: val.specificationModel}) - }) - this.addEquipDia = false - this.rowDrop() + this.deviceTraceabilityManagementDetails.push({ + deviceId: val.id, + managementNumber: val.value, + deviceName: val.label, + specificationModel: val.specificationModel + }); + }); + this.addEquipDia = false; + this.rowDrop(); }, rowDrop() { - const that = this + const that = this; const tbody = document.querySelector( - '#templateParamTable .el-table__body-wrapper tbody' - ) + "#templateParamTable .el-table__body-wrapper tbody" + ); if (!this.sortTable) { this.sortTable = Sortable.create(tbody, { animation: 200, //鍔ㄧ敾鏃堕暱 handle: ".el-table__row", //鍙嫋鎷藉尯鍩焎lass //鎷栨嫿涓簨浠� onMove: ({ dragged, related }) => { - const oldRow = that.deviceTraceabilityManagementDetails[dragged.rowIndex] //鏃т綅缃暟鎹� - const newRow = that.deviceTraceabilityManagementDetails[related.rowIndex] //琚嫋鎷界殑鏂版暟鎹� + const oldRow = + that.deviceTraceabilityManagementDetails[dragged.rowIndex]; //鏃т綅缃暟鎹� + const newRow = + that.deviceTraceabilityManagementDetails[related.rowIndex]; //琚嫋鎷界殑鏂版暟鎹� }, //鎷栨嫿缁撴潫浜嬩欢 onEnd: evt => { - const curRow = that.deviceTraceabilityManagementDetails.splice(evt.oldIndex, 1)[0]; - that.deviceTraceabilityManagementDetails.splice(evt.newIndex, 0, curRow); + const curRow = that.deviceTraceabilityManagementDetails.splice( + evt.oldIndex, + 1 + )[0]; + that.deviceTraceabilityManagementDetails.splice( + evt.newIndex, + 0, + curRow + ); } - }) + }); } }, // 鍒犻櫎琛ㄦ牸琛� - deleteRow (index) { - this.deviceTraceabilityManagementDetails.splice(index, 1) + deleteRow(index) { + this.deviceTraceabilityManagementDetails.splice(index, 1); }, // 鎻愪氦鏂板鍜屼慨鏀� submitForm() { - this.form.deviceTraceabilityManagementDetails = this.HaveJson(this.deviceTraceabilityManagementDetails) - this.submitFormLoading = true - if (this.operationType === 'add') { - this.$axios.post(this.$api.deviceTraceabilityManagement.addTraceabilityManagement, - this.form, { - headers: { - 'Content-Type': 'application/json' - }, - noQs: true - }).then(res => { - if (res.code == 200) { - this.$message.success('鏂板鎴愬姛') - this.applicationForm = false - this.getYearTableDetailData() - } - this.submitFormLoading = false - }).catch(err => { - this.submitFormLoading = false - }) + this.form.deviceTraceabilityManagementDetails = this.HaveJson( + this.deviceTraceabilityManagementDetails + ); + this.submitFormLoading = true; + if (this.operationType === "add") { + this.$axios + .post( + this.$api.deviceTraceabilityManagement.addTraceabilityManagement, + this.form, + { + headers: { + "Content-Type": "application/json" + }, + noQs: true + } + ) + .then(res => { + if (res.code == 200) { + this.$message.success("鏂板鎴愬姛"); + this.applicationForm = false; + this.getYearTableDetailData(); + } + this.submitFormLoading = false; + }) + .catch(err => { + this.submitFormLoading = false; + }); } else { - this.$axios.post(this.$api.deviceTraceabilityManagement.updateTraceabilityManagement, - this.form, { - headers: { - 'Content-Type': 'application/json' - }, - noQs: true - }).then(res => { - if (res.code == 200) { - this.$message.success('淇敼鎴愬姛') - this.applicationForm = false - this.getYearTableDetailData() - } - this.submitFormLoading = false - }).catch(err => { - this.submitFormLoading = false - }) + this.$axios + .post( + this.$api.deviceTraceabilityManagement.updateTraceabilityManagement, + this.form, + { + headers: { + "Content-Type": "application/json" + }, + noQs: true + } + ) + .then(res => { + if (res.code == 200) { + this.$message.success("淇敼鎴愬姛"); + this.applicationForm = false; + this.getYearTableDetailData(); + } + this.submitFormLoading = false; + }) + .catch(err => { + this.submitFormLoading = false; + }); } }, // 鎻愪氦瀹℃牳 @@ -307,106 +572,133 @@ const params = { status: status, traceabilityManagementId: this.traceabilityManagementId - } - this.$axios.post(this.$api.deviceTraceabilityManagement.reviewTraceabilityManagementStatus, - params, { - headers: { - 'Content-Type': 'application/json' - }, - noQs: true - }).then(res => { - if (res.code == 200) { - this.$message.success('瀹℃牳鎴愬姛') - this.applicationForm = false - this.getYearTableDetailData() - } - this.submitFormLoading = false - }).catch(err => { - this.submitFormLoading = false - }) + }; + this.$axios + .post( + this.$api.deviceTraceabilityManagement + .reviewTraceabilityManagementStatus, + params, + { + headers: { + "Content-Type": "application/json" + }, + noQs: true + } + ) + .then(res => { + if (res.code == 200) { + this.$message.success("瀹℃牳鎴愬姛"); + this.applicationForm = false; + this.getYearTableDetailData(); + } + this.submitFormLoading = false; + }) + .catch(err => { + this.submitFormLoading = false; + }); }, closeDialog() { - this.applicationForm = false - this.getYearTableDetailData() + this.applicationForm = false; + this.getYearTableDetailData(); }, // 鍒嗛〉 handleSizeChange1(val) { - this.pagination1.size = val - this.getYearTableDetailData() + this.pagination1.size = val; + this.getYearTableDetailData(); }, // 鍒嗛〉 handleCurrentChange1(val) { - this.pagination1.current = val - this.getYearTableDetailData() + this.pagination1.current = val; + this.getYearTableDetailData(); }, handleDownOne(id) { - this.outLoading = true - this.$axios.get(this.$api.deviceTraceabilityManagement.exportDeviceTraceabilityManagement + '?traceabilityManagementId=' + id, { - responseType: "blob" - }).then(res => { - this.outLoading = false - const blob = new Blob([res], {type: 'application/octet-stream'}); - //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆 - let reader = new FileReader(); - reader.readAsText(blob, 'utf-8'); - reader.onload = () => { - try { - let result = JSON.parse(reader.result); - if (result.message) { - this.$message.error(result.message); - } else { - const url = URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = url; - link.download = '浠櫒璁惧閲忓�兼函婧愮鐞嗘�讳綋璁″垝.doc'; - link.click(); - this.$message.success('瀵煎嚭鎴愬姛') - } - } catch (err) { - console.log(err); - const url = URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = url; - link.download = '浠櫒璁惧閲忓�兼函婧愮鐞嗘�讳綋璁″垝.doc'; - link.click(); - this.$message.success('瀵煎嚭鎴愬姛') + this.outLoading = true; + this.$axios + .get( + this.$api.deviceTraceabilityManagement + .exportDeviceTraceabilityManagement + + "?traceabilityManagementId=" + + id, + { + responseType: "blob" } - } - }) + ) + .then(res => { + this.outLoading = false; + const blob = new Blob([res], { type: "application/octet-stream" }); + //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆 + let reader = new FileReader(); + reader.readAsText(blob, "utf-8"); + reader.onload = () => { + try { + let result = JSON.parse(reader.result); + if (result.message) { + this.$message.error(result.message); + } else { + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = "浠櫒璁惧閲忓�兼函婧愮鐞嗘�讳綋璁″垝.doc"; + link.click(); + this.$message.success("瀵煎嚭鎴愬姛"); + } + } catch (err) { + console.log(err); + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = "浠櫒璁惧閲忓�兼函婧愮鐞嗘�讳綋璁″垝.doc"; + link.click(); + this.$message.success("瀵煎嚭鎴愬姛"); + } + }; + }); }, // 鍒犻櫎 deleteFun(id) { - this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?', '鎻愮ず', { - confirmButtonText: '纭畾', - cancelButtonText: '鍙栨秷', - type: 'warning' - }).then(() => { - this.$axios.get(this.$api.deviceTraceabilityManagement.deleteTraceabilityManagement + '?traceabilityManagementId=' + id).then(res => { - this.$message.success('鍒犻櫎鎴愬姛锛�'); - this.getYearTableDetailData(); + this.$confirm("姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?", "鎻愮ず", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + this.$axios + .get( + this.$api.deviceTraceabilityManagement + .deleteTraceabilityManagement + + "?traceabilityManagementId=" + + id + ) + .then(res => { + this.$message.success("鍒犻櫎鎴愬姛锛�"); + this.getYearTableDetailData(); + }); + }) + .catch(() => { + this.$message({ + type: "info", + message: "宸插彇娑堝垹闄�" + }); }); - }).catch(() => { - this.$message({ - type: 'info', - message: '宸插彇娑堝垹闄�' - }); - }); }, // 鑾峰彇鎵�鏈夎澶� getEquipOptions() { - this.equipOptions = [] - this.$axios.get(this.$api.deviceScope.deviceScopeSearch + '?status=0').then(res => { - if (res.code === 200 && res.data) { - this.equipOptions = res.data.map(m => { - m.value = m.managementNumber - m.label = m.deviceName - return m - }) - } - }).catch(error => { - console.error(error) - }) - }, + this.equipOptions = []; + this.$axios + .get(this.$api.deviceScope.deviceScopeSearch + "?status=0") + .then(res => { + if (res.code === 200 && res.data) { + this.equipOptions = res.data.map(m => { + m.value = m.managementNumber; + m.label = m.deviceName; + return m; + }); + } + }) + .catch(error => { + console.error(error); + }); + } }, watch: { // 鐩戝惉鐐瑰嚮el-tree鐨勬暟鎹紝杩涜鏁版嵁鍒锋柊 @@ -414,9 +706,9 @@ if (newVal.value) { this.getYearTableDetailData(); } - }, + } } -} +}; </script> <style scoped> -- Gitblit v1.9.3