Bladeren bron

保养计划优化

wyh 1 jaar geleden
bovenliggende
commit
1601bc23f8

+ 63 - 22
src/views/module_cmms/upkeepPlan/UpkeepPlanList.vue

@@ -88,6 +88,10 @@
         class="j-table-force-nowrap"
         @change="handleTableChange">
 
+        <template slot="status"  slot-scope="text, record">
+          <a-switch :checked= "record.status == 0 ? true : false" @click="statusChange(record,$event)" />
+        </template>
+
         <template slot="htmlSlot" slot-scope="text">
           <div v-html="text"></div>
         </template>
@@ -139,6 +143,7 @@
   import '@/assets/less/TableExpand.less'
   import { mixinDevice } from '@/utils/mixin'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+  import { httpAction, getAction } from '@/api/manage'
   import UpkeepPlanModal from './modules/UpkeepPlanModal'
 
   export default {
@@ -172,6 +177,11 @@
             align:"center",
             dataIndex: 'planname'
           },
+          {
+            title:'设备',
+            align:"center",
+            dataIndex: 'equipmentName'
+          },
           // {
           //   title:'保养工作项目ID',
           //   align:"center",
@@ -221,62 +231,59 @@
             title:'开始时间',
             align:"center",
             dataIndex: 'begintime',
-            customRender:function (text) {
-              return !text?"":(text.length>10?text.substr(0,10):text)
-            }
+            // customRender:function (text) {
+            //   return !text?"":(text.length>10?text.substr(0,10):text)
+            // }
           },
           {
-            title:'重复',
+            title:'重复间隔',
             align:"center",
             dataIndex: 'repeatnum'
           },
           {
-            title:'重复类型:年、月、周、日、时、分',
+            title:'间隔单位',
             align:"center",
             dataIndex: 'repeattype'
           },
           {
-            title:'提前通知时',
+            title:'提前通知时',
             align:"center",
             dataIndex: 'noticenum'
           },
           {
-            title:'提前通知类型:天、时、分',
+            title:'时长单位',
             align:"center",
             dataIndex: 'noticetype'
           },
+          // 状态(0启用 1停用)
           {
-            title:'状态(0启用 1停用)',
+            title:'状态',
             align:"center",
-            dataIndex: 'status'
+            dataIndex: 'status',
+            scopedSlots: { customRender: 'status' }
           },
           {
             title:'下次执行时间',
             align:"center",
             dataIndex: 'nexttime',
-            customRender:function (text) {
-              return !text?"":(text.length>10?text.substr(0,10):text)
-            }
+            // customRender:function (text) {
+            //   return !text?"":(text.length>10?text.substr(0,10):text)
+            // }
           },
           {
             title:'下次通知时间',
             align:"center",
             dataIndex: 'noticetime',
-            customRender:function (text) {
-              return !text?"":(text.length>10?text.substr(0,10):text)
-            }
+            // customRender:function (text) {
+            //   return !text?"":(text.length>10?text.substr(0,10):text)
+            // }
           },
           {
-            title:'是否已通知:是/否',
+            title:'通知状态',
             align:"center",
             dataIndex: 'ifnotice'
           },
           {
-            title:'设备id(根据设备id查找保养项内容)',
-            align:"center",
-            dataIndex: 'equipmentid'
-          },
-          {
             title:'备注',
             align:"center",
             dataIndex: 'remark'
@@ -296,10 +303,11 @@
           deleteBatch: "/cmmsUpkeepPlan/cmmsUpkeepPlan/deleteBatch",
           exportXlsUrl: "/cmmsUpkeepPlan/cmmsUpkeepPlan/exportXls",
           importExcelUrl: "cmmsUpkeepPlan/cmmsUpkeepPlan/importExcel",
-          
+          edit: "/cmmsUpkeepPlan/cmmsUpkeepPlan/updateCmmsUpkeepPlanStatusById",
         },
         dictOptions:{},
         superFieldList:[],
