newsForm.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div id="newsForm">
  3. <el-row v-if="loading">
  4. <el-col :span="24">
  5. <el-col :span="24" class="top">
  6. <span class="shu"></span><span class="title">{{ formTitle }}</span>
  7. </el-col>
  8. <el-col :span="24" class="form">
  9. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  10. <!--<el-form-item label="名称" prop="name">
  11. <el-input v-model="ruleForm.name" placeholder="请输入名称"></el-input>
  12. </el-form-item>
  13. <el-form-item label="图片" prop="image">
  14. <uploadImage
  15. :limit="1"
  16. :data="ruleForm.image"
  17. :url="`/files/financial/custom/upload`"
  18. @uploadSuccess="uploadSuccess"
  19. @remove="remove"
  20. ></uploadImage>
  21. </el-form-item>
  22. <el-form-item label="链接" prop="link">
  23. <el-input v-model="ruleForm.link" placeholder="请输入链接"></el-input>
  24. </el-form-item>-->
  25. <el-form-item label="标题" prop="title">
  26. <el-input v-model="ruleForm.title" placeholder="请输入标题"></el-input>
  27. </el-form-item>
  28. <el-form-item label="图片" prop="image">
  29. <uploadImage
  30. :limit="1"
  31. :data="ruleForm.image"
  32. :url="`/files/financial/custom/upload`"
  33. @uploadSuccess="uploadSuccess"
  34. @remove="remove"
  35. ></uploadImage>
  36. </el-form-item>
  37. <el-form-item label="简介" prop="brief_introduction">
  38. <el-input v-model="ruleForm.brief_introduction" type="textarea" placeholder="请输入简介"></el-input>
  39. </el-form-item>
  40. <el-form-item label="来源" prop="source">
  41. <el-input v-model="ruleForm.source" placeholder="请输入来源"></el-input>
  42. </el-form-item>
  43. <el-form-item label="是否热门" prop="hot">
  44. <el-radio-group v-model="ruleForm.hot">
  45. <el-radio label="1" >是</el-radio>
  46. <el-radio label="0" >否</el-radio>
  47. </el-radio-group>
  48. </el-form-item>
  49. <el-form-item label="内容" prop="description">
  50. <wang-editor v-model="ruleForm.description" placeholder="请输入内容"></wang-editor>
  51. </el-form-item>
  52. <el-col :span="24" class="clickBtn">
  53. <el-button @click="submitForm">提交</el-button>
  54. <el-button @click="resetForm">取消</el-button>
  55. </el-col>
  56. </el-form>
  57. </el-col>
  58. </el-col>
  59. </el-row>
  60. </div>
  61. </template>
  62. <script>
  63. import uploadImage from '@/layout/custom/uploadImage.vue';
  64. import WangEditor from '@/components/wang-editor.vue';
  65. export default {
  66. name: 'newsForm',
  67. props: {
  68. ruleForm: null,
  69. loading: null,
  70. },
  71. components: {
  72. uploadImage, //图片
  73. WangEditor, //富文本
  74. },
  75. data: () => ({
  76. formTitle: '新闻中心管理',
  77. rules: {
  78. title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
  79. hot: [{ required: true, message: '请选择是否热门', trigger: 'change' }],
  80. description: [{ required: true, message: '请输入内容', trigger: 'blur' }],
  81. },
  82. }),
  83. created() {},
  84. computed: {},
  85. methods: {
  86. submitForm() {
  87. if(!this.ruleForm.description){
  88. this.$message.error('请输入内容');
  89. return false;
  90. }
  91. this.$refs['ruleForm'].validate((valid) => {
  92. if (valid) {
  93. this.$emit('submitForm', { data: this.ruleForm });
  94. } else {
  95. console.log('error submit!!');
  96. return false;
  97. }
  98. });
  99. /*this.$emit('submitForm', { data: this.ruleForm });*/
  100. },
  101. resetForm() {
  102. this.$emit('resetForm');
  103. },
  104. uploadSuccess({ data }) {
  105. this.$set(this.ruleForm, 'image', data.uri);
  106. },
  107. remove(file) {
  108. this.$set(this.ruleForm, 'image', '')
  109. },
  110. },
  111. };
  112. </script>
  113. <style lang="less" scoped>
  114. .form {
  115. padding: 0 200px 0 0;
  116. }
  117. p {
  118. padding: 0;
  119. margin: 0;
  120. }
  121. .top .shu {
  122. float: left;
  123. width: 4px;
  124. height: 20px;
  125. background: rgba(233, 2, 29, 1);
  126. }
  127. .top .title {
  128. float: left;
  129. padding: 0 10px;
  130. font-size: 16px;
  131. font-family: Source Han Sans SC;
  132. font-weight: bold;
  133. color: rgba(40, 40, 40, 1);
  134. }
  135. /deep/ .el-textarea__inner {
  136. min-height: 100px !important;
  137. }
  138. /deep/ .select {
  139. width: 632px;
  140. }
  141. .selects {
  142. width: 473px;
  143. margin: 0 15px 0 0;
  144. }
  145. /deep/ .el-radio__input.is-checked + .el-radio__label {
  146. color: #e9021d;
  147. }
  148. /deep/ .el-radio__input.is-checked .el-radio__inner {
  149. border-color: #e9021d;
  150. background: #e9021d;
  151. }
  152. /deep/ .el-checkbox__input.is-checked + .el-checkbox__label {
  153. color: #e9021d;
  154. }
  155. /deep/ .el-checkbox__input.is-checked .el-checkbox__inner,
  156. .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  157. background-color: #e9021d;
  158. border-color: #e9021d;
  159. }
  160. /deep/ .el-checkbox-button,
  161. .el-checkbox-button__inner {
  162. margin: 0 15px 0 0;
  163. }
  164. /deep/ .el-checkbox-button__inner {
  165. padding: 7px 5px;
  166. border: 1px solid #ccc;
  167. border-radius: 5px;
  168. }
  169. /deep/ .el-checkbox-button__inner:hover {
  170. color: #e9021d;
  171. }
  172. /deep/ .el-checkbox-button:first-child .el-checkbox-button__inner {
  173. border-left: 1px solid #ccc;
  174. border-radius: 5px;
  175. }
  176. /deep/ .el-checkbox-button:last-child .el-checkbox-button__inner {
  177. border-radius: 5px;
  178. }
  179. /deep/ .el-checkbox-button.is-checked .el-checkbox-button__inner {
  180. color: #e9021d;
  181. background-color: #ffffff;
  182. border-color: #e9021d;
  183. }
  184. /deep/ .el-checkbox-button.is-checked .el-checkbox-button__inner {
  185. box-shadow: none;
  186. }
  187. /deep/ .el-switch.is-checked .el-switch__core {
  188. border-color: #e9021d;
  189. background-color: #e9021d;
  190. }
  191. .clickBtn .el-button {
  192. width: 100px;
  193. height: 40px;
  194. padding: 0;
  195. color: #ffffff;
  196. background: #b9b9b9;
  197. border-radius: 4px;
  198. margin: 40px;
  199. }
  200. .clickBtn {
  201. text-align: center;
  202. margin: 40px 0;
  203. border-top: 1px solid #ccc;
  204. }
  205. .clickBtn .el-button:first-child {
  206. background-color: #e9021d;
  207. }
  208. </style>