pushTask.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="dataShare-pushTask-container layout-pd">
  3. <el-card shadow="never">
  4. <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
  5. <el-form-item label="ID" prop="Id">
  6. <el-input v-model="state.queryParams.Id" placeholder="查询ID" clearable @keyup.enter="handleQuery" />
  7. </el-form-item>
  8. <!-- <el-form-item label="关键词" prop="Keyword">
  9. <el-input v-model="state.queryParams.Keyword" placeholder="关键词" clearable @keyup.enter="handleQuery" />
  10. </el-form-item>-->
  11. <el-form-item label="是否成功" prop="IsSuccess">
  12. <el-select v-model="state.queryParams.IsSuccess" placeholder="请选择是否成功" @change="handleQuery" clearable>
  13. <el-option label="成功" value="true" />
  14. <el-option label="失败" value="false" />
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="时间段" prop="crTime">
  18. <el-date-picker
  19. v-model="state.queryParams.crTime"
  20. type="daterange"
  21. unlink-panels
  22. range-separator="至"
  23. start-placeholder="开始时间"
  24. end-placeholder="结束时间"
  25. :shortcuts="shortcuts"
  26. @change="handleQuery"
  27. value-format="YYYY-MM-DD"
  28. :clearable="false"
  29. />
  30. </el-form-item>
  31. <el-form-item label-width="0">
  32. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  33. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  34. <SvgIcon name="ele-Refresh" class="mr5" />重置
  35. </el-button>
  36. </el-form-item>
  37. </el-form>
  38. </el-card>
  39. <el-card shadow="never">
  40. <ProTable
  41. ref="proTableRef"
  42. :columns="columns"
  43. :data="state.tableData"
  44. @updateTable="queryList"
  45. :loading="state.loading"
  46. :total="state.total"
  47. v-model:page-index="state.queryParams.PageIndex"
  48. v-model:page-size="state.queryParams.PageSize"
  49. border
  50. >
  51. <template #operation="{ row }">
  52. <el-button link type="primary" @click="onDetail(row)" title="查看任务明细"> 任务明细 </el-button>
  53. <el-button link type="primary" @click="onRePush(row)" title="重新推送"> 重推 </el-button>
  54. <el-button link type="primary" @click="onPushed(row)" title="修改状态为已推送"> 已推送 </el-button>
  55. </template>
  56. </ProTable>
  57. </el-card>
  58. </div>
  59. </template>
  60. <script setup lang="tsx" name="dataSharePushTask">
  61. import { onMounted, reactive, ref } from 'vue';
  62. import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
  63. import { defaultDate, shortcuts } from "@/utils/constants";
  64. import { getPushTaskList, rePush, taskPushed } from "@/api/dataShare";
  65. import { formatDate } from '@/utils/formatTime';
  66. import { useRouter } from 'vue-router';
  67. import other from "@/utils/other";
  68. const proTableRef = ref<RefType>(); // 表格ref
  69. // 表格配置项
  70. const columns = ref<any[]>([
  71. // { prop: 'id', label: 'ID', align: 'center',minWidth: 210 },
  72. { prop: 'provinceNo', label: '省工单编码', align: 'center',minWidth: 200 },
  73. {
  74. prop: 'firstTime',
  75. label: '初次推送时间',
  76. align: 'center',
  77. width: 170,
  78. render: (scope) => {
  79. return <span>{formatDate(scope.row.firstTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  80. },
  81. },
  82. {
  83. prop: 'lastTime',
  84. label: '最近一次推送时间',
  85. align: 'center',
  86. width: 170,
  87. render: (scope) => {
  88. return <span>{formatDate(scope.row.lastTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  89. },
  90. },
  91. {
  92. prop: 'sendTimes',
  93. label: '推送次数',
  94. align: 'center',
  95. },
  96. {
  97. prop: 'isSuccess',
  98. label: '推送状态',
  99. align: 'center',
  100. render: (scope) => {
  101. return <span>{scope.row.isSuccess ? '成功' : '失败'}</span>;
  102. },
  103. },
  104. {
  105. prop: 'platformSourceText',
  106. label: '平台名称',
  107. align: 'center',
  108. },
  109. { prop: 'pathText', label: '任务类型', align: 'center' },
  110. { prop: 'request', label: '请求参数', align: 'center' },
  111. {
  112. prop: 'generationTime',
  113. label: '生成时间',
  114. align: 'center',
  115. width: 170,
  116. render: (scope) => {
  117. return <span>{formatDate(scope.row.generationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  118. },
  119. },
  120. {
  121. prop: 'creationTime',
  122. label: '创建时间',
  123. align: 'center',
  124. width: 170,
  125. render: (scope) => {
  126. return <span>{formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  127. },
  128. },
  129. { prop: 'operation', label: '操作', fixed: 'right', width: 210, align: 'center' },
  130. ]);
  131. // 定义变量内容
  132. const ruleFormRef = ref<RefType>(); // 表单ref
  133. const state = reactive<any>({
  134. queryParams: {
  135. // 查询条件
  136. PageIndex: 1,
  137. PageSize: 10,
  138. Id: null, //
  139. Keyword: null,
  140. IsSuccess: null,
  141. crTime: defaultDate,
  142. StartTime:null,
  143. EndTime:null
  144. },
  145. tableData: [], //表单
  146. loading: false, // 加载
  147. total: 0, // 总数
  148. });
  149. /** 搜索按钮操作 */
  150. const handleQuery = () => {
  151. state.queryParams.PageIndex = 1;
  152. queryList();
  153. };
  154. /** 获取列表 */
  155. const queryList = () => {
  156. state.loading = true;
  157. let request = other.deepClone(state.queryParams);
  158. request.StartTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0];
  159. request.EndTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
  160. Reflect.deleteProperty(request, 'crTime');
  161. getPushTaskList(request)
  162. .then((res: any) => {
  163. state.tableData = res.result?.items ?? [];
  164. state.total = res.result?.total ?? 0;
  165. state.loading = false;
  166. })
  167. .catch(() => {
  168. state.loading = false;
  169. });
  170. };
  171. /** 重置按钮操作 */
  172. const resetQuery = (formEl: FormInstance | undefined) => {
  173. if (!formEl) return;
  174. formEl.resetFields();
  175. queryList();
  176. };
  177. // 查看任务明细
  178. const router = useRouter();
  179. const onDetail = (row: any) => {
  180. router.push({
  181. name: 'dataShareTaskDetail',
  182. query: {
  183. IsSuccess: state.queryParams.IsSuccess,
  184. id: row.id,
  185. },
  186. });
  187. };
  188. // 重推
  189. const onRePush = (row: any) => {
  190. ElMessageBox.confirm(`确定重新推送省工单编码为【${row.provinceNo}】吗?`, '提示', {
  191. confirmButtonText: '确定',
  192. cancelButtonText: '取消',
  193. type: 'warning',
  194. draggable: true,
  195. })
  196. .then(() => {
  197. rePush({ id: row.id })
  198. .then(() => {
  199. ElMessage({
  200. message: '操作成功',
  201. type: 'success',
  202. });
  203. queryList();
  204. })
  205. .catch(() => {});
  206. })
  207. .catch(() => {});
  208. };
  209. // 改状态为已推送
  210. const onPushed = (row: any) => {
  211. ElMessageBox.confirm(`确定将省工单编码为【${row.provinceNo}】的任务状态修改为已推送吗?`, '提示', {
  212. confirmButtonText: '确定',
  213. cancelButtonText: '取消',
  214. type: 'warning',
  215. draggable: true,
  216. })
  217. .then(() => {
  218. taskPushed({id:row.id})
  219. .then(() => {
  220. ElMessage({
  221. message: '操作成功',
  222. type: 'success',
  223. });
  224. queryList();
  225. })
  226. .catch(() => {});
  227. })
  228. .catch(() => {});
  229. };
  230. onMounted(() => {
  231. queryList();
  232. });
  233. </script>