无人机管理后台前端(已迁走)
罗广辉
2025-10-11 02409bfbe15f22fc3b5dccadabfd860a660a49d9
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!-- 运营收益 -->
<template>
  <div class="operatingIncome">
    <div class="search-box">
      <!-- <el-form :model="params" inline>
        <el-form-item label="空域名称:">
          <el-input v-model="params.algName" placeholder="请输入空域名称" clearable />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getList">搜索</el-button>
          <el-button @click="cancelSearch">取消</el-button>
        </el-form-item>
      </el-form> -->
      <div>
        <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
      </div>
    </div>
    <div class="mange-table">
            <el-table border :data="tableList" class="custom-header">
                <el-table-column label="序号" type="index" width="60"></el-table-column>
        <el-table-column prop="operating_income" label="营业收入" align="center"></el-table-column>
        <el-table-column prop="total_cost" label="综合总成本费用" align="center"></el-table-column>
        <el-table-column prop="net_profit" label="净利润" align="center"></el-table-column>
        <el-table-column prop="financial_irr" label="财务内部收益率" align="center"></el-table-column>
        <el-table-column prop="market_space" label="市场空间" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="create_time" label="创建时间" align="center"></el-table-column>
        <el-table-column prop="nick_name" label="创建人" align="center"></el-table-column>
                <el-table-column label="操作" width="180" align="center">
                    <template #default="scope">
            <!-- <el-button icon="el-icon-view" type="text" @click="handleDetail(scope.row)">查看</el-button> -->
            <el-button icon="el-icon-edit" type="text" @click="handleEdit(scope.row)">编辑</el-button>
                        <el-button icon="el-icon-edit" type="text" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div class="pagination">
            <el-pagination class="ztzf-pagination" popper-class="custom-pagination-dropdown" background
                :page-sizes="[10, 20, 30, 40, 50, 100]" :size="size" v-model:current-page="params.current"
                v-model:page-size="params.size" layout="total, sizes, prev, pager, next, jumper" :total="total"
                @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </div>
  </div>
  <el-dialog class="ztzf-dialog" append-to-body v-model="isShowEditView" :title="txtTitle"
        :width="pxToRem(800)" :close-on-click-modal="false" :destroy-on-close="true" @close="handleClose">
        <div class="content-edit">
      <el-form ref="ruleFormRef" :model="editParams" :rules="rules" inline>
        <el-form-item label="营业收入" prop="operating_income">
          <el-input v-model="editParams.operating_income" />
        </el-form-item>
        <el-form-item label="综合总成本费用" prop="total_cost">
          <el-input v-model="editParams.total_cost" />
        </el-form-item>
        <el-form-item label="净利润" prop="net_profit">
          <el-input v-model="editParams.net_profit" />
        </el-form-item>
        <el-form-item label="财务内部收益率" prop="financial_irr">
          <el-input v-model="editParams.financial_irr" />
        </el-form-item>
        <el-form-item label="市场空间" prop="market_space" style="width: 716px;">
          <el-input v-model="editParams.market_space"  />
        </el-form-item>
        <div class="btns">
          <el-button v-if="titleTxt === '新增'" type="primary" @click="submit(ruleFormRef)"><el-icon><CirclePlus /></el-icon>确认</el-button>
          <el-button v-else type="primary" @click="submit(ruleFormRef)"><el-icon><CircleCheck /></el-icon>修改</el-button>
          <el-button @click="isShowEditView = false"><el-icon><CircleClose /></el-icon>取消</el-button>
        </div>
      </el-form>
    </div>
    </el-dialog>
</template>
<script setup>
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';
import { operatingIncomePage, operatingIncomeUpdate, operatingIncomeAdd, operatingIncomeDelete } from '@/api/airspace/airspace';
 
let titleTxt = ref('新增')
const total = ref(0)
const params = ref({
  current: 1,
  size: 10,
});
 
let tableList = ref([])
 
let isShowEditView = ref(false)
 
