index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="risk-setting">
  3. <a-table :columns="columns" size="small" :data-source="tableData" :scroll="{ y: 500 }" class="tableW" :pagination="false">
  4. <template #action="{ record }">
  5. <a class="table-action-link" @click="handlerEdit(record)">编辑</a>
  6. </template>
  7. <template #bodyCell="{ column, text }"></template>
  8. </a-table>
  9. <!-- 编辑弹窗 -->
  10. <a-modal v-model:visible="visibleEdit" width="650px" :footer="null" :title="titleEdit" centered destroyOnClose>
  11. <a-form :model="formState" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }" autocomplete="off">
  12. <a-form-item label="粉尘占比:">
  13. <a-input v-model:value="formState.dust" type="number" clearable placeholder="请输入" />
  14. </a-form-item>
  15. <a-form-item label="火灾占比:">
  16. <a-input v-model:value="formState.fire" type="number" clearable placeholder="请输入" />
  17. </a-form-item>
  18. <a-form-item label="瓦斯占比:">
  19. <a-input v-model:value="formState.gas" type="number" clearable placeholder="请输入" />
  20. </a-form-item>
  21. <a-form-item label="通风占比:">
  22. <a-input v-model:value="formState.vent" type="number" clearable placeholder="请输入" />
  23. </a-form-item>
  24. </a-form>
  25. <div class="edit-btn">
  26. <a-button type="primary" style="margin-right: 10px" @click="confirmSave">保存</a-button>
  27. <a-button type="success" @click="cancelSave">取消</a-button>
  28. </div>
  29. </a-modal>
  30. </div>
  31. </template>
  32. <script setup lang="ts">
  33. import { ref, reactive, onMounted } from 'vue';
  34. import { getDisasterProportion, updateDisasterProportion } from './riskSetting.api';
  35. import { columns } from './riskSetting.data';
  36. import { message } from 'ant-design-vue';
  37. let tableData = reactive<any[]>([]);
  38. let visibleEdit = ref(false);
  39. let titleEdit = ref('');
  40. let formState = reactive<any>({
  41. id: '',
  42. dust: '',
  43. fire: '',
  44. gas: '',
  45. vent: '',
  46. });
  47. //编辑
  48. let handlerEdit = (record) => {
  49. titleEdit.value = '编辑';
  50. visibleEdit.value = true;
  51. formState.dust = record.dust;
  52. formState.fire = record.fire;
  53. formState.vent = record.vent;
  54. formState.gas = record.gas;
  55. formState.id = record.id;
  56. };
  57. //确认编辑
  58. async function confirmSave() {
  59. let data = (parseFloat(formState.dust) + parseFloat(formState.fire) + parseFloat(formState.gas) + parseFloat(formState.vent)).toFixed(2);
  60. if (parseFloat(data) == 1) {
  61. let res = await updateDisasterProportion({ ...formState });
  62. if (res.code == 200) {
  63. visibleEdit.value = false;
  64. getDisasterProportionList();
  65. }
  66. } else {
  67. message.warning('录入错误!');
  68. }
  69. }
  70. //取消编辑
  71. let cancelSave = () => {
  72. visibleEdit.value = false;
  73. };
  74. //查询各种灾害风险比重
  75. async function getDisasterProportionList() {
  76. tableData.length = 0;
  77. let res = await getDisasterProportion();
  78. console.log(res, '风险比重占比');
  79. if (res) {
  80. tableData.push(res);
  81. } else {
  82. tableData.length = 0;
  83. }
  84. }
  85. onMounted(() => {
  86. getDisasterProportionList();
  87. });
  88. </script>
  89. <style lang="less" scoped>
  90. .risk-setting {
  91. position: relative;
  92. padding: 10px;
  93. box-sizing: border-box;
  94. }
  95. .zxm-form {
  96. padding-top: 15px !important;
  97. box-sizing: border-box;
  98. }
  99. .edit-btn {
  100. margin: 15px;
  101. display: flex;
  102. justify-content: flex-end;
  103. .zxm-btn {
  104. margin: 0px 10px;
  105. }
  106. }
  107. :deep(.zxm-input) {
  108. color: #fff;
  109. border: 1px solid #3ad8ff77 !important;
  110. background-color: #ffffff00 !important;
  111. }
  112. </style>