From 7ec7fea9b03f6fb66b25769e3ec578528ccf2365 Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期五, 21 三月 2025 16:44:41 +0800 Subject: [PATCH] 合并装备代码 --- src/views/CNAS/resourceDemand/device/component/state.vue | 108 ++++++++++++++++-------------------------------------- 1 files changed, 32 insertions(+), 76 deletions(-) diff --git a/src/views/CNAS/resourceDemand/device/component/state.vue b/src/views/CNAS/resourceDemand/device/component/state.vue index 9994f65..8715991 100644 --- a/src/views/CNAS/resourceDemand/device/component/state.vue +++ b/src/views/CNAS/resourceDemand/device/component/state.vue @@ -12,8 +12,8 @@ </div> </div> <div class="search_thing" style="padding-left: 20px;"> - <el-button size="small" @click="resetSearch">閲� 缃�</el-button> - <el-button size="small" type="primary" @click="getDeviceStatePage(clickNodeVal.value)">鏌� 璇�</el-button> + <el-button size="mini" type="primary" @click="getDeviceStatePage(clickNodeVal.value)">鏌ヨ</el-button> + <el-button size="mini" @click="resetSearch">閲嶇疆</el-button> </div> </el-col> <el-col :span="4"> @@ -25,7 +25,8 @@ </el-row> </div> <div> - <el-table :data="tableDatalist" height="calc(100vh - 20em)" style="width: 100% ;"> + <el-table :data="tableDatalist" height="calc(100vh - 20em)" style="width: 100% ;" + :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border> <!-- 琛ㄦ牸鍒� --> <el-table-column align="center" header-align="center" label="搴忓彿" prop="prop" type="index" width="70"></el-table-column> @@ -237,7 +238,17 @@ </div> </template> <script> +import { + saveDeviceState, + selectDeviceByCode, + exportDeviceStatus, + deleteDeviceState, + deviceStateExport, + getDeviceStatePage, +} from '@/api/cnas/resourceDemand/device.js' +import { selectUserCondition } from "@/api/business/inspectionTask"; import { dateFormat } from '@/utils/date' +import { mapGetters } from "vuex"; export default { props: { clickNodeVal: { @@ -246,6 +257,9 @@ return {}; } } + }, + computed: { + ...mapGetters(["nickName"]), }, data() { return { @@ -311,25 +325,24 @@ this.$refs.form.validate((valid) => { if (valid === true || saveState !== '1submit') { // 缁欏綋鍓嶇幆鑺傝缃垱寤轰汉涓庢椂闂� - let user = JSON.parse(localStorage.getItem('user')) const dateTime = dateFormat(new Date()) // 鑾峰彇褰撳墠鐜妭鎿嶄綔浜轰笌鏃ユ湡 switch (this.currentStep) { case 0: - this.form.createUser = user.name - this.form.submitOperatingPersonnel = user.name + this.form.createUser = this.nickName + this.form.submitOperatingPersonnel = this.nickName this.form.submitDate = dateTime break case 1: - this.form.departmentOperatingPersonnel = user.name + this.form.departmentOperatingPersonnel = this.nickName this.form.departmentDate = dateTime break case 2: - this.form.measuringRoomOperatingPersonnel = user.name + this.form.measuringRoomOperatingPersonnel = this.nickName this.form.measuringRoomDate = dateTime break case 3: - this.form.approvalOperatingPersonnel = user.name + this.form.approvalOperatingPersonnel = this.nickName this.form.approvalDate = dateTime break default: @@ -355,11 +368,7 @@ // 鑾峰彇褰撳墠鐘舵�� this.form.currentState = currentStepAction === 4 ? '鍏抽棴' : this.steps[currentStepAction] this.form.deviceId = this.clickNodeVal.value - this.$axios.post(this.$api.deviceCheck.saveDeviceState, this.form, { - headers: { - 'Content-Type': 'application/json' - } - }).then(res => { + saveDeviceState(this.form).then(res => { if (res.code == 200) { this.$message.success('鎻愪氦鎴愬姛') this.getDeviceStatePage(this.clickNodeVal.value) @@ -385,7 +394,7 @@ }, openRecordAcceptance() { // 鑾峰彇璁惧鍩虹淇℃伅 - this.$axios.get(this.$api.deviceScope.selectDeviceByCode + '?id=' + this.clickNodeVal.value).then(res => { + selectDeviceByCode({ id: this.clickNodeVal.value }).then(res => { this.form.deviceName = res.data.deviceName this.form.specificationModel = res.data.specificationModel this.form.managementNumber = res.data.managementNumber @@ -398,7 +407,7 @@ }, // 鑾峰彇璐熻矗浜轰俊鎭帴鍙� getUserList() { - this.$axios.get(this.$api.deviceScope.selectUserList).then(res => { + selectUserCondition().then(res => { if (res.code == 200) { this.responsibleOptions = res.data } @@ -418,37 +427,10 @@ // 瀵煎嚭 handleDownOne(row) { this.outLoading = true - this.$axios.get(this.$api.deviceCheck.exportDeviceStatus + '?deviceId=' + row.deviceId + '&processNumber=' + row.processNumber, { - responseType: "blob" - }).then(res => { + exportDeviceStatus({ deviceId: row.deviceId, processNumber: row.processNumber }).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.$download.saveAs(blob, '璁惧鍋�/鍚敤.doc') }) }, // 鍒犻櫎 @@ -458,7 +440,7 @@ cancelButtonText: '鍙栨秷', type: 'warning' }).then(() => { - this.$axios.delete(this.$api.deviceCheck.deleteDeviceState + '?stateId=' + row.stateId).then(res => { + deleteDeviceState({ stateId: row.stateId }).then(res => { if (res.code == 200) { this.$message.success('鍒犻櫎鎴愬姛') this.getDeviceStatePage(this.clickNodeVal.value) @@ -470,43 +452,17 @@ message: '宸插彇娑堝垹闄�' }); }); - }, //瀵煎嚭 handleDown() { this.outLoading = true - this.$axios.post(this.$api.deviceCheck.deviceStateExport, { + deviceStateExport({ deviceId: this.clickNodeVal.value, processNumber: this.search.processNumber - }, { responseType: "blob" }).then(res => { + }).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 = '璁惧鍋滅敤/鍚敤.xlsx'; - 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 = '璁惧鍋滅敤/鍚敤.xlsx'; - link.click(); - this.$message.success('瀵煎嚭鎴愬姛') - } - } + this.$download.saveAs(blob, '璁惧鍋滅敤/鍚敤.xlsx') }).finally(() => { this.outLoading = false }) @@ -521,7 +477,7 @@ this.getDeviceStatePage(this.clickNodeVal.value); }, getDeviceStatePage(deviceId) { - this.$axios.get(this.$api.deviceCheck.getDeviceStatePage + '?deviceId=' + deviceId + "&size=" + this.search.size + "¤t=" + this.search.current + "&processNumber=" + this.search.processNumber).then(res => { + getDeviceStatePage({ deviceId, ...this.search }).then(res => { if (res.code == 200) { this.tableDatalist = res.data.records this.search.total = res.data.total -- Gitblit v1.9.3