setInputTPT.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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
  18. style="width:100%;"
  19. v-model="from.type"
  20. clearable
  21. placeholder="请选择"
  22. >
  23. <el-option
  24. v-for="item in kjtype"
  25. :key="item.dictKey"
  26. :label="item.remark"
  27. :value="item.dictKey"
  28. >
  29. </el-option>
  30. </el-select>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. <!-- 添加框 -->
  35. <div
  36. style="border: 1px dotted rgb(187, 187, 187);box-sizing: border-box;padding: 0px 15px;"
  37. class="martop20 marbottom10"
  38. v-show="from.type=='select'||from.type=='radio'||from.type=='checkbox'"
  39. >
  40. <table
  41. class="table"
  42. width='100%'
  43. border='1px'
  44. cellpadding='2px'
  45. bordercolor="#E5E5E5"
  46. >
  47. <thead
  48. cellpadding='2px'
  49. height='40px'
  50. >
  51. <tr>
  52. <th width='15%'>序号</th>
  53. <th width='65%'>默认值</th>
  54. <th width='20%'>操作</th>
  55. </tr>
  56. </thead>
  57. <tbody height='36px'>
  58. <tr
  59. v-for="(item,key) in setInputTable"
  60. :key="key"
  61. >
  62. <td align="center">{{key+1}}</td>
  63. <td>
  64. <el-input
  65. v-model="setInputTable[key].dictValue"
  66. size="mini"
  67. placeholder="请输入内容"
  68. ></el-input>
  69. </td>
  70. <td align="center">
  71. <el-link
  72. type="warning"
  73. @click="deleteTable(key)"
  74. >删除</el-link>
  75. </td>
  76. </tr>
  77. </tbody>
  78. </table>
  79. <div class="martop20 flexEnd marbottom10"><i
  80. style="padding-bottom: 10px;color:rgb(10, 134, 217);font-size:24px;cursor: pointer;"
  81. class="el-icon-circle-plus"
  82. @click="addTable()"
  83. ></i></div>
  84. </div>
  85. <el-row style="text-align: center">
  86. <el-button type="primary"
  87. size="small"
  88. icon="el-icon-circle-plus-outline"
  89. @click="saveType()">保存设置</el-button> &nbsp;&nbsp;
  90. <el-button type="primary"
  91. size="small"
  92. icon="el-icon-circle-plus-outline"
  93. @click="saveType()">继续保存</el-button>
  94. </el-row>
  95. </div>
  96. </template>
  97. <script>
  98. import { dictionary, saveInput, getColByTabId } from "@/api/manager/AdjustForm";
  99. import { getExcelHtml } from '@/api/exctab/excelmodel'
  100. export default {
  101. props: ['pkeyId', 'htmlData'],
  102. data () {
  103. return {
  104. elementName: [],
  105. kjtype: [],//框架类型
  106. from: {
  107. type: '',
  108. value: '',
  109. },
  110. setInputTable: [],//数据体
  111. disabled: false,
  112. }
  113. },
  114. methods: {
  115. addTable () {//添加table表
  116. this.setInputTable.push({ dictValue: '' })
  117. },
  118. deleteTable (key) {//删除数据
  119. this.setInputTable.splice(key, 1)
  120. },
  121. saveType () {//保存设置按钮
  122. if(this.htmlData.tr == '' || this.htmlData.td == ''){
  123. this.$message({
  124. type: "warning",
  125. message: "请先选择元素"
  126. });
  127. return;
  128. }
  129. this.disabled = true
  130. if (this.from.type) {
  131. let ks = false
  132. if (this.from.type == 'select' | this.from.type == 'radio' | this.from.type == 'checkbox') {
  133. if (this.setInputTable) {
  134. this.setInputTable.forEach(val => {
  135. if (!val.dictValue) {
  136. ks = true
  137. }
  138. })
  139. }
  140. if (ks) {
  141. this.$message({
  142. type: "error",
  143. message: "请填写完枚举值"
  144. });
  145. this.disabled = false
  146. } else {
  147. this.saveInput({
  148. trIndex: this.htmlData.tr,
  149. tdIndex: this.htmlData.td,
  150. tableId: this.pkeyId,
  151. textId: this.from.type,
  152. type: '1',
  153. textInfo: this.setInputTable
  154. })
  155. }
  156. } else {
  157. this.saveInput({
  158. trIndex: this.htmlData.tr,
  159. tdIndex: this.htmlData.td,
  160. tableId: this.pkeyId,
  161. textId: this.from.type,
  162. type: '1',
  163. textInfo: []
  164. })
  165. }
  166. } else {
  167. this.disabled = false
  168. this.$message({
  169. type: "warning",
  170. message: "请选择文本格式"
  171. });
  172. }
  173. },
  174. async dictionary () {//获取文本类型接口
  175. const { data: res } = await dictionary()
  176. console.log(res);
  177. if (res.code === 200) {
  178. this.kjtype = res.data
  179. }
  180. },
  181. async saveInput (da) {//保存设置文本接口
  182. const { data: res } = await saveInput(da)
  183. console.log(res);
  184. if (res.code == 200) {
  185. this.setInputTable = []
  186. this.disabled = false
  187. this.getExcelHtml()
  188. }
  189. },
  190. // async getColByTabId () {//获取字段信息
  191. // const { data: res } = await getColByTabId({ tabId: this.pkeyId })
  192. // console.log(res);
  193. // if (res.code === 200) {
  194. // this.elementName = res.data
  195. // }
  196. // },
  197. async getExcelHtml () {
  198. const { data: res } = await getExcelHtml({ pkeyId:this.pkeyId})
  199. console.log(res);
  200. if (res.code === 200) {
  201. this.htmlData.name = ''
  202. this.from.type = ''
  203. this.htmlData.tr = ''
  204. this.htmlData.td = ''
  205. this.setInputTable = []
  206. localStorage.setItem('excelHtml', res.data)
  207. this.$emit('cop')
  208. }
  209. },
  210. },
  211. created () {
  212. this.dictionary() //获取文本类型接口
  213. // this.getColByTabId()
  214. },
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .table {
  219. margin-top: 20px;
  220. border-radius: 5px;
  221. color: #101010;
  222. font-size: 14px;
  223. }
  224. .setInputcss{
  225. width: 90%;
  226. height: 100%;
  227. }
  228. </style>