| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogFormVisible" |
| | | :title="dialogTitle" |
| | | width="70%" |
| | | @close="closeDia" |
| | | > |
| | | <el-form |
| | | :model="form" |
| | | label-width="140px" |
| | | label-position="top" |
| | | :rules="rules" |
| | | ref="formRef" |
| | | > |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="临æäº§ååç§°ï¼" prop="productName"> |
| | | <el-input |
| | | v-model="form.productName" |
| | | placeholder="请è¾å
¥äº§ååç§°" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="äº§åæ¹å·ï¼" prop="batchNumber"> |
| | | <el-input |
| | | v-model="form.batchNumber" |
| | | placeholder="请è¾å
¥äº§åæ¹å·" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ä¸´ææ¥æï¼" prop="expiryDate"> |
| | | <el-date-picker |
| | | style="width: 100%" |
| | | v-model="form.expiryDate" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="è¯·éæ©ä¸´ææ¥æ" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="åºåæ°éï¼" prop="stockQuantity"> |
| | | <el-input-number |
| | | v-model="form.stockQuantity" |
| | | :min="0" |
| | | placeholder="请è¾å
¥åºåæ°é" |
| | | style="width: 100%" |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="客æ·åç§°ï¼" prop="customerName"> |
| | | <el-input |
| | | v-model="form.customerName" |
| | | placeholder="请è¾å
¥å®¢æ·åç§°" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="èç³»çµè¯ï¼" prop="contactPhone"> |
| | | <el-input |
| | | v-model="form.contactPhone" |
| | | placeholder="请è¾å
¥èç³»çµè¯" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="é®é¢æè¿°ï¼" prop="problemDesc"> |
| | | <el-input |
| | | v-model="form.problemDesc" |
| | | placeholder="请è¾å
¥é®é¢æè¿°" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | type="textarea" |
| | | :rows="3" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30" v-if="operationType !== 'add'"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å¤ç人ï¼" prop="handlerId"> |
| | | <el-select |
| | | v-model="form.handlerId" |
| | | placeholder="è¯·éæ©å¤ç人" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.userId" |
| | | :label="item.nickName" |
| | | :value="item.userId" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å¤çæ¥æï¼" prop="handleDate"> |
| | | <el-date-picker |
| | | style="width: 100%" |
| | | v-model="form.handleDate" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="è¯·éæ©å¤çæ¥æ" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30" v-if="operationType !== 'add'"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="å¤çç»æï¼" prop="handleResult"> |
| | | <el-input |
| | | v-model="form.handleResult" |
| | | placeholder="请è¾å
¥å¤çç»æ" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | type="textarea" |
| | | :rows="3" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm" v-if="operationType !== 'view'">确认</el-button> |
| | | <el-button @click="closeDia">{{ operationType === 'view' ? 'å
³é' : 'åæ¶' }}</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, computed} from "vue"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | import { getCurrentDate } from "@/utils/index.js"; |
| | | // import {userListNoPageByTenantId} from "@/api/system/user.js"; // ææ¶æ³¨éæï¼ä½¿ç¨åæ°æ® |
| | | // import {expiryAfterSalesAdd, expiryAfterSalesUpdate} from "@/api/customerService/index.js"; // ææ¶æ³¨éæï¼ä½¿ç¨åæ°æ® |
| | | const { proxy } = getCurrentInstance() |
| | | const emit = defineEmits(['close']) |
| | | const dialogFormVisible = ref(false); |
| | | const operationType = ref('') |
| | | const userStore = useUserStore(); |
| | | |
| | | const dialogTitle = computed(() => { |
| | | switch (operationType.value) { |
| | | case 'add': |
| | | return 'æ°å¢ä¸´æå®å'; |
| | | case 'edit': |
| | | return 'ç¼è¾ä¸´æå®å'; |
| | | case 'view': |
| | | return 'æ¥ç临æå®å'; |
| | | default: |
| | | return '临æå®å管ç'; |
| | | } |
| | | }); |
| | | |
| | | const data = reactive({ |
| | | form: { |
| | | id: "", |
| | | productName: "", |
| | | batchNumber: "", |
| | | expiryDate: "", |
| | | stockQuantity: 0, |
| | | customerName: "", |
| | | contactPhone: "", |
| | | problemDesc: "", |
| | | handlerId: "", |
| | | handleDate: "", |
| | | handleResult: "", |
| | | status: 1 |
| | | }, |
| | | rules: { |
| | | productName: [{required: true, message: "请è¾å
¥äº§ååç§°", trigger: "blur"}], |
| | | batchNumber: [{required: true, message: "请è¾å
¥äº§åæ¹å·", trigger: "blur"}], |
| | | expiryDate: [{required: true, message: "è¯·éæ©ä¸´ææ¥æ", trigger: "change"}], |
| | | stockQuantity: [{required: true, message: "请è¾å
¥åºåæ°é", trigger: "blur"}], |
| | | customerName: [{required: true, message: "请è¾å
¥å®¢æ·åç§°", trigger: "blur"}], |
| | | contactPhone: [ |
| | | {required: true, message: "请è¾å
¥èç³»çµè¯", trigger: "blur"}, |
| | | {pattern: /^1[3-9]\d{9}$/, message: "请è¾å
¥æ£ç¡®çææºå·ç ", trigger: "blur"} |
| | | ], |
| | | problemDesc: [{required: true, message: "请è¾å
¥é®é¢æè¿°", trigger: "blur"}], |
| | | } |
| | | }) |
| | | const { form, rules } = toRefs(data); |
| | | const userList = ref([]) |
| | | |
| | | // æå¼å¼¹æ¡ |
| | | const openDialog = (type, row) => { |
| | | operationType.value = type; |
| | | dialogFormVisible.value = true; |
| | | |
| | | // 模æè·åç¨æ·å表 |
| | | userList.value = [ |
| | | { userId: 1, nickName: "å¼ ä¸" }, |
| | | { userId: 2, nickName: "æå" }, |
| | | { userId: 3, nickName: "çäº" }, |
| | | { userId: 4, nickName: "èµµå
" }, |
| | | { userId: 5, nickName: "åå
«" } |
| | | ]; |
| | | |
| | | if (type === 'add') { |
| | | // æ°å¢æ¶é置表å |
| | | form.value = { |
| | | id: "", |
| | | productName: "", |
| | | batchNumber: "", |
| | | expiryDate: "", |
| | | stockQuantity: 0, |
| | | customerName: "", |
| | | contactPhone: "", |
| | | problemDesc: "", |
| | | handlerId: "", |
| | | handleDate: "", |
| | | handleResult: "", |
| | | status: 1 |
| | | }; |
| | | } else { |
| | | // ç¼è¾ææ¥çæ¶å¡«å
æ°æ® |
| | | form.value = { ...row }; |
| | | if (type === 'edit' && !form.value.handlerId) { |
| | | form.value.handlerId = userStore.id; |
| | | form.value.handleDate = getCurrentDate(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | // 模ææäº¤æä½ |
| | | setTimeout(() => { |
| | | console.log("模ææäº¤çæ°æ®:", form.value); |
| | | proxy.$modal.msgSuccess(operationType.value === 'add' ? "æ°å¢æå" : "æ´æ°æå"); |
| | | closeDia(); |
| | | }, 300); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // å
³éå¼¹æ¡ |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | dialogFormVisible.value = false; |
| | | emit('close') |
| | | }; |
| | | |
| | | defineExpose({ |
| | | openDialog, |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |