| | |
| | | v-model="dialogFormVisible" |
| | | title="计量器具" |
| | | width="50%" |
| | | draggable |
| | | @close="closeDia" |
| | | > |
| | | <el-form |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="有效期:" prop="valid"> |
| | | <el-form-item label="有效日期(天):" prop="valid"> |
| | | <el-input |
| | | v-model="form.valid" |
| | | placeholder="请输入" |
| | | type="number" |
| | | placeholder="请输入有效期天数" |
| | | clearable |
| | | :min="1" |
| | | @input="handleValidInput" |
| | | > |
| | | <template #append>日</template> |
| | | </el-input> |
| | |
| | | <el-select |
| | | v-model="form.userId" |
| | | placeholder="请选择" |
| | | disabled |
| | | filterable |
| | | default-first-option |
| | | :reserve-keyword="false" |
| | | clearable |
| | | > |
| | | <el-option |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref} from "vue"; |
| | | import {ref, reactive, toRefs, getCurrentInstance} from "vue"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | import {userListNoPageByTenantId} from "@/api/system/user.js"; |
| | | import {afterSalesServiceAdd, afterSalesServiceUpdate} from "@/api/customerService/index.js"; |
| | | import {getToken} from "@/utils/auth.js"; |
| | | import {ledgerRecordUpdate, ledgerRecordVerifying} from "@/api/equipmentManagement/calibration.js"; |
| | | import {delLedgerFile} from "@/api/salesManagement/salesLedger.js"; |
| | | import { getCurrentDate } from "@/utils/index.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | const emit = defineEmits(['close']) |
| | | const dialogFormVisible = ref(false); |
| | |
| | | rules: { |
| | | code: [{required: true, message: "请输入", trigger: "blur"}], |
| | | name: [{required: true, message: "请输入", trigger: "blur"}], |
| | | valid: [{required: true, message: "请输入", trigger: "blur"}], |
| | | valid: [ |
| | | {required: true, message: "请输入", trigger: "blur"}, |
| | | { |
| | | validator: (rule, value, callback) => { |
| | | if (value === '' || value === null || value === undefined) { |
| | | callback(); |
| | | return; |
| | | } |
| | | const numValue = Number(value); |
| | | if (isNaN(numValue)) { |
| | | callback(new Error('请输入有效的数字')); |
| | | return; |
| | | } |
| | | if (numValue <= 0) { |
| | | callback(new Error('只能输入正数')); |
| | | return; |
| | | } |
| | | if (!Number.isInteger(numValue)) { |
| | | callback(new Error('请输入整数')); |
| | | return; |
| | | } |
| | | callback(); |
| | | }, |
| | | trigger: 'blur' |
| | | } |
| | | ], |
| | | recordDate: [{required: true, message: "请选择", trigger: "change"}], |
| | | userId: [{required: true, message: "请选择", trigger: "change"}], |
| | | entryDate: [{required: true, message: "请选择", trigger: "change"}], |
| | |
| | | if(type === "add"){ |
| | | fileList.value = row.commonFiles; |
| | | } |
| | | if(type === "verifying"){ |
| | | form.value.valid = row.valid; |
| | | form.value.recordDate = row.mostDate; |
| | | } |
| | | |
| | | form.value.id = row.id; |
| | | form.value.code = row.code; |
| | |
| | | } |
| | | } |
| | | |
| | | // 处理有效日期输入,只允许正整数 |
| | | const handleValidInput = (value) => { |
| | | if (value === '' || value === null || value === undefined) { |
| | | form.value.valid = ''; |
| | | return; |
| | | } |
| | | // 转换为字符串并移除所有非数字字符(包括负号、小数点等) |
| | | const numStr = String(value).replace(/[^0-9]/g, ''); |
| | | if (numStr === '') { |
| | | form.value.valid = ''; |
| | | return; |
| | | } |
| | | const numValue = parseInt(numStr, 10); |
| | | // 确保是正整数(大于0) |
| | | if (numValue > 0 && !isNaN(numValue)) { |
| | | form.value.valid = numValue; |
| | | } else { |
| | | form.value.valid = ''; |
| | | } |
| | | } |
| | | |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | |
| | | dialogFormVisible.value = false; |
| | | emit('close') |
| | | }; |
| | | // 获取当前日期并格式化为 YYYY-MM-DD |
| | | function getCurrentDate() { |
| | | const today = new Date(); |
| | | const year = today.getFullYear(); |
| | | const month = String(today.getMonth() + 1).padStart(2, "0"); // 月份从0开始 |
| | | const day = String(today.getDate()).padStart(2, "0"); |
| | | return `${year}-${month}-${day}`; |
| | | } |
| | | defineExpose({ |
| | | openDialog, |
| | | }); |