search-batch-main.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <script setup lang="ts">
  2. import { reactive, ref, shallowRef, unref } from "vue";
  3. import { httpBatchOrderList } from "/@/api/InvoiceSales/invoiceApply";
  4. import { responseHandle } from "/@/utils/responseHandle";
  5. import { useNav } from "/@/layout/hooks/nav";
  6. import { ElMessage } from "element-plus";
  7. import { useColumns } from "./columns";
  8. import { useTypeOptions } from "/@/utils/status";
  9. const emit = defineEmits(["reload", "confirm"]);
  10. const { columns } = useColumns();
  11. columns.value = columns.value.slice(1);
  12. const { logout } = useNav();
  13. const loading = ref(false);
  14. const selected = ref([]);
  15. const tableRef = ref();
  16. const pagination = reactive({
  17. total: 0,
  18. pageSize: 15,
  19. currentPage: 1,
  20. background: true,
  21. pageSizes: [15, 50, 100]
  22. });
  23. const props = defineProps<{
  24. payload: object;
  25. }>();
  26. const sourceText = shallowRef("");
  27. //列表展示
  28. async function onSearch(sequenceNo = []) {
  29. loading.value = true;
  30. const { currentPage: page, pageSize: size } = pagination;
  31. const { code, data, message } = await httpBatchOrderList({
  32. ...props.payload,
  33. cxCode: sequenceNo.join(","),
  34. is_comon: "0",
  35. inv_is: "1",
  36. cat_status: "2",
  37. inv_status: "0",
  38. status: '3',
  39. page,
  40. size
  41. });
  42. responseHandle({
  43. code,
  44. message,
  45. logout,
  46. handler: () => {
  47. // const { li } = data ?? {};
  48. selected.value = data ?? [];
  49. // pagination.total = count ?? 0;
  50. sourceText.value = "";
  51. }
  52. });
  53. loading.value = false;
  54. }
  55. const $space = " ";
  56. const $wrap = "\n";
  57. const replaceTextWrapAndSpace = function (text = "") {
  58. if (!text) return "";
  59. let _text = text;
  60. const hasSpace = _text.includes($space);
  61. const hasWrap = _text.includes($wrap);
  62. if (hasSpace) _text = _text.split($space).join("");
  63. if (hasWrap) _text = _text.split($wrap).join("");
  64. return _text;
  65. };
  66. function handleEnter() {
  67. const text = replaceTextWrapAndSpace(sourceText.value);
  68. /* 去掉回车和空格 **/
  69. if (text.length === 0) {
  70. ElMessage.warning("不能解析空文本");
  71. sourceText.value = text;
  72. return;
  73. }
  74. /* 统一替换字符 **/
  75. const parserText = text.replace(/[,。;、; .]/g, ",");
  76. const sequenceNo = parserText.split(",");
  77. onSearch(sequenceNo);
  78. }
  79. function handleConfirm() {
  80. if (selected.value.length === 0) {
  81. return ElMessage.error("至少添加一个销售订单!");
  82. }
  83. //商品数量或开票金额为空
  84. const noConfirm = selected.value.filter(o => o.winv_fee === "0.00");
  85. const noInvNum = selected.value.filter(o => String(o.winv_num) === "0");
  86. if (noConfirm.length !== 0) {
  87. return ElMessage.error(`销售订单 ${noConfirm[0].sequenceNo} 开票金额为零`);
  88. }
  89. if (noInvNum.length !== 0) {
  90. return ElMessage.error(`销售订单 ${noInvNum[0].sequenceNo} 开票数量为零`);
  91. }
  92. emit("confirm", unref(selected));
  93. }
  94. </script>
  95. <template>
  96. <div relative>
  97. <ElInput
  98. :rows="4"
  99. v-model="sourceText"
  100. style="margin-bottom: 10px"
  101. placeholder="输入销售订单主编号(小于100条),系统支持的分割符为逗号(,)、句号(.)、分号(;)、顿号(、),回车后开始解析。"
  102. type="textarea"
  103. @keydown.enter="handleEnter"
  104. />
  105. <div v-loading="loading">
  106. <PureTable
  107. ref="tableRef"
  108. border
  109. align="left"
  110. row-key="id"
  111. table-layout="auto"
  112. :size="'small'"
  113. :data="selected"
  114. :columns="columns"
  115. max-height="560px"
  116. :header-cell-style="{ background: '#fafafa', color: '#606266' }"
  117. >
  118. <template #platform_type="scope">
  119. <el-tag>{{
  120. useTypeOptions.find(
  121. ({ value }) => value === scope.row.platform_type
  122. )?.label || "--"
  123. }}</el-tag>
  124. </template>
  125. </PureTable>
  126. </div>
  127. <div class="flex justify-end mt-10px">
  128. <el-button type="primary" @click="handleConfirm" size="small"
  129. >保存</el-button
  130. >
  131. </div>
  132. </div>
  133. </template>
  134. <style lang="scss" scoped>
  135. :deep(.el-pagination) {
  136. justify-content: flex-start !important;
  137. }
  138. .search {
  139. padding: 0px !important;
  140. }
  141. </style>