AddDisclInfo.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!-- 添加机构信息 By_liucf -->
  2. <template>
  3. <div>
  4. <crumbs :title="topInfo" linkTo="/admin/LT-YXSJWH-MZSMWH">
  5. </crumbs>
  6. <div class="contents">
  7. <el-form ref="form" :label-position="labelPosition" :model="form" :rules="rules" label-width="65px" class="add-discl-form">
  8. <el-form-item label="标题:" prop="title">
  9. <el-input v-model="form.title" placeholder="请输入标题"></el-input>
  10. </el-form-item>
  11. <el-form-item label="内容:" prop="description" class="discDesc">
  12. <el-input type="textarea" :rows="3" placeholder="请输入内容述" v-model="form.description" maxlength="1024"></el-input>
  13. </el-form-item>
  14. <el-form-item label="归属:" prop="disclaimerCode">
  15. <el-select v-model="form.disclaimerCode" clearable placeholder="请选择">
  16. <el-option
  17. v-for="item in options"
  18. :key="item.key"
  19. :label="item.name"
  20. :value="item.key">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-button class="disclButn" size="small" type="primary" @click="addDiscl">{{text}}</el-button>
  25. </el-form>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import api from '@api/icss.js';
  31. export default {
  32. name: 'AddDisclInfo',
  33. data(){
  34. const titleVaild = (rule, value, callback) => {
  35. if (!value) {
  36. return callback(new Error('请输入标题'));
  37. }
  38. if (value.length > 30) {
  39. this.form.name = value.substr(0, 120);
  40. this.$message({
  41. showClose: true,
  42. type: 'warning',
  43. message: '已超过最大字数限制'
  44. })
  45. }
  46. callback();
  47. };
  48. /*const descVaild = (rule, value, callback) => {
  49. if (!value) {
  50. return callback(new Error('请输入内容'));
  51. }
  52. if (value.length > 1024) {
  53. this.form.name = value.substr(0, 120);
  54. this.$message({
  55. showClose: true,
  56. type: 'warning',
  57. message: '科室名称最多可输入1024个字'
  58. })
  59. }
  60. callback();
  61. };*/
  62. const disclVaild = (rule, value, callback) => {
  63. if (!value) {
  64. return callback(new Error('请选择归属'));
  65. }
  66. callback();
  67. };
  68. return {
  69. id:null,
  70. labelPosition:'right',
  71. options:[],
  72. form: {
  73. title: '',
  74. description: '',//内容
  75. disclaimerCode:'' //归属
  76. },
  77. rules: {
  78. title:[
  79. { required: true, validator: titleVaild, trigger: ['blur', 'change'] },
  80. { required: true, message: '请输入标题', trigger: ['blur', 'change'] }
  81. ],
  82. description:[
  83. // { required: true, validator: descVaild, trigger: ['blur', 'change'] },
  84. { required: true, message: '请输入内容', trigger: ['blur', 'change'] }
  85. ],
  86. disclaimerCode:[
  87. { required: true, validator: disclVaild, trigger: ['blur', 'change'] },
  88. { required: true, message: '请选择归属', trigger: ['blur', 'change'] }
  89. ],
  90. },
  91. text:'确定添加',
  92. topInfo:'免责声明维护-添加免责声明',
  93. toast:'添加成功'
  94. }
  95. },
  96. created(){
  97. const params = JSON.parse(localStorage.getItem("icssEnumsData"));
  98. this.options = params.disclaimerCodeEnum;
  99. // 修改
  100. const data = this.$route.params.info;
  101. if(data){
  102. this.id = data.id;
  103. this.text = "确定修改";
  104. this.topInfo = "免责声明维护-修改";
  105. this.toast = "修改成功";
  106. this.form.title = data.title;
  107. this.form.description = data.description;
  108. this.form.disclaimerCode = data.disclaimerCode;
  109. }
  110. },
  111. methods: {
  112. addDiscl() {
  113. this.$refs.form.validate((valid)=> {
  114. if (valid) {
  115. // 有id是修改,没有id是添加
  116. if(this.id){
  117. let param = {
  118. id:this.id,
  119. title:this.form.title,
  120. description:this.form.description,
  121. disclaimerCode:this.form.disclaimerCode
  122. }
  123. api.modifDiscInformation(param).then((res) => {
  124. if (res.data.code == '0') {
  125. this.$message({showClose: true,message: this.toast, type: 'success'});
  126. this.$router.push({path: 'LT-YXSJWH-MZSMWH'});
  127. } else {
  128. this.$message({
  129. showClose: true,
  130. message: res.data.msg,
  131. type: 'warning'
  132. });
  133. }
  134. }).catch((error) => {
  135. this.$message({
  136. showClose: true,
  137. message: "服务器正忙...",
  138. type: 'warning'
  139. });
  140. })
  141. }else{
  142. api.addDiscInformation(this.form).then((res) => {
  143. if (res.data.code == '0') {
  144. this.$message({showClose: true,message: this.toast, type: 'success'});
  145. this.$router.push({path: 'LT-YXSJWH-MZSMWH'});
  146. } else {
  147. this.$message({
  148. showClose: true,
  149. message: res.data.msg,
  150. type: 'warning'
  151. });
  152. }
  153. }).catch((error) => {
  154. this.$message({
  155. showClose: true,
  156. message: "服务器正忙...",
  157. type: 'warning'
  158. });
  159. })
  160. }
  161. }
  162. });
  163. },
  164. back(){
  165. this.$router.go(-1);
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="less" >
  171. @import "../../less/admin.less";
  172. .add-discl-form {
  173. background: #fff;
  174. padding: 20px 20px 30px;
  175. }
  176. // .el-button{
  177. .disclButn{
  178. margin: 30px 0 0 20px;
  179. }
  180. .discDesc{
  181. // .el-textarea{
  182. // width: 97%;
  183. // }
  184. margin-top: 10px;
  185. margin-bottom: 25px;
  186. .el-form-item__error{
  187. top:70px;
  188. }
  189. }
  190. </style>