|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, unref } from "vue";
|
|
|
+import { ref, unref, watch } from "vue";
|
|
|
import { ElTable } from "element-plus";
|
|
|
import { useAsync } from "/@/hooks/core/useAsync";
|
|
|
import { httpBatch } from "/@/api/purchase/orderRecord";
|
|
@@ -11,13 +11,14 @@ import {
|
|
|
cg_order_source_options,
|
|
|
cg_order_type_options
|
|
|
} from "/@/utils/status";
|
|
|
-
|
|
|
const emit = defineEmits(["selection"]);
|
|
|
const props = defineProps<{
|
|
|
supplierNo?: string;
|
|
|
companyNo?: string;
|
|
|
+ type: string;
|
|
|
}>();
|
|
|
-
|
|
|
+const searchType = ref(props.type);
|
|
|
+const placeholder = ref(setPlaceholder(searchType.value));
|
|
|
const tableRef = ref<InstanceType<typeof ElTable>>(null);
|
|
|
const sourceText = ref("");
|
|
|
|
|
@@ -43,26 +44,35 @@ function replaceTextWrapAndSpace(text = "") {
|
|
|
|
|
|
function handleEnter() {
|
|
|
const text = replaceTextWrapAndSpace(sourceText.value);
|
|
|
+ /* 统一替换字符 **/
|
|
|
+ const parserText = text
|
|
|
+ .replace(/[,。;、; .]/g, ",")
|
|
|
+ .replace(/(^,*)|(,*$)/g, "");
|
|
|
+ const cgdNoArr = parserText.split(",");
|
|
|
/* 去掉回车和空格 **/
|
|
|
- if (text.length === 0) {
|
|
|
+ if (parserText.length === 0 || cgdNoArr.length === 0) {
|
|
|
ElMessage.warning("不能解析空文本");
|
|
|
sourceText.value = text;
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- /* 统一替换字符 **/
|
|
|
- const parserText = text.replace(/[,。;、; .]/g, ",");
|
|
|
- const cgdNoArr = parserText.split(",");
|
|
|
- sourceText.value = "";
|
|
|
-
|
|
|
run(
|
|
|
- httpBatch({
|
|
|
- size: 100,
|
|
|
- cgdNoArr,
|
|
|
- companyNo: props.companyNo,
|
|
|
- supplierNo: props.supplierNo
|
|
|
- })
|
|
|
+ httpBatch(
|
|
|
+ searchType.value == "2"
|
|
|
+ ? {
|
|
|
+ size: 100,
|
|
|
+ cgdNoArr,
|
|
|
+ companyNo: props.companyNo,
|
|
|
+ supplierNo: props.supplierNo
|
|
|
+ }
|
|
|
+ : {
|
|
|
+ size: 100,
|
|
|
+ qrdNoArr: cgdNoArr,
|
|
|
+ companyNo: props.companyNo,
|
|
|
+ supplierNo: props.supplierNo
|
|
|
+ }
|
|
|
+ )
|
|
|
);
|
|
|
+ sourceText.value = "";
|
|
|
}
|
|
|
|
|
|
function onSubmit() {
|
|
@@ -76,6 +86,24 @@ function onSubmit() {
|
|
|
// }
|
|
|
emit("selection", unref(tableData));
|
|
|
}
|
|
|
+function setPlaceholder(type) {
|
|
|
+ return `输入${
|
|
|
+ type === "2" ? "采购单" : "销售单"
|
|
|
+ }编码(小于100条),系统支持的分割符为逗号(,)、句号(.)、分号(;)、顿号(、),回车后开始解析。`;
|
|
|
+}
|
|
|
+watch(
|
|
|
+ () => props.type,
|
|
|
+ type => {
|
|
|
+ searchType.value = type;
|
|
|
+ placeholder.value = setPlaceholder(type);
|
|
|
+ tableData.value = [];
|
|
|
+ loading.value = false;
|
|
|
+ sourceText.value = "";
|
|
|
+ },
|
|
|
+ {
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+);
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -83,7 +111,7 @@ function onSubmit() {
|
|
|
:rows="4"
|
|
|
v-model="sourceText"
|
|
|
style="margin-bottom: 10px"
|
|
|
- placeholder="输入采购单编码(小于100条),系统支持的分割符为逗号(,)、句号(.)、分号(;)、顿号(、),回车后开始解析。"
|
|
|
+ :placeholder="placeholder"
|
|
|
type="textarea"
|
|
|
@keydown.enter="handleEnter"
|
|
|
/>
|