addPage.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="addPage">
  3. <div class="title-box">
  4. <p>{{addPropsData.id?'编辑':'新增'}}</p>
  5. <p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
  6. </div>
  7. <div class="addPage-min safe-book-el-dialog" v-if="addType">
  8. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  9. <el-form-item label="化学品名称" prop="name" style="width:498px;">
  10. <el-input v-model="form.name" placeholder="请输入化学品名称" maxLength="20" style="width:500px;"/>
  11. </el-form-item>
  12. <el-form-item label="化学品编号" prop="code" style="width:498px;">
  13. <el-input v-model="form.code" placeholder="请输入化学品编号" maxLength="20" style="width:500px;"/>
  14. </el-form-item>
  15. <el-form-item label="化学品详情" prop="content" style="color:#606266;font-size:16px;font-weight:500;" class="wang-editor-form-item-box">
  16. <wangEditor :content="form.content" placeholder="请输入化学品详情" @change="change" :min-height="192" style="width:1000px;"/>
  17. </el-form-item>
  18. </el-form>
  19. <p class="bottom-button-p inquire-button-one" @click="submitForm">提交</p>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { addHazard_book, updateHazard_book } from "@/api/laboratory/hazard_book";
  25. export default {
  26. name: "addPage",
  27. props:{
  28. addPropsData:{},
  29. },
  30. data() {
  31. return {
  32. addType:false,
  33. // 表单参数
  34. form: {},
  35. // 表单校验
  36. rules: {
  37. name:[
  38. {required: true, message: '请输入化学品名称', trigger: 'blur'},
  39. { required: true, message: "请输入化学品名称", validator: this.spaceJudgment, trigger: "blur" }
  40. ],
  41. code:[
  42. {required: true, message: '请输入化学品编号', trigger: 'blur'},
  43. { required: true, message: "请输入化学品编号", validator: this.spaceJudgment, trigger: "blur" }
  44. ],
  45. content:[
  46. {required: true, message: '请输入化学品详情', trigger: 'blur'},
  47. { required: true, message: "请输入化学品详情", validator: this.spaceJudgmentHTML, trigger: "blur" }
  48. ],
  49. },
  50. };
  51. },
  52. created() {
  53. },
  54. mounted(){
  55. if(this.addPropsData.id){
  56. this.$set(this,'form',this.addPropsData);
  57. this.addType=true;
  58. }else{
  59. this.addType=true;
  60. }
  61. },
  62. methods: {
  63. /** 提交按钮 */
  64. submitForm() {
  65. this.$refs["form"].validate(valid => {
  66. if (valid) {
  67. this.form.content = escape(this.form.content);
  68. if (this.form.id != null) {
  69. updateHazard_book(this.form).then( response => {
  70. this.msgSuccess("修改成功");
  71. this.$parent.pageToggle(1);
  72. });
  73. } else {
  74. addHazard_book(this.form).then( response => {
  75. this.msgSuccess("新增成功");
  76. this.$parent.pageToggle(1);
  77. });
  78. }
  79. }
  80. });
  81. },
  82. backPage(){
  83. this.$parent.pageToggle(0);
  84. },
  85. change(val) {
  86. this.$set(this.form,'content',val);
  87. // this.form.content = val;
  88. console.log(val)
  89. },
  90. }
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. .addPage{
  95. flex:1;
  96. display: flex !important;
  97. flex-direction: column;
  98. p{
  99. margin:0;
  100. }
  101. .title-box{
  102. display: flex;
  103. height:90px;
  104. border-bottom: 1px solid #D8D8D8;
  105. p:nth-child(1){
  106. flex:1;
  107. font-size:16px;
  108. line-height:90px;
  109. margin-left:18px;
  110. color:#0045AF;
  111. }
  112. p:nth-child(2){
  113. margin:25px 25px 0 0;
  114. }
  115. }
  116. .addPage-min{
  117. flex:1;
  118. display: flex !important;
  119. flex-direction: column;
  120. padding:20px!important;
  121. .bottom-button-p{
  122. margin:40px auto;
  123. line-height:40px;
  124. width:100px;
  125. text-align: center;
  126. }
  127. }
  128. }
  129. </style>
  130. <style lang="scss">
  131. .wang-editor-form-item-box{
  132. .el-form-item__content{
  133. z-index:0;
  134. }
  135. }
  136. </style>