From 6ef9e5189ac1888b8c4c504d5c5d3f431807ff56 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期六, 15 三月 2025 11:57:40 +0800
Subject: [PATCH] 修改电路试验单位
---
src/components/do/a6-device/record.vue | 472 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 469 insertions(+), 3 deletions(-)
diff --git a/src/components/do/a6-device/record.vue b/src/components/do/a6-device/record.vue
index 0d26a3d..3675e0e 100644
--- a/src/components/do/a6-device/record.vue
+++ b/src/components/do/a6-device/record.vue
@@ -1,13 +1,479 @@
+<!-- 浣跨敤璁板綍 -->
<template>
- <div>璁惧璁板綍</div>
+ <div>
+ <div class="search">
+ <div class="search_thing">
+ <div class="search_label">鏍峰搧缂栧彿锛�</div>
+ <el-input v-model="search.sampleCode" clearable placeholder="璇疯緭鍏�" size="small" style="width: 70%;"
+ @keyup.enter.native="getTableList(clickNodeVal.value)"></el-input>
+ </div>
+ <div class="search_thing" style="padding-left: 30px;">
+ <el-button size="small" @click="resetSearch">閲� 缃�</el-button>
+ <el-button size="small" type="primary" @click="getTableList(clickNodeVal.value)">鏌� 璇�</el-button>
+ </div>
+ <div class="btns">
+ <el-button size="small" type="primary" @click="dialogVisible = true, openAdd()">鏂� 寤�</el-button>
+ <el-button :loading="outLoading" size="small" type="primary" @click="handleDown">瀵� 鍑�</el-button>
+ </div>
+ </div>
+ <div class="tables" style="margin-top: 10px;">
+ <el-table ref="Recordtable" :data="formParamList" height="calc(100vh - 20em)">
+ <!-- 琛ㄦ牸鍒� -->
+ <el-table-column label="搴忓彿" type="index" width="120">
+ <template v-slot="scope">
+ <span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鏍峰搧缂栧彿" min-width="180" prop="sampleCode" />
+ <el-table-column label="璁惧鍚嶇О" min-width="150" prop="deviceName" />
+ <el-table-column label="绠$悊缂栧彿" min-width="150" prop="managementNumber" />
+<!-- <el-table-column label="娓╁害(掳C)" min-width="120" prop="temperature" />-->
+<!-- <el-table-column label="婀垮害(%RH)" min-width="120" prop="humidity" />-->
+ <el-table-column label="浣跨敤鍓�" min-width="120" prop="useBefore">
+ <template v-slot="scope">
+ {{ scope.row.useBefore === 1 ? '姝e父' : '涓嶆甯�' }}
+ </template>
+ </el-table-column>
+ <el-table-column label="浣跨敤鍚�" min-width="120" prop="useAfter">
+ <template v-slot="scope">
+ {{ scope.row.useAfter === 1 ? '姝e父' : '涓嶆甯�' }}
+ </template>
+ </el-table-column>
+<!-- <el-table-column label="寮傚父鎯呭喌" min-width="120" prop="abnormal" />-->
+ <el-table-column label="浣跨敤寮�濮嬫棩鏈�" min-width="150" prop="useStartDate" />
+ <el-table-column label="浣跨敤缁撴潫鏃ユ湡" min-width="150" prop="useEndDate" />
+ <el-table-column label="浣跨敤浜�" min-width="120" prop="usePerson" />
+ <el-table-column label="澶囨敞" min-width="120" prop="remark" />
+ <!-- 鎿嶄綔鎸夐挳 -->
+ <el-table-column fixed="right" label="鎿嶄綔" width="150" align="center">
+ <template slot-scope="scope">
+ <el-button size="small" type="text" @click="showDetailsDialog('edit',scope.row)">缂栬緫</el-button>
+ <el-button size="small" type="text" @click="showDetailsDialog('view',scope.row)">鏌ョ湅</el-button>
+ <el-button size="small" type="text" @click="handleDeleteClick(scope.$index, scope.row)">鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]"
+ :total="search.total" layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
+ @current-change="handleCurrentChange">
+ </el-pagination>
+ </div>
+ <el-dialog :visible.sync="dialogVisible" title="浠櫒璁惧浣跨敤璁板綍琛�" top="5vh" width="55%">
+ <el-form ref="form" :model="form" label-width="130px">
+ <el-row>
+ <el-col :span="24">
+ <el-form-item :rules="[{ required: true, message: '鏍峰搧缂栧彿', trigger: 'blur' }]" label="鏍峰搧缂栧彿:" prop="sampleCode">
+ <el-input v-model="form.sampleCode" :disabled="operationType === 'view'" size="small" style="width: 100%;"></el-input>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="璁惧鍚嶇О:" required>
+ <el-input v-model="form.deviceName" :disabled="operationType === 'view'" size="small" style="width: 100%;"></el-input>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="绠$悊缂栧彿:" required>
+ <el-input v-model="form.managementNumber" :disabled="operationType === 'view'" size="small" style="width: 100%;"></el-input>
+ </el-form-item>
+ </el-col>
+<!-- <el-col :span="12">-->
+<!-- <el-form-item :rules="[{ required: true, message: '璇疯緭鍏ユ俯搴�(掳C)', trigger: 'blur' }]" label="娓╁害(掳C):"-->
+<!-- prop="temperature">-->
+<!-- <el-input v-model="form.temperature" :disabled="isShow" size="small" style="width: 100%;"></el-input>-->
+<!-- </el-form-item>-->
+<!-- </el-col>-->
+<!-- <el-col :span="12">-->
+<!-- <el-form-item :rules="[{ required: true, message: '璇疯緭鍏ユ箍搴�(%RH)', trigger: 'blur' }]" label="婀垮害(%RH):"-->
+<!-- prop="humidity">-->
+<!-- <el-input v-model="form.humidity" :disabled="isShow" size="small" style="width: 100%;"></el-input>-->
+<!-- </el-form-item>-->
+<!-- </el-col>-->
+ <el-col :span="12">
+ <el-form-item :rules="[{ required: true, message: '璇烽�夋嫨浣跨敤鍓�', trigger: 'change' }]" label="浣跨敤鍓�:"
+ prop="useBefore">
+ <el-radio-group v-model="form.useBefore" :disabled="operationType === 'view'">
+ <el-radio :label="1">姝e父</el-radio>
+ <el-radio :label="0">涓嶆甯�</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item :rules="[{ required: true, message: '璇烽�夋嫨浣跨敤鍚�', trigger: 'change' }]" label="浣跨敤鍚�:"
+ prop="useAfter">
+ <el-radio-group v-model="form.useAfter" :disabled="operationType === 'view'">
+ <el-radio :label="1">姝e父</el-radio>
+ <el-radio :label="0">涓嶆甯�</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ </el-col>
+<!-- <el-col v-if="form.useAfter === 0" :span="24">-->
+<!-- <el-form-item :rules="[{ required: form.useAfter === 0, message: '璇疯緭鍏ュ紓甯告儏鍐�', trigger: 'blur' }]" label="寮傚父鎯呭喌:"-->
+<!-- prop="abnormal">-->
+<!-- <el-input v-model="form.abnormal" :disabled="operationType === 'view'" size="small" style="width: 100%;"-->
+<!-- type="textarea"></el-input>-->
+<!-- </el-form-item>-->
+<!-- </el-col>-->
+ <el-col :span="12">
+ <el-form-item :rules="[{ required: true, message: '璇疯緭鍏ヤ娇鐢ㄦ棩鏈�', trigger: 'blur' }]" label="浣跨敤鏃ユ湡:"
+ prop="useDateList">
+ <el-date-picker
+ v-model="form.useDateList" :disabled="operationType === 'view'" end-placeholder="缁撴潫鏃ユ湡" format="yyyy-MM-dd HH:mm:ss"
+ size="small"
+ start-placeholder="寮�濮嬫棩鏈�"
+ style="width:100%"
+ type="datetimerange"
+ value-format="yyyy-MM-dd HH:mm:ss">
+ </el-date-picker>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item :rules="[{ required: true, message: '璇疯緭鍏ヤ娇鐢ㄤ汉', trigger: 'change' }]" label="浣跨敤浜�:"
+ prop="usePersonId">
+ <el-select @change="usePersonName" v-model="form.usePersonId" :disabled="operationType === 'view'" placeholder="璇烽�夋嫨" size="small" style="width: 100%">
+ <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="24">
+ <el-form-item label="澶囨敞:">
+ <el-input v-model="form.remark" :disabled="operationType === 'view'" type="textarea"></el-input>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <span slot="footer" class="dialog-footer">
+ <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+ <el-button v-if="operationType !== 'view'" type="primary" @click="saveRecord">纭� 瀹�</el-button>
+ </span>
+ </el-dialog>
+ </div>
</template>
-
<script>
export default {
-
+ props: {
+ clickNodeVal: {
+ type: Object,
+ default: () => {
+ return {};
+ }
+ }
+ },
+ data() {
+ return {
+ search: {
+ size: 20,
+ current: 1,
+ total: 0,
+ sampleCode: ''
+ },
+ responsiblePersonList: {},
+ isShow: false,
+ outLoading: false,
+ userList: [],
+ form: {
+ // deviceId:'',
+ processNumber: '',
+ deviceName: '',
+ managementNumber: '',
+ //娓╁害
+ temperature: '',
+ //婀垮害
+ humidity: '',
+ //浣跨敤鍓�
+ useBefore: 1,
+ //浣跨敤鍚�
+ useAfter: 1,
+ //寮傚父鎯呭喌
+ abnormal: '',
+ useDateList: [],
+ //浣跨敤鏃ユ湡
+ useStartDate: null,
+ useEndDate: null,
+ //浣跨敤浜�
+ usePerson: '',
+ usePersonId: '',
+ //澶囨敞
+ remark: '',
+ },
+ dialogVisible: false,
+ operationType: '',
+ formParamList: [],
+ }
+ },
+ mounted() {
+ this.getTableList(this.clickNodeVal.value);
+ },
+ methods: {
+ handleSizeChange(val) {
+ this.search.size = val
+ this.getTableList(this.clickNodeVal.value);
+ },
+ handleCurrentChange(val) {
+ this.search.current = val
+ this.getTableList(this.clickNodeVal.value);
+ },
+ resetSearch() {
+ this.search = {
+ size: 20,
+ current: 1,
+ total: 0,
+ sampleCode: '',
+ }
+ this.getTableList(this.clickNodeVal.value);
+ },
+ async getTableList(deviceId) {
+ await this.$axios.get(this.$api.deviceCheck.deviceRecordPage + "?deviceId=" + deviceId + "&size=" + this.search.size + "¤t=" + this.search.current + "&sampleCode=" + this.search.sampleCode).then(res => {
+ if (res.code == 200) {
+ this.formParamList = res.data.records
+ this.search.total = res.data.total
+ }
+ })
+ },
+ //瀵煎嚭
+ handleDown() {
+ this.outLoading = true
+ this.$axios.get(this.$api.deviceCheck.exportUseRecord + "?deviceId=" + this.clickNodeVal.value, {
+ 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('瀵煎嚭鎴愬姛')
+ }
+ }
+ })
+ },
+ //鏂板缓
+ openAdd() {
+ this.operationType = 'add'
+ this.getUserList()
+ this.$axios.get(this.$api.deviceScope.selectDeviceByCode + '?id=' + this.clickNodeVal.value).then(res => {
+ this.form.deviceName = res.data.deviceName
+ this.form.managementNumber = res.data.managementNumber
+ this.$nextTick(() => {
+ this.$refs['form'].clearValidate()
+ })
+ });
+ },
+ usePersonName (value) {
+ const index = this.userList.findIndex(item => item.id === value)
+ if (index > -1) {
+ this.form.usePerson = this.userList[index].name
+ }
+ },
+ //纭娣诲姞璁板綍
+ saveRecord() {
+ this.$refs.form.validate((valid) => {
+ if (valid) {
+ this.form.useStartDate = this.form.useDateList[0]
+ this.form.useEndDate = this.form.useDateList[1]
+ this.form.deviceId = this.clickNodeVal.value
+ if (this.operationType === 'add') {
+ this.$axios.post(this.$api.deviceCheck.saveDeviceRecord, this.form, {
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ noQs: true
+ }).then(res => {
+ if (res.code == 200) {
+ this.$message.success('鏂板鎴愬姛')
+ this.getTableList(this.clickNodeVal.value)
+ this.dialogVisible = false
+ }
+ })
+ this.dialogVisible = false;
+ } else {
+ this.$axios.post(this.$api.deviceCheck.updateDeviceRecord, this.form, {
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ noQs: true
+ }).then(res => {
+ if (res.code == 200) {
+ this.$message.success('淇敼鎴愬姛')
+ this.getTableList(this.clickNodeVal.value)
+ this.dialogVisible = false
+ }
+ })
+ this.dialogVisible = false;
+ }
+ }
+ });
+ },
+ //鏌ョ湅璇︽儏
+ showDetailsDialog(type,row) {
+ this.operationType = type;
+ console.log(row)
+ this.dialogVisible = true;
+ this.getUserList()
+ this.form = row;
+ let list = []
+ if (row.useStartDate === null) {
+ row.useStartDate = ''
+ }
+ if (row.useEndDate === null) {
+ row.useEndDate = ''
+ }
+ list.push(row.useStartDate)
+ list.push(row.useEndDate)
+ this.$set(this.form, 'useDateList', list)
+ },
+ handleDeleteClick(index, row) {
+ this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ this.$axios.delete(this.$api.deviceCheck.deleteDeviceRecord + '?id=' + row.id).then(res => {
+ this.formParamList.splice(index, 1);
+ this.$message({
+ type: 'success',
+ message: '鍒犻櫎鎴愬姛!'
+ });
+ })
+ }).catch(() => {
+ this.$message({
+ type: 'info',
+ message: '宸插彇娑堝垹闄�'
+ });
+ });
+ },
+ getUserList(){
+ this.$axios.post(this.$api.user.selectUserList, {
+ page: {current: -1, size: -1,},
+ entity: {name: null}
+ }, {
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ }).then(res => {
+ if (res.code === 201) {
+ return
+ }
+ this.userList = res.data.body.records
+ })
+ },
+ },
+ watch: {
+ // 鐩戝惉鐐瑰嚮el-tree鐨勬暟鎹紝杩涜鏁版嵁鍒锋柊
+ clickNodeVal(newVal) {
+ if (newVal.value) {
+ this.getTableList(newVal.value);
+ }
+ },
+ dialogVisible(newVal) {
+ if (newVal === false) {
+ this.form = {
+ // deviceId:'',
+ sampleCode: '',
+ deviceName: '',
+ managementNumber: '',
+ //娓╁害
+ temperature: '',
+ //婀垮害
+ humidity: '',
+ //浣跨敤鍓�
+ useBefore: 1,
+ //浣跨敤鍚�
+ useAfter: 1,
+ //寮傚父鎯呭喌
+ abnormal: '',
+ //浣跨敤鏃ユ湡
+ useDateList: [],
+ //浣跨敤浜�
+ usePersonId: '',
+ //澶囨敞
+ remark: '',
+ }
+ this.$refs.form.clearValidate()
+ }
+ }
+ }
}
</script>
<style scoped>
+.tables {
+ width: 100%;
+ height: calc(100vh - 15em);
+}
+.el-from {
+ max-width: 400px;
+ margin: 0 auto;
+}
+
+.form-row {
+ display: flex;
+ justify-content: space-between;
+}
+
+.el-input {
+ width: calc(100% - 120px);
+ /* 纭繚杈撳叆妗嗗搴︿竴鑷� */
+}
+
+.form-row .el-form-item {
+ flex: 1;
+ /* 姣忎釜琛ㄥ崟椤瑰崰鎹浉鍚屾瘮渚嬬殑绌洪棿 */
+ margin-right: 100px;
+ /* 鍙�夛細涓哄彸渚у厓绱犳坊鍔犻棿璺� */
+}
+
+/* 绉婚櫎鏈�鍚庝竴涓厓绱犵殑鍙宠竟璺� */
+.form-row .el-form-item:last-child {
+ margin-right: 0;
+
+}
+
+.search {
+ background-color: #fff;
+ margin-top: 10px;
+ display: flex;
+ align-items: center;
+ position: relative;
+}
+
+.search_thing {
+ display: flex;
+ align-items: center;
+ height: 40px;
+
+}
+
+.search_label {
+ width: 80px;
+ font-size: 14px;
+ text-align: right;
+ margin-right: 10px;
+}
+
+.btns {
+ position: absolute;
+ right: 0px;
+ top: 50%;
+ transform: translate(0, -50%);
+}
</style>
--
Gitblit v1.9.3