setInputTPT.vue 5.5 KB

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