zzw
3 天以前 757dcb3fcad665eaef93074a4981c4134f7a027e
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
<template>
  <div class="page">
    <div class="page-title">
      <div>
        <h2>承修单位管理</h2>
        <p>数据来源:组织机构部门表(DEPT_TYPE = cj)</p>
      </div>
      <el-button icon="el-icon-refresh" @click="load">刷新</el-button>
    </div>
 
    <div class="toolbar">
      <el-input
        v-model="keyword"
        placeholder="名称 / 部门编码 / 负责人"
        clearable
        style="width:280px"
        @keyup.enter.native="load"
      ></el-input>
      <el-button type="primary" icon="el-icon-search" @click="load">查询</el-button>
      <div class="spacer"></div>
      <span class="summary">共 {{ filteredRows.length }} 个承修单位</span>
    </div>
 
    <div class="table-panel">
      <el-table
        v-loading="loading"
        :data="filteredRows"
        border
        stripe
        height="calc(100vh - 245px)"
      >
        <el-table-column prop="sortNo" label="排序" width="80" align="center"></el-table-column>
        <el-table-column label="常用" width="80" align="center">
          <template slot-scope="{ $index }">
            <el-tag v-if="$index < 7" size="mini" type="success">前7</el-tag>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="名称" min-width="240" show-overflow-tooltip></el-table-column>
        <el-table-column prop="deptCode" label="部门编码" width="160"></el-table-column>
        <el-table-column prop="contact" label="负责人" width="120"></el-table-column>
        <el-table-column prop="phone" label="联系电话" width="160"></el-table-column>
        <el-table-column label="状态" width="100" align="center">
          <template slot-scope="{ row }">
            <el-tag size="mini" :type="row.status === '1' ? 'info' : 'success'">
              {{ row.status === '1' ? '停用' : '正常' }}
            </el-tag>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import api from '@/api'
export default {
  name: 'ContractorManage',
  data() {
    return {
      loading: false,
      rows: [],
      keyword: ''
    }
  },
  computed: {
    filteredRows() {
      const keyword = this.keyword.trim().toLowerCase()
      if (!keyword) return this.rows
      return this.rows.filter(item => [item.name, item.deptCode, item.contact]
        .some(value => String(value || '').toLowerCase().includes(keyword)))
    }
  },
  created() {
    this.load()
  },
  methods: {
    load() {
      this.loading = true
      api.get('/system/contractors').then(res => {
        this.rows = res.data || []
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>
<style scoped>
.summary {
  color: #6d7f91;
  font-size: 13px;
}
</style>