check_edit.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div id="vip-setting">
  3. <el-form
  4. label-position="right"
  5. label-width="80px"
  6. :model="ruleForm"
  7. :rules="rules"
  8. ref="ruleForm"
  9. >
  10. <h3>会员定价</h3>
  11. <h4>月付</h4>
  12. <el-form-item label="中文名称" prop="cn">
  13. <el-input v-model="ruleForm.cn"></el-input>
  14. </el-form-item>
  15. <el-form-item label="英文名称" prop="en">
  16. <el-input v-model="ruleForm.en"></el-input>
  17. </el-form-item>
  18. <el-form-item label="状态" prop="status">
  19. <el-input v-model="ruleForm.status"></el-input>
  20. </el-form-item>
  21. <el-form-item label="排序" prop="sort">
  22. <el-input v-model="ruleForm.sort"></el-input>
  23. </el-form-item>
  24. <el-form-item label="价格" prop="price">
  25. <el-input v-model="ruleForm.price"></el-input>
  26. </el-form-item>
  27. <el-form-item label="配图" prop="img">
  28. <el-input v-model="ruleForm.img"></el-input>
  29. </el-form-item>
  30. <el-form-item label="简介" prop="summary">
  31. <el-input type="textarea" v-model="ruleForm.summary"></el-input>
  32. </el-form-item>
  33. <el-form-item label="证书" prop="id">
  34. <el-input type="textarea" v-model="ruleForm.id"></el-input>
  35. </el-form-item>
  36. <el-form-item label="说明" prop="remind">
  37. <quill-editor
  38. v-model="ruleForm.remind"
  39. ref="quillEditor"
  40. class="editer"
  41. :options="editorOption"
  42. @ready="onEditorReady($event)"
  43. ></quill-editor>
  44. </el-form-item>
  45. <el-form-item>
  46. <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
  47. <el-button type="primary" @click="clickCancel">取消</el-button>
  48. </el-form-item>
  49. </el-form>
  50. </div>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. editorOption: {
  57. modules: {
  58. toolbar: [
  59. ['bold', 'italic', 'underline', 'strike'], // toggled buttons
  60. ['blockquote', 'code-block'],
  61. [{ 'header': 1 }, { 'header': 2 }], // custom button values
  62. [{ 'list': 'ordered' }, { 'list': 'bullet' }],
  63. [{ 'script': 'sub' }, { 'script': 'super' }], // superscript/subscript
  64. [{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent
  65. [{ 'direction': 'rtl' }], // text direction
  66. [{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
  67. [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
  68. // [{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
  69. [{ 'font': [] }],
  70. // [{ 'align': [] }],
  71. ['clean'] // remove formatting button
  72. ]
  73. }
  74. },
  75. ruleForm: {},
  76. rules: {
  77. cn: [
  78. { required: true, message: '请输入数字', trigger: 'blur' },
  79. ],
  80. en: [
  81. { required: true, message: '请输入数字', trigger: 'blur' },
  82. ],
  83. id: [
  84. { required: true, message: '请输入数字', trigger: 'blur' },
  85. ],
  86. sort: [
  87. { required: true, message: '请输入数字', trigger: 'blur' },
  88. ],
  89. status: [
  90. { required: true, message: '请输入数字', trigger: 'blur' },
  91. ],
  92. price: [
  93. { required: true, message: '请输入数字', trigger: 'blur' },
  94. ],
  95. img: [
  96. { required: true, message: '请输入数字', trigger: 'blur' },
  97. ],
  98. summary: [
  99. { required: true, message: '请输入数字', trigger: 'blur' },
  100. ],
  101. remind: [
  102. { required: true, message: '请输入数字', trigger: 'blur' },
  103. ],
  104. },
  105. // vip 列表
  106. list: [],
  107. }
  108. },
  109. computed: {
  110. editor() {
  111. return this.$refs.quillEditor.quill
  112. }
  113. },
  114. mounted() {
  115. this.getList()
  116. },
  117. methods: {
  118. onEditorReady(editor) {
  119. },
  120. clickCancel() {
  121. },
  122. /**
  123. * 重置
  124. */
  125. resetForm(formName = 'ruleForm') {
  126. this.$refs[formName].resetFields()
  127. },
  128. /**
  129. * 保存或更新
  130. */
  131. async update() {
  132. // const ruleForm = this.ruleForm
  133. // const can_buy_monthly = ruleForm.can_buy_monthly ? '1' : '0'
  134. // const can_buy_quarterly = ruleForm.can_buy_quarterly ? '1' : '0'
  135. // const can_buy_yearly = ruleForm.can_buy_yearly ? '1' : '0'
  136. // const res = await this.$post("/api/admin/vip/update", {
  137. // ...ruleForm,
  138. // can_buy_monthly,
  139. // can_buy_quarterly,
  140. // can_buy_yearly,
  141. // })
  142. // if(res) this.$message({
  143. // message: '更新成功',
  144. // type: 'success'
  145. // })
  146. },
  147. /**
  148. * 提交
  149. */
  150. submitForm(formName) {
  151. // this.$refs[formName].validate((valid) => {
  152. // if(valid) {
  153. // console.log(this.ruleForm)
  154. // this.update()
  155. // } else {
  156. // console.log('error submit!!')
  157. // return false
  158. // }
  159. // })
  160. },
  161. /**
  162. * 获取详情数据
  163. */
  164. async getDetail({ id }) {
  165. // const res = await this.$post("/api/admin/vip/getDetail", { id })
  166. // const data = res.data
  167. // const can_buy_monthly = data.can_buy_monthly === '1'
  168. // const can_buy_quarterly = data.can_buy_quarterly === '1'
  169. // const can_buy_yearly = data.can_buy_yearly === '1'
  170. // // ruleForm 相当于 detail, 这里同步下关键词
  171. // this.ruleForm = {
  172. // ...data,
  173. // can_buy_monthly,
  174. // can_buy_quarterly,
  175. // can_buy_yearly,
  176. // }
  177. },
  178. /**
  179. * 获取列表数据
  180. */
  181. async getList() {
  182. // const res = await this.$post("/api/admin/vip/getList")
  183. // // console.log(res)
  184. // this.list = res.data
  185. // this.titles = this.list.map(i => i.name)
  186. }
  187. }
  188. }
  189. </script>
  190. <style>
  191. #vip-setting {
  192. padding: 20px;
  193. }
  194. .table {
  195. height: 100%;
  196. height: calc(100% - 80px);
  197. }
  198. .el-input {
  199. width: auto;
  200. }
  201. .editer {
  202. height: 300px;
  203. padding: 0 0 100px;
  204. }
  205. </style>