储能智慧云平台web端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

addition copy.vue 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div>
  3. <div class="card content-box">
  4. <div class="name">{{ supertype }}</div>
  5. <el-divider />
  6. <div class="user_box">
  7. <div class="user_left">
  8. <el-form ref="formRef" :model="numberValidateForm" label-width="auto" class="demo-ruleForm">
  9. <div class="elform">
  10. <el-form-item label="模板名称:" prop="postName" :rules="[{ required: true, message: '请输入模板名称' }]">
  11. <el-input
  12. v-model.number="numberValidateForm.postName"
  13. style="width: 300px"
  14. size="large"
  15. type="text"
  16. placeholder="请输入模板名称"
  17. autocomplete="off"
  18. />
  19. </el-form-item>
  20. <el-form-item label="电站名称:">
  21. <el-input
  22. v-model.number="numberValidateForm.postCode"
  23. style="width: 300px"
  24. size="large"
  25. type="text"
  26. placeholder="请输入电站名称"
  27. autocomplete="off"
  28. />
  29. </el-form-item>
  30. </div>
  31. <div class="elform">
  32. <el-form-item label="模板状态:">
  33. <el-radio-group v-model="numberValidateForm.status">
  34. <el-radio value="0">正常</el-radio>
  35. <el-radio value="1">停用</el-radio>
  36. </el-radio-group>
  37. </el-form-item>
  38. </div>
  39. <div class="elform1">
  40. <!-- <el-form-item label="标签:">
  41. <el-input
  42. v-model.number="numberValidateForm.remark"
  43. style="width: 300px"
  44. size="large"
  45. type="text"
  46. placeholder="请输入标签"
  47. autocomplete="off"
  48. />
  49. </el-form-item> -->
  50. <el-button type="primary" @click="addNewRow">新增行</el-button>
  51. <el-table :data="tableData" style="width: 100%" v-loading="loading" border @row-click="handleRowClick">
  52. <el-table-column prop="name" label="姓名"></el-table-column>
  53. <el-table-column prop="age" label="年龄"></el-table-column>
  54. <el-table-column prop="email" label="邮箱"></el-table-column>
  55. <el-table-column label="操作">
  56. <template #default="{ row }">
  57. <el-button type="text" @click="editRow(row)">编辑</el-button>
  58. <el-button type="text" @click="deleteRow(row)">删除</el-button>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </div>
  63. <el-divider />
  64. <el-form-item class="bottom">
  65. <el-button type="primary" @click="submitForm(formRef)">保存</el-button>
  66. <el-button @click="resetForm(formRef)">关闭</el-button>
  67. </el-form-item>
  68. </el-form>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script setup lang="ts">
  75. import { platformpostadd, platformpostedit, platformshupostedit } from "@/api/home/Multisite";
  76. import { FormInstance } from "element-plus";
  77. import { onMounted, reactive, ref } from "vue";
  78. import { useRouter, useRoute } from "vue-router";
  79. import { nextTick } from "vue";
  80. const router = useRouter();
  81. const route = useRoute();
  82. const formRef = ref<FormInstance>();
  83. const supertype = ref(route.query.type);
  84. const numberValidateForm = reactive({
  85. id: route.query.id,
  86. parentId: "",
  87. postName: "",
  88. postCode: "",
  89. postSort: "",
  90. remark: "",
  91. status: "0"
  92. });
  93. const submitForm = (formEl: FormInstance | undefined) => {
  94. if (!formEl) return;
  95. formEl.validate(async valid => {
  96. if (valid) {
  97. if (route.query.type == "岗位新增") {
  98. const { data } = await platformpostadd(numberValidateForm);
  99. console.log(data);
  100. } else {
  101. const { data } = await platformpostedit(numberValidateForm);
  102. console.log(data);
  103. }
  104. router.back();
  105. } else {
  106. console.log("error submit!");
  107. return false;
  108. }
  109. });
  110. };
  111. const resetForm = (formEl: FormInstance | undefined) => {
  112. if (!formEl) return;
  113. formEl.resetFields();
  114. router.push("/post/index");
  115. };
  116. const yonghueditdata = ref();
  117. const getghuedit = async () => {
  118. const { data } = await platformshupostedit(route.query.id);
  119. yonghueditdata.value = data;
  120. console.log(yonghueditdata.value);
  121. numberValidateForm.postName = yonghueditdata.value.post.postName;
  122. numberValidateForm.postCode = yonghueditdata.value.post.postCode;
  123. numberValidateForm.postSort = yonghueditdata.value.post.postSort;
  124. numberValidateForm.remark = yonghueditdata.value.post.remark;
  125. numberValidateForm.status = yonghueditdata.value.post.status;
  126. };
  127. interface TableDataItem {
  128. name: string;
  129. age: number;
  130. email: string;
  131. }
  132. const loading = ref(false);
  133. const addNewRow = () => {
  134. const newRow = ref<TableDataItem>({
  135. name: "",
  136. age: 0,
  137. email: ""
  138. });
  139. tableData.push(newRow.value);
  140. nextTick(() => {
  141. const tableBody = document.querySelector(".el-table__body-wrapper");
  142. if (tableBody) {
  143. tableBody.scrollTop = tableBody.scrollHeight;
  144. }
  145. });
  146. };
  147. const tableData = reactive<TableDataItem[]>([
  148. { name: "张三", age: 30, email: "zhangsan@example.com" },
  149. { name: "李四", age: 25, email: "lisi@example.com" },
  150. { name: "王五", age: 28, email: "wangwu@example.com" }
  151. // ...其他数据
  152. ]);
  153. const editRow = (row: TableDataItem) => {
  154. console.log(row);
  155. // 编辑行的逻辑,可以根据实际情况进行实现
  156. };
  157. const deleteRow = (row: TableDataItem) => {
  158. console.log(row);
  159. // 删除行的逻辑,可以根据实际情况进行实现
  160. };
  161. const handleRowClick = (row: TableDataItem) => {
  162. console.log(row);
  163. // 点击行的处理逻辑,可以根据实际情况进行实现
  164. };
  165. onMounted(() => {
  166. if (route.query.type == "岗位编辑") {
  167. getghuedit();
  168. }
  169. });
  170. </script>
  171. <style scoped lang="scss">
  172. @import "./addition.scss";
  173. </style>