wente
2024-03-14 de1b6284b3cb6349575938782ee34d2ad0349735
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<template>
  <zt-dialog ref="dialog" column="2" title="选择通用模型" append-to-body :editAble="false" :hasConfirm="true"
             @confirm="formSubmit">
    <el-card shadow="never" class="aui-card--fill">
      <div class="mod-tyProductModel-tyProductModel}">
        <zt-table-wraper :query-url=url
                         :paging='false'
                         v-slot="{ table }">
          <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
          </el-form>
          <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:70}"
                    border
                    @selection-change="changeRow">
            <el-table-column type="selection" width="40" align="center"/>
            <el-table-column prop="name" label="名称"/>
          </el-table>
        </zt-table-wraper>
      </div>
    </el-card>
  </zt-dialog>
</template>
 
<script>
  export default {
    name: 'SelectTyModel',
    data() {
      return {
        url: '/basicInfo/XhProductModel/page',
        selectList: [],
        data: '',
        pageCode:'',
        dataForm: {
          type: 'noTree',
          nodeType: '',
          id: '',
          pid: '',
          name: '',
          operationalStatus: '',
          standbyState: '',
          faultState: '',
          sort: ''
        }
      }
    },
    components: {},
    methods: {
      init(id, params) {
        this.dataForm.nodeType = params.type
        this.dataForm.pid = params.id
        this.pageCode = params.pageCode
        if (!this.pageCode) {
          this.url = '/basicInfo/TyProductModel/page'
        }
        console.log(params, 'init()')
      },
      changeRow(selection) {
        console.log(selection, ' changeRow(selection)')
        let item = {}
        for (item of selection) {
          console.log(item)
          item.pid = this.dataForm.pid
        }
        this.selectList = selection
        this.selectList.forEach( item => {
          item.pageCode = this.pageCode
        })
      },
      async formSubmit() {
        let res
        if (this.pageCode) {
          if (this.pageCode === 'expect' || this.pageCode === 'assign') {
            res = await this.$http.post('/basicInfo/ParamData/get', this.selectList)
          }
          } else {
            res = await this.$http.post('/basicInfo/XhProductModel/get', this.selectList)
          }
          if (res.success) {
            await this.$tip.success()
            this.$refs.dialog.close()
            this.$emit('refreshDataList')
          }
        }
      }
    }
</script>