index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. <template v-slot:planStatus="{ row }">
  41. {{ dict.planStatus[row.planStatus] }}
  42. </template>
  43. <!-- 操作列 -->
  44. <template v-slot:action="{ row }">
  45. <el-link
  46. v-if="row.cycleType == 0 || row.planStatus == 4"
  47. type="primary"
  48. :underline="false"
  49. icon="el-icon-edit"
  50. @click="openAdd('编辑保养计划配置', row)"
  51. >
  52. 编辑
  53. </el-link>
  54. <el-link
  55. v-if="row.cycleType == 0 || row.planStatus == 4"
  56. type="primary"
  57. :underline="false"
  58. icon="el-icon-edit"
  59. @click="openAdd('派单', row)"
  60. >
  61. 派单
  62. </el-link>
  63. <el-link
  64. v-if="row.planStatus != 2 && row.planStatus != 3"
  65. type="primary"
  66. :underline="false"
  67. icon="el-icon-edit"
  68. @click="handleWithdraw(row)"
  69. >
  70. 撤回
  71. </el-link>
  72. </template>
  73. </ele-pro-table>
  74. </el-card>
  75. <!-- 新建或编辑弹窗 -->
  76. <programRulesDialog
  77. ref="programRulesDialog"
  78. :visible.sync="addProgramRulesDialog"
  79. :dialogTitle="dialogTitle"
  80. :isBindPlan="isBindPlan"
  81. @done="reload"
  82. />
  83. <AddPatrolPlanDialog ref="addPatrolPlanDialogRef" @refreshList="reload" />
  84. <dispatchDialog ref="dispatchDialogRef" @refreshList="reload" type="保养" />
  85. </div>
  86. </template>
  87. <script>
  88. import ProgramRulesDialog from '../../components/programRulesDialog.vue';
  89. import DispatchDialog from '@/components/addPatrolPlanDialog/DispatchDialog';
  90. import AddPatrolPlanDialog from '@/components/addPatrolPlanDialog';
  91. import PlanSearch from './components/plan-search.vue';
  92. import { getPage, revocation } from '@/api/maintenance/patrol_maintenance';
  93. import { getByCode } from '@/api/system/dictionary-data';
  94. export default {
  95. components: {
  96. PlanSearch,
  97. DispatchDialog,
  98. AddPatrolPlanDialog,
  99. ProgramRulesDialog
  100. },
  101. data() {
  102. return {
  103. addProgramRulesDialog: false,
  104. // 表格列配置
  105. columns: [
  106. {
  107. columnKey: 'index',
  108. label: '序号',
  109. type: 'index',
  110. width: 55,
  111. align: 'center',
  112. showOverflowTooltip: true,
  113. fixed: 'left'
  114. },
  115. {
  116. columnKey: 'planCode',
  117. slot: 'planCode',
  118. prop: 'planCode',
  119. label: '计划单号',
  120. align: 'center',
  121. showOverflowTooltip: true,
  122. minWidth: 200
  123. },
  124. {
  125. prop: 'planName',
  126. label: '计划名称',
  127. align: 'center',
  128. showOverflowTooltip: true,
  129. minWidth: 110
  130. },
  131. {
  132. prop: 'ruleName',
  133. label: '计划规则',
  134. align: 'center',
  135. showOverflowTooltip: true,
  136. slot: 'enable',
  137. minWidth: 200
  138. },
  139. {
  140. prop: 'categoryLevelName',
  141. label: '设备分类',
  142. align: 'center',
  143. showOverflowTooltip: true,
  144. minWidth: 110
  145. },
  146. {
  147. prop: 'cycleType',
  148. label: '计划性质',
  149. align: 'center',
  150. showOverflowTooltip: true,
  151. minWidth: 110,
  152. formatter(item) {
  153. return { 1: '自动', 0: '手动' }[item.cycleType];
  154. }
  155. },
  156. {
  157. prop: 'planStatus',
  158. label: '状态',
  159. align: 'center',
  160. showOverflowTooltip: true,
  161. minWidth: 110,
  162. formatter(item) {
  163. return {
  164. 0: '待派单',
  165. 1: '已派单',
  166. 2: '执行中',
  167. 3: '已完成',
  168. 4: '已撤回',
  169. 5: '已驳回'
  170. }[item.planStatus];
  171. }
  172. },
  173. {
  174. prop: 'approvalUserName',
  175. label: '审批人',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 110
  179. },
  180. {
  181. prop: 'createUserName',
  182. label: '创建人',
  183. align: 'center',
  184. showOverflowTooltip: true,
  185. minWidth: 110
  186. },
  187. {
  188. prop: 'createTime',
  189. label: '生成时间',
  190. align: 'center',
  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. dict: {
  212. planStatus: {}
  213. }
  214. };
  215. },
  216. computed: {},
  217. async mounted() {
  218. const res = await getByCode('plan_status');
  219. const statusObject = Object.assign({}, ...res.data);
  220. this.dict.planStatus = statusObject;
  221. },
  222. methods: {
  223. /* 表格数据源 */
  224. datasource({ page, limit, where, order }) {
  225. return getPage({ pageNum: page, size: limit, ...where, planType: 2 });
  226. },
  227. async changeEnable(row) {
  228. const res = await putRoles(row);
  229. if (res.code == 0) {
  230. this.$message({
  231. type: 'success',
  232. message: '修改成功',
  233. customClass: 'ele-message-border'
  234. });
  235. this.reload();
  236. }
  237. },
  238. /* 刷新表格 */
  239. reload(where) {
  240. this.addProgramRulesDialog = false;
  241. this.$refs.table.reload({ page: 1, where });
  242. },
  243. handleWithdraw(row) {
  244. // 撤回
  245. this.$confirm(`确认撤回?`, '提示').then(async () => {
  246. revocation(row.id)
  247. .then(() => {
  248. this.$message.success('撤回成功!');
  249. this.reload();
  250. })
  251. .catch((err) => {
  252. this.$message.success(err.message || '撤回失败!');
  253. });
  254. });
  255. },
  256. // openAdd(dialogTitle, row) {
  257. // this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
  258. // },
  259. openAdd(dialogTitle, row) {
  260. // this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
  261. this.isBindPlan = false;
  262. this.addProgramRulesDialog = true;
  263. this.dialogTitle = dialogTitle;
  264. this.$nextTick(() => {
  265. this.$refs.programRulesDialog.init(row, '保养');
  266. });
  267. },
  268. // openDispatch(row) {
  269. // this.$refs.dispatchDialogRef.open(row);
  270. // },
  271. goDetail({ id }) {
  272. this.$router.push({
  273. path: '/maintenance/equipment/plan/details',
  274. query: {
  275. id
  276. }
  277. });
  278. }
  279. }
  280. };
  281. </script>
  282. <style lang="scss" scoped></style>