+        model: {}
       }
     },
     created() {
@@ -338,6 +346,39 @@
         fieldList.push({type:'string',value:'ifnotice',text:'是否已通知:是/否',dictCode:''})
         fieldList.push({type:'string',value:'equipmentid',text:'设备id(根据设备id查找保养项内容)',dictCode:''})
         this.superFieldList = fieldList
+      },
+      statusChange(record,$event){
+        console.log(record.status,$event)
+        let text1 = record.status === "0" ? "是否确认停用“" : "是否确认使用“";
+        let text2 = record.status === "0" ? "”,请确保该设备有可使用的保养计划" : "”,若启用当前保养计划则该设备其他保养计划默认禁用";
+        const that = this
+        that.$confirm({
+          title: "提示",
+          content: text1 + record.planname + text2,
+          onOk() {
+            let httpurl = '';
+            let method = 'put';
+            httpurl+=that.url.edit;
+            if (record.status == 1) {
+              that.model.id = record.id
+              that.model.status = 0
+            } else {
+              that.model.id = record.id
+              that.model.status = 1
+            }
+            httpAction(httpurl,that.model,method).then((res)=>{
+              if(res.success){
+                that.$message.success(res.message);
+                that.modalFormOk()
+              }else{
+                that.$message.warning(res.message);
+              }
+            })
+          },
+          onCancel() {
+            // that.modalFormOk()
+          }
+        });
       }
     }
   }

+ 41 - 8
src/views/module_cmms/upkeepPlan/modules/UpkeepPlanForm.vue

@@ -219,22 +219,27 @@
         },
         columns: [
           {
-            title:'保养项名称',
+            title:'保养项ID',
             align:"center",
-            dataIndex: 'itemname'
+            dataIndex: 'id'
           },
           {
-            title:'设备类型',
+            title:'保养项名称',
             align:"center",
-            dataIndex: 'equiptypeName'
+            dataIndex: 'itemname'
           },
+          // {
+          //   title:'设备类型',
+          //   align:"center",
+          //   dataIndex: 'equiptypeName'
+          // },
           {
-            title:'保养编号',
+            title:'保养编号',
             align:"center",
             dataIndex: 'itemcode'
           },
           {
-            title:'保养标准',
+            title:'保养标准',
             align:"center",
             dataIndex: 'itemcontent'
           },
@@ -257,10 +262,25 @@
     },
     methods: {
       add () {
-        this.edit(this.modelDefault);
+        // this.edit(this.modelDefault);
+        this.model = Object.assign({}, this.modelDefault);
+        this.visible = true;
       },
       edit (record) {
-        this.model = Object.assign({}, record);
+        // this.model = Object.assign({}, record);
+        getAction(this.url.queryById, record).then((res) => {
+            console.log(88,res)
+            this.model = res.result
+            // this.model.cmmsUpkeepItemDtoList = this.model.cmmsUpkeepItemDtoList.map((res) => {
+            //   return {
+            //     id: id,
+            //     itemcode: res.itemcode,
+            //     itemname: res.itemname,
+            //     itemcontent: res.itemcontent,
+            //     remark: res.remark
+            //   }
+            // })
+        })
         this.visible = true;
       },
       submitForm () {
@@ -274,10 +294,23 @@
             if(!this.model.id){
               httpurl+=this.url.add;
               method = 'post';
+              // 默认状态是禁用
+              this.model.status = 1
+              this.model.cmmsUpkeepItemDtoList = this.model.cmmsUpkeepItemDtoList.map((res) => {
+                return {
+                  id: res.id
+                }
+              })
             }else{
               httpurl+=this.url.edit;
                method = 'put';
+               this.model.cmmsUpkeepItemDtoList = this.model.cmmsUpkeepItemDtoList.map((res) => {
+                return {
+                  id: res.id
+                }
+              })
             }
+            console.log(999,this.model)
             httpAction(httpurl,this.model,method).then((res)=>{
               if(res.success){
                 that.$message.success(res.message);

+ 11 - 6
src/views/module_cmms/upkeepPlan/modules/UpkeepPlanModalAdd.vue

@@ -57,22 +57,27 @@ import { httpAction, getAction } from '@/api/manage'
         selectionRows: [],
         columns: [
           {
-            title:'保养项名称',
+            title:'保养项ID',
             align:"center",
-            dataIndex: 'itemname'
+            dataIndex: 'id'
           },
           {
-            title:'设备类型',
+            title:'保养项名称',
             align:"center",
-            dataIndex: 'equiptypeName'
+            dataIndex: 'itemname'
           },
+          // {
+          //   title:'设备类型',
+          //   align:"center",
+          //   dataIndex: 'equiptypeName'
+          // },
           {
-            title:'保养编号',
+            title:'保养编号',
             align:"center",
             dataIndex: 'itemcode'
           },
           {
-            title:'保养标准',
+            title:'保养标准',
             align:"center",
             dataIndex: 'itemcontent'
           },