lyh
2025-04-03 78e463e1dbab2dae9cbf98d4f976c08600ba6b3b
点检工单
已添加5个文件
971 ■■■■■ 文件已修改
src/views/eam/equipment/modules/MaintenanceEquipmentSelect.vue 166 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/maintenance/EamInspectionOrderList.vue 280 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/maintenance/modules/EamInspectionOrderDetailForm.vue 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/maintenance/modules/EamInspectionOrderForm.vue 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/maintenance/modules/EamInspectionOrderModal.vue 237 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/equipment/modules/MaintenanceEquipmentSelect.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,166 @@
<template>
  <a-select
    showSearch
    labelInValue
    :disabled="disabled"
    :getPopupContainer="getParentContainer"
    @search="loadData"
    :placeholder="placeholder"
    v-model="selectedAsyncValue"
    style="width: 100%"
    :filterOption="false"
    @change="handleAsyncChange"
    allowClear
    :notFoundContent="loading ? undefined : null"
    mode="default"
  >
    <template #suffixIcon>
      <a-icon type="search" />
    </template>
    <a-spin v-if="loading" slot="notFoundContent" size="small" />
    <a-select-option v-for="d in options" :key="d.value" :value="d.value">{{ d.text }}</a-select-option>
  </a-select>
</template>
<script>
import debounce from 'lodash/debounce'
import { getAction } from '@/api/manage'
export default {
  name: 'MaintenanceEquipmentSelect',
  props: {
    disabled: Boolean,
    value: [String, Number],
    placeholder: {
      type: String,
      default: '请选择',
      required: false
    },
    pageSize: {
      type: Number,
      default: 20,
      required: false
    },
  },
  data() {
    this.loadData = debounce(this.loadData, 800)//消抖
    this.lastLoad = 0
    return {
      loading: false,
      selectedValue: undefined,
      selectedAsyncValue: undefined,
      options: []
    }
  },
  created() {
    // this.initDictData()
  },
  watch: {
    'value': {
      immediate: true,
      handler(val) {
        if (!val) {
          this.initDictData();
        } else {
          this.initSelectValue()
        }
      }
    }
  },
  methods: {
    initSelectValue() {
      if(!this.selectedAsyncValue || !this.selectedAsyncValue.key || this.selectedAsyncValue.key!=this.value){
        console.log("这才请求后台")
        getAction(`/eam/maintenanceStandard/listByUser`, { id: this.value }).then(res=>{
          if(res.success){
            if(res.result && res.result.length > 0){
              let obj = {
                key : this.value,
                label: res.result[0].text
              }
              this.selectedAsyncValue = {...obj};
            }
            this.options = res.result;
          }
        })
      }
    },
    loadData(value) {
      console.log('数据加载', value)
      this.lastLoad += 1
      const currentLoad = this.lastLoad
      this.options = []
      this.loading = true
      // å­—å…¸code格式:table,text,code
      getAction(`/eam/maintenanceStandard/listByUser`, { keyword: value, pageSize: this.pageSize }).then(res => {
        this.loading = false
        if (res.success) {
          if (currentLoad != this.lastLoad) {
            return
          }
          this.options = res.result
          console.log('我是第一个', res)
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    initDictData() {
      //异步一开始也加载一点数据
      this.loading = true
      getAction(`/eam/maintenanceStandard/listByUser`, { pageSize: this.pageSize, keyword: '' }).then(res => {
        this.loading = false
        if (res.success) {
          this.options = [...res.result]
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    filterOption(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    },
    handleAsyncChange(selectedObj) {
      //update-begin-author:scott date:20201222 for:【搜索】搜索查询组件,删除条件,默认下拉还是上次的缓存数据,不好 JT-191
      if (selectedObj) {
        this.selectedAsyncValue = selectedObj
        //update-begin---author:wangshuai ---date:20221115  for:[issues/4213]JSearchSelectTag改造支持多选------------
        this.selectedValue = selectedObj.key
        //update-end---author:wangshuai ---date:20221115  for:[issues/4213]JSearchSelectTag改造支持多选------------
      } else {
        this.selectedAsyncValue = null
        this.selectedValue = null
        this.options = null
        this.loadData('')
      }
      this.callback()
      //update-end-author:scott date:20201222 for:【搜索】搜索查询组件,删除条件,默认下拉还是上次的缓存数据,不好 JT-191
    },
    callback() {
      this.$emit('change', this.selectedValue)
    },
    getParentContainer(node) {
      if (typeof this.getPopupContainer === 'function') {
        return this.getPopupContainer(node)
      } else if (!this.popContainer) {
        return node.parentNode
      } else {
        return document.querySelector(this.popContainer)
      }
    }
  },
  model: {
    prop: 'value',
    event: 'change'
  }
}
</script>
<style scoped>
</style>
src/views/eam/maintenance/EamInspectionOrderList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,280 @@
<template>
  <a-card :bordered="false">
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <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.orderNum"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="设备ID">
              <a-input placeholder="请输入设备ID" v-model="queryParam.equipmentId"></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-date placeholder="请选择点检日期" v-model="queryParam.inspectionDate"></j-date>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="点检时间">
                <j-date placeholder="请选择点检时间" v-model="queryParam.operateTime"></j-date>
              </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>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æŸ¥è¯¢åŒºåŸŸ-END -->
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<!--      <a-button type="primary" icon="download" @click="handleExportXls('eam_inspection_order')">导出</a-button>-->
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> æ‰¹é‡æ“ä½œ <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> å·²é€‰æ‹© <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            ä¸‹è½½
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <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-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
    <eam-inspection-order-modal ref="modalForm" @ok="modalFormOk"></eam-inspection-order-modal>
  </a-card>
</template>
<script>
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import EamInspectionOrderModal from './modules/EamInspectionOrderModal'
  export default {
    name: 'EamInspectionOrderList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      EamInspectionOrderModal
    },
    data () {
      return {
        description: 'eam_inspection_order管理页面',
        // è¡¨å¤´
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'工单号',
            align:"center",
            dataIndex: 'orderNum'
          },
          {
            title:'设备编号',
            align:"center",
            dataIndex: 'equipmentId'
          },
          {
            title:'标准编码',
            align:"center",
            dataIndex: 'standardId'
          },
          {
            title:'点检日期',
            align:"center",
            dataIndex: 'inspectionDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'点检时间',
            align:"center",
            dataIndex: 'operateTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'点检人',
            align:"center",
            dataIndex: 'operator'
          },
          {
            title:'点检过期时间',
            align:"center",
            dataIndex: 'expirationTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'创建方式',
            align:"center",
            dataIndex: 'creationMethod'
          },
          {
            title:'点检状态',
            align:"center",
            dataIndex: 'inspectionStatus_dictText'
          },
          {
            title:'班组长确认',
            align:"center",
            dataIndex: 'confirmUser'
          },
          {
            title:'确认时间',
            align:"center",
            dataIndex: 'confirmTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/eam/eamInspectionOrder/list",
          delete: "/eam/eamInspectionOrder/delete",
          deleteBatch: "/eam/eamInspectionOrder/deleteBatch",
          exportXlsUrl: "/eam/eamInspectionOrder/exportXls",
          importExcelUrl: "eam/eamInspectionOrder/importExcel",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'orderNum',text:'工单号',dictCode:''})
        fieldList.push({type:'string',value:'equipmentId',text:'设备ID',dictCode:''})
        fieldList.push({type:'string',value:'standardId',text:'标准ID',dictCode:''})
        fieldList.push({type:'date',value:'inspectionDate',text:'点检日期'})
        fieldList.push({type:'date',value:'operateTime',text:'点检时间'})
        fieldList.push({type:'string',value:'operator',text:'点检人',dictCode:''})
        fieldList.push({type:'date',value:'expirationTime',text:'点检过期时间'})
        fieldList.push({type:'string',value:'creationMethod',text:'创建方式',dictCode:''})
        fieldList.push({type:'string',value:'inspectionStatus',text:'点检状态',dictCode:''})
        fieldList.push({type:'string',value:'confirmUser',text:'设备管理员确认',dictCode:''})
        fieldList.push({type:'date',value:'confirmTime',text:'确认时间'})
        fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
        fieldList.push({type:'string',value:'imageFiles',text:'照片文件ids;id以逗号分隔',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
src/views/eam/maintenance/modules/EamInspectionOrderDetailForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,124 @@
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="删除标记" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag">
              <a-input-number v-model="model.delFlag" placeholder="请输入删除标记" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="工单ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderId">
              <a-input v-model="model.orderId" placeholder="请输入工单ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="点检项ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="itemId">
              <a-input v-model="model.itemId" placeholder="请输入点检项ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="点检结果" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inspectionResult">
              <a-input v-model="model.inspectionResult" placeholder="请输入点检结果"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="异常描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="exceptionDescription">
              <a-input v-model="model.exceptionDescription" placeholder="请输入异常描述"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>
<script>
  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  export default {
    name: 'EamInspectionOrderDetailForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/eam/eamInspectionOrderDetail/add",
          edit: "/eam/eamInspectionOrderDetail/edit",
          queryById: "/eam/eamInspectionOrderDetail/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      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>
src/views/eam/maintenance/modules/EamInspectionOrderForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,164 @@
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="工单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNum">
              <a-input v-model="model.orderNum" placeholder="请输入工单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="设备ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentId">
              <a-input v-model="model.equipmentId" placeholder="请输入设备ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardId">
              <a-input v-model="model.standardId" placeholder="请输入标准ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="点检日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inspectionDate">
              <j-date placeholder="请选择点检日期" v-model="model.inspectionDate"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="点检时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operateTime">
              <j-date placeholder="请选择点检时间" v-model="model.operateTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="点检人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operator">
              <a-input v-model="model.operator" placeholder="请输入点检人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="点检过期时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="expirationTime">
              <j-date placeholder="请选择点检过期时间" v-model="model.expirationTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="创建方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="creationMethod">
              <a-input v-model="model.creationMethod" placeholder="请输入创建方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="点检状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inspectionStatus">
              <j-dict-select-tag type="list" v-model="model.inspectionStatus" dictCode="" placeholder="请选择点检状态" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="设备管理员确认" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="confirmUser">
              <a-input v-model="model.confirmUser" placeholder="请输入设备管理员确认"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="确认时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="confirmTime">
              <j-date placeholder="请选择确认时间" v-model="model.confirmTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <a-textarea v-model="model.remark" rows="4" placeholder="请输入备注" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="照片文件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="imageFiles">
              <j-image-upload isMultiple  v-model="model.imageFiles" ></j-image-upload>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>
<script>
  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  export default {
    name: 'EamInspectionOrderForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/eam/eamInspectionOrder/add",
          edit: "/eam/eamInspectionOrder/edit",
          queryById: "/eam/eamInspectionOrder/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      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>
src/views/eam/maintenance/modules/EamInspectionOrderModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,237 @@
<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardCode" label="标准编码">
              <a-input placeholder="编码系统自动生成" v-model="model.standardCode" disabled />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentId" label="设备编号">
              <MaintenanceEquipmentSelect placeholder="请输入设备编号或名称搜索" v-model="model.equipmentId" :disabled="editable"></MaintenanceEquipmentSelect>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardName" label="标准名称">
              <a-input placeholder="请输入标准名称" disabled v-model="model.standardName" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item label="点检日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inspectionDate">
              <j-date placeholder="请选择点检日期" v-model="model.inspectionDate"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maintenancePeriod" label="保养周期">
              <a-input-number v-model="model.maintenancePeriod" :min="1" :precision="0" disabled style="width: 100%"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="点检过期时间" :labelCol="{span:6}"   :wrapperCol="{span:15}" prop="expirationTime">
              <j-date placeholder="请选择点检过期时间" v-model="model.expirationTime" disabled  style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item label="备注"  :labelCol="{span:1}"   :wrapperCol="{span:22}" prop="remark">
              <a-textarea v-model="model.remark" rows="3" placeholder="请输入备注" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <j-vxe-table
            ref="editableDetailTable"
            :rowNumber="true"
            :rowSelection="false"
            :bordered="true"
            :alwaysEdit="true"
            :toolbar="false"
            keep-source
            :height="300"
            :loading="detail.loading"
            :dataSource="detail.dataSource"
            :columns="detail.columns"
            style="margin-top: 8px;"/>
        </a-row>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>
<script>
import { getAction, httpAction } from '@/api/manage'
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import MaintenanceEquipmentSelect from '@views/eam/equipment/modules/MaintenanceEquipmentSelect'
export default {
  name: "EamMaintenanceStandardModal",
  mixins: [JVxeTableModelMixin],
  components: {
    MaintenanceEquipmentSelect,
  },
  data () {
    return {
      title:"操作",
      visible: false,
      model: {},
      editable: false,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        standardName: [
          { required: true, message: '请输入标准名称!' }
        ],
        maintenanceCategory: [
          { required: true, message: '请选择保养分类!' }
        ],
        initialDate: [
          { required: true, message: '请选择初始日期!' }
        ],
        maintenancePeriod: [
          { required: true, message: '请输入保养周期,单位:天!' }
        ],
        equipmentId: [
          { required: true, message: '请选择设备!' }
        ]
      },
      url: {
        add: "/eam/maintenanceStandard/add",
        edit: "/eam/maintenanceStandard/edit",
        detail: "/eam/eamMaintenanceStandardDetail/queryList",
      },
      detail: {
        loading: false,
        dataSource: [],
        columns: [
          {
            title: '序号',
            key: 'itemCode',
            width: '10%',
            align:"center",
          },
          {
            title: '保养项',
            key: 'itemName',
            width: '20%',
            align:"center",
          },
          {
            title: '保养要求',
            key: 'itemDemand',
            width: '30%',
            align:"center",
          },
        ],
      }
    }
  },
  created () {
  },
  methods: {
    add () {
      this.model = {};
      this.visible = true;
      this.editable = false;
    },
    edit (record) {
      this.model = Object.assign({}, record);
      this.visible = true;
      this.editable = true;
      if(record && record.referenceFile) {
        let obj = JSON.parse(record.referenceFile);
        this.model.fileList = [obj];
      }else {
        this.model.fieldList = [];
      }
      this.loadDetail(record.id);
    },
    close () {
      this.$emit('close');
      this.visible = false;
      this.$refs.form.clearValidate();
    },
    async handleOk () {
      const that = this;
      let errMap = await that.$refs.editableDetailTable.validateTable();
      if(errMap){
        this.$message.warning("数据校验失败!");
        return;
      }
      // è§¦å‘表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          let tableData = that.$refs.editableDetailTable.getTableData();
          let removeData = that.$refs.editableDetailTable.getDeleteData();
          that.model.tableDetailList = [...tableData];
          that.model.removeDetailList = [...removeData];
          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');
              that.close();
            }else{
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }else{
          return false;
        }
      })
    },
    handleCancel () {
      this.close()
    },
    //加载详情数据
    loadDetail(standardId) {
      this.detail.dataSource = [];
      if (standardId) {
        getAction(this.url.detail, { standardId: standardId }).then(res => {
          if (res.success) {
            this.detail.dataSource = [...res.result];
          }
        })
      }
    }
  }
}
</script>
<style lang="less" scoped>
</style>