|
@@ -1,5 +1,5 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { computed, reactive, ref, watch, shallowRef } from "vue";
|
|
|
|
|
|
+import { computed, reactive, ref, watch, shallowRef, nextTick } from "vue";
|
|
import { cost_rules } from "./../supplyCommodityCost/config/configs";
|
|
import { cost_rules } from "./../supplyCommodityCost/config/configs";
|
|
import RemoteSelect from "/@/components/RemoteSelect";
|
|
import RemoteSelect from "/@/components/RemoteSelect";
|
|
import { useResponseHandle } from "/@/hooks";
|
|
import { useResponseHandle } from "/@/hooks";
|
|
@@ -7,6 +7,8 @@ import { useRoute } from "vue-router";
|
|
import { ElForm } from "element-plus";
|
|
import { ElForm } from "element-plus";
|
|
import { httpCatlist, httpAdd } from "/@/api/InvoiceSaleSettings/commodityCost";
|
|
import { httpCatlist, httpAdd } from "/@/api/InvoiceSaleSettings/commodityCost";
|
|
|
|
|
|
|
|
+import QueryCategory from "./query-category.vue"
|
|
|
|
+
|
|
import { type DescriptionColumn } from "/@/components/BasicDescriptions";
|
|
import { type DescriptionColumn } from "/@/components/BasicDescriptions";
|
|
|
|
|
|
const remoteSelectRef = ref<any>(null);
|
|
const remoteSelectRef = ref<any>(null);
|
|
@@ -68,40 +70,55 @@ function handleRelatedCategories() {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
-function handleSelectCategory(category) {
|
|
|
|
|
|
+function handleSelectCategory(category, isInit) {
|
|
if (!category) {
|
|
if (!category) {
|
|
formData.tax = "";
|
|
formData.tax = "";
|
|
formData.cat_name = "";
|
|
formData.cat_name = "";
|
|
return (taxs.value = []);
|
|
return (taxs.value = []);
|
|
}
|
|
}
|
|
|
|
|
|
- const { tax, cat_name } = category;
|
|
|
|
|
|
+ const { tax, label } = category;
|
|
taxs.value = [...tax, "0%"];
|
|
taxs.value = [...tax, "0%"];
|
|
- formData.cat_name = cat_name;
|
|
|
|
- formData.tax = "";
|
|
|
|
|
|
+
|
|
|
|
+ if(!isInit){
|
|
|
|
+ formData.cat_name = label;
|
|
|
|
+ formData.tax = "";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
watch(
|
|
watch(
|
|
() => props.detail,
|
|
() => props.detail,
|
|
async () => {
|
|
async () => {
|
|
- console.log(props.detail);
|
|
|
|
- if (!props.detail) return;
|
|
|
|
- const { inv_good_name, inv_cat_code, good_name, inv_tax } = props.detail;
|
|
|
|
|
|
+ if (!props.detail) return;
|
|
|
|
+ const { inv_good_name, inv_cat_code, good_name, inv_tax, cgd_inv_tax, cgd_inv_cat_code } = props.detail;
|
|
|
|
|
|
formData.inv_good_name = inv_good_name ? inv_good_name : good_name;
|
|
formData.inv_good_name = inv_good_name ? inv_good_name : good_name;
|
|
formData.tax = inv_tax ? inv_tax * 100 + "%" : "";
|
|
formData.tax = inv_tax ? inv_tax * 100 + "%" : "";
|
|
|
|
|
|
|
|
+
|
|
if (formData.inv_good_name.length > 70) {
|
|
if (formData.inv_good_name.length > 70) {
|
|
formData.inv_good_name = formData.inv_good_name.slice(0, 70);
|
|
formData.inv_good_name = formData.inv_good_name.slice(0, 70);
|
|
}
|
|
}
|
|
|
|
|
|
- if (inv_cat_code && remoteSelectRef.value) {
|
|
|
|
- const params = { cat_code: inv_cat_code };
|
|
|
|
- const result = await remoteSelectRef.value.initalData(params);
|
|
|
|
- if (!result || !Array.isArray(result)) return;
|
|
|
|
- const { tax } = result[0];
|
|
|
|
- taxs.value = tax;
|
|
|
|
- }
|
|
|
|
|
|
+ if (cgd_inv_tax) {
|
|
|
|
+ formData.tax = cgd_inv_tax;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nextTick(async () => {
|
|
|
|
+ if (inv_cat_code && remoteSelectRef.value && inv_cat_code.trim().length !== 0) {
|
|
|
|
+ const params = { cat_code: inv_cat_code };
|
|
|
|
+ const result = await remoteSelectRef.value.initalData(params);
|
|
|
|
+ if (!result || !Array.isArray(result)) return;
|
|
|
|
+ const { tax } = result[0];
|
|
|
|
+ taxs.value = [...tax, '0%','1%','3%'];
|
|
|
|
+ } else if (cgd_inv_cat_code && remoteSelectRef.value && cgd_inv_cat_code.trim().length !== 0) {
|
|
|
|
+ const params = { cat_code: cgd_inv_cat_code };
|
|
|
|
+ const result = await remoteSelectRef.value.initalData(params);
|
|
|
|
+ if (!result || !Array.isArray(result)) return;
|
|
|
|
+ const { tax } = result[0];
|
|
|
|
+ taxs.value = [...tax, '0%','1%','3%'];
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
{
|
|
{
|
|
immediate: true
|
|
immediate: true
|
|
@@ -118,7 +135,7 @@ watch(
|
|
>
|
|
>
|
|
<div flex gap="1">
|
|
<div flex gap="1">
|
|
<el-form-item label="商品类目设置" prop="cat_code" flex-1>
|
|
<el-form-item label="商品类目设置" prop="cat_code" flex-1>
|
|
- <RemoteSelect
|
|
|
|
|
|
+ <!-- <RemoteSelect
|
|
ref="remoteSelectRef"
|
|
ref="remoteSelectRef"
|
|
w-full
|
|
w-full
|
|
is-root
|
|
is-root
|
|
@@ -131,7 +148,13 @@ watch(
|
|
sub-label-prop="short_name"
|
|
sub-label-prop="short_name"
|
|
@item-change="handleSelectCategory"
|
|
@item-change="handleSelectCategory"
|
|
@inital="code => (formData.cat_code = code)"
|
|
@inital="code => (formData.cat_code = code)"
|
|
- />
|
|
|
|
|
|
+ /> -->
|
|
|
|
+
|
|
|
|
+ <QueryCategory
|
|
|
|
+ ref="remoteSelectRef"
|
|
|
|
+ v-model="formData.cat_code"
|
|
|
|
+ @change="handleSelectCategory"
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="开票商品名称" prop="inv_good_name" flex-1>
|
|
<el-form-item label="开票商品名称" prop="inv_good_name" flex-1>
|
|
<el-input
|
|
<el-input
|