| | |
| | | <script setup lang="ts"> |
| | | import { UploadFilled } from "@element-plus/icons-vue"; |
| | | import { genFileId } from "element-plus"; |
| | | import type { FormInstance, UploadProps, UploadRawFile } from "element-plus"; |
| | | import type { FormInstance, UploadProps, UploadRawFile, UploadUserFile } from "element-plus"; |
| | | import SoftwareApi from "@/api/software"; |
| | | |
| | | const props = defineProps(["data"]); |
| | | const emit = defineEmits(["update:close", "success"]); |
| | | |
| | | const paramsRef = ref({ |
| | | id: "", |
| | | snCode: "", |
| | | serialNumber: "", |
| | | materialCode: "", |
| | | description: "", |
| | | }); |
| | | const rulesRef = ref({ |
| | | snCode: [{ required: true, message: "请输入SN码", trigger: "blur" }], |
| | | serialNumber: [{ required: true, message: "请输入序列号", trigger: "blur" }], |
| | | materialCode: [{ required: true, message: "请输入物料编码", trigger: "blur" }], |
| | | snCode: [ |
| | | { required: true, message: "请输入SN码", trigger: "blur" }, |
| | | { |
| | | validator: (rule: any, value: any, callback: Function) => { |
| | | if (value !== props.data.snCode) { |
| | | callback(new Error("SN码与当前包SN码不匹配!!!")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }, |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | serialNumber: [ |
| | | { required: true, message: "请输入序列号", trigger: "blur" }, |
| | | { |
| | | validator: (rule: any, value: any, callback: Function) => { |
| | | if (value !== props.data.serialNumber) { |
| | | callback(new Error("序列号与当前包序列号不匹配!!!")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }, |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | description: [{ required: true, message: "请输入版本更新内容", trigger: "blur" }], |
| | | }); |
| | | const layout = reactive({ |
| | | gutter: 16, |
| | |
| | | } |
| | | |
| | | function uploadFile() { |
| | | const params = getParams(); |
| | | SoftwareApi.uploadSoftware(params) |
| | | SoftwareApi.uploadSoftware(paramsRef.value.id, paramsRef.value.description, fileList.value[0].raw) |
| | | .then((result) => { |
| | | const { code } = result; |
| | | if (code === 1) { |
| | |
| | | .finally(() => {}); |
| | | } |
| | | |
| | | function getParams(): FormData { |
| | | const formData = new FormData(); |
| | | formData.append("file", fileList.value[0].raw); |
| | | formData.append("softwareStr", JSON.stringify(paramsRef.value)); |
| | | return formData; |
| | | } |
| | | |
| | | function close() { |
| | | emit("update:close", false); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | paramsRef.value.id = props.data.id; |
| | | paramsRef.value.description = props.data.description; |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | label-width="auto" |
| | | > |
| | | <el-row :gutter="layout.gutter"> |
| | | <el-col :span="layout.span"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="序列号" prop="serialNumber"> |
| | | <el-input v-model="paramsRef.serialNumber"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="SN码" prop="snCode"> |
| | | <el-input v-model="paramsRef.snCode"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="layout.span"> |
| | | <el-form-item label="物料编码" prop="materialCode"> |
| | | <el-input v-model="paramsRef.materialCode"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="layout.span"> |
| | | <el-form-item label="序列号" prop="serialNumber"> |
| | | <el-input v-model="paramsRef.serialNumber"></el-input> |
| | | <el-form-item label="版本更新内容" prop="description"> |
| | | <el-input |
| | | v-model="paramsRef.description" |
| | | type="textarea" |
| | | :autosize="{ minRows: 4, maxRows: 10 }" |
| | | ></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | |
| | | |
| | | <style scoped lang="scss"> |
| | | .dialog-wrapper { |
| | | width: 580px; |
| | | width: 620px; |
| | | .from-footer { |
| | | text-align: right; |
| | | } |