Browse Source

feat(销售开票类目):更新绑定类目必填项目验证

snow 2 years ago
parent
commit
8bff13875c

+ 6 - 3
src/components/ReconciliationForm/src/cpns/purchase-table.vue

@@ -1,9 +1,12 @@
 <script setup lang="ts">
 import { ref, computed } from "vue";
 import { ElMessage } from "element-plus";
-import { CG_ORDER_SOURCE_OPTIONS } from "/@/config/status";
 import PurchaseModal from "./purchase-modal.vue";
-import { cg_order_type_options } from "/@/utils/status";
+
+import {
+  cg_order_type_options,
+  cg_order_source_options
+} from "/@/utils/status";
 
 const emit = defineEmits(["push", "delete", "choose"]);
 
@@ -105,7 +108,7 @@ function handleAddPurchase() {
           <template #default="{ row }">
             <ElTag>
               {{
-                CG_ORDER_SOURCE_OPTIONS.find(t => t.value === row.cgdSource)
+                cg_order_source_options.find(t => t.value === row.cgdSource)
                   ?.label
               }}
             </ElTag>

+ 81 - 0
src/layout/components/help-modal.vue

@@ -157,6 +157,61 @@ const config_3 = {
   ]
 };
 
+const config_4 = {
+  columns: [
+    {
+      prop: "tax",
+      label: "税率"
+    },
+    {
+      prop: "discount",
+      label: "优惠政策"
+    },
+    {
+      prop: "addTaxRequired",
+      label: "增值税管理是否必填"
+    },
+    {
+      prop: "addTax",
+      label: "增值税管理"
+    },
+    {
+      prop: "invTag",
+      label: "税率标识"
+    }
+  ],
+  data: [
+    {
+      tax: "零税率",
+      discount: "有优惠政策",
+      addTaxRequired: true,
+      addTax: "免税、不征税",
+      invTag: "免税、不征税"
+    },
+    {
+      tax: "非零税率",
+      discount: "有优惠政策",
+      addTaxRequired: true,
+      addTax: "--",
+      invTag: "--"
+    },
+    {
+      tax: "零税率",
+      discount: "没有优惠政策",
+      addTaxRequired: false,
+      addTax: "--",
+      invTag: "零税率"
+    },
+    {
+      tax: "非零税率",
+      discount: "没有优惠政策",
+      addTaxRequired: false,
+      addTax: "--",
+      invTag: "--"
+    }
+  ]
+};
+
 defineExpose({
   onDisplay: () => (visible.value = true)
 });
