addLaboratory.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!--新增危险源-->
  2. <template>
  3. <div class="addLaboratory scrollbar-box" v-if="getType">
  4. <!--<p class="title-p color_one">添加危险源</p>-->
  5. <el-form :model="form" ref="form" :rules="rules" label-position="right" label-width="120px">
  6. <el-form-item label="危险源名称:" prop="chName" style="margin-bottom:40px;">
  7. <el-input
  8. v-model="form.chName"
  9. maxlength="20"
  10. placeholder="请输入危险源名称"
  11. clearable
  12. size="small"
  13. />
  14. </el-form-item>
  15. <el-form-item label="型号:" prop="code" style="margin-bottom:40px;">
  16. <el-input
  17. v-model="form.code"
  18. maxlength="10"
  19. placeholder="请输入型号"
  20. clearable
  21. size="small"
  22. />
  23. </el-form-item>
  24. <el-form-item label="危险源类型:" prop="hazardTypeMode">
  25. <el-select v-model="form.hazardTypeMode" placeholder="请选择">
  26. <el-option :label="item.dictLabel" :value="item.dictValue" v-for="(item,index) in materialTypeList" :key="index"></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="详情:" prop="content">
  30. <UEditor ref="UEditor" :content="form.content" :min-height="192" />
  31. <!--<ueditortwo :config=config ref="ueditor"></ueditortwo>-->
  32. </el-form-item>
  33. <div class="button-box">
  34. <el-button class="color_99" @click="leftButtonClick">取消</el-button>
  35. <el-button class="color_ff back_one" @click="rightButtonClick">确定</el-button>
  36. </div>
  37. </el-form>
  38. </div>
  39. </template>
  40. <script>
  41. import { getHazard, addHazard, updateHazard } from "@/api/laboratory/hazard";
  42. import { dangerList, gasCategoryList } from '@/api/gasManage3_0/gasManage'
  43. export default {
  44. props:{
  45. hazardId: null,
  46. },
  47. name: 'addLaboratory',
  48. data() {
  49. return {
  50. getType:false,
  51. form:{},
  52. // 表单校验
  53. rules: {
  54. chName: [
  55. { required: true, message: "请输入标题", trigger: "blur" },
  56. { required: true, message: "请输入标题", validator: this.spaceJudgment, trigger: "blur" }
  57. ],
  58. code: [
  59. { required: true, message: "请输入编号", trigger: "blur" },
  60. { required: true, message: "请输入编号", validator: this.spaceJudgment, trigger: "blur" }
  61. ],
  62. content: [
  63. { required: true, message: "请编辑详情", trigger: "change" },
  64. { required: true, message: "请编辑详情", validator: this.spaceJudgmentHTML, trigger: "blur" }
  65. ],
  66. hazardTypeMode: [
  67. { required: true, message: "请选择危险源类型", trigger: "change" },
  68. { required: true, message: "请选择危险源类型", validator: this.spaceJudgmentHTML, trigger: "blur" }
  69. ],
  70. },
  71. config: {
  72. autoHeightEnabled: false,
  73. autoFloatEnabled: true,
  74. initialContent: '请输入内容', //初始化编辑器的内容,也可以通过textarea/script给值,看官网例子
  75. autoClearinitialContent: true, //是否自动清除编辑器初始内容,注意:如果focus属性设置为true,这个也为真,那么编辑器一上来就会触发导致初始化的内容看不到了
  76. initialFrameWidth: null,
  77. initialFrameHeight: 450,
  78. BaseUrl: '',
  79. // serverUrl: '//192.168.1.8:9300/exec',
  80. //serverUrl: '//180.76.134.43:30002/base/exec',
  81. serverUrl: '//'+process.env.VUE_APP_BASE_API+'/base/exec',
  82. UEDITOR_HOME_URL: '/public/ueditor-1.4.3.3/'
  83. },
  84. materialTypeList:[],
  85. }
  86. },
  87. created() {
  88. // this.reset();
  89. console.log(this.form.content)
  90. this.form.id = this.hazardId
  91. if(this.form.id){
  92. this.handleUpdate()
  93. }else{
  94. this.getType = true;
  95. }
  96. this.getDicts("combustibility").then(response => {
  97. this.combustibilitys= response.data;
  98. })
  99. },
  100. methods: {
  101. //获取危险源类型
  102. dangerList(){
  103. let _this=this;
  104. dangerList().then( response => {
  105. let res=response.rows;
  106. _this.materialTypeList=res;
  107. });
  108. },
  109. leftButtonClick(){
  110. this.$parent.offLaboratoryButton();
  111. },
  112. rightButtonClick(){
  113. this.$set(this.form,'content',this.$refs.UEditor.text||"");
  114. this.form.content = this.$refs.UEditor.text;
  115. this.submitForm()
  116. },
  117. /** 修改按钮操作 */
  118. handleUpdate() {
  119. getHazard(this.form.id).then(response => {
  120. this.form = response.data;
  121. this.form.hazardTypeMode=response.data.hazardTypeMode+''
  122. this.form.content = unescape(response.data.content);
  123. this.getType = true;
  124. });
  125. },
  126. /** 提交按钮 */
  127. submitForm() {
  128. this.$refs["form"].validate(valid => {
  129. if (valid) {
  130. this.form.content = escape(this.form.content);
  131. // this.form.ignitionPoint = this.form.ignitionPoint + '℃';
  132. if (this.form.id != null) {
  133. updateHazard(this.form).then(response => {
  134. if(response.code = 200){
  135. this.msgSuccess("修改成功");
  136. this.$parent.clickPageTypeOne()
  137. }
  138. });
  139. } else {
  140. addHazard(this.form).then(response => {
  141. if(response.code = 200){
  142. this.msgSuccess("新增成功");
  143. this.$parent.clickPageTypeOne()
  144. }
  145. });
  146. }
  147. }
  148. });
  149. },
  150. },
  151. mounted() {
  152. this.dangerList();
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. .addLaboratory{
  158. padding:40px 20px;
  159. .button-box{
  160. margin:0 auto;
  161. width:220px;
  162. display: flex;
  163. p{
  164. cursor:pointer;
  165. width: 100px;
  166. height:40px;
  167. line-height:40px;
  168. font-size:14px;
  169. text-align: center;
  170. }
  171. p:nth-child(1){
  172. margin-right:20px;
  173. color:#999;
  174. background:#e0e0e0;
  175. border-radius:4px;
  176. }
  177. p:nth-child(2){
  178. color:#fff;
  179. border-radius:4px;
  180. }
  181. }
  182. }
  183. </style>