Browse Source

退款申请

lxf 2 years ago
parent
commit
48e23a71b5
2 changed files with 167 additions and 176 deletions
  1. 3 3
      src/components/process/PurchasePayment.vue
  2. 164 173
      src/components/process/PurchaseRefund.vue

+ 3 - 3
src/components/process/PurchasePayment.vue

@@ -26,7 +26,7 @@
       </template>
       <template #payDetailList>
         <div style="width: 100%">
-          <el-button type="primary" @click="clickAdd">添加行</el-button>
+          <el-button type="primary" @click="clickAdd()">添加行</el-button>
           <el-table :data="formData.data.payDetailList" style="width: 100%; margin-top: 16px">
             <el-table-column label="采购合同" width="220">
               <template #default="{ row, $index }">
@@ -82,7 +82,7 @@
 
 <script setup>
 import byForm from "@/components/byForm/index";
-import { ElMessage, ElMessageBox } from "element-plus";
+import { ElMessage } from "element-plus";
 import useUserStore from "@/store/modules/user";
 
 const { proxy } = getCurrentInstance();
@@ -369,7 +369,7 @@ const changeMoney = () => {
   formData.data.amount = money;
 };
 const handleSubmit = async () => {
-  let status = submit.value.handleSubmit(() => {});
+  let status = await submit.value.handleSubmit(() => {});
   if (status) {
     if (formData.data.payDetailList && formData.data.payDetailList.length > 0) {
       if (fileList.value && fileList.value.length > 0) {

+ 164 - 173
src/components/process/PurchaseRefund.vue

@@ -1,25 +1,78 @@
 <template>
   <div style="width: 100%; padding: 0px 15px">
-    <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit"></byForm>
+    <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+      <template #refundDetailList>
+        <div style="width: 100%">
+          <el-button type="primary" @click="clickAdd()">添加行</el-button>
+          <el-table :data="formData.data.refundDetailList" style="width: 100%; margin-top: 16px">
+            <el-table-column label="退货单号" width="220">
+              <template #default="{ row, $index }">
+                <div style="width: 100%">
+                  <el-form-item :prop="'refundDetailList.' + $index + '.salesReturnId'" :rules="rules.salesReturnId" :inline-message="true">
+                    <el-select v-model="row.salesReturnId" placeholder="请选择退货单号" style="width: 100%" @change="changePurchaseId(row)">
+                      <el-option v-for="item in returnGoods" :key="item.value" :label="item.label" :value="item.value" />
+                    </el-select>
+                  </el-form-item>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column prop="createTime" label="退货时间" width="160" />
+            <el-table-column label="退款金额" width="180">
+              <template #default="{ row, $index }">
+                <div style="width: 100%">
+                  <el-form-item :prop="'refundDetailList.' + $index + '.money'" :rules="rules.money" :inline-message="true">
+                    <el-input-number
+                      v-model="row.money"
+                      placeholder="请输入金额"
+                      style="width: 100%"
+                      :precision="2"
+                      :controls="false"
+                      :min="0"
+                      :disabled="row.id"
+                      @change="changeMoney()" />
+                  </el-form-item>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="备注">
+              <template #default="{ row, $index }">
+                <div style="width: 100%">
+                  <el-form-item :prop="'refundDetailList.' + $index + '.remark'" :rules="rules.remark" :inline-message="true">
+                    <el-input v-model="row.remark" placeholder="请输入款项说明" style="width: 100%" />
+                  </el-form-item>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="操作" width="80">
+              <template #default="{ row, $index }">
+                <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+          <br />
+        </div>
+      </template>
+    </byForm>
   </div>
 </template>
 
 <script setup>
 import byForm from "@/components/byForm/index";
-import { ElMessage, ElMessageBox } from "element-plus";
-import SelectGoods from "@/components/product/SelectGoods";
 import useUserStore from "@/store/modules/user";
+import moment from "moment";
+import { ElMessage } from "element-plus";
 
 const { proxy } = getCurrentInstance();
 const supplierList = ref([]);
+const returnGoods = ref([]);
 let formData = reactive({
   data: {
     supplyId: "",
-    deptName: "",
-    refundName: "",
+    deptName: useUserStore().user.dept.deptName,
+    refundName: useUserStore().user.dept.userName,
     amount: "",
     remark: "",
-    refundTime: "",
+    refundTime: moment().format("yyyy-MM-DD HH:mm:ss"),
     refundDetailList: [],
   },
 });
@@ -33,6 +86,36 @@ const formOption = reactive({
 const formConfig = computed(() => {
   return [
     {
+      label: "基础信息",
+    },
+    {
+      type: "input",
+      prop: "deptName",
+      label: "申请部门",
+      required: true,
+      itemType: "text",
+      disabled: true,
+      itemWidth: 25,
+    },
+    {
+      type: "input",
+      prop: "refundName",
+      label: "申请人",
+      required: true,
+      itemType: "text",
+      disabled: true,
+      itemWidth: 25,
+    },
+    {
+      type: "input",
+      prop: "refundTime",
+      label: "申请时间",
+      required: true,
+      itemType: "text",
+      disabled: true,
+      itemWidth: 25,
+    },
+    {
       type: "select",
       label: "供应商",
       prop: "supplyId",
@@ -40,57 +123,35 @@ const formConfig = computed(() => {
       fn: (val) => {
         changeSupply(val);
       },
-      disabled: formData.data.id,
     },
     {
-      type: "select",
-      label: "发票类型",
-      prop: "type",
-      data: invoiceType.value,
+      type: "input",
+      prop: "remark",
+      label: "退款原因",
+      itemType: "textarea",
     },
     {
       type: "slot",
-      prop: "money",
-      slotName: "money",
-      label: "开票金额",
+      prop: "refundDetailList",
+      slotName: "refundDetailList",
+      label: "关联退货",
     },
     {
-      type: "slot",
-      prop: "file",
-      slotName: "file",
-      label: "上传附件",
-    },
-    {
-      type: "slot",
-      prop: "information",
-      slotName: "information",
-      label: "发票信息",
+      type: "input",
+      prop: "amount",
+      label: "应退款金额",
+      required: true,
+      itemType: "text",
+      disabled: true,
     },
   ];
 });
 let rules = ref({
   supplyId: [{ required: true, message: "请选择供应商", trigger: "change" }],
-  count: [{ required: true, message: "请输入退货数量", trigger: "blur" }],
-  remark: [{ required: true, message: "请输入退货原因", trigger: "blur" }],
+  salesReturnId: [{ required: true, message: "请选择退货单号", trigger: "change" }],
+  money: [{ required: true, message: "请输入退款金额", trigger: "blur" }],
 });
 const getDict = () => {
-  //   proxy
-  //     .post("/dictTenantData/page", {
-  //       pageNum: 1,
-  //       pageSize: 999,
-  //       dictCode: "invoice_type",
-  //       tenantId: useUserStore().user.tenantId,
-  //     })
-  //     .then((res) => {
-  //       if (res.rows && res.rows.length > 0) {
-  //         invoiceType.value = res.rows.map((item) => {
-  //           return {
-  //             label: item.dictValue,
-  //             value: item.dictKey,
-  //           };
-  //         });
-  //       }
-  //     });
   proxy.post("/supplierInfo/page", { pageNum: 1, pageSize: 999 }).then((res) => {
     if (res.rows && res.rows.length > 0) {
       supplierList.value = res.rows.map((item) => {
@@ -103,135 +164,65 @@ const getDict = () => {
   });
 };
 getDict();
-//   const formOption = reactive({
-//     inline: true,
-//     labelWidth: 100,
-//     itemWidth: 100,
-//   });
-//   const formConfig = computed(() => {
-//     return [
-//       {
-//         type: "input",
-//         prop: "returnDept",
-//         label: "申请部门",
-//         itemWidth: 25,
-//         disabled: true,
-//         style: {
-//           "margin-right": "10px",
-//         },
-//       },
-//       {
-//         type: "input",
-//         prop: "returnName",
-//         label: "申请人",
-//         itemWidth: 25,
-//         disabled: true,
-//         style: {
-//           "margin-right": "10px",
-//         },
-//       },
-//       {
-//         type: "date",
-//         prop: "purchaseTime",
-//         label: "申请时间",
-//         itemWidth: 25,
-//         disabled: true,
-//         style: {
-//           "margin-right": "10px",
-//         },
-//       },
-//       {
-//         type: "select",
-//         prop: "supplyId",
-//         label: "供应商",
-//         isLoad: {
-//           url: "/supplierInfo/page",
-//           req: {
-//             pageNum: 1,
-//             pageSize: 9999,
-//           },
-//           labelKey: "name",
-//           labelVal: "id",
-//           method: "post",
-//           resUrl: "rows",
-//         },
-//       },
-//       {
-//         type: "slot",
-//         slotName: "details",
-//         label: "退货明细",
-//       },
-//     ];
-//   });
-//   const formDom = ref(null);
-//   const handleSubmit = async () => {
-//     const vaild = await formDom.value.handleSubmit(() => {}); //拿到内部表单是否验证通过
-//     if (vaild) {
-//       if (formData.data.salesReturnDetailList.length > 0) {
-//         const list = formData.data.salesReturnDetailList;
-//         for (let i = 0; i < list.length; i++) {
-//           const e = list[i];
-//           if (e.count == 0) {
-//             ElMessage({
-//               message: "退货数量不能为0!",
-//               type: "info",
-//             });
-//             return false;
-//           }
-//         }
-//         return true;
-//       }
-//       ElMessage({
-//         message: "请添加退货明细!",
-//         type: "info",
-//       });
-//       return false;
-//     }
-//   };
-//   let openProduct = ref(false);
-//   const handleRemove = (index) => {
-//     formData.data.salesReturnDetailList.splice(index, 1);
-//     return ElMessage({
-//       message: "删除成功!",
-//       type: "success",
-//     });
-//   };
-//   const pushGoods = (goods) => {
-//     const arr = goods.map((x) => ({
-//       goodType: x.goodType,
-//       productCode: x.code,
-//       productName: x.name,
-//       productSpec: x.spec,
-//       productUnit: x.unit,
-//       count: 0,
-//       bussinessId: x.id,
-//       remark: "",
-//     }));
-//     formData.data.salesReturnDetailList =
-//       formData.data.salesReturnDetailList.concat(arr);
-//     return ElMessage({
-//       message: "添加成功!",
-//       type: "success",
-//     });
-//   };
-
-//   // 接收父组件的传值
-//   const props = defineProps({
-//     queryData: String,
-//   });
-
-//   // 获取用户信息并赋默认值
-//   const userInfo = useUserStore().user;
-//   onMounted(() => {
-//     formData.data.purchaseTime = proxy.parseTime(new Date());
-//     formData.data.returnDept = userInfo.dept.deptName;
-//     formData.data.returnName = userInfo.nickName;
-//   });
-//   // 向父组件暴露
-//   defineExpose({
-//     submitData: formData.data,
-//     handleSubmit,
-//   });
+const changeSupply = (val) => {
+  if (val) {
+    proxy.get("/salesReturn/getBySupplyId", { supplyId: val }).then((res) => {
+      if (res.data && res.data.length > 0) {
+        returnGoods.value = res.data.map((item) => {
+          return {
+            value: item.id,
+            label: item.code,
+            createTime: item.createTime,
+          };
+        });
+      } else {
+        returnGoods.value = [];
+      }
+    });
+  } else {
+    returnGoods.value = [];
+  }
+};
+const clickAdd = () => {
+  if (formData.data.refundDetailList && formData.data.refundDetailList.length > 0) {
+    formData.data.refundDetailList.push({ salesReturnId: "", money: undefined, remark: "" });
+  } else {
+    formData.data.refundDetailList = [{ salesReturnId: "", money: undefined, remark: "" }];
+  }
+};
+const handleRemove = (index) => {
+  formData.data.refundDetailList.splice(index, 1);
+};
+const changeMoney = () => {
+  let money = 0;
+  for (let i = 0; i < formData.data.refundDetailList.length; i++) {
+    if (formData.data.refundDetailList[i].money) {
+      money = parseFloat(Number(money) + Number(formData.data.refundDetailList[i].money)).toFixed(2);
+    }
+  }
+  formData.data.amount = money;
+};
+const handleSubmit = async () => {
+  let status = await submit.value.handleSubmit(() => {});
+  if (status) {
+    if (formData.data.refundDetailList && formData.data.refundDetailList.length > 0) {
+      return true;
+    } else {
+      ElMessage("请添加至少一条退货信息");
+    }
+    return false;
+  }
+  return status;
+};
+// 向父组件暴露
+defineExpose({
+  submitData: formData.data,
+  handleSubmit,
+});
 </script>
 
-<style lang="scss" scoped></style>
+<style lang="scss" scoped>
+::v-deep(.el-input-number .el-input__inner) {
+  text-align: left;
+}
+</style>