index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="todo-order-container layout-pd">
  3. <el-card shadow="never">
  4. <el-tabs v-model="state.queryParams.IsHandled" @tab-change="handleQuery">
  5. <el-tab-pane name="false" label="工单待办"></el-tab-pane>
  6. <el-tab-pane name="true" label="工单已办"></el-tab-pane>
  7. </el-tabs>
  8. <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
  9. <el-form-item label="关键字" prop="Keyword">
  10. <el-input v-model="state.queryParams.Keyword" placeholder="工单编码/标题" clearable @keyup.enter="handleQuery" class="keyword-input" />
  11. </el-form-item>
  12. <el-form-item label="是否省工单" prop="IsProvince">
  13. <el-select v-model="state.queryParams.IsProvince" placeholder="请选择是否省工单" @change="handleQuery">
  14. <el-option label="是" value="true" />
  15. <el-option label="否" value="false" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="是否会签" prop="IsCounterSign">
  19. <el-select v-model="state.queryParams.IsCounterSign" placeholder="请选择是否会签" @change="handleQuery">
  20. <el-option label="是" value="true" />
  21. <el-option label="否" value="false" />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  26. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  27. <SvgIcon name="ele-Refresh" class="mr5" />重置
  28. </el-button>
  29. </el-form-item>
  30. </el-form>
  31. <!-- 表格 -->
  32. <ProTable
  33. ref="proTableRef"
  34. :columns="columns"
  35. :data="state.tableData"
  36. @updateTable="queryList"
  37. :loading="state.loading"
  38. :total="state.total"
  39. v-model:page-index="state.queryParams.PageIndex"
  40. v-model:page-size="state.queryParams.PageSize"
  41. :key="Math.random()"
  42. :toolButton="['refresh', 'setting', 'exportCurrent', 'exportAll']"
  43. @export-current="exportTable($event)"
  44. @export-all="exportTable($event, true)"
  45. >
  46. <!-- 表格 header 按钮 -->
  47. <template #tableHeader="scope">
  48. <el-button type="primary" @click="onAddOrder" v-auth="'todo:seats:add'"> <SvgIcon name="ele-Plus" class="mr5" />新建工单 </el-button>
  49. <el-button type="primary" @click="onJbExport" :disabled="!scope.isSelected" :loading="state.loading" v-auth="'todo:order:jbdExport'"
  50. ><SvgIcon name="iconfont icon-daochu" class="mr5" />交办单导出
  51. </el-button>
  52. </template>
  53. <template #expiredStatusText="{ row }">
  54. <span :class="'overdue-status-' + row.expiredStatus" :title="row.expiredStatusText"></span>
  55. </template>
  56. <template #title="{ row }">
  57. <order-detail :order="row" @updateList="queryList" :type="row.canSign ? 'danger' : 'primary'">{{ row.title }}</order-detail>
  58. </template>
  59. <!-- 表格操作 -->
  60. <template #operation="{ row }">
  61. <el-button link type="success" @click="onOrderEdit(row)" title="编辑工单" v-if="row.canEdit" v-auth="'todo:seats:edit'"> 修改 </el-button>
  62. <el-button link type="primary" @click="onSign(row)" title="签收工单" v-if="row.canSign" v-auth="'todo:seats:sign'"> 签收 </el-button>
  63. <order-detail :order="row" @updateList="queryList" />
  64. </template>
  65. </ProTable>
  66. </el-card>
  67. </div>
  68. </template>
  69. <script setup lang="tsx" name="todoOrder">
  70. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  71. import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
  72. import { formatDate } from '@/utils/formatTime';
  73. import { useRouter } from 'vue-router';
  74. import { seatsListTodo, orderSign } from '@/api/todo/order';
  75. import { downloadFileByStream, downloadZip } from '@/utils/tools';
  76. import { exportJbOrder, exportOrder } from '@/api/business/order';
  77. // 引入组件
  78. const OrderDetail = defineAsyncComponent(() => import('@/components/OrderDetail/index.vue')); // 工单详情
  79. // 定义变量内容
  80. const state = reactive({
  81. queryParams: {
  82. // 查询条件
  83. PageIndex: 1, // 当前页
  84. PageSize: 10, // 每页条数
  85. IsHandled: 'false', // 工单状态
  86. Keyword: null, // 关键字
  87. IsProvince: null, // 是否省工单
  88. IsCounterSign: null, // 是否会签
  89. },
  90. tableData: [], //表单
  91. loading: false, // 加载
  92. total: 0, // 总数
  93. });
  94. const ruleFormRef = ref<RefType>(); // 表单ref
  95. const router = useRouter(); // 路由
  96. const proTableRef = ref<RefType>(); // 表格ref
  97. // 表格配置项
  98. const columns = ref<any[]>([]);
  99. const columnsTodo = [
  100. { type: 'selection', fixed: 'left', width: 55, align: 'center' },
  101. { prop: 'expiredStatusText', label: '超期状态', align: 'center', width: 80 },
  102. { prop: 'no', label: '工单编码', width: 150 },
  103. { prop: 'isProvinceText', label: '省/市工单', width: 100 },
  104. { prop: 'actualHandleStepName', label: '办理节点', width: 150 },
  105. { prop: 'statusText', label: '工单状态', width: 100 },
  106. { prop: 'title', label: '工单标题', width: 300 },
  107. { prop: 'counterSignTypeText', label: '是否会签', width: 100 },
  108. {
  109. prop: 'creationTime',
  110. label: '生成时间',
  111. width: 170,
  112. render: (scope) => {
  113. return <span>{formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  114. },
  115. },
  116. {
  117. prop: 'startTime',
  118. label: '受理时间',
  119. width: 170,
  120. render: (scope) => {
  121. return <span>{formatDate(scope.row.startTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  122. },
  123. },
  124. {
  125. prop: 'expiredTime',
  126. label: '工单期满时间',
  127. width: 170,
  128. render: (scope) => {
  129. return <span>{formatDate(scope.row.expiredTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  130. },
  131. },
  132. { prop: 'acceptType', label: '受理类型', width: 150 },
  133. { prop: 'emergencyLevelText', label: '紧急程度', width: 150 },
  134. { prop: 'sourceChannel', label: '来源方式', width: 100 },
  135. { prop: 'hotspotName', label: '热点分类', width: 200 },
  136. { prop: 'acceptorName', label: '受理人', width: 120 },
  137. {
  138. prop: 'reTransactNum',
  139. label: '重办次数',
  140. },
  141. { prop: 'operation', label: '操作', fixed: 'right', width: 140, align: 'center' },
  142. ];
  143. const columnsDone = [
  144. // 已办
  145. { type: 'selection', fixed: 'left', width: 55, align: 'center' },
  146. { prop: 'expiredStatusText', label: '超期状态', align: 'center', width: 80 },
  147. { prop: 'no', label: '工单编码', width: 150 },
  148. { prop: 'isProvinceText', label: '省/市工单', width: 100 },
  149. { prop: 'actualHandleStepName', label: '办理节点', width: 150 },
  150. { prop: 'statusText', label: '工单状态', width: 100 },
  151. { prop: 'title', label: '工单标题', width: 300 },
  152. { prop: 'counterSignTypeText', label: '是否会签', width: 100 },
  153. {
  154. prop: 'creationTime',
  155. label: '生成时间',
  156. width: 170,
  157. render: (scope) => {
  158. return <span>{formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  159. },
  160. },
  161. {
  162. prop: 'startTime',
  163. label: '受理时间',
  164. width: 170,
  165. render: (scope) => {
  166. return <span>{formatDate(scope.row.startTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  167. },
  168. },
  169. {
  170. prop: 'expiredTime',
  171. label: '工单期满时间',
  172. width: 170,
  173. render: (scope) => {
  174. return <span>{formatDate(scope.row.expiredTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
  175. },
  176. },
  177. { prop: 'orgLevelOneName', label: '一级部门', width: 150 },
  178. { prop: 'actualHandleOrgName', label: '接办部门', width: 150 },
  179. { prop: 'acceptType', label: '受理类型', width: 150 },
  180. { prop: 'emergencyLevelText', label: '紧急程度', width: 150 },
  181. { prop: 'sourceChannel', label: '来源方式', width: 100 },
  182. { prop: 'hotspotName', label: '热点分类', width: 200 },
  183. { prop: 'acceptorName', label: '受理人', width: 120 },
  184. {
  185. prop: 'reTransactNum',
  186. label: '重办次数',
  187. },
  188. { prop: 'operation', label: '操作', fixed: 'right', width: 140, align: 'center' },
  189. ];
  190. // 手动查询,将页码设置为1
  191. const handleQuery = () => {
  192. state.queryParams.PageIndex = 1;
  193. queryList();
  194. };
  195. /** 获取列表 */
  196. const queryList = async () => {
  197. try {
  198. state.loading = true;
  199. if (state.queryParams.IsHandled === 'true') {
  200. columns.value = columnsDone;
  201. } else {
  202. columns.value = columnsTodo;
  203. }
  204. const res: any = await seatsListTodo(state.queryParams);
  205. state.tableData = res.result?.items ?? [];
  206. state.total = res.result?.total ?? 0;
  207. state.loading = false;
  208. } catch (e) {
  209. state.loading = false;
  210. }
  211. };
  212. /** 重置按钮操作 */
  213. const resetQuery = (formEl: FormInstance | undefined) => {
  214. if (!formEl) return;
  215. formEl.resetFields();
  216. queryList();
  217. };
  218. // 新增工单
  219. const onAddOrder = () => {
  220. router.push({
  221. name: 'orderAccept',
  222. params: {
  223. tagsViewName: `工单受理`,
  224. callId: new Date().getTime(),
  225. },
  226. });
  227. };
  228. // 编辑工单
  229. const onOrderEdit = (row: any) => {
  230. router.push({
  231. name: 'orderAccept',
  232. params: {
  233. tagsViewName: '工单受理-' + row.no,
  234. id: row.id,
  235. callId: '0',
  236. },
  237. });
  238. };
  239. // 签收工单
  240. const onSign = (row: any) => {
  241. ElMessageBox.confirm(`您确定要要签收【${row.title}】,是否继续?`, '提示', {
  242. confirmButtonText: '确认',
  243. cancelButtonText: '取消',
  244. type: 'warning',
  245. draggable: true,
  246. cancelButtonClass: 'default-button',
  247. autofocus: false,
  248. })
  249. .then(() => {
  250. orderSign(row.id).then(() => {
  251. ElMessage.success('签收成功');
  252. queryList();
  253. });
  254. })
  255. .catch(() => {});
  256. };
  257. // 交办单导出
  258. const onJbExport = () => {
  259. const ids = proTableRef.value.selectedList.map((item: any) => item.id);
  260. ElMessageBox.confirm(`您确定导出选中的${proTableRef.value.selectedList.length}个工单的交办单,是否继续?`, '提示', {
  261. confirmButtonText: '确认',
  262. cancelButtonText: '取消',
  263. type: 'warning',
  264. draggable: true,
  265. cancelButtonClass: 'default-button',
  266. autofocus: false,
  267. })
  268. .then(() => {
  269. state.loading = true;
  270. exportJbOrder(ids)
  271. .then((res: any) => {
  272. downloadZip(res);
  273. state.loading = false;
  274. ElMessage.success('导出成功');
  275. })
  276. .catch(() => {
  277. state.loading = false;
  278. });
  279. })
  280. .catch(() => {});
  281. };
  282. // 表格导出
  283. const exportTable = (val: any, isExportAll = false) => {
  284. const columnInfos = val.map((item: any) => {
  285. return {
  286. prop: item.prop,
  287. name: item.label,
  288. };
  289. });
  290. const req = {
  291. queryDto: { ...state.queryParams },
  292. columnInfos,
  293. isExportAll,
  294. };
  295. state.loading = true;
  296. exportOrder(req)
  297. .then((res: any) => {
  298. state.loading = false;
  299. downloadFileByStream(res);
  300. })
  301. .catch(() => {
  302. state.loading = false;
  303. });
  304. };
  305. onMounted(() => {
  306. queryList();
  307. });
  308. </script>