Order-history.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <el-dialog v-model="state.dialogVisible" draggable title="历史工单" ref="dialogRef" width="60%" append-to-body>
  3. <el-form :model="state.queryParams" ref="ruleFormRef" inline @submit.native.prevent>
  4. <el-form-item label="关键词" prop="Keyword">
  5. <el-input v-model="state.queryParams.Keyword" placeholder="工单标题/工单编码" clearable @keyup.enter="handleQuery" />
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  9. <el-button @click="resetQuery(ruleFormRef)" class="default-button"> <SvgIcon name="ele-Refresh" class="mr5" />重置 </el-button>
  10. </el-form-item>
  11. </el-form>
  12. <el-table :data="state.tableData" @selection-change="handleSelectionChange" max-height="500" ref="multipleTableRef" row-key="id">
  13. <el-table-column type="selection" label="请选择" width="80" :reserve-selection="true" />
  14. <el-table-column prop="phoneNo" label="工单标题" show-overflow-tooltip>
  15. <template #default="{ row }">
  16. <span class="color-primary">{{ row.title }}</span>
  17. </template>
  18. </el-table-column>
  19. <el-table-column prop="hotspotName" label="热点分类" show-overflow-tooltip> </el-table-column>
  20. <el-table-column prop="no" label="工单编码" show-overflow-tooltip> </el-table-column>
  21. <el-table-column prop="actualHandleStepName" label="当前环节" show-overflow-tooltip></el-table-column>
  22. <el-table-column prop="statusText" label="状态" width="100" fixed="right" align="center"></el-table-column>
  23. <template #empty>
  24. <Empty />
  25. </template>
  26. </el-table>
  27. <pagination
  28. @pagination="queryList"
  29. :total="state.total"
  30. v-model:current-page="state.queryParams.PageIndex"
  31. v-model:page-size="state.queryParams.PageSize"
  32. />
  33. <template #footer>
  34. <span class="dialog-footer">
  35. <el-button class="default-button" @click="state.dialogVisible = false">取 消</el-button>
  36. <el-button type="primary" @click="selectConfirm" :disabled="!multipleSelection.length">确 定</el-button>
  37. </span>
  38. </template>
  39. </el-dialog>
  40. </template>
  41. <script setup lang="ts" name="orderHistory">
  42. import { reactive, ref, defineAsyncComponent } from 'vue';
  43. import type { FormInstance } from 'element-plus';
  44. import { historyOrder } from '@/api/business/order';
  45. import { useRoute } from 'vue-router';
  46. const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
  47. // 引入组件
  48. const emit = defineEmits(['saveSelect']);
  49. // 定义变量内容
  50. const state = reactive<any>({
  51. dialogVisible: false, // 弹窗显示隐藏
  52. queryParams: {
  53. PageIndex: 1, // 当前页
  54. PageSize: 10, // 每页条数
  55. Keyword: null, // 关键字
  56. },
  57. tableData: [], // 表格数据
  58. total: 0, // 总条数
  59. loading: false, // 加载状态
  60. ruleForm: {}, // 表单数据
  61. });
  62. const ruleFormRef = ref<RefType>(); // 表单ref
  63. const route = useRoute(); // 路由
  64. const multipleSelection = ref<any[]>([]); // 选中的数据
  65. const multipleTableRef = ref<RefType>(); // 表格ref
  66. // 打开弹窗
  67. const openDialog = (row: any) => {
  68. state.ruleForm = row;
  69. queryList();
  70. state.dialogVisible = true;
  71. };
  72. const dialogRef = ref<RefType>();
  73. // 关闭弹窗
  74. const closeDialog = () => {
  75. state.dialogVisible = false;
  76. };
  77. /** 搜索按钮操作 */
  78. const handleQuery = () => {
  79. state.queryParams.PageIndex = 1;
  80. queryList();
  81. };
  82. /** 重置按钮操作 */
  83. const resetQuery = (formEl: FormInstance | undefined) => {
  84. if (!formEl) return;
  85. formEl.resetFields();
  86. handleQuery();
  87. };
  88. /** 获取历史工单 */
  89. const queryList = () => {
  90. if (!state.ruleForm.contact) return;
  91. state.loading = true;
  92. let request = {
  93. ...state.queryParams,
  94. PhoneNo: state.ruleForm.contact,
  95. OrderId: route.query.id ?? '', //传入id 排除重复工单选择自己
  96. };
  97. historyOrder(request)
  98. .then((response: any) => {
  99. state.tableData = response?.result.items ?? [];
  100. multipleTableRef.value!.clearSelection();
  101. if (state.ruleForm.duplicateIds && state.ruleForm.duplicateIds.length) {
  102. for (let i of state.ruleForm.duplicateIds) {
  103. for (let j of state.tableData) {
  104. if (i === j.id) {
  105. setTimeout(() => {
  106. multipleTableRef.value!.toggleRowSelection(j, true);
  107. multipleSelection.value.push(j);
  108. }, 0);
  109. }
  110. }
  111. }
  112. } else {
  113. multipleSelection.value = [];
  114. multipleTableRef.value!.clearSelection();
  115. }
  116. state.total = response?.result.total;
  117. state.loading = false;
  118. })
  119. .catch(() => {
  120. state.loading = false;
  121. });
  122. };
  123. // 选择重复件
  124. const handleSelectionChange = (row: any) => {
  125. if (row) {
  126. multipleSelection.value = row;
  127. }
  128. };
  129. // 确定选择历史工单
  130. const selectConfirm = () => {
  131. emit('saveSelect', multipleSelection.value);
  132. };
  133. // 暴露变量
  134. defineExpose({
  135. openDialog,
  136. closeDialog,
  137. });
  138. </script>