index.vue 7.6 KB

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