index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. @row-dblclick="openDetail"
  84. >
  85. <el-table-column
  86. width="80px"
  87. label="序号"
  88. type="index"
  89. :index="indexMethod"
  90. >
  91. </el-table-column>
  92. <el-table-column prop="code" label="工单编号" />
  93. <el-table-column prop="planCode" label="计划单号" />
  94. <el-table-column prop="planName" label="保养名称" />
  95. <!-- <el-table-column prop="createTime" label="设备分类" /> -->
  96. <el-table-column prop="ruleName" label="规则名称" />
  97. <el-table-column prop="createUserName" label="创建人" />
  98. <el-table-column prop="createTime" 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. {{ { 0: '缺陷', 1: '正常' }[row.isAbnormal] }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="orderStatus" label="状态">
  108. <template slot-scope="{ row }">
  109. {{
  110. ticketStatus.filter((item) => item.id == row.orderStatus)[0].label
  111. }}
  112. </template>
  113. </el-table-column>
  114. <el-table-column prop="practicalTime" label="实际工时">
  115. <template slot-scope="{ row }">
  116. {{ time_interval(row.acceptTime, row.finishTime) }}
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="操作" width="150">
  120. <template slot-scope="{ row }">
  121. <el-link
  122. v-if="row.orderStatus !== 3 && row.orderStatus !== 4"
  123. type="primary"
  124. :underline="false"
  125. icon="el-icon-edit"
  126. @click="toSigningUpWork(row)"
  127. >
  128. 报工
  129. </el-link>
  130. <el-link
  131. v-if="row.orderStatus !== 3 && row.orderStatus !== 4"
  132. type="primary"
  133. :underline="false"
  134. icon="el-icon-edit"
  135. @click="toRedeploy(row)"
  136. >
  137. 转派
  138. </el-link>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. </div>
  143. <div class="table-footer">
  144. <el-pagination
  145. background
  146. layout="total, sizes, prev, pager, next, jumper"
  147. :total="total"
  148. :page-sizes="[15, 30, 50, 100, 500]"
  149. :page-size.sync="pages.size"
  150. :current-page.sync="pages.page"
  151. @current-change="handleCurrentChange"
  152. @size-change="handleSizeChange"
  153. >
  154. </el-pagination>
  155. </div>
  156. <!-- 转派弹窗 -->
  157. <redeployOther ref="redeployOtherRef" @refresh="getData" />
  158. <!-- 报工弹框 -->
  159. <signingUpWork ref="signingUpWorkRef" @refresh="getData" />
  160. </div>
  161. </template>
  162. <script>
  163. import redeployOther from '../components/redeployOther.vue';
  164. import signingUpWork from '../components/signingUpWork.vue';
  165. import { ticketStatus } from '@/utils/dict/tickets';
  166. import { getWorkOrderPage, getRule } from '@/api/tickets';
  167. import pagenation from '@/components/Pagination';
  168. import { deepClone } from 'ele-admin/lib/utils/core';
  169. export default {
  170. components: { pagenation, redeployOther, signingUpWork },
  171. data() {
  172. return {
  173. ruleNameList: [],
  174. tableData: [],
  175. statusOptions: [],
  176. ticketStatus: [],
  177. searchForm: {
  178. code: '',
  179. orderStatus: 0,
  180. ruleId: '',
  181. date: '',
  182. startTime: '',
  183. endTime: '',
  184. type: 2
  185. },
  186. pages: {
  187. page: 1,
  188. size: 15
  189. },
  190. total: 0
  191. };
  192. },
  193. created() {
  194. this.getRuleNameList();
  195. this.getData();
  196. // 过滤待接收和执行中
  197. this.ticketStatus = ticketStatus.filter((item) => {
  198. return [0, 2].includes(item.id);
  199. });
  200. },
  201. methods: {
  202. // 转派
  203. toRedeploy(row) {
  204. this.$refs.redeployOtherRef.open(row);
  205. },
  206. // 报工
  207. toSigningUpWork(row) {
  208. this.$refs.signingUpWorkRef.open(row);
  209. },
  210. reload(where) {
  211. this.$refs.table.reload({ page: 1, ...where });
  212. },
  213. openDetail({ id }) {
  214. this.$router.push({
  215. path: '/tickets/maintenance/detail',
  216. query: {
  217. id
  218. }
  219. });
  220. },
  221. // 获取规则名列表(设备保养)
  222. async getRuleNameList() {
  223. const res = await getRule({
  224. status: 1,
  225. type: 2,
  226. pageNum: 1,
  227. size: -1
  228. });
  229. if (res.list) {
  230. this.ruleNameList = res.list || [];
  231. }
  232. },
  233. // 实现分页序号连贯
  234. indexMethod(index) {
  235. index = index + 1 + (this.pages.page - 1) * this.pages.size;
  236. return index;
  237. },
  238. getData() {
  239. let userId = localStorage.getItem('userId');
  240. console.log(userId);
  241. let par = {
  242. ...this.pages,
  243. ...this.searchForm,
  244. executeUserId: userId
  245. };
  246. if (this.searchForm.date) {
  247. par.startTime = this.searchForm.date[0];
  248. par.endTime = this.searchForm.date[1];
  249. }
  250. delete par.date;
  251. getWorkOrderPage(par).then((res) => {
  252. this.tableData = res.list;
  253. this.total = res.total;
  254. });
  255. this.$emit('recount');
  256. },
  257. search() {
  258. this.pages.page = 1;
  259. this.getData();
  260. },
  261. rest() {
  262. this.searchForm = {
  263. code: '',
  264. orderStatus: 0,
  265. ruleId: '',
  266. date: '',
  267. startTime: '',
  268. endTime: '',
  269. type: 2
  270. };
  271. this.pages.page = 1;
  272. this.getData();
  273. },
  274. handleCurrentChange() {
  275. this.getData();
  276. },
  277. handleSizeChange() {
  278. this.pages.page = 1;
  279. this.getData();
  280. },
  281. // 计算实际工时
  282. time_interval(dt1, dt2) {
  283. if (!dt1 || !dt2) {
  284. return '';
  285. }
  286. if (typeof dt1 == 'string') {
  287. dt1 = new Date(dt1.replace(/-/, '/'));
  288. dt2 = new Date(dt2.replace(/-/, '/'));
  289. }
  290. var res = dt2 - dt1;
  291. if (isNaN(res)) throw Error('invalid dates arguments');
  292. let re = res / (1000 * 60 * 60);
  293. var h = parseInt(re);
  294. var m = parseInt((re - h) * 60);
  295. let result = '';
  296. if (h) {
  297. result += `${h} 小时`;
  298. }
  299. if (m) {
  300. result += `${m} 分钟`;
  301. }
  302. return result;
  303. }
  304. }
  305. };
  306. </script>
  307. <style lang="scss" scoped>
  308. .patrolInspection {
  309. height: 100%;
  310. width: 100%;
  311. display: flex;
  312. flex-direction: column;
  313. .search {
  314. flex: 0 0 50px;
  315. }
  316. .table {
  317. flex: 1;
  318. .el-table {
  319. width: 100%;
  320. display: flex;
  321. flex-direction: column;
  322. }
  323. }
  324. .table-footer {
  325. flex: 0 0 30px;
  326. display: flex;
  327. justify-content: flex-end;
  328. }
  329. }
  330. </style>