warn.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <!-- warn -->
  3. <div class="Warn">
  4. <h2 style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd">消息提醒</h2>
  5. <formList v-model="list" :title="['消息']" type="textarea" inputWidth="600px"></formList>
  6. <el-button style="margin-left:610px" type="primary" @click="onSubmit">更新信息</el-button>
  7. </div>
  8. </template>
  9. <script>
  10. import { reqWarn, reqSetWarn } from "@/api/breed.js";
  11. export default {
  12. name: "Warn",
  13. data() {
  14. return {
  15. list: [{ key: "" }]
  16. };
  17. },
  18. created() {
  19. this.getWarn();
  20. },
  21. methods: {
  22. /*
  23. 无害化仓库已满请及时清理
  24. 14587号母羊已到达断奶时间请及时断奶
  25. 阿莫西林药品已经低于安全库存请补充
  26. */
  27. onSubmit() {
  28. let data = [];
  29. this.list.forEach(item => {
  30. data.push(item.msg);
  31. });
  32. this.$confirm("确定更新信息?").then(() => {
  33. reqSetWarn({ content: data.join("--") })
  34. .then(res => {
  35. console.log(res);
  36. if (res.errcode) {
  37. this.$message.error("更新失败!");
  38. }
  39. this.$message.success("更新成功!");
  40. })
  41. .catch(err => {
  42. console.log(err);
  43. this.$message.error("更新失败!");
  44. });
  45. });
  46. },
  47. getWarn() {
  48. reqWarn()
  49. .then(res => {
  50. console.log(res.conf.content);
  51. this.list = [];
  52. res.conf.content.split("--").forEach(item => {
  53. this.list.push({ msg: item });
  54. });
  55. })
  56. .catch(err => {
  57. console.error(err);
  58. });
  59. }
  60. }
  61. };
  62. </script>
  63. <style lang="scss" scoped>
  64. .Warn {
  65. .left {
  66. width: 400px;
  67. margin-left: 50px;
  68. }
  69. }
  70. </style>