liuxiaolong
2019-05-06 d380e76ec9783bcd80eb42e495d6f8e1af0827b4
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
  <el-table
    ref="multipleTable"
    :data="$attrs.tableList"
    :border="true"
    fit
    height="59vh"
    @sort-change="sortChange"
    @selection-change="handleSelectionChange"
  >
    <el-tableColumn
      type="index"
      prop="index"
      label="序号"
      :index="snMethod"
      :fit="true"
      width="80px"
      align="center"
    />
    <el-tableColumn label="布控任务" sortable="custom" prop="name" align="center"/>
    <el-tableColumn label="开始时间" sortable="custom" prop="startTime" align="center"/>
    <el-tableColumn label="截至时间" sortable="custom" prop="endTime" align="center"/>
    <!-- 自定义title select start -->
    <el-table-column label="布控状态" :render-header="renderCtrlState" sortable="custom" prop="statusName">
    </el-table-column>
    <el-tableColumn label="布控人数" sortable="custom" prop="personCount" align="center"/>
    <!-- 自定义title select end -->
    <el-table-column label="布控来源" :render-header="renderCtrlData" sortable="custom" prop="source"/>
 
    <el-tableColumn label="布控范围" sortable="custom" prop="scope" align="center">
      <template slot-scope="scope">
        <div class="media flex-center">
          <div class="d-block fas fa-map-marker-alt" style="color:#35bde7" @click="toMap(scope.row)"></div>
          <div class="line-height-condenced ml-3" @click="showlayer(scope.row)">{{scope.row.scope}}</div>
        </div>
      </template>
    </el-tableColumn>
    <el-table-column label="操作人" sortable="custom" prop="updateBy" align="center"/>
    <el-table-column label="操作" align="center">
      <template slot-scope="scope">
        <div @click.stop>
          <fButton
            type="link"
            title="编辑布控"
            style="padding:2px;"
            @click.native="$router.push({path:'/drogPerson',query:{isEdit:true,rowData:scope.row}})"
            authority="sys:attendce:catchImg"
          >编辑</fButton>
          <fButton
            type="link"
            title="编辑人员"
            style="padding:2px;"
            @click.native="$router.push({path:'/person',query:{rowData:scope.row}})"
            authority="sys:attendce:catchImg"
          >人员</fButton>
          <fButton
            type="link"
            title="查看详情"
            style="padding:2px;"
            @click.native="$router.push({path:'/cdetail',query:{rowData:scope.row}})"
            authority="sys:attendce:catchImg"
          >详情</fButton>
        </div>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import { Table, TableColumn } from 'element-ui'
import rangeTree from './rangeTree'
import {
  findScopeDetailByTaskId
} from '@/server/task.js'
export default {
  name: 'taskTable',
  metaInfo: {
    title: '布控任务'
  },
  props: ['total', 'activePage', 'pageSize'],
  inheritAttrs: false,
  data() {
    return {}
  },
  computed: {},
  methods: {
    snMethod(index) {
      return this.activePage > 1
        ? this.pageSize * (this.activePage - 1) + index + 1
        : index + 1
    },
    /* 表格表头渲染 start */
    /* eslint-disable */
    renderCtrlState(h, { column, $index }) {
      return (
        <div
          class="vertical-middle"
          onClick={e => {
            e.stopPropagation()
            return false
          }}
        >
          <select
            value={this.$attrs.selectVal}
            onChange={ev => {
              this.$emit('selectChange', ev.target.value,'ctrolStatus')
              console.log(ev.target.value, 'select---data')
            }}
          >
            {this.$attrs.selectOpts &&
              this.$attrs.selectOpts.map(item => {
                return <option value={item.value}>{item.name}</option>
              })}
          </select>
        </div>
      )
    },
    renderCtrlData(h, { column, $index }) {
      return (
        <div
          class="vertical-middle"
          onClick={e => {
            e.stopPropagation()
            return false
          }}
        >
          <select
            value={this.$attrs.sourceVal}
            onChange={ev => {
              this.$emit('selectChange', ev.target.value,'ctrolSource')
              console.log(ev.target.value, 'select---data')
            }}
          >
            {this.$attrs.selectOpts2 &&
              this.$attrs.selectOpts2.map(item => {
                return <option value={item.value}>{item.name}</option>
              })}
          </select>
        </div>
      )
    },
    /* 表格表头渲染 end */
    sortChange(data) {
      this.$emit('sortChange', data)
    },
    /* 多选 */
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row)
        })
      } else {
        this.$refs.multipleTable.clearSelection()
      }
    },
    handleSelectionChange(val) {
      this.$emit('handleSelectionChange', val)
      this.multipleSelection = val
    },
    /** 布控详情的地图 */
    toMap(data){
      console.log(this.$router,'toMap')
      this.$router.push({
        path:'/cdetail',
        query:{
          rowData:data,
          isMap:true
        }
 
      })
    },
    /** layer弹框 */
    async showlayer(data){
      console.log(data,'data')
      let res = await findScopeDetailByTaskId({taskId:data.id})
      let treelist = []
      if(res && res.success){
        if(res.data && res.data.length !== 0){
          treelist = res.data
        }
      }else{
        this.$toast({
          type:'error',
          message:'查询布控范围失败!'
        })
        return false
      }
      this.$layer.iframe({
        content: {
          content: rangeTree, //传递的组件对象
          parent: this,//当前的vue对象
          data:{
            data:JSON.stringify(treelist),
          }//props
        },
        shade:false,
        area:['400px','490px'],
        title:'布控范围'
      })
    }
  },
  components: {
    elTable: Table,
    elTableColumn: TableColumn,
    rangeTree: rangeTree
  }
}
</script>