石广澎
2023-10-20 4cb068fb1d51129be7199cbd83fb0ef1f97915e2
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
208
209
210
<template>
  <div class="app-container">
    <el-card class="box-card" shadow="never">
      <div class="filter-container" style="margin-bottom: 10px">
        <my-search ref="searchBar" :items="items" @search="filterForm"></my-search>
      </div>
      <!--列表-->
      <my-table-v2 ref="myTable" :filter="filterFrom" :table="table"/>
    </el-card>
    <edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search"></edit>
    <detail v-if="detailSetting.show" :setting="detailSetting" @close="detailSetting.show = false" @search="search"></detail>
    <nodeChoose v-if="nodeSetting.show" :setting="nodeSetting" @close="nodeSetting.show = false" @search="search"></nodeChoose>
  </div>
</template>
 
<script>
import MyTableV2 from '@/components/myTable/myTableV2';
import SettingIplatform from '@/utils/settingIplatform';
import items from './items';
import edit from './edit'
import detail from "@/views/projectConfig/buildPlan/detail";
import nodeChoose from './nodeChoose/index'
import {del, updStatus} from "@/api/projectConfig/buildPlan";
 
export default {
  components: {MyTableV2, edit,detail,nodeChoose},
  data() {
    return {
      // 搜索条件
      items: items,
      filterFrom: {
        projectName: '',
        projectCode: '',
        planTypeCode: '',
        status: '1',
      },
      //新增编辑
      editSetting: {
        title: '',
        id: '',
        show: false,
      },
      //详情
      detailSetting: {
        title: '阶段节点预览',
        id: '',
        show: false,
      },
      //节点设置
      nodeSetting: {
        title: '节点选择',
        stageId: '',
        show: false,
      },
      // 表格数据
      table: {
        showIndex: true, // 是否显示序号
        expand: false, // 是否显示详情数据
        url: SettingIplatform.apiBaseURL + '/pc/p/temp/project/list', // 请求地址
        // 工具条
        tools: {
          columnsCtrl: {
            // 列控制按钮
            show: false,
          },
          generalExport: {
            // 通用导出按钮
            show: false,
          },
          // 自定义工具条按钮
          custom: [
            {
              name: '新增',
              click: () => {
                this.showAdd(null);
              },
            },
          ],
        },
        // 列信息
        columns: [
          {
            title: '模板名称', field: 'projectName', align: 'left',
            formatter: (row) => {
                return {
                  value: row.projectName,
                  type: 'primary',
                  click: () => {
                    // 点击事件
                    this.shoDetail(row.id);
                  },
                }
            }
          },
          {title: '编号', field: 'projectCode', align: 'left', width: 200},
          {title: '计划类型', field: 'planTypeName', align: 'left', width: 300},
          {
            field: 'status',
            title: '状态',
            align: 'center',
            width: 80,
            switch: (row) => {
              return {
                value: row.status === 1, // 开
                label: row.status === 1 ? '启用' : '禁用', // 开的描述
                click: () => {
                  // 点击事件
                  this.updState(row);
                },
              };
            },
          },
        ],
        // 操作信息
        operation: {
          show: true, // 显示操作列
          width: '200', // 列宽
          attr: [
            {
              title: '编辑',
              events: (row) => {
                this.showAdd(row.id);
              },
            },
            {
              title: '节点选择',
              type: 'success',
              events: (row) => {
                this.showNode(row.id);
              },
            },
          ],
        },
        paging: {
          show: false, // 显示分页
          // 分页信息
          page: {
            small: false,
            pageNum: 1,
            pageSize: 10,
            total: 0,
          },
        },
      },
    };
  },
  mounted() {
  },
  methods: {
    // 查询table列表
    search(pageNum) {
      if (pageNum != undefined) {
        this.$refs.myTable.search(pageNum);
      } else {
        this.$refs.myTable.search();
      }
    },
    filterForm(params) {
      this.filterFrom = Object.assign(this.filterFrom, params);
      this.search();
    },
    //添加、编辑
    showAdd(id) {
      let title = '添加';
      if (id != null) {
        title = '编辑';
      }
      this.editSetting.id = id;
      this.editSetting.title = title;
      this.editSetting.show = true;
    },
    updState(row) {
      let text = row.status === 0 ? "启用" : "禁用";
      this.$modal.confirm('确认要' + text + '"' + row.projectName + '"吗?').then(() => {
        let status = row.status === 1 ? 0 : 1
        updStatus({
          id: row.id,
          status
        }).then(res => {
          if (res) {
            row.status = row.status === 1 ? 0 : 1
            this.$modal.msgSuccess(text + "成功");
          }
        })
      })
    },
    showNode(id) {
      this.nodeSetting.stageId = id;
      this.nodeSetting.show = true;
    },
    shoDetail(id) {
      this.detailSetting.id = id;
      this.detailSetting.show = true;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm('是否确认删除"' + row.stageName + '"阶段?', {
        type: 'warning'
      }).then(() => {
        del({id: row.id}).then(res => {
          this.$modal.msgSuccess("删除成功");
          this.search()
        })
      })
    },
  },
};
</script>
 
<style scoped></style>