editDefault.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div>
  3. <div class="editDefault">
  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="htmlData1.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-input
  18. class="martop15"
  19. style="width:100%;"
  20. type="textarea"
  21. :rows="5"
  22. placeholder="请输入内容"
  23. v-model="textarea"
  24. ></el-input>
  25. </el-col>
  26. </el-row>
  27. <el-row style="text-align: center">
  28. <el-button type="primary"
  29. size="small"
  30. icon="el-icon-check"
  31. @click="saveDdefual()">保存
  32. </el-button> &nbsp;&nbsp;
  33. <el-button
  34. class="el-button el-button--default el-button--small"
  35. icon="el-icon-use"
  36. @click="cleanDefult()">清&nbsp;&nbsp;空
  37. </el-button>
  38. </el-row>
  39. </div>
  40. <div style="border: 1px dotted rgb(187, 187, 187);box-sizing: border-box;padding: 0px 15px;"
  41. class="martop20 marbottom10">
  42. <table @click
  43. class="table martop20 copyTable"
  44. width='100%'
  45. border='1px '
  46. bordercolor="#E5E5E5"
  47. cellpadding='2px'
  48. >
  49. <thead
  50. cellpadding='2px'
  51. height='40px'
  52. >
  53. <tr>
  54. <th width='30%'>元素位置</th>
  55. <th width='30%'>默认值</th>
  56. <th width='20%'>操作</th>
  57. </tr>
  58. </thead>
  59. <tbody height='36px'>
  60. <tr v-for="(item,key) in setsignaTable" :key="key" v-on:click="">
  61. <td>{{ item.colName }}</td>
  62. <td>{{ item.sigRoleName }}</td>
  63. <td align="center"><span style="color:red;cursor: pointer;" v-on:click="deleteTableSig(item.id)">删除</span></td>
  64. </tr>
  65. </tbody>
  66. </table>
  67. </div>
  68. </div>
  69. </template>
  70. <script>
  71. import {getSigList, remove, saveDdefual} from "../../../../../api/manager/AdjustForm";
  72. export default {
  73. props: ['pkeyId1', 'htmlData1'],
  74. data() {
  75. return {
  76. textarea: '',
  77. setsignaTable: []
  78. }
  79. },
  80. methods: {
  81. async saveDdefual() {
  82. if(this.htmlData1.tr === '' || this.htmlData1.td === ''){
  83. this.$message({
  84. type: "warning",
  85. message: "请先选择元素"
  86. });
  87. return;
  88. }
  89. if(this.textarea === '' || this.textarea=== ''){
  90. this.$message({
  91. type: "warning",
  92. message: "请输入默认值"
  93. });
  94. return;
  95. }
  96. //一个字段只能配置一个默认信息
  97. let isCan=true
  98. this.setsignaTable.forEach(element => {
  99. if (isCan) {
  100. // 如果满足条件,执行相应的操作,并将条件修改为 false
  101. if (element.colKey===this.htmlData1.keyname) { // 这里 someConditionMet 是你的条件判断函数
  102. isCan = false;
  103. }
  104. }
  105. });
  106. if(isCan){
  107. const {data: res} = await saveDdefual({
  108. trIndex: this.htmlData1.tr,
  109. tdIndex: this.htmlData1.td,
  110. tableId: this.pkeyId1,
  111. textId: this.textarea,
  112. type: '4',
  113. })
  114. if (res.code === 200) {
  115. this.getSingInfo();
  116. this.$message({
  117. type: "success",
  118. message: "操作成功"
  119. });
  120. this.$parent.copss();
  121. }
  122. }else{
  123. this.$message.warning('一个字段只能配置一个默认信息')
  124. }
  125. },
  126. async deleteTableSig (ids) {//删除数据
  127. const {data: res} = await remove(ids);
  128. this.getSingInfo();
  129. if (res.code === 200) {
  130. this.$message({
  131. type: "success",
  132. message: "操作成功"
  133. });
  134. }
  135. },
  136. cleanDefult () {//删除数据
  137. this.textarea='';
  138. },
  139. async getSingInfo() {
  140. const {data: res} = await getSigList(
  141. {
  142. current: 0,
  143. size: 100,
  144. tabId: this.pkeyId1,
  145. type:4
  146. }
  147. )
  148. if (res.code === 200) {
  149. this.setsignaTable = res.data.records;
  150. }
  151. }
  152. },
  153. created() {
  154. this.getSingInfo();
  155. this.setsignaTable = [];
  156. this.textarea='';
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .copyTable td{
  162. user-select:initial !important;
  163. }
  164. </style>