@@ -244,6 +299,32 @@ defineExpose({
           </ElTable>
         </div>
       </ElCol>
+
+      <ElCol :span="24">
+        <h2>4.TODO</h2>
+        <div class="py-[10px] px-[20px]">
+          <ElTable size="small" :data="config_4.data" border>
+            <ElTableColumn
+              v-for="col in config_4.columns"
+              :key="col.prop"
+              :prop="col.prop"
+              :label="col.label"
+            >
+              <template #="{ row }">
+                <span v-if="typeof row[col.prop] === 'string'">{{
+                  row[col.prop]
+                }}</span>
+
+                <IconifyIconOffline
+                  v-else
+                  :style="{ color: row[col.prop] ? '#67C23A' : '#F56C6C' }"
+                  :icon="row[col.prop] ? 'success' : 'close-bold'"
+                />
+              </template>
+            </ElTableColumn>
+          </ElTable>
+        </div>
+      </ElCol>
     </ElRow>
   </ElDialog>
 </template>

+ 0 - 1
src/utils/details/_purchase/orderRecord.ts

@@ -1,7 +1,6 @@
 /**
  * 订单对账详情
  */
-
 import { h } from "vue";
 import { ElTag } from "element-plus";
 import { createTooltip } from "/@/utils/tootip";

+ 65 - 40
src/utils/details/_purchase/porder.ts

@@ -107,7 +107,7 @@ export const PAY_STATUS = [
 export const purchaseOrderNotIncludeProduceColumns: DescriptionColumns = [
   {
     label: "采购单编号",
-    field: "name",
+    field: "sequenceNo",
     span: 6
   },
   {
@@ -142,6 +142,13 @@ export const purchaseOrderNotIncludeProduceColumns: DescriptionColumns = [
     render: (supplierName, { supplierNo }) =>
       createTooltip(supplierName, "供应商编号 : " + supplierNo, 300)
   },
+  {
+    label: "商品名称",
+    field: "goodName",
+    span: 24,
+    render: (goodName, { goodNo }) =>
+      createTooltip(goodName, "商品编号 : " + goodNo, 260)
+  },
   {
     label: "对账状态",
     field: "status",
@@ -162,7 +169,7 @@ export const purchaseOrderNotIncludeProduceColumns: DescriptionColumns = [
   },
   {
     label: "商品类型",
-    field: "goodType",
+    field: "cgdType",
     render(type) {
       return h(ElTag, null, {
         default: () => cg_order_type_options.find(c => c.value == type)?.label
@@ -170,77 +177,95 @@ export const purchaseOrderNotIncludeProduceColumns: DescriptionColumns = [
     }
   },
   {
-    label: "备库编号",
-    field: "bkCode"
+    label: "发货状态",
+    field: "sendStatus",
+    render(type) {
+      return h(ElTag, null, {
+        default: () => send_status_list.find(c => c.value == type)?.label
+      });
+    }
   },
+
   {
-    label: "已付金额",
-    field: "apay_fee"
+    label: "商品数量",
+    field: "goodNum"
   },
   {
-    label: "待付金额",
-    field: "wpay_fee"
+    label: "已发货数量",
+    field: "sendNum"
   },
   {
-    label: "已回票",
-    field: "ainv_fee"
+    label: "未发货数量",
+    field: "wsendNum"
   },
   {
-    label: "未回票",
-    field: "winv_fee"
+    label: "退货数量",
+    field: "thNum"
   },
   {
-    label: "发货方式",
-    field: "sendType",
-    render(type) {
-      return h(ElTag, null, {
-        default: () => SEND_TYPE.find(c => c.value == type)?.label
-      });
-    }
+    label: "备库编号",
+    field: "bkCode"
   },
   {
     label: "备库人员",
     field: "bkCreater"
   },
+  // {
+  //   label: "发货方式",
+  //   field: "sendType",
+  //   render(sendType) {
+  //     return h(ElTag, null, {
+  //       default: () => cgd_send_type.find(c => c.value == sendType + "")?.label
+  //     });
+  //   }
+  // },
   {
-    label: "发货状态",
-    field: "sendStatus",
-    render(type) {
+    label: "核算码",
+    field: "fundCode",
+    span: 12
+  },
+  {
+    label: "分类",
+    span: 12,
+    field: "cat",
+    render(_, { firstCat, secCat, thirdCat }) {
       return h(ElTag, null, {
-        default: () => send_status_list.find(c => c.value == type)?.label
+        default: () => firstCat + "_" + secCat + "_" + thirdCat
       });
     }
   },
   {
-    label: "未发货数量",
-    field: "wsendNum"
+    label: "品牌",
+    span: 12,
+    field: "goodBrand"
   },
   {
-    label: "发货数量",
-    field: "sendNum"
+    label: "单位",
+    field: "goodUnit"
   },
+
   {
-    label: "备注",
-    field: "remark"
+    label: "税率",
+    field: "tax"
   },
   {
-    label: "工差重量",
-    field: "diff_weight"
+    label: "单价",
+    field: "goodPrice"
   },
+
   {
-    label: "工差金额",
-    field: "diff_fee"
+    label: "总价",
+    field: "totalPrice"
   },
   {
-    label: "退货数量",
-    field: "thNum"
+    label: "工艺描述",
+    span: 24,
+    field: "goodDesc"
   },
   {
-    label: "商品名称",
-    field: "goodName",
-    span: 18,
-    render: (goodName, { goodNo }) =>
-      createTooltip(goodName, "商品编号 : " + goodNo, 260)
+    label: "备注",
+    span: 24,
+    field: "remark"
   }
 ];
 

+ 3 - 3
src/utils/responsive.ts

@@ -31,9 +31,9 @@ export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
     },
     config.MultiTagsCache
       ? {
-          // 默认显示首页tag
-          tags: Storage.getData("tags", nameSpace) ?? routerArrays
-        }
+        // 默认显示首页tag
+        tags: Storage.getData("tags", nameSpace) ?? routerArrays
+      }
       : {}
   );
 

+ 19 - 42
src/utils/status.ts

@@ -20,7 +20,7 @@ const levelList = [
 ];
 
 export const checkTypeOptions = [
-  { label: "未分配查询" },
+  { value: "0", label: "未分配查询" },
   { value: "1", label: "金税接口" },
   { value: "2", label: "华为云" }
 ];
@@ -88,7 +88,7 @@ const inv_type_list = [
 ];
 
 /**
- * 销售发票类型
+ * 发票类型
  * @param scanValue 扫描枪对应的发票类型
  */
 export const invoiceTypeList = [
@@ -98,16 +98,10 @@ export const invoiceTypeList = [
   { label: "增值税电子普通发票", value: "electronic", scanValue: "10" },
   { label: "增值税电子普通发票(通行费)", value: "toll", scanValue: "" },
   { label: "增值税普通发票(卷式)", value: "roll", scanValue: "" },
-  {
-    label: "电子发票(增值税专用发票)",
-    value: "fully_digitalized_special_electronic",
-    scanValue: "31"
-  },
-  {
-    label: "电子发票(增值税普通发票)",
-    value: "fully_digitalized_normal_electronic",
-    scanValue: ""
-  }
+  // eslint-disable-next-line prettier/prettier
+  { label: "电子发票(增值税专用发票)", value: "fully_digitalized_special_electronic", scanValue: "31" },
+  // eslint-disable-next-line prettier/prettier
+  { label: "电子发票(增值税普通发票)", value: "fully_digitalized_normal_electronic", scanValue: "" }
 ];
 
 /**
@@ -119,18 +113,16 @@ export const cg_inv_type_list = [
   { label: "增值税普通发票", value: "normal", scanValue: "04" },
   { label: "增值税电子专用发票", value: "special_electronic", scanValue: "20" },
   { label: "增值税电子普通发票", value: "electronic", scanValue: "10" },
-  {
-    label: "电子发票(增值税专用发票)",
-    value: "fully_digitalized_special_electronic",
-    scanValue: "31"
-  },
-  {
-    label: "电子发票(增值税普通发票)",
-    value: "fully_digitalized_normal_electronic",
-    scanValue: ""
-  }
+  // eslint-disable-next-line prettier/prettier
+  { label: "电子发票(增值税专用发票)", value: "fully_digitalized_special_electronic", scanValue: "31" },
+  // eslint-disable-next-line prettier/prettier
+  { label: "电子发票(增值税普通发票)", value: "fully_digitalized_normal_electronic", scanValue: "" }
 ];
 
+/**
+ * 销售发票类型
+ * @param scanValue 扫描枪对应的发票类型
+ */
 export const xs_inv_type_list = [
   { label: "增值税专用发票", value: "special", scanValue: "01" },
   { label: "增值税普通发票", value: "normal", scanValue: "04" },
@@ -278,26 +270,11 @@ export const capitalClaimStatusOptions = [
 
 //资金状态
 export const capitalStatusOptions = [
-  {
-    value: "1",
-    label: "待审批"
-  },
-  {
-    value: "2",
-    label: "审批通过"
-  },
-  {
-    value: "3",
-    label: "审批驳回"
-  },
-  {
-    value: "4",
-    label: "已解除认领"
-  },
-  {
-    value: "5",
-    label: "已取消认领"
-  }
+  { value: "1", label: "待审批" },
+  { value: "2", label: "审批通过" },
+  { value: "3", label: "审批驳回" },
+  { value: "4", label: "已解除认领" },
+  { value: "5", label: "已取消认领" }
 ];
 
 export {

+ 144 - 82
src/views/InvoiceSaleSettings/basic-settings.vue

@@ -1,18 +1,18 @@
 <script setup lang="ts">
-import { ElForm } from "element-plus";
-import { computed, reactive, ref, watchEffect, nextTick, watch } from "vue";
-import { cost_rules, inv_tag, add_tax } from "./commodityCost/config/configs";
+import { computed, reactive, ref, nextTick, watch } from "vue";
+import { cost_rules, inv_tag } from "./commodityCost/config/configs";
 import RemoteSelect from "/@/components/RemoteSelect";
 import { useResponseHandle } from "/@/hooks";
 import { useRoute, useRouter } from "vue-router";
+import { ElForm } from "element-plus";
+
+import { httpCatlist, httpAdd } from "/@/api/InvoiceSaleSettings/commodityCost";
+const remoteSelectRef = ref<InstanceType<typeof RemoteSelect>>(null);
 
 import BasicDescriptions, {
   type DescriptionColumn
 } from "/@/components/BasicDescriptions";
 
-import { httpCatlist, httpAdd } from "/@/api/InvoiceSaleSettings/commodityCost";
-const remoteSelectRef = ref<InstanceType<typeof RemoteSelect>>(null);
-
 const props = defineProps<{
   title: string;
   detail: any;
@@ -22,34 +22,88 @@ const props = defineProps<{
   canChange?: boolean;
 }>();
 
-const formRef = ref<InstanceType<typeof ElForm>>(null);
-const responseHandle = useResponseHandle();
-const inv_tag_options = ref([...inv_tag]);
-const { push } = useRouter();
-const { query } = useRoute();
-const rules = reactive({ ...cost_rules });
-
-const spuCode = computed(() => query.id as string);
-const taxs = ref<Array<string>>([]);
-
-const formData = reactive({
+const initalFormData = {
   cat_code: "",
   cat_name: "",
   inv_good_name: "",
   tax: "",
-  inv_tag: "0",
-  is_discount: "0",
+  inv_tag: "",
+  is_discount: "",
   addTax: ""
+};
+
+const { push } = useRouter();
+const { query } = useRoute();
+
+const formRef = ref<InstanceType<typeof ElForm>>(null);
+const responseHandle = useResponseHandle();
+const taxs = ref<Array<string>>([]);
+const spuCode = computed(() => query.id as string);
+const formData = reactive({ ...initalFormData });
+
+const state = computed(() => ({
+  //是否包含优惠政策
+  isDiscount: formData.is_discount === "1",
+  //税率是否为0
+  isZeroTaxRate: formData.tax === "0%"
+}));
+
+//禁用字段
+const disabledField = computed(() => {
+  const { isDiscount, isZeroTaxRate } = state.value;
+  const isDisabledTaxField = !formData.cat_code;
+  return {
+    tax: isDisabledTaxField,
+    is_discount: isDisabledTaxField,
+    //非零税率没有优惠政策禁用
+    addTax: isDisabledTaxField || !isZeroTaxRate || !isDiscount,
+    //非零税率禁用 有优惠政策且零税率
+    inv_tag:
+      isDisabledTaxField || !isZeroTaxRate || (isDiscount && isZeroTaxRate)
+  };
 });
 
-function handleSave() {
+//动态验证规则
+const dynamicRules = computed(() => {
+  const { isDiscount, isZeroTaxRate } = state.value;
+  return {
+    ...cost_rules,
+    //汇率标识是否必填(零税率)
+    inv_tag: [{ ...cost_rules.inv_tag[0], required: isZeroTaxRate }],
+    //增值税管理是否必填(有优惠政策且零税率)
+    addTax: [{ ...cost_rules.addTax[0], required: isDiscount && isZeroTaxRate }]
+  };
+});
+
+const dynamicOptions = computed(() => {
+  const { isDiscount, isZeroTaxRate } = state.value;
+  let addTax = [];
+  let invTag = [];
+
+  if (isDiscount && isZeroTaxRate) {
+    invTag = addTax = [inv_tag[0], inv_tag[1]];
+  }
+
+  if (isZeroTaxRate && !isDiscount) {
+    invTag = [inv_tag[2]];
+  }
+  return {
+    addTax,
+    invTag
+  };
+});
+
+function handleRelatedCategories() {
   formRef.value.validate(async isVaild => {
     if (!isVaild) return;
 
-    const { code, message } = await httpAdd({
+    const params = {
       spuCode: spuCode.value,
       ...formData
-    });
+    };
+
+    console.log(params);
+    const { code, message } = await httpAdd(params);
 
     responseHandle({
       code,
@@ -67,38 +121,41 @@ function handleSelectCategory(category) {
   }
 
   const { tax, cat_name } = category;
-
-  console.log(tax);
-
-  taxs.value = tax;
-  formData.tax = tax[0];
+  taxs.value = [...tax];
   formData.cat_name = cat_name;
+  formData.tax = "";
+  formData.addTax = "";
+  formData.inv_tag = "";
+  formData.is_discount = "";
 }
 
-watchEffect(() => {
-  const { is_discount } = formData;
-  let tags: Array<string> = [];
+//优惠政策改变清空增值税管理和汇率标识
+const handleDiscountChange = () => {
+  formData.addTax = "";
   formData.inv_tag = "";
-  //非优惠政策 -》 税率标识可选择为3 普通零税率和0非零税率
-  if (is_discount === "0" || !is_discount) {
-    tags = ["0", "3"];
-    formData.addTax = "";
-  } else {
-    //优惠政策 => 税率标识可选择为 0/1/2
-    tags = ["0", "1", "2"];
-  }
+};
 
-  rules.addTax[0].required = is_discount === "1";
-  inv_tag_options.value = inv_tag.filter(i => tags.includes(i.value));
-});
+//税率改变清空增值税管理和汇率标识
+const handleTaxChange = () => {
+  formData.is_discount = "";
+  formData.addTax = "";
+  formData.inv_tag = "";
+};
+
+watch(
+  () => formData.addTax,
+  addTax => {
+    if (!addTax) return;
+    //零税率且有优惠政策时需要同步增值税管理和汇率标识的值
+    const { isZeroTaxRate, isDiscount } = state.value;
+    if (isZeroTaxRate && isDiscount) formData.inv_tag = formData.addTax;
+  }
+);
 
 watch(
   () => props.detail,
   () => {
     if (!props.detail) return;
-
-    console.log(props.detail);
-
     const {
       good_name,
       inv_good_name,
@@ -118,15 +175,14 @@ watch(
     }
 
     nextTick(() => {
-      formData.inv_tag = String(inv_tag);
+      formData.inv_tag = String(inv_tag) !== "0" ? String(inv_tag) : "";
       formData.addTax = addTax;
     });
 
-    if (inv_cat_code) {
-      remoteSelectRef.value &&
-        (remoteSelectRef.value as any).initalData({
-          cat_code: inv_cat_code
-        });
+    if (inv_cat_code && remoteSelectRef.value) {
+      (remoteSelectRef.value as any).initalData({
+        cat_code: inv_cat_code
+      });
     }
   }
 );
@@ -150,7 +206,7 @@ watch(
       <el-form
         label-position="left"
         ref="formRef"
-        :rules="rules"
+        :rules="dynamicRules"
         :model="formData"
         v-if="canChange"
       >
@@ -182,38 +238,13 @@ watch(
         </div>
 
         <div flex gap-3>
-          <el-form-item label="是否有优惠政策" prop="is_discount">
-            <el-select
-              w-150px
-              v-model="formData.is_discount"
-              placeholder="请选择是否包含优惠政策"
-            >
-              <el-option label="否" value="0" />
-              <el-option label="是" value="1" />
-            </el-select>
-          </el-form-item>
-
-          <el-form-item label="汇率标识" prop="inv_tag">
-            <el-select
-              w-180px
-              v-model="formData.inv_tag"
-              placeholder="请选择汇率标识"
-            >
-              <el-option
-                v-for="(tag, index) in inv_tag_options"
-                :key="index"
-                :label="tag.label"
-                :value="tag.value"
-              />
-            </el-select>
-          </el-form-item>
-
           <el-form-item label="税率" prop="tax">
             <el-select
               w-180px
               v-model="formData.tax"
-              :disabled="taxs.length === 0"
+              :disabled="disabledField.tax"
               placeholder="请输入税率"
+              @change="handleTaxChange"
             >
               <el-option
                 v-for="(t, index) in taxs"
@@ -224,26 +255,57 @@ watch(
             </el-select>
           </el-form-item>
 
+          <el-form-item label="是否有优惠政策" prop="is_discount">
+            <el-select
+              :disabled="disabledField.is_discount"
+              w-150px
+              v-model="formData.is_discount"
+              placeholder="请选择是否包含优惠政策"
+              @change="handleDiscountChange"
+            >
+              <el-option label="否" value="0" />
+              <el-option label="是" value="1" />
+            </el-select>
+          </el-form-item>
+
           <el-form-item label="增值税管理内容" prop="addTax">
             <el-select
-              w-200px
+              :disabled="disabledField.addTax"
+              w-230px
               v-model="formData.addTax"
-              :disabled="formData.is_discount === '0'"
               placeholder="请选择增值税管理税内容"
             >
               <el-option
-                v-for="(t, i) in add_tax"
+                v-for="(t, i) in dynamicOptions.addTax"
                 :key="i"
                 :label="t.label"
                 :value="t.value"
               />
             </el-select>
           </el-form-item>
+
+          <el-form-item label="汇率标识" prop="inv_tag">
+            <el-select
+              :disabled="disabledField.inv_tag"
+              w-180px
+              v-model="formData.inv_tag"
+              placeholder="请选择汇率标识"
+            >
+              <el-option
+                v-for="(tag, index) in dynamicOptions.invTag"
+                :key="index"
+                :label="tag.label"
+                :value="tag.value"
+              />
+            </el-select>
+          </el-form-item>
         </div>
       </el-form>
 
       <div flex justify-end v-if="canChange">
-        <el-button type="primary" @click="handleSave">保存</el-button>
+        <el-button type="primary" @click="handleRelatedCategories"
+          >保存</el-button
+        >
       </div>
     </div>
   </div>

+ 4 - 4
src/views/InvoiceSaleSettings/commodityCost/config/configs.ts

@@ -150,10 +150,10 @@ export const good_detail_columns = [
 ];
 
 export const inv_tag = [
-  {
-    value: "0",
-    label: "非零税率"
-  },
+  // {
+  //   value: "0",
+  //   label: "非零税率"
+  // },
   {
     value: "1",
     label: "免税"

+ 5 - 2
src/views/purchase/porder/components/purchase-modal.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { ref } from "vue";
 import BasicDescriptions from "/@/components/BasicDescriptions";
-import { purchaseOrderColumns } from "/@/utils/details/_purchase";
+import { purchaseOrderNotIncludeProduceColumns } from "/@/utils/details/_purchase";
 
 const visible = ref(false);
 const data = ref<Record<string, string>>({});
@@ -22,6 +22,9 @@ defineExpose({
     center
     @close="data = {}"
   >
-    <BasicDescriptions :columns="purchaseOrderColumns" :data="data" />
+    <BasicDescriptions
+      :columns="purchaseOrderNotIncludeProduceColumns"
+      :data="data"
+    />
   </ElDialog>
 </template>

+ 0 - 4
src/views/purchase/purchPayRelive/component/choose-form.vue

@@ -1,7 +1,6 @@
 <script setup lang="ts">
 import { ref, watch, unref } from "vue";
 import { ElForm } from "element-plus";
-// import ReconciliationForm from "/@/components/ReconciliationForm";
 import { createRules } from "../config/_rules";
 import { useAsync } from "/@/hooks/core/useAsync";
 import ChooseModal from "./choose-modal.vue";
@@ -13,9 +12,6 @@ const emit = defineEmits(["create"]);
 
 const formRef = ref<InstanceType<typeof ElForm> | null>(null);
 const chooseModalRef = ref<InstanceType<typeof ChooseModal> | null>(null);
-// const reconciliationRef = ref<InstanceType<typeof ReconciliationForm> | null>(
-//   null
-// );
 
 const { data: detail, run: runDetail } = useAsync<Record<string, string>>({
   initalData: {}

+ 5 - 2
src/views/supply/porder/components/purchase-modal.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { ref } from "vue";
 import BasicDescriptions from "/@/components/BasicDescriptions";
-import { purchaseOrderColumns } from "/@/utils/details/_purchase";
+import { purchaseOrderNotIncludeProduceColumns } from "/@/utils/details/_purchase";
 
 const visible = ref(false);
 const data = ref<Record<string, string>>({});
@@ -22,6 +22,9 @@ defineExpose({
     center
     @close="data = {}"
   >
-    <BasicDescriptions :columns="purchaseOrderColumns" :data="data" />
+    <BasicDescriptions
+      :columns="purchaseOrderNotIncludeProduceColumns"
+      :data="data"
+    />
   </ElDialog>
 </template>