index.vue 4.79 KB
Newer Older
caolaoban's avatar
caolaoban committed
1 2
<template>
  <div class="search-sorties">
3 4
    <el-form :inline="true" :model="form" class="demo-form-inline search-bar" label-width="50px">
      <el-col :span="12">
5 6 7 8 9 10 11 12 13 14 15
        <el-form-item label="架次:">
          <el-select v-model="form.sorties" placeholder="架次" @change="changeFrom">
            <el-option
              v-for="(item, i) in sortiesData"
              :key="item.value + i"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-col>
16
      <el-col :span="12">
17
        <el-form-item label="站位:">
18
          <el-select v-model="form.postion" placeholder="站位" @change="changePostion">
19 20 21 22 23 24 25 26 27
            <el-option
              v-for="(item, i) in postionList"
              :key="item.value + i"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-col>
28
      <!-- <el-col :span="8">
29 30 31
        <el-form-item label="AO(号/名称):">
          <el-input v-model="form.name" placeholder="AO(号/名称)" clearable @change="changeFrom" />
        </el-form-item>
32
      </el-col> -->
caolaoban's avatar
caolaoban committed
33 34 35 36 37 38 39 40 41 42
    </el-form>
  </div>
</template>

<script>
import { post } from '@/utils/http'
export default {
  componentName: 'AO架次站位搜索',
  name: 'SearchSorties',
  components: {},
43 44 45 46 47 48
  props: {
    form: {
      type: Object,
      default: () => ({ sorties: '', postion: '' })
    }
  },
caolaoban's avatar
caolaoban committed
49 50 51 52
  data() {
    return {
      sortiesData: [],
      SoriteTypeOptions: [],
53
      // form: {},
caolaoban's avatar
caolaoban committed
54 55 56 57 58 59 60 61
      postionList: []
    }
  },
  computed: {},
  watch: {
    'form.sorties': {
      immediate: true,
      handler(val) {
62 63
        const sorties = this.sortiesData.find(r => r.value === val)
        this.$set(this.form, 'sortiesName', sorties && sorties.sortiesName || '')
caolaoban's avatar
caolaoban committed
64 65 66 67 68
        this.$utils.getDicListByCode('SoriteType').then(res => {
          this.SoriteTypeOptions = res
          this.getStation(val)
        })
      }
69 70 71 72 73 74 75
    },
    'form.postion': {
      immediate: true,
      handler(val) {
        const postion = this.postionList.find(r => r.value === val)
        this.$set(this.form, 'postionName', postion && postion.label || '')
      }
caolaoban's avatar
caolaoban committed
76 77 78
    }
  },
  created() {
79
    this.$emit('input', this.form)
caolaoban's avatar
caolaoban committed
80 81 82 83 84 85
    this.getModelData()
    this.getSortiesList()
  },
  mounted() {},
  // 组件方法
  methods: {
86 87 88
    changeFrom(val) {
      this.$emit('input', val)
    },
89 90 91 92
    changePostion(val) {
      this.$emit('input', val)
      this.$bus.$emit('getTableData', this.form)
    },
caolaoban's avatar
caolaoban committed
93 94 95 96 97
    getStation(val) {
      this.postionList = []
      this.$set(this.form, 'postion', '')
      if (val) {
        const params = {
98
          'searchItems': { 'items': [{ 'fieldName': 'aircraftSortiesId', 'operator': 'EQ', 'value': val }] },
caolaoban's avatar
caolaoban committed
99 100 101 102 103 104 105 106 107 108 109 110
          'openProps': [{ name: 'aircraftSorties' }],
          'sortItem': [{ 'fieldName': 'serialNumber', 'sortOrder': 'asc' }]
        }
        post('ExtPosition/search', params).then(res => {
          if (res.items && res.items.content) {
            this.postionList = res.items.content.map(row => {
              return {
                value: `${row.id}`,
                label: row.serialNumber
              }
            })
            this.$set(this.form, 'postion', this.postionList[0].value)
111
            this.$set(this.form, 'postionName', this.postionList[0].label)
112
            this.$bus.$emit('getTableData', this.form)
caolaoban's avatar
caolaoban committed
113 114 115 116 117 118
          }
        })
      }
    },
    getSortiesList() {
      this.sortiesData = []
119
      const params = { 'searchItems': { 'items': [] }, 'sortItem': [{ 'fieldName': 'defCode', 'sortOrder': 'asc' }] }
120
      this.$api.searchApi('AircraftSorties', params).then(res => {
caolaoban's avatar
caolaoban committed
121 122 123
        if (res.items && res.items.content) {
          this.sortiesData = res.items.content.map(row => {
            return {
124 125 126
              value: row.id,
              label: row.defName,
              sortiesName: row.defName
caolaoban's avatar
caolaoban committed
127 128 129
            }
          })
          this.$set(this.form, 'sorties', this.sortiesData[0].value)
130
          this.$set(this.form, 'sortiesName', this.sortiesData[0].sortiesName)
caolaoban's avatar
caolaoban committed
131 132 133
        }
      })
    },
134 135 136 137
    // getSoritesLabel(row) {
    //   const type = (row.target && row.target.type) ? this.SoriteTypeOptions.find(r => r.value === row.target.type) : ''
    //   return `${row.source.defName} ${type && type.label || ''}`
    // },
caolaoban's avatar
caolaoban committed
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    getModelData() {
      this.modelData = []
      const params = { 'searchItems': { 'items': [{ 'fieldName': 'id', 'operator': 'NEQ', 'value': 0 }] }, 'sortItem': [{ 'fieldName': 'modifyTime', 'sortOrder': 'asc' }] }
      this.$api.searchApi('AircraftType', params).then(res => {
        if (res.items && res.items.content) {
          this.modelData = res.items.content
          this.$set(this.form, 'model', this.modelData[0].id)
        }
      })
    }
  }
}
</script>

<style lang='scss'>
153
#SearchSorties {
xioln's avatar
xioln committed
154
  // width:450px;
155
}
caolaoban's avatar
caolaoban committed
156
</style>