choose-modal.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <script setup lang="ts">
  2. import { ref, unref, reactive } from "vue";
  3. import { ElMessage, ElTable } from "element-plus";
  4. import { columns } from "../config/_details";
  5. import { useResponseHandle } from "/@/hooks";
  6. import { httpList } from "/@/api/purchase/orderRecord";
  7. import { useCompany } from "/@/hooks/core/useCompany";
  8. import { payStatusOptions, tagOptions } from "/@/utils/status";
  9. import { SupplierQuery, DateRange } from "/@/components/BasicForm";
  10. import { orderTypeCgOptions } from "/@/utils/status";
  11. const emit = defineEmits(["choose"]);
  12. const visible = ref(false);
  13. const paymentList = ref<Array<Record<string, string>>>([]);
  14. const selects = ref<Array<Record<string, string>>>([]);
  15. const { currentCompany } = useCompany();
  16. const pagination = reactive({
  17. total: 0,
  18. size: 15,
  19. page: 1,
  20. background: true
  21. });
  22. const formData = ref<Record<string, any>>({
  23. is_comon: '0',
  24. pay_status: "0",
  25. supplierNo: "",
  26. currentValue: "",
  27. tag_id: "",
  28. timer: []
  29. });
  30. const tableRef = ref<InstanceType<typeof ElTable>>(null);
  31. const currentKey = ref("payNo");
  32. const loading = ref(false);
  33. const responseHandle = useResponseHandle();
  34. //初始化订单对账列表
  35. async function requestPaymentList() {
  36. const { size, page } = pagination;
  37. loading.value = true;
  38. const { currentValue, timer, ...otherParams } = formData.value;
  39. const { code, message, data } = await httpList({
  40. status: "2",
  41. // is_comon: "0",
  42. pay_status: "0",
  43. [currentKey.value]: currentValue,
  44. companyNo: currentCompany.value.companyNo,
  45. startTime: timer[0],
  46. endTime: timer[1],
  47. ...otherParams,
  48. page,
  49. size
  50. });
  51. responseHandle({
  52. code, message,
  53. handler: () => {
  54. pagination.total = data.count;
  55. paymentList.value = data.list;
  56. }
  57. });
  58. loading.value = false;
  59. }
  60. function handleConfirm() {
  61. const [order] = selects.value;
  62. if (!order) return ElMessage.warning("请选择一个对账单");
  63. emit("choose", unref(order.payNo));
  64. visible.value = false;
  65. }
  66. function handleSelectionChange(values) {
  67. if (values.length > 1) {
  68. const value = values.pop();
  69. tableRef.value.clearSelection();
  70. tableRef.value.toggleRowSelection(value, true);
  71. selects.value = [value];
  72. } else {
  73. selects.value = [values[0]];
  74. }
  75. }
  76. function handleSizeChange() {
  77. pagination.page = 1;
  78. requestPaymentList();
  79. }
  80. function handleSearch(_isReset?: boolean) {
  81. if (_isReset) {
  82. formData.value = {
  83. is_comon: '0',
  84. pay_status: "0",
  85. supplierNo: "",
  86. currentValue: "",
  87. tag_id: "",
  88. timer: []
  89. };
  90. }
  91. pagination.page = 1;
  92. requestPaymentList();
  93. }
  94. defineExpose({
  95. onDisplay: () => (visible.value = true)
  96. });
  97. </script>
  98. <template>
  99. <el-dialog top="10vh" :close-on-click-modal="false" v-model="visible" title="订单对账" center width="1040px"
  100. @open="() => requestPaymentList()">
  101. <el-form size="small">
  102. <el-row :gutter="8">
  103. <el-col :span="8">
  104. <el-form-item>
  105. <el-input clearable v-model="formData.currentValue" placeholder="请输入">
  106. <template #prepend>
  107. <el-select v-model="currentKey" style="width: 130px">
  108. <el-option label="对账编码" value="payNo" />
  109. </el-select>
  110. </template>
  111. </el-input>
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="8">
  115. <date-range v-model="formData.timer" />
  116. </el-col>
  117. <el-col :span="8">
  118. <supplier-query v-model="formData.supplierNo" placeholder="卖出方公司" />
  119. </el-col>
  120. <el-col :span="6">
  121. <el-form-item>
  122. <el-select w-80 v-model="formData.pay_status" placeholder="付款状态">
  123. <el-option value="0" label="未付款或部分付款" />
  124. <el-option value="1" label="未付款" />
  125. <el-option value="2" label="部分付款" />
  126. </el-select>
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="6">
  130. <el-form-item>
  131. <el-select w-80 v-model="formData.tag_id" placeholder="标签状态">
  132. <el-option v-for="tag in tagOptions" :key="tag.value" :value="tag.value" :label="tag.label" />
  133. </el-select>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="6">
  137. <el-select v-model="formData.is_comon" style="width: 155px" placeholder="业务类型">
  138. <el-option v-for="option in orderTypeCgOptions" :label="option.label" :value="option.value" />
  139. </el-select>
  140. </el-col>
  141. <el-col :span="6">
  142. <el-form-item>
  143. <el-button type="primary" @click="() => handleSearch()">搜索</el-button>
  144. <el-button @click="() => handleSearch(true)">重置</el-button>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. </el-form>
  149. <el-table border ref="tableRef" :data="paymentList" size="small" row-key="id"
  150. @selection-change="handleSelectionChange" mb-2 v-loading="loading" max-height="520px">
  151. <el-table-column type="selection" align="center" width="40" />
  152. <el-table-column v-for="(col, index) in columns" :key="index" v-bind="col" show-overflow-tooltip>
  153. <template #="{ row }">
  154. <el-tag v-if="col.prop === 'pay_status'" size="small">{{
  155. payStatusOptions.find(p => p.value === String(row.pay_status))
  156. ?.label
  157. }}</el-tag>
  158. <el-tag v-else-if="col.prop === 'is_comon'">{{
  159. orderTypeCgOptions.find(p => p.value === row.is_comon)?.label
  160. }}</el-tag>
  161. <span v-else>{{ row[col.prop] }}</span>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <div flex>
  166. <el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.size"
  167. :total="pagination.total" :page-sizes="[15, 50, 100]" layout="sizes, prev, pager, next"
  168. @current-change="requestPaymentList" @size-change="handleSizeChange" />
  169. <div w-full flex justify-end mt-2>
  170. <el-button type="primary" size="small" @click="handleConfirm">
  171. 保存
  172. </el-button>
  173. </div>
  174. </div>
  175. </el-dialog>
  176. </template>
  177. <style lang="scss" scoped>
  178. :deep(.el-table__header) {
  179. .el-checkbox {
  180. display: none;
  181. }
  182. }
  183. </style>