choose-modal.vue 6.0 KB

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