index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <!-- 巡点检工单 -->
  2. <template>
  3. <div class="patrolInspection">
  4. <div class="search">
  5. <el-form label-width="120px">
  6. <el-row>
  7. <el-col :md="4" :sm="8" :xs="8">
  8. <el-form-item label="工单编号">
  9. <el-input
  10. v-model="searchForm.code"
  11. placeholder="请输入"
  12. size="small"
  13. ></el-input> </el-form-item
  14. ></el-col>
  15. <el-col :md="4" :sm="8" :xs="8">
  16. <el-form-item label="规则名称">
  17. <el-select
  18. v-model="searchForm.ruleId"
  19. size="small"
  20. clearable
  21. style="width: 100%"
  22. filterable
  23. >
  24. <el-option
  25. v-for="item in ruleNameList"
  26. :key="item.id"
  27. :value="item.id"
  28. :label="item.name"
  29. ></el-option> </el-select></el-form-item
  30. ></el-col>
  31. <el-col :md="4" :sm="8" :xs="8">
  32. <el-form-item label="状态">
  33. <el-select
  34. filterable
  35. v-model="searchForm.orderStatus"
  36. size="small"
  37. >
  38. <el-option
  39. v-for="item in ticketStatus"
  40. :key="item.id"
  41. :value="item.id"
  42. :label="item.label"
  43. ></el-option>
  44. </el-select> </el-form-item
  45. ></el-col>
  46. <el-col :md="8" :sm="8" :xs="8">
  47. <el-form-item label="开始结束时间">
  48. <el-date-picker
  49. class="form-input"
  50. size="small"
  51. v-model="searchForm.date"
  52. type="daterange"
  53. range-separator="至"
  54. start-placeholder="开始日期"
  55. end-placeholder="结束日期"
  56. value-format="yyyy-MM-dd HH:mm:ss"
  57. :default-time="['00:00:00', '23:59:59']"
  58. >
  59. </el-date-picker> </el-form-item
  60. ></el-col>
  61. <el-col :md="4" :sm="16" :xs="16" style="text-align: right">
  62. <el-button icon="el-icon-refresh-left" size="small" @click="rest"
  63. >重置</el-button
  64. >
  65. <el-button
  66. type="primary"
  67. icon="el-icon-search"
  68. size="small"
  69. @click="search"
  70. >搜索</el-button
  71. ></el-col
  72. >
  73. </el-row>
  74. </el-form>
  75. </div>
  76. <div class="table">
  77. <el-table
  78. :data="tableData"
  79. border
  80. height="99%"
  81. tooltip-effect="dark"
  82. :header-cell-style="{ background: '#F0F3F3', border: 'none' }"
  83. >
  84. <el-table-column
  85. width="80px"
  86. label="序号"
  87. type="index"
  88. :index="indexMethod"
  89. >
  90. </el-table-column>
  91. <el-table-column prop="code" label="工单编号" />
  92. <el-table-column prop="planCode" label="计划单号" />
  93. <el-table-column prop="planName" label="维修名称" />
  94. <!-- <el-table-column prop="createTime" label="设备分类" /> -->
  95. <el-table-column prop="ruleName" label="规则名称" />
  96. <el-table-column prop="equiCode" label="设备编号" />
  97. <el-table-column prop="equiName" label="设备名称" />
  98. <el-table-column prop="executeUserName" label="执行人" />
  99. <el-table-column prop="acceptTime" label="开始时间" />
  100. <el-table-column prop="finishTime" label="结束时间" />
  101. <el-table-column prop="planFinishTime" label="计划完成时间" />
  102. <el-table-column prop="orderStatus" label="执行结果">
  103. <template slot-scope="{ row }">
  104. {{
  105. row.acceptanceStatus
  106. ? resultStatus.filter(
  107. (item) => item.code == row.acceptanceStatus
  108. )[0].label
  109. : ''
  110. }}
  111. </template>
  112. </el-table-column>
  113. <el-table-column prop="orderStatus" label="状态">
  114. <template slot-scope="{ row }">
  115. {{
  116. ticketStatus.filter((item) => item.id == row.orderStatus)[0].label
  117. }}
  118. </template>
  119. </el-table-column>
  120. <el-table-column prop="practicalTime" label="实际工时">
  121. <template slot-scope="{ row }">
  122. {{ time_interval(row.acceptTime, row.finishTime) }}
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="操作" width="200">
  126. <template slot-scope="{ row }">
  127. <el-link
  128. v-if="row.orderStatus == 3 && row.createUserId == userId"
  129. type="primary"
  130. :underline="false"
  131. icon="el-icon-edit"
  132. @click="goDetail(row)"
  133. >
  134. 验收
  135. </el-link>
  136. <el-link
  137. v-if="
  138. row.orderStatus !== 3 &&
  139. row.orderStatus !== 4 &&
  140. userId === row.executeUserId
  141. "
  142. type="primary"
  143. :underline="false"
  144. icon="el-icon-edit"
  145. @click="toSigningUpWork(row)"
  146. >
  147. 报工
  148. </el-link>
  149. <el-link
  150. v-if="
  151. row.orderStatus !== 3 &&
  152. row.orderStatus !== 4 &&
  153. userId === row.executeUserId
  154. "
  155. type="primary"
  156. :underline="false"
  157. icon="el-icon-edit"
  158. @click="toRedeploy(row)"
  159. >
  160. 转派
  161. </el-link>
  162. <el-link
  163. type="primary"
  164. :underline="false"
  165. icon="el-icon-edit"
  166. @click="openDetail(row)"
  167. >
  168. 详情
  169. </el-link>
  170. </template>
  171. </el-table-column>
  172. </el-table>
  173. </div>
  174. <div class="table-footer">
  175. <el-pagination
  176. background
  177. layout="total, sizes, prev, pager, next, jumper"
  178. :total="total"
  179. :page-sizes="[15, 30, 50, 100, 500]"
  180. :page-size.sync="pages.size"
  181. :current-page.sync="pages.page"
  182. @current-change="handleCurrentChange"
  183. @size-change="handleSizeChange"
  184. >
  185. </el-pagination>
  186. </div>
  187. <!-- 验收 -->
  188. <RepairDetailsDialog ref="detailsDialogRef" @refesh="getData" />
  189. <!-- 转派弹窗 -->
  190. <redeployOther ref="redeployOtherRef" @refresh="getData" />
  191. <!-- 报工弹框 -->
  192. <signingUpWork ref="signingUpWorkRef" @refresh="getData" />
  193. </div>
  194. </template>
  195. <script>
  196. import redeployOther from '../components/redeployOther.vue';
  197. import signingUpWork from '../components/signingUpWork.vue';
  198. import { ticketStatus, resultStatus } from '@/utils/dict/tickets';
  199. import RepairDetailsDialog from '../components/RepairDetailsDialog.vue';
  200. import { getWorkOrderList, getRule } from '@/api/tickets';
  201. import pagenation from '@/components/Pagination';
  202. export default {
  203. components: {
  204. pagenation,
  205. redeployOther,
  206. signingUpWork,
  207. RepairDetailsDialog
  208. },
  209. data() {
  210. return {
  211. resultStatus,
  212. ruleNameList: [],
  213. tableData: [],
  214. statusOptions: [],
  215. userId: '',
  216. ticketStatus: [],
  217. searchForm: {
  218. code: '',
  219. orderStatus: 0,
  220. ruleId: '',
  221. date: '',
  222. startTime: '',
  223. endTime: '',
  224. type: 3
  225. },
  226. pages: {
  227. page: 1,
  228. size: 15
  229. },
  230. total: 0
  231. };
  232. },
  233. created() {
  234. this.userId = localStorage.getItem('userId');
  235. this.getRuleNameList();
  236. this.getData();
  237. // 过滤待接收和执行中
  238. this.ticketStatus = ticketStatus.filter((item) => {
  239. return [0, 2, 3].includes(item.id);
  240. });
  241. console.log('-----this.ticketStatus');
  242. console.log(this.ticketStatus);
  243. },
  244. methods: {
  245. // 验收
  246. goDetail(row) {
  247. row.title = '工单详情';
  248. row.tabLabel = '工单信息';
  249. this.$refs.detailsDialogRef.init(row);
  250. },
  251. // 转派
  252. toRedeploy(row) {
  253. this.$refs.redeployOtherRef.open(row);
  254. },
  255. // 报工
  256. toSigningUpWork(row) {
  257. this.$refs.signingUpWorkRef.open(row);
  258. },
  259. reload(where) {
  260. this.$refs.table.reload({ page: 1, ...where });
  261. },
  262. openDetail(row) {
  263. row.title = '工单详情';
  264. row.tabLabel = '工单信息';
  265. this.$refs.detailsDialogRef.init(row, true);
  266. },
  267. // 获取规则名列表(设备维修)
  268. async getRuleNameList() {
  269. const res = await getRule({
  270. status: 1,
  271. type: 3,
  272. pageNum: 1,
  273. size: -1
  274. });
  275. if (res.list) {
  276. this.ruleNameList = res.list || [];
  277. }
  278. },
  279. // 实现分页序号连贯
  280. indexMethod(index) {
  281. index = index + 1 + (this.pages.page - 1) * this.pages.size;
  282. return index;
  283. },
  284. getData() {
  285. let par = {
  286. ...this.pages,
  287. ...this.searchForm,
  288. executeUserId: this.userId,
  289. statusType: 1
  290. };
  291. if (this.searchForm.date) {
  292. par.startTime = this.searchForm.date[0];
  293. par.endTime = this.searchForm.date[1];
  294. }
  295. delete par.date;
  296. getWorkOrderList(par).then((res) => {
  297. this.tableData = res.list;
  298. this.total = res.total;
  299. });
  300. this.$emit('recount');
  301. },
  302. search() {
  303. this.pages.page = 1;
  304. this.getData();
  305. },
  306. rest() {
  307. this.searchForm = {
  308. code: '',
  309. orderStatus: 0,
  310. ruleId: '',
  311. date: '',
  312. startTime: '',
  313. endTime: '',
  314. type: 3
  315. };
  316. this.pages.page = 1;
  317. this.getData();
  318. },
  319. handleCurrentChange() {
  320. this.getData();
  321. },
  322. handleSizeChange() {
  323. this.pages.page = 1;
  324. this.getData();
  325. },
  326. // 计算实际工时
  327. time_interval(dt1, dt2) {
  328. if (!dt1 || !dt2) {
  329. return '';
  330. }
  331. if (typeof dt1 == 'string') {
  332. dt1 = new Date(dt1.replace(/-/, '/'));
  333. dt2 = new Date(dt2.replace(/-/, '/'));
  334. }
  335. var res = dt2 - dt1;
  336. if (isNaN(res)) throw Error('invalid dates arguments');
  337. let re = res / (1000 * 60 * 60);
  338. var h = parseInt(re);
  339. var m = parseInt((re - h) * 60);
  340. let result = '';
  341. if (h) {
  342. result += `${h} 小时`;
  343. }
  344. if (m) {
  345. result += `${m} 分钟`;
  346. }
  347. return result;
  348. }
  349. }
  350. };
  351. </script>
  352. <style lang="scss" scoped>
  353. // 步骤条边线显示
  354. ::v-deep .el-step__head.is-process .el-step__icon.is-text {
  355. border: none !important;
  356. background: none !important;
  357. }
  358. ::v-deep .el-step:last-of-type .el-step__line {
  359. display: block !important;
  360. width: 3px !important;
  361. }
  362. ::v-deep .el-steps:last-child .el-step__line {
  363. display: none !important;
  364. }
  365. .patrolInspection {
  366. height: 100%;
  367. width: 100%;
  368. display: flex;
  369. flex-direction: column;
  370. .search {
  371. flex: 0 0 50px;
  372. }
  373. .table {
  374. flex: 1;
  375. .el-table {
  376. width: 100%;
  377. display: flex;
  378. flex-direction: column;
  379. }
  380. }
  381. .table-footer {
  382. flex: 0 0 30px;
  383. display: flex;
  384. justify-content: flex-end;
  385. }
  386. }
  387. </style>