setFormula.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div>
  3. <div class="setInputcss">
  4. <el-row :span="24">
  5. <el-col :span="3.3" style="line-height: 40px">
  6. 元素坐标:
  7. </el-col>
  8. <el-col :span="18">
  9. <avue-input v-model="htmlData.name" placeholder="请输入内容" :disabled='true'></avue-input>
  10. </el-col>
  11. </el-row>
  12. <el-row :span="24">
  13. <el-col :span="3.3" style="line-height: 40px">
  14. 参数名称:
  15. </el-col>
  16. <el-col :span="18">
  17. <el-select v-model="value" placeholder="请选择" style="width: 100%;">
  18. <el-option
  19. v-for="item in options"
  20. :key="item.id"
  21. :label="item.paramName"
  22. :value="item.id">
  23. </el-option>
  24. </el-select>
  25. </el-col>
  26. </el-row>
  27. <el-row style="text-align: center;margin-top: 15px;">
  28. <el-button type="primary" size="small" icon="el-icon-circle-plus-outline" @click="addList">保存入库</el-button>
  29. </el-row>
  30. <el-row style="margin-top: 15px;">
  31. <el-table
  32. :data="tableData"
  33. border
  34. style="width: 100%">
  35. <el-table-column
  36. fixed
  37. prop="elementName"
  38. label="元素位置"
  39. >
  40. </el-table-column>
  41. <el-table-column
  42. prop="paramName"
  43. label="参数名称"
  44. >
  45. </el-table-column>
  46. </el-table>
  47. </el-row>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import {checkParamElement } from '@/api/exctab/exceltab'
  53. import { queryParameterList,submitElement } from "@/api/paramter/parmter.js";
  54. export default {
  55. props: ['pkeyId1', 'htmlData'],
  56. data() {
  57. return {
  58. options: [],
  59. value: '',
  60. tableData: [],
  61. projectId:''
  62. }
  63. },
  64. created() {
  65. this.projectId = this.$route.query.pid;
  66. this.getOptionData();
  67. this.getTableData()
  68. },
  69. methods: {
  70. getOptionData () {
  71. queryParameterList({
  72. current: 1,
  73. size:1000
  74. }).then((res) => {
  75. if(res.data.code===200){
  76. this.options = res.data.data.records;
  77. }else{
  78. this.options=[]
  79. }
  80. })
  81. },
  82. //获取表格数据
  83. getTableData(){
  84. checkParamElement({
  85. pkeyId:this.pkeyId1,
  86. }).then((res) => {
  87. console.log(res,'res');
  88. if(res.data.code===200){
  89. this.tableData = res.data.data
  90. }else{
  91. this.tableData=[]
  92. }
  93. })
  94. },
  95. addList() {
  96. try {
  97. // 检查关键字段是否存在
  98. if (!this.htmlData || !this.htmlData.keyname || this.value === undefined) {
  99. console.error('缺少必要的数据字段');
  100. return;
  101. }
  102. console.log(this.htmlData,'this.htmlData');
  103. const {name}=this.htmlData
  104. const paramId = this.value;
  105. let type=''
  106. this.options.forEach(item => {
  107. if (item.id === paramId) {
  108. type= item.type;
  109. }
  110. });
  111. // 检查 name 是否已存在于 tableData 中
  112. const isKeynameExists = this.tableData.some(item => item.elementName === name);
  113. if (isKeynameExists) {
  114. this.$message.warning('已存在相同的关键字段,请勿重复添加');
  115. return;
  116. }
  117. let subObj={
  118. parameterId: paramId,
  119. type:type,
  120. elementName:name,
  121. projectList:[{projectId:this.projectId}]
  122. }
  123. submitElement([subObj]).then((res) => {
  124. if(res.data.code==200){
  125. this.$message.success(res.data.msg)
  126. }else{
  127. this.$message.error(res.data.msg)
  128. }
  129. this.getTableData()
  130. });
  131. } catch (error) {
  132. console.error('插入数据时发生错误:', error);
  133. }
  134. },
  135. editClick(index,row){
  136. this.tableData.forEach((ele) => {
  137. this.$set(ele,"isEdit", false)
  138. })
  139. this.$set(row, "isEdit", true)
  140. this.htmlData.name=row.site
  141. this.value=row.name
  142. },
  143. saveClick(index,row){
  144. this.$set(row, "isEdit", false)
  145. this.$set(row, "name", this.value)
  146. },
  147. delRow(index,row){
  148. this.tableData.splice(index,1)
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .table {
  155. margin-top: 20px;
  156. border-radius: 5px;
  157. color: #101010;
  158. font-size: 14px;
  159. }
  160. .setInputcss {
  161. width: 90%;
  162. height: 100%;
  163. }
  164. </style>