index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <div style="padding: 10px">
  3. <div class="formbody">
  4. <el-form
  5. :inline="true"
  6. v-model="queryparameters"
  7. class="demo-form-inline"
  8. >
  9. <el-row>
  10. <el-col :span="6">
  11. <el-form-item label="任务时间">
  12. <el-date-picker
  13. v-model="qdate"
  14. type="daterange"
  15. value-format="YYYY-MM-DD"
  16. range-separator="到"
  17. start-placeholder="开始时间"
  18. end-placeholder="结束时间"
  19. />
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="3" v-if="currentstatus == 1">
  23. <el-form-item label="任务状态" >
  24. <el-select
  25. v-model="queryparameters.status"
  26. class="m-1"
  27. placeholder="请选择"
  28. >
  29. <el-option
  30. v-for="item in task_status"
  31. :label="item.label"
  32. :value="item.value"
  33. ></el-option>
  34. </el-select>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="4">
  38. <el-form-item label="事件来源">
  39. <el-select
  40. v-model="queryparameters.taskType"
  41. class="m-2"
  42. placeholder="请选择"
  43. >
  44. <el-option
  45. v-for="item in task_type"
  46. :label="item.label"
  47. :value="item.value"
  48. ></el-option>
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="3">
  53. <el-form-item label="区属">
  54. <el-select
  55. v-model="queryparameters.taskArea"
  56. class="m-2"
  57. placeholder="请选择"
  58. >
  59. <el-option
  60. v-for="item in sys_area"
  61. :label="item.label"
  62. :value="item.value"
  63. ></el-option>
  64. </el-select>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="4">
  68. <el-form-item label="关键字">
  69. <el-input v-model="queryparameters.searchkey" placeholder="道路名或任务内容"></el-input>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="4">
  73. <div style="float: right">
  74. <el-form-item>
  75. <el-button type="primary" @click="getList">查询</el-button>
  76. </el-form-item>
  77. <el-form-item v-if="route.params.status==6">
  78. <el-button type="primary" @click="exportexcel2(queryparameters)"
  79. >导出成本记录
  80. </el-button>
  81. </el-form-item>
  82. <el-form-item>
  83. <el-button type="success" @click="addtask">新增</el-button>
  84. </el-form-item>
  85. </div>
  86. </el-col>
  87. </el-row>
  88. </el-form>
  89. <div>
  90. <el-table
  91. :data="tableData"
  92. class="eltable"
  93. style="width: 100%"
  94. @row-click="tblrowclick"
  95. :row-class-name="tableRowClassName"
  96. >
  97. <el-table-column prop="taskCode" label="工单号" width="180" />
  98. <el-table-column prop="taskArea" label="行政区">
  99. <template #default="scope">
  100. {{
  101. (sys_area ?? []).filter(
  102. (i) => i.value === scope.row.taskArea + ""
  103. )[0]?.label ?? "-"
  104. }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="事件来源">
  108. <template #default="scope">
  109. {{
  110. task_type.filter((i) => i.value === scope.row.taskType + "")[0]
  111. ?.label ?? "-"
  112. }}
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="状态">
  116. <template #default="scope">
  117. {{
  118. task_status.filter((i) => i.value === scope.row.status + "")[0]
  119. ?.label ?? "-"
  120. }}
  121. </template>
  122. </el-table-column>
  123. <el-table-column prop="taskAddrRoad" label="道路名" />
  124. <el-table-column prop="taskContent" label="任务内容" />
  125. <el-table-column prop="taskTime" label="来件时间" />
  126. <el-table-column prop="taskTime" label="剩余时间" v-if="currentstatus!=6">
  127. <template #default="scope"><div>
  128. <div v-if="scope.row.taskReqCompleteTime!=null && scope.row.status<5" :class="moment(scope.row.taskReqCompleteTime).diff(moment(),'days')<2?'tip-e':(moment(scope.row.taskReqCompleteTime).diff(moment(),'days')<3?'tip-w':(moment(scope.row.taskReqCompleteTime).diff(moment(),'days')>5?'tip-i':''))">
  129. <el-icon style="vertical-align: middle;"><Clock /></el-icon> <span> {{ moment(scope.row.taskReqCompleteTime).diff(moment(),'days')}}天</span>
  130. </div>
  131. <div v-if="scope.row.taskReqCompleteTime==null">
  132. -
  133. </div>
  134. </div>
  135. </template>
  136. </el-table-column>
  137. <el-table-column prop="address" label="操作" :width="currentstatus==6?'400px':''">
  138. <template #default="scope">
  139. <el-button text size="small" @click.stop="edittask(scope.row)"
  140. >修改
  141. </el-button>
  142. <el-popconfirm title="确定删除?" @confirm="deltask(scope.row)">
  143. <template #reference>
  144. <el-button text size="small" @click.stop="">删除</el-button>
  145. </template>
  146. </el-popconfirm>
  147. <el-button v-if="scope.row.status==6" text size="small" @click.stop="exportexcel(scope.row)"
  148. >导出工单
  149. </el-button>
  150. <el-button v-if="scope.row.status==6" text size="small" @click.stop="exportexcel1(scope.row)"
  151. >导出热线照片
  152. </el-button>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. <div style="position: relative; padding-right: 20px; margin-top: -20px">
  157. <Pagination
  158. :total="pagedata.total ?? 0"
  159. v-show="pagedata.total > 0"
  160. v-model:page="queryparameters.pageNum"
  161. v-model:limit="queryparameters.pageSize"
  162. @pagination="getList"
  163. ></Pagination>
  164. <!-- <el-pagination
  165. style="float: right"
  166. small
  167. background
  168. :page-sizes="[10, 20, 30, 50]"
  169. :page-size="10"
  170. layout=" sizes,prev, pager, next"
  171. :total="pagedata.total??0"
  172. class="mt-4"
  173. /> -->
  174. </div>
  175. </div>
  176. </div>
  177. <el-dialog
  178. v-model="showadd"
  179. v-loading="loading"
  180. :title="`${
  181. taskinfo.taskId == null || taskinfo.taskId == undefined
  182. ? '新增任务'
  183. : '编辑任务'
  184. }`"
  185. width="70%"
  186. draggable
  187. >
  188. <div>
  189. <TaskAdd v-model:taskinfo="taskinfo" ref="taskaddref"></TaskAdd>
  190. </div>
  191. <template #footer>
  192. <span class="dialog-footer">
  193. <el-button @click="showadd = false">取消</el-button>
  194. <el-button type="primary" @click="ontaskadd">保存</el-button>
  195. </span>
  196. </template>
  197. </el-dialog>
  198. </div>
  199. </template>
  200. <script setup>
  201. import { defineComponent, ref, reactive, onMounted, computed } from "vue";
  202. import { useDict } from "@/utils/dict";
  203. import TaskAdd from "@/components/Task/Add";
  204. import MapSelect from "@/components/MapSelect";
  205. import router from "../../../router";
  206. import { ElMessage } from "element-plus";
  207. // 分页组件
  208. import Pagination from "@/components/Pagination";
  209. import {
  210. listTask,
  211. getTask,
  212. delTask,
  213. addTask,
  214. updateTask,
  215. } from "@/api/system/task";
  216. import { cloneDeep } from "lodash";
  217. import { isArray } from "@vue/shared";
  218. import { useRoute } from "vue-router";
  219. import moment from "moment";
  220. const formlocation = ref({ addr: "", locations: "" });
  221. const {
  222. task_status,
  223. task_type,
  224. task_event_type,
  225. task_event_category,
  226. sys_area,
  227. } = useDict(
  228. "task_status",
  229. "task_type",
  230. "task_event_type",
  231. "task_event_category",
  232. "sys_area"
  233. );
  234. const queryparameters = ref({
  235. status: "",
  236. taskArea: "",
  237. taskType: "",
  238. searchkey:"",
  239. pageNum: 1,
  240. pageSize: 10,
  241. });
  242. const loading = ref(false);
  243. const { proxy } = getCurrentInstance();
  244. const showadd = ref(false);
  245. const qdate = ref([]);
  246. const tableData = ref([]);
  247. const pagedata = ref({});
  248. const taskinfo = ref({
  249. taskName: null,
  250. taskContent: null,
  251. taskAddr: null,
  252. taskLocation: null,
  253. taskCode: null,
  254. taskType: null,
  255. taskEventType: null,
  256. taskEventCategory: null,
  257. taskFromRemark: null,
  258. taskAddrRoad: null,
  259. taskOtherId: null,
  260. taskTime: null,
  261. taskArea: "1",
  262. taskReqCompleteTime: null,
  263. status: 1,
  264. taskId: null,
  265. remark: "",
  266. taskCreater: null,
  267. taskReporter: null,
  268. taskPics: null,
  269. taskVideos: null,
  270. taskComplainConnect: null,
  271. taskDeptRange: "",
  272. taskFacilitieCode: "",
  273. });
  274. const taskaddref = ref();
  275. const route = useRoute();
  276. const currentstatus = computed(() => route.params.status);
  277. const addtask = () => {
  278. showadd.value = true;
  279. taskinfo.value = {
  280. taskName: null,
  281. taskContent: null,
  282. taskAddr: null,
  283. taskLocation: null,
  284. taskCode: null,
  285. taskType: null,
  286. taskEventType: null,
  287. taskEventCategory: null,
  288. taskFromRemark: null,
  289. taskAddrRoad: null,
  290. taskOtherId: null,
  291. taskTime: null,
  292. taskArea: "1",
  293. taskReqCompleteTime: null,
  294. status: 1,
  295. taskId: null,
  296. remark: "",
  297. taskCreater: null,
  298. taskReporter: null,
  299. taskPics: null,
  300. taskVideos: null,
  301. taskComplainConnect: null,
  302. taskDeptRange: "",
  303. taskFacilitieCode: "",
  304. };
  305. taskaddref.value?.doinit(taskinfo.value);
  306. };
  307. const tblrowclick = (row) => {
  308. router.push(`/task/detail/${row.taskId}`);
  309. };
  310. const ontaskadd = async () => {
  311. taskaddref.value?.updateallvalue();
  312. showadd.value = false;
  313. var taskobj = cloneDeep(taskinfo.value);
  314. taskobj.status = 1;
  315. taskobj.taskDeptRange =
  316. taskobj.taskDeptRange instanceof Array
  317. ? taskobj.taskDeptRange.join(",")
  318. : "";
  319. console.log(taskobj);
  320. loading.value = true;
  321. if (taskobj.taskId) {
  322. await updateTask(taskobj);
  323. } else {
  324. await addTask(taskobj);
  325. }
  326. loading.value = false;
  327. getList();
  328. };
  329. const getList = () => {
  330. if (currentstatus.value != '1' && queryparameters.value.status==="") {
  331. if (currentstatus.value == '2') {
  332. queryparameters.value.status = 1;
  333. } else {
  334. queryparameters.value.status = currentstatus.value;
  335. }
  336. } else {
  337. // queryparameters.value.status = "";
  338. }
  339. var query = proxy.addDateRange(queryparameters.value, qdate.value)
  340. if (query.searchkey!=undefined && query.searchkey !== '') {
  341. query.params['searchkey'] = query.searchkey;
  342. }
  343. listTask(query).then(
  344. (response) => {
  345. tableData.value = response.rows;
  346. pagedata.value = response;
  347. }
  348. );
  349. };
  350. getList();
  351. const edittask = (row) => {
  352. taskinfo.value = cloneDeep(row);
  353. showadd.value = true;
  354. taskaddref.value?.doinit(taskinfo.value);
  355. };
  356. const deltask = (row) => {
  357. delTask(row.taskId).then((res) => {
  358. ElMessage.success("删除成功");
  359. getList();
  360. });
  361. };
  362. const exportexcel = (row) => {
  363. proxy.download("system/task/export", {
  364. ...{ "taskId": row.taskId},
  365. }, `${row.taskCode}工单.xlsx`);
  366. }
  367. const exportexcel1 = (row) => {
  368. proxy.download("system/task/export1", {
  369. ...{ "taskId": row.taskId},
  370. }, `${row.taskCode}热线照片.xlsx`);
  371. }
  372. const exportexcel2 = (row) => {
  373. proxy.download("system/task/export2", {
  374. ...row,
  375. }, `成本记录.xlsx`);
  376. }
  377. const tableRowClassName = ({
  378. row,
  379. rowIndex,
  380. }) => {
  381. if (row.status < 5 && row.tblTaskLogList.filter((ii) => ii.taskStatus === 6).length>0) {
  382. return 'warning-row'
  383. }
  384. return ''
  385. }
  386. onMounted(() => {
  387. if (currentstatus.value == '2') {
  388. queryparameters.value.status = 1;
  389. } else {
  390. queryparameters.value.status = currentstatus.value;
  391. }
  392. });
  393. </script>
  394. <style lang="scss" scoped>
  395. .formbody {
  396. background: #fff;
  397. width: 100%;
  398. border-radius: 5px;
  399. min-height: 80vh;
  400. padding: 15px 10px;
  401. .eltable {
  402. border: 1px solid #e5e9f2;
  403. border-radius: 5px;
  404. .tip-e{
  405. color:red;
  406. }
  407. .tip-w{
  408. color:yellow;
  409. }
  410. .tip-i{
  411. color:green;
  412. }
  413. }
  414. }
  415. </style>
  416. <style>
  417. .el-table__row:hover {
  418. cursor: pointer;
  419. }
  420. .el-table .warning-row {
  421. --el-table-tr-bg-color: var(--el-color-warning-light-9);
  422. }
  423. </style>