index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <plan-search @search="reload"> </plan-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. cache-key="systemRoleTable"
  11. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <el-button
  15. size="small"
  16. type="primary"
  17. icon="el-icon-plus"
  18. class="ele-btn-icon"
  19. @click="openAdd('新增巡点检计划配置')"
  20. >
  21. 新建临时计划
  22. </el-button>
  23. </template>
  24. <!-- <template v-slot:enable="{ row }">
  25. <el-switch
  26. v-model="row.enable"
  27. active-color="#13ce66"
  28. inactive-color="#ff4949"
  29. :active-value="1"
  30. :inactive-value="0"
  31. @change="changeEnable(row)"
  32. >
  33. </el-switch>
  34. </template> -->
  35. <template v-slot:planCode="{ row }">
  36. <el-link type="primary" :underline="false" @click="goDetail(row)">
  37. {{ row.planCode }}
  38. </el-link>
  39. </template>
  40. <!-- 操作列 -->
  41. <template v-slot:action="{ row }">
  42. <el-link
  43. type="primary"
  44. :underline="false"
  45. v-if="row.cycleType == 0 || row.planStatus == 4"
  46. icon="el-icon-edit"
  47. @click="openAdd('编辑巡点检计划配置', row)"
  48. >
  49. 编辑
  50. </el-link>
  51. <el-link
  52. v-if="row.cycleType == 0 || row.planStatus == 4"
  53. type="primary"
  54. :underline="false"
  55. icon="el-icon-edit"
  56. @click="openAdd('派单', row)"
  57. >
  58. 派单
  59. </el-link>
  60. <el-link
  61. v-if="row.planStatus != 2 && row.planStatus != 3"
  62. type="primary"
  63. :underline="false"
  64. icon="el-icon-edit"
  65. @click="handleWithdraw(row)"
  66. >
  67. 撤回
  68. </el-link>
  69. </template>
  70. </ele-pro-table>
  71. </el-card>
  72. <!-- 新建或编辑弹窗 -->
  73. <!-- <AddPatrolPlanDialog ref="addPatrolPlanDialogRef" @refreshList="reload" /> -->
  74. <programRulesDialog
  75. ref="programRulesDialog"
  76. :visible.sync="addProgramRulesDialog"
  77. :dialogTitle="dialogTitle"
  78. :isBindPlan="isBindPlan"
  79. @done="reload"
  80. />
  81. <dispatchDialog ref="dispatchDialogRef" @refreshList="reload" />
  82. </div>
  83. </template>
  84. <script>
  85. import ProgramRulesDialog from '../../components/programRulesDialog.vue';
  86. import AddPatrolPlanDialog from '@/components/addPatrolPlanDialog/index.vue';
  87. import DispatchDialog from '@/components/addPatrolPlanDialog/DispatchDialog';
  88. import PlanSearch from './components/plan-search.vue';
  89. import { getPage, revocation } from '@/api/maintenance/patrol_maintenance';
  90. export default {
  91. components: {
  92. PlanSearch,
  93. DispatchDialog,
  94. AddPatrolPlanDialog,
  95. ProgramRulesDialog
  96. },
  97. data() {
  98. return {
  99. addProgramRulesDialog: false,
  100. isBindPlan: false,
  101. dialogTitle: '',
  102. // 表格列配置
  103. columns: [
  104. {
  105. columnKey: 'index',
  106. label: '序号',
  107. type: 'index',
  108. width: 55,
  109. align: 'center',
  110. showOverflowTooltip: true,
  111. fixed: 'left'
  112. },
  113. {
  114. columnKey: 'planCode',
  115. slot: 'planCode',
  116. prop: 'planCode',
  117. label: '计划单号',
  118. align: 'center',
  119. showOverflowTooltip: true,
  120. minWidth: 200
  121. },
  122. {
  123. prop: 'planName',
  124. label: '计划名称',
  125. align: 'center',
  126. showOverflowTooltip: true,
  127. minWidth: 110
  128. },
  129. {
  130. prop: 'ruleName',
  131. label: '计划规则',
  132. align: 'center',
  133. showOverflowTooltip: true,
  134. slot: 'enable',
  135. minWidth: 200
  136. },
  137. {
  138. prop: 'categoryLevelName',
  139. label: '设备分类',
  140. align: 'center',
  141. showOverflowTooltip: true,
  142. minWidth: 110
  143. },
  144. {
  145. prop: 'cycleType',
  146. label: '计划性质',
  147. align: 'center',
  148. showOverflowTooltip: true,
  149. minWidth: 110,
  150. formatter(item) {
  151. return { 1: '自动', 0: '手动' }[item.cycleType];
  152. }
  153. },
  154. {
  155. prop: 'planStatus',
  156. label: '状态',
  157. align: 'center',
  158. showOverflowTooltip: true,
  159. minWidth: 110,
  160. formatter(item) {
  161. return {
  162. 0: '待派单',
  163. 1: '已派单',
  164. 2: '执行中',
  165. 3: '已完成',
  166. 4: '已撤回',
  167. 5: '已驳回'
  168. }[item.planStatus];
  169. }
  170. },
  171. {
  172. prop: 'approvalUserName',
  173. label: '审批人',
  174. align: 'center',
  175. showOverflowTooltip: true,
  176. minWidth: 110
  177. },
  178. {
  179. prop: 'createUserName',
  180. label: '创建人',
  181. align: 'center',
  182. showOverflowTooltip: true,
  183. minWidth: 110
  184. },
  185. {
  186. prop: 'createTime',
  187. label: '生成时间',
  188. align: 'center',
  189. showOverflowTooltip: true,
  190. minWidth: 150,
  191. formatter: (_row, _column, cellValue) => {
  192. return this.$util.toDateString(cellValue);
  193. }
  194. },
  195. {
  196. columnKey: 'action',
  197. label: '操作',
  198. width: 230,
  199. align: 'center',
  200. resizable: false,
  201. slot: 'action',
  202. showOverflowTooltip: true
  203. }
  204. ],
  205. // 加载状态
  206. loading: false,
  207. pageType: 'add',
  208. isBindPlan: false
  209. };
  210. },
  211. methods: {
  212. /* 表格数据源 */
  213. datasource({ page, limit, where, order }) {
  214. return getPage({ pageNum: page, size: limit, ...where, planType: 1 });
  215. },
  216. async changeEnable(row) {
  217. const res = await putRoles(row);
  218. if (res.code == 0) {
  219. this.$message({
  220. type: 'success',
  221. message: '修改成功',
  222. customClass: 'ele-message-border'
  223. });
  224. this.reload();
  225. }
  226. },
  227. /* 刷新表格 */
  228. reload(where) {
  229. this.addProgramRulesDialog = false;
  230. this.$refs.table.reload({ page: 1, where });
  231. },
  232. handleWithdraw(row) {
  233. // 撤回
  234. this.$confirm(`确认撤回?`, '提示').then(async () => {
  235. revocation(row.id)
  236. .then(() => {
  237. this.$message.success('撤回成功!');
  238. this.reload();
  239. })
  240. .catch((err) => {
  241. this.$message.success(err.message || '撤回失败!');
  242. });
  243. });
  244. },
  245. openAdd(dialogTitle, row) {
  246. // this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
  247. this.isBindPlan = false;
  248. this.addProgramRulesDialog = true;
  249. this.dialogTitle = dialogTitle;
  250. this.$nextTick(() => {
  251. this.$refs.programRulesDialog.init(row, '巡点检');
  252. });
  253. },
  254. goDetail({ id }) {
  255. this.$router.push({
  256. path: '/maintenance/patrol/plan/details',
  257. query: {
  258. id
  259. }
  260. });
  261. }
  262. }
  263. };
  264. </script>
  265. <style lang="scss" scoped></style>