edit.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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-option value="datetime">日期时间</i-option>
  50. </i-select>
  51. </Form-Item>
  52. </i-col>
  53. </row>
  54. </i-col>
  55. <i-col span="12">
  56. <Form-Item>
  57. <i-input type="textarea" rows="4" :placeholder="item.param.placeholder"
  58. v-model="item.param.value"></i-input>
  59. </Form-Item>
  60. </i-col>
  61. <i-col span="2" style="display:inline-block; text-align:right;">
  62. <i-button type="primary" icon="close-round" @click="removeType(index)"></i-button>
  63. </i-col>
  64. </row>
  65. </row>
  66. </Form-Item>
  67. <Form-Item>
  68. <i-button type="primary" @click="addType">添加字段</i-button>
  69. </Form-Item>
  70. <Form-Item :class="'add-submit-item'">
  71. <i-Button :type="'primary'" :html-type="'submit'" :size="'large'" :long="true" @click.prevent="submit">提交
  72. </i-Button>
  73. </Form-Item>
  74. </i-Form>
  75. </div>
  76. <script>
  77. $eb = parent._mpApi;
  78. mpFrame.start(function (Vue) {
  79. new Vue({
  80. el: "#form-add",
  81. data: {
  82. formData: {
  83. id: '{$Groupinfo.id}',
  84. name: '{$Groupinfo.name}',
  85. config_name: '{$Groupinfo.config_name}',
  86. typelist: <?php echo $Groupinfo['fields'];?>,
  87. info: '{$Groupinfo.info}'
  88. }
  89. },
  90. methods: {
  91. addType: function () {
  92. this.formData.typelist.push({
  93. name: {
  94. placeholder: "字段名称:姓名",
  95. value: ''
  96. },
  97. title: {
  98. placeholder: "字段配置名:name",
  99. value: ''
  100. },
  101. type: {
  102. placeholder: "字段类型",
  103. value: ''
  104. },
  105. param: {
  106. placeholder: "参数方式例如:\n1=白色\n2=红色\n3=黑色",
  107. value: ''
  108. }
  109. })
  110. },
  111. removeType: function (index) {
  112. this.formData.typelist.splice(index, 1);
  113. },
  114. submit: function () {
  115. $eb.axios.post("{$save}", this.formData).then((res) => {
  116. if (res.status && res.data.code == 200)
  117. return Promise.resolve(res.data);
  118. else
  119. return Promise.reject(res.data.msg || '添加失败,请稍候再试!');
  120. }).then((res) => {
  121. $eb.message('success', res.msg || '操作成功!');
  122. $eb.closeModalFrame(window.name);
  123. parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
  124. }).catch((err) => {
  125. this.loading = false;
  126. $eb.message('error', err);
  127. });
  128. }
  129. }
  130. });
  131. });
  132. </script>
  133. </body>