index.vue 7.82 KB
<!-- 作业单管理  -->
<template>
  <d2-container>
      <el-form
      :inline="true"
      :model="searchForm"
      label-width="100px"
      slot="header"
    >
      <el-form-item
        v-for="(item, index) in searchFormArr"
        :key="index"
        :label="item.label"
      >
        <el-input
          v-if="item.type == 'input'"
          v-model="searchForm[item.model]"
          :placeholder=  "'请输入' + item.label"
          clearable>
        </el-input>
         <el-select
         v-else-if="item.type == 'select'"
          v-model="searchForm[item.model]"
          :placeholder= "'请选择' + item.label"
          clearable
          filterable>
            <el-option
              v-for="(optionItem, optionIndex) in item.options"
              :key="optionIndex"
              :label="optionItem.confValue"
              :value="optionItem.confCode"
            ></el-option>
        </el-select>
        <el-date-picker
          v-else-if="item.type == 'datePick'"
          v-model="creatTime"
          value-format="yyyy-MM-dd"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
          <el-button type="primary"  icon="el-icon-search" :id="tableParams.btnId">查询</el-button>
      </el-form-item>
    </el-form>
    <d2-table-header title="作业单列表"><auth-button category="Button"></auth-button></d2-table-header>
    <d2-table
      :searchForm="searchForm"
      :tableParams="tableParams"
      :getListApi="getListApi"
    >
      <auth-button
        slot="auth-button"
        slot-scope="scope"
        :data="scope.scope"
      ></auth-button>
    </d2-table>
  </d2-container>
</template>

<script>
import { getListApi, removeApi, exportApi } from '@api/maintainManagement'
import { mapActions } from 'vuex'
// import { BaseData } from '@/common/constants'
import notice from '@/common/notice'
import util from '@/libs/util'
export default {
  name: 'fimsMaintainManagement',
  data() {
    return {
      creatTime: '',
      // 搜索
      searchForm: {
        taskCode: '',
        taskType: '',
        downDeviceNum: '',
        userName: '',
        startTime: '',
        endTime: '',
        trafficCode: '',
        stationCode: '',
        subsystemCode: '',
        downType: '',
        subsystemTypeCode: ''
      },
      searchFormArr: [{
        label: '订单编号',
        type: 'input',
        model: 'taskCode'
      }, {
        label: '订单类型',
        type: 'select',
        model: 'taskType',
        options: [{
          confValue: '系统',
          confCode: '1'
        }, {
          confValue: '人工',
          confCode: '2'
        }]
      }, {
        label: '故障物料代码',
        type: 'input',
        model: 'downDeviceNum'
      }, {
        label: '处理人',
        type: 'input',
        model: 'userName'
      }, {
        label: '车辆编号',
        type: 'input',
        model: 'trafficCode'
      }, {
        label: '车辆站点',
        type: 'select',
        model: 'stationCode',
        options: []
      }, {
        label: '子系统编号',
        type: 'input',
        model: 'subsystemCode'
      }, {
        label: '子系统类型',
        type: 'select',
        model: 'subsystemTypeCode',
        options: []
      }, {
        label: '故障类型',
        type: 'select',
        model: 'downType',
        options: [{
          confValue: '临时维修',
          confCode: '1'
        }, {
          confValue: '车辆整改',
          confCode: '2'
        }, {
          confValue: '重点车次',
          confCode: '3'
        }, {
          confValue: '181故障',
          confCode: '4'
        }]
      }, {
        label: '创建时间',
        type: 'datePick',
        // singleVal: 'creatTime',
        model: 'creatTime'
      }],
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'maintainList',
        tableOption: {
          width: 100
        },
        tableColumns: [{
          label: '订单编号',
          prop: 'taskCode'
        }, {
          label: '创建时间',
          prop: 'createTime'
        }, {
          label: '类型',
          prop: 'taskType',
          formatter: (cellValue) => {
            if (cellValue.taskType) {
              return {
                1: '系统',
                2: '人工'
              }[cellValue.taskType]
            }
          }
        }, {
          label: '车辆编号',
          prop: 'trafficCode'
        }, {
          label: '车辆站点',
          prop: 'stationName'
        }, {
          label: '子系统编号',
          prop: 'subsystemCode'
        }, {
          label: '子系统类型',
          prop: 'subsystemType'
        }, {
          label: '故障类型',
          prop: 'downType',
          formatter: (cellValue) => {
            if (cellValue.downType) {
              return {
                1: '临时维修',
                2: '车辆整改',
                3: '重点车次',
                4: '181故障'
              }[cellValue.downType]
            }
          }
        }, {
          label: '故障描述',
          prop: 'downDescription',
          width: '300'
        }, {
          label: '处理方式',
          prop: 'treatment',
          formatter: (cellValue) => {
            if (cellValue.treatment) {
              return {
                1: '现场维修',
                2: '更换'
              }[cellValue.treatment]
            }
          }
        }, {
          label: '故障物料代码',
          prop: 'downDeviceNum'
        }, {
          label: '故障物料编码',
          prop: 'downDeviceCode'
        }, {
          label: '故障物料处理',
          prop: 'downDeviceTreatment',
          formatter: (cellValue) => {
            if (cellValue.downDeviceTreatment) {
              return {
                1: '返厂维修',
                2: '报废'
              }[cellValue.downDeviceTreatment]
            }
          }
        }, {
          label: '更换物料物料代码',
          prop: 'replaceDeviceNum'
        }, {
          label: '更换物料物料编码',
          prop: 'replaceDeviceCode'
        }, {
          label: '使用数量',
          prop: 'usedCount'
        }, {
          label: '处理人',
          prop: 'userName'
        }]
      },
      getListApi: getListApi
    }
  },

  watch: {
    'creatTime'(value) {
      Object.assign(this.searchForm, util.formatTime(this.creatTime))
    }
  },

  mounted() {
    this.loadBaseData()
  },

  methods: {
    ...mapActions('d2admin/base', ['load']),

    async loadBaseData() {
      const { station, subsys } = await this.load()
      this.searchFormArr.map(item => {
        item.model === 'stationCode' && (item.options = station)
        item.model === 'subsystemTypeCode' && (item.options = subsys)
      })
    },

    /* 接口请求-start */
    getParams() {
      return Object.assign(this.searchForm, util.formatTime(this.creatTime))
    },

    // getList() {
    //   this.getParams()
    //   this.$refs.table.refreshTable()
    // },
    exportOrder() {
      // const params = this.getParams()
      exportApi(this.searchForm).then(res => {
        this.$open(res.url)
        notice.okTips()
      }).catch(() => {
        notice.errorTips()
      })
    },
    /* 接口请求-end */
    handleDelete(row) {
      this.$confirm('确认删除?', '删除', {
        comfirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        removeApi({
          id: row.id
        }).then(res => {
          notice.okTips()
          // this.getList()
        }).catch(() => {
          notice.errorTips()
        })
      }).catch(() => {})
    }
  }
}
</script>
<style scoped>
</style>