order-dialog.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <script setup lang="ts">
  2. import { reactive, ref, unref } from "vue";
  3. import { httpOrderList } from "/@/api/InvoiceSales/invoiceApply";
  4. import { responseHandle } from "/@/utils/responseHandle";
  5. import { useNav } from "/@/layout/hooks/nav";
  6. import { useColumns } from "./columns";
  7. import { type PaginationProps } from "@pureadmin/table";
  8. import { PageSearch, usePageSearch } from "/@/components/PageSearch";
  9. import searchFormConfig from "./../../config/search.config";
  10. import { ElMessage } from "element-plus";
  11. const { columns } = useColumns();
  12. const { logout } = useNav();
  13. const showModel = ref(false);
  14. const loading = ref(false);
  15. const dataList = ref([]);
  16. const tableRef = ref();
  17. const handleSelection = ref([]);
  18. const pagination = reactive<PaginationProps>({
  19. total: 0,
  20. pageSize: 15,
  21. currentPage: 1,
  22. background: true
  23. });
  24. const emit = defineEmits(["reload", "save-btn-click"]);
  25. let otherParams: Record<any, any> = {};
  26. const initform = {
  27. page: 1,
  28. size: 10,
  29. start: "",
  30. end: "",
  31. total_min: "",
  32. total_max: "",
  33. inv_status: "1", //部分开/未开
  34. pay_status: "",
  35. sequenceNo: "",
  36. customerNo: "",
  37. customer: "",
  38. platName: "",
  39. status: "0"
  40. };
  41. const ruleForm = ref({ ...initform });
  42. const { handleSearchClick, handleResetClick } = usePageSearch(
  43. params => {
  44. otherParams = params;
  45. onSearch();
  46. return {
  47. result: {},
  48. deleteProps: []
  49. };
  50. },
  51. () => {
  52. otherParams = {};
  53. console.log(123);
  54. onSearch();
  55. }
  56. );
  57. const handleCurrentChange = (current: number) => {
  58. ruleForm.value.page = current;
  59. onSearch();
  60. };
  61. async function show() {
  62. showModel.value = true;
  63. await onSearch();
  64. }
  65. function handleSelectionChange(val) {
  66. handleSelection.value = val;
  67. }
  68. //列表展示
  69. async function onSearch() {
  70. loading.value = true;
  71. const { code, data, message } = await httpOrderList({
  72. cat_status: "1",
  73. ...ruleForm.value,
  74. ...otherParams
  75. });
  76. responseHandle({
  77. code,
  78. message,
  79. logout,
  80. handler: () => {
  81. const { list, count } = data ?? {};
  82. dataList.value = list ?? [];
  83. pagination.total = count ?? 0;
  84. pagination.pageSize = ruleForm.value.size;
  85. pagination.currentPage = ruleForm.value.page;
  86. }
  87. });
  88. loading.value = false;
  89. }
  90. function handleConfirm() {
  91. const selectList = unref(handleSelection);
  92. if (selectList.length === 0) return ElMessage.error("至少选择一个销售订单!");
  93. //商品数量或开票金额为空
  94. const noConfirm = selectList.filter(
  95. o => o.goodNum === "0" || o.winv_fee === "0.00"
  96. );
  97. if (noConfirm.length !== 0) {
  98. return ElMessage.error(
  99. `销售单 ${noConfirm[0].SequenceNo} 开票金额或数量为空`
  100. );
  101. }
  102. emit("save-btn-click", selectList);
  103. showModel.value = false;
  104. }
  105. defineExpose({
  106. show
  107. });
  108. </script>
  109. <template>
  110. <div>
  111. <el-dialog
  112. v-model="showModel"
  113. :close-on-press-escape="false"
  114. center
  115. append-to-body
  116. destroy-on-close
  117. top="5vh"
  118. title="添加销售订单"
  119. :width="'1040px'"
  120. >
  121. <PageSearch
  122. @reset-btn-click="handleResetClick"
  123. @search-btn-click="handleSearchClick"
  124. :form-config="searchFormConfig"
  125. />
  126. <div v-loading="loading">
  127. <PureTable
  128. ref="tableRef"
  129. border
  130. align="left"
  131. row-key="id"
  132. table-layout="auto"
  133. :size="'small'"
  134. :data="dataList"
  135. :columns="columns"
  136. :pagination="pagination"
  137. :paginationSmall="true"
  138. :header-cell-style="{ background: '#fafafa', color: '#606266' }"
  139. @selection-change="handleSelectionChange"
  140. @current-change="handleCurrentChange"
  141. />
  142. </div>
  143. <el-button type="primary" @click="handleConfirm">保存</el-button>
  144. </el-dialog>
  145. </div>
  146. </template>