const ruleFormRef = ref()
let editParams = ref({
  id: '',
  operating_income: '',
  total_cost: '',
  net_profit: '',
  financial_irr: '',
  market_space: '',
})
const rules = reactive({
  operating_income: [
    { required: true, message: '请输入营业收入', trigger: 'blur' },
    {
      validator: (rule, value, callback) => {
        if (!/^\d+(\.\d+)?$/.test(value)) {
          callback(new Error('请输入有效的数字(整数或小数)'));
        } else {
          callback();
        }
      },
      trigger: 'blur'
    }
  ],
  total_cost: [
    { required: true, message: '请输入综合总成本费用', trigger: 'blur' },
    {
      validator: (rule, value, callback) => {
        if (!/^\d+(\.\d+)?$/.test(value)) {
          callback(new Error('请输入有效的数字(整数或小数)'));
        } else {
          callback();
        }
      },
      trigger: 'blur'
    }
  ],
  net_profit: [
    { required: true, message: '请输入净利润', trigger: 'blur' },
    {
      validator: (rule, value, callback) => {
        if (!/^\d+(\.\d+)?$/.test(value)) {
          callback(new Error('请输入有效的数字(整数或小数)'));
        } else {
          callback();
        }
      },
      trigger: 'blur'
    }
  ],
  financial_irr: [
    { required: true, message: '请输入财务内部收益率', trigger: 'blur' },
    {
      validator: (rule, value, callback) => {
        if (!/^\d+(\.\d+)?$/.test(value)) {
          callback(new Error('请输入有效的数字(整数或小数)'));
        } else {
          callback();
        }
      },
      trigger: 'blur'
    }
  ],
  market_space: [
    { required: true, message: '请输入市场空间', trigger: 'blur' },
  ],
})
 
function getList() {
  operatingIncomePage(params.value).then(res => {
    tableList.value = res.data.data.records || []
    total.value = res.data.data.total || 0
  })
}
function handleEdit(row) {
  titleTxt.value = '编辑'
  isShowEditView.value = true
  editParams.value = { ...row }
}
function handleDelete (row) {
  ElMessageBox.confirm('确定删除吗?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  })
    .then(() => {
      operatingIncomeDelete(row.id).then(res => {
        ElMessage.success('删除成功')
        getList()
      }).catch(error => {
        ElMessage.error('删除失败');
      });
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '已取消删除',
      })
    });
}
 
function handleAdd(row) {
  titleTxt.value = '新增'
  isShowEditView.value = true
}
 
function handleSizeChange(val) {
  params.value.size = val
  getList()
}
 
function handleCurrentChange(val) {
  params.value.current = val
  getList()
}
 
async function submit(formValidate) {
  if (!formValidate) return
  await formValidate.validate((valid, fields) => {
    if (valid) {
      if (titleTxt.value === '新增') {
        operatingIncomeAdd(editParams.value).then(res => {
          isShowEditView.value = false
          ElMessage.success('新增成功')
          getList()
        })
      } else {
        operatingIncomeUpdate(editParams.value).then(res => {
          isShowEditView.value = false
          ElMessage.success('操作成功')
          getList()
        })
      }
      
    }
  })
}
 
function handleClose() {
  // 清除表单内容
  editParams.value = {
    id: '',
    operating_income: '',
    total_cost: '',
    net_profit: '',
    financial_irr: '',
    market_space: '',
  }
}
 
onMounted(() => {
  getList()
})
</script>
 
<style lang="scss" scoped>
  .operatingIncome {
    height: 0;
    flex: 1;
    margin: 0 10px 10px 10px;
    background-color: #ffffff;
    padding: 10px 20px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    .search-box {
      margin-top: 20px;
      height: 40px;
    }
 
    :deep(.el-input) {
      .el-input__wrapper {
        width: 200px;
      }
    }
 
    // 表格
    .mange-table {
      height: 0;
      flex: 1;
      margin-top: 18px;
      overflow: auto;
    }
    :deep(.el-pagination) {
      display: flex;
      justify-content: right;
    }
 
    :deep(.el-pagination button) {
      background: center center no-repeat none !important;
      color: #8eb8ea !important;
    }
    :deep(.ztzf-select){
      .el-select__selection {
        width: 200px;
      }
    }
  }
  
 .content {
  padding: 20px;
  
  .view-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #EBEEF5;
    
    tr {
      &:not(:last-child) {
        border-bottom: 1px solid #EBEEF5;
      }
      
      td {
        padding: 12px 10px;
        
        &.label {
          width: 140px;
          text-align: right;
          // color: #909399;
          // background-color: #F5F7FA;
          border-right: 1px solid #EBEEF5;
        }
        
        &.value {
          width: 180px;
          // color: #303133;
        }
      }
    }
  }
}
.content-edit {
  .el-form {
    .el-form-item {
      width: 320px;
      :deep(.el-form-item__label) {
        width: 140px;
      }
    }
    // .el-form-item:last-child {
    //   width: 640px;
    // }
    .btns {
        display: flex;
        justify-content: center
      }
  }
}
</style>