index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div>
  3. <el-form ref="form" :model="form" :rules="rules" label-width="160px" class="from_index">
  4. <el-row>
  5. <el-col :span="24" v-for="(item,index) in formConfig.columns" :key="index">
  6. <el-form-item :label="item.columnComment" style="display: inline-block;" :prop="item.columnName" v-if="item.isEdit == 1">
  7. <!-- 输入框 -->
  8. <el-input v-if="item.htmlType == 'input'" v-model="config[item.columnName]" :placeholder="'请输入'+item.columnComment"
  9. clearable @keyup.enter.native="submitForm" />
  10. <!-- 多行输入框 -->
  11. <el-input v-if="item.htmlType == 'textarea'" type="textarea" v-model="config[item.columnName]" :placeholder="'请输入'+item.columnComment"
  12. clearable @keyup.enter.native="submitForm" @change="submitForm"/>
  13. <!-- 下拉框 -->
  14. <el-select v-model="config[item.columnName]" v-if="item.htmlType == 'select'" filterable :placeholder="'请输入'+item.columnComment">
  15. <el-option v-for="itemChild in item.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictLabel" :value="itemChild.dictValue" @change="submitForm">
  16. </el-option>
  17. </el-select>
  18. <!-- 复选框 -->
  19. <el-checkbox-group v-model="config" v-if="item.htmlType == 'checkbox'">
  20. <el-checkbox @change="submitForm" v-for="itemChild in item.sysDictData" :label="itemChild.dictValue" :key="itemChild.dictLabel" >
  21. {{itemChild.dictLabel}}
  22. </el-checkbox>
  23. </el-checkbox-group>
  24. <!-- 单选框 -->
  25. <el-radio-group v-model="config[item.columnName]" v-if="item.htmlType == 'radio'">
  26. <el-radio v-for="itemChild in item.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictLabel" :value="itemChild.dictValue" @change="submitForm"></el-radio>
  27. </el-radio-group>
  28. <!-- 时间控件 -->
  29. <el-date-picker v-model="config[item.columnName]" v-if="item.htmlType == 'datetime'" type="date" :placeholder="'请输入'+item.columnComment" @change="submitForm">
  30. </el-date-picker>
  31. <!-- 上传图片 -->
  32. <el-upload v-if="item.htmlType == 'imageUpload'" :headers="{Authorization: 'Bearer ' + getToken()}" :action="process + '/boman-file/upload'" list-type="picture-card"
  33. :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
  34. <i class="el-icon-plus"></i>
  35. </el-upload>
  36. <el-dialog :visible.sync="dialogVisible" v-if="item.htmlType == 'imageUpload'">
  37. <img width="100%" :src="dialogImageUrl" alt="">
  38. </el-dialog>
  39. <!-- 上传文件 -->
  40. <el-upload
  41. class="upload-demo"
  42. :headers="{Authorization: 'Bearer ' + getToken()}"
  43. v-if="item.htmlType == 'fileUpload'"
  44. :action="process + '/boman-file/upload'"
  45. :on-change="handleChange"
  46. :file-list="fileList">
  47. <el-button size="small" type="primary">点击上传</el-button>
  48. <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
  49. </el-upload>
  50. <!-- 富文本 -->
  51. <editor v-model="config[item.columnName]" v-if="item.htmlType == 'editor'" :min-height="192"/>
  52. </el-form-item>
  53. </el-col>
  54. </el-row>
  55. </el-form>
  56. <div slot="footer" class="dialog-footer">
  57. <el-button type="primary" @click="submitForm">确 定</el-button>
  58. <el-button @click="cancel">取 消</el-button>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. const defaultSettings = require('@/settings.js')
  64. import { addConfigindex } from "@/api/system/config";
  65. import Editor from '@/components/Editor';
  66. import { getToken } from "@/utils/auth";
  67. export default {
  68. data() {
  69. return {
  70. fileList: [],
  71. defaultSettings,
  72. dialogImageUrl: '',
  73. process: process.env.VUE_APP_BASE_API,
  74. dialogVisible: false,
  75. disabled: false,
  76. config: {},
  77. form:{},
  78. // 表单校验
  79. rules: {
  80. },
  81. open:false
  82. }
  83. },
  84. components: {
  85. Editor
  86. },
  87. props: {
  88. formConfig: {},
  89. nummer:0
  90. },
  91. created() {
  92. this.init()
  93. },
  94. mounted() {
  95. },
  96. methods: {
  97. init() {
  98. // if(this.formConfig.htmlType == 'checkbox'){
  99. // this.config = []
  100. // }
  101. console.log(this.config,99888)
  102. console.log(this.nummer)
  103. },
  104. handleChange(file, fileList) {
  105. this.fileList = fileList.slice(-3);
  106. },
  107. getToken() {
  108. return getToken()
  109. },
  110. handleRemove(file, fileList) {
  111. console.log(file, fileList);
  112. },
  113. handlePictureCardPreview(file) {
  114. this.dialogImageUrl = file.url;
  115. this.dialogVisible = true;
  116. },
  117. handleDownload(file) {
  118. console.log(file);
  119. },
  120. handleQuery() {
  121. this.$emit('btns')
  122. },
  123. submitForm(value){
  124. console.log(1243)
  125. console.log(this.config,value)
  126. this.form.fixedData = this.config
  127. this.form.table = 'sys_memorandum'
  128. this.form.objId = -1
  129. this.$refs["form"].validate(valid => {
  130. if (valid) {
  131. // if (this.form.id != undefined) {
  132. // updateNotice(this.form).then(response => {
  133. // this.msgSuccess("修改成功");
  134. // this.open = false;
  135. // this.getList();
  136. // });
  137. // } else {
  138. addConfigindex(this.form).then(response => {
  139. this.msgSuccess("新增成功");
  140. // this.open = false;
  141. this.cancel();
  142. });
  143. // }
  144. }
  145. });
  146. // this.$emit('submitForm',this.config)
  147. },
  148. cancel(){
  149. this.$emit('cancel',this.config)
  150. },
  151. handleCheckedCitiesChange(value){
  152. console.log(this.config)
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. .from_index{
  159. .el-form-item{
  160. width: 93%;
  161. }
  162. .el-input{
  163. width: 100%;
  164. }
  165. .el-select{
  166. width: 100%;
  167. }
  168. }
  169. </style>
  170. <style scoped lang="scss">
  171. .dialog-footer{
  172. display: flex;
  173. justify-content: flex-end;
  174. }
  175. </style>