Explorar o código

巡检工单及其他优化

yuhan hai 1 ano
pai
achega
a5c3ff84e0

+ 11 - 2
src/components/module_ems/UModal/UModal.vue

@@ -28,8 +28,13 @@
           <a-icon :type="isModalFull?'menu-unfold':'menu-fold'" @click="isModalFull = !isModalFull"/>
           <!-- <a-icon type="column-width" /> -->
           <a-icon :type="isContentFull?'pic-right':'pic-center'" @click="isContentFull = !isContentFull"/>
-          <a-button type="primary" @click="handleOk">确定</a-button>
-          <a-button @click="handleCancel">取消</a-button>
+          <template v-if="bottons">
+            <a-button type="primary" @click="handleOk">确定</a-button>
+            <a-button @click="handleCancel">取消</a-button>
+          </template>
+          <template v-if="!bottons">
+            <a-button @click="handleCancel">返回</a-button>
+          </template>
         </a-col>
       </a-row>
     </template>
@@ -90,6 +95,10 @@ export default {
         type: Boolean,
         default: false
       },
+      bottons: {
+        type: Boolean,
+        default: true
+      },
       // 是否允许切换全屏(允许后右上角会出现一个按钮)
       // switchFullscreen: {
       //   type: Boolean,

+ 9 - 9
src/views/module_cmms/inspect/InspectList.vue

@@ -5,8 +5,8 @@
       <a-form layout="inline" @keyup.enter.native="searchQuery">
         <a-row :gutter="24">
           <a-col :xl="6" :lg="7" :md="8" :sm="24">
-            <a-form-item label="巡检计划名称">
-              <a-input placeholder="请输入巡检计划名称" v-model="queryParam.planname"></a-input>
+            <a-form-item label="工单名称">
+              <a-input placeholder="请输入工单名称" v-model="queryParam.inspectname"></a-input>
             </a-form-item>
           </a-col>
           <a-col :xl="6" :lg="7" :md="8" :sm="24">
@@ -83,22 +83,22 @@
         </template>
 
         <span slot="action" slot-scope="text, record">
-          <a @click="handleEdit(record)">巡检</a>
+          <a @click="handleEdit(record)">巡检反馈</a>
 
-          <a-divider type="vertical" />
+          <!-- <a-divider type="vertical" />
           <a-dropdown>
             <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
             <a-menu slot="overlay">
               <a-menu-item>
                 <a @click="handleDetail(record)">详情</a>
               </a-menu-item>
-              <!-- <a-menu-item>
+              <a-menu-item>
                 <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                   <a>删除</a>
                 </a-popconfirm>
-              </a-menu-item> -->
+              </a-menu-item>
             </a-menu>
-          </a-dropdown>
+          </a-dropdown> -->
         </span>
 
       </a-table>
