index.vue 9.86 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"
          @clear="loadingGetList"
          clearable>
        </el-input>
         <el-select
         v-else-if="item.type == 'select'"
          v-model="searchForm[item.model]"
          :placeholder= "'请选择' + item.label"
          @clear="loadingGetList"
          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="searchForm[item.model]"
          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" @click="handleSearch">查询</el-button>
      </el-form-item>
    </el-form>
    <d2-table-header title="作业单列表"><auth-button category="Button"></auth-button></d2-table-header>
    <el-table
      :data="tableData"
      v-loading="$store.state.d2admin.loading.value"
      border
      :highlight-current-row="true"
      :stripe="true"
    >
      <el-table-column
        align="center"
        width="60px"
        label="序号"
        type='index'
        :index="index=>index+(currentPage - 1) * pageSize + 1"
      ></el-table-column>
      <el-table-column
        v-for="(item, index) in tableColumns"
        :key="index"
        :label="item.label"
        :prop="item.prop"
        :width="item.width||200"
        align="center"
      >
        <template slot-scope="scope">
          <template v-if="item.formatter">
            {{item.formatter(scope.row)}}
          </template>
          <template v-else>
            {{tableData[scope.$index][item.prop]}}
          </template>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="操作"
        fixed="right"
        width="200"
      >
        <template slot-scope="scope">
          <auth-button
            :data="scope.row"
          ></auth-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10,20,30,40]"
      :page-size="pageSize"
      :total="total"
      layout="sizes,total,->,prev,pager,next,jumper"
    >
    </el-pagination>
  </d2-container>
</template>

<script>
import { getListApi, removeApi, exportApi } from '@api/maintainManagement'
import { mapActions } from 'vuex'
import notice from '@/common/notice'
export default {
  name: 'fimsMaintainManagement',
  data() {
    return {
      // 搜索
      searchForm: {
        taskCode: '',
        taskType: '',
        downDeviceNum: '',
        userName: '',
        createTime: '',
        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',
        model: 'createTime'
      }],
      // 表格
      tableData: [],
      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'
        // formatter: (cellValue) => {
        //   if (cellValue.subsystemType) {
        //     return {
        //       1: '座椅',
        //       2: '电池'
        //     }[cellValue.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'
      }],
      // 页码
      currentPage: 1,
      pageSize: 10,
      total: 30
    }
  },

  watch: {
    'searchForm.createTime'(value) {
      !value && this.loadingGetList()
    }
  },

  mounted() {
    this.loadingGetList()
    this.loadBaseData()
  },

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

    async loadBaseData() {
      const modelToOptions = { 'stationCode': 'station', 'subsystemTypeCode': 'subsys' }
      const data = await this.load()
      if (data) {
        for (var item in modelToOptions) {
          let pos = this.searchFormArr.findIndex(arrItem => arrItem.model === item)
          this.searchFormArr[pos].options = data[modelToOptions[item]]
        }
      }
    },

    loadingGetList() {
      this.getList()
    },
    /* 接口请求-start */
    getParams() {
      this.searchForm.startTime = this.searchForm.createTime ? this.searchForm.createTime[0] + ' ' + '00:00:00' : ''
      this.searchForm.endTime = this.searchForm.createTime ? this.searchForm.createTime[1] + ' ' + '23:59:59' : ''
      return {
        pageCount: this.pageSize,
        pageSize: this.currentPage,
        ...this.searchForm
      }
    },

    getList() {
      const params = this.getParams()
      delete params.createTime
      // console.log(params)
      getListApi(params).then(res => {
        this.tableData = res.maintainList
        this.total = res.pagination.totalCount
      }).catch(() => {
        notice.errorTips()
      })
    },
    exportOrder() {
      const params = this.getParams()
      delete params.createTime
      exportApi(params).then(res => {
        this.$open(res.url)
        notice.okTips()
      }).catch(() => {
        notice.errorTips()
      })
    },
    /* 接口请求-end */
    // 搜索
    handleSearch() {
      this.loadingGetList()
    },

    // 页码
    handleSizeChange(value) {
      this.pageSize = value
      // 调接口
      this.loadingGetList()
    },

    handleCurrentChange(value) {
      this.currentPage = value
      // 调接口
      this.loadingGetList()
    },

    handleDelete(row) {
      this.$confirm('确认删除?', '删除', {
        comfirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        removeApi({
          id: row.id
        }).then(res => {
          notice.okTips()
          this.loadingGetList()
        }).catch(() => {
          notice.errorTips()
        })
      }).catch(() => {})
    }
  }
}
</script>
<style scoped>
</style>