TransferTask.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <Navbar title="调度任务" :is-go-back="false" />
  3. <div>
  4. <a-form :colon="false" :label-col="labelStyle">
  5. <a-row :gutter="[8, 14]" justify="space-start">
  6. <a-form-item label="任务类型" class="horizontal-form-item">
  7. <a-select
  8. v-model:value="formData.workCategory" class="w-full" :options="workTypes" allow-clear
  9. placeholder="请选择任务类型" @change="searchDatas"
  10. />
  11. </a-form-item>
  12. <a-form-item label="仓库" class="horizontal-form-item">
  13. <a-select
  14. v-model:value="formData.warehouseId" class="w-full" :options="warehouseOptions" allow-clear
  15. placeholder="请选择仓库" @change="searchDatas"
  16. />
  17. </a-form-item>
  18. <a-form-item label="起始货位编号" class="horizontal-form-item">
  19. <a-input
  20. v-model:value="formData.positionBeginNo" class="w-full" placeholder="请输入起始货位编号"
  21. @press-enter="searchDatas"
  22. />
  23. </a-form-item>
  24. <a-form-item label="终点货位编号" class="horizontal-form-item">
  25. <a-input
  26. v-model:value="formData.positionEndNo" class="w-full" placeholder="请输入起始货位编号"
  27. @press-enter="searchDatas"
  28. />
  29. </a-form-item>
  30. <a-form-item label="执行状态" class="horizontal-form-item">
  31. <a-select
  32. v-model:value="formData.executeStatus" class="w-full" :options="executeStatus" allow-clear
  33. placeholder="请选择执行状态" @change="searchDatas"
  34. />
  35. </a-form-item>
  36. <a-form-item label="AGV编号" class="horizontal-form-item">
  37. <a-input v-model:value="formData.agvNo" class="w-full" placeholder="请输入AGV编号" @press-enter="searchDatas" />
  38. </a-form-item>
  39. <a-form-item label="是否成功" class="horizontal-form-item">
  40. <a-select
  41. v-model:value="formData.success" class="w-full" :options="successTypes" allow-clear
  42. placeholder="请选择是否成功" @change="searchDatas"
  43. />
  44. </a-form-item>
  45. <a-form-item label="" class="horizontal-form-item">
  46. <a-space>
  47. <a-button danger @click="clearFilter">清空</a-button>
  48. <a-button type="primary" @click="searchDatas">查询</a-button>
  49. </a-space>
  50. </a-form-item>
  51. </a-row>
  52. </a-form>
  53. <CommonTable
  54. ref="commonTableRef" :columns="columns" :data-source="taskList" :total="totalSize" :is-select="false" :extra-height="90"
  55. @get-pager="getPageParams"
  56. >
  57. <template #bodyCell="{ column, record, index }">
  58. <template v-if="column.dataIndex === 'index'">
  59. {{ index + 1 }}
  60. </template>
  61. <template v-if="column.dataIndex === 'documentNo'">
  62. <a-button type="link" @click="openWindow(record)">{{ record.documentNo }}</a-button>
  63. </template>
  64. <template v-if="column.dataIndex === 'success'">
  65. <a-tag v-if="record.success === true" color="green">成功</a-tag>
  66. </template>
  67. <template v-if="column.dataIndex === 'operation'">
  68. <a-tag v-if="record.executeStatus === '已完成'" color="green">已完成</a-tag>
  69. <a-button v-if="record.executeStatus === '执行中'" type="link" danger @click="cancelTask(record)">取消任务</a-button>
  70. <a-button v-if="record.executeStatus === '未开始'" type="link" @click="executeTask(record)">
  71. 执行
  72. </a-button>
  73. </template>
  74. </template>
  75. </CommonTable>
  76. </div>
  77. <Loading v-if="loading" />
  78. </template>
  79. <script setup>
  80. import { ref, onMounted } from 'vue';
  81. import Common from '../common/Common';
  82. import { Uuid } from 'pc-component-v3';
  83. import { message } from 'ant-design-vue';
  84. import CommonTable from '../common/CommonTable.vue';
  85. import { taskColumns, workOptions, executeOptions, successOptions } from '../common/transferTask';
  86. const loading = ref(false);
  87. const commonTableRef = ref(null);
  88. const labelStyle = { style: { width: '90px' } };
  89. const columns = ref(taskColumns);
  90. const taskList = ref([]);
  91. const formData = ref({
  92. workCategory: null,
  93. positionBeginNo: null,
  94. positionEndNo: null,
  95. executeStatus: null,
  96. agvNo: null,
  97. success: null,
  98. warehouseId: null,
  99. });
  100. const totalSize = ref(0);
  101. const pagination = ref({
  102. start: 1,
  103. length: 20,
  104. });
  105. const workTypes = ref(workOptions);
  106. const successTypes = ref(successOptions);
  107. const executeStatus = ref(executeOptions);
  108. const warehouseOptions = ref([]);
  109. // 获取分页参数后查询
  110. const getPageParams = (page, pageSize) => {
  111. pagination.value.start = page;
  112. pagination.value.length = pageSize;
  113. getTableDatas();
  114. };
  115. // 执行任务
  116. const executeTask = record => {
  117. executeTaskById(record.schedulingTasksId);
  118. };
  119. // 执行任务
  120. const cancelTask = record => {
  121. cancelTaskById(record.schedulingTasksId);
  122. };
  123. // 打开窗口
  124. const openWindow = record => {
  125. const url = Common.getHostPageBaseURL() + `#/desktop/window1/window-read/view/${record.windowNo}/0/${record.documentId}?currPage=1&currIndex=1&totalCount=1&uuid=${Uuid.createUUID()}`;
  126. window.open(url,'_blank');
  127. };
  128. // 条件变化查询
  129. const searchDatas = () => {
  130. commonTableRef.value.backFirstPage();
  131. };
  132. // 清空条件
  133. const clearFilter = () => {
  134. formData.value = {
  135. workCategory: null,
  136. positionBeginNo: null,
  137. positionEndNo: null,
  138. executeStatus: null,
  139. agvNo: null,
  140. success: null,
  141. warehouseId: null,
  142. };
  143. searchDatas();
  144. };
  145. const getWarehouseOptions = () => {
  146. $.ajax({
  147. url: Common.getApiURL('WarehouseResource/queryUserManageWarehouse'),
  148. type: 'get',
  149. dataType: 'json',
  150. beforeSend: function (request) {
  151. Common.addTokenToRequest(request);
  152. },
  153. success: function (res) {
  154. if (res && res.length > 0) {
  155. warehouseOptions.value = res.map(item => ({
  156. label: item.name,
  157. value: item.id,
  158. }));
  159. } else {
  160. warehouseOptions.value = [];
  161. }
  162. },
  163. error: function (XMLHttpRequest, textStatus, errorThrown) {
  164. console.error(XMLHttpRequest, textStatus, errorThrown);
  165. },
  166. });
  167. };
  168. onMounted(() => {
  169. getWarehouseOptions();
  170. getTableDatas();
  171. });
  172. // 查询调度任务
  173. const getTableDatas = () => {
  174. const start = (pagination.value.start - 1) * pagination.value.length;
  175. const params = {
  176. ...formData.value,
  177. ...pagination.value,
  178. start,
  179. };
  180. loading.value = true;
  181. $.ajax({
  182. url: Common.getApiURL('SchedulingTasksResource/querySchedulingTasks'),
  183. type: 'post',
  184. contentType: 'application/json',
  185. dataType: 'json',
  186. data: JSON.stringify(params),
  187. beforeSend: function (request) {
  188. Common.addTokenToRequest(request);
  189. },
  190. success: function ({ errorCode, errorMessage, datas, total }) {
  191. if (errorCode === 0) {
  192. if (datas && datas.length > 0) {
  193. taskList.value = datas;
  194. totalSize.value = total;
  195. } else {
  196. taskList.value = [];
  197. totalSize.value = 0;
  198. }
  199. } else {
  200. taskList.value = [];
  201. totalSize.value = 0;
  202. message.warning(errorMessage);
  203. }
  204. loading.value = false;
  205. },
  206. error: function (XMLHttpRequest, textStatus, errorThrown) {
  207. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  208. loading.value = false;
  209. },
  210. });
  211. };
  212. // 执行任务Api
  213. const executeTaskById = id => {
  214. loading.value = true;
  215. $.ajax({
  216. type: 'get',
  217. url: Common.getApiURL(`SchedulingTasksResource/executeTaskById?schedulingTasksId=${id}`),
  218. beforeSend(request) {
  219. Common.addTokenToRequest(request);
  220. },
  221. success: function ({ errorCode, errorMessage }) {
  222. if (errorCode === 0) {
  223. searchDatas();
  224. message.success('执行成功!');
  225. } else {
  226. searchDatas();
  227. message.warning(errorMessage);
  228. }
  229. loading.value = false;
  230. },
  231. error: function (XMLHttpRequest, textStatus, errorThrown) {
  232. loading.value = false;
  233. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  234. },
  235. });
  236. };
  237. // 取消任务Api
  238. const cancelTaskById = id => {
  239. loading.value = true;
  240. $.ajax({
  241. type: 'get',
  242. url: Common.getApiURL(`SchedulingTasksResource/cancelWorkById?schedulingTasksId=${id}`),
  243. beforeSend(request) {
  244. Common.addTokenToRequest(request);
  245. },
  246. success: function ({ errorCode, errorMessage }) {
  247. if (errorCode === 0) {
  248. searchDatas();
  249. message.success('取消成功!');
  250. } else {
  251. searchDatas();
  252. message.warning(errorMessage);
  253. }
  254. loading.value = false;
  255. },
  256. error: function (XMLHttpRequest, textStatus, errorThrown) {
  257. loading.value = false;
  258. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  259. },
  260. });
  261. };
  262. </script>
  263. <style scoped>
  264. .horizontal-form-item {
  265. display: flex;
  266. align-items: center;
  267. gap: 8px;
  268. }
  269. .w-full {
  270. width: 230px;
  271. }
  272. :deep(.ant-form-item-label > label) {
  273. font-size: 14px !important;
  274. font-weight: 600 !important;
  275. }
  276. :deep(.ant-form-item) {
  277. margin-bottom: 0px !important;
  278. margin-right: 16px !important;
  279. }
  280. </style>