@@ -147,14 +147,14 @@
             dataIndex: 'inspectname'
           },
           {
-            title:'任务类型:单次任务、周期任务',
+            title:'任务类型',
             align:"center",
             dataIndex: 'tasktype'
           },
           {
             title:'状态',
             align:"center",
-            dataIndex: 'status_dict'
+            dataIndex: 'status_dictText'
           },
           {
             title:'巡检细项',

+ 47 - 45
src/views/module_cmms/inspect/modules/InspectForm.vue

@@ -3,26 +3,33 @@
     <j-form-container :disabled="formDisabled">
       <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
         <a-row class="inspect-order-layout">
-          <a-col :span="8" class="inspect-tree">
+          <a-col :span="6" class="inspect-tree">
             <a-tree
               :tree-data="treeData"
               show-icon
-              default-expand-all
               showLine
+              default-expand-all
               :selected-keys="selectedKeys"
               :replaceFields="replaceFields"
               @select="onSelect"
-            >
-              <a-icon slot="switcherIcon" type="down" />
-              <a-icon slot="smile" type="smile-o" />
-              <a-icon slot="meh" type="smile-o" />
-              <template slot="custom" slot-scope="{ selected }">
-                <a-icon :type="selected ? 'frown' : 'frown-o'" />
+              >
+              <!-- 每项 最前面的 箭头的 icon -->
+              <a-icon slot="switcherIcon" type="caret-down" />
+              <!-- slot="praent" 配合 treeData数据中的 slots 设置目录下 的 icon -->
+              <!-- <a-icon slot="parent" style="color:#0DD3FF" type="folder-open" /> -->
+              <!-- slot="child" 配合 treeData数据children下的 slots 设置children目录 的 icon -->
+              <!-- <a-icon slot="child" style="color:#FED037" type="folder-open" /> -->
+              <!-- 数据中 每个 节点 的 scopedSlots 字段(插槽) 用来设置 所有(子父节点)节点  的 统一的 icon-->
+              <template slot="handle" slot-scope="item">
+                <!--item.title 为treeData的 title 字段-->
+                <span>{{item.title}}</span>
+                <!-- completionStatus === '1'表示已完成 -->
+                <a-icon type="check-circle" theme="twoTone" two-tone-color="#52c41a" v-if="item.completionStatus === '1'" style="margin-left: 4px;"/>
               </template>
             </a-tree>
           </a-col>
-          <a-col :span="16" class="itemList-table">
-            <a-button @click="handleFeedback">提交反馈</a-button>
+          <a-col :span="18" class="itemList-table">
+            <a-button type="primary" @click="handleFeedback" style="margin-bottom: 8px;float: right;z-index: 9999;">提交反馈</a-button>
             <a-table
               ref="table"
               size="middle"
@@ -60,21 +67,29 @@
 
 <script>
 
-const treeData = [
+const treeData1 = [
   {
     title: '测试123456',
     key: '1111111111111',
     type: '巡检路线',
+    completionStatus: '0',
+    slots: { icon: 'parent', },
+    // ⚠️重点这这里⚠️每一条数据上都添加scopedSlots属性
+    scopedSlots:{ title:"handle" },
     children: [
       {
         title: '测试巡检点的修改NO1',
         key: '12223333333',
         type: '巡检点',
+        slots: { icon: 'child', },
+        // ⚠️重点这这里⚠️每一条数据上都添加scopedSlots属性
+        scopedSlots:{ title:"handle" },
         children: [
           {
             title: '半自动立钻Z5180C',
             key: '55555555555',
             type: '巡检内容',
+            scopedSlots:{ title:"handle" },
             ItemList: [
               // 巡检项相关信息
             ]
@@ -87,6 +102,8 @@ const treeData = [
     title: '测试巡检点的修改NO2',
     key: '456293324552',
     type: '巡检点',
+    completionStatus: '1',
+    scopedSlots:{ title:"handle" },
     children: [
       {
         title: '半自动立钻Z5180D',
@@ -200,9 +217,6 @@ const treeData = [
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
     },
     methods: {
-      add () {
-        this.edit(this.modelDefault);
-      },
       edit (record) {
         // this.model = Object.assign({}, record);
         this.visible = true;
@@ -297,12 +311,29 @@ const treeData = [
         // })
         getAction(this.url.queryTreeById, {id: record.id}).then((res) => {
           console.log(res)
-          this.model = res.result
+          if(this.selectedKeys.length === 0){
+            this.model = res.result
+          }
           // this.model.itemList = []
-          this.treeData = res.result.children
+          this.treeData = this.setIcon(res.result.children)
           this.confirmLoading = false
         })
       },
+      // 设置树结构图标
+      setIcon(data) {
+        var setIconData = data
+        for (let item of setIconData) {
+          //   判断是不是父级
+          if (item.children && item.children.length > 0) {
+            //是父级的话递归调用
+            this.setIcon(item.children);
+            item.scopedSlots = { title: "handle" }
+          } else {
+            item.scopedSlots = { title: "handle" }
+          }
+        }
+        return setIconData
+      },
       onSelect(selectedKeys, info) {
         //  二次点击树节点时selectedKeys为空,直接return中断执行
         if (selectedKeys.length === 0) return
@@ -338,35 +369,6 @@ const treeData = [
           this.confirmLoading = false;
         })
       },
-      submitForm () {
-        const that = this;
-        // 触发表单验证
-        this.$refs.form.validate(valid => {
-          if (valid) {
-            that.confirmLoading = true;
-            let httpurl = '';
-            let method = '';
-            if(!this.model.id){
-              httpurl+=this.url.add;
-              method = 'post';
-            }else{
-              httpurl+=this.url.edit;
-               method = 'put';
-            }
-            httpAction(httpurl,this.model,method).then((res)=>{
-              if(res.success){
-                that.$message.success(res.message);
-                that.$emit('ok');
-              }else{
-                that.$message.warning(res.message);
-              }
-            }).finally(() => {
-              that.confirmLoading = false;
-            })
-          }
-         
-        })
-      },
     }
   }
 </script>

+ 3 - 15
src/views/module_cmms/inspect/modules/InspectModal.vue

@@ -3,9 +3,10 @@
     :title="title"
     :visible.sync="visible"
     contentFull
-    @ok="handleOk"
+    :bottons="false"
     @cancel="handleCancel">
-    <inspect-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></inspect-form>
+
+    <inspect-form ref="realForm" :disabled="disableSubmit"></inspect-form>
   </u-modal>
 </template>
 
@@ -26,12 +27,6 @@
       }
     },
     methods: {
-      add () {
-        this.visible=true
-        this.$nextTick(()=>{
-          this.$refs.realForm.add();
-        })
-      },
       edit (record) {
         this.visible=true
         this.$nextTick(()=>{
@@ -42,13 +37,6 @@
         this.$emit('close');
         this.visible = false;
       },
-      handleOk () {
-        this.$refs.realForm.submitForm();
-      },
-      submitCallback(){
-        this.$emit('ok');
-        this.visible = false;
-      },
       handleCancel () {
         this.close()
       }

+ 53 - 21
src/views/module_cmms/inspectPlan/InspectPlanList.vue

@@ -9,6 +9,18 @@
               <a-input placeholder="请输入巡检计划名称" v-model="queryParam.planname"></a-input>
             </a-form-item>
           </a-col>
+          <template v-if="toggleSearchStatus">
+            <a-col :xl="6" :lg="7" :md="8" :sm="24">
+              <a-form-item label="是否开启时间设置">
+                <j-dict-select-tag v-model="queryParam.iftimeset" dictCode="common_yes_no" placeholder="请选择是否开启时间设置" />
+              </a-form-item>
+            </a-col>
+            <a-col :xl="6" :lg="7" :md="8" :sm="24">
+              <a-form-item label="状态">
+                <j-dict-select-tag v-model="queryParam.status" dictCode="common_status" placeholder="请选择状态" />
+              </a-form-item>
+            </a-col>
+          </template>
           <a-col :xl="6" :lg="7" :md="8" :sm="24">
             <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
               <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
@@ -82,6 +94,10 @@
           </a-button>
         </template>
 
+        <span slot="iftimeset" slot-scope="text, record">
+          <a-tag v-if="record.iftimeset === 'Y'" color="blue">是</a-tag>
+          <a-tag v-if="record.iftimeset === 'N'">否</a-tag>
+        </span>
         <template slot="status" slot-scope="text, record">
           <a-switch :checked="record.status === '0' ? true : false" checked-children="启动" un-checked-children="停用" @click="changeStatus(record)"/>
           <!--  checked-children="启动" un-checked-children="停用" -->
@@ -89,9 +105,14 @@
 
         <span slot="action" slot-scope="text, record">
           <a @click="handleEdit(record)">编辑</a>
-
           <a-divider type="vertical" />
-          <a-dropdown>
+          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
+            <a>删除</a>
+          </a-popconfirm>
+          <a-divider type="vertical" />
+          <a @click="handleOneOrder(record)">生成一次工单</a>
+
+          <!-- <a-dropdown>
             <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
             <a-menu slot="overlay">
               <a-menu-item>
@@ -103,7 +124,7 @@
                 </a-popconfirm>
               </a-menu-item>
             </a-menu>
-          </a-dropdown>
+          </a-dropdown> -->
         </span>
 
       </a-table>
@@ -154,7 +175,24 @@
           {
             title:'是否开启时间设置',
             align:"center",
-            dataIndex: 'iftimeset'
+            dataIndex: 'iftimeset',
+            scopedSlots: { customRender: 'iftimeset' }
+          },
+          {
+            title:'待办人',
+            align:"center",
+            dataIndex: 'chargeruser'
+          },
+          {
+            title:'任务数量',
+            align:"center",
+            dataIndex: 'tasknum'
+          },
+          {
+            title:'状态',
+            align:"center",
+            dataIndex: 'status',
+            scopedSlots: { customRender: 'status' }
           },
           {
             title:'开始时间',
@@ -191,17 +229,6 @@
           //   dataIndex: 'noticetype'
           // },
           {
-            title:'状态',
-            align:"center",
-            dataIndex: 'status',
-            scopedSlots: { customRender: 'status' }
-          },
-          {
-            title:'待办人',
-            align:"center",
-            dataIndex: 'chargeruser'
-          },
-          {
             title:'下次执行时间',
             align:"center",
             dataIndex: 'nexttime',
@@ -210,11 +237,6 @@
             }
           },
           {
-            title:'任务数量',
-            align:"center",
-            dataIndex: 'tasknum'
-          },
-          {
             title:'下次通知时间',
             align:"center",
             dataIndex: 'noticetime',
@@ -248,7 +270,7 @@
           exportXlsUrl: "/cmmsInspectPlan/cmmsInspectPlan/exportXls",
           importExcelUrl: "cmmsInspectPlan/cmmsInspectPlan/importExcel",
           updateStatus: "cmmsInspectPlan/cmmsInspectPlan/updateStatus",
-          
+          generateinspect: "/cmmsInspectPlan/cmmsInspectPlan/generateinspect"
         },
         dictOptions:{},
         superFieldList:[],
@@ -287,6 +309,16 @@
           }
         });
       },
+      // 生成一次工单
+      handleOneOrder(record){
+        getAction(this.url.generateinspect, {id: record.id}).then((res)=>{
+          if(res.success){
+            this.$message.success(res.message);
+          }else{
+            this.$message.warning(res.message);
+          }
+        })
+      },
       initDictConfig(){
       },
       getSuperFieldList(){

+ 6 - 0
src/views/module_cmms/inspectPlan/modules/InspectPlanFormSet.vue

@@ -107,6 +107,12 @@
           chargeruser: [
             { required: true, message: '请选择负责人!'},
           ],
+          iftimeset: [
+            { required: true, message: '请选择!'},
+          ],
+          status: [
+            { required: true, message: '请选择!'},
+          ],
           begintime: [
             { required: true, message: '请选择开始时间!'},
           ],