messageNotice-detail.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <style scoped>
  2. .user-panel {
  3. margin: 10px auto;
  4. }
  5. </style>
  6. <template>
  7. <el-dialog
  8. :visible.sync="showDialog"
  9. :title="title"
  10. :modal-append-to-body="false"
  11. style="text-align:left;"
  12. width="800px;"
  13. @close="closeDialog"
  14. :close-on-click-modal="false"
  15. >
  16. <div class="user-panel" v-loading="loading">
  17. <el-form ref="form" :model="formModel" :rules="ruleValidate" :label-width="'100px'">
  18. <el-form-item label="标题" prop="title">
  19. <el-input v-model="formModel.title" placeholder="请输入" style="width:100%"></el-input>
  20. </el-form-item>
  21. <el-form-item label="发送单位" prop="noticeCompany">
  22. <el-select
  23. v-model="formModel.noticeCompany"
  24. filterable
  25. multiple
  26. placeholder="请选择"
  27. style="width:100% "
  28. >
  29. <el-option
  30. v-for="company in companyResult"
  31. :key="company.id"
  32. :label="company.name"
  33. :value="company.id"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="内容" prop="content">
  38. <quill-editor v-model="formModel.content" :options="editorOption"></quill-editor>
  39. </el-form-item>
  40. <el-form-item label="审核状态" prop="status">
  41. <el-radio-group v-model="formModel.status">
  42. <el-radio :label="true">已审核</el-radio>
  43. <el-radio :label="false">未审核</el-radio>
  44. </el-radio-group>
  45. </el-form-item>
  46. </el-form>
  47. </div>
  48. <span slot="footer" class="dialog-footer">
  49. <el-button @click="closeDialog">取 消</el-button>
  50. <el-button type="primary" @click="handleSubmit" :loading="submitting">确 定</el-button>
  51. </span>
  52. </el-dialog>
  53. </template>
  54. <script>
  55. import Constant from "@/constant";
  56. import messageNoticeApi from "@/api/base/messageNotice";
  57. import companyInfoApi from "@/api/base/companyInfo";
  58. import { quillEditor } from "vue-quill-editor";
  59. export default {
  60. props: ["businessKey", "title"],
  61. data() {
  62. return {
  63. ruleValidate: {
  64. title: [{ required: true, message: "不能为空", trigger: "blur" }]
  65. },
  66. showDialog: true,
  67. loading: false,
  68. submitting: false,
  69. formModel: {},
  70. companyResult: ""
  71. };
  72. },
  73. methods: {
  74. closeDialog() {
  75. this.$emit("close", false);
  76. },
  77. handleSubmit() {
  78. var self = this;
  79. this.$refs["form"].validate(valid => {
  80. if (valid) {
  81. (function() {
  82. var id = self.formModel.id;
  83. //子单位
  84. var noticeCompany = self.formModel.noticeCompany.join(",");
  85. self.formModel.noticeCompany = noticeCompany;
  86. if (id == null || id.length == 0) {
  87. return messageNoticeApi.add(self.formModel);
  88. } else {
  89. return messageNoticeApi.update(self.formModel);
  90. }
  91. })().then(function(response) {
  92. var jsonData = response.data;
  93. if (jsonData.result) {
  94. self.$message({
  95. message: "保存成功!",
  96. type: "success"
  97. });
  98. self.$emit("close", true);
  99. } else {
  100. self.$message({
  101. message: jsonData.message + "",
  102. type: "warning"
  103. });
  104. self.$emit("close", false);
  105. }
  106. });
  107. }
  108. });
  109. },
  110. editorOption: {
  111. modules: {
  112. toolbar: "title" // 设置文本编辑器的头部是否展示
  113. },
  114. placeholder: "文本占位", // 文本框为空时 , 占位文本
  115. theme: "snow" // 或者为 `bubble`
  116. }
  117. },
  118. mounted: function() {
  119. var self = this;
  120. companyInfoApi.list().then(function(response) {
  121. var jsonData = response.data;
  122. if (jsonData.result) {
  123. self.companyResult = jsonData.data;
  124. }
  125. });
  126. (function() {
  127. if (self.businessKey.length == 0) {
  128. return messageNoticeApi.create();
  129. } else {
  130. return messageNoticeApi.edit(self.businessKey);
  131. }
  132. })()
  133. .then(response => {
  134. var jsonData = response.data;
  135. self.loading = false;
  136. if (jsonData.result) {
  137. self.formModel = jsonData.data;
  138. if (self.businessKey.length == 0) {
  139. self.formModel.status = false;
  140. }
  141. var noticeCompany = self.formModel.noticeCompany;
  142. if (noticeCompany != null) {
  143. self.formModel.noticeCompany = noticeCompany.split(",");
  144. }
  145. } else {
  146. self.$message.error(jsonData.message + "");
  147. }
  148. })
  149. .catch(error => {
  150. self.$message.error(error + "");
  151. });
  152. }
  153. };
  154. </script>
  155. <style>
  156. .ql-editor {
  157. height: 300px;
  158. }
  159. </style>