edit.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. {include file="public/head"}
  5. <title>{$title}</title>
  6. </head>
  7. <body>
  8. <div id="form-add" class="mp-form" v-cloak="">
  9. <i-Form :model="formData" :label-width="80">
  10. <i-input v-model="formData.id" type="hidden" placeholder="请输入数据组名称"></i-input>
  11. <Form-Item label="数据组名称">
  12. <i-input v-model="formData.name" placeholder="请输入数据组名称"></i-input>
  13. </Form-Item>
  14. <Form-Item label="数据字段">
  15. <i-input v-model="formData.config_name" placeholder="请输入数据字段例如:site_url"></i-input>
  16. </Form-Item>
  17. <Form-Item label="数据组简介">
  18. <i-input v-model="formData.info" placeholder="请输入数据组简介"></i-input>
  19. </Form-Item>
  20. <Form-Item v-for="(item, index) in formData.typelist" :label="'字段' + (index+1)">
  21. <row type="flex" ref="typelist" align="middle">
  22. <i-col span="10">
  23. <row>
  24. <i-col span="23">
  25. <Form-Item>
  26. <i-input :placeholder="item.name.placeholder" v-model="item.name.value"></i-input>
  27. </Form-Item>
  28. </i-col>
  29. </row>
  30. <row>
  31. <i-col span="23">
  32. <Form-Item>
  33. <i-input :placeholder="item.title.placeholder" v-model="item.title.value"></i-input>
  34. </Form-Item>
  35. </i-col>
  36. </row>
  37. <row>
  38. <i-col span="23">
  39. <Form-Item>
  40. <i-select :placeholder="item.type.placeholder" v-model="item.type.value">
  41. <i-option value="input">文本框</i-option>
  42. <i-option value="textarea">多行文本框</i-option>
  43. <i-option value="radio">单选框</i-option>
  44. <i-option value="checkbox">多选框</i-option>
  45. <i-option value="select">下拉选择</i-option>
  46. <i-option value="upload">单图</i-option>
  47. <i-option value="uploads">多图</i-option>
  48. <i-option value="number">数字</i-option>
  49. </i-select>
  50. </Form-Item>
  51. </i-col>
  52. </row>
  53. </i-col>
  54. <i-col span="12">
  55. <Form-Item>
  56. <i-input type="textarea" rows="4" :placeholder="item.param.placeholder"
  57. v-model="item.param.value"></i-input>
  58. </Form-Item>
  59. </i-col>
  60. <i-col span="2" style="display:inline-block; text-align:right;">
  61. <i-button type="primary" icon="close-round" @click="removeType(index)"></i-button>
  62. </i-col>
  63. </row>
  64. </row>
  65. </Form-Item>
  66. <Form-Item>
  67. <i-button type="primary" @click="addType">添加字段</i-button>
  68. </Form-Item>
  69. <Form-Item :class="'add-submit-item'">
  70. <i-Button :type="'primary'" :html-type="'submit'" :size="'large'" :long="true" @click.prevent="submit">提交
  71. </i-Button>
  72. </Form-Item>
  73. </i-Form>
  74. </div>
  75. <script>
  76. $eb = parent._mpApi;
  77. mpFrame.start(function (Vue) {
  78. new Vue({
  79. el: "#form-add",
  80. data: {
  81. formData: {
  82. id: '{$Groupinfo.id}',
  83. name: '{$Groupinfo.name}',
  84. config_name: '{$Groupinfo.config_name}',
  85. typelist: <?php echo $Groupinfo['fields'];?>,
  86. info: '{$Groupinfo.info}'
  87. }
  88. },
  89. methods: {
  90. addType: function () {
  91. this.formData.typelist.push({
  92. name: {
  93. placeholder: "字段名称:姓名",
  94. value: ''
  95. },
  96. title: {
  97. placeholder: "字段配置名:name",
  98. value: ''
  99. },
  100. type: {
  101. placeholder: "字段类型",
  102. value: ''
  103. },
  104. param: {
  105. placeholder: "参数方式例如:\n1=白色\n2=红色\n3=黑色",
  106. value: ''
  107. }
  108. })
  109. },
  110. removeType: function (index) {
  111. this.formData.typelist.splice(index, 1);
  112. },
  113. submit: function () {
  114. $eb.axios.post("{$save}", this.formData).then((res) => {
  115. if (res.status && res.data.code == 200)
  116. return Promise.resolve(res.data);
  117. else
  118. return Promise.reject(res.data.msg || '添加失败,请稍候再试!');
  119. }).then((res) => {
  120. $eb.message('success', res.msg || '操作成功!');
  121. $eb.closeModalFrame(window.name);
  122. parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
  123. }).catch((err) => {
  124. this.loading = false;
  125. $eb.message('error', err);
  126. });
  127. }
  128. }
  129. });
  130. });
  131. </script>
  132. </body>