index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="计划编号" prop="planCode">
  5. <el-input
  6. v-model="queryParams.planCode"
  7. placeholder="请输入计划编号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="计划名称" prop="planName">
  13. <el-input
  14. v-model="queryParams.planName"
  15. placeholder="请输入计划名称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="计划类型" prop="planType">
  21. <el-select v-model="queryParams.planType" placeholder="请选择类型" clearable>
  22. <el-option
  23. v-for="dict in dict.type.dv_plan_type"
  24. :key="dict.value"
  25. :label="dict.label"
  26. :value="dict.value"
  27. />
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="状态" prop="status">
  31. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
  32. <el-option
  33. v-for="dict in dict.type.mes_order_status"
  34. :key="dict.value"
  35. :label="dict.label"
  36. :value="dict.value"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button v-no-more-click type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button v-no-more-click icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-col :span="1.5">
  47. <el-button v-no-more-click
  48. type="primary"
  49. plain
  50. icon="el-icon-plus"
  51. size="mini"
  52. @click="handleAdd"
  53. v-hasPermi="['mes:dv:checkplan:add']"
  54. >新增</el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button v-no-more-click
  58. type="success"
  59. plain
  60. icon="el-icon-edit"
  61. size="mini"
  62. :disabled="single"
  63. @click="handleUpdate"
  64. v-hasPermi="['mes:dv:checkplan:edit']"
  65. >修改</el-button>
  66. </el-col>
  67. <el-col :span="1.5">
  68. <el-button v-no-more-click
  69. type="danger"
  70. plain
  71. icon="el-icon-delete"
  72. size="mini"
  73. :disabled="multiple"
  74. @click="handleDelete"
  75. v-hasPermi="['mes:dv:checkplan:remove']"
  76. >删除</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button v-no-more-click
  80. type="warning"
  81. plain
  82. icon="el-icon-download"
  83. size="mini"
  84. @click="handleExport"
  85. v-hasPermi="['mes:dv:checkplan:export']"
  86. >导出</el-button>
  87. </el-col>
  88. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  89. </el-row>
  90. <el-table v-loading="loading" :data="checkplanList" @selection-change="handleSelectionChange">
  91. <el-table-column type="selection" width="55" align="center" />
  92. <el-table-column label="计划编码" align="center" prop="planCode" >
  93. <template slot-scope="scope">
  94. <el-button v-no-more-click
  95. type="text"
  96. @click="handleView(scope.row)"
  97. v-hasPermi="['mes:dv:checkplan:query']"
  98. >{{scope.row.planCode}}</el-button>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="计划名称" align="center" width="200px" prop="planName" />
  102. <el-table-column label="计划类型" align="center" width="120px" prop="planType">
  103. <template slot-scope="scope">
  104. <dict-tag :options="dict.type.dv_plan_type" :value="scope.row.planType"/>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="开始日期" align="center" prop="startDate" width="180">
  108. <template slot-scope="scope">
  109. <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="结束日期" align="center" prop="endDate" width="180">
  113. <template slot-scope="scope">
  114. <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="频率" align="center" prop="cycleType">
  118. <template slot-scope="scope">
  119. {{scope.row.cycleCount}}
  120. <dict-tag :options="dict.type.mes_cycle_type" :value="scope.row.cycleType"/>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="状态" align="center" prop="status">
  124. <template slot-scope="scope">
  125. <dict-tag :options="dict.type.mes_order_status" :value="scope.row.status"/>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="操作" align="center" width="130px" class-name="small-padding fixed-width">
  129. <template slot-scope="scope">
  130. <el-button v-no-more-click
  131. size="mini"
  132. type="text"
  133. icon="el-icon-edit"
  134. @click="handleUpdate(scope.row)"
  135. v-if="scope.row.status =='PREPARE'"
  136. v-hasPermi="['mes:dv:checkplan:edit']"
  137. >修改</el-button>
  138. <el-button v-no-more-click
  139. size="mini"
  140. type="text"
  141. icon="el-icon-delete"
  142. @click="handleDelete(scope.row)"
  143. v-if="scope.row.status =='PREPARE'"
  144. v-hasPermi="['mes:dv:checkplan:remove']"
  145. >删除</el-button>
  146. <el-button v-no-more-click
  147. size="mini"
  148. type="text"
  149. icon="el-icon-delete"
  150. @click="handleUpdate(scope.row)"
  151. v-if="scope.row.status =='FINISHED'"
  152. v-hasPermi="['mes:dv:checkplan:edit']"
  153. >停用</el-button>
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. <pagination
  158. v-show="total>0"
  159. :total="total"
  160. :page.sync="queryParams.pageNum"
  161. :limit.sync="queryParams.pageSize"
  162. @pagination="getList"
  163. />
  164. <!-- 添加或修改设备点检计划头对话框 -->
  165. <el-dialog :title="title" :visible.sync="open" width="960px" append-to-body>
  166. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  167. <el-row>
  168. <el-col :span="8">
  169. <el-form-item label="计划编码" prop="planCode">
  170. <el-input v-model="form.planCode" placeholder="请输入计划编码" />
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="4">
  174. <el-form-item label-width="80">
  175. <el-switch v-model="autoGenFlag"
  176. active-color="#13ce66"
  177. active-text="自动生成"
  178. @change="handleAutoGenChange(autoGenFlag)" v-if="optType != 'view'">
  179. </el-switch>
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="12">
  183. <el-form-item label="计划名称" prop="planName">
  184. <el-input v-model="form.planName" placeholder="请输入计划名称" />
  185. </el-form-item>
  186. </el-col>
  187. </el-row>
  188. <el-row>
  189. <el-col :span="12">
  190. <el-form-item label="计划类型" prop="planType" >
  191. <el-select v-model="form.planType" placeholder="请选择计划类型">
  192. <el-option
  193. v-for="dict in dict.type.dv_plan_type"
  194. :key="dict.value"
  195. :label="dict.label"
  196. :value="dict.value"
  197. ></el-option>
  198. </el-select>
  199. </el-form-item>
  200. </el-col>
  201. <el-col :span="8">
  202. <el-form-item label="频率" prop="cycleCount">
  203. <el-input-number :min="1" :step="1" v-model="form.cycleCount" placeholder="请输入次数" />
  204. </el-form-item>
  205. </el-col>
  206. <el-col :span="4" >
  207. <el-form-item prop="cycleType" label-width="80">
  208. <el-select v-model="form.cycleType" placeholder="请选择频率">
  209. <el-option
  210. v-for="dict in dict.type.mes_cycle_type"
  211. :key="dict.value"
  212. :label="dict.label"
  213. :value="dict.value"
  214. ></el-option>
  215. </el-select>
  216. </el-form-item>
  217. </el-col>
  218. </el-row>
  219. <el-row>
  220. <el-col :span="8">
  221. <el-form-item label="开始日期" prop="startDate">
  222. <el-date-picker clearable
  223. v-model="form.startDate"
  224. type="date"
  225. value-format="yyyy-MM-dd"
  226. placeholder="请选择开始日期">
  227. </el-date-picker>
  228. </el-form-item>
  229. </el-col>
  230. <el-col :span="8">
  231. <el-form-item label="结束日期" prop="endDate">
  232. <el-date-picker clearable
  233. v-model="form.endDate"
  234. type="date"
  235. value-format="yyyy-MM-dd"
  236. placeholder="请选择结束日期">
  237. </el-date-picker>
  238. </el-form-item>
  239. </el-col>
  240. <el-col :span="8">
  241. <el-form-item label="状态" prop="status">
  242. <el-select v-model="form.status" disabled>
  243. <el-option
  244. v-for="dict in dict.type.mes_order_status"
  245. :key="dict.value"
  246. :label="dict.label"
  247. :value="dict.value"
  248. ></el-option>
  249. </el-select>
  250. </el-form-item>
  251. </el-col>
  252. </el-row>
  253. <el-row>
  254. <el-col :span="24">
  255. <el-form-item label="备注" prop="remark">
  256. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  257. </el-form-item>
  258. </el-col>
  259. </el-row>
  260. </el-form>
  261. <el-tabs type="border-card" v-if="form.planId != null">
  262. <el-tab-pane label="设备清单">
  263. <Checkmachinery ref="machinerylist" :optType="optType" :planId="form.planId" ></Checkmachinery>
  264. </el-tab-pane>
  265. <el-tab-pane :label="form.planType=='CHECK'?'点检项目':'保养项目'">
  266. <Checksubject ref="subjectlist" :optType="optType" :planId="form.planId" ></Checksubject>
  267. </el-tab-pane>
  268. </el-tabs>
  269. <div slot="footer" class="dialog-footer">
  270. <el-button v-no-more-click type="primary" @click="cancel" v-if="optType =='view' || form.status !='PREPARE' ">返回</el-button>
  271. <el-button v-no-more-click type="primary" @click="submitForm" v-if="form.status =='PREPARE' && optType !='view' ">保存</el-button>
  272. <el-button v-no-more-click type="success" @click="handleFinish" v-if="form.status =='PREPARE' && optType !='view' && form.planId !=null">启用</el-button>
  273. <el-button v-no-more-click type="success" @click="handleDeFinish" v-if="form.status =='FINISHED' && optType !='view' && form.planId !=null">停用</el-button>
  274. <el-button v-no-more-click @click="cancel">取 消</el-button>
  275. </div>
  276. </el-dialog>
  277. </div>
  278. </template>
  279. <script>
  280. import { listCheckplan, getCheckplan, delCheckplan, addCheckplan, updateCheckplan } from "@/api/mes/dv/checkplan";
  281. import Checkmachinery from "./machinery.vue"
  282. import Checksubject from "./subject.vue"
  283. import {genCode} from "@/api/system/autocode/rule"
  284. export default {
  285. name: "Checkplan",
  286. dicts: ['mes_cycle_type','mes_order_status','dv_plan_type'],
  287. components:{Checkmachinery,Checksubject},
  288. data() {
  289. return {
  290. autoGenFlag: false,
  291. optType: null,
  292. // 遮罩层
  293. loading: true,
  294. // 选中数组
  295. ids: [],
  296. // 非单个禁用
  297. single: true,
  298. // 非多个禁用
  299. multiple: true,
  300. // 显示搜索条件
  301. showSearch: true,
  302. // 总条数
  303. total: 0,
  304. // 设备点检计划头表格数据
  305. checkplanList: [],
  306. // 弹出层标题
  307. title: "",
  308. // 是否显示弹出层
  309. open: false,
  310. // 查询参数
  311. queryParams: {
  312. pageNum: 1,
  313. pageSize: 10,
  314. planCode: null,
  315. planName: null,
  316. startDate: null,
  317. endDate: null,
  318. cycleType: null,
  319. cycleCount: null,
  320. status: null
  321. },
  322. // 表单参数
  323. form: {},
  324. // 表单校验
  325. rules: {
  326. planCode: [
  327. { required: true, message: "计划编码不能为空", trigger: "blur" }
  328. ],
  329. planName: [
  330. { required: true, message: "计划名称不能为空", trigger: "blur" }
  331. ],
  332. planType:[
  333. { required: true, message: "计划类型不能为空", trigger: "blur" }
  334. ],
  335. cycleType: [
  336. { required: true, message: "请选择点检频率", trigger: "blur" }
  337. ],
  338. cycleCount: [
  339. { required: true, message: "请输入点检次数", trigger: "blur" }
  340. ],
  341. }
  342. };
  343. },
  344. created() {
  345. this.getList();
  346. },
  347. methods: {
  348. /** 查询设备点检计划头列表 */
  349. getList() {
  350. this.loading = true;
  351. listCheckplan(this.queryParams).then(response => {
  352. this.checkplanList = response.rows;
  353. this.total = response.total;
  354. this.loading = false;
  355. });
  356. },
  357. // 取消按钮
  358. cancel() {
  359. this.open = false;
  360. this.reset();
  361. },
  362. // 表单重置
  363. reset() {
  364. this.form = {
  365. planId: null,
  366. planCode: null,
  367. planName: null,
  368. planType: null,
  369. startDate: null,
  370. endDate: null,
  371. cycleType: null,
  372. cycleCount: null,
  373. status: 'PREPARE',
  374. remark: null,
  375. attr1: null,
  376. attr2: null,
  377. attr3: null,
  378. attr4: null,
  379. createBy: null,
  380. createTime: null,
  381. updateBy: null,
  382. updateTime: null
  383. };
  384. this.autoGenFlag = false;
  385. this.resetForm("form");
  386. },
  387. /** 搜索按钮操作 */
  388. handleQuery() {
  389. this.queryParams.pageNum = 1;
  390. this.getList();
  391. },
  392. /** 重置按钮操作 */
  393. resetQuery() {
  394. this.resetForm("queryForm");
  395. this.handleQuery();
  396. },
  397. // 多选框选中数据
  398. handleSelectionChange(selection) {
  399. this.ids = selection.map(item => item.planId)
  400. this.single = selection.length!==1
  401. this.multiple = !selection.length
  402. },
  403. /** 新增按钮操作 */
  404. handleAdd() {
  405. this.reset();
  406. this.open = true;
  407. this.title = "添加计划";
  408. this.optType = "add";
  409. },
  410. // 查询明细按钮操作
  411. handleView(row){
  412. this.reset();
  413. const planId = row.planId || this.ids;
  414. getCheckplan(planId).then(response => {
  415. this.form = response.data;
  416. this.open = true;
  417. this.title = "查看计划信息";
  418. this.optType = "view";
  419. });
  420. },
  421. /** 修改按钮操作 */
  422. handleUpdate(row) {
  423. this.reset();
  424. const planId = row.planId || this.ids
  425. getCheckplan(planId).then(response => {
  426. this.form = response.data;
  427. this.open = true;
  428. this.title = "修改计划";
  429. this.optType = "edit";
  430. });
  431. },
  432. /** 提交按钮 */
  433. submitForm() {
  434. this.$refs["form"].validate(valid => {
  435. if (valid) {
  436. if (this.form.planId != null) {
  437. updateCheckplan(this.form).then(response => {
  438. this.$modal.msgSuccess("修改成功");
  439. this.open = false;
  440. this.getList();
  441. });
  442. } else {
  443. addCheckplan(this.form).then(response => {
  444. this.$modal.msgSuccess("新增成功");
  445. this.open = false;
  446. this.getList();
  447. });
  448. }
  449. }
  450. });
  451. },
  452. handleFinish(){
  453. if(this.form.planId != null && this.form.status =='PREPARE'){
  454. this.form.status='FINISHED';
  455. updateCheckplan(this.form).then(response => {
  456. this.$modal.msgSuccess("已启用");
  457. this.open = false;
  458. this.getList();
  459. },err =>{
  460. this.form.status='PREPARE';
  461. });
  462. }
  463. },
  464. handleDeFinish(){
  465. if(this.form.planId != null && this.form.status =='FINISHED'){
  466. this.form.status='PREPARE';
  467. updateCheckplan(this.form).then(response => {
  468. this.$modal.msgSuccess("已停用");
  469. this.open = false;
  470. this.getList();
  471. },err =>{
  472. this.form.status='FINISHED';
  473. });
  474. }
  475. },
  476. /** 删除按钮操作 */
  477. handleDelete(row) {
  478. const planIds = row.planId || this.ids;
  479. this.$modal.confirm('是否确认删除计划编号为"' + planIds + '"的数据项?').then(function() {
  480. return delCheckplan(planIds);
  481. }).then(() => {
  482. this.getList();
  483. this.$modal.msgSuccess("删除成功");
  484. }).catch(() => {});
  485. },
  486. /** 导出按钮操作 */
  487. handleExport() {
  488. this.download('dv/checkplan/export', {
  489. ...this.queryParams
  490. }, `checkplan_${new Date().getTime()}.xlsx`)
  491. },
  492. //自动生成编码
  493. handleAutoGenChange(autoGenFlag){
  494. if(autoGenFlag){
  495. genCode('CHECKPLAN_CODE').then(response =>{
  496. this.form.planCode = response;
  497. });
  498. }else{
  499. this.form.planCode = null;
  500. }
  501. }
  502. }
  503. };
  504. </script>