Преглед на файлове

feat:收款条件功能

liujt преди 1 ден
родител
ревизия
5f96ea1e51

+ 42 - 24
src/api/rulesManagement/receiveTerms/index.js

@@ -1,37 +1,55 @@
 import request from '@/utils/request';
 
 // 获取收款条件列表
-export function getTableList(data) {
-  return request({
-    url: '/api/receiveTerms/list',
-    method: 'post',
-    data
-  });
+export async function getTableList(data) {
+  const res = await request.post(`/main/paymentConditionRules/page`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取收款条件详情
+export async function getInfo(id) {
+  const res = await request.get(`/main/paymentConditionRules/getById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 
 // 新增收款条件
-export function addReceiveTerms(data) {
-  return request({
-    url: '/api/receiveTerms',
-    method: 'post',
-    data
-  });
+export async function addReceiveTerms(data) {
+  const res = await request.post(`/main/paymentConditionRules/save`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 
 // 修改收款条件
-export function updateReceiveTerms(data) {
-  return request({
-    url: '/api/receiveTerms',
-    method: 'put',
-    data
-  });
+export async function updateReceiveTerms(data) {
+  const res = await request.put(`/main/paymentConditionRules/update`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 启用停用
+export async function updateRuleState(data) {
+  const res = await request.put(`/main/paymentConditionRules/updateRuleState`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 
 // 删除收款条件
-export function deleteInformation(data) {
-  return request({
-    url: '/api/receiveTerms',
-    method: 'delete',
-    data
-  });
+export async function deleteInformation(id) {
+  const res = await request.get(`/main/paymentConditionRules/delete/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }

+ 13 - 7
src/enum/dict.js

@@ -278,23 +278,23 @@ export const calcPayDateTypeOp = [
 export const calcReceiveDateTypeOp = [
   {
     label: '订单日期',
-    value: 1
+    value: '1'
   },
   {
     label: '出库日期',
-    value: 2
+    value: '2'
   },
   {
     label: '应收单日期',
-    value: 3
+    value: '3'
   },
   {
     label: '开票日期',
-    value: 4
+    value: '4'
   },
   {
     label: '对账单日期',
-    value: 5
+    value: '5'
   }
 ];
 
@@ -302,14 +302,20 @@ export const calcReceiveDateTypeOp = [
 export const payConfirmTypeOp = [
   {
     label: '交易日',
-    value: 1
+    value: '1'
   },
   {
     label: 'X天后',
-    value: 2
+    value: '2'
   }
 ];
 
+export const dateUnitOptions = [
+  { value: 'day', label: '天' },
+  { value: 'month', label: '月' },
+  { value: 'year', label: '年' }
+];
+
 //持证类型
 export const holderTypeOptions = [
   {

+ 83 - 79
src/views/rulesManagement/receiveTerms/components/addDialog.vue

@@ -19,7 +19,7 @@
       <el-form-item label="收款条件编码:" prop="code">
         <el-input
           v-model="form.code"
-          placeholder="SKTJ+年月日+3位数字"
+          placeholder="自动生成"
           :disabled="true"
         />
       </el-form-item>
@@ -35,9 +35,9 @@
       </el-form-item>
 
       <!-- 收款日计算日期 -->
-      <el-form-item label="收款日计算日期:" prop="calcDateType">
+      <el-form-item label="收款日计算日期:" prop="dateType">
         <el-select
-          v-model="form.calcDateType"
+          v-model="form.dateType"
           placeholder="请选择"
           style="width: 100%"
           :disabled="isDetail"
@@ -47,9 +47,9 @@
       </el-form-item>
 
       <!-- 收款日确定方式 -->
-      <el-form-item label="收款日确定方式:" prop="confirmType">
+      <el-form-item label="收款日确定方式:" prop="determinationMethod">
         <el-select
-          v-model="form.confirmType"
+          v-model="form.determinationMethod"
           placeholder="请选择"
           style="width: 100%"
           :disabled="isDetail"
@@ -60,9 +60,9 @@
       </el-form-item>
 
       <!-- 月数(X天后显示) -->
-      <el-form-item label="月数:" v-if="form.confirmType === 2">
+      <el-form-item label="月数:" v-if="form.determinationMethod == 2">
         <el-input-number
-          v-model="form.months"
+          v-model="form.determinationMethodMonth"
           :min="0"
           :precision="0"
           controls-position="right"
@@ -72,9 +72,9 @@
       </el-form-item>
 
       <!-- 天数(X天后显示) -->
-      <el-form-item label="天数:" v-if="form.confirmType === 2">
+      <el-form-item label="天数:" v-if="form.determinationMethod == 2">
         <el-input-number
-          v-model="form.days"
+          v-model="form.determinationMethodDay"
           :min="0"
           :precision="0"
           controls-position="right"
@@ -85,7 +85,7 @@
 
       <!-- 支付方式列表 -->
       <el-form-item
-        v-for="(item, index) in form.paymentList"
+        v-for="(item, index) in form.rulesTypePOList"
         :key="item.id"
         :label="index === 0 ? '支付方式:' : ''"
         :required="index === 0"
@@ -93,7 +93,7 @@
       >
         <div class="payment-method-row">
           <el-input-number
-            v-model="item.ratio"
+            v-model="item.percentage"
             :min="0"
             :max="100"
             :precision="0"
@@ -104,31 +104,38 @@
           />
           <span class="payment-unit">%</span>
           <el-input-number
-            v-model="item.months"
+            v-model="item.paymentSum"
             :min="0"
             :precision="0"
             controls-position="right"
             class="payment-input"
-            placeholder="月数"
+            placeholder="请输入"
             :disabled="isDetail"
           />
-          <span class="payment-unit">月</span>
+          <el-select
+            v-model="item.dateType"
+            placeholder="请选择"
+            class="payment-unit-select"
+            :disabled="isDetail"
+          >
+            <el-option v-for="opt in dateUnitOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
+          </el-select>
           <DictSelection
-            v-model="item.type"
+            v-model="item.paymentType"
             dictName="支付类型"
             placeholder="请选择"
             class="payment-select"
             :disabled="isDetail"
           />
           <el-button
-            v-if="!isDetail && index === form.paymentList.length - 1"
+            v-if="!isDetail && index === form.rulesTypePOList.length - 1"
             type="text"
             icon="el-icon-circle-plus-outline"
             class="add-payment-btn"
             @click="addPaymentRow"
           />
           <el-button
-            v-if="!isDetail && form.paymentList.length > 1 && index !== 0"
+            v-if="!isDetail && form.rulesTypePOList.length > 1 && index !== 0"
             type="text"
             icon="el-icon-remove-outline"
             class="remove-payment-btn"
@@ -164,8 +171,8 @@
 </template>
 
 <script>
-  import { addReceiveTerms, updateReceiveTerms } from '@/api/rulesManagement/receiveTerms';
-  import { calcReceiveDateTypeOp, payConfirmTypeOp } from '@/enum/dict';
+  import { addReceiveTerms, updateReceiveTerms, getInfo } from '@/api/rulesManagement/receiveTerms';
+  import { calcReceiveDateTypeOp, payConfirmTypeOp, dateUnitOptions } from '@/enum/dict';
 
   let paymentId = 0;
 
@@ -178,22 +185,25 @@
         isDetail: false,
         calcReceiveDateTypeOp,
         payConfirmTypeOp,
+        // 支付周期单位(天/月/年)
+        dateUnitOptions,
         form: {
           id: null,
           code: '',
           name: '',
-          calcDateType: null,
-          confirmType: null,
-          months: 0,
-          days: 0,
-          paymentList: [],
-          remark: ''
+          dateType: null,
+          determinationMethod: null,
+          determinationMethodMonth: 0,
+          determinationMethodDay: 0,
+          rulesTypePOList: [],
+          remark: '',
+          ruleState: 1
         },
         rules: {
-          code: [{ required: true, message: '请输入收款条件编码', trigger: 'blur' }],
+          // code: [{ required: true, message: '请输入收款条件编码', trigger: 'blur' }],
           name: [{ required: true, message: '请输入收款条件名称', trigger: 'blur' }],
-          calcDateType: [{ required: true, message: '请选择收款日计算日期', trigger: 'change' }],
-          confirmType: [{ required: true, message: '请选择收款日确定方式', trigger: 'change' }]
+          dateType: [{ required: true, message: '请选择收款日计算日期', trigger: 'change' }],
+          determinationMethod: [{ required: true, message: '请选择收款日确定方式', trigger: 'change' }]
         }
       };
     },
@@ -213,96 +223,84 @@
         this.isUpdate = type === 'edit';
         this.isDetail = type === 'detail';
         if ((this.isUpdate || this.isDetail) && row) {
-          this.form = {
-            ...row,
-            paymentList: this.parsePaymentMethod(row.paymentMethod)
-          };
-          if (!this.form.paymentList || this.form.paymentList.length === 0) {
-            this.form.paymentList = [this.createEmptyPayment()];
-          }
+          this.getDetail(row.id)
         } else {
           this.resetForm();
-          this.generateCode();
+          // this.generateCode();
         }
         this.$nextTick(() => {
           this.$refs.form && this.$refs.form.clearValidate();
         });
       },
 
+      getDetail(id) {
+        getInfo(id).then(res => {
+          console.log('getInfo res', res);
+          this.form = {
+            ...res,
+          };
+
+        })
+      },
+
       resetForm() {
         this.form = {
-          id: null,
+          // id: null,
           code: '',
           name: '',
-          calcDateType: 1,        // 默认:订单日期
-          confirmType: 1,         // 默认:交易日(隐藏月数、天数)
-          months: 0,
-          days: 0,
-          paymentList: [this.createEmptyPayment()], // 默认:100% 0月 现金
-          remark: ''
+          dateType: '1',        // 默认:订单日期
+          determinationMethod: '1',         // 默认:交易日(隐藏月数、天数)
+          determinationMethodMonth: 0,
+          determinationMethodDay: 0,
+          rulesTypePOList: [this.createEmptyPayment()], // 默认:100% 0月 现金
+          remark: '',
+          ruleState: 1
         };
       },
 
       createEmptyPayment() {
         return {
-          id: ++paymentId,
-          ratio: 100,
-          months: 0,
-          type: '现金'
+          key: ++paymentId,
+          percentage: 100,
+          paymentSum: 0,
+          dateType: 'month',
+          paymentType: 1
         };
       },
 
-      // 解析支付方式字符串为数组
-      parsePaymentMethod(methodStr) {
-        if (!methodStr) return [this.createEmptyPayment()];
-        const parts = methodStr.split(',');
-        return parts.map(part => {
-          const match = part.trim().match(/(\d+)%\s*(\d+)月\s*(.+)/);
-          if (match) {
-            return {
-              id: ++paymentId,
-              ratio: parseInt(match[1]),
-              months: parseInt(match[2]),
-              type: match[3]
-            };
-          }
-          return null;
-        }).filter(Boolean);
-      },
-
       // 收款日确定方式变化
       handleConfirmTypeChange() {
-        if (this.form.confirmType === 1) {
-          this.form.months = 0;
-          this.form.days = 0;
+        if (this.form.determinationMethod == 1) {
+          this.form.determinationMethodMonth = 0;
+          this.form.determinationMethodDay = 0;
         }
       },
 
       // 添加支付方式行
       addPaymentRow() {
-        this.form.paymentList.push(this.createEmptyPayment());
+        this.form.rulesTypePOList.push(this.createEmptyPayment());
       },
 
       // 移除支付方式行
       removePaymentRow(index) {
-        this.form.paymentList.splice(index, 1);
+        this.form.rulesTypePOList.splice(index, 1);
       },
 
       // 构建支付方式字符串
       buildPaymentMethod() {
-        return this.form.paymentList
-          .map(item => `${item.ratio}% ${item.months}月 ${item.type}`)
+        return this.form.rulesTypePOList
+          .map(item => `${item.percentage}% ${item.paymentSum}${item.dateType || 'month'} ${item.paymentType}`)
           .join(',');
       },
 
       // 构建确认方式描述
       buildConfirmDesc() {
-        if (this.form.confirmType === 1) {
+        if (this.form.determinationMethod === 1) {
           return '交易日';
         }
         const parts = [];
-        if (this.form.months > 0) parts.push(`月数:${this.form.months}`);
-        if (this.form.days > 0) parts.push(`天数:${this.form.days}`);
+        if (this.form.determinationMethodMonth > 0) parts.push(`月数:${this.form.determinationMethodMonth}`);
+        if (this.form.determinationMethodDay > 0) parts.push(`天数:${this.form.determinationMethodDay}`);
         if (parts.length === 0) return '0月0天即交易日';
         return parts.join(',');
       },
@@ -312,7 +310,7 @@
           if (!valid) return;
 
           // 校验支付方式比例总和
-          const totalRatio = this.form.paymentList.reduce((sum, item) => sum + item.ratio, 0);
+          const totalRatio = this.form.rulesTypePOList.reduce((sum, item) => sum + item.percentage, 0);
           if (totalRatio !== 100) {
             this.$message.warning('支付比例总和必须等于100%');
             return;
@@ -322,10 +320,13 @@
 
           const data = {
             ...this.form,
-            paymentMethod: this.buildPaymentMethod(),
-            confirmDesc: this.buildConfirmDesc()
+            // paymentMethod: this.buildPaymentMethod(),
+            // confirmDesc: this.buildConfirmDesc()
           };
-          delete data.paymentList;
+          // delete data.rulesTypePOList;
+
+          console.log('save data', data);
+          // return
 
           const saveOrUpdate = this.isUpdate ? updateReceiveTerms : addReceiveTerms;
           saveOrUpdate(data)
@@ -364,6 +365,9 @@
     color: #606266;
     font-size: 14px;
   }
+  .payment-unit-select {
+    width: 80px;
+  }
   .payment-select {
     width: 120px!important;
   }

+ 19 - 19
src/views/rulesManagement/receiveTerms/components/searchForm.vue

@@ -13,27 +13,27 @@
         return [
           {
             label: '关键词:',
-            value: 'searchName',
-            type: 'input',
-            placeholder: '编码、名称、型号、规格'
-          },
-          {
-            label: '下拉检索:',
-            value: 'searchType',
-            type: 'select',
-            placeholder: '请选择',
-            planList: [
-              { value: 1, label: '选项一' },
-              { value: 2, label: '选项二' },
-              { value: 3, label: '选项三' }
-            ]
-          },
-          {
-            label: '关键词:',
-            value: 'searchName2',
+            value: 'keyword',
             type: 'input',
             placeholder: '编码、名称、型号、规格'
           },
+          // {
+          //   label: '下拉检索:',
+          //   value: 'searchType',
+          //   type: 'select',
+          //   placeholder: '请选择',
+          //   planList: [
+          //     { value: 1, label: '选项一' },
+          //     { value: 2, label: '选项二' },
+          //     { value: 3, label: '选项三' }
+          //   ]
+          // },
+          // {
+          //   label: '关键词:',
+          //   value: 'searchName2',
+          //   type: 'input',
+          //   placeholder: '编码、名称、型号、规格'
+          // },
           {
             label: '创建时间:',
             value: 'createTime',
@@ -41,7 +41,7 @@
             dateType: 'daterange',
             placeholder: '',
             width: 380,
-            valueAr: ['createTimeStart', 'createTimeEnd']
+            valueAr: ['startCreateTime', 'endCreateTime']
           }
         ];
       }

+ 77 - 23
src/views/rulesManagement/receiveTerms/index.vue

@@ -30,6 +30,18 @@
             </el-button>
           </template>
 
+          <template v-slot:ruleState="{ row }">
+            <el-switch
+              v-model="row.ruleState"
+              active-color="#13ce66"
+              inactive-color="#ff4949"
+              active-value="1"
+              inactive-value="0"
+              @change="(val) => handleStatus(row, val)"
+            >
+            </el-switch>
+          </template>
+
           <!-- 操作列 -->
           <template v-slot:action="{ row }">
             <el-link
@@ -74,8 +86,10 @@
   import tabMixins from '@/mixins/tableColumnsMixin';
   import {
     getTableList,
-    deleteInformation
+    deleteInformation,
+    updateRuleState
   } from '@/api/rulesManagement/receiveTerms';
+  import { calcReceiveDateTypeOp, payConfirmTypeOp, dateUnitOptions } from '@/enum/dict';
 
   export default {
     mixins: [tabMixins],
@@ -107,7 +121,7 @@
             prop: 'code',
             label: '编码',
             align: 'center',
-            sortable: true,
+            // sortable: true,
             showOverflowTooltip: true,
             minWidth: 160
           },
@@ -119,46 +133,38 @@
             minWidth: 160
           },
           {
-            prop: 'calcDateType',
+            prop: 'dateType',
             label: '收款日计算日期',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 160,
             formatter: (row) => {
-              const map = {
-                1: '订单日期',
-                2: '出库日期',
-                3: '应收单日期',
-                4: '开票日期',
-                5: '对账单日期'
-              };
-              return map[row.calcDateType] || '';
+              return calcReceiveDateTypeOp.find(item => item.value === row.dateType)?.label || '';
             }
           },
           {
-            prop: 'paymentMethod',
+            prop: 'rulesTypePOList',
             label: '支付方式',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 140
+            minWidth: 140,
+            formatter: (row) => {
+              return this.buildPaymentMethod(row.rulesTypePOList);
+            }
           },
           {
-            prop: 'confirmType',
+            prop: 'determinationMethod',
             label: '收款日确认方式',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 140,
             formatter: (row) => {
-              const map = {
-                1: '交易日',
-                2: 'X天后'
-              };
-              return map[row.confirmType] || '';
+              return payConfirmTypeOp.find(item => item.value === row.determinationMethod)?.label || '';
             }
           },
           {
-            prop: 'confirmDesc',
-            label: '收款日确认方式描述',
+            prop: 'remark',
+            label: '备注',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 180
@@ -170,6 +176,21 @@
             showOverflowTooltip: true,
             minWidth: 120
           },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 120
+          },
+          {
+            prop: 'ruleState',
+            slot: 'ruleState',
+            label: '状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 120
+          },
           {
             columnKey: 'action',
             label: '操作',
@@ -186,12 +207,16 @@
     },
     methods: {
       /* 表格数据源 */
-      datasource({ page, limit, where, order }) {
-        return getTableList({
+      async datasource({ page, limit, where, order }) {
+
+        const res = await getTableList({
           pageNum: page,
           size: limit,
+          conditionConfigurationType: 'rules',
           ...where
         });
+        console.log('res', res);
+        return res
       },
 
       /* 刷新表格 */
@@ -215,6 +240,35 @@
           this.$message.success('删除成功!');
           this.reload();
         });
+      },
+      // 构建支付方式字符串
+      buildPaymentMethod(list) {
+        return list
+          .map(item => {
+            const unit =
+              (dateUnitOptions.find(opt => opt.value === item.dateType) || {}).label ||
+              '月';
+            return `${item.percentage}% ${item.paymentSum}${unit} ${item.paymentType}`;
+          })
+          .join(',');
+      },
+      handleStatus(row, val) {
+        console.log('row', row);
+        console.log('val', val);
+        let msg = val == 1 ? '是否启用该规则' : '是否关闭该规则';
+        this.$confirm(msg, '提示', {
+          type: 'warning'
+        })
+          .then(async () => {
+            await updateRuleState({
+              id: row.id,
+              ruleState: val
+            });
+            this.$message.success('操作成功');
+          })
+          .catch(() => {
+            row.ruleState = val == 1 ? 0 : 1;
+          });
       }
     